@canvist/web 0.0.0 → 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/dist/collab.d.ts +99 -0
- package/dist/collab.js +211 -0
- package/dist/edit-context.d.ts +59 -0
- package/dist/edit-context.js +16 -0
- package/dist/editor.d.ts +301 -0
- package/dist/editor.js +776 -0
- package/dist/font-watcher.d.ts +28 -0
- package/dist/font-watcher.js +88 -0
- package/dist/fonts.d.ts +130 -0
- package/dist/fonts.js +343 -0
- package/dist/full.d.ts +40 -0
- package/dist/full.js +25 -0
- package/dist/input.d.ts +68 -0
- package/dist/input.js +551 -0
- package/dist/load.d.ts +9 -0
- package/dist/load.js +21 -0
- package/dist/measure.d.ts +56 -0
- package/dist/measure.js +524 -0
- package/dist/menus.d.ts +71 -0
- package/dist/menus.js +173 -0
- package/dist/mirror.d.ts +24 -0
- package/dist/mirror.js +73 -0
- package/dist/mod.d.ts +30 -0
- package/dist/mod.js +7 -0
- package/dist/placeholder.d.ts +27 -0
- package/dist/placeholder.js +69 -0
- package/dist/platform.d.ts +9 -0
- package/dist/platform.js +12 -0
- package/dist/plugin.d.ts +39 -0
- package/dist/plugin.js +1 -0
- package/package.json +87 -1
- package/readme.md +92 -0
- package/wasm/canvist_web.d.ts +358 -0
- package/wasm/canvist_web.js +1175 -0
- package/wasm/canvist_web_bg.wasm +0 -0
- package/wasm/canvist_web_bg.wasm.d.ts +59 -0
- package/wasm-collab/canvist_web.d.ts +391 -0
- package/wasm-collab/canvist_web.js +1343 -0
- package/wasm-collab/canvist_web_bg.wasm +0 -0
- package/wasm-collab/canvist_web_bg.wasm.d.ts +64 -0
- package/wasm-full/canvist_web.d.ts +358 -0
- package/wasm-full/canvist_web.js +1175 -0
- package/wasm-full/canvist_web_bg.wasm +0 -0
- package/wasm-full/canvist_web_bg.wasm.d.ts +59 -0
- package/CHANGELOG.md +0 -3
- package/LICENSE +0 -24
- package/README.md +0 -3
|
@@ -0,0 +1,1343 @@
|
|
|
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
|
+
* This editor's changes since the last call, as y-sync messages for the
|
|
192
|
+
* server.
|
|
193
|
+
* @returns {Uint8Array[]}
|
|
194
|
+
*/
|
|
195
|
+
flushSync() {
|
|
196
|
+
const ret = wasm.webeditor_flushSync(this.__wbg_ptr);
|
|
197
|
+
if (ret[2]) {
|
|
198
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
199
|
+
}
|
|
200
|
+
return takeFromExternrefTable0(ret[0]);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Font faces of `families` finished loading: forget only the
|
|
204
|
+
* measurements of fonts that list one of them, so the blocks using them
|
|
205
|
+
* lay out again on the next frame. Returns how many measured blocks were
|
|
206
|
+
* invalidated.
|
|
207
|
+
* @param {string[]} families
|
|
208
|
+
* @returns {number}
|
|
209
|
+
*/
|
|
210
|
+
fontsLoaded(families) {
|
|
211
|
+
const ptr0 = passArrayJsValueToWasm0(families, wasm.__wbindgen_malloc);
|
|
212
|
+
const len0 = WASM_VECTOR_LEN;
|
|
213
|
+
const ret = wasm.webeditor_fontsLoaded(this.__wbg_ptr, ptr0, len0);
|
|
214
|
+
return ret >>> 0;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The CSS `font` shorthand of every font the layout has used, indexed
|
|
218
|
+
* by font id.
|
|
219
|
+
* @returns {string[]}
|
|
220
|
+
*/
|
|
221
|
+
fonts() {
|
|
222
|
+
const ret = wasm.webeditor_fonts(this.__wbg_ptr);
|
|
223
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
224
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
225
|
+
return v1;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Forget every measurement, as when the device pixel ratio changes:
|
|
229
|
+
* browsers round font metrics to device pixels, so line positions can
|
|
230
|
+
* move. Blocks lay out again as they come into view.
|
|
231
|
+
*/
|
|
232
|
+
forgetMeasurements() {
|
|
233
|
+
wasm.webeditor_forgetMeasurements(this.__wbg_ptr);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Lay out the viewport and paint whatever changed since the last frame.
|
|
237
|
+
* Returns what it did as `[height, shift, laidOut, measured, drawn,
|
|
238
|
+
* full, painted]`: `height` is the document's height in CSS px, `shift`
|
|
239
|
+
* how far content at the viewport's top moved (add it to the scroll
|
|
240
|
+
* position), and the flags are 0 or 1.
|
|
241
|
+
* @returns {Float64Array}
|
|
242
|
+
*/
|
|
243
|
+
frame() {
|
|
244
|
+
const ret = wasm.webeditor_frame(this.__wbg_ptr);
|
|
245
|
+
if (ret[3]) {
|
|
246
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
247
|
+
}
|
|
248
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
249
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
250
|
+
return v1;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The whole document laid out, as JSON: block rectangles, caret stops,
|
|
254
|
+
* and text runs (see the parity tests). Lays out every block first.
|
|
255
|
+
* @returns {string}
|
|
256
|
+
*/
|
|
257
|
+
geometry() {
|
|
258
|
+
let deferred2_0;
|
|
259
|
+
let deferred2_1;
|
|
260
|
+
try {
|
|
261
|
+
const ret = wasm.webeditor_geometry(this.__wbg_ptr);
|
|
262
|
+
var ptr1 = ret[0];
|
|
263
|
+
var len1 = ret[1];
|
|
264
|
+
if (ret[3]) {
|
|
265
|
+
ptr1 = 0; len1 = 0;
|
|
266
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
267
|
+
}
|
|
268
|
+
deferred2_0 = ptr1;
|
|
269
|
+
deferred2_1 = len1;
|
|
270
|
+
return getStringFromWasm0(ptr1, len1);
|
|
271
|
+
} finally {
|
|
272
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Lay out text in `families` but draw it invisibly, as browsers do
|
|
277
|
+
* during a `font-display` block period. Pass an empty list once the
|
|
278
|
+
* faces load or the period ends.
|
|
279
|
+
* @param {string[]} families
|
|
280
|
+
*/
|
|
281
|
+
hideFamilies(families) {
|
|
282
|
+
const ptr0 = passArrayJsValueToWasm0(families, wasm.__wbindgen_malloc);
|
|
283
|
+
const len0 = WASM_VECTOR_LEN;
|
|
284
|
+
wasm.webeditor_hideFamilies(this.__wbg_ptr, ptr0, len0);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Server-rendered HTML for the document at the current width, as
|
|
288
|
+
* `[fragment, stylesheet]`: what SSR sends down, and what the
|
|
289
|
+
* accessibility mirror shows.
|
|
290
|
+
* @returns {string[]}
|
|
291
|
+
*/
|
|
292
|
+
html() {
|
|
293
|
+
const ret = wasm.webeditor_html(this.__wbg_ptr);
|
|
294
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
295
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
296
|
+
return v1;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Replace the selection with `text`, running input rules as typing
|
|
300
|
+
* does. Returns whether anything changed.
|
|
301
|
+
* @param {string} text
|
|
302
|
+
* @returns {boolean}
|
|
303
|
+
*/
|
|
304
|
+
insertText(text) {
|
|
305
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
306
|
+
const len0 = WASM_VECTOR_LEN;
|
|
307
|
+
const ret = wasm.webeditor_insertText(this.__wbg_ptr, ptr0, len0);
|
|
308
|
+
if (ret[2]) {
|
|
309
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
310
|
+
}
|
|
311
|
+
return ret[0] !== 0;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Whether the document is a single empty text block, as a new one is.
|
|
315
|
+
* Hosts show a placeholder then.
|
|
316
|
+
* @returns {boolean}
|
|
317
|
+
*/
|
|
318
|
+
isEmpty() {
|
|
319
|
+
const ret = wasm.webeditor_isEmpty(this.__wbg_ptr);
|
|
320
|
+
return ret !== 0;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Whether `(x, y)` is inside a non-empty selection, where a press starts
|
|
324
|
+
* dragging the selection rather than selecting.
|
|
325
|
+
* @param {number} x
|
|
326
|
+
* @param {number} y
|
|
327
|
+
* @returns {boolean}
|
|
328
|
+
*/
|
|
329
|
+
isInSelection(x, y) {
|
|
330
|
+
const ret = wasm.webeditor_isInSelection(this.__wbg_ptr, x, y);
|
|
331
|
+
return ret !== 0;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Whether the editor holds a shared document, as it does once the
|
|
335
|
+
* server's state has arrived.
|
|
336
|
+
* @returns {boolean}
|
|
337
|
+
*/
|
|
338
|
+
isShared() {
|
|
339
|
+
const ret = wasm.webeditor_isShared(this.__wbg_ptr);
|
|
340
|
+
return ret !== 0;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Start joining a shared document as yrs client `client_id`, which must
|
|
344
|
+
* be unique among the room's peers. Returns the message to send the
|
|
345
|
+
* server first. The current document stays on screen until the
|
|
346
|
+
* server's state arrives in [`WebEditor::receive_sync`].
|
|
347
|
+
* @param {number} client_id
|
|
348
|
+
* @returns {Uint8Array}
|
|
349
|
+
*/
|
|
350
|
+
join(client_id) {
|
|
351
|
+
const ret = wasm.webeditor_join(this.__wbg_ptr, client_id);
|
|
352
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
353
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
354
|
+
return v1;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Run the key binding for `key`, a DOM `KeyboardEvent.key`, with
|
|
358
|
+
* `modifiers` (bits: 1 Shift, 2 Ctrl, 4 Alt, 8 Meta). Returns whether a
|
|
359
|
+
* binding applied; when none did, the host lets the browser handle the
|
|
360
|
+
* key.
|
|
361
|
+
* @param {string} key
|
|
362
|
+
* @param {number} modifiers
|
|
363
|
+
* @returns {boolean}
|
|
364
|
+
*/
|
|
365
|
+
keyDown(key, modifiers) {
|
|
366
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
367
|
+
const len0 = WASM_VECTOR_LEN;
|
|
368
|
+
const ret = wasm.webeditor_keyDown(this.__wbg_ptr, ptr0, len0, modifiers);
|
|
369
|
+
if (ret[2]) {
|
|
370
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
371
|
+
}
|
|
372
|
+
return ret[0] !== 0;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Replace the document with `input` read as `format` (`json`, `html`,
|
|
376
|
+
* `markdown`, or `text`).
|
|
377
|
+
* @param {string} format
|
|
378
|
+
* @param {string} input
|
|
379
|
+
*/
|
|
380
|
+
load(format, input) {
|
|
381
|
+
const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
383
|
+
const ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
384
|
+
const len1 = WASM_VECTOR_LEN;
|
|
385
|
+
const ret = wasm.webeditor_load(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
386
|
+
if (ret[1]) {
|
|
387
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* An editor painting on `canvas`, measuring through `measurer`, with the
|
|
392
|
+
* named extensions and JSON `options` (see `@canvist/web`'s
|
|
393
|
+
* `EditorOptions`).
|
|
394
|
+
* @param {HTMLCanvasElement} canvas
|
|
395
|
+
* @param {HostMeasurer} measurer
|
|
396
|
+
* @param {string[]} extensions
|
|
397
|
+
* @param {string} options
|
|
398
|
+
*/
|
|
399
|
+
constructor(canvas, measurer, extensions, options) {
|
|
400
|
+
const ptr0 = passArrayJsValueToWasm0(extensions, wasm.__wbindgen_malloc);
|
|
401
|
+
const len0 = WASM_VECTOR_LEN;
|
|
402
|
+
const ptr1 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
403
|
+
const len1 = WASM_VECTOR_LEN;
|
|
404
|
+
const ret = wasm.webeditor_new(canvas, measurer, ptr0, len0, ptr1, len1);
|
|
405
|
+
if (ret[2]) {
|
|
406
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
407
|
+
}
|
|
408
|
+
this.__wbg_ptr = ret[0];
|
|
409
|
+
WebEditorFinalization.register(this, this.__wbg_ptr, this);
|
|
410
|
+
return this;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Paste HTML over the selection.
|
|
414
|
+
* Excessive nesting throws a `parse` error without changing the document.
|
|
415
|
+
* @param {string} html
|
|
416
|
+
* @returns {boolean}
|
|
417
|
+
*/
|
|
418
|
+
pasteHtml(html) {
|
|
419
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
420
|
+
const len0 = WASM_VECTOR_LEN;
|
|
421
|
+
const ret = wasm.webeditor_pasteHtml(this.__wbg_ptr, ptr0, len0);
|
|
422
|
+
if (ret[2]) {
|
|
423
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
424
|
+
}
|
|
425
|
+
return ret[0] !== 0;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Paste plain text over the selection; paste rules apply.
|
|
429
|
+
* @param {string} text
|
|
430
|
+
* @returns {boolean}
|
|
431
|
+
*/
|
|
432
|
+
pasteText(text) {
|
|
433
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
434
|
+
const len0 = WASM_VECTOR_LEN;
|
|
435
|
+
const ret = wasm.webeditor_pasteText(this.__wbg_ptr, ptr0, len0);
|
|
436
|
+
if (ret[2]) {
|
|
437
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
438
|
+
}
|
|
439
|
+
return ret[0] !== 0;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Press the pointer at document coordinates `(x, y)`. One click places
|
|
443
|
+
* the caret, or extends the selection with `extend`; two select a word
|
|
444
|
+
* and three the whole text block, and dragging afterwards extends by
|
|
445
|
+
* that unit.
|
|
446
|
+
* @param {number} x
|
|
447
|
+
* @param {number} y
|
|
448
|
+
* @param {boolean} extend
|
|
449
|
+
* @param {number} clicks
|
|
450
|
+
* @returns {boolean}
|
|
451
|
+
*/
|
|
452
|
+
pointerDown(x, y, extend, clicks) {
|
|
453
|
+
const ret = wasm.webeditor_pointerDown(this.__wbg_ptr, x, y, extend, clicks);
|
|
454
|
+
if (ret[2]) {
|
|
455
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
456
|
+
}
|
|
457
|
+
return ret[0] !== 0;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Move a pressed pointer to `(x, y)`, extending the selection from the
|
|
461
|
+
* press.
|
|
462
|
+
* @param {number} x
|
|
463
|
+
* @param {number} y
|
|
464
|
+
* @returns {boolean}
|
|
465
|
+
*/
|
|
466
|
+
pointerMove(x, y) {
|
|
467
|
+
const ret = wasm.webeditor_pointerMove(this.__wbg_ptr, x, y);
|
|
468
|
+
if (ret[2]) {
|
|
469
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
470
|
+
}
|
|
471
|
+
return ret[0] !== 0;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Release the pointer.
|
|
475
|
+
*/
|
|
476
|
+
pointerUp() {
|
|
477
|
+
wasm.webeditor_pointerUp(this.__wbg_ptr);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Answer the query an extension registered as `name`, as JSON.
|
|
481
|
+
* @param {string} name
|
|
482
|
+
* @param {string} args
|
|
483
|
+
* @returns {string}
|
|
484
|
+
*/
|
|
485
|
+
query(name, args) {
|
|
486
|
+
let deferred4_0;
|
|
487
|
+
let deferred4_1;
|
|
488
|
+
try {
|
|
489
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
491
|
+
const ptr1 = passStringToWasm0(args, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
492
|
+
const len1 = WASM_VECTOR_LEN;
|
|
493
|
+
const ret = wasm.webeditor_query(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
494
|
+
var ptr3 = ret[0];
|
|
495
|
+
var len3 = ret[1];
|
|
496
|
+
if (ret[3]) {
|
|
497
|
+
ptr3 = 0; len3 = 0;
|
|
498
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
499
|
+
}
|
|
500
|
+
deferred4_0 = ptr3;
|
|
501
|
+
deferred4_1 = len3;
|
|
502
|
+
return getStringFromWasm0(ptr3, len3);
|
|
503
|
+
} finally {
|
|
504
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Handle one binary y-sync message from the server, as
|
|
509
|
+
* `[replies, changed]`: the messages to send back, and whether the
|
|
510
|
+
* document changed, in which case the next frame shows it.
|
|
511
|
+
* @param {Uint8Array} message
|
|
512
|
+
* @returns {[replies: Uint8Array[], changed: boolean]}
|
|
513
|
+
*/
|
|
514
|
+
receiveSync(message) {
|
|
515
|
+
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
516
|
+
const len0 = WASM_VECTOR_LEN;
|
|
517
|
+
const ret = wasm.webeditor_receiveSync(this.__wbg_ptr, ptr0, len0);
|
|
518
|
+
if (ret[2]) {
|
|
519
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
520
|
+
}
|
|
521
|
+
return takeFromExternrefTable0(ret[0]);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Redo the last undone change.
|
|
525
|
+
* @returns {boolean}
|
|
526
|
+
*/
|
|
527
|
+
redo() {
|
|
528
|
+
const ret = wasm.webeditor_redo(this.__wbg_ptr);
|
|
529
|
+
if (ret[2]) {
|
|
530
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
531
|
+
}
|
|
532
|
+
return ret[0] !== 0;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Replace UTF-16 range `start..end` of the head's text block with
|
|
536
|
+
* `text`, as an input method or the platform's text input does. A
|
|
537
|
+
* replacement at a caret is typing, so input rules apply.
|
|
538
|
+
* @param {number} start
|
|
539
|
+
* @param {number} end
|
|
540
|
+
* @param {string} text
|
|
541
|
+
* @returns {boolean}
|
|
542
|
+
*/
|
|
543
|
+
replaceText(start, end, text) {
|
|
544
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
545
|
+
const len0 = WASM_VECTOR_LEN;
|
|
546
|
+
const ret = wasm.webeditor_replaceText(this.__wbg_ptr, start, end, ptr0, len0);
|
|
547
|
+
if (ret[2]) {
|
|
548
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
549
|
+
}
|
|
550
|
+
return ret[0] !== 0;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Size the canvas: `width` and `height` in CSS pixels, `scale` device
|
|
554
|
+
* pixels per CSS pixel, and the backing store in device pixels. The
|
|
555
|
+
* document is laid out to `width`.
|
|
556
|
+
* @param {number} width
|
|
557
|
+
* @param {number} height
|
|
558
|
+
* @param {number} scale
|
|
559
|
+
* @param {number} pixel_width
|
|
560
|
+
* @param {number} pixel_height
|
|
561
|
+
*/
|
|
562
|
+
resize(width, height, scale, pixel_width, pixel_height) {
|
|
563
|
+
wasm.webeditor_resize(this.__wbg_ptr, width, height, scale, pixel_width, pixel_height);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Run the command an extension registered as `name`, with JSON `args`
|
|
567
|
+
* (`null` for none). Returns whether it applied.
|
|
568
|
+
* @param {string} name
|
|
569
|
+
* @param {string} args
|
|
570
|
+
* @returns {boolean}
|
|
571
|
+
*/
|
|
572
|
+
run(name, args) {
|
|
573
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
574
|
+
const len0 = WASM_VECTOR_LEN;
|
|
575
|
+
const ptr1 = passStringToWasm0(args, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
576
|
+
const len1 = WASM_VECTOR_LEN;
|
|
577
|
+
const ret = wasm.webeditor_run(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
578
|
+
if (ret[2]) {
|
|
579
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
580
|
+
}
|
|
581
|
+
return ret[0] !== 0;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Select from (`anchor_path`, `anchor_offset`) to (`head_path`,
|
|
585
|
+
* `head_offset`). Offsets count UTF-16 code units.
|
|
586
|
+
* @param {Uint32Array} anchor_path
|
|
587
|
+
* @param {number} anchor_offset
|
|
588
|
+
* @param {Uint32Array} head_path
|
|
589
|
+
* @param {number} head_offset
|
|
590
|
+
*/
|
|
591
|
+
select(anchor_path, anchor_offset, head_path, head_offset) {
|
|
592
|
+
const ptr0 = passArray32ToWasm0(anchor_path, wasm.__wbindgen_malloc);
|
|
593
|
+
const len0 = WASM_VECTOR_LEN;
|
|
594
|
+
const ptr1 = passArray32ToWasm0(head_path, wasm.__wbindgen_malloc);
|
|
595
|
+
const len1 = WASM_VECTOR_LEN;
|
|
596
|
+
const ret = wasm.webeditor_select(this.__wbg_ptr, ptr0, len0, anchor_offset, ptr1, len1, head_offset);
|
|
597
|
+
if (ret[1]) {
|
|
598
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* The smallest rectangle around the selection in document coordinates,
|
|
603
|
+
* as `[x, y, width, height]`: the caret's rectangle for a caret, and
|
|
604
|
+
* empty while the selection is not laid out. Hosts anchor menus to it.
|
|
605
|
+
* @returns {Float32Array}
|
|
606
|
+
*/
|
|
607
|
+
selectionBounds() {
|
|
608
|
+
const ret = wasm.webeditor_selectionBounds(this.__wbg_ptr);
|
|
609
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
610
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
611
|
+
return v1;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* The anchor and head as JSON positions, or `null` for a block
|
|
615
|
+
* selection.
|
|
616
|
+
* @returns {string}
|
|
617
|
+
*/
|
|
618
|
+
selection() {
|
|
619
|
+
let deferred1_0;
|
|
620
|
+
let deferred1_1;
|
|
621
|
+
try {
|
|
622
|
+
const ret = wasm.webeditor_selection(this.__wbg_ptr);
|
|
623
|
+
deferred1_0 = ret[0];
|
|
624
|
+
deferred1_1 = ret[1];
|
|
625
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
626
|
+
} finally {
|
|
627
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Snap border widths down to `scale` device pixels per CSS pixel, as
|
|
632
|
+
* this browser draws them, or not at all when `scale` is not positive.
|
|
633
|
+
* @param {number} scale
|
|
634
|
+
*/
|
|
635
|
+
setBorderScale(scale) {
|
|
636
|
+
wasm.webeditor_setBorderScale(this.__wbg_ptr, scale);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Blink the caret.
|
|
640
|
+
* @param {boolean} on
|
|
641
|
+
*/
|
|
642
|
+
setCaretOn(on) {
|
|
643
|
+
wasm.webeditor_setCaretOn(this.__wbg_ptr, on);
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Show `text` as IME preedit text at the selection, replacing any
|
|
647
|
+
* earlier preedit.
|
|
648
|
+
* @param {string} text
|
|
649
|
+
* @returns {boolean}
|
|
650
|
+
*/
|
|
651
|
+
setComposition(text) {
|
|
652
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
653
|
+
const len0 = WASM_VECTOR_LEN;
|
|
654
|
+
const ret = wasm.webeditor_setComposition(this.__wbg_ptr, ptr0, len0);
|
|
655
|
+
if (ret[2]) {
|
|
656
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
657
|
+
}
|
|
658
|
+
return ret[0] !== 0;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Show or hide the caret: hosts call this on focus and blur.
|
|
662
|
+
* @param {boolean} focused
|
|
663
|
+
*/
|
|
664
|
+
setFocused(focused) {
|
|
665
|
+
wasm.webeditor_setFocused(this.__wbg_ptr, focused);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Snap text baselines and rectangle edges to the grid the browser
|
|
669
|
+
* snaps DOM content to: `"device"` pixels, or `"css"` pixels for
|
|
670
|
+
* Chromium laying out in CSS units on a high-density screen.
|
|
671
|
+
* @param {string} grid
|
|
672
|
+
*/
|
|
673
|
+
setPixelGrid(grid) {
|
|
674
|
+
const ptr0 = passStringToWasm0(grid, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
675
|
+
const len0 = WASM_VECTOR_LEN;
|
|
676
|
+
const ret = wasm.webeditor_setPixelGrid(this.__wbg_ptr, ptr0, len0);
|
|
677
|
+
if (ret[1]) {
|
|
678
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Scroll so document coordinate `top` is at the canvas's top edge.
|
|
683
|
+
* @param {number} top
|
|
684
|
+
*/
|
|
685
|
+
setTop(top) {
|
|
686
|
+
wasm.webeditor_setTop(this.__wbg_ptr, top);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Measurement and cache statistics as JSON: cache hits and misses,
|
|
690
|
+
* cached bytes per font, and how many segments and batches the browser
|
|
691
|
+
* measured. The host derives the hit rate, so no float is formatted here
|
|
692
|
+
* (see `canvist_layout::css_number`).
|
|
693
|
+
* @returns {string}
|
|
694
|
+
*/
|
|
695
|
+
stats() {
|
|
696
|
+
let deferred1_0;
|
|
697
|
+
let deferred1_1;
|
|
698
|
+
try {
|
|
699
|
+
const ret = wasm.webeditor_stats(this.__wbg_ptr);
|
|
700
|
+
deferred1_0 = ret[0];
|
|
701
|
+
deferred1_1 = ret[1];
|
|
702
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
703
|
+
} finally {
|
|
704
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* The whole document as an SVG image painted from the same display
|
|
709
|
+
* list as the canvas. Lays out every block first.
|
|
710
|
+
* @returns {string}
|
|
711
|
+
*/
|
|
712
|
+
svg() {
|
|
713
|
+
let deferred2_0;
|
|
714
|
+
let deferred2_1;
|
|
715
|
+
try {
|
|
716
|
+
const ret = wasm.webeditor_svg(this.__wbg_ptr);
|
|
717
|
+
var ptr1 = ret[0];
|
|
718
|
+
var len1 = ret[1];
|
|
719
|
+
if (ret[3]) {
|
|
720
|
+
ptr1 = 0; len1 = 0;
|
|
721
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
722
|
+
}
|
|
723
|
+
deferred2_0 = ptr1;
|
|
724
|
+
deferred2_1 = len1;
|
|
725
|
+
return getStringFromWasm0(ptr1, len1);
|
|
726
|
+
} finally {
|
|
727
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* The message to send a server on reconnecting: sync step 1, which asks
|
|
732
|
+
* for what this editor missed.
|
|
733
|
+
* @returns {Uint8Array}
|
|
734
|
+
*/
|
|
735
|
+
syncStart() {
|
|
736
|
+
const ret = wasm.webeditor_syncStart(this.__wbg_ptr);
|
|
737
|
+
if (ret[3]) {
|
|
738
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
739
|
+
}
|
|
740
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
741
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
742
|
+
return v1;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Undo the last change. A shared document undoes only this editor's
|
|
746
|
+
* own changes.
|
|
747
|
+
* @returns {boolean}
|
|
748
|
+
*/
|
|
749
|
+
undo() {
|
|
750
|
+
const ret = wasm.webeditor_undo(this.__wbg_ptr);
|
|
751
|
+
if (ret[2]) {
|
|
752
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
753
|
+
}
|
|
754
|
+
return ret[0] !== 0;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (Symbol.dispose) WebEditor.prototype[Symbol.dispose] = WebEditor.prototype.free;
|
|
758
|
+
function __wbg_get_imports() {
|
|
759
|
+
const import0 = {
|
|
760
|
+
__proto__: null,
|
|
761
|
+
__wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
|
|
762
|
+
const ret = typeof(arg0) === 'function';
|
|
763
|
+
return ret;
|
|
764
|
+
},
|
|
765
|
+
__wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
|
|
766
|
+
const val = arg0;
|
|
767
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
768
|
+
return ret;
|
|
769
|
+
},
|
|
770
|
+
__wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
|
|
771
|
+
const ret = typeof(arg0) === 'string';
|
|
772
|
+
return ret;
|
|
773
|
+
},
|
|
774
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
775
|
+
const ret = arg0 === undefined;
|
|
776
|
+
return ret;
|
|
777
|
+
},
|
|
778
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
779
|
+
const obj = arg1;
|
|
780
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
781
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
782
|
+
var len1 = WASM_VECTOR_LEN;
|
|
783
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
784
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
785
|
+
},
|
|
786
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
787
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
788
|
+
},
|
|
789
|
+
__wbg_addFont_7bf9358d0c77aed6: function(arg0, arg1, arg2, arg3) {
|
|
790
|
+
arg0.addFont(arg1 >>> 0, getStringFromWasm0(arg2, arg3));
|
|
791
|
+
},
|
|
792
|
+
__wbg_arcTo_a1ca709a1aae1a9b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
793
|
+
arg0.arcTo(arg1, arg2, arg3, arg4, arg5);
|
|
794
|
+
}, arguments); },
|
|
795
|
+
__wbg_beginPath_8598d895c13f1c86: function(arg0) {
|
|
796
|
+
arg0.beginPath();
|
|
797
|
+
},
|
|
798
|
+
__wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
799
|
+
const ret = arg0.call(arg1, arg2);
|
|
800
|
+
return ret;
|
|
801
|
+
}, arguments); },
|
|
802
|
+
__wbg_clip_275e70d2dc182fec: function(arg0) {
|
|
803
|
+
arg0.clip();
|
|
804
|
+
},
|
|
805
|
+
__wbg_closePath_355eb6da179dd9c2: function(arg0) {
|
|
806
|
+
arg0.closePath();
|
|
807
|
+
},
|
|
808
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
809
|
+
const ret = arg0.crypto;
|
|
810
|
+
return ret;
|
|
811
|
+
},
|
|
812
|
+
__wbg_fillRect_0ef59adb9acb7d06: function(arg0, arg1, arg2, arg3, arg4) {
|
|
813
|
+
arg0.fillRect(arg1, arg2, arg3, arg4);
|
|
814
|
+
},
|
|
815
|
+
__wbg_fillText_1bcec8b81ad73bd0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
816
|
+
arg0.fillText(getStringFromWasm0(arg1, arg2), arg3, arg4);
|
|
817
|
+
}, arguments); },
|
|
818
|
+
__wbg_fill_fc5e02a06cc26e92: function(arg0) {
|
|
819
|
+
arg0.fill();
|
|
820
|
+
},
|
|
821
|
+
__wbg_getContext_051324720aa5b7e8: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
822
|
+
const ret = arg0.getContext(getStringFromWasm0(arg1, arg2), arg3);
|
|
823
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
824
|
+
}, arguments); },
|
|
825
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
826
|
+
arg0.getRandomValues(arg1);
|
|
827
|
+
}, arguments); },
|
|
828
|
+
__wbg_instanceof_CanvasRenderingContext2d_769208c72dcbf5e6: function(arg0) {
|
|
829
|
+
let result;
|
|
830
|
+
try {
|
|
831
|
+
result = arg0 instanceof CanvasRenderingContext2D;
|
|
832
|
+
} catch (_) {
|
|
833
|
+
result = false;
|
|
834
|
+
}
|
|
835
|
+
const ret = result;
|
|
836
|
+
return ret;
|
|
837
|
+
},
|
|
838
|
+
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
839
|
+
const ret = arg0.length;
|
|
840
|
+
return ret;
|
|
841
|
+
},
|
|
842
|
+
__wbg_lineTo_63fac7d60279d95e: function(arg0, arg1, arg2) {
|
|
843
|
+
arg0.lineTo(arg1, arg2);
|
|
844
|
+
},
|
|
845
|
+
__wbg_measure_79e75cf23afa247f: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) {
|
|
846
|
+
const ret = arg1.measure(getArrayU32FromWasm0(arg2, arg3), getArrayU32FromWasm0(arg4, arg5), getArrayF32FromWasm0(arg6, arg7), getArrayU32FromWasm0(arg8, arg9), getStringFromWasm0(arg10, arg11), getArrayU32FromWasm0(arg12, arg13));
|
|
847
|
+
const ptr1 = passArrayF32ToWasm0(ret, wasm.__wbindgen_malloc);
|
|
848
|
+
const len1 = WASM_VECTOR_LEN;
|
|
849
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
850
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
851
|
+
},
|
|
852
|
+
__wbg_moveTo_037e3deefec91ae1: function(arg0, arg1, arg2) {
|
|
853
|
+
arg0.moveTo(arg1, arg2);
|
|
854
|
+
},
|
|
855
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
856
|
+
const ret = arg0.msCrypto;
|
|
857
|
+
return ret;
|
|
858
|
+
},
|
|
859
|
+
__wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
|
|
860
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
861
|
+
return ret;
|
|
862
|
+
},
|
|
863
|
+
__wbg_new_617a8cdb8bb1130e: function() {
|
|
864
|
+
const ret = new Object();
|
|
865
|
+
return ret;
|
|
866
|
+
},
|
|
867
|
+
__wbg_new_ee2291f50781bf1d: function() {
|
|
868
|
+
const ret = new Array();
|
|
869
|
+
return ret;
|
|
870
|
+
},
|
|
871
|
+
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
872
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
873
|
+
return ret;
|
|
874
|
+
},
|
|
875
|
+
__wbg_new_with_length_3da0ad195f6f63ba: function(arg0) {
|
|
876
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
877
|
+
return ret;
|
|
878
|
+
},
|
|
879
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
880
|
+
const ret = arg0.node;
|
|
881
|
+
return ret;
|
|
882
|
+
},
|
|
883
|
+
__wbg_now_aa4ccb83129e9e55: function() {
|
|
884
|
+
const ret = Date.now();
|
|
885
|
+
return ret;
|
|
886
|
+
},
|
|
887
|
+
__wbg_paintFont_f6833c16ddedaff0: function(arg0, arg1, arg2) {
|
|
888
|
+
const ret = arg1.paintFont(arg2 >>> 0);
|
|
889
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
890
|
+
const len1 = WASM_VECTOR_LEN;
|
|
891
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
892
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
893
|
+
},
|
|
894
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
895
|
+
const ret = arg0.process;
|
|
896
|
+
return ret;
|
|
897
|
+
},
|
|
898
|
+
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
899
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
900
|
+
},
|
|
901
|
+
__wbg_push_2baf45db356cf468: function(arg0, arg1) {
|
|
902
|
+
const ret = arg0.push(arg1);
|
|
903
|
+
return ret;
|
|
904
|
+
},
|
|
905
|
+
__wbg_quadraticCurveTo_4f57843d21c4f90d: function(arg0, arg1, arg2, arg3, arg4) {
|
|
906
|
+
arg0.quadraticCurveTo(arg1, arg2, arg3, arg4);
|
|
907
|
+
},
|
|
908
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
909
|
+
arg0.randomFillSync(arg1);
|
|
910
|
+
}, arguments); },
|
|
911
|
+
__wbg_rect_c6f60004ffec8f09: function(arg0, arg1, arg2, arg3, arg4) {
|
|
912
|
+
arg0.rect(arg1, arg2, arg3, arg4);
|
|
913
|
+
},
|
|
914
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
915
|
+
const ret = module.require;
|
|
916
|
+
return ret;
|
|
917
|
+
}, arguments); },
|
|
918
|
+
__wbg_restore_c93ba7571816b182: function(arg0) {
|
|
919
|
+
arg0.restore();
|
|
920
|
+
},
|
|
921
|
+
__wbg_save_f32554f1747071d1: function(arg0) {
|
|
922
|
+
arg0.save();
|
|
923
|
+
},
|
|
924
|
+
__wbg_setTransform_fa787a8f0adc1ade: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
925
|
+
arg0.setTransform(arg1, arg2, arg3, arg4, arg5, arg6);
|
|
926
|
+
}, arguments); },
|
|
927
|
+
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
928
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
929
|
+
return ret;
|
|
930
|
+
}, arguments); },
|
|
931
|
+
__wbg_set_alpha_15af6d7f9268a627: function(arg0, arg1) {
|
|
932
|
+
arg0.alpha = arg1 !== 0;
|
|
933
|
+
},
|
|
934
|
+
__wbg_set_direction_7ceac10a3a56e7ab: function(arg0, arg1, arg2) {
|
|
935
|
+
arg0.direction = getStringFromWasm0(arg1, arg2);
|
|
936
|
+
},
|
|
937
|
+
__wbg_set_fillStyle_a2961b4d44e572af: function(arg0, arg1, arg2) {
|
|
938
|
+
arg0.fillStyle = getStringFromWasm0(arg1, arg2);
|
|
939
|
+
},
|
|
940
|
+
__wbg_set_font_1f60a05a2544a2ff: function(arg0, arg1, arg2) {
|
|
941
|
+
arg0.font = getStringFromWasm0(arg1, arg2);
|
|
942
|
+
},
|
|
943
|
+
__wbg_set_font_kerning_e22d5e53e0b49b4a: function(arg0, arg1, arg2) {
|
|
944
|
+
arg0.fontKerning = getStringFromWasm0(arg1, arg2);
|
|
945
|
+
},
|
|
946
|
+
__wbg_set_font_variant_caps_fddb2612d001f247: function(arg0, arg1, arg2) {
|
|
947
|
+
arg0.fontVariantCaps = getStringFromWasm0(arg1, arg2);
|
|
948
|
+
},
|
|
949
|
+
__wbg_set_height_c9789c1c77eaedff: function(arg0, arg1) {
|
|
950
|
+
arg0.height = arg1 >>> 0;
|
|
951
|
+
},
|
|
952
|
+
__wbg_set_letter_spacing_a9766069411bd841: function(arg0, arg1, arg2) {
|
|
953
|
+
arg0.letterSpacing = getStringFromWasm0(arg1, arg2);
|
|
954
|
+
},
|
|
955
|
+
__wbg_set_lineCap_c9b7bdd3b7f5ce74: function(arg0, arg1, arg2) {
|
|
956
|
+
arg0.lineCap = getStringFromWasm0(arg1, arg2);
|
|
957
|
+
},
|
|
958
|
+
__wbg_set_lineJoin_c1780f2096e6f970: function(arg0, arg1, arg2) {
|
|
959
|
+
arg0.lineJoin = getStringFromWasm0(arg1, arg2);
|
|
960
|
+
},
|
|
961
|
+
__wbg_set_lineWidth_cc15473552c60c9c: function(arg0, arg1) {
|
|
962
|
+
arg0.lineWidth = arg1;
|
|
963
|
+
},
|
|
964
|
+
__wbg_set_name_2c630595dc90a7aa: function(arg0, arg1, arg2) {
|
|
965
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
966
|
+
},
|
|
967
|
+
__wbg_set_strokeStyle_d51608fa918b53d4: function(arg0, arg1, arg2) {
|
|
968
|
+
arg0.strokeStyle = getStringFromWasm0(arg1, arg2);
|
|
969
|
+
},
|
|
970
|
+
__wbg_set_textAlign_1bda1733d57574ed: function(arg0, arg1, arg2) {
|
|
971
|
+
arg0.textAlign = getStringFromWasm0(arg1, arg2);
|
|
972
|
+
},
|
|
973
|
+
__wbg_set_textBaseline_d5ba548751584f49: function(arg0, arg1, arg2) {
|
|
974
|
+
arg0.textBaseline = getStringFromWasm0(arg1, arg2);
|
|
975
|
+
},
|
|
976
|
+
__wbg_set_text_rendering_111c051258ca1e75: function(arg0, arg1, arg2) {
|
|
977
|
+
arg0.textRendering = getStringFromWasm0(arg1, arg2);
|
|
978
|
+
},
|
|
979
|
+
__wbg_set_width_b0e1267db4b196b5: function(arg0, arg1) {
|
|
980
|
+
arg0.width = arg1 >>> 0;
|
|
981
|
+
},
|
|
982
|
+
__wbg_set_word_spacing_0d1d87f6d472beac: function(arg0, arg1, arg2) {
|
|
983
|
+
arg0.wordSpacing = getStringFromWasm0(arg1, arg2);
|
|
984
|
+
},
|
|
985
|
+
__wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
|
|
986
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
987
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
988
|
+
},
|
|
989
|
+
__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
|
|
990
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
991
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
992
|
+
},
|
|
993
|
+
__wbg_static_accessor_SELF_0b583911f537483a: function() {
|
|
994
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
995
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
996
|
+
},
|
|
997
|
+
__wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
|
|
998
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
999
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1000
|
+
},
|
|
1001
|
+
__wbg_stroke_385d731098398489: function(arg0) {
|
|
1002
|
+
arg0.stroke();
|
|
1003
|
+
},
|
|
1004
|
+
__wbg_subarray_002b94d5e13d1411: function(arg0, arg1, arg2) {
|
|
1005
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1006
|
+
return ret;
|
|
1007
|
+
},
|
|
1008
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
1009
|
+
const ret = arg0.versions;
|
|
1010
|
+
return ret;
|
|
1011
|
+
},
|
|
1012
|
+
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
1013
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1014
|
+
const ret = arg0;
|
|
1015
|
+
return ret;
|
|
1016
|
+
},
|
|
1017
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1018
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1019
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1020
|
+
return ret;
|
|
1021
|
+
},
|
|
1022
|
+
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1023
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1024
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1025
|
+
return ret;
|
|
1026
|
+
},
|
|
1027
|
+
__wbindgen_init_externref_table: function() {
|
|
1028
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1029
|
+
const offset = table.grow(4);
|
|
1030
|
+
table.set(0, undefined);
|
|
1031
|
+
table.set(offset + 0, undefined);
|
|
1032
|
+
table.set(offset + 1, null);
|
|
1033
|
+
table.set(offset + 2, true);
|
|
1034
|
+
table.set(offset + 3, false);
|
|
1035
|
+
},
|
|
1036
|
+
};
|
|
1037
|
+
return {
|
|
1038
|
+
__proto__: null,
|
|
1039
|
+
"./canvist_web_bg.js": import0,
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
const WebEditorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1044
|
+
? { register: () => {}, unregister: () => {} }
|
|
1045
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_webeditor_free(ptr, 1));
|
|
1046
|
+
|
|
1047
|
+
function addToExternrefTable0(obj) {
|
|
1048
|
+
const idx = wasm.__externref_table_alloc();
|
|
1049
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1050
|
+
return idx;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
1054
|
+
ptr = ptr >>> 0;
|
|
1055
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
1059
|
+
ptr = ptr >>> 0;
|
|
1060
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
1064
|
+
ptr = ptr >>> 0;
|
|
1065
|
+
const mem = getDataViewMemory0();
|
|
1066
|
+
const result = [];
|
|
1067
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
1068
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
1069
|
+
}
|
|
1070
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
1071
|
+
return result;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
1075
|
+
ptr = ptr >>> 0;
|
|
1076
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1080
|
+
ptr = ptr >>> 0;
|
|
1081
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
let cachedDataViewMemory0 = null;
|
|
1085
|
+
function getDataViewMemory0() {
|
|
1086
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1087
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1088
|
+
}
|
|
1089
|
+
return cachedDataViewMemory0;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
1093
|
+
function getFloat32ArrayMemory0() {
|
|
1094
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
1095
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
1096
|
+
}
|
|
1097
|
+
return cachedFloat32ArrayMemory0;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
1101
|
+
function getFloat64ArrayMemory0() {
|
|
1102
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
1103
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
1104
|
+
}
|
|
1105
|
+
return cachedFloat64ArrayMemory0;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
function getStringFromWasm0(ptr, len) {
|
|
1109
|
+
return decodeText(ptr >>> 0, len);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
let cachedUint32ArrayMemory0 = null;
|
|
1113
|
+
function getUint32ArrayMemory0() {
|
|
1114
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
1115
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
1116
|
+
}
|
|
1117
|
+
return cachedUint32ArrayMemory0;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1121
|
+
function getUint8ArrayMemory0() {
|
|
1122
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1123
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1124
|
+
}
|
|
1125
|
+
return cachedUint8ArrayMemory0;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function handleError(f, args) {
|
|
1129
|
+
try {
|
|
1130
|
+
return f.apply(this, args);
|
|
1131
|
+
} catch (e) {
|
|
1132
|
+
const idx = addToExternrefTable0(e);
|
|
1133
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function isLikeNone(x) {
|
|
1138
|
+
return x === undefined || x === null;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
1142
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1143
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
1144
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1145
|
+
return ptr;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1149
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1150
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1151
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1152
|
+
return ptr;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
1156
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1157
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
1158
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1159
|
+
return ptr;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1163
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1164
|
+
for (let i = 0; i < array.length; i++) {
|
|
1165
|
+
const add = addToExternrefTable0(array[i]);
|
|
1166
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1167
|
+
}
|
|
1168
|
+
WASM_VECTOR_LEN = array.length;
|
|
1169
|
+
return ptr;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1173
|
+
if (realloc === undefined) {
|
|
1174
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1175
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1176
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1177
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1178
|
+
return ptr;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
let len = arg.length;
|
|
1182
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1183
|
+
|
|
1184
|
+
const mem = getUint8ArrayMemory0();
|
|
1185
|
+
|
|
1186
|
+
let offset = 0;
|
|
1187
|
+
|
|
1188
|
+
for (; offset < len; offset++) {
|
|
1189
|
+
const code = arg.charCodeAt(offset);
|
|
1190
|
+
if (code > 0x7F) break;
|
|
1191
|
+
mem[ptr + offset] = code;
|
|
1192
|
+
}
|
|
1193
|
+
if (offset !== len) {
|
|
1194
|
+
if (offset !== 0) {
|
|
1195
|
+
arg = arg.slice(offset);
|
|
1196
|
+
}
|
|
1197
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1198
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1199
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1200
|
+
|
|
1201
|
+
offset += ret.written;
|
|
1202
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
WASM_VECTOR_LEN = offset;
|
|
1206
|
+
return ptr;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
function takeFromExternrefTable0(idx) {
|
|
1210
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1211
|
+
wasm.__externref_table_dealloc(idx);
|
|
1212
|
+
return value;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1216
|
+
cachedTextDecoder.decode();
|
|
1217
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1218
|
+
let numBytesDecoded = 0;
|
|
1219
|
+
function decodeText(ptr, len) {
|
|
1220
|
+
numBytesDecoded += len;
|
|
1221
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1222
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1223
|
+
cachedTextDecoder.decode();
|
|
1224
|
+
numBytesDecoded = len;
|
|
1225
|
+
}
|
|
1226
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1230
|
+
|
|
1231
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1232
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1233
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1234
|
+
view.set(buf);
|
|
1235
|
+
return {
|
|
1236
|
+
read: arg.length,
|
|
1237
|
+
written: buf.length
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
let WASM_VECTOR_LEN = 0;
|
|
1243
|
+
|
|
1244
|
+
let wasmModule, wasmInstance, wasm;
|
|
1245
|
+
function __wbg_finalize_init(instance, module) {
|
|
1246
|
+
wasmInstance = instance;
|
|
1247
|
+
wasm = instance.exports;
|
|
1248
|
+
wasmModule = module;
|
|
1249
|
+
cachedDataViewMemory0 = null;
|
|
1250
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1251
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1252
|
+
cachedUint32ArrayMemory0 = null;
|
|
1253
|
+
cachedUint8ArrayMemory0 = null;
|
|
1254
|
+
wasm.__wbindgen_start();
|
|
1255
|
+
return wasm;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
async function __wbg_load(module, imports) {
|
|
1259
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1260
|
+
if (!module.ok) {
|
|
1261
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1265
|
+
try {
|
|
1266
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1267
|
+
} catch (e) {
|
|
1268
|
+
const validResponse = expectedResponseType(module.type);
|
|
1269
|
+
|
|
1270
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1271
|
+
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);
|
|
1272
|
+
|
|
1273
|
+
} else { throw e; }
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
const bytes = await module.arrayBuffer();
|
|
1278
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1279
|
+
} else {
|
|
1280
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1281
|
+
|
|
1282
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1283
|
+
return { instance, module };
|
|
1284
|
+
} else {
|
|
1285
|
+
return instance;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
function expectedResponseType(type) {
|
|
1290
|
+
switch (type) {
|
|
1291
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1292
|
+
}
|
|
1293
|
+
return false;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
function initSync(module) {
|
|
1298
|
+
if (wasm !== undefined) return wasm;
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
if (module !== undefined) {
|
|
1302
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1303
|
+
({module} = module)
|
|
1304
|
+
} else {
|
|
1305
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
const imports = __wbg_get_imports();
|
|
1310
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1311
|
+
module = new WebAssembly.Module(module);
|
|
1312
|
+
}
|
|
1313
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1314
|
+
return __wbg_finalize_init(instance, module);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
async function __wbg_init(module_or_path) {
|
|
1318
|
+
if (wasm !== undefined) return wasm;
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
if (module_or_path !== undefined) {
|
|
1322
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1323
|
+
({module_or_path} = module_or_path)
|
|
1324
|
+
} else {
|
|
1325
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if (module_or_path === undefined) {
|
|
1330
|
+
module_or_path = new URL('canvist_web_bg.wasm', import.meta.url);
|
|
1331
|
+
}
|
|
1332
|
+
const imports = __wbg_get_imports();
|
|
1333
|
+
|
|
1334
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1335
|
+
module_or_path = fetch(module_or_path);
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1339
|
+
|
|
1340
|
+
return __wbg_finalize_init(instance, module);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
export { initSync, __wbg_init as default };
|