Skip to content

Add clean dart2wasm web support - #1

Open
dh0er wants to merge 1 commit into
vm75-mainfrom
codex/clean-dart2wasm
Open

dh0er wants to merge 1 commit into
vm75-mainfrom
codex/clean-dart2wasm

Conversation

@dh0er

@dh0er dh0er commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

This adds clean dart2wasm support for the web build while keeping the existing standalone .wasm asset flow.

The package now uses the current universal_ffi release line for web FFI support and avoids package-local Dart code generation for Wasm function signatures. The Wasm asset is built as a standalone module and the asset saver uses an explicit typed lookup for the write_file bridge.

Dependency

This depends on the standalone Wasm function export fix in dh0er/wasm_ffi#2. Without that wasm_ffi change, standalone Wasm exports are surfaced as JSFunction under dart2wasm and cannot be invoked through the existing lookupFunction / asFunction path reliably.

Changes

  • Raise the package and example SDK floor to Dart 3.10.8.
  • Update universal_ffi to ^1.5.0.
  • Build assets/sweph.wasm as standalone Wasm with explicit standalone/web-worker flags.
  • Keep -DNO_SWE_GLP for the Wasm build so Swiss Ephemeris does not depend on native library-path behavior.
  • Export and use the in-memory write_file bridge for web asset loading.
  • Use typed pointer parameters for the web asset saver bridge and call lookup<NativeFunction<...>>(...).asFunction<...>() explicitly.
  • Keep the public Sweph.init / web asset loading shape intact.

Validation

  • dart pub get
  • flutter pub get in example/
  • dart analyze
  • make wasm
  • flutter build web --wasm in example/
  • Browser smoke of the Wasm build:
    • renders Sweph Version: 2.10.03
    • renders numeric Moon longitude/latitude
    • renders fixed-star Rohini output
    • renders house ASCMC and house cusp output
    • no current browser error logs for the served build
  • flutter build web in example/
  • Browser smoke of the JS web build with the same rendered example values
  • git diff --check

Note

Medium Risk
Touches the Wasm build pipeline and FFI boundary for ephemeris file loading on web; behavior was validated manually but depends on external wasm_ffi export fixes.

Overview
Adds dart2wasm-compatible web support by building assets/sweph.wasm as a standalone module (no Emscripten JS shell), with -DNO_SWE_GLP, a stubbed getenv, and an exported write_file bridge for in-memory ephemeris assets.

The Dart side bumps the SDK floor to 3.10.8, upgrades universal_ffi to ^1.5.0, and fixes the web asset saver to use typed lookup<NativeFunction<...>>().asFunction() and Pointer<Uint8> when calling write_file and freeing WASM memory. Examples use textContent on the DOM API; Utf8Pointer.toDartString is a small refactor only.

Reviewed by Cursor Bugbot for commit e6ffdbd. Bugbot is set up for automated code reviews on this repo. Configure here.

@dh0er
dh0er changed the base branch from main to vm75-main June 1, 2026 21:46
@dh0er
dh0er marked this pull request as ready for review June 1, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant