@viewscript/wasm 0.1.0-20260514140823 → 0.1.0-20260514180229
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 +1 -1
- package/vsc_wasm.d.ts +44 -4
- package/vsc_wasm.js +87 -15
- package/vsc_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/vsc_wasm.d.ts
CHANGED
|
@@ -206,6 +206,22 @@ export class WasmViewScriptEngine {
|
|
|
206
206
|
* ```
|
|
207
207
|
*/
|
|
208
208
|
loadFfiManifest(manifest_json: string): void;
|
|
209
|
+
/**
|
|
210
|
+
* Register a font for text rendering.
|
|
211
|
+
*
|
|
212
|
+
* The font binary is stored in the engine's font cache. When adding
|
|
213
|
+
* a Text component, the font_family parameter is used to look up the font.
|
|
214
|
+
*
|
|
215
|
+
* # Arguments
|
|
216
|
+
*
|
|
217
|
+
* * `family` - Font family name (e.g., "Inter", "Roboto")
|
|
218
|
+
* * `font_bytes` - Raw font file bytes (TTF, OTF, or TTC)
|
|
219
|
+
*
|
|
220
|
+
* # Returns
|
|
221
|
+
*
|
|
222
|
+
* `Ok(())` if the font was registered successfully, `Err` if parsing failed.
|
|
223
|
+
*/
|
|
224
|
+
register_font(family: string, font_bytes: Uint8Array): void;
|
|
209
225
|
/**
|
|
210
226
|
* Register a static image texture.
|
|
211
227
|
*
|
|
@@ -308,6 +324,28 @@ export class WasmViewScriptEngine {
|
|
|
308
324
|
* - `{"pending_ffi_calls": [{"ffi_id": 2, "args": [...]}]}` when triggers fired
|
|
309
325
|
*/
|
|
310
326
|
tick(input_json: string): string;
|
|
327
|
+
/**
|
|
328
|
+
* Update text content for an existing text entity.
|
|
329
|
+
*
|
|
330
|
+
* Re-expands the text to paths and updates the stored data.
|
|
331
|
+
* Removes old glyph PathEntityEntries and registers new ones.
|
|
332
|
+
*
|
|
333
|
+
* # Arguments
|
|
334
|
+
*
|
|
335
|
+
* * `entity_id` - The text entity ID returned by `add_component('Text', ...)`
|
|
336
|
+
* * `content` - The new text content to display
|
|
337
|
+
*
|
|
338
|
+
* # Example
|
|
339
|
+
*
|
|
340
|
+
* ```javascript
|
|
341
|
+
* const labelId = engine.add_component('Text', JSON.stringify({
|
|
342
|
+
* x: 100, y: 100, content: '0', font_family: 'Inter', font_size: 48
|
|
343
|
+
* }));
|
|
344
|
+
* // Later, update the content:
|
|
345
|
+
* engine.update_text_content(labelId, '42');
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
update_text_content(entity_id: bigint, content: string): void;
|
|
311
349
|
/**
|
|
312
350
|
* Update texture pixel data.
|
|
313
351
|
*
|
|
@@ -364,6 +402,7 @@ export interface InitOutput {
|
|
|
364
402
|
readonly wasmviewscriptengine_create: (a: number, b: number) => number;
|
|
365
403
|
readonly wasmviewscriptengine_height: (a: number) => number;
|
|
366
404
|
readonly wasmviewscriptengine_loadFfiManifest: (a: number, b: number, c: number, d: number) => void;
|
|
405
|
+
readonly wasmviewscriptengine_register_font: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
367
406
|
readonly wasmviewscriptengine_register_image_texture: (a: number, b: number, c: number, d: number, e: number) => bigint;
|
|
368
407
|
readonly wasmviewscriptengine_register_video_texture: (a: number, b: number, c: number) => bigint;
|
|
369
408
|
readonly wasmviewscriptengine_remove_texture: (a: number, b: bigint) => number;
|
|
@@ -371,12 +410,13 @@ export interface InitOutput {
|
|
|
371
410
|
readonly wasmviewscriptengine_set_component_fill_texture: (a: number, b: number, c: bigint, d: bigint) => void;
|
|
372
411
|
readonly wasmviewscriptengine_texture_count: (a: number) => number;
|
|
373
412
|
readonly wasmviewscriptengine_tick: (a: number, b: number, c: number, d: number) => void;
|
|
413
|
+
readonly wasmviewscriptengine_update_text_content: (a: number, b: number, c: bigint, d: number, e: number) => void;
|
|
374
414
|
readonly wasmviewscriptengine_update_texture_pixels: (a: number, b: bigint, c: number, d: number) => number;
|
|
375
415
|
readonly wasmviewscriptengine_width: (a: number) => number;
|
|
376
|
-
readonly
|
|
377
|
-
readonly
|
|
378
|
-
readonly
|
|
379
|
-
readonly
|
|
416
|
+
readonly __wasm_bindgen_func_elem_3718: (a: number, b: number, c: number, d: number) => void;
|
|
417
|
+
readonly __wasm_bindgen_func_elem_3740: (a: number, b: number, c: number, d: number) => void;
|
|
418
|
+
readonly __wasm_bindgen_func_elem_1843: (a: number, b: number, c: number) => void;
|
|
419
|
+
readonly __wasm_bindgen_func_elem_1843_2: (a: number, b: number, c: number) => void;
|
|
380
420
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
381
421
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
382
422
|
readonly __wbindgen_export3: (a: number) => void;
|
package/vsc_wasm.js
CHANGED
|
@@ -309,6 +309,40 @@ export class WasmViewScriptEngine {
|
|
|
309
309
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Register a font for text rendering.
|
|
314
|
+
*
|
|
315
|
+
* The font binary is stored in the engine's font cache. When adding
|
|
316
|
+
* a Text component, the font_family parameter is used to look up the font.
|
|
317
|
+
*
|
|
318
|
+
* # Arguments
|
|
319
|
+
*
|
|
320
|
+
* * `family` - Font family name (e.g., "Inter", "Roboto")
|
|
321
|
+
* * `font_bytes` - Raw font file bytes (TTF, OTF, or TTC)
|
|
322
|
+
*
|
|
323
|
+
* # Returns
|
|
324
|
+
*
|
|
325
|
+
* `Ok(())` if the font was registered successfully, `Err` if parsing failed.
|
|
326
|
+
* @param {string} family
|
|
327
|
+
* @param {Uint8Array} font_bytes
|
|
328
|
+
*/
|
|
329
|
+
register_font(family, font_bytes) {
|
|
330
|
+
try {
|
|
331
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
332
|
+
const ptr0 = passStringToWasm0(family, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
333
|
+
const len0 = WASM_VECTOR_LEN;
|
|
334
|
+
const ptr1 = passArray8ToWasm0(font_bytes, wasm.__wbindgen_export);
|
|
335
|
+
const len1 = WASM_VECTOR_LEN;
|
|
336
|
+
wasm.wasmviewscriptengine_register_font(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
337
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
338
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
339
|
+
if (r1) {
|
|
340
|
+
throw takeObject(r0);
|
|
341
|
+
}
|
|
342
|
+
} finally {
|
|
343
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
312
346
|
/**
|
|
313
347
|
* Register a static image texture.
|
|
314
348
|
*
|
|
@@ -490,6 +524,44 @@ export class WasmViewScriptEngine {
|
|
|
490
524
|
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
491
525
|
}
|
|
492
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* Update text content for an existing text entity.
|
|
529
|
+
*
|
|
530
|
+
* Re-expands the text to paths and updates the stored data.
|
|
531
|
+
* Removes old glyph PathEntityEntries and registers new ones.
|
|
532
|
+
*
|
|
533
|
+
* # Arguments
|
|
534
|
+
*
|
|
535
|
+
* * `entity_id` - The text entity ID returned by `add_component('Text', ...)`
|
|
536
|
+
* * `content` - The new text content to display
|
|
537
|
+
*
|
|
538
|
+
* # Example
|
|
539
|
+
*
|
|
540
|
+
* ```javascript
|
|
541
|
+
* const labelId = engine.add_component('Text', JSON.stringify({
|
|
542
|
+
* x: 100, y: 100, content: '0', font_family: 'Inter', font_size: 48
|
|
543
|
+
* }));
|
|
544
|
+
* // Later, update the content:
|
|
545
|
+
* engine.update_text_content(labelId, '42');
|
|
546
|
+
* ```
|
|
547
|
+
* @param {bigint} entity_id
|
|
548
|
+
* @param {string} content
|
|
549
|
+
*/
|
|
550
|
+
update_text_content(entity_id, content) {
|
|
551
|
+
try {
|
|
552
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
553
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
555
|
+
wasm.wasmviewscriptengine_update_text_content(retptr, this.__wbg_ptr, entity_id, ptr0, len0);
|
|
556
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
557
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
558
|
+
if (r1) {
|
|
559
|
+
throw takeObject(r0);
|
|
560
|
+
}
|
|
561
|
+
} finally {
|
|
562
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
493
565
|
/**
|
|
494
566
|
* Update texture pixel data.
|
|
495
567
|
*
|
|
@@ -1118,7 +1190,7 @@ function __wbg_get_imports() {
|
|
|
1118
1190
|
const a = state0.a;
|
|
1119
1191
|
state0.a = 0;
|
|
1120
1192
|
try {
|
|
1121
|
-
return
|
|
1193
|
+
return __wasm_bindgen_func_elem_3740(a, state0.b, arg0, arg1);
|
|
1122
1194
|
} finally {
|
|
1123
1195
|
state0.a = a;
|
|
1124
1196
|
}
|
|
@@ -1353,18 +1425,18 @@ function __wbg_get_imports() {
|
|
|
1353
1425
|
getObject(arg0).writeTexture(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
|
|
1354
1426
|
},
|
|
1355
1427
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1356
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1357
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1428
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 185, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1429
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1843);
|
|
1358
1430
|
return addHeapObject(ret);
|
|
1359
1431
|
},
|
|
1360
1432
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1361
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1362
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1433
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 407, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1434
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3718);
|
|
1363
1435
|
return addHeapObject(ret);
|
|
1364
1436
|
},
|
|
1365
1437
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1366
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1367
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1438
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 185, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1439
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1843_2);
|
|
1368
1440
|
return addHeapObject(ret);
|
|
1369
1441
|
},
|
|
1370
1442
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -1396,18 +1468,18 @@ function __wbg_get_imports() {
|
|
|
1396
1468
|
};
|
|
1397
1469
|
}
|
|
1398
1470
|
|
|
1399
|
-
function
|
|
1400
|
-
wasm.
|
|
1471
|
+
function __wasm_bindgen_func_elem_1843(arg0, arg1, arg2) {
|
|
1472
|
+
wasm.__wasm_bindgen_func_elem_1843(arg0, arg1, addHeapObject(arg2));
|
|
1401
1473
|
}
|
|
1402
1474
|
|
|
1403
|
-
function
|
|
1404
|
-
wasm.
|
|
1475
|
+
function __wasm_bindgen_func_elem_1843_2(arg0, arg1, arg2) {
|
|
1476
|
+
wasm.__wasm_bindgen_func_elem_1843_2(arg0, arg1, addHeapObject(arg2));
|
|
1405
1477
|
}
|
|
1406
1478
|
|
|
1407
|
-
function
|
|
1479
|
+
function __wasm_bindgen_func_elem_3718(arg0, arg1, arg2) {
|
|
1408
1480
|
try {
|
|
1409
1481
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1410
|
-
wasm.
|
|
1482
|
+
wasm.__wasm_bindgen_func_elem_3718(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1411
1483
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1412
1484
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1413
1485
|
if (r1) {
|
|
@@ -1418,8 +1490,8 @@ function __wasm_bindgen_func_elem_3646(arg0, arg1, arg2) {
|
|
|
1418
1490
|
}
|
|
1419
1491
|
}
|
|
1420
1492
|
|
|
1421
|
-
function
|
|
1422
|
-
wasm.
|
|
1493
|
+
function __wasm_bindgen_func_elem_3740(arg0, arg1, arg2, arg3) {
|
|
1494
|
+
wasm.__wasm_bindgen_func_elem_3740(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1423
1495
|
}
|
|
1424
1496
|
|
|
1425
1497
|
|
package/vsc_wasm_bg.wasm
CHANGED
|
Binary file
|