@docmentis/udoc-wasm 0.0.0-stage → 0.8.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.
Files changed (42) hide show
  1. package/LICENSE +434 -0
  2. package/README.md +53 -2
  3. package/dist/error.d.ts +16 -0
  4. package/dist/error.js +36 -0
  5. package/dist/font-fulfill.d.ts +92 -0
  6. package/dist/font-fulfill.js +203 -0
  7. package/dist/fonts/Caladea-Bold.ttf +0 -0
  8. package/dist/fonts/Caladea-BoldItalic.ttf +0 -0
  9. package/dist/fonts/Caladea-Italic.ttf +0 -0
  10. package/dist/fonts/Caladea-Regular.ttf +0 -0
  11. package/dist/fonts/Carlito-Bold.ttf +0 -0
  12. package/dist/fonts/Carlito-BoldItalic.ttf +0 -0
  13. package/dist/fonts/Carlito-Italic.ttf +0 -0
  14. package/dist/fonts/Carlito-Regular.ttf +0 -0
  15. package/dist/fonts/LICENSE-Liberation.txt +102 -0
  16. package/dist/fonts/LiberationMono-Bold.ttf +0 -0
  17. package/dist/fonts/LiberationMono-BoldItalic.ttf +0 -0
  18. package/dist/fonts/LiberationMono-Italic.ttf +0 -0
  19. package/dist/fonts/LiberationMono-Regular.ttf +0 -0
  20. package/dist/fonts/LiberationSans-Bold.ttf +0 -0
  21. package/dist/fonts/LiberationSans-BoldItalic.ttf +0 -0
  22. package/dist/fonts/LiberationSans-Italic.ttf +0 -0
  23. package/dist/fonts/LiberationSans-Regular.ttf +0 -0
  24. package/dist/fonts/LiberationSerif-Bold.ttf +0 -0
  25. package/dist/fonts/LiberationSerif-BoldItalic.ttf +0 -0
  26. package/dist/fonts/LiberationSerif-Italic.ttf +0 -0
  27. package/dist/fonts/LiberationSerif-Regular.ttf +0 -0
  28. package/dist/fonts/OFL-Caladea.txt +93 -0
  29. package/dist/fonts/OFL-Carlito.txt +94 -0
  30. package/dist/google-font-catalog.d.ts +21 -0
  31. package/dist/google-font-catalog.js +1860 -0
  32. package/dist/index.d.ts +58 -0
  33. package/dist/index.js +150 -0
  34. package/dist/meta-url.d.ts +3 -0
  35. package/dist/meta-url.js +46 -0
  36. package/dist/office-compatible-fonts.d.ts +3 -0
  37. package/dist/office-compatible-fonts.js +33 -0
  38. package/dist/wasm/THIRD-PARTY-NOTICES.txt +9395 -0
  39. package/dist/wasm/udoc.d.ts +20260 -0
  40. package/dist/wasm/udoc.js +4600 -0
  41. package/dist/wasm/udoc_bg.wasm +0 -0
  42. package/package.json +41 -5
@@ -0,0 +1,4600 @@
1
+ /* @ts-self-types="./udoc.d.ts" */
2
+
3
+ /**
4
+ * A font specimen returned by
5
+ * [`renderFontPreview`](WasmSession::render_font_preview): a PNG whose **alpha
6
+ * is the glyph coverage** (the color is flat black and carries nothing), plus
7
+ * the CSS box to draw it in.
8
+ *
9
+ * The host wraps the bytes in a `Blob`, points a CSS `mask-image` at the object
10
+ * URL, and gives the element `background: currentColor` — the specimen then
11
+ * inherits the theme's text color, and a light/dark switch needs no redraw. The
12
+ * PNG is rendered at the device pixel ratio behind [`width`](Self::width) ×
13
+ * [`height`](Self::height), so a mask sized to that box is sharp on a retina
14
+ * display.
15
+ */
16
+ export class FontPreviewImage {
17
+ static __wrap(ptr) {
18
+ const obj = Object.create(FontPreviewImage.prototype);
19
+ obj.__wbg_ptr = ptr;
20
+ FontPreviewImageFinalization.register(obj, obj.__wbg_ptr, obj);
21
+ return obj;
22
+ }
23
+ __destroy_into_raw() {
24
+ const ptr = this.__wbg_ptr;
25
+ this.__wbg_ptr = 0;
26
+ FontPreviewImageFinalization.unregister(this);
27
+ return ptr;
28
+ }
29
+ free() {
30
+ const ptr = this.__destroy_into_raw();
31
+ wasm.__wbg_fontpreviewimage_free(ptr, 0);
32
+ }
33
+ /**
34
+ * The transparent bleed baked into **every side**, in CSS px.
35
+ *
36
+ * The raster's left edge sits one of these left of where the pen started,
37
+ * because the box is grown all round to hold ink that overhangs the
38
+ * advances (an italic's ascender, a script face's tail). A host laying the
39
+ * specimen beside ordinary text at the same em offsets by `-bleed`, which
40
+ * puts the two pen origins in the same place.
41
+ * @returns {number}
42
+ */
43
+ get bleed() {
44
+ const ret = wasm.fontpreviewimage_bleed(this.__wbg_ptr);
45
+ return ret;
46
+ }
47
+ /**
48
+ * The specimen's height in **CSS px** — the box, not the PNG's pixels.
49
+ * @returns {number}
50
+ */
51
+ get height() {
52
+ const ret = wasm.fontpreviewimage_height(this.__wbg_ptr);
53
+ return ret;
54
+ }
55
+ /**
56
+ * Take the PNG bytes, leaving the image empty — call once. Moving avoids
57
+ * cloning the buffer before it crosses the wasm boundary as a
58
+ * `Uint8Array`.
59
+ * @returns {Uint8Array}
60
+ */
61
+ takePng() {
62
+ try {
63
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
64
+ wasm.fontpreviewimage_takePng(retptr, this.__wbg_ptr);
65
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
66
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
67
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
68
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
69
+ return v1;
70
+ } finally {
71
+ wasm.__wbindgen_add_to_stack_pointer(16);
72
+ }
73
+ }
74
+ /**
75
+ * The specimen's width in **CSS px** — the box, not the PNG's pixels.
76
+ * @returns {number}
77
+ */
78
+ get width() {
79
+ const ret = wasm.fontpreviewimage_width(this.__wbg_ptr);
80
+ return ret;
81
+ }
82
+ }
83
+ if (Symbol.dispose) FontPreviewImage.prototype[Symbol.dispose] = FontPreviewImage.prototype.free;
84
+
85
+ /**
86
+ * A rasterized page image returned by
87
+ * [`renderPageToRgba`](WasmSession::render_page_to_rgba): premultiplied RGBA8
88
+ * bytes (`width * height * 4`, row-major, Y-down, tightly packed) plus the
89
+ * pixel dimensions the renderer chose. The host reads `width`/`height`, pulls
90
+ * the pixels once via [`takeData`](PageImage::take_data) (which moves them out
91
+ * — call once), wraps them in an `ImageData`, and `createImageBitmap`s it.
92
+ */
93
+ export class PageImage {
94
+ static __wrap(ptr) {
95
+ const obj = Object.create(PageImage.prototype);
96
+ obj.__wbg_ptr = ptr;
97
+ PageImageFinalization.register(obj, obj.__wbg_ptr, obj);
98
+ return obj;
99
+ }
100
+ __destroy_into_raw() {
101
+ const ptr = this.__wbg_ptr;
102
+ this.__wbg_ptr = 0;
103
+ PageImageFinalization.unregister(this);
104
+ return ptr;
105
+ }
106
+ free() {
107
+ const ptr = this.__destroy_into_raw();
108
+ wasm.__wbg_pageimage_free(ptr, 0);
109
+ }
110
+ /**
111
+ * @returns {number}
112
+ */
113
+ get height() {
114
+ const ret = wasm.pageimage_height(this.__wbg_ptr);
115
+ return ret >>> 0;
116
+ }
117
+ /**
118
+ * Take the premultiplied RGBA8 pixels, leaving the image empty — call
119
+ * once. Moving avoids cloning the (sizable) buffer before it crosses the
120
+ * wasm boundary as a `Uint8Array`.
121
+ * @returns {Uint8Array}
122
+ */
123
+ takeData() {
124
+ try {
125
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
126
+ wasm.pageimage_takeData(retptr, this.__wbg_ptr);
127
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
128
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
129
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
130
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
131
+ return v1;
132
+ } finally {
133
+ wasm.__wbindgen_add_to_stack_pointer(16);
134
+ }
135
+ }
136
+ /**
137
+ * @returns {number}
138
+ */
139
+ get width() {
140
+ const ret = wasm.pageimage_width(this.__wbg_ptr);
141
+ return ret >>> 0;
142
+ }
143
+ }
144
+ if (Symbol.dispose) PageImage.prototype[Symbol.dispose] = PageImage.prototype.free;
145
+
146
+ /**
147
+ * The wasm-facing session host: owns the document [`UDocSession`] and its
148
+ * canvas, and forwards the worker's resize/scroll/zoom intents. See the
149
+ * module docs.
150
+ */
151
+ export class WasmSession {
152
+ static __wrap(ptr) {
153
+ const obj = Object.create(WasmSession.prototype);
154
+ obj.__wbg_ptr = ptr;
155
+ WasmSessionFinalization.register(obj, obj.__wbg_ptr, obj);
156
+ return obj;
157
+ }
158
+ __destroy_into_raw() {
159
+ const ptr = this.__wbg_ptr;
160
+ this.__wbg_ptr = 0;
161
+ WasmSessionFinalization.unregister(this);
162
+ return ptr;
163
+ }
164
+ free() {
165
+ const ptr = this.__destroy_into_raw();
166
+ wasm.__wbg_wasmsession_free(ptr, 0);
167
+ }
168
+ /**
169
+ * Follow `destination` — an outline item's or a link's: a named one
170
+ * resolves through the document's named destinations, the target page
171
+ * composes ahead, and the view lands as its view asks (§12.3.2, Table 149),
172
+ * each zoom set once for that page — the point a view lands, by
173
+ * `alignment` (`"top"`, the spec's own landing, `"center"`, `"bottom"` or
174
+ * `"nearest"`). Returns the view it landed by — a named
175
+ * destination's, resolved — so the host can tell whether the zoom was set;
176
+ * `undefined` for a name the document doesn't define or a page no longer
177
+ * in it. The resulting zoom and scroll ride back in the next
178
+ * [`view_state`](Self::view_state); the repaint happens on the next
179
+ * [`render_frame`](Self::render_frame).
180
+ *
181
+ * # Errors
182
+ * Returns a JS error if no document is open, it isn't a PDF,
183
+ * `destination` isn't a `Destination`, or `alignment` isn't one of the
184
+ * four names.
185
+ * @param {Destination} destination
186
+ * @param {ScrollAlignment} alignment
187
+ * @returns {DestinationView | undefined}
188
+ */
189
+ __portable_goToDestination(destination, alignment) {
190
+ try {
191
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
192
+ wasm.wasmsession___portable_goToDestination(retptr, this.__wbg_ptr, addBorrowedObject(destination), addBorrowedObject(alignment));
193
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
194
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
195
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
196
+ if (r2) {
197
+ throw takeObject(r1);
198
+ }
199
+ return takeObject(r0);
200
+ } finally {
201
+ wasm.__wbindgen_add_to_stack_pointer(16);
202
+ heap[stack_pointer++] = undefined;
203
+ heap[stack_pointer++] = undefined;
204
+ }
205
+ }
206
+ /**
207
+ * Run a hide action: hide each of `targets` — a hide action's `/T` — or
208
+ * show it where `hide` is `false`. Which annotations hide actions have
209
+ * hidden or shown is session state, held over their own flags as a
210
+ * layer's is; the composed pages recompose and repaint. Returns whether
211
+ * any annotation changed.
212
+ *
213
+ * # Errors
214
+ * Returns a JS error if no document is open, it isn't a PDF, or `targets`
215
+ * isn't a list of hide targets.
216
+ * @param {ActionHideTarget[]} targets
217
+ * @param {boolean} hide
218
+ * @returns {boolean}
219
+ */
220
+ __portable_hideAnnotations(targets, hide) {
221
+ try {
222
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
223
+ const ptr0 = passArrayJsValueToWasm0(targets, wasm.__wbindgen_export);
224
+ const len0 = WASM_VECTOR_LEN;
225
+ wasm.wasmsession___portable_hideAnnotations(retptr, this.__wbg_ptr, ptr0, len0, hide);
226
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
227
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
228
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
229
+ if (r2) {
230
+ throw takeObject(r1);
231
+ }
232
+ return r0 !== 0;
233
+ } finally {
234
+ wasm.__wbindgen_add_to_stack_pointer(16);
235
+ }
236
+ }
237
+ /**
238
+ * Serialize the annotation `annotation` on the model **page** `page` —
239
+ * both 32-char hex keys — or `undefined` when the page's annotations part
240
+ * doesn't list it. Loaded on first read, whether or not the page has
241
+ * composed — hence `&mut self`. The value a host builds an
242
+ * `UpdateAnnotations` command from: it reads an annotation here, changes
243
+ * what it edits, and sends the annotation back. A dump: the annotation
244
+ * whole, its appearance's artwork included.
245
+ *
246
+ * # Errors
247
+ * Returns a JS error if no document is open, it isn't a PDF, a key is not
248
+ * valid, the page's annotations part or the annotation fails to load, or
249
+ * serialization fails.
250
+ * @param {string} page
251
+ * @param {string} annotation
252
+ * @returns {Annotation | undefined}
253
+ */
254
+ __portable_model__page__annotation_dump(page, annotation) {
255
+ try {
256
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
257
+ const ptr0 = passStringToWasm0(page, wasm.__wbindgen_export, wasm.__wbindgen_export2);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ const ptr1 = passStringToWasm0(annotation, wasm.__wbindgen_export, wasm.__wbindgen_export2);
260
+ const len1 = WASM_VECTOR_LEN;
261
+ wasm.wasmsession___portable_model__page__annotation_dump(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
262
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
263
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
264
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
265
+ if (r2) {
266
+ throw takeObject(r1);
267
+ }
268
+ return takeObject(r0);
269
+ } finally {
270
+ wasm.__wbindgen_add_to_stack_pointer(16);
271
+ }
272
+ }
273
+ /**
274
+ * The rich contents of the annotation `annotation` on the model **page**
275
+ * `page` — both 32-char hex keys — as XHTML (`Annotation::rich_contents`):
276
+ * its `/RC` as the file wrote it or an edit set it, else its `/Contents`
277
+ * a paragraph a line. `undefined` when the page's annotations part doesn't
278
+ * list it, or it isn't loaded. What a host's comment popup shows, and
279
+ * edits into a `SetAnnotationRichContents` command.
280
+ *
281
+ * # Errors
282
+ * Returns a JS error if no document is open, it isn't a PDF, or a key is
283
+ * not valid.
284
+ * @param {string} page
285
+ * @param {string} annotation
286
+ * @returns {string | undefined}
287
+ */
288
+ __portable_model__page__annotation_richContents(page, annotation) {
289
+ try {
290
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
291
+ const ptr0 = passStringToWasm0(page, wasm.__wbindgen_export, wasm.__wbindgen_export2);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ptr1 = passStringToWasm0(annotation, wasm.__wbindgen_export, wasm.__wbindgen_export2);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ wasm.wasmsession___portable_model__page__annotation_richContents(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
296
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
297
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
298
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
299
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
300
+ if (r3) {
301
+ throw takeObject(r2);
302
+ }
303
+ let v3;
304
+ if (r0 !== 0) {
305
+ v3 = getStringFromWasm0(r0, r1).slice();
306
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
307
+ }
308
+ return v3;
309
+ } finally {
310
+ wasm.__wbindgen_add_to_stack_pointer(16);
311
+ }
312
+ }
313
+ /**
314
+ * Serialize the annotations part of the model **page** named by `id` (its
315
+ * 32-char hex key) — its `PageAnnotationList`: the ids of its annotations, in
316
+ * paint order — or `undefined` for a page not in the document. The part is
317
+ * reached through the page's `Page::annotations`, the page and the part
318
+ * loaded on first read, whether or not the page has composed — hence
319
+ * `&mut self` — so a host can list a document's comments without composing
320
+ * its pages, reading each through
321
+ * [`annotation(id).dump`](Self::__portable_model__page__annotation_dump).
322
+ *
323
+ * # Errors
324
+ * Returns a JS error if no document is open, it isn't a PDF, `id` is not a
325
+ * valid key, the part fails to load, or serialization fails.
326
+ * @param {string} id
327
+ * @returns {PageAnnotationList | undefined}
328
+ */
329
+ __portable_model__page_annotations_dump(id) {
330
+ try {
331
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
332
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ wasm.wasmsession___portable_model__page_annotations_dump(retptr, this.__wbg_ptr, ptr0, len0);
335
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
336
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
337
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
338
+ if (r2) {
339
+ throw takeObject(r1);
340
+ }
341
+ return takeObject(r0);
342
+ } finally {
343
+ wasm.__wbindgen_add_to_stack_pointer(16);
344
+ }
345
+ }
346
+ /**
347
+ * Serialize the portable document's **interactive form** — the catalog's
348
+ * `/AcroForm`: its terminal fields, each with its name, its type, its
349
+ * value and its widgets' ids — as JSON. Loaded on first read, hence
350
+ * `&mut self`; a document with no form gives one with no fields. A dump:
351
+ * the whole part, which a host reads to find the field a widget belongs
352
+ * to, and fills in with a `FillAcroFormFields` command.
353
+ *
354
+ * # Errors
355
+ * Returns a JS error if no document is open, it isn't a PDF, the form
356
+ * fails to load, or serialization fails.
357
+ * @returns {AcroForm}
358
+ */
359
+ __portable_model_acroForm_dump() {
360
+ try {
361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
362
+ wasm.wasmsession___portable_model_acroForm_dump(retptr, this.__wbg_ptr);
363
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
364
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
365
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
366
+ if (r2) {
367
+ throw takeObject(r1);
368
+ }
369
+ return takeObject(r0);
370
+ } finally {
371
+ wasm.__wbindgen_add_to_stack_pointer(16);
372
+ }
373
+ }
374
+ /**
375
+ * Serialize the portable document's **font list** — every font it has,
376
+ * each with its id, `/BaseFont`, type, and whether it is embedded, a subset
377
+ * or one of the standard 14 — as JSON. Walked on first read, hence
378
+ * `&mut self`; a font an edit added is in it too. A dump: the whole list,
379
+ * which a host reads to find the font a free text's `/DA` names before
380
+ * adding one with an `AddStandardFont` command.
381
+ *
382
+ * # Errors
383
+ * Returns a JS error if no document is open, it isn't a PDF, the font list
384
+ * fails to load, or serialization fails.
385
+ * @returns {FontInfoList}
386
+ */
387
+ __portable_model_fontInfoList_dump() {
388
+ try {
389
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
390
+ wasm.wasmsession___portable_model_fontInfoList_dump(retptr, this.__wbg_ptr);
391
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
392
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
393
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
394
+ if (r2) {
395
+ throw takeObject(r1);
396
+ }
397
+ return takeObject(r0);
398
+ } finally {
399
+ wasm.__wbindgen_add_to_stack_pointer(16);
400
+ }
401
+ }
402
+ /**
403
+ * Serialize the portable document's **optional content properties** —
404
+ * the catalog's `/OCProperties`: every group (its id, and the name a layers
405
+ * panel labels it with) and the configurations, the default one's `order`
406
+ * being the tree the panel shows. Loaded on
407
+ * first read, hence `&mut self`; a document with no layers gives no groups.
408
+ * A dump: the whole part.
409
+ *
410
+ * # Errors
411
+ * Returns a JS error if no document is open, it isn't a PDF, the
412
+ * properties fail to load, or serialization fails.
413
+ * @returns {OptionalContentProperties}
414
+ */
415
+ __portable_model_optionalContentProperties_dump() {
416
+ try {
417
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
418
+ wasm.wasmsession___portable_model_optionalContentProperties_dump(retptr, this.__wbg_ptr);
419
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
420
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
421
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
422
+ if (r2) {
423
+ throw takeObject(r1);
424
+ }
425
+ return takeObject(r0);
426
+ } finally {
427
+ wasm.__wbindgen_add_to_stack_pointer(16);
428
+ }
429
+ }
430
+ /**
431
+ * Serialize the portable document's **outline** — its bookmarks, the
432
+ * catalog's `/Outlines` — as JSON: every item with its title, action or
433
+ * destination, colour, style, open state and children. The part is loaded
434
+ * on first read, hence `&mut self`; a document with no outline gives one
435
+ * with no items. A dump: the whole tree.
436
+ *
437
+ * # Errors
438
+ * Returns a JS error if no document is open, it isn't a PDF, the outline
439
+ * fails to load, or serialization fails.
440
+ * @returns {Outline}
441
+ */
442
+ __portable_model_outline_dump() {
443
+ try {
444
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
445
+ wasm.wasmsession___portable_model_outline_dump(retptr, this.__wbg_ptr);
446
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
447
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
448
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
449
+ if (r2) {
450
+ throw takeObject(r1);
451
+ }
452
+ return takeObject(r0);
453
+ } finally {
454
+ wasm.__wbindgen_add_to_stack_pointer(16);
455
+ }
456
+ }
457
+ /**
458
+ * Serialize the portable document's whole **catalog** — each page's id,
459
+ * media box, rotation and annotations part — as JSON. One entry per page,
460
+ * so it grows with the document: a dump for looking inside, where a lookup
461
+ * is [`portable.model.root.pageIdByIndex`](Self::__portable_model_root_pageIdByIndex)
462
+ * / [`pageIndexById`](Self::__portable_model_root_pageIndexById).
463
+ *
464
+ * # Errors
465
+ * Returns a JS error if no document is open, it isn't a PDF, or
466
+ * serialization fails.
467
+ * @returns {Catalog}
468
+ */
469
+ __portable_model_root_dump() {
470
+ try {
471
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
472
+ wasm.wasmsession___portable_model_root_dump(retptr, this.__wbg_ptr);
473
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
474
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
475
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
476
+ if (r2) {
477
+ throw takeObject(r1);
478
+ }
479
+ return takeObject(r0);
480
+ } finally {
481
+ wasm.__wbindgen_add_to_stack_pointer(16);
482
+ }
483
+ }
484
+ /**
485
+ * The id (hex key) of the page at `index`, or `undefined` past the last
486
+ * page — how the host turns the page index it works in into the id an
487
+ * id-addressed command or selection takes.
488
+ *
489
+ * # Errors
490
+ * Returns a JS error if no document is open or it isn't a PDF.
491
+ * @param {number} index
492
+ * @returns {string | undefined}
493
+ */
494
+ __portable_model_root_pageIdByIndex(index) {
495
+ try {
496
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
497
+ wasm.wasmsession___portable_model_root_pageIdByIndex(retptr, this.__wbg_ptr, index);
498
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
499
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
500
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
501
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
502
+ if (r3) {
503
+ throw takeObject(r2);
504
+ }
505
+ let v1;
506
+ if (r0 !== 0) {
507
+ v1 = getStringFromWasm0(r0, r1).slice();
508
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
509
+ }
510
+ return v1;
511
+ } finally {
512
+ wasm.__wbindgen_add_to_stack_pointer(16);
513
+ }
514
+ }
515
+ /**
516
+ * The ids (hex keys) of the portable document's pages, in page order — the
517
+ * page list.
518
+ *
519
+ * # Errors
520
+ * Returns a JS error if no document is open or it isn't a PDF.
521
+ * @returns {string[]}
522
+ */
523
+ __portable_model_root_pageIds() {
524
+ try {
525
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
526
+ wasm.wasmsession___portable_model_root_pageIds(retptr, this.__wbg_ptr);
527
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
528
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
529
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
530
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
531
+ if (r3) {
532
+ throw takeObject(r2);
533
+ }
534
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
535
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
536
+ return v1;
537
+ } finally {
538
+ wasm.__wbindgen_add_to_stack_pointer(16);
539
+ }
540
+ }
541
+ /**
542
+ * The index of the page named by `id` (its hex key), or `undefined` for a
543
+ * page not in the document — the reverse of
544
+ * [`portable.model.root.pageIdByIndex`](Self::__portable_model_root_pageIdByIndex).
545
+ *
546
+ * # Errors
547
+ * Returns a JS error if no document is open, it isn't a PDF, or `id` is not
548
+ * a valid key.
549
+ * @param {string} id
550
+ * @returns {number | undefined}
551
+ */
552
+ __portable_model_root_pageIndexById(id) {
553
+ try {
554
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
555
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
556
+ const len0 = WASM_VECTOR_LEN;
557
+ wasm.wasmsession___portable_model_root_pageIndexById(retptr, this.__wbg_ptr, ptr0, len0);
558
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
559
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
560
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
561
+ if (r3) {
562
+ throw takeObject(r2);
563
+ }
564
+ return r0 === Number.MAX_SAFE_INTEGER ? undefined : r0;
565
+ } finally {
566
+ wasm.__wbindgen_add_to_stack_pointer(16);
567
+ }
568
+ }
569
+ /**
570
+ * The document's `/PageMode` — how it asks to be shown when it opens: the
571
+ * outline, the thumbnails, full screen, … — or `undefined` when the file
572
+ * gives none, which reads as `UseNone`.
573
+ *
574
+ * # Errors
575
+ * Returns a JS error if no document is open, it isn't a PDF, or
576
+ * serialization fails.
577
+ * @returns {PageMode | undefined}
578
+ */
579
+ __portable_model_root_pageMode() {
580
+ try {
581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
582
+ wasm.wasmsession___portable_model_root_pageMode(retptr, this.__wbg_ptr);
583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
585
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
586
+ if (r2) {
587
+ throw takeObject(r1);
588
+ }
589
+ return takeObject(r0);
590
+ } finally {
591
+ wasm.__wbindgen_add_to_stack_pointer(16);
592
+ }
593
+ }
594
+ /**
595
+ * The ids (hex keys) of the optional content groups that are **OFF** now;
596
+ * every other group is ON. Starts from the default configuration when the
597
+ * document opens and changes with
598
+ * [`portable.setOptionalContentGroupOn`](Self::__portable_setOptionalContentGroupOn).
599
+ *
600
+ * # Errors
601
+ * Returns a JS error if no document is open or it isn't a PDF.
602
+ * @returns {string[]}
603
+ */
604
+ __portable_optionalContentOff() {
605
+ try {
606
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
607
+ wasm.wasmsession___portable_optionalContentOff(retptr, this.__wbg_ptr);
608
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
609
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
610
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
611
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
612
+ if (r3) {
613
+ throw takeObject(r2);
614
+ }
615
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
616
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
617
+ return v1;
618
+ } finally {
619
+ wasm.__wbindgen_add_to_stack_pointer(16);
620
+ }
621
+ }
622
+ /**
623
+ * Switch the optional content group `id` (its hex key) ON or OFF, as a
624
+ * layers panel does: a locked group doesn't switch, and turning one ON
625
+ * turns the others of its radio groups OFF. The composed pages recompose
626
+ * and repaint. Returns whether any group changed.
627
+ *
628
+ * # Errors
629
+ * Returns a JS error if no document is open, it isn't a PDF, or `id` is
630
+ * not a valid key.
631
+ * @param {string} id
632
+ * @param {boolean} on
633
+ * @returns {boolean}
634
+ */
635
+ __portable_setOptionalContentGroupOn(id, on) {
636
+ try {
637
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
638
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
639
+ const len0 = WASM_VECTOR_LEN;
640
+ wasm.wasmsession___portable_setOptionalContentGroupOn(retptr, this.__wbg_ptr, ptr0, len0, on);
641
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
642
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
643
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
644
+ if (r2) {
645
+ throw takeObject(r1);
646
+ }
647
+ return r0 !== 0;
648
+ } finally {
649
+ wasm.__wbindgen_add_to_stack_pointer(16);
650
+ }
651
+ }
652
+ /**
653
+ * The elements of page `index` on the current plane that play media, each
654
+ * with its box in page-local points — what the host lays its players over.
655
+ * Empty for a page not composed, or one that plays nothing.
656
+ *
657
+ * # Errors
658
+ * Returns a JS error if no document is open, it isn't a presentation, or
659
+ * serialization fails.
660
+ * @param {number} index
661
+ * @returns {ComposedShapeMedia[]}
662
+ */
663
+ __presentation_layout__page_media(index) {
664
+ try {
665
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
666
+ wasm.wasmsession___presentation_layout__page_media(retptr, this.__wbg_ptr, index);
667
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
668
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
669
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
670
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
671
+ if (r3) {
672
+ throw takeObject(r2);
673
+ }
674
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
675
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
676
+ return v1;
677
+ } finally {
678
+ wasm.__wbindgen_add_to_stack_pointer(16);
679
+ }
680
+ }
681
+ /**
682
+ * The bytes of the media file `id` (a 32-char hex key) — the audio or
683
+ * video a player plays, as an element's `media.data` names it. Loaded on
684
+ * first read, the one part alone, hence `&mut self`.
685
+ *
686
+ * # Errors
687
+ * Returns a JS error if no document is open, it isn't a presentation, the
688
+ * key is not valid, or the part fails to load.
689
+ * @param {string} id
690
+ * @returns {Uint8Array}
691
+ */
692
+ __presentation_model__mediaData_bytes(id) {
693
+ try {
694
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
695
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
696
+ const len0 = WASM_VECTOR_LEN;
697
+ wasm.wasmsession___presentation_model__mediaData_bytes(retptr, this.__wbg_ptr, ptr0, len0);
698
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
699
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
700
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
701
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
702
+ if (r3) {
703
+ throw takeObject(r2);
704
+ }
705
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
706
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
707
+ return v2;
708
+ } finally {
709
+ wasm.__wbindgen_add_to_stack_pointer(16);
710
+ }
711
+ }
712
+ /**
713
+ * The content type of the media file `id` (a 32-char hex key), as the
714
+ * package declared it — `video/mp4`, `audio/mp4`, … — which the host
715
+ * hands its player with [the bytes](Self::__presentation_model__mediaData_bytes).
716
+ *
717
+ * # Errors
718
+ * Returns a JS error if no document is open, it isn't a presentation, the
719
+ * key is not valid, or the part fails to load.
720
+ * @param {string} id
721
+ * @returns {string}
722
+ */
723
+ __presentation_model__mediaData_contentType(id) {
724
+ let deferred3_0;
725
+ let deferred3_1;
726
+ try {
727
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
728
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
729
+ const len0 = WASM_VECTOR_LEN;
730
+ wasm.wasmsession___presentation_model__mediaData_contentType(retptr, this.__wbg_ptr, ptr0, len0);
731
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
732
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
733
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
734
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
735
+ var ptr2 = r0;
736
+ var len2 = r1;
737
+ if (r3) {
738
+ ptr2 = 0; len2 = 0;
739
+ throw takeObject(r2);
740
+ }
741
+ deferred3_0 = ptr2;
742
+ deferred3_1 = len2;
743
+ return getStringFromWasm0(ptr2, len2);
744
+ } finally {
745
+ wasm.__wbindgen_add_to_stack_pointer(16);
746
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
747
+ }
748
+ }
749
+ /**
750
+ * Every slide master, in `p:sldMasterIdLst` order, as a
751
+ * [`SlideMasterSummary`] — the roster the New-Slide picker enumerates.
752
+ * Ensures every slide master (loading it to learn its slide layouts), so
753
+ * the picker offers unused slide layouts too, and every slide layout, for
754
+ * its name — the ones the picker then renders a thumbnail of anyway —
755
+ * hence `&mut self`.
756
+ *
757
+ * # Errors
758
+ * Returns a JS error if no document is open, it isn't a presentation, or
759
+ * serialization fails.
760
+ * @returns {SlideMasterSummary[]}
761
+ */
762
+ __presentation_model_slideMasters_summary() {
763
+ try {
764
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
765
+ wasm.wasmsession___presentation_model_slideMasters_summary(retptr, this.__wbg_ptr);
766
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
767
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
768
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
769
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
770
+ if (r3) {
771
+ throw takeObject(r2);
772
+ }
773
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
774
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
775
+ return v1;
776
+ } finally {
777
+ wasm.__wbindgen_add_to_stack_pointer(16);
778
+ }
779
+ }
780
+ /**
781
+ * Load the sheet at tab position `plane` without showing it, so
782
+ * [`planeTabColor`](Self::plane_tab_color) can read its tab's colour —
783
+ * what the host's background walk over the sheets calls, one sheet a call.
784
+ * Returns whether the sheet is loaded: `false` past the last sheet, or for
785
+ * one that failed to load.
786
+ *
787
+ * # Errors
788
+ * Returns a JS error if no document is open or it isn't a spreadsheet.
789
+ * @param {number} plane
790
+ * @returns {boolean}
791
+ */
792
+ __spreadsheet_loadSheet(plane) {
793
+ try {
794
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
795
+ wasm.wasmsession___spreadsheet_loadSheet(retptr, this.__wbg_ptr, plane);
796
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
797
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
798
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
799
+ if (r2) {
800
+ throw takeObject(r1);
801
+ }
802
+ return r0 !== 0;
803
+ } finally {
804
+ wasm.__wbindgen_add_to_stack_pointer(16);
805
+ }
806
+ }
807
+ /**
808
+ * The id (hex key) of the sheet at tab position `index`, or `undefined`
809
+ * past the last sheet — how the host turns the plane it works in (a plane
810
+ * is a sheet, in tab order) into the id an id-addressed command takes.
811
+ *
812
+ * # Errors
813
+ * Returns a JS error if no document is open or it isn't a spreadsheet.
814
+ * @param {number} index
815
+ * @returns {string | undefined}
816
+ */
817
+ __spreadsheet_model_root_sheetIdByIndex(index) {
818
+ try {
819
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
820
+ wasm.wasmsession___spreadsheet_model_root_sheetIdByIndex(retptr, this.__wbg_ptr, index);
821
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
822
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
823
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
824
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
825
+ if (r3) {
826
+ throw takeObject(r2);
827
+ }
828
+ let v1;
829
+ if (r0 !== 0) {
830
+ v1 = getStringFromWasm0(r0, r1).slice();
831
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
832
+ }
833
+ return v1;
834
+ } finally {
835
+ wasm.__wbindgen_add_to_stack_pointer(16);
836
+ }
837
+ }
838
+ /**
839
+ * Follow a link to bookmark `name` (`w:hyperlink@w:anchor`): the view
840
+ * lands on the bookmark's start, the point placed by `alignment`
841
+ * (`"top"`, `"center"`, `"bottom"` or `"nearest"`) — or on the document's
842
+ * start where no bookmark has the name, which is where ECMA-376 §17.16.22
843
+ * has such a link go. The resulting scroll rides back in the next
844
+ * [`view_state`](Self::view_state); the repaint happens on the next
845
+ * [`render_frame`](Self::render_frame).
846
+ *
847
+ * # Errors
848
+ * Returns a JS error if no document is open, it isn't a word-processing
849
+ * document, `alignment` isn't one of the four names, or laying the
850
+ * document out to the bookmark fails.
851
+ * @param {string} name
852
+ * @param {ScrollAlignment} alignment
853
+ */
854
+ __wordprocessing_goToBookmark(name, alignment) {
855
+ try {
856
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
857
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
858
+ const len0 = WASM_VECTOR_LEN;
859
+ wasm.wasmsession___wordprocessing_goToBookmark(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(alignment));
860
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
861
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
862
+ if (r1) {
863
+ throw takeObject(r0);
864
+ }
865
+ } finally {
866
+ wasm.__wbindgen_add_to_stack_pointer(16);
867
+ heap[stack_pointer++] = undefined;
868
+ }
869
+ }
870
+ /**
871
+ * Attach the (already transferred) `OffscreenCanvas` this session paints
872
+ * into — the browser viewport path. A headless host never calls this.
873
+ *
874
+ * # Errors
875
+ * Returns a JS error if a 2D context can't be obtained.
876
+ * @param {OffscreenCanvas} canvas
877
+ */
878
+ attach(canvas) {
879
+ try {
880
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
881
+ wasm.wasmsession_attach(retptr, this.__wbg_ptr, addHeapObject(canvas));
882
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
883
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
884
+ if (r1) {
885
+ throw takeObject(r0);
886
+ }
887
+ } finally {
888
+ wasm.__wbindgen_add_to_stack_pointer(16);
889
+ }
890
+ }
891
+ /**
892
+ * Unlock the document that [`needsPassword`](Self::needs_password) with
893
+ * `password` — its user or its owner password. Returns `true` once it is
894
+ * open, the host then pulling the layout as after [`open`](Self::open),
895
+ * and `false` when `password` is rejected, the document waiting for
896
+ * another.
897
+ *
898
+ * Not a second open: the document was opened, and this session's permit
899
+ * spent, by [`open`](Self::open).
900
+ *
901
+ * # Errors
902
+ * Returns a JS error if no document is open, its encryption is one this
903
+ * build can't unlock, or it fails to open once unlocked.
904
+ * @param {string} password
905
+ * @returns {boolean}
906
+ */
907
+ authenticate(password) {
908
+ try {
909
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
910
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
911
+ const len0 = WASM_VECTOR_LEN;
912
+ wasm.wasmsession_authenticate(retptr, this.__wbg_ptr, ptr0, len0);
913
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
914
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
915
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
916
+ if (r2) {
917
+ throw takeObject(r1);
918
+ }
919
+ return r0 !== 0;
920
+ } finally {
921
+ wasm.__wbindgen_add_to_stack_pointer(16);
922
+ }
923
+ }
924
+ /**
925
+ * The brand decal's CSS-px rect as `[x, y, width, height]`, or empty before
926
+ * a viewport is known. Screen-fixed (bottom-right), so it changes only with
927
+ * the viewport size, density, or [inset](Self::set_branding_inset) — the
928
+ * host places a click target over it for the attribution link. The same box
929
+ * [`render_frame`](Self::render_frame) paints the mark into.
930
+ * @returns {Float64Array}
931
+ */
932
+ brandingRect() {
933
+ try {
934
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
935
+ wasm.wasmsession_brandingRect(retptr, this.__wbg_ptr);
936
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
937
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
938
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
939
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
940
+ return v1;
941
+ } finally {
942
+ wasm.__wbindgen_add_to_stack_pointer(16);
943
+ }
944
+ }
945
+ /**
946
+ * Whether a [`redo`](Self::redo) would do anything (see
947
+ * [`canUndo`](Self::can_undo)).
948
+ * @returns {boolean}
949
+ */
950
+ canRedo() {
951
+ const ret = wasm.wasmsession_canRedo(this.__wbg_ptr);
952
+ return ret !== 0;
953
+ }
954
+ /**
955
+ * Whether an [`undo`](Self::undo) would do anything — the host's cue to
956
+ * enable/disable its undo control. `false` when no document is open or the
957
+ * doc type has no undo stack. The worker re-reads this after every edit and
958
+ * pushes it to the host (see the `history` report).
959
+ * @returns {boolean}
960
+ */
961
+ canUndo() {
962
+ const ret = wasm.wasmsession_canUndo(this.__wbg_ptr);
963
+ return ret !== 0;
964
+ }
965
+ /**
966
+ * Stop drawing the page border — what a host does when the pages touch,
967
+ * where the frame would only rule a line between them. Remembered across
968
+ * [`open`](Self::open) like the color, and applied to the current document
969
+ * immediately; the next [`render_frame`](Self::render_frame) repaints
970
+ * without it. [`setPageBorderColor`](Self::set_page_border_color) draws it
971
+ * again.
972
+ */
973
+ clearPageBorder() {
974
+ wasm.wasmsession_clearPageBorder(this.__wbg_ptr);
975
+ }
976
+ /**
977
+ * Delete this peer's pointer — the pointer left the view, or sharing it
978
+ * stopped. Returns the blob carrying the deletion, as
979
+ * [`setPointer`](Self::set_pointer) does.
980
+ *
981
+ * # Errors
982
+ * Returns a JS error if the session is not entitled to collaboration, no
983
+ * document is open, or serialization fails.
984
+ * @returns {Uint8Array}
985
+ */
986
+ clearPointer() {
987
+ try {
988
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
989
+ wasm.wasmsession_clearPointer(retptr, this.__wbg_ptr);
990
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
991
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
992
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
993
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
994
+ if (r3) {
995
+ throw takeObject(r2);
996
+ }
997
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
998
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
999
+ return v1;
1000
+ } finally {
1001
+ wasm.__wbindgen_add_to_stack_pointer(16);
1002
+ }
1003
+ }
1004
+ /**
1005
+ * Clear the selection, returning the (empty) geometry.
1006
+ *
1007
+ * # Errors
1008
+ * Returns a JS error only if the new geometry can't be serialized — never
1009
+ * in practice for these plain page-anchored boxes.
1010
+ * @returns {SelectionGeometry}
1011
+ */
1012
+ clearSelection() {
1013
+ try {
1014
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1015
+ wasm.wasmsession_clearSelection(retptr, this.__wbg_ptr);
1016
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1017
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1018
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1019
+ if (r2) {
1020
+ throw takeObject(r1);
1021
+ }
1022
+ return takeObject(r0);
1023
+ } finally {
1024
+ wasm.__wbindgen_add_to_stack_pointer(16);
1025
+ }
1026
+ }
1027
+ /**
1028
+ * Release the open document — its model, composed layout, editor, and
1029
+ * viewer all go with it — keeping the canvas attached.
1030
+ *
1031
+ * This does **not** free the session for another document: its permit was
1032
+ * spent on the document being released, so [`open`](Self::open) stays
1033
+ * refused afterwards. Closing is how a host clears the screen while
1034
+ * keeping the canvas it transferred; the next file needs a new session.
1035
+ *
1036
+ * Clears the canvas on the way out: the painted pixels belong to the
1037
+ * document being released, and [`renderFrame`](Self::render_frame) has
1038
+ * nothing to draw without a session, so without this the closed document
1039
+ * would stay on screen.
1040
+ */
1041
+ close() {
1042
+ wasm.wasmsession_close(this.__wbg_ptr);
1043
+ }
1044
+ /**
1045
+ * Settle order `id` with the binaries fetched for it — **`[]` means "I have
1046
+ * nothing"**, and either way that this order is finished.
1047
+ *
1048
+ * A 404, a css2 response with no covering block, and giving up after three
1049
+ * retries are the same event: those characters are recorded as unavailable
1050
+ * from that vendor and the next layout tries the next one down the chain. To
1051
+ * retry instead, simply don't call this until you have stopped trying — the
1052
+ * order stays open and the document renders in the stand-in meanwhile.
1053
+ *
1054
+ * Returns whether `id` named a live order; `false` for a stale one (a
1055
+ * doc-type switch rebuilt the session while the fetch was out), which is
1056
+ * exactly when there is nothing to re-render.
1057
+ * @param {bigint} id
1058
+ * @param {Uint8Array[]} binaries
1059
+ * @returns {boolean}
1060
+ */
1061
+ completeFontRequest(id, binaries) {
1062
+ const ptr0 = passArrayJsValueToWasm0(binaries, wasm.__wbindgen_export);
1063
+ const len0 = WASM_VECTOR_LEN;
1064
+ const ret = wasm.wasmsession_completeFontRequest(this.__wbg_ptr, id, ptr0, len0);
1065
+ return ret !== 0;
1066
+ }
1067
+ /**
1068
+ * How many pages have been composed so far. Grows as composition advances
1069
+ * (see [`updateLayout`](Self::update_layout)) and changes on a
1070
+ * page-inserting or -deleting edit, so the host re-pulls it after either.
1071
+ * It is the document's page count once `updateLayout` reports complete.
1072
+ * `0` when no document is open or the doc type has no pagination. The
1073
+ * companion content extent rides the per-frame
1074
+ * [`viewState`](Self::view_state) (indices 3–4).
1075
+ * @returns {number}
1076
+ */
1077
+ composedPageCount() {
1078
+ const ret = wasm.wasmsession_composedPageCount(this.__wbg_ptr);
1079
+ return ret >>> 0;
1080
+ }
1081
+ /**
1082
+ * The camera as `[a, b, c, d, e, f]` (PDF/SVG order): content space
1083
+ * (document points) → **CSS px** under the current scroll/zoom.
1084
+ * Composed with [`pageToContent`](Self::page_to_content) it projects a
1085
+ * page- (or, with a node's local transform, node-) anchored HTML
1086
+ * overlay onto the canvas; its inverse maps a pointer back to content
1087
+ * space. The viewer's own camera lands in device px; this divides the
1088
+ * dpr back out so the DOM-facing contract stays CSS px. Empty when no
1089
+ * document is open.
1090
+ * @returns {Float64Array}
1091
+ */
1092
+ contentToViewport() {
1093
+ try {
1094
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1095
+ wasm.wasmsession_contentToViewport(retptr, this.__wbg_ptr);
1096
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1097
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1098
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
1099
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
1100
+ return v1;
1101
+ } finally {
1102
+ wasm.__wbindgen_add_to_stack_pointer(16);
1103
+ }
1104
+ }
1105
+ /**
1106
+ * The current selection as a [`UDocFragment`] for the system clipboard — the
1107
+ * host writes its JSON as our own custom flavor and projects the other
1108
+ * flavors from it (see [`plainText`](Self::plain_text) for `text/plain`),
1109
+ * then hands it back to [`paste`](Self::paste). A pure read: no CRDT write,
1110
+ * not undoable. `undefined` when no document is open or nothing copyable is
1111
+ * selected, so the host leaves the clipboard untouched.
1112
+ *
1113
+ * [`UDocFragment`]: docmentis_udoc_facade::UDocFragment
1114
+ * @returns {UDocFragment | undefined}
1115
+ */
1116
+ copy() {
1117
+ const ret = wasm.wasmsession_copy(this.__wbg_ptr);
1118
+ return takeObject(ret);
1119
+ }
1120
+ /**
1121
+ * The current plane — the active sheet of a spreadsheet (0-based); `0`
1122
+ * for a single-plane doc type, and `0` when no document is open.
1123
+ * @returns {number}
1124
+ */
1125
+ currentPlane() {
1126
+ const ret = wasm.wasmsession_currentPlane(this.__wbg_ptr);
1127
+ return ret >>> 0;
1128
+ }
1129
+ /**
1130
+ * Which doc type is open (`"portable"`, `"presentation"`, …), or
1131
+ * `undefined` when nothing is — the tag a host puts on a
1132
+ * [`UDocSelectionEdit`], and its cue for a doc-type-appropriate default
1133
+ * fit (fit-width for paged text, fit-page for slides and images).
1134
+ * @returns {UDocType | undefined}
1135
+ */
1136
+ docType() {
1137
+ const ret = wasm.wasmsession_docType(this.__wbg_ptr);
1138
+ return takeObject(ret);
1139
+ }
1140
+ /**
1141
+ * What this session was granted, for the host's own UI. Advisory: the
1142
+ * entitlements are enforced at the calls they guard, so a host that
1143
+ * ignores this is refused rather than obeyed.
1144
+ *
1145
+ * # Errors
1146
+ * If the value can't be serialized.
1147
+ * @returns {Entitlements}
1148
+ */
1149
+ entitlements() {
1150
+ try {
1151
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1152
+ wasm.wasmsession_entitlements(retptr, this.__wbg_ptr);
1153
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1154
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1155
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1156
+ if (r2) {
1157
+ throw takeObject(r1);
1158
+ }
1159
+ return takeObject(r0);
1160
+ } finally {
1161
+ wasm.__wbindgen_add_to_stack_pointer(16);
1162
+ }
1163
+ }
1164
+ /**
1165
+ * Execute one edit, given as a [`UDocCommand`] object — the single
1166
+ * edit seam every document mutation crosses, replacing the old per-verb
1167
+ * wall. Page ops address by index, object/content ops by id (see the
1168
+ * command's own docs); the host builds the command, e.g.
1169
+ * `{"portable":{"insertPage":{"index":0}}}`. Relayouts, so the host's
1170
+ * follow-up [`composedPageCount`](Self::composed_page_count) /
1171
+ * [`viewState`](Self::view_state) pulls see the edit.
1172
+ *
1173
+ * # Errors
1174
+ * Returns a JS error if the session is not entitled to the feature the
1175
+ * command needs, no document is open, the JSON isn't a valid command, it
1176
+ * doesn't match the open doc type, or the edit fails.
1177
+ * @param {UDocCommand} command
1178
+ */
1179
+ execute(command) {
1180
+ try {
1181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1182
+ wasm.wasmsession_execute(retptr, this.__wbg_ptr, addBorrowedObject(command));
1183
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1184
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1185
+ if (r1) {
1186
+ throw takeObject(r0);
1187
+ }
1188
+ } finally {
1189
+ wasm.__wbindgen_add_to_stack_pointer(16);
1190
+ heap[stack_pointer++] = undefined;
1191
+ }
1192
+ }
1193
+ /**
1194
+ * Apply a selection-relative edit to the current selection — a doc-type-tagged
1195
+ * [`UDocSelectionEdit`] (`{"portable":{"object":{"edit":"deleteObjects"}}}`), the ribbon/canvas
1196
+ * edit tagged with the open format. The editor binds it to the live
1197
+ * selection's ids and the matching command (a portable object command, a
1198
+ * presentation shape command, …). The typed twin of [`execute`](Self::execute)
1199
+ * / [`setSelection`](Self::set_selection): the caller emits the format-blind
1200
+ * inner edit and the boundary tags it, replacing the old worker-side
1201
+ * `runOnSelection`. A committing edit (one undo step); relayouts like
1202
+ * [`execute`](Self::execute), and the worker re-posts the selection after.
1203
+ *
1204
+ * # Errors
1205
+ * Returns a JS error if the session is not entitled to the feature the
1206
+ * edit needs, no document is open, the payload isn't a valid edit for the
1207
+ * open doc type, or the bound command fails.
1208
+ *
1209
+ * [`UDocSelectionEdit`]: docmentis_udoc_facade::UDocSelectionEdit
1210
+ * @param {UDocSelectionEdit} edit
1211
+ */
1212
+ executeOnSelection(edit) {
1213
+ try {
1214
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1215
+ wasm.wasmsession_executeOnSelection(retptr, this.__wbg_ptr, addBorrowedObject(edit));
1216
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1217
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1218
+ if (r1) {
1219
+ throw takeObject(r0);
1220
+ }
1221
+ } finally {
1222
+ wasm.__wbindgen_add_to_stack_pointer(16);
1223
+ heap[stack_pointer++] = undefined;
1224
+ }
1225
+ }
1226
+ /**
1227
+ * Export page `page_index` on `plane` as `format` — `{ png: { scale } }`
1228
+ * (1.0 == 1 output pixel per document point, i.e. 72 DPI) — and return the
1229
+ * encoded bytes. `plane` is `0` for a single-plane doc type and a
1230
+ * presentation's slide plane; `1..` addresses a slide-master's layout plane.
1231
+ *
1232
+ * The encoded counterpart to
1233
+ * [`render_page_to_rgba`](Self::render_page_to_rgba): it hands back a
1234
+ * ready-to-write file rather than raw pixels a JS host must encode, so a
1235
+ * Node backend needs no PNG encoder of its own. Like it, a CPU render into
1236
+ * a fresh pixmap, independent of any attached viewport canvas. Plane-leading
1237
+ * and required, matching the facade session's
1238
+ * `export_page_to_bytes(plane, page_index, ..)`.
1239
+ *
1240
+ * # Errors
1241
+ * Returns a JS error if `format` isn't a format this build knows, no
1242
+ * document is open, the page index is out of the composed range,
1243
+ * rasterization / encoding fails, or exporting to `format` isn't built yet.
1244
+ * @param {number} plane
1245
+ * @param {number} page_index
1246
+ * @param {PageExportFormat} format
1247
+ * @returns {Uint8Array}
1248
+ */
1249
+ exportPageToBytes(plane, page_index, format) {
1250
+ try {
1251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1252
+ wasm.wasmsession_exportPageToBytes(retptr, this.__wbg_ptr, plane, page_index, addBorrowedObject(format));
1253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1256
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1257
+ if (r3) {
1258
+ throw takeObject(r2);
1259
+ }
1260
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1261
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1262
+ return v1;
1263
+ } finally {
1264
+ wasm.__wbindgen_add_to_stack_pointer(16);
1265
+ heap[stack_pointer++] = undefined;
1266
+ }
1267
+ }
1268
+ /**
1269
+ * Export the whole open document as `format` — a rendering of its
1270
+ * laid-out pages, fixed and one-way.
1271
+ *
1272
+ * # Errors
1273
+ * Returns a JS error if `format` isn't a format this build knows, no
1274
+ * document is open, or — until PDF export is built — always.
1275
+ * @param {ExportFormat} format
1276
+ * @returns {Uint8Array}
1277
+ */
1278
+ exportToBytes(format) {
1279
+ try {
1280
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1281
+ wasm.wasmsession_exportToBytes(retptr, this.__wbg_ptr, addBorrowedObject(format));
1282
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1283
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1284
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1285
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1286
+ if (r3) {
1287
+ throw takeObject(r2);
1288
+ }
1289
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1290
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1291
+ return v1;
1292
+ } finally {
1293
+ wasm.__wbindgen_add_to_stack_pointer(16);
1294
+ heap[stack_pointer++] = undefined;
1295
+ }
1296
+ }
1297
+ /**
1298
+ * Every font family available to the open document, sorted by name, with its
1299
+ * faces grouped under it — the whole picker dropdown, so a row renders with
1300
+ * bold and italic enabled or greyed out. `[]` when no document is open or the
1301
+ * doc type has no text font registry (PDF composes its own embedded font
1302
+ * programs; an image carries no text). A pure read.
1303
+ *
1304
+ * Carries each family's faces, for a picker that greys out bold and italic
1305
+ * per family; [`fontFamilySummaries`](Self::font_family_summaries) is the
1306
+ * same list without them, and is what a picker that only lists families
1307
+ * should read.
1308
+ *
1309
+ * Availability is all the host gets: a family still downloading is listed
1310
+ * like any other, since picking it shapes in a stand-in at once and re-shapes
1311
+ * when its binary lands.
1312
+ *
1313
+ * # Errors
1314
+ *
1315
+ * If the family list can't be serialized.
1316
+ * @returns {FontFamily[]}
1317
+ */
1318
+ fontFamilies() {
1319
+ try {
1320
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1321
+ wasm.wasmsession_fontFamilies(retptr, this.__wbg_ptr);
1322
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1323
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1324
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1325
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1326
+ if (r3) {
1327
+ throw takeObject(r2);
1328
+ }
1329
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1330
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
1331
+ return v1;
1332
+ } finally {
1333
+ wasm.__wbindgen_add_to_stack_pointer(16);
1334
+ }
1335
+ }
1336
+ /**
1337
+ * Every font family available, sorted by name, with its `sourceType` and
1338
+ * **without** its faces — the picker's list. `[]` when no document is open
1339
+ * or the doc type has no text font registry.
1340
+ *
1341
+ * The same families [`fontFamilies`](Self::font_families) reports, and the
1342
+ * read to prefer whenever the faces aren't wanted. A picker draws a row per
1343
+ * family and needs two things: what to call it, and which vendor it comes
1344
+ * from — the latter deciding whether the browser can load the family into
1345
+ * its own text stack (`Local` / `Url` / `Google`) or the row has to go
1346
+ * through [`renderFontPreview`](Self::render_font_preview). At ~1800
1347
+ * families the faces are three quarters of the payload, and the
1348
+ * `FontEntryId`s in them are process-local, so they cross for nothing.
1349
+ *
1350
+ * # Errors
1351
+ *
1352
+ * If the list can't be serialized.
1353
+ * @returns {FontFamilySummary[]}
1354
+ */
1355
+ fontFamilySummaries() {
1356
+ try {
1357
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1358
+ wasm.wasmsession_fontFamilySummaries(retptr, this.__wbg_ptr);
1359
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1360
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1361
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1362
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1363
+ if (r3) {
1364
+ throw takeObject(r2);
1365
+ }
1366
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1367
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
1368
+ return v1;
1369
+ } finally {
1370
+ wasm.__wbindgen_add_to_stack_pointer(16);
1371
+ }
1372
+ }
1373
+ /**
1374
+ * The phase breakdown (ms) of the most recent painted frame — the host
1375
+ * reads this after a painted [`render_frame`](Self::render_frame) while the
1376
+ * perf toggle is on. All zero when timing is off.
1377
+ *
1378
+ * # Errors
1379
+ * Returns a JS error only if the timings can't be serialized — never in
1380
+ * practice for this plain four-`f64` struct.
1381
+ * @returns {FrameTimings}
1382
+ */
1383
+ frameTimings() {
1384
+ try {
1385
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1386
+ wasm.wasmsession_frameTimings(retptr, this.__wbg_ptr);
1387
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1388
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1389
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1390
+ if (r2) {
1391
+ throw takeObject(r1);
1392
+ }
1393
+ return takeObject(r0);
1394
+ } finally {
1395
+ wasm.__wbindgen_add_to_stack_pointer(16);
1396
+ }
1397
+ }
1398
+ /**
1399
+ * Whether the open document came from a udoc package rather than a file
1400
+ * imported here — which `sourceFormat` alone can't tell, since a package
1401
+ * reports the format it recorded. `false` when nothing is open.
1402
+ * @returns {boolean}
1403
+ */
1404
+ fromPackage() {
1405
+ const ret = wasm.wasmsession_fromPackage(this.__wbg_ptr);
1406
+ return ret !== 0;
1407
+ }
1408
+ /**
1409
+ * Scroll so page `index` (0-based) is brought to the top of the viewport —
1410
+ * the "go to page N" intent behind the page-number control. Composes the
1411
+ * target page first (the stack composes lazily), so a far jump arranges
1412
+ * it before the camera moves; in spread mode it shows the page's spread. The resulting clamped scroll and centered page ride back to the
1413
+ * host in the next [`view_state`](Self::view_state). A no-op when no
1414
+ * document is open. The repaint happens on the next
1415
+ * [`render_frame`](Self::render_frame).
1416
+ * @param {number} index
1417
+ */
1418
+ goToPage(index) {
1419
+ wasm.wasmsession_goToPage(this.__wbg_ptr, index);
1420
+ }
1421
+ /**
1422
+ * Switch the current plane — the active sheet of a multi-sheet
1423
+ * spreadsheet (0-based). Resets the view to the new sheet's top; its
1424
+ * content lands on the next [`render_frame`](Self::render_frame). A no-op
1425
+ * when no document is open or for a single-plane doc type (its only plane
1426
+ * is `0`). Read [`planeCount`](Self::plane_count) for the bound and
1427
+ * [`currentPlane`](Self::current_plane) for the active one.
1428
+ * @param {number} plane
1429
+ */
1430
+ goToPlane(plane) {
1431
+ wasm.wasmsession_goToPlane(this.__wbg_ptr, plane);
1432
+ }
1433
+ /**
1434
+ * Bring the rect `x0`, `y0`, `x1`, `y1` — page-local document points, as
1435
+ * an annotation's rect is — on page `index` (0-based) into view as
1436
+ * `alignment` (`"top"`, `"center"`, `"bottom"` or `"nearest"`) says,
1437
+ * keeping the zoom — `"top"` is a PDF `/XYZ` destination's landing: what
1438
+ * choosing a comment or stepping to a search match does. Composes the
1439
+ * target page first, as [`goToPage`](Self::go_to_page) does. The resulting
1440
+ * scroll rides back in the next [`view_state`](Self::view_state). A no-op
1441
+ * when no document is open.
1442
+ *
1443
+ * # Errors
1444
+ *
1445
+ * If `alignment` is not one of the four names.
1446
+ * @param {number} index
1447
+ * @param {number} x0
1448
+ * @param {number} y0
1449
+ * @param {number} x1
1450
+ * @param {number} y1
1451
+ * @param {ScrollAlignment} alignment
1452
+ */
1453
+ goToRect(index, x0, y0, x1, y1, alignment) {
1454
+ try {
1455
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1456
+ wasm.wasmsession_goToRect(retptr, this.__wbg_ptr, index, x0, y0, x1, y1, addBorrowedObject(alignment));
1457
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1458
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1459
+ if (r1) {
1460
+ throw takeObject(r0);
1461
+ }
1462
+ } finally {
1463
+ wasm.__wbindgen_add_to_stack_pointer(16);
1464
+ heap[stack_pointer++] = undefined;
1465
+ }
1466
+ }
1467
+ /**
1468
+ * The viewer's guide chrome — a spreadsheet's row/column headers or a paged
1469
+ * ruler — as a resolved render list for the host to draw in the DOM. The
1470
+ * viewer projects it in its own **device px** (origin at the content pane's
1471
+ * top-left); this boundary divides by the dpr into the CSS px the DOM bands
1472
+ * draw in, so the host contract stays CSS px throughout. `undefined` with no
1473
+ * open document or a doc type with no chrome. Pull on each viewport change,
1474
+ * beside [`viewState`](Self::view_state) — and after a selection change that
1475
+ * moves the ruler's "0" (which rides the text frame a caret edits).
1476
+ * @returns {Guide | undefined}
1477
+ */
1478
+ guide() {
1479
+ const ret = wasm.wasmsession_guide(this.__wbg_ptr);
1480
+ return takeObject(ret);
1481
+ }
1482
+ /**
1483
+ * Pick at CSS-px point `(css_x, css_y)`: the whole hit as a [`UDocHit`] JSON
1484
+ * string (e.g. `{"portable":{"page":"7-0","object":"7-3","text":{"run":0,"boundary":2}}}`,
1485
+ * or `"none"`) — the one read behind the host's hover cursor (an I-beam when
1486
+ * the hit carries `text`) and click routing. Returned as JSON the same way
1487
+ * [`selection`](Self::selection) returns `UDocSelection`, so a doc-tagged hit
1488
+ * needs no bespoke boundary type; the host parses it against the generated
1489
+ * `UDocHit` type. The host calls it **latest-wins** on pointer move (one in
1490
+ * flight, coalesced), so there is no cached set to invalidate as the
1491
+ * document, layout, or a co-editor changes it: the answer is always the live
1492
+ * engine's, and the same query a click routes on, so the cursor can never
1493
+ * disagree with what a click does. `"none"` with no document open.
1494
+ * @param {number} css_x
1495
+ * @param {number} css_y
1496
+ * @returns {UDocHit}
1497
+ */
1498
+ hitTest(css_x, css_y) {
1499
+ const ret = wasm.wasmsession_hitTest(this.__wbg_ptr, css_x, css_y);
1500
+ return takeObject(ret);
1501
+ }
1502
+ /**
1503
+ * Insert the image file `bytes` as a picture on the current page, centred
1504
+ * and scaled down to fit, and select it — one undo step, relayouting like
1505
+ * [`execute`](Self::execute). `contentType` is the file's MIME type
1506
+ * (`image/png`, …); an empty one is read from the bytes' own signature.
1507
+ * The image is an opaque part: its bytes never enter the CRDT, and reach a
1508
+ * peer through [`opaquePartsSince`](Self::opaque_parts_since).
1509
+ *
1510
+ * # Errors
1511
+ * Returns a JS error if the session is not entitled to editing, no
1512
+ * document is open, it isn't a presentation, no codec reads the bytes, or
1513
+ * the edit fails.
1514
+ * @param {Uint8Array} bytes
1515
+ * @param {string} content_type
1516
+ */
1517
+ insertImage(bytes, content_type) {
1518
+ try {
1519
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1520
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1521
+ const len0 = WASM_VECTOR_LEN;
1522
+ const ptr1 = passStringToWasm0(content_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1523
+ const len1 = WASM_VECTOR_LEN;
1524
+ wasm.wasmsession_insertImage(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1525
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1526
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1527
+ if (r1) {
1528
+ throw takeObject(r0);
1529
+ }
1530
+ } finally {
1531
+ wasm.__wbindgen_add_to_stack_pointer(16);
1532
+ }
1533
+ }
1534
+ /**
1535
+ * Mark the whole visible window dirty (e.g. after an edit).
1536
+ */
1537
+ invalidate() {
1538
+ wasm.wasmsession_invalidate(this.__wbg_ptr);
1539
+ }
1540
+ /**
1541
+ * Mark a layout-space (document-points) region dirty.
1542
+ * @param {number} x
1543
+ * @param {number} y
1544
+ * @param {number} width
1545
+ * @param {number} height
1546
+ */
1547
+ invalidateRect(x, y, width, height) {
1548
+ wasm.wasmsession_invalidateRect(this.__wbg_ptr, x, y, width, height);
1549
+ }
1550
+ /**
1551
+ * The families that are **loaded** — parsed and in hand this moment — a
1552
+ * subset of [`fontFamilySummaries`](Self::font_family_summaries), in the
1553
+ * same order.
1554
+ *
1555
+ * The set the document has actually *used*: fonts materialize lazily, so a
1556
+ * family arrives here when something resolves to it, whether it was bundled
1557
+ * all along or just finished downloading. A bundled family nothing has
1558
+ * touched is not in it — it would apply instantly, but it isn't loaded.
1559
+ *
1560
+ * It grows as a document composes and as fonts are picked, so re-read it
1561
+ * rather than caching it:
1562
+ * [`fontFamilySummaries`](Self::font_family_summaries) stays put, this does
1563
+ * not. A hint for ordering a picker, never a gate —
1564
+ * resolution is total, and any family in the full list can be chosen.
1565
+ * @returns {string[]}
1566
+ */
1567
+ loadedFontFamilyNames() {
1568
+ try {
1569
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1570
+ wasm.wasmsession_loadedFontFamilyNames(retptr, this.__wbg_ptr);
1571
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1572
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1573
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
1574
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
1575
+ return v1;
1576
+ } finally {
1577
+ wasm.__wbindgen_add_to_stack_pointer(16);
1578
+ }
1579
+ }
1580
+ /**
1581
+ * Create each part a peer's [`opaquePartsSince`](Self::opaque_parts_since)
1582
+ * carries, to pass on in turn. A part arrives before
1583
+ * [`mergePatch`](Self::merge_patch) takes the patch that names it, so
1584
+ * nothing relayouts.
1585
+ *
1586
+ * # Errors
1587
+ * Returns a JS error if the session is not entitled to collaboration, no
1588
+ * document is open, or the data is malformed.
1589
+ * @param {Uint8Array} data
1590
+ */
1591
+ mergeOpaqueParts(data) {
1592
+ try {
1593
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1594
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1595
+ const len0 = WASM_VECTOR_LEN;
1596
+ wasm.wasmsession_mergeOpaqueParts(retptr, this.__wbg_ptr, ptr0, len0);
1597
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1598
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1599
+ if (r1) {
1600
+ throw takeObject(r0);
1601
+ }
1602
+ } finally {
1603
+ wasm.__wbindgen_add_to_stack_pointer(16);
1604
+ }
1605
+ }
1606
+ /**
1607
+ * Merge a peer's [`snapshot`](Self::snapshot) or [`patchSince`](Self::patch_since)
1608
+ * blob and relayout (like the page-edit methods), so the host's follow-up
1609
+ * pulls see the merged state.
1610
+ *
1611
+ * # Errors
1612
+ * Returns a JS error if the session is not entitled to collaboration, no
1613
+ * document is open, or the merge fails.
1614
+ * @param {Uint8Array} data
1615
+ */
1616
+ mergePatch(data) {
1617
+ try {
1618
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1619
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1620
+ const len0 = WASM_VECTOR_LEN;
1621
+ wasm.wasmsession_mergePatch(retptr, this.__wbg_ptr, ptr0, len0);
1622
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1623
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1624
+ if (r1) {
1625
+ throw takeObject(r0);
1626
+ }
1627
+ } finally {
1628
+ wasm.__wbindgen_add_to_stack_pointer(16);
1629
+ }
1630
+ }
1631
+ /**
1632
+ * Merge a peer's [`presence`](Self::presence) blob — last-write-wins,
1633
+ * idempotent, and repaint-free (peer selections render as host-side
1634
+ * overlay, not document pixels). The host re-pulls
1635
+ * [`peerSelectionGeometry`](Self::peer_selection_geometry) after.
1636
+ *
1637
+ * # Errors
1638
+ * Returns a JS error if the session is not entitled to collaboration, no
1639
+ * document is open, or the data is malformed.
1640
+ * @param {Uint8Array} data
1641
+ */
1642
+ mergePresence(data) {
1643
+ try {
1644
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1645
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1646
+ const len0 = WASM_VECTOR_LEN;
1647
+ wasm.wasmsession_mergePresence(retptr, this.__wbg_ptr, ptr0, len0);
1648
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1649
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1650
+ if (r1) {
1651
+ throw takeObject(r0);
1652
+ }
1653
+ } finally {
1654
+ wasm.__wbindgen_add_to_stack_pointer(16);
1655
+ }
1656
+ }
1657
+ /**
1658
+ * Mint one fresh, CRDT-safe id (its `replica-counter` key) for a host
1659
+ * building a new object: the host stamps it into the object's `id`, then
1660
+ * inserts the object with an `InsertObjects` command through
1661
+ * [`execute`](Self::execute) and selects it by that id with
1662
+ * [`setSelection`](Self::set_selection). Id allocation is the editor's, so
1663
+ * a drawn/pasted id can't collide; the host requests one id per node it
1664
+ * creates. `undefined` when no document is open or the doc type mints no
1665
+ * ids.
1666
+ * @returns {string | undefined}
1667
+ */
1668
+ mintId() {
1669
+ try {
1670
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1671
+ wasm.wasmsession_mintId(retptr, this.__wbg_ptr);
1672
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1673
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1674
+ let v1;
1675
+ if (r0 !== 0) {
1676
+ v1 = getStringFromWasm0(r0, r1).slice();
1677
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1678
+ }
1679
+ return v1;
1680
+ } finally {
1681
+ wasm.__wbindgen_add_to_stack_pointer(16);
1682
+ }
1683
+ }
1684
+ /**
1685
+ * Move the text caret per a keyboard `movement` (arrows / Home / End),
1686
+ * extending the selection instead of collapsing when `extend` (Shift).
1687
+ * Presence only — not a command, not undoable. Returns the refreshed
1688
+ * selection geometry, like [`select`](Self::select).
1689
+ *
1690
+ * # Errors
1691
+ * Returns a JS error if the [`TextCaretMove`] JSON can't be decoded, or
1692
+ * (never in practice) if the resulting geometry can't be serialized.
1693
+ * @param {TextCaretMove} movement
1694
+ * @param {boolean} extend
1695
+ * @returns {SelectionGeometry}
1696
+ */
1697
+ moveTextCaret(movement, extend) {
1698
+ try {
1699
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1700
+ wasm.wasmsession_moveTextCaret(retptr, this.__wbg_ptr, addBorrowedObject(movement), extend);
1701
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1702
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1703
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1704
+ if (r2) {
1705
+ throw takeObject(r1);
1706
+ }
1707
+ return takeObject(r0);
1708
+ } finally {
1709
+ wasm.__wbindgen_add_to_stack_pointer(16);
1710
+ heap[stack_pointer++] = undefined;
1711
+ }
1712
+ }
1713
+ /**
1714
+ * Whether the document opened needs a password before it can be read — a
1715
+ * PDF encrypted with a user password. Until
1716
+ * [`authenticate`](Self::authenticate) unlocks it, the session answers as
1717
+ * with no document open, except for [`docType`](Self::doc_type) and
1718
+ * [`sourceFormat`](Self::source_format).
1719
+ * @returns {boolean}
1720
+ */
1721
+ needsPassword() {
1722
+ const ret = wasm.wasmsession_needsPassword(this.__wbg_ptr);
1723
+ return ret !== 0;
1724
+ }
1725
+ /**
1726
+ * The content of every opaque part — an inserted picture's image — a
1727
+ * peer lacks. `peer` is that peer's
1728
+ * [`versionVector`](Self::version_vector). Send it ahead of the
1729
+ * [`patchSince`](Self::patch_since) that names them, so the far side has
1730
+ * each part first; empty when there is none to send.
1731
+ *
1732
+ * # Errors
1733
+ * Returns a JS error if the session is not entitled to collaboration, no
1734
+ * document is open, or a part's content can't be encoded.
1735
+ * @param {Uint8Array} peer
1736
+ * @returns {Uint8Array}
1737
+ */
1738
+ opaquePartsSince(peer) {
1739
+ try {
1740
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1741
+ const ptr0 = passArray8ToWasm0(peer, wasm.__wbindgen_export);
1742
+ const len0 = WASM_VECTOR_LEN;
1743
+ wasm.wasmsession_opaquePartsSince(retptr, this.__wbg_ptr, ptr0, len0);
1744
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1745
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1746
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1747
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1748
+ if (r3) {
1749
+ throw takeObject(r2);
1750
+ }
1751
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1752
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1753
+ return v2;
1754
+ } finally {
1755
+ wasm.__wbindgen_add_to_stack_pointer(16);
1756
+ }
1757
+ }
1758
+ /**
1759
+ * Open a document from raw bytes. The host then pulls the initial layout
1760
+ * ([`composedPageCount`](Self::composed_page_count) + the
1761
+ * [`viewState`](Self::view_state) extent) and the
1762
+ * [`docType`](Self::doc_type).
1763
+ *
1764
+ * `format` is for bytes detection gets wrong: given, it skips detection
1765
+ * outright; absent, the format is detected, and a `.udoc` zip opens as a
1766
+ * package.
1767
+ *
1768
+ * One document per session: the permit this session was started with is
1769
+ * spent on this open, so a second call is refused and the host starts a
1770
+ * new session for the next file.
1771
+ *
1772
+ * A document that [`needsPassword`](Self::needs_password) — an encrypted
1773
+ * PDF — opens without its pages: the host asks for the password and hands
1774
+ * it to [`authenticate`](Self::authenticate), as often as it takes, then
1775
+ * pulls the layout.
1776
+ *
1777
+ * `delimiter` splits a CSV's fields — one ASCII character, `";"`, `"|"`, …
1778
+ * Absent, it is a comma, or a semicolon where the first record is split by
1779
+ * more of them. No other format takes one.
1780
+ *
1781
+ * # Errors
1782
+ * Returns a JS error if `format` isn't a format this build opens,
1783
+ * `delimiter` isn't one ASCII character or is given for a format that
1784
+ * takes none, a document was already opened here, the format can't be
1785
+ * detected, or parsing fails.
1786
+ * @param {Uint8Array} bytes
1787
+ * @param {FileFormat | null} [format]
1788
+ * @param {string | null} [delimiter]
1789
+ */
1790
+ open(bytes, format, delimiter) {
1791
+ try {
1792
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1793
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1794
+ const len0 = WASM_VECTOR_LEN;
1795
+ var ptr1 = isLikeNone(delimiter) ? 0 : passStringToWasm0(delimiter, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1796
+ var len1 = WASM_VECTOR_LEN;
1797
+ wasm.wasmsession_open(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(format) ? 0 : addHeapObject(format), ptr1, len1);
1798
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1799
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1800
+ if (r1) {
1801
+ throw takeObject(r0);
1802
+ }
1803
+ } finally {
1804
+ wasm.__wbindgen_add_to_stack_pointer(16);
1805
+ }
1806
+ }
1807
+ /**
1808
+ * Open the package a server keeps at `url` — its package resource,
1809
+ * `…/documents/{documentId}/package` — fetching each part through `fetch`
1810
+ * the first time the document needs it. The host then pulls the initial
1811
+ * layout as after [`open`](Self::open).
1812
+ *
1813
+ * `fetch` is the host's: it fetches a URL synchronously and returns its
1814
+ * bytes, or throws when the request fails. The session holds it for as
1815
+ * long as the document is open, since every page composed later may reach
1816
+ * a part not yet fetched. It blocks the engine's thread while it waits, so
1817
+ * this is for a session running off the host's main thread.
1818
+ *
1819
+ * One document per session, as for [`open`](Self::open): this spends the
1820
+ * session's permit.
1821
+ *
1822
+ * # Errors
1823
+ * Returns a JS error if a document was already opened here, a fetch fails,
1824
+ * or the package can't be read.
1825
+ * @param {string} url
1826
+ * @param {(url: string) => Uint8Array} fetch
1827
+ */
1828
+ openRemote(url, fetch) {
1829
+ try {
1830
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1831
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1832
+ const len0 = WASM_VECTOR_LEN;
1833
+ wasm.wasmsession_openRemote(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(fetch));
1834
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1835
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1836
+ if (r1) {
1837
+ throw takeObject(r0);
1838
+ }
1839
+ } finally {
1840
+ wasm.__wbindgen_add_to_stack_pointer(16);
1841
+ }
1842
+ }
1843
+ /**
1844
+ * The size (document points) of page `page_index` on `plane` —
1845
+ * doc-type-agnostic, so the host's thumbnail strip can shape and scale a
1846
+ * preview of any open document's page (slide, PDF page, image frame),
1847
+ * including a slide layout or master on its own plane. `plane` is `0` for a
1848
+ * single-plane doc type and a presentation's slide plane; `1..` addresses a
1849
+ * slide-master's layout plane. Composes the page if needed (hence `&mut`),
1850
+ * like the render below. Plane-leading and required, matching the facade
1851
+ * session's `page_metrics(plane, page_index)`.
1852
+ *
1853
+ * # Errors
1854
+ * Returns a JS error if no document is open or the page index is out of
1855
+ * the composed range.
1856
+ * @param {number} plane
1857
+ * @param {number} page_index
1858
+ * @returns {Size}
1859
+ */
1860
+ pageSize(plane, page_index) {
1861
+ try {
1862
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1863
+ wasm.wasmsession_pageSize(retptr, this.__wbg_ptr, plane, page_index);
1864
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1865
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1866
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1867
+ if (r2) {
1868
+ throw takeObject(r1);
1869
+ }
1870
+ return takeObject(r0);
1871
+ } finally {
1872
+ wasm.__wbindgen_add_to_stack_pointer(16);
1873
+ }
1874
+ }
1875
+ /**
1876
+ * The arrangement transform for page `index` as `[a, b, c, d, e, f]`: the
1877
+ * page's page-local space (origin top-left, `(0, 0, width, height)` in
1878
+ * points) → content space. Composed under
1879
+ * [`contentToViewport`](Self::content_to_viewport) — and, for a node
1880
+ * within the page, prepended with that node's local transform — it places
1881
+ * an overlay anchored in page coordinates. Empty when `index` isn't
1882
+ * arranged or no document is open.
1883
+ * @param {number} index
1884
+ * @returns {Float64Array}
1885
+ */
1886
+ pageToContent(index) {
1887
+ try {
1888
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1889
+ wasm.wasmsession_pageToContent(retptr, this.__wbg_ptr, index);
1890
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1891
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1892
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
1893
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
1894
+ return v1;
1895
+ } finally {
1896
+ wasm.__wbindgen_add_to_stack_pointer(16);
1897
+ }
1898
+ }
1899
+ /**
1900
+ * The on-screen pages projected to viewport (CSS px) space, as a flat
1901
+ * buffer with stride 6: `[index, x, y, width, height, rotation, …]`. The
1902
+ * per-frame payload an HTML overlay layer positions page chrome from — a
1903
+ * corner button from a page's rect, an inter-page divider from the gap
1904
+ * between two consecutive rects. `rotation` is the page's quarter turn
1905
+ * clockwise (`0`/`1`/`2`/`3` = 0°/90°/180°/270°) — what an overlay
1906
+ * projecting page-anchored geometry needs to orient itself on a rotated
1907
+ * page, since the rect alone is axis-aligned. Only the pages currently
1908
+ * within the viewport are emitted, so the buffer stays small regardless of
1909
+ * document length. Empty when no document is open.
1910
+ * @returns {Float64Array}
1911
+ */
1912
+ pageViewRects() {
1913
+ try {
1914
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1915
+ wasm.wasmsession_pageViewRects(retptr, this.__wbg_ptr);
1916
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1917
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1918
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
1919
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
1920
+ return v1;
1921
+ } finally {
1922
+ wasm.__wbindgen_add_to_stack_pointer(16);
1923
+ }
1924
+ }
1925
+ /**
1926
+ * The viewport box the last [`render_frame`](Self::render_frame) repainted,
1927
+ * as `[x, y, width, height]` in **CSS px** — the dirty window the
1928
+ * compositor settled on, after the scroll-blit and any full-repaint
1929
+ * promotion. Empty when that frame painted nothing, so a host that wants to
1930
+ * keep the box on screen through the idle frames that follow holds the last
1931
+ * non-empty one itself.
1932
+ *
1933
+ * A developer diagnostic: the host outlines it over the canvas to see how
1934
+ * much of the surface each frame costs. Costs nothing to report —
1935
+ * `render_frame` hands the window back either way.
1936
+ * @returns {Float64Array}
1937
+ */
1938
+ paintedArea() {
1939
+ try {
1940
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1941
+ wasm.wasmsession_paintedArea(retptr, this.__wbg_ptr);
1942
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1943
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1944
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
1945
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
1946
+ return v1;
1947
+ } finally {
1948
+ wasm.__wbindgen_add_to_stack_pointer(16);
1949
+ }
1950
+ }
1951
+ /**
1952
+ * Paste a [`UDocFragment`] into the open document — a doc-type-tagged fragment
1953
+ * the host read back off the system clipboard. The fragment's objects are
1954
+ * re-inserted with fresh ids onto the selection's page (else the current page)
1955
+ * and become the selection. A committing edit (one undo step); relayouts like
1956
+ * [`execute`](Self::execute), and the worker re-posts the selection after.
1957
+ *
1958
+ * # Errors
1959
+ * Returns a JS error if the session is not entitled to editing, no
1960
+ * document is open, the payload isn't a valid fragment, its doc type
1961
+ * doesn't match the open document, or the paste fails.
1962
+ *
1963
+ * [`UDocFragment`]: docmentis_udoc_facade::UDocFragment
1964
+ * @param {UDocFragment} fragment
1965
+ */
1966
+ paste(fragment) {
1967
+ try {
1968
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1969
+ wasm.wasmsession_paste(retptr, this.__wbg_ptr, addBorrowedObject(fragment));
1970
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1971
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1972
+ if (r1) {
1973
+ throw takeObject(r0);
1974
+ }
1975
+ } finally {
1976
+ wasm.__wbindgen_add_to_stack_pointer(16);
1977
+ heap[stack_pointer++] = undefined;
1978
+ }
1979
+ }
1980
+ /**
1981
+ * Serialize only the ops a peer lacks — the delta-sync export. `peer` is a
1982
+ * peer's [`versionVector`](Self::version_vector); feed the result to that
1983
+ * peer's [`mergePatch`](Self::merge_patch).
1984
+ *
1985
+ * # Errors
1986
+ * Returns a JS error if the session is not entitled to collaboration, no
1987
+ * document is open, or serialization fails.
1988
+ * @param {Uint8Array} peer
1989
+ * @returns {Uint8Array}
1990
+ */
1991
+ patchSince(peer) {
1992
+ try {
1993
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1994
+ const ptr0 = passArray8ToWasm0(peer, wasm.__wbindgen_export);
1995
+ const len0 = WASM_VECTOR_LEN;
1996
+ wasm.wasmsession_patchSince(retptr, this.__wbg_ptr, ptr0, len0);
1997
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1998
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1999
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2000
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2001
+ if (r3) {
2002
+ throw takeObject(r2);
2003
+ }
2004
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
2005
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2006
+ return v2;
2007
+ } finally {
2008
+ wasm.__wbindgen_add_to_stack_pointer(16);
2009
+ }
2010
+ }
2011
+ /**
2012
+ * Every remote peer's pointer on the plane shown — what the host draws as
2013
+ * collaborator pointers. Each is a [`PeerPointer`]: the peer (id + name,
2014
+ * the same color seed as its selection) and the page its pointer rests on
2015
+ * with the point in that page's local space, placed like a selection box.
2016
+ * Re-pulled whenever presence changes or the plane does; scroll and zoom
2017
+ * never require a re-pull. Empty when no document is open or no peer
2018
+ * shares a pointer.
2019
+ *
2020
+ * # Errors
2021
+ * Returns a JS error only if the pointers can't be serialized — never in
2022
+ * practice for these plain page-anchored points.
2023
+ * @returns {PeerPointer[]}
2024
+ */
2025
+ peerPointers() {
2026
+ try {
2027
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2028
+ wasm.wasmsession_peerPointers(retptr, this.__wbg_ptr);
2029
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2030
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2031
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2032
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2033
+ if (r3) {
2034
+ throw takeObject(r2);
2035
+ }
2036
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
2037
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
2038
+ return v1;
2039
+ } finally {
2040
+ wasm.__wbindgen_add_to_stack_pointer(16);
2041
+ }
2042
+ }
2043
+ /**
2044
+ * Every remote peer's selection projected against the local layout —
2045
+ * what the host renders as collaborator selection overlays, beside its
2046
+ * own [`selectionGeometry`](Self::selection_geometry). Each peer rides
2047
+ * with its replica as a 16-hex string (a stable color seed). Re-pulled
2048
+ * whenever presence, the document, or the layout changes; scroll and
2049
+ * zoom never require a re-pull. Empty when no document is open or no
2050
+ * peer has presence. Each entry is a [`PeerSelectionGeometry`] — the peer
2051
+ * (id + name) and its role-grouped geometry, faithful like the local user's.
2052
+ *
2053
+ * [`PeerSelectionGeometry`]: docmentis_udoc_core::viewer::PeerSelectionGeometry
2054
+ *
2055
+ * # Errors
2056
+ * Returns a JS error only if the geometry can't be serialized — never in
2057
+ * practice for these plain page-anchored boxes.
2058
+ * @returns {PeerSelectionGeometry[]}
2059
+ */
2060
+ peerSelectionGeometry() {
2061
+ try {
2062
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2063
+ wasm.wasmsession_peerSelectionGeometry(retptr, this.__wbg_ptr);
2064
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2065
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2066
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2067
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2068
+ if (r3) {
2069
+ throw takeObject(r2);
2070
+ }
2071
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
2072
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
2073
+ return v1;
2074
+ } finally {
2075
+ wasm.__wbindgen_add_to_stack_pointer(16);
2076
+ }
2077
+ }
2078
+ /**
2079
+ * The remote peers present on the presence channel — each one's id (a
2080
+ * 16-hex string, the same color seed as its selection) and the name it
2081
+ * advertised — the roster a host lists them by. A peer is present once it
2082
+ * has any presence: a name, a selection or a pointer. Re-pulled whenever
2083
+ * presence changes. Empty when no document is open or no peer is present.
2084
+ *
2085
+ * # Errors
2086
+ * Returns a JS error only if the peers can't be serialized — never in
2087
+ * practice for these plain records.
2088
+ * @returns {Peer[]}
2089
+ */
2090
+ peers() {
2091
+ try {
2092
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2093
+ wasm.wasmsession_peers(retptr, this.__wbg_ptr);
2094
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2095
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2096
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2097
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2098
+ if (r3) {
2099
+ throw takeObject(r2);
2100
+ }
2101
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
2102
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
2103
+ return v1;
2104
+ } finally {
2105
+ wasm.__wbindgen_add_to_stack_pointer(16);
2106
+ }
2107
+ }
2108
+ /**
2109
+ * A copied [`UDocFragment`] projected to plain text — the `text/plain`
2110
+ * clipboard flavor beside our own format, so a paste into any other app gets
2111
+ * readable text, not our JSON. Empty when the fragment carries no text (a
2112
+ * pure shape / image copy), so the host writes only our flavor. Pairs with
2113
+ * [`copy`](Self::copy): the host copies, then projects each flavor it writes
2114
+ * (a future `html` joins here).
2115
+ *
2116
+ * # Errors
2117
+ * Returns a JS error if the payload isn't a valid fragment.
2118
+ *
2119
+ * [`UDocFragment`]: docmentis_udoc_facade::UDocFragment
2120
+ * @param {UDocFragment} fragment
2121
+ * @returns {string}
2122
+ */
2123
+ plainText(fragment) {
2124
+ let deferred2_0;
2125
+ let deferred2_1;
2126
+ try {
2127
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2128
+ wasm.wasmsession_plainText(retptr, this.__wbg_ptr, addBorrowedObject(fragment));
2129
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2130
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2131
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2132
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2133
+ var ptr1 = r0;
2134
+ var len1 = r1;
2135
+ if (r3) {
2136
+ ptr1 = 0; len1 = 0;
2137
+ throw takeObject(r2);
2138
+ }
2139
+ deferred2_0 = ptr1;
2140
+ deferred2_1 = len1;
2141
+ return getStringFromWasm0(ptr1, len1);
2142
+ } finally {
2143
+ wasm.__wbindgen_add_to_stack_pointer(16);
2144
+ heap[stack_pointer++] = undefined;
2145
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2146
+ }
2147
+ }
2148
+ /**
2149
+ * How many planes the document has — the sheet count for a spreadsheet,
2150
+ * `1` for a single-plane doc type, `0` when nothing is open. The bound the
2151
+ * host's sheet tabs and [`goToPlane`](Self::go_to_plane) page
2152
+ * through (reflected once the first [`render_frame`](Self::render_frame)
2153
+ * has reconciled).
2154
+ * @returns {number}
2155
+ */
2156
+ planeCount() {
2157
+ const ret = wasm.wasmsession_planeCount(this.__wbg_ptr);
2158
+ return ret >>> 0;
2159
+ }
2160
+ /**
2161
+ * Whether plane `plane` is a spreadsheet's chartsheet — a chart, with no
2162
+ * grid and so no row and column headers. `false` for a worksheet, a sheet
2163
+ * not loaded yet (see `spreadsheet.loadSheet`), a plane out of range, a doc
2164
+ * type with no sheets, or when nothing is open.
2165
+ * @param {number} plane
2166
+ * @returns {boolean}
2167
+ */
2168
+ planeIsChartsheet(plane) {
2169
+ const ret = wasm.wasmsession_planeIsChartsheet(this.__wbg_ptr, plane);
2170
+ return ret !== 0;
2171
+ }
2172
+ /**
2173
+ * Whether plane `plane` is a spreadsheet's very hidden sheet —
2174
+ * `state="veryHidden"`, which shows no tab. `false` for any other sheet, a
2175
+ * plane out of range, a doc type with no sheets, or when nothing is open.
2176
+ * @param {number} plane
2177
+ * @returns {boolean}
2178
+ */
2179
+ planeIsVeryHidden(plane) {
2180
+ const ret = wasm.wasmsession_planeIsVeryHidden(this.__wbg_ptr, plane);
2181
+ return ret !== 0;
2182
+ }
2183
+ /**
2184
+ * The display name of plane `plane` — a spreadsheet's sheet-tab label
2185
+ * (the `<sheet name>` from `workbook.xml`), or `undefined` for a plane out
2186
+ * of range, a doc type without named planes, or when nothing is open. The
2187
+ * label the host's sheet tabs show; read [`planeCount`](Self::plane_count)
2188
+ * for the bound.
2189
+ * @param {number} plane
2190
+ * @returns {string | undefined}
2191
+ */
2192
+ planeName(plane) {
2193
+ try {
2194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2195
+ wasm.wasmsession_planeName(retptr, this.__wbg_ptr, plane);
2196
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2197
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2198
+ let v1;
2199
+ if (r0 !== 0) {
2200
+ v1 = getStringFromWasm0(r0, r1).slice();
2201
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2202
+ }
2203
+ return v1;
2204
+ } finally {
2205
+ wasm.__wbindgen_add_to_stack_pointer(16);
2206
+ }
2207
+ }
2208
+ /**
2209
+ * The colour of plane `plane`'s tab — a spreadsheet's sheet-tab colour
2210
+ * (`<sheetPr><tabColor>`) as Excel draws it — or `undefined` for a tab in
2211
+ * no colour, a sheet not loaded yet (see `spreadsheet.loadSheet`), a plane
2212
+ * out of range, a doc type without tabs, or when nothing is open.
2213
+ * @param {number} plane
2214
+ * @returns {PaintSRgbColor | undefined}
2215
+ */
2216
+ planeTabColor(plane) {
2217
+ const ret = wasm.wasmsession_planeTabColor(this.__wbg_ptr, plane);
2218
+ return takeObject(ret);
2219
+ }
2220
+ /**
2221
+ * Serialize the session's presence (its selection) for sync with a peer
2222
+ * — the transient channel beside [`snapshot`](Self::snapshot): no
2223
+ * history, no undo, never part of a save. Feed it to a peer's
2224
+ * [`mergePresence`](Self::merge_presence).
2225
+ *
2226
+ * # Errors
2227
+ * Returns a JS error if the session is not entitled to collaboration, no
2228
+ * document is open, or serialization fails.
2229
+ * @returns {Uint8Array}
2230
+ */
2231
+ presence() {
2232
+ try {
2233
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2234
+ wasm.wasmsession_presence(retptr, this.__wbg_ptr);
2235
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2236
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2237
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2238
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2239
+ if (r3) {
2240
+ throw takeObject(r2);
2241
+ }
2242
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2243
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2244
+ return v1;
2245
+ } finally {
2246
+ wasm.__wbindgen_add_to_stack_pointer(16);
2247
+ }
2248
+ }
2249
+ /**
2250
+ * Redo the last undone edit. Relayouts like the page-edit methods.
2251
+ *
2252
+ * # Errors
2253
+ * Returns a JS error if no document is open or the redo fails.
2254
+ */
2255
+ redo() {
2256
+ try {
2257
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2258
+ wasm.wasmsession_redo(retptr, this.__wbg_ptr);
2259
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2260
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2261
+ if (r1) {
2262
+ throw takeObject(r0);
2263
+ }
2264
+ } finally {
2265
+ wasm.__wbindgen_add_to_stack_pointer(16);
2266
+ }
2267
+ }
2268
+ /**
2269
+ * Re-shape the composed pages against the fonts that have landed, and report
2270
+ * whether there was anything composed to re-shape — repaint if `true`.
2271
+ *
2272
+ * Separate from [`completeFontRequest`](Self::complete_font_request) so a
2273
+ * batch of completions costs one recompose rather than one each: this is the
2274
+ * expensive half of the cycle (a full invalidate plus a recompose of the
2275
+ * composed prefix).
2276
+ * @returns {boolean}
2277
+ */
2278
+ refreshFonts() {
2279
+ const ret = wasm.wasmsession_refreshFonts(this.__wbg_ptr);
2280
+ return ret !== 0;
2281
+ }
2282
+ /**
2283
+ * Keep this peer present: stamp its own presence entries anew, so peers
2284
+ * keep them past the presence timeout, and drop the entries of peers that
2285
+ * vanished without leaving. A joined host calls it on a period well inside
2286
+ * the timeout, and on each join before it sends
2287
+ * [`presence`](Self::presence); the host re-pulls the peers after.
2288
+ *
2289
+ * # Errors
2290
+ * Returns a JS error if the session is not entitled to collaboration.
2291
+ */
2292
+ refreshPresence() {
2293
+ try {
2294
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2295
+ wasm.wasmsession_refreshPresence(retptr, this.__wbg_ptr);
2296
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2297
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2298
+ if (r1) {
2299
+ throw takeObject(r0);
2300
+ }
2301
+ } finally {
2302
+ wasm.__wbindgen_add_to_stack_pointer(16);
2303
+ }
2304
+ }
2305
+ /**
2306
+ * Register host-supplied font bytes — an OS font, an upload, anything the
2307
+ * host already holds.
2308
+ *
2309
+ * Just the bytes: the font names itself, and every face of a collection is
2310
+ * registered under the family it declares.
2311
+ *
2312
+ * Host state: it applies to documents opened **after** this call, since a
2313
+ * session's font system is built when the document is. Register at startup,
2314
+ * before the first [`open`](Self::open). The bytes are copied once, here,
2315
+ * and shared with every session thereafter.
2316
+ * @param {Uint8Array} bytes
2317
+ */
2318
+ registerLocalFont(bytes) {
2319
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
2320
+ const len0 = WASM_VECTOR_LEN;
2321
+ wasm.wasmsession_registerLocalFont(this.__wbg_ptr, ptr0, len0);
2322
+ }
2323
+ /**
2324
+ * Register fonts the host will fetch by URL when they are asked for —
2325
+ * `[{ descriptor: { family, bold, italic }, url, scripts? }]`.
2326
+ *
2327
+ * `scripts` is an optional list of Unicode script names (`"Latin"`,
2328
+ * `"Greek"`) used only as a prefilter, to avoid ordering a font for a script
2329
+ * it can't serve. Omit it when unsure: unconstrained means "always try",
2330
+ * and guessing narrow is the one error that loses a font permanently.
2331
+ * Host state, like [`registerLocalFont`](Self::register_local_font).
2332
+ *
2333
+ * # Errors
2334
+ *
2335
+ * If `fonts` isn't a list of that shape.
2336
+ * @param {UrlFont[]} fonts
2337
+ */
2338
+ registerUrlFonts(fonts) {
2339
+ try {
2340
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2341
+ const ptr0 = passArrayJsValueToWasm0(fonts, wasm.__wbindgen_export);
2342
+ const len0 = WASM_VECTOR_LEN;
2343
+ wasm.wasmsession_registerUrlFonts(retptr, this.__wbg_ptr, ptr0, len0);
2344
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2345
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2346
+ if (r1) {
2347
+ throw takeObject(r0);
2348
+ }
2349
+ } finally {
2350
+ wasm.__wbindgen_add_to_stack_pointer(16);
2351
+ }
2352
+ }
2353
+ /**
2354
+ * Draw `text` in one family's own face as a PNG **alpha mask** — the picker
2355
+ * row for a family the browser can't load itself, which is any family whose
2356
+ * `sourceType` is `Embedded`, `OfficeCompatible` or `AdobeStandard`.
2357
+ *
2358
+ * Opaque black on transparent: the host uses it as a CSS `mask-image` over
2359
+ * `currentColor`, so the specimen takes the theme's text color and one
2360
+ * raster serves light and dark.
2361
+ *
2362
+ * The family's **own** face or nothing — `undefined` when no document is
2363
+ * open, the doc type has no text font registry, the family has no face here
2364
+ * yet, or nothing shaped. A row that gets `undefined` keeps its plain name,
2365
+ * which beats labelling one face with another's name. A pure read: drawing
2366
+ * a specimen does not load the family, so browsing the picker leaves
2367
+ * [`loadedFontFamilyNames`](Self::loaded_font_family_names) alone.
2368
+ *
2369
+ * `size` is the em in **CSS px** and the returned `width` / `height` are
2370
+ * the CSS box to give the element; the PNG itself is rendered at the
2371
+ * device pixel ratio behind that box, so it stays sharp on a retina display
2372
+ * without the host doing any scaling arithmetic. `bleed` is the transparent
2373
+ * margin baked into every side — offset the element by `-bleed` to line the
2374
+ * specimen up with ordinary text at the same em.
2375
+ *
2376
+ * # Errors
2377
+ *
2378
+ * If rasterization or PNG encoding fails.
2379
+ * @param {string} family
2380
+ * @param {boolean} bold
2381
+ * @param {boolean} italic
2382
+ * @param {string} text
2383
+ * @param {number} size
2384
+ * @returns {FontPreviewImage | undefined}
2385
+ */
2386
+ renderFontPreview(family, bold, italic, text, size) {
2387
+ try {
2388
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2389
+ const ptr0 = passStringToWasm0(family, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2390
+ const len0 = WASM_VECTOR_LEN;
2391
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2392
+ const len1 = WASM_VECTOR_LEN;
2393
+ wasm.wasmsession_renderFontPreview(retptr, this.__wbg_ptr, ptr0, len0, bold, italic, ptr1, len1, size);
2394
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2395
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2396
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2397
+ if (r2) {
2398
+ throw takeObject(r1);
2399
+ }
2400
+ return r0 === 0 ? undefined : FontPreviewImage.__wrap(r0);
2401
+ } finally {
2402
+ wasm.__wbindgen_add_to_stack_pointer(16);
2403
+ }
2404
+ }
2405
+ /**
2406
+ * Paint the pending dirty area. Safe to call every frame; a no-op when
2407
+ * nothing is dirty. Returns true if it painted.
2408
+ *
2409
+ * Applies any deferred backing-store resize first, so the clear and the
2410
+ * full repaint it triggers happen together in this frame.
2411
+ *
2412
+ * # Errors
2413
+ * Returns a JS error if rasterization or a canvas draw fails.
2414
+ * @returns {boolean}
2415
+ */
2416
+ renderFrame() {
2417
+ try {
2418
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2419
+ wasm.wasmsession_renderFrame(retptr, this.__wbg_ptr);
2420
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2421
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2422
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2423
+ if (r2) {
2424
+ throw takeObject(r1);
2425
+ }
2426
+ return r0 !== 0;
2427
+ } finally {
2428
+ wasm.__wbindgen_add_to_stack_pointer(16);
2429
+ }
2430
+ }
2431
+ /**
2432
+ * Rasterize page `page_index` on `plane` to premultiplied RGBA8 at `scale`
2433
+ * (1.0 == 1 output pixel per document point, i.e. 72 DPI) for an
2434
+ * off-viewport preview — the thumbnail strip, or a slide-layout / master
2435
+ * preview off a non-current plane. `plane` is `0` for a single-plane doc
2436
+ * type and a presentation's slide plane; `1..` addresses a slide-master's
2437
+ * layout plane. A CPU render into a fresh pixmap, wholly independent of the
2438
+ * live OffscreenCanvas/compositor, so it never disturbs the painted frame;
2439
+ * it does run synchronously on the worker thread, so the host throttles it
2440
+ * against viewport painting (renders only while the camera is settled).
2441
+ * Returns the pixels plus the dimensions the renderer chose (the host sizes
2442
+ * its `ImageData` to them). Plane-leading and required, matching the facade
2443
+ * session's `render_page_to_pixmap(plane, page_index, ..)`. `ephemeral`
2444
+ * draws the ephemeral annotations — shown, never saved — which a print
2445
+ * leaves out.
2446
+ *
2447
+ * # Errors
2448
+ * Returns a JS error if no document is open, the page index is out of the
2449
+ * composed range, or rasterization fails.
2450
+ * @param {number} plane
2451
+ * @param {number} page_index
2452
+ * @param {number} scale
2453
+ * @param {boolean} ephemeral
2454
+ * @returns {PageImage}
2455
+ */
2456
+ renderPageToRgba(plane, page_index, scale, ephemeral) {
2457
+ try {
2458
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2459
+ wasm.wasmsession_renderPageToRgba(retptr, this.__wbg_ptr, plane, page_index, scale, ephemeral);
2460
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2461
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2462
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2463
+ if (r2) {
2464
+ throw takeObject(r1);
2465
+ }
2466
+ return PageImage.__wrap(r0);
2467
+ } finally {
2468
+ wasm.__wbindgen_add_to_stack_pointer(16);
2469
+ }
2470
+ }
2471
+ /**
2472
+ * Raise a font request for text the document doesn't have yet — the font
2473
+ * picker's seam. `undefined` when there is nothing to fetch.
2474
+ *
2475
+ * Applying a family the document has never used lays the text out in a
2476
+ * stand-in, raises the request then, and reflows when it lands: the text
2477
+ * changes twice for one click. Ask here first and it changes once:
2478
+ *
2479
+ * ```js
2480
+ * let request;
2481
+ * while ((request = session.requestFont(family, bold, italic, session.selectedText()))) {
2482
+ * session.completeFontRequest(BigInt(request.id), await fetchBinaries(request));
2483
+ * }
2484
+ * session.executeOnSelection(theFontChange); // composes once, in the real font
2485
+ * ```
2486
+ *
2487
+ * The request is the same shape and settles the same way as one from
2488
+ * [`takeFontRequests`](Self::take_font_requests), because it is the same
2489
+ * thing — but it goes straight to in-flight, so that call never hands it
2490
+ * out and **no [`refreshFonts`](Self::refresh_fonts) follows**: nothing
2491
+ * composed is waiting on it, and your own edit is what composes.
2492
+ *
2493
+ * Ask again after settling: the next call names the next vendor down the
2494
+ * chain, and `undefined` ends the loop — the family is here, or nobody has
2495
+ * it. Either way, apply the change.
2496
+ *
2497
+ * # Errors
2498
+ *
2499
+ * If the request can't be serialized.
2500
+ * @param {string} family
2501
+ * @param {boolean} bold
2502
+ * @param {boolean} italic
2503
+ * @param {string} characters
2504
+ * @returns {FontRequest | undefined}
2505
+ */
2506
+ requestFont(family, bold, italic, characters) {
2507
+ try {
2508
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2509
+ const ptr0 = passStringToWasm0(family, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2510
+ const len0 = WASM_VECTOR_LEN;
2511
+ const ptr1 = passStringToWasm0(characters, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2512
+ const len1 = WASM_VECTOR_LEN;
2513
+ wasm.wasmsession_requestFont(retptr, this.__wbg_ptr, ptr0, len0, bold, italic, ptr1, len1);
2514
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2515
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2516
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2517
+ if (r2) {
2518
+ throw takeObject(r1);
2519
+ }
2520
+ return takeObject(r0);
2521
+ } finally {
2522
+ wasm.__wbindgen_add_to_stack_pointer(16);
2523
+ }
2524
+ }
2525
+ /**
2526
+ * The viewport size (CSS px) or device-pixel ratio changed: record the
2527
+ * new logical viewport and queue the backing-store resize for the next
2528
+ * frame. The actual `set_width` (which clears the backing) is deferred to
2529
+ * [`render_frame`](Self::render_frame) so it lands in the same rAF frame
2530
+ * as the repaint — no blank flash, and on the vsync cadence.
2531
+ * @param {number} css_width
2532
+ * @param {number} css_height
2533
+ * @param {number} dpr
2534
+ */
2535
+ resize(css_width, css_height, dpr) {
2536
+ wasm.wasmsession_resize(this.__wbg_ptr, css_width, css_height, dpr);
2537
+ }
2538
+ /**
2539
+ * Save the open document as `format`, faithfully — the bytes reopen as
2540
+ * the same document. `format` is one of the open doc type's own (a PDF
2541
+ * saves to `"pdf"`, a presentation to `"pptx"`); rendering it into any
2542
+ * other is an [export](Self::export_to_bytes).
2543
+ *
2544
+ * `strategy` is how much of the file the session was opened from, the
2545
+ * original, the saved bytes keep. A `"delta"` or `"incremental"` save
2546
+ * writes over it, which a session opened with `openRemote` doesn't hold.
2547
+ * Absent, it is the one keeping the most of it that `format` saves by: a
2548
+ * PDF's `"incremental"`, a CSV's, a TSV's, a PSV's or an image's
2549
+ * `"rewrite"`, any other's `"delta"`.
2550
+ *
2551
+ * `delimiter` splits a CSV's fields, one ASCII character; absent, the
2552
+ * one the document was opened with, else a comma. No other format takes
2553
+ * one.
2554
+ *
2555
+ * # Errors
2556
+ * Returns a JS error if `format` or `strategy` isn't one this build knows,
2557
+ * `delimiter` isn't one ASCII character or is given for a format that
2558
+ * takes none, no document is open, `format` isn't one of its doc type's, `format`
2559
+ * never saves by `strategy`, the session holds no original for a strategy
2560
+ * that writes over it, saving that way isn't built yet, or serializing
2561
+ * fails.
2562
+ * @param {FileFormat} format
2563
+ * @param {SaveStrategy | null} [strategy]
2564
+ * @param {string | null} [delimiter]
2565
+ * @returns {Uint8Array}
2566
+ */
2567
+ saveToBytes(format, strategy, delimiter) {
2568
+ try {
2569
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2570
+ var ptr0 = isLikeNone(delimiter) ? 0 : passStringToWasm0(delimiter, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2571
+ var len0 = WASM_VECTOR_LEN;
2572
+ wasm.wasmsession_saveToBytes(retptr, this.__wbg_ptr, addBorrowedObject(format), isLikeNone(strategy) ? 0 : addHeapObject(strategy), ptr0, len0);
2573
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2574
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2575
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2576
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2577
+ if (r3) {
2578
+ throw takeObject(r2);
2579
+ }
2580
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
2581
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2582
+ return v2;
2583
+ } finally {
2584
+ wasm.__wbindgen_add_to_stack_pointer(16);
2585
+ heap[stack_pointer++] = undefined;
2586
+ }
2587
+ }
2588
+ /**
2589
+ * Save the open document as a udoc package — the bytes of a `.udoc` zip,
2590
+ * the one package backend in wasm — recording the format it came from, so
2591
+ * a reopen can still save back to it.
2592
+ *
2593
+ * `version` makes it a checkpoint, baseline `v<version>`: the package
2594
+ * keeps the edit log a reopen replays. Absent, the package is a flat
2595
+ * baseline — the whole document and no log.
2596
+ *
2597
+ * # Errors
2598
+ * Returns a JS error if no document is open or serializing fails.
2599
+ * @param {number | null} [version]
2600
+ * @returns {Uint8Array}
2601
+ */
2602
+ saveToPackage(version) {
2603
+ try {
2604
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2605
+ wasm.wasmsession_saveToPackage(retptr, this.__wbg_ptr, isLikeNone(version) ? Number.MAX_SAFE_INTEGER : (version) >>> 0);
2606
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2607
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2608
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2609
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2610
+ if (r3) {
2611
+ throw takeObject(r2);
2612
+ }
2613
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2614
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2615
+ return v1;
2616
+ } finally {
2617
+ wasm.__wbindgen_add_to_stack_pointer(16);
2618
+ }
2619
+ }
2620
+ /**
2621
+ * The next batch of `query`'s matches, as a [`SearchBatch`]: at most
2622
+ * [`MAX_MATCHES`](SearchBatch::MAX_MATCHES), each with its page, its
2623
+ * highlight quads (page-local points) and its context, plus `next` — the
2624
+ * [`SearchContinuation`] to hand back as `from` for the batch after, `null`
2625
+ * when the search is done. `scope` is a [`UDocSearchScope`] for the open
2626
+ * doc type, or `undefined` for the whole document; `from` is `undefined`
2627
+ * for the first batch. Stateless: nothing is kept between calls. A page
2628
+ * not laid out yet is laid out first, so the host re-pulls the layout
2629
+ * after, as after [`updateLayout`](Self::update_layout).
2630
+ *
2631
+ * # Errors
2632
+ * Returns a JS error if no document is open, a payload isn't valid, the
2633
+ * scope's doc type doesn't match the open document's, or a part the search
2634
+ * reads fails to load.
2635
+ * @param {string} query
2636
+ * @param {SearchOptions} options
2637
+ * @param {UDocSearchScope | null} [scope]
2638
+ * @param {SearchContinuation | null} [from]
2639
+ * @returns {SearchBatch}
2640
+ */
2641
+ search(query, options, scope, from) {
2642
+ try {
2643
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2644
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2645
+ const len0 = WASM_VECTOR_LEN;
2646
+ wasm.wasmsession_search(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(options), isLikeNone(scope) ? 0 : addHeapObject(scope), isLikeNone(from) ? 0 : addHeapObject(from));
2647
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2648
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2649
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2650
+ if (r2) {
2651
+ throw takeObject(r1);
2652
+ }
2653
+ return takeObject(r0);
2654
+ } finally {
2655
+ wasm.__wbindgen_add_to_stack_pointer(16);
2656
+ heap[stack_pointer++] = undefined;
2657
+ }
2658
+ }
2659
+ /**
2660
+ * The [`UDocSelection`] naming the text of a match — the separate step
2661
+ * from a [`SearchMatch`](docmentis_udoc_core::engine::SearchMatch) to a
2662
+ * selection, taking the match's `location`. Hand the result to
2663
+ * [`setSelection`](Self::set_selection) to select it. `undefined` when no
2664
+ * document is open or nothing at `location` can be selected.
2665
+ *
2666
+ * # Errors
2667
+ * Returns a JS error if `location` isn't a valid [`SearchMatchLocation`].
2668
+ * @param {SearchMatchLocation} location
2669
+ * @returns {UDocSelection | undefined}
2670
+ */
2671
+ searchMatchSelection(location) {
2672
+ try {
2673
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2674
+ wasm.wasmsession_searchMatchSelection(retptr, this.__wbg_ptr, addBorrowedObject(location));
2675
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2676
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2677
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2678
+ if (r2) {
2679
+ throw takeObject(r1);
2680
+ }
2681
+ return takeObject(r0);
2682
+ } finally {
2683
+ wasm.__wbindgen_add_to_stack_pointer(16);
2684
+ heap[stack_pointer++] = undefined;
2685
+ }
2686
+ }
2687
+ /**
2688
+ * Set an **object** selection from a pointer gesture (CSS px) — a click
2689
+ * picks the topmost object, a drag sweeps a marquee. The host routes here
2690
+ * when a [`hitTest`](Self::hit_test) says the anchor is over an object or
2691
+ * bare canvas. `mode` is the engine's [`SelectMode`] (how the pick combines
2692
+ * with the current selection); `enclose` is the marquee's window rule
2693
+ * (`true` fully-contained only, `false` any-overlap). Unlike text and cells,
2694
+ * the object domain takes these two directly — it has no options struct.
2695
+ * Returns the new selection's geometry.
2696
+ *
2697
+ * # Errors
2698
+ * Returns a JS error if the [`SelectMode`] JSON can't be decoded, or (never
2699
+ * in practice) if the resulting geometry can't be serialized.
2700
+ * @param {number} anchor_css_x
2701
+ * @param {number} anchor_css_y
2702
+ * @param {number} focus_css_x
2703
+ * @param {number} focus_css_y
2704
+ * @param {SelectMode} mode
2705
+ * @param {boolean} enclose
2706
+ * @returns {SelectionGeometry}
2707
+ */
2708
+ selectObjects(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, mode, enclose) {
2709
+ try {
2710
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2711
+ wasm.wasmsession_selectObjects(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(mode), enclose);
2712
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2713
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2714
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2715
+ if (r2) {
2716
+ throw takeObject(r1);
2717
+ }
2718
+ return takeObject(r0);
2719
+ } finally {
2720
+ wasm.__wbindgen_add_to_stack_pointer(16);
2721
+ heap[stack_pointer++] = undefined;
2722
+ }
2723
+ }
2724
+ /**
2725
+ * Select the whole sheet — a press on the header corner box. Returns the new
2726
+ * selection's geometry. A no-op on a non-spreadsheet document.
2727
+ *
2728
+ * # Errors
2729
+ * Returns a JS error only if the new geometry can't be serialized — never
2730
+ * in practice for these plain page-anchored boxes.
2731
+ * @returns {SelectionGeometry}
2732
+ */
2733
+ selectSheet() {
2734
+ try {
2735
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2736
+ wasm.wasmsession_selectSheet(retptr, this.__wbg_ptr);
2737
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2738
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2739
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2740
+ if (r2) {
2741
+ throw takeObject(r1);
2742
+ }
2743
+ return takeObject(r0);
2744
+ } finally {
2745
+ wasm.__wbindgen_add_to_stack_pointer(16);
2746
+ }
2747
+ }
2748
+ /**
2749
+ * Set a **cell** selection from a pointer gesture (CSS px) — a block on the
2750
+ * active sheet of a spreadsheet. `options` ([`GridCellSelectOptions`] —
2751
+ * `extend`) is optional. Returns the new selection's geometry.
2752
+ *
2753
+ * # Errors
2754
+ * Returns a JS error if the [`GridCellSelectOptions`] JSON can't be decoded, or
2755
+ * (never in practice) if the resulting geometry can't be serialized.
2756
+ * @param {number} anchor_css_x
2757
+ * @param {number} anchor_css_y
2758
+ * @param {number} focus_css_x
2759
+ * @param {number} focus_css_y
2760
+ * @param {GridCellSelectOptions} options
2761
+ * @returns {SelectionGeometry}
2762
+ */
2763
+ selectSheetCells(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, options) {
2764
+ try {
2765
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2766
+ wasm.wasmsession_selectSheetCells(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(options));
2767
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2768
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2769
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2770
+ if (r2) {
2771
+ throw takeObject(r1);
2772
+ }
2773
+ return takeObject(r0);
2774
+ } finally {
2775
+ wasm.__wbindgen_add_to_stack_pointer(16);
2776
+ heap[stack_pointer++] = undefined;
2777
+ }
2778
+ }
2779
+ /**
2780
+ * Select whole **columns** from a header gesture (CSS px) — a press / drag on
2781
+ * the top header band. The x resolves the column run (the y is ignored);
2782
+ * `options` ([`GridCellSelectOptions`] — `extend`) is optional. Returns the new
2783
+ * selection's geometry. A no-op on a non-spreadsheet document.
2784
+ *
2785
+ * # Errors
2786
+ * Returns a JS error if the [`GridCellSelectOptions`] JSON can't be decoded, or
2787
+ * (never in practice) if the resulting geometry can't be serialized.
2788
+ * @param {number} anchor_css_x
2789
+ * @param {number} anchor_css_y
2790
+ * @param {number} focus_css_x
2791
+ * @param {number} focus_css_y
2792
+ * @param {GridCellSelectOptions} options
2793
+ * @returns {SelectionGeometry}
2794
+ */
2795
+ selectSheetColumns(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, options) {
2796
+ try {
2797
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2798
+ wasm.wasmsession_selectSheetColumns(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(options));
2799
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2800
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2801
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2802
+ if (r2) {
2803
+ throw takeObject(r1);
2804
+ }
2805
+ return takeObject(r0);
2806
+ } finally {
2807
+ wasm.__wbindgen_add_to_stack_pointer(16);
2808
+ heap[stack_pointer++] = undefined;
2809
+ }
2810
+ }
2811
+ /**
2812
+ * Select whole **rows** from a header gesture (CSS px) — a press / drag on the
2813
+ * left header band. The y resolves the row run (the x is ignored). Returns the
2814
+ * new selection's geometry. A no-op on a non-spreadsheet document.
2815
+ *
2816
+ * # Errors
2817
+ * Returns a JS error if the [`GridCellSelectOptions`] JSON can't be decoded, or
2818
+ * (never in practice) if the resulting geometry can't be serialized.
2819
+ * @param {number} anchor_css_x
2820
+ * @param {number} anchor_css_y
2821
+ * @param {number} focus_css_x
2822
+ * @param {number} focus_css_y
2823
+ * @param {GridCellSelectOptions} options
2824
+ * @returns {SelectionGeometry}
2825
+ */
2826
+ selectSheetRows(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, options) {
2827
+ try {
2828
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2829
+ wasm.wasmsession_selectSheetRows(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(options));
2830
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2831
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2832
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2833
+ if (r2) {
2834
+ throw takeObject(r1);
2835
+ }
2836
+ return takeObject(r0);
2837
+ } finally {
2838
+ wasm.__wbindgen_add_to_stack_pointer(16);
2839
+ heap[stack_pointer++] = undefined;
2840
+ }
2841
+ }
2842
+ /**
2843
+ * Select the whole table the current selection sits in — Select ▸ Table.
2844
+ * A no-op when the selection is not inside one.
2845
+ *
2846
+ * # Errors
2847
+ * Returns a JS error if the resulting geometry can't be serialized.
2848
+ * @returns {SelectionGeometry}
2849
+ */
2850
+ selectTable() {
2851
+ try {
2852
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2853
+ wasm.wasmsession_selectTable(retptr, this.__wbg_ptr);
2854
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2855
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2856
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2857
+ if (r2) {
2858
+ throw takeObject(r1);
2859
+ }
2860
+ return takeObject(r0);
2861
+ } finally {
2862
+ wasm.__wbindgen_add_to_stack_pointer(16);
2863
+ }
2864
+ }
2865
+ /**
2866
+ * Set a **table cell** selection from a pointer gesture (CSS px) — a block
2867
+ * inside one graphic frame's table on the current slide. A click collapses
2868
+ * to the cell under it, a drag spans to the focus's cell, and
2869
+ * `options` ([`TableSelectOptions`] — `extend`) Shift-extends from what is
2870
+ * already picked in that table. Returns the new selection's geometry.
2871
+ *
2872
+ * Routed here when [`hitTest`](Self::hit_test) says the anchor is over a
2873
+ * table cell *and* the gesture means cells rather than text — the same hit
2874
+ * that would otherwise open a caret. A no-op on a doc type without tables.
2875
+ *
2876
+ * # Errors
2877
+ * Returns a JS error if the [`TableSelectOptions`] JSON can't be decoded,
2878
+ * or (never in practice) if the resulting geometry can't be serialized.
2879
+ * @param {number} anchor_css_x
2880
+ * @param {number} anchor_css_y
2881
+ * @param {number} focus_css_x
2882
+ * @param {number} focus_css_y
2883
+ * @param {TableSelectOptions} options
2884
+ * @returns {SelectionGeometry}
2885
+ */
2886
+ selectTableCells(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, options) {
2887
+ try {
2888
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2889
+ wasm.wasmsession_selectTableCells(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(options));
2890
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2891
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2892
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2893
+ if (r2) {
2894
+ throw takeObject(r1);
2895
+ }
2896
+ return takeObject(r0);
2897
+ } finally {
2898
+ wasm.__wbindgen_add_to_stack_pointer(16);
2899
+ heap[stack_pointer++] = undefined;
2900
+ }
2901
+ }
2902
+ /**
2903
+ * Widen the current table selection to its whole **columns** — Select ▸
2904
+ * Column, the twin of [`selectTableRows`](Self::select_table_rows).
2905
+ *
2906
+ * # Errors
2907
+ * Returns a JS error if the resulting geometry can't be serialized.
2908
+ * @returns {SelectionGeometry}
2909
+ */
2910
+ selectTableColumns() {
2911
+ try {
2912
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2913
+ wasm.wasmsession_selectTableColumns(retptr, this.__wbg_ptr);
2914
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2915
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2916
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2917
+ if (r2) {
2918
+ throw takeObject(r1);
2919
+ }
2920
+ return takeObject(r0);
2921
+ } finally {
2922
+ wasm.__wbindgen_add_to_stack_pointer(16);
2923
+ }
2924
+ }
2925
+ /**
2926
+ * Widen the current table selection to its whole **rows** — the Select ▸ Row
2927
+ * context-menu command. Takes no point: a table has no row header to press,
2928
+ * so it acts on whatever is already picked (a caret in a cell widens to its
2929
+ * row). Returns the new selection's geometry.
2930
+ *
2931
+ * # Errors
2932
+ * Returns a JS error if the resulting geometry can't be serialized.
2933
+ * @returns {SelectionGeometry}
2934
+ */
2935
+ selectTableRows() {
2936
+ try {
2937
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2938
+ wasm.wasmsession_selectTableRows(retptr, this.__wbg_ptr);
2939
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2940
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2941
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2942
+ if (r2) {
2943
+ throw takeObject(r1);
2944
+ }
2945
+ return takeObject(r0);
2946
+ } finally {
2947
+ wasm.__wbindgen_add_to_stack_pointer(16);
2948
+ }
2949
+ }
2950
+ /**
2951
+ * Set a **text** selection from a pointer gesture between two viewport-space
2952
+ * points (CSS px) — a caret / range in the open doc's text. The host routes
2953
+ * here after a [`hitTest`](Self::hit_test) says the anchor is over text.
2954
+ * `options` ([`TextSelectOptions`] — `granularity`, `extend`, `global`) is
2955
+ * optional per field (`{}` is a plain click). Returns the new selection's
2956
+ * geometry (see [`selectionGeometry`](Self::selection_geometry)).
2957
+ *
2958
+ * # Errors
2959
+ * Returns a JS error if the [`TextSelectOptions`] JSON can't be decoded, or
2960
+ * (never in practice) if the resulting geometry can't be serialized.
2961
+ * @param {number} anchor_css_x
2962
+ * @param {number} anchor_css_y
2963
+ * @param {number} focus_css_x
2964
+ * @param {number} focus_css_y
2965
+ * @param {TextSelectOptions} options
2966
+ * @returns {SelectionGeometry}
2967
+ */
2968
+ selectText(anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, options) {
2969
+ try {
2970
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2971
+ wasm.wasmsession_selectText(retptr, this.__wbg_ptr, anchor_css_x, anchor_css_y, focus_css_x, focus_css_y, addBorrowedObject(options));
2972
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2973
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2974
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2975
+ if (r2) {
2976
+ throw takeObject(r1);
2977
+ }
2978
+ return takeObject(r0);
2979
+ } finally {
2980
+ wasm.__wbindgen_add_to_stack_pointer(16);
2981
+ heap[stack_pointer++] = undefined;
2982
+ }
2983
+ }
2984
+ /**
2985
+ * The plain text of the current selection — the characters a font about to
2986
+ * be applied will have to render, for [`requestFont`](Self::request_font).
2987
+ *
2988
+ * Empty for a caret, a doc type without copy, or nothing selected, which is
2989
+ * a useful answer in its own right: no text on screen is about to change,
2990
+ * so there is nothing to fetch ahead.
2991
+ * @returns {string}
2992
+ */
2993
+ selectedText() {
2994
+ let deferred1_0;
2995
+ let deferred1_1;
2996
+ try {
2997
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2998
+ wasm.wasmsession_selectedText(retptr, this.__wbg_ptr);
2999
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3000
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3001
+ deferred1_0 = r0;
3002
+ deferred1_1 = r1;
3003
+ return getStringFromWasm0(r0, r1);
3004
+ } finally {
3005
+ wasm.__wbindgen_add_to_stack_pointer(16);
3006
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
3007
+ }
3008
+ }
3009
+ /**
3010
+ * The current selection as its JSON wire form (see [`UDocSelection`]) — the
3011
+ * read that lets a host fold the live selection into an id-addressed edit
3012
+ * command (transform / delete) or mirror it in its own UI. `undefined` when
3013
+ * no document is open. The host `JSON.parse`s it and reads the ids out of
3014
+ * the per-doc-type shape (e.g. `.Portable.Objects`).
3015
+ *
3016
+ * [`UDocSelection`]: docmentis_udoc_facade::UDocSelection
3017
+ * @returns {UDocSelection | undefined}
3018
+ */
3019
+ selection() {
3020
+ const ret = wasm.wasmsession_selection(this.__wbg_ptr);
3021
+ return takeObject(ret);
3022
+ }
3023
+ /**
3024
+ * The engine's verdict on which selection commands are live for the current
3025
+ * selection — the host's input for enabling/disabling the selection-gated
3026
+ * toolbar controls (Delete, Arrange ▸ z-order / group / ungroup). Re-pulled
3027
+ * on the same cadence as [`selectionGeometry`](Self::selection_geometry) (a
3028
+ * selection change or an edit). All-`false` with no document open.
3029
+ *
3030
+ * # Errors
3031
+ * Returns a JS error only if the capabilities can't be serialized — never
3032
+ * in practice for this plain `{ count, allowed }` struct.
3033
+ * @returns {UDocSelectionCapabilities}
3034
+ */
3035
+ selectionCapabilities() {
3036
+ try {
3037
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3038
+ wasm.wasmsession_selectionCapabilities(retptr, this.__wbg_ptr);
3039
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3040
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3041
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3042
+ if (r2) {
3043
+ throw takeObject(r1);
3044
+ }
3045
+ return takeObject(r0);
3046
+ } finally {
3047
+ wasm.__wbindgen_add_to_stack_pointer(16);
3048
+ }
3049
+ }
3050
+ /**
3051
+ * The current selection projected to page-anchored rectangles
3052
+ * (page-local document points). Camera-independent — the host re-pulls
3053
+ * it after a selection change or an edit (an edit can move or delete
3054
+ * selected objects), then projects it against the per-frame page view
3055
+ * rects; scroll and zoom never require a re-pull. Empty when nothing is
3056
+ * selected or no document is open.
3057
+ *
3058
+ * # Errors
3059
+ * Returns a JS error only if the geometry can't be serialized — never in
3060
+ * practice for these plain page-anchored boxes.
3061
+ * @returns {SelectionGeometry}
3062
+ */
3063
+ selectionGeometry() {
3064
+ try {
3065
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3066
+ wasm.wasmsession_selectionGeometry(retptr, this.__wbg_ptr);
3067
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3068
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3069
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3070
+ if (r2) {
3071
+ throw takeObject(r1);
3072
+ }
3073
+ return takeObject(r0);
3074
+ } finally {
3075
+ wasm.__wbindgen_add_to_stack_pointer(16);
3076
+ }
3077
+ }
3078
+ /**
3079
+ * Where geometry handle `index` of
3080
+ * [`selectionGeometry`](Self::selection_geometry)'s `handles` would land if
3081
+ * it were dragged at `(to_x, to_y)` — a point in that handle's **own local
3082
+ * space** (document points, the space the streamed handle's `point` is
3083
+ * already in), not CSS pixels: the host un-projects the pointer through the
3084
+ * handle's own transform before asking, exactly as it does to commit the
3085
+ * drag.
3086
+ *
3087
+ * A handle travels the track its geometry describes and stops at the ends
3088
+ * of its range, so drawing the grip under the raw cursor puts it where the
3089
+ * shape never will. This hands back the position the committed drag will
3090
+ * produce and writes nothing, so a host can call it latest-wins (one in
3091
+ * flight, coalesced) on every pointer move and draw the answer.
3092
+ * `undefined` when the selection offers no such handle, or no document is
3093
+ * open.
3094
+ * @param {number} index
3095
+ * @param {number} to_x
3096
+ * @param {number} to_y
3097
+ * @returns {SelectionHandle | undefined}
3098
+ */
3099
+ selectionHandlePreview(index, to_x, to_y) {
3100
+ const ret = wasm.wasmsession_selectionHandlePreview(this.__wbg_ptr, index, to_x, to_y);
3101
+ return takeObject(ret);
3102
+ }
3103
+ /**
3104
+ * The current values of the selection's editable properties, as a
3105
+ * [`UDocSelectionProperties`] JSON string (e.g.
3106
+ * `{"portable":{"nonstrokingStyle":{"value":{"brush":{"solid":…},…}},"strokingStyle":"absent"}}`).
3107
+ * Returned
3108
+ * as JSON the same way [`selection`](Self::selection) returns `UDocSelection`,
3109
+ * so each doc type's native paint / text vocabulary stays faithful — the host
3110
+ * parses it against the generated `UDocSelectionProperties` type and the
3111
+ * (doc-type-aware) UI decides how to present it. Re-pulled on the same cadence
3112
+ * as [`selectionCapabilities`](Self::selection_capabilities). `None` with no
3113
+ * document open.
3114
+ *
3115
+ * [`UDocSelectionProperties`]: docmentis_udoc_facade::UDocSelectionProperties
3116
+ * @returns {UDocSelectionProperties | undefined}
3117
+ */
3118
+ selectionProperties() {
3119
+ const ret = wasm.wasmsession_selectionProperties(this.__wbg_ptr);
3120
+ return takeObject(ret);
3121
+ }
3122
+ /**
3123
+ * Set the viewport backdrop — the color filled in the gaps around and
3124
+ * between pages — from 8-bit sRGB components. Remembered across
3125
+ * [`open`](Self::open) (a fresh document otherwise resets it) and applied
3126
+ * to the current document immediately, forcing a full repaint on the next
3127
+ * [`render_frame`](Self::render_frame).
3128
+ * @param {number} r
3129
+ * @param {number} g
3130
+ * @param {number} b
3131
+ */
3132
+ setBackdropColor(r, g, b) {
3133
+ wasm.wasmsession_setBackdropColor(this.__wbg_ptr, r, g, b);
3134
+ }
3135
+ /**
3136
+ * Set how far, in CSS px, the brand decal sits in from the viewport's
3137
+ * bottom and right edges — the thickness of chrome the host lays over
3138
+ * them, such as scrollbars floating over the canvas. `0` (the default)
3139
+ * tucks it flush into the corner. Clamped to `0..=24`, so no inset can
3140
+ * push the decal off the surface; `NaN` counts as `0`. Re-projects the
3141
+ * decal onto the current document; the host re-reads
3142
+ * [`branding_rect`](Self::branding_rect).
3143
+ * @param {number} css_px
3144
+ */
3145
+ setBrandingInset(css_px) {
3146
+ wasm.wasmsession_setBrandingInset(this.__wbg_ptr, css_px);
3147
+ }
3148
+ /**
3149
+ * Turn canvas fonts on with the host's own text stack, or off with
3150
+ * `undefined`.
3151
+ *
3152
+ * On, a family no vendor offers — not the document, not the host, not the
3153
+ * Google catalog — is drawn by `canvas_text` when the viewer's machine has it
3154
+ * installed, before resolution gives the family up for a substitute. The
3155
+ * same document then renders differently on machines with different
3156
+ * fonts, which is why it is off unless a host turns it on. Host state,
3157
+ * like [`registerLocalFont`](Self::register_local_font).
3158
+ * @param {CanvasText | null} [canvas_text]
3159
+ */
3160
+ setCanvasText(canvas_text) {
3161
+ wasm.wasmsession_setCanvasText(this.__wbg_ptr, isLikeNone(canvas_text) ? 0 : addHeapObject(canvas_text));
3162
+ }
3163
+ /**
3164
+ * Set how many CSS px make a physical inch on the host's screen: `96`,
3165
+ * the CSS inch — `72` for a spreadsheet, whose 100% is Mac Excel's —
3166
+ * unless the host calibrated it, so 100% shows a page at its real size, a
3167
+ * Letter page as wide as the paper beside the screen.
3168
+ * The viewer's dpi becomes `dpi × dpr`; the zoom stays, so the next frame
3169
+ * shows the same zoom at the new size.
3170
+ * @param {number} dpi
3171
+ */
3172
+ setDpi(dpi) {
3173
+ wasm.wasmsession_setDpi(this.__wbg_ptr, dpi);
3174
+ }
3175
+ /**
3176
+ * Set the fit: its `mode` is `"none"`, `"width"`, `"height"`, `"both"`
3177
+ * (contain) or `"either"` (cover); its `zoomCap` caps the derived zoom
3178
+ * (`null` uncapped, `1.0` to never enlarge past natural size). The viewer
3179
+ * derives the zoom to fit the current spread and re-derives it on resize;
3180
+ * while a fit is active the per-frame zoom in [`set_view`](Self::set_view)
3181
+ * is ignored. The derived zoom rides back to the host in
3182
+ * [`view_state`](Self::view_state)'s `scale`.
3183
+ *
3184
+ * # Errors
3185
+ * Returns a `JsValue` error if `fit` is not a [`Fit`].
3186
+ * @param {Fit} fit
3187
+ */
3188
+ setFit(fit) {
3189
+ try {
3190
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3191
+ wasm.wasmsession_setFit(retptr, this.__wbg_ptr, addBorrowedObject(fit));
3192
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3193
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3194
+ if (r1) {
3195
+ throw takeObject(r0);
3196
+ }
3197
+ } finally {
3198
+ wasm.__wbindgen_add_to_stack_pointer(16);
3199
+ heap[stack_pointer++] = undefined;
3200
+ }
3201
+ }
3202
+ /**
3203
+ * Toggle formatting marks — `¶` at each paragraph mark, a dot in each
3204
+ * space, an arrow in each tab and `↵` at each line break — drawn over
3205
+ * composed text in the space it already holds, so showing them never
3206
+ * reflows. On while an editor's user asks for them, never in an export.
3207
+ * Remembered across [`open`](Self::open) like the backdrop and applied to
3208
+ * the current document immediately, forcing a repaint on the next
3209
+ * [`render_frame`](Self::render_frame). PDF text ignores it; a
3210
+ * spreadsheet's cells compose through the same text engine as a slide's
3211
+ * and a page's, so they show marks too.
3212
+ * @param {boolean} on
3213
+ */
3214
+ setFormattingMarks(on) {
3215
+ wasm.wasmsession_setFormattingMarks(this.__wbg_ptr, on);
3216
+ }
3217
+ /**
3218
+ * Set the host's Google font catalog —
3219
+ * `[{ name, variants: [[bold, italic], …], subsets: ["latin", …] }]` —
3220
+ * replacing the one set before.
3221
+ *
3222
+ * There is no compiled-in family list: the host owns the catalog, because it
3223
+ * already owns the css2 protocol that fetches from it. An empty catalog *is*
3224
+ * Google disabled, so `[]` turns off a catalog set earlier. `subsets` feeds
3225
+ * only the script prefilter — the host's fulfiller picks what to actually
3226
+ * download from the live `unicode-range`s. Host state, like
3227
+ * [`registerLocalFont`](Self::register_local_font).
3228
+ *
3229
+ * # Errors
3230
+ *
3231
+ * If `families` isn't a list of that shape.
3232
+ * @param {GoogleFontFamily[]} families
3233
+ */
3234
+ setGoogleFontFamilies(families) {
3235
+ try {
3236
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3237
+ const ptr0 = passArrayJsValueToWasm0(families, wasm.__wbindgen_export);
3238
+ const len0 = WASM_VECTOR_LEN;
3239
+ wasm.wasmsession_setGoogleFontFamilies(retptr, this.__wbg_ptr, ptr0, len0);
3240
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3241
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3242
+ if (r1) {
3243
+ throw takeObject(r0);
3244
+ }
3245
+ } finally {
3246
+ wasm.__wbindgen_add_to_stack_pointer(16);
3247
+ }
3248
+ }
3249
+ /**
3250
+ * Set how the layout groups pages into spreads: `"singlePage"`,
3251
+ * `"doublePage"`, `"doublePageOddRight"` or `"doublePageOddLeft"`.
3252
+ * Remembered across [`open`](Self::open) like the spacing, and applied to
3253
+ * the current document immediately; the re-stack and repaint happen on the
3254
+ * next [`render_frame`](Self::render_frame).
3255
+ *
3256
+ * # Errors
3257
+ * Returns a `JsValue` error if `mode` is not one of the four names.
3258
+ * @param {LayoutMode} mode
3259
+ */
3260
+ setLayoutMode(mode) {
3261
+ try {
3262
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3263
+ wasm.wasmsession_setLayoutMode(retptr, this.__wbg_ptr, addBorrowedObject(mode));
3264
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3265
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3266
+ if (r1) {
3267
+ throw takeObject(r0);
3268
+ }
3269
+ } finally {
3270
+ wasm.__wbindgen_add_to_stack_pointer(16);
3271
+ heap[stack_pointer++] = undefined;
3272
+ }
3273
+ }
3274
+ /**
3275
+ * Set whether content overflowing the page bounds is drawn. When set, an
3276
+ * object that runs off the page stays visible within the spread (the
3277
+ * viewport in spread mode, or the page plus half the inter-page gap in
3278
+ * continuous); otherwise content is clipped to the page. Remembered across
3279
+ * [`open`](Self::open) like the scroll mode, and applied to the current
3280
+ * document immediately — only the clip changes, so the repaint happens on
3281
+ * the next [`render_frame`](Self::render_frame).
3282
+ * @param {boolean} visible
3283
+ */
3284
+ setOverflowVisible(visible) {
3285
+ wasm.wasmsession_setOverflowVisible(this.__wbg_ptr, visible);
3286
+ }
3287
+ /**
3288
+ * Set the page-border color — the 1-device-pixel frame drawn just outside
3289
+ * each page (typically the theme's outline, so the host recolors it per
3290
+ * theme) — from 8-bit sRGB components. Remembered across
3291
+ * [`open`](Self::open) (a fresh document otherwise draws none) and applied
3292
+ * to the current document immediately; the next
3293
+ * [`render_frame`](Self::render_frame) reconciles and repaints it.
3294
+ * @param {number} r
3295
+ * @param {number} g
3296
+ * @param {number} b
3297
+ */
3298
+ setPageBorderColor(r, g, b) {
3299
+ wasm.wasmsession_setPageBorderColor(this.__wbg_ptr, r, g, b);
3300
+ }
3301
+ /**
3302
+ * Turn every page `quarter_turns` quarter turns clockwise (`0`–`3`) on top
3303
+ * of its own rotation — a view setting, never a document edit. Remembered
3304
+ * across [`open`](Self::open) like the spacing, and applied to the current
3305
+ * document immediately; the re-stack and repaint happen on the next
3306
+ * [`render_frame`](Self::render_frame).
3307
+ *
3308
+ * # Errors
3309
+ * Returns a `JsValue` error if `quarter_turns` is past three.
3310
+ * @param {number} quarter_turns
3311
+ */
3312
+ setPageRotation(quarter_turns) {
3313
+ try {
3314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3315
+ wasm.wasmsession_setPageRotation(retptr, this.__wbg_ptr, quarter_turns);
3316
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3317
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3318
+ if (r1) {
3319
+ throw takeObject(r0);
3320
+ }
3321
+ } finally {
3322
+ wasm.__wbindgen_add_to_stack_pointer(16);
3323
+ }
3324
+ }
3325
+ /**
3326
+ * Turn the developer performance counter's per-frame timing on or off.
3327
+ * While on, [`render_frame`](Self::render_frame) splits each painted frame
3328
+ * into reconcile / record / rasterize / composite, readable via
3329
+ * [`frame_timings`](Self::frame_timings); while off, the frame path is
3330
+ * untimed and pays nothing. Sticky across [`open`](Self::open) — it lives
3331
+ * on the persistent canvas, not the per-document session.
3332
+ * @param {boolean} enabled
3333
+ */
3334
+ setPerf(enabled) {
3335
+ wasm.wasmsession_setPerf(this.__wbg_ptr, enabled);
3336
+ }
3337
+ /**
3338
+ * Toggle empty-placeholder authoring chrome — the dashed frame and
3339
+ * "Click to add …" prompt an empty presentation placeholder shows while it
3340
+ * is being edited. On for an editor, off for a reading view / export (an
3341
+ * empty placeholder then renders blank, as `PowerPoint`'s slideshow does).
3342
+ * Remembered across [`open`](Self::open) like the backdrop and applied to
3343
+ * the current document immediately, forcing a repaint on the next
3344
+ * [`render_frame`](Self::render_frame). Doc types without placeholders
3345
+ * (only presentations have them) ignore it.
3346
+ * @param {boolean} on
3347
+ */
3348
+ setPlaceholderPrompts(on) {
3349
+ wasm.wasmsession_setPlaceholderPrompts(this.__wbg_ptr, on);
3350
+ }
3351
+ /**
3352
+ * Set where this peer's pointer rests from the viewport point (CSS px)
3353
+ * it is at — the page under it and the point in that page's local space —
3354
+ * or delete it when the point is off every page. Presence only. Returns
3355
+ * the blob carrying that one entry, to send as a presence a peer
3356
+ * [merges](Self::merge_presence): a pointer set on every move travels
3357
+ * alone.
3358
+ *
3359
+ * # Errors
3360
+ * Returns a JS error if the session is not entitled to collaboration, no
3361
+ * document is open, or serialization fails.
3362
+ * @param {number} css_x
3363
+ * @param {number} css_y
3364
+ * @returns {Uint8Array}
3365
+ */
3366
+ setPointer(css_x, css_y) {
3367
+ try {
3368
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3369
+ wasm.wasmsession_setPointer(retptr, this.__wbg_ptr, css_x, css_y);
3370
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3371
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3372
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3373
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3374
+ if (r3) {
3375
+ throw takeObject(r2);
3376
+ }
3377
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3378
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3379
+ return v1;
3380
+ } finally {
3381
+ wasm.__wbindgen_add_to_stack_pointer(16);
3382
+ }
3383
+ }
3384
+ /**
3385
+ * Switch the scroll mode: `"spread"` (one spread at a time) or
3386
+ * `"continuous"` (the scrolling stack default). Remembered across
3387
+ * [`open`](Self::open) like the backdrop and spacing, and applied to the
3388
+ * current document immediately — keeping the page you were on in view. The
3389
+ * repaint happens on the next [`render_frame`](Self::render_frame).
3390
+ *
3391
+ * # Errors
3392
+ * Returns a `JsValue` error if `mode` is not one of the two names.
3393
+ * @param {ScrollMode} mode
3394
+ */
3395
+ setScrollMode(mode) {
3396
+ try {
3397
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3398
+ wasm.wasmsession_setScrollMode(retptr, this.__wbg_ptr, addBorrowedObject(mode));
3399
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3400
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3401
+ if (r1) {
3402
+ throw takeObject(r0);
3403
+ }
3404
+ } finally {
3405
+ wasm.__wbindgen_add_to_stack_pointer(16);
3406
+ heap[stack_pointer++] = undefined;
3407
+ }
3408
+ }
3409
+ /**
3410
+ * Set the scrollbar size, in CSS px — the thickness of the strip the camera
3411
+ * keeps clear along the right edge while the vertical bar shows and along
3412
+ * the bottom while the horizontal one does, for the host to draw the bar
3413
+ * in ([`viewState`](Self::view_state) says which show). A fit measures the
3414
+ * viewport less one strip on each axis, so the zoom never follows the bars.
3415
+ * `0` (the default) keeps no strip, for bars that float over the content;
3416
+ * negative or `NaN` counts as `0`. Remembered across [`open`](Self::open)
3417
+ * like the spacing, re-stretched on a dpr change, and applied to the
3418
+ * current document immediately.
3419
+ * @param {number} css_px
3420
+ */
3421
+ setScrollbarSize(css_px) {
3422
+ wasm.wasmsession_setScrollbarSize(this.__wbg_ptr, css_px);
3423
+ }
3424
+ /**
3425
+ * Replace the selection from its JSON wire form — externally tagged by doc
3426
+ * type, e.g. `{"portable":{"objects":["7-0"]}}` or `{"portable":"none"}`
3427
+ * (see [`UDocSelection`]). Presence only: not a command, not undoable.
3428
+ * This is the agnostic seam that replaces the per-doc-type select verbs —
3429
+ * the host builds the JSON (stamping the object ids it minted or read back
3430
+ * from [`selection`](Self::selection)) and gets the new selection geometry.
3431
+ * A `None` selection clears.
3432
+ *
3433
+ * # Errors
3434
+ * Returns a JS error if no document is open, the JSON is malformed, or its
3435
+ * doc type doesn't match the open document.
3436
+ *
3437
+ * [`UDocSelection`]: docmentis_udoc_facade::UDocSelection
3438
+ * @param {UDocSelection} selection
3439
+ * @returns {SelectionGeometry}
3440
+ */
3441
+ setSelection(selection) {
3442
+ try {
3443
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3444
+ wasm.wasmsession_setSelection(retptr, this.__wbg_ptr, addBorrowedObject(selection));
3445
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3446
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3447
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3448
+ if (r2) {
3449
+ throw takeObject(r1);
3450
+ }
3451
+ return takeObject(r0);
3452
+ } finally {
3453
+ wasm.__wbindgen_add_to_stack_pointer(16);
3454
+ heap[stack_pointer++] = undefined;
3455
+ }
3456
+ }
3457
+ /**
3458
+ * Set the page arrangement's spacing — the `content_padding` on each edge of
3459
+ * the content block and the `page_gap` between adjacent pages, across a
3460
+ * spread and down from one spread to the next. The gaps are in document
3461
+ * points (page-fixed: they scale with zoom and read as part of the paper).
3462
+ * Each padding edge is a
3463
+ * `ViewLength` — screen-fixed pixels (`px`, sized for screen chrome) or
3464
+ * document points (`pt`). The host sends both in its own CSS units; this
3465
+ * boundary multiplies the `px` edges by the dpr into the viewer's device px
3466
+ * (the `pt` edges and the gap are page units and pass through). The CSS-px
3467
+ * padding is remembered across [`open`](Self::open) like the backdrop and
3468
+ * applied to the current document immediately, keeping the page at the
3469
+ * viewport's top edge anchored. A dpr change re-stretches the `px` edges
3470
+ * automatically ([`resize`](Self::resize) re-applies), so the host sets the
3471
+ * spacing once and never re-sends it.
3472
+ *
3473
+ * # Errors
3474
+ * Returns a JS error if the [`ContentPadding`] or [`PageGap`] JSON can't be
3475
+ * decoded.
3476
+ * @param {ContentPadding} content_padding
3477
+ * @param {PageGap} page_gap
3478
+ */
3479
+ setSpacing(content_padding, page_gap) {
3480
+ try {
3481
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3482
+ wasm.wasmsession_setSpacing(retptr, this.__wbg_ptr, addBorrowedObject(content_padding), addBorrowedObject(page_gap));
3483
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3484
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3485
+ if (r1) {
3486
+ throw takeObject(r0);
3487
+ }
3488
+ } finally {
3489
+ wasm.__wbindgen_add_to_stack_pointer(16);
3490
+ heap[stack_pointer++] = undefined;
3491
+ heap[stack_pointer++] = undefined;
3492
+ }
3493
+ }
3494
+ /**
3495
+ * Set the local user's info (currently a display name) shown on this peer's
3496
+ * selection to others. Sticky like the backdrop: remembered and re-applied
3497
+ * to every document opened later (a fresh session's presence starts
3498
+ * nameless), so it survives a re-open. Rides the presence channel with the
3499
+ * selection — the host re-broadcasts [`presence`](Self::presence) so peers
3500
+ * pick it up.
3501
+ * @param {string} name
3502
+ */
3503
+ setUserInfo(name) {
3504
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3505
+ const len0 = WASM_VECTOR_LEN;
3506
+ wasm.wasmsession_setUserInfo(this.__wbg_ptr, ptr0, len0);
3507
+ }
3508
+ /**
3509
+ * Scroll and/or zoom changed. The viewer clamps scroll and, in fit
3510
+ * modes, derives zoom; the actual blit/repaint happens once per frame
3511
+ * in [`Self::render_frame`].
3512
+ * @param {number} scroll_x
3513
+ * @param {number} scroll_y
3514
+ * @param {number} zoom
3515
+ */
3516
+ setView(scroll_x, scroll_y, zoom) {
3517
+ wasm.wasmsession_setView(this.__wbg_ptr, scroll_x, scroll_y, zoom);
3518
+ }
3519
+ /**
3520
+ * Serialize the session's full CRDT state for a fresh peer — an opaque blob
3521
+ * to hand another session's [`mergePatch`](Self::merge_patch). For delta sync, use
3522
+ * [`versionVector`](Self::version_vector) + [`patchSince`](Self::patch_since)
3523
+ * instead; this ships the whole document.
3524
+ *
3525
+ * # Errors
3526
+ * Returns a JS error if the session is not entitled to collaboration, no
3527
+ * document is open, or serialization fails.
3528
+ * @returns {Uint8Array}
3529
+ */
3530
+ snapshot() {
3531
+ try {
3532
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3533
+ wasm.wasmsession_snapshot(retptr, this.__wbg_ptr);
3534
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3535
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3536
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3537
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3538
+ if (r3) {
3539
+ throw takeObject(r2);
3540
+ }
3541
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3542
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3543
+ return v1;
3544
+ } finally {
3545
+ wasm.__wbindgen_add_to_stack_pointer(16);
3546
+ }
3547
+ }
3548
+ /**
3549
+ * The file format the open document came from (`"pdf"`, `"pptx"`,
3550
+ * `"png"`, …) — what saving it back means — or `undefined` when nothing is
3551
+ * open or a package recorded none.
3552
+ * @returns {FileFormat | undefined}
3553
+ */
3554
+ sourceFormat() {
3555
+ const ret = wasm.wasmsession_sourceFormat(this.__wbg_ptr);
3556
+ return takeObject(ret);
3557
+ }
3558
+ /**
3559
+ * Take the outstanding font orders —
3560
+ * `[{ id, family, bold, italic, vendor, characters }]`, `[]` when there is
3561
+ * nothing to fetch.
3562
+ *
3563
+ * **The host does the fetching.** Each order names a font and the characters
3564
+ * wanted from it; `vendor` is either `"google"` (ask css2, read the
3565
+ * `unicode-range`s, download the blocks that hold those characters) or
3566
+ * `{ url: { url } }`. Fetch them however you like — in parallel, with
3567
+ * whatever retry policy — then settle each with
3568
+ * [`completeFontRequest`](Self::complete_font_request) and call
3569
+ * [`refreshFonts`](Self::refresh_fonts) once for the batch.
3570
+ *
3571
+ * Nothing here blocks or waits: an order is out until it is settled, and the
3572
+ * document keeps rendering in a stand-in throughout.
3573
+ *
3574
+ * # Errors
3575
+ *
3576
+ * If the order list can't be serialized.
3577
+ * @returns {FontRequest[]}
3578
+ */
3579
+ takeFontRequests() {
3580
+ try {
3581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3582
+ wasm.wasmsession_takeFontRequests(retptr, this.__wbg_ptr);
3583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3585
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3586
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3587
+ if (r3) {
3588
+ throw takeObject(r2);
3589
+ }
3590
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
3591
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
3592
+ return v1;
3593
+ } finally {
3594
+ wasm.__wbindgen_add_to_stack_pointer(16);
3595
+ }
3596
+ }
3597
+ /**
3598
+ * The current slide's resolved theme color palette as a JSON string — the
3599
+ * mapped scheme slots (`bg1`/`tx1`/accents/links) a host renders as "Theme
3600
+ * Colors", each a `#rrggbb` device-sRGB hex. `undefined` when no document is
3601
+ * open or the doc type carries no theme (only presentations do). The host
3602
+ * `JSON.parse`s it into `{ name, text1, background1, … }` (camelCase keys)
3603
+ * and drives its color picker with the resolved swatches. Per slide, not
3604
+ * per document (a multi-master deck re-themes per slide); loads that slide's
3605
+ * theme chain on demand, hence `&mut self`.
3606
+ * @returns {string | undefined}
3607
+ */
3608
+ themePalette() {
3609
+ try {
3610
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3611
+ wasm.wasmsession_themePalette(retptr, this.__wbg_ptr);
3612
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3613
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3614
+ let v1;
3615
+ if (r0 !== 0) {
3616
+ v1 = getStringFromWasm0(r0, r1).slice();
3617
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3618
+ }
3619
+ return v1;
3620
+ } finally {
3621
+ wasm.__wbindgen_add_to_stack_pointer(16);
3622
+ }
3623
+ }
3624
+ /**
3625
+ * Undo the last edit. Relayouts like the page-edit methods, so the host's
3626
+ * follow-up pulls see the reverted state.
3627
+ *
3628
+ * # Errors
3629
+ * Returns a JS error if no document is open or the undo fails.
3630
+ */
3631
+ undo() {
3632
+ try {
3633
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3634
+ wasm.wasmsession_undo(retptr, this.__wbg_ptr);
3635
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3636
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3637
+ if (r1) {
3638
+ throw takeObject(r0);
3639
+ }
3640
+ } finally {
3641
+ wasm.__wbindgen_add_to_stack_pointer(16);
3642
+ }
3643
+ }
3644
+ /**
3645
+ * Compose ahead through page index `page_limit`, growing the composed
3646
+ * prefix, and return whether the document is now **fully composed**. The
3647
+ * idle compose-ahead seam: the host calls it from `requestIdleCallback`
3648
+ * with a rising limit (e.g. `composedPageCount + 1` to advance one page)
3649
+ * until it returns `true` — at which point
3650
+ * [`composedPageCount`](Self::composed_page_count) is the document's page
3651
+ * count. There is no total to ask for up front: a page is known only once
3652
+ * composed.
3653
+ *
3654
+ * Best-effort, like every viewer-side compose: a page that fails to
3655
+ * compose is left out (it paints as a placeholder) and reported as *not*
3656
+ * complete rather than thrown, so one bad page can't abort the pump. A
3657
+ * host that needs the failure — a batch export — drives the native
3658
+ * `UDocSession::update_layout`, which returns it. Since a stalled page
3659
+ * keeps `false` coming back, pair the flag with a no-progress guard on
3660
+ * `composedPageCount`.
3661
+ *
3662
+ * # Errors
3663
+ * Returns a JS error if no document is open.
3664
+ * @param {number} page_limit
3665
+ * @returns {boolean}
3666
+ */
3667
+ updateLayout(page_limit) {
3668
+ try {
3669
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3670
+ wasm.wasmsession_updateLayout(retptr, this.__wbg_ptr, page_limit);
3671
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3672
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3673
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3674
+ if (r2) {
3675
+ throw takeObject(r1);
3676
+ }
3677
+ return r0 !== 0;
3678
+ } finally {
3679
+ wasm.__wbindgen_add_to_stack_pointer(16);
3680
+ }
3681
+ }
3682
+ /**
3683
+ * The session's version vector — the opaque handshake token to hand another
3684
+ * session's [`patchSince`](Self::patch_since) so it can send back only the
3685
+ * ops this session lacks.
3686
+ *
3687
+ * # Errors
3688
+ * Returns a JS error if the session is not entitled to collaboration, no
3689
+ * document is open, or serialization fails.
3690
+ * @returns {Uint8Array}
3691
+ */
3692
+ versionVector() {
3693
+ try {
3694
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3695
+ wasm.wasmsession_versionVector(retptr, this.__wbg_ptr);
3696
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3697
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3698
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3699
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3700
+ if (r3) {
3701
+ throw takeObject(r2);
3702
+ }
3703
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3704
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3705
+ return v1;
3706
+ } finally {
3707
+ wasm.__wbindgen_add_to_stack_pointer(16);
3708
+ }
3709
+ }
3710
+ /**
3711
+ * The authoritative view state as `[scale, scrollX, scrollY,
3712
+ * contentWidth, contentHeight, currentPage, usedWidth, usedHeight,
3713
+ * scrollbarX, scrollbarY]`: the CSS px per document point under the current
3714
+ * zoom (`zoom × dpi / 72`), the scroll/extent in document points after the
3715
+ * viewer's clamping/anchoring, the 0-based index of the page the viewport is
3716
+ * centered on (`-1` when no page is arranged), the **used** content size the
3717
+ * scrollbar is drawn from (the scrollable extent for most doc types; a
3718
+ * spreadsheet's used data range, which is smaller than its scrollable grid),
3719
+ * and whether the horizontal / vertical scrollbar shows (`1` / `0`) — the
3720
+ * bars the frame kept a strip clear for. Streamed to the main thread beside
3721
+ * [`pageViewRects`](Self::page_view_rects) each painted frame: with
3722
+ * screen-fixed (px) spacing the content extent — and, across a re-arrangement,
3723
+ * the scroll — depend on zoom in ways the host can't derive, so it adopts
3724
+ * these instead. The guide chrome rides its own structured pull
3725
+ * ([`guide`](Self::guide)). Empty when no document is open.
3726
+ * @returns {Float64Array}
3727
+ */
3728
+ viewState() {
3729
+ try {
3730
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3731
+ wasm.wasmsession_viewState(retptr, this.__wbg_ptr);
3732
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3733
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3734
+ var v1 = getArrayF64FromWasm0(r0, r1).slice();
3735
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
3736
+ return v1;
3737
+ } finally {
3738
+ wasm.__wbindgen_add_to_stack_pointer(16);
3739
+ }
3740
+ }
3741
+ /**
3742
+ * Leave the presence channel: the blob deleting this peer's entries for
3743
+ * every peer that [merges](Self::merge_presence) it, with every peer's
3744
+ * entries forgotten here. A host leaving a collaboration sends it before
3745
+ * it goes, and re-pulls the peers after.
3746
+ *
3747
+ * # Errors
3748
+ * Returns a JS error if the session is not entitled to collaboration, no
3749
+ * document is open, or serialization fails.
3750
+ * @returns {Uint8Array}
3751
+ */
3752
+ withdrawPresence() {
3753
+ try {
3754
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3755
+ wasm.wasmsession_withdrawPresence(retptr, this.__wbg_ptr);
3756
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3757
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3758
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3759
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3760
+ if (r3) {
3761
+ throw takeObject(r2);
3762
+ }
3763
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3764
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3765
+ return v1;
3766
+ } finally {
3767
+ wasm.__wbindgen_add_to_stack_pointer(16);
3768
+ }
3769
+ }
3770
+ /**
3771
+ * Zoom to an explicit magnification keeping the content point under the
3772
+ * viewport point (`x`, `y`, **CSS px**) pinned on screen — cursor-anchored
3773
+ * zoom (the wheel and the zoom controls). Multiplied by the dpr into the
3774
+ * viewer's device px here, like every pointer intent. Unlike
3775
+ * [`set_view`](Self::set_view) the engine owns the resulting scroll, so it's
3776
+ * exact at any step; it rides back in the next
3777
+ * [`view_state`](Self::view_state). Clears any active fit. A no-op when no
3778
+ * document is open.
3779
+ * @param {number} zoom
3780
+ * @param {number} css_x
3781
+ * @param {number} css_y
3782
+ */
3783
+ zoomAtPoint(zoom, css_x, css_y) {
3784
+ wasm.wasmsession_zoomAtPoint(this.__wbg_ptr, zoom, css_x, css_y);
3785
+ }
3786
+ /**
3787
+ * Fit a viewport-space rectangle (`x`, `y`, `width`, `height` in **CSS px**)
3788
+ * to the viewport and centre it — the marquee zoom. Multiplied by the dpr
3789
+ * into the viewer's device px here. The engine derives the zoom and resolves
3790
+ * the scroll after re-arranging, so it stays correct across the screen-fixed
3791
+ * spacing a host can't account for. The result rides back in the next
3792
+ * [`view_state`](Self::view_state). A no-op when no document is open or for a
3793
+ * doc type without a paginated view.
3794
+ * @param {number} css_x
3795
+ * @param {number} css_y
3796
+ * @param {number} css_width
3797
+ * @param {number} css_height
3798
+ */
3799
+ zoomToRect(css_x, css_y, css_width, css_height) {
3800
+ wasm.wasmsession_zoomToRect(this.__wbg_ptr, css_x, css_y, css_width, css_height);
3801
+ }
3802
+ }
3803
+ if (Symbol.dispose) WasmSession.prototype[Symbol.dispose] = WasmSession.prototype.free;
3804
+
3805
+ /**
3806
+ * Start a licensed or permitted session — the module's only constructor.
3807
+ *
3808
+ * Validates the license offline; a valid one's features are the session's, and
3809
+ * this returns without touching the network. Otherwise the session is free
3810
+ * tier: this mints a nonce, asks the permit server for a permit, and verifies
3811
+ * the one it gets back, all inside wasm — and the features that permit grants
3812
+ * are the session's.
3813
+ *
3814
+ * Being a free function, it borrows no session across its `await`, so the
3815
+ * host's frame loop and message pump keep running while the permit is in
3816
+ * flight.
3817
+ *
3818
+ * # Errors
3819
+ * A `UDocError` describing the refusal — its `code` `invalidLicense`,
3820
+ * `permitRefused` or `cannotVerify`, the variant's fields its `detail` — and the
3821
+ * same refusal on the console with the specifics; or, for a `config` that
3822
+ * won't decode, an `invalidRequest` one. A supplied key that does not validate is a
3823
+ * refusal like any other: it does **not** fall back to metered free usage,
3824
+ * because a customer whose key broke should be told, not quietly metered until
3825
+ * they hit a cap.
3826
+ * @param {SessionConfig} config
3827
+ * @returns {Promise<WasmSession>}
3828
+ */
3829
+ export function startSession(config) {
3830
+ const ret = wasm.startSession(addHeapObject(config));
3831
+ return takeObject(ret);
3832
+ }
3833
+ function __wbg_get_imports() {
3834
+ const import0 = {
3835
+ __proto__: null,
3836
+ __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
3837
+ const ret = typeof(getObject(arg0)) === 'function';
3838
+ return ret;
3839
+ },
3840
+ __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
3841
+ const val = getObject(arg0);
3842
+ const ret = typeof(val) === 'object' && val !== null;
3843
+ return ret;
3844
+ },
3845
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
3846
+ const ret = typeof(getObject(arg0)) === 'string';
3847
+ return ret;
3848
+ },
3849
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
3850
+ const ret = getObject(arg0) === undefined;
3851
+ return ret;
3852
+ },
3853
+ __wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
3854
+ const obj = getObject(arg1);
3855
+ const ret = typeof(obj) === 'number' ? obj : undefined;
3856
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3857
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3858
+ },
3859
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
3860
+ const obj = getObject(arg1);
3861
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3862
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3863
+ var len1 = WASM_VECTOR_LEN;
3864
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3865
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3866
+ },
3867
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
3868
+ throw new Error(getStringFromWasm0(arg0, arg1));
3869
+ },
3870
+ __wbg__wbg_cb_unref_61db23ac97f16c31: function(arg0) {
3871
+ getObject(arg0)._wbg_cb_unref();
3872
+ },
3873
+ __wbg_assign_671cc7293104db6d: function(arg0, arg1) {
3874
+ const ret = Object.assign(getObject(arg0), getObject(arg1));
3875
+ return addHeapObject(ret);
3876
+ },
3877
+ __wbg_beginPath_13add782681be0f7: function(arg0) {
3878
+ getObject(arg0).beginPath();
3879
+ },
3880
+ __wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
3881
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
3882
+ return addHeapObject(ret);
3883
+ }, arguments); },
3884
+ __wbg_clearRect_3e4ce26e687ec49f: function(arg0, arg1, arg2, arg3, arg4) {
3885
+ getObject(arg0).clearRect(arg1, arg2, arg3, arg4);
3886
+ },
3887
+ __wbg_clip_5f059eebddcbe6ae: function(arg0) {
3888
+ getObject(arg0).clip();
3889
+ },
3890
+ __wbg_covers_ccd7618eb4a0c3da: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3891
+ const ret = getObject(arg0).covers(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
3892
+ return ret;
3893
+ }, arguments); },
3894
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
3895
+ const ret = getObject(arg0).crypto;
3896
+ return addHeapObject(ret);
3897
+ },
3898
+ __wbg_drawImage_c3d17f387dd48be1: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3899
+ getObject(arg0).drawImage(getObject(arg1), arg2, arg3);
3900
+ }, arguments); },
3901
+ __wbg_error_78ff5b3a29b770e0: function(arg0) {
3902
+ console.error(getObject(arg0));
3903
+ },
3904
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
3905
+ let deferred0_0;
3906
+ let deferred0_1;
3907
+ try {
3908
+ deferred0_0 = arg0;
3909
+ deferred0_1 = arg1;
3910
+ console.error(getStringFromWasm0(arg0, arg1));
3911
+ } finally {
3912
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
3913
+ }
3914
+ },
3915
+ __wbg_fetch_8e5a5301575dfbb6: function() { return handleError(function (arg0) {
3916
+ const ret = fetch(getObject(arg0));
3917
+ return addHeapObject(ret);
3918
+ }, arguments); },
3919
+ __wbg_fillRect_515c1159951ba081: function(arg0, arg1, arg2, arg3, arg4) {
3920
+ getObject(arg0).fillRect(arg1, arg2, arg3, arg4);
3921
+ },
3922
+ __wbg_getContext_7d3a8f461c828713: function() { return handleError(function (arg0, arg1, arg2) {
3923
+ const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));
3924
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
3925
+ }, arguments); },
3926
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
3927
+ getObject(arg0).getRandomValues(getObject(arg1));
3928
+ }, arguments); },
3929
+ __wbg_getTime_00b3f7db575e4ef5: function(arg0) {
3930
+ const ret = getObject(arg0).getTime();
3931
+ return ret;
3932
+ },
3933
+ __wbg_getTimezoneOffset_08e2892156231088: function(arg0) {
3934
+ const ret = getObject(arg0).getTimezoneOffset();
3935
+ return ret;
3936
+ },
3937
+ __wbg_get_de6a0f7d4d18a304: function() { return handleError(function (arg0, arg1) {
3938
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
3939
+ return addHeapObject(ret);
3940
+ }, arguments); },
3941
+ __wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
3942
+ const ret = getObject(arg0)[arg1 >>> 0];
3943
+ return addHeapObject(ret);
3944
+ },
3945
+ __wbg_height_6664d43063375ca4: function(arg0) {
3946
+ const ret = getObject(arg0).height;
3947
+ return ret;
3948
+ },
3949
+ __wbg_instanceof_OffscreenCanvasRenderingContext2d_2649509607c20f77: function(arg0) {
3950
+ let result;
3951
+ try {
3952
+ result = getObject(arg0) instanceof OffscreenCanvasRenderingContext2D;
3953
+ } catch (_) {
3954
+ result = false;
3955
+ }
3956
+ const ret = result;
3957
+ return ret;
3958
+ },
3959
+ __wbg_instanceof_Response_cb984bd66d7bd408: function(arg0) {
3960
+ let result;
3961
+ try {
3962
+ result = getObject(arg0) instanceof Response;
3963
+ } catch (_) {
3964
+ result = false;
3965
+ }
3966
+ const ret = result;
3967
+ return ret;
3968
+ },
3969
+ __wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
3970
+ let result;
3971
+ try {
3972
+ result = getObject(arg0) instanceof Uint8Array;
3973
+ } catch (_) {
3974
+ result = false;
3975
+ }
3976
+ const ret = result;
3977
+ return ret;
3978
+ },
3979
+ __wbg_instanceof_WorkerGlobalScope_fe1d59aa8cd22e9a: function(arg0) {
3980
+ let result;
3981
+ try {
3982
+ result = getObject(arg0) instanceof WorkerGlobalScope;
3983
+ } catch (_) {
3984
+ result = false;
3985
+ }
3986
+ const ret = result;
3987
+ return ret;
3988
+ },
3989
+ __wbg_length_4a591ecaa01354d9: function(arg0) {
3990
+ const ret = getObject(arg0).length;
3991
+ return ret;
3992
+ },
3993
+ __wbg_length_66f1a4b2e9026940: function(arg0) {
3994
+ const ret = getObject(arg0).length;
3995
+ return ret;
3996
+ },
3997
+ __wbg_measure_472c24e52a63dff8: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3998
+ const ret = getObject(arg0).measure(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
3999
+ return ret;
4000
+ }, arguments); },
4001
+ __wbg_metrics_4e3e3c9e1e0cac37: function() { return handleError(function (arg0, arg1, arg2) {
4002
+ const ret = getObject(arg0).metrics(getStringFromWasm0(arg1, arg2));
4003
+ return addHeapObject(ret);
4004
+ }, arguments); },
4005
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
4006
+ const ret = getObject(arg0).msCrypto;
4007
+ return addHeapObject(ret);
4008
+ },
4009
+ __wbg_new_0_445c13a750296eb6: function() {
4010
+ const ret = new Date();
4011
+ return addHeapObject(ret);
4012
+ },
4013
+ __wbg_new_227d7c05414eb861: function() {
4014
+ const ret = new Error();
4015
+ return addHeapObject(ret);
4016
+ },
4017
+ __wbg_new_3b242422c588a8f3: function() { return handleError(function (arg0, arg1) {
4018
+ const ret = new OffscreenCanvas(arg0 >>> 0, arg1 >>> 0);
4019
+ return addHeapObject(ret);
4020
+ }, arguments); },
4021
+ __wbg_new_50bb5ebeecef71a8: function(arg0, arg1) {
4022
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
4023
+ return addHeapObject(ret);
4024
+ },
4025
+ __wbg_new_6d75fd236f920a62: function(arg0) {
4026
+ const ret = new Date(getObject(arg0));
4027
+ return addHeapObject(ret);
4028
+ },
4029
+ __wbg_new_ce1ab61c1c2b300d: function() {
4030
+ const ret = new Object();
4031
+ return addHeapObject(ret);
4032
+ },
4033
+ __wbg_new_d90091b82fdf5b91: function() {
4034
+ const ret = new Array();
4035
+ return addHeapObject(ret);
4036
+ },
4037
+ __wbg_new_e436d06bc8e77460: function() { return handleError(function () {
4038
+ const ret = new Headers();
4039
+ return addHeapObject(ret);
4040
+ }, arguments); },
4041
+ __wbg_new_typed_bf31d18f92484486: function(arg0, arg1) {
4042
+ try {
4043
+ var state0 = {a: arg0, b: arg1};
4044
+ var cb0 = (arg0, arg1) => {
4045
+ const a = state0.a;
4046
+ state0.a = 0;
4047
+ try {
4048
+ return __wasm_bindgen_func_elem_68499(a, state0.b, arg0, arg1);
4049
+ } finally {
4050
+ state0.a = a;
4051
+ }
4052
+ };
4053
+ const ret = new Promise(cb0);
4054
+ return addHeapObject(ret);
4055
+ } finally {
4056
+ state0.a = 0;
4057
+ }
4058
+ },
4059
+ __wbg_new_with_length_36a4998e27b014c5: function(arg0) {
4060
+ const ret = new Uint8Array(arg0 >>> 0);
4061
+ return addHeapObject(ret);
4062
+ },
4063
+ __wbg_new_with_str_and_init_bcd02b79a793d27f: function() { return handleError(function (arg0, arg1, arg2) {
4064
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
4065
+ return addHeapObject(ret);
4066
+ }, arguments); },
4067
+ __wbg_new_with_u8_clamped_array_and_sh_e3609225f4ad3a74: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4068
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
4069
+ return addHeapObject(ret);
4070
+ }, arguments); },
4071
+ __wbg_node_84ea875411254db1: function(arg0) {
4072
+ const ret = getObject(arg0).node;
4073
+ return addHeapObject(ret);
4074
+ },
4075
+ __wbg_now_190933fa139cc119: function() {
4076
+ const ret = Date.now();
4077
+ return ret;
4078
+ },
4079
+ __wbg_now_f462ca322babb89f: function() {
4080
+ const ret = Date.now();
4081
+ return ret;
4082
+ },
4083
+ __wbg_now_f565250295e2d180: function(arg0) {
4084
+ const ret = getObject(arg0).now();
4085
+ return ret;
4086
+ },
4087
+ __wbg_parse_03863847d06c4e89: function() { return handleError(function (arg0, arg1) {
4088
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
4089
+ return addHeapObject(ret);
4090
+ }, arguments); },
4091
+ __wbg_performance_6712214a47b62987: function(arg0) {
4092
+ const ret = getObject(arg0).performance;
4093
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
4094
+ },
4095
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
4096
+ const ret = getObject(arg0).process;
4097
+ return addHeapObject(ret);
4098
+ },
4099
+ __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
4100
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
4101
+ },
4102
+ __wbg_push_a6822215aa43e71c: function(arg0, arg1) {
4103
+ const ret = getObject(arg0).push(getObject(arg1));
4104
+ return ret;
4105
+ },
4106
+ __wbg_putImageData_18be978638bb8a18: function() { return handleError(function (arg0, arg1, arg2, arg3) {
4107
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
4108
+ }, arguments); },
4109
+ __wbg_queueMicrotask_35c611f4a14830b2: function(arg0) {
4110
+ queueMicrotask(getObject(arg0));
4111
+ },
4112
+ __wbg_queueMicrotask_404ed0a58e0b63cc: function(arg0) {
4113
+ const ret = getObject(arg0).queueMicrotask;
4114
+ return addHeapObject(ret);
4115
+ },
4116
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
4117
+ getObject(arg0).randomFillSync(takeObject(arg1));
4118
+ }, arguments); },
4119
+ __wbg_rasterize_52a5149dd7613d64: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
4120
+ const ret = getObject(arg0).rasterize(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getArrayF64FromWasm0(arg5, arg6), arg7 === 0 ? undefined : arg8);
4121
+ return addHeapObject(ret);
4122
+ }, arguments); },
4123
+ __wbg_rect_cfd51c6824c010ab: function(arg0, arg1, arg2, arg3, arg4) {
4124
+ getObject(arg0).rect(arg1, arg2, arg3, arg4);
4125
+ },
4126
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
4127
+ const ret = module.require;
4128
+ return addHeapObject(ret);
4129
+ }, arguments); },
4130
+ __wbg_resolve_25a7e548d5881dca: function(arg0) {
4131
+ const ret = Promise.resolve(getObject(arg0));
4132
+ return addHeapObject(ret);
4133
+ },
4134
+ __wbg_restore_e6b5ec8b57c26465: function(arg0) {
4135
+ getObject(arg0).restore();
4136
+ },
4137
+ __wbg_save_5b28126dc816c631: function(arg0) {
4138
+ getObject(arg0).save();
4139
+ },
4140
+ __wbg_set_25ef40a9aeff260d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4141
+ getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4142
+ }, arguments); },
4143
+ __wbg_set_6e30c9374c26414c: function() { return handleError(function (arg0, arg1, arg2) {
4144
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
4145
+ return ret;
4146
+ }, arguments); },
4147
+ __wbg_set_body_36614c7e61546809: function(arg0, arg1) {
4148
+ getObject(arg0).body = getObject(arg1);
4149
+ },
4150
+ __wbg_set_fillStyle_73054f7e9d1c5cbe: function(arg0, arg1, arg2) {
4151
+ getObject(arg0).fillStyle = getStringFromWasm0(arg1, arg2);
4152
+ },
4153
+ __wbg_set_headers_7c1e39ece7826bec: function(arg0, arg1) {
4154
+ getObject(arg0).headers = getObject(arg1);
4155
+ },
4156
+ __wbg_set_method_7a6811dec7a4feff: function(arg0, arg1, arg2) {
4157
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
4158
+ },
4159
+ __wbg_set_name_3c3fc49c8f747e56: function(arg0, arg1, arg2) {
4160
+ getObject(arg0).name = getStringFromWasm0(arg1, arg2);
4161
+ },
4162
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
4163
+ const ret = getObject(arg1).stack;
4164
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4165
+ const len1 = WASM_VECTOR_LEN;
4166
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4167
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4168
+ },
4169
+ __wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
4170
+ const ret = typeof global === 'undefined' ? null : global;
4171
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
4172
+ },
4173
+ __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
4174
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
4175
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
4176
+ },
4177
+ __wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
4178
+ const ret = typeof self === 'undefined' ? null : self;
4179
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
4180
+ },
4181
+ __wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
4182
+ const ret = typeof window === 'undefined' ? null : window;
4183
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
4184
+ },
4185
+ __wbg_stringify_8286df6dcc591521: function() { return handleError(function (arg0) {
4186
+ const ret = JSON.stringify(getObject(arg0));
4187
+ return addHeapObject(ret);
4188
+ }, arguments); },
4189
+ __wbg_subarray_4aa221f6a4f5ab22: function(arg0, arg1, arg2) {
4190
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
4191
+ return addHeapObject(ret);
4192
+ },
4193
+ __wbg_text_a17febec76d36501: function() { return handleError(function (arg0) {
4194
+ const ret = getObject(arg0).text();
4195
+ return addHeapObject(ret);
4196
+ }, arguments); },
4197
+ __wbg_then_18f476d590e58992: function(arg0, arg1, arg2) {
4198
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
4199
+ return addHeapObject(ret);
4200
+ },
4201
+ __wbg_then_ac7b025999b52837: function(arg0, arg1) {
4202
+ const ret = getObject(arg0).then(getObject(arg1));
4203
+ return addHeapObject(ret);
4204
+ },
4205
+ __wbg_toISOString_d485be0388a74494: function(arg0) {
4206
+ const ret = getObject(arg0).toISOString();
4207
+ return addHeapObject(ret);
4208
+ },
4209
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
4210
+ const ret = getObject(arg0).versions;
4211
+ return addHeapObject(ret);
4212
+ },
4213
+ __wbg_wasmsession_new: function(arg0) {
4214
+ const ret = WasmSession.__wrap(arg0);
4215
+ return addHeapObject(ret);
4216
+ },
4217
+ __wbg_width_440db126d7331632: function(arg0) {
4218
+ const ret = getObject(arg0).width;
4219
+ return ret;
4220
+ },
4221
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
4222
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 15189, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4223
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_68497);
4224
+ return addHeapObject(ret);
4225
+ },
4226
+ __wbindgen_cast_0000000000000002: function(arg0) {
4227
+ // Cast intrinsic for `F64 -> Externref`.
4228
+ const ret = arg0;
4229
+ return addHeapObject(ret);
4230
+ },
4231
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
4232
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
4233
+ const ret = getArrayU8FromWasm0(arg0, arg1);
4234
+ return addHeapObject(ret);
4235
+ },
4236
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
4237
+ // Cast intrinsic for `Ref(String) -> Externref`.
4238
+ const ret = getStringFromWasm0(arg0, arg1);
4239
+ return addHeapObject(ret);
4240
+ },
4241
+ __wbindgen_object_clone_ref: function(arg0) {
4242
+ const ret = getObject(arg0);
4243
+ return addHeapObject(ret);
4244
+ },
4245
+ __wbindgen_object_drop_ref: function(arg0) {
4246
+ takeObject(arg0);
4247
+ },
4248
+ };
4249
+ return {
4250
+ __proto__: null,
4251
+ "./udoc_bg.js": import0,
4252
+ };
4253
+ }
4254
+
4255
+ function __wasm_bindgen_func_elem_68497(arg0, arg1, arg2) {
4256
+ try {
4257
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4258
+ wasm.__wasm_bindgen_func_elem_68497(retptr, arg0, arg1, addHeapObject(arg2));
4259
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4260
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4261
+ if (r1) {
4262
+ throw takeObject(r0);
4263
+ }
4264
+ } finally {
4265
+ wasm.__wbindgen_add_to_stack_pointer(16);
4266
+ }
4267
+ }
4268
+
4269
+ function __wasm_bindgen_func_elem_68499(arg0, arg1, arg2, arg3) {
4270
+ wasm.__wasm_bindgen_func_elem_68499(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
4271
+ }
4272
+
4273
+ const FontPreviewImageFinalization = (typeof FinalizationRegistry === 'undefined')
4274
+ ? { register: () => {}, unregister: () => {} }
4275
+ : new FinalizationRegistry(ptr => wasm.__wbg_fontpreviewimage_free(ptr, 1));
4276
+ const PageImageFinalization = (typeof FinalizationRegistry === 'undefined')
4277
+ ? { register: () => {}, unregister: () => {} }
4278
+ : new FinalizationRegistry(ptr => wasm.__wbg_pageimage_free(ptr, 1));
4279
+ const WasmSessionFinalization = (typeof FinalizationRegistry === 'undefined')
4280
+ ? { register: () => {}, unregister: () => {} }
4281
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsession_free(ptr, 1));
4282
+
4283
+ function addHeapObject(obj) {
4284
+ if (heap_next === heap.length) heap.push(heap.length + 1);
4285
+ const idx = heap_next;
4286
+ heap_next = heap[idx];
4287
+
4288
+ heap[idx] = obj;
4289
+ return idx;
4290
+ }
4291
+
4292
+ function addBorrowedObject(obj) {
4293
+ if (stack_pointer == 1) throw new Error('out of js stack');
4294
+ heap[--stack_pointer] = obj;
4295
+ return stack_pointer;
4296
+ }
4297
+
4298
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
4299
+ ? { register: () => {}, unregister: () => {} }
4300
+ : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));
4301
+
4302
+ function dropObject(idx) {
4303
+ if (idx < 1028) return;
4304
+ heap[idx] = heap_next;
4305
+ heap_next = idx;
4306
+ }
4307
+
4308
+ function getArrayF64FromWasm0(ptr, len) {
4309
+ ptr = ptr >>> 0;
4310
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
4311
+ }
4312
+
4313
+ function getArrayJsValueFromWasm0(ptr, len) {
4314
+ ptr = ptr >>> 0;
4315
+ const mem = getDataViewMemory0();
4316
+ const result = [];
4317
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
4318
+ result.push(takeObject(mem.getUint32(i, true)));
4319
+ }
4320
+ return result;
4321
+ }
4322
+
4323
+ function getArrayU8FromWasm0(ptr, len) {
4324
+ ptr = ptr >>> 0;
4325
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4326
+ }
4327
+
4328
+ function getClampedArrayU8FromWasm0(ptr, len) {
4329
+ ptr = ptr >>> 0;
4330
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4331
+ }
4332
+
4333
+ let cachedDataViewMemory0 = null;
4334
+ function getDataViewMemory0() {
4335
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4336
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4337
+ }
4338
+ return cachedDataViewMemory0;
4339
+ }
4340
+
4341
+ let cachedFloat64ArrayMemory0 = null;
4342
+ function getFloat64ArrayMemory0() {
4343
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
4344
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
4345
+ }
4346
+ return cachedFloat64ArrayMemory0;
4347
+ }
4348
+
4349
+ function getStringFromWasm0(ptr, len) {
4350
+ return decodeText(ptr >>> 0, len);
4351
+ }
4352
+
4353
+ let cachedUint8ArrayMemory0 = null;
4354
+ function getUint8ArrayMemory0() {
4355
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
4356
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4357
+ }
4358
+ return cachedUint8ArrayMemory0;
4359
+ }
4360
+
4361
+ let cachedUint8ClampedArrayMemory0 = null;
4362
+ function getUint8ClampedArrayMemory0() {
4363
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
4364
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
4365
+ }
4366
+ return cachedUint8ClampedArrayMemory0;
4367
+ }
4368
+
4369
+ function getObject(idx) { return heap[idx]; }
4370
+
4371
+ function handleError(f, args) {
4372
+ try {
4373
+ return f.apply(this, args);
4374
+ } catch (e) {
4375
+ wasm.__wbindgen_export3(addHeapObject(e));
4376
+ }
4377
+ }
4378
+
4379
+ let heap = new Array(1024).fill(undefined);
4380
+ heap.push(undefined, null, true, false);
4381
+
4382
+ let heap_next = heap.length;
4383
+
4384
+ function isLikeNone(x) {
4385
+ return x === undefined || x === null;
4386
+ }
4387
+
4388
+ function makeMutClosure(arg0, arg1, f) {
4389
+ const state = { a: arg0, b: arg1, cnt: 1 };
4390
+ const real = (...args) => {
4391
+
4392
+ // First up with a closure we increment the internal reference
4393
+ // count. This ensures that the Rust closure environment won't
4394
+ // be deallocated while we're invoking it.
4395
+ state.cnt++;
4396
+ const a = state.a;
4397
+ state.a = 0;
4398
+ try {
4399
+ return f(a, state.b, ...args);
4400
+ } finally {
4401
+ state.a = a;
4402
+ real._wbg_cb_unref();
4403
+ }
4404
+ };
4405
+ real._wbg_cb_unref = () => {
4406
+ if (--state.cnt === 0) {
4407
+ wasm.__wbindgen_export5(state.a, state.b);
4408
+ state.a = 0;
4409
+ CLOSURE_DTORS.unregister(state);
4410
+ }
4411
+ };
4412
+ CLOSURE_DTORS.register(real, state, state);
4413
+ return real;
4414
+ }
4415
+
4416
+ function passArray8ToWasm0(arg, malloc) {
4417
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
4418
+ getUint8ArrayMemory0().set(arg, ptr / 1);
4419
+ WASM_VECTOR_LEN = arg.length;
4420
+ return ptr;
4421
+ }
4422
+
4423
+ function passArrayJsValueToWasm0(array, malloc) {
4424
+ const ptr = malloc(array.length * 4, 4) >>> 0;
4425
+ const mem = getDataViewMemory0();
4426
+ for (let i = 0; i < array.length; i++) {
4427
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
4428
+ }
4429
+ WASM_VECTOR_LEN = array.length;
4430
+ return ptr;
4431
+ }
4432
+
4433
+ function passStringToWasm0(arg, malloc, realloc) {
4434
+ if (realloc === undefined) {
4435
+ const buf = cachedTextEncoder.encode(arg);
4436
+ const ptr = malloc(buf.length, 1) >>> 0;
4437
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
4438
+ WASM_VECTOR_LEN = buf.length;
4439
+ return ptr;
4440
+ }
4441
+
4442
+ let len = arg.length;
4443
+ let ptr = malloc(len, 1) >>> 0;
4444
+
4445
+ const mem = getUint8ArrayMemory0();
4446
+
4447
+ let offset = 0;
4448
+
4449
+ for (; offset < len; offset++) {
4450
+ const code = arg.charCodeAt(offset);
4451
+ if (code > 0x7F) break;
4452
+ mem[ptr + offset] = code;
4453
+ }
4454
+ if (offset !== len) {
4455
+ if (offset !== 0) {
4456
+ arg = arg.slice(offset);
4457
+ }
4458
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
4459
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
4460
+ const ret = cachedTextEncoder.encodeInto(arg, view);
4461
+
4462
+ offset += ret.written;
4463
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
4464
+ }
4465
+
4466
+ WASM_VECTOR_LEN = offset;
4467
+ return ptr;
4468
+ }
4469
+
4470
+ let stack_pointer = 1024;
4471
+
4472
+ function takeObject(idx) {
4473
+ const ret = getObject(idx);
4474
+ dropObject(idx);
4475
+ return ret;
4476
+ }
4477
+
4478
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4479
+ cachedTextDecoder.decode();
4480
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
4481
+ let numBytesDecoded = 0;
4482
+ function decodeText(ptr, len) {
4483
+ numBytesDecoded += len;
4484
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
4485
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4486
+ cachedTextDecoder.decode();
4487
+ numBytesDecoded = len;
4488
+ }
4489
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
4490
+ }
4491
+
4492
+ const cachedTextEncoder = new TextEncoder();
4493
+
4494
+ if (!('encodeInto' in cachedTextEncoder)) {
4495
+ cachedTextEncoder.encodeInto = function (arg, view) {
4496
+ const buf = cachedTextEncoder.encode(arg);
4497
+ view.set(buf);
4498
+ return {
4499
+ read: arg.length,
4500
+ written: buf.length
4501
+ };
4502
+ };
4503
+ }
4504
+
4505
+ let WASM_VECTOR_LEN = 0;
4506
+
4507
+ let wasmModule, wasmInstance, wasm;
4508
+ function __wbg_finalize_init(instance, module) {
4509
+ wasmInstance = instance;
4510
+ wasm = instance.exports;
4511
+ wasmModule = module;
4512
+ cachedDataViewMemory0 = null;
4513
+ cachedFloat64ArrayMemory0 = null;
4514
+ cachedUint8ArrayMemory0 = null;
4515
+ cachedUint8ClampedArrayMemory0 = null;
4516
+ return wasm;
4517
+ }
4518
+
4519
+ async function __wbg_load(module, imports) {
4520
+ if (typeof Response === 'function' && module instanceof Response) {
4521
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
4522
+ try {
4523
+ return await WebAssembly.instantiateStreaming(module, imports);
4524
+ } catch (e) {
4525
+ const validResponse = module.ok && expectedResponseType(module.type);
4526
+
4527
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
4528
+ 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);
4529
+
4530
+ } else { throw e; }
4531
+ }
4532
+ }
4533
+
4534
+ const bytes = await module.arrayBuffer();
4535
+ return await WebAssembly.instantiate(bytes, imports);
4536
+ } else {
4537
+ const instance = await WebAssembly.instantiate(module, imports);
4538
+
4539
+ if (instance instanceof WebAssembly.Instance) {
4540
+ return { instance, module };
4541
+ } else {
4542
+ return instance;
4543
+ }
4544
+ }
4545
+
4546
+ function expectedResponseType(type) {
4547
+ switch (type) {
4548
+ case 'basic': case 'cors': case 'default': return true;
4549
+ }
4550
+ return false;
4551
+ }
4552
+ }
4553
+
4554
+ function initSync(module) {
4555
+ if (wasm !== undefined) return wasm;
4556
+
4557
+
4558
+ if (module !== undefined) {
4559
+ if (Object.getPrototypeOf(module) === Object.prototype) {
4560
+ ({module} = module)
4561
+ } else {
4562
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
4563
+ }
4564
+ }
4565
+
4566
+ const imports = __wbg_get_imports();
4567
+ if (!(module instanceof WebAssembly.Module)) {
4568
+ module = new WebAssembly.Module(module);
4569
+ }
4570
+ const instance = new WebAssembly.Instance(module, imports);
4571
+ return __wbg_finalize_init(instance, module);
4572
+ }
4573
+
4574
+ async function __wbg_init(module_or_path) {
4575
+ if (wasm !== undefined) return wasm;
4576
+
4577
+
4578
+ if (module_or_path !== undefined) {
4579
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
4580
+ ({module_or_path} = module_or_path)
4581
+ } else {
4582
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
4583
+ }
4584
+ }
4585
+
4586
+ if (module_or_path === undefined) {
4587
+ module_or_path = new URL('udoc_bg.wasm', import.meta.url);
4588
+ }
4589
+ const imports = __wbg_get_imports();
4590
+
4591
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
4592
+ module_or_path = fetch(module_or_path);
4593
+ }
4594
+
4595
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
4596
+
4597
+ return __wbg_finalize_init(instance, module);
4598
+ }
4599
+
4600
+ export { initSync, __wbg_init as default };