@octoseq/visualiser 0.1.0-main.6402764 → 0.1.0-main.8dc1dc3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octoseq/visualiser",
3
- "version": "0.1.0-main.6402764",
3
+ "version": "0.1.0-main.8dc1dc3",
4
4
  "description": "WASM-based visualiser for Octoseq",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,12 +18,30 @@ export class WasmVisualiser {
18
18
  * The signal will be available as `inputs.<name>` in Rhai scripts.
19
19
  */
20
20
  push_signal(name: string, samples: Float32Array, sample_rate: number): void;
21
+ /**
22
+ * Run script in analysis mode to collect debug.emit() signals.
23
+ *
24
+ * This runs the script headlessly across the full track duration,
25
+ * collecting all debug.emit() calls without rendering.
26
+ *
27
+ * Returns a JSON-serialized AnalysisResultJson.
28
+ */
29
+ run_analysis(script: string, duration: number, time_step: number): string;
21
30
  /**
22
31
  * Clear all named signals.
23
32
  */
24
33
  clear_signals(): void;
25
34
  set_sigmoid_k(k: number): void;
35
+ /**
36
+ * Isolate a single entity for rendering (useful for debugging).
37
+ * Only this entity will be rendered.
38
+ */
39
+ isolate_entity(entity_id: bigint): void;
26
40
  push_zoom_data(samples: Float32Array, sample_rate: number): void;
41
+ /**
42
+ * Clear entity isolation, resume normal rendering.
43
+ */
44
+ clear_isolation(): void;
27
45
  /**
28
46
  * Get current state values for debugging.
29
47
  * Returns [time, scene_entity_count, mesh_count, line_count]
@@ -33,7 +51,168 @@ export class WasmVisualiser {
33
51
  * Get the last script error message, if any.
34
52
  */
35
53
  get_script_error(): string | undefined;
54
+ /**
55
+ * Get the list of available signal names.
56
+ * Returns a JSON array of signal names.
57
+ */
58
+ get_signal_names(): string;
59
+ /**
60
+ * Get a list of all registered mesh asset IDs.
61
+ * Returns a JSON array of asset IDs.
62
+ */
63
+ list_mesh_assets(): string;
64
+ /**
65
+ * Push pre-extracted events for a band.
66
+ *
67
+ * Events are extracted by the TypeScript layer using the existing peak picker,
68
+ * then pushed here for script access via `inputs.bands[id].events`.
69
+ *
70
+ * The JSON format should be an array of event objects with:
71
+ * - time: f32
72
+ * - weight: f32
73
+ * - beat_position: Option<f32>
74
+ * - beat_phase: Option<f32>
75
+ * - cluster_id: Option<u32>
76
+ *
77
+ * Returns true if successful, false if parsing failed.
78
+ */
79
+ push_band_events(band_id: string, events_json: string): boolean;
80
+ /**
81
+ * Push a band-scoped signal for use in scripts.
82
+ * The signal will be available as `inputs.bands[band_id].{feature}` in Rhai scripts.
83
+ * Stores under both band_id and band_label for dual-access support.
84
+ *
85
+ * - `band_id`: The unique ID of the frequency band.
86
+ * - `band_label`: The user-visible label of the band.
87
+ * - `feature`: Signal type ("energy", "onset", "flux").
88
+ * - `samples`: Signal data.
89
+ * - `sample_rate`: Sample rate of the signal.
90
+ */
91
+ push_band_signal(band_id: string, band_label: string, feature: string, samples: Float32Array, sample_rate: number): void;
92
+ /**
93
+ * Set the musical time structure for beat-aware signal processing.
94
+ * The JSON format matches the TypeScript MusicalTimeStructure type.
95
+ * Returns true if successful, false if parsing failed.
96
+ */
97
+ set_musical_time(json: string): boolean;
98
+ /**
99
+ * Clear all band event streams.
100
+ */
101
+ clear_band_events(): void;
102
+ /**
103
+ * Push a named event stream (e.g., "beatCandidates") for script access.
104
+ *
105
+ * The event stream will be available as `inputs.<name>` in Rhai scripts.
106
+ * This is used for MIR-derived events like beat candidates, onset peaks, etc.
107
+ *
108
+ * The JSON format should be an array of event objects with:
109
+ * - time: f32
110
+ * - weight: f32
111
+ * - beat_position: Option<f32>
112
+ * - beat_phase: Option<f32>
113
+ * - cluster_id: Option<u32>
114
+ *
115
+ * Returns true if successful, false if parsing failed.
116
+ */
117
+ push_event_stream(name: string, events_json: string): boolean;
118
+ /**
119
+ * Set debug visualization options.
120
+ */
121
+ set_debug_options(wireframe: boolean, bounding_boxes: boolean): void;
122
+ /**
123
+ * Clear all band signals.
124
+ */
125
+ clear_band_signals(): void;
126
+ /**
127
+ * Clear the musical time structure.
128
+ * Beat-aware operations will fall back to 120 BPM default.
129
+ */
130
+ clear_musical_time(): void;
131
+ /**
132
+ * Get frequency bounds for all active bands at a given time.
133
+ * Returns a JSON array of { bandId, label, lowHz, highHz, enabled } objects.
134
+ */
135
+ get_band_bounds_at(time: number): string;
36
136
  push_rotation_data(samples: Float32Array, sample_rate: number): void;
137
+ /**
138
+ * Render with a frame budget timeout.
139
+ *
140
+ * If the frame takes longer than `budget_ms` to process, it will be dropped
141
+ * and a warning logged. This prevents expensive scripts from freezing the browser.
142
+ *
143
+ * Returns true if the frame completed, false if it was dropped due to budget.
144
+ */
145
+ render_with_budget(dt: number, budget_ms: number): boolean;
146
+ /**
147
+ * Clear all named event streams.
148
+ */
149
+ clear_event_streams(): void;
150
+ /**
151
+ * Check if frequency bands are currently set.
152
+ */
153
+ has_frequency_bands(): boolean;
154
+ /**
155
+ * Register a mesh asset from OBJ content.
156
+ * The asset will be available as `mesh.load(asset_id)` in scripts.
157
+ * Returns true if successful, false if parsing failed.
158
+ */
159
+ register_mesh_asset(asset_id: string, obj_content: string): boolean;
160
+ /**
161
+ * Set the frequency band structure for band-aware processing.
162
+ * The JSON format matches the TypeScript FrequencyBandStructure type.
163
+ * Returns true if successful, false if parsing failed.
164
+ */
165
+ set_frequency_bands(json: string): boolean;
166
+ /**
167
+ * Get the number of events for a specific band.
168
+ * Returns 0 if no events are stored for this band.
169
+ */
170
+ get_band_event_count(band_id: string): number;
171
+ /**
172
+ * Get list of band keys (IDs and labels) that have signals.
173
+ * Returns a JSON array of strings.
174
+ */
175
+ get_band_signal_keys(): string;
176
+ /**
177
+ * Clear the frequency band structure.
178
+ */
179
+ clear_frequency_bands(): void;
180
+ /**
181
+ * Unregister a mesh asset.
182
+ * Returns true if the asset was unregistered, false if it didn't exist.
183
+ */
184
+ unregister_mesh_asset(asset_id: string): boolean;
185
+ /**
186
+ * Get the number of events in a named event stream.
187
+ * Returns 0 if no events are stored for this name.
188
+ */
189
+ get_event_stream_count(name: string): number;
190
+ /**
191
+ * Get the number of frequency bands.
192
+ */
193
+ get_frequency_band_count(): number;
194
+ /**
195
+ * Run script in analysis mode with event extraction support.
196
+ *
197
+ * This runs the script headlessly across the full track duration,
198
+ * collecting all debug.emit() calls AND extracting events from
199
+ * any signal.pick.events() calls.
200
+ *
201
+ * Returns a JSON-serialized ExtendedAnalysisResultJson.
202
+ */
203
+ run_analysis_with_events(script: string, duration: number, time_step: number): string;
204
+ /**
205
+ * Get entity positions as JSON for debugging.
206
+ * Returns a JSON array of objects with id, type, and position fields.
207
+ */
208
+ get_entity_positions_json(): string;
209
+ /**
210
+ * Drain and return any pending structured script diagnostics as JSON.
211
+ *
212
+ * Intended for UI consumption. Calling this clears the pending diagnostics
213
+ * queue so repeated polling does not duplicate messages.
214
+ */
215
+ take_script_diagnostics_json(): string;
37
216
  constructor();
38
217
  render(dt: number): void;
39
218
  resize(width: number, height: number): void;
@@ -43,6 +222,15 @@ export class WasmVisualiser {
43
222
 
44
223
  export function create_visualiser(canvas: HTMLCanvasElement): Promise<WasmVisualiser>;
45
224
 
225
+ /**
226
+ * Get the host-defined Script API metadata as a JSON string.
227
+ *
228
+ * This is a stable, versioned description of the scripting API surface and is
229
+ * intended to drive editor UX (autocomplete/hover/docs) and future language
230
+ * bindings.
231
+ */
232
+ export function get_script_api_metadata_json(): string;
233
+
46
234
  export function init_panic_hook(): void;
47
235
 
48
236
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -51,25 +239,54 @@ export interface InitOutput {
51
239
  readonly memory: WebAssembly.Memory;
52
240
  readonly __wbg_wasmvisualiser_free: (a: number, b: number) => void;
53
241
  readonly create_visualiser: (a: any) => any;
242
+ readonly get_script_api_metadata_json: () => [number, number];
243
+ readonly wasmvisualiser_clear_band_events: (a: number) => void;
244
+ readonly wasmvisualiser_clear_band_signals: (a: number) => void;
245
+ readonly wasmvisualiser_clear_event_streams: (a: number) => void;
246
+ readonly wasmvisualiser_clear_frequency_bands: (a: number) => void;
247
+ readonly wasmvisualiser_clear_isolation: (a: number) => void;
248
+ readonly wasmvisualiser_clear_musical_time: (a: number) => void;
54
249
  readonly wasmvisualiser_clear_signals: (a: number) => void;
250
+ readonly wasmvisualiser_get_band_bounds_at: (a: number, b: number) => [number, number];
251
+ readonly wasmvisualiser_get_band_event_count: (a: number, b: number, c: number) => number;
252
+ readonly wasmvisualiser_get_band_signal_keys: (a: number) => [number, number];
55
253
  readonly wasmvisualiser_get_current_vals: (a: number) => [number, number];
254
+ readonly wasmvisualiser_get_entity_positions_json: (a: number) => [number, number];
255
+ readonly wasmvisualiser_get_event_stream_count: (a: number, b: number, c: number) => number;
256
+ readonly wasmvisualiser_get_frequency_band_count: (a: number) => number;
56
257
  readonly wasmvisualiser_get_script_error: (a: number) => [number, number];
258
+ readonly wasmvisualiser_get_signal_names: (a: number) => [number, number];
259
+ readonly wasmvisualiser_has_frequency_bands: (a: number) => number;
57
260
  readonly wasmvisualiser_has_script: (a: number) => number;
261
+ readonly wasmvisualiser_isolate_entity: (a: number, b: bigint) => void;
262
+ readonly wasmvisualiser_list_mesh_assets: (a: number) => [number, number];
58
263
  readonly wasmvisualiser_load_script: (a: number, b: number, c: number) => number;
59
264
  readonly wasmvisualiser_new: () => number;
265
+ readonly wasmvisualiser_push_band_events: (a: number, b: number, c: number, d: number, e: number) => number;
266
+ readonly wasmvisualiser_push_band_signal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
60
267
  readonly wasmvisualiser_push_data: (a: number, b: number, c: number, d: number) => void;
268
+ readonly wasmvisualiser_push_event_stream: (a: number, b: number, c: number, d: number, e: number) => number;
61
269
  readonly wasmvisualiser_push_signal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
62
270
  readonly wasmvisualiser_push_zoom_data: (a: number, b: number, c: number, d: number) => void;
271
+ readonly wasmvisualiser_register_mesh_asset: (a: number, b: number, c: number, d: number, e: number) => number;
63
272
  readonly wasmvisualiser_render: (a: number, b: number) => void;
273
+ readonly wasmvisualiser_render_with_budget: (a: number, b: number, c: number) => number;
64
274
  readonly wasmvisualiser_resize: (a: number, b: number, c: number) => void;
275
+ readonly wasmvisualiser_run_analysis: (a: number, b: number, c: number, d: number, e: number) => [number, number];
276
+ readonly wasmvisualiser_run_analysis_with_events: (a: number, b: number, c: number, d: number, e: number) => [number, number];
277
+ readonly wasmvisualiser_set_debug_options: (a: number, b: number, c: number) => void;
278
+ readonly wasmvisualiser_set_frequency_bands: (a: number, b: number, c: number) => number;
279
+ readonly wasmvisualiser_set_musical_time: (a: number, b: number, c: number) => number;
65
280
  readonly wasmvisualiser_set_sigmoid_k: (a: number, b: number) => void;
66
281
  readonly wasmvisualiser_set_time: (a: number, b: number) => void;
282
+ readonly wasmvisualiser_take_script_diagnostics_json: (a: number) => [number, number];
283
+ readonly wasmvisualiser_unregister_mesh_asset: (a: number, b: number, c: number) => number;
67
284
  readonly init_panic_hook: () => void;
68
285
  readonly wasmvisualiser_push_rotation_data: (a: number, b: number, c: number, d: number) => void;
69
- readonly wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
70
- readonly wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
71
286
  readonly wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8: (a: number, b: number, c: any) => void;
72
287
  readonly wasm_bindgen__closure__destroy__heb49a8f426ac2d2e: (a: number, b: number) => void;
288
+ readonly wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
289
+ readonly wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
73
290
  readonly wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba: (a: number, b: number, c: any, d: any) => void;
74
291
  readonly __wbindgen_malloc: (a: number, b: number) => number;
75
292
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
package/pkg/visualiser.js CHANGED
@@ -241,14 +241,14 @@ if (!('encodeInto' in cachedTextEncoder)) {
241
241
 
242
242
  let WASM_VECTOR_LEN = 0;
243
243
 
244
- function wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7(arg0, arg1, arg2) {
245
- wasm.wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7(arg0, arg1, arg2);
246
- }
247
-
248
244
  function wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8(arg0, arg1, arg2) {
249
245
  wasm.wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8(arg0, arg1, arg2);
250
246
  }
251
247
 
248
+ function wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7(arg0, arg1, arg2) {
249
+ wasm.wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7(arg0, arg1, arg2);
250
+ }
251
+
252
252
  function wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba(arg0, arg1, arg2, arg3) {
253
253
  wasm.wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba(arg0, arg1, arg2, arg3);
254
254
  }
@@ -319,6 +319,32 @@ export class WasmVisualiser {
319
319
  const len1 = WASM_VECTOR_LEN;
320
320
  wasm.wasmvisualiser_push_signal(this.__wbg_ptr, ptr0, len0, ptr1, len1, sample_rate);
321
321
  }
322
+ /**
323
+ * Run script in analysis mode to collect debug.emit() signals.
324
+ *
325
+ * This runs the script headlessly across the full track duration,
326
+ * collecting all debug.emit() calls without rendering.
327
+ *
328
+ * Returns a JSON-serialized AnalysisResultJson.
329
+ * @param {string} script
330
+ * @param {number} duration
331
+ * @param {number} time_step
332
+ * @returns {string}
333
+ */
334
+ run_analysis(script, duration, time_step) {
335
+ let deferred2_0;
336
+ let deferred2_1;
337
+ try {
338
+ const ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ret = wasm.wasmvisualiser_run_analysis(this.__wbg_ptr, ptr0, len0, duration, time_step);
341
+ deferred2_0 = ret[0];
342
+ deferred2_1 = ret[1];
343
+ return getStringFromWasm0(ret[0], ret[1]);
344
+ } finally {
345
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
346
+ }
347
+ }
322
348
  /**
323
349
  * Clear all named signals.
324
350
  */
@@ -331,6 +357,14 @@ export class WasmVisualiser {
331
357
  set_sigmoid_k(k) {
332
358
  wasm.wasmvisualiser_set_sigmoid_k(this.__wbg_ptr, k);
333
359
  }
360
+ /**
361
+ * Isolate a single entity for rendering (useful for debugging).
362
+ * Only this entity will be rendered.
363
+ * @param {bigint} entity_id
364
+ */
365
+ isolate_entity(entity_id) {
366
+ wasm.wasmvisualiser_isolate_entity(this.__wbg_ptr, entity_id);
367
+ }
334
368
  /**
335
369
  * @param {Float32Array} samples
336
370
  * @param {number} sample_rate
@@ -340,6 +374,12 @@ export class WasmVisualiser {
340
374
  const len0 = WASM_VECTOR_LEN;
341
375
  wasm.wasmvisualiser_push_zoom_data(this.__wbg_ptr, ptr0, len0, sample_rate);
342
376
  }
377
+ /**
378
+ * Clear entity isolation, resume normal rendering.
379
+ */
380
+ clear_isolation() {
381
+ wasm.wasmvisualiser_clear_isolation(this.__wbg_ptr);
382
+ }
343
383
  /**
344
384
  * Get current state values for debugging.
345
385
  * Returns [time, scene_entity_count, mesh_count, line_count]
@@ -364,6 +404,177 @@ export class WasmVisualiser {
364
404
  }
365
405
  return v1;
366
406
  }
407
+ /**
408
+ * Get the list of available signal names.
409
+ * Returns a JSON array of signal names.
410
+ * @returns {string}
411
+ */
412
+ get_signal_names() {
413
+ let deferred1_0;
414
+ let deferred1_1;
415
+ try {
416
+ const ret = wasm.wasmvisualiser_get_signal_names(this.__wbg_ptr);
417
+ deferred1_0 = ret[0];
418
+ deferred1_1 = ret[1];
419
+ return getStringFromWasm0(ret[0], ret[1]);
420
+ } finally {
421
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
422
+ }
423
+ }
424
+ /**
425
+ * Get a list of all registered mesh asset IDs.
426
+ * Returns a JSON array of asset IDs.
427
+ * @returns {string}
428
+ */
429
+ list_mesh_assets() {
430
+ let deferred1_0;
431
+ let deferred1_1;
432
+ try {
433
+ const ret = wasm.wasmvisualiser_list_mesh_assets(this.__wbg_ptr);
434
+ deferred1_0 = ret[0];
435
+ deferred1_1 = ret[1];
436
+ return getStringFromWasm0(ret[0], ret[1]);
437
+ } finally {
438
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
439
+ }
440
+ }
441
+ /**
442
+ * Push pre-extracted events for a band.
443
+ *
444
+ * Events are extracted by the TypeScript layer using the existing peak picker,
445
+ * then pushed here for script access via `inputs.bands[id].events`.
446
+ *
447
+ * The JSON format should be an array of event objects with:
448
+ * - time: f32
449
+ * - weight: f32
450
+ * - beat_position: Option<f32>
451
+ * - beat_phase: Option<f32>
452
+ * - cluster_id: Option<u32>
453
+ *
454
+ * Returns true if successful, false if parsing failed.
455
+ * @param {string} band_id
456
+ * @param {string} events_json
457
+ * @returns {boolean}
458
+ */
459
+ push_band_events(band_id, events_json) {
460
+ const ptr0 = passStringToWasm0(band_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
461
+ const len0 = WASM_VECTOR_LEN;
462
+ const ptr1 = passStringToWasm0(events_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
463
+ const len1 = WASM_VECTOR_LEN;
464
+ const ret = wasm.wasmvisualiser_push_band_events(this.__wbg_ptr, ptr0, len0, ptr1, len1);
465
+ return ret !== 0;
466
+ }
467
+ /**
468
+ * Push a band-scoped signal for use in scripts.
469
+ * The signal will be available as `inputs.bands[band_id].{feature}` in Rhai scripts.
470
+ * Stores under both band_id and band_label for dual-access support.
471
+ *
472
+ * - `band_id`: The unique ID of the frequency band.
473
+ * - `band_label`: The user-visible label of the band.
474
+ * - `feature`: Signal type ("energy", "onset", "flux").
475
+ * - `samples`: Signal data.
476
+ * - `sample_rate`: Sample rate of the signal.
477
+ * @param {string} band_id
478
+ * @param {string} band_label
479
+ * @param {string} feature
480
+ * @param {Float32Array} samples
481
+ * @param {number} sample_rate
482
+ */
483
+ push_band_signal(band_id, band_label, feature, samples, sample_rate) {
484
+ const ptr0 = passStringToWasm0(band_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
485
+ const len0 = WASM_VECTOR_LEN;
486
+ const ptr1 = passStringToWasm0(band_label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
487
+ const len1 = WASM_VECTOR_LEN;
488
+ const ptr2 = passStringToWasm0(feature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
489
+ const len2 = WASM_VECTOR_LEN;
490
+ const ptr3 = passArrayF32ToWasm0(samples, wasm.__wbindgen_malloc);
491
+ const len3 = WASM_VECTOR_LEN;
492
+ wasm.wasmvisualiser_push_band_signal(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, sample_rate);
493
+ }
494
+ /**
495
+ * Set the musical time structure for beat-aware signal processing.
496
+ * The JSON format matches the TypeScript MusicalTimeStructure type.
497
+ * Returns true if successful, false if parsing failed.
498
+ * @param {string} json
499
+ * @returns {boolean}
500
+ */
501
+ set_musical_time(json) {
502
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
503
+ const len0 = WASM_VECTOR_LEN;
504
+ const ret = wasm.wasmvisualiser_set_musical_time(this.__wbg_ptr, ptr0, len0);
505
+ return ret !== 0;
506
+ }
507
+ /**
508
+ * Clear all band event streams.
509
+ */
510
+ clear_band_events() {
511
+ wasm.wasmvisualiser_clear_band_events(this.__wbg_ptr);
512
+ }
513
+ /**
514
+ * Push a named event stream (e.g., "beatCandidates") for script access.
515
+ *
516
+ * The event stream will be available as `inputs.<name>` in Rhai scripts.
517
+ * This is used for MIR-derived events like beat candidates, onset peaks, etc.
518
+ *
519
+ * The JSON format should be an array of event objects with:
520
+ * - time: f32
521
+ * - weight: f32
522
+ * - beat_position: Option<f32>
523
+ * - beat_phase: Option<f32>
524
+ * - cluster_id: Option<u32>
525
+ *
526
+ * Returns true if successful, false if parsing failed.
527
+ * @param {string} name
528
+ * @param {string} events_json
529
+ * @returns {boolean}
530
+ */
531
+ push_event_stream(name, events_json) {
532
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
533
+ const len0 = WASM_VECTOR_LEN;
534
+ const ptr1 = passStringToWasm0(events_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
535
+ const len1 = WASM_VECTOR_LEN;
536
+ const ret = wasm.wasmvisualiser_push_event_stream(this.__wbg_ptr, ptr0, len0, ptr1, len1);
537
+ return ret !== 0;
538
+ }
539
+ /**
540
+ * Set debug visualization options.
541
+ * @param {boolean} wireframe
542
+ * @param {boolean} bounding_boxes
543
+ */
544
+ set_debug_options(wireframe, bounding_boxes) {
545
+ wasm.wasmvisualiser_set_debug_options(this.__wbg_ptr, wireframe, bounding_boxes);
546
+ }
547
+ /**
548
+ * Clear all band signals.
549
+ */
550
+ clear_band_signals() {
551
+ wasm.wasmvisualiser_clear_band_signals(this.__wbg_ptr);
552
+ }
553
+ /**
554
+ * Clear the musical time structure.
555
+ * Beat-aware operations will fall back to 120 BPM default.
556
+ */
557
+ clear_musical_time() {
558
+ wasm.wasmvisualiser_clear_musical_time(this.__wbg_ptr);
559
+ }
560
+ /**
561
+ * Get frequency bounds for all active bands at a given time.
562
+ * Returns a JSON array of { bandId, label, lowHz, highHz, enabled } objects.
563
+ * @param {number} time
564
+ * @returns {string}
565
+ */
566
+ get_band_bounds_at(time) {
567
+ let deferred1_0;
568
+ let deferred1_1;
569
+ try {
570
+ const ret = wasm.wasmvisualiser_get_band_bounds_at(this.__wbg_ptr, time);
571
+ deferred1_0 = ret[0];
572
+ deferred1_1 = ret[1];
573
+ return getStringFromWasm0(ret[0], ret[1]);
574
+ } finally {
575
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
576
+ }
577
+ }
367
578
  /**
368
579
  * @param {Float32Array} samples
369
580
  * @param {number} sample_rate
@@ -373,6 +584,194 @@ export class WasmVisualiser {
373
584
  const len0 = WASM_VECTOR_LEN;
374
585
  wasm.wasmvisualiser_push_data(this.__wbg_ptr, ptr0, len0, sample_rate);
375
586
  }
587
+ /**
588
+ * Render with a frame budget timeout.
589
+ *
590
+ * If the frame takes longer than `budget_ms` to process, it will be dropped
591
+ * and a warning logged. This prevents expensive scripts from freezing the browser.
592
+ *
593
+ * Returns true if the frame completed, false if it was dropped due to budget.
594
+ * @param {number} dt
595
+ * @param {number} budget_ms
596
+ * @returns {boolean}
597
+ */
598
+ render_with_budget(dt, budget_ms) {
599
+ const ret = wasm.wasmvisualiser_render_with_budget(this.__wbg_ptr, dt, budget_ms);
600
+ return ret !== 0;
601
+ }
602
+ /**
603
+ * Clear all named event streams.
604
+ */
605
+ clear_event_streams() {
606
+ wasm.wasmvisualiser_clear_event_streams(this.__wbg_ptr);
607
+ }
608
+ /**
609
+ * Check if frequency bands are currently set.
610
+ * @returns {boolean}
611
+ */
612
+ has_frequency_bands() {
613
+ const ret = wasm.wasmvisualiser_has_frequency_bands(this.__wbg_ptr);
614
+ return ret !== 0;
615
+ }
616
+ /**
617
+ * Register a mesh asset from OBJ content.
618
+ * The asset will be available as `mesh.load(asset_id)` in scripts.
619
+ * Returns true if successful, false if parsing failed.
620
+ * @param {string} asset_id
621
+ * @param {string} obj_content
622
+ * @returns {boolean}
623
+ */
624
+ register_mesh_asset(asset_id, obj_content) {
625
+ const ptr0 = passStringToWasm0(asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
626
+ const len0 = WASM_VECTOR_LEN;
627
+ const ptr1 = passStringToWasm0(obj_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
628
+ const len1 = WASM_VECTOR_LEN;
629
+ const ret = wasm.wasmvisualiser_register_mesh_asset(this.__wbg_ptr, ptr0, len0, ptr1, len1);
630
+ return ret !== 0;
631
+ }
632
+ /**
633
+ * Set the frequency band structure for band-aware processing.
634
+ * The JSON format matches the TypeScript FrequencyBandStructure type.
635
+ * Returns true if successful, false if parsing failed.
636
+ * @param {string} json
637
+ * @returns {boolean}
638
+ */
639
+ set_frequency_bands(json) {
640
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
641
+ const len0 = WASM_VECTOR_LEN;
642
+ const ret = wasm.wasmvisualiser_set_frequency_bands(this.__wbg_ptr, ptr0, len0);
643
+ return ret !== 0;
644
+ }
645
+ /**
646
+ * Get the number of events for a specific band.
647
+ * Returns 0 if no events are stored for this band.
648
+ * @param {string} band_id
649
+ * @returns {number}
650
+ */
651
+ get_band_event_count(band_id) {
652
+ const ptr0 = passStringToWasm0(band_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
653
+ const len0 = WASM_VECTOR_LEN;
654
+ const ret = wasm.wasmvisualiser_get_band_event_count(this.__wbg_ptr, ptr0, len0);
655
+ return ret >>> 0;
656
+ }
657
+ /**
658
+ * Get list of band keys (IDs and labels) that have signals.
659
+ * Returns a JSON array of strings.
660
+ * @returns {string}
661
+ */
662
+ get_band_signal_keys() {
663
+ let deferred1_0;
664
+ let deferred1_1;
665
+ try {
666
+ const ret = wasm.wasmvisualiser_get_band_signal_keys(this.__wbg_ptr);
667
+ deferred1_0 = ret[0];
668
+ deferred1_1 = ret[1];
669
+ return getStringFromWasm0(ret[0], ret[1]);
670
+ } finally {
671
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
672
+ }
673
+ }
674
+ /**
675
+ * Clear the frequency band structure.
676
+ */
677
+ clear_frequency_bands() {
678
+ wasm.wasmvisualiser_clear_frequency_bands(this.__wbg_ptr);
679
+ }
680
+ /**
681
+ * Unregister a mesh asset.
682
+ * Returns true if the asset was unregistered, false if it didn't exist.
683
+ * @param {string} asset_id
684
+ * @returns {boolean}
685
+ */
686
+ unregister_mesh_asset(asset_id) {
687
+ const ptr0 = passStringToWasm0(asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
688
+ const len0 = WASM_VECTOR_LEN;
689
+ const ret = wasm.wasmvisualiser_unregister_mesh_asset(this.__wbg_ptr, ptr0, len0);
690
+ return ret !== 0;
691
+ }
692
+ /**
693
+ * Get the number of events in a named event stream.
694
+ * Returns 0 if no events are stored for this name.
695
+ * @param {string} name
696
+ * @returns {number}
697
+ */
698
+ get_event_stream_count(name) {
699
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
700
+ const len0 = WASM_VECTOR_LEN;
701
+ const ret = wasm.wasmvisualiser_get_event_stream_count(this.__wbg_ptr, ptr0, len0);
702
+ return ret >>> 0;
703
+ }
704
+ /**
705
+ * Get the number of frequency bands.
706
+ * @returns {number}
707
+ */
708
+ get_frequency_band_count() {
709
+ const ret = wasm.wasmvisualiser_get_frequency_band_count(this.__wbg_ptr);
710
+ return ret >>> 0;
711
+ }
712
+ /**
713
+ * Run script in analysis mode with event extraction support.
714
+ *
715
+ * This runs the script headlessly across the full track duration,
716
+ * collecting all debug.emit() calls AND extracting events from
717
+ * any signal.pick.events() calls.
718
+ *
719
+ * Returns a JSON-serialized ExtendedAnalysisResultJson.
720
+ * @param {string} script
721
+ * @param {number} duration
722
+ * @param {number} time_step
723
+ * @returns {string}
724
+ */
725
+ run_analysis_with_events(script, duration, time_step) {
726
+ let deferred2_0;
727
+ let deferred2_1;
728
+ try {
729
+ const ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
730
+ const len0 = WASM_VECTOR_LEN;
731
+ const ret = wasm.wasmvisualiser_run_analysis_with_events(this.__wbg_ptr, ptr0, len0, duration, time_step);
732
+ deferred2_0 = ret[0];
733
+ deferred2_1 = ret[1];
734
+ return getStringFromWasm0(ret[0], ret[1]);
735
+ } finally {
736
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
737
+ }
738
+ }
739
+ /**
740
+ * Get entity positions as JSON for debugging.
741
+ * Returns a JSON array of objects with id, type, and position fields.
742
+ * @returns {string}
743
+ */
744
+ get_entity_positions_json() {
745
+ let deferred1_0;
746
+ let deferred1_1;
747
+ try {
748
+ const ret = wasm.wasmvisualiser_get_entity_positions_json(this.__wbg_ptr);
749
+ deferred1_0 = ret[0];
750
+ deferred1_1 = ret[1];
751
+ return getStringFromWasm0(ret[0], ret[1]);
752
+ } finally {
753
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
754
+ }
755
+ }
756
+ /**
757
+ * Drain and return any pending structured script diagnostics as JSON.
758
+ *
759
+ * Intended for UI consumption. Calling this clears the pending diagnostics
760
+ * queue so repeated polling does not duplicate messages.
761
+ * @returns {string}
762
+ */
763
+ take_script_diagnostics_json() {
764
+ let deferred1_0;
765
+ let deferred1_1;
766
+ try {
767
+ const ret = wasm.wasmvisualiser_take_script_diagnostics_json(this.__wbg_ptr);
768
+ deferred1_0 = ret[0];
769
+ deferred1_1 = ret[1];
770
+ return getStringFromWasm0(ret[0], ret[1]);
771
+ } finally {
772
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
773
+ }
774
+ }
376
775
  constructor() {
377
776
  const ret = wasm.wasmvisualiser_new();
378
777
  this.__wbg_ptr = ret >>> 0;
@@ -419,6 +818,27 @@ export function create_visualiser(canvas) {
419
818
  return ret;
420
819
  }
421
820
 
821
+ /**
822
+ * Get the host-defined Script API metadata as a JSON string.
823
+ *
824
+ * This is a stable, versioned description of the scripting API surface and is
825
+ * intended to drive editor UX (autocomplete/hover/docs) and future language
826
+ * bindings.
827
+ * @returns {string}
828
+ */
829
+ export function get_script_api_metadata_json() {
830
+ let deferred1_0;
831
+ let deferred1_1;
832
+ try {
833
+ const ret = wasm.get_script_api_metadata_json();
834
+ deferred1_0 = ret[0];
835
+ deferred1_1 = ret[1];
836
+ return getStringFromWasm0(ret[0], ret[1]);
837
+ } finally {
838
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
839
+ }
840
+ }
841
+
422
842
  export function init_panic_hook() {
423
843
  wasm.init_panic_hook();
424
844
  }
@@ -1070,6 +1490,10 @@ function __wbg_get_imports() {
1070
1490
  const ret = arg0.offset;
1071
1491
  return ret;
1072
1492
  };
1493
+ imports.wbg.__wbg_performance_c77a440eff2efd9b = function(arg0) {
1494
+ const ret = arg0.performance;
1495
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1496
+ };
1073
1497
  imports.wbg.__wbg_popErrorScope_af0b22f136a861d6 = function(arg0) {
1074
1498
  const ret = arg0.popErrorScope();
1075
1499
  return ret;
@@ -1273,21 +1697,21 @@ function __wbg_get_imports() {
1273
1697
  imports.wbg.__wbg_writeTexture_246118eb2f5a1592 = function(arg0, arg1, arg2, arg3, arg4) {
1274
1698
  arg0.writeTexture(arg1, arg2, arg3, arg4);
1275
1699
  };
1276
- imports.wbg.__wbindgen_cast_1ad8672233d2fd7b = function(arg0, arg1) {
1277
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2007, function: Function { arguments: [Externref], shim_idx: 2008, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1278
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf5eaa61ced318e08, wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7);
1279
- return ret;
1280
- };
1281
1700
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1282
1701
  // Cast intrinsic for `Ref(String) -> Externref`.
1283
1702
  const ret = getStringFromWasm0(arg0, arg1);
1284
1703
  return ret;
1285
1704
  };
1286
- imports.wbg.__wbindgen_cast_762879c56a766cac = function(arg0, arg1) {
1287
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1873, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 1874, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1705
+ imports.wbg.__wbindgen_cast_3382faf1314a867c = function(arg0, arg1) {
1706
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2460, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 2461, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1288
1707
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__heb49a8f426ac2d2e, wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8);
1289
1708
  return ret;
1290
1709
  };
1710
+ imports.wbg.__wbindgen_cast_81075635f0fa4021 = function(arg0, arg1) {
1711
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2592, function: Function { arguments: [Externref], shim_idx: 2593, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1712
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf5eaa61ced318e08, wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7);
1713
+ return ret;
1714
+ };
1291
1715
  imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1292
1716
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1293
1717
  const ret = getArrayU8FromWasm0(arg0, arg1);
Binary file
@@ -3,25 +3,54 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_wasmvisualiser_free: (a: number, b: number) => void;
5
5
  export const create_visualiser: (a: any) => any;
6
+ export const get_script_api_metadata_json: () => [number, number];
7
+ export const wasmvisualiser_clear_band_events: (a: number) => void;
8
+ export const wasmvisualiser_clear_band_signals: (a: number) => void;
9
+ export const wasmvisualiser_clear_event_streams: (a: number) => void;
10
+ export const wasmvisualiser_clear_frequency_bands: (a: number) => void;
11
+ export const wasmvisualiser_clear_isolation: (a: number) => void;
12
+ export const wasmvisualiser_clear_musical_time: (a: number) => void;
6
13
  export const wasmvisualiser_clear_signals: (a: number) => void;
14
+ export const wasmvisualiser_get_band_bounds_at: (a: number, b: number) => [number, number];
15
+ export const wasmvisualiser_get_band_event_count: (a: number, b: number, c: number) => number;
16
+ export const wasmvisualiser_get_band_signal_keys: (a: number) => [number, number];
7
17
  export const wasmvisualiser_get_current_vals: (a: number) => [number, number];
18
+ export const wasmvisualiser_get_entity_positions_json: (a: number) => [number, number];
19
+ export const wasmvisualiser_get_event_stream_count: (a: number, b: number, c: number) => number;
20
+ export const wasmvisualiser_get_frequency_band_count: (a: number) => number;
8
21
  export const wasmvisualiser_get_script_error: (a: number) => [number, number];
22
+ export const wasmvisualiser_get_signal_names: (a: number) => [number, number];
23
+ export const wasmvisualiser_has_frequency_bands: (a: number) => number;
9
24
  export const wasmvisualiser_has_script: (a: number) => number;
25
+ export const wasmvisualiser_isolate_entity: (a: number, b: bigint) => void;
26
+ export const wasmvisualiser_list_mesh_assets: (a: number) => [number, number];
10
27
  export const wasmvisualiser_load_script: (a: number, b: number, c: number) => number;
11
28
  export const wasmvisualiser_new: () => number;
29
+ export const wasmvisualiser_push_band_events: (a: number, b: number, c: number, d: number, e: number) => number;
30
+ export const wasmvisualiser_push_band_signal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
12
31
  export const wasmvisualiser_push_data: (a: number, b: number, c: number, d: number) => void;
32
+ export const wasmvisualiser_push_event_stream: (a: number, b: number, c: number, d: number, e: number) => number;
13
33
  export const wasmvisualiser_push_signal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
14
34
  export const wasmvisualiser_push_zoom_data: (a: number, b: number, c: number, d: number) => void;
35
+ export const wasmvisualiser_register_mesh_asset: (a: number, b: number, c: number, d: number, e: number) => number;
15
36
  export const wasmvisualiser_render: (a: number, b: number) => void;
37
+ export const wasmvisualiser_render_with_budget: (a: number, b: number, c: number) => number;
16
38
  export const wasmvisualiser_resize: (a: number, b: number, c: number) => void;
39
+ export const wasmvisualiser_run_analysis: (a: number, b: number, c: number, d: number, e: number) => [number, number];
40
+ export const wasmvisualiser_run_analysis_with_events: (a: number, b: number, c: number, d: number, e: number) => [number, number];
41
+ export const wasmvisualiser_set_debug_options: (a: number, b: number, c: number) => void;
42
+ export const wasmvisualiser_set_frequency_bands: (a: number, b: number, c: number) => number;
43
+ export const wasmvisualiser_set_musical_time: (a: number, b: number, c: number) => number;
17
44
  export const wasmvisualiser_set_sigmoid_k: (a: number, b: number) => void;
18
45
  export const wasmvisualiser_set_time: (a: number, b: number) => void;
46
+ export const wasmvisualiser_take_script_diagnostics_json: (a: number) => [number, number];
47
+ export const wasmvisualiser_unregister_mesh_asset: (a: number, b: number, c: number) => number;
19
48
  export const init_panic_hook: () => void;
20
49
  export const wasmvisualiser_push_rotation_data: (a: number, b: number, c: number, d: number) => void;
21
- export const wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
22
- export const wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
23
50
  export const wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8: (a: number, b: number, c: any) => void;
24
51
  export const wasm_bindgen__closure__destroy__heb49a8f426ac2d2e: (a: number, b: number) => void;
52
+ export const wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
53
+ export const wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
25
54
  export const wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba: (a: number, b: number, c: any, d: any) => void;
26
55
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
56
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;