feat(wasm): use zig-js's exact JS interop ABI
Ghostty's wasm code talks to JavaScript through the zig-js library (mitchellh/zig-js, pinned in build.zig.zon). The first port invented its own import ABI because the dependency wasn't available; now: - ghostty-os/src/wasm/js.rs is a Rust port of zig-js's Zig side (Ref, Value, Object get/set/call/new, global, runtime, string) using its "zig-js" import module, function names and NaN-boxed value refs. - web_canvas face and the atlas debug canvas make the same JS calls as Ghostty's Zig code. - zig-js's unmodified JS host (+ LICENSE) is vendored under crates/ghostty-wasm/js/zig-js and drives the node test. Test Plan: - cargo test -p ghostty-wasm (node >= 24; asserts zig-js imports and no leaked host values)
This commit is contained in:
1 parent
28f55ff2dd
commit
a07b224869
16 files changed
+1532
-479
No files matched your search
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "zig-js-glue",
|
||||
"version": "0.1.3",
|
||||
"description": "JS glue for Zig to interface with JS from Wasm",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mitchellh/zig-js.git"
|
||||
},
|
||||
"source": "src/index.ts",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/module.js",
|
||||
"types": "dist/types.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "parcel build",
|
||||
"build": "parcel build",
|
||||
"test": "jest",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"author": "Mitchell Hashimoto",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@parcel/packager-ts": "^2.8.0",
|
||||
"@parcel/transformer-typescript-types": "^2.8.0",
|
||||
"@types/jest": "^29.2.3",
|
||||
"jest": "^29.3.1",
|
||||
"parcel": "^2.8.0",
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^4.9.3"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user