@scalable-vector-audio/sva-wasm 0.0.0-bootstrap → 0.2.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/LICENSE +21 -0
- package/package.json +17 -6
- package/sva_wasm.d.ts +83 -0
- package/sva_wasm.js +424 -0
- package/sva_wasm_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fredrik Ryden
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalable-vector-audio/sva-wasm",
|
|
3
|
-
"
|
|
4
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "JS bindings: a composition a page fills node by node, rendered in the browser",
|
|
5
|
+
"version": "0.2.0",
|
|
5
6
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/fredrikolis/scalable-vector-audio"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"sva_wasm_bg.wasm",
|
|
13
|
+
"sva_wasm.js",
|
|
14
|
+
"sva_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "sva_wasm.js",
|
|
17
|
+
"types": "sva_wasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
]
|
|
10
21
|
}
|
package/sva_wasm.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class Composition {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
bound_cache(max_bytes: number): void;
|
|
8
|
+
clear_cache(): void;
|
|
9
|
+
insert(path: string, text: string): void;
|
|
10
|
+
constructor(name?: string | null);
|
|
11
|
+
/**
|
|
12
|
+
* Unset, `target` is `master`; `seconds` is the horizon and `rate` the observation rate.
|
|
13
|
+
*/
|
|
14
|
+
render(target?: string | null, rate?: number | null, seconds?: number | null): Rendering;
|
|
15
|
+
readonly cache_bytes: number;
|
|
16
|
+
readonly cache_max_bytes: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class Rendering {
|
|
20
|
+
private constructor();
|
|
21
|
+
free(): void;
|
|
22
|
+
[Symbol.dispose](): void;
|
|
23
|
+
/**
|
|
24
|
+
* The object `sva-cli render --as <name>` puts under `data`, arrays capped as it caps.
|
|
25
|
+
*/
|
|
26
|
+
query(representation: string, from_secs?: number | null, to_secs?: number | null): any;
|
|
27
|
+
samples(channel: number, from_secs?: number | null, to_secs?: number | null): Float32Array;
|
|
28
|
+
readonly channels: number;
|
|
29
|
+
readonly duration_secs: number;
|
|
30
|
+
readonly sample_rate: number;
|
|
31
|
+
readonly target: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
35
|
+
|
|
36
|
+
export interface InitOutput {
|
|
37
|
+
readonly memory: WebAssembly.Memory;
|
|
38
|
+
readonly __wbg_composition_free: (a: number, b: number) => void;
|
|
39
|
+
readonly __wbg_rendering_free: (a: number, b: number) => void;
|
|
40
|
+
readonly composition_bound_cache: (a: number, b: number) => void;
|
|
41
|
+
readonly composition_cache_bytes: (a: number) => number;
|
|
42
|
+
readonly composition_cache_max_bytes: (a: number) => number;
|
|
43
|
+
readonly composition_clear_cache: (a: number) => void;
|
|
44
|
+
readonly composition_insert: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
45
|
+
readonly composition_new: (a: number, b: number) => number;
|
|
46
|
+
readonly composition_render: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
47
|
+
readonly rendering_channels: (a: number) => number;
|
|
48
|
+
readonly rendering_duration_secs: (a: number) => number;
|
|
49
|
+
readonly rendering_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
50
|
+
readonly rendering_sample_rate: (a: number) => number;
|
|
51
|
+
readonly rendering_samples: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
52
|
+
readonly rendering_target: (a: number) => [number, number];
|
|
53
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
54
|
+
readonly __externref_table_alloc: () => number;
|
|
55
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
56
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
57
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
58
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
59
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
60
|
+
readonly __wbindgen_start: () => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
67
|
+
* a precompiled `WebAssembly.Module`.
|
|
68
|
+
*
|
|
69
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
70
|
+
*
|
|
71
|
+
* @returns {InitOutput}
|
|
72
|
+
*/
|
|
73
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
77
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
78
|
+
*
|
|
79
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
80
|
+
*
|
|
81
|
+
* @returns {Promise<InitOutput>}
|
|
82
|
+
*/
|
|
83
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/sva_wasm.js
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/* @ts-self-types="./sva_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
export class Composition {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
CompositionFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_composition_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @param {number} max_bytes
|
|
16
|
+
*/
|
|
17
|
+
bound_cache(max_bytes) {
|
|
18
|
+
wasm.composition_bound_cache(this.__wbg_ptr, max_bytes);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @returns {number}
|
|
22
|
+
*/
|
|
23
|
+
get cache_bytes() {
|
|
24
|
+
const ret = wasm.composition_cache_bytes(this.__wbg_ptr);
|
|
25
|
+
return ret;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @returns {number}
|
|
29
|
+
*/
|
|
30
|
+
get cache_max_bytes() {
|
|
31
|
+
const ret = wasm.composition_cache_max_bytes(this.__wbg_ptr);
|
|
32
|
+
return ret;
|
|
33
|
+
}
|
|
34
|
+
clear_cache() {
|
|
35
|
+
wasm.composition_clear_cache(this.__wbg_ptr);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} path
|
|
39
|
+
* @param {string} text
|
|
40
|
+
*/
|
|
41
|
+
insert(path, text) {
|
|
42
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
43
|
+
const len0 = WASM_VECTOR_LEN;
|
|
44
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
45
|
+
const len1 = WASM_VECTOR_LEN;
|
|
46
|
+
wasm.composition_insert(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @param {string | null} [name]
|
|
50
|
+
*/
|
|
51
|
+
constructor(name) {
|
|
52
|
+
var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
53
|
+
var len0 = WASM_VECTOR_LEN;
|
|
54
|
+
const ret = wasm.composition_new(ptr0, len0);
|
|
55
|
+
this.__wbg_ptr = ret;
|
|
56
|
+
CompositionFinalization.register(this, this.__wbg_ptr, this);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Unset, `target` is `master`; `seconds` is the horizon and `rate` the observation rate.
|
|
61
|
+
* @param {string | null} [target]
|
|
62
|
+
* @param {number | null} [rate]
|
|
63
|
+
* @param {number | null} [seconds]
|
|
64
|
+
* @returns {Rendering}
|
|
65
|
+
*/
|
|
66
|
+
render(target, rate, seconds) {
|
|
67
|
+
var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
68
|
+
var len0 = WASM_VECTOR_LEN;
|
|
69
|
+
const ret = wasm.composition_render(this.__wbg_ptr, ptr0, len0, isLikeNone(rate) ? Number.MAX_SAFE_INTEGER : (rate) >>> 0, !isLikeNone(seconds), isLikeNone(seconds) ? 0 : seconds);
|
|
70
|
+
if (ret[2]) {
|
|
71
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
72
|
+
}
|
|
73
|
+
return Rendering.__wrap(ret[0]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (Symbol.dispose) Composition.prototype[Symbol.dispose] = Composition.prototype.free;
|
|
77
|
+
|
|
78
|
+
export class Rendering {
|
|
79
|
+
static __wrap(ptr) {
|
|
80
|
+
const obj = Object.create(Rendering.prototype);
|
|
81
|
+
obj.__wbg_ptr = ptr;
|
|
82
|
+
RenderingFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
__destroy_into_raw() {
|
|
86
|
+
const ptr = this.__wbg_ptr;
|
|
87
|
+
this.__wbg_ptr = 0;
|
|
88
|
+
RenderingFinalization.unregister(this);
|
|
89
|
+
return ptr;
|
|
90
|
+
}
|
|
91
|
+
free() {
|
|
92
|
+
const ptr = this.__destroy_into_raw();
|
|
93
|
+
wasm.__wbg_rendering_free(ptr, 0);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @returns {number}
|
|
97
|
+
*/
|
|
98
|
+
get channels() {
|
|
99
|
+
const ret = wasm.rendering_channels(this.__wbg_ptr);
|
|
100
|
+
return ret >>> 0;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @returns {number}
|
|
104
|
+
*/
|
|
105
|
+
get duration_secs() {
|
|
106
|
+
const ret = wasm.rendering_duration_secs(this.__wbg_ptr);
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The object `sva-cli render --as <name>` puts under `data`, arrays capped as it caps.
|
|
111
|
+
* @param {string} representation
|
|
112
|
+
* @param {number | null} [from_secs]
|
|
113
|
+
* @param {number | null} [to_secs]
|
|
114
|
+
* @returns {any}
|
|
115
|
+
*/
|
|
116
|
+
query(representation, from_secs, to_secs) {
|
|
117
|
+
const ptr0 = passStringToWasm0(representation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.rendering_query(this.__wbg_ptr, ptr0, len0, !isLikeNone(from_secs), isLikeNone(from_secs) ? 0 : from_secs, !isLikeNone(to_secs), isLikeNone(to_secs) ? 0 : to_secs);
|
|
120
|
+
if (ret[2]) {
|
|
121
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
122
|
+
}
|
|
123
|
+
return takeFromExternrefTable0(ret[0]);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @returns {number}
|
|
127
|
+
*/
|
|
128
|
+
get sample_rate() {
|
|
129
|
+
const ret = wasm.rendering_sample_rate(this.__wbg_ptr);
|
|
130
|
+
return ret >>> 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @param {number} channel
|
|
134
|
+
* @param {number | null} [from_secs]
|
|
135
|
+
* @param {number | null} [to_secs]
|
|
136
|
+
* @returns {Float32Array}
|
|
137
|
+
*/
|
|
138
|
+
samples(channel, from_secs, to_secs) {
|
|
139
|
+
const ret = wasm.rendering_samples(this.__wbg_ptr, channel, !isLikeNone(from_secs), isLikeNone(from_secs) ? 0 : from_secs, !isLikeNone(to_secs), isLikeNone(to_secs) ? 0 : to_secs);
|
|
140
|
+
if (ret[3]) {
|
|
141
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
142
|
+
}
|
|
143
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
144
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
145
|
+
return v1;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @returns {string}
|
|
149
|
+
*/
|
|
150
|
+
get target() {
|
|
151
|
+
let deferred1_0;
|
|
152
|
+
let deferred1_1;
|
|
153
|
+
try {
|
|
154
|
+
const ret = wasm.rendering_target(this.__wbg_ptr);
|
|
155
|
+
deferred1_0 = ret[0];
|
|
156
|
+
deferred1_1 = ret[1];
|
|
157
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
158
|
+
} finally {
|
|
159
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (Symbol.dispose) Rendering.prototype[Symbol.dispose] = Rendering.prototype.free;
|
|
164
|
+
function __wbg_get_imports() {
|
|
165
|
+
const import0 = {
|
|
166
|
+
__proto__: null,
|
|
167
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
168
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
169
|
+
},
|
|
170
|
+
__wbg_new_ba59ef2486993134: function(arg0, arg1) {
|
|
171
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg_parse_8ede4cc41eba4991: function() { return handleError(function (arg0, arg1) {
|
|
175
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
176
|
+
return ret;
|
|
177
|
+
}, arguments); },
|
|
178
|
+
__wbg_set_name_1c3c10b65efaa3ed: function(arg0, arg1, arg2) {
|
|
179
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
180
|
+
},
|
|
181
|
+
__wbg_set_refusal_f44fac85733e1451: function(arg0, arg1) {
|
|
182
|
+
arg0.refusal = arg1;
|
|
183
|
+
},
|
|
184
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
185
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
186
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
187
|
+
return ret;
|
|
188
|
+
},
|
|
189
|
+
__wbindgen_init_externref_table: function() {
|
|
190
|
+
const table = wasm.__wbindgen_externrefs;
|
|
191
|
+
const offset = table.grow(4);
|
|
192
|
+
table.set(0, undefined);
|
|
193
|
+
table.set(offset + 0, undefined);
|
|
194
|
+
table.set(offset + 1, null);
|
|
195
|
+
table.set(offset + 2, true);
|
|
196
|
+
table.set(offset + 3, false);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
__proto__: null,
|
|
201
|
+
"./sva_wasm_bg.js": import0,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const CompositionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
206
|
+
? { register: () => {}, unregister: () => {} }
|
|
207
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_composition_free(ptr, 1));
|
|
208
|
+
const RenderingFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
209
|
+
? { register: () => {}, unregister: () => {} }
|
|
210
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rendering_free(ptr, 1));
|
|
211
|
+
|
|
212
|
+
function addToExternrefTable0(obj) {
|
|
213
|
+
const idx = wasm.__externref_table_alloc();
|
|
214
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
215
|
+
return idx;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
219
|
+
ptr = ptr >>> 0;
|
|
220
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
224
|
+
function getFloat32ArrayMemory0() {
|
|
225
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
226
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
227
|
+
}
|
|
228
|
+
return cachedFloat32ArrayMemory0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function getStringFromWasm0(ptr, len) {
|
|
232
|
+
return decodeText(ptr >>> 0, len);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let cachedUint8ArrayMemory0 = null;
|
|
236
|
+
function getUint8ArrayMemory0() {
|
|
237
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
238
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
239
|
+
}
|
|
240
|
+
return cachedUint8ArrayMemory0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function handleError(f, args) {
|
|
244
|
+
try {
|
|
245
|
+
return f.apply(this, args);
|
|
246
|
+
} catch (e) {
|
|
247
|
+
const idx = addToExternrefTable0(e);
|
|
248
|
+
wasm.__wbindgen_exn_store(idx);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function isLikeNone(x) {
|
|
253
|
+
return x === undefined || x === null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
257
|
+
if (realloc === undefined) {
|
|
258
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
259
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
260
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
261
|
+
WASM_VECTOR_LEN = buf.length;
|
|
262
|
+
return ptr;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
let len = arg.length;
|
|
266
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
267
|
+
|
|
268
|
+
const mem = getUint8ArrayMemory0();
|
|
269
|
+
|
|
270
|
+
let offset = 0;
|
|
271
|
+
|
|
272
|
+
for (; offset < len; offset++) {
|
|
273
|
+
const code = arg.charCodeAt(offset);
|
|
274
|
+
if (code > 0x7F) break;
|
|
275
|
+
mem[ptr + offset] = code;
|
|
276
|
+
}
|
|
277
|
+
if (offset !== len) {
|
|
278
|
+
if (offset !== 0) {
|
|
279
|
+
arg = arg.slice(offset);
|
|
280
|
+
}
|
|
281
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
282
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
283
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
284
|
+
|
|
285
|
+
offset += ret.written;
|
|
286
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
WASM_VECTOR_LEN = offset;
|
|
290
|
+
return ptr;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function takeFromExternrefTable0(idx) {
|
|
294
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
295
|
+
wasm.__externref_table_dealloc(idx);
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
300
|
+
cachedTextDecoder.decode();
|
|
301
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
302
|
+
let numBytesDecoded = 0;
|
|
303
|
+
function decodeText(ptr, len) {
|
|
304
|
+
numBytesDecoded += len;
|
|
305
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
306
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
307
|
+
cachedTextDecoder.decode();
|
|
308
|
+
numBytesDecoded = len;
|
|
309
|
+
}
|
|
310
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const cachedTextEncoder = new TextEncoder();
|
|
314
|
+
|
|
315
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
316
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
317
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
318
|
+
view.set(buf);
|
|
319
|
+
return {
|
|
320
|
+
read: arg.length,
|
|
321
|
+
written: buf.length
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
let WASM_VECTOR_LEN = 0;
|
|
327
|
+
|
|
328
|
+
let wasmModule, wasmInstance, wasm;
|
|
329
|
+
function __wbg_finalize_init(instance, module) {
|
|
330
|
+
wasmInstance = instance;
|
|
331
|
+
wasm = instance.exports;
|
|
332
|
+
wasmModule = module;
|
|
333
|
+
cachedFloat32ArrayMemory0 = null;
|
|
334
|
+
cachedUint8ArrayMemory0 = null;
|
|
335
|
+
wasm.__wbindgen_start();
|
|
336
|
+
return wasm;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async function __wbg_load(module, imports) {
|
|
340
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
341
|
+
if (!module.ok) {
|
|
342
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
346
|
+
try {
|
|
347
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
const validResponse = expectedResponseType(module.type);
|
|
350
|
+
|
|
351
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
352
|
+
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);
|
|
353
|
+
|
|
354
|
+
} else { throw e; }
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const bytes = await module.arrayBuffer();
|
|
359
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
360
|
+
} else {
|
|
361
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
362
|
+
|
|
363
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
364
|
+
return { instance, module };
|
|
365
|
+
} else {
|
|
366
|
+
return instance;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function expectedResponseType(type) {
|
|
371
|
+
switch (type) {
|
|
372
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function initSync(module) {
|
|
379
|
+
if (wasm !== undefined) return wasm;
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
if (module !== undefined) {
|
|
383
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
384
|
+
({module} = module)
|
|
385
|
+
} else {
|
|
386
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const imports = __wbg_get_imports();
|
|
391
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
392
|
+
module = new WebAssembly.Module(module);
|
|
393
|
+
}
|
|
394
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
395
|
+
return __wbg_finalize_init(instance, module);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async function __wbg_init(module_or_path) {
|
|
399
|
+
if (wasm !== undefined) return wasm;
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
if (module_or_path !== undefined) {
|
|
403
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
404
|
+
({module_or_path} = module_or_path)
|
|
405
|
+
} else {
|
|
406
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (module_or_path === undefined) {
|
|
411
|
+
module_or_path = new URL('sva_wasm_bg.wasm', import.meta.url);
|
|
412
|
+
}
|
|
413
|
+
const imports = __wbg_get_imports();
|
|
414
|
+
|
|
415
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
416
|
+
module_or_path = fetch(module_or_path);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
420
|
+
|
|
421
|
+
return __wbg_finalize_init(instance, module);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export { initSync, __wbg_init as default };
|
package/sva_wasm_bg.wasm
ADDED
|
Binary file
|