@gjsify/webassembly 0.4.43 → 0.4.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @gjsify/webassembly
|
|
2
|
+
|
|
3
|
+
Promise-API polyfill for `WebAssembly` on GJS. SpiderMonkey ships working synchronous `new WebAssembly.Module` and `new WebAssembly.Instance` constructors but the async methods (`compile`, `instantiate`, `compileStreaming`, `instantiateStreaming`) throw at runtime. This package wraps the synchronous constructors so async-API consumers work unmodified on GJS.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gjsify install @gjsify/webassembly
|
|
11
|
+
|
|
12
|
+
# npm or yarn also work (e.g. adding it to an existing project):
|
|
13
|
+
npm install @gjsify/webassembly
|
|
14
|
+
yarn add @gjsify/webassembly
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { compile, instantiate, instantiateStreaming, validate } from '@gjsify/webassembly';
|
|
21
|
+
|
|
22
|
+
// Compile from a buffer
|
|
23
|
+
const module = await compile(wasmBuffer);
|
|
24
|
+
|
|
25
|
+
// Compile and instantiate in one step
|
|
26
|
+
const { instance } = await instantiate(wasmBuffer, importObject);
|
|
27
|
+
|
|
28
|
+
// Stream-instantiate from a fetch Response
|
|
29
|
+
const { instance: inst } = await instantiateStreaming(fetch('/app.wasm'), importObject);
|
|
30
|
+
|
|
31
|
+
// Validate a buffer without throwing
|
|
32
|
+
const ok = validate(wasmBuffer);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/webassembly",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.44",
|
|
4
4
|
"description": "WebAssembly Promise-API polyfill for GJS — wraps the synchronous Module/Instance constructors that work in SpiderMonkey 128+.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"polyfill"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@gjsify/cli": "^0.4.
|
|
54
|
-
"@gjsify/unit": "^0.4.
|
|
53
|
+
"@gjsify/cli": "^0.4.44",
|
|
54
|
+
"@gjsify/unit": "^0.4.44",
|
|
55
55
|
"@types/node": "^25.9.1",
|
|
56
56
|
"typescript": "^6.0.3"
|
|
57
57
|
},
|