@f-office/wasm 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1189 @@
1
+ /* @ts-self-types="./f_office_wasm.d.ts" */
2
+
3
+ /**
4
+ * A document laid out into pages. Page indexes count from 0.
5
+ */
6
+ export class Document {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(Document.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ DocumentFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ DocumentFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_document_free(ptr, 0);
22
+ }
23
+ /**
24
+ * Returns the fonts that the layout looked for and the renderer lacks, each once, with the
25
+ * families that the target tries for each. This includes fallback fonts looked up for
26
+ * characters that the primary fonts lack.
27
+ * @returns {FontNeed[]}
28
+ */
29
+ fontNeeds() {
30
+ const ret = wasm.document_fontNeeds(this.__wbg_ptr);
31
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
32
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
33
+ return v1;
34
+ }
35
+ /**
36
+ * Returns the headings of the body in the order of the document.
37
+ * @returns {OutlineEntry[]}
38
+ */
39
+ outline() {
40
+ const ret = wasm.document_outline(this.__wbg_ptr);
41
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
42
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
43
+ return v1;
44
+ }
45
+ /**
46
+ * Returns the number of pages.
47
+ * @returns {number}
48
+ */
49
+ pageCount() {
50
+ const ret = wasm.document_pageCount(this.__wbg_ptr);
51
+ return ret >>> 0;
52
+ }
53
+ /**
54
+ * Returns the height in pixels of the image that `renderPage` draws at `dpi`.
55
+ *
56
+ * # Errors
57
+ *
58
+ * Throws when the page does not exist or cannot be drawn at this resolution.
59
+ * @param {number} index
60
+ * @param {number} dpi
61
+ * @returns {number}
62
+ */
63
+ pageHeight(index, dpi) {
64
+ const ret = wasm.document_pageHeight(this.__wbg_ptr, index, dpi);
65
+ if (ret[2]) {
66
+ throw takeFromExternrefTable0(ret[1]);
67
+ }
68
+ return ret[0] >>> 0;
69
+ }
70
+ /**
71
+ * Returns the width and the height in points of every page, in order: the width of page 0,
72
+ * its height, the width of page 1, and so on.
73
+ * @returns {Float64Array}
74
+ */
75
+ pageSizes() {
76
+ const ret = wasm.document_pageSizes(this.__wbg_ptr);
77
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
78
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
79
+ return v1;
80
+ }
81
+ /**
82
+ * Returns the width in pixels of the image that `renderPage` draws at `dpi`.
83
+ *
84
+ * # Errors
85
+ *
86
+ * Throws when the page does not exist or cannot be drawn at this resolution.
87
+ * @param {number} index
88
+ * @param {number} dpi
89
+ * @returns {number}
90
+ */
91
+ pageWidth(index, dpi) {
92
+ const ret = wasm.document_pageWidth(this.__wbg_ptr, index, dpi);
93
+ if (ret[2]) {
94
+ throw takeFromExternrefTable0(ret[1]);
95
+ }
96
+ return ret[0] >>> 0;
97
+ }
98
+ /**
99
+ * Draws one page at `dpi` pixels per inch on a white background. A CSS pixel is 1/96 inch,
100
+ * so a sharp image for the screen uses `96 * devicePixelRatio`.
101
+ *
102
+ * # Errors
103
+ *
104
+ * Throws when the page does not exist, or cannot be drawn at this resolution.
105
+ * @param {number} index
106
+ * @param {number} dpi
107
+ * @returns {PageImage}
108
+ */
109
+ renderPage(index, dpi) {
110
+ const ret = wasm.document_renderPage(this.__wbg_ptr, index, dpi);
111
+ if (ret[2]) {
112
+ throw takeFromExternrefTable0(ret[1]);
113
+ }
114
+ return PageImage.__wrap(ret[0]);
115
+ }
116
+ /**
117
+ * Draws only the rectangular pixel tile `(x, y, width, height)` of page `index` at `dpi`
118
+ * pixels per inch on a white background, keeping memory proportional to the tile size.
119
+ *
120
+ * # Errors
121
+ *
122
+ * Throws when the page does not exist or the tile cannot be drawn at this resolution.
123
+ * @param {number} index
124
+ * @param {number} x
125
+ * @param {number} y
126
+ * @param {number} width
127
+ * @param {number} height
128
+ * @param {number} dpi
129
+ * @returns {PageImage}
130
+ */
131
+ renderRegion(index, x, y, width, height, dpi) {
132
+ const ret = wasm.document_renderRegion(this.__wbg_ptr, index, x, y, width, height, dpi);
133
+ if (ret[2]) {
134
+ throw takeFromExternrefTable0(ret[1]);
135
+ }
136
+ return PageImage.__wrap(ret[0]);
137
+ }
138
+ /**
139
+ * Returns the upright text runs of one page in painting order, for a text layer.
140
+ *
141
+ * # Errors
142
+ *
143
+ * Throws when the page does not exist.
144
+ * @param {number} index
145
+ * @returns {TextRun[]}
146
+ */
147
+ textRuns(index) {
148
+ const ret = wasm.document_textRuns(this.__wbg_ptr, index);
149
+ if (ret[3]) {
150
+ throw takeFromExternrefTable0(ret[2]);
151
+ }
152
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
153
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
154
+ return v1;
155
+ }
156
+ /**
157
+ * Returns the text of each distinct warning of the layout, such as a font that another font
158
+ * draws or a picture that the file lacks, once each.
159
+ * @returns {string[]}
160
+ */
161
+ warnings() {
162
+ const ret = wasm.document_warnings(this.__wbg_ptr);
163
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
164
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
165
+ return v1;
166
+ }
167
+ /**
168
+ * Streams the laid-out pages as PDF 1.7 chunks into `onChunk(chunk: Uint8Array)` without
169
+ * buffering the complete PDF in WebAssembly linear memory, returning distinct PDF warnings.
170
+ *
171
+ * # Errors
172
+ *
173
+ * Throws when the pages cannot be written as PDF or `onChunk` throws.
174
+ * @param {Function} on_chunk
175
+ * @returns {string[]}
176
+ */
177
+ writePdfTo(on_chunk) {
178
+ const ret = wasm.document_writePdfTo(this.__wbg_ptr, on_chunk);
179
+ if (ret[3]) {
180
+ throw takeFromExternrefTable0(ret[2]);
181
+ }
182
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
183
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
184
+ return v1;
185
+ }
186
+ /**
187
+ * Writes the laid-out pages as a PDF file with the renderer's fonts subset and embedded.
188
+ *
189
+ * # Errors
190
+ *
191
+ * Throws when the pages cannot be written as PDF.
192
+ * @returns {Uint8Array}
193
+ */
194
+ writePdf() {
195
+ const ret = wasm.document_writePdf(this.__wbg_ptr);
196
+ if (ret[3]) {
197
+ throw takeFromExternrefTable0(ret[2]);
198
+ }
199
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
200
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
201
+ return v1;
202
+ }
203
+ }
204
+ if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
205
+
206
+ /**
207
+ * A font that a document's text asks for and the families that the target tries for it.
208
+ */
209
+ export class FontNeed {
210
+ static __wrap(ptr) {
211
+ const obj = Object.create(FontNeed.prototype);
212
+ obj.__wbg_ptr = ptr;
213
+ FontNeedFinalization.register(obj, obj.__wbg_ptr, obj);
214
+ return obj;
215
+ }
216
+ __destroy_into_raw() {
217
+ const ptr = this.__wbg_ptr;
218
+ this.__wbg_ptr = 0;
219
+ FontNeedFinalization.unregister(this);
220
+ return ptr;
221
+ }
222
+ free() {
223
+ const ptr = this.__destroy_into_raw();
224
+ wasm.__wbg_fontneed_free(ptr, 0);
225
+ }
226
+ /**
227
+ * The family that the text asks for, or `undefined` for text that names no font.
228
+ * @returns {string | undefined}
229
+ */
230
+ get family() {
231
+ const ret = wasm.fontneed_family(this.__wbg_ptr);
232
+ let v1;
233
+ if (ret[0] !== 0) {
234
+ v1 = getStringFromWasm0(ret[0], ret[1]);
235
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
236
+ }
237
+ return v1;
238
+ }
239
+ /**
240
+ * The families that the layout tries for the text, in order.
241
+ * @returns {string[]}
242
+ */
243
+ get tried() {
244
+ const ret = wasm.fontneed_tried(this.__wbg_ptr);
245
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
246
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
247
+ return v1;
248
+ }
249
+ }
250
+ if (Symbol.dispose) FontNeed.prototype[Symbol.dispose] = FontNeed.prototype.free;
251
+
252
+ /**
253
+ * A heading of the document's outline.
254
+ */
255
+ export class OutlineEntry {
256
+ static __wrap(ptr) {
257
+ const obj = Object.create(OutlineEntry.prototype);
258
+ obj.__wbg_ptr = ptr;
259
+ OutlineEntryFinalization.register(obj, obj.__wbg_ptr, obj);
260
+ return obj;
261
+ }
262
+ __destroy_into_raw() {
263
+ const ptr = this.__wbg_ptr;
264
+ this.__wbg_ptr = 0;
265
+ OutlineEntryFinalization.unregister(this);
266
+ return ptr;
267
+ }
268
+ free() {
269
+ const ptr = this.__destroy_into_raw();
270
+ wasm.__wbg_outlineentry_free(ptr, 0);
271
+ }
272
+ /**
273
+ * The address of its paragraph in the body, such as `p12`.
274
+ * @returns {string}
275
+ */
276
+ get address() {
277
+ let deferred1_0;
278
+ let deferred1_1;
279
+ try {
280
+ const ret = wasm.outlineentry_address(this.__wbg_ptr);
281
+ deferred1_0 = ret[0];
282
+ deferred1_1 = ret[1];
283
+ return getStringFromWasm0(ret[0], ret[1]);
284
+ } finally {
285
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
286
+ }
287
+ }
288
+ /**
289
+ * The heading's level, from 0 for the top level to 8: the level that the body's table of
290
+ * contents gives it when the outline follows that table, else its outline level.
291
+ * @returns {number}
292
+ */
293
+ get level() {
294
+ const ret = wasm.outlineentry_level(this.__wbg_ptr);
295
+ return ret;
296
+ }
297
+ /**
298
+ * The index of the page of its first line, counted from 0.
299
+ * @returns {number}
300
+ */
301
+ get page() {
302
+ const ret = wasm.outlineentry_page(this.__wbg_ptr);
303
+ return ret >>> 0;
304
+ }
305
+ /**
306
+ * The heading's text on one line.
307
+ * @returns {string}
308
+ */
309
+ get text() {
310
+ let deferred1_0;
311
+ let deferred1_1;
312
+ try {
313
+ const ret = wasm.outlineentry_text(this.__wbg_ptr);
314
+ deferred1_0 = ret[0];
315
+ deferred1_1 = ret[1];
316
+ return getStringFromWasm0(ret[0], ret[1]);
317
+ } finally {
318
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
319
+ }
320
+ }
321
+ }
322
+ if (Symbol.dispose) OutlineEntry.prototype[Symbol.dispose] = OutlineEntry.prototype.free;
323
+
324
+ /**
325
+ * One drawn page: RGBA pixels with their width and height, and the warnings of the drawing.
326
+ */
327
+ export class PageImage {
328
+ static __wrap(ptr) {
329
+ const obj = Object.create(PageImage.prototype);
330
+ obj.__wbg_ptr = ptr;
331
+ PageImageFinalization.register(obj, obj.__wbg_ptr, obj);
332
+ return obj;
333
+ }
334
+ __destroy_into_raw() {
335
+ const ptr = this.__wbg_ptr;
336
+ this.__wbg_ptr = 0;
337
+ PageImageFinalization.unregister(this);
338
+ return ptr;
339
+ }
340
+ free() {
341
+ const ptr = this.__destroy_into_raw();
342
+ wasm.__wbg_pageimage_free(ptr, 0);
343
+ }
344
+ /**
345
+ * The pixels in gray, one byte each, row by row from the top left corner, as a comparison
346
+ * with a gray page image reads them: each pixel's luma, 0.299 red, 0.587 green and 0.114
347
+ * blue, rounded.
348
+ * @returns {Uint8Array}
349
+ */
350
+ get gray() {
351
+ const ret = wasm.pageimage_gray(this.__wbg_ptr);
352
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
353
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
354
+ return v1;
355
+ }
356
+ /**
357
+ * Height in pixels.
358
+ * @returns {number}
359
+ */
360
+ get height() {
361
+ const ret = wasm.pageimage_height(this.__wbg_ptr);
362
+ return ret >>> 0;
363
+ }
364
+ /**
365
+ * The pixels as RGBA bytes, row by row from the top left corner. Each read copies them
366
+ * once out of WebAssembly memory into a new array, which
367
+ * `new ImageData(pixels, width, height)` takes without another copy. Read it once, then
368
+ * call `free()`.
369
+ * @returns {Uint8ClampedArray}
370
+ */
371
+ get pixels() {
372
+ const ret = wasm.pageimage_pixels(this.__wbg_ptr);
373
+ return ret;
374
+ }
375
+ /**
376
+ * Returns the text of each distinct warning of the drawing, such as an image that does not
377
+ * decode, once each.
378
+ * @returns {string[]}
379
+ */
380
+ warnings() {
381
+ const ret = wasm.pageimage_warnings(this.__wbg_ptr);
382
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
383
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
384
+ return v1;
385
+ }
386
+ /**
387
+ * Width in pixels.
388
+ * @returns {number}
389
+ */
390
+ get width() {
391
+ const ret = wasm.pageimage_width(this.__wbg_ptr);
392
+ return ret >>> 0;
393
+ }
394
+ }
395
+ if (Symbol.dispose) PageImage.prototype[Symbol.dispose] = PageImage.prototype.free;
396
+
397
+ /**
398
+ * Fonts for rendering. Add the fonts first, then open documents.
399
+ */
400
+ export class Renderer {
401
+ __destroy_into_raw() {
402
+ const ptr = this.__wbg_ptr;
403
+ this.__wbg_ptr = 0;
404
+ RendererFinalization.unregister(this);
405
+ return ptr;
406
+ }
407
+ free() {
408
+ const ptr = this.__destroy_into_raw();
409
+ wasm.__wbg_renderer_free(ptr, 0);
410
+ }
411
+ /**
412
+ * Adds the pictures of the art page borders in a file of their form, and returns how many
413
+ * it added. Without them, a page border's side of an art style, such as `apples`, is not
414
+ * drawn, with a warning. A document that is already open keeps its layout.
415
+ *
416
+ * # Errors
417
+ *
418
+ * Throws when the data does not read as art pictures.
419
+ * @param {Uint8Array | number[]} data
420
+ * @returns {number}
421
+ */
422
+ addArtPictures(data) {
423
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
424
+ const len0 = WASM_VECTOR_LEN;
425
+ const ret = wasm.renderer_addArtPictures(this.__wbg_ptr, ptr0, len0);
426
+ if (ret[2]) {
427
+ throw takeFromExternrefTable0(ret[1]);
428
+ }
429
+ return ret[0] >>> 0;
430
+ }
431
+ /**
432
+ * Adds every face in an OpenType font or font collection (`.ttf`, `.otf`, `.ttc` or
433
+ * `.otc`), and returns the number of faces that it added. A document that is already open
434
+ * keeps its layout.
435
+ *
436
+ * # Errors
437
+ *
438
+ * Throws when the data is not a font that can be loaded.
439
+ * @param {Uint8Array | number[]} data
440
+ * @returns {number}
441
+ */
442
+ addFont(data) {
443
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
444
+ const len0 = WASM_VECTOR_LEN;
445
+ const ret = wasm.renderer_addFont(this.__wbg_ptr, ptr0, len0);
446
+ if (ret[2]) {
447
+ throw takeFromExternrefTable0(ret[1]);
448
+ }
449
+ return ret[0] >>> 0;
450
+ }
451
+ /**
452
+ * Returns the fonts that a DOCX file asks for, reading lazily from a JavaScript random-access
453
+ * byte source (`readAt(offset, length) -> Uint8Array`) without copying the archive into WASM
454
+ * linear memory.
455
+ *
456
+ * # Errors
457
+ *
458
+ * Throws when `byteLength` is invalid, `target` is unknown, or the DOCX file cannot be read.
459
+ * @param {number} byte_length
460
+ * @param {Function} read_at
461
+ * @param {string | null} [target]
462
+ * @returns {FontNeed[]}
463
+ */
464
+ static fontsNeededSource(byte_length, read_at, target) {
465
+ const val2 = +byte_length;
466
+ var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
467
+ var len0 = WASM_VECTOR_LEN;
468
+ const ret = wasm.renderer_fontsNeededSource(val2, read_at, ptr0, len0);
469
+ if (ret[3]) {
470
+ throw takeFromExternrefTable0(ret[2]);
471
+ }
472
+ var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]);
473
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
474
+ return v3;
475
+ }
476
+ /**
477
+ * Returns the fonts that the text of a DOCX file asks for, for the target whose ID
478
+ * `target` gives or the base target, each with the families that the target tries for it.
479
+ * It needs no fonts: fetch the first family of each that you can, add it, then open the
480
+ * document.
481
+ *
482
+ * # Errors
483
+ *
484
+ * Throws when no target has the ID, or when the data is not a DOCX file that can be read.
485
+ * @param {Uint8Array | number[]} docx
486
+ * @param {string | null} [target]
487
+ * @returns {FontNeed[]}
488
+ */
489
+ static fontsNeeded(docx, target) {
490
+ let ptr0, len0, ptr1, len1;
491
+ try {
492
+ ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_malloc);
493
+ len0 = WASM_VECTOR_LEN;
494
+ ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
495
+ len1 = WASM_VECTOR_LEN;
496
+ } catch (e) {
497
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
498
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
499
+ throw e;
500
+ }
501
+ const ret = wasm.renderer_fontsNeeded(ptr0, len0, ptr1, len1);
502
+ if (ret[3]) {
503
+ throw takeFromExternrefTable0(ret[2]);
504
+ }
505
+ var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]);
506
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
507
+ return v3;
508
+ }
509
+ /**
510
+ * Makes a renderer without fonts.
511
+ */
512
+ constructor() {
513
+ const ret = wasm.renderer_new();
514
+ this.__wbg_ptr = ret;
515
+ RendererFinalization.register(this, this.__wbg_ptr, this);
516
+ return this;
517
+ }
518
+ /**
519
+ * Lays out a DOCX file into pages using constrained mobile/browser resource limits
520
+ * (`f_office::Limits::mobile()`) so oversized or hostile files fail cleanly instead of
521
+ * exhausting tab memory.
522
+ *
523
+ * # Errors
524
+ *
525
+ * Throws when no target has the ID, `now` is malformed, or the DOCX file breaks mobile
526
+ * limits or cannot be read.
527
+ * @param {Uint8Array | number[]} docx
528
+ * @param {string | null} [target]
529
+ * @param {string | null} [now]
530
+ * @returns {Document}
531
+ */
532
+ openDocxMobile(docx, target, now) {
533
+ let ptr0, len0, ptr1, len1, ptr2, len2;
534
+ try {
535
+ ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_malloc);
536
+ len0 = WASM_VECTOR_LEN;
537
+ ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
538
+ len1 = WASM_VECTOR_LEN;
539
+ ptr2 = isLikeNone(now) ? 0 : passStringToWasm0(now, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
540
+ len2 = WASM_VECTOR_LEN;
541
+ } catch (e) {
542
+ if (ptr2) { wasm.__wbindgen_free(ptr2, len2 * 1, 1); }
543
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
544
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
545
+ throw e;
546
+ }
547
+ const ret = wasm.renderer_openDocxMobile(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
548
+ if (ret[2]) {
549
+ throw takeFromExternrefTable0(ret[1]);
550
+ }
551
+ return Document.__wrap(ret[0]);
552
+ }
553
+ /**
554
+ * Lays out a DOCX file from a JavaScript random-access byte source (`readAt(offset, length)
555
+ * -> Uint8Array`) without copying the archive into WebAssembly linear memory.
556
+ *
557
+ * # Errors
558
+ *
559
+ * Throws when `byteLength` is invalid, `target`/`now` is invalid, or the DOCX file cannot be
560
+ * read.
561
+ * @param {number} byte_length
562
+ * @param {Function} read_at
563
+ * @param {string | null} [target]
564
+ * @param {string | null} [now]
565
+ * @param {boolean | null} [mobile]
566
+ * @returns {Document}
567
+ */
568
+ openDocxSource(byte_length, read_at, target, now, mobile) {
569
+ const val3 = +byte_length;
570
+ let ptr0, len0, ptr1, len1;
571
+ try {
572
+ ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
573
+ len0 = WASM_VECTOR_LEN;
574
+ ptr1 = isLikeNone(now) ? 0 : passStringToWasm0(now, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
575
+ len1 = WASM_VECTOR_LEN;
576
+ } catch (e) {
577
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
578
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
579
+ throw e;
580
+ }
581
+ const ret = wasm.renderer_openDocxSource(this.__wbg_ptr, val3, read_at, ptr0, len0, ptr1, len1, isLikeNone(mobile) ? 0xFFFFFF : mobile ? 1 : 0);
582
+ if (ret[2]) {
583
+ throw takeFromExternrefTable0(ret[1]);
584
+ }
585
+ return Document.__wrap(ret[0]);
586
+ }
587
+ /**
588
+ * Lays out a DOCX file into pages with the fonts added so far, for the Word product whose
589
+ * pages to reproduce: the target whose ID `target` gives, or the base target without one.
590
+ * `now`, written as `YYYY-MM-DDTHH:MM:SSZ` with the digits of the local clock, is the date
591
+ * and time that date fields show; without it they show the results stored in the file.
592
+ *
593
+ * # Errors
594
+ *
595
+ * Throws when no target has the ID, `now` is not written in that form, or the data is not
596
+ * a DOCX file that can be read.
597
+ * @param {Uint8Array | number[]} docx
598
+ * @param {string | null} [target]
599
+ * @param {string | null} [now]
600
+ * @returns {Document}
601
+ */
602
+ openDocx(docx, target, now) {
603
+ let ptr0, len0, ptr1, len1, ptr2, len2;
604
+ try {
605
+ ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_malloc);
606
+ len0 = WASM_VECTOR_LEN;
607
+ ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
608
+ len1 = WASM_VECTOR_LEN;
609
+ ptr2 = isLikeNone(now) ? 0 : passStringToWasm0(now, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
610
+ len2 = WASM_VECTOR_LEN;
611
+ } catch (e) {
612
+ if (ptr2) { wasm.__wbindgen_free(ptr2, len2 * 1, 1); }
613
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
614
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
615
+ throw e;
616
+ }
617
+ const ret = wasm.renderer_openDocx(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
618
+ if (ret[2]) {
619
+ throw takeFromExternrefTable0(ret[1]);
620
+ }
621
+ return Document.__wrap(ret[0]);
622
+ }
623
+ /**
624
+ * Returns the IDs of the targets that `openDocx` and `fontsNeeded` accept.
625
+ * @returns {string[]}
626
+ */
627
+ static targets() {
628
+ const ret = wasm.renderer_targets();
629
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
630
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
631
+ return v1;
632
+ }
633
+ }
634
+ if (Symbol.dispose) Renderer.prototype[Symbol.dispose] = Renderer.prototype.free;
635
+
636
+ /**
637
+ * A run of upright text on a page, in points from the page's top left corner: the box of its
638
+ * glyphs from its font's ascender to its descender, and its glyphs.
639
+ */
640
+ export class TextRun {
641
+ static __wrap(ptr) {
642
+ const obj = Object.create(TextRun.prototype);
643
+ obj.__wbg_ptr = ptr;
644
+ TextRunFinalization.register(obj, obj.__wbg_ptr, obj);
645
+ return obj;
646
+ }
647
+ __destroy_into_raw() {
648
+ const ptr = this.__wbg_ptr;
649
+ this.__wbg_ptr = 0;
650
+ TextRunFinalization.unregister(this);
651
+ return ptr;
652
+ }
653
+ free() {
654
+ const ptr = this.__destroy_into_raw();
655
+ wasm.__wbg_textrun_free(ptr, 0);
656
+ }
657
+ /**
658
+ * The baseline.
659
+ * @returns {number}
660
+ */
661
+ get baseline() {
662
+ const ret = wasm.textrun_baseline(this.__wbg_ptr);
663
+ return ret;
664
+ }
665
+ /**
666
+ * The end of each glyph's text in `text`, counted in UTF-16 code units as JavaScript
667
+ * counts a string's characters.
668
+ * @returns {Uint32Array}
669
+ */
670
+ get glyphEnds() {
671
+ const ret = wasm.textrun_glyphEnds(this.__wbg_ptr);
672
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
673
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
674
+ return v1;
675
+ }
676
+ /**
677
+ * The left edge of each glyph's cell, in the order of the text.
678
+ * @returns {Float64Array}
679
+ */
680
+ get glyphLefts() {
681
+ const ret = wasm.textrun_glyphLefts(this.__wbg_ptr);
682
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
683
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
684
+ return v1;
685
+ }
686
+ /**
687
+ * The advance of each glyph.
688
+ * @returns {Float64Array}
689
+ */
690
+ get glyphWidths() {
691
+ const ret = wasm.textrun_glyphWidths(this.__wbg_ptr);
692
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
693
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
694
+ return v1;
695
+ }
696
+ /**
697
+ * The height of the box.
698
+ * @returns {number}
699
+ */
700
+ get height() {
701
+ const ret = wasm.textrun_height(this.__wbg_ptr);
702
+ return ret;
703
+ }
704
+ /**
705
+ * The left edge of the box.
706
+ * @returns {number}
707
+ */
708
+ get left() {
709
+ const ret = wasm.textrun_left(this.__wbg_ptr);
710
+ return ret;
711
+ }
712
+ /**
713
+ * The font size.
714
+ * @returns {number}
715
+ */
716
+ get size() {
717
+ const ret = wasm.textrun_size(this.__wbg_ptr);
718
+ return ret;
719
+ }
720
+ /**
721
+ * The text that the glyphs show.
722
+ * @returns {string}
723
+ */
724
+ get text() {
725
+ let deferred1_0;
726
+ let deferred1_1;
727
+ try {
728
+ const ret = wasm.textrun_text(this.__wbg_ptr);
729
+ deferred1_0 = ret[0];
730
+ deferred1_1 = ret[1];
731
+ return getStringFromWasm0(ret[0], ret[1]);
732
+ } finally {
733
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
734
+ }
735
+ }
736
+ /**
737
+ * The top edge of the box.
738
+ * @returns {number}
739
+ */
740
+ get top() {
741
+ const ret = wasm.textrun_top(this.__wbg_ptr);
742
+ return ret;
743
+ }
744
+ /**
745
+ * The width of the box.
746
+ * @returns {number}
747
+ */
748
+ get width() {
749
+ const ret = wasm.textrun_width(this.__wbg_ptr);
750
+ return ret;
751
+ }
752
+ }
753
+ if (Symbol.dispose) TextRun.prototype[Symbol.dispose] = TextRun.prototype.free;
754
+ function __wbg_get_imports() {
755
+ const import0 = {
756
+ __proto__: null,
757
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
758
+ const ret = Error(getStringFromWasm0(arg0, arg1));
759
+ return ret;
760
+ },
761
+ __wbg___wbindgen_debug_string_f249a2a76caa9a55: function(arg0, arg1) {
762
+ const ret = debugString(arg1);
763
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
764
+ const len1 = WASM_VECTOR_LEN;
765
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
766
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
767
+ },
768
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
769
+ throw new Error(getStringFromWasm0(arg0, arg1));
770
+ },
771
+ __wbg_call_a410eb4b59ed5965: function() { return handleError(function (arg0, arg1, arg2) {
772
+ const ret = arg0.call(arg1, arg2);
773
+ return ret;
774
+ }, arguments); },
775
+ __wbg_call_fc92fee6137d452d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
776
+ const ret = arg0.call(arg1, arg2, arg3);
777
+ return ret;
778
+ }, arguments); },
779
+ __wbg_fontneed_new: function(arg0) {
780
+ const ret = FontNeed.__wrap(arg0);
781
+ return ret;
782
+ },
783
+ __wbg_instanceof_Uint8Array_d7aeb0dcb3108fea: function(arg0) {
784
+ let result;
785
+ try {
786
+ result = arg0 instanceof Uint8Array;
787
+ } catch (_) {
788
+ result = false;
789
+ }
790
+ const ret = result;
791
+ return ret;
792
+ },
793
+ __wbg_length_186163212ffe79c3: function(arg0) {
794
+ const ret = arg0.length;
795
+ return ret;
796
+ },
797
+ __wbg_new_from_slice_b8daf545a41c6aa0: function(arg0, arg1) {
798
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
799
+ return ret;
800
+ },
801
+ __wbg_new_from_slice_c7cf3126a626653c: function(arg0, arg1) {
802
+ const ret = new Uint8ClampedArray(getArrayU8FromWasm0(arg0, arg1));
803
+ return ret;
804
+ },
805
+ __wbg_outlineentry_new: function(arg0) {
806
+ const ret = OutlineEntry.__wrap(arg0);
807
+ return ret;
808
+ },
809
+ __wbg_prototypesetcall_13162965d1fe7aa3: function(arg0, arg1, arg2) {
810
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
811
+ },
812
+ __wbg_subarray_58f388a9247ac0bb: function(arg0, arg1, arg2) {
813
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
814
+ return ret;
815
+ },
816
+ __wbg_textrun_new: function(arg0) {
817
+ const ret = TextRun.__wrap(arg0);
818
+ return ret;
819
+ },
820
+ __wbindgen_generic_0000000000000001: function(arg0) {
821
+ // Cast intrinsic for `F64 -> Externref`.
822
+ const ret = arg0;
823
+ return ret;
824
+ },
825
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
826
+ // Cast intrinsic for `Ref(String) -> Externref`.
827
+ const ret = getStringFromWasm0(arg0, arg1);
828
+ return ret;
829
+ },
830
+ __wbindgen_init_externref_table: function() {
831
+ const table = wasm.__wbindgen_externrefs;
832
+ table.set(0, undefined);
833
+ table.set(1024, undefined);
834
+ table.set(1025, null);
835
+ table.set(1026, true);
836
+ table.set(1027, false);
837
+ },
838
+ };
839
+ return {
840
+ __proto__: null,
841
+ "./f_office_wasm_bg.js": import0,
842
+ };
843
+ }
844
+
845
+ const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
846
+ ? { register: () => {}, unregister: () => {} }
847
+ : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr, 1));
848
+ const FontNeedFinalization = (typeof FinalizationRegistry === 'undefined')
849
+ ? { register: () => {}, unregister: () => {} }
850
+ : new FinalizationRegistry(ptr => wasm.__wbg_fontneed_free(ptr, 1));
851
+ const OutlineEntryFinalization = (typeof FinalizationRegistry === 'undefined')
852
+ ? { register: () => {}, unregister: () => {} }
853
+ : new FinalizationRegistry(ptr => wasm.__wbg_outlineentry_free(ptr, 1));
854
+ const PageImageFinalization = (typeof FinalizationRegistry === 'undefined')
855
+ ? { register: () => {}, unregister: () => {} }
856
+ : new FinalizationRegistry(ptr => wasm.__wbg_pageimage_free(ptr, 1));
857
+ const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
858
+ ? { register: () => {}, unregister: () => {} }
859
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderer_free(ptr, 1));
860
+ const TextRunFinalization = (typeof FinalizationRegistry === 'undefined')
861
+ ? { register: () => {}, unregister: () => {} }
862
+ : new FinalizationRegistry(ptr => wasm.__wbg_textrun_free(ptr, 1));
863
+
864
+ function addToExternrefTable0(obj) {
865
+ const idx = wasm.__externref_table_alloc();
866
+ wasm.__wbindgen_externrefs.set(idx, obj);
867
+ return idx;
868
+ }
869
+
870
+ function debugString(val) {
871
+ switch (typeof val) {
872
+ // primitive types
873
+ case 'number':
874
+ case 'boolean':
875
+ case 'undefined':
876
+ return `${val}`;
877
+ case 'string':
878
+ return JSON.stringify(val);
879
+ case 'bigint':
880
+ return `${val}n`;
881
+ case 'symbol':
882
+ return val.description !== undefined
883
+ ? `Symbol(${val.description})`
884
+ : 'Symbol';
885
+ case 'function':
886
+ return typeof val.name === 'string' && val.name !== ''
887
+ ? `Function(${val.name})`
888
+ : 'Function';
889
+ case 'object': {
890
+ if (val === null) {
891
+ return 'null';
892
+ }
893
+ // objects
894
+ if (Array.isArray(val)) {
895
+ return '[' + Array.from(val, debugString).join(', ') + ']';
896
+ }
897
+ // errors
898
+ if (val instanceof Error) {
899
+ return `${val.name}: ${val.message}\n${val.stack}`;
900
+ }
901
+
902
+ const toStringOutput = toString.call(val);
903
+ // Test for built-in
904
+ const className = /\[object ([^\]]+)\]/.exec(toStringOutput)?.[1];
905
+
906
+ // Failed to match the standard '[object ClassName]'
907
+ if (className === undefined) {
908
+ return toStringOutput;
909
+ }
910
+ if (className === 'Object') {
911
+ // we're a user defined class or Object
912
+ // JSON.stringify avoids problems with cycles, and is generally much
913
+ // easier than looping through ownProperties of `val`.
914
+ try {
915
+ return 'Object(' + JSON.stringify(val) + ')';
916
+ } catch (_) {
917
+ return 'Object';
918
+ }
919
+ }
920
+ // TODO we could test for more things here, like `Set`s and `Map`s.
921
+ return className;
922
+ }
923
+ // Per MDN: 'This list of values is exhaustive.'
924
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#description
925
+ }
926
+ }
927
+
928
+ function getArrayF64FromWasm0(ptr, len) {
929
+ ptr = ptr >>> 0;
930
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
931
+ }
932
+
933
+ function getArrayJsValueFromWasm0(ptr, len) {
934
+ ptr = ptr >>> 0;
935
+ const mem = getDataViewMemory0();
936
+ const result = [];
937
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
938
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
939
+ }
940
+ wasm.__externref_drop_slice(ptr, len);
941
+ return result;
942
+ }
943
+
944
+ function getArrayU32FromWasm0(ptr, len) {
945
+ ptr = ptr >>> 0;
946
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
947
+ }
948
+
949
+ function getArrayU8FromWasm0(ptr, len) {
950
+ ptr = ptr >>> 0;
951
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
952
+ }
953
+
954
+ let cachedDataViewMemory0 = null;
955
+ function getDataViewMemory0() {
956
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
957
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
958
+ }
959
+ return cachedDataViewMemory0;
960
+ }
961
+
962
+ let cachedFloat64ArrayMemory0 = null;
963
+ function getFloat64ArrayMemory0() {
964
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
965
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
966
+ }
967
+ return cachedFloat64ArrayMemory0;
968
+ }
969
+
970
+ function getStringFromWasm0(ptr, len) {
971
+ ptr = ptr >>> 0;
972
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
973
+ }
974
+
975
+ let cachedUint32ArrayMemory0 = null;
976
+ function getUint32ArrayMemory0() {
977
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
978
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
979
+ }
980
+ return cachedUint32ArrayMemory0;
981
+ }
982
+
983
+ let cachedUint8ArrayMemory0 = null;
984
+ function getUint8ArrayMemory0() {
985
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
986
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
987
+ }
988
+ return cachedUint8ArrayMemory0;
989
+ }
990
+
991
+ function handleError(f, args) {
992
+ try {
993
+ return f.apply(this, args);
994
+ } catch (e) {
995
+ const idx = addToExternrefTable0(e);
996
+ wasm.__wbindgen_exn_store(idx);
997
+ }
998
+ }
999
+
1000
+ function isLikeNone(x) {
1001
+ return x === undefined || x === null;
1002
+ }
1003
+
1004
+ function passArray8ToWasm0(arg, malloc) {
1005
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1006
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1007
+ WASM_VECTOR_LEN = arg.length;
1008
+ return ptr;
1009
+ }
1010
+
1011
+ function passStringToWasm0(arg, malloc, realloc) {
1012
+ if (realloc === undefined) {
1013
+ const buf = cachedTextEncoder.encode(arg);
1014
+ const ptr = malloc(buf.length, 1) >>> 0;
1015
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1016
+ WASM_VECTOR_LEN = buf.length;
1017
+ return ptr;
1018
+ }
1019
+
1020
+ let len = arg.length;
1021
+ let ptr = malloc(len, 1) >>> 0;
1022
+
1023
+ const mem = getUint8ArrayMemory0();
1024
+
1025
+ let offset = 0;
1026
+
1027
+ for (; offset < len; offset++) {
1028
+ const code = arg.charCodeAt(offset);
1029
+ if (code > 0x7F) break;
1030
+ mem[ptr + offset] = code;
1031
+ }
1032
+ if (offset !== len) {
1033
+ if (offset !== 0) {
1034
+ arg = arg.slice(offset);
1035
+ }
1036
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1037
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1038
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1039
+
1040
+ offset += ret.written;
1041
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1042
+ }
1043
+
1044
+ WASM_VECTOR_LEN = offset;
1045
+ return ptr;
1046
+ }
1047
+
1048
+ function takeFromExternrefTable0(idx) {
1049
+ const value = wasm.__wbindgen_externrefs.get(idx);
1050
+ wasm.__externref_table_dealloc(idx);
1051
+ return value;
1052
+ }
1053
+
1054
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
1055
+ cachedTextDecoder.decode();
1056
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1057
+ let numBytesDecoded = 0;
1058
+ function decodeText(bytes) {
1059
+ numBytesDecoded += bytes.length;
1060
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1061
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
1062
+ cachedTextDecoder.decode();
1063
+ numBytesDecoded = bytes.length;
1064
+ }
1065
+ return cachedTextDecoder.decode(bytes);
1066
+ }
1067
+
1068
+ const cachedTextEncoder = new TextEncoder();
1069
+
1070
+ if (!('encodeInto' in cachedTextEncoder)) {
1071
+ cachedTextEncoder.encodeInto = function (arg, view) {
1072
+ const buf = cachedTextEncoder.encode(arg);
1073
+ view.set(buf);
1074
+ return {
1075
+ read: arg.length,
1076
+ written: buf.length
1077
+ };
1078
+ };
1079
+ }
1080
+
1081
+ let WASM_VECTOR_LEN = 0;
1082
+
1083
+ let wasmModule, wasmInstance, wasm;
1084
+ function __wbg_finalize_init(instance, module) {
1085
+ wasmInstance = instance;
1086
+ wasm = instance.exports;
1087
+ wasmModule = module;
1088
+ cachedDataViewMemory0 = null;
1089
+ cachedFloat64ArrayMemory0 = null;
1090
+ cachedUint32ArrayMemory0 = null;
1091
+ cachedUint8ArrayMemory0 = null;
1092
+ wasm.__wbindgen_start();
1093
+ return wasm;
1094
+ }
1095
+
1096
+ async function __wbg_load(module, imports) {
1097
+ if (typeof Response === 'function' && module instanceof Response) {
1098
+ if (!module.ok) {
1099
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1100
+ }
1101
+
1102
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1103
+ try {
1104
+ return await WebAssembly.instantiateStreaming(module, imports);
1105
+ } catch (e) {
1106
+ const validResponse = expectedResponseType(module.type);
1107
+
1108
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1109
+ 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);
1110
+
1111
+ } else { throw e; }
1112
+ }
1113
+ }
1114
+
1115
+ const bytes = await module.arrayBuffer();
1116
+ return await WebAssembly.instantiate(bytes, imports);
1117
+ } else {
1118
+ const instance = await WebAssembly.instantiate(module, imports);
1119
+
1120
+ if (instance instanceof WebAssembly.Instance) {
1121
+ return { instance, module };
1122
+ } else {
1123
+ return instance;
1124
+ }
1125
+ }
1126
+
1127
+ function expectedResponseType(type) {
1128
+ switch (type) {
1129
+ case 'basic': case 'cors': case 'default': return true;
1130
+ }
1131
+ return false;
1132
+ }
1133
+ }
1134
+
1135
+ function initSync(module) {
1136
+ if (wasm !== undefined) return wasm;
1137
+
1138
+
1139
+ if (module !== undefined) {
1140
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1141
+ ({module} = module)
1142
+ } else {
1143
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1144
+ }
1145
+ }
1146
+
1147
+ const imports = __wbg_get_imports();
1148
+ if (!(module instanceof WebAssembly.Module)) {
1149
+ module = new WebAssembly.Module(module);
1150
+ }
1151
+ const instance = new WebAssembly.Instance(module, imports);
1152
+ return __wbg_finalize_init(instance, module);
1153
+ }
1154
+
1155
+ let __wbg_init_promise;
1156
+ async function __wbg_init(module_or_path) {
1157
+ if (wasm !== undefined) return wasm;
1158
+ if (__wbg_init_promise === undefined) {
1159
+ __wbg_init_promise = __wbg_init_once(module_or_path);
1160
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
1161
+ }
1162
+ return __wbg_init_promise;
1163
+ }
1164
+
1165
+ async function __wbg_init_once(module_or_path) {
1166
+
1167
+ if (module_or_path !== undefined) {
1168
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1169
+ ({module_or_path} = module_or_path)
1170
+ } else {
1171
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1172
+ }
1173
+ }
1174
+
1175
+ if (module_or_path === undefined) {
1176
+ module_or_path = new URL('f_office_wasm_bg.wasm', import.meta.url);
1177
+ }
1178
+ const imports = __wbg_get_imports();
1179
+
1180
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1181
+ module_or_path = fetch(module_or_path);
1182
+ }
1183
+
1184
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1185
+
1186
+ return __wbg_finalize_init(instance, module);
1187
+ }
1188
+
1189
+ export { initSync, __wbg_init as default };