Skip to content

Releases: bikallem/webapi

v0.4.0

12 Mar 20:57

Choose a tag to compare

Highlights

  • Added first-class wasm-gc support alongside the existing JS target.
  • Expanded the live demo gallery to 45 examples covering DOM, Fetch, Canvas, Streams, IndexedDB, Web Animations, WebSocket, URLPattern, File System Access, custom elements, and more.
  • Broadened generated API coverage with variadic arguments, namespaces, special operations, more specs, richer dictionary support, and improved callback ergonomics.
  • Added webapi_trim, a CLI/tooling path for trimming webapi.mjs to only the modules required by a compiled wasm binary.

Breaking Changes

  • Promise-returning APIs now use JsPromise[T] instead of @js_async.Promise[T].
  • For JS-only async/await integration, use the bikallem/webapi/js_promise bridge package to convert JsPromise[T] values.

Added

  • Added JsPromise[T] support for both JS and wasm-gc, including then(), catch_(), and finally_() helpers plus the webapi/js_promise bridge package.
  • Added webapi_trim for producing minimal webapi.mjs bundles from wasm imports, including function-level trimming and test coverage.
  • Added new bindings and examples across a wide range of APIs, including Console, timers, storage, clipboard, notifications, WebSocket, fullscreen, screen orientation, requestIdleCallback, pointer/touch/selection/resize/intersection observers, streams, IndexedDB, Web Animations, permissions, service workers, URLPattern, File System Access, Trusted Types, and more.
  • Added custom element helpers and examples such as wc-counter, wc-edit-word, and the larger wc-todo / wc-calculator examples.
  • Added generator support for WebIDL namespaces, variadic arguments, special operations (getter/setter/deleter), dictionary getters, dynamic JsObject helpers, and additional overload handling.

Changed

  • The generated bindings now target both backends throughout the pipeline, and backend-specific FFI is emitted through unified source files guarded with #cfg(...).
  • The project layout was consolidated around the webapi/ module, with package metadata, examples, and tests updated to match.
  • The examples gallery, GitHub Pages deployment, and local development flow were expanded to support both JS and wasm-gc demos.
  • Generated runtime and emitters were refactored substantially to reduce duplication, improve determinism, and make backend behavior easier to reason about.

Fixed

  • Fixed multiple wasm-gc conversion issues, including callback wrapping, nullable returns, string handling, enum conversion, primitive array decoding, and UInt64/Int64 BigInt bridging.
  • Fixed generated JS runtime issues around reserved words, hyphenated CSS property names, overloaded method name collisions, and namespace module key casing.
  • Fixed bugs in example behavior and encapsulation, including per-instance component state and broader JS/wasm parity across demos.
  • Fixed webapi_trim robustness issues, including UTF-8 import decoding, structured parse failures, resilient filtering, and proper non-zero CLI exits on fatal errors.
  • Fixed several generator correctness issues around dictionary inheritance gaps, stale output reconciliation, lexer position tracking, and nullable method/attribute conversion.

Quality and Tooling

  • Grew end-to-end browser coverage to 339 Playwright tests across the example gallery.
  • Added broader CI coverage for JS and wasm-gc checks, example builds, Pages deployment, and webapi_trim.
  • Reworked large parts of the generator and parser internals to use smaller helpers, more deterministic output, and more MoonBit-idiomatic patterns.

v0.3.0

08 Feb 18:34

Choose a tag to compare

Bug Fixes

  • Fix multi-level dictionary inheritance - Dictionary types that inherit through multiple levels now correctly include all ancestor members. Previously, only the immediate parent's members were merged. This affects the UIEvents/DOM event init dictionary chain:
    • EventModifierInit now includes EventInit fields (bubbles, cancelable, composed) and UIEventInit fields (view, detail, which)
    • MouseEventInit now includes EventInit, UIEventInit, and EventModifierInit fields
    • WheelEventInit, DragEventInit, KeyboardEventInit, FocusEventInit, InputEventInit, CompositionEventInit similarly gain their full ancestor fields

Code Generator Improvements

  • Replace yacc-generated parser with hand-written recursive descent - The WebIDL parser no longer depends on moonbitlang/yacc. The new parser is faster and easier to maintain.
  • Extract type_mapping package - Type resolution logic (WebIDL-to-MoonBit type mapping) is now in its own type_mapping/ package, separated from code rendering in emit/.
  • Introduce FlattenedInterface type - Decouples the flattened IDL representation from the partial-merged intermediate form, preventing unintended mutation of pipeline inputs.
  • Extract render helpers from mbt_code_gen - The monolithic 200-line code generator match is now a 40-line dispatcher calling focused render functions.
  • Split InterfaceEmitter.emit into helpers - The 270-line method is now composed of emit_constructor, emit_regular_operation, emit_attribute, emit_const_member, and emit_union_return_type.
  • Replace println/panic with logger callbacks - Pipeline stages use injected logger functions instead of direct I/O, improving testability.
  • Convert file-based snapshot tests to inline assertions - Tests use inspect() and @json.inspect() instead of external snapshot files.
  • Convert moon.pkg.json to moon.pkg DSL format - Package configs use the newer MoonBit package DSL.
  • Address all build warnings in webapi_gen and examples.

Full Changelog: v0.2.0...v0.3.0

v0.2.0 - MDN Documentation

07 Jan 10:16

Choose a tag to compare

What's Changed

  • Add MDN documentation links to generated WebAPI bindings by @Copilot in #11

Full Changelog: https://github.com/bikallem/webapi/commits/v0.2.0