@octoseq/visualiser 0.1.0-main.6402764 → 0.1.0-main.856feb5

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