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