@scalable-vector-audio/sva-wasm 0.9.5 → 0.9.6

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
@@ -2,7 +2,7 @@
2
2
  "name": "@scalable-vector-audio/sva-wasm",
3
3
  "type": "module",
4
4
  "description": "JS bindings: a composition a page fills node by node, rendered in the browser",
5
- "version": "0.9.5",
5
+ "version": "0.9.6",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/sva_wasm.d.ts CHANGED
@@ -1,6 +1,74 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /** What one call did so far, or every call since `subscribe`. */
5
+ export interface EngineWork {
6
+ /** Samples of the target delivered. */
7
+ samples: number;
8
+ /** Samples computed meanwhile, summed over every value: 0 when all was read back. */
9
+ computed_samples: number;
10
+ /**
11
+ * Lookups by what each came to, the counts `Rendering.stats()` ends at. Cached: `hit`
12
+ * (`from_memory` + `from_store`) and `reused`. Uncached: `miss`, and `prefix` (found only in
13
+ * part). `new`: misses kept for the next call. A count may fall as a lookup settles.
14
+ */
15
+ lookups: {
16
+ hit: number; from_memory: number; from_store: number;
17
+ prefix: number; miss: number; new: number; reused: number;
18
+ };
19
+ /** Memory's disk traffic meanwhile, whichever call asked: `Rendering.stats().tier`. */
20
+ tier: {
21
+ disk_lookups: number; disk_reads: number; disk_read_bytes: number; promotions: number;
22
+ writebacks: number; hits: number; evictions: number;
23
+ probation_evictions: number; protected_evictions: number;
24
+ };
25
+ }
26
+
27
+ /** One call: a render, a stream from its open on, one stream edit, or a persist. */
28
+ export interface EngineCall extends EngineWork {
29
+ /** Counted from 1 over the composition, never given twice. */
30
+ id: number;
31
+ kind: "render" | "stream" | "edit" | "persist";
32
+ /** As the page wrote it; a persist's is empty. */
33
+ target: string;
34
+ /**
35
+ * Samples are delivered in `delivering` alone. `done`, `failed` and `abandoned` end the call:
36
+ * its last report.
37
+ */
38
+ phase: "parsing" | "typing" | "looking_up" | "planning" | "fetching" | "delivering"
39
+ | "finishing" | "storing" | "done" | "failed" | "abandoned";
40
+ /**
41
+ * What `samples` counts up to. null until the range is decided (before `delivering`), and
42
+ * for a stream whose end is open.
43
+ */
44
+ total_samples: number | null;
45
+ }
46
+
47
+ /**
48
+ * One report of `Composition.subscribe`. A call reports when it begins, at each new phase, per
49
+ * fetch from the store while `fetching`, while `delivering` at block boundaries no more than ten
50
+ * times per second of samples delivered, and when it ends. The callback runs inside the call, on the thread
51
+ * that made it, never on a render thread: a worker forwards each report with `postMessage`. A
52
+ * page on the engine's own thread hears every report as it is made, but paints nothing until the
53
+ * call yields to the event loop, which a render does between blocks only when given a `signal`
54
+ * or reading a store. What the callback throws is logged, and stops nothing.
55
+ */
56
+ export interface EngineStats {
57
+ /**
58
+ * "working" while a render, a stream's open, an edit or a persist is in flight. A stream's
59
+ * reads never count: what they report says "idle" unless such a call is in flight beside it.
60
+ */
61
+ state: "working" | "idle";
62
+ /** How many such calls are in flight. */
63
+ working: number;
64
+ /** The call this report is about; null in the one report `subscribe` answers with. */
65
+ call: EngineCall | null;
66
+ /** Every call's work since `subscribe`. */
67
+ totals: EngineWork;
68
+ }
69
+
70
+
71
+
4
72
  export class Composition {
5
73
  free(): void;
6
74
  [Symbol.dispose](): void;
@@ -33,6 +101,12 @@ export class Composition {
33
101
  * `threads` (as `open` takes it).
34
102
  */
35
103
  stream(target: string, block: number, options: any): Promise<Stream>;
104
+ /**
105
+ * `callback`, in place of the last one, hears an `EngineStats` at once, then from every
106
+ * render, stream, edit and persist of this composition while it works and when it ends.
107
+ */
108
+ subscribe(callback: (stats: EngineStats) => void): void;
109
+ unsubscribe(): void;
36
110
  readonly cache_bytes: number;
37
111
  readonly cache_entries: number;
38
112
  readonly cache_evictions: number;
@@ -164,6 +238,8 @@ export interface InitOutput {
164
238
  readonly composition_store_bytes: (a: number) => [number, number];
165
239
  readonly composition_store_max_bytes: (a: number) => [number, number];
166
240
  readonly composition_stream: (a: number, b: number, c: number, d: number, e: any) => any;
241
+ readonly composition_subscribe: (a: number, b: any) => void;
242
+ readonly composition_unsubscribe: (a: number) => void;
167
243
  readonly initThreadPool: (a: number) => any;
168
244
  readonly rendering_channels: (a: number) => number;
169
245
  readonly rendering_duration_secs: (a: number) => number;
package/sva_wasm.js CHANGED
@@ -157,6 +157,17 @@ export class Composition {
157
157
  const ret = wasm.composition_stream(this.__wbg_ptr, ptr0, len0, block, options);
158
158
  return ret;
159
159
  }
160
+ /**
161
+ * `callback`, in place of the last one, hears an `EngineStats` at once, then from every
162
+ * render, stream, edit and persist of this composition while it works and when it ends.
163
+ * @param {(stats: EngineStats) => void} callback
164
+ */
165
+ subscribe(callback) {
166
+ wasm.composition_subscribe(this.__wbg_ptr, callback);
167
+ }
168
+ unsubscribe() {
169
+ wasm.composition_unsubscribe(this.__wbg_ptr);
170
+ }
160
171
  }
161
172
  if (Symbol.dispose) Composition.prototype[Symbol.dispose] = Composition.prototype.free;
162
173
 
@@ -560,7 +571,7 @@ function __wbg_get_imports(memory) {
560
571
  __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
561
572
  arg0._wbg_cb_unref();
562
573
  },
563
- __wbg_arrayBuffer_840f6cee53783ab5: function(arg0) {
574
+ __wbg_arrayBuffer_ca727a2a5437ebb5: function(arg0) {
564
575
  const ret = arg0.arrayBuffer();
565
576
  return ret;
566
577
  },
@@ -580,18 +591,18 @@ function __wbg_get_imports(memory) {
580
591
  const ret = arg0.call(arg1, arg2);
581
592
  return ret;
582
593
  }, arguments); },
583
- __wbg_close_079e5dfd4d0b7025: function(arg0) {
594
+ __wbg_close_708ebf920f3ea7ca: function(arg0) {
584
595
  const ret = arg0.close();
585
596
  return ret;
586
597
  },
587
- __wbg_close_1fc7943048263f1c: function(arg0) {
598
+ __wbg_close_ed5e9b27b36b4a58: function(arg0) {
588
599
  arg0.close();
589
600
  },
590
601
  __wbg_composition_new: function(arg0) {
591
602
  const ret = Composition.__wrap(arg0);
592
603
  return ret;
593
604
  },
594
- __wbg_createWritable_eb49ae1a38a27748: function(arg0) {
605
+ __wbg_createWritable_bd0c7c16a78b0321: function(arg0) {
595
606
  const ret = arg0.createWritable();
596
607
  return ret;
597
608
  },
@@ -607,15 +618,15 @@ function __wbg_get_imports(memory) {
607
618
  const ret = Array.from(arg0);
608
619
  return ret;
609
620
  },
610
- __wbg_getDirectoryHandle_87163dd5ce083804: function(arg0, arg1, arg2, arg3) {
621
+ __wbg_getDirectoryHandle_4b86f3073ed463f1: function(arg0, arg1, arg2, arg3) {
611
622
  const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
612
623
  return ret;
613
624
  },
614
- __wbg_getFileHandle_e3bc25991894dffd: function(arg0, arg1, arg2, arg3) {
625
+ __wbg_getFileHandle_c30cbc45acfedaa7: function(arg0, arg1, arg2, arg3) {
615
626
  const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
616
627
  return ret;
617
628
  },
618
- __wbg_getFile_1d1e8ae322a0bcc1: function(arg0) {
629
+ __wbg_getFile_941a29388bde207f: function(arg0) {
619
630
  const ret = arg0.getFile();
620
631
  return ret;
621
632
  },
@@ -659,7 +670,7 @@ function __wbg_get_imports(memory) {
659
670
  const ret = Array.isArray(arg0);
660
671
  return ret;
661
672
  },
662
- __wbg_keys_86ce54571fde5fa1: function(arg0) {
673
+ __wbg_keys_89f211fd7be63aec: function(arg0) {
663
674
  const ret = arg0.keys();
664
675
  return ret;
665
676
  },
@@ -675,11 +686,11 @@ function __wbg_get_imports(memory) {
675
686
  const ret = arg0.length;
676
687
  return ret;
677
688
  },
678
- __wbg_move_d371e6c98198a836: function(arg0, arg1, arg2, arg3) {
689
+ __wbg_move_c9336b1e6b1b4197: function(arg0, arg1, arg2, arg3) {
679
690
  const ret = arg0.move(arg1, getStringFromWasm0(arg2, arg3));
680
691
  return ret;
681
692
  },
682
- __wbg_name_3949f1232649f0db: function(arg0, arg1) {
693
+ __wbg_name_58b92bcf5b65574b: function(arg0, arg1) {
683
694
  const ret = arg1.name;
684
695
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
685
696
  const len1 = WASM_VECTOR_LEN;
@@ -690,12 +701,16 @@ function __wbg_get_imports(memory) {
690
701
  const ret = new Int32Array(arg0);
691
702
  return ret;
692
703
  },
704
+ __wbg_new_19a2e1ad79ba0ef2: function() {
705
+ const ret = new MessageChannel();
706
+ return ret;
707
+ },
693
708
  __wbg_new_1da3429bc3c4541c: function(arg0) {
694
709
  const ret = new Uint8Array(arg0);
695
710
  return ret;
696
711
  },
697
- __wbg_new_48023d79e7a2e0f4: function() {
698
- const ret = new MessageChannel();
712
+ __wbg_new_44be9c56c1230128: function(arg0, arg1) {
713
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
699
714
  return ret;
700
715
  },
701
716
  __wbg_new_8f72ed7c652bf5a2: function(arg0, arg1) {
@@ -720,10 +735,6 @@ function __wbg_get_imports(memory) {
720
735
  const ret = new Object();
721
736
  return ret;
722
737
  },
723
- __wbg_new_c38fc43a35a11a41: function(arg0, arg1) {
724
- const ret = new Error(getStringFromWasm0(arg0, arg1));
725
- return ret;
726
- },
727
738
  __wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
728
739
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
729
740
  return ret;
@@ -750,7 +761,7 @@ function __wbg_get_imports(memory) {
750
761
  const ret = new Worker(getStringFromWasm0(arg0, arg1));
751
762
  return ret;
752
763
  },
753
- __wbg_next_ab692ce2d3f8c5b8: function(arg0) {
764
+ __wbg_next_5a7cb7819ee1bc88: function(arg0) {
754
765
  const ret = arg0.next();
755
766
  return ret;
756
767
  },
@@ -758,28 +769,28 @@ function __wbg_get_imports(memory) {
758
769
  const ret = Array.of(arg0, arg1, arg2);
759
770
  return ret;
760
771
  },
761
- __wbg_parse_23aa75de5140423d: function() { return handleError(function (arg0, arg1) {
772
+ __wbg_parse_3c17fe4e94eb39f5: function() { return handleError(function (arg0, arg1) {
762
773
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
763
774
  return ret;
764
775
  }, arguments); },
765
- __wbg_port1_24596868d987fde6: function(arg0) {
776
+ __wbg_port1_eac34109aa737b69: function(arg0) {
766
777
  const ret = arg0.port1;
767
778
  return ret;
768
779
  },
769
- __wbg_port2_4164d04bdc804b58: function(arg0) {
780
+ __wbg_port2_7e9c530d0b66d38b: function(arg0) {
770
781
  const ret = arg0.port2;
771
782
  return ret;
772
783
  },
773
784
  __wbg_postMessage_8105a302ed002474: function() { return handleError(function (arg0, arg1) {
774
785
  arg0.postMessage(arg1);
775
786
  }, arguments); },
776
- __wbg_postMessage_993ae22fc5c9c66c: function(arg0, arg1) {
787
+ __wbg_postMessage_f09ef855b53cb647: function(arg0, arg1) {
777
788
  arg0.postMessage(arg1);
778
789
  },
779
790
  __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
780
791
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
781
792
  },
782
- __wbg_query_7a0b50aa8d084f73: function(arg0) {
793
+ __wbg_query_f5697193f450c601: function(arg0) {
783
794
  const ret = arg0.query();
784
795
  return ret;
785
796
  },
@@ -794,19 +805,19 @@ function __wbg_get_imports(memory) {
794
805
  const ret = Math.random();
795
806
  return ret;
796
807
  },
797
- __wbg_removeEntry_1ebb67c168ea09c9: function(arg0, arg1, arg2, arg3) {
798
- const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
808
+ __wbg_removeEntry_1a97420c5a9f6f99: function(arg0, arg1, arg2) {
809
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
799
810
  return ret;
800
811
  },
801
- __wbg_removeEntry_edc21914f22bae4c: function(arg0, arg1, arg2) {
802
- const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
812
+ __wbg_removeEntry_de675a309ac183da: function(arg0, arg1, arg2, arg3) {
813
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
803
814
  return ret;
804
815
  },
805
816
  __wbg_rendering_new: function(arg0) {
806
817
  const ret = Rendering.__wrap(arg0);
807
818
  return ret;
808
819
  },
809
- __wbg_request_857918013adf1ed3: function(arg0, arg1, arg2, arg3) {
820
+ __wbg_request_210c800f06d0c757: function(arg0, arg1, arg2, arg3) {
810
821
  const ret = arg0.request(getStringFromWasm0(arg1, arg2), arg3);
811
822
  return ret;
812
823
  },
@@ -821,23 +832,23 @@ function __wbg_get_imports(memory) {
821
832
  __wbg_set_c41f8dbc07a2190f: function(arg0, arg1, arg2) {
822
833
  arg0.set(getArrayF32FromWasm0(arg1, arg2));
823
834
  },
824
- __wbg_set_name_665f9bc15f60f94b: function(arg0, arg1, arg2) {
835
+ __wbg_set_name_bdf1245644137892: function(arg0, arg1, arg2) {
825
836
  arg0.name = getStringFromWasm0(arg1, arg2);
826
837
  },
827
838
  __wbg_set_onmessage_2244c2525c4e0c38: function(arg0, arg1) {
828
839
  arg0.onmessage = arg1;
829
840
  },
830
- __wbg_set_onmessage_81be37e59419a29d: function(arg0, arg1) {
841
+ __wbg_set_onmessage_a5511a9bda9fcffd: function(arg0, arg1) {
831
842
  arg0.onmessage = arg1;
832
843
  },
833
- __wbg_set_refusal_dd4086d9e81ea709: function(arg0, arg1) {
844
+ __wbg_set_refusal_a6fbdf2910883e33: function(arg0, arg1) {
834
845
  arg0.refusal = arg1;
835
846
  },
836
- __wbg_size_10991f391b641021: function(arg0) {
847
+ __wbg_size_9292c1f221818f87: function(arg0) {
837
848
  const ret = arg0.size;
838
849
  return ret;
839
850
  },
840
- __wbg_slice_3e6a4fe3e9c0b057: function(arg0, arg1, arg2) {
851
+ __wbg_slice_6cf55ffb2d36810c: function(arg0, arg1, arg2) {
841
852
  const ret = arg0.slice(arg1, arg2);
842
853
  return ret;
843
854
  },
@@ -897,10 +908,10 @@ function __wbg_get_imports(memory) {
897
908
  const ret = Atomics.waitAsync;
898
909
  return ret;
899
910
  },
900
- __wbg_warn_53de75b39da09994: function(arg0, arg1) {
911
+ __wbg_warn_1a71557ff61ac2e7: function(arg0, arg1) {
901
912
  console.warn(getStringFromWasm0(arg0, arg1));
902
913
  },
903
- __wbg_write_fd00fab297d6bcb5: function(arg0, arg1) {
914
+ __wbg_write_7491dbbb4466b287: function(arg0, arg1) {
904
915
  const ret = arg0.write(arg1);
905
916
  return ret;
906
917
  },
@@ -910,12 +921,12 @@ function __wbg_get_imports(memory) {
910
921
  return ret;
911
922
  },
912
923
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
913
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 705, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
924
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 709, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
914
925
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d3a5247b0aa3f0ac___convert__closures_____invoke___wasm_bindgen_d3a5247b0aa3f0ac___JsValue__core_ea519e494776717c___result__Result_____wasm_bindgen_d3a5247b0aa3f0ac___JsError___true_);
915
926
  return ret;
916
927
  },
917
928
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
918
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 707, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
929
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 711, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
919
930
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d3a5247b0aa3f0ac___convert__closures_____invoke___js_sys_2b088e2931f41c5___futures__task__wait_async_polyfill__MessageEvent______true_);
920
931
  return ret;
921
932
  },
package/sva_wasm_bg.wasm CHANGED
Binary file