Skip to content

Releases: wasm-bindgen/wasm-bindgen

0.2.128

Choose a tag to compare

@github-actions github-actions released this 05 Sep 00:00
Immutable release. Only release title and notes can be modified.
246946f

Added

  • Added OffscreenCanvas overloads for the WebGL texImage2D, texSubImage2D,
    texImage3D and texSubImage3D functions, matching the TexImageSource
    typedef in the WebGL specification.
    #5312

  • Added --split-debug-info to the CLI. This option extracts the DWARF debug
    info to a separate *_bg.debug.wasm file. Use --debug-info-url to set
    the recorded URL for the debug info. #5279

  • Added #[wasm_bindgen(experimental_generic_mono)] for imported functions,
    which binds a generic import once per monomorphisation instead of erasing
    its type parameters to JsValue. It can be applied to an individual import
    or to a whole extern "C" block, which every generic function in the block
    then inherits. Each instantiation gets its own descriptor, so arguments and
    return values are marshalled at their concrete types (a u32 crosses as a
    number, a String as a string) rather than being boxed. Trait bounds,
    where predicates (including higher-ranked ones), associated-type
    projections, lifetime parameters, argument-position impl Trait, raw
    callbacks with owned generic inputs and returns, async, catch, and
    slice_to_array are all supported; see
    the guide
    for the supported surface and the shapes that are rejected. The attribute
    is experimental and may change as it stabilizes.
    #5230
    #5272
    #5314

  • #[wasm_bindgen(experimental_generic_mono)] now supports class-level generic
    parameters: an imported type that is itself generic (type Holder<T>),
    used as a method receiver (this: &Holder<T>), or as the return type of a
    constructor or self-returning static method (fn new<T>(value: T) -> Holder<T>). See Class-level generics
    in the guide.
    #5290

  • A generic imported type used as a method receiver or a constructor's return
    type may now carry concrete generic arguments (this: &Holder<u32>,
    this: &Holder<u32, T>). The arguments are re-emitted as written, so the
    generated method hangs off impl Holder<u32> rather than the class's own
    parameter defaults.
    #5290

  • Added experimental JSPI (JS Promise Integration) support: using it emits a
    compiler warning noting the experimental status.
    Supports #[wasm_bindgen(jspi)] on exports (sync or async), within which
    a #[wasm_bindgen(suspending)] import call can suspend to the JS event
    loop until its Promise settles. js_sys::futures::jspi_block_on_promise
    also suspends on any Promise inside a synchronous function, while
    spawn_local is context-aware: tasks spawned from within a JSPI context
    support synchronous JSPI suspensions throughout their call trees.
    Compatible with catch (rejections as Err), async, and
    panic=unwind.
    #5193

  • Added a --ts-typed-array-buffers CLI flag to declare owned typed-array
    return values (e.g. Vec<u8>) as Uint8Array<ArrayBuffer> in generated
    TypeScript, since they are always copied into a fresh, non-shared
    ArrayBuffer. Requires TypeScript 5.7+.
    #5263

Changed

  • Export shim symbols are now mangled with a per-crate hash, so identically
    named exports from different crates (or two versions of one crate) no
    longer fail the link with duplicate-symbol errors; the CLI restores the
    canonical names in the final module. Same-named #[wasm_bindgen(private)]
    structs/enums now coexist (numbered Name, Name2, ... internally in the
    generated bindings), while genuinely conflicting public exports are
    reported as a wasm-bindgen error instead of a wasm-ld failure. Requires
    matching wasm-bindgen and CLI versions (schema bump).
    #2247

  • Setting js_namespace on both an extern "C" block and an item inside it
    is now a hard error. Nested paths must be written in a single attribute,
    e.g. js_namespace = ["a", "b"]. The previous behavior silently dropped
    the block-level namespace.
    #4324

  • Changed WebGPU setImmediates APIs to take immutable u8 slice.
    #5289

  • Changed Web Bluetooth writeValue / writeValueWithResponse /
    writeValueWithoutResponse and WebUSB controlTransferOut / transferOut
    / isochronousTransferOut APIs to take immutable u8 slices.
    #5309

  • Emscripten glue no longer reads wasmExports['name'] inline inside inner
    functions. It now references the asmjs-mangled identifiers emcc's own
    top-level assignWasmExports receiving code binds for every wasm export
    (e.g. ___wbindgen_malloc, ___wbindgen_externrefs), which are the
    canonical DCE-graph pairs: wasm-metadce keeps exactly the exports the
    included glue uses (previously internal exports and the externref table
    could be stripped or left unrenamed by the import/export minifier at -O2,
    breaking at runtime). Hoisted classes are now emitted as =-prefixed
    string value snippets so jsifier declares them as
    export var Class = class Class {...} instead of an export class
    declaration, which crashes emcc's acorn-optimizer under
    -sMODULARIZE=instance.

Fixed

  • The thread-bootstrap transform is now skipped in Emscripten mode, where the
    Emscripten runtime owns pthread startup and TLS. It previously ran on any
    module with shared memory and aborted the build (failed to find __wasm_init_tls), since Emscripten's linker had already consumed the
    synthetic symbols it looks for.
    #5315

  • Fixed conflicting deprecation messages on web-sys dictionary fields that
    are themselves deprecated: the deprecated builder-style method no longer
    points at an equally-deprecated setter, and the WebAuthn fields removed from
    the specification (such as PublicKeyCredentialRpEntity's icon) now state
    why they are deprecated.
    #5302

  • #[wasm_bindgen] on a struct now reports an actionable error when the path
    to the wasm_bindgen crate cannot be resolved (e.g. when wasm-bindgen is
    only a transitive dependency through web-sys), instead of a confusing
    recursion limit error.
    #5295

  • Fixed js_namespace exports missing from the bundler target's entry module
    re-export list, making namespaces unreachable when importing the package.
    #5267

  • The CLI now reports an actionable error when the __wasm_bindgen_unstable
    custom section is missing from a module that still contains wasm-bindgen
    shims (e.g. stripped by llvm-objcopy --strip-all, which removes all custom
    sections since LLVM 23), instead of the confusing
    import of `X` doesn't have an adapter listed.
    #5268

  • The generated &T handle conversions (IntoWasmAbi/OptionIntoWasmAbi) for
    an imported type with lifetime parameters (type Holder<'a, T>) no longer
    reuse 'a for the reference itself. Previously the impl header declared only
    a fresh 'a plus the type's type parameters, so a type whose lifetime was
    not literally named 'a failed with E0261 against generated code, and one
    that was named 'a had its lifetime forced to unify with the borrow of
    &self — surfacing as E0521 whenever a generic method also had to resolve
    through the same impl.
    #5290

  • An inline lifetime bound on a generic import (fn f<'a: 'b, 'b, T>(..)) is no
    longer dropped from the generated wrapper. Previously the bound was lost while
    the generated shim still declared it, so calling the import failed with
    "lifetime may not live long enough" reported against generated code.
    #5290

  • A type-parameter default on a #[wasm_bindgen(experimental_generic_mono)] import is no
    longer silently ignored. It has no meaning there (every instantiation gets its
    own shim, so there is no single one to default) and rustc's own
    invalid_type_param_default lint cannot see it, since nothing of the original
    signature survives expansion; it is now rejected with the same
    defaults for generic parameters are not allowed here diagnostic rustc gives.
    Defaults on the type-erasure generic path are unaffected, where they remain
    meaningful.
    #5290

  • Fix js-sys wasm64 build with atomics feature.
    #5274

  • Declare initSync in the generated TypeScript definitions for
    --target no-modules, matching the wasm_bindgen.initSync function that
    the JS output already exposes.
    #5284

  • Removed the last panicking code paths from externref table management:
    RefCell::borrow_mut() embe...

Read more

0.2.127

Choose a tag to compare

@github-actions github-actions released this 08 Aug 00:58
Immutable release. Only release title and notes can be modified.
a579ee6

Added

  • Navigation API
    to web-sys #5247

  • Added riscv64gc-unknown-linux-gnu release artifacts.
    #5265

  • Added JsNullable<T>, modeling WebIDL nullable types (T | null). Both
    null and undefined are treated as absent, per WebIDL's ECMAScript
    conversion rules; the canonical empty value produced from Rust is null.
    web-sys now uses JsNullable<T> instead of JsOption<T> for nullable
    types nested inside generics (e.g. Promise<GpuError?> from
    GPUDevice.popErrorScope()), fixing spec-defined null resolutions being
    treated as present values under JsOption<T>'s strict undefined-only
    semantics. JsNullable<T> participates in the same upcast lattice as
    JsOption<T> (including contravariant closure argument casts), and
    additionally upcasts from Null and from JsOption<T> itself. Imported
    extern types now also upcast into JsOption<JsValue> and
    JsNullable<JsValue>, so catch-all nullable closures can be used where a
    typed callback is expected.
    #5234

Changed

  • Emscripten output now marks public exports (free functions, classes, enums,
    and namespace roots) with the __export: true and __force: true symbol
    attributes on their addToLibrary entries, instead of mutating
    EXPORTED_FUNCTIONS and pushing to extraLibraryFuncs at library-load time.
    The $initBindgen init closure is kept via __force: true, and private
    symbols (including namespace leaves) carry neither attribute — they remain
    reachable through __deps. Requires an emscripten with __export/__force
    symbol-attribute support.

  • Updated WebGPU bindings to the August 2026 spec, including the new
    GPUCommandEncoder::copy_buffer_to_buffer overloads and setImmediates.
    #5246

  • Unstable API overload names now elide name tokens shared by every overload
    variant: LockManager::request_with_callback is now request, and
    request_with_options_and_callback is now request_with_options.
    #5246

Fixed

  • The name property of the JS error thrown for panic=unwind is now set from
    a string literal instead of PanicError.name, so it survives minification.
    #5260

  • Fixed Emscripten builds using pthreads failing to link.
    #5254

  • __wbg_load in web targets now throws a clear error including the HTTP
    status and URL when given a non-ok fetch Response, instead of surfacing a
    misleading MIME-type or Wasm-magic-number error.
    #5256

  • Restored __stack_pointer when an exception unwinds out of a wasm export,
    preventing repeated panic = "unwind" calls from leaking shadow-stack frames
    until the shadow stack is exhausted and calls trap. Node reports
    memory access out of bounds; poisoned instances can instead report
    Module terminated.
    #5244

  • slice_to_array on a &mut slice (which silently discarded JS's writes) or
    on a slice with a generic element type is now a compile error, and strings
    and arrays received by JS (e.g. a Vec<String> return value) no longer make
    a redundant copy of the freshly built value.
    #5261

  • Fixed async imports with non-JS-handle resolved types (e.g.
    async fn f() -> u32;) silently producing garbage since 0.2.109: the
    descriptor named the resolved type instead of the Promise handle that
    actually crosses the ABI.
    #5249

  • Fixed catch imports returning i64/u64 throwing a TypeError (and
    panicking in __wbindgen_exn_store) when the JS import throws, since the
    handleError catch path returned undefined which cannot be converted to
    a Wasm i64.
    #5238

  • js_namespace is now part of an imported function's and imported static's
    generated shim name. Two imports with identical Rust signatures that differed
    only in their js_namespace hashed to the same __wbg_<name>_<hash>
    symbol, so they were treated as one binding and one of the two call sites
    silently invoked the wrong JS value.
    #5250

  • Macro hygiene fixes - slice_to_array now works in #![no_std] crates.
    Generated code no longer names core or std unqualified.
    #5251

  • Fixed length prefixes in descriptor strings to count chars rather than
    UTF-8 bytes, so non-ASCII names in js_name/typescript_type no longer
    panic the CLI or mis-bind the generated bindings.
    #5248

  • Fixed threaded Wasm memory layout to reserve wasm-bindgen's internal thread
    page after the module's original initial memory instead of at __heap_base,
    avoiding overlap with allocators that resolve __heap_base/__heap_end at
    link time and treat that range as preexisting heap space.
    #5225

  • Emscripten output now reaches wasm exports through emscripten's wasmExports
    object using bracket (string-literal) access (wasmExports['__wbindgen_start'])
    instead of a local wasm alias with dot access. wasmExports['name'] is the
    form emcc's DCE graph roots and its import/export minifier renames in the JS
    and the wasm together, so the glue now survives and stays consistent under
    -O3/-Os (previously the export names were minified without updating the JS
    call sites, e.g. __wbindgen_start is not defined).

  • The emscripten detection marker static is no longer leaked as public API.
    #5220
    #5222

0.2.126

Choose a tag to compare

@github-actions github-actions released this 24 Jun 19:58
Immutable release. Only release title and notes can be modified.
21ac804

Changed

  • Emscripten output now hoists every clean export (free functions, classes,
    enums, plus their finalization registries and string-enum tables) out of the
    $initBindgen init closure into its own top-level addToLibrary symbol and
    self-registers it into EXPORTED_FUNCTIONS. emscripten then emits the clean
    API (add, Counter, ...) as named ESM exports under -sMODULARIZE=instance
    and as Module.<name> properties (via each symbol's __postset) in factory
    mode, with no extra sidecar files. Namespaced exports are reached through
    their namespace root (e.g. app), assembled in the root symbol's __postset.
    User module/inline-js imports are now wired as addToLibrary shims (they were
    previously dropped, since emcc resolves imports only against env), and their
    ESM-imported bindings are __wbg_-prefixed to avoid colliding with emcc
    runtime names such as Module/HEAP8.
    #5210

Fixed

  • The descriptor interpreter now follows emscripten invoke_* trampolines.
    emscripten's exception/longjmp lowering rewrites direct calls into indirect
    calls through the function table wrapped in imported invoke_*(fnptr, ..args)
    helpers, including the describe helpers a descriptor function must reach. The
    interpreter resolves fnptr against the reconstructed function table, forwards
    the trailing arguments, and evaluates the surrounding "did it throw?" control
    flow (if/else, loop, br_table), so descriptors are interpreted
    correctly on emscripten builds with unwinding/longjmp enabled.
    #5215

  • Relaxed alignment requirement for 8-byte types.
    #5204

0.2.125

Choose a tag to compare

@github-actions github-actions released this 12 Jun 22:10
Immutable release. Only release title and notes can be modified.
6ff7f1c

Added

  • Added the --force-enable-abort-handler CLI flag, which emits the hard-abort
    detection and set_on_abort machinery on panic=abort builds. With
    panic=unwind this machinery is generated automatically; the flag does
    nothing there.
    #5191

Changed

  • Made the internal __wbindgen_destroy_closure export private in the Rust API.
    #5196

0.2.123

Choose a tag to compare

@github-actions github-actions released this 08 Jun 21:53
Immutable release. Only release title and notes can be modified.
861696a

Added

  • Added the maxAge attribute to the CookieInit dictionary in web-sys,
    matching the current Cookie Store API specification.
    #5169

  • The js-sys futures codegen opt-in can now also be enabled via the
    WASM_BINDGEN_USE_JS_SYS=1 environment variable, in addition to
    --cfg=wasm_bindgen_use_js_sys. This works on stable when --target
    is in use, where Cargo does not propagate the cfg to host proc-macros.
    #5164

Changed

  • JsOption<T> now treats only undefined as empty, aligning it with
    TypeScript's strict T | undefined semantics and with Option<T>'s wire
    shape (Noneundefined). Previously is_empty, as_option,
    into_option, unwrap, expect, unwrap_or_default, and
    unwrap_or_else treated both null and undefined as absent; JS null
    is now a distinct present value. The impl<T> UpcastFrom<Null> for JsOption<T> is removed (Undefined still models absence), and the
    Debug/Display absent placeholder changed from "null" to
    "undefined". Code relying on null → None should return undefined
    from the JS side, or check explicitly with
    val.as_option().filter(|v| !v.is_null()).
    #5170

Fixed

  • Removed invalid js_sys::Array<T> to js_sys::ArrayTuple<(...)> upcasts.
    ArrayTuple encodes a fixed tuple arity, while a plain JavaScript array does
    not prove that arity statically.

  • Fixed incorrect variance in &mut reference upcasting. &mut T upcasts
    were covariant in the pointee, so a &mut T could be widened to a &mut
    of a supertype and used to write back a value the original type would not
    accept, leaving a reference whose static type no longer matches the value
    it points to. Mutable references are now invariant in their pointee:
    &mut T only upcasts to &mut Target when both Target: UpcastFrom<T>
    and T: UpcastFrom<Target> hold. This rejects the invalid widening but is
    a breaking change for callers that relied on widening &mut references.
    #5176

  • Fixed WASI targets (wasm32-wasip1/wasm32-wasip2) emitting unresolved
    __wbindgen_placeholder__ imports, which broke component linking. The
    codegen and runtime gates now exclude target_os = "wasi" (restoring the
    pre-0.2.115 stub behavior), including the panic = "unwind" paths in
    wasm-bindgen-futures.
    #5175

  • Fixed a panic ("Unhandled load width 8") in the descriptor interpreter when
    processing -Cinstrument-coverage-instrumented modules, unblocking
    cargo llvm-cov --target wasm32-unknown-unknown for crates whose describe
    helpers get instrumented.
    #5179

  • Fixed main silently never running on wasm64 for bin crates.
    #5181

0.2.122

Choose a tag to compare

@github-actions github-actions released this 22 May 17:26
Immutable release. Only release title and notes can be modified.
ddd3225

Notices

  • Threading support now requires -Clink-arg=--export=__heap_base to be set
    in RUSTFLAGS for nightly toolchains from 2026-05-06 onward, after
    rust-lang/rust#156174
    removed the implicit __heap_base/__data_end exports on wasm*
    targets. Atomics CI, CLI reference tests, and the nodejs-threads,
    raytrace-parallel, and wasm-audio-worklet examples have been
    updated to pass --export=__heap_base explicitly. The flag is
    backward-compatible with older nightlies.

  • -Cpanic=unwind on wasm targets now emits modern (exnref) exception
    handling by default after
    rust-lang/rust#156061,
    and requires Node.js 22.22.3+ (for WebAssembly.JSTag). Legacy EH wasm
    can still be produced on current nightlies by adding
    -Cllvm-args=-wasm-use-legacy-eh to RUSTFLAGS; Node.js 20 may be
    supported with legacy exception handling, with a tracking issue in
    #5151.

Added

  • Implemented TryFromJsValue for Vec<T> where T: TryFromJsValue.
    A JS value converts when it is a real Array (per Array.isArray)
    and every element converts via T::try_from_js_value. This composes
    recursively (Vec<Vec<String>>, Vec<Option<T>>) and works for any
    T with a TryFromJsValue impl, including primitives, String,
    JsValue, and JsCast types. Array-likes (objects with length and
    numeric indices) are intentionally rejected to mirror the static ABI
    representation used by js_value_vector_from_abi.

  • New extends_js_class and extends_js_namespace attributes on
    exported structs to allow defining the parent js_class name when
    it has been customized by js_name and the parent's own js_namespace
    as well in turn. New validation is added at code generation time that
    will now catch these cases instead of emitting invalid code. Example:

    #[wasm_bindgen(js_name = "Animal", js_namespace = zoo)]
    pub struct AnimalImpl { /* ... */ }
    
    #[wasm_bindgen(
        extends = AnimalImpl,
        extends_js_class = "Animal",
        extends_js_namespace = zoo,
    )]
    pub struct DogImpl { /* ... */ }

    #5154

Changed

  • When an exported struct uses js_namespace, the corresponding value
    must now be repeated on every impl block. Previously the impl-side
    defaults silently worked resulting in inconsistent emission. Example:

    // Before:
    #[wasm_bindgen(js_namespace = "default")]
    pub struct Counter { /* ... */ }
    
    #[wasm_bindgen]              // worked, but fragile
    impl Counter { /* ... */ }
    
    // After:
    #[wasm_bindgen(js_namespace = "default")]
    pub struct Counter { /* ... */ }
    
    #[wasm_bindgen(js_namespace = "default")]   // now required
    impl Counter { /* ... */ }

    To ease this transition for js_namespace usage, diagnostic
    messages now include hints for missing namespaces for easier
    fixing.

    #5154

Fixed

  • Fixed the descriptor interpreter panicking on Br and BrIf
    instructions emitted by recent nightly compilers when building with
    panic=unwind.
    #5158

  • Emscripten output now works against vanilla upstream emscripten without
    requiring a fork. Dependency tracking, HEAP_DATA_VIEW setup,
    function-decl intrinsic inlining, catch-wrapper gating, and imported
    global handling have all been corrected; ESM imports
    (#[wasm_bindgen(module = "...")] and snippets) are emitted to a
    sidecar library_bindgen.extern-pre.js consumers pass to emcc via
    --extern-pre-js; namespaced exports (js_namespace = [...] on a
    struct/impl) now attach to Module.<segments> instead of emitting
    top-level export const (which emcc's library evaluator rejects);
    the generated .d.ts for namespaced exports is now valid TypeScript
    (mangled identifiers stay module-internal via declare class /
    declare enum / declare function plus export { BindgenModule };
    to mark the file as a module; no spurious unqualified Calc:
    property on BindgenModule for namespaced items; namespace shapes
    land as plain interface members (app: { math: { Calc: typeof app__math__Calc } };) instead of the previously-emitted export let app: { ... }; which was invalid TS1131 syntax inside an
    interface body).
    #5156

  • Fixed a duplicate phantom class being emitted for an exported struct
    renamed via js_name (Rust ident != JS class name) and/or placed in a
    js_namespace, when the struct crosses the boundary as a JsValue
    (e.g. via .into()). The WrapInExportedClass / UnwrapExportedClass
    imports were keyed by the Rust ident rather than the qualified JS name
    that exported_classes is keyed by (a regression from #5154), so a
    fresh empty class entry was minted and emitted alongside the real one,
    with a free() referencing a nonexistent wasm export. Riding the
    same release's #5154 wire-format bump, the now-vestigial rust_name
    field is dropped from the schema and the namespace-qualified name is
    no longer cached on AuxStruct, AuxEnum, or ExportedClass
    (derived on demand from (name, js_namespace)), collapsing three
    fallback chains that only papered over the pre-#5154 keying.

    #5160

0.2.121

Choose a tag to compare

@github-actions github-actions released this 07 May 00:53
Immutable release. Only release title and notes can be modified.
49457f2

Added

  • Added the slice_to_array attribute for imported JS functions,
    which makes a &[T] (or Option<&[T]>) argument arrive on the JS
    side as a plain Array rather than a typed array — without
    changing the Rust-side &[T] signature. Useful when binding JS
    APIs that take T[] rather than TypedArray<T>. For primitive
    element kinds the wire is the same zero-copy borrow used by plain
    &[T], with the JS-side shim wrapping the view in Array.from(...)
    to materialise the Array — no extra allocation. For String,
    JsValue, and JS-imported element types the Rust side builds a
    fresh [u32] index buffer that JS reads and frees, with per-element
    &T -> JsValue (refcount bump for handle-shaped types). No T: Clone bound is required. The attribute can be set per-fn
    (#[wasm_bindgen(slice_to_array)] fn ...) or per-block on an
    extern "C" { ... } declaration to apply to every imported function
    in that block. &[ExportedRustStruct] remains unsupported (use
    owned Vec<T> for that). Has no effect on exported functions;
    default &[T] (typed-array view / memory borrow) and owned
    Vec<T> semantics are unchanged for callers that didn't opt in.
    See the
    slice_to_array guide page.
    #5145

  • Added js_sys::AggregateError bindings (constructor, errors getter, and
    new_with_message / new_with_options overloads). AggregateError represents
    multiple unrelated errors wrapped in a single error, e.g. as thrown by
    Promise.any when all input promises reject, along with js_sys::ErrorOptions,
    accepted by built-in error constructors. ErrorOptions::new(cause)
    constructs an instance pre-populated with cause, and get_cause /
    set_cause provide typed access to the property. All standard error
    constructors that previously took only a message (EvalError,
    RangeError, ReferenceError, SyntaxError, TypeError, URIError,
    WebAssembly.CompileError, WebAssembly.LinkError,
    WebAssembly.RuntimeError) now expose a new_with_options(message, &ErrorOptions) overload, and Error gains
    new_with_error_options(message, &ErrorOptions) alongside the existing
    untyped new_with_options. AggregateError::new_with_options also takes
    &ErrorOptions.
    #5139

  • Added inheritance for Rust-exported types: an exported struct may
    declare #[wasm_bindgen(extends = Parent)] to inherit from another
    exported #[wasm_bindgen] struct. The macro injects a hidden
    parent: wasm_bindgen::Parent<Parent> field (a refcounted cell around
    the parent value) and emits class Child extends Parent in the
    generated JS / .d.ts. The child gets an AsRef<Parent<Parent>> impl
    for the direct parent, and threads per-class pointer slots through
    the wasm ABI so that instanceof Parent is true and parent methods
    dispatch soundly via the JS prototype chain. From inside child
    methods, parent data is reached via self.parent.borrow() /
    self.parent.borrow_mut(). See the new
    extends guide page.
    #5120

  • Added js_sys::FinalizationRegistry bindings (constructor, register,
    register_with_token, and unregister). The cleanup callback parameter
    is typed as &Function<fn(JsValue) -> Undefined>, so closures created via
    Closure::new can be passed using Function::from_closure (for owned
    closures retained by JS) or Function::closure_ref (for borrowed scoped
    closures). Pairs with the existing js_sys::WeakRef bindings.
    #5140

  • Added support for well-known symbols in js_name, getter, and
    setter via the explicit bracket-string form
    "[Symbol.<name>]". This works for imported and exported methods,
    fields, getters, and setters. For example,
    #[wasm_bindgen(js_name = "[Symbol.iterator]")] on an exported method
    generates [Symbol.iterator]() { ... } on the generated JS class, and
    the same syntax works for getter / setter and for imported items.
    #4230

  • Added level 2 bindings for ViewTransition to web-sys.
    #5138

  • Add support for dynamic unions: a #[wasm_bindgen] enum that mixes string-literal
    variants with single-field tuple variants is now exported as an untagged TypeScript
    union and dispatched dynamically at the JS↔Rust boundary. The new enum-level
    #[wasm_bindgen(fallback)] attribute makes the last tuple variant an
    unconditional catch-all, supporting unions whose trailing variant has no
    runtime check (e.g., interface-only imports). String enums and dynamic
    unions now emit export type (was bare type) so the alias is a named
    export, and both honour the private flag to suppress the keyword.
    #4734
    #2153
    #2088

Fixed

  • From<Promise<T>> for JsFuture<T> and IntoFuture for Promise<T> now
    accept any T: FromWasmAbi (rather than T: JsGeneric), letting
    imported async fns return dynamic-union enums.

  • TryFromJsValue for C-style enums no longer accepts non-numeric values
    via JS unary + coercion. Previously calling dyn_into::<MyEnum>() on
    a string would silently coerce it via +"foo" (yielding NaN, then
    NaN as u32 = 0) and could match a discriminant by accident; the
    conversion now returns None for any value that is not a JS number.
    #4734

  • Fix compilation failure with no_std + release
    #5134

  • Raw identifiers (r#name) on enums, enum variants, extern types, statics,
    and impl blocks no longer leak the r# prefix into generated JS / TS
    output and shim names. The Rust-side identifier and the JS-side name are
    now tracked separately for enum variants, and all known identifier
    fallback paths apply Ident::unraw() so e.g.
    pub enum r#Enum { r#A } generates Enum.A instead of producing
    syntactically invalid JS.
    #4323

  • Using the -C panic=unwind option when building for the bundler target
    would produce invalid JS.
    #5142

Changed

  • js_sys::DataView now implements the js_sys::TypedArray trait. A
    FIXME notes that the trait should be renamed to ArrayBufferView in
    the next major release to better reflect the WebIDL spec name covering
    both DataView and the typed-array types.
    #5135

0.2.120

Choose a tag to compare

@github-actions github-actions released this 28 Apr 07:49
Immutable release. Only release title and notes can be modified.
0.2.120
3c5043f

Added

  • Added support for the wasm64-unknown-unknown target (memory64 / wasm64).
    usize / isize and raw pointers are now lowered through an f64 JS
    number ABI on wasm64 (matching the existing convention used for Option<u32>
    etc. on wasm32), with the CLI inspecting the module's memory type to pick
    the right codegen path. Includes a dedicated wasm64 CI job and test
    suite covering the new ABI paths.
    #5004

  • Promise ergonomics: Promise::all_tuple and Promise::all_settled_tuple
    for heterogeneous concurrent awaits (arity 1..=8, destructure via
    .into_tuple()), and a new wasm_bindgen::IntoJsGeneric trait underpinning
    typed-Array inference (with codegen-emitted identity impls and a
    #[wasm_bindgen(no_into_js_generic)] opt-out for types like JsClosure).
    Also re-exports JsGeneric from the prelude. Typed collection on
    js_sys::Array<T> is exposed as the inherent constructor
    Array::<T>::from_iter_typed (and companion extend_typed), inferring T
    from the iterator item via IntoJsGeneric. The stable FromIterator /
    Extend impls on Array (= Array<JsValue>) bound by AsRef<JsValue>
    are preserved, so existing .collect::<Array>() call sites keep compiling
    unchanged. Fixes #5042.
    #5121,
    #5125

  • Added wasm_bindgen::instance() to return the current
    WebAssembly.Instance. The generated JS glue retains the
    instantiated WebAssembly.Instance.
    #5118

  • Added a --cfg=wasm_bindgen_use_js_sys opt-in that makes async macro codegen
    use js_sys::futures instead of wasm_bindgen_futures, dropping the need
    for wasm-bindgen-futures when the crate already depends on js-sys. A cfg
    is used rather than a Cargo feature so the choice stays scoped to the crate
    that opts in.
    #5112
    #5127

Changed

  • Simplified generated web-sys bindings by omitting redundant
    #[wasm_bindgen] attributes when they match wasm-bindgen defaults, including
    structural method annotations and matching js_name entries. The
    #[wasm_bindgen] attribute parser now also accepts string-literal forms for
    extends, static_method_of, and vendor_prefix (alongside the existing
    bare-path/ident syntax), and the generator emits these arguments along with
    js_name as string literals so rustfmt can format the generated
    #[wasm_bindgen(...)] attributes uniformly.
    #5122

Fixed

  • Fixed namespaced export identifiers in generated JS/TS to use qualified names
    consistently, resolving order-dependent codegen issues across platforms. Also
    fixed Vec<T> types in TS signatures to resolve through the identifier map.
    #5106

  • Fixed wasm-bindgen-test-runner treating ChromeDriver stderr warnings as
    startup failures on macOS, causing a restart loop until timeout. The runner
    no longer uses stderr output to determine if a driver has failed; instead a
    per-attempt timeout detects stuck drivers and retries on a new port.
    #5111

0.2.118

Choose a tag to compare

@github-actions github-actions released this 10 Apr 16:58
753bb7f

Added

  • Added Error::stack_trace_limit() and Error::set_stack_trace_limit() bindings
    to js-sys for the non-standard V8 Error.stackTraceLimit property.
    #5082

  • Added support for multiple #[wasm_bindgen(start)] functions, which are
    chained together at initialization, as well as a new
    #[wasm_bindgen(start, private)] to register a start function without
    exporting it as a public export.
    #5081

  • Reinitialization is no longer automatically applied when using panic=unwind
    and --experimental-reset-state-function, instead it is triggered by any
    use of the handler::schedule_reinit() function under panic=unwind,
    which is supported from within the on_abort handler for reinit workflows.
    Renamed handler::reinit() to handler::schedule_reinit() and removed
    the set_on_reinit() handler. The __instance_terminated address
    is now always a simple boolean (0 = live, 1 = terminated).
    #5083

  • handler::schedule_reinit() now works under panic=abort builds. Previously
    it was a no-op; it now sets the JS-side reinit flag and the next export call
    transparently creates a fresh WebAssembly.Instance.
    #5099

Changed

  • MSRV bump from 1.71 to 1.76 for the CLI, and 1.82 to 1.86 for the API
    #5102

Fixed

  • ES module import statements are now hoisted to the top of generated JS
    files, placed right after the @ts-self-types directive. This ensures
    valid ES module output since import declarations must precede other
    statements.
    #5103

  • Fixed two CLI issues affecting WASM modules built by rustc 1.94+. First,
    a panic (failed to find N in function table) caused by lld emitting element
    segment offsets as global.get $__table_base or extended const expressions
    instead of plain i32.const N for large function tables; the fix adds a
    const-expression evaluator in get_function_table_entry and guards against
    integer underflow in multi-segment tables. Second, the descriptor interpreter
    now routes all global reads/writes through a single globals HashMap seeded
    from the module's own globals, and mirrors the module's actual linear memory
    rather than a fixed 32KB buffer, so the stack pointer's real value is valid
    without any override. This fixes panics like failed to find 32752 in function table caused by GOT.func.internal.* globals being misidentified as the
    stack pointer.
    #5076
    #5080
    #5093
    #5095

0.2.117

Choose a tag to compare

@github-actions github-actions released this 31 Mar 23:35
fb403cf

Fixed

  • Fixed a regression introduced in #5026 where stable web-sys methods that
    accept a union type containing a [WbgGeneric] interface (e.g.
    ImageBitmapSource, which includes VideoFrame) incorrectly applied typed
    generics to all union expansions rather than only those whose argument type
    is itself [WbgGeneric]. In practice this caused Window::create_image_bitmap_with_*
    and the corresponding WorkerGlobalScope overloads to return
    Promise<ImageBitmap> instead of Promise<JsValue> for the stable
    (non-VideoFrame) call sites, breaking JsFuture::from(promise).await?.
    #5064
    #5073