Releases: bikallem/webapi
Releases · bikallem/webapi
v0.4.0
Highlights
- Added first-class
wasm-gcsupport 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 trimmingwebapi.mjsto 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_promisebridge package to convertJsPromise[T]values.
Added
- Added
JsPromise[T]support for both JS andwasm-gc, includingthen(),catch_(), andfinally_()helpers plus thewebapi/js_promisebridge package. - Added
webapi_trimfor producing minimalwebapi.mjsbundles 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 largerwc-todo/wc-calculatorexamples. - Added generator support for WebIDL namespaces, variadic arguments, special operations (getter/setter/deleter), dictionary getters, dynamic
JsObjecthelpers, 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-gcdemos. - Generated runtime and emitters were refactored substantially to reduce duplication, improve determinism, and make backend behavior easier to reason about.
Fixed
- Fixed multiple
wasm-gcconversion issues, including callback wrapping, nullable returns, string handling, enum conversion, primitive array decoding, andUInt64/Int64BigInt 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_trimrobustness 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-gcchecks, example builds, Pages deployment, andwebapi_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
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:
EventModifierInitnow includesEventInitfields (bubbles,cancelable,composed) andUIEventInitfields (view,detail,which)MouseEventInitnow includesEventInit,UIEventInit, andEventModifierInitfieldsWheelEventInit,DragEventInit,KeyboardEventInit,FocusEventInit,InputEventInit,CompositionEventInitsimilarly 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_mappingpackage - Type resolution logic (WebIDL-to-MoonBit type mapping) is now in its owntype_mapping/package, separated from code rendering inemit/. - Introduce
FlattenedInterfacetype - 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.emitinto helpers - The 270-line method is now composed ofemit_constructor,emit_regular_operation,emit_attribute,emit_const_member, andemit_union_return_type. - Replace
println/panicwith 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.jsontomoon.pkgDSL format - Package configs use the newer MoonBit package DSL. - Address all build warnings in
webapi_genand examples.
Full Changelog: v0.2.0...v0.3.0
v0.2.0 - MDN Documentation
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