From 47ec49f7f6ab67c0626559979d4320b4e9537895 Mon Sep 17 00:00:00 2001 From: renovate <29139614+renovate@users.noreply.github.com> Date: Fri, 29 Nov 2024 05:11:03 +0000 Subject: [PATCH] chore(deps): update dependency rust to v1.82.0 (#6649) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Update | Change | |---|---|---| | [rust](https://redirect.github.com/rust-lang/rust) | minor | `1.81.0` -> `1.82.0` | --- ### Release Notes
rust-lang/rust (rust) ### [`v1.82.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1820-2024-10-17) [Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.81.0...1.82.0) \========================== ## Language - [Don't make statement nonterminals match pattern nonterminals](https://redirect.github.com/rust-lang/rust/pull/120221/) - [Patterns matching empty types can now be omitted in common cases](https://redirect.github.com/rust-lang/rust/pull/122792) - [Enforce supertrait outlives obligations when using trait impls](https://redirect.github.com/rust-lang/rust/pull/124336) - [`addr_of(_mut)!` macros and the newly stabilized `&raw (const|mut)` are now safe to use with all static items](https://redirect.github.com/rust-lang/rust/pull/125834) - [size_of_val_raw: for length 0 this is safe to call](https://redirect.github.com/rust-lang/rust/pull/126152/) - [Reorder trait bound modifiers *after* `for<...>` binder in trait bounds](https://redirect.github.com/rust-lang/rust/pull/127054/) - [Stabilize opaque type precise capturing (RFC 3617)](https://redirect.github.com/rust-lang/rust/pull/127672) - [Stabilize `&raw const` and `&raw mut` operators (RFC 2582)](https://redirect.github.com/rust-lang/rust/pull/127679) - [Stabilize unsafe extern blocks (RFC 3484)](https://redirect.github.com/rust-lang/rust/pull/127921) - [Stabilize nested field access in `offset_of!`](https://redirect.github.com/rust-lang/rust/pull/128284) - [Do not require `T` to be live when dropping `[T; 0]`](https://redirect.github.com/rust-lang/rust/pull/128438) - [Stabilize `const` operands in inline assembly](https://redirect.github.com/rust-lang/rust/pull/128570) - [Stabilize floating-point arithmetic in `const fn`](https://redirect.github.com/rust-lang/rust/pull/128596) - [Stabilize explicit opt-in to unsafe attributes](https://redirect.github.com/rust-lang/rust/pull/128771) - [Document NaN bit patterns guarantees](https://redirect.github.com/rust-lang/rust/pull/129559) ## Compiler - [Promote riscv64gc-unknown-linux-musl to tier 2](https://redirect.github.com/rust-lang/rust/pull/122049) - [Promote Mac Catalyst targets `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi` to Tier 2, and ship them with rustup](https://redirect.github.com/rust-lang/rust/pull/126450) - [Add tier 3 NuttX based targets for RISC-V and ARM](https://redirect.github.com/rust-lang/rust/pull/127755) - [Add tier 3 powerpc-unknown-linux-muslspe target](https://redirect.github.com/rust-lang/rust/pull/127905) - [Improved diagnostics to explain why a pattern is unreachable](https://redirect.github.com/rust-lang/rust/pull/128034) - [The compiler now triggers the unreachable code warning properly for async functions that don't return/are `-> !`](https://redirect.github.com/rust-lang/rust/pull/128443) - [Promote `aarch64-apple-darwin` to Tier 1](https://redirect.github.com/rust-lang/rust/pull/128592) - [Add Trusty OS target `aarch64-unknown-trusty` and `armv7-unknown-trusty` as tier 3 targets](https://redirect.github.com/rust-lang/rust/pull/129490) - [Promote `wasm32-wasip2` to Tier 2.](https://redirect.github.com/rust-lang/rust/pull/126967/) ## Libraries - [Generalize `{Rc,Arc}::make_mut()` to `Path`, `OsStr`, and `CStr`.](https://redirect.github.com/rust-lang/rust/pull/126877) ## Stabilized APIs - [`std::thread::Builder::spawn_unchecked`](https://doc.rust-lang.org/stable/std/thread/struct.Builder.html#method.spawn_unchecked) - [`std::str::CharIndices::offset`](https://doc.rust-lang.org/nightly/std/str/struct.CharIndices.html#method.offset) - [`std::option::Option::is_none_or`](https://doc.rust-lang.org/nightly/std/option/enum.Option.html#method.is_none_or) - [`[T]::is_sorted`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.is_sorted) - [`[T]::is_sorted_by`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.is_sorted_by) - [`[T]::is_sorted_by_key`](https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.is_sorted_by_key) - [`Iterator::is_sorted`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.is_sorted) - [`Iterator::is_sorted_by`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.is_sorted_by) - [`Iterator::is_sorted_by_key`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.is_sorted_by_key) - [`std::future::Ready::into_inner`](https://doc.rust-lang.org/nightly/std/future/struct.Ready.html#method.into_inner) - [`std::iter::repeat_n`](https://doc.rust-lang.org/nightly/std/iter/fn.repeat_n.html) - [`impl DoubleEndedIterator for Take>`](https://doc.rust-lang.org/nightly/std/iter/struct.Take.html#impl-DoubleEndedIterator-for-Take%3CRepeat%3CT%3E%3E) - [`impl ExactSizeIterator for Take>`](https://doc.rust-lang.org/nightly/std/iter/struct.Take.html#impl-ExactSizeIterator-for-Take%3CRepeat%3CT%3E%3E) - [`impl ExactSizeIterator for Take>`](https://doc.rust-lang.org/nightly/std/iter/struct.Take.html#impl-ExactSizeIterator-for-Take%3CRepeatWith%3CF%3E%3E) - [`impl Default for std::collections::binary_heap::Iter`](https://doc.rust-lang.org/nightly/std/collections/binary_heap/struct.Iter.html#impl-Default-for-Iter%3C'\_,+T%3E) - [`impl Default for std::collections::btree_map::RangeMut`](https://doc.rust-lang.org/nightly/std/collections/btree_map/struct.RangeMut.html#impl-Default-for-RangeMut%3C'\_,+K,+V%3E) - [`impl Default for std::collections::btree_map::ValuesMut`](https://doc.rust-lang.org/nightly/std/collections/btree_map/struct.ValuesMut.html#impl-Default-for-ValuesMut%3C'\_,+K,+V%3E) - [`impl Default for std::collections::vec_deque::Iter`](https://doc.rust-lang.org/nightly/std/collections/vec_deque/struct.Iter.html#impl-Default-for-Iter%3C'\_,+T%3E) - [`impl Default for std::collections::vec_deque::IterMut`](https://doc.rust-lang.org/nightly/std/collections/vec_deque/struct.IterMut.html#impl-Default-for-IterMut%3C'\_,+T%3E) - [`Rc::new_uninit`](https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new_uninit) - [`Rc::assume_init`](https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.assume_init) - [`Rc<[T]>::new_uninit_slice`](https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new_uninit_slice) - [`Rc<[MaybeUninit]>::assume_init`](https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.assume_init-1) - [`Arc::new_uninit`](https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.new_uninit) - [`Arc::assume_init`](https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.assume_init) - [`Arc<[T]>::new_uninit_slice`](https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.new_uninit_slice) - [`Arc<[MaybeUninit]>::assume_init`](https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.assume_init-1) - [`Box::new_uninit`](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.new_uninit) - [`Box::assume_init`](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.assume_init) - [`Box<[T]>::new_uninit_slice`](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.new_uninit_slice) - [`Box<[MaybeUninit]>::assume_init`](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.assume_init-1) - [`core::arch::x86_64::_bextri_u64`](https://doc.rust-lang.org/stable/core/arch/x86\_64/fn.\_bextri_u64.html) - [`core::arch::x86_64::_bextri_u32`](https://doc.rust-lang.org/stable/core/arch/x86\_64/fn.\_bextri_u32.html) - [`core::arch::x86::_mm_broadcastsi128_si256`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_broadcastsi128\_si256.html) - [`core::arch::x86::_mm256_stream_load_si256`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm256\_stream_load_si256.html) - [`core::arch::x86::_tzcnt_u16`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_tzcnt_u16.html) - [`core::arch::x86::_mm_extracti_si64`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_extracti_si64.html) - [`core::arch::x86::_mm_inserti_si64`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_inserti_si64.html) - [`core::arch::x86::_mm_storeu_si16`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_storeu_si16.html) - [`core::arch::x86::_mm_storeu_si32`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_storeu_si32.html) - [`core::arch::x86::_mm_storeu_si64`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_storeu_si64.html) - [`core::arch::x86::_mm_loadu_si16`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_loadu_si16.html) - [`core::arch::x86::_mm_loadu_si32`](https://doc.rust-lang.org/stable/core/arch/x86/fn.\_mm_loadu_si32.html) - [`core::arch::wasm32::u8x16_relaxed_swizzle`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u8x16\_relaxed_swizzle.html) - [`core::arch::wasm32::i8x16_relaxed_swizzle`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i8x16\_relaxed_swizzle.html) - [`core::arch::wasm32::i32x4_relaxed_trunc_f32x4`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i32x4\_relaxed_trunc_f32x4.html) - [`core::arch::wasm32::u32x4_relaxed_trunc_f32x4`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u32x4\_relaxed_trunc_f32x4.html) - [`core::arch::wasm32::i32x4_relaxed_trunc_f64x2_zero`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i32x4\_relaxed_trunc_f64x2\_zero.html) - [`core::arch::wasm32::u32x4_relaxed_trunc_f64x2_zero`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u32x4\_relaxed_trunc_f64x2\_zero.html) - [`core::arch::wasm32::f32x4_relaxed_madd`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f32x4\_relaxed_madd.html) - [`core::arch::wasm32::f32x4_relaxed_nmadd`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f32x4\_relaxed_nmadd.html) - [`core::arch::wasm32::f64x2_relaxed_madd`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f64x2\_relaxed_madd.html) - [`core::arch::wasm32::f64x2_relaxed_nmadd`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f64x2\_relaxed_nmadd.html) - [`core::arch::wasm32::i8x16_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i8x16\_relaxed_laneselect.html) - [`core::arch::wasm32::u8x16_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u8x16\_relaxed_laneselect.html) - [`core::arch::wasm32::i16x8_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i16x8\_relaxed_laneselect.html) - [`core::arch::wasm32::u16x8_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u16x8\_relaxed_laneselect.html) - [`core::arch::wasm32::i32x4_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i32x4\_relaxed_laneselect.html) - [`core::arch::wasm32::u32x4_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u32x4\_relaxed_laneselect.html) - [`core::arch::wasm32::i64x2_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i64x2\_relaxed_laneselect.html) - [`core::arch::wasm32::u64x2_relaxed_laneselect`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u64x2\_relaxed_laneselect.html) - [`core::arch::wasm32::f32x4_relaxed_min`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f32x4\_relaxed_min.html) - [`core::arch::wasm32::f32x4_relaxed_max`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f32x4\_relaxed_max.html) - [`core::arch::wasm32::f64x2_relaxed_min`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f64x2\_relaxed_min.html) - [`core::arch::wasm32::f64x2_relaxed_max`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.f64x2\_relaxed_max.html) - [`core::arch::wasm32::i16x8_relaxed_q15mulr`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i16x8\_relaxed_q15mulr.html) - [`core::arch::wasm32::u16x8_relaxed_q15mulr`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u16x8\_relaxed_q15mulr.html) - [`core::arch::wasm32::i16x8_relaxed_dot_i8x16_i7x16`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i16x8\_relaxed_dot_i8x16\_i7x16.html) - [`core::arch::wasm32::u16x8_relaxed_dot_i8x16_i7x16`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u16x8\_relaxed_dot_i8x16\_i7x16.html) - [`core::arch::wasm32::i32x4_relaxed_dot_i8x16_i7x16_add`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.i32x4\_relaxed_dot_i8x16\_i7x16\_add.html) - [`core::arch::wasm32::u32x4_relaxed_dot_i8x16_i7x16_add`](https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.u32x4\_relaxed_dot_i8x16\_i7x16\_add.html) These APIs are now stable in const contexts: - [`std::task::Waker::from_raw`](https://doc.rust-lang.org/nightly/std/task/struct.Waker.html#method.from_raw) - [`std::task::Context::from_waker`](https://doc.rust-lang.org/nightly/std/task/struct.Context.html#method.from_waker) - [`std::task::Context::waker`](https://doc.rust-lang.org/nightly/std/task/struct.Context.html#method.waker) - [`$integer::from_str_radix`](https://doc.rust-lang.org/nightly/std/primitive.u32.html#method.from_str_radix) - [`std::num::ParseIntError::kind`](https://doc.rust-lang.org/nightly/std/num/struct.ParseIntError.html#method.kind) ## Cargo - [feat: Add `info` cargo subcommand](https://redirect.github.com/rust-lang/cargo/pull/14141/) ## Compatibility Notes - We now [disallow setting some built-in cfgs via the command-line](https://redirect.github.com/rust-lang/rust/pull/126158) with the newly added [`explicit_builtin_cfgs_in_flags`](https://doc.rust-lang.org/rustc/lints/listing/deny-by-default.html#explicit-builtin-cfgs-in-flags) lint in order to prevent incoherent state, eg. `windows` cfg active but target is Linux based. The appropriate [`rustc` flag](https://doc.rust-lang.org/rustc/command-line-arguments.html) should be used instead. - The standard library has a new implementation of `binary_search` which is significantly improves performance ([#​128254](https://redirect.github.com/rust-lang/rust/pull/128254)). However when a sorted slice has multiple values which compare equal, the new implementation may select a different value among the equal ones than the old implementation. - [illumos/Solaris now sets `MSG_NOSIGNAL` when writing to sockets](https://redirect.github.com/rust-lang/rust/pull/128259). This avoids killing the process with SIGPIPE when writing to a closed socket, which matches the existing behavior on other UNIX targets. - [Removes a problematic hack that always passed the --whole-archive linker flag for tests, which may cause linker errors for code accidentally relying on it.](https://redirect.github.com/rust-lang/rust/pull/128400) - The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default. These two features both have subtle changes implied for generated WebAssembly binaries. For the `multivalue` feature, WebAssembly target support has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. There is no longer any supported means to generate a module that has a function with multiple returns in WebAssembly from Rust source code. For the `reference-types` feature the encoding of immediates in the `call_indirect`, a commonly used instruction by the WebAssembly backend, has changed. Validators and parsers which don't understand the `reference-types` proposal will no longer accept modules produced by LLVM due to this change in encoding of immediates. Additionally these features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module. Generating a WebAssembly module that disables default features requires `-Zbuild-std` support from Cargo and more information can be found at [rust-lang/rust#128511](https://redirect.github.com/rust-lang/rust/pull/128511). - [Rust now raises unsafety errors for union patterns in parameter-position](https://redirect.github.com/rust-lang/rust/pull/130531) ## Internal Changes These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools. - [Update to LLVM 19](https://redirect.github.com/rust-lang/rust/pull/127513)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc). --- .github/workflows/ci.yml | 5 +- .github/workflows/release_wasm.yml | 4 + napi/minify/index.d.ts | 3 +- napi/minify/index.js | 341 +++++++++++++++-------------- napi/transform/index.d.ts | 2 +- npm/oxc-wasm/oxc_wasm.d.ts | 122 ++++++----- npm/oxc-wasm/oxc_wasm.js | 341 +++++++++++------------------ npm/oxc-wasm/oxc_wasm_bg.wasm.d.ts | 28 ++- npm/parser-wasm/package.json | 2 +- rust-toolchain.toml | 2 +- tasks/ast_tools/src/schema/defs.rs | 1 + 11 files changed, 406 insertions(+), 445 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cd132c635535..e4848a2b37485 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,6 +121,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: taiki-e/checkout-action@v1 + - uses: Boshen/setup-rust@main with: cache-key: wasm @@ -134,7 +135,9 @@ jobs: - run: just build-wasm debug - working-directory: npm/oxc-wasm - run: pnpm run check + run: | + sed -i ${{ (runner.os == 'macOS' && '""') || '' }} -e 's/=> Array;/=> number[];/g' oxc_wasm.d.ts + pnpm run check - working-directory: wasm/parser run: pnpm run build diff --git a/.github/workflows/release_wasm.yml b/.github/workflows/release_wasm.yml index 1fd1d49af3c03..e49b885355b3e 100644 --- a/.github/workflows/release_wasm.yml +++ b/.github/workflows/release_wasm.yml @@ -59,6 +59,10 @@ jobs: pnpm run build pnpm run test + - name: Check + working-directory: npm/parser-wasm + run: pnpm run check + - name: Publish working-directory: npm/parser-wasm env: diff --git a/napi/minify/index.d.ts b/napi/minify/index.d.ts index 7928e4f5941c4..e69391abf3f30 100644 --- a/napi/minify/index.d.ts +++ b/napi/minify/index.d.ts @@ -1,3 +1,4 @@ /* auto-generated by NAPI-RS */ /* eslint-disable */ -export declare function minify(filename: string, sourceText: string): string; +export declare function minify(filename: string, sourceText: string): string + diff --git a/napi/minify/index.js b/napi/minify/index.js index 6b860f19a988f..ff8f447a87d0b 100644 --- a/napi/minify/index.js +++ b/napi/minify/index.js @@ -2,330 +2,349 @@ /* eslint-disable */ /* auto-generated by NAPI-RS */ -const { readFileSync } = require('fs'); +const { readFileSync } = require('fs') -let nativeBinding = null; -const loadErrors = []; +let nativeBinding = null +const loadErrors = [] const isMusl = () => { - let musl = false; + let musl = false if (process.platform === 'linux') { - musl = isMuslFromFilesystem(); + musl = isMuslFromFilesystem() if (musl === null) { - musl = isMuslFromReport(); + musl = isMuslFromReport() } if (musl === null) { - musl = isMuslFromChildProcess(); + musl = isMuslFromChildProcess() } } - return musl; -}; + return musl +} -const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-'); +const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-') const isMuslFromFilesystem = () => { try { - return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl'); + return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl') } catch { - return null; + return null } -}; +} const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null; + const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null if (!report) { - return null; + return null } if (report.header && report.header.glibcVersionRuntime) { - return false; + return false } if (Array.isArray(report.sharedObjects)) { if (report.sharedObjects.some(isFileMusl)) { - return true; + return true } } - return false; -}; + return false +} const isMuslFromChildProcess = () => { try { - return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl'); + return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl') } catch (e) { // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false - return false; + return false } -}; +} function requireNative() { if (process.platform === 'android') { if (process.arch === 'arm64') { try { - return require('./minify.android-arm64.node'); + return require('./minify.android-arm64.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-android-arm64'); + return require('@oxc-minify/binding-android-arm64') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 'arm') { try { - return require('./minify.android-arm-eabi.node'); + return require('./minify.android-arm-eabi.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-android-arm-eabi'); + return require('@oxc-minify/binding-android-arm-eabi') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else { - loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)); + loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { try { - return require('./minify.win32-x64-msvc.node'); + return require('./minify.win32-x64-msvc.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-win32-x64-msvc'); + return require('@oxc-minify/binding-win32-x64-msvc') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 'ia32') { try { - return require('./minify.win32-ia32-msvc.node'); + return require('./minify.win32-ia32-msvc.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-win32-ia32-msvc'); + return require('@oxc-minify/binding-win32-ia32-msvc') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 'arm64') { try { - return require('./minify.win32-arm64-msvc.node'); + return require('./minify.win32-arm64-msvc.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-win32-arm64-msvc'); + return require('@oxc-minify/binding-win32-arm64-msvc') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else { - loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)); + loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./minify.darwin-universal.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-darwin-universal'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-darwin-universal') + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { - return require('./minify.darwin-x64.node'); + return require('./minify.darwin-x64.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-darwin-x64'); + return require('@oxc-minify/binding-darwin-x64') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 'arm64') { try { - return require('./minify.darwin-arm64.node'); + return require('./minify.darwin-arm64.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-darwin-arm64'); + return require('@oxc-minify/binding-darwin-arm64') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else { - loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)); + loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } } else if (process.platform === 'freebsd') { if (process.arch === 'x64') { try { - return require('./minify.freebsd-x64.node'); + return require('./minify.freebsd-x64.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-freebsd-x64'); + return require('@oxc-minify/binding-freebsd-x64') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 'arm64') { try { - return require('./minify.freebsd-arm64.node'); + return require('./minify.freebsd-arm64.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-freebsd-arm64'); + return require('@oxc-minify/binding-freebsd-arm64') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else { - loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)); + loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } } else if (process.platform === 'linux') { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./minify.linux-x64-musl.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-x64-musl'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-x64-musl') + } catch (e) { + loadErrors.push(e) + } + } else { try { - return require('./minify.linux-x64-gnu.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-x64-gnu'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-x64-gnu') + } catch (e) { + loadErrors.push(e) + } + } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./minify.linux-arm64-musl.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-arm64-musl'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-arm64-musl') + } catch (e) { + loadErrors.push(e) + } + } else { try { - return require('./minify.linux-arm64-gnu.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-arm64-gnu'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-arm64-gnu') + } catch (e) { + loadErrors.push(e) + } + } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./minify.linux-arm-musleabihf.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-arm-musleabihf'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-arm-musleabihf') + } catch (e) { + loadErrors.push(e) + } + } else { try { - return require('./minify.linux-arm-gnueabihf.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-arm-gnueabihf'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-arm-gnueabihf') + } catch (e) { + loadErrors.push(e) + } + } } else if (process.arch === 'riscv64') { if (isMusl()) { try { - return require('./minify.linux-riscv64-musl.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-riscv64-musl'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-riscv64-musl') + } catch (e) { + loadErrors.push(e) + } + } else { try { - return require('./minify.linux-riscv64-gnu.node'); - } catch (e) { - loadErrors.push(e); - } - try { - return require('@oxc-minify/binding-linux-riscv64-gnu'); - } catch (e) { - loadErrors.push(e); - } + return require('./minify.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@oxc-minify/binding-linux-riscv64-gnu') + } catch (e) { + loadErrors.push(e) + } + } } else if (process.arch === 'ppc64') { try { - return require('./minify.linux-ppc64-gnu.node'); + return require('./minify.linux-ppc64-gnu.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-linux-ppc64-gnu'); + return require('@oxc-minify/binding-linux-ppc64-gnu') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else if (process.arch === 's390x') { try { - return require('./minify.linux-s390x-gnu.node'); + return require('./minify.linux-s390x-gnu.node') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } try { - return require('@oxc-minify/binding-linux-s390x-gnu'); + return require('@oxc-minify/binding-linux-s390x-gnu') } catch (e) { - loadErrors.push(e); + loadErrors.push(e) } + } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)); + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) } } else { - loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)); + loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) } } -nativeBinding = requireNative(); +nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { try { - nativeBinding = require('./minify.wasi.cjs'); + nativeBinding = require('./minify.wasi.cjs') } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - console.error(err); + console.error(err) } } if (!nativeBinding) { try { - nativeBinding = require('@oxc-minify/binding-wasm32-wasi'); + nativeBinding = require('@oxc-minify/binding-wasm32-wasi') } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - console.error(err); + console.error(err) } } } @@ -337,9 +356,9 @@ if (!nativeBinding) { // - The package owner could build/publish bindings for this arch // - The user may need to bundle the correct files // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }); + throw new Error('Failed to load native binding', { cause: loadErrors }) } - throw new Error(`Failed to load native binding`); + throw new Error(`Failed to load native binding`) } -module.exports.minify = nativeBinding.minify; +module.exports.minify = nativeBinding.minify diff --git a/napi/transform/index.d.ts b/napi/transform/index.d.ts index 5e3100e1bf82e..abac5894f1fa9 100644 --- a/napi/transform/index.d.ts +++ b/napi/transform/index.d.ts @@ -215,7 +215,7 @@ export interface TransformOptions { * * @default `esnext` (No transformation) * - * @see [esbuild#target]( /** Define Plugin */ diff --git a/npm/oxc-wasm/oxc_wasm.d.ts b/npm/oxc-wasm/oxc_wasm.d.ts index 80fb839a0037e..90fb5fceef807 100644 --- a/npm/oxc-wasm/oxc_wasm.d.ts +++ b/npm/oxc-wasm/oxc_wasm.d.ts @@ -6,32 +6,6 @@ * @returns {any} */ export function browserslist(query: string, opts: any): any; - -import type { Program, Span } from "@oxc-project/types"; -export * from "@oxc-project/types"; - - -export interface Oxc { - ast: Program; - ir: string; - controlFlowGraph: string; - symbols: SymbolTable; - scopeText: string; - codegenText: string; - formattedText: string; - prettierFormattedText: string; - prettierIrText: string; -} - -export interface Comment { - type: CommentType; - value: string; - start: number; - end: number; -} - -export type CommentType = "Line" | "Block"; - export interface OxcOptions { run?: OxcRunOptions; parser?: OxcParserOptions; @@ -94,6 +68,38 @@ export interface OxcCompressOptions { } +import type { Program, Span } from "@oxc-project/types"; +export * from "@oxc-project/types"; + + +export interface Oxc { + ast: Program; + ir: string; + controlFlowGraph: string; + symbols: SymbolTable; + scopeText: string; + codegenText: string; + formattedText: string; + prettierFormattedText: string; + prettierIrText: string; +} + +export interface Comment { + type: CommentType; + value: string; + start: number; + end: number; +} + +export type CommentType = "Line" | "Block"; + +export interface Reference { + nodeId: NodeId; + symbolId: SymbolId | null; + flags: ReferenceFlags; +} + + export type IndexVec = Array; export type CompactStr = string; @@ -110,27 +116,6 @@ export interface SymbolTable { references: IndexVec; } -export interface Reference { - nodeId: NodeId; - symbolId: SymbolId | null; - flags: ReferenceFlags; -} - - -export type ReferenceId = number; -export type ReferenceFlags = { - None: 0, - Read: 0b1, - Write: 0b10, - Type: 0b100, - Value: 0b11 -} - - - -export type ScopeId = number; - - export type SymbolId = number; export type SymbolFlags = unknown; @@ -147,6 +132,21 @@ export type NodeFlags = { }; + +export type ScopeId = number; + + + +export type ReferenceId = number; +export type ReferenceFlags = { + None: 0, + Read: 0b1, + Write: 0b10, + Type: 0b100, + Value: 0b11 +} + + export class Oxc { free(): void; constructor(); @@ -178,24 +178,28 @@ export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_oxc_free: (a: number, b: number) => void; readonly __wbg_get_oxc_ast: (a: number) => number; - readonly __wbg_get_oxc_ir: (a: number, b: number) => void; - readonly __wbg_get_oxc_controlFlowGraph: (a: number, b: number) => void; + readonly __wbg_get_oxc_ir: (a: number) => number[]; + readonly __wbg_get_oxc_controlFlowGraph: (a: number) => number[]; readonly __wbg_get_oxc_symbols: (a: number) => number; - readonly __wbg_get_oxc_scopeText: (a: number, b: number) => void; - readonly __wbg_get_oxc_codegenText: (a: number, b: number) => void; - readonly __wbg_get_oxc_formattedText: (a: number, b: number) => void; - readonly __wbg_get_oxc_prettierFormattedText: (a: number, b: number) => void; - readonly __wbg_get_oxc_prettierIrText: (a: number, b: number) => void; + readonly __wbg_get_oxc_scopeText: (a: number) => number[]; + readonly __wbg_get_oxc_codegenText: (a: number) => number[]; + readonly __wbg_get_oxc_formattedText: (a: number) => number[]; + readonly __wbg_get_oxc_prettierFormattedText: (a: number) => number[]; + readonly __wbg_get_oxc_prettierIrText: (a: number) => number[]; readonly oxc_new: () => number; - readonly oxc_getDiagnostics: (a: number, b: number) => void; - readonly oxc_getComments: (a: number, b: number) => void; - readonly oxc_run: (a: number, b: number, c: number, d: number, e: number) => void; - readonly browserslist: (a: number, b: number, c: number, d: number) => void; + readonly oxc_getDiagnostics: (a: number) => number[]; + readonly oxc_getComments: (a: number) => number[]; + readonly oxc_run: (a: number, b: number, c: number, d: number) => number[]; + readonly browserslist: (a: number, b: number, c: number) => number[]; readonly __wbindgen_malloc: (a: number, b: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; - readonly __wbindgen_add_to_stack_pointer: (a: number) => number; + readonly __wbindgen_export_2: WebAssembly.Table; readonly __wbindgen_free: (a: number, b: number, c: number) => void; + readonly __externref_table_dealloc: (a: number) => void; + readonly __externref_drop_slice: (a: number, b: number) => void; readonly __wbindgen_exn_store: (a: number) => void; + readonly __externref_table_alloc: () => number; + readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; diff --git a/npm/oxc-wasm/oxc_wasm.js b/npm/oxc-wasm/oxc_wasm.js index 98d572c24dfac..cd2706a30820f 100644 --- a/npm/oxc-wasm/oxc_wasm.js +++ b/npm/oxc-wasm/oxc_wasm.js @@ -18,25 +18,6 @@ function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } -const heap = new Array(128).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - if (typeof(heap_next) !== 'number') throw new Error('corrupt heap'); - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - function _assertBoolean(n) { if (typeof(n) !== 'boolean') { throw new Error(`expected a boolean argument, found ${typeof(n)}`); @@ -183,16 +164,10 @@ function debugString(val) { return className; } -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; +function takeFromExternrefTable0(idx) { + const value = wasm.__wbindgen_export_2.get(idx); + wasm.__externref_table_dealloc(idx); + return value; } function getArrayJsValueFromWasm0(ptr, len) { @@ -200,8 +175,9 @@ function getArrayJsValueFromWasm0(ptr, len) { const mem = getDataViewMemory0(); const result = []; for (let i = ptr; i < ptr + 4 * len; i += 4) { - result.push(takeObject(mem.getUint32(i, true))); + result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true))); } + wasm.__externref_drop_slice(ptr, len); return result; } @@ -226,28 +202,27 @@ function logError(f, args) { * @returns {any} */ export function browserslist(query, opts) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.browserslist(retptr, ptr0, len0, addHeapObject(opts)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); + const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.browserslist(ptr0, len0, opts); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); } + return takeFromExternrefTable0(ret[0]); +} + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_export_2.set(idx, obj); + return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); } } @@ -275,7 +250,7 @@ export class Oxc { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_ast(this.__wbg_ptr); - return takeObject(ret); + return ret; } /** * @returns {string} @@ -285,16 +260,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_ir(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_ir(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -306,16 +277,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_controlFlowGraph(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_controlFlowGraph(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -326,7 +293,7 @@ export class Oxc { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); _assertNum(this.__wbg_ptr); const ret = wasm.__wbg_get_oxc_symbols(this.__wbg_ptr); - return takeObject(ret); + return ret; } /** * @returns {string} @@ -336,16 +303,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_scopeText(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_scopeText(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -357,16 +320,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_codegenText(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_codegenText(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -378,16 +337,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_formattedText(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_formattedText(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -399,16 +354,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_prettierFormattedText(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_prettierFormattedText(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -420,16 +371,12 @@ export class Oxc { let deferred1_1; try { if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertNum(this.__wbg_ptr); - wasm.__wbg_get_oxc_prettierIrText(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); + const ret = wasm.__wbg_get_oxc_prettierIrText(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); } finally { - wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); } } @@ -446,24 +393,15 @@ export class Oxc { * @returns {any[]} */ getDiagnostics() { - try { - if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertNum(this.__wbg_ptr); - wasm.oxc_getDiagnostics(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); + const ret = wasm.oxc_getDiagnostics(this.__wbg_ptr); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); } + var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); + return v1; } /** * Returns comments @@ -471,24 +409,15 @@ export class Oxc { * @returns {any[]} */ getComments() { - try { - if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertNum(this.__wbg_ptr); - wasm.oxc_getComments(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); + const ret = wasm.oxc_getComments(this.__wbg_ptr); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); } + var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); + return v1; } /** * # Errors @@ -497,20 +426,13 @@ export class Oxc { * @param {OxcOptions} options */ run(source_text, options) { - try { - if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertNum(this.__wbg_ptr); - const ptr0 = passStringToWasm0(source_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.oxc_run(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); + if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value'); + _assertNum(this.__wbg_ptr); + const ptr0 = passStringToWasm0(source_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.oxc_run(this.__wbg_ptr, ptr0, len0, options); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); } } } @@ -551,21 +473,17 @@ function __wbg_get_imports() { imports.wbg = {}; imports.wbg.__wbindgen_error_new = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; + const ret = arg0 === undefined; _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_as_number = function(arg0) { - const ret = +getObject(arg0); + const ret = +arg0; return ret; }; - imports.wbg.__wbindgen_object_clone_ref = function(arg0) { - const ret = getObject(arg0); - return addHeapObject(ret); - }; imports.wbg.__wbg_error_f851667af71bcfc6 = function() { return logError(function (arg0, arg1) { let deferred0_0; let deferred0_1; @@ -579,32 +497,32 @@ function __wbg_get_imports() { }, arguments) }; imports.wbg.__wbg_new_abda76e883ba8a5f = function() { return logError(function () { const ret = new Error(); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_stack_658279fe44541cf6 = function() { return logError(function (arg0, arg1) { - const ret = getObject(arg1).stack; + const ret = arg1.stack; const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }, arguments) }; imports.wbg.__wbindgen_in = function(arg0, arg1) { - const ret = getObject(arg0) in getObject(arg1); + const ret = arg0 in arg1; _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_boolean_get = function(arg0) { - const v = getObject(arg0); + const v = arg0; const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; _assertNum(ret); return ret; }; imports.wbg.__wbindgen_string_new = function(arg0, arg1) { const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); + const obj = arg1; const ret = typeof(obj) === 'string' ? obj : undefined; var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); var len1 = WASM_VECTOR_LEN; @@ -612,13 +530,13 @@ function __wbg_get_imports() { getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; imports.wbg.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); + const val = arg0; const ret = typeof(val) === 'object' && val !== null; _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); + const obj = arg1; const ret = typeof(obj) === 'number' ? obj : undefined; if (!isLikeNone(ret)) { _assertNum(ret); @@ -628,35 +546,35 @@ function __wbg_get_imports() { }; imports.wbg.__wbindgen_number_new = function(arg0) { const ret = arg0; - return addHeapObject(ret); + return ret; }; imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { - const ret = getObject(arg0) == getObject(arg1); + const ret = arg0 == arg1; _assertBoolean(ret); return ret; }; imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { const ret = BigInt.asUintN(64, arg0); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function() { return logError(function (arg0, arg1) { - const ret = getObject(arg0)[getObject(arg1)]; - return addHeapObject(ret); + const ret = arg0[arg1]; + return ret; }, arguments) }; imports.wbg.__wbg_set_f975102236d3c502 = function() { return logError(function (arg0, arg1, arg2) { - getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + arg0[arg1] = arg2; }, arguments) }; imports.wbg.__wbg_new_034f913e7636e987 = function() { return logError(function () { const ret = new Array(); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_set_425e70f7c64ac962 = function() { return logError(function (arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); + arg0[arg1 >>> 0] = arg2; }, arguments) }; imports.wbg.__wbg_instanceof_ArrayBuffer_74945570b4a62ec7 = function() { return logError(function (arg0) { let result; try { - result = getObject(arg0) instanceof ArrayBuffer; + result = arg0 instanceof ArrayBuffer; } catch (_) { result = false; } @@ -666,52 +584,52 @@ function __wbg_get_imports() { }, arguments) }; imports.wbg.__wbg_newnoargs_1ede4bf2ebbaaf43 = function() { return logError(function (arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_call_a9ef466721e824f2 = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); + const ret = arg0.call(arg1); + return ret; }, arguments) }; imports.wbg.__wbg_new_7a87a0376e40533b = function() { return logError(function () { const ret = new Map(); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_set_277a63e77c89279f = function() { return logError(function (arg0, arg1, arg2) { - const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); + const ret = arg0.set(arg1, arg2); + return ret; }, arguments) }; imports.wbg.__wbg_getTime_41225036a0393d63 = function() { return logError(function (arg0) { - const ret = getObject(arg0).getTime(); + const ret = arg0.getTime(); return ret; }, arguments) }; imports.wbg.__wbg_new0_218ada33b570be35 = function() { return logError(function () { const ret = new Date(); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_new_e69b5f66fda8f13c = function() { return logError(function () { const ret = new Object(); - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_globalThis_05c129bf37fcf1be = function() { return handleError(function () { const ret = globalThis.globalThis; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_self_bf91bf94d9e04084 = function() { return handleError(function () { const ret = self.self; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_window_52dd9f07d03fd5f8 = function() { return handleError(function () { const ret = window.window; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_global_3eca19bb09e9c484 = function() { return handleError(function () { const ret = global.global; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_instanceof_Uint8Array_df0761410414ef36 = function() { return logError(function (arg0) { let result; try { - result = getObject(arg0) instanceof Uint8Array; + result = arg0 instanceof Uint8Array; } catch (_) { result = false; } @@ -720,50 +638,57 @@ function __wbg_get_imports() { return ret; }, arguments) }; imports.wbg.__wbg_new_fec2611eb9180f95 = function() { return logError(function (arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); + const ret = new Uint8Array(arg0); + return ret; }, arguments) }; imports.wbg.__wbg_length_9254c4bd3b9f23c4 = function() { return logError(function (arg0) { - const ret = getObject(arg0).length; + const ret = arg0.length; _assertNum(ret); return ret; }, arguments) }; imports.wbg.__wbg_set_ec2fcf81bc573fd9 = function() { return logError(function (arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); - }, arguments) }; - imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function() { return logError(function (arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); + arg0.set(arg1, arg2 >>> 0); }, arguments) }; imports.wbg.__wbindgen_is_string = function(arg0) { - const ret = typeof(getObject(arg0)) === 'string'; + const ret = typeof(arg0) === 'string'; _assertBoolean(ret); return ret; }; imports.wbg.__wbg_stringify_eead5648c09faaf8 = function() { return handleError(function (arg0) { - const ret = JSON.stringify(getObject(arg0)); - return addHeapObject(ret); + const ret = JSON.stringify(arg0); + return ret; }, arguments) }; imports.wbg.__wbg_get_ef828680c64da212 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); + const ret = Reflect.get(arg0, arg1); + return ret; + }, arguments) }; + imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function() { return logError(function (arg0) { + const ret = arg0.buffer; + return ret; }, arguments) }; imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); + const ret = debugString(arg1); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; - imports.wbg.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); - }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; imports.wbg.__wbindgen_memory = function() { const ret = wasm.memory; - return addHeapObject(ret); + return ret; + }; + imports.wbg.__wbindgen_init_externref_table = function() { + const table = wasm.__wbindgen_export_2; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + ; }; return imports; @@ -780,7 +705,7 @@ function __wbg_finalize_init(instance, module) { cachedUint8ArrayMemory0 = null; - + wasm.__wbindgen_start(); return wasm; } diff --git a/npm/oxc-wasm/oxc_wasm_bg.wasm.d.ts b/npm/oxc-wasm/oxc_wasm_bg.wasm.d.ts index 661d0470abf8c..ba336bc45dbbd 100644 --- a/npm/oxc-wasm/oxc_wasm_bg.wasm.d.ts +++ b/npm/oxc-wasm/oxc_wasm_bg.wasm.d.ts @@ -3,21 +3,25 @@ export const memory: WebAssembly.Memory; export function __wbg_oxc_free(a: number, b: number): void; export function __wbg_get_oxc_ast(a: number): number; -export function __wbg_get_oxc_ir(a: number, b: number): void; -export function __wbg_get_oxc_controlFlowGraph(a: number, b: number): void; +export function __wbg_get_oxc_ir(a: number): Array; +export function __wbg_get_oxc_controlFlowGraph(a: number): Array; export function __wbg_get_oxc_symbols(a: number): number; -export function __wbg_get_oxc_scopeText(a: number, b: number): void; -export function __wbg_get_oxc_codegenText(a: number, b: number): void; -export function __wbg_get_oxc_formattedText(a: number, b: number): void; -export function __wbg_get_oxc_prettierFormattedText(a: number, b: number): void; -export function __wbg_get_oxc_prettierIrText(a: number, b: number): void; +export function __wbg_get_oxc_scopeText(a: number): Array; +export function __wbg_get_oxc_codegenText(a: number): Array; +export function __wbg_get_oxc_formattedText(a: number): Array; +export function __wbg_get_oxc_prettierFormattedText(a: number): Array; +export function __wbg_get_oxc_prettierIrText(a: number): Array; export function oxc_new(): number; -export function oxc_getDiagnostics(a: number, b: number): void; -export function oxc_getComments(a: number, b: number): void; -export function oxc_run(a: number, b: number, c: number, d: number, e: number): void; -export function browserslist(a: number, b: number, c: number, d: number): void; +export function oxc_getDiagnostics(a: number): Array; +export function oxc_getComments(a: number): Array; +export function oxc_run(a: number, b: number, c: number, d: number): Array; +export function browserslist(a: number, b: number, c: number): Array; export function __wbindgen_malloc(a: number, b: number): number; export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; +export const __wbindgen_export_2: WebAssembly.Table; export function __wbindgen_free(a: number, b: number, c: number): void; +export function __externref_table_dealloc(a: number): void; +export function __externref_drop_slice(a: number, b: number): void; export function __wbindgen_exn_store(a: number): void; +export function __externref_table_alloc(): number; +export function __wbindgen_start(): void; diff --git a/npm/parser-wasm/package.json b/npm/parser-wasm/package.json index 139a96cd7e610..95c32b676e817 100644 --- a/npm/parser-wasm/package.json +++ b/npm/parser-wasm/package.json @@ -1,6 +1,6 @@ { "name": "@oxc-parser/wasm", - "version": "0.34.0", + "version": "0.38.0", "description": "Wasm target for the oxc parser.", "keywords": [ "JavaScript", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index bbf217f21b9ac..5f3ff177655ca 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81.0" +channel = "1.82.0" profile = "default" diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 6a05e355e73c4..433d5f05be2f0 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -14,6 +14,7 @@ use super::TypeName; #[derive(Debug, Serialize)] #[serde(untagged)] +#[expect(clippy::large_enum_variant)] pub enum TypeDef { Struct(StructDef), Enum(EnumDef),