@francisdb/vpin-wasm 0.30.0 → 0.31.1

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 CHANGED
@@ -62,6 +62,30 @@ const vpxBytes = assemble(files, (message) => {
62
62
 
63
63
  **Returns:** `Uint8Array` - VPX file bytes
64
64
 
65
+ ### audit(files, callback?)
66
+
67
+ Checks the expanded table files for consistency problems: references to
68
+ images, materials, surfaces or collection items that do not exist, duplicate
69
+ or over-long names, and storage suggestions. The checks themselves run in a
70
+ few milliseconds even on very large tables, so it is fine to call this after
71
+ every change; the cost is dominated by reading the files into a table.
72
+
73
+ ```typescript
74
+ const findings = audit(files);
75
+ for (const finding of findings) {
76
+ console.log(`${finding.severity}: ${finding.message}`);
77
+ }
78
+ // warning: Light "L18": placed on missing surface "!l68"
79
+ // suggestion: image "chrome" is stored as a bitmap, consider converting to webp
80
+ ```
81
+
82
+ **Parameters:**
83
+
84
+ - `files: VpxFileMap` (`Record<string, Uint8Array>`) - file paths to contents
85
+ - `callback?: (message: string) => void` - Optional progress callback
86
+
87
+ **Returns:** `{severity: "warning" | "suggestion", message: string}[]` - empty when the table is clean
88
+
65
89
  ### export_glb(files, options?, callback?)
66
90
 
67
91
  Exports a whole table to a GLB (binary glTF 2.0) file. Takes the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@francisdb/vpin-wasm",
3
- "version": "0.30.0",
3
+ "version": "0.31.1",
4
4
  "description": "WASM bindings for vpin, a rust library for the visual/virtual pinball ecosystem.",
5
5
  "homepage": "https://github.com/francisdb/vpin",
6
6
  "bugs": {
package/vpin.d.ts CHANGED
@@ -8,6 +8,20 @@
8
8
  */
9
9
  export type VpxFileMap = Record<string, Uint8Array>;
10
10
 
11
+ /**
12
+ * Progress callback: receives a human readable status message while a
13
+ * long running operation works through a table.
14
+ */
15
+ export type ProgressCallback = (message: string) => void;
16
+
17
+ /**
18
+ * One table consistency finding reported by `audit`.
19
+ */
20
+ export type AuditFinding = {
21
+ severity: "error" | "warning" | "suggestion";
22
+ message: string;
23
+ };
24
+
11
25
 
12
26
 
13
27
  /**
@@ -221,7 +235,15 @@ export class PrimitiveMesh {
221
235
  readonly texCoords: Float32Array;
222
236
  }
223
237
 
224
- export function assemble(files: VpxFileMap, callback?: Function | null): Uint8Array;
238
+ export function assemble(files: VpxFileMap, callback?: ProgressCallback | null): Uint8Array;
239
+
240
+ /**
241
+ * Checks the expanded table files for consistency problems: references to
242
+ * images, materials, surfaces or collection items that do not exist,
243
+ * duplicate or over-long names, and storage suggestions. Returns an array
244
+ * of `{severity, message}` objects, empty when the table is clean.
245
+ */
246
+ export function audit(files: VpxFileMap, callback?: ProgressCallback | null): AuditFinding[];
225
247
 
226
248
  /**
227
249
  * Export a whole table to a GLB (binary glTF 2.0) file.
@@ -242,7 +264,7 @@ export function assemble(files: VpxFileMap, callback?: Function | null): Uint8Ar
242
264
  * memory down on sound-heavy tables. Passing a map without them works
243
265
  * too.
244
266
  */
245
- export function export_glb(files: VpxFileMap, options?: GlbExportOptions | null, callback?: Function | null): Uint8Array;
267
+ export function export_glb(files: VpxFileMap, options?: GlbExportOptions | null, callback?: ProgressCallback | null): Uint8Array;
246
268
 
247
269
  /**
248
270
  * Export a whole table as a Wavefront OBJ with its MTL and, by
@@ -252,9 +274,9 @@ export function export_glb(files: VpxFileMap, options?: GlbExportOptions | null,
252
274
  *
253
275
  * Sound entries are ignored like in `export_glb`.
254
276
  */
255
- export function export_obj(files: VpxFileMap, options?: ObjExportOptions | null, callback?: Function | null): ObjExportFileMap;
277
+ export function export_obj(files: VpxFileMap, options?: ObjExportOptions | null, callback?: ProgressCallback | null): ObjExportFileMap;
256
278
 
257
- export function extract(data: Uint8Array, callback?: Function | null): VpxFileMap;
279
+ export function extract(data: Uint8Array, callback?: ProgressCallback | null): VpxFileMap;
258
280
 
259
281
  /**
260
282
  * Generate the procedural mesh used by vpinball primitives that
@@ -371,10 +393,12 @@ export interface InitOutput {
371
393
  readonly memory: WebAssembly.Memory;
372
394
  readonly __wbg_primitivemesh_free: (a: number, b: number) => void;
373
395
  readonly assemble: (a: any, b: number) => [number, number, number, number];
396
+ readonly audit: (a: any, b: number) => [number, number, number];
374
397
  readonly export_glb: (a: any, b: number, c: number) => [number, number, number, number];
375
398
  readonly export_obj: (a: any, b: number, c: number) => [number, number, number];
376
399
  readonly extract: (a: number, b: number, c: number) => [number, number, number];
377
400
  readonly generate_builtin_primitive: (a: number, b: number) => [number, number, number];
401
+ readonly init: () => void;
378
402
  readonly mesh_to_glb: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
379
403
  readonly mesh_to_obj: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
380
404
  readonly obj_to_mesh: (a: number, b: number, c: number) => [number, number, number];
@@ -384,7 +408,6 @@ export interface InitOutput {
384
408
  readonly primitivemesh_normals: (a: number) => any;
385
409
  readonly primitivemesh_positions: (a: number) => any;
386
410
  readonly primitivemesh_texCoords: (a: number) => any;
387
- readonly init: () => void;
388
411
  readonly __wbindgen_malloc: (a: number, b: number) => number;
389
412
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
390
413
  readonly __wbindgen_exn_store: (a: number) => void;
package/vpin.js CHANGED
@@ -177,7 +177,7 @@ if (Symbol.dispose) PrimitiveMesh.prototype[Symbol.dispose] = PrimitiveMesh.prot
177
177
 
178
178
  /**
179
179
  * @param {VpxFileMap} files
180
- * @param {Function | null} [callback]
180
+ * @param {ProgressCallback | null} [callback]
181
181
  * @returns {Uint8Array}
182
182
  */
183
183
  export function assemble(files, callback) {
@@ -190,6 +190,23 @@ export function assemble(files, callback) {
190
190
  return v1;
191
191
  }
192
192
 
193
+ /**
194
+ * Checks the expanded table files for consistency problems: references to
195
+ * images, materials, surfaces or collection items that do not exist,
196
+ * duplicate or over-long names, and storage suggestions. Returns an array
197
+ * of `{severity, message}` objects, empty when the table is clean.
198
+ * @param {VpxFileMap} files
199
+ * @param {ProgressCallback | null} [callback]
200
+ * @returns {AuditFinding[]}
201
+ */
202
+ export function audit(files, callback) {
203
+ const ret = wasm.audit(files, isLikeNone(callback) ? 0 : addToExternrefTable0(callback));
204
+ if (ret[2]) {
205
+ throw takeFromExternrefTable0(ret[1]);
206
+ }
207
+ return takeFromExternrefTable0(ret[0]);
208
+ }
209
+
193
210
  /**
194
211
  * Export a whole table to a GLB (binary glTF 2.0) file.
195
212
  *
@@ -210,7 +227,7 @@ export function assemble(files, callback) {
210
227
  * too.
211
228
  * @param {VpxFileMap} files
212
229
  * @param {GlbExportOptions | null} [options]
213
- * @param {Function | null} [callback]
230
+ * @param {ProgressCallback | null} [callback]
214
231
  * @returns {Uint8Array}
215
232
  */
216
233
  export function export_glb(files, options, callback) {
@@ -232,7 +249,7 @@ export function export_glb(files, options, callback) {
232
249
  * Sound entries are ignored like in `export_glb`.
233
250
  * @param {VpxFileMap} files
234
251
  * @param {ObjExportOptions | null} [options]
235
- * @param {Function | null} [callback]
252
+ * @param {ProgressCallback | null} [callback]
236
253
  * @returns {ObjExportFileMap}
237
254
  */
238
255
  export function export_obj(files, options, callback) {
@@ -245,7 +262,7 @@ export function export_obj(files, options, callback) {
245
262
 
246
263
  /**
247
264
  * @param {Uint8Array} data
248
- * @param {Function | null} [callback]
265
+ * @param {ProgressCallback | null} [callback]
249
266
  * @returns {VpxFileMap}
250
267
  */
251
268
  export function extract(data, callback) {
@@ -441,11 +458,11 @@ export function obj_to_mesh(data, options) {
441
458
  function __wbg_get_imports() {
442
459
  const import0 = {
443
460
  __proto__: null,
444
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
461
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
445
462
  const ret = Error(getStringFromWasm0(arg0, arg1));
446
463
  return ret;
447
464
  },
448
- __wbg_Number_3890faa6d3ff057d: function(arg0) {
465
+ __wbg_Number_c54e7112a3fa7e3e: function(arg0) {
449
466
  const ret = Number(arg0);
450
467
  return ret;
451
468
  },
@@ -456,46 +473,46 @@ function __wbg_get_imports() {
456
473
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
457
474
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
458
475
  },
459
- __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
476
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
460
477
  const v = arg0;
461
478
  const ret = typeof(v) === 'boolean' ? v : undefined;
462
479
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
463
480
  },
464
- __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
481
+ __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
465
482
  const ret = debugString(arg1);
466
483
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
467
484
  const len1 = WASM_VECTOR_LEN;
468
485
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
469
486
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
470
487
  },
471
- __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
488
+ __wbg___wbindgen_in_50072d4d6e45c193: function(arg0, arg1) {
472
489
  const ret = arg0 in arg1;
473
490
  return ret;
474
491
  },
475
- __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
492
+ __wbg___wbindgen_is_null_5160b3e381865372: function(arg0) {
476
493
  const ret = arg0 === null;
477
494
  return ret;
478
495
  },
479
- __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
496
+ __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
480
497
  const val = arg0;
481
498
  const ret = typeof(val) === 'object' && val !== null;
482
499
  return ret;
483
500
  },
484
- __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
501
+ __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
485
502
  const ret = arg0 === undefined;
486
503
  return ret;
487
504
  },
488
- __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
505
+ __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd: function(arg0, arg1) {
489
506
  const ret = arg0 == arg1;
490
507
  return ret;
491
508
  },
492
- __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
509
+ __wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
493
510
  const obj = arg1;
494
511
  const ret = typeof(obj) === 'number' ? obj : undefined;
495
512
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
496
513
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
497
514
  },
498
- __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
515
+ __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
499
516
  const obj = arg1;
500
517
  const ret = typeof(obj) === 'string' ? obj : undefined;
501
518
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -503,10 +520,10 @@ function __wbg_get_imports() {
503
520
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
504
521
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
505
522
  },
506
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
523
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
507
524
  throw new Error(getStringFromWasm0(arg0, arg1));
508
525
  },
509
- __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
526
+ __wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
510
527
  const ret = arg0.call(arg1, arg2);
511
528
  return ret;
512
529
  }, arguments); },
@@ -521,11 +538,11 @@ function __wbg_get_imports() {
521
538
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
522
539
  }
523
540
  },
524
- __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
541
+ __wbg_get_989d0a1309644f2b: function() { return handleError(function (arg0, arg1) {
525
542
  const ret = Reflect.get(arg0, arg1);
526
543
  return ret;
527
544
  }, arguments); },
528
- __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
545
+ __wbg_get_b1f0ab13c737f856: function(arg0, arg1) {
529
546
  const ret = arg0[arg1 >>> 0];
530
547
  return ret;
531
548
  },
@@ -533,7 +550,7 @@ function __wbg_get_imports() {
533
550
  const ret = arg0[arg1];
534
551
  return ret;
535
552
  },
536
- __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
553
+ __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
537
554
  let result;
538
555
  try {
539
556
  result = arg0 instanceof ArrayBuffer;
@@ -543,7 +560,7 @@ function __wbg_get_imports() {
543
560
  const ret = result;
544
561
  return ret;
545
562
  },
546
- __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
563
+ __wbg_instanceof_Uint8Array_598adc0fef426aa8: function(arg0) {
547
564
  let result;
548
565
  try {
549
566
  result = arg0 instanceof Uint8Array;
@@ -553,54 +570,64 @@ function __wbg_get_imports() {
553
570
  const ret = result;
554
571
  return ret;
555
572
  },
556
- __wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
573
+ __wbg_isSafeInteger_8f51c743827d1ec5: function(arg0) {
557
574
  const ret = Number.isSafeInteger(arg0);
558
575
  return ret;
559
576
  },
560
- __wbg_keys_ec7f8c0c2370d91d: function(arg0) {
577
+ __wbg_keys_6efc298980178da1: function(arg0) {
561
578
  const ret = Object.keys(arg0);
562
579
  return ret;
563
580
  },
564
- __wbg_length_36bd29c6848c2144: function(arg0) {
581
+ __wbg_length_31bdaf014f5fbde2: function(arg0) {
565
582
  const ret = arg0.length;
566
583
  return ret;
567
584
  },
568
- __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
585
+ __wbg_length_4e1adc0d42e23620: function(arg0) {
569
586
  const ret = arg0.length;
570
587
  return ret;
571
588
  },
572
- __wbg_new_227d7c05414eb861: function() {
573
- const ret = new Error();
589
+ __wbg_new_1da3429bc3c4541c: function(arg0) {
590
+ const ret = new Uint8Array(arg0);
574
591
  return ret;
575
592
  },
576
- __wbg_new_77cc4f4f472aeb81: function(arg0) {
577
- const ret = new Uint8Array(arg0);
593
+ __wbg_new_227d7c05414eb861: function() {
594
+ const ret = new Error();
578
595
  return ret;
579
596
  },
580
- __wbg_new_ebe3e0f6837f0879: function() {
597
+ __wbg_new_bebc3f4757acf305: function() {
581
598
  const ret = new Object();
582
599
  return ret;
583
600
  },
584
- __wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
585
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
601
+ __wbg_new_ffa92086ea89f79c: function() {
602
+ const ret = new Array();
586
603
  return ret;
587
604
  },
588
- __wbg_new_from_slice_709ab7061ebcc5da: function(arg0, arg1) {
605
+ __wbg_new_from_slice_2221cabb71753908: function(arg0, arg1) {
589
606
  const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
590
607
  return ret;
591
608
  },
592
- __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
609
+ __wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
610
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
611
+ return ret;
612
+ },
613
+ __wbg_new_from_slice_a500ec81601be48f: function(arg0, arg1) {
593
614
  const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
594
615
  return ret;
595
616
  },
596
- __wbg_now_8b265300afd5f2b9: function() {
617
+ __wbg_now_d1fb6650485d7f3e: function() {
597
618
  const ret = Date.now();
598
619
  return ret;
599
620
  },
600
- __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
621
+ __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
601
622
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
602
623
  },
603
- __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
624
+ __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
625
+ arg0[arg1 >>> 0] = arg2;
626
+ },
627
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
628
+ arg0[arg1] = arg2;
629
+ },
630
+ __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
604
631
  const ret = Reflect.set(arg0, arg1, arg2);
605
632
  return ret;
606
633
  }, arguments); },
@@ -611,7 +638,7 @@ function __wbg_get_imports() {
611
638
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
612
639
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
613
640
  },
614
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
641
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
615
642
  // Cast intrinsic for `Ref(String) -> Externref`.
616
643
  const ret = getStringFromWasm0(arg0, arg1);
617
644
  return ret;
package/vpin_bg.wasm CHANGED
Binary file
package/vpin_bg.wasm.d.ts CHANGED
@@ -3,10 +3,12 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_primitivemesh_free: (a: number, b: number) => void;
5
5
  export const assemble: (a: any, b: number) => [number, number, number, number];
6
+ export const audit: (a: any, b: number) => [number, number, number];
6
7
  export const export_glb: (a: any, b: number, c: number) => [number, number, number, number];
7
8
  export const export_obj: (a: any, b: number, c: number) => [number, number, number];
8
9
  export const extract: (a: number, b: number, c: number) => [number, number, number];
9
10
  export const generate_builtin_primitive: (a: number, b: number) => [number, number, number];
11
+ export const init: () => void;
10
12
  export const mesh_to_glb: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
11
13
  export const mesh_to_obj: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
12
14
  export const obj_to_mesh: (a: number, b: number, c: number) => [number, number, number];
@@ -16,7 +18,6 @@ export const primitivemesh_name: (a: number) => [number, number];
16
18
  export const primitivemesh_normals: (a: number) => any;
17
19
  export const primitivemesh_positions: (a: number) => any;
18
20
  export const primitivemesh_texCoords: (a: number) => any;
19
- export const init: () => void;
20
21
  export const __wbindgen_malloc: (a: number, b: number) => number;
21
22
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
22
23
  export const __wbindgen_exn_store: (a: number) => void;