@dotgui/embed 0.2.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -9
- package/dist/fonts/Inter.woff2 +0 -0
- package/dist/fonts/OFL.txt +92 -0
- package/dist/gui-embed.esm.js +1 -120
- package/dist/gui-embed.js +10 -120
- package/dist/pkg/dotgui_renderer_wasm.js +1110 -0
- package/dist/pkg/dotgui_renderer_wasm_bg.wasm +0 -0
- package/dist/render-worker.js +262 -0
- package/package.json +15 -9
- package/src/auto.ts +26 -3
- package/src/error-message.test.ts +55 -0
- package/src/error-message.ts +63 -0
- package/src/gui-embed.ts +299 -112
- package/src/index.ts +8 -6
- package/src/decode.ts +0 -60
- package/src/modes.ts +0 -26
|
@@ -0,0 +1,1110 @@
|
|
|
1
|
+
/* @ts-self-types="./dotgui_renderer_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A renderer that outlives one call, for a host that redraws as a document is
|
|
5
|
+
* edited.
|
|
6
|
+
*
|
|
7
|
+
* It holds the bytes a document needs and cannot fetch for itself: a package's
|
|
8
|
+
* own assets, and whatever the host has fetched on its behalf — Google font
|
|
9
|
+
* stylesheets and files, remote images, the host's system font files — each
|
|
10
|
+
* kept under the exact URL or path the document resolves it by. The markup is
|
|
11
|
+
* not held: the host owns it, edits it, and passes the current text to every
|
|
12
|
+
* [`Engine::render`].
|
|
13
|
+
*/
|
|
14
|
+
export class Engine {
|
|
15
|
+
__destroy_into_raw() {
|
|
16
|
+
const ptr = this.__wbg_ptr;
|
|
17
|
+
this.__wbg_ptr = 0;
|
|
18
|
+
EngineFinalization.unregister(this);
|
|
19
|
+
return ptr;
|
|
20
|
+
}
|
|
21
|
+
free() {
|
|
22
|
+
const ptr = this.__destroy_into_raw();
|
|
23
|
+
wasm.__wbg_engine_free(ptr, 0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What an edit changed: the areas, in document pixels, that paint
|
|
27
|
+
* differently in `after` than in `before`, as `[x, y, width, height, …]`.
|
|
28
|
+
* Empty when nothing changed; nothing at all when the whole page should be
|
|
29
|
+
* painted again — its size changed, most of it changed, or `library` is
|
|
30
|
+
* set, since a library edit reaches every document.
|
|
31
|
+
* @param {string} before
|
|
32
|
+
* @param {string} after
|
|
33
|
+
* @param {boolean | null} [library]
|
|
34
|
+
* @returns {Float32Array | undefined}
|
|
35
|
+
*/
|
|
36
|
+
changed_areas(before, after, library) {
|
|
37
|
+
const ptr0 = passStringToWasm0(before, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ptr1 = passStringToWasm0(after, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
|
+
const len1 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.engine_changed_areas(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
42
|
+
if (ret[3]) {
|
|
43
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
44
|
+
}
|
|
45
|
+
let v3;
|
|
46
|
+
if (ret[0] !== 0) {
|
|
47
|
+
v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
48
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
49
|
+
}
|
|
50
|
+
return v3;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns every axis to the document's own default.
|
|
54
|
+
*/
|
|
55
|
+
clear_modes() {
|
|
56
|
+
wasm.engine_clear_modes(this.__wbg_ptr);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The box of the first element whose `attribute` is `value` — an `id`, a
|
|
60
|
+
* layer `name`, a `data-uid` — as `[x, y, width, height]` in document
|
|
61
|
+
* pixels, or nothing when no element has it.
|
|
62
|
+
* @param {string} xml
|
|
63
|
+
* @param {string} attribute
|
|
64
|
+
* @param {string} value
|
|
65
|
+
* @param {boolean | null} [library]
|
|
66
|
+
* @returns {Float32Array | undefined}
|
|
67
|
+
*/
|
|
68
|
+
element_bounds(xml, attribute, value, library) {
|
|
69
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
70
|
+
const len0 = WASM_VECTOR_LEN;
|
|
71
|
+
const ptr1 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
72
|
+
const len1 = WASM_VECTOR_LEN;
|
|
73
|
+
const ptr2 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
74
|
+
const len2 = WASM_VECTOR_LEN;
|
|
75
|
+
const ret = wasm.engine_element_bounds(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
76
|
+
if (ret[3]) {
|
|
77
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
78
|
+
}
|
|
79
|
+
let v4;
|
|
80
|
+
if (ret[0] !== 0) {
|
|
81
|
+
v4 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
82
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
83
|
+
}
|
|
84
|
+
return v4;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reads a packaged `.gui`, keeps its assets and library, and returns its
|
|
88
|
+
* pages as JSON:
|
|
89
|
+
*
|
|
90
|
+
* ```json
|
|
91
|
+
* { "documents": [{ "name": "01-welcome.guix", "xml": "<gui …" }],
|
|
92
|
+
* "library": { "name": "library.guix", "xml": "<gui …", "hasPage": true } }
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Documents are in presentation order. `library` is `null` when the
|
|
96
|
+
* package has none. A document that is not valid UTF-8 comes back with
|
|
97
|
+
* `xml: null` and an `error`, so the rest still open.
|
|
98
|
+
* @param {Uint8Array} _package
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
load_package(_package) {
|
|
102
|
+
let deferred3_0;
|
|
103
|
+
let deferred3_1;
|
|
104
|
+
try {
|
|
105
|
+
const ptr0 = passArray8ToWasm0(_package, wasm.__wbindgen_malloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ret = wasm.engine_load_package(this.__wbg_ptr, ptr0, len0);
|
|
108
|
+
var ptr2 = ret[0];
|
|
109
|
+
var len2 = ret[1];
|
|
110
|
+
if (ret[3]) {
|
|
111
|
+
ptr2 = 0; len2 = 0;
|
|
112
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
113
|
+
}
|
|
114
|
+
deferred3_0 = ptr2;
|
|
115
|
+
deferred3_1 = len2;
|
|
116
|
+
return getStringFromWasm0(ptr2, len2);
|
|
117
|
+
} finally {
|
|
118
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The system font files this document needs whose bytes the engine does
|
|
123
|
+
* not hold yet. Like [`Engine::missing_font_urls`], ask again after supplying
|
|
124
|
+
* them: a family that is not installed falls back to the next UI font.
|
|
125
|
+
* @param {string} xml
|
|
126
|
+
* @param {boolean | null} [library]
|
|
127
|
+
* @returns {string[]}
|
|
128
|
+
*/
|
|
129
|
+
missing_font_files(xml, library) {
|
|
130
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
132
|
+
const ret = wasm.engine_missing_font_files(this.__wbg_ptr, ptr0, len0, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
133
|
+
if (ret[3]) {
|
|
134
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
135
|
+
}
|
|
136
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
137
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
138
|
+
return v2;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The web font URLs this document needs that the engine does not hold
|
|
142
|
+
* yet: Google stylesheets, then the font files they name.
|
|
143
|
+
*
|
|
144
|
+
* Font files are only known once their stylesheet is held, so a host
|
|
145
|
+
* fetches what this returns and asks again until it comes back empty.
|
|
146
|
+
* Fonts decide where text breaks, so a host should wait for these before
|
|
147
|
+
* a first render, or the layout will jump when they arrive.
|
|
148
|
+
* @param {string} xml
|
|
149
|
+
* @param {boolean | null} [library]
|
|
150
|
+
* @returns {string[]}
|
|
151
|
+
*/
|
|
152
|
+
missing_font_urls(xml, library) {
|
|
153
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.engine_missing_font_urls(this.__wbg_ptr, ptr0, len0, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
156
|
+
if (ret[3]) {
|
|
157
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
158
|
+
}
|
|
159
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
160
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
161
|
+
return v2;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The remote images this document needs that the engine does not hold
|
|
165
|
+
* yet: `src` values, `url(...)` fills, and tokens that name either.
|
|
166
|
+
*
|
|
167
|
+
* Images never move the layout — their boxes are sized by the markup — so
|
|
168
|
+
* a host can render first and fill these in when they arrive.
|
|
169
|
+
* @param {string} xml
|
|
170
|
+
* @param {boolean | null} [library]
|
|
171
|
+
* @returns {string[]}
|
|
172
|
+
*/
|
|
173
|
+
missing_image_urls(xml, library) {
|
|
174
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ret = wasm.engine_missing_image_urls(this.__wbg_ptr, ptr0, len0, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
177
|
+
if (ret[3]) {
|
|
178
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
179
|
+
}
|
|
180
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
181
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
182
|
+
return v2;
|
|
183
|
+
}
|
|
184
|
+
constructor() {
|
|
185
|
+
const ret = wasm.engine_new();
|
|
186
|
+
this.__wbg_ptr = ret;
|
|
187
|
+
EngineFinalization.register(this, this.__wbg_ptr, this);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The page's size in document pixels, `[width, height]`, for a host
|
|
192
|
+
* planning which regions to ask for. Lays the page out if it is not yet.
|
|
193
|
+
* @param {string} xml
|
|
194
|
+
* @param {boolean | null} [library]
|
|
195
|
+
* @returns {Float32Array}
|
|
196
|
+
*/
|
|
197
|
+
page_size(xml, library) {
|
|
198
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
199
|
+
const len0 = WASM_VECTOR_LEN;
|
|
200
|
+
const ret = wasm.engine_page_size(this.__wbg_ptr, ptr0, len0, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
201
|
+
if (ret[3]) {
|
|
202
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
203
|
+
}
|
|
204
|
+
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
205
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
206
|
+
return v2;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Renders at `density` device pixels per document pixel — pass the
|
|
210
|
+
* screen's `devicePixelRatio` for a sharp canvas. The layout stays in
|
|
211
|
+
* document pixels, so hit testing does not change with density.
|
|
212
|
+
*
|
|
213
|
+
* Pass `library: true` when `xml` is the package's `library.guix`: its
|
|
214
|
+
* page is drawn, and every later document resolves against this markup,
|
|
215
|
+
* so an edit to the library shows up in the documents that use it.
|
|
216
|
+
*
|
|
217
|
+
* The page is kept laid out, so rendering the same markup again — at
|
|
218
|
+
* another density, or by region — only paints.
|
|
219
|
+
* @param {string} xml
|
|
220
|
+
* @param {number} density
|
|
221
|
+
* @param {boolean | null} [library]
|
|
222
|
+
* @returns {Frame}
|
|
223
|
+
*/
|
|
224
|
+
render(xml, density, library) {
|
|
225
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
226
|
+
const len0 = WASM_VECTOR_LEN;
|
|
227
|
+
const ret = wasm.engine_render(this.__wbg_ptr, ptr0, len0, density, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
228
|
+
if (ret[2]) {
|
|
229
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
230
|
+
}
|
|
231
|
+
return Frame.__wrap(ret[0]);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* An area of the page, in document pixels, drawn at `scale` — ready for a
|
|
235
|
+
* canvas. Its edges snap outward to whole pixels; the frame's `x` and `y`
|
|
236
|
+
* say where it landed.
|
|
237
|
+
* @param {string} xml
|
|
238
|
+
* @param {number} x
|
|
239
|
+
* @param {number} y
|
|
240
|
+
* @param {number} width
|
|
241
|
+
* @param {number} height
|
|
242
|
+
* @param {number} scale
|
|
243
|
+
* @param {boolean | null} [library]
|
|
244
|
+
* @returns {Frame}
|
|
245
|
+
*/
|
|
246
|
+
render_area(xml, x, y, width, height, scale, library) {
|
|
247
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
248
|
+
const len0 = WASM_VECTOR_LEN;
|
|
249
|
+
const ret = wasm.engine_render_area(this.__wbg_ptr, ptr0, len0, x, y, width, height, scale, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
250
|
+
if (ret[2]) {
|
|
251
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
252
|
+
}
|
|
253
|
+
return Frame.__wrap(ret[0]);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* One element as it appears on the page, grown by `padding` document
|
|
257
|
+
* pixels on each side, drawn at `scale` — ready for a canvas.
|
|
258
|
+
* @param {string} xml
|
|
259
|
+
* @param {string} attribute
|
|
260
|
+
* @param {string} value
|
|
261
|
+
* @param {number} scale
|
|
262
|
+
* @param {number} padding
|
|
263
|
+
* @param {boolean | null} [library]
|
|
264
|
+
* @returns {Frame}
|
|
265
|
+
*/
|
|
266
|
+
render_element(xml, attribute, value, scale, padding, library) {
|
|
267
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr1 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len1 = WASM_VECTOR_LEN;
|
|
271
|
+
const ptr2 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
+
const len2 = WASM_VECTOR_LEN;
|
|
273
|
+
const ret = wasm.engine_render_element(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, scale, padding, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
274
|
+
if (ret[2]) {
|
|
275
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
276
|
+
}
|
|
277
|
+
return Frame.__wrap(ret[0]);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Renders one rectangle of the page at `scale`: what a zoomed-in view or
|
|
281
|
+
* a screenshot of one area needs, without painting the rest.
|
|
282
|
+
*
|
|
283
|
+
* `x`, `y`, `width` and `height` are in the pixels of the page painted at
|
|
284
|
+
* `scale` — at 2, a 1280×720 page is 2560×1440 of them — so regions laid
|
|
285
|
+
* side by side tile the page exactly. Parts past the page are transparent.
|
|
286
|
+
* @param {string} xml
|
|
287
|
+
* @param {number} scale
|
|
288
|
+
* @param {number} x
|
|
289
|
+
* @param {number} y
|
|
290
|
+
* @param {number} width
|
|
291
|
+
* @param {number} height
|
|
292
|
+
* @param {boolean | null} [library]
|
|
293
|
+
* @returns {Frame}
|
|
294
|
+
*/
|
|
295
|
+
render_region(xml, scale, x, y, width, height, library) {
|
|
296
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
297
|
+
const len0 = WASM_VECTOR_LEN;
|
|
298
|
+
const ret = wasm.engine_render_region(this.__wbg_ptr, ptr0, len0, scale, x, y, width, height, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
299
|
+
if (ret[2]) {
|
|
300
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
301
|
+
}
|
|
302
|
+
return Frame.__wrap(ret[0]);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* After an edit, the frames to put over the last frame of `before` at
|
|
306
|
+
* `scale` to show `after`: one per changed area, each at its own `x` and
|
|
307
|
+
* `y`. None when nothing changed; a single whole-page frame when the page
|
|
308
|
+
* should be painted again — check its `density`, since a page too large
|
|
309
|
+
* for a canvas is drawn smaller.
|
|
310
|
+
* @param {string} before
|
|
311
|
+
* @param {string} after
|
|
312
|
+
* @param {number} scale
|
|
313
|
+
* @param {boolean | null} [library]
|
|
314
|
+
* @returns {Frame[]}
|
|
315
|
+
*/
|
|
316
|
+
repaint(before, after, scale, library) {
|
|
317
|
+
const ptr0 = passStringToWasm0(before, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
const len0 = WASM_VECTOR_LEN;
|
|
319
|
+
const ptr1 = passStringToWasm0(after, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
const len1 = WASM_VECTOR_LEN;
|
|
321
|
+
const ret = wasm.engine_repaint(this.__wbg_ptr, ptr0, len0, ptr1, len1, scale, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
322
|
+
if (ret[3]) {
|
|
323
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
324
|
+
}
|
|
325
|
+
var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
326
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
327
|
+
return v3;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* An area of the page, in document pixels, at `scale`, as PNG bytes.
|
|
331
|
+
* @param {string} xml
|
|
332
|
+
* @param {number} x
|
|
333
|
+
* @param {number} y
|
|
334
|
+
* @param {number} width
|
|
335
|
+
* @param {number} height
|
|
336
|
+
* @param {number} scale
|
|
337
|
+
* @param {boolean | null} [library]
|
|
338
|
+
* @returns {Uint8Array}
|
|
339
|
+
*/
|
|
340
|
+
screenshot_area_png(xml, x, y, width, height, scale, library) {
|
|
341
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
342
|
+
const len0 = WASM_VECTOR_LEN;
|
|
343
|
+
const ret = wasm.engine_screenshot_area_png(this.__wbg_ptr, ptr0, len0, x, y, width, height, scale, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
344
|
+
if (ret[3]) {
|
|
345
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
346
|
+
}
|
|
347
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
348
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
349
|
+
return v2;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* One element, grown by `padding` document pixels, at `scale`, as PNG
|
|
353
|
+
* bytes.
|
|
354
|
+
* @param {string} xml
|
|
355
|
+
* @param {string} attribute
|
|
356
|
+
* @param {string} value
|
|
357
|
+
* @param {number} scale
|
|
358
|
+
* @param {number} padding
|
|
359
|
+
* @param {boolean | null} [library]
|
|
360
|
+
* @returns {Uint8Array}
|
|
361
|
+
*/
|
|
362
|
+
screenshot_element_png(xml, attribute, value, scale, padding, library) {
|
|
363
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
364
|
+
const len0 = WASM_VECTOR_LEN;
|
|
365
|
+
const ptr1 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
|
+
const len1 = WASM_VECTOR_LEN;
|
|
367
|
+
const ptr2 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
368
|
+
const len2 = WASM_VECTOR_LEN;
|
|
369
|
+
const ret = wasm.engine_screenshot_element_png(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, scale, padding, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
370
|
+
if (ret[3]) {
|
|
371
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
372
|
+
}
|
|
373
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
374
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
375
|
+
return v4;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* The whole page at `scale`, encoded as `format`: `png`, `webp` (lossless)
|
|
379
|
+
* or `jpeg` (on white, since JPEG has no transparency). What a host needs
|
|
380
|
+
* for a preview or an export without a browser to encode it.
|
|
381
|
+
* @param {string} xml
|
|
382
|
+
* @param {number} scale
|
|
383
|
+
* @param {boolean | null | undefined} library
|
|
384
|
+
* @param {string} format
|
|
385
|
+
* @returns {Uint8Array}
|
|
386
|
+
*/
|
|
387
|
+
screenshot_page_image(xml, scale, library, format) {
|
|
388
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
390
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
391
|
+
const len1 = WASM_VECTOR_LEN;
|
|
392
|
+
const ret = wasm.engine_screenshot_page_image(this.__wbg_ptr, ptr0, len0, scale, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0, ptr1, len1);
|
|
393
|
+
if (ret[3]) {
|
|
394
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
395
|
+
}
|
|
396
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
397
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
398
|
+
return v3;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* The whole page at `scale`, as PNG bytes: a screenshot to save or send.
|
|
402
|
+
* Unlike [`Engine::render`], it is not held to a canvas's size limit.
|
|
403
|
+
* @param {string} xml
|
|
404
|
+
* @param {number} scale
|
|
405
|
+
* @param {boolean | null} [library]
|
|
406
|
+
* @returns {Uint8Array}
|
|
407
|
+
*/
|
|
408
|
+
screenshot_page_png(xml, scale, library) {
|
|
409
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
410
|
+
const len0 = WASM_VECTOR_LEN;
|
|
411
|
+
const ret = wasm.engine_screenshot_page_png(this.__wbg_ptr, ptr0, len0, scale, isLikeNone(library) ? 0xFFFFFF : library ? 1 : 0);
|
|
412
|
+
if (ret[3]) {
|
|
413
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
414
|
+
}
|
|
415
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
416
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
417
|
+
return v2;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Holds `bytes` under `key`: a package path, a remote URL, or the path of
|
|
421
|
+
* a system font file the host listed.
|
|
422
|
+
* @param {string} key
|
|
423
|
+
* @param {Uint8Array} bytes
|
|
424
|
+
*/
|
|
425
|
+
set_asset(key, bytes) {
|
|
426
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
427
|
+
const len0 = WASM_VECTOR_LEN;
|
|
428
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
429
|
+
const len1 = WASM_VECTOR_LEN;
|
|
430
|
+
wasm.engine_set_asset(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* The font files on the host, by path — what a native renderer would find
|
|
434
|
+
* in the host's font directories. `source="system"` families resolve
|
|
435
|
+
* against this list exactly as they would against those directories; the
|
|
436
|
+
* files' bytes arrive through [`Engine::set_asset`], as
|
|
437
|
+
* [`Engine::missing_font_files`] asks for them.
|
|
438
|
+
* @param {string[]} paths
|
|
439
|
+
*/
|
|
440
|
+
set_host_font_files(paths) {
|
|
441
|
+
const ptr0 = passArrayJsValueToWasm0(paths, wasm.__wbindgen_malloc);
|
|
442
|
+
const len0 = WASM_VECTOR_LEN;
|
|
443
|
+
wasm.engine_set_host_font_files(this.__wbg_ptr, ptr0, len0);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* The mode to render in, as `{"theme": "dark"}` (RFC-0037).
|
|
447
|
+
*
|
|
448
|
+
* It applies to every document read from here on, and only to the axes a
|
|
449
|
+
* document declares — asking for an axis it does not have changes
|
|
450
|
+
* nothing. A subtree that pins `mode-{axis}` keeps its own mode whatever
|
|
451
|
+
* is set here, so a light card stays light on a page turned dark.
|
|
452
|
+
*
|
|
453
|
+
* One axis at a time, because that is how a viewer uses it: a theme
|
|
454
|
+
* switch sets `theme`, and leaves `density` alone. `None` drops the axis
|
|
455
|
+
* and returns it to the document's own default.
|
|
456
|
+
* @param {string} axis
|
|
457
|
+
* @param {string | null} [value]
|
|
458
|
+
*/
|
|
459
|
+
set_mode(axis, value) {
|
|
460
|
+
const ptr0 = passStringToWasm0(axis, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
461
|
+
const len0 = WASM_VECTOR_LEN;
|
|
462
|
+
var ptr1 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
463
|
+
var len1 = WASM_VECTOR_LEN;
|
|
464
|
+
wasm.engine_set_mode(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* One render: the pixels, and the geometry a host needs to answer "what is
|
|
471
|
+
* under this point".
|
|
472
|
+
*/
|
|
473
|
+
export class Frame {
|
|
474
|
+
static __wrap(ptr) {
|
|
475
|
+
const obj = Object.create(Frame.prototype);
|
|
476
|
+
obj.__wbg_ptr = ptr;
|
|
477
|
+
FrameFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
478
|
+
return obj;
|
|
479
|
+
}
|
|
480
|
+
__destroy_into_raw() {
|
|
481
|
+
const ptr = this.__wbg_ptr;
|
|
482
|
+
this.__wbg_ptr = 0;
|
|
483
|
+
FrameFinalization.unregister(this);
|
|
484
|
+
return ptr;
|
|
485
|
+
}
|
|
486
|
+
free() {
|
|
487
|
+
const ptr = this.__destroy_into_raw();
|
|
488
|
+
wasm.__wbg_frame_free(ptr, 0);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* The density the frame was drawn at: the one asked for, or less when
|
|
492
|
+
* the page would not fit a canvas at it (see [`MAX_CANVAS_SIDE`]).
|
|
493
|
+
* @returns {number}
|
|
494
|
+
*/
|
|
495
|
+
get density() {
|
|
496
|
+
const ret = wasm.frame_density(this.__wbg_ptr);
|
|
497
|
+
return ret;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* @returns {number}
|
|
501
|
+
*/
|
|
502
|
+
get height() {
|
|
503
|
+
const ret = wasm.frame_height(this.__wbg_ptr);
|
|
504
|
+
return ret >>> 0;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The whole page's layout tree as JSON, in document pixels, with every
|
|
508
|
+
* node's attributes. The same for every frame of one page, so a host
|
|
509
|
+
* that already has it need not ask again.
|
|
510
|
+
* @returns {string}
|
|
511
|
+
*/
|
|
512
|
+
get layout() {
|
|
513
|
+
let deferred2_0;
|
|
514
|
+
let deferred2_1;
|
|
515
|
+
try {
|
|
516
|
+
const ret = wasm.frame_layout(this.__wbg_ptr);
|
|
517
|
+
var ptr1 = ret[0];
|
|
518
|
+
var len1 = ret[1];
|
|
519
|
+
if (ret[3]) {
|
|
520
|
+
ptr1 = 0; len1 = 0;
|
|
521
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
522
|
+
}
|
|
523
|
+
deferred2_0 = ptr1;
|
|
524
|
+
deferred2_1 = len1;
|
|
525
|
+
return getStringFromWasm0(ptr1, len1);
|
|
526
|
+
} finally {
|
|
527
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Straight RGBA, row by row: the bytes of an `ImageData` of
|
|
532
|
+
* `width` x `height`, ready for `putImageData` with no PNG in between.
|
|
533
|
+
* @returns {Uint8Array}
|
|
534
|
+
*/
|
|
535
|
+
get pixels() {
|
|
536
|
+
const ret = wasm.frame_pixels(this.__wbg_ptr);
|
|
537
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
538
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
539
|
+
return v1;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Fonts that did not resolve, and what was used instead.
|
|
543
|
+
* @returns {string[]}
|
|
544
|
+
*/
|
|
545
|
+
get warnings() {
|
|
546
|
+
const ret = wasm.frame_warnings(this.__wbg_ptr);
|
|
547
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
548
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
549
|
+
return v1;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* @returns {number}
|
|
553
|
+
*/
|
|
554
|
+
get width() {
|
|
555
|
+
const ret = wasm.frame_width(this.__wbg_ptr);
|
|
556
|
+
return ret >>> 0;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* The frame's left edge in the page's pixels at [`Frame::density`].
|
|
560
|
+
* @returns {number}
|
|
561
|
+
*/
|
|
562
|
+
get x() {
|
|
563
|
+
const ret = wasm.frame_x(this.__wbg_ptr);
|
|
564
|
+
return ret;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* The frame's top edge in the page's pixels at [`Frame::density`].
|
|
568
|
+
* @returns {number}
|
|
569
|
+
*/
|
|
570
|
+
get y() {
|
|
571
|
+
const ret = wasm.frame_y(this.__wbg_ptr);
|
|
572
|
+
return ret;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (Symbol.dispose) Frame.prototype[Symbol.dispose] = Frame.prototype.free;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @param {string} xml
|
|
579
|
+
* @returns {string}
|
|
580
|
+
*/
|
|
581
|
+
export function build_scene_json(xml) {
|
|
582
|
+
let deferred3_0;
|
|
583
|
+
let deferred3_1;
|
|
584
|
+
try {
|
|
585
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
587
|
+
const ret = wasm.build_scene_json(ptr0, len0);
|
|
588
|
+
var ptr2 = ret[0];
|
|
589
|
+
var len2 = ret[1];
|
|
590
|
+
if (ret[3]) {
|
|
591
|
+
ptr2 = 0; len2 = 0;
|
|
592
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
593
|
+
}
|
|
594
|
+
deferred3_0 = ptr2;
|
|
595
|
+
deferred3_1 = len2;
|
|
596
|
+
return getStringFromWasm0(ptr2, len2);
|
|
597
|
+
} finally {
|
|
598
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* @param {Uint8Array} _package
|
|
604
|
+
* @returns {string}
|
|
605
|
+
*/
|
|
606
|
+
export function build_scene_json_from_package(_package) {
|
|
607
|
+
let deferred3_0;
|
|
608
|
+
let deferred3_1;
|
|
609
|
+
try {
|
|
610
|
+
const ptr0 = passArray8ToWasm0(_package, wasm.__wbindgen_malloc);
|
|
611
|
+
const len0 = WASM_VECTOR_LEN;
|
|
612
|
+
const ret = wasm.build_scene_json_from_package(ptr0, len0);
|
|
613
|
+
var ptr2 = ret[0];
|
|
614
|
+
var len2 = ret[1];
|
|
615
|
+
if (ret[3]) {
|
|
616
|
+
ptr2 = 0; len2 = 0;
|
|
617
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
618
|
+
}
|
|
619
|
+
deferred3_0 = ptr2;
|
|
620
|
+
deferred3_1 = len2;
|
|
621
|
+
return getStringFromWasm0(ptr2, len2);
|
|
622
|
+
} finally {
|
|
623
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* @param {string} xml
|
|
629
|
+
* @returns {string}
|
|
630
|
+
*/
|
|
631
|
+
export function compute_layout_json(xml) {
|
|
632
|
+
let deferred3_0;
|
|
633
|
+
let deferred3_1;
|
|
634
|
+
try {
|
|
635
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
636
|
+
const len0 = WASM_VECTOR_LEN;
|
|
637
|
+
const ret = wasm.compute_layout_json(ptr0, len0);
|
|
638
|
+
var ptr2 = ret[0];
|
|
639
|
+
var len2 = ret[1];
|
|
640
|
+
if (ret[3]) {
|
|
641
|
+
ptr2 = 0; len2 = 0;
|
|
642
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
643
|
+
}
|
|
644
|
+
deferred3_0 = ptr2;
|
|
645
|
+
deferred3_1 = len2;
|
|
646
|
+
return getStringFromWasm0(ptr2, len2);
|
|
647
|
+
} finally {
|
|
648
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* @param {Uint8Array} _package
|
|
654
|
+
* @returns {string}
|
|
655
|
+
*/
|
|
656
|
+
export function compute_layout_json_from_package(_package) {
|
|
657
|
+
let deferred3_0;
|
|
658
|
+
let deferred3_1;
|
|
659
|
+
try {
|
|
660
|
+
const ptr0 = passArray8ToWasm0(_package, wasm.__wbindgen_malloc);
|
|
661
|
+
const len0 = WASM_VECTOR_LEN;
|
|
662
|
+
const ret = wasm.compute_layout_json_from_package(ptr0, len0);
|
|
663
|
+
var ptr2 = ret[0];
|
|
664
|
+
var len2 = ret[1];
|
|
665
|
+
if (ret[3]) {
|
|
666
|
+
ptr2 = 0; len2 = 0;
|
|
667
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
668
|
+
}
|
|
669
|
+
deferred3_0 = ptr2;
|
|
670
|
+
deferred3_1 = len2;
|
|
671
|
+
return getStringFromWasm0(ptr2, len2);
|
|
672
|
+
} finally {
|
|
673
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* The markup with presence attributes (`<frame clip>`) given values, so a
|
|
679
|
+
* strict XML parser — the browser's `DOMParser` — accepts what `.gui` allows.
|
|
680
|
+
* @param {string} xml
|
|
681
|
+
* @returns {string}
|
|
682
|
+
*/
|
|
683
|
+
export function normalize_markup(xml) {
|
|
684
|
+
let deferred2_0;
|
|
685
|
+
let deferred2_1;
|
|
686
|
+
try {
|
|
687
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
688
|
+
const len0 = WASM_VECTOR_LEN;
|
|
689
|
+
const ret = wasm.normalize_markup(ptr0, len0);
|
|
690
|
+
deferred2_0 = ret[0];
|
|
691
|
+
deferred2_1 = ret[1];
|
|
692
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
693
|
+
} finally {
|
|
694
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* @param {string} xml
|
|
700
|
+
* @returns {string}
|
|
701
|
+
*/
|
|
702
|
+
export function parse_gui_summary(xml) {
|
|
703
|
+
let deferred3_0;
|
|
704
|
+
let deferred3_1;
|
|
705
|
+
try {
|
|
706
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
707
|
+
const len0 = WASM_VECTOR_LEN;
|
|
708
|
+
const ret = wasm.parse_gui_summary(ptr0, len0);
|
|
709
|
+
var ptr2 = ret[0];
|
|
710
|
+
var len2 = ret[1];
|
|
711
|
+
if (ret[3]) {
|
|
712
|
+
ptr2 = 0; len2 = 0;
|
|
713
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
714
|
+
}
|
|
715
|
+
deferred3_0 = ptr2;
|
|
716
|
+
deferred3_1 = len2;
|
|
717
|
+
return getStringFromWasm0(ptr2, len2);
|
|
718
|
+
} finally {
|
|
719
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Reads a packaged `.gui` (a ZIP) from memory.
|
|
725
|
+
*
|
|
726
|
+
* This is the entry point to prefer in a browser: images and fonts inside the
|
|
727
|
+
* package resolve without any host I/O.
|
|
728
|
+
* @param {Uint8Array} _package
|
|
729
|
+
* @returns {string}
|
|
730
|
+
*/
|
|
731
|
+
export function parse_package_summary(_package) {
|
|
732
|
+
let deferred3_0;
|
|
733
|
+
let deferred3_1;
|
|
734
|
+
try {
|
|
735
|
+
const ptr0 = passArray8ToWasm0(_package, wasm.__wbindgen_malloc);
|
|
736
|
+
const len0 = WASM_VECTOR_LEN;
|
|
737
|
+
const ret = wasm.parse_package_summary(ptr0, len0);
|
|
738
|
+
var ptr2 = ret[0];
|
|
739
|
+
var len2 = ret[1];
|
|
740
|
+
if (ret[3]) {
|
|
741
|
+
ptr2 = 0; len2 = 0;
|
|
742
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
743
|
+
}
|
|
744
|
+
deferred3_0 = ptr2;
|
|
745
|
+
deferred3_1 = len2;
|
|
746
|
+
return getStringFromWasm0(ptr2, len2);
|
|
747
|
+
} finally {
|
|
748
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* @param {Uint8Array} _package
|
|
754
|
+
* @returns {Uint8Array}
|
|
755
|
+
*/
|
|
756
|
+
export function render_png_from_package(_package) {
|
|
757
|
+
const ptr0 = passArray8ToWasm0(_package, wasm.__wbindgen_malloc);
|
|
758
|
+
const len0 = WASM_VECTOR_LEN;
|
|
759
|
+
const ret = wasm.render_png_from_package(ptr0, len0);
|
|
760
|
+
if (ret[3]) {
|
|
761
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
762
|
+
}
|
|
763
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
764
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
765
|
+
return v2;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* @param {string} xml
|
|
770
|
+
* @returns {Uint8Array}
|
|
771
|
+
*/
|
|
772
|
+
export function render_png_from_xml(xml) {
|
|
773
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
774
|
+
const len0 = WASM_VECTOR_LEN;
|
|
775
|
+
const ret = wasm.render_png_from_xml(ptr0, len0);
|
|
776
|
+
if (ret[3]) {
|
|
777
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
778
|
+
}
|
|
779
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
780
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
781
|
+
return v2;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* This renderer's version, e.g. `0.3.1`. Its `major.minor` is the newest spec
|
|
786
|
+
* version it reads.
|
|
787
|
+
* @returns {string}
|
|
788
|
+
*/
|
|
789
|
+
export function renderer_version() {
|
|
790
|
+
let deferred1_0;
|
|
791
|
+
let deferred1_1;
|
|
792
|
+
try {
|
|
793
|
+
const ret = wasm.renderer_version();
|
|
794
|
+
deferred1_0 = ret[0];
|
|
795
|
+
deferred1_1 = ret[1];
|
|
796
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
797
|
+
} finally {
|
|
798
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* The newest spec version this renderer reads, e.g. `0.3`. A document
|
|
804
|
+
* declaring a newer one is refused.
|
|
805
|
+
* @returns {string}
|
|
806
|
+
*/
|
|
807
|
+
export function supported_spec_version() {
|
|
808
|
+
let deferred1_0;
|
|
809
|
+
let deferred1_1;
|
|
810
|
+
try {
|
|
811
|
+
const ret = wasm.supported_spec_version();
|
|
812
|
+
deferred1_0 = ret[0];
|
|
813
|
+
deferred1_1 = ret[1];
|
|
814
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
815
|
+
} finally {
|
|
816
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function __wbg_get_imports() {
|
|
820
|
+
const import0 = {
|
|
821
|
+
__proto__: null,
|
|
822
|
+
__wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
|
|
823
|
+
const obj = arg1;
|
|
824
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
825
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
826
|
+
var len1 = WASM_VECTOR_LEN;
|
|
827
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
828
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
829
|
+
},
|
|
830
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
831
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
832
|
+
},
|
|
833
|
+
__wbg_frame_new: function(arg0) {
|
|
834
|
+
const ret = Frame.__wrap(arg0);
|
|
835
|
+
return ret;
|
|
836
|
+
},
|
|
837
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
838
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
839
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
840
|
+
return ret;
|
|
841
|
+
},
|
|
842
|
+
__wbindgen_init_externref_table: function() {
|
|
843
|
+
const table = wasm.__wbindgen_externrefs;
|
|
844
|
+
const offset = table.grow(4);
|
|
845
|
+
table.set(0, undefined);
|
|
846
|
+
table.set(offset + 0, undefined);
|
|
847
|
+
table.set(offset + 1, null);
|
|
848
|
+
table.set(offset + 2, true);
|
|
849
|
+
table.set(offset + 3, false);
|
|
850
|
+
},
|
|
851
|
+
};
|
|
852
|
+
return {
|
|
853
|
+
__proto__: null,
|
|
854
|
+
"./dotgui_renderer_wasm_bg.js": import0,
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
859
|
+
? { register: () => {}, unregister: () => {} }
|
|
860
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr, 1));
|
|
861
|
+
const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
862
|
+
? { register: () => {}, unregister: () => {} }
|
|
863
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_frame_free(ptr, 1));
|
|
864
|
+
|
|
865
|
+
function addToExternrefTable0(obj) {
|
|
866
|
+
const idx = wasm.__externref_table_alloc();
|
|
867
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
868
|
+
return idx;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
872
|
+
ptr = ptr >>> 0;
|
|
873
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
877
|
+
ptr = ptr >>> 0;
|
|
878
|
+
const mem = getDataViewMemory0();
|
|
879
|
+
const result = [];
|
|
880
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
881
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
882
|
+
}
|
|
883
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
884
|
+
return result;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
888
|
+
ptr = ptr >>> 0;
|
|
889
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
let cachedDataViewMemory0 = null;
|
|
893
|
+
function getDataViewMemory0() {
|
|
894
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
895
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
896
|
+
}
|
|
897
|
+
return cachedDataViewMemory0;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
901
|
+
function getFloat32ArrayMemory0() {
|
|
902
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
903
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
904
|
+
}
|
|
905
|
+
return cachedFloat32ArrayMemory0;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function getStringFromWasm0(ptr, len) {
|
|
909
|
+
return decodeText(ptr >>> 0, len);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
let cachedUint8ArrayMemory0 = null;
|
|
913
|
+
function getUint8ArrayMemory0() {
|
|
914
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
915
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
916
|
+
}
|
|
917
|
+
return cachedUint8ArrayMemory0;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function isLikeNone(x) {
|
|
921
|
+
return x === undefined || x === null;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
925
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
926
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
927
|
+
WASM_VECTOR_LEN = arg.length;
|
|
928
|
+
return ptr;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
932
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
933
|
+
for (let i = 0; i < array.length; i++) {
|
|
934
|
+
const add = addToExternrefTable0(array[i]);
|
|
935
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
936
|
+
}
|
|
937
|
+
WASM_VECTOR_LEN = array.length;
|
|
938
|
+
return ptr;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
942
|
+
if (realloc === undefined) {
|
|
943
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
944
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
945
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
946
|
+
WASM_VECTOR_LEN = buf.length;
|
|
947
|
+
return ptr;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
let len = arg.length;
|
|
951
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
952
|
+
|
|
953
|
+
const mem = getUint8ArrayMemory0();
|
|
954
|
+
|
|
955
|
+
let offset = 0;
|
|
956
|
+
|
|
957
|
+
for (; offset < len; offset++) {
|
|
958
|
+
const code = arg.charCodeAt(offset);
|
|
959
|
+
if (code > 0x7F) break;
|
|
960
|
+
mem[ptr + offset] = code;
|
|
961
|
+
}
|
|
962
|
+
if (offset !== len) {
|
|
963
|
+
if (offset !== 0) {
|
|
964
|
+
arg = arg.slice(offset);
|
|
965
|
+
}
|
|
966
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
967
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
968
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
969
|
+
|
|
970
|
+
offset += ret.written;
|
|
971
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
WASM_VECTOR_LEN = offset;
|
|
975
|
+
return ptr;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function takeFromExternrefTable0(idx) {
|
|
979
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
980
|
+
wasm.__externref_table_dealloc(idx);
|
|
981
|
+
return value;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
985
|
+
cachedTextDecoder.decode();
|
|
986
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
987
|
+
let numBytesDecoded = 0;
|
|
988
|
+
function decodeText(ptr, len) {
|
|
989
|
+
numBytesDecoded += len;
|
|
990
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
991
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
992
|
+
cachedTextDecoder.decode();
|
|
993
|
+
numBytesDecoded = len;
|
|
994
|
+
}
|
|
995
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
const cachedTextEncoder = new TextEncoder();
|
|
999
|
+
|
|
1000
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1001
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1002
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1003
|
+
view.set(buf);
|
|
1004
|
+
return {
|
|
1005
|
+
read: arg.length,
|
|
1006
|
+
written: buf.length
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
let WASM_VECTOR_LEN = 0;
|
|
1012
|
+
|
|
1013
|
+
let wasmModule, wasmInstance, wasm;
|
|
1014
|
+
function __wbg_finalize_init(instance, module) {
|
|
1015
|
+
wasmInstance = instance;
|
|
1016
|
+
wasm = instance.exports;
|
|
1017
|
+
wasmModule = module;
|
|
1018
|
+
cachedDataViewMemory0 = null;
|
|
1019
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1020
|
+
cachedUint8ArrayMemory0 = null;
|
|
1021
|
+
wasm.__wbindgen_start();
|
|
1022
|
+
return wasm;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
async function __wbg_load(module, imports) {
|
|
1026
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1027
|
+
if (!module.ok) {
|
|
1028
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1032
|
+
try {
|
|
1033
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1034
|
+
} catch (e) {
|
|
1035
|
+
const validResponse = expectedResponseType(module.type);
|
|
1036
|
+
|
|
1037
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1038
|
+
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);
|
|
1039
|
+
|
|
1040
|
+
} else { throw e; }
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
const bytes = await module.arrayBuffer();
|
|
1045
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1046
|
+
} else {
|
|
1047
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1048
|
+
|
|
1049
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1050
|
+
return { instance, module };
|
|
1051
|
+
} else {
|
|
1052
|
+
return instance;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
function expectedResponseType(type) {
|
|
1057
|
+
switch (type) {
|
|
1058
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1059
|
+
}
|
|
1060
|
+
return false;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
function initSync(module) {
|
|
1065
|
+
if (wasm !== undefined) return wasm;
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
if (module !== undefined) {
|
|
1069
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1070
|
+
({module} = module)
|
|
1071
|
+
} else {
|
|
1072
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
const imports = __wbg_get_imports();
|
|
1077
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1078
|
+
module = new WebAssembly.Module(module);
|
|
1079
|
+
}
|
|
1080
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1081
|
+
return __wbg_finalize_init(instance, module);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
async function __wbg_init(module_or_path) {
|
|
1085
|
+
if (wasm !== undefined) return wasm;
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
if (module_or_path !== undefined) {
|
|
1089
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1090
|
+
({module_or_path} = module_or_path)
|
|
1091
|
+
} else {
|
|
1092
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
if (module_or_path === undefined) {
|
|
1097
|
+
module_or_path = new URL('dotgui_renderer_wasm_bg.wasm', import.meta.url);
|
|
1098
|
+
}
|
|
1099
|
+
const imports = __wbg_get_imports();
|
|
1100
|
+
|
|
1101
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1102
|
+
module_or_path = fetch(module_or_path);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1106
|
+
|
|
1107
|
+
return __wbg_finalize_init(instance, module);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
export { initSync, __wbg_init as default };
|