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

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.6.0",
5
+ "version": "0.7.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/sva_wasm.d.ts CHANGED
@@ -1,39 +1,40 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- export class Checkpoint {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- readonly position: number;
9
- }
10
-
11
4
  export class Composition {
12
5
  free(): void;
13
6
  [Symbol.dispose](): void;
14
7
  clear_cache(): void;
15
8
  insert(path: string, text: string): void;
16
9
  constructor(name?: string | null);
10
+ /**
11
+ * Over the store in `dir`, an origin-private file system directory, or memory alone
12
+ * where there is none.
13
+ */
14
+ static open(name?: string | null, dir?: FileSystemDirectoryHandle | null): Promise<Composition>;
15
+ /**
16
+ * The only write to the directory `open` was handed: every value computed since the last.
17
+ */
18
+ persist(): Promise<number>;
17
19
  /**
18
20
  * `"oldest"` evicts what the latest render neither stored nor read, `"forks"` every value
19
21
  * fewer than two nodes read.
20
22
  */
21
23
  prune(policy: string): void;
22
24
  /**
23
- * Unset, `target` is `master`; `until` is the horizon in seconds, or `"silent"` to end
24
- * where every later sample is provably under `2^-bits` (default the profile's own), by
25
- * `max_secs` at the latest. `rate` is the observation rate. What reads a `volatile`
26
- * parameter keeps one value in the store, its last. `cache` overrides `cache_policy`.
25
+ * `target` as `sva-cli render` takes it, `@piano([0, 2b], f0=C4)`; `representations`
26
+ * what `representations()` answers, `samples` where unset, each a call as
27
+ * `--representation` writes it. `options` sets `rate`, `bits`, `flop_budget`, `until`,
28
+ * `volatile` and `cache`.
27
29
  */
28
- render(target: string | null | undefined, rate: number | null | undefined, until: any, volatile?: string[] | null, bits?: number | null, max_secs?: number | null, cache?: string | null): Rendering;
30
+ render(target: string, representations: string[] | null | undefined, options: any): Promise<Rendering>;
29
31
  set_cache_policy(policy: string): void;
30
32
  set_prune_policy(policy: string): void;
31
33
  /**
32
- * A stream of `target` (`master` unset) at `rate`, `block` samples a block, each key of
33
- * `bindings` a named argument on the target. `until: "silent"` ends it at the first block
34
- * whose end proves every later sample under `2^-bits`, throwing past `max_secs`.
34
+ * `target` block by block, through this store. `options`: `rate`, `bits`, `until`, `cache`,
35
+ * `live`.
35
36
  */
36
- stream(target: string | null | undefined, rate: number | null | undefined, block: number, bindings: any, until: any, bits?: number | null, max_secs?: number | null): Stream;
37
+ stream(target: string, block: number, options: any): Stream;
37
38
  readonly cache_bytes: number;
38
39
  readonly cache_entries: number;
39
40
  readonly cache_evictions: number;
@@ -47,10 +48,11 @@ export class Rendering {
47
48
  free(): void;
48
49
  [Symbol.dispose](): void;
49
50
  /**
50
- * The object `sva-cli render --as <name>` puts under `data`, arrays capped as it caps.
51
+ * The object `sva-cli render` puts under `data`, one reading per representation asked,
52
+ * arrays capped as it caps.
51
53
  */
52
- query(representation: string, from_secs?: number | null, to_secs?: number | null): any;
53
- samples(channel: number, from_secs?: number | null, to_secs?: number | null): Float32Array;
54
+ representations(): any;
55
+ samples(channel: number): Float32Array;
54
56
  /**
55
57
  * Every lookup this render made of the composition's store, and what each came to.
56
58
  */
@@ -59,33 +61,46 @@ export class Rendering {
59
61
  readonly channels: number;
60
62
  readonly duration_secs: number;
61
63
  readonly sample_rate: number;
64
+ readonly start_secs: number;
62
65
  readonly target: string;
63
66
  }
64
67
 
65
68
  /**
66
- * A target block by block, for a player that cannot know how long a note is held.
69
+ * A target block by block, reading `@notes` as the sum of its terms, as `@hall(t, x=@notes)`.
70
+ * A key-up replaces a term with one whose release is a number. A term leaves with its handle
71
+ * once its node ends, bar the last.
67
72
  */
68
73
  export class Stream {
69
74
  private constructor();
70
75
  free(): void;
71
76
  [Symbol.dispose](): void;
72
- checkpoint(): Checkpoint;
77
+ /**
78
+ * `term` summed into `@notes`.
79
+ */
80
+ add(term: string): number;
81
+ /**
82
+ * `expr` in place of the target.
83
+ */
84
+ edit(expr: string): void;
73
85
  /**
74
86
  * Writes the next block into `out`, component `c` from `c * block`, and returns the
75
87
  * samples each component took: `block`, fewer where silence ends inside it, `0` after.
76
88
  */
77
89
  next(out: Float32Array): number;
90
+ remove(handle: number): boolean;
78
91
  /**
79
- * `until` as `stream` takes it, `max_secs` counted from the checkpoint.
92
+ * False where the stream no longer holds `handle`.
80
93
  */
81
- resume(checkpoint: Checkpoint, bindings: any, until: any, bits?: number | null, max_secs?: number | null): Stream;
94
+ replace(handle: number, term: string): boolean;
95
+ stats(): any;
82
96
  /**
83
- * `{ samples, proofs, priced_flops, waves }` since it opened or resumed.
97
+ * `{ samples, priced_flops, waves }` since it opened.
84
98
  */
85
99
  work(): any;
86
100
  readonly block: number;
87
101
  readonly channels: number;
88
102
  readonly end: number | undefined;
103
+ readonly held_bytes: number;
89
104
  readonly position: number;
90
105
  readonly sample_rate: number;
91
106
  }
@@ -101,12 +116,10 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
101
116
 
102
117
  export interface InitOutput {
103
118
  readonly memory: WebAssembly.Memory;
104
- readonly __wbg_checkpoint_free: (a: number, b: number) => void;
105
119
  readonly __wbg_composition_free: (a: number, b: number) => void;
106
120
  readonly __wbg_rendering_free: (a: number, b: number) => void;
107
121
  readonly __wbg_stream_free: (a: number, b: number) => void;
108
122
  readonly builtins: () => [number, number, number];
109
- readonly checkpoint_position: (a: number) => number;
110
123
  readonly composition_cache_bytes: (a: number) => number;
111
124
  readonly composition_cache_entries: (a: number) => number;
112
125
  readonly composition_cache_evictions: (a: number) => number;
@@ -115,36 +128,47 @@ export interface InitOutput {
115
128
  readonly composition_clear_cache: (a: number) => void;
116
129
  readonly composition_insert: (a: number, b: number, c: number, d: number, e: number) => void;
117
130
  readonly composition_new: (a: number, b: number) => number;
131
+ readonly composition_open: (a: number, b: number, c: number) => any;
132
+ readonly composition_persist: (a: number) => any;
118
133
  readonly composition_prune: (a: number, b: number, c: number) => [number, number];
119
134
  readonly composition_prune_policy: (a: number) => [number, number];
120
- readonly composition_render: (a: number, b: number, c: number, d: number, e: any, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number];
135
+ readonly composition_render: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
121
136
  readonly composition_set_cache_max_bytes: (a: number, b: number) => void;
122
137
  readonly composition_set_cache_policy: (a: number, b: number, c: number) => [number, number];
123
138
  readonly composition_set_prune_policy: (a: number, b: number, c: number) => [number, number];
124
- readonly composition_stream: (a: number, b: number, c: number, d: number, e: number, f: any, g: any, h: number, i: number, j: number) => [number, number, number];
139
+ readonly composition_stream: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
125
140
  readonly outline: (a: number, b: number) => [number, number, number];
126
141
  readonly rendering_channels: (a: number) => number;
127
142
  readonly rendering_duration_secs: (a: number) => number;
128
- readonly rendering_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
143
+ readonly rendering_representations: (a: number) => [number, number, number];
129
144
  readonly rendering_sample_rate: (a: number) => number;
130
- readonly rendering_samples: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
145
+ readonly rendering_samples: (a: number, b: number) => [number, number, number, number];
146
+ readonly rendering_start_secs: (a: number) => number;
131
147
  readonly rendering_stats: (a: number) => [number, number, number];
132
148
  readonly rendering_target: (a: number) => [number, number];
133
149
  readonly rendering_work: (a: number) => [number, number, number];
150
+ readonly stream_add: (a: number, b: number, c: number) => [number, number, number];
134
151
  readonly stream_block: (a: number) => number;
135
152
  readonly stream_channels: (a: number) => number;
136
- readonly stream_checkpoint: (a: number) => number;
153
+ readonly stream_edit: (a: number, b: number, c: number) => [number, number];
137
154
  readonly stream_end: (a: number) => [number, number];
155
+ readonly stream_held_bytes: (a: number) => number;
138
156
  readonly stream_next: (a: number, b: number, c: number, d: any) => [number, number, number];
139
157
  readonly stream_position: (a: number) => number;
140
- readonly stream_resume: (a: number, b: number, c: any, d: any, e: number, f: number, g: number) => [number, 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];
141
160
  readonly stream_sample_rate: (a: number) => number;
161
+ readonly stream_stats: (a: number) => [number, number, number];
142
162
  readonly stream_work: (a: number) => [number, number, number];
163
+ readonly wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95: (a: number, b: number, c: any, d: any) => void;
164
+ 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;
143
166
  readonly __wbindgen_malloc: (a: number, b: number) => number;
144
167
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
145
168
  readonly __wbindgen_exn_store: (a: number) => void;
146
169
  readonly __externref_table_alloc: () => number;
147
170
  readonly __wbindgen_externrefs: WebAssembly.Table;
171
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
148
172
  readonly __externref_table_dealloc: (a: number) => void;
149
173
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
150
174
  readonly __wbindgen_start: () => void;
package/sva_wasm.js CHANGED
@@ -1,33 +1,12 @@
1
1
  /* @ts-self-types="./sva_wasm.d.ts" */
2
2
 
3
- export class Checkpoint {
3
+ export class Composition {
4
4
  static __wrap(ptr) {
5
- const obj = Object.create(Checkpoint.prototype);
5
+ const obj = Object.create(Composition.prototype);
6
6
  obj.__wbg_ptr = ptr;
7
- CheckpointFinalization.register(obj, obj.__wbg_ptr, obj);
7
+ CompositionFinalization.register(obj, obj.__wbg_ptr, obj);
8
8
  return obj;
9
9
  }
10
- __destroy_into_raw() {
11
- const ptr = this.__wbg_ptr;
12
- this.__wbg_ptr = 0;
13
- CheckpointFinalization.unregister(this);
14
- return ptr;
15
- }
16
- free() {
17
- const ptr = this.__destroy_into_raw();
18
- wasm.__wbg_checkpoint_free(ptr, 0);
19
- }
20
- /**
21
- * @returns {number}
22
- */
23
- get position() {
24
- const ret = wasm.checkpoint_position(this.__wbg_ptr);
25
- return ret;
26
- }
27
- }
28
- if (Symbol.dispose) Checkpoint.prototype[Symbol.dispose] = Checkpoint.prototype.free;
29
-
30
- export class Composition {
31
10
  __destroy_into_raw() {
32
11
  const ptr = this.__wbg_ptr;
33
12
  this.__wbg_ptr = 0;
@@ -106,6 +85,27 @@ export class Composition {
106
85
  CompositionFinalization.register(this, this.__wbg_ptr, this);
107
86
  return this;
108
87
  }
88
+ /**
89
+ * Over the store in `dir`, an origin-private file system directory, or memory alone
90
+ * where there is none.
91
+ * @param {string | null} [name]
92
+ * @param {FileSystemDirectoryHandle | null} [dir]
93
+ * @returns {Promise<Composition>}
94
+ */
95
+ static open(name, dir) {
96
+ var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
97
+ var len0 = WASM_VECTOR_LEN;
98
+ const ret = wasm.composition_open(ptr0, len0, isLikeNone(dir) ? 0 : addToExternrefTable0(dir));
99
+ return ret;
100
+ }
101
+ /**
102
+ * The only write to the directory `open` was handed: every value computed since the last.
103
+ * @returns {Promise<number>}
104
+ */
105
+ persist() {
106
+ const ret = wasm.composition_persist(this.__wbg_ptr);
107
+ return ret;
108
+ }
109
109
  /**
110
110
  * `"oldest"` evicts what the latest render neither stored nor read, `"forks"` every value
111
111
  * fewer than two nodes read.
@@ -135,31 +135,22 @@ export class Composition {
135
135
  }
136
136
  }
137
137
  /**
138
- * Unset, `target` is `master`; `until` is the horizon in seconds, or `"silent"` to end
139
- * where every later sample is provably under `2^-bits` (default the profile's own), by
140
- * `max_secs` at the latest. `rate` is the observation rate. What reads a `volatile`
141
- * parameter keeps one value in the store, its last. `cache` overrides `cache_policy`.
142
- * @param {string | null | undefined} target
143
- * @param {number | null | undefined} rate
144
- * @param {any} until
145
- * @param {string[] | null} [volatile]
146
- * @param {number | null} [bits]
147
- * @param {number | null} [max_secs]
148
- * @param {string | null} [cache]
149
- * @returns {Rendering}
138
+ * `target` as `sva-cli render` takes it, `@piano([0, 2b], f0=C4)`; `representations`
139
+ * what `representations()` answers, `samples` where unset, each a call as
140
+ * `--representation` writes it. `options` sets `rate`, `bits`, `flop_budget`, `until`,
141
+ * `volatile` and `cache`.
142
+ * @param {string} target
143
+ * @param {string[] | null | undefined} representations
144
+ * @param {any} options
145
+ * @returns {Promise<Rendering>}
150
146
  */
151
- render(target, rate, until, volatile, bits, max_secs, cache) {
152
- var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
- var len0 = WASM_VECTOR_LEN;
154
- var ptr1 = isLikeNone(volatile) ? 0 : passArrayJsValueToWasm0(volatile, wasm.__wbindgen_malloc);
147
+ render(target, representations, options) {
148
+ const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
149
+ const len0 = WASM_VECTOR_LEN;
150
+ var ptr1 = isLikeNone(representations) ? 0 : passArrayJsValueToWasm0(representations, wasm.__wbindgen_malloc);
155
151
  var len1 = WASM_VECTOR_LEN;
156
- var ptr2 = isLikeNone(cache) ? 0 : passStringToWasm0(cache, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
- var len2 = WASM_VECTOR_LEN;
158
- const ret = wasm.composition_render(this.__wbg_ptr, ptr0, len0, isLikeNone(rate) ? Number.MAX_SAFE_INTEGER : (rate) >>> 0, until, ptr1, len1, isLikeNone(bits) ? Number.MAX_SAFE_INTEGER : (bits) >>> 0, !isLikeNone(max_secs), isLikeNone(max_secs) ? 0 : max_secs, ptr2, len2);
159
- if (ret[2]) {
160
- throw takeFromExternrefTable0(ret[1]);
161
- }
162
- return Rendering.__wrap(ret[0]);
152
+ const ret = wasm.composition_render(this.__wbg_ptr, ptr0, len0, ptr1, len1, options);
153
+ return ret;
163
154
  }
164
155
  /**
165
156
  * @param {number} max_bytes
@@ -190,22 +181,17 @@ export class Composition {
190
181
  }
191
182
  }
192
183
  /**
193
- * A stream of `target` (`master` unset) at `rate`, `block` samples a block, each key of
194
- * `bindings` a named argument on the target. `until: "silent"` ends it at the first block
195
- * whose end proves every later sample under `2^-bits`, throwing past `max_secs`.
196
- * @param {string | null | undefined} target
197
- * @param {number | null | undefined} rate
184
+ * `target` block by block, through this store. `options`: `rate`, `bits`, `until`, `cache`,
185
+ * `live`.
186
+ * @param {string} target
198
187
  * @param {number} block
199
- * @param {any} bindings
200
- * @param {any} until
201
- * @param {number | null} [bits]
202
- * @param {number | null} [max_secs]
188
+ * @param {any} options
203
189
  * @returns {Stream}
204
190
  */
205
- stream(target, rate, block, bindings, until, bits, max_secs) {
206
- var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
207
- var len0 = WASM_VECTOR_LEN;
208
- const ret = wasm.composition_stream(this.__wbg_ptr, ptr0, len0, isLikeNone(rate) ? Number.MAX_SAFE_INTEGER : (rate) >>> 0, block, bindings, until, isLikeNone(bits) ? Number.MAX_SAFE_INTEGER : (bits) >>> 0, !isLikeNone(max_secs), isLikeNone(max_secs) ? 0 : max_secs);
191
+ stream(target, block, options) {
192
+ const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
+ const len0 = WASM_VECTOR_LEN;
194
+ const ret = wasm.composition_stream(this.__wbg_ptr, ptr0, len0, block, options);
209
195
  if (ret[2]) {
210
196
  throw takeFromExternrefTable0(ret[1]);
211
197
  }
@@ -246,16 +232,12 @@ export class Rendering {
246
232
  return ret;
247
233
  }
248
234
  /**
249
- * The object `sva-cli render --as <name>` puts under `data`, arrays capped as it caps.
250
- * @param {string} representation
251
- * @param {number | null} [from_secs]
252
- * @param {number | null} [to_secs]
235
+ * The object `sva-cli render` puts under `data`, one reading per representation asked,
236
+ * arrays capped as it caps.
253
237
  * @returns {any}
254
238
  */
255
- query(representation, from_secs, to_secs) {
256
- const ptr0 = passStringToWasm0(representation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
- const len0 = WASM_VECTOR_LEN;
258
- const ret = wasm.rendering_query(this.__wbg_ptr, ptr0, len0, !isLikeNone(from_secs), isLikeNone(from_secs) ? 0 : from_secs, !isLikeNone(to_secs), isLikeNone(to_secs) ? 0 : to_secs);
239
+ representations() {
240
+ const ret = wasm.rendering_representations(this.__wbg_ptr);
259
241
  if (ret[2]) {
260
242
  throw takeFromExternrefTable0(ret[1]);
261
243
  }
@@ -270,12 +252,10 @@ export class Rendering {
270
252
  }
271
253
  /**
272
254
  * @param {number} channel
273
- * @param {number | null} [from_secs]
274
- * @param {number | null} [to_secs]
275
255
  * @returns {Float32Array}
276
256
  */
277
- samples(channel, from_secs, to_secs) {
278
- const ret = wasm.rendering_samples(this.__wbg_ptr, channel, !isLikeNone(from_secs), isLikeNone(from_secs) ? 0 : from_secs, !isLikeNone(to_secs), isLikeNone(to_secs) ? 0 : to_secs);
257
+ samples(channel) {
258
+ const ret = wasm.rendering_samples(this.__wbg_ptr, channel);
279
259
  if (ret[3]) {
280
260
  throw takeFromExternrefTable0(ret[2]);
281
261
  }
@@ -283,6 +263,13 @@ export class Rendering {
283
263
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
284
264
  return v1;
285
265
  }
266
+ /**
267
+ * @returns {number}
268
+ */
269
+ get start_secs() {
270
+ const ret = wasm.rendering_start_secs(this.__wbg_ptr);
271
+ return ret;
272
+ }
286
273
  /**
287
274
  * Every lookup this render made of the composition's store, and what each came to.
288
275
  * @returns {any}
@@ -323,7 +310,9 @@ export class Rendering {
323
310
  if (Symbol.dispose) Rendering.prototype[Symbol.dispose] = Rendering.prototype.free;
324
311
 
325
312
  /**
326
- * A target block by block, for a player that cannot know how long a note is held.
313
+ * A target block by block, reading `@notes` as the sum of its terms, as `@hall(t, x=@notes)`.
314
+ * A key-up replaces a term with one whose release is a number. A term leaves with its handle
315
+ * once its node ends, bar the last.
327
316
  */
328
317
  export class Stream {
329
318
  static __wrap(ptr) {
@@ -342,6 +331,20 @@ export class Stream {
342
331
  const ptr = this.__destroy_into_raw();
343
332
  wasm.__wbg_stream_free(ptr, 0);
344
333
  }
334
+ /**
335
+ * `term` summed into `@notes`.
336
+ * @param {string} term
337
+ * @returns {number}
338
+ */
339
+ add(term) {
340
+ const ptr0 = passStringToWasm0(term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ 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;
347
+ }
345
348
  /**
346
349
  * @returns {number}
347
350
  */
@@ -357,11 +360,16 @@ export class Stream {
357
360
  return ret >>> 0;
358
361
  }
359
362
  /**
360
- * @returns {Checkpoint}
363
+ * `expr` in place of the target.
364
+ * @param {string} expr
361
365
  */
362
- checkpoint() {
363
- const ret = wasm.stream_checkpoint(this.__wbg_ptr);
364
- return Checkpoint.__wrap(ret);
366
+ edit(expr) {
367
+ const ptr0 = passStringToWasm0(expr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
+ const len0 = WASM_VECTOR_LEN;
369
+ const ret = wasm.stream_edit(this.__wbg_ptr, ptr0, len0);
370
+ if (ret[1]) {
371
+ throw takeFromExternrefTable0(ret[0]);
372
+ }
365
373
  }
366
374
  /**
367
375
  * @returns {number | undefined}
@@ -370,6 +378,13 @@ export class Stream {
370
378
  const ret = wasm.stream_end(this.__wbg_ptr);
371
379
  return ret[0] === 0 ? undefined : ret[1];
372
380
  }
381
+ /**
382
+ * @returns {number}
383
+ */
384
+ get held_bytes() {
385
+ const ret = wasm.stream_held_bytes(this.__wbg_ptr);
386
+ return ret;
387
+ }
373
388
  /**
374
389
  * Writes the next block into `out`, component `c` from `c * block`, and returns the
375
390
  * samples each component took: `block`, fewer where silence ends inside it, `0` after.
@@ -393,21 +408,30 @@ export class Stream {
393
408
  return ret;
394
409
  }
395
410
  /**
396
- * `until` as `stream` takes it, `max_secs` counted from the checkpoint.
397
- * @param {Checkpoint} checkpoint
398
- * @param {any} bindings
399
- * @param {any} until
400
- * @param {number | null} [bits]
401
- * @param {number | null} [max_secs]
402
- * @returns {Stream}
411
+ * @param {number} handle
412
+ * @returns {boolean}
403
413
  */
404
- resume(checkpoint, bindings, until, bits, max_secs) {
405
- _assertClass(checkpoint, Checkpoint);
406
- const ret = wasm.stream_resume(this.__wbg_ptr, checkpoint.__wbg_ptr, bindings, until, isLikeNone(bits) ? Number.MAX_SAFE_INTEGER : (bits) >>> 0, !isLikeNone(max_secs), isLikeNone(max_secs) ? 0 : max_secs);
414
+ remove(handle) {
415
+ const ret = wasm.stream_remove(this.__wbg_ptr, handle);
407
416
  if (ret[2]) {
408
417
  throw takeFromExternrefTable0(ret[1]);
409
418
  }
410
- return Stream.__wrap(ret[0]);
419
+ return ret[0] !== 0;
420
+ }
421
+ /**
422
+ * False where the stream no longer holds `handle`.
423
+ * @param {number} handle
424
+ * @param {string} term
425
+ * @returns {boolean}
426
+ */
427
+ replace(handle, term) {
428
+ const ptr0 = passStringToWasm0(term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
429
+ const len0 = WASM_VECTOR_LEN;
430
+ 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;
411
435
  }
412
436
  /**
413
437
  * @returns {number}
@@ -417,7 +441,17 @@ export class Stream {
417
441
  return ret >>> 0;
418
442
  }
419
443
  /**
420
- * `{ samples, proofs, priced_flops, waves }` since it opened or resumed.
444
+ * @returns {any}
445
+ */
446
+ stats() {
447
+ const ret = wasm.stream_stats(this.__wbg_ptr);
448
+ if (ret[2]) {
449
+ throw takeFromExternrefTable0(ret[1]);
450
+ }
451
+ return takeFromExternrefTable0(ret[0]);
452
+ }
453
+ /**
454
+ * `{ samples, priced_flops, waves }` since it opened.
421
455
  * @returns {any}
422
456
  */
423
457
  work() {
@@ -458,9 +492,29 @@ export function outline(text) {
458
492
  function __wbg_get_imports() {
459
493
  const import0 = {
460
494
  __proto__: null,
495
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
496
+ const v = arg0;
497
+ const ret = typeof(v) === 'boolean' ? v : undefined;
498
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
499
+ },
461
500
  __wbg___wbindgen_copy_to_typed_array_cccd104be8cf0b8d: function(arg0, arg1, arg2) {
462
501
  new Uint8Array(arg2.buffer, arg2.byteOffset, arg2.byteLength).set(getArrayU8FromWasm0(arg0, arg1));
463
502
  },
503
+ __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
504
+ const ret = debugString(arg1);
505
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
506
+ const len1 = WASM_VECTOR_LEN;
507
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
508
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
509
+ },
510
+ __wbg___wbindgen_is_falsy_4502df4d571fca70: function(arg0) {
511
+ const ret = !arg0;
512
+ return ret;
513
+ },
514
+ __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
515
+ const ret = typeof(arg0) === 'function';
516
+ return ret;
517
+ },
464
518
  __wbg___wbindgen_is_null_5160b3e381865372: function(arg0) {
465
519
  const ret = arg0 === null;
466
520
  return ret;
@@ -486,6 +540,33 @@ function __wbg_get_imports() {
486
540
  __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
487
541
  throw new Error(getStringFromWasm0(arg0, arg1));
488
542
  },
543
+ __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
544
+ arg0._wbg_cb_unref();
545
+ },
546
+ __wbg_arrayBuffer_303605bfdb02dbaa: function(arg0) {
547
+ const ret = arg0.arrayBuffer();
548
+ return ret;
549
+ },
550
+ __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
551
+ const ret = arg0.call(arg1);
552
+ return ret;
553
+ }, arguments); },
554
+ __wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
555
+ const ret = arg0.call(arg1, arg2);
556
+ return ret;
557
+ }, arguments); },
558
+ __wbg_close_c91cbb2cddb6f7aa: function(arg0) {
559
+ const ret = arg0.close();
560
+ return ret;
561
+ },
562
+ __wbg_composition_new: function(arg0) {
563
+ const ret = Composition.__wrap(arg0);
564
+ return ret;
565
+ },
566
+ __wbg_createWritable_dcac2d262cf50ae7: function(arg0) {
567
+ const ret = arg0.createWritable();
568
+ return ret;
569
+ },
489
570
  __wbg_entries_972a87586902cf87: function(arg0) {
490
571
  const ret = Object.entries(arg0);
491
572
  return ret;
@@ -494,6 +575,22 @@ function __wbg_get_imports() {
494
575
  const ret = Array.from(arg0);
495
576
  return ret;
496
577
  },
578
+ __wbg_getDirectoryHandle_6ba4491be2862323: function(arg0, arg1, arg2, arg3) {
579
+ const ret = arg0.getDirectoryHandle(getStringFromWasm0(arg1, arg2), arg3);
580
+ return ret;
581
+ },
582
+ __wbg_getFileHandle_9709cc764716faf0: function(arg0, arg1, arg2, arg3) {
583
+ const ret = arg0.getFileHandle(getStringFromWasm0(arg1, arg2), arg3);
584
+ return ret;
585
+ },
586
+ __wbg_getFile_514e6ad2d0b16f74: function(arg0) {
587
+ const ret = arg0.getFile();
588
+ return ret;
589
+ },
590
+ __wbg_get_989d0a1309644f2b: function() { return handleError(function (arg0, arg1) {
591
+ const ret = Reflect.get(arg0, arg1);
592
+ return ret;
593
+ }, arguments); },
497
594
  __wbg_get_b1f0ab13c737f856: function(arg0, arg1) {
498
595
  const ret = arg0[arg1 >>> 0];
499
596
  return ret;
@@ -512,25 +609,182 @@ function __wbg_get_imports() {
512
609
  const ret = result;
513
610
  return ret;
514
611
  },
612
+ __wbg_isArray_5674713bb7b79043: function(arg0) {
613
+ const ret = Array.isArray(arg0);
614
+ return ret;
615
+ },
616
+ __wbg_keys_23712aa1a6f4aa5d: function(arg0) {
617
+ const ret = arg0.keys();
618
+ return ret;
619
+ },
620
+ __wbg_length_31bdaf014f5fbde2: function(arg0) {
621
+ const ret = arg0.length;
622
+ return ret;
623
+ },
515
624
  __wbg_length_4e1adc0d42e23620: function(arg0) {
516
625
  const ret = arg0.length;
517
626
  return ret;
518
627
  },
519
- __wbg_new_26350c3c2446a215: function(arg0, arg1) {
628
+ __wbg_move_2019b378ef90cf6c: function(arg0, arg1, arg2, arg3) {
629
+ const ret = arg0.move(arg1, getStringFromWasm0(arg2, arg3));
630
+ return ret;
631
+ },
632
+ __wbg_new_1da3429bc3c4541c: function(arg0) {
633
+ const ret = new Uint8Array(arg0);
634
+ return ret;
635
+ },
636
+ __wbg_new_30145d082ba9492c: function(arg0, arg1) {
520
637
  const ret = new Error(getStringFromWasm0(arg0, arg1));
521
638
  return ret;
522
639
  },
523
- __wbg_parse_e158b3a26b0b7727: function() { return handleError(function (arg0, arg1) {
640
+ __wbg_new_8f72ed7c652bf5a2: function(arg0, arg1) {
641
+ try {
642
+ var state0 = {a: arg0, b: arg1};
643
+ var cb0 = (arg0, arg1) => {
644
+ const a = state0.a;
645
+ state0.a = 0;
646
+ try {
647
+ return wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95(a, state0.b, arg0, arg1);
648
+ } finally {
649
+ state0.a = a;
650
+ }
651
+ };
652
+ const ret = new Promise(cb0);
653
+ return ret;
654
+ } finally {
655
+ state0.a = 0;
656
+ }
657
+ },
658
+ __wbg_new_bebc3f4757acf305: function() {
659
+ const ret = new Object();
660
+ return ret;
661
+ },
662
+ __wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
663
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
664
+ return ret;
665
+ },
666
+ __wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
667
+ try {
668
+ var state0 = {a: arg0, b: arg1};
669
+ var cb0 = (arg0, arg1) => {
670
+ const a = state0.a;
671
+ state0.a = 0;
672
+ try {
673
+ return wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95(a, state0.b, arg0, arg1);
674
+ } finally {
675
+ state0.a = a;
676
+ }
677
+ };
678
+ const ret = new Promise(cb0);
679
+ return ret;
680
+ } finally {
681
+ state0.a = 0;
682
+ }
683
+ },
684
+ __wbg_next_30e6632b4218cb09: function(arg0) {
685
+ const ret = arg0.next();
686
+ return ret;
687
+ },
688
+ __wbg_parse_a1c86daae8e336bd: function() { return handleError(function (arg0, arg1) {
524
689
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
525
690
  return ret;
526
691
  }, arguments); },
527
- __wbg_set_name_2739c17d34a6a152: function(arg0, arg1, arg2) {
692
+ __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
693
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
694
+ },
695
+ __wbg_query_259d928d723fff72: function(arg0) {
696
+ const ret = arg0.query();
697
+ return ret;
698
+ },
699
+ __wbg_queueMicrotask_85c90f6987555d65: function(arg0) {
700
+ const ret = arg0.queueMicrotask;
701
+ return ret;
702
+ },
703
+ __wbg_queueMicrotask_f6a1fa10b81d1fc0: function(arg0) {
704
+ queueMicrotask(arg0);
705
+ },
706
+ __wbg_random_7bce4e9e78e2e0d0: function() {
707
+ const ret = Math.random();
708
+ return ret;
709
+ },
710
+ __wbg_removeEntry_526b61f67204248f: function(arg0, arg1, arg2) {
711
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2));
712
+ return ret;
713
+ },
714
+ __wbg_removeEntry_73524952fdb64743: function(arg0, arg1, arg2, arg3) {
715
+ const ret = arg0.removeEntry(getStringFromWasm0(arg1, arg2), arg3);
716
+ return ret;
717
+ },
718
+ __wbg_rendering_new: function(arg0) {
719
+ const ret = Rendering.__wrap(arg0);
720
+ return ret;
721
+ },
722
+ __wbg_request_eda21e880c785d71: function(arg0, arg1, arg2, arg3) {
723
+ const ret = arg0.request(getStringFromWasm0(arg1, arg2), arg3);
724
+ return ret;
725
+ },
726
+ __wbg_resolve_35ec7e0c6af4c82c: function(arg0) {
727
+ const ret = Promise.resolve(arg0);
728
+ return ret;
729
+ },
730
+ __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
731
+ const ret = Reflect.set(arg0, arg1, arg2);
732
+ return ret;
733
+ }, arguments); },
734
+ __wbg_set_name_67f69e636c52b8b8: function(arg0, arg1, arg2) {
528
735
  arg0.name = getStringFromWasm0(arg1, arg2);
529
736
  },
530
- __wbg_set_refusal_b6aab88e0790b056: function(arg0, arg1) {
737
+ __wbg_set_refusal_67dcb641bf92d6bd: function(arg0, arg1) {
531
738
  arg0.refusal = arg1;
532
739
  },
740
+ __wbg_size_a827722774ab6a64: function(arg0) {
741
+ const ret = arg0.size;
742
+ return ret;
743
+ },
744
+ __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
745
+ const ret = typeof global === 'undefined' ? null : global;
746
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
747
+ },
748
+ __wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
749
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
750
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
751
+ },
752
+ __wbg_static_accessor_SELF_d8b50611246a6d92: function() {
753
+ const ret = typeof self === 'undefined' ? null : self;
754
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
755
+ },
756
+ __wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
757
+ const ret = typeof window === 'undefined' ? null : window;
758
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
759
+ },
760
+ __wbg_then_7a850dae4493f353: function(arg0, arg1, arg2) {
761
+ const ret = arg0.then(arg1, arg2);
762
+ return ret;
763
+ },
764
+ __wbg_then_b830475380919203: function(arg0, arg1) {
765
+ const ret = arg0.then(arg1);
766
+ return ret;
767
+ },
768
+ __wbg_write_b2d191debe961263: function(arg0, arg1) {
769
+ const ret = arg0.write(arg1);
770
+ return ret;
771
+ },
533
772
  __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`.
774
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd55bb211d6a08150);
775
+ return ret;
776
+ },
777
+ __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);
780
+ return ret;
781
+ },
782
+ __wbindgen_generic_0000000000000003: function(arg0) {
783
+ // Cast intrinsic for `F64 -> Externref`.
784
+ const ret = arg0;
785
+ return ret;
786
+ },
787
+ __wbindgen_generic_0000000000000004: function(arg0, arg1) {
534
788
  // Cast intrinsic for `Ref(String) -> Externref`.
535
789
  const ret = getStringFromWasm0(arg0, arg1);
536
790
  return ret;
@@ -551,9 +805,22 @@ function __wbg_get_imports() {
551
805
  };
552
806
  }
553
807
 
554
- const CheckpointFinalization = (typeof FinalizationRegistry === 'undefined')
555
- ? { register: () => {}, unregister: () => {} }
556
- : new FinalizationRegistry(ptr => wasm.__wbg_checkpoint_free(ptr, 1));
808
+ function wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385(arg0, arg1) {
809
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h2cf8ee606c8af385(arg0, arg1);
810
+ return ret;
811
+ }
812
+
813
+ function wasm_bindgen__convert__closures_____invoke__hd55bb211d6a08150(arg0, arg1, arg2) {
814
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__hd55bb211d6a08150(arg0, arg1, arg2);
815
+ if (ret[1]) {
816
+ throw takeFromExternrefTable0(ret[0]);
817
+ }
818
+ }
819
+
820
+ function wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95(arg0, arg1, arg2, arg3) {
821
+ wasm.wasm_bindgen__convert__closures_____invoke__h76bd71bceeca2b95(arg0, arg1, arg2, arg3);
822
+ }
823
+
557
824
  const CompositionFinalization = (typeof FinalizationRegistry === 'undefined')
558
825
  ? { register: () => {}, unregister: () => {} }
559
826
  : new FinalizationRegistry(ptr => wasm.__wbg_composition_free(ptr, 1));
@@ -570,10 +837,73 @@ function addToExternrefTable0(obj) {
570
837
  return idx;
571
838
  }
572
839
 
573
- function _assertClass(instance, klass) {
574
- if (!(instance instanceof klass)) {
575
- throw new Error(`expected instance of ${klass.name}`);
840
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
841
+ ? { register: () => {}, unregister: () => {} }
842
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
843
+
844
+ function debugString(val) {
845
+ // primitive types
846
+ const type = typeof val;
847
+ if (type == 'number' || type == 'boolean' || val == null) {
848
+ return `${val}`;
576
849
  }
850
+ if (type == 'string') {
851
+ return `"${val}"`;
852
+ }
853
+ if (type == 'symbol') {
854
+ const description = val.description;
855
+ if (description == null) {
856
+ return 'Symbol';
857
+ } else {
858
+ return `Symbol(${description})`;
859
+ }
860
+ }
861
+ if (type == 'function') {
862
+ const name = val.name;
863
+ if (typeof name == 'string' && name.length > 0) {
864
+ return `Function(${name})`;
865
+ } else {
866
+ return 'Function';
867
+ }
868
+ }
869
+ // objects
870
+ if (Array.isArray(val)) {
871
+ const length = val.length;
872
+ let debug = '[';
873
+ if (length > 0) {
874
+ debug += debugString(val[0]);
875
+ }
876
+ for(let i = 1; i < length; i++) {
877
+ debug += ', ' + debugString(val[i]);
878
+ }
879
+ debug += ']';
880
+ return debug;
881
+ }
882
+ // Test for built-in
883
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
884
+ let className;
885
+ if (builtInMatches && builtInMatches.length > 1) {
886
+ className = builtInMatches[1];
887
+ } else {
888
+ // Failed to match the standard '[object ClassName]'
889
+ return toString.call(val);
890
+ }
891
+ if (className == 'Object') {
892
+ // we're a user defined class or Object
893
+ // JSON.stringify avoids problems with cycles, and is generally much
894
+ // easier than looping through ownProperties of `val`.
895
+ try {
896
+ return 'Object(' + JSON.stringify(val) + ')';
897
+ } catch (_) {
898
+ return 'Object';
899
+ }
900
+ }
901
+ // errors
902
+ if (val instanceof Error) {
903
+ return `${val.name}: ${val.message}\n${val.stack}`;
904
+ }
905
+ // TODO we could test for more things here, like `Set`s and `Map`s.
906
+ return className;
577
907
  }
578
908
 
579
909
  function getArrayF32FromWasm0(ptr, len) {
@@ -627,6 +957,34 @@ function isLikeNone(x) {
627
957
  return x === undefined || x === null;
628
958
  }
629
959
 
960
+ function makeMutClosure(arg0, arg1, f) {
961
+ const state = { a: arg0, b: arg1, cnt: 1 };
962
+ const real = (...args) => {
963
+
964
+ // First up with a closure we increment the internal reference
965
+ // count. This ensures that the Rust closure environment won't
966
+ // be deallocated while we're invoking it.
967
+ state.cnt++;
968
+ const a = state.a;
969
+ state.a = 0;
970
+ try {
971
+ return f(a, state.b, ...args);
972
+ } finally {
973
+ state.a = a;
974
+ real._wbg_cb_unref();
975
+ }
976
+ };
977
+ real._wbg_cb_unref = () => {
978
+ if (--state.cnt === 0) {
979
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
980
+ state.a = 0;
981
+ CLOSURE_DTORS.unregister(state);
982
+ }
983
+ };
984
+ CLOSURE_DTORS.register(real, state, state);
985
+ return real;
986
+ }
987
+
630
988
  function passArrayF32ToWasm0(arg, malloc) {
631
989
  const ptr = malloc(arg.length * 4, 4) >>> 0;
632
990
  getFloat32ArrayMemory0().set(arg, ptr / 4);
package/sva_wasm_bg.wasm CHANGED
Binary file