@scalable-vector-audio/sva-wasm 0.7.0 → 0.7.2

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.7.0",
5
+ "version": "0.7.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/sva_wasm.d.ts CHANGED
@@ -32,9 +32,15 @@ export class Composition {
32
32
  set_prune_policy(policy: string): void;
33
33
  /**
34
34
  * `target` block by block, through this store. `options`: `rate`, `bits`, `until`, `cache`,
35
- * `live`.
35
+ * `live`. Opening and every edit look the store on disk up, so each is awaited.
36
36
  */
37
- stream(target: string, block: number, options: any): Stream;
37
+ stream(target: string, block: number, options: any): Promise<Stream>;
38
+ /**
39
+ * `target` staged as `render` would, until `persist`; `{ stats, representations }`,
40
+ * the latter `representations()` for `readings`, null unasked. Options: `rate`, `bits`,
41
+ * `flop_budget`, `readings`.
42
+ */
43
+ warm(target: string, options: any): Promise<any>;
38
44
  readonly cache_bytes: number;
39
45
  readonly cache_entries: number;
40
46
  readonly cache_evictions: number;
@@ -77,21 +83,27 @@ export class Stream {
77
83
  /**
78
84
  * `term` summed into `@notes`.
79
85
  */
80
- add(term: string): number;
86
+ add(term: string): Promise<number>;
81
87
  /**
82
88
  * `expr` in place of the target.
83
89
  */
84
- edit(expr: string): void;
90
+ edit(expr: string): Promise<void>;
91
+ /**
92
+ * Reads the stored samples the next second of blocks plays, and the stream plays on
93
+ * meanwhile. A block reading stored samples not yet read computes them, or, live, starts
94
+ * the note silent where its live remainder is not ready.
95
+ */
96
+ fetch(): Promise<void>;
85
97
  /**
86
98
  * Writes the next block into `out`, component `c` from `c * block`, and returns the
87
99
  * samples each component took: `block`, fewer where silence ends inside it, `0` after.
88
100
  */
89
101
  next(out: Float32Array): number;
90
- remove(handle: number): boolean;
102
+ remove(handle: number): Promise<boolean>;
91
103
  /**
92
104
  * False where the stream no longer holds `handle`.
93
105
  */
94
- replace(handle: number, term: string): boolean;
106
+ replace(handle: number, term: string): Promise<boolean>;
95
107
  stats(): any;
96
108
  /**
97
109
  * `{ samples, priced_flops, waves }` since it opened.
@@ -136,7 +148,8 @@ export interface InitOutput {
136
148
  readonly composition_set_cache_max_bytes: (a: number, b: number) => void;
137
149
  readonly composition_set_cache_policy: (a: number, b: number, c: number) => [number, number];
138
150
  readonly composition_set_prune_policy: (a: number, b: number, c: number) => [number, number];
139
- readonly composition_stream: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
151
+ readonly composition_stream: (a: number, b: number, c: number, d: number, e: any) => any;
152
+ readonly composition_warm: (a: number, b: number, c: number, d: any) => any;
140
153
  readonly outline: (a: number, b: number) => [number, number, number];
141
154
  readonly rendering_channels: (a: number) => number;
142
155
  readonly rendering_duration_secs: (a: number) => number;
@@ -147,22 +160,23 @@ export interface InitOutput {
147
160
  readonly rendering_stats: (a: number) => [number, number, number];
148
161
  readonly rendering_target: (a: number) => [number, number];
149
162
  readonly rendering_work: (a: number) => [number, number, number];
150
- readonly stream_add: (a: number, b: number, c: number) => [number, number, number];
151
- readonly stream_block: (a: number) => number;
152
- readonly stream_channels: (a: number) => number;
153
- readonly stream_edit: (a: number, b: number, c: number) => [number, number];
154
- readonly stream_end: (a: number) => [number, number];
155
- readonly stream_held_bytes: (a: number) => number;
163
+ readonly stream_add: (a: number, b: number, c: number) => any;
164
+ readonly stream_block: (a: number) => [number, number, number];
165
+ readonly stream_channels: (a: number) => [number, number, number];
166
+ readonly stream_edit: (a: number, b: number, c: number) => any;
167
+ readonly stream_end: (a: number) => [number, number, number, number];
168
+ readonly stream_fetch: (a: number) => any;
169
+ readonly stream_held_bytes: (a: number) => [number, number, number];
156
170
  readonly stream_next: (a: number, b: number, c: number, d: any) => [number, number, number];
157
- readonly stream_position: (a: number) => number;
158
- readonly stream_remove: (a: number, b: number) => [number, number, number];
159
- readonly stream_replace: (a: number, b: number, c: number, d: number) => [number, number, number];
160
- readonly stream_sample_rate: (a: number) => number;
171
+ readonly stream_position: (a: number) => [number, number, number];
172
+ readonly stream_remove: (a: number, b: number) => any;
173
+ readonly stream_replace: (a: number, b: number, c: number, d: number) => any;
174
+ readonly stream_sample_rate: (a: number) => [number, number, number];
161
175
  readonly stream_stats: (a: number) => [number, number, number];
162
176
  readonly stream_work: (a: number) => [number, number, number];
163
177
  readonly wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95: (a: number, b: number, c: any, d: any) => void;
164
178
  readonly wasm_bindgen__convert__closures_____invoke__hd55bb211d6a08150: (a: number, b: number, c: any) => [number, number];
165
- readonly wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385: (a: number, b: number) => any;
179
+ readonly wasm_bindgen__convert__closures_____invoke__h1fa9803413ae3c8c: (a: number, b: number) => any;
166
180
  readonly __wbindgen_malloc: (a: number, b: number) => number;
167
181
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
168
182
  readonly __wbindgen_exn_store: (a: number) => void;
package/sva_wasm.js CHANGED
@@ -182,20 +182,31 @@ export class Composition {
182
182
  }
183
183
  /**
184
184
  * `target` block by block, through this store. `options`: `rate`, `bits`, `until`, `cache`,
185
- * `live`.
185
+ * `live`. Opening and every edit look the store on disk up, so each is awaited.
186
186
  * @param {string} target
187
187
  * @param {number} block
188
188
  * @param {any} options
189
- * @returns {Stream}
189
+ * @returns {Promise<Stream>}
190
190
  */
191
191
  stream(target, block, options) {
192
192
  const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
193
  const len0 = WASM_VECTOR_LEN;
194
194
  const ret = wasm.composition_stream(this.__wbg_ptr, ptr0, len0, block, options);
195
- if (ret[2]) {
196
- throw takeFromExternrefTable0(ret[1]);
197
- }
198
- return Stream.__wrap(ret[0]);
195
+ return ret;
196
+ }
197
+ /**
198
+ * `target` staged as `render` would, until `persist`; `{ stats, representations }`,
199
+ * the latter `representations()` for `readings`, null unasked. Options: `rate`, `bits`,
200
+ * `flop_budget`, `readings`.
201
+ * @param {string} target
202
+ * @param {any} options
203
+ * @returns {Promise<any>}
204
+ */
205
+ warm(target, options) {
206
+ const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
207
+ const len0 = WASM_VECTOR_LEN;
208
+ const ret = wasm.composition_warm(this.__wbg_ptr, ptr0, len0, options);
209
+ return ret;
199
210
  }
200
211
  }
201
212
  if (Symbol.dispose) Composition.prototype[Symbol.dispose] = Composition.prototype.free;
@@ -334,56 +345,74 @@ export class Stream {
334
345
  /**
335
346
  * `term` summed into `@notes`.
336
347
  * @param {string} term
337
- * @returns {number}
348
+ * @returns {Promise<number>}
338
349
  */
339
350
  add(term) {
340
351
  const ptr0 = passStringToWasm0(term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
352
  const len0 = WASM_VECTOR_LEN;
342
353
  const ret = wasm.stream_add(this.__wbg_ptr, ptr0, len0);
343
- if (ret[2]) {
344
- throw takeFromExternrefTable0(ret[1]);
345
- }
346
- return ret[0] >>> 0;
354
+ return ret;
347
355
  }
348
356
  /**
349
357
  * @returns {number}
350
358
  */
351
359
  get block() {
352
360
  const ret = wasm.stream_block(this.__wbg_ptr);
353
- return ret >>> 0;
361
+ if (ret[2]) {
362
+ throw takeFromExternrefTable0(ret[1]);
363
+ }
364
+ return ret[0] >>> 0;
354
365
  }
355
366
  /**
356
367
  * @returns {number}
357
368
  */
358
369
  get channels() {
359
370
  const ret = wasm.stream_channels(this.__wbg_ptr);
360
- return ret >>> 0;
371
+ if (ret[2]) {
372
+ throw takeFromExternrefTable0(ret[1]);
373
+ }
374
+ return ret[0] >>> 0;
361
375
  }
362
376
  /**
363
377
  * `expr` in place of the target.
364
378
  * @param {string} expr
379
+ * @returns {Promise<void>}
365
380
  */
366
381
  edit(expr) {
367
382
  const ptr0 = passStringToWasm0(expr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
383
  const len0 = WASM_VECTOR_LEN;
369
384
  const ret = wasm.stream_edit(this.__wbg_ptr, ptr0, len0);
370
- if (ret[1]) {
371
- throw takeFromExternrefTable0(ret[0]);
372
- }
385
+ return ret;
373
386
  }
374
387
  /**
375
388
  * @returns {number | undefined}
376
389
  */
377
390
  get end() {
378
391
  const ret = wasm.stream_end(this.__wbg_ptr);
392
+ if (ret[3]) {
393
+ throw takeFromExternrefTable0(ret[2]);
394
+ }
379
395
  return ret[0] === 0 ? undefined : ret[1];
380
396
  }
397
+ /**
398
+ * Reads the stored samples the next second of blocks plays, and the stream plays on
399
+ * meanwhile. A block reading stored samples not yet read computes them, or, live, starts
400
+ * the note silent where its live remainder is not ready.
401
+ * @returns {Promise<void>}
402
+ */
403
+ fetch() {
404
+ const ret = wasm.stream_fetch(this.__wbg_ptr);
405
+ return ret;
406
+ }
381
407
  /**
382
408
  * @returns {number}
383
409
  */
384
410
  get held_bytes() {
385
411
  const ret = wasm.stream_held_bytes(this.__wbg_ptr);
386
- return ret;
412
+ if (ret[2]) {
413
+ throw takeFromExternrefTable0(ret[1]);
414
+ }
415
+ return ret[0];
387
416
  }
388
417
  /**
389
418
  * Writes the next block into `out`, component `c` from `c * block`, and returns the
@@ -405,40 +434,40 @@ export class Stream {
405
434
  */
406
435
  get position() {
407
436
  const ret = wasm.stream_position(this.__wbg_ptr);
408
- return ret;
437
+ if (ret[2]) {
438
+ throw takeFromExternrefTable0(ret[1]);
439
+ }
440
+ return ret[0];
409
441
  }
410
442
  /**
411
443
  * @param {number} handle
412
- * @returns {boolean}
444
+ * @returns {Promise<boolean>}
413
445
  */
414
446
  remove(handle) {
415
447
  const ret = wasm.stream_remove(this.__wbg_ptr, handle);
416
- if (ret[2]) {
417
- throw takeFromExternrefTable0(ret[1]);
418
- }
419
- return ret[0] !== 0;
448
+ return ret;
420
449
  }
421
450
  /**
422
451
  * False where the stream no longer holds `handle`.
423
452
  * @param {number} handle
424
453
  * @param {string} term
425
- * @returns {boolean}
454
+ * @returns {Promise<boolean>}
426
455
  */
427
456
  replace(handle, term) {
428
457
  const ptr0 = passStringToWasm0(term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
429
458
  const len0 = WASM_VECTOR_LEN;
430
459
  const ret = wasm.stream_replace(this.__wbg_ptr, handle, ptr0, len0);
431
- if (ret[2]) {
432
- throw takeFromExternrefTable0(ret[1]);
433
- }
434
- return ret[0] !== 0;
460
+ return ret;
435
461
  }
436
462
  /**
437
463
  * @returns {number}
438
464
  */
439
465
  get sample_rate() {
440
466
  const ret = wasm.stream_sample_rate(this.__wbg_ptr);
441
- return ret >>> 0;
467
+ if (ret[2]) {
468
+ throw takeFromExternrefTable0(ret[1]);
469
+ }
470
+ return ret[0] >>> 0;
442
471
  }
443
472
  /**
444
473
  * @returns {any}
@@ -543,7 +572,7 @@ function __wbg_get_imports() {
543
572
  __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
544
573
  arg0._wbg_cb_unref();
545
574
  },
546
- __wbg_arrayBuffer_303605bfdb02dbaa: function(arg0) {
575
+ __wbg_arrayBuffer_dbd53e75db738fae: function(arg0) {
547
576
  const ret = arg0.arrayBuffer();
548
577
  return ret;
549
578
  },
@@ -555,7 +584,7 @@ function __wbg_get_imports() {
555
584
  const ret = arg0.call(arg1, arg2);
556
585
  return ret;
557
586
  }, arguments); },
558
- __wbg_close_c91cbb2cddb6f7aa: function(arg0) {
587
+ __wbg_close_5aa4fdce5d27170d: function(arg0) {
559
588
  const ret = arg0.close();
560
589
  return ret;
561
590
  },
@@ -563,7 +592,7 @@ function __wbg_get_imports() {
563
592
  const ret = Composition.__wrap(arg0);
564
593
  return ret;
565
594
  },
566
- __wbg_createWritable_dcac2d262cf50ae7: function(arg0) {
595
+ __wbg_createWritable_813278137702c672: function(arg0) {
567
596
  const ret = arg0.createWritable();
568
597
  return ret;
569
598
  },
@@ -575,15 +604,15 @@ function __wbg_get_imports() {
575
604
  const ret = Array.from(arg0);
576
605
  return ret;
577
606
  },
578
- __wbg_getDirectoryHandle_6ba4491be2862323: function(arg0, arg1, arg2, arg3) {
607
+ __wbg_getDirectoryHandle_abeab464f3c65f25: function(arg0, arg1, arg2, arg3) {
579
608
  const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
580
609
  return ret;
581
610
  },
582
- __wbg_getFileHandle_9709cc764716faf0: function(arg0, arg1, arg2, arg3) {
611
+ __wbg_getFileHandle_9b7788a10f51304f: function(arg0, arg1, arg2, arg3) {
583
612
  const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
584
613
  return ret;
585
614
  },
586
- __wbg_getFile_514e6ad2d0b16f74: function(arg0) {
615
+ __wbg_getFile_880d5e36fcbe5891: function(arg0) {
587
616
  const ret = arg0.getFile();
588
617
  return ret;
589
618
  },
@@ -613,7 +642,7 @@ function __wbg_get_imports() {
613
642
  const ret = Array.isArray(arg0);
614
643
  return ret;
615
644
  },
616
- __wbg_keys_23712aa1a6f4aa5d: function(arg0) {
645
+ __wbg_keys_bb1628b5f767331c: function(arg0) {
617
646
  const ret = arg0.keys();
618
647
  return ret;
619
648
  },
@@ -625,7 +654,7 @@ function __wbg_get_imports() {
625
654
  const ret = arg0.length;
626
655
  return ret;
627
656
  },
628
- __wbg_move_2019b378ef90cf6c: function(arg0, arg1, arg2, arg3) {
657
+ __wbg_move_7b940aab376195ce: function(arg0, arg1, arg2, arg3) {
629
658
  const ret = arg0.move(arg1, getStringFromWasm0(arg2, arg3));
630
659
  return ret;
631
660
  },
@@ -633,7 +662,7 @@ function __wbg_get_imports() {
633
662
  const ret = new Uint8Array(arg0);
634
663
  return ret;
635
664
  },
636
- __wbg_new_30145d082ba9492c: function(arg0, arg1) {
665
+ __wbg_new_536d8ff546834a3d: function(arg0, arg1) {
637
666
  const ret = new Error(getStringFromWasm0(arg0, arg1));
638
667
  return ret;
639
668
  },
@@ -681,18 +710,18 @@ function __wbg_get_imports() {
681
710
  state0.a = 0;
682
711
  }
683
712
  },
684
- __wbg_next_30e6632b4218cb09: function(arg0) {
713
+ __wbg_next_f4b7785cddb77159: function(arg0) {
685
714
  const ret = arg0.next();
686
715
  return ret;
687
716
  },
688
- __wbg_parse_a1c86daae8e336bd: function() { return handleError(function (arg0, arg1) {
717
+ __wbg_parse_77f086087c089de1: function() { return handleError(function (arg0, arg1) {
689
718
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
690
719
  return ret;
691
720
  }, arguments); },
692
721
  __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
693
722
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
694
723
  },
695
- __wbg_query_259d928d723fff72: function(arg0) {
724
+ __wbg_query_3333eea8f8b016ee: function(arg0) {
696
725
  const ret = arg0.query();
697
726
  return ret;
698
727
  },
@@ -707,19 +736,19 @@ function __wbg_get_imports() {
707
736
  const ret = Math.random();
708
737
  return ret;
709
738
  },
710
- __wbg_removeEntry_526b61f67204248f: function(arg0, arg1, arg2) {
711
- const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
739
+ __wbg_removeEntry_2a712749f1dc4003: function(arg0, arg1, arg2, arg3) {
740
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
712
741
  return ret;
713
742
  },
714
- __wbg_removeEntry_73524952fdb64743: function(arg0, arg1, arg2, arg3) {
715
- const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
743
+ __wbg_removeEntry_7ea9843e2b12fd01: function(arg0, arg1, arg2) {
744
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
716
745
  return ret;
717
746
  },
718
747
  __wbg_rendering_new: function(arg0) {
719
748
  const ret = Rendering.__wrap(arg0);
720
749
  return ret;
721
750
  },
722
- __wbg_request_eda21e880c785d71: function(arg0, arg1, arg2, arg3) {
751
+ __wbg_request_8ca00ebd07e4a6e8: function(arg0, arg1, arg2, arg3) {
723
752
  const ret = arg0.request(getStringFromWasm0(arg1, arg2), arg3);
724
753
  return ret;
725
754
  },
@@ -731,16 +760,20 @@ function __wbg_get_imports() {
731
760
  const ret = Reflect.set(arg0, arg1, arg2);
732
761
  return ret;
733
762
  }, arguments); },
734
- __wbg_set_name_67f69e636c52b8b8: function(arg0, arg1, arg2) {
763
+ __wbg_set_name_676ed49f8d7df324: function(arg0, arg1, arg2) {
735
764
  arg0.name = getStringFromWasm0(arg1, arg2);
736
765
  },
737
- __wbg_set_refusal_67dcb641bf92d6bd: function(arg0, arg1) {
766
+ __wbg_set_refusal_e944caff565482ce: function(arg0, arg1) {
738
767
  arg0.refusal = arg1;
739
768
  },
740
- __wbg_size_a827722774ab6a64: function(arg0) {
769
+ __wbg_size_98080bde78dcec98: function(arg0) {
741
770
  const ret = arg0.size;
742
771
  return ret;
743
772
  },
773
+ __wbg_slice_d3997ea27cf70829: function(arg0, arg1, arg2) {
774
+ const ret = arg0.slice(arg1, arg2);
775
+ return ret;
776
+ },
744
777
  __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
745
778
  const ret = typeof global === 'undefined' ? null : global;
746
779
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -757,6 +790,10 @@ function __wbg_get_imports() {
757
790
  const ret = typeof window === 'undefined' ? null : window;
758
791
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
759
792
  },
793
+ __wbg_stream_new: function(arg0) {
794
+ const ret = Stream.__wrap(arg0);
795
+ return ret;
796
+ },
760
797
  __wbg_then_7a850dae4493f353: function(arg0, arg1, arg2) {
761
798
  const ret = arg0.then(arg1, arg2);
762
799
  return ret;
@@ -765,18 +802,18 @@ function __wbg_get_imports() {
765
802
  const ret = arg0.then(arg1);
766
803
  return ret;
767
804
  },
768
- __wbg_write_b2d191debe961263: function(arg0, arg1) {
805
+ __wbg_write_84516362671d6058: function(arg0, arg1) {
769
806
  const ret = arg0.write(arg1);
770
807
  return ret;
771
808
  },
772
809
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
773
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 491, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
810
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 540, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
774
811
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd55bb211d6a08150);
775
812
  return ret;
776
813
  },
777
814
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
778
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 38, ret: NamedExternref("Promise<any>"), inner_ret: Some(NamedExternref("Promise<any>")) }, mutable: true }) -> Externref`.
779
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385);
815
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 90, ret: NamedExternref("Promise<any>"), inner_ret: Some(NamedExternref("Promise<any>")) }, mutable: true }) -> Externref`.
816
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h1fa9803413ae3c8c);
780
817
  return ret;
781
818
  },
782
819
  __wbindgen_generic_0000000000000003: function(arg0) {
@@ -805,8 +842,8 @@ function __wbg_get_imports() {
805
842
  };
806
843
  }
807
844
 
808
- function wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385(arg0, arg1) {
809
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385(arg0, arg1);
845
+ function wasm_bindgen__convert__closures_____invoke__h1fa9803413ae3c8c(arg0, arg1) {
846
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h1fa9803413ae3c8c(arg0, arg1);
810
847
  return ret;
811
848
  }
812
849
 
package/sva_wasm_bg.wasm CHANGED
Binary file