@canvist/web 0.0.0-stage → 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.
Files changed (45) hide show
  1. package/dist/collab.d.ts +99 -0
  2. package/dist/collab.js +211 -0
  3. package/dist/edit-context.d.ts +59 -0
  4. package/dist/edit-context.js +16 -0
  5. package/dist/editor.d.ts +301 -0
  6. package/dist/editor.js +776 -0
  7. package/dist/font-watcher.d.ts +28 -0
  8. package/dist/font-watcher.js +88 -0
  9. package/dist/fonts.d.ts +130 -0
  10. package/dist/fonts.js +343 -0
  11. package/dist/full.d.ts +40 -0
  12. package/dist/full.js +25 -0
  13. package/dist/input.d.ts +68 -0
  14. package/dist/input.js +551 -0
  15. package/dist/load.d.ts +9 -0
  16. package/dist/load.js +21 -0
  17. package/dist/measure.d.ts +56 -0
  18. package/dist/measure.js +524 -0
  19. package/dist/menus.d.ts +71 -0
  20. package/dist/menus.js +173 -0
  21. package/dist/mirror.d.ts +24 -0
  22. package/dist/mirror.js +73 -0
  23. package/dist/mod.d.ts +30 -0
  24. package/dist/mod.js +7 -0
  25. package/dist/placeholder.d.ts +27 -0
  26. package/dist/placeholder.js +69 -0
  27. package/dist/platform.d.ts +9 -0
  28. package/dist/platform.js +12 -0
  29. package/dist/plugin.d.ts +39 -0
  30. package/dist/plugin.js +1 -0
  31. package/package.json +86 -5
  32. package/readme.md +92 -0
  33. package/wasm/canvist_web.d.ts +358 -0
  34. package/wasm/canvist_web.js +1175 -0
  35. package/wasm/canvist_web_bg.wasm +0 -0
  36. package/wasm/canvist_web_bg.wasm.d.ts +59 -0
  37. package/wasm-collab/canvist_web.d.ts +391 -0
  38. package/wasm-collab/canvist_web.js +1343 -0
  39. package/wasm-collab/canvist_web_bg.wasm +0 -0
  40. package/wasm-collab/canvist_web_bg.wasm.d.ts +64 -0
  41. package/wasm-full/canvist_web.d.ts +358 -0
  42. package/wasm-full/canvist_web.js +1175 -0
  43. package/wasm-full/canvist_web_bg.wasm +0 -0
  44. package/wasm-full/canvist_web_bg.wasm.d.ts +59 -0
  45. package/README.md +0 -3
@@ -0,0 +1,1175 @@
1
+ /* @ts-self-types="./canvist_web.d.ts" */
2
+
3
+ /**
4
+ * One editor on one canvas.
5
+ */
6
+ export class WebEditor {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ WebEditorFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_webeditor_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Body text's CSS `font` shorthand and colour, as `[font, color]`, for
19
+ * text the host draws over the canvas in the document's style, such as
20
+ * a placeholder.
21
+ * @returns {string[]}
22
+ */
23
+ bodyStyle() {
24
+ const ret = wasm.webeditor_bodyStyle(this.__wbg_ptr);
25
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
26
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
27
+ return v1;
28
+ }
29
+ /**
30
+ * Whether the named command would apply. Nothing changes.
31
+ * @param {string} name
32
+ * @param {string} args
33
+ * @returns {boolean}
34
+ */
35
+ can(name, args) {
36
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
37
+ const len0 = WASM_VECTOR_LEN;
38
+ const ptr1 = passStringToWasm0(args, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len1 = WASM_VECTOR_LEN;
40
+ const ret = wasm.webeditor_can(this.__wbg_ptr, ptr0, len0, ptr1, len1);
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return ret[0] !== 0;
45
+ }
46
+ /**
47
+ * The rectangle of a caret at `path` and `offset` (UTF-16 code units),
48
+ * in document coordinates as `[x, y, width, height]`, or an empty array
49
+ * when the document has no such position or it is not laid out. Hosts
50
+ * draw collaborators' carets with it.
51
+ * @param {Uint32Array} path
52
+ * @param {number} offset
53
+ * @returns {Float32Array}
54
+ */
55
+ caretRectAt(path, offset) {
56
+ const ptr0 = passArray32ToWasm0(path, wasm.__wbindgen_malloc);
57
+ const len0 = WASM_VECTOR_LEN;
58
+ const ret = wasm.webeditor_caretRectAt(this.__wbg_ptr, ptr0, len0, offset);
59
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
60
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
61
+ return v2;
62
+ }
63
+ /**
64
+ * The caret's rectangle in document coordinates as `[x, y, width,
65
+ * height]`, or an empty array when the selection is not a caret. Hosts
66
+ * place IME windows and scroll the caret into view with it.
67
+ * @returns {Float32Array}
68
+ */
69
+ caretRect() {
70
+ const ret = wasm.webeditor_caretRect(this.__wbg_ptr);
71
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
72
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
73
+ return v1;
74
+ }
75
+ /**
76
+ * The rectangles of the characters in UTF-16 range `start..end` of the
77
+ * head's text block, as `[x, y, width, height]` per character in
78
+ * document coordinates, for placing IME candidate windows.
79
+ * @param {number} start
80
+ * @param {number} end
81
+ * @returns {Float32Array}
82
+ */
83
+ characterBounds(start, end) {
84
+ const ret = wasm.webeditor_characterBounds(this.__wbg_ptr, start, end);
85
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
86
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
87
+ return v1;
88
+ }
89
+ /**
90
+ * Commit the composition as `text`.
91
+ * @param {string} text
92
+ * @returns {boolean}
93
+ */
94
+ commitComposition(text) {
95
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
+ const len0 = WASM_VECTOR_LEN;
97
+ const ret = wasm.webeditor_commitComposition(this.__wbg_ptr, ptr0, len0);
98
+ if (ret[2]) {
99
+ throw takeFromExternrefTable0(ret[1]);
100
+ }
101
+ return ret[0] !== 0;
102
+ }
103
+ /**
104
+ * The selection as `[html, text]` for the clipboard, or empty when
105
+ * nothing is selected.
106
+ * @returns {string[]}
107
+ */
108
+ copySelection() {
109
+ const ret = wasm.webeditor_copySelection(this.__wbg_ptr);
110
+ if (ret[3]) {
111
+ throw takeFromExternrefTable0(ret[2]);
112
+ }
113
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
114
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
115
+ return v1;
116
+ }
117
+ /**
118
+ * Cut the selection, returning it as [`WebEditor::copy_selection`]
119
+ * does.
120
+ * @returns {string[]}
121
+ */
122
+ cutSelection() {
123
+ const ret = wasm.webeditor_cutSelection(this.__wbg_ptr);
124
+ if (ret[3]) {
125
+ throw takeFromExternrefTable0(ret[2]);
126
+ }
127
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
128
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
129
+ return v1;
130
+ }
131
+ /**
132
+ * Drop content at `(x, y)`: `html` when the source offered it, otherwise
133
+ * `text`. With `moving`, the content is this editor's own selection,
134
+ * dragged: it leaves its old place. A drop inside the dragged selection
135
+ * does nothing.
136
+ * @param {number} x
137
+ * @param {number} y
138
+ * @param {string | null | undefined} html
139
+ * @param {string} text
140
+ * @param {boolean} moving
141
+ * @returns {boolean}
142
+ */
143
+ dropAt(x, y, html, text, moving) {
144
+ var ptr0 = isLikeNone(html) ? 0 : passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
+ var len0 = WASM_VECTOR_LEN;
146
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
147
+ const len1 = WASM_VECTOR_LEN;
148
+ const ret = wasm.webeditor_dropAt(this.__wbg_ptr, x, y, ptr0, len0, ptr1, len1, moving);
149
+ if (ret[2]) {
150
+ throw takeFromExternrefTable0(ret[1]);
151
+ }
152
+ return ret[0] !== 0;
153
+ }
154
+ /**
155
+ * The text an `EditContext` edits: the text block holding the
156
+ * selection's head, and the selection within it in UTF-16 code units, as
157
+ * `[text, start, end]`. A selection reaching into another block is
158
+ * clamped to this one. Empty when the head is not in a text block.
159
+ * @returns {[text: string, start: number, end: number] | []}
160
+ */
161
+ editContextState() {
162
+ const ret = wasm.webeditor_editContextState(this.__wbg_ptr);
163
+ return ret;
164
+ }
165
+ /**
166
+ * The document as `format`.
167
+ * @param {string} format
168
+ * @returns {string}
169
+ */
170
+ export(format) {
171
+ let deferred3_0;
172
+ let deferred3_1;
173
+ try {
174
+ const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
175
+ const len0 = WASM_VECTOR_LEN;
176
+ const ret = wasm.webeditor_export(this.__wbg_ptr, ptr0, len0);
177
+ var ptr2 = ret[0];
178
+ var len2 = ret[1];
179
+ if (ret[3]) {
180
+ ptr2 = 0; len2 = 0;
181
+ throw takeFromExternrefTable0(ret[2]);
182
+ }
183
+ deferred3_0 = ptr2;
184
+ deferred3_1 = len2;
185
+ return getStringFromWasm0(ptr2, len2);
186
+ } finally {
187
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
188
+ }
189
+ }
190
+ /**
191
+ * Font faces of `families` finished loading: forget only the
192
+ * measurements of fonts that list one of them, so the blocks using them
193
+ * lay out again on the next frame. Returns how many measured blocks were
194
+ * invalidated.
195
+ * @param {string[]} families
196
+ * @returns {number}
197
+ */
198
+ fontsLoaded(families) {
199
+ const ptr0 = passArrayJsValueToWasm0(families, wasm.__wbindgen_malloc);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ret = wasm.webeditor_fontsLoaded(this.__wbg_ptr, ptr0, len0);
202
+ return ret >>> 0;
203
+ }
204
+ /**
205
+ * The CSS `font` shorthand of every font the layout has used, indexed
206
+ * by font id.
207
+ * @returns {string[]}
208
+ */
209
+ fonts() {
210
+ const ret = wasm.webeditor_fonts(this.__wbg_ptr);
211
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
212
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
213
+ return v1;
214
+ }
215
+ /**
216
+ * Forget every measurement, as when the device pixel ratio changes:
217
+ * browsers round font metrics to device pixels, so line positions can
218
+ * move. Blocks lay out again as they come into view.
219
+ */
220
+ forgetMeasurements() {
221
+ wasm.webeditor_forgetMeasurements(this.__wbg_ptr);
222
+ }
223
+ /**
224
+ * Lay out the viewport and paint whatever changed since the last frame.
225
+ * Returns what it did as `[height, shift, laidOut, measured, drawn,
226
+ * full, painted]`: `height` is the document's height in CSS px, `shift`
227
+ * how far content at the viewport's top moved (add it to the scroll
228
+ * position), and the flags are 0 or 1.
229
+ * @returns {Float64Array}
230
+ */
231
+ frame() {
232
+ const ret = wasm.webeditor_frame(this.__wbg_ptr);
233
+ if (ret[3]) {
234
+ throw takeFromExternrefTable0(ret[2]);
235
+ }
236
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
237
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
238
+ return v1;
239
+ }
240
+ /**
241
+ * The whole document laid out, as JSON: block rectangles, caret stops,
242
+ * and text runs (see the parity tests). Lays out every block first.
243
+ * @returns {string}
244
+ */
245
+ geometry() {
246
+ let deferred2_0;
247
+ let deferred2_1;
248
+ try {
249
+ const ret = wasm.webeditor_geometry(this.__wbg_ptr);
250
+ var ptr1 = ret[0];
251
+ var len1 = ret[1];
252
+ if (ret[3]) {
253
+ ptr1 = 0; len1 = 0;
254
+ throw takeFromExternrefTable0(ret[2]);
255
+ }
256
+ deferred2_0 = ptr1;
257
+ deferred2_1 = len1;
258
+ return getStringFromWasm0(ptr1, len1);
259
+ } finally {
260
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
261
+ }
262
+ }
263
+ /**
264
+ * Lay out text in `families` but draw it invisibly, as browsers do
265
+ * during a `font-display` block period. Pass an empty list once the
266
+ * faces load or the period ends.
267
+ * @param {string[]} families
268
+ */
269
+ hideFamilies(families) {
270
+ const ptr0 = passArrayJsValueToWasm0(families, wasm.__wbindgen_malloc);
271
+ const len0 = WASM_VECTOR_LEN;
272
+ wasm.webeditor_hideFamilies(this.__wbg_ptr, ptr0, len0);
273
+ }
274
+ /**
275
+ * Server-rendered HTML for the document at the current width, as
276
+ * `[fragment, stylesheet]`: what SSR sends down, and what the
277
+ * accessibility mirror shows.
278
+ * @returns {string[]}
279
+ */
280
+ html() {
281
+ const ret = wasm.webeditor_html(this.__wbg_ptr);
282
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
283
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
284
+ return v1;
285
+ }
286
+ /**
287
+ * Replace the selection with `text`, running input rules as typing
288
+ * does. Returns whether anything changed.
289
+ * @param {string} text
290
+ * @returns {boolean}
291
+ */
292
+ insertText(text) {
293
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ const ret = wasm.webeditor_insertText(this.__wbg_ptr, ptr0, len0);
296
+ if (ret[2]) {
297
+ throw takeFromExternrefTable0(ret[1]);
298
+ }
299
+ return ret[0] !== 0;
300
+ }
301
+ /**
302
+ * Whether the document is a single empty text block, as a new one is.
303
+ * Hosts show a placeholder then.
304
+ * @returns {boolean}
305
+ */
306
+ isEmpty() {
307
+ const ret = wasm.webeditor_isEmpty(this.__wbg_ptr);
308
+ return ret !== 0;
309
+ }
310
+ /**
311
+ * Whether `(x, y)` is inside a non-empty selection, where a press starts
312
+ * dragging the selection rather than selecting.
313
+ * @param {number} x
314
+ * @param {number} y
315
+ * @returns {boolean}
316
+ */
317
+ isInSelection(x, y) {
318
+ const ret = wasm.webeditor_isInSelection(this.__wbg_ptr, x, y);
319
+ return ret !== 0;
320
+ }
321
+ /**
322
+ * Run the key binding for `key`, a DOM `KeyboardEvent.key`, with
323
+ * `modifiers` (bits: 1 Shift, 2 Ctrl, 4 Alt, 8 Meta). Returns whether a
324
+ * binding applied; when none did, the host lets the browser handle the
325
+ * key.
326
+ * @param {string} key
327
+ * @param {number} modifiers
328
+ * @returns {boolean}
329
+ */
330
+ keyDown(key, modifiers) {
331
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
+ const len0 = WASM_VECTOR_LEN;
333
+ const ret = wasm.webeditor_keyDown(this.__wbg_ptr, ptr0, len0, modifiers);
334
+ if (ret[2]) {
335
+ throw takeFromExternrefTable0(ret[1]);
336
+ }
337
+ return ret[0] !== 0;
338
+ }
339
+ /**
340
+ * Replace the document with `input` read as `format` (`json`, `html`,
341
+ * `markdown`, or `text`).
342
+ * @param {string} format
343
+ * @param {string} input
344
+ */
345
+ load(format, input) {
346
+ const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
347
+ const len0 = WASM_VECTOR_LEN;
348
+ const ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
+ const len1 = WASM_VECTOR_LEN;
350
+ const ret = wasm.webeditor_load(this.__wbg_ptr, ptr0, len0, ptr1, len1);
351
+ if (ret[1]) {
352
+ throw takeFromExternrefTable0(ret[0]);
353
+ }
354
+ }
355
+ /**
356
+ * An editor painting on `canvas`, measuring through `measurer`, with the
357
+ * named extensions and JSON `options` (see `@canvist/web`'s
358
+ * `EditorOptions`).
359
+ * @param {HTMLCanvasElement} canvas
360
+ * @param {HostMeasurer} measurer
361
+ * @param {string[]} extensions
362
+ * @param {string} options
363
+ */
364
+ constructor(canvas, measurer, extensions, options) {
365
+ const ptr0 = passArrayJsValueToWasm0(extensions, wasm.__wbindgen_malloc);
366
+ const len0 = WASM_VECTOR_LEN;
367
+ const ptr1 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
+ const len1 = WASM_VECTOR_LEN;
369
+ const ret = wasm.webeditor_new(canvas, measurer, ptr0, len0, ptr1, len1);
370
+ if (ret[2]) {
371
+ throw takeFromExternrefTable0(ret[1]);
372
+ }
373
+ this.__wbg_ptr = ret[0];
374
+ WebEditorFinalization.register(this, this.__wbg_ptr, this);
375
+ return this;
376
+ }
377
+ /**
378
+ * Paste HTML over the selection.
379
+ * Excessive nesting throws a `parse` error without changing the document.
380
+ * @param {string} html
381
+ * @returns {boolean}
382
+ */
383
+ pasteHtml(html) {
384
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
385
+ const len0 = WASM_VECTOR_LEN;
386
+ const ret = wasm.webeditor_pasteHtml(this.__wbg_ptr, ptr0, len0);
387
+ if (ret[2]) {
388
+ throw takeFromExternrefTable0(ret[1]);
389
+ }
390
+ return ret[0] !== 0;
391
+ }
392
+ /**
393
+ * Paste plain text over the selection; paste rules apply.
394
+ * @param {string} text
395
+ * @returns {boolean}
396
+ */
397
+ pasteText(text) {
398
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
399
+ const len0 = WASM_VECTOR_LEN;
400
+ const ret = wasm.webeditor_pasteText(this.__wbg_ptr, ptr0, len0);
401
+ if (ret[2]) {
402
+ throw takeFromExternrefTable0(ret[1]);
403
+ }
404
+ return ret[0] !== 0;
405
+ }
406
+ /**
407
+ * Press the pointer at document coordinates `(x, y)`. One click places
408
+ * the caret, or extends the selection with `extend`; two select a word
409
+ * and three the whole text block, and dragging afterwards extends by
410
+ * that unit.
411
+ * @param {number} x
412
+ * @param {number} y
413
+ * @param {boolean} extend
414
+ * @param {number} clicks
415
+ * @returns {boolean}
416
+ */
417
+ pointerDown(x, y, extend, clicks) {
418
+ const ret = wasm.webeditor_pointerDown(this.__wbg_ptr, x, y, extend, clicks);
419
+ if (ret[2]) {
420
+ throw takeFromExternrefTable0(ret[1]);
421
+ }
422
+ return ret[0] !== 0;
423
+ }
424
+ /**
425
+ * Move a pressed pointer to `(x, y)`, extending the selection from the
426
+ * press.
427
+ * @param {number} x
428
+ * @param {number} y
429
+ * @returns {boolean}
430
+ */
431
+ pointerMove(x, y) {
432
+ const ret = wasm.webeditor_pointerMove(this.__wbg_ptr, x, y);
433
+ if (ret[2]) {
434
+ throw takeFromExternrefTable0(ret[1]);
435
+ }
436
+ return ret[0] !== 0;
437
+ }
438
+ /**
439
+ * Release the pointer.
440
+ */
441
+ pointerUp() {
442
+ wasm.webeditor_pointerUp(this.__wbg_ptr);
443
+ }
444
+ /**
445
+ * Answer the query an extension registered as `name`, as JSON.
446
+ * @param {string} name
447
+ * @param {string} args
448
+ * @returns {string}
449
+ */
450
+ query(name, args) {
451
+ let deferred4_0;
452
+ let deferred4_1;
453
+ try {
454
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
455
+ const len0 = WASM_VECTOR_LEN;
456
+ const ptr1 = passStringToWasm0(args, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
457
+ const len1 = WASM_VECTOR_LEN;
458
+ const ret = wasm.webeditor_query(this.__wbg_ptr, ptr0, len0, ptr1, len1);
459
+ var ptr3 = ret[0];
460
+ var len3 = ret[1];
461
+ if (ret[3]) {
462
+ ptr3 = 0; len3 = 0;
463
+ throw takeFromExternrefTable0(ret[2]);
464
+ }
465
+ deferred4_0 = ptr3;
466
+ deferred4_1 = len3;
467
+ return getStringFromWasm0(ptr3, len3);
468
+ } finally {
469
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
470
+ }
471
+ }
472
+ /**
473
+ * Redo the last undone change.
474
+ * @returns {boolean}
475
+ */
476
+ redo() {
477
+ const ret = wasm.webeditor_redo(this.__wbg_ptr);
478
+ if (ret[2]) {
479
+ throw takeFromExternrefTable0(ret[1]);
480
+ }
481
+ return ret[0] !== 0;
482
+ }
483
+ /**
484
+ * Replace UTF-16 range `start..end` of the head's text block with
485
+ * `text`, as an input method or the platform's text input does. A
486
+ * replacement at a caret is typing, so input rules apply.
487
+ * @param {number} start
488
+ * @param {number} end
489
+ * @param {string} text
490
+ * @returns {boolean}
491
+ */
492
+ replaceText(start, end, text) {
493
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ const ret = wasm.webeditor_replaceText(this.__wbg_ptr, start, end, ptr0, len0);
496
+ if (ret[2]) {
497
+ throw takeFromExternrefTable0(ret[1]);
498
+ }
499
+ return ret[0] !== 0;
500
+ }
501
+ /**
502
+ * Size the canvas: `width` and `height` in CSS pixels, `scale` device
503
+ * pixels per CSS pixel, and the backing store in device pixels. The
504
+ * document is laid out to `width`.
505
+ * @param {number} width
506
+ * @param {number} height
507
+ * @param {number} scale
508
+ * @param {number} pixel_width
509
+ * @param {number} pixel_height
510
+ */
511
+ resize(width, height, scale, pixel_width, pixel_height) {
512
+ wasm.webeditor_resize(this.__wbg_ptr, width, height, scale, pixel_width, pixel_height);
513
+ }
514
+ /**
515
+ * Run the command an extension registered as `name`, with JSON `args`
516
+ * (`null` for none). Returns whether it applied.
517
+ * @param {string} name
518
+ * @param {string} args
519
+ * @returns {boolean}
520
+ */
521
+ run(name, args) {
522
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
523
+ const len0 = WASM_VECTOR_LEN;
524
+ const ptr1 = passStringToWasm0(args, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
525
+ const len1 = WASM_VECTOR_LEN;
526
+ const ret = wasm.webeditor_run(this.__wbg_ptr, ptr0, len0, ptr1, len1);
527
+ if (ret[2]) {
528
+ throw takeFromExternrefTable0(ret[1]);
529
+ }
530
+ return ret[0] !== 0;
531
+ }
532
+ /**
533
+ * Select from (`anchor_path`, `anchor_offset`) to (`head_path`,
534
+ * `head_offset`). Offsets count UTF-16 code units.
535
+ * @param {Uint32Array} anchor_path
536
+ * @param {number} anchor_offset
537
+ * @param {Uint32Array} head_path
538
+ * @param {number} head_offset
539
+ */
540
+ select(anchor_path, anchor_offset, head_path, head_offset) {
541
+ const ptr0 = passArray32ToWasm0(anchor_path, wasm.__wbindgen_malloc);
542
+ const len0 = WASM_VECTOR_LEN;
543
+ const ptr1 = passArray32ToWasm0(head_path, wasm.__wbindgen_malloc);
544
+ const len1 = WASM_VECTOR_LEN;
545
+ const ret = wasm.webeditor_select(this.__wbg_ptr, ptr0, len0, anchor_offset, ptr1, len1, head_offset);
546
+ if (ret[1]) {
547
+ throw takeFromExternrefTable0(ret[0]);
548
+ }
549
+ }
550
+ /**
551
+ * The smallest rectangle around the selection in document coordinates,
552
+ * as `[x, y, width, height]`: the caret's rectangle for a caret, and
553
+ * empty while the selection is not laid out. Hosts anchor menus to it.
554
+ * @returns {Float32Array}
555
+ */
556
+ selectionBounds() {
557
+ const ret = wasm.webeditor_selectionBounds(this.__wbg_ptr);
558
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
559
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
560
+ return v1;
561
+ }
562
+ /**
563
+ * The anchor and head as JSON positions, or `null` for a block
564
+ * selection.
565
+ * @returns {string}
566
+ */
567
+ selection() {
568
+ let deferred1_0;
569
+ let deferred1_1;
570
+ try {
571
+ const ret = wasm.webeditor_selection(this.__wbg_ptr);
572
+ deferred1_0 = ret[0];
573
+ deferred1_1 = ret[1];
574
+ return getStringFromWasm0(ret[0], ret[1]);
575
+ } finally {
576
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
577
+ }
578
+ }
579
+ /**
580
+ * Snap border widths down to `scale` device pixels per CSS pixel, as
581
+ * this browser draws them, or not at all when `scale` is not positive.
582
+ * @param {number} scale
583
+ */
584
+ setBorderScale(scale) {
585
+ wasm.webeditor_setBorderScale(this.__wbg_ptr, scale);
586
+ }
587
+ /**
588
+ * Blink the caret.
589
+ * @param {boolean} on
590
+ */
591
+ setCaretOn(on) {
592
+ wasm.webeditor_setCaretOn(this.__wbg_ptr, on);
593
+ }
594
+ /**
595
+ * Show `text` as IME preedit text at the selection, replacing any
596
+ * earlier preedit.
597
+ * @param {string} text
598
+ * @returns {boolean}
599
+ */
600
+ setComposition(text) {
601
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
602
+ const len0 = WASM_VECTOR_LEN;
603
+ const ret = wasm.webeditor_setComposition(this.__wbg_ptr, ptr0, len0);
604
+ if (ret[2]) {
605
+ throw takeFromExternrefTable0(ret[1]);
606
+ }
607
+ return ret[0] !== 0;
608
+ }
609
+ /**
610
+ * Show or hide the caret: hosts call this on focus and blur.
611
+ * @param {boolean} focused
612
+ */
613
+ setFocused(focused) {
614
+ wasm.webeditor_setFocused(this.__wbg_ptr, focused);
615
+ }
616
+ /**
617
+ * Snap text baselines and rectangle edges to the grid the browser
618
+ * snaps DOM content to: `"device"` pixels, or `"css"` pixels for
619
+ * Chromium laying out in CSS units on a high-density screen.
620
+ * @param {string} grid
621
+ */
622
+ setPixelGrid(grid) {
623
+ const ptr0 = passStringToWasm0(grid, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
624
+ const len0 = WASM_VECTOR_LEN;
625
+ const ret = wasm.webeditor_setPixelGrid(this.__wbg_ptr, ptr0, len0);
626
+ if (ret[1]) {
627
+ throw takeFromExternrefTable0(ret[0]);
628
+ }
629
+ }
630
+ /**
631
+ * Scroll so document coordinate `top` is at the canvas's top edge.
632
+ * @param {number} top
633
+ */
634
+ setTop(top) {
635
+ wasm.webeditor_setTop(this.__wbg_ptr, top);
636
+ }
637
+ /**
638
+ * Measurement and cache statistics as JSON: cache hits and misses,
639
+ * cached bytes per font, and how many segments and batches the browser
640
+ * measured. The host derives the hit rate, so no float is formatted here
641
+ * (see `canvist_layout::css_number`).
642
+ * @returns {string}
643
+ */
644
+ stats() {
645
+ let deferred1_0;
646
+ let deferred1_1;
647
+ try {
648
+ const ret = wasm.webeditor_stats(this.__wbg_ptr);
649
+ deferred1_0 = ret[0];
650
+ deferred1_1 = ret[1];
651
+ return getStringFromWasm0(ret[0], ret[1]);
652
+ } finally {
653
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
654
+ }
655
+ }
656
+ /**
657
+ * The whole document as an SVG image painted from the same display
658
+ * list as the canvas. Lays out every block first.
659
+ * @returns {string}
660
+ */
661
+ svg() {
662
+ let deferred2_0;
663
+ let deferred2_1;
664
+ try {
665
+ const ret = wasm.webeditor_svg(this.__wbg_ptr);
666
+ var ptr1 = ret[0];
667
+ var len1 = ret[1];
668
+ if (ret[3]) {
669
+ ptr1 = 0; len1 = 0;
670
+ throw takeFromExternrefTable0(ret[2]);
671
+ }
672
+ deferred2_0 = ptr1;
673
+ deferred2_1 = len1;
674
+ return getStringFromWasm0(ptr1, len1);
675
+ } finally {
676
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
677
+ }
678
+ }
679
+ /**
680
+ * Undo the last change. A shared document undoes only this editor's
681
+ * own changes.
682
+ * @returns {boolean}
683
+ */
684
+ undo() {
685
+ const ret = wasm.webeditor_undo(this.__wbg_ptr);
686
+ if (ret[2]) {
687
+ throw takeFromExternrefTable0(ret[1]);
688
+ }
689
+ return ret[0] !== 0;
690
+ }
691
+ }
692
+ if (Symbol.dispose) WebEditor.prototype[Symbol.dispose] = WebEditor.prototype.free;
693
+ function __wbg_get_imports() {
694
+ const import0 = {
695
+ __proto__: null,
696
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
697
+ const obj = arg1;
698
+ const ret = typeof(obj) === 'string' ? obj : undefined;
699
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
700
+ var len1 = WASM_VECTOR_LEN;
701
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
702
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
703
+ },
704
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
705
+ throw new Error(getStringFromWasm0(arg0, arg1));
706
+ },
707
+ __wbg_addFont_7bf9358d0c77aed6: function(arg0, arg1, arg2, arg3) {
708
+ arg0.addFont(arg1 >>> 0, getStringFromWasm0(arg2, arg3));
709
+ },
710
+ __wbg_arcTo_a1ca709a1aae1a9b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
711
+ arg0.arcTo(arg1, arg2, arg3, arg4, arg5);
712
+ }, arguments); },
713
+ __wbg_beginPath_8598d895c13f1c86: function(arg0) {
714
+ arg0.beginPath();
715
+ },
716
+ __wbg_clip_275e70d2dc182fec: function(arg0) {
717
+ arg0.clip();
718
+ },
719
+ __wbg_closePath_355eb6da179dd9c2: function(arg0) {
720
+ arg0.closePath();
721
+ },
722
+ __wbg_fillRect_0ef59adb9acb7d06: function(arg0, arg1, arg2, arg3, arg4) {
723
+ arg0.fillRect(arg1, arg2, arg3, arg4);
724
+ },
725
+ __wbg_fillText_1bcec8b81ad73bd0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
726
+ arg0.fillText(getStringFromWasm0(arg1, arg2), arg3, arg4);
727
+ }, arguments); },
728
+ __wbg_fill_fc5e02a06cc26e92: function(arg0) {
729
+ arg0.fill();
730
+ },
731
+ __wbg_getContext_051324720aa5b7e8: function() { return handleError(function (arg0, arg1, arg2, arg3) {
732
+ const ret = arg0.getContext(getStringFromWasm0(arg1, arg2), arg3);
733
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
734
+ }, arguments); },
735
+ __wbg_instanceof_CanvasRenderingContext2d_769208c72dcbf5e6: function(arg0) {
736
+ let result;
737
+ try {
738
+ result = arg0 instanceof CanvasRenderingContext2D;
739
+ } catch (_) {
740
+ result = false;
741
+ }
742
+ const ret = result;
743
+ return ret;
744
+ },
745
+ __wbg_lineTo_63fac7d60279d95e: function(arg0, arg1, arg2) {
746
+ arg0.lineTo(arg1, arg2);
747
+ },
748
+ __wbg_measure_79e75cf23afa247f: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) {
749
+ const ret = arg1.measure(getArrayU32FromWasm0(arg2, arg3), getArrayU32FromWasm0(arg4, arg5), getArrayF32FromWasm0(arg6, arg7), getArrayU32FromWasm0(arg8, arg9), getStringFromWasm0(arg10, arg11), getArrayU32FromWasm0(arg12, arg13));
750
+ const ptr1 = passArrayF32ToWasm0(ret, wasm.__wbindgen_malloc);
751
+ const len1 = WASM_VECTOR_LEN;
752
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
753
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
754
+ },
755
+ __wbg_moveTo_037e3deefec91ae1: function(arg0, arg1, arg2) {
756
+ arg0.moveTo(arg1, arg2);
757
+ },
758
+ __wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
759
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
760
+ return ret;
761
+ },
762
+ __wbg_new_617a8cdb8bb1130e: function() {
763
+ const ret = new Object();
764
+ return ret;
765
+ },
766
+ __wbg_new_ee2291f50781bf1d: function() {
767
+ const ret = new Array();
768
+ return ret;
769
+ },
770
+ __wbg_now_aa4ccb83129e9e55: function() {
771
+ const ret = Date.now();
772
+ return ret;
773
+ },
774
+ __wbg_paintFont_f6833c16ddedaff0: function(arg0, arg1, arg2) {
775
+ const ret = arg1.paintFont(arg2 >>> 0);
776
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
777
+ const len1 = WASM_VECTOR_LEN;
778
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
779
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
780
+ },
781
+ __wbg_push_2baf45db356cf468: function(arg0, arg1) {
782
+ const ret = arg0.push(arg1);
783
+ return ret;
784
+ },
785
+ __wbg_quadraticCurveTo_4f57843d21c4f90d: function(arg0, arg1, arg2, arg3, arg4) {
786
+ arg0.quadraticCurveTo(arg1, arg2, arg3, arg4);
787
+ },
788
+ __wbg_rect_c6f60004ffec8f09: function(arg0, arg1, arg2, arg3, arg4) {
789
+ arg0.rect(arg1, arg2, arg3, arg4);
790
+ },
791
+ __wbg_restore_c93ba7571816b182: function(arg0) {
792
+ arg0.restore();
793
+ },
794
+ __wbg_save_f32554f1747071d1: function(arg0) {
795
+ arg0.save();
796
+ },
797
+ __wbg_setTransform_fa787a8f0adc1ade: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
798
+ arg0.setTransform(arg1, arg2, arg3, arg4, arg5, arg6);
799
+ }, arguments); },
800
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
801
+ const ret = Reflect.set(arg0, arg1, arg2);
802
+ return ret;
803
+ }, arguments); },
804
+ __wbg_set_alpha_15af6d7f9268a627: function(arg0, arg1) {
805
+ arg0.alpha = arg1 !== 0;
806
+ },
807
+ __wbg_set_direction_7ceac10a3a56e7ab: function(arg0, arg1, arg2) {
808
+ arg0.direction = getStringFromWasm0(arg1, arg2);
809
+ },
810
+ __wbg_set_fillStyle_a2961b4d44e572af: function(arg0, arg1, arg2) {
811
+ arg0.fillStyle = getStringFromWasm0(arg1, arg2);
812
+ },
813
+ __wbg_set_font_1f60a05a2544a2ff: function(arg0, arg1, arg2) {
814
+ arg0.font = getStringFromWasm0(arg1, arg2);
815
+ },
816
+ __wbg_set_font_kerning_e22d5e53e0b49b4a: function(arg0, arg1, arg2) {
817
+ arg0.fontKerning = getStringFromWasm0(arg1, arg2);
818
+ },
819
+ __wbg_set_font_variant_caps_fddb2612d001f247: function(arg0, arg1, arg2) {
820
+ arg0.fontVariantCaps = getStringFromWasm0(arg1, arg2);
821
+ },
822
+ __wbg_set_height_c9789c1c77eaedff: function(arg0, arg1) {
823
+ arg0.height = arg1 >>> 0;
824
+ },
825
+ __wbg_set_letter_spacing_a9766069411bd841: function(arg0, arg1, arg2) {
826
+ arg0.letterSpacing = getStringFromWasm0(arg1, arg2);
827
+ },
828
+ __wbg_set_lineCap_c9b7bdd3b7f5ce74: function(arg0, arg1, arg2) {
829
+ arg0.lineCap = getStringFromWasm0(arg1, arg2);
830
+ },
831
+ __wbg_set_lineJoin_c1780f2096e6f970: function(arg0, arg1, arg2) {
832
+ arg0.lineJoin = getStringFromWasm0(arg1, arg2);
833
+ },
834
+ __wbg_set_lineWidth_cc15473552c60c9c: function(arg0, arg1) {
835
+ arg0.lineWidth = arg1;
836
+ },
837
+ __wbg_set_name_2c630595dc90a7aa: function(arg0, arg1, arg2) {
838
+ arg0.name = getStringFromWasm0(arg1, arg2);
839
+ },
840
+ __wbg_set_strokeStyle_d51608fa918b53d4: function(arg0, arg1, arg2) {
841
+ arg0.strokeStyle = getStringFromWasm0(arg1, arg2);
842
+ },
843
+ __wbg_set_textAlign_1bda1733d57574ed: function(arg0, arg1, arg2) {
844
+ arg0.textAlign = getStringFromWasm0(arg1, arg2);
845
+ },
846
+ __wbg_set_textBaseline_d5ba548751584f49: function(arg0, arg1, arg2) {
847
+ arg0.textBaseline = getStringFromWasm0(arg1, arg2);
848
+ },
849
+ __wbg_set_text_rendering_111c051258ca1e75: function(arg0, arg1, arg2) {
850
+ arg0.textRendering = getStringFromWasm0(arg1, arg2);
851
+ },
852
+ __wbg_set_width_b0e1267db4b196b5: function(arg0, arg1) {
853
+ arg0.width = arg1 >>> 0;
854
+ },
855
+ __wbg_set_word_spacing_0d1d87f6d472beac: function(arg0, arg1, arg2) {
856
+ arg0.wordSpacing = getStringFromWasm0(arg1, arg2);
857
+ },
858
+ __wbg_stroke_385d731098398489: function(arg0) {
859
+ arg0.stroke();
860
+ },
861
+ __wbindgen_generic_0000000000000001: function(arg0) {
862
+ // Cast intrinsic for `F64 -> Externref`.
863
+ const ret = arg0;
864
+ return ret;
865
+ },
866
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
867
+ // Cast intrinsic for `Ref(String) -> Externref`.
868
+ const ret = getStringFromWasm0(arg0, arg1);
869
+ return ret;
870
+ },
871
+ __wbindgen_init_externref_table: function() {
872
+ const table = wasm.__wbindgen_externrefs;
873
+ const offset = table.grow(4);
874
+ table.set(0, undefined);
875
+ table.set(offset + 0, undefined);
876
+ table.set(offset + 1, null);
877
+ table.set(offset + 2, true);
878
+ table.set(offset + 3, false);
879
+ },
880
+ };
881
+ return {
882
+ __proto__: null,
883
+ "./canvist_web_bg.js": import0,
884
+ };
885
+ }
886
+
887
+ const WebEditorFinalization = (typeof FinalizationRegistry === 'undefined')
888
+ ? { register: () => {}, unregister: () => {} }
889
+ : new FinalizationRegistry(ptr => wasm.__wbg_webeditor_free(ptr, 1));
890
+
891
+ function addToExternrefTable0(obj) {
892
+ const idx = wasm.__externref_table_alloc();
893
+ wasm.__wbindgen_externrefs.set(idx, obj);
894
+ return idx;
895
+ }
896
+
897
+ function getArrayF32FromWasm0(ptr, len) {
898
+ ptr = ptr >>> 0;
899
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
900
+ }
901
+
902
+ function getArrayF64FromWasm0(ptr, len) {
903
+ ptr = ptr >>> 0;
904
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
905
+ }
906
+
907
+ function getArrayJsValueFromWasm0(ptr, len) {
908
+ ptr = ptr >>> 0;
909
+ const mem = getDataViewMemory0();
910
+ const result = [];
911
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
912
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
913
+ }
914
+ wasm.__externref_drop_slice(ptr, len);
915
+ return result;
916
+ }
917
+
918
+ function getArrayU32FromWasm0(ptr, len) {
919
+ ptr = ptr >>> 0;
920
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
921
+ }
922
+
923
+ let cachedDataViewMemory0 = null;
924
+ function getDataViewMemory0() {
925
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
926
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
927
+ }
928
+ return cachedDataViewMemory0;
929
+ }
930
+
931
+ let cachedFloat32ArrayMemory0 = null;
932
+ function getFloat32ArrayMemory0() {
933
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
934
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
935
+ }
936
+ return cachedFloat32ArrayMemory0;
937
+ }
938
+
939
+ let cachedFloat64ArrayMemory0 = null;
940
+ function getFloat64ArrayMemory0() {
941
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
942
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
943
+ }
944
+ return cachedFloat64ArrayMemory0;
945
+ }
946
+
947
+ function getStringFromWasm0(ptr, len) {
948
+ return decodeText(ptr >>> 0, len);
949
+ }
950
+
951
+ let cachedUint32ArrayMemory0 = null;
952
+ function getUint32ArrayMemory0() {
953
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
954
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
955
+ }
956
+ return cachedUint32ArrayMemory0;
957
+ }
958
+
959
+ let cachedUint8ArrayMemory0 = null;
960
+ function getUint8ArrayMemory0() {
961
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
962
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
963
+ }
964
+ return cachedUint8ArrayMemory0;
965
+ }
966
+
967
+ function handleError(f, args) {
968
+ try {
969
+ return f.apply(this, args);
970
+ } catch (e) {
971
+ const idx = addToExternrefTable0(e);
972
+ wasm.__wbindgen_exn_store(idx);
973
+ }
974
+ }
975
+
976
+ function isLikeNone(x) {
977
+ return x === undefined || x === null;
978
+ }
979
+
980
+ function passArray32ToWasm0(arg, malloc) {
981
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
982
+ getUint32ArrayMemory0().set(arg, ptr / 4);
983
+ WASM_VECTOR_LEN = arg.length;
984
+ return ptr;
985
+ }
986
+
987
+ function passArrayF32ToWasm0(arg, malloc) {
988
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
989
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
990
+ WASM_VECTOR_LEN = arg.length;
991
+ return ptr;
992
+ }
993
+
994
+ function passArrayJsValueToWasm0(array, malloc) {
995
+ const ptr = malloc(array.length * 4, 4) >>> 0;
996
+ for (let i = 0; i < array.length; i++) {
997
+ const add = addToExternrefTable0(array[i]);
998
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
999
+ }
1000
+ WASM_VECTOR_LEN = array.length;
1001
+ return ptr;
1002
+ }
1003
+
1004
+ function passStringToWasm0(arg, malloc, realloc) {
1005
+ if (realloc === undefined) {
1006
+ const buf = cachedTextEncoder.encode(arg);
1007
+ const ptr = malloc(buf.length, 1) >>> 0;
1008
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1009
+ WASM_VECTOR_LEN = buf.length;
1010
+ return ptr;
1011
+ }
1012
+
1013
+ let len = arg.length;
1014
+ let ptr = malloc(len, 1) >>> 0;
1015
+
1016
+ const mem = getUint8ArrayMemory0();
1017
+
1018
+ let offset = 0;
1019
+
1020
+ for (; offset < len; offset++) {
1021
+ const code = arg.charCodeAt(offset);
1022
+ if (code > 0x7F) break;
1023
+ mem[ptr + offset] = code;
1024
+ }
1025
+ if (offset !== len) {
1026
+ if (offset !== 0) {
1027
+ arg = arg.slice(offset);
1028
+ }
1029
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1030
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1031
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1032
+
1033
+ offset += ret.written;
1034
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1035
+ }
1036
+
1037
+ WASM_VECTOR_LEN = offset;
1038
+ return ptr;
1039
+ }
1040
+
1041
+ function takeFromExternrefTable0(idx) {
1042
+ const value = wasm.__wbindgen_externrefs.get(idx);
1043
+ wasm.__externref_table_dealloc(idx);
1044
+ return value;
1045
+ }
1046
+
1047
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1048
+ cachedTextDecoder.decode();
1049
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1050
+ let numBytesDecoded = 0;
1051
+ function decodeText(ptr, len) {
1052
+ numBytesDecoded += len;
1053
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1054
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1055
+ cachedTextDecoder.decode();
1056
+ numBytesDecoded = len;
1057
+ }
1058
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1059
+ }
1060
+
1061
+ const cachedTextEncoder = new TextEncoder();
1062
+
1063
+ if (!('encodeInto' in cachedTextEncoder)) {
1064
+ cachedTextEncoder.encodeInto = function (arg, view) {
1065
+ const buf = cachedTextEncoder.encode(arg);
1066
+ view.set(buf);
1067
+ return {
1068
+ read: arg.length,
1069
+ written: buf.length
1070
+ };
1071
+ };
1072
+ }
1073
+
1074
+ let WASM_VECTOR_LEN = 0;
1075
+
1076
+ let wasmModule, wasmInstance, wasm;
1077
+ function __wbg_finalize_init(instance, module) {
1078
+ wasmInstance = instance;
1079
+ wasm = instance.exports;
1080
+ wasmModule = module;
1081
+ cachedDataViewMemory0 = null;
1082
+ cachedFloat32ArrayMemory0 = null;
1083
+ cachedFloat64ArrayMemory0 = null;
1084
+ cachedUint32ArrayMemory0 = null;
1085
+ cachedUint8ArrayMemory0 = null;
1086
+ wasm.__wbindgen_start();
1087
+ return wasm;
1088
+ }
1089
+
1090
+ async function __wbg_load(module, imports) {
1091
+ if (typeof Response === 'function' && module instanceof Response) {
1092
+ if (!module.ok) {
1093
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1094
+ }
1095
+
1096
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1097
+ try {
1098
+ return await WebAssembly.instantiateStreaming(module, imports);
1099
+ } catch (e) {
1100
+ const validResponse = expectedResponseType(module.type);
1101
+
1102
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1103
+ 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);
1104
+
1105
+ } else { throw e; }
1106
+ }
1107
+ }
1108
+
1109
+ const bytes = await module.arrayBuffer();
1110
+ return await WebAssembly.instantiate(bytes, imports);
1111
+ } else {
1112
+ const instance = await WebAssembly.instantiate(module, imports);
1113
+
1114
+ if (instance instanceof WebAssembly.Instance) {
1115
+ return { instance, module };
1116
+ } else {
1117
+ return instance;
1118
+ }
1119
+ }
1120
+
1121
+ function expectedResponseType(type) {
1122
+ switch (type) {
1123
+ case 'basic': case 'cors': case 'default': return true;
1124
+ }
1125
+ return false;
1126
+ }
1127
+ }
1128
+
1129
+ function initSync(module) {
1130
+ if (wasm !== undefined) return wasm;
1131
+
1132
+
1133
+ if (module !== undefined) {
1134
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1135
+ ({module} = module)
1136
+ } else {
1137
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1138
+ }
1139
+ }
1140
+
1141
+ const imports = __wbg_get_imports();
1142
+ if (!(module instanceof WebAssembly.Module)) {
1143
+ module = new WebAssembly.Module(module);
1144
+ }
1145
+ const instance = new WebAssembly.Instance(module, imports);
1146
+ return __wbg_finalize_init(instance, module);
1147
+ }
1148
+
1149
+ async function __wbg_init(module_or_path) {
1150
+ if (wasm !== undefined) return wasm;
1151
+
1152
+
1153
+ if (module_or_path !== undefined) {
1154
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1155
+ ({module_or_path} = module_or_path)
1156
+ } else {
1157
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1158
+ }
1159
+ }
1160
+
1161
+ if (module_or_path === undefined) {
1162
+ module_or_path = new URL('canvist_web_bg.wasm', import.meta.url);
1163
+ }
1164
+ const imports = __wbg_get_imports();
1165
+
1166
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1167
+ module_or_path = fetch(module_or_path);
1168
+ }
1169
+
1170
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1171
+
1172
+ return __wbg_finalize_init(instance, module);
1173
+ }
1174
+
1175
+ export { initSync, __wbg_init as default };