@ilusiv/fyug-js 2026.11.8 → 2026.11.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/generated/embedded-assets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAW,mrfAAmrf,CAAC;AAEjuf,MAAM,CAAC,MAAM,kBAAkB,GAAW,07qhIAA07qhI,CAAC"}
1
+ {"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/generated/embedded-assets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAW,gkhBAAgkhB,CAAC;AAE9mhB,MAAM,CAAC,MAAM,kBAAkB,GAAW,8l/1IAA8l/1I,CAAC"}
@@ -17,16 +17,24 @@ export class FugueEngine {
17
17
  addModule(id: string, module_type: string, config_json?: string | null): void;
18
18
  /**
19
19
  * Applies a JSON array of `apply_edits` operations (`add_module`,
20
- * `remove_module`, `connect`, `disconnect`) to the loaded graph as one
21
- * change, or refuses them all with nothing changed.
20
+ * `remove_module`, `connect`, `disconnect`, `set_control`) to the
21
+ * loaded graph as one change, or refuses them all with nothing changed.
22
+ *
23
+ * Returns the batch's report as JSON text (see [`RenderEditsReport`]):
24
+ * `controls_written`, `controls_failed` when a write failed as it was
25
+ * made, and `configs`, each written module's config as the engine's
26
+ * document now holds it, for a host that keeps its own copy.
22
27
  *
23
28
  * A refusal throws the daemon's error as JSON text: `code`, `message`
24
29
  * and, when one edit is to blame, `edit` with its `index`, `op` and
25
30
  * `reason`. The edits build and install on the calling thread, between
26
31
  * renders: on an AudioWorklet that is the audio thread, so a batch
27
- * that builds heavy modules can delay the next render.
32
+ * that builds heavy modules, or checks `set_control` writes on
33
+ * throwaway copies of their modules, can delay the next render.
34
+ *
35
+ * [`RenderEditsReport`]: crate::RenderEditsReport
28
36
  */
29
- applyEdits(edits_json: string): void;
37
+ applyEdits(edits_json: string): string;
30
38
  /**
31
39
  * Connects two module ports.
32
40
  */
@@ -142,6 +150,29 @@ export class FugueEngine {
142
150
  * Sets a string control value.
143
151
  */
144
152
  setControlString(module_id: string, key: string, value: string): void;
153
+ /**
154
+ * Makes a JSON array of control writes (each `module_id`, `key`,
155
+ * `value`, and optionally `intent`, `source` and `priority`) in order,
156
+ * or none of them, as a daemon's `set_controls` does: a value in a
157
+ * loose form (number text, a choice in another case) is read as its
158
+ * control's kind, and a number outside the range its control holds is
159
+ * set to the nearer limit.
160
+ *
161
+ * Returns `{"controls": [...]}` as JSON text, an entry per write with
162
+ * the daemon's fields: `module_id`, `key`, `value` (read back),
163
+ * `state`, `requested`, `clamped` when it was clamped, and `reason`
164
+ * when it failed as it was made. A refusal throws the daemon's error
165
+ * as JSON text: `code` `invalid_control_write`, `message`, and `write`
166
+ * with the refused write's `index`, `module_id`, `key`, `reason` and
167
+ * `message`; nothing was written.
168
+ */
169
+ setControls(writes_json: string): string;
170
+ /**
171
+ * Names the clock whose beats `takeViewsInto` reads, or none. It copies
172
+ * the id, so call it when the clock changes (a load or an edit), never
173
+ * per read.
174
+ */
175
+ setViewsClock(clock?: string | null): void;
145
176
  /**
146
177
  * Returns runtime status as a JSON string.
147
178
  */
@@ -150,7 +181,7 @@ export class FugueEngine {
150
181
  * The output's levels since the last call (or since the piece loaded),
151
182
  * as JSON: `left_peak` and `right_peak` (linear, read before the
152
183
  * device clamp, so an over reads above 1.0), `left_rms` and `right_rms`
153
- * (before the clamp, absent with no frames or a non-finite sum),
184
+ * (of the samples rendered, after the clamp; absent with no frames),
154
185
  * `frames`, `left_overs` and `right_overs` (samples beyond ±1.0, which
155
186
  * the clamp cut) and `non_finite_samples` (NaN or ±inf samples the
156
187
  * sinks silenced; a sink rebuilt during the stretch takes its count
@@ -158,6 +189,21 @@ export class FugueEngine {
158
189
  * starts after it.
159
190
  */
160
191
  takeLevels(): string;
192
+ /**
193
+ * Takes the output's levels since the last read (the same stretch
194
+ * `takeLevels` measures, which then starts over) and the views clock's
195
+ * beats, written into `out` (length `viewsLength()`) as `[left_peak,
196
+ * right_peak, left_rms, right_rms, frames, left_overs, right_overs,
197
+ * non_finite_samples, beats]`. An absent RMS or beats count is NaN.
198
+ * Returns false, writing nothing, with no piece loaded. Allocates
199
+ * nothing on the wasm heap, so a player may call it from its audio
200
+ * thread; the copy out makes one short-lived typed-array view in JS.
201
+ */
202
+ takeViewsInto(out: Float64Array): boolean;
203
+ /**
204
+ * The length of the buffer `takeViewsInto` fills.
205
+ */
206
+ static viewsLength(): number;
161
207
  }
162
208
 
163
209
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -166,7 +212,7 @@ export interface InitOutput {
166
212
  readonly memory: WebAssembly.Memory;
167
213
  readonly __wbg_fugueengine_free: (a: number, b: number) => void;
168
214
  readonly fugueengine_addModule: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
169
- readonly fugueengine_applyEdits: (a: number, b: number, c: number) => [number, number];
215
+ readonly fugueengine_applyEdits: (a: number, b: number, c: number) => [number, number, number, number];
170
216
  readonly fugueengine_connect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
171
217
  readonly fugueengine_disconnect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
172
218
  readonly fugueengine_finishAudioFileSink: (a: number, b: number, c: number) => [number, number, number, number];
@@ -191,8 +237,12 @@ export interface InitOutput {
191
237
  readonly fugueengine_setControlBool: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
192
238
  readonly fugueengine_setControlNumber: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
193
239
  readonly fugueengine_setControlString: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
240
+ readonly fugueengine_setControls: (a: number, b: number, c: number) => [number, number, number, number];
241
+ readonly fugueengine_setViewsClock: (a: number, b: number, c: number) => void;
194
242
  readonly fugueengine_status: (a: number) => [number, number, number, number];
195
243
  readonly fugueengine_takeLevels: (a: number) => [number, number, number, number];
244
+ readonly fugueengine_takeViewsInto: (a: number, b: any) => [number, number, number];
245
+ readonly fugueengine_viewsLength: () => number;
196
246
  readonly wasm_bindgen__convert__closures_____invoke__h1b9b7a832ddda534: (a: number, b: number, c: any, d: any) => void;
197
247
  readonly wasm_bindgen__convert__closures_____invoke__hd2d6d321acd2ef74: (a: number, b: number) => void;
198
248
  readonly __wbindgen_exn_store: (a: number) => void;
@@ -38,22 +38,43 @@ export class FugueEngine {
38
38
  }
39
39
  /**
40
40
  * Applies a JSON array of `apply_edits` operations (`add_module`,
41
- * `remove_module`, `connect`, `disconnect`) to the loaded graph as one
42
- * change, or refuses them all with nothing changed.
41
+ * `remove_module`, `connect`, `disconnect`, `set_control`) to the
42
+ * loaded graph as one change, or refuses them all with nothing changed.
43
+ *
44
+ * Returns the batch's report as JSON text (see [`RenderEditsReport`]):
45
+ * `controls_written`, `controls_failed` when a write failed as it was
46
+ * made, and `configs`, each written module's config as the engine's
47
+ * document now holds it, for a host that keeps its own copy.
43
48
  *
44
49
  * A refusal throws the daemon's error as JSON text: `code`, `message`
45
50
  * and, when one edit is to blame, `edit` with its `index`, `op` and
46
51
  * `reason`. The edits build and install on the calling thread, between
47
52
  * renders: on an AudioWorklet that is the audio thread, so a batch
48
- * that builds heavy modules can delay the next render.
53
+ * that builds heavy modules, or checks `set_control` writes on
54
+ * throwaway copies of their modules, can delay the next render.
55
+ *
56
+ * [`RenderEditsReport`]: crate::RenderEditsReport
49
57
  * @param {string} edits_json
58
+ * @returns {string}
50
59
  */
51
60
  applyEdits(edits_json) {
52
- const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
- const len0 = WASM_VECTOR_LEN;
54
- const ret = wasm.fugueengine_applyEdits(this.__wbg_ptr, ptr0, len0);
55
- if (ret[1]) {
56
- throw takeFromExternrefTable0(ret[0]);
61
+ let deferred3_0;
62
+ let deferred3_1;
63
+ try {
64
+ const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
65
+ const len0 = WASM_VECTOR_LEN;
66
+ const ret = wasm.fugueengine_applyEdits(this.__wbg_ptr, ptr0, len0);
67
+ var ptr2 = ret[0];
68
+ var len2 = ret[1];
69
+ if (ret[3]) {
70
+ ptr2 = 0; len2 = 0;
71
+ throw takeFromExternrefTable0(ret[2]);
72
+ }
73
+ deferred3_0 = ptr2;
74
+ deferred3_1 = len2;
75
+ return getStringFromWasm0(ptr2, len2);
76
+ } finally {
77
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
57
78
  }
58
79
  }
59
80
  /**
@@ -507,6 +528,55 @@ export class FugueEngine {
507
528
  throw takeFromExternrefTable0(ret[0]);
508
529
  }
509
530
  }
531
+ /**
532
+ * Makes a JSON array of control writes (each `module_id`, `key`,
533
+ * `value`, and optionally `intent`, `source` and `priority`) in order,
534
+ * or none of them, as a daemon's `set_controls` does: a value in a
535
+ * loose form (number text, a choice in another case) is read as its
536
+ * control's kind, and a number outside the range its control holds is
537
+ * set to the nearer limit.
538
+ *
539
+ * Returns `{"controls": [...]}` as JSON text, an entry per write with
540
+ * the daemon's fields: `module_id`, `key`, `value` (read back),
541
+ * `state`, `requested`, `clamped` when it was clamped, and `reason`
542
+ * when it failed as it was made. A refusal throws the daemon's error
543
+ * as JSON text: `code` `invalid_control_write`, `message`, and `write`
544
+ * with the refused write's `index`, `module_id`, `key`, `reason` and
545
+ * `message`; nothing was written.
546
+ * @param {string} writes_json
547
+ * @returns {string}
548
+ */
549
+ setControls(writes_json) {
550
+ let deferred3_0;
551
+ let deferred3_1;
552
+ try {
553
+ const ptr0 = passStringToWasm0(writes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
554
+ const len0 = WASM_VECTOR_LEN;
555
+ const ret = wasm.fugueengine_setControls(this.__wbg_ptr, ptr0, len0);
556
+ var ptr2 = ret[0];
557
+ var len2 = ret[1];
558
+ if (ret[3]) {
559
+ ptr2 = 0; len2 = 0;
560
+ throw takeFromExternrefTable0(ret[2]);
561
+ }
562
+ deferred3_0 = ptr2;
563
+ deferred3_1 = len2;
564
+ return getStringFromWasm0(ptr2, len2);
565
+ } finally {
566
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
567
+ }
568
+ }
569
+ /**
570
+ * Names the clock whose beats `takeViewsInto` reads, or none. It copies
571
+ * the id, so call it when the clock changes (a load or an edit), never
572
+ * per read.
573
+ * @param {string | null} [clock]
574
+ */
575
+ setViewsClock(clock) {
576
+ var ptr0 = isLikeNone(clock) ? 0 : passStringToWasm0(clock, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
577
+ var len0 = WASM_VECTOR_LEN;
578
+ wasm.fugueengine_setViewsClock(this.__wbg_ptr, ptr0, len0);
579
+ }
510
580
  /**
511
581
  * Returns runtime status as a JSON string.
512
582
  * @returns {string}
@@ -533,7 +603,7 @@ export class FugueEngine {
533
603
  * The output's levels since the last call (or since the piece loaded),
534
604
  * as JSON: `left_peak` and `right_peak` (linear, read before the
535
605
  * device clamp, so an over reads above 1.0), `left_rms` and `right_rms`
536
- * (before the clamp, absent with no frames or a non-finite sum),
606
+ * (of the samples rendered, after the clamp; absent with no frames),
537
607
  * `frames`, `left_overs` and `right_overs` (samples beyond ±1.0, which
538
608
  * the clamp cut) and `non_finite_samples` (NaN or ±inf samples the
539
609
  * sinks silenced; a sink rebuilt during the stretch takes its count
@@ -559,6 +629,33 @@ export class FugueEngine {
559
629
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
560
630
  }
561
631
  }
632
+ /**
633
+ * Takes the output's levels since the last read (the same stretch
634
+ * `takeLevels` measures, which then starts over) and the views clock's
635
+ * beats, written into `out` (length `viewsLength()`) as `[left_peak,
636
+ * right_peak, left_rms, right_rms, frames, left_overs, right_overs,
637
+ * non_finite_samples, beats]`. An absent RMS or beats count is NaN.
638
+ * Returns false, writing nothing, with no piece loaded. Allocates
639
+ * nothing on the wasm heap, so a player may call it from its audio
640
+ * thread; the copy out makes one short-lived typed-array view in JS.
641
+ * @param {Float64Array} out
642
+ * @returns {boolean}
643
+ */
644
+ takeViewsInto(out) {
645
+ const ret = wasm.fugueengine_takeViewsInto(this.__wbg_ptr, out);
646
+ if (ret[2]) {
647
+ throw takeFromExternrefTable0(ret[1]);
648
+ }
649
+ return ret[0] !== 0;
650
+ }
651
+ /**
652
+ * The length of the buffer `takeViewsInto` fills.
653
+ * @returns {number}
654
+ */
655
+ static viewsLength() {
656
+ const ret = wasm.fugueengine_viewsLength();
657
+ return ret >>> 0;
658
+ }
562
659
  }
563
660
  if (Symbol.dispose) FugueEngine.prototype[Symbol.dispose] = FugueEngine.prototype.free;
564
661
  function __wbg_get_imports() {
@@ -581,6 +678,10 @@ function __wbg_get_imports() {
581
678
  const ret = arg0.length;
582
679
  return ret;
583
680
  },
681
+ __wbg_length_b5f0008bbf60cf59: function(arg0) {
682
+ const ret = arg0.length;
683
+ return ret;
684
+ },
584
685
  __wbg_new_5502aad30c185fc8: function(arg0, arg1) {
585
686
  try {
586
687
  var state0 = {a: arg0, b: arg1};
@@ -610,8 +711,11 @@ function __wbg_get_imports() {
610
711
  __wbg_set_070bd465f1c195a4: function(arg0, arg1, arg2) {
611
712
  arg0.set(getArrayF32FromWasm0(arg1, arg2));
612
713
  },
714
+ __wbg_set_8b5ae6cfd49dec9f: function(arg0, arg1, arg2) {
715
+ arg0.set(getArrayF64FromWasm0(arg1, arg2));
716
+ },
613
717
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
614
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1640, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
718
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1660, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
615
719
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd2d6d321acd2ef74);
616
720
  return ret;
617
721
  },
@@ -663,6 +767,11 @@ function getArrayF32FromWasm0(ptr, len) {
663
767
  return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
664
768
  }
665
769
 
770
+ function getArrayF64FromWasm0(ptr, len) {
771
+ ptr = ptr >>> 0;
772
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
773
+ }
774
+
666
775
  function getArrayU8FromWasm0(ptr, len) {
667
776
  ptr = ptr >>> 0;
668
777
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -676,6 +785,14 @@ function getFloat32ArrayMemory0() {
676
785
  return cachedFloat32ArrayMemory0;
677
786
  }
678
787
 
788
+ let cachedFloat64ArrayMemory0 = null;
789
+ function getFloat64ArrayMemory0() {
790
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
791
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
792
+ }
793
+ return cachedFloat64ArrayMemory0;
794
+ }
795
+
679
796
  function getStringFromWasm0(ptr, len) {
680
797
  return decodeText(ptr >>> 0, len);
681
798
  }
@@ -814,6 +931,7 @@ function __wbg_finalize_init(instance, module) {
814
931
  wasm = instance.exports;
815
932
  wasmModule = module;
816
933
  cachedFloat32ArrayMemory0 = null;
934
+ cachedFloat64ArrayMemory0 = null;
817
935
  cachedUint8ArrayMemory0 = null;
818
936
  wasm.__wbindgen_start();
819
937
  return wasm;
Binary file
@@ -3,7 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_fugueengine_free: (a: number, b: number) => void;
5
5
  export const fugueengine_addModule: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
6
- export const fugueengine_applyEdits: (a: number, b: number, c: number) => [number, number];
6
+ export const fugueengine_applyEdits: (a: number, b: number, c: number) => [number, number, number, number];
7
7
  export const fugueengine_connect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
8
8
  export const fugueengine_disconnect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
9
9
  export const fugueengine_finishAudioFileSink: (a: number, b: number, c: number) => [number, number, number, number];
@@ -28,8 +28,12 @@ export const fugueengine_setCodeModuleStatus: (a: number, b: number, c: number,
28
28
  export const fugueengine_setControlBool: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
29
29
  export const fugueengine_setControlNumber: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
30
30
  export const fugueengine_setControlString: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
31
+ export const fugueengine_setControls: (a: number, b: number, c: number) => [number, number, number, number];
32
+ export const fugueengine_setViewsClock: (a: number, b: number, c: number) => void;
31
33
  export const fugueengine_status: (a: number) => [number, number, number, number];
32
34
  export const fugueengine_takeLevels: (a: number) => [number, number, number, number];
35
+ export const fugueengine_takeViewsInto: (a: number, b: any) => [number, number, number];
36
+ export const fugueengine_viewsLength: () => number;
33
37
  export const wasm_bindgen__convert__closures_____invoke__h1b9b7a832ddda534: (a: number, b: number, c: any, d: any) => void;
34
38
  export const wasm_bindgen__convert__closures_____invoke__hd2d6d321acd2ef74: (a: number, b: number) => void;
35
39
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilusiv/fyug-js",
3
- "version": "2026.11.8",
3
+ "version": "2026.11.9",
4
4
  "description": "Browser JavaScript player for the Fyug runtime.",
5
5
  "type": "module",
6
6
  "license": "MIT",