@octoseq/visualiser 0.1.0-main.6402764 → 0.1.0-main.97b6261

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.97b6261",
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,143 @@ 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
+ * Set debug visualization options.
104
+ */
105
+ set_debug_options(wireframe: boolean, bounding_boxes: boolean): void;
106
+ /**
107
+ * Clear all band signals.
108
+ */
109
+ clear_band_signals(): void;
110
+ /**
111
+ * Clear the musical time structure.
112
+ * Beat-aware operations will fall back to 120 BPM default.
113
+ */
114
+ clear_musical_time(): void;
115
+ /**
116
+ * Get frequency bounds for all active bands at a given time.
117
+ * Returns a JSON array of { bandId, label, lowHz, highHz, enabled } objects.
118
+ */
119
+ get_band_bounds_at(time: number): string;
36
120
  push_rotation_data(samples: Float32Array, sample_rate: number): void;
121
+ /**
122
+ * Render with a frame budget timeout.
123
+ *
124
+ * If the frame takes longer than `budget_ms` to process, it will be dropped
125
+ * and a warning logged. This prevents expensive scripts from freezing the browser.
126
+ *
127
+ * Returns true if the frame completed, false if it was dropped due to budget.
128
+ */
129
+ render_with_budget(dt: number, budget_ms: number): boolean;
130
+ /**
131
+ * Check if frequency bands are currently set.
132
+ */
133
+ has_frequency_bands(): boolean;
134
+ /**
135
+ * Register a mesh asset from OBJ content.
136
+ * The asset will be available as `mesh.load(asset_id)` in scripts.
137
+ * Returns true if successful, false if parsing failed.
138
+ */
139
+ register_mesh_asset(asset_id: string, obj_content: string): boolean;
140
+ /**
141
+ * Set the frequency band structure for band-aware processing.
142
+ * The JSON format matches the TypeScript FrequencyBandStructure type.
143
+ * Returns true if successful, false if parsing failed.
144
+ */
145
+ set_frequency_bands(json: string): boolean;
146
+ /**
147
+ * Get the number of events for a specific band.
148
+ * Returns 0 if no events are stored for this band.
149
+ */
150
+ get_band_event_count(band_id: string): number;
151
+ /**
152
+ * Get list of band keys (IDs and labels) that have signals.
153
+ * Returns a JSON array of strings.
154
+ */
155
+ get_band_signal_keys(): string;
156
+ /**
157
+ * Clear the frequency band structure.
158
+ */
159
+ clear_frequency_bands(): void;
160
+ /**
161
+ * Unregister a mesh asset.
162
+ * Returns true if the asset was unregistered, false if it didn't exist.
163
+ */
164
+ unregister_mesh_asset(asset_id: string): boolean;
165
+ /**
166
+ * Get the number of frequency bands.
167
+ */
168
+ get_frequency_band_count(): number;
169
+ /**
170
+ * Run script in analysis mode with event extraction support.
171
+ *
172
+ * This runs the script headlessly across the full track duration,
173
+ * collecting all debug.emit() calls AND extracting events from
174
+ * any signal.pick.events() calls.
175
+ *
176
+ * Returns a JSON-serialized ExtendedAnalysisResultJson.
177
+ */
178
+ run_analysis_with_events(script: string, duration: number, time_step: number): string;
179
+ /**
180
+ * Get entity positions as JSON for debugging.
181
+ * Returns a JSON array of objects with id, type, and position fields.
182
+ */
183
+ get_entity_positions_json(): string;
184
+ /**
185
+ * Drain and return any pending structured script diagnostics as JSON.
186
+ *
187
+ * Intended for UI consumption. Calling this clears the pending diagnostics
188
+ * queue so repeated polling does not duplicate messages.
189
+ */
190
+ take_script_diagnostics_json(): string;
37
191
  constructor();
38
192
  render(dt: number): void;
39
193
  resize(width: number, height: number): void;
@@ -43,6 +197,15 @@ export class WasmVisualiser {
43
197
 
44
198
  export function create_visualiser(canvas: HTMLCanvasElement): Promise<WasmVisualiser>;
45
199
 
200
+ /**
201
+ * Get the host-defined Script API metadata as a JSON string.
202
+ *
203
+ * This is a stable, versioned description of the scripting API surface and is
204
+ * intended to drive editor UX (autocomplete/hover/docs) and future language
205
+ * bindings.
206
+ */
207
+ export function get_script_api_metadata_json(): string;
208
+
46
209
  export function init_panic_hook(): void;
47
210
 
48
211
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -51,25 +214,51 @@ export interface InitOutput {
51
214
  readonly memory: WebAssembly.Memory;
52
215
  readonly __wbg_wasmvisualiser_free: (a: number, b: number) => void;
53
216
  readonly create_visualiser: (a: any) => any;
217
+ readonly get_script_api_metadata_json: () => [number, number];
218
+ readonly wasmvisualiser_clear_band_events: (a: number) => void;
219
+ readonly wasmvisualiser_clear_band_signals: (a: number) => void;
220
+ readonly wasmvisualiser_clear_frequency_bands: (a: number) => void;
221
+ readonly wasmvisualiser_clear_isolation: (a: number) => void;
222
+ readonly wasmvisualiser_clear_musical_time: (a: number) => void;
54
223
  readonly wasmvisualiser_clear_signals: (a: number) => void;
224
+ readonly wasmvisualiser_get_band_bounds_at: (a: number, b: number) => [number, number];
225
+ readonly wasmvisualiser_get_band_event_count: (a: number, b: number, c: number) => number;
226
+ readonly wasmvisualiser_get_band_signal_keys: (a: number) => [number, number];
55
227
  readonly wasmvisualiser_get_current_vals: (a: number) => [number, number];
228
+ readonly wasmvisualiser_get_entity_positions_json: (a: number) => [number, number];
229
+ readonly wasmvisualiser_get_frequency_band_count: (a: number) => number;
56
230
  readonly wasmvisualiser_get_script_error: (a: number) => [number, number];
231
+ readonly wasmvisualiser_get_signal_names: (a: number) => [number, number];
232
+ readonly wasmvisualiser_has_frequency_bands: (a: number) => number;
57
233
  readonly wasmvisualiser_has_script: (a: number) => number;
234
+ readonly wasmvisualiser_isolate_entity: (a: number, b: bigint) => void;
235
+ readonly wasmvisualiser_list_mesh_assets: (a: number) => [number, number];
58
236
  readonly wasmvisualiser_load_script: (a: number, b: number, c: number) => number;
59
237
  readonly wasmvisualiser_new: () => number;
238
+ readonly wasmvisualiser_push_band_events: (a: number, b: number, c: number, d: number, e: number) => number;
239
+ 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
240
  readonly wasmvisualiser_push_data: (a: number, b: number, c: number, d: number) => void;
61
241
  readonly wasmvisualiser_push_signal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
62
242
  readonly wasmvisualiser_push_zoom_data: (a: number, b: number, c: number, d: number) => void;
243
+ readonly wasmvisualiser_register_mesh_asset: (a: number, b: number, c: number, d: number, e: number) => number;
63
244
  readonly wasmvisualiser_render: (a: number, b: number) => void;
245
+ readonly wasmvisualiser_render_with_budget: (a: number, b: number, c: number) => number;
64
246
  readonly wasmvisualiser_resize: (a: number, b: number, c: number) => void;
247
+ readonly wasmvisualiser_run_analysis: (a: number, b: number, c: number, d: number, e: number) => [number, number];
248
+ readonly wasmvisualiser_run_analysis_with_events: (a: number, b: number, c: number, d: number, e: number) => [number, number];
249
+ readonly wasmvisualiser_set_debug_options: (a: number, b: number, c: number) => void;
250
+ readonly wasmvisualiser_set_frequency_bands: (a: number, b: number, c: number) => number;
251
+ readonly wasmvisualiser_set_musical_time: (a: number, b: number, c: number) => number;
65
252
  readonly wasmvisualiser_set_sigmoid_k: (a: number, b: number) => void;
66
253
  readonly wasmvisualiser_set_time: (a: number, b: number) => void;
67
- readonly init_panic_hook: () => void;
254
+ readonly wasmvisualiser_take_script_diagnostics_json: (a: number) => [number, number];
255
+ readonly wasmvisualiser_unregister_mesh_asset: (a: number, b: number, c: number) => number;
68
256
  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;
257
+ readonly init_panic_hook: () => void;
71
258
  readonly wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8: (a: number, b: number, c: any) => void;
72
259
  readonly wasm_bindgen__closure__destroy__heb49a8f426ac2d2e: (a: number, b: number) => void;
260
+ readonly wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
261
+ readonly wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
73
262
  readonly wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba: (a: number, b: number, c: any, d: any) => void;
74
263
  readonly __wbindgen_malloc: (a: number, b: number) => number;
75
264
  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,151 @@ 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
+ * Set debug visualization options.
515
+ * @param {boolean} wireframe
516
+ * @param {boolean} bounding_boxes
517
+ */
518
+ set_debug_options(wireframe, bounding_boxes) {
519
+ wasm.wasmvisualiser_set_debug_options(this.__wbg_ptr, wireframe, bounding_boxes);
520
+ }
521
+ /**
522
+ * Clear all band signals.
523
+ */
524
+ clear_band_signals() {
525
+ wasm.wasmvisualiser_clear_band_signals(this.__wbg_ptr);
526
+ }
527
+ /**
528
+ * Clear the musical time structure.
529
+ * Beat-aware operations will fall back to 120 BPM default.
530
+ */
531
+ clear_musical_time() {
532
+ wasm.wasmvisualiser_clear_musical_time(this.__wbg_ptr);
533
+ }
534
+ /**
535
+ * Get frequency bounds for all active bands at a given time.
536
+ * Returns a JSON array of { bandId, label, lowHz, highHz, enabled } objects.
537
+ * @param {number} time
538
+ * @returns {string}
539
+ */
540
+ get_band_bounds_at(time) {
541
+ let deferred1_0;
542
+ let deferred1_1;
543
+ try {
544
+ const ret = wasm.wasmvisualiser_get_band_bounds_at(this.__wbg_ptr, time);
545
+ deferred1_0 = ret[0];
546
+ deferred1_1 = ret[1];
547
+ return getStringFromWasm0(ret[0], ret[1]);
548
+ } finally {
549
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
550
+ }
551
+ }
367
552
  /**
368
553
  * @param {Float32Array} samples
369
554
  * @param {number} sample_rate
@@ -373,6 +558,176 @@ export class WasmVisualiser {
373
558
  const len0 = WASM_VECTOR_LEN;
374
559
  wasm.wasmvisualiser_push_data(this.__wbg_ptr, ptr0, len0, sample_rate);
375
560
  }
561
+ /**
562
+ * Render with a frame budget timeout.
563
+ *
564
+ * If the frame takes longer than `budget_ms` to process, it will be dropped
565
+ * and a warning logged. This prevents expensive scripts from freezing the browser.
566
+ *
567
+ * Returns true if the frame completed, false if it was dropped due to budget.
568
+ * @param {number} dt
569
+ * @param {number} budget_ms
570
+ * @returns {boolean}
571
+ */
572
+ render_with_budget(dt, budget_ms) {
573
+ const ret = wasm.wasmvisualiser_render_with_budget(this.__wbg_ptr, dt, budget_ms);
574
+ return ret !== 0;
575
+ }
576
+ /**
577
+ * Check if frequency bands are currently set.
578
+ * @returns {boolean}
579
+ */
580
+ has_frequency_bands() {
581
+ const ret = wasm.wasmvisualiser_has_frequency_bands(this.__wbg_ptr);
582
+ return ret !== 0;
583
+ }
584
+ /**
585
+ * Register a mesh asset from OBJ content.
586
+ * The asset will be available as `mesh.load(asset_id)` in scripts.
587
+ * Returns true if successful, false if parsing failed.
588
+ * @param {string} asset_id
589
+ * @param {string} obj_content
590
+ * @returns {boolean}
591
+ */
592
+ register_mesh_asset(asset_id, obj_content) {
593
+ const ptr0 = passStringToWasm0(asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
594
+ const len0 = WASM_VECTOR_LEN;
595
+ const ptr1 = passStringToWasm0(obj_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
596
+ const len1 = WASM_VECTOR_LEN;
597
+ const ret = wasm.wasmvisualiser_register_mesh_asset(this.__wbg_ptr, ptr0, len0, ptr1, len1);
598
+ return ret !== 0;
599
+ }
600
+ /**
601
+ * Set the frequency band structure for band-aware processing.
602
+ * The JSON format matches the TypeScript FrequencyBandStructure type.
603
+ * Returns true if successful, false if parsing failed.
604
+ * @param {string} json
605
+ * @returns {boolean}
606
+ */
607
+ set_frequency_bands(json) {
608
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
609
+ const len0 = WASM_VECTOR_LEN;
610
+ const ret = wasm.wasmvisualiser_set_frequency_bands(this.__wbg_ptr, ptr0, len0);
611
+ return ret !== 0;
612
+ }
613
+ /**
614
+ * Get the number of events for a specific band.
615
+ * Returns 0 if no events are stored for this band.
616
+ * @param {string} band_id
617
+ * @returns {number}
618
+ */
619
+ get_band_event_count(band_id) {
620
+ const ptr0 = passStringToWasm0(band_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
621
+ const len0 = WASM_VECTOR_LEN;
622
+ const ret = wasm.wasmvisualiser_get_band_event_count(this.__wbg_ptr, ptr0, len0);
623
+ return ret >>> 0;
624
+ }
625
+ /**
626
+ * Get list of band keys (IDs and labels) that have signals.
627
+ * Returns a JSON array of strings.
628
+ * @returns {string}
629
+ */
630
+ get_band_signal_keys() {
631
+ let deferred1_0;
632
+ let deferred1_1;
633
+ try {
634
+ const ret = wasm.wasmvisualiser_get_band_signal_keys(this.__wbg_ptr);
635
+ deferred1_0 = ret[0];
636
+ deferred1_1 = ret[1];
637
+ return getStringFromWasm0(ret[0], ret[1]);
638
+ } finally {
639
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
640
+ }
641
+ }
642
+ /**
643
+ * Clear the frequency band structure.
644
+ */
645
+ clear_frequency_bands() {
646
+ wasm.wasmvisualiser_clear_frequency_bands(this.__wbg_ptr);
647
+ }
648
+ /**
649
+ * Unregister a mesh asset.
650
+ * Returns true if the asset was unregistered, false if it didn't exist.
651
+ * @param {string} asset_id
652
+ * @returns {boolean}
653
+ */
654
+ unregister_mesh_asset(asset_id) {
655
+ const ptr0 = passStringToWasm0(asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
656
+ const len0 = WASM_VECTOR_LEN;
657
+ const ret = wasm.wasmvisualiser_unregister_mesh_asset(this.__wbg_ptr, ptr0, len0);
658
+ return ret !== 0;
659
+ }
660
+ /**
661
+ * Get the number of frequency bands.
662
+ * @returns {number}
663
+ */
664
+ get_frequency_band_count() {
665
+ const ret = wasm.wasmvisualiser_get_frequency_band_count(this.__wbg_ptr);
666
+ return ret >>> 0;
667
+ }
668
+ /**
669
+ * Run script in analysis mode with event extraction support.
670
+ *
671
+ * This runs the script headlessly across the full track duration,
672
+ * collecting all debug.emit() calls AND extracting events from
673
+ * any signal.pick.events() calls.
674
+ *
675
+ * Returns a JSON-serialized ExtendedAnalysisResultJson.
676
+ * @param {string} script
677
+ * @param {number} duration
678
+ * @param {number} time_step
679
+ * @returns {string}
680
+ */
681
+ run_analysis_with_events(script, duration, time_step) {
682
+ let deferred2_0;
683
+ let deferred2_1;
684
+ try {
685
+ const ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
686
+ const len0 = WASM_VECTOR_LEN;
687
+ const ret = wasm.wasmvisualiser_run_analysis_with_events(this.__wbg_ptr, ptr0, len0, duration, time_step);
688
+ deferred2_0 = ret[0];
689
+ deferred2_1 = ret[1];
690
+ return getStringFromWasm0(ret[0], ret[1]);
691
+ } finally {
692
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
693
+ }
694
+ }
695
+ /**
696
+ * Get entity positions as JSON for debugging.
697
+ * Returns a JSON array of objects with id, type, and position fields.
698
+ * @returns {string}
699
+ */
700
+ get_entity_positions_json() {
701
+ let deferred1_0;
702
+ let deferred1_1;
703
+ try {
704
+ const ret = wasm.wasmvisualiser_get_entity_positions_json(this.__wbg_ptr);
705
+ deferred1_0 = ret[0];
706
+ deferred1_1 = ret[1];
707
+ return getStringFromWasm0(ret[0], ret[1]);
708
+ } finally {
709
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
710
+ }
711
+ }
712
+ /**
713
+ * Drain and return any pending structured script diagnostics as JSON.
714
+ *
715
+ * Intended for UI consumption. Calling this clears the pending diagnostics
716
+ * queue so repeated polling does not duplicate messages.
717
+ * @returns {string}
718
+ */
719
+ take_script_diagnostics_json() {
720
+ let deferred1_0;
721
+ let deferred1_1;
722
+ try {
723
+ const ret = wasm.wasmvisualiser_take_script_diagnostics_json(this.__wbg_ptr);
724
+ deferred1_0 = ret[0];
725
+ deferred1_1 = ret[1];
726
+ return getStringFromWasm0(ret[0], ret[1]);
727
+ } finally {
728
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
729
+ }
730
+ }
376
731
  constructor() {
377
732
  const ret = wasm.wasmvisualiser_new();
378
733
  this.__wbg_ptr = ret >>> 0;
@@ -419,6 +774,27 @@ export function create_visualiser(canvas) {
419
774
  return ret;
420
775
  }
421
776
 
777
+ /**
778
+ * Get the host-defined Script API metadata as a JSON string.
779
+ *
780
+ * This is a stable, versioned description of the scripting API surface and is
781
+ * intended to drive editor UX (autocomplete/hover/docs) and future language
782
+ * bindings.
783
+ * @returns {string}
784
+ */
785
+ export function get_script_api_metadata_json() {
786
+ let deferred1_0;
787
+ let deferred1_1;
788
+ try {
789
+ const ret = wasm.get_script_api_metadata_json();
790
+ deferred1_0 = ret[0];
791
+ deferred1_1 = ret[1];
792
+ return getStringFromWasm0(ret[0], ret[1]);
793
+ } finally {
794
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
795
+ }
796
+ }
797
+
422
798
  export function init_panic_hook() {
423
799
  wasm.init_panic_hook();
424
800
  }
@@ -1070,6 +1446,10 @@ function __wbg_get_imports() {
1070
1446
  const ret = arg0.offset;
1071
1447
  return ret;
1072
1448
  };
1449
+ imports.wbg.__wbg_performance_c77a440eff2efd9b = function(arg0) {
1450
+ const ret = arg0.performance;
1451
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1452
+ };
1073
1453
  imports.wbg.__wbg_popErrorScope_af0b22f136a861d6 = function(arg0) {
1074
1454
  const ret = arg0.popErrorScope();
1075
1455
  return ret;
@@ -1273,21 +1653,21 @@ function __wbg_get_imports() {
1273
1653
  imports.wbg.__wbg_writeTexture_246118eb2f5a1592 = function(arg0, arg1, arg2, arg3, arg4) {
1274
1654
  arg0.writeTexture(arg1, arg2, arg3, arg4);
1275
1655
  };
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
1656
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1282
1657
  // Cast intrinsic for `Ref(String) -> Externref`.
1283
1658
  const ret = getStringFromWasm0(arg0, arg1);
1284
1659
  return ret;
1285
1660
  };
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`.
1661
+ imports.wbg.__wbindgen_cast_4559dc9fab9d2c87 = function(arg0, arg1) {
1662
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2452, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 2453, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1288
1663
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__heb49a8f426ac2d2e, wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8);
1289
1664
  return ret;
1290
1665
  };
1666
+ imports.wbg.__wbindgen_cast_5c1c4a6a0672b30d = function(arg0, arg1) {
1667
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 2584, function: Function { arguments: [Externref], shim_idx: 2585, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1668
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf5eaa61ced318e08, wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7);
1669
+ return ret;
1670
+ };
1291
1671
  imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1292
1672
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1293
1673
  const ret = getArrayU8FromWasm0(arg0, arg1);
Binary file
@@ -3,25 +3,51 @@
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_frequency_bands: (a: number) => void;
10
+ export const wasmvisualiser_clear_isolation: (a: number) => void;
11
+ export const wasmvisualiser_clear_musical_time: (a: number) => void;
6
12
  export const wasmvisualiser_clear_signals: (a: number) => void;
13
+ export const wasmvisualiser_get_band_bounds_at: (a: number, b: number) => [number, number];
14
+ export const wasmvisualiser_get_band_event_count: (a: number, b: number, c: number) => number;
15
+ export const wasmvisualiser_get_band_signal_keys: (a: number) => [number, number];
7
16
  export const wasmvisualiser_get_current_vals: (a: number) => [number, number];
17
+ export const wasmvisualiser_get_entity_positions_json: (a: number) => [number, number];
18
+ export const wasmvisualiser_get_frequency_band_count: (a: number) => number;
8
19
  export const wasmvisualiser_get_script_error: (a: number) => [number, number];
20
+ export const wasmvisualiser_get_signal_names: (a: number) => [number, number];
21
+ export const wasmvisualiser_has_frequency_bands: (a: number) => number;
9
22
  export const wasmvisualiser_has_script: (a: number) => number;
23
+ export const wasmvisualiser_isolate_entity: (a: number, b: bigint) => void;
24
+ export const wasmvisualiser_list_mesh_assets: (a: number) => [number, number];
10
25
  export const wasmvisualiser_load_script: (a: number, b: number, c: number) => number;
11
26
  export const wasmvisualiser_new: () => number;
27
+ export const wasmvisualiser_push_band_events: (a: number, b: number, c: number, d: number, e: number) => number;
28
+ 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
29
  export const wasmvisualiser_push_data: (a: number, b: number, c: number, d: number) => void;
13
30
  export const wasmvisualiser_push_signal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
14
31
  export const wasmvisualiser_push_zoom_data: (a: number, b: number, c: number, d: number) => void;
32
+ export const wasmvisualiser_register_mesh_asset: (a: number, b: number, c: number, d: number, e: number) => number;
15
33
  export const wasmvisualiser_render: (a: number, b: number) => void;
34
+ export const wasmvisualiser_render_with_budget: (a: number, b: number, c: number) => number;
16
35
  export const wasmvisualiser_resize: (a: number, b: number, c: number) => void;
36
+ export const wasmvisualiser_run_analysis: (a: number, b: number, c: number, d: number, e: number) => [number, number];
37
+ export const wasmvisualiser_run_analysis_with_events: (a: number, b: number, c: number, d: number, e: number) => [number, number];
38
+ export const wasmvisualiser_set_debug_options: (a: number, b: number, c: number) => void;
39
+ export const wasmvisualiser_set_frequency_bands: (a: number, b: number, c: number) => number;
40
+ export const wasmvisualiser_set_musical_time: (a: number, b: number, c: number) => number;
17
41
  export const wasmvisualiser_set_sigmoid_k: (a: number, b: number) => void;
18
42
  export const wasmvisualiser_set_time: (a: number, b: number) => void;
19
- export const init_panic_hook: () => void;
43
+ export const wasmvisualiser_take_script_diagnostics_json: (a: number) => [number, number];
44
+ export const wasmvisualiser_unregister_mesh_asset: (a: number, b: number, c: number) => number;
20
45
  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;
46
+ export const init_panic_hook: () => void;
23
47
  export const wasm_bindgen__convert__closures_____invoke__h9d1c5a23ecfcd5c8: (a: number, b: number, c: any) => void;
24
48
  export const wasm_bindgen__closure__destroy__heb49a8f426ac2d2e: (a: number, b: number) => void;
49
+ export const wasm_bindgen__convert__closures_____invoke__h53437a38721e89f7: (a: number, b: number, c: any) => void;
50
+ export const wasm_bindgen__closure__destroy__hf5eaa61ced318e08: (a: number, b: number) => void;
25
51
  export const wasm_bindgen__convert__closures_____invoke__h320f3d825d3712ba: (a: number, b: number, c: any, d: any) => void;
26
52
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
53
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;