@viewscript/wasm 0.1.0-202605140732 → 0.1.0-20260514130715

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@viewscript/wasm",
3
3
  "type": "module",
4
- "version": "0.1.0-202605140732",
4
+ "version": "0.1.0-20260514130715",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "files": [
7
7
  "vsc_wasm_bg.wasm",
package/vsc_wasm.d.ts CHANGED
@@ -174,6 +174,38 @@ export class WasmViewScriptEngine {
174
174
  * A `Promise` that resolves to `WasmViewScriptEngine` or rejects with an error.
175
175
  */
176
176
  static create(canvas: HTMLCanvasElement, device_pixel_ratio: number): Promise<WasmViewScriptEngine>;
177
+ /**
178
+ * Load an FFI manifest generated by the Vite plugin.
179
+ *
180
+ * This method registers:
181
+ * - `bindings`: Q-dimension variables bound to JS functions
182
+ * - `triggers`: Post-solve conditions that fire FFI calls
183
+ *
184
+ * # Arguments
185
+ *
186
+ * * `manifest_json` - JSON string conforming to FfiManifest schema
187
+ *
188
+ * # Example
189
+ *
190
+ * ```json
191
+ * {
192
+ * "version": 1,
193
+ * "entity_map": { "button": 42, "cursor": 57 },
194
+ * "bindings": [
195
+ * { "ffi_id": 1, "bind_name": "mouse.x", "module_path": "./input.ts", "export_name": "getMouseX" }
196
+ * ],
197
+ * "triggers": [
198
+ * {
199
+ * "trigger_id": 100,
200
+ * "ffi_id": 2,
201
+ * "condition": { "kind": "bounds_overlap", "entity_a": 42, "entity_b": 57 },
202
+ * "args": []
203
+ * }
204
+ * ]
205
+ * }
206
+ * ```
207
+ */
208
+ loadFfiManifest(manifest_json: string): void;
177
209
  /**
178
210
  * Register a static image texture.
179
211
  *
@@ -271,9 +303,11 @@ export class WasmViewScriptEngine {
271
303
  *
272
304
  * # Returns
273
305
  *
274
- * `Ok(())` on success, or a JavaScript error on failure.
306
+ * JSON string with `TickResult`:
307
+ * - `{"pending_ffi_calls": []}` when no triggers fired
308
+ * - `{"pending_ffi_calls": [{"ffi_id": 2, "args": [...]}]}` when triggers fired
275
309
  */
276
- tick(input_json: string): void;
310
+ tick(input_json: string): string;
277
311
  /**
278
312
  * Update texture pixel data.
279
313
  *
@@ -329,6 +363,7 @@ export interface InitOutput {
329
363
  readonly wasmviewscriptengine_add_component: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
330
364
  readonly wasmviewscriptengine_create: (a: number, b: number) => number;
331
365
  readonly wasmviewscriptengine_height: (a: number) => number;
366
+ readonly wasmviewscriptengine_loadFfiManifest: (a: number, b: number, c: number, d: number) => void;
332
367
  readonly wasmviewscriptengine_register_image_texture: (a: number, b: number, c: number, d: number, e: number) => bigint;
333
368
  readonly wasmviewscriptengine_register_video_texture: (a: number, b: number, c: number) => bigint;
334
369
  readonly wasmviewscriptengine_remove_texture: (a: number, b: bigint) => number;
@@ -338,10 +373,10 @@ export interface InitOutput {
338
373
  readonly wasmviewscriptengine_tick: (a: number, b: number, c: number, d: number) => void;
339
374
  readonly wasmviewscriptengine_update_texture_pixels: (a: number, b: bigint, c: number, d: number) => number;
340
375
  readonly wasmviewscriptengine_width: (a: number) => number;
341
- readonly __wasm_bindgen_func_elem_3241: (a: number, b: number, c: number, d: number) => void;
342
- readonly __wasm_bindgen_func_elem_3263: (a: number, b: number, c: number, d: number) => void;
343
- readonly __wasm_bindgen_func_elem_1613: (a: number, b: number, c: number) => void;
344
- readonly __wasm_bindgen_func_elem_1613_2: (a: number, b: number, c: number) => void;
376
+ readonly __wasm_bindgen_func_elem_3646: (a: number, b: number, c: number, d: number) => void;
377
+ readonly __wasm_bindgen_func_elem_3668: (a: number, b: number, c: number, d: number) => void;
378
+ readonly __wasm_bindgen_func_elem_2018: (a: number, b: number, c: number) => void;
379
+ readonly __wasm_bindgen_func_elem_2018_2: (a: number, b: number, c: number) => void;
345
380
  readonly __wbindgen_export: (a: number, b: number) => number;
346
381
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
347
382
  readonly __wbindgen_export3: (a: number) => void;
package/vsc_wasm.js CHANGED
@@ -262,6 +262,53 @@ export class WasmViewScriptEngine {
262
262
  const ret = wasm.wasmviewscriptengine_height(this.__wbg_ptr);
263
263
  return ret >>> 0;
264
264
  }
265
+ /**
266
+ * Load an FFI manifest generated by the Vite plugin.
267
+ *
268
+ * This method registers:
269
+ * - `bindings`: Q-dimension variables bound to JS functions
270
+ * - `triggers`: Post-solve conditions that fire FFI calls
271
+ *
272
+ * # Arguments
273
+ *
274
+ * * `manifest_json` - JSON string conforming to FfiManifest schema
275
+ *
276
+ * # Example
277
+ *
278
+ * ```json
279
+ * {
280
+ * "version": 1,
281
+ * "entity_map": { "button": 42, "cursor": 57 },
282
+ * "bindings": [
283
+ * { "ffi_id": 1, "bind_name": "mouse.x", "module_path": "./input.ts", "export_name": "getMouseX" }
284
+ * ],
285
+ * "triggers": [
286
+ * {
287
+ * "trigger_id": 100,
288
+ * "ffi_id": 2,
289
+ * "condition": { "kind": "bounds_overlap", "entity_a": 42, "entity_b": 57 },
290
+ * "args": []
291
+ * }
292
+ * ]
293
+ * }
294
+ * ```
295
+ * @param {string} manifest_json
296
+ */
297
+ loadFfiManifest(manifest_json) {
298
+ try {
299
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
300
+ const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
301
+ const len0 = WASM_VECTOR_LEN;
302
+ wasm.wasmviewscriptengine_loadFfiManifest(retptr, this.__wbg_ptr, ptr0, len0);
303
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
304
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
305
+ if (r1) {
306
+ throw takeObject(r0);
307
+ }
308
+ } finally {
309
+ wasm.__wbindgen_add_to_stack_pointer(16);
310
+ }
311
+ }
265
312
  /**
266
313
  * Register a static image texture.
267
314
  *
@@ -411,10 +458,15 @@ export class WasmViewScriptEngine {
411
458
  *
412
459
  * # Returns
413
460
  *
414
- * `Ok(())` on success, or a JavaScript error on failure.
461
+ * JSON string with `TickResult`:
462
+ * - `{"pending_ffi_calls": []}` when no triggers fired
463
+ * - `{"pending_ffi_calls": [{"ffi_id": 2, "args": [...]}]}` when triggers fired
415
464
  * @param {string} input_json
465
+ * @returns {string}
416
466
  */
417
467
  tick(input_json) {
468
+ let deferred3_0;
469
+ let deferred3_1;
418
470
  try {
419
471
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
420
472
  const ptr0 = passStringToWasm0(input_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -422,11 +474,20 @@ export class WasmViewScriptEngine {
422
474
  wasm.wasmviewscriptengine_tick(retptr, this.__wbg_ptr, ptr0, len0);
423
475
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
424
476
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
425
- if (r1) {
426
- throw takeObject(r0);
477
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
478
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
479
+ var ptr2 = r0;
480
+ var len2 = r1;
481
+ if (r3) {
482
+ ptr2 = 0; len2 = 0;
483
+ throw takeObject(r2);
427
484
  }
485
+ deferred3_0 = ptr2;
486
+ deferred3_1 = len2;
487
+ return getStringFromWasm0(ptr2, len2);
428
488
  } finally {
429
489
  wasm.__wbindgen_add_to_stack_pointer(16);
490
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
430
491
  }
431
492
  }
432
493
  /**
@@ -1057,7 +1118,7 @@ function __wbg_get_imports() {
1057
1118
  const a = state0.a;
1058
1119
  state0.a = 0;
1059
1120
  try {
1060
- return __wasm_bindgen_func_elem_3263(a, state0.b, arg0, arg1);
1121
+ return __wasm_bindgen_func_elem_3668(a, state0.b, arg0, arg1);
1061
1122
  } finally {
1062
1123
  state0.a = a;
1063
1124
  }
@@ -1292,18 +1353,18 @@ function __wbg_get_imports() {
1292
1353
  getObject(arg0).writeTexture(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
1293
1354
  },
1294
1355
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1295
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 151, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1296
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1613);
1356
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 176, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1357
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2018);
1297
1358
  return addHeapObject(ret);
1298
1359
  },
1299
1360
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1300
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 370, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1301
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3241);
1361
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 395, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1362
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3646);
1302
1363
  return addHeapObject(ret);
1303
1364
  },
1304
1365
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1305
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 151, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1306
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1613_2);
1366
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 176, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1367
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2018_2);
1307
1368
  return addHeapObject(ret);
1308
1369
  },
1309
1370
  __wbindgen_cast_0000000000000004: function(arg0) {
@@ -1335,18 +1396,18 @@ function __wbg_get_imports() {
1335
1396
  };
1336
1397
  }
1337
1398
 
1338
- function __wasm_bindgen_func_elem_1613(arg0, arg1, arg2) {
1339
- wasm.__wasm_bindgen_func_elem_1613(arg0, arg1, addHeapObject(arg2));
1399
+ function __wasm_bindgen_func_elem_2018(arg0, arg1, arg2) {
1400
+ wasm.__wasm_bindgen_func_elem_2018(arg0, arg1, addHeapObject(arg2));
1340
1401
  }
1341
1402
 
1342
- function __wasm_bindgen_func_elem_1613_2(arg0, arg1, arg2) {
1343
- wasm.__wasm_bindgen_func_elem_1613_2(arg0, arg1, addHeapObject(arg2));
1403
+ function __wasm_bindgen_func_elem_2018_2(arg0, arg1, arg2) {
1404
+ wasm.__wasm_bindgen_func_elem_2018_2(arg0, arg1, addHeapObject(arg2));
1344
1405
  }
1345
1406
 
1346
- function __wasm_bindgen_func_elem_3241(arg0, arg1, arg2) {
1407
+ function __wasm_bindgen_func_elem_3646(arg0, arg1, arg2) {
1347
1408
  try {
1348
1409
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1349
- wasm.__wasm_bindgen_func_elem_3241(retptr, arg0, arg1, addHeapObject(arg2));
1410
+ wasm.__wasm_bindgen_func_elem_3646(retptr, arg0, arg1, addHeapObject(arg2));
1350
1411
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1351
1412
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1352
1413
  if (r1) {
@@ -1357,8 +1418,8 @@ function __wasm_bindgen_func_elem_3241(arg0, arg1, arg2) {
1357
1418
  }
1358
1419
  }
1359
1420
 
1360
- function __wasm_bindgen_func_elem_3263(arg0, arg1, arg2, arg3) {
1361
- wasm.__wasm_bindgen_func_elem_3263(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1421
+ function __wasm_bindgen_func_elem_3668(arg0, arg1, arg2, arg3) {
1422
+ wasm.__wasm_bindgen_func_elem_3668(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1362
1423
  }
1363
1424
 
1364
1425
 
package/vsc_wasm_bg.wasm CHANGED
Binary file