@ilusiv/fyug-js 2026.5.2
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/README.md +93 -0
- package/dist/FuguePlayer.d.ts +34 -0
- package/dist/FuguePlayer.d.ts.map +1 -0
- package/dist/FuguePlayer.js +350 -0
- package/dist/FuguePlayer.js.map +1 -0
- package/dist/fugue-audio-worklet.d.ts +2 -0
- package/dist/fugue-audio-worklet.d.ts.map +1 -0
- package/dist/fugue-audio-worklet.js +138 -0
- package/dist/fugue-audio-worklet.js.map +1 -0
- package/dist/fugue-worklet-utf8.d.ts +1 -0
- package/dist/fugue-worklet-utf8.d.ts.map +1 -0
- package/dist/fugue-worklet-utf8.js +116 -0
- package/dist/fugue-worklet-utf8.js.map +1 -0
- package/dist/generated/embedded-assets.d.ts +3 -0
- package/dist/generated/embedded-assets.d.ts.map +1 -0
- package/dist/generated/embedded-assets.js +3 -0
- package/dist/generated/embedded-assets.js.map +1 -0
- package/dist/generated/fugue.d.ts +174 -0
- package/dist/generated/fugue.js +792 -0
- package/dist/generated/fugue_bg.wasm +0 -0
- package/dist/generated/fugue_bg.wasm.d.ts +36 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
/* @ts-self-types="./fugue.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* wasm-bindgen wrapper around `RenderEngine`.
|
|
5
|
+
*
|
|
6
|
+
* In addition to offline rendering, this wrapper exposes orchestration APIs so
|
|
7
|
+
* a surrounding JS host can inspect and mutate the graph and drive `code`
|
|
8
|
+
* modules from JavaScript.
|
|
9
|
+
*/
|
|
10
|
+
export class FugueEngine {
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
FugueEngineFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_fugueengine_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Adds a module to the loaded graph.
|
|
23
|
+
* @param {string} id
|
|
24
|
+
* @param {string} module_type
|
|
25
|
+
* @param {string | null} [config_json]
|
|
26
|
+
*/
|
|
27
|
+
addModule(id, module_type, config_json) {
|
|
28
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29
|
+
const len0 = WASM_VECTOR_LEN;
|
|
30
|
+
const ptr1 = passStringToWasm0(module_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
31
|
+
const len1 = WASM_VECTOR_LEN;
|
|
32
|
+
var ptr2 = isLikeNone(config_json) ? 0 : passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
33
|
+
var len2 = WASM_VECTOR_LEN;
|
|
34
|
+
const ret = wasm.fugueengine_addModule(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
35
|
+
if (ret[1]) {
|
|
36
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Connects two module ports.
|
|
41
|
+
* @param {string} from
|
|
42
|
+
* @param {string} from_port
|
|
43
|
+
* @param {string} to
|
|
44
|
+
* @param {string} to_port
|
|
45
|
+
*/
|
|
46
|
+
connect(from, from_port, to, to_port) {
|
|
47
|
+
const ptr0 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
|
+
const len0 = WASM_VECTOR_LEN;
|
|
49
|
+
const ptr1 = passStringToWasm0(from_port, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
50
|
+
const len1 = WASM_VECTOR_LEN;
|
|
51
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
52
|
+
const len2 = WASM_VECTOR_LEN;
|
|
53
|
+
const ptr3 = passStringToWasm0(to_port, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
|
+
const len3 = WASM_VECTOR_LEN;
|
|
55
|
+
const ret = wasm.fugueengine_connect(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
56
|
+
if (ret[1]) {
|
|
57
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Disconnects two module ports.
|
|
62
|
+
* @param {string} from
|
|
63
|
+
* @param {string} from_port
|
|
64
|
+
* @param {string} to
|
|
65
|
+
* @param {string} to_port
|
|
66
|
+
*/
|
|
67
|
+
disconnect(from, from_port, to, to_port) {
|
|
68
|
+
const ptr0 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
|
+
const len0 = WASM_VECTOR_LEN;
|
|
70
|
+
const ptr1 = passStringToWasm0(from_port, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
|
+
const len1 = WASM_VECTOR_LEN;
|
|
72
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
73
|
+
const len2 = WASM_VECTOR_LEN;
|
|
74
|
+
const ptr3 = passStringToWasm0(to_port, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
const len3 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.fugueengine_disconnect(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
77
|
+
if (ret[1]) {
|
|
78
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Finalizes an in-memory `audio_file_sink` and returns JSON stats.
|
|
83
|
+
* @param {string} module_id
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
finishAudioFileSink(module_id) {
|
|
87
|
+
let deferred3_0;
|
|
88
|
+
let deferred3_1;
|
|
89
|
+
try {
|
|
90
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
91
|
+
const len0 = WASM_VECTOR_LEN;
|
|
92
|
+
const ret = wasm.fugueengine_finishAudioFileSink(this.__wbg_ptr, ptr0, len0);
|
|
93
|
+
var ptr2 = ret[0];
|
|
94
|
+
var len2 = ret[1];
|
|
95
|
+
if (ret[3]) {
|
|
96
|
+
ptr2 = 0; len2 = 0;
|
|
97
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
98
|
+
}
|
|
99
|
+
deferred3_0 = ptr2;
|
|
100
|
+
deferred3_1 = len2;
|
|
101
|
+
return getStringFromWasm0(ptr2, len2);
|
|
102
|
+
} finally {
|
|
103
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns finalized WAV bytes from an in-memory `audio_file_sink`.
|
|
108
|
+
* @param {string} module_id
|
|
109
|
+
* @returns {Uint8Array}
|
|
110
|
+
*/
|
|
111
|
+
getAudioFileSinkWav(module_id) {
|
|
112
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
113
|
+
const len0 = WASM_VECTOR_LEN;
|
|
114
|
+
const ret = wasm.fugueengine_getAudioFileSinkWav(this.__wbg_ptr, ptr0, len0);
|
|
115
|
+
if (ret[3]) {
|
|
116
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
117
|
+
}
|
|
118
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
119
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
120
|
+
return v2;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Returns one `code` module's runtime config as JSON.
|
|
124
|
+
* @param {string} id
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
getCodeModuleConfig(id) {
|
|
128
|
+
let deferred3_0;
|
|
129
|
+
let deferred3_1;
|
|
130
|
+
try {
|
|
131
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.fugueengine_getCodeModuleConfig(this.__wbg_ptr, ptr0, len0);
|
|
134
|
+
var ptr2 = ret[0];
|
|
135
|
+
var len2 = ret[1];
|
|
136
|
+
if (ret[3]) {
|
|
137
|
+
ptr2 = 0; len2 = 0;
|
|
138
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
139
|
+
}
|
|
140
|
+
deferred3_0 = ptr2;
|
|
141
|
+
deferred3_1 = len2;
|
|
142
|
+
return getStringFromWasm0(ptr2, len2);
|
|
143
|
+
} finally {
|
|
144
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns a control value encoded as JSON.
|
|
149
|
+
* @param {string} module_id
|
|
150
|
+
* @param {string} key
|
|
151
|
+
* @returns {string}
|
|
152
|
+
*/
|
|
153
|
+
getControl(module_id, key) {
|
|
154
|
+
let deferred4_0;
|
|
155
|
+
let deferred4_1;
|
|
156
|
+
try {
|
|
157
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
158
|
+
const len0 = WASM_VECTOR_LEN;
|
|
159
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
160
|
+
const len1 = WASM_VECTOR_LEN;
|
|
161
|
+
const ret = wasm.fugueengine_getControl(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
162
|
+
var ptr3 = ret[0];
|
|
163
|
+
var len3 = ret[1];
|
|
164
|
+
if (ret[3]) {
|
|
165
|
+
ptr3 = 0; len3 = 0;
|
|
166
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
167
|
+
}
|
|
168
|
+
deferred4_0 = ptr3;
|
|
169
|
+
deferred4_1 = len3;
|
|
170
|
+
return getStringFromWasm0(ptr3, len3);
|
|
171
|
+
} finally {
|
|
172
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Returns discovered `code` modules and their runtime config as JSON.
|
|
177
|
+
* @returns {string}
|
|
178
|
+
*/
|
|
179
|
+
listCodeModules() {
|
|
180
|
+
let deferred2_0;
|
|
181
|
+
let deferred2_1;
|
|
182
|
+
try {
|
|
183
|
+
const ret = wasm.fugueengine_listCodeModules(this.__wbg_ptr);
|
|
184
|
+
var ptr1 = ret[0];
|
|
185
|
+
var len1 = ret[1];
|
|
186
|
+
if (ret[3]) {
|
|
187
|
+
ptr1 = 0; len1 = 0;
|
|
188
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
189
|
+
}
|
|
190
|
+
deferred2_0 = ptr1;
|
|
191
|
+
deferred2_1 = len1;
|
|
192
|
+
return getStringFromWasm0(ptr1, len1);
|
|
193
|
+
} finally {
|
|
194
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns the current connection snapshot as a JSON string.
|
|
199
|
+
* @returns {string}
|
|
200
|
+
*/
|
|
201
|
+
listConnections() {
|
|
202
|
+
let deferred2_0;
|
|
203
|
+
let deferred2_1;
|
|
204
|
+
try {
|
|
205
|
+
const ret = wasm.fugueengine_listConnections(this.__wbg_ptr);
|
|
206
|
+
var ptr1 = ret[0];
|
|
207
|
+
var len1 = ret[1];
|
|
208
|
+
if (ret[3]) {
|
|
209
|
+
ptr1 = 0; len1 = 0;
|
|
210
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
211
|
+
}
|
|
212
|
+
deferred2_0 = ptr1;
|
|
213
|
+
deferred2_1 = len1;
|
|
214
|
+
return getStringFromWasm0(ptr1, len1);
|
|
215
|
+
} finally {
|
|
216
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Returns control metadata as a JSON string.
|
|
221
|
+
* @param {string | null} [module_id]
|
|
222
|
+
* @returns {string}
|
|
223
|
+
*/
|
|
224
|
+
listControls(module_id) {
|
|
225
|
+
let deferred3_0;
|
|
226
|
+
let deferred3_1;
|
|
227
|
+
try {
|
|
228
|
+
var ptr0 = isLikeNone(module_id) ? 0 : passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
229
|
+
var len0 = WASM_VECTOR_LEN;
|
|
230
|
+
const ret = wasm.fugueengine_listControls(this.__wbg_ptr, ptr0, len0);
|
|
231
|
+
var ptr2 = ret[0];
|
|
232
|
+
var len2 = ret[1];
|
|
233
|
+
if (ret[3]) {
|
|
234
|
+
ptr2 = 0; len2 = 0;
|
|
235
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
236
|
+
}
|
|
237
|
+
deferred3_0 = ptr2;
|
|
238
|
+
deferred3_1 = len2;
|
|
239
|
+
return getStringFromWasm0(ptr2, len2);
|
|
240
|
+
} finally {
|
|
241
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Returns the current module snapshot as a JSON string.
|
|
246
|
+
* @returns {string}
|
|
247
|
+
*/
|
|
248
|
+
listModules() {
|
|
249
|
+
let deferred2_0;
|
|
250
|
+
let deferred2_1;
|
|
251
|
+
try {
|
|
252
|
+
const ret = wasm.fugueengine_listModules(this.__wbg_ptr);
|
|
253
|
+
var ptr1 = ret[0];
|
|
254
|
+
var len1 = ret[1];
|
|
255
|
+
if (ret[3]) {
|
|
256
|
+
ptr1 = 0; len1 = 0;
|
|
257
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
258
|
+
}
|
|
259
|
+
deferred2_0 = ptr1;
|
|
260
|
+
deferred2_1 = len1;
|
|
261
|
+
return getStringFromWasm0(ptr1, len1);
|
|
262
|
+
} finally {
|
|
263
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Loads invention JSON into the render engine.
|
|
268
|
+
* @param {string} json
|
|
269
|
+
*/
|
|
270
|
+
loadInvention(json) {
|
|
271
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
+
const len0 = WASM_VECTOR_LEN;
|
|
273
|
+
const ret = wasm.fugueengine_loadInvention(this.__wbg_ptr, ptr0, len0);
|
|
274
|
+
if (ret[1]) {
|
|
275
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Creates a new engine for the given sample rate.
|
|
280
|
+
* @param {number} sample_rate
|
|
281
|
+
*/
|
|
282
|
+
constructor(sample_rate) {
|
|
283
|
+
const ret = wasm.fugueengine_new(sample_rate);
|
|
284
|
+
this.__wbg_ptr = ret;
|
|
285
|
+
FugueEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Removes a module from the loaded graph.
|
|
290
|
+
* @param {string} id
|
|
291
|
+
*/
|
|
292
|
+
removeModule(id) {
|
|
293
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
295
|
+
const ret = wasm.fugueengine_removeModule(this.__wbg_ptr, ptr0, len0);
|
|
296
|
+
if (ret[1]) {
|
|
297
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Renders a block of interleaved stereo samples.
|
|
302
|
+
* @param {number} frame_count
|
|
303
|
+
* @returns {Float32Array}
|
|
304
|
+
*/
|
|
305
|
+
renderInterleaved(frame_count) {
|
|
306
|
+
const ret = wasm.fugueengine_renderInterleaved(this.__wbg_ptr, frame_count);
|
|
307
|
+
if (ret[3]) {
|
|
308
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
309
|
+
}
|
|
310
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
311
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
312
|
+
return v1;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Renders interleaved stereo samples into a caller-provided buffer.
|
|
316
|
+
*
|
|
317
|
+
* The buffer length must be even and is interpreted as
|
|
318
|
+
* `[left0, right0, left1, right1, ...]`.
|
|
319
|
+
* @param {Float32Array} output
|
|
320
|
+
* @returns {number}
|
|
321
|
+
*/
|
|
322
|
+
renderInterleavedInto(output) {
|
|
323
|
+
const ret = wasm.fugueengine_renderInterleavedInto(this.__wbg_ptr, output);
|
|
324
|
+
if (ret[2]) {
|
|
325
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
326
|
+
}
|
|
327
|
+
return ret[0] >>> 0;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Resets engine state without reloading the invention definition.
|
|
331
|
+
*/
|
|
332
|
+
reset() {
|
|
333
|
+
const ret = wasm.fugueengine_reset(this.__wbg_ptr);
|
|
334
|
+
if (ret[1]) {
|
|
335
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Returns the configured sample rate.
|
|
340
|
+
* @returns {number}
|
|
341
|
+
*/
|
|
342
|
+
sampleRate() {
|
|
343
|
+
const ret = wasm.fugueengine_sampleRate(this.__wbg_ptr);
|
|
344
|
+
return ret >>> 0;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Updates the last-error string for a `code` module.
|
|
348
|
+
* @param {string} id
|
|
349
|
+
* @param {string} error
|
|
350
|
+
*/
|
|
351
|
+
setCodeModuleError(id, error) {
|
|
352
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
|
+
const len0 = WASM_VECTOR_LEN;
|
|
354
|
+
const ptr1 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
355
|
+
const len1 = WASM_VECTOR_LEN;
|
|
356
|
+
const ret = wasm.fugueengine_setCodeModuleError(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
357
|
+
if (ret[1]) {
|
|
358
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Updates the runtime status string for a `code` module.
|
|
363
|
+
* @param {string} id
|
|
364
|
+
* @param {string} status
|
|
365
|
+
*/
|
|
366
|
+
setCodeModuleStatus(id, status) {
|
|
367
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
368
|
+
const len0 = WASM_VECTOR_LEN;
|
|
369
|
+
const ptr1 = passStringToWasm0(status, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
370
|
+
const len1 = WASM_VECTOR_LEN;
|
|
371
|
+
const ret = wasm.fugueengine_setCodeModuleStatus(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
372
|
+
if (ret[1]) {
|
|
373
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Sets a boolean control value.
|
|
378
|
+
* @param {string} module_id
|
|
379
|
+
* @param {string} key
|
|
380
|
+
* @param {boolean} value
|
|
381
|
+
*/
|
|
382
|
+
setControlBool(module_id, key, value) {
|
|
383
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
384
|
+
const len0 = WASM_VECTOR_LEN;
|
|
385
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
const len1 = WASM_VECTOR_LEN;
|
|
387
|
+
const ret = wasm.fugueengine_setControlBool(this.__wbg_ptr, ptr0, len0, ptr1, len1, value);
|
|
388
|
+
if (ret[1]) {
|
|
389
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Sets a numeric control value.
|
|
394
|
+
* @param {string} module_id
|
|
395
|
+
* @param {string} key
|
|
396
|
+
* @param {number} value
|
|
397
|
+
*/
|
|
398
|
+
setControlNumber(module_id, key, value) {
|
|
399
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
402
|
+
const len1 = WASM_VECTOR_LEN;
|
|
403
|
+
const ret = wasm.fugueengine_setControlNumber(this.__wbg_ptr, ptr0, len0, ptr1, len1, value);
|
|
404
|
+
if (ret[1]) {
|
|
405
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Sets a string control value.
|
|
410
|
+
* @param {string} module_id
|
|
411
|
+
* @param {string} key
|
|
412
|
+
* @param {string} value
|
|
413
|
+
*/
|
|
414
|
+
setControlString(module_id, key, value) {
|
|
415
|
+
const ptr0 = passStringToWasm0(module_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
416
|
+
const len0 = WASM_VECTOR_LEN;
|
|
417
|
+
const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
418
|
+
const len1 = WASM_VECTOR_LEN;
|
|
419
|
+
const ptr2 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
420
|
+
const len2 = WASM_VECTOR_LEN;
|
|
421
|
+
const ret = wasm.fugueengine_setControlString(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
422
|
+
if (ret[1]) {
|
|
423
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Returns runtime status as a JSON string.
|
|
428
|
+
* @returns {string}
|
|
429
|
+
*/
|
|
430
|
+
status() {
|
|
431
|
+
let deferred2_0;
|
|
432
|
+
let deferred2_1;
|
|
433
|
+
try {
|
|
434
|
+
const ret = wasm.fugueengine_status(this.__wbg_ptr);
|
|
435
|
+
var ptr1 = ret[0];
|
|
436
|
+
var len1 = ret[1];
|
|
437
|
+
if (ret[3]) {
|
|
438
|
+
ptr1 = 0; len1 = 0;
|
|
439
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
440
|
+
}
|
|
441
|
+
deferred2_0 = ptr1;
|
|
442
|
+
deferred2_1 = len1;
|
|
443
|
+
return getStringFromWasm0(ptr1, len1);
|
|
444
|
+
} finally {
|
|
445
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (Symbol.dispose) FugueEngine.prototype[Symbol.dispose] = FugueEngine.prototype.free;
|
|
450
|
+
function __wbg_get_imports() {
|
|
451
|
+
const import0 = {
|
|
452
|
+
__proto__: null,
|
|
453
|
+
__wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
|
|
454
|
+
const ret = typeof(arg0) === 'function';
|
|
455
|
+
return ret;
|
|
456
|
+
},
|
|
457
|
+
__wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
|
|
458
|
+
const val = arg0;
|
|
459
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
460
|
+
return ret;
|
|
461
|
+
},
|
|
462
|
+
__wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
|
|
463
|
+
const ret = typeof(arg0) === 'string';
|
|
464
|
+
return ret;
|
|
465
|
+
},
|
|
466
|
+
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
467
|
+
const ret = arg0 === undefined;
|
|
468
|
+
return ret;
|
|
469
|
+
},
|
|
470
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
471
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
472
|
+
},
|
|
473
|
+
__wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
|
|
474
|
+
const ret = arg0.call(arg1, arg2);
|
|
475
|
+
return ret;
|
|
476
|
+
}, arguments); },
|
|
477
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
478
|
+
const ret = arg0.crypto;
|
|
479
|
+
return ret;
|
|
480
|
+
},
|
|
481
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
482
|
+
arg0.getRandomValues(arg1);
|
|
483
|
+
}, arguments); },
|
|
484
|
+
__wbg_length_1009454859bb3e03: function(arg0) {
|
|
485
|
+
const ret = arg0.length;
|
|
486
|
+
return ret;
|
|
487
|
+
},
|
|
488
|
+
__wbg_length_36bd29c6848c2144: function(arg0) {
|
|
489
|
+
const ret = arg0.length;
|
|
490
|
+
return ret;
|
|
491
|
+
},
|
|
492
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
493
|
+
const ret = arg0.msCrypto;
|
|
494
|
+
return ret;
|
|
495
|
+
},
|
|
496
|
+
__wbg_new_with_length_3ffc1c56427c525c: function(arg0) {
|
|
497
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
498
|
+
return ret;
|
|
499
|
+
},
|
|
500
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
501
|
+
const ret = arg0.node;
|
|
502
|
+
return ret;
|
|
503
|
+
},
|
|
504
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
505
|
+
const ret = arg0.process;
|
|
506
|
+
return ret;
|
|
507
|
+
},
|
|
508
|
+
__wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
|
|
509
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
510
|
+
},
|
|
511
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
512
|
+
arg0.randomFillSync(arg1);
|
|
513
|
+
}, arguments); },
|
|
514
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
515
|
+
const ret = module.require;
|
|
516
|
+
return ret;
|
|
517
|
+
}, arguments); },
|
|
518
|
+
__wbg_set_577f5f7485b6744e: function(arg0, arg1, arg2) {
|
|
519
|
+
arg0.set(getArrayF32FromWasm0(arg1, arg2));
|
|
520
|
+
},
|
|
521
|
+
__wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76: function() {
|
|
522
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
523
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
524
|
+
},
|
|
525
|
+
__wbg_static_accessor_GLOBAL_c7aea38d4de089bc: function() {
|
|
526
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
527
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
528
|
+
},
|
|
529
|
+
__wbg_static_accessor_SELF_42d4fae05e59267a: function() {
|
|
530
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
531
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
532
|
+
},
|
|
533
|
+
__wbg_static_accessor_WINDOW_e0db14a0eba6a812: function() {
|
|
534
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
535
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
536
|
+
},
|
|
537
|
+
__wbg_subarray_a4cc58201c7359fd: function(arg0, arg1, arg2) {
|
|
538
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
539
|
+
return ret;
|
|
540
|
+
},
|
|
541
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
542
|
+
const ret = arg0.versions;
|
|
543
|
+
return ret;
|
|
544
|
+
},
|
|
545
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
546
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
547
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
548
|
+
return ret;
|
|
549
|
+
},
|
|
550
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
551
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
552
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
553
|
+
return ret;
|
|
554
|
+
},
|
|
555
|
+
__wbindgen_init_externref_table: function() {
|
|
556
|
+
const table = wasm.__wbindgen_externrefs;
|
|
557
|
+
const offset = table.grow(4);
|
|
558
|
+
table.set(0, undefined);
|
|
559
|
+
table.set(offset + 0, undefined);
|
|
560
|
+
table.set(offset + 1, null);
|
|
561
|
+
table.set(offset + 2, true);
|
|
562
|
+
table.set(offset + 3, false);
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
return {
|
|
566
|
+
__proto__: null,
|
|
567
|
+
"./fugue_bg.js": import0,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const FugueEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
572
|
+
? { register: () => {}, unregister: () => {} }
|
|
573
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fugueengine_free(ptr, 1));
|
|
574
|
+
|
|
575
|
+
function addToExternrefTable0(obj) {
|
|
576
|
+
const idx = wasm.__externref_table_alloc();
|
|
577
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
578
|
+
return idx;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
582
|
+
ptr = ptr >>> 0;
|
|
583
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
587
|
+
ptr = ptr >>> 0;
|
|
588
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
592
|
+
function getFloat32ArrayMemory0() {
|
|
593
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
594
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
595
|
+
}
|
|
596
|
+
return cachedFloat32ArrayMemory0;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function getStringFromWasm0(ptr, len) {
|
|
600
|
+
return decodeText(ptr >>> 0, len);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
let cachedUint8ArrayMemory0 = null;
|
|
604
|
+
function getUint8ArrayMemory0() {
|
|
605
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
606
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
607
|
+
}
|
|
608
|
+
return cachedUint8ArrayMemory0;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function handleError(f, args) {
|
|
612
|
+
try {
|
|
613
|
+
return f.apply(this, args);
|
|
614
|
+
} catch (e) {
|
|
615
|
+
const idx = addToExternrefTable0(e);
|
|
616
|
+
wasm.__wbindgen_exn_store(idx);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function isLikeNone(x) {
|
|
621
|
+
return x === undefined || x === null;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
625
|
+
if (realloc === undefined) {
|
|
626
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
627
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
628
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
629
|
+
WASM_VECTOR_LEN = buf.length;
|
|
630
|
+
return ptr;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
let len = arg.length;
|
|
634
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
635
|
+
|
|
636
|
+
const mem = getUint8ArrayMemory0();
|
|
637
|
+
|
|
638
|
+
let offset = 0;
|
|
639
|
+
|
|
640
|
+
for (; offset < len; offset++) {
|
|
641
|
+
const code = arg.charCodeAt(offset);
|
|
642
|
+
if (code > 0x7F) break;
|
|
643
|
+
mem[ptr + offset] = code;
|
|
644
|
+
}
|
|
645
|
+
if (offset !== len) {
|
|
646
|
+
if (offset !== 0) {
|
|
647
|
+
arg = arg.slice(offset);
|
|
648
|
+
}
|
|
649
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
650
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
651
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
652
|
+
|
|
653
|
+
offset += ret.written;
|
|
654
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
WASM_VECTOR_LEN = offset;
|
|
658
|
+
return ptr;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function takeFromExternrefTable0(idx) {
|
|
662
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
663
|
+
wasm.__externref_table_dealloc(idx);
|
|
664
|
+
return value;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
668
|
+
cachedTextDecoder.decode();
|
|
669
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
670
|
+
let numBytesDecoded = 0;
|
|
671
|
+
function decodeText(ptr, len) {
|
|
672
|
+
numBytesDecoded += len;
|
|
673
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
674
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
675
|
+
cachedTextDecoder.decode();
|
|
676
|
+
numBytesDecoded = len;
|
|
677
|
+
}
|
|
678
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
const cachedTextEncoder = new TextEncoder();
|
|
682
|
+
|
|
683
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
684
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
685
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
686
|
+
view.set(buf);
|
|
687
|
+
return {
|
|
688
|
+
read: arg.length,
|
|
689
|
+
written: buf.length
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
let WASM_VECTOR_LEN = 0;
|
|
695
|
+
|
|
696
|
+
let wasmModule, wasmInstance, wasm;
|
|
697
|
+
function __wbg_finalize_init(instance, module) {
|
|
698
|
+
wasmInstance = instance;
|
|
699
|
+
wasm = instance.exports;
|
|
700
|
+
wasmModule = module;
|
|
701
|
+
cachedFloat32ArrayMemory0 = null;
|
|
702
|
+
cachedUint8ArrayMemory0 = null;
|
|
703
|
+
wasm.__wbindgen_start();
|
|
704
|
+
return wasm;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
async function __wbg_load(module, imports) {
|
|
708
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
709
|
+
if (!module.ok) {
|
|
710
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
714
|
+
try {
|
|
715
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
716
|
+
} catch (e) {
|
|
717
|
+
const validResponse = expectedResponseType(module.type);
|
|
718
|
+
|
|
719
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
720
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
721
|
+
|
|
722
|
+
} else { throw e; }
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const bytes = await module.arrayBuffer();
|
|
727
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
728
|
+
} else {
|
|
729
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
730
|
+
|
|
731
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
732
|
+
return { instance, module };
|
|
733
|
+
} else {
|
|
734
|
+
return instance;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function expectedResponseType(type) {
|
|
739
|
+
switch (type) {
|
|
740
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function initSync(module) {
|
|
747
|
+
if (wasm !== undefined) return wasm;
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
if (module !== undefined) {
|
|
751
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
752
|
+
({module} = module)
|
|
753
|
+
} else {
|
|
754
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const imports = __wbg_get_imports();
|
|
759
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
760
|
+
module = new WebAssembly.Module(module);
|
|
761
|
+
}
|
|
762
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
763
|
+
return __wbg_finalize_init(instance, module);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
async function __wbg_init(module_or_path) {
|
|
767
|
+
if (wasm !== undefined) return wasm;
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
if (module_or_path !== undefined) {
|
|
771
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
772
|
+
({module_or_path} = module_or_path)
|
|
773
|
+
} else {
|
|
774
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (module_or_path === undefined) {
|
|
779
|
+
module_or_path = new URL('fugue_bg.wasm', import.meta.url);
|
|
780
|
+
}
|
|
781
|
+
const imports = __wbg_get_imports();
|
|
782
|
+
|
|
783
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
784
|
+
module_or_path = fetch(module_or_path);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
788
|
+
|
|
789
|
+
return __wbg_finalize_init(instance, module);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
export { initSync, __wbg_init as default };
|