@pencil-lang/figure 0.0.2 → 0.0.3

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/pkg/pencil_web.js CHANGED
@@ -133,6 +133,14 @@ export class Player {
133
133
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
134
134
  return v1;
135
135
  }
136
+ /**
137
+ * This player's number, for `let_go`.
138
+ * @returns {number}
139
+ */
140
+ get id() {
141
+ const ret = wasm.player_id(this.__wbg_ptr);
142
+ return ret >>> 0;
143
+ }
136
144
  /**
137
145
  * The figure's params and duration, as JSON. `timeDriven` names the bindings whose values
138
146
  * change with time, so a page knows whether stepping one seeks time or sets it, and
@@ -194,6 +202,22 @@ export class Player {
194
202
  throw takeFromExternrefTable0(ret[0]);
195
203
  }
196
204
  }
205
+ /**
206
+ * Destroys the GPU device, as a browser does when it loses it (after sleep, or when its GPU
207
+ * process restarts), for testing what a figure does then. On WebGL2 a page loses the
208
+ * context instead, through `WEBGL_lose_context`.
209
+ */
210
+ lose_device() {
211
+ wasm.player_lose_device(this.__wbg_ptr);
212
+ }
213
+ /**
214
+ * Whether the GPU device is lost.
215
+ * @returns {boolean}
216
+ */
217
+ get lost() {
218
+ const ret = wasm.player_lost(this.__wbg_ptr);
219
+ return ret !== 0;
220
+ }
197
221
  /**
198
222
  * Moves a handle by this many device pixels from where it is, through its inverse, as an
199
223
  * arrow key does. Returns the param it set, if the handle's mark exists this frame.
@@ -215,6 +239,14 @@ export class Player {
215
239
  }
216
240
  return v1;
217
241
  }
242
+ /**
243
+ * Calls `callback(message)` once the GPU device is lost, so a page can start the figure again
244
+ * on a new one at once, without waiting for a frame to fail.
245
+ * @param {Function} callback
246
+ */
247
+ on_lost(callback) {
248
+ wasm.player_on_lost(this.__wbg_ptr, callback);
249
+ }
218
250
  /**
219
251
  * Computes the CPU side of a frame without drawing, to measure that cost. Returns
220
252
  * the number of stroke segments.
@@ -312,6 +344,13 @@ export class Player {
312
344
  }
313
345
  return ret[0];
314
346
  }
347
+ /**
348
+ * Panics, which traps in WASM as a panic inside wgpu would, leaving this player unusable,
349
+ * for testing that a page gets past one.
350
+ */
351
+ trap() {
352
+ wasm.player_trap(this.__wbg_ptr);
353
+ }
315
354
  /**
316
355
  * A binding's value this frame, or NaN if it doesn't exist this frame.
317
356
  * @param {string} name
@@ -506,6 +545,16 @@ export function is_latex(text) {
506
545
  return ret !== 0;
507
546
  }
508
547
 
548
+ /**
549
+ * Lets go of a player's GPU device by its number (`Player.id`), and forgets what it was to say
550
+ * when that's lost. For a player that can't be used any more, after a trap: its device would
551
+ * otherwise live on, and the page's callback with it.
552
+ * @param {number} id
553
+ */
554
+ export function let_go(id) {
555
+ wasm.let_go(id);
556
+ }
557
+
509
558
  /**
510
559
  * The colors these sheets name, as a JSON object of CSS colors, so a page can match the figure
511
560
  * it holds without its own copy of the palette.
@@ -1092,6 +1141,10 @@ function __wbg_get_imports() {
1092
1141
  __wbg_end_b57473834b877409: function(arg0) {
1093
1142
  arg0.end();
1094
1143
  },
1144
+ __wbg_error_4e2c22b7e3952509: function(arg0) {
1145
+ const ret = arg0.error;
1146
+ return ret;
1147
+ },
1095
1148
  __wbg_error_757e9472f8410341: function(arg0, arg1) {
1096
1149
  let deferred0_0;
1097
1150
  let deferred0_1;
@@ -1298,6 +1351,26 @@ function __wbg_get_imports() {
1298
1351
  const ret = arg0.info;
1299
1352
  return ret;
1300
1353
  },
1354
+ __wbg_instanceof_GpuOutOfMemoryError_7126123117d274a4: function(arg0) {
1355
+ let result;
1356
+ try {
1357
+ result = arg0 instanceof GPUOutOfMemoryError;
1358
+ } catch (_) {
1359
+ result = false;
1360
+ }
1361
+ const ret = result;
1362
+ return ret;
1363
+ },
1364
+ __wbg_instanceof_GpuValidationError_f18d09609dc737d7: function(arg0) {
1365
+ let result;
1366
+ try {
1367
+ result = arg0 instanceof GPUValidationError;
1368
+ } catch (_) {
1369
+ result = false;
1370
+ }
1371
+ const ret = result;
1372
+ return ret;
1373
+ },
1301
1374
  __wbg_instanceof_HtmlCanvasElement_89f280683e987b9e: function(arg0) {
1302
1375
  let result;
1303
1376
  try {
@@ -1346,10 +1419,6 @@ function __wbg_get_imports() {
1346
1419
  getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
1347
1420
  getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
1348
1421
  },
1349
- __wbg_length_186163212ffe79c3: function(arg0) {
1350
- const ret = arg0.length;
1351
- return ret;
1352
- },
1353
1422
  __wbg_length_b03a0fabb109b1e9: function(arg0) {
1354
1423
  const ret = arg0.length;
1355
1424
  return ret;
@@ -1368,6 +1437,10 @@ function __wbg_get_imports() {
1368
1437
  __wbg_linkProgram_dee7cda98bacb12f: function(arg0, arg1) {
1369
1438
  arg0.linkProgram(arg1);
1370
1439
  },
1440
+ __wbg_lost_25273dba897db03c: function(arg0) {
1441
+ const ret = arg0.lost;
1442
+ return ret;
1443
+ },
1371
1444
  __wbg_mapAsync_b0597127f5037286: function(arg0, arg1, arg2, arg3) {
1372
1445
  const ret = arg0.mapAsync(arg1 >>> 0, arg2, arg3);
1373
1446
  return ret;
@@ -1496,6 +1569,20 @@ function __wbg_get_imports() {
1496
1569
  const ret = arg0.maxVertexBuffers;
1497
1570
  return ret;
1498
1571
  },
1572
+ __wbg_message_408f555d03641e84: function(arg0, arg1) {
1573
+ const ret = arg1.message;
1574
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1575
+ const len1 = WASM_VECTOR_LEN;
1576
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
1577
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
1578
+ },
1579
+ __wbg_message_5223ba7df7256eac: function(arg0, arg1) {
1580
+ const ret = arg1.message;
1581
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1582
+ const len1 = WASM_VECTOR_LEN;
1583
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
1584
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
1585
+ },
1499
1586
  __wbg_minStorageBufferOffsetAlignment_529f1f52e61188fc: function(arg0) {
1500
1587
  const ret = arg0.minStorageBufferOffsetAlignment;
1501
1588
  return ret;
@@ -1582,9 +1669,6 @@ function __wbg_get_imports() {
1582
1669
  __wbg_polygonOffset_acf166e60739dbfa: function(arg0, arg1, arg2) {
1583
1670
  arg0.polygonOffset(arg1, arg2);
1584
1671
  },
1585
- __wbg_prototypesetcall_13162965d1fe7aa3: function(arg0, arg1, arg2) {
1586
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1587
- },
1588
1672
  __wbg_push_c9f4893fc209f768: function(arg0, arg1) {
1589
1673
  const ret = arg0.push(arg1);
1590
1674
  return ret;
@@ -1623,6 +1707,10 @@ function __wbg_get_imports() {
1623
1707
  __wbg_readPixels_7c7b54a733248182: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
1624
1708
  arg0.readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7);
1625
1709
  }, arguments); },
1710
+ __wbg_reason_53e762e714b67b72: function(arg0) {
1711
+ const ret = arg0.reason;
1712
+ return (__wbindgen_enum_GpuDeviceLostReason.indexOf(ret) + 1 || 3) - 1;
1713
+ },
1626
1714
  __wbg_renderbufferStorageMultisample_d5b01825cc08514b: function(arg0, arg1, arg2, arg3, arg4, arg5) {
1627
1715
  arg0.renderbufferStorageMultisample(arg1 >>> 0, arg2, arg3 >>> 0, arg4, arg5);
1628
1716
  },
@@ -1681,9 +1769,6 @@ function __wbg_get_imports() {
1681
1769
  __wbg_setViewport_c0be08dcc8965ccf: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1682
1770
  arg0.setViewport(arg1, arg2, arg3, arg4, arg5, arg6);
1683
1771
  },
1684
- __wbg_set_118fefd528ab0a79: function(arg0, arg1, arg2) {
1685
- arg0.set(arg1, arg2 >>> 0);
1686
- },
1687
1772
  __wbg_set_2793479888329cb6: function() { return handleError(function (arg0, arg1, arg2) {
1688
1773
  const ret = Reflect.set(arg0, arg1, arg2);
1689
1774
  return ret;
@@ -1979,6 +2064,9 @@ function __wbg_get_imports() {
1979
2064
  __wbg_set_offset_f64_9374d9e912985773: function(arg0, arg1) {
1980
2065
  arg0.offset = arg1;
1981
2066
  },
2067
+ __wbg_set_onuncapturederror_19ad0d0daa325d10: function(arg0, arg1) {
2068
+ arg0.onuncapturederror = arg1;
2069
+ },
1982
2070
  __wbg_set_operation_e103287df7ac9cf6: function(arg0, arg1) {
1983
2071
  arg0.operation = __wbindgen_enum_GpuBlendOperation[arg1];
1984
2072
  },
@@ -2301,6 +2389,10 @@ function __wbg_get_imports() {
2301
2389
  __wbg_texSubImage3D_ed8982daddcccd1e: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
2302
2390
  arg0.texSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 >>> 0, arg10 >>> 0, arg11);
2303
2391
  }, arguments); },
2392
+ __wbg_then_3a4f899454bcf8c9: function(arg0, arg1) {
2393
+ const ret = arg0.then(arg1);
2394
+ return ret;
2395
+ },
2304
2396
  __wbg_then_656f253a5dd7d8ea: function(arg0, arg1, arg2) {
2305
2397
  const ret = arg0.then(arg1, arg2);
2306
2398
  return ret;
@@ -2426,6 +2518,10 @@ function __wbg_get_imports() {
2426
2518
  __wbg_useProgram_f6341ea2eeea1e5a: function(arg0, arg1) {
2427
2519
  arg0.useProgram(arg1);
2428
2520
  },
2521
+ __wbg_valueOf_2ad4a09774ac959e: function(arg0) {
2522
+ const ret = arg0.valueOf();
2523
+ return ret;
2524
+ },
2429
2525
  __wbg_vertexAttribDivisorANGLE_5bec9a774ccd1cf8: function(arg0, arg1, arg2) {
2430
2526
  arg0.vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0);
2431
2527
  },
@@ -2458,66 +2554,76 @@ function __wbg_get_imports() {
2458
2554
  arg0.writeTexture(arg1, getArrayU8FromWasm0(arg2, arg3), arg4, arg5);
2459
2555
  }, arguments); },
2460
2556
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
2461
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2585, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2557
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2617, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2462
2558
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd4acdde59c21f30c);
2463
2559
  return ret;
2464
2560
  },
2465
2561
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
2466
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 342, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2562
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 369, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2467
2563
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab);
2468
2564
  return ret;
2469
2565
  },
2470
2566
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
2471
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 342, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2472
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_35);
2567
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 385, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2568
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086);
2473
2569
  return ret;
2474
2570
  },
2475
2571
  __wbindgen_generic_0000000000000004: function(arg0, arg1) {
2476
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 342, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2477
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_36);
2572
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 385, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2573
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086_42);
2478
2574
  return ret;
2479
2575
  },
2480
- __wbindgen_generic_0000000000000005: function(arg0) {
2576
+ __wbindgen_generic_0000000000000005: function(arg0, arg1) {
2577
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 369, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2578
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_43);
2579
+ return ret;
2580
+ },
2581
+ __wbindgen_generic_0000000000000006: function(arg0, arg1) {
2582
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 369, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2583
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_44);
2584
+ return ret;
2585
+ },
2586
+ __wbindgen_generic_0000000000000007: function(arg0) {
2481
2587
  // Cast intrinsic for `F64 -> Externref`.
2482
2588
  const ret = arg0;
2483
2589
  return ret;
2484
2590
  },
2485
- __wbindgen_generic_0000000000000006: function(arg0, arg1) {
2591
+ __wbindgen_generic_0000000000000008: function(arg0, arg1) {
2486
2592
  // Cast intrinsic for `Ref(Slice(F32)) -> NamedExternref("Float32Array")`.
2487
2593
  const ret = getArrayF32FromWasm0(arg0, arg1);
2488
2594
  return ret;
2489
2595
  },
2490
- __wbindgen_generic_0000000000000007: function(arg0, arg1) {
2596
+ __wbindgen_generic_0000000000000009: function(arg0, arg1) {
2491
2597
  // Cast intrinsic for `Ref(Slice(I16)) -> NamedExternref("Int16Array")`.
2492
2598
  const ret = getArrayI16FromWasm0(arg0, arg1);
2493
2599
  return ret;
2494
2600
  },
2495
- __wbindgen_generic_0000000000000008: function(arg0, arg1) {
2601
+ __wbindgen_generic_000000000000000a: function(arg0, arg1) {
2496
2602
  // Cast intrinsic for `Ref(Slice(I32)) -> NamedExternref("Int32Array")`.
2497
2603
  const ret = getArrayI32FromWasm0(arg0, arg1);
2498
2604
  return ret;
2499
2605
  },
2500
- __wbindgen_generic_0000000000000009: function(arg0, arg1) {
2606
+ __wbindgen_generic_000000000000000b: function(arg0, arg1) {
2501
2607
  // Cast intrinsic for `Ref(Slice(I8)) -> NamedExternref("Int8Array")`.
2502
2608
  const ret = getArrayI8FromWasm0(arg0, arg1);
2503
2609
  return ret;
2504
2610
  },
2505
- __wbindgen_generic_000000000000000a: function(arg0, arg1) {
2611
+ __wbindgen_generic_000000000000000c: function(arg0, arg1) {
2506
2612
  // Cast intrinsic for `Ref(Slice(U16)) -> NamedExternref("Uint16Array")`.
2507
2613
  const ret = getArrayU16FromWasm0(arg0, arg1);
2508
2614
  return ret;
2509
2615
  },
2510
- __wbindgen_generic_000000000000000b: function(arg0, arg1) {
2616
+ __wbindgen_generic_000000000000000d: function(arg0, arg1) {
2511
2617
  // Cast intrinsic for `Ref(Slice(U32)) -> NamedExternref("Uint32Array")`.
2512
2618
  const ret = getArrayU32FromWasm0(arg0, arg1);
2513
2619
  return ret;
2514
2620
  },
2515
- __wbindgen_generic_000000000000000c: function(arg0, arg1) {
2621
+ __wbindgen_generic_000000000000000e: function(arg0, arg1) {
2516
2622
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2517
2623
  const ret = getArrayU8FromWasm0(arg0, arg1);
2518
2624
  return ret;
2519
2625
  },
2520
- __wbindgen_generic_000000000000000d: function(arg0, arg1) {
2626
+ __wbindgen_generic_000000000000000f: function(arg0, arg1) {
2521
2627
  // Cast intrinsic for `Ref(String) -> Externref`.
2522
2628
  const ret = getStringFromWasm0(arg0, arg1);
2523
2629
  return ret;
@@ -2537,6 +2643,14 @@ function __wbg_get_imports() {
2537
2643
  };
2538
2644
  }
2539
2645
 
2646
+ function wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086(arg0, arg1, arg2) {
2647
+ wasm.wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086(arg0, arg1, arg2);
2648
+ }
2649
+
2650
+ function wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086_42(arg0, arg1, arg2) {
2651
+ wasm.wasm_bindgen__convert__closures_____invoke__h0f29fc2faa2e5086_42(arg0, arg1, arg2);
2652
+ }
2653
+
2540
2654
  function wasm_bindgen__convert__closures_____invoke__hd4acdde59c21f30c(arg0, arg1, arg2) {
2541
2655
  const ret = wasm.wasm_bindgen__convert__closures_____invoke__hd4acdde59c21f30c(arg0, arg1, arg2);
2542
2656
  if (ret[1]) {
@@ -2551,15 +2665,15 @@ function wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab(arg0, arg
2551
2665
  }
2552
2666
  }
2553
2667
 
2554
- function wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_35(arg0, arg1, arg2) {
2555
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_35(arg0, arg1, arg2);
2668
+ function wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_43(arg0, arg1, arg2) {
2669
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_43(arg0, arg1, arg2);
2556
2670
  if (ret[1]) {
2557
2671
  throw takeFromExternrefTable0(ret[0]);
2558
2672
  }
2559
2673
  }
2560
2674
 
2561
- function wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_36(arg0, arg1, arg2) {
2562
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_36(arg0, arg1, arg2);
2675
+ function wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_44(arg0, arg1, arg2) {
2676
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0ac39b197b40bdab_44(arg0, arg1, arg2);
2563
2677
  if (ret[1]) {
2564
2678
  throw takeFromExternrefTable0(ret[0]);
2565
2679
  }
@@ -2594,6 +2708,9 @@ const __wbindgen_enum_GpuCompareFunction = ["never", "less", "equal", "less-equa
2594
2708
  const __wbindgen_enum_GpuCullMode = ["none", "front", "back"];
2595
2709
 
2596
2710
 
2711
+ const __wbindgen_enum_GpuDeviceLostReason = ["unknown", "destroyed"];
2712
+
2713
+
2597
2714
  const __wbindgen_enum_GpuFrontFace = ["ccw", "cw"];
2598
2715
 
2599
2716
 
Binary file