@viritura/score-engine 0.0.0 → 0.1.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/CHANGELOG.md +50 -0
- package/README.md +125 -1
- package/dist/LICENSE +21 -0
- package/dist/LICENSES/OFL-1.1.txt +80 -0
- package/dist/THIRD_PARTY_NOTICES.md +95 -0
- package/dist/fonts/Bravura.otf +0 -0
- package/dist/fonts/LibertinusSerif-Bold.otf +0 -0
- package/dist/fonts/LibertinusSerif-BoldItalic.otf +0 -0
- package/dist/fonts/LibertinusSerif-Italic.otf +0 -0
- package/dist/fonts/LibertinusSerif-Regular.otf +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5740 -0
- package/dist/index.js.map +7 -0
- package/dist/score-engine.worker.js +136 -0
- package/dist/score-engine.worker.js.map +7 -0
- package/dist/types/engine.d.ts +56 -0
- package/dist/types/errors.d.ts +36 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/timeline.d.ts +67 -0
- package/dist/types/types.d.ts +255 -0
- package/dist/wasm/viritura_wasm.js +975 -0
- package/dist/wasm/viritura_wasm_bg.wasm +0 -0
- package/package.json +56 -10
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
/* @ts-self-types="./viritura_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stateful layout engine that persists a measure-level cache and the
|
|
5
|
+
* parsed Score model across calls. Supports patch-based updates that
|
|
6
|
+
* only re-parse changed measures, skipping full MNX parse on edits.
|
|
7
|
+
*/
|
|
8
|
+
export class LayoutEngine {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
LayoutEngineFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_layoutengine_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Apply a measure/root-settings patch and re-layout incrementally.
|
|
21
|
+
*
|
|
22
|
+
* The patch JSON format:
|
|
23
|
+
* ```json
|
|
24
|
+
* {
|
|
25
|
+
* "globalMeasures": { "3": { ... GlobalMeasure JSON ... } },
|
|
26
|
+
* "partMeasures": { "0": { "3": { ... PartMeasure JSON ... } } },
|
|
27
|
+
* "timeSignatures": { "score": { "scale": 1.5 } }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Only the specified measures are re-parsed and replaced in the retained
|
|
32
|
+
* Score model. The layout cache handles skipping unchanged measures.
|
|
33
|
+
* Falls back to full parse if no score is retained.
|
|
34
|
+
* @param {string} patch_json
|
|
35
|
+
* @param {number} spatium
|
|
36
|
+
* @param {number} page_width
|
|
37
|
+
* @param {string | null} [page_setup_json]
|
|
38
|
+
* @param {number | null} [score_index]
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
apply_patch_and_layout(patch_json, spatium, page_width, page_setup_json, score_index) {
|
|
42
|
+
let deferred4_0;
|
|
43
|
+
let deferred4_1;
|
|
44
|
+
try {
|
|
45
|
+
const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
|
+
var len1 = WASM_VECTOR_LEN;
|
|
49
|
+
const ret = wasm.layoutengine_apply_patch_and_layout(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
50
|
+
var ptr3 = ret[0];
|
|
51
|
+
var len3 = ret[1];
|
|
52
|
+
if (ret[3]) {
|
|
53
|
+
ptr3 = 0; len3 = 0;
|
|
54
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
55
|
+
}
|
|
56
|
+
deferred4_0 = ptr3;
|
|
57
|
+
deferred4_1 = len3;
|
|
58
|
+
return getStringFromWasm0(ptr3, len3);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Apply a measure-level patch and return a binary display list.
|
|
65
|
+
* @param {string} patch_json
|
|
66
|
+
* @param {number} spatium
|
|
67
|
+
* @param {number} page_width
|
|
68
|
+
* @param {string | null} [page_setup_json]
|
|
69
|
+
* @param {number | null} [score_index]
|
|
70
|
+
* @returns {Float32Array}
|
|
71
|
+
*/
|
|
72
|
+
apply_patch_and_layout_binary(patch_json, spatium, page_width, page_setup_json, score_index) {
|
|
73
|
+
const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
74
|
+
const len0 = WASM_VECTOR_LEN;
|
|
75
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
+
var len1 = WASM_VECTOR_LEN;
|
|
77
|
+
const ret = wasm.layoutengine_apply_patch_and_layout_binary(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
78
|
+
if (ret[2]) {
|
|
79
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
80
|
+
}
|
|
81
|
+
return takeFromExternrefTable0(ret[0]);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Apply a measure-level patch and return a PATCH-FRAME delta when the
|
|
85
|
+
* incremental path is available, else a full binary display list.
|
|
86
|
+
*
|
|
87
|
+
* The returned `Float32Array` is tagged at element 0:
|
|
88
|
+
* - `0.0` → full frame: the remainder is `DisplayList::to_binary()`.
|
|
89
|
+
* - `1.0` → patch frame: the remainder is the packed patch (changed
|
|
90
|
+
* systems + per-system shifts). The client reassembles against its
|
|
91
|
+
* retained per-system segment array.
|
|
92
|
+
*
|
|
93
|
+
* Only the auto-flow (paginated) layout path emits patch frames; all other
|
|
94
|
+
* paths (explicit pages, single-page) return a full frame transparently.
|
|
95
|
+
* @param {string} patch_json
|
|
96
|
+
* @param {number} spatium
|
|
97
|
+
* @param {number} page_width
|
|
98
|
+
* @param {string | null} [page_setup_json]
|
|
99
|
+
* @param {number | null} [score_index]
|
|
100
|
+
* @returns {Float32Array}
|
|
101
|
+
*/
|
|
102
|
+
apply_patch_and_layout_patch_frame_binary(patch_json, spatium, page_width, page_setup_json, score_index) {
|
|
103
|
+
const ptr0 = passStringToWasm0(patch_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
104
|
+
const len0 = WASM_VECTOR_LEN;
|
|
105
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
var len1 = WASM_VECTOR_LEN;
|
|
107
|
+
const ret = wasm.layoutengine_apply_patch_and_layout_patch_frame_binary(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
108
|
+
if (ret[2]) {
|
|
109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
110
|
+
}
|
|
111
|
+
return takeFromExternrefTable0(ret[0]);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get cache stats from the last layout pass: [hits, misses].
|
|
115
|
+
* @returns {Uint32Array}
|
|
116
|
+
*/
|
|
117
|
+
cache_stats() {
|
|
118
|
+
const ret = wasm.layoutengine_cache_stats(this.__wbg_ptr);
|
|
119
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
120
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
121
|
+
return v1;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Layout all parts (full score) with cache. Returns DisplayList JSON.
|
|
125
|
+
* Parses the full MNX JSON and retains the Score internally.
|
|
126
|
+
* @param {string} mnx_json
|
|
127
|
+
* @param {number} spatium
|
|
128
|
+
* @param {number} page_width
|
|
129
|
+
* @param {string | null} [page_setup_json]
|
|
130
|
+
* @param {number | null} [score_index]
|
|
131
|
+
* @returns {string}
|
|
132
|
+
*/
|
|
133
|
+
compute_full_score_layout_cached(mnx_json, spatium, page_width, page_setup_json, score_index) {
|
|
134
|
+
let deferred4_0;
|
|
135
|
+
let deferred4_1;
|
|
136
|
+
try {
|
|
137
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len0 = WASM_VECTOR_LEN;
|
|
139
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
var len1 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.layoutengine_compute_full_score_layout_cached(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
142
|
+
var ptr3 = ret[0];
|
|
143
|
+
var len3 = ret[1];
|
|
144
|
+
if (ret[3]) {
|
|
145
|
+
ptr3 = 0; len3 = 0;
|
|
146
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
147
|
+
}
|
|
148
|
+
deferred4_0 = ptr3;
|
|
149
|
+
deferred4_1 = len3;
|
|
150
|
+
return getStringFromWasm0(ptr3, len3);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Binary sibling of [`Self::compute_full_score_layout_cached`]. Returns the
|
|
157
|
+
* packed `Float32Array` so the worker can `transfer` it to the main thread
|
|
158
|
+
* zero-copy, avoiding a multi-megabyte JSON serialize + structured-clone +
|
|
159
|
+
* `JSON.parse` of the full display list on initial load of large scores.
|
|
160
|
+
* @param {string} mnx_json
|
|
161
|
+
* @param {number} spatium
|
|
162
|
+
* @param {number} page_width
|
|
163
|
+
* @param {string | null} [page_setup_json]
|
|
164
|
+
* @param {number | null} [score_index]
|
|
165
|
+
* @returns {Float32Array}
|
|
166
|
+
*/
|
|
167
|
+
compute_full_score_layout_cached_binary(mnx_json, spatium, page_width, page_setup_json, score_index) {
|
|
168
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
169
|
+
const len0 = WASM_VECTOR_LEN;
|
|
170
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
171
|
+
var len1 = WASM_VECTOR_LEN;
|
|
172
|
+
const ret = wasm.layoutengine_compute_full_score_layout_cached_binary(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
173
|
+
if (ret[2]) {
|
|
174
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
175
|
+
}
|
|
176
|
+
return takeFromExternrefTable0(ret[0]);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Layout a single part with cache. Returns DisplayList JSON.
|
|
180
|
+
* Parses the full MNX JSON and retains the Score internally.
|
|
181
|
+
* @param {string} mnx_json
|
|
182
|
+
* @param {number} part_index
|
|
183
|
+
* @param {number} spatium
|
|
184
|
+
* @param {number} page_width
|
|
185
|
+
* @param {string | null} [page_setup_json]
|
|
186
|
+
* @returns {string}
|
|
187
|
+
*/
|
|
188
|
+
compute_layout_cached(mnx_json, part_index, spatium, page_width, page_setup_json) {
|
|
189
|
+
let deferred4_0;
|
|
190
|
+
let deferred4_1;
|
|
191
|
+
try {
|
|
192
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
var len1 = WASM_VECTOR_LEN;
|
|
196
|
+
const ret = wasm.layoutengine_compute_layout_cached(this.__wbg_ptr, ptr0, len0, part_index, spatium, page_width, ptr1, len1);
|
|
197
|
+
var ptr3 = ret[0];
|
|
198
|
+
var len3 = ret[1];
|
|
199
|
+
if (ret[3]) {
|
|
200
|
+
ptr3 = 0; len3 = 0;
|
|
201
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
202
|
+
}
|
|
203
|
+
deferred4_0 = ptr3;
|
|
204
|
+
deferred4_1 = len3;
|
|
205
|
+
return getStringFromWasm0(ptr3, len3);
|
|
206
|
+
} finally {
|
|
207
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Use when structural changes occur (parts added/removed, etc.).
|
|
212
|
+
* @param {string} mnx_json
|
|
213
|
+
* @param {number} spatium
|
|
214
|
+
* @param {number} page_width
|
|
215
|
+
* @param {string | null} [page_setup_json]
|
|
216
|
+
* @param {number | null} [score_index]
|
|
217
|
+
* @returns {string}
|
|
218
|
+
*/
|
|
219
|
+
full_layout(mnx_json, spatium, page_width, page_setup_json, score_index) {
|
|
220
|
+
let deferred4_0;
|
|
221
|
+
let deferred4_1;
|
|
222
|
+
try {
|
|
223
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
224
|
+
const len0 = WASM_VECTOR_LEN;
|
|
225
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
226
|
+
var len1 = WASM_VECTOR_LEN;
|
|
227
|
+
const ret = wasm.layoutengine_full_layout(this.__wbg_ptr, ptr0, len0, spatium, page_width, ptr1, len1, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
228
|
+
var ptr3 = ret[0];
|
|
229
|
+
var len3 = ret[1];
|
|
230
|
+
if (ret[3]) {
|
|
231
|
+
ptr3 = 0; len3 = 0;
|
|
232
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
233
|
+
}
|
|
234
|
+
deferred4_0 = ptr3;
|
|
235
|
+
deferred4_1 = len3;
|
|
236
|
+
return getStringFromWasm0(ptr3, len3);
|
|
237
|
+
} finally {
|
|
238
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Check if a score is retained (patch API is available).
|
|
243
|
+
* @returns {boolean}
|
|
244
|
+
*/
|
|
245
|
+
has_retained_score() {
|
|
246
|
+
const ret = wasm.layoutengine_has_retained_score(this.__wbg_ptr);
|
|
247
|
+
return ret !== 0;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Invalidate the entire layout cache (e.g. after a config change).
|
|
251
|
+
*/
|
|
252
|
+
invalidate_cache() {
|
|
253
|
+
wasm.layoutengine_invalidate_cache(this.__wbg_ptr);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Deterministic engagement counters for the most recent layout pass.
|
|
257
|
+
* Timing remains in `take_timings_json`; this payload intentionally holds
|
|
258
|
+
* counts/bytes that are stable enough for CI correctness gates.
|
|
259
|
+
* @returns {string}
|
|
260
|
+
*/
|
|
261
|
+
layout_metrics_json() {
|
|
262
|
+
let deferred1_0;
|
|
263
|
+
let deferred1_1;
|
|
264
|
+
try {
|
|
265
|
+
const ret = wasm.layoutengine_layout_metrics_json(this.__wbg_ptr);
|
|
266
|
+
deferred1_0 = ret[0];
|
|
267
|
+
deferred1_1 = ret[1];
|
|
268
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
269
|
+
} finally {
|
|
270
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Create a new layout engine with an empty cache.
|
|
275
|
+
*/
|
|
276
|
+
constructor() {
|
|
277
|
+
const ret = wasm.layoutengine_new();
|
|
278
|
+
this.__wbg_ptr = ret;
|
|
279
|
+
LayoutEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Re-layout the already-retained Score for a (possibly different) score
|
|
284
|
+
* view / config WITHOUT re-parsing the MNX JSON. Returns DisplayList JSON.
|
|
285
|
+
*
|
|
286
|
+
* This is the fast path for switching score views (layouts) on large
|
|
287
|
+
* scores: the parsed + reconciled Score is reused and the measure-level
|
|
288
|
+
* cache absorbs unchanged horizontal spacing, so only the system assembly
|
|
289
|
+
* for the new view is recomputed. Errors if no score is retained, in which
|
|
290
|
+
* case the caller must fall back to `compute_full_score_layout_cached`.
|
|
291
|
+
* @param {number} spatium
|
|
292
|
+
* @param {number} page_width
|
|
293
|
+
* @param {string | null} [page_setup_json]
|
|
294
|
+
* @param {number | null} [score_index]
|
|
295
|
+
* @returns {string}
|
|
296
|
+
*/
|
|
297
|
+
relayout_retained_score_cached(spatium, page_width, page_setup_json, score_index) {
|
|
298
|
+
let deferred3_0;
|
|
299
|
+
let deferred3_1;
|
|
300
|
+
try {
|
|
301
|
+
var ptr0 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
302
|
+
var len0 = WASM_VECTOR_LEN;
|
|
303
|
+
const ret = wasm.layoutengine_relayout_retained_score_cached(this.__wbg_ptr, spatium, page_width, ptr0, len0, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
304
|
+
var ptr2 = ret[0];
|
|
305
|
+
var len2 = ret[1];
|
|
306
|
+
if (ret[3]) {
|
|
307
|
+
ptr2 = 0; len2 = 0;
|
|
308
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
309
|
+
}
|
|
310
|
+
deferred3_0 = ptr2;
|
|
311
|
+
deferred3_1 = len2;
|
|
312
|
+
return getStringFromWasm0(ptr2, len2);
|
|
313
|
+
} finally {
|
|
314
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Binary sibling of [`Self::relayout_retained_score_cached`]. Returns the
|
|
319
|
+
* packed `Float32Array` so the worker can `transfer` it to the main thread
|
|
320
|
+
* zero-copy (avoiding a Comlink structured-clone of the display list).
|
|
321
|
+
* @param {number} spatium
|
|
322
|
+
* @param {number} page_width
|
|
323
|
+
* @param {string | null} [page_setup_json]
|
|
324
|
+
* @param {number | null} [score_index]
|
|
325
|
+
* @returns {Float32Array}
|
|
326
|
+
*/
|
|
327
|
+
relayout_retained_score_cached_binary(spatium, page_width, page_setup_json, score_index) {
|
|
328
|
+
var ptr0 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
329
|
+
var len0 = WASM_VECTOR_LEN;
|
|
330
|
+
const ret = wasm.layoutengine_relayout_retained_score_cached_binary(this.__wbg_ptr, spatium, page_width, ptr0, len0, isLikeNone(score_index) ? Number.MAX_SAFE_INTEGER : (score_index) >>> 0);
|
|
331
|
+
if (ret[2]) {
|
|
332
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
333
|
+
}
|
|
334
|
+
return takeFromExternrefTable0(ret[0]);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Lever 2 step 4 (B-full): enable/disable the per-system wholesale
|
|
338
|
+
* layout-reuse store. Off by default — the live app keeps the shipped
|
|
339
|
+
* per-measure-retention path until the editor perf test confirms the
|
|
340
|
+
* patch-path win. When on, a clean system is moved back in wholesale on
|
|
341
|
+
* each edit (skipping the per-measure HashMap churn + cross-staff fix).
|
|
342
|
+
* Byte-identical to the off path (proven by the engine oracle).
|
|
343
|
+
* @param {boolean} enabled
|
|
344
|
+
*/
|
|
345
|
+
set_system_layout_reuse(enabled) {
|
|
346
|
+
wasm.layoutengine_set_system_layout_reuse(this.__wbg_ptr, enabled);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Phase Q: take the most recent patch-frame timing breakdown as a JSON
|
|
350
|
+
* string and clear it. Returns `None` if `set_wasm_timing(true)` was
|
|
351
|
+
* not called before the layout, or if no patch call has run since the
|
|
352
|
+
* last take.
|
|
353
|
+
* @returns {string | undefined}
|
|
354
|
+
*/
|
|
355
|
+
take_timings_json() {
|
|
356
|
+
const ret = wasm.layoutengine_take_timings_json(this.__wbg_ptr);
|
|
357
|
+
let v1;
|
|
358
|
+
if (ret[0] !== 0) {
|
|
359
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
360
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
361
|
+
}
|
|
362
|
+
return v1;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (Symbol.dispose) LayoutEngine.prototype[Symbol.dispose] = LayoutEngine.prototype.free;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Layout all parts of a score stacked vertically and return a DisplayList as JSON.
|
|
369
|
+
* @param {string} mnx_json
|
|
370
|
+
* @param {number} spatium
|
|
371
|
+
* @param {number} page_width
|
|
372
|
+
* @param {string | null} [page_setup_json]
|
|
373
|
+
* @returns {string}
|
|
374
|
+
*/
|
|
375
|
+
export function compute_full_score_layout(mnx_json, spatium, page_width, page_setup_json) {
|
|
376
|
+
let deferred4_0;
|
|
377
|
+
let deferred4_1;
|
|
378
|
+
try {
|
|
379
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
380
|
+
const len0 = WASM_VECTOR_LEN;
|
|
381
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
382
|
+
var len1 = WASM_VECTOR_LEN;
|
|
383
|
+
const ret = wasm.compute_full_score_layout(ptr0, len0, spatium, page_width, ptr1, len1);
|
|
384
|
+
var ptr3 = ret[0];
|
|
385
|
+
var len3 = ret[1];
|
|
386
|
+
if (ret[3]) {
|
|
387
|
+
ptr3 = 0; len3 = 0;
|
|
388
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
389
|
+
}
|
|
390
|
+
deferred4_0 = ptr3;
|
|
391
|
+
deferred4_1 = len3;
|
|
392
|
+
return getStringFromWasm0(ptr3, len3);
|
|
393
|
+
} finally {
|
|
394
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Layout all parts of a score and return a binary display list as Float32Array.
|
|
400
|
+
* @param {string} mnx_json
|
|
401
|
+
* @param {number} spatium
|
|
402
|
+
* @param {number} page_width
|
|
403
|
+
* @param {string | null} [page_setup_json]
|
|
404
|
+
* @returns {Float32Array}
|
|
405
|
+
*/
|
|
406
|
+
export function compute_full_score_layout_binary(mnx_json, spatium, page_width, page_setup_json) {
|
|
407
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
|
+
const len0 = WASM_VECTOR_LEN;
|
|
409
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
410
|
+
var len1 = WASM_VECTOR_LEN;
|
|
411
|
+
const ret = wasm.compute_full_score_layout_binary(ptr0, len0, spatium, page_width, ptr1, len1);
|
|
412
|
+
if (ret[2]) {
|
|
413
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
414
|
+
}
|
|
415
|
+
return takeFromExternrefTable0(ret[0]);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Layout a score from MNX JSON and return a DisplayList as JSON.
|
|
420
|
+
* @param {string} mnx_json
|
|
421
|
+
* @param {number} part_index
|
|
422
|
+
* @param {number} spatium
|
|
423
|
+
* @param {number} page_width
|
|
424
|
+
* @param {string | null} [page_setup_json]
|
|
425
|
+
* @returns {string}
|
|
426
|
+
*/
|
|
427
|
+
export function compute_layout(mnx_json, part_index, spatium, page_width, page_setup_json) {
|
|
428
|
+
let deferred4_0;
|
|
429
|
+
let deferred4_1;
|
|
430
|
+
try {
|
|
431
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
432
|
+
const len0 = WASM_VECTOR_LEN;
|
|
433
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
434
|
+
var len1 = WASM_VECTOR_LEN;
|
|
435
|
+
const ret = wasm.compute_layout(ptr0, len0, part_index, spatium, page_width, ptr1, len1);
|
|
436
|
+
var ptr3 = ret[0];
|
|
437
|
+
var len3 = ret[1];
|
|
438
|
+
if (ret[3]) {
|
|
439
|
+
ptr3 = 0; len3 = 0;
|
|
440
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
441
|
+
}
|
|
442
|
+
deferred4_0 = ptr3;
|
|
443
|
+
deferred4_1 = len3;
|
|
444
|
+
return getStringFromWasm0(ptr3, len3);
|
|
445
|
+
} finally {
|
|
446
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Layout a score from MNX JSON and return a binary display list as Float32Array.
|
|
452
|
+
* @param {string} mnx_json
|
|
453
|
+
* @param {number} part_index
|
|
454
|
+
* @param {number} spatium
|
|
455
|
+
* @param {number} page_width
|
|
456
|
+
* @param {string | null} [page_setup_json]
|
|
457
|
+
* @returns {Float32Array}
|
|
458
|
+
*/
|
|
459
|
+
export function compute_layout_binary(mnx_json, part_index, spatium, page_width, page_setup_json) {
|
|
460
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
461
|
+
const len0 = WASM_VECTOR_LEN;
|
|
462
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
463
|
+
var len1 = WASM_VECTOR_LEN;
|
|
464
|
+
const ret = wasm.compute_layout_binary(ptr0, len0, part_index, spatium, page_width, ptr1, len1);
|
|
465
|
+
if (ret[2]) {
|
|
466
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
467
|
+
}
|
|
468
|
+
return takeFromExternrefTable0(ret[0]);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Layout a score using a specific MNX score definition index.
|
|
473
|
+
* @param {string} mnx_json
|
|
474
|
+
* @param {number} spatium
|
|
475
|
+
* @param {number} page_width
|
|
476
|
+
* @param {number} score_index
|
|
477
|
+
* @param {string | null} [page_setup_json]
|
|
478
|
+
* @returns {string}
|
|
479
|
+
*/
|
|
480
|
+
export function compute_mnx_score_layout(mnx_json, spatium, page_width, score_index, page_setup_json) {
|
|
481
|
+
let deferred4_0;
|
|
482
|
+
let deferred4_1;
|
|
483
|
+
try {
|
|
484
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
485
|
+
const len0 = WASM_VECTOR_LEN;
|
|
486
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
487
|
+
var len1 = WASM_VECTOR_LEN;
|
|
488
|
+
const ret = wasm.compute_mnx_score_layout(ptr0, len0, spatium, page_width, score_index, ptr1, len1);
|
|
489
|
+
var ptr3 = ret[0];
|
|
490
|
+
var len3 = ret[1];
|
|
491
|
+
if (ret[3]) {
|
|
492
|
+
ptr3 = 0; len3 = 0;
|
|
493
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
494
|
+
}
|
|
495
|
+
deferred4_0 = ptr3;
|
|
496
|
+
deferred4_1 = len3;
|
|
497
|
+
return getStringFromWasm0(ptr3, len3);
|
|
498
|
+
} finally {
|
|
499
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Layout a score using a specific MNX score definition and return a binary display list.
|
|
505
|
+
* @param {string} mnx_json
|
|
506
|
+
* @param {number} spatium
|
|
507
|
+
* @param {number} page_width
|
|
508
|
+
* @param {number} score_index
|
|
509
|
+
* @param {string | null} [page_setup_json]
|
|
510
|
+
* @returns {Float32Array}
|
|
511
|
+
*/
|
|
512
|
+
export function compute_mnx_score_layout_binary(mnx_json, spatium, page_width, score_index, page_setup_json) {
|
|
513
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
514
|
+
const len0 = WASM_VECTOR_LEN;
|
|
515
|
+
var ptr1 = isLikeNone(page_setup_json) ? 0 : passStringToWasm0(page_setup_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
516
|
+
var len1 = WASM_VECTOR_LEN;
|
|
517
|
+
const ret = wasm.compute_mnx_score_layout_binary(ptr0, len0, spatium, page_width, score_index, ptr1, len1);
|
|
518
|
+
if (ret[2]) {
|
|
519
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
520
|
+
}
|
|
521
|
+
return takeFromExternrefTable0(ret[0]);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Engrave an isolated input cursor note/rest and return a RenderCommand JSON array.
|
|
526
|
+
* @param {string} preview_json
|
|
527
|
+
* @returns {string}
|
|
528
|
+
*/
|
|
529
|
+
export function compute_note_preview(preview_json) {
|
|
530
|
+
let deferred3_0;
|
|
531
|
+
let deferred3_1;
|
|
532
|
+
try {
|
|
533
|
+
const ptr0 = passStringToWasm0(preview_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
534
|
+
const len0 = WASM_VECTOR_LEN;
|
|
535
|
+
const ret = wasm.compute_note_preview(ptr0, len0);
|
|
536
|
+
var ptr2 = ret[0];
|
|
537
|
+
var len2 = ret[1];
|
|
538
|
+
if (ret[3]) {
|
|
539
|
+
ptr2 = 0; len2 = 0;
|
|
540
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
541
|
+
}
|
|
542
|
+
deferred3_0 = ptr2;
|
|
543
|
+
deferred3_1 = len2;
|
|
544
|
+
return getStringFromWasm0(ptr2, len2);
|
|
545
|
+
} finally {
|
|
546
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Compute one live slur drag preview with the same graver as final layout.
|
|
552
|
+
* @param {string} preview_json
|
|
553
|
+
* @returns {string}
|
|
554
|
+
*/
|
|
555
|
+
export function compute_slur_preview(preview_json) {
|
|
556
|
+
let deferred3_0;
|
|
557
|
+
let deferred3_1;
|
|
558
|
+
try {
|
|
559
|
+
const ptr0 = passStringToWasm0(preview_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
561
|
+
const ret = wasm.compute_slur_preview(ptr0, len0);
|
|
562
|
+
var ptr2 = ret[0];
|
|
563
|
+
var len2 = ret[1];
|
|
564
|
+
if (ret[3]) {
|
|
565
|
+
ptr2 = 0; len2 = 0;
|
|
566
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
567
|
+
}
|
|
568
|
+
deferred3_0 = ptr2;
|
|
569
|
+
deferred3_1 = len2;
|
|
570
|
+
return getStringFromWasm0(ptr2, len2);
|
|
571
|
+
} finally {
|
|
572
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Returns the engine version string.
|
|
578
|
+
* @returns {string}
|
|
579
|
+
*/
|
|
580
|
+
export function engine_version() {
|
|
581
|
+
let deferred1_0;
|
|
582
|
+
let deferred1_1;
|
|
583
|
+
try {
|
|
584
|
+
const ret = wasm.engine_version();
|
|
585
|
+
deferred1_0 = ret[0];
|
|
586
|
+
deferred1_1 = ret[1];
|
|
587
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
588
|
+
} finally {
|
|
589
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Convert a DisplayList (JSON) to per-page SVG strings using font data for glyph outlines.
|
|
595
|
+
*
|
|
596
|
+
* Returns a JSON array: `[{pageNumber, svg, widthMm, heightMm}, ...]`
|
|
597
|
+
*
|
|
598
|
+
* * `display_list_json` — serialized DisplayList from any `compute_*` function.
|
|
599
|
+
* * `bravura_data` — raw bytes of Bravura.otf (SMuFL music font).
|
|
600
|
+
* * `text_font_data` — raw bytes of a text font (e.g. BravuraText.otf). Pass empty for fallback.
|
|
601
|
+
* * `spatium_mm`, `sp_pixels` — coordinate conversion factors.
|
|
602
|
+
* * `page_width_mm`, `page_height_mm` — output page dimensions.
|
|
603
|
+
* @param {string} display_list_json
|
|
604
|
+
* @param {Uint8Array} bravura_data
|
|
605
|
+
* @param {Uint8Array} text_font_data
|
|
606
|
+
* @param {number} spatium_mm
|
|
607
|
+
* @param {number} sp_pixels
|
|
608
|
+
* @param {number} page_width_mm
|
|
609
|
+
* @param {number} page_height_mm
|
|
610
|
+
* @returns {string}
|
|
611
|
+
*/
|
|
612
|
+
export function export_svg(display_list_json, bravura_data, text_font_data, spatium_mm, sp_pixels, page_width_mm, page_height_mm) {
|
|
613
|
+
let deferred5_0;
|
|
614
|
+
let deferred5_1;
|
|
615
|
+
try {
|
|
616
|
+
const ptr0 = passStringToWasm0(display_list_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
617
|
+
const len0 = WASM_VECTOR_LEN;
|
|
618
|
+
const ptr1 = passArray8ToWasm0(bravura_data, wasm.__wbindgen_malloc);
|
|
619
|
+
const len1 = WASM_VECTOR_LEN;
|
|
620
|
+
const ptr2 = passArray8ToWasm0(text_font_data, wasm.__wbindgen_malloc);
|
|
621
|
+
const len2 = WASM_VECTOR_LEN;
|
|
622
|
+
const ret = wasm.export_svg(ptr0, len0, ptr1, len1, ptr2, len2, spatium_mm, sp_pixels, page_width_mm, page_height_mm);
|
|
623
|
+
var ptr4 = ret[0];
|
|
624
|
+
var len4 = ret[1];
|
|
625
|
+
if (ret[3]) {
|
|
626
|
+
ptr4 = 0; len4 = 0;
|
|
627
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
628
|
+
}
|
|
629
|
+
deferred5_0 = ptr4;
|
|
630
|
+
deferred5_1 = len4;
|
|
631
|
+
return getStringFromWasm0(ptr4, len4);
|
|
632
|
+
} finally {
|
|
633
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Read the current value of the layout debug toggle.
|
|
639
|
+
* @returns {boolean}
|
|
640
|
+
*/
|
|
641
|
+
export function get_emit_layout_debug() {
|
|
642
|
+
const ret = wasm.get_emit_layout_debug();
|
|
643
|
+
return ret !== 0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Parse an MNX JSON string and return score metadata as JSON.
|
|
648
|
+
* @param {string} mnx_json
|
|
649
|
+
* @returns {string}
|
|
650
|
+
*/
|
|
651
|
+
export function get_score_info(mnx_json) {
|
|
652
|
+
let deferred3_0;
|
|
653
|
+
let deferred3_1;
|
|
654
|
+
try {
|
|
655
|
+
const ptr0 = passStringToWasm0(mnx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
656
|
+
const len0 = WASM_VECTOR_LEN;
|
|
657
|
+
const ret = wasm.get_score_info(ptr0, len0);
|
|
658
|
+
var ptr2 = ret[0];
|
|
659
|
+
var len2 = ret[1];
|
|
660
|
+
if (ret[3]) {
|
|
661
|
+
ptr2 = 0; len2 = 0;
|
|
662
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
663
|
+
}
|
|
664
|
+
deferred3_0 = ptr2;
|
|
665
|
+
deferred3_1 = len2;
|
|
666
|
+
return getStringFromWasm0(ptr2, len2);
|
|
667
|
+
} finally {
|
|
668
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Toggle the layout debug sidecar globally. When enabled, every layout
|
|
674
|
+
* invocation emits a `layoutDebug` field on the returned DisplayList that
|
|
675
|
+
* the editor's spacing overlay consumes.
|
|
676
|
+
* @param {boolean} enabled
|
|
677
|
+
*/
|
|
678
|
+
export function set_emit_layout_debug(enabled) {
|
|
679
|
+
wasm.set_emit_layout_debug(enabled);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Phase Q: toggle wall-clock timing of the patch-frame entry. When enabled,
|
|
684
|
+
* `LayoutEngine.take_timings_json()` returns a JSON breakdown after each
|
|
685
|
+
* patch call. Off in production.
|
|
686
|
+
* @param {boolean} enabled
|
|
687
|
+
*/
|
|
688
|
+
export function set_wasm_timing(enabled) {
|
|
689
|
+
wasm.set_wasm_timing(enabled);
|
|
690
|
+
}
|
|
691
|
+
function __wbg_get_imports() {
|
|
692
|
+
const import0 = {
|
|
693
|
+
__proto__: null,
|
|
694
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
695
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
696
|
+
},
|
|
697
|
+
__wbg_getRandomValues_a678b7300e8ed57f: function() { return handleError(function (arg0, arg1) {
|
|
698
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
699
|
+
}, arguments); },
|
|
700
|
+
__wbg_new_from_slice_2221cabb71753908: function(arg0, arg1) {
|
|
701
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
702
|
+
return ret;
|
|
703
|
+
},
|
|
704
|
+
__wbg_now_b72b0bf55c221a9d: function() { return handleError(function () {
|
|
705
|
+
const ret = Date.now();
|
|
706
|
+
return ret;
|
|
707
|
+
}, arguments); },
|
|
708
|
+
__wbg_now_d1fb6650485d7f3e: function() {
|
|
709
|
+
const ret = Date.now();
|
|
710
|
+
return ret;
|
|
711
|
+
},
|
|
712
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
713
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
714
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
715
|
+
return ret;
|
|
716
|
+
},
|
|
717
|
+
__wbindgen_init_externref_table: function() {
|
|
718
|
+
const table = wasm.__wbindgen_externrefs;
|
|
719
|
+
const offset = table.grow(4);
|
|
720
|
+
table.set(0, undefined);
|
|
721
|
+
table.set(offset + 0, undefined);
|
|
722
|
+
table.set(offset + 1, null);
|
|
723
|
+
table.set(offset + 2, true);
|
|
724
|
+
table.set(offset + 3, false);
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
return {
|
|
728
|
+
__proto__: null,
|
|
729
|
+
"./viritura_wasm_bg.js": import0,
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const LayoutEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
734
|
+
? { register: () => {}, unregister: () => {} }
|
|
735
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_layoutengine_free(ptr, 1));
|
|
736
|
+
|
|
737
|
+
function addToExternrefTable0(obj) {
|
|
738
|
+
const idx = wasm.__externref_table_alloc();
|
|
739
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
740
|
+
return idx;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
744
|
+
ptr = ptr >>> 0;
|
|
745
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
749
|
+
ptr = ptr >>> 0;
|
|
750
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
754
|
+
ptr = ptr >>> 0;
|
|
755
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
759
|
+
function getFloat32ArrayMemory0() {
|
|
760
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
761
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
762
|
+
}
|
|
763
|
+
return cachedFloat32ArrayMemory0;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
function getStringFromWasm0(ptr, len) {
|
|
767
|
+
return decodeText(ptr >>> 0, len);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
let cachedUint32ArrayMemory0 = null;
|
|
771
|
+
function getUint32ArrayMemory0() {
|
|
772
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
773
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
774
|
+
}
|
|
775
|
+
return cachedUint32ArrayMemory0;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
let cachedUint8ArrayMemory0 = null;
|
|
779
|
+
function getUint8ArrayMemory0() {
|
|
780
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
781
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
782
|
+
}
|
|
783
|
+
return cachedUint8ArrayMemory0;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
function handleError(f, args) {
|
|
787
|
+
try {
|
|
788
|
+
return f.apply(this, args);
|
|
789
|
+
} catch (e) {
|
|
790
|
+
const idx = addToExternrefTable0(e);
|
|
791
|
+
wasm.__wbindgen_exn_store(idx);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function isLikeNone(x) {
|
|
796
|
+
return x === undefined || x === null;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
800
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
801
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
802
|
+
WASM_VECTOR_LEN = arg.length;
|
|
803
|
+
return ptr;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
807
|
+
if (realloc === undefined) {
|
|
808
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
809
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
810
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
811
|
+
WASM_VECTOR_LEN = buf.length;
|
|
812
|
+
return ptr;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
let len = arg.length;
|
|
816
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
817
|
+
|
|
818
|
+
const mem = getUint8ArrayMemory0();
|
|
819
|
+
|
|
820
|
+
let offset = 0;
|
|
821
|
+
|
|
822
|
+
for (; offset < len; offset++) {
|
|
823
|
+
const code = arg.charCodeAt(offset);
|
|
824
|
+
if (code > 0x7F) break;
|
|
825
|
+
mem[ptr + offset] = code;
|
|
826
|
+
}
|
|
827
|
+
if (offset !== len) {
|
|
828
|
+
if (offset !== 0) {
|
|
829
|
+
arg = arg.slice(offset);
|
|
830
|
+
}
|
|
831
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
832
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
833
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
834
|
+
|
|
835
|
+
offset += ret.written;
|
|
836
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
WASM_VECTOR_LEN = offset;
|
|
840
|
+
return ptr;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function takeFromExternrefTable0(idx) {
|
|
844
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
845
|
+
wasm.__externref_table_dealloc(idx);
|
|
846
|
+
return value;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
850
|
+
cachedTextDecoder.decode();
|
|
851
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
852
|
+
let numBytesDecoded = 0;
|
|
853
|
+
function decodeText(ptr, len) {
|
|
854
|
+
numBytesDecoded += len;
|
|
855
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
856
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
857
|
+
cachedTextDecoder.decode();
|
|
858
|
+
numBytesDecoded = len;
|
|
859
|
+
}
|
|
860
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const cachedTextEncoder = new TextEncoder();
|
|
864
|
+
|
|
865
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
866
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
867
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
868
|
+
view.set(buf);
|
|
869
|
+
return {
|
|
870
|
+
read: arg.length,
|
|
871
|
+
written: buf.length
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
let WASM_VECTOR_LEN = 0;
|
|
877
|
+
|
|
878
|
+
let wasmModule, wasmInstance, wasm;
|
|
879
|
+
function __wbg_finalize_init(instance, module) {
|
|
880
|
+
wasmInstance = instance;
|
|
881
|
+
wasm = instance.exports;
|
|
882
|
+
wasmModule = module;
|
|
883
|
+
cachedFloat32ArrayMemory0 = null;
|
|
884
|
+
cachedUint32ArrayMemory0 = null;
|
|
885
|
+
cachedUint8ArrayMemory0 = null;
|
|
886
|
+
wasm.__wbindgen_start();
|
|
887
|
+
return wasm;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
async function __wbg_load(module, imports) {
|
|
891
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
892
|
+
if (!module.ok) {
|
|
893
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
897
|
+
try {
|
|
898
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
899
|
+
} catch (e) {
|
|
900
|
+
const validResponse = expectedResponseType(module.type);
|
|
901
|
+
|
|
902
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
903
|
+
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);
|
|
904
|
+
|
|
905
|
+
} else { throw e; }
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
const bytes = await module.arrayBuffer();
|
|
910
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
911
|
+
} else {
|
|
912
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
913
|
+
|
|
914
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
915
|
+
return { instance, module };
|
|
916
|
+
} else {
|
|
917
|
+
return instance;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function expectedResponseType(type) {
|
|
922
|
+
switch (type) {
|
|
923
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
924
|
+
}
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function initSync(module) {
|
|
930
|
+
if (wasm !== undefined) return wasm;
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
if (module !== undefined) {
|
|
934
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
935
|
+
({module} = module)
|
|
936
|
+
} else {
|
|
937
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const imports = __wbg_get_imports();
|
|
942
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
943
|
+
module = new WebAssembly.Module(module);
|
|
944
|
+
}
|
|
945
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
946
|
+
return __wbg_finalize_init(instance, module);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
async function __wbg_init(module_or_path) {
|
|
950
|
+
if (wasm !== undefined) return wasm;
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
if (module_or_path !== undefined) {
|
|
954
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
955
|
+
({module_or_path} = module_or_path)
|
|
956
|
+
} else {
|
|
957
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (module_or_path === undefined) {
|
|
962
|
+
module_or_path = new URL('viritura_wasm_bg.wasm', import.meta.url);
|
|
963
|
+
}
|
|
964
|
+
const imports = __wbg_get_imports();
|
|
965
|
+
|
|
966
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
967
|
+
module_or_path = fetch(module_or_path);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
971
|
+
|
|
972
|
+
return __wbg_finalize_init(instance, module);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
export { initSync, __wbg_init as default };
|