@laminapdf/wasm 0.0.0-stage → 0.2.0-alpha.3

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,1718 @@
1
+ /* @ts-self-types="./lamina_pdf_base.d.ts" */
2
+
3
+ /**
4
+ * Builds a new document: pages, navigation and metadata, then [`WasmBuilder::finish`]
5
+ * gives a [`WasmDocument`] (unsaved; its save is a full rewrite).
6
+ */
7
+ export class WasmBuilder {
8
+ __destroy_into_raw() {
9
+ const ptr = this.__wbg_ptr;
10
+ this.__wbg_ptr = 0;
11
+ WasmBuilderFinalization.unregister(this);
12
+ return ptr;
13
+ }
14
+ free() {
15
+ const ptr = this.__destroy_into_raw();
16
+ wasm.__wbg_wasmbuilder_free(ptr, 0);
17
+
18
+ }
19
+ /**
20
+ * Attaches a file (`/EmbeddedFiles`, the catalog's `/AF`): `name`, its bytes and its MIME
21
+ * type. The same name again replaces the file.
22
+ *
23
+ * # Errors
24
+ * `builder-finished`; `invalid-argument` (a date that isn't a PDF date); `unknown-option`.
25
+ * @param {string} name
26
+ * @param {Uint8Array} bytes
27
+ * @param {string} mime
28
+ * @param {AttachmentInit | undefined} options
29
+ */
30
+ attach(name, bytes, mime, options) {
31
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
32
+ const len0 = WASM_VECTOR_LEN;
33
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
34
+ const len1 = WASM_VECTOR_LEN;
35
+ const ptr2 = passStringToWasm0(mime, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
36
+ const len2 = WASM_VECTOR_LEN;
37
+ let ret;
38
+ ret = wasm.wasmbuilder_attach(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, options);
39
+ if (ret[1]) {
40
+ throw takeFromExternrefTable0(ret[0]);
41
+ }
42
+ }
43
+ /**
44
+ * Defines the named destination `name`: page `index` shown as `fit` (default: the page).
45
+ *
46
+ * # Errors
47
+ * `builder-finished`; `invalid-argument` for a bad `fit`.
48
+ * @param {string} name
49
+ * @param {number} index
50
+ * @param {FitInit | undefined} fit
51
+ */
52
+ destination(name, index, fit) {
53
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ let ret;
56
+ ret = wasm.wasmbuilder_destination(this.__wbg_ptr, ptr0, len0, index, fit);
57
+ if (ret[1]) {
58
+ throw takeFromExternrefTable0(ret[0]);
59
+ }
60
+ }
61
+ /**
62
+ * Writes the fonts, links, page tree, outline and metadata, and returns the document.
63
+ * The builder is finished afterwards, and so are its unfinished pages.
64
+ *
65
+ * # Errors
66
+ * `builder-finished`; `page-index-out-of-range`, `unknown-destination`,
67
+ * `invalid-page-labels`, `invalid-geometry`, `subset-failed`.
68
+ * @returns {WasmDocument}
69
+ */
70
+ finish() {
71
+ let ret;
72
+ ret = wasm.wasmbuilder_finish(this.__wbg_ptr);
73
+ if (ret[2]) {
74
+ throw takeFromExternrefTable0(ret[1]);
75
+ }
76
+ return WasmDocument.__wrap(ret[0]);
77
+ }
78
+ /**
79
+ * The natural language (`/Lang`), a BCP 47 tag.
80
+ *
81
+ * # Errors
82
+ * `builder-finished`.
83
+ * @param {string} lang
84
+ */
85
+ lang(lang) {
86
+ const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
+ const len0 = WASM_VECTOR_LEN;
88
+ let ret;
89
+ ret = wasm.wasmbuilder_lang(this.__wbg_ptr, ptr0, len0);
90
+ if (ret[1]) {
91
+ throw takeFromExternrefTable0(ret[0]);
92
+ }
93
+ }
94
+ /**
95
+ * The metadata, written as the Info dictionary and an XMP packet.
96
+ *
97
+ * # Errors
98
+ * `builder-finished`; `invalid-argument` (a date that isn't a PDF date).
99
+ * @param {MetadataInit} metadata
100
+ */
101
+ metadata(metadata) {
102
+ let ret;
103
+ ret = wasm.wasmbuilder_metadata(this.__wbg_ptr, metadata);
104
+ if (ret[1]) {
105
+ throw takeFromExternrefTable0(ret[0]);
106
+ }
107
+ }
108
+ /**
109
+ * A builder for a new, empty document.
110
+ *
111
+ * # Errors
112
+ * `invalid-argument` / `unknown-option` for bad options.
113
+ * @param {BuildOptionsInit | undefined} options
114
+ */
115
+ constructor(options) {
116
+ let ret;
117
+ ret = wasm.wasmbuilder_new(options);
118
+ if (ret[2]) {
119
+ throw takeFromExternrefTable0(ret[1]);
120
+ }
121
+ this.__wbg_ptr = ret[0];
122
+ Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
123
+ WasmBuilderFinalization.register(this, { ptr: ret[0], instance: __wbg_instance_id }, this);
124
+ return this;
125
+ }
126
+ /**
127
+ * Adds outline items (with their children); returns their IDs in pre-order.
128
+ *
129
+ * # Errors
130
+ * `builder-finished`; `invalid-argument`; `limit-exceeded`.
131
+ * @param {OutlineEntryInit[]} entries
132
+ * @returns {string[]}
133
+ */
134
+ outline(entries) {
135
+ let ret;
136
+ ret = wasm.wasmbuilder_outline(this.__wbg_ptr, entries);
137
+ if (ret[2]) {
138
+ throw takeFromExternrefTable0(ret[1]);
139
+ }
140
+ return takeFromExternrefTable0(ret[0]);
141
+ }
142
+ /**
143
+ * The page labels, ranges by first page (checked at [`WasmBuilder::finish`]).
144
+ *
145
+ * # Errors
146
+ * `builder-finished`; `invalid-argument`.
147
+ * @param {PageLabelInit[]} ranges
148
+ */
149
+ pageLabels(ranges) {
150
+ let ret;
151
+ ret = wasm.wasmbuilder_pageLabels(this.__wbg_ptr, ranges);
152
+ if (ret[1]) {
153
+ throw takeFromExternrefTable0(ret[0]);
154
+ }
155
+ }
156
+ /**
157
+ * A page of `width` × `height` points, written by [`WasmPageBuilder::finish`].
158
+ * @param {number} width
159
+ * @param {number} height
160
+ * @returns {WasmPageBuilder}
161
+ */
162
+ page(width, height) {
163
+ let ret;
164
+ ret = wasm.wasmbuilder_page(this.__wbg_ptr, width, height);
165
+ return WasmPageBuilder.__wrap(ret);
166
+ }
167
+ /**
168
+ * How viewers present the document when it opens.
169
+ *
170
+ * # Errors
171
+ * `builder-finished`; `invalid-argument`.
172
+ * @param {ViewerPreferencesInit} prefs
173
+ */
174
+ viewerPreferences(prefs) {
175
+ let ret;
176
+ ret = wasm.wasmbuilder_viewerPreferences(this.__wbg_ptr, prefs);
177
+ if (ret[1]) {
178
+ throw takeFromExternrefTable0(ret[0]);
179
+ }
180
+ }
181
+ }
182
+ if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
183
+
184
+ /**
185
+ * An open PDF: read it, edit it with ops (with undo), save it. The binding of
186
+ * `laminapdf::Document`, method for method (F12).
187
+ */
188
+ export class WasmDocument {
189
+ static __wrap(ptr) {
190
+ const obj = Object.create(WasmDocument.prototype);
191
+ obj.__wbg_ptr = ptr;
192
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
193
+
194
+ WasmDocumentFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
195
+ return obj;
196
+ }
197
+ __destroy_into_raw() {
198
+ const ptr = this.__wbg_ptr;
199
+ this.__wbg_ptr = 0;
200
+ WasmDocumentFinalization.unregister(this);
201
+ return ptr;
202
+ }
203
+ free() {
204
+ const ptr = this.__destroy_into_raw();
205
+ wasm.__wbg_wasmdocument_free(ptr, 0);
206
+
207
+ }
208
+ /**
209
+ * Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
210
+ *
211
+ * # Errors
212
+ * `invalid-op-log`, `unsupported-version`; as [`WasmDocument::apply`].
213
+ * @param {string} json
214
+ * @returns {EditedJs}
215
+ */
216
+ applyLog(json) {
217
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ let ret;
220
+ ret = wasm.wasmdocument_applyLog(this.__wbg_ptr, ptr0, len0);
221
+ if (ret[2]) {
222
+ throw takeFromExternrefTable0(ret[1]);
223
+ }
224
+ return takeFromExternrefTable0(ret[0]);
225
+ }
226
+ /**
227
+ * Applies `ops` (the op JSON of ADR 0006 §6) in order, as one transaction.
228
+ *
229
+ * # Errors
230
+ * `invalid-argument` / `unknown-option` for a value that isn't an op; the first op's
231
+ * error (nothing is applied).
232
+ * @param {Op[]} ops
233
+ * @returns {EditedJs}
234
+ */
235
+ apply(ops) {
236
+ let ret;
237
+ ret = wasm.wasmdocument_apply(this.__wbg_ptr, ops);
238
+ if (ret[2]) {
239
+ throw takeFromExternrefTable0(ret[1]);
240
+ }
241
+ return takeFromExternrefTable0(ret[0]);
242
+ }
243
+ /**
244
+ * Whether there are changes no save has written yet.
245
+ * @returns {boolean}
246
+ */
247
+ hasUnsavedChanges() {
248
+ let ret;
249
+ ret = wasm.wasmdocument_hasUnsavedChanges(this.__wbg_ptr);
250
+ return ret !== 0;
251
+ }
252
+ /**
253
+ * The Info dictionary's text entries.
254
+ *
255
+ * # Errors
256
+ * Reading errors.
257
+ * @returns {DocumentInfoJs}
258
+ */
259
+ info() {
260
+ let ret;
261
+ ret = wasm.wasmdocument_info(this.__wbg_ptr);
262
+ if (ret[2]) {
263
+ throw takeFromExternrefTable0(ret[1]);
264
+ }
265
+ return takeFromExternrefTable0(ret[0]);
266
+ }
267
+ /**
268
+ * Opens a document from its bytes.
269
+ *
270
+ * # Errors
271
+ * The §1 object: `not-pdf`, `password-required`, `wrong-password`, `limit-exceeded`, …;
272
+ * `invalid-argument` / `unknown-option` for bad options.
273
+ * @param {Uint8Array} bytes
274
+ * @param {OpenOptionsInit | undefined} options
275
+ * @returns {WasmDocument}
276
+ */
277
+ static openBytes(bytes, options) {
278
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
279
+ const len0 = WASM_VECTOR_LEN;
280
+ let ret;
281
+ ret = wasm.wasmdocument_openBytes(ptr0, len0, options);
282
+ if (ret[2]) {
283
+ throw takeFromExternrefTable0(ret[1]);
284
+ }
285
+ return WasmDocument.__wrap(ret[0]);
286
+ }
287
+ /**
288
+ * Opens a document over a sparse source whose bytes arrive later. Until the source holds
289
+ * what a call needs, the call throws `data-pending` with `data.ranges` (`[offset, length]`
290
+ * pairs): supply them and call again. Lazy reads on the document can do the same.
291
+ *
292
+ * # Errors
293
+ * As `openBytes`, and `data-pending`.
294
+ * @param {WasmSparseSource} source
295
+ * @param {OpenOptionsInit | undefined} options
296
+ * @returns {WasmDocument}
297
+ */
298
+ static openSource(source, options) {
299
+ _assertClass(source, WasmSparseSource);
300
+ let ret;
301
+ ret = wasm.wasmdocument_openSource(source.__wbg_ptr, options);
302
+ if (ret[2]) {
303
+ throw takeFromExternrefTable0(ret[1]);
304
+ }
305
+ return WasmDocument.__wrap(ret[0]);
306
+ }
307
+ /**
308
+ * A handle on the page with `id` (`p12.0`).
309
+ *
310
+ * # Errors
311
+ * `invalid-argument` for a malformed ID; `unknown-page`.
312
+ * @param {string} id
313
+ * @returns {WasmPage}
314
+ */
315
+ pageById(id) {
316
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
317
+ const len0 = WASM_VECTOR_LEN;
318
+ let ret;
319
+ ret = wasm.wasmdocument_pageById(this.__wbg_ptr, ptr0, len0);
320
+ if (ret[2]) {
321
+ throw takeFromExternrefTable0(ret[1]);
322
+ }
323
+ return WasmPage.__wrap(ret[0]);
324
+ }
325
+ /**
326
+ * The number of pages.
327
+ *
328
+ * # Errors
329
+ * Reading errors.
330
+ * @returns {number}
331
+ */
332
+ pageCount() {
333
+ let ret;
334
+ ret = wasm.wasmdocument_pageCount(this.__wbg_ptr);
335
+ if (ret[2]) {
336
+ throw takeFromExternrefTable0(ret[1]);
337
+ }
338
+ return ret[0] >>> 0;
339
+ }
340
+ /**
341
+ * Page `index`'s facts.
342
+ *
343
+ * # Errors
344
+ * `page-index-out-of-range`; reading errors.
345
+ * @param {number} index
346
+ * @returns {PageInfoJs}
347
+ */
348
+ pageInfo(index) {
349
+ let ret;
350
+ ret = wasm.wasmdocument_pageInfo(this.__wbg_ptr, index);
351
+ if (ret[2]) {
352
+ throw takeFromExternrefTable0(ret[1]);
353
+ }
354
+ return takeFromExternrefTable0(ret[0]);
355
+ }
356
+ /**
357
+ * Every page's facts, in order (one page-tree walk).
358
+ *
359
+ * # Errors
360
+ * Reading errors.
361
+ * @returns {PageInfoJs[]}
362
+ */
363
+ pageInfos() {
364
+ let ret;
365
+ ret = wasm.wasmdocument_pageInfos(this.__wbg_ptr);
366
+ if (ret[2]) {
367
+ throw takeFromExternrefTable0(ret[1]);
368
+ }
369
+ return takeFromExternrefTable0(ret[0]);
370
+ }
371
+ /**
372
+ * A handle on page `index` that follows the page by its ID (F2).
373
+ *
374
+ * # Errors
375
+ * `page-index-out-of-range`; reading errors.
376
+ * @param {number} index
377
+ * @returns {WasmPage}
378
+ */
379
+ page(index) {
380
+ let ret;
381
+ ret = wasm.wasmdocument_page(this.__wbg_ptr, index);
382
+ if (ret[2]) {
383
+ throw takeFromExternrefTable0(ret[1]);
384
+ }
385
+ return WasmPage.__wrap(ret[0]);
386
+ }
387
+ /**
388
+ * Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
389
+ *
390
+ * # Errors
391
+ * `no-pending-save`; reading errors in `bytes`.
392
+ * @param {Uint8Array} bytes
393
+ */
394
+ rebase(bytes) {
395
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
396
+ const len0 = WASM_VECTOR_LEN;
397
+ let ret;
398
+ ret = wasm.wasmdocument_rebase(this.__wbg_ptr, ptr0, len0);
399
+ if (ret[1]) {
400
+ throw takeFromExternrefTable0(ret[0]);
401
+ }
402
+ }
403
+ /**
404
+ * Redoes the newest undone transaction; `undefined` when there is nothing to redo.
405
+ *
406
+ * # Errors
407
+ * As [`WasmDocument::undo`].
408
+ * @returns {UndoOutcomeJs | undefined}
409
+ */
410
+ redo() {
411
+ let ret;
412
+ ret = wasm.wasmdocument_redo(this.__wbg_ptr);
413
+ if (ret[2]) {
414
+ throw takeFromExternrefTable0(ret[1]);
415
+ }
416
+ return takeFromExternrefTable0(ret[0]);
417
+ }
418
+ /**
419
+ * A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
420
+ *
421
+ * # Errors
422
+ * `invalid-argument` / `unknown-option` for bad options.
423
+ * @param {SaveOptionsInit | undefined} options
424
+ * @returns {WasmSaveJob}
425
+ */
426
+ saveJob(options) {
427
+ let ret;
428
+ ret = wasm.wasmdocument_saveJob(this.__wbg_ptr, options);
429
+ if (ret[2]) {
430
+ throw takeFromExternrefTable0(ret[1]);
431
+ }
432
+ return WasmSaveJob.__wrap(ret[0]);
433
+ }
434
+ /**
435
+ * Saves and rebases onto the output, running to completion: `{ bytes, report }`.
436
+ *
437
+ * # Errors
438
+ * The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
439
+ * @param {SaveOptionsInit | undefined} options
440
+ * @returns {{ bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
441
+ */
442
+ save(options) {
443
+ let ret;
444
+ ret = wasm.wasmdocument_save(this.__wbg_ptr, options);
445
+ if (ret[2]) {
446
+ throw takeFromExternrefTable0(ret[1]);
447
+ }
448
+ return takeFromExternrefTable0(ret[0]);
449
+ }
450
+ /**
451
+ * Undoes the newest transaction; `undefined` when there is nothing to undo.
452
+ *
453
+ * # Errors
454
+ * `nested-transaction`, `saved-not-rebased`; reading errors.
455
+ * @returns {UndoOutcomeJs | undefined}
456
+ */
457
+ undo() {
458
+ let ret;
459
+ ret = wasm.wasmdocument_undo(this.__wbg_ptr);
460
+ if (ret[2]) {
461
+ throw takeFromExternrefTable0(ret[1]);
462
+ }
463
+ return takeFromExternrefTable0(ret[0]);
464
+ }
465
+ /**
466
+ * A cursor over the warnings so far (build warnings first), each as the §1 object.
467
+ * @returns {WasmWarningCursor}
468
+ */
469
+ warnings() {
470
+ let ret;
471
+ ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
472
+ return WasmWarningCursor.__wrap(ret);
473
+ }
474
+ }
475
+ if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
476
+
477
+ /**
478
+ * An image to draw (decoded or passed through once, shared by every use).
479
+ */
480
+ export class WasmImage {
481
+ static __wrap(ptr) {
482
+ const obj = Object.create(WasmImage.prototype);
483
+ obj.__wbg_ptr = ptr;
484
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
485
+
486
+ WasmImageFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
487
+ return obj;
488
+ }
489
+ __destroy_into_raw() {
490
+ const ptr = this.__wbg_ptr;
491
+ this.__wbg_ptr = 0;
492
+ WasmImageFinalization.unregister(this);
493
+ return ptr;
494
+ }
495
+ free() {
496
+ const ptr = this.__destroy_into_raw();
497
+ wasm.__wbg_wasmimage_free(ptr, 0);
498
+
499
+ }
500
+ /**
501
+ * Height in pixels.
502
+ * @returns {number}
503
+ */
504
+ get height() {
505
+ let ret;
506
+ ret = wasm.wasmimage_height(this.__wbg_ptr);
507
+ return ret >>> 0;
508
+ }
509
+ /**
510
+ * A JPEG, passed through (`DCTDecode`).
511
+ *
512
+ * # Errors
513
+ * `invalid-image`, `unsupported-image`.
514
+ * @param {Uint8Array} bytes
515
+ * @returns {WasmImage}
516
+ */
517
+ static jpeg(bytes) {
518
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
519
+ const len0 = WASM_VECTOR_LEN;
520
+ let ret;
521
+ ret = wasm.wasmimage_jpeg(ptr0, len0);
522
+ if (ret[2]) {
523
+ throw takeFromExternrefTable0(ret[1]);
524
+ }
525
+ return WasmImage.__wrap(ret[0]);
526
+ }
527
+ /**
528
+ * A PNG (alpha as an `/SMask`).
529
+ *
530
+ * # Errors
531
+ * `invalid-image`, `unsupported-image`, `image-too-large`.
532
+ * @param {Uint8Array} bytes
533
+ * @returns {WasmImage}
534
+ */
535
+ static png(bytes) {
536
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
537
+ const len0 = WASM_VECTOR_LEN;
538
+ let ret;
539
+ ret = wasm.wasmimage_png(ptr0, len0);
540
+ if (ret[2]) {
541
+ throw takeFromExternrefTable0(ret[1]);
542
+ }
543
+ return WasmImage.__wrap(ret[0]);
544
+ }
545
+ /**
546
+ * Raw 8-bit RGBA pixels, row by row.
547
+ *
548
+ * # Errors
549
+ * `invalid-image` when the length isn't `width × height × 4`.
550
+ * @param {number} width
551
+ * @param {number} height
552
+ * @param {Uint8Array} rgba
553
+ * @returns {WasmImage}
554
+ */
555
+ static rgba(width, height, rgba) {
556
+ const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
557
+ const len0 = WASM_VECTOR_LEN;
558
+ let ret;
559
+ ret = wasm.wasmimage_rgba(width, height, ptr0, len0);
560
+ if (ret[2]) {
561
+ throw takeFromExternrefTable0(ret[1]);
562
+ }
563
+ return WasmImage.__wrap(ret[0]);
564
+ }
565
+ /**
566
+ * Width in pixels.
567
+ * @returns {number}
568
+ */
569
+ get width() {
570
+ let ret;
571
+ ret = wasm.wasmimage_width(this.__wbg_ptr);
572
+ return ret >>> 0;
573
+ }
574
+ }
575
+ if (Symbol.dispose) WasmImage.prototype[Symbol.dispose] = WasmImage.prototype.free;
576
+
577
+ /**
578
+ * A page of a [`WasmDocument`], held by its ID (F2): moving pages doesn't retarget it.
579
+ */
580
+ export class WasmPage {
581
+ static __wrap(ptr) {
582
+ const obj = Object.create(WasmPage.prototype);
583
+ obj.__wbg_ptr = ptr;
584
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
585
+
586
+ WasmPageFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
587
+ return obj;
588
+ }
589
+ __destroy_into_raw() {
590
+ const ptr = this.__wbg_ptr;
591
+ this.__wbg_ptr = 0;
592
+ WasmPageFinalization.unregister(this);
593
+ return ptr;
594
+ }
595
+ free() {
596
+ const ptr = this.__destroy_into_raw();
597
+ wasm.__wbg_wasmpage_free(ptr, 0);
598
+
599
+ }
600
+ /**
601
+ * The page's stable ID (`p12.0`).
602
+ * @returns {string}
603
+ */
604
+ get id() {
605
+ let deferred1_0;
606
+ let deferred1_1;
607
+ try {
608
+ let ret;
609
+ ret = wasm.wasmpage_id(this.__wbg_ptr);
610
+ deferred1_0 = ret[0];
611
+ deferred1_1 = ret[1];
612
+ return getStringFromWasm0(ret[0], ret[1]);
613
+ } finally {
614
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
615
+ }
616
+ }
617
+ /**
618
+ * The page's current 0-based index.
619
+ *
620
+ * # Errors
621
+ * `unknown-page` when the page is gone; `disposed` when its document is freed; reading
622
+ * errors.
623
+ * @returns {number}
624
+ */
625
+ index() {
626
+ let ret;
627
+ ret = wasm.wasmpage_index(this.__wbg_ptr);
628
+ if (ret[2]) {
629
+ throw takeFromExternrefTable0(ret[1]);
630
+ }
631
+ return ret[0] >>> 0;
632
+ }
633
+ /**
634
+ * The page's facts now.
635
+ *
636
+ * # Errors
637
+ * As [`WasmPage::index`].
638
+ * @returns {PageInfoJs}
639
+ */
640
+ info() {
641
+ let ret;
642
+ ret = wasm.wasmpage_info(this.__wbg_ptr);
643
+ if (ret[2]) {
644
+ throw takeFromExternrefTable0(ret[1]);
645
+ }
646
+ return takeFromExternrefTable0(ret[0]);
647
+ }
648
+ }
649
+ if (Symbol.dispose) WasmPage.prototype[Symbol.dispose] = WasmPage.prototype.free;
650
+
651
+ /**
652
+ * One page being drawn, in page space (points from the top-left, y down; ADR 0027).
653
+ * Invalid geometry is reported by [`WasmPageBuilder::finish`] (`invalid-geometry`).
654
+ */
655
+ export class WasmPageBuilder {
656
+ static __wrap(ptr) {
657
+ const obj = Object.create(WasmPageBuilder.prototype);
658
+ obj.__wbg_ptr = ptr;
659
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
660
+
661
+ WasmPageBuilderFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
662
+ return obj;
663
+ }
664
+ __destroy_into_raw() {
665
+ const ptr = this.__wbg_ptr;
666
+ this.__wbg_ptr = 0;
667
+ WasmPageBuilderFinalization.unregister(this);
668
+ return ptr;
669
+ }
670
+ free() {
671
+ const ptr = this.__destroy_into_raw();
672
+ wasm.__wbg_wasmpagebuilder_free(ptr, 0);
673
+
674
+ }
675
+ /**
676
+ * Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
677
+ * or `background`.
678
+ *
679
+ * # Errors
680
+ * `invalid-argument` for another kind.
681
+ * @param {string} kind
682
+ */
683
+ beginArtifact(kind) {
684
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
685
+ const len0 = WASM_VECTOR_LEN;
686
+ let ret;
687
+ ret = wasm.wasmpagebuilder_beginArtifact(this.__wbg_ptr, ptr0, len0);
688
+ if (ret[1]) {
689
+ throw takeFromExternrefTable0(ret[0]);
690
+ }
691
+ }
692
+ /**
693
+ * Opens a structure element until the matching `endTag`: `kind` names a standard type
694
+ * (`Document`, `Part`, `Sect`, `H1`–`H6`, `P`, `L`, `LI`, `Lbl`, `LBody`, `Table`, `TR`,
695
+ * `TH`, `TD`, `Figure`, `Caption`, `Link`, `Span`, `Quote`, `Note`, `Code`), the role of
696
+ * `custom` when given; `/Alt`, `/ActualText`, `/Lang`, `/E`; `scope` is `row`, `column` or
697
+ * `both` when given.
698
+ *
699
+ * # Errors
700
+ * `invalid-argument` for an unknown `kind` or `scope`.
701
+ * @param {string} kind
702
+ * @param {string | null} [custom]
703
+ * @param {string | null} [alt]
704
+ * @param {string | null} [actualText]
705
+ * @param {string | null} [lang]
706
+ * @param {string | null} [expansion]
707
+ * @param {string | null} [scope]
708
+ */
709
+ beginTag(kind, custom, alt, actualText, lang, expansion, scope) {
710
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
711
+ const len0 = WASM_VECTOR_LEN;
712
+ var ptr1 = isLikeNone(custom) ? 0 : passStringToWasm0(custom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
713
+ var len1 = WASM_VECTOR_LEN;
714
+ var ptr2 = isLikeNone(alt) ? 0 : passStringToWasm0(alt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
715
+ var len2 = WASM_VECTOR_LEN;
716
+ var ptr3 = isLikeNone(actualText) ? 0 : passStringToWasm0(actualText, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
717
+ var len3 = WASM_VECTOR_LEN;
718
+ var ptr4 = isLikeNone(lang) ? 0 : passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
719
+ var len4 = WASM_VECTOR_LEN;
720
+ var ptr5 = isLikeNone(expansion) ? 0 : passStringToWasm0(expansion, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
721
+ var len5 = WASM_VECTOR_LEN;
722
+ var ptr6 = isLikeNone(scope) ? 0 : passStringToWasm0(scope, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
723
+ var len6 = WASM_VECTOR_LEN;
724
+ let ret;
725
+ ret = wasm.wasmpagebuilder_beginTag(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
726
+ if (ret[1]) {
727
+ throw takeFromExternrefTable0(ret[0]);
728
+ }
729
+ }
730
+ /**
731
+ * The blend mode, camelCase (`multiply`, `colorDodge`, …).
732
+ *
733
+ * # Errors
734
+ * `invalid-argument` for an unknown mode.
735
+ * @param {string} mode
736
+ */
737
+ blendMode(mode) {
738
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
739
+ const len0 = WASM_VECTOR_LEN;
740
+ let ret;
741
+ ret = wasm.wasmpagebuilder_blendMode(this.__wbg_ptr, ptr0, len0);
742
+ if (ret[1]) {
743
+ throw takeFromExternrefTable0(ret[0]);
744
+ }
745
+ }
746
+ /**
747
+ * Clips to `path` (with `rule`) until the next `restore`.
748
+ *
749
+ * # Errors
750
+ * As [`WasmPageBuilder::fill_path`].
751
+ * @param {Float64Array} path
752
+ * @param {string} rule
753
+ */
754
+ clipPath(path, rule) {
755
+ const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
756
+ const len0 = WASM_VECTOR_LEN;
757
+ const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
758
+ const len1 = WASM_VECTOR_LEN;
759
+ let ret;
760
+ ret = wasm.wasmpagebuilder_clipPath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
761
+ if (ret[1]) {
762
+ throw takeFromExternrefTable0(ret[0]);
763
+ }
764
+ }
765
+ /**
766
+ * Ends the innermost open element or artifact (none open: nothing happens).
767
+ *
768
+ * # Errors
769
+ * `builder-finished`.
770
+ */
771
+ endTag() {
772
+ let ret;
773
+ ret = wasm.wasmpagebuilder_endTag(this.__wbg_ptr);
774
+ if (ret[1]) {
775
+ throw takeFromExternrefTable0(ret[0]);
776
+ }
777
+ }
778
+ /**
779
+ * The fill colour as `#rrggbb` or `#rgb` (`DeviceRGB`).
780
+ *
781
+ * # Errors
782
+ * `invalid-color`.
783
+ * @param {string} hex
784
+ */
785
+ fillColorHex(hex) {
786
+ const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
787
+ const len0 = WASM_VECTOR_LEN;
788
+ let ret;
789
+ ret = wasm.wasmpagebuilder_fillColorHex(this.__wbg_ptr, ptr0, len0);
790
+ if (ret[1]) {
791
+ throw takeFromExternrefTable0(ret[0]);
792
+ }
793
+ }
794
+ /**
795
+ * The colour fills use: 1 (gray), 3 (RGB) or 4 (CMYK) components, 0 to 1.
796
+ *
797
+ * # Errors
798
+ * `invalid-argument` for another number of components.
799
+ * @param {Float64Array} components
800
+ */
801
+ fillColor(components) {
802
+ const ptr0 = passArrayF64ToWasm0(components, wasm.__wbindgen_malloc);
803
+ const len0 = WASM_VECTOR_LEN;
804
+ let ret;
805
+ ret = wasm.wasmpagebuilder_fillColor(this.__wbg_ptr, ptr0, len0);
806
+ if (ret[1]) {
807
+ throw takeFromExternrefTable0(ret[0]);
808
+ }
809
+ }
810
+ /**
811
+ * Fills `path` (the flat path encoding) with `rule` (`nonZero` or `evenOdd`).
812
+ *
813
+ * # Errors
814
+ * `invalid-argument` for a bad path or rule.
815
+ * @param {Float64Array} path
816
+ * @param {string} rule
817
+ */
818
+ fillPath(path, rule) {
819
+ const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
820
+ const len0 = WASM_VECTOR_LEN;
821
+ const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
822
+ const len1 = WASM_VECTOR_LEN;
823
+ let ret;
824
+ ret = wasm.wasmpagebuilder_fillPath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
825
+ if (ret[1]) {
826
+ throw takeFromExternrefTable0(ret[0]);
827
+ }
828
+ }
829
+ /**
830
+ * Fills `path` with `rule`, then strokes it with the current stroke style.
831
+ *
832
+ * # Errors
833
+ * As [`WasmPageBuilder::fill_path`].
834
+ * @param {Float64Array} path
835
+ * @param {string} rule
836
+ */
837
+ fillStrokePath(path, rule) {
838
+ const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
839
+ const len0 = WASM_VECTOR_LEN;
840
+ const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
841
+ const len1 = WASM_VECTOR_LEN;
842
+ let ret;
843
+ ret = wasm.wasmpagebuilder_fillStrokePath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
844
+ if (ret[1]) {
845
+ throw takeFromExternrefTable0(ret[0]);
846
+ }
847
+ }
848
+ /**
849
+ * Writes the page into its builder: content stream, resources and page dictionary.
850
+ * Returns its page ID. The page is finished afterwards: every later call on it fails
851
+ * with `builder-finished`.
852
+ *
853
+ * # Errors
854
+ * `builder-finished` (the page or its builder already finished); `invalid-geometry` for
855
+ * the first invalid value drawn; `unknown-font` for a font from another builder.
856
+ * @returns {string}
857
+ */
858
+ finish() {
859
+ let deferred2_0;
860
+ let deferred2_1;
861
+ try {
862
+ let ret;
863
+ ret = wasm.wasmpagebuilder_finish(this.__wbg_ptr);
864
+ var ptr1 = ret[0];
865
+ var len1 = ret[1];
866
+ if (ret[3]) {
867
+ ptr1 = 0; len1 = 0;
868
+ throw takeFromExternrefTable0(ret[2]);
869
+ }
870
+ deferred2_0 = ptr1;
871
+ deferred2_1 = len1;
872
+ return getStringFromWasm0(ptr1, len1);
873
+ } finally {
874
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
875
+ }
876
+ }
877
+ /**
878
+ * Draws `image` scaled into the rectangle.
879
+ *
880
+ * # Errors
881
+ * `builder-finished`.
882
+ * @param {WasmImage} image
883
+ * @param {number} x
884
+ * @param {number} y
885
+ * @param {number} width
886
+ * @param {number} height
887
+ */
888
+ image(image, x, y, width, height) {
889
+ _assertClass(image, WasmImage);
890
+ let ret;
891
+ ret = wasm.wasmpagebuilder_image(this.__wbg_ptr, image.__wbg_ptr, x, y, width, height);
892
+ if (ret[1]) {
893
+ throw takeFromExternrefTable0(ret[0]);
894
+ }
895
+ }
896
+ /**
897
+ * A link annotation over the rectangle, with `contents` as its alternate text.
898
+ *
899
+ * # Errors
900
+ * `invalid-argument` / `unknown-option` for a bad target.
901
+ * @param {number} x
902
+ * @param {number} y
903
+ * @param {number} width
904
+ * @param {number} height
905
+ * @param {LinkTargetInit} target
906
+ * @param {string | null} [contents]
907
+ */
908
+ link(x, y, width, height, target, contents) {
909
+ var ptr0 = isLikeNone(contents) ? 0 : passStringToWasm0(contents, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
910
+ var len0 = WASM_VECTOR_LEN;
911
+ let ret;
912
+ ret = wasm.wasmpagebuilder_link(this.__wbg_ptr, x, y, width, height, target, ptr0, len0);
913
+ if (ret[1]) {
914
+ throw takeFromExternrefTable0(ret[0]);
915
+ }
916
+ }
917
+ /**
918
+ * Fill and stroke opacity, 0 to 1 (an `ExtGState`).
919
+ *
920
+ * # Errors
921
+ * `builder-finished`.
922
+ * @param {number} fill
923
+ * @param {number} stroke
924
+ */
925
+ opacity(fill, stroke) {
926
+ let ret;
927
+ ret = wasm.wasmpagebuilder_opacity(this.__wbg_ptr, fill, stroke);
928
+ if (ret[1]) {
929
+ throw takeFromExternrefTable0(ret[0]);
930
+ }
931
+ }
932
+ /**
933
+ * Restores the graphics state (`Q`); one without a matching save is ignored.
934
+ *
935
+ * # Errors
936
+ * `builder-finished`.
937
+ */
938
+ restore() {
939
+ let ret;
940
+ ret = wasm.wasmpagebuilder_restore(this.__wbg_ptr);
941
+ if (ret[1]) {
942
+ throw takeFromExternrefTable0(ret[0]);
943
+ }
944
+ }
945
+ /**
946
+ * `/Rotate`: 0, 90, 180 or 270 degrees.
947
+ *
948
+ * # Errors
949
+ * `invalid-argument` for another angle.
950
+ * @param {number} degrees
951
+ */
952
+ rotate(degrees) {
953
+ let ret;
954
+ ret = wasm.wasmpagebuilder_rotate(this.__wbg_ptr, degrees);
955
+ if (ret[1]) {
956
+ throw takeFromExternrefTable0(ret[0]);
957
+ }
958
+ }
959
+ /**
960
+ * Saves the graphics state (`q`).
961
+ *
962
+ * # Errors
963
+ * `builder-finished` after [`WasmPageBuilder::finish`] (so does every drawing method).
964
+ */
965
+ save() {
966
+ let ret;
967
+ ret = wasm.wasmpagebuilder_save(this.__wbg_ptr);
968
+ if (ret[1]) {
969
+ throw takeFromExternrefTable0(ret[0]);
970
+ }
971
+ }
972
+ /**
973
+ * `/CropBox`, `/BleedBox`, `/TrimBox` or `/ArtBox` (`kind`: `crop`, `bleed`, `trim`,
974
+ * `art`), in the media box's page space.
975
+ *
976
+ * # Errors
977
+ * `invalid-argument` for another kind.
978
+ * @param {"crop" | "bleed" | "trim" | "art"} kind
979
+ * @param {number} x
980
+ * @param {number} y
981
+ * @param {number} width
982
+ * @param {number} height
983
+ */
984
+ setBox(kind, x, y, width, height) {
985
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
986
+ const len0 = WASM_VECTOR_LEN;
987
+ let ret;
988
+ ret = wasm.wasmpagebuilder_setBox(this.__wbg_ptr, ptr0, len0, x, y, width, height);
989
+ if (ret[1]) {
990
+ throw takeFromExternrefTable0(ret[0]);
991
+ }
992
+ }
993
+ /**
994
+ * The stroke colour as `#rrggbb` or `#rgb`.
995
+ *
996
+ * # Errors
997
+ * `invalid-color`.
998
+ * @param {string} hex
999
+ */
1000
+ strokeColorHex(hex) {
1001
+ const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1002
+ const len0 = WASM_VECTOR_LEN;
1003
+ let ret;
1004
+ ret = wasm.wasmpagebuilder_strokeColorHex(this.__wbg_ptr, ptr0, len0);
1005
+ if (ret[1]) {
1006
+ throw takeFromExternrefTable0(ret[0]);
1007
+ }
1008
+ }
1009
+ /**
1010
+ * The colour strokes use (as [`WasmPageBuilder::fill_color`]).
1011
+ *
1012
+ * # Errors
1013
+ * As [`WasmPageBuilder::fill_color`].
1014
+ * @param {Float64Array} components
1015
+ */
1016
+ strokeColor(components) {
1017
+ const ptr0 = passArrayF64ToWasm0(components, wasm.__wbindgen_malloc);
1018
+ const len0 = WASM_VECTOR_LEN;
1019
+ let ret;
1020
+ ret = wasm.wasmpagebuilder_strokeColor(this.__wbg_ptr, ptr0, len0);
1021
+ if (ret[1]) {
1022
+ throw takeFromExternrefTable0(ret[0]);
1023
+ }
1024
+ }
1025
+ /**
1026
+ * Strokes `path` with the current stroke style.
1027
+ *
1028
+ * # Errors
1029
+ * `invalid-argument` for a bad path.
1030
+ * @param {Float64Array} path
1031
+ */
1032
+ strokePath(path) {
1033
+ const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
1034
+ const len0 = WASM_VECTOR_LEN;
1035
+ let ret;
1036
+ ret = wasm.wasmpagebuilder_strokePath(this.__wbg_ptr, ptr0, len0);
1037
+ if (ret[1]) {
1038
+ throw takeFromExternrefTable0(ret[0]);
1039
+ }
1040
+ }
1041
+ /**
1042
+ * The style later strokes use: `width` (points), `cap` (`butt`, `round`, `square`),
1043
+ * `join` (`miter`, `round`, `bevel`), the miter limit and a dash pattern (empty: solid).
1044
+ *
1045
+ * # Errors
1046
+ * `invalid-argument` for an unknown cap or join.
1047
+ * @param {number} width
1048
+ * @param {string} cap
1049
+ * @param {string} join
1050
+ * @param {number} miterLimit
1051
+ * @param {Float64Array} dash
1052
+ * @param {number} dashPhase
1053
+ */
1054
+ strokeStyle(width, cap, join, miterLimit, dash, dashPhase) {
1055
+ const ptr0 = passStringToWasm0(cap, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1056
+ const len0 = WASM_VECTOR_LEN;
1057
+ const ptr1 = passStringToWasm0(join, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1058
+ const len1 = WASM_VECTOR_LEN;
1059
+ const ptr2 = passArrayF64ToWasm0(dash, wasm.__wbindgen_malloc);
1060
+ const len2 = WASM_VECTOR_LEN;
1061
+ let ret;
1062
+ ret = wasm.wasmpagebuilder_strokeStyle(this.__wbg_ptr, width, ptr0, len0, ptr1, len1, miterLimit, ptr2, len2, dashPhase);
1063
+ if (ret[1]) {
1064
+ throw takeFromExternrefTable0(ret[0]);
1065
+ }
1066
+ }
1067
+ /**
1068
+ * Applies `[a, b, c, d, e, f]` (page space) to what is drawn next.
1069
+ *
1070
+ * # Errors
1071
+ * `invalid-argument` unless there are 6 numbers.
1072
+ * @param {Float64Array} m
1073
+ */
1074
+ transform(m) {
1075
+ const ptr0 = passArrayF64ToWasm0(m, wasm.__wbindgen_malloc);
1076
+ const len0 = WASM_VECTOR_LEN;
1077
+ let ret;
1078
+ ret = wasm.wasmpagebuilder_transform(this.__wbg_ptr, ptr0, len0);
1079
+ if (ret[1]) {
1080
+ throw takeFromExternrefTable0(ret[0]);
1081
+ }
1082
+ }
1083
+ /**
1084
+ * `/UserUnit`, for pages larger than 14,400 units.
1085
+ * @param {number} unit
1086
+ */
1087
+ userUnit(unit) {
1088
+ wasm.wasmpagebuilder_userUnit(this.__wbg_ptr, unit);
1089
+ }
1090
+ }
1091
+ if (Symbol.dispose) WasmPageBuilder.prototype[Symbol.dispose] = WasmPageBuilder.prototype.free;
1092
+
1093
+ /**
1094
+ * A save in progress (F10). Each `step` checks that the document is unchanged since the
1095
+ * job was created (`document-changed`).
1096
+ */
1097
+ export class WasmSaveJob {
1098
+ static __wrap(ptr) {
1099
+ const obj = Object.create(WasmSaveJob.prototype);
1100
+ obj.__wbg_ptr = ptr;
1101
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
1102
+
1103
+ WasmSaveJobFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
1104
+ return obj;
1105
+ }
1106
+ __destroy_into_raw() {
1107
+ const ptr = this.__wbg_ptr;
1108
+ this.__wbg_ptr = 0;
1109
+ WasmSaveJobFinalization.unregister(this);
1110
+ return ptr;
1111
+ }
1112
+ free() {
1113
+ const ptr = this.__destroy_into_raw();
1114
+ wasm.__wbg_wasmsavejob_free(ptr, 0);
1115
+
1116
+ }
1117
+ /**
1118
+ * Stops the job: its next step fails with `cancelled`.
1119
+ */
1120
+ cancel() {
1121
+ wasm.wasmsavejob_cancel(this.__wbg_ptr);
1122
+ }
1123
+ /**
1124
+ * Runs at most `budget` work units: `{ state: "progress", done, total?, phase }` or
1125
+ * `{ state: "done", bytes, report }`.
1126
+ *
1127
+ * # Errors
1128
+ * `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
1129
+ * or the save's own errors.
1130
+ * @param {number} budget
1131
+ * @returns {({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
1132
+ */
1133
+ step(budget) {
1134
+ let ret;
1135
+ ret = wasm.wasmsavejob_step(this.__wbg_ptr, budget);
1136
+ if (ret[2]) {
1137
+ throw takeFromExternrefTable0(ret[1]);
1138
+ }
1139
+ return takeFromExternrefTable0(ret[0]);
1140
+ }
1141
+ }
1142
+ if (Symbol.dispose) WasmSaveJob.prototype[Symbol.dispose] = WasmSaveJob.prototype.free;
1143
+
1144
+ /**
1145
+ * A PDF of known size whose bytes arrive later: give it to `WasmDocument.openSource`, and
1146
+ * after a `data-pending` error `supply` the ranges in its `data.ranges` and call again.
1147
+ */
1148
+ export class WasmSparseSource {
1149
+ __destroy_into_raw() {
1150
+ const ptr = this.__wbg_ptr;
1151
+ this.__wbg_ptr = 0;
1152
+ WasmSparseSourceFinalization.unregister(this);
1153
+ return ptr;
1154
+ }
1155
+ free() {
1156
+ const ptr = this.__destroy_into_raw();
1157
+ wasm.__wbg_wasmsparsesource_free(ptr, 0);
1158
+
1159
+ }
1160
+ /**
1161
+ * An empty source of `size` bytes holding at most `budget` bytes (no limit when omitted).
1162
+ *
1163
+ * # Errors
1164
+ * `invalid-argument` when a number isn't a whole number of bytes.
1165
+ * @param {number} size
1166
+ * @param {number | null} [budget]
1167
+ */
1168
+ constructor(size, budget) {
1169
+ let ret;
1170
+ ret = wasm.wasmsparsesource_new(size, !isLikeNone(budget), isLikeNone(budget) ? 0 : budget);
1171
+ if (ret[2]) {
1172
+ throw takeFromExternrefTable0(ret[1]);
1173
+ }
1174
+ this.__wbg_ptr = ret[0];
1175
+ Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
1176
+ WasmSparseSourceFinalization.register(this, { ptr: ret[0], instance: __wbg_instance_id }, this);
1177
+ return this;
1178
+ }
1179
+ /**
1180
+ * The source's size in bytes.
1181
+ * @returns {number}
1182
+ */
1183
+ get size() {
1184
+ let ret;
1185
+ ret = wasm.wasmsparsesource_size(this.__wbg_ptr);
1186
+ return ret;
1187
+ }
1188
+ /**
1189
+ * Adds `bytes` at `offset` (bytes already held win over overlapping ones).
1190
+ *
1191
+ * # Errors
1192
+ * `invalid-argument` past the end; `source-budget-exceeded` over the budget.
1193
+ * @param {number} offset
1194
+ * @param {Uint8Array} bytes
1195
+ */
1196
+ supply(offset, bytes) {
1197
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1198
+ const len0 = WASM_VECTOR_LEN;
1199
+ let ret;
1200
+ ret = wasm.wasmsparsesource_supply(this.__wbg_ptr, offset, ptr0, len0);
1201
+ if (ret[1]) {
1202
+ throw takeFromExternrefTable0(ret[0]);
1203
+ }
1204
+ }
1205
+ /**
1206
+ * What to fetch for the ranges a `data-pending` asked for (flat `[start, end, …]`): each
1207
+ * widened to blocks of `block` bytes (0: as asked) plus `readahead`, merged, minus what is
1208
+ * held, in the same flat form. The planning step of `laminapdf-source`'s `retry`, so every
1209
+ * loop plans the same way.
1210
+ *
1211
+ * # Errors
1212
+ * `invalid-argument` for an odd length or a value that isn't a whole number of bytes.
1213
+ * @param {Float64Array} asked
1214
+ * @param {number} block
1215
+ * @param {number} readahead
1216
+ * @returns {Float64Array}
1217
+ */
1218
+ toFetch(asked, block, readahead) {
1219
+ const ptr0 = passArrayF64ToWasm0(asked, wasm.__wbindgen_malloc);
1220
+ const len0 = WASM_VECTOR_LEN;
1221
+ let ret;
1222
+ ret = wasm.wasmsparsesource_toFetch(this.__wbg_ptr, ptr0, len0, block, readahead);
1223
+ if (ret[2]) {
1224
+ throw takeFromExternrefTable0(ret[1]);
1225
+ }
1226
+ return takeFromExternrefTable0(ret[0]);
1227
+ }
1228
+ }
1229
+ if (Symbol.dispose) WasmSparseSource.prototype[Symbol.dispose] = WasmSparseSource.prototype.free;
1230
+
1231
+ /**
1232
+ * The warnings of a document, read in batches (F8).
1233
+ */
1234
+ export class WasmWarningCursor {
1235
+ static __wrap(ptr) {
1236
+ const obj = Object.create(WasmWarningCursor.prototype);
1237
+ obj.__wbg_ptr = ptr;
1238
+ Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
1239
+
1240
+ WasmWarningCursorFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
1241
+ return obj;
1242
+ }
1243
+ __destroy_into_raw() {
1244
+ const ptr = this.__wbg_ptr;
1245
+ this.__wbg_ptr = 0;
1246
+ WasmWarningCursorFinalization.unregister(this);
1247
+ return ptr;
1248
+ }
1249
+ free() {
1250
+ const ptr = this.__destroy_into_raw();
1251
+ wasm.__wbg_wasmwarningcursor_free(ptr, 0);
1252
+
1253
+ }
1254
+ /**
1255
+ * Up to `max` more warnings, each as the ADR 0026 §1 object; empty at the end.
1256
+ * @param {number} max
1257
+ * @returns {Diagnostic[]}
1258
+ */
1259
+ nextBatch(max) {
1260
+ let ret;
1261
+ ret = wasm.wasmwarningcursor_nextBatch(this.__wbg_ptr, max);
1262
+ return ret;
1263
+ }
1264
+ /**
1265
+ * How many warnings are left.
1266
+ * @returns {number}
1267
+ */
1268
+ remaining() {
1269
+ let ret;
1270
+ ret = wasm.wasmwarningcursor_remaining(this.__wbg_ptr);
1271
+ return ret >>> 0;
1272
+ }
1273
+ }
1274
+ if (Symbol.dispose) WasmWarningCursor.prototype[Symbol.dispose] = WasmWarningCursor.prototype.free;
1275
+
1276
+ export function __wbg_reset_state () {
1277
+ __wbg_instance_id++;
1278
+ cachedDataViewMemory0 = null;
1279
+ cachedFloat64ArrayMemory0 = null;
1280
+ cachedUint8ArrayMemory0 = null;
1281
+ if (typeof numBytesDecoded !== 'undefined') numBytesDecoded = 0;
1282
+ if (typeof WASM_VECTOR_LEN !== 'undefined') WASM_VECTOR_LEN = 0;
1283
+ __wbg_reinit_scheduled = false;
1284
+ wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
1285
+ wasm = wasmInstance.exports;
1286
+ wasm.__wbindgen_start();
1287
+ }
1288
+
1289
+ /**
1290
+ * Whether the most recent allocation failed: after a trap, `true` means the module ran out of
1291
+ * memory.
1292
+ * @returns {boolean}
1293
+ */
1294
+ export function allocationFailed() {
1295
+ let ret;
1296
+ ret = wasm.allocationFailed();
1297
+ return ret !== 0;
1298
+ }
1299
+
1300
+ /**
1301
+ * Whether this module is the text module (fonts, `text`, `textBox`).
1302
+ * @returns {boolean}
1303
+ */
1304
+ export function hasText() {
1305
+ let ret;
1306
+ ret = wasm.hasText();
1307
+ return ret !== 0;
1308
+ }
1309
+
1310
+ /**
1311
+ * The crate version (`@laminapdf/wasm`'s).
1312
+ * @returns {string}
1313
+ */
1314
+ export function version() {
1315
+ let deferred1_0;
1316
+ let deferred1_1;
1317
+ try {
1318
+ let ret;
1319
+ ret = wasm.version();
1320
+ deferred1_0 = ret[0];
1321
+ deferred1_1 = ret[1];
1322
+ return getStringFromWasm0(ret[0], ret[1]);
1323
+ } finally {
1324
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1325
+ }
1326
+ }
1327
+ function __wbg_get_imports() {
1328
+ const import0 = {
1329
+ __proto__: null,
1330
+ __wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
1331
+ const ret = arg0 === null;
1332
+ return ret;
1333
+ },
1334
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
1335
+ const val = arg0;
1336
+ const ret = typeof(val) === 'object' && val !== null;
1337
+ return ret;
1338
+ },
1339
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
1340
+ const ret = arg0 === undefined;
1341
+ return ret;
1342
+ },
1343
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
1344
+ const obj = arg1;
1345
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1346
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1347
+ var len1 = WASM_VECTOR_LEN;
1348
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1349
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1350
+ },
1351
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
1352
+ throw new Error(getStringFromWasm0(arg0, arg1));
1353
+ },
1354
+ __wbg_keys_440be172f17c0265: function(arg0) {
1355
+ const ret = Object.keys(arg0);
1356
+ return ret;
1357
+ },
1358
+ __wbg_new_617a8cdb8bb1130e: function() {
1359
+ const ret = new Object();
1360
+ return ret;
1361
+ },
1362
+ __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
1363
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1364
+ return ret;
1365
+ },
1366
+ __wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
1367
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
1368
+ return ret;
1369
+ },
1370
+ __wbg_parse_0fc53dead14b3b42: function() { return handleError(function (arg0, arg1) {
1371
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1372
+ return ret;
1373
+ }, arguments); },
1374
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
1375
+ const ret = Reflect.set(arg0, arg1, arg2);
1376
+ return ret;
1377
+ }, arguments); },
1378
+ __wbg_slice_6da4cdc5d543fcd0: function(arg0, arg1) {
1379
+ const ret = arg1.slice();
1380
+ const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_malloc);
1381
+ const len1 = WASM_VECTOR_LEN;
1382
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1383
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1384
+ },
1385
+ __wbg_stringify_52ff602c1cc4fbb6: function() { return handleError(function (arg0) {
1386
+ const ret = JSON.stringify(arg0);
1387
+ return ret;
1388
+ }, arguments); },
1389
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1390
+ // Cast intrinsic for `Ref(String) -> Externref`.
1391
+ const ret = getStringFromWasm0(arg0, arg1);
1392
+ return ret;
1393
+ },
1394
+ __wbindgen_init_externref_table: function() {
1395
+ const table = wasm.__wbindgen_externrefs;
1396
+ const offset = table.grow(4);
1397
+ table.set(0, undefined);
1398
+ table.set(offset + 0, undefined);
1399
+ table.set(offset + 1, null);
1400
+ table.set(offset + 2, true);
1401
+ table.set(offset + 3, false);
1402
+ },
1403
+ };
1404
+ return {
1405
+ __proto__: null,
1406
+ "./lamina_pdf_base_bg.js": import0,
1407
+ };
1408
+ }
1409
+
1410
+ function __wbg_call_guard() {
1411
+ if (__wbg_reinit_scheduled) {
1412
+ __wbg_reset_state();
1413
+ return;
1414
+ }
1415
+ }
1416
+
1417
+
1418
+ let __wbg_instance_id = 0;
1419
+ const WasmBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
1420
+ ? { register: () => {}, unregister: () => {} }
1421
+ : new FinalizationRegistry(({ ptr, instance }) => {
1422
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmbuilder_free(ptr, 1);
1423
+ });
1424
+ const WasmDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
1425
+ ? { register: () => {}, unregister: () => {} }
1426
+ : new FinalizationRegistry(({ ptr, instance }) => {
1427
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmdocument_free(ptr, 1);
1428
+ });
1429
+ const WasmImageFinalization = (typeof FinalizationRegistry === 'undefined')
1430
+ ? { register: () => {}, unregister: () => {} }
1431
+ : new FinalizationRegistry(({ ptr, instance }) => {
1432
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmimage_free(ptr, 1);
1433
+ });
1434
+ const WasmPageFinalization = (typeof FinalizationRegistry === 'undefined')
1435
+ ? { register: () => {}, unregister: () => {} }
1436
+ : new FinalizationRegistry(({ ptr, instance }) => {
1437
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmpage_free(ptr, 1);
1438
+ });
1439
+ const WasmPageBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
1440
+ ? { register: () => {}, unregister: () => {} }
1441
+ : new FinalizationRegistry(({ ptr, instance }) => {
1442
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmpagebuilder_free(ptr, 1);
1443
+ });
1444
+ const WasmSaveJobFinalization = (typeof FinalizationRegistry === 'undefined')
1445
+ ? { register: () => {}, unregister: () => {} }
1446
+ : new FinalizationRegistry(({ ptr, instance }) => {
1447
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmsavejob_free(ptr, 1);
1448
+ });
1449
+ const WasmSparseSourceFinalization = (typeof FinalizationRegistry === 'undefined')
1450
+ ? { register: () => {}, unregister: () => {} }
1451
+ : new FinalizationRegistry(({ ptr, instance }) => {
1452
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmsparsesource_free(ptr, 1);
1453
+ });
1454
+ const WasmWarningCursorFinalization = (typeof FinalizationRegistry === 'undefined')
1455
+ ? { register: () => {}, unregister: () => {} }
1456
+ : new FinalizationRegistry(({ ptr, instance }) => {
1457
+ if (instance === __wbg_instance_id) wasm.__wbg_wasmwarningcursor_free(ptr, 1);
1458
+ });
1459
+
1460
+ function addToExternrefTable0(obj) {
1461
+ const idx = wasm.__externref_table_alloc();
1462
+ wasm.__wbindgen_externrefs.set(idx, obj);
1463
+ return idx;
1464
+ }
1465
+
1466
+ function _assertClass(instance, klass) {
1467
+ if (!(instance instanceof klass)) {
1468
+ throw new Error(`expected instance of ${klass.name}`);
1469
+ }
1470
+ }
1471
+
1472
+ function getArrayF64FromWasm0(ptr, len) {
1473
+ ptr = ptr >>> 0;
1474
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1475
+ }
1476
+
1477
+ function getArrayU8FromWasm0(ptr, len) {
1478
+ ptr = ptr >>> 0;
1479
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1480
+ }
1481
+
1482
+ let cachedDataViewMemory0 = null;
1483
+ function getDataViewMemory0() {
1484
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1485
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1486
+ }
1487
+ return cachedDataViewMemory0;
1488
+ }
1489
+
1490
+ let cachedFloat64ArrayMemory0 = null;
1491
+ function getFloat64ArrayMemory0() {
1492
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1493
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1494
+ }
1495
+ return cachedFloat64ArrayMemory0;
1496
+ }
1497
+
1498
+ function getStringFromWasm0(ptr, len) {
1499
+ return decodeText(ptr >>> 0, len);
1500
+ }
1501
+
1502
+ let cachedUint8ArrayMemory0 = null;
1503
+ function getUint8ArrayMemory0() {
1504
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1505
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1506
+ }
1507
+ return cachedUint8ArrayMemory0;
1508
+ }
1509
+
1510
+ function handleError(f, args) {
1511
+ try {
1512
+ return f.apply(this, args);
1513
+ } catch (e) {
1514
+ const idx = addToExternrefTable0(e);
1515
+ wasm.__wbindgen_exn_store(idx);
1516
+ }
1517
+ }
1518
+
1519
+ function isLikeNone(x) {
1520
+ return x === undefined || x === null;
1521
+ }
1522
+
1523
+ function passArray8ToWasm0(arg, malloc) {
1524
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1525
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1526
+ WASM_VECTOR_LEN = arg.length;
1527
+ return ptr;
1528
+ }
1529
+
1530
+ function passArrayF64ToWasm0(arg, malloc) {
1531
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1532
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1533
+ WASM_VECTOR_LEN = arg.length;
1534
+ return ptr;
1535
+ }
1536
+
1537
+ function passArrayJsValueToWasm0(array, malloc) {
1538
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1539
+ for (let i = 0; i < array.length; i++) {
1540
+ const add = addToExternrefTable0(array[i]);
1541
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1542
+ }
1543
+ WASM_VECTOR_LEN = array.length;
1544
+ return ptr;
1545
+ }
1546
+
1547
+ function passStringToWasm0(arg, malloc, realloc) {
1548
+ if (realloc === undefined) {
1549
+ const buf = cachedTextEncoder.encode(arg);
1550
+ const ptr = malloc(buf.length, 1) >>> 0;
1551
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1552
+ WASM_VECTOR_LEN = buf.length;
1553
+ return ptr;
1554
+ }
1555
+
1556
+ let len = arg.length;
1557
+ let ptr = malloc(len, 1) >>> 0;
1558
+
1559
+ const mem = getUint8ArrayMemory0();
1560
+
1561
+ let offset = 0;
1562
+
1563
+ for (; offset < len; offset++) {
1564
+ const code = arg.charCodeAt(offset);
1565
+ if (code > 0x7F) break;
1566
+ mem[ptr + offset] = code;
1567
+ }
1568
+ if (offset !== len) {
1569
+ if (offset !== 0) {
1570
+ arg = arg.slice(offset);
1571
+ }
1572
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1573
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1574
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1575
+
1576
+ offset += ret.written;
1577
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1578
+ }
1579
+
1580
+ WASM_VECTOR_LEN = offset;
1581
+ return ptr;
1582
+ }
1583
+
1584
+ let __wbg_reinit_scheduled = false;
1585
+
1586
+ function takeFromExternrefTable0(idx) {
1587
+ const value = wasm.__wbindgen_externrefs.get(idx);
1588
+ wasm.__externref_table_dealloc(idx);
1589
+ return value;
1590
+ }
1591
+
1592
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1593
+ cachedTextDecoder.decode();
1594
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1595
+ let numBytesDecoded = 0;
1596
+ function decodeText(ptr, len) {
1597
+ numBytesDecoded += len;
1598
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1599
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1600
+ cachedTextDecoder.decode();
1601
+ numBytesDecoded = len;
1602
+ }
1603
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1604
+ }
1605
+
1606
+ const cachedTextEncoder = new TextEncoder();
1607
+
1608
+ if (!('encodeInto' in cachedTextEncoder)) {
1609
+ cachedTextEncoder.encodeInto = function (arg, view) {
1610
+ const buf = cachedTextEncoder.encode(arg);
1611
+ view.set(buf);
1612
+ return {
1613
+ read: arg.length,
1614
+ written: buf.length
1615
+ };
1616
+ };
1617
+ }
1618
+
1619
+ let WASM_VECTOR_LEN = 0;
1620
+
1621
+ let wasmModule, wasmInstance, wasm;
1622
+ function __wbg_finalize_init(instance, module) {
1623
+ wasmInstance = instance;
1624
+ wasm = instance.exports;
1625
+ wasmModule = module;
1626
+ cachedDataViewMemory0 = null;
1627
+ cachedFloat64ArrayMemory0 = null;
1628
+ cachedUint8ArrayMemory0 = null;
1629
+ wasm.__wbindgen_start();
1630
+ return wasm;
1631
+ }
1632
+
1633
+ async function __wbg_load(module, imports) {
1634
+ if (typeof Response === 'function' && module instanceof Response) {
1635
+ if (!module.ok) {
1636
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1637
+ }
1638
+
1639
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1640
+ try {
1641
+ return await WebAssembly.instantiateStreaming(module, imports);
1642
+ } catch (e) {
1643
+ const validResponse = expectedResponseType(module.type);
1644
+
1645
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1646
+ 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);
1647
+
1648
+ } else { throw e; }
1649
+ }
1650
+ }
1651
+
1652
+ const bytes = await module.arrayBuffer();
1653
+ return await WebAssembly.instantiate(bytes, imports);
1654
+ } else {
1655
+ const instance = await WebAssembly.instantiate(module, imports);
1656
+
1657
+ if (instance instanceof WebAssembly.Instance) {
1658
+ return { instance, module };
1659
+ } else {
1660
+ return instance;
1661
+ }
1662
+ }
1663
+
1664
+ function expectedResponseType(type) {
1665
+ switch (type) {
1666
+ case 'basic': case 'cors': case 'default': return true;
1667
+ }
1668
+ return false;
1669
+ }
1670
+ }
1671
+
1672
+ function initSync(module) {
1673
+ if (wasm !== undefined) return wasm;
1674
+
1675
+
1676
+ if (module !== undefined) {
1677
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1678
+ ({module} = module)
1679
+ } else {
1680
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1681
+ }
1682
+ }
1683
+
1684
+ const imports = __wbg_get_imports();
1685
+ if (!(module instanceof WebAssembly.Module)) {
1686
+ module = new WebAssembly.Module(module);
1687
+ }
1688
+ const instance = new WebAssembly.Instance(module, imports);
1689
+ return __wbg_finalize_init(instance, module);
1690
+ }
1691
+
1692
+ async function __wbg_init(module_or_path) {
1693
+ if (wasm !== undefined) return wasm;
1694
+
1695
+
1696
+ if (module_or_path !== undefined) {
1697
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1698
+ ({module_or_path} = module_or_path)
1699
+ } else {
1700
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1701
+ }
1702
+ }
1703
+
1704
+ if (module_or_path === undefined) {
1705
+ module_or_path = new URL('lamina_pdf_base.wasm', import.meta.url);
1706
+ }
1707
+ const imports = __wbg_get_imports();
1708
+
1709
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1710
+ module_or_path = fetch(module_or_path);
1711
+ }
1712
+
1713
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1714
+
1715
+ return __wbg_finalize_init(instance, module);
1716
+ }
1717
+
1718
+ export { initSync, __wbg_init as default };