wurble-rs 0.0.0-stage → 0.4.0

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 CHANGED
@@ -1,3 +1,89 @@
1
- # Temporary Holding Version
1
+ # wurble
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **mumble** **mumble** **mumble**
4
+
5
+ I don't always warble but when I do I always burble
6
+
7
+ Mumble speech you can put just about anywhere! (I think... well no, I didn't expect you'd try there)
8
+
9
+ Human speech is costly and AI speech is ... uncanny (and costly I suppose)? So instead make sounds go with your words that aren't words (also sounds). Who are you and why are you reading this, can you help me, can you release me from this prison, can you feel my heart, is 2 pounds of Nutella too much?
10
+
11
+ ## How to wurble
12
+
13
+ ```sh
14
+ cargo add wurble
15
+ ```
16
+
17
+ Pick a voice, give it words, get a WAV.
18
+
19
+ ```rust,no_run
20
+ use wurble::Voice;
21
+
22
+ let wav = Voice::chitter().wav("Well, hello there. Is that you?");
23
+ std::fs::write("hello.wav", wav).unwrap();
24
+ ```
25
+
26
+ ### Voices
27
+
28
+ Each example is saying "Oh, hi! Um... can you hear me?" Make them say something else [here](https://06chaynes.github.io/wurble/).
29
+
30
+ | Voice | Sounds like | Listen |
31
+ |---|---|---|
32
+ | `Voice::chitter()` | quick and squeaky, I'm in the crossing for animals | [▶](https://cdn.jsdelivr.net/gh/06chaynes/wurble@main/assets/chitter.wav) |
33
+ | `Voice::grumble()` | low grunts, grab a banjo or a kazoo(ie) | [▶](https://cdn.jsdelivr.net/gh/06chaynes/wurble@main/assets/grumble.wav) |
34
+ | `Voice::blip()` | one beep per letter, under the night stars... tale (idk either) | [▶](https://cdn.jsdelivr.net/gh/06chaynes/wurble@main/assets/blip.wav) |
35
+ | `Voice::babble()` | slow fluent nonsense, the neighbours have a pool but no ladder | [▶](https://cdn.jsdelivr.net/gh/06chaynes/wurble@main/assets/babble.wav) |
36
+
37
+ ### Make it yours
38
+
39
+ Start from a voice and change whatever bothers you.
40
+
41
+ ```rust
42
+ use wurble::Voice;
43
+
44
+ let deep = Voice { pitch: 0.5, jitter: 6.0, ..Voice::grumble() };
45
+ ```
46
+
47
+ | Field | What it does |
48
+ |---|---|
49
+ | `pitch` | playback rate; `2.0` is an octave up |
50
+ | `jitter` | semitones of random wobble per sound |
51
+ | `inflection` | semitones of rise into a `?`; a `!` gets half |
52
+ | `tick` | seconds per character |
53
+ | `length` | seconds each sound lasts, half again for a sentence's last word |
54
+ | `skip` | letters left silent after each sound, starting fresh each word |
55
+ | `pause` | seconds of silence after `, ; :`, doubled after `. ! ? …` |
56
+ | `hiss` | how breathy each consonant starts, `0` to `1` |
57
+ | `seed` | same seed, same wobble |
58
+
59
+ Got your own noises? Hand them over as mono `f32` clips at the voice's `sample_rate`. Each letter picks a clip, so one clip means everything is that noise and 26 in a to z order is an alphabet.
60
+
61
+ ```rust
62
+ let mine = Voice::new(vec![my_grunt]);
63
+ ```
64
+
65
+ `wave` grows one cycle of sound from the loudness of each harmonic.
66
+
67
+ ```rust
68
+ use wurble::{Voice, wave};
69
+
70
+ let hum = Voice::new(vec![wave(|k| 1.0 / (k * k) as f32)]);
71
+ ```
72
+
73
+ ### Typewriter text
74
+
75
+ `cues` says when each character starts, in seconds, so the words can show up as they're mumbled. The last entry is when the line ends.
76
+
77
+ ```rust
78
+ let cues = voice.cues(line);
79
+ let shown = cues.iter().filter(|cue| **cue <= elapsed).count();
80
+ let visible: String = line.chars().take(shown).collect();
81
+ ```
82
+
83
+ ### Putting it places
84
+
85
+ - **A file:** `voice.wav(text)` is a complete WAV file.
86
+ - **Bevy:** `AudioSource { bytes: voice.wav(text).into() }`, with Bevy's `wav` feature on.
87
+ - **rodio, Kira, cpal:** `voice.speak(text)` is mono `f32` samples at `voice.sample_rate`.
88
+ - **A browser:** turn on the `wasm-bindgen` feature and `Voice` works from JavaScript.
89
+ - **npm:** `npm add wurble-rs` for `Voice` in JavaScript or TypeScript, types included. `import init, { Voice } from "wurble-rs"; await init();` then `Voice.chitter().wav("Well, hello there. Is that you?")`. TypeScript needs 5.2+ and `esnext.disposable` in `lib`.
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "wurble-rs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "Dialogue voice synthesis for games, from procedural blips or your own sample banks",
5
+ "license": "MIT OR Apache-2.0",
6
+ "type": "module",
7
+ "keywords": [
8
+ "wasm",
9
+ "voice",
10
+ "speech",
11
+ "games",
12
+ "rust"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/06chaynes/wurble.git"
17
+ },
18
+ "main": "./wurble.js",
19
+ "types": "./wurble.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./wurble.d.ts",
23
+ "default": "./wurble.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "wurble.js",
28
+ "wurble_bg.wasm",
29
+ "wurble.d.ts"
30
+ ]
31
+ }
package/wurble.d.ts ADDED
@@ -0,0 +1,89 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class Voice {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ add_clip(clip: Float32Array): void;
8
+ static babble(): Voice;
9
+ static blip(): Voice;
10
+ static chitter(): Voice;
11
+ cues(text: string): Float32Array;
12
+ constructor();
13
+ static grumble(): Voice;
14
+ speak(text: string): Float32Array;
15
+ wav(text: string): Uint8Array;
16
+ hiss: number;
17
+ inflection: number;
18
+ jitter: number;
19
+ length: number;
20
+ pause: number;
21
+ pitch: number;
22
+ sample_rate: number;
23
+ seed: bigint;
24
+ skip: number;
25
+ tick: number;
26
+ }
27
+
28
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
29
+
30
+ export interface InitOutput {
31
+ readonly memory: WebAssembly.Memory;
32
+ readonly __wbg_get_voice_hiss: (a: number) => number;
33
+ readonly __wbg_get_voice_inflection: (a: number) => number;
34
+ readonly __wbg_get_voice_jitter: (a: number) => number;
35
+ readonly __wbg_get_voice_length: (a: number) => number;
36
+ readonly __wbg_get_voice_pause: (a: number) => number;
37
+ readonly __wbg_get_voice_pitch: (a: number) => number;
38
+ readonly __wbg_get_voice_sample_rate: (a: number) => number;
39
+ readonly __wbg_get_voice_seed: (a: number) => bigint;
40
+ readonly __wbg_get_voice_skip: (a: number) => number;
41
+ readonly __wbg_get_voice_tick: (a: number) => number;
42
+ readonly __wbg_set_voice_hiss: (a: number, b: number) => void;
43
+ readonly __wbg_set_voice_inflection: (a: number, b: number) => void;
44
+ readonly __wbg_set_voice_jitter: (a: number, b: number) => void;
45
+ readonly __wbg_set_voice_length: (a: number, b: number) => void;
46
+ readonly __wbg_set_voice_pause: (a: number, b: number) => void;
47
+ readonly __wbg_set_voice_pitch: (a: number, b: number) => void;
48
+ readonly __wbg_set_voice_sample_rate: (a: number, b: number) => void;
49
+ readonly __wbg_set_voice_seed: (a: number, b: bigint) => void;
50
+ readonly __wbg_set_voice_skip: (a: number, b: number) => void;
51
+ readonly __wbg_set_voice_tick: (a: number, b: number) => void;
52
+ readonly __wbg_voice_free: (a: number, b: number) => void;
53
+ readonly voice_add_clip: (a: number, b: number, c: number) => void;
54
+ readonly voice_babble: () => number;
55
+ readonly voice_blip: () => number;
56
+ readonly voice_chitter: () => number;
57
+ readonly voice_cues: (a: number, b: number, c: number) => [number, number];
58
+ readonly voice_empty: () => number;
59
+ readonly voice_grumble: () => number;
60
+ readonly voice_speak: (a: number, b: number, c: number) => [number, number];
61
+ readonly voice_wav: (a: number, b: number, c: number) => [number, number];
62
+ readonly __wbindgen_externrefs: WebAssembly.Table;
63
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
64
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
65
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
66
+ readonly __wbindgen_start: () => void;
67
+ }
68
+
69
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
70
+
71
+ /**
72
+ * Instantiates the given `module`, which can either be bytes or
73
+ * a precompiled `WebAssembly.Module`.
74
+ *
75
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
76
+ *
77
+ * @returns {InitOutput}
78
+ */
79
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
80
+
81
+ /**
82
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
83
+ * for everything else, calls `WebAssembly.instantiate` directly.
84
+ *
85
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
86
+ *
87
+ * @returns {Promise<InitOutput>}
88
+ */
89
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/wurble.js ADDED
@@ -0,0 +1,455 @@
1
+ /* @ts-self-types="./wurble.d.ts" */
2
+
3
+ export class Voice {
4
+ static __wrap(ptr) {
5
+ const obj = Object.create(Voice.prototype);
6
+ obj.__wbg_ptr = ptr;
7
+ VoiceFinalization.register(obj, obj.__wbg_ptr, obj);
8
+ return obj;
9
+ }
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ VoiceFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_voice_free(ptr, 0);
19
+ }
20
+ /**
21
+ * @returns {number}
22
+ */
23
+ get hiss() {
24
+ const ret = wasm.__wbg_get_voice_hiss(this.__wbg_ptr);
25
+ return ret;
26
+ }
27
+ /**
28
+ * @returns {number}
29
+ */
30
+ get inflection() {
31
+ const ret = wasm.__wbg_get_voice_inflection(this.__wbg_ptr);
32
+ return ret;
33
+ }
34
+ /**
35
+ * @returns {number}
36
+ */
37
+ get jitter() {
38
+ const ret = wasm.__wbg_get_voice_jitter(this.__wbg_ptr);
39
+ return ret;
40
+ }
41
+ /**
42
+ * @returns {number}
43
+ */
44
+ get length() {
45
+ const ret = wasm.__wbg_get_voice_length(this.__wbg_ptr);
46
+ return ret;
47
+ }
48
+ /**
49
+ * @returns {number}
50
+ */
51
+ get pause() {
52
+ const ret = wasm.__wbg_get_voice_pause(this.__wbg_ptr);
53
+ return ret;
54
+ }
55
+ /**
56
+ * @returns {number}
57
+ */
58
+ get pitch() {
59
+ const ret = wasm.__wbg_get_voice_pitch(this.__wbg_ptr);
60
+ return ret;
61
+ }
62
+ /**
63
+ * @returns {number}
64
+ */
65
+ get sample_rate() {
66
+ const ret = wasm.__wbg_get_voice_sample_rate(this.__wbg_ptr);
67
+ return ret >>> 0;
68
+ }
69
+ /**
70
+ * @returns {bigint}
71
+ */
72
+ get seed() {
73
+ const ret = wasm.__wbg_get_voice_seed(this.__wbg_ptr);
74
+ return BigInt.asUintN(64, ret);
75
+ }
76
+ /**
77
+ * @returns {number}
78
+ */
79
+ get skip() {
80
+ const ret = wasm.__wbg_get_voice_skip(this.__wbg_ptr);
81
+ return ret >>> 0;
82
+ }
83
+ /**
84
+ * @returns {number}
85
+ */
86
+ get tick() {
87
+ const ret = wasm.__wbg_get_voice_tick(this.__wbg_ptr);
88
+ return ret;
89
+ }
90
+ /**
91
+ * @param {number} arg0
92
+ */
93
+ set hiss(arg0) {
94
+ wasm.__wbg_set_voice_hiss(this.__wbg_ptr, arg0);
95
+ }
96
+ /**
97
+ * @param {number} arg0
98
+ */
99
+ set inflection(arg0) {
100
+ wasm.__wbg_set_voice_inflection(this.__wbg_ptr, arg0);
101
+ }
102
+ /**
103
+ * @param {number} arg0
104
+ */
105
+ set jitter(arg0) {
106
+ wasm.__wbg_set_voice_jitter(this.__wbg_ptr, arg0);
107
+ }
108
+ /**
109
+ * @param {number} arg0
110
+ */
111
+ set length(arg0) {
112
+ wasm.__wbg_set_voice_length(this.__wbg_ptr, arg0);
113
+ }
114
+ /**
115
+ * @param {number} arg0
116
+ */
117
+ set pause(arg0) {
118
+ wasm.__wbg_set_voice_pause(this.__wbg_ptr, arg0);
119
+ }
120
+ /**
121
+ * @param {number} arg0
122
+ */
123
+ set pitch(arg0) {
124
+ wasm.__wbg_set_voice_pitch(this.__wbg_ptr, arg0);
125
+ }
126
+ /**
127
+ * @param {number} arg0
128
+ */
129
+ set sample_rate(arg0) {
130
+ wasm.__wbg_set_voice_sample_rate(this.__wbg_ptr, arg0);
131
+ }
132
+ /**
133
+ * @param {bigint} arg0
134
+ */
135
+ set seed(arg0) {
136
+ wasm.__wbg_set_voice_seed(this.__wbg_ptr, arg0);
137
+ }
138
+ /**
139
+ * @param {number} arg0
140
+ */
141
+ set skip(arg0) {
142
+ wasm.__wbg_set_voice_skip(this.__wbg_ptr, arg0);
143
+ }
144
+ /**
145
+ * @param {number} arg0
146
+ */
147
+ set tick(arg0) {
148
+ wasm.__wbg_set_voice_tick(this.__wbg_ptr, arg0);
149
+ }
150
+ /**
151
+ * @param {Float32Array} clip
152
+ */
153
+ add_clip(clip) {
154
+ const ptr0 = passArrayF32ToWasm0(clip, wasm.__wbindgen_malloc);
155
+ const len0 = WASM_VECTOR_LEN;
156
+ wasm.voice_add_clip(this.__wbg_ptr, ptr0, len0);
157
+ }
158
+ /**
159
+ * @returns {Voice}
160
+ */
161
+ static babble() {
162
+ const ret = wasm.voice_babble();
163
+ return Voice.__wrap(ret);
164
+ }
165
+ /**
166
+ * @returns {Voice}
167
+ */
168
+ static blip() {
169
+ const ret = wasm.voice_blip();
170
+ return Voice.__wrap(ret);
171
+ }
172
+ /**
173
+ * @returns {Voice}
174
+ */
175
+ static chitter() {
176
+ const ret = wasm.voice_chitter();
177
+ return Voice.__wrap(ret);
178
+ }
179
+ /**
180
+ * @param {string} text
181
+ * @returns {Float32Array}
182
+ */
183
+ cues(text) {
184
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
+ const len0 = WASM_VECTOR_LEN;
186
+ const ret = wasm.voice_cues(this.__wbg_ptr, ptr0, len0);
187
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
188
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
189
+ return v2;
190
+ }
191
+ constructor() {
192
+ const ret = wasm.voice_empty();
193
+ this.__wbg_ptr = ret;
194
+ VoiceFinalization.register(this, this.__wbg_ptr, this);
195
+ return this;
196
+ }
197
+ /**
198
+ * @returns {Voice}
199
+ */
200
+ static grumble() {
201
+ const ret = wasm.voice_grumble();
202
+ return Voice.__wrap(ret);
203
+ }
204
+ /**
205
+ * @param {string} text
206
+ * @returns {Float32Array}
207
+ */
208
+ speak(text) {
209
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
210
+ const len0 = WASM_VECTOR_LEN;
211
+ const ret = wasm.voice_speak(this.__wbg_ptr, ptr0, len0);
212
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
213
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
214
+ return v2;
215
+ }
216
+ /**
217
+ * @param {string} text
218
+ * @returns {Uint8Array}
219
+ */
220
+ wav(text) {
221
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
+ const len0 = WASM_VECTOR_LEN;
223
+ const ret = wasm.voice_wav(this.__wbg_ptr, ptr0, len0);
224
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
225
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
226
+ return v2;
227
+ }
228
+ }
229
+ if (Symbol.dispose) Voice.prototype[Symbol.dispose] = Voice.prototype.free;
230
+ function __wbg_get_imports() {
231
+ const import0 = {
232
+ __proto__: null,
233
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
234
+ throw new Error(getStringFromWasm0(arg0, arg1));
235
+ },
236
+ __wbindgen_init_externref_table: function() {
237
+ const table = wasm.__wbindgen_externrefs;
238
+ const offset = table.grow(4);
239
+ table.set(0, undefined);
240
+ table.set(offset + 0, undefined);
241
+ table.set(offset + 1, null);
242
+ table.set(offset + 2, true);
243
+ table.set(offset + 3, false);
244
+ },
245
+ };
246
+ return {
247
+ __proto__: null,
248
+ "./wurble_bg.js": import0,
249
+ };
250
+ }
251
+
252
+ const VoiceFinalization = (typeof FinalizationRegistry === 'undefined')
253
+ ? { register: () => {}, unregister: () => {} }
254
+ : new FinalizationRegistry(ptr => wasm.__wbg_voice_free(ptr, 1));
255
+
256
+ function getArrayF32FromWasm0(ptr, len) {
257
+ ptr = ptr >>> 0;
258
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
259
+ }
260
+
261
+ function getArrayU8FromWasm0(ptr, len) {
262
+ ptr = ptr >>> 0;
263
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
264
+ }
265
+
266
+ let cachedFloat32ArrayMemory0 = null;
267
+ function getFloat32ArrayMemory0() {
268
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
269
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
270
+ }
271
+ return cachedFloat32ArrayMemory0;
272
+ }
273
+
274
+ function getStringFromWasm0(ptr, len) {
275
+ return decodeText(ptr >>> 0, len);
276
+ }
277
+
278
+ let cachedUint8ArrayMemory0 = null;
279
+ function getUint8ArrayMemory0() {
280
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
281
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
282
+ }
283
+ return cachedUint8ArrayMemory0;
284
+ }
285
+
286
+ function passArrayF32ToWasm0(arg, malloc) {
287
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
288
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
289
+ WASM_VECTOR_LEN = arg.length;
290
+ return ptr;
291
+ }
292
+
293
+ function passStringToWasm0(arg, malloc, realloc) {
294
+ if (realloc === undefined) {
295
+ const buf = cachedTextEncoder.encode(arg);
296
+ const ptr = malloc(buf.length, 1) >>> 0;
297
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
298
+ WASM_VECTOR_LEN = buf.length;
299
+ return ptr;
300
+ }
301
+
302
+ let len = arg.length;
303
+ let ptr = malloc(len, 1) >>> 0;
304
+
305
+ const mem = getUint8ArrayMemory0();
306
+
307
+ let offset = 0;
308
+
309
+ for (; offset < len; offset++) {
310
+ const code = arg.charCodeAt(offset);
311
+ if (code > 0x7F) break;
312
+ mem[ptr + offset] = code;
313
+ }
314
+ if (offset !== len) {
315
+ if (offset !== 0) {
316
+ arg = arg.slice(offset);
317
+ }
318
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
319
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
320
+ const ret = cachedTextEncoder.encodeInto(arg, view);
321
+
322
+ offset += ret.written;
323
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
324
+ }
325
+
326
+ WASM_VECTOR_LEN = offset;
327
+ return ptr;
328
+ }
329
+
330
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
331
+ cachedTextDecoder.decode();
332
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
333
+ let numBytesDecoded = 0;
334
+ function decodeText(ptr, len) {
335
+ numBytesDecoded += len;
336
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
337
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
338
+ cachedTextDecoder.decode();
339
+ numBytesDecoded = len;
340
+ }
341
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
342
+ }
343
+
344
+ const cachedTextEncoder = new TextEncoder();
345
+
346
+ if (!('encodeInto' in cachedTextEncoder)) {
347
+ cachedTextEncoder.encodeInto = function (arg, view) {
348
+ const buf = cachedTextEncoder.encode(arg);
349
+ view.set(buf);
350
+ return {
351
+ read: arg.length,
352
+ written: buf.length
353
+ };
354
+ };
355
+ }
356
+
357
+ let WASM_VECTOR_LEN = 0;
358
+
359
+ let wasmModule, wasmInstance, wasm;
360
+ function __wbg_finalize_init(instance, module) {
361
+ wasmInstance = instance;
362
+ wasm = instance.exports;
363
+ wasmModule = module;
364
+ cachedFloat32ArrayMemory0 = null;
365
+ cachedUint8ArrayMemory0 = null;
366
+ wasm.__wbindgen_start();
367
+ return wasm;
368
+ }
369
+
370
+ async function __wbg_load(module, imports) {
371
+ if (typeof Response === 'function' && module instanceof Response) {
372
+ if (!module.ok) {
373
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
374
+ }
375
+
376
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
377
+ try {
378
+ return await WebAssembly.instantiateStreaming(module, imports);
379
+ } catch (e) {
380
+ const validResponse = expectedResponseType(module.type);
381
+
382
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
383
+ 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);
384
+
385
+ } else { throw e; }
386
+ }
387
+ }
388
+
389
+ const bytes = await module.arrayBuffer();
390
+ return await WebAssembly.instantiate(bytes, imports);
391
+ } else {
392
+ const instance = await WebAssembly.instantiate(module, imports);
393
+
394
+ if (instance instanceof WebAssembly.Instance) {
395
+ return { instance, module };
396
+ } else {
397
+ return instance;
398
+ }
399
+ }
400
+
401
+ function expectedResponseType(type) {
402
+ switch (type) {
403
+ case 'basic': case 'cors': case 'default': return true;
404
+ }
405
+ return false;
406
+ }
407
+ }
408
+
409
+ function initSync(module) {
410
+ if (wasm !== undefined) return wasm;
411
+
412
+
413
+ if (module !== undefined) {
414
+ if (Object.getPrototypeOf(module) === Object.prototype) {
415
+ ({module} = module)
416
+ } else {
417
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
418
+ }
419
+ }
420
+
421
+ const imports = __wbg_get_imports();
422
+ if (!(module instanceof WebAssembly.Module)) {
423
+ module = new WebAssembly.Module(module);
424
+ }
425
+ const instance = new WebAssembly.Instance(module, imports);
426
+ return __wbg_finalize_init(instance, module);
427
+ }
428
+
429
+ async function __wbg_init(module_or_path) {
430
+ if (wasm !== undefined) return wasm;
431
+
432
+
433
+ if (module_or_path !== undefined) {
434
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
435
+ ({module_or_path} = module_or_path)
436
+ } else {
437
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
438
+ }
439
+ }
440
+
441
+ if (module_or_path === undefined) {
442
+ module_or_path = new URL('wurble_bg.wasm', import.meta.url);
443
+ }
444
+ const imports = __wbg_get_imports();
445
+
446
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
447
+ module_or_path = fetch(module_or_path);
448
+ }
449
+
450
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
451
+
452
+ return __wbg_finalize_init(instance, module);
453
+ }
454
+
455
+ export { initSync, __wbg_init as default };
package/wurble_bg.wasm ADDED
Binary file