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

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,1580 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /** A page's text as `WasmPage.text` returns it (B9c). */
5
+ export interface PageTextJs {
6
+ /** The text by line, in content order (runs on one baseline, joined; trimmed). */
7
+ lines: string[];
8
+ /** The runs, in content order. */
9
+ runs: TextRunJs[];
10
+ /** Each glyph's quad in page space: 8 numbers per glyph (x0, y0 … x3, y3). */
11
+ quads: Float32Array;
12
+ /** Every glyph's text, concatenated. */
13
+ glyphText: string;
14
+ /** UTF-16 offsets into glyphText: glyph i is glyphText.slice(glyphOffsets[i], glyphOffsets[i + 1]). */
15
+ glyphOffsets: Uint32Array;
16
+ /** Glyphs whose Unicode is unknown (U+FFFD). */
17
+ unmapped: number;
18
+ }
19
+
20
+
21
+
22
+ /** An error or warning (ADR 0026 §1). Errors are thrown as this object. */
23
+ export interface Diagnostic {
24
+ code: string;
25
+ kind: "input" | "io" | "unsupported" | "limit" | "security" | "usage" | "state" | "cancelled" | "internal";
26
+ message: string;
27
+ hint?: string;
28
+ didYouMean?: string[];
29
+ location?: { offset?: number; object?: number; streamOffset?: number; pageIndex?: number; id?: string };
30
+ data?: Record<string, unknown>;
31
+ docsUrl: string;
32
+ }
33
+
34
+
35
+ /**
36
+ * A colour for text options (the text module's records).
37
+ */
38
+ export type ColorInit = number[] | string;
39
+
40
+ /**
41
+ * A conformance profile.
42
+ */
43
+ export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
44
+
45
+ /**
46
+ * A job's progress (`laminapdf::Step::Progress`).
47
+ */
48
+ export interface ProgressJs {
49
+ /**
50
+ * Work done so far (units of the phase).
51
+ */
52
+ done: number;
53
+ /**
54
+ * The total, when known.
55
+ */
56
+ total?: number;
57
+ /**
58
+ * The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`).
59
+ */
60
+ phase: string;
61
+ }
62
+
63
+ /**
64
+ * A link over drawn text.
65
+ */
66
+ export interface TextLinkInit {
67
+ /**
68
+ * Where it goes.
69
+ */
70
+ target: LinkTargetInit;
71
+ /**
72
+ * Alternate text.
73
+ */
74
+ contents?: string;
75
+ }
76
+
77
+ /**
78
+ * A list of ops with its schema version ([ADR 0006] §6): `{ "v": 1, "ops": [ … ] }`, used
79
+ * for saved op logs, batch processing and sync messages. Unknown fields are rejected, and so
80
+ * is a `v` this reader does not know; [`OpLog::from_json`] checks `v` before reading any op.
81
+ *
82
+ * ```
83
+ * use laminapdf_ops::OpLog;
84
+ *
85
+ * let log = OpLog::from_json(r#"{ "v": 1, "ops": [{ "op": "rotatePage", "args": { "page": "p3.0", "rotate": 180 } }] }"#)?;
86
+ * assert_eq!(log.ops().len(), 1);
87
+ * assert_eq!(OpLog::from_json(r#"{ "v": 2, "ops": [] }"#).map_err(|e| e.code()), Err("unsupported-version"));
88
+ * # Ok::<(), laminapdf_ops::Error>(())
89
+ * ```
90
+ *
91
+ * [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
92
+ */
93
+ export interface OpLog {
94
+ v: 1;
95
+ ops: Op[];
96
+ }
97
+
98
+ /**
99
+ * A page-label numbering style.
100
+ */
101
+ export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
102
+
103
+ /**
104
+ * A rectangle as returned to JavaScript.
105
+ */
106
+ export interface RectJs {
107
+ /**
108
+ * Left.
109
+ */
110
+ x: number;
111
+ /**
112
+ * Top.
113
+ */
114
+ y: number;
115
+ /**
116
+ * Width.
117
+ */
118
+ width: number;
119
+ /**
120
+ * Height.
121
+ */
122
+ height: number;
123
+ }
124
+
125
+ /**
126
+ * Alignment of a text box's lines.
127
+ */
128
+ export type AlignInit = "start" | "end" | "left" | "right" | "center";
129
+
130
+ /**
131
+ * An attached file's options.
132
+ */
133
+ export interface AttachmentInit {
134
+ /**
135
+ * How the file relates to the document (default `unspecified`).
136
+ */
137
+ relationship?: AfRelationshipInit;
138
+ /**
139
+ * `/Desc`, shown next to the file.
140
+ */
141
+ description?: string;
142
+ /**
143
+ * When the file last changed, a PDF date (default: the document's creation date).
144
+ */
145
+ modDate?: string;
146
+ }
147
+
148
+ /**
149
+ * An editing operation ([ADR 0006] §1): typed and semantic (it names things by
150
+ * [`LaminaPdfId`](laminapdf_model::LaminaPdfId), never by object reference), serialisable, and free
151
+ * of ambient inputs (a modification date is in the payload), so the same op on the same
152
+ * document gives the same result on every platform.
153
+ *
154
+ * Apply it inside a transaction ([`Tx::apply`](crate::Tx::apply)); its JSON form is
155
+ * adjacently tagged, `{ "op": "rotatePage", "args": { … } }`, and unknown ops and fields
156
+ * are rejected, never skipped.
157
+ *
158
+ * ```
159
+ * use laminapdf_ops::Op;
160
+ *
161
+ * let op: Op = serde_json::from_str(r#"{ "op": "rotatePage", "args": { "page": "p3.0", "rotate": 90 } }"#)?;
162
+ * assert_eq!(serde_json::to_string(&op)?, r#"{"op":"rotatePage","args":{"page":"p3.0","rotate":90}}"#);
163
+ * assert!(serde_json::from_str::<Op>(r#"{ "op": "explode", "args": {} }"#).is_err());
164
+ * # Ok::<(), serde_json::Error>(())
165
+ * ```
166
+ *
167
+ * [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
168
+ */
169
+ export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage };
170
+
171
+ /**
172
+ * Changes to the Info dictionary's text entries. For each field, `None` leaves the entry
173
+ * alone, `Some(None)` removes it and `Some(Some(text))` sets it (encoded as
174
+ * PDFDocEncoding when it can be, else UTF-16BE, §7.9.2.2).
175
+ *
176
+ * On the wire an absent field is left alone and `null` clears: `{ "title": "Report",
177
+ * "author": null }`.
178
+ */
179
+ export interface InfoPatch {
180
+ /**
181
+ * `/Title`.
182
+ */
183
+ title?: string | null;
184
+ /**
185
+ * `/Author`.
186
+ */
187
+ author?: string | null;
188
+ /**
189
+ * `/Subject`.
190
+ */
191
+ subject?: string | null;
192
+ /**
193
+ * `/Keywords`.
194
+ */
195
+ keywords?: string | null;
196
+ /**
197
+ * `/Creator`: the application that created the original document.
198
+ */
199
+ creator?: string | null;
200
+ /**
201
+ * `/Producer`: the application that converted it to PDF.
202
+ */
203
+ producer?: string | null;
204
+ }
205
+
206
+ /**
207
+ * Edits the Info dictionary: applies `patch` and, when `at` is given, sets `/ModDate` to it.
208
+ * The date is part of the op, never read from a clock, so the same op gives the same bytes
209
+ * everywhere (ADR 0006 §1).
210
+ *
211
+ * An Info dictionary written directly in the trailer, or missing, becomes a new indirect
212
+ * object that the trailer's `/Info` points to (the first time the op changes something).
213
+ */
214
+ export interface SetInfo {
215
+ /**
216
+ * The entries to set or clear.
217
+ */
218
+ patch?: InfoPatch;
219
+ /**
220
+ * The modification date to record as `/ModDate`.
221
+ */
222
+ at?: string;
223
+ }
224
+
225
+ /**
226
+ * How a destination shows its page (§12.3.2.2).
227
+ */
228
+ export type FitInit = { type: "page" } | { type: "width"; top?: number } | { type: "height"; left?: number } | { type: "xyz"; left?: number; top?: number; zoom?: number } | { type: "rect"; x: number; y: number; width: number; height: number } | { type: "bounds" };
229
+
230
+ /**
231
+ * How a run of text is drawn.
232
+ */
233
+ export interface TextOptionsInit {
234
+ /**
235
+ * The fill colour.
236
+ */
237
+ fill?: ColorInit;
238
+ /**
239
+ * The rendering mode.
240
+ */
241
+ renderMode?: RenderModeInit;
242
+ /**
243
+ * A link over the run.
244
+ */
245
+ link?: TextLinkInit;
246
+ /**
247
+ * OpenType features (`liga=0`, `smcp`).
248
+ */
249
+ features?: string[];
250
+ /**
251
+ * The language (BCP 47).
252
+ */
253
+ language?: string;
254
+ /**
255
+ * The paragraph direction (default: from the first strong character).
256
+ */
257
+ direction?: DirectionInit;
258
+ }
259
+
260
+ /**
261
+ * How a text box laid its text out.
262
+ */
263
+ export interface TextLayoutJs {
264
+ /**
265
+ * The lines drawn.
266
+ */
267
+ lines: LineBoxJs[];
268
+ /**
269
+ * Where the text that didn't fit starts (UTF-16 offset), if any.
270
+ */
271
+ overflow?: number;
272
+ }
273
+
274
+ /**
275
+ * How a viewer lays pages out.
276
+ */
277
+ export type PageLayoutInit = "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight";
278
+
279
+ /**
280
+ * How an attached file relates to the document (`/AFRelationship`).
281
+ */
282
+ export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement" | "unspecified";
283
+
284
+ /**
285
+ * How an undo or redo went (`laminapdf::UndoOutcome`).
286
+ */
287
+ export type UndoOutcomeJs = "applied" | "partial" | "skipped";
288
+
289
+ /**
290
+ * How viewers present the document when it opens.
291
+ */
292
+ export interface ViewerPreferencesInit {
293
+ /**
294
+ * Show the title, not the file name.
295
+ */
296
+ displayDocTitle?: boolean;
297
+ /**
298
+ * The panel shown.
299
+ */
300
+ pageMode?: PageModeInit;
301
+ /**
302
+ * The page layout.
303
+ */
304
+ pageLayout?: PageLayoutInit;
305
+ }
306
+
307
+ /**
308
+ * Object numbering in a full rewrite.
309
+ */
310
+ export type RenumberJs = "keep" | "compact";
311
+
312
+ /**
313
+ * One drawn line of a text box. Offsets are UTF-16 code units into the text (JS
314
+ * string indices).
315
+ */
316
+ export interface LineBoxJs {
317
+ /**
318
+ * Where the line's text starts.
319
+ */
320
+ start: number;
321
+ /**
322
+ * Where it ends (trailing spaces and the line break included).
323
+ */
324
+ end: number;
325
+ /**
326
+ * The end of what is drawn (without trailing spaces and the break).
327
+ */
328
+ contentEnd: number;
329
+ /**
330
+ * The line's box.
331
+ */
332
+ rect: RectJs;
333
+ /**
334
+ * Its baseline (y).
335
+ */
336
+ baseline: number;
337
+ }
338
+
339
+ /**
340
+ * One outline item and its children.
341
+ */
342
+ export interface OutlineEntryInit {
343
+ /**
344
+ * The title shown.
345
+ */
346
+ title: string;
347
+ /**
348
+ * Where it goes (none: a heading).
349
+ */
350
+ target?: LinkTargetInit;
351
+ /**
352
+ * Its children.
353
+ */
354
+ children?: OutlineEntryInit[];
355
+ /**
356
+ * Shown expanded.
357
+ */
358
+ open?: boolean;
359
+ /**
360
+ * The title's colour, RGB 0 to 1.
361
+ */
362
+ color?: [number, number, number];
363
+ /**
364
+ * Bold title.
365
+ */
366
+ bold?: boolean;
367
+ /**
368
+ * Italic title.
369
+ */
370
+ italic?: boolean;
371
+ }
372
+
373
+ /**
374
+ * One page's facts (`laminapdf::PageInfo`).
375
+ */
376
+ export interface PageInfoJs {
377
+ /**
378
+ * The 0-based index.
379
+ */
380
+ index: number;
381
+ /**
382
+ * The stable page ID (`p12.0`).
383
+ */
384
+ id: string;
385
+ /**
386
+ * Displayed width in points.
387
+ */
388
+ width: number;
389
+ /**
390
+ * Displayed height in points.
391
+ */
392
+ height: number;
393
+ /**
394
+ * `/Rotate` in degrees.
395
+ */
396
+ rotation: number;
397
+ /**
398
+ * The page label, when the document defines one (document text).
399
+ */
400
+ label?: string;
401
+ }
402
+
403
+ /**
404
+ * One page-label range, from page `start` (0-based) on.
405
+ */
406
+ export interface PageLabelInit {
407
+ /**
408
+ * The first page of the range.
409
+ */
410
+ start: number;
411
+ /**
412
+ * The numbering style (none: prefix only).
413
+ */
414
+ style?: LabelStyleInit;
415
+ /**
416
+ * A prefix.
417
+ */
418
+ prefix?: string;
419
+ /**
420
+ * The first number (default 1).
421
+ */
422
+ first?: number;
423
+ }
424
+
425
+ /**
426
+ * One text run (`laminapdf::extract::TextRun`): glyphs of one font, size, direction and marked
427
+ * content on one baseline, in logical order.
428
+ */
429
+ export interface TextRunJs {
430
+ /**
431
+ * The run's text in logical order (document text).
432
+ */
433
+ text: string;
434
+ /**
435
+ * The font's `/BaseFont` (document text).
436
+ */
437
+ font: string;
438
+ /**
439
+ * Font size in user-space units, the text matrix applied.
440
+ */
441
+ size: number;
442
+ /**
443
+ * Vertical writing.
444
+ */
445
+ vertical: boolean;
446
+ /**
447
+ * The marked-content ID the run is in, if any.
448
+ */
449
+ mcid?: number;
450
+ /**
451
+ * The text comes from an `/ActualText` span.
452
+ */
453
+ actualText: boolean;
454
+ /**
455
+ * Drawn invisibly (`Tr` 3 or 7).
456
+ */
457
+ invisible: boolean;
458
+ /**
459
+ * The bounds of the run's glyph quads, in page space (ADR 0027).
460
+ */
461
+ bounds: [number, number, number, number];
462
+ /**
463
+ * The run's glyphs: `[start, end)` into the page's glyph arrays.
464
+ */
465
+ glyphs: [number, number];
466
+ }
467
+
468
+ /**
469
+ * Options for `WasmDocument.openBytes`.
470
+ */
471
+ export interface OpenOptionsInit {
472
+ /**
473
+ * The user or owner password of an encrypted document.
474
+ */
475
+ password?: string;
476
+ /**
477
+ * Refuse files that need repair (`strict`).
478
+ */
479
+ strict?: boolean;
480
+ /**
481
+ * Resource limits (ADR 0003 §3); each one left out keeps its default.
482
+ */
483
+ limits?: LimitsInit;
484
+ }
485
+
486
+ /**
487
+ * Options for `WasmPage.text`.
488
+ */
489
+ export interface TextOptionsInit {
490
+ /**
491
+ * Leave out text drawn invisibly (rendering modes 3 and 7: OCR layers, hidden text).
492
+ */
493
+ skipInvisible?: boolean;
494
+ }
495
+
496
+ /**
497
+ * Options for `textBox`.
498
+ */
499
+ export interface TextBoxOptionsInit {
500
+ /**
501
+ * Line alignment.
502
+ */
503
+ align?: AlignInit;
504
+ /**
505
+ * Line height as a factor of the size (default 1.2).
506
+ */
507
+ lineHeight?: number;
508
+ /**
509
+ * Overflow handling.
510
+ */
511
+ overflow?: OverflowInit;
512
+ /**
513
+ * Paragraph direction.
514
+ */
515
+ direction?: DirectionInit;
516
+ /**
517
+ * The language (BCP 47).
518
+ */
519
+ language?: string;
520
+ /**
521
+ * OpenType features.
522
+ */
523
+ features?: string[];
524
+ }
525
+
526
+ /**
527
+ * Options for a new document: everything that would come from the environment is given,
528
+ * so the same calls give the same bytes.
529
+ */
530
+ export interface BuildOptionsInit {
531
+ /**
532
+ * The header version (default 1.7).
533
+ */
534
+ version?: PdfVersionInit;
535
+ /**
536
+ * The first `/ID` entry: 16 bytes as 32 hex digits (default: a content hash).
537
+ */
538
+ id?: string;
539
+ /**
540
+ * `/Producer`.
541
+ */
542
+ producer?: string;
543
+ /**
544
+ * `/CreationDate`, a PDF date (`D:20261030120000Z`).
545
+ */
546
+ creationDate?: string;
547
+ /**
548
+ * Flate-compress content streams (default `true`).
549
+ */
550
+ compress?: boolean;
551
+ /**
552
+ * A tagged document (structure tree, `/MarkInfo`) even before any element (default
553
+ * `false`; a page using `beginTag` or `beginArtifact` makes it tagged either way).
554
+ */
555
+ tagged?: boolean;
556
+ /**
557
+ * Conformance profiles: `PDF/UA-1` with at most one PDF/A profile. `finish` then fails
558
+ * with a coded error for each machine-checkable rule the document breaks.
559
+ */
560
+ profiles?: ProfileInit[];
561
+ }
562
+
563
+ /**
564
+ * Options for saving.
565
+ */
566
+ export interface SaveOptionsInit {
567
+ /**
568
+ * The mode (default `auto`).
569
+ */
570
+ mode?: SaveModeJs;
571
+ /**
572
+ * Save even when it invalidates signatures (removing them from the output).
573
+ */
574
+ invalidateSignatures?: boolean;
575
+ /**
576
+ * Write an encrypted document as a plaintext full rewrite.
577
+ */
578
+ removeEncryption?: boolean;
579
+ /**
580
+ * What an incremental save returns.
581
+ */
582
+ output?: OutputJs;
583
+ /**
584
+ * Numbering in a full rewrite.
585
+ */
586
+ renumber?: RenumberJs;
587
+ /**
588
+ * The cross-reference form.
589
+ */
590
+ xref?: XrefJs;
591
+ }
592
+
593
+ /**
594
+ * Paragraph direction.
595
+ */
596
+ export type DirectionInit = "ltr" | "rtl";
597
+
598
+ /**
599
+ * Sets a page's rotation to `rotate` (absolute, not relative to the current value).
600
+ *
601
+ * `/Rotate` is written on the page object itself, so a value inherited from a `/Pages`
602
+ * node is materialised on this page and its siblings keep theirs; an existing own entry
603
+ * keeps its position in the dictionary. The page object is changed, never replaced, so the
604
+ * page keeps its [`PageId`] and object number ([ADR 0005] §5). Nothing is written when the
605
+ * page already displays at `rotate` without an own entry.
606
+ *
607
+ * On the wire: `{ "op": "rotatePage", "args": { "page": "p12.0", "rotate": 90 } }`.
608
+ *
609
+ * [ADR 0005]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0005-document-model.md
610
+ */
611
+ export interface RotatePage {
612
+ /**
613
+ * The page.
614
+ */
615
+ page: string;
616
+ /**
617
+ * The rotation in degrees clockwise: 0, 90, 180 or 270.
618
+ */
619
+ rotate: 0 | 90 | 180 | 270;
620
+ }
621
+
622
+ /**
623
+ * Text rendering (`Tr`).
624
+ */
625
+ export type RenderModeInit = "fill" | "stroke" | "fillStroke" | "invisible";
626
+
627
+ /**
628
+ * The Info dictionary's text entries; absent ones are left out (document text).
629
+ */
630
+ export interface DocumentInfoJs {
631
+ /**
632
+ * `/Title`.
633
+ */
634
+ title?: string;
635
+ /**
636
+ * `/Author`.
637
+ */
638
+ author?: string;
639
+ /**
640
+ * `/Subject`.
641
+ */
642
+ subject?: string;
643
+ /**
644
+ * `/Keywords`.
645
+ */
646
+ keywords?: string;
647
+ /**
648
+ * `/Creator`.
649
+ */
650
+ creator?: string;
651
+ /**
652
+ * `/Producer`.
653
+ */
654
+ producer?: string;
655
+ }
656
+
657
+ /**
658
+ * The PDF version of a new document.
659
+ */
660
+ export type PdfVersionInit = "1.4" | "1.5" | "1.6" | "1.7" | "2.0";
661
+
662
+ /**
663
+ * The cross-reference form.
664
+ */
665
+ export type XrefJs = "stream" | "classic";
666
+
667
+ /**
668
+ * The document metadata (Info and XMP from the same values).
669
+ */
670
+ export interface MetadataInit {
671
+ /**
672
+ * Title.
673
+ */
674
+ title?: string;
675
+ /**
676
+ * Author.
677
+ */
678
+ author?: string;
679
+ /**
680
+ * Subject.
681
+ */
682
+ subject?: string;
683
+ /**
684
+ * Keywords.
685
+ */
686
+ keywords?: string;
687
+ /**
688
+ * Creator (the application that made the content).
689
+ */
690
+ creator?: string;
691
+ /**
692
+ * Producer.
693
+ */
694
+ producer?: string;
695
+ /**
696
+ * Creation date, a PDF date.
697
+ */
698
+ creationDate?: string;
699
+ /**
700
+ * Modification date, a PDF date.
701
+ */
702
+ modDate?: string;
703
+ }
704
+
705
+ /**
706
+ * The kind of change an op makes. The save planner checks it against `DocMDP` / `FieldMDP`
707
+ * permissions and the document's `SaveConstraint` ([ADR 0007]).
708
+ *
709
+ * [ADR 0007]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0007-save-planner.md
710
+ */
711
+ export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
712
+
713
+ /**
714
+ * The pages an edit touched.
715
+ */
716
+ export interface EditedJs {
717
+ /**
718
+ * IDs of the pages whose content or attributes changed.
719
+ */
720
+ touchedPages: string[];
721
+ }
722
+
723
+ /**
724
+ * The panel a viewer opens with.
725
+ */
726
+ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "optionalContent" | "attachments";
727
+
728
+ /**
729
+ * The save mode (ADR 0007 §3).
730
+ */
731
+ export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
732
+
733
+ /**
734
+ * What a run measures.
735
+ */
736
+ export interface TextRunJs {
737
+ /**
738
+ * The advance width of its widest line.
739
+ */
740
+ width: number;
741
+ /**
742
+ * Its box, page space.
743
+ */
744
+ bounds: RectJs;
745
+ /**
746
+ * Its lines (a run breaks only at line breaks in the text).
747
+ */
748
+ lines: number;
749
+ }
750
+
751
+ /**
752
+ * What a save wrote (`laminapdf::SaveReport`).
753
+ */
754
+ export interface SaveReportJs {
755
+ /**
756
+ * Bytes written.
757
+ */
758
+ bytesWritten: number;
759
+ /**
760
+ * The mode used (`incremental` or `fullRewrite`).
761
+ */
762
+ mode: SaveModeJs;
763
+ /**
764
+ * Old → new object numbers, when a full rewrite renumbered.
765
+ */
766
+ renumbered?: Record<string, number>;
767
+ /**
768
+ * Where the appended revision starts, for an incremental save.
769
+ */
770
+ appendOffset?: number;
771
+ /**
772
+ * How many signatures the save invalidated (with `invalidateSignatures`).
773
+ */
774
+ invalidatedSignatures: number;
775
+ /**
776
+ * Whether encryption was removed.
777
+ */
778
+ encryptionRemoved: boolean;
779
+ }
780
+
781
+ /**
782
+ * What an incremental save returns.
783
+ */
784
+ export type OutputJs = "whole" | "appendedOnly";
785
+
786
+ /**
787
+ * What happens to text that doesn't fit a text box.
788
+ */
789
+ export type OverflowInit = "clip" | "error";
790
+
791
+ /**
792
+ * Where a link or outline item goes.
793
+ */
794
+ export type LinkTargetInit = { type: "uri"; uri: string } | { type: "page"; index: number; fit?: FitInit } | { type: "named"; name: string };
795
+
796
+ /**
797
+ * `Limits` with every field optional (ADR 0003 §3; names as in Rust, camelCase).
798
+ */
799
+ export interface LimitsInit {
800
+ /**
801
+ *
802
+ */
803
+ maxNestingDepth?: number;
804
+ /**
805
+ *
806
+ */
807
+ maxStreamDecoded?: number;
808
+ /**
809
+ *
810
+ */
811
+ maxDecodedTotal?: number;
812
+ /**
813
+ *
814
+ */
815
+ maxFilterChain?: number;
816
+ /**
817
+ *
818
+ */
819
+ maxResolveDepth?: number;
820
+ /**
821
+ *
822
+ */
823
+ maxPageTreeDepth?: number;
824
+ /**
825
+ *
826
+ */
827
+ maxTreeDepth?: number;
828
+ /**
829
+ *
830
+ */
831
+ maxStringLength?: number;
832
+ /**
833
+ *
834
+ */
835
+ maxXrefSections?: number;
836
+ /**
837
+ *
838
+ */
839
+ maxObjectNumber?: number;
840
+ /**
841
+ *
842
+ */
843
+ maxWarnings?: number;
844
+ /**
845
+ *
846
+ */
847
+ maxContentOperators?: number;
848
+ /**
849
+ *
850
+ */
851
+ maxXobjectDepth?: number;
852
+ /**
853
+ *
854
+ */
855
+ maxImagePixels?: number;
856
+ /**
857
+ *
858
+ */
859
+ maxReadWindow?: number;
860
+ }
861
+
862
+
863
+ /**
864
+ * Builds a new document: pages, navigation and metadata, then [`WasmBuilder::finish`]
865
+ * gives a [`WasmDocument`] (unsaved; its save is a full rewrite).
866
+ */
867
+ export class WasmBuilder {
868
+ free(): void;
869
+ [Symbol.dispose](): void;
870
+ /**
871
+ * Attaches a file (`/EmbeddedFiles`, the catalog's `/AF`): `name`, its bytes and its MIME
872
+ * type. The same name again replaces the file.
873
+ *
874
+ * # Errors
875
+ * `builder-finished`; `invalid-argument` (a date that isn't a PDF date); `unknown-option`.
876
+ */
877
+ attach(name: string, bytes: Uint8Array, mime: string, options: AttachmentInit | undefined): void;
878
+ /**
879
+ * Defines the named destination `name`: page `index` shown as `fit` (default: the page).
880
+ *
881
+ * # Errors
882
+ * `builder-finished`; `invalid-argument` for a bad `fit`.
883
+ */
884
+ destination(name: string, index: number, fit: FitInit | undefined): void;
885
+ /**
886
+ * Writes the fonts, links, page tree, outline and metadata, and returns the document.
887
+ * The builder is finished afterwards, and so are its unfinished pages.
888
+ *
889
+ * # Errors
890
+ * `builder-finished`; `page-index-out-of-range`, `unknown-destination`,
891
+ * `invalid-page-labels`, `invalid-geometry`, `subset-failed`.
892
+ */
893
+ finish(): WasmDocument;
894
+ /**
895
+ * Loads a font from its bytes (TrueType or OpenType/CFF) and registers it; it is
896
+ * subset to the glyphs drawn.
897
+ *
898
+ * # Errors
899
+ * `builder-finished`; `invalid-font`, `font-not-embeddable`.
900
+ */
901
+ fontBytes(bytes: Uint8Array): WasmFont;
902
+ /**
903
+ * The natural language (`/Lang`), a BCP 47 tag.
904
+ *
905
+ * # Errors
906
+ * `builder-finished`.
907
+ */
908
+ lang(lang: string): void;
909
+ /**
910
+ * The metadata, written as the Info dictionary and an XMP packet.
911
+ *
912
+ * # Errors
913
+ * `builder-finished`; `invalid-argument` (a date that isn't a PDF date).
914
+ */
915
+ metadata(metadata: MetadataInit): void;
916
+ /**
917
+ * A builder for a new, empty document.
918
+ *
919
+ * # Errors
920
+ * `invalid-argument` / `unknown-option` for bad options.
921
+ */
922
+ constructor(options: BuildOptionsInit | undefined);
923
+ /**
924
+ * Adds outline items (with their children); returns their IDs in pre-order.
925
+ *
926
+ * # Errors
927
+ * `builder-finished`; `invalid-argument`; `limit-exceeded`.
928
+ */
929
+ outline(entries: OutlineEntryInit[]): string[];
930
+ /**
931
+ * The page labels, ranges by first page (checked at [`WasmBuilder::finish`]).
932
+ *
933
+ * # Errors
934
+ * `builder-finished`; `invalid-argument`.
935
+ */
936
+ pageLabels(ranges: PageLabelInit[]): void;
937
+ /**
938
+ * A page of `width` × `height` points, written by [`WasmPageBuilder::finish`].
939
+ */
940
+ page(width: number, height: number): WasmPageBuilder;
941
+ /**
942
+ * One of the standard 14 fonts, by its PostScript name (`Helvetica`,
943
+ * `Times-Roman`, …): not embedded, Latin only, no shaping.
944
+ *
945
+ * # Errors
946
+ * `builder-finished`; `invalid-argument` for another name.
947
+ */
948
+ standardFont(name: string): WasmFont;
949
+ /**
950
+ * How viewers present the document when it opens.
951
+ *
952
+ * # Errors
953
+ * `builder-finished`; `invalid-argument`.
954
+ */
955
+ viewerPreferences(prefs: ViewerPreferencesInit): void;
956
+ }
957
+
958
+ /**
959
+ * An open PDF: read it, edit it with ops (with undo), save it. The binding of
960
+ * `laminapdf::Document`, method for method (F12).
961
+ */
962
+ export class WasmDocument {
963
+ private constructor();
964
+ free(): void;
965
+ [Symbol.dispose](): void;
966
+ /**
967
+ * Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
968
+ *
969
+ * # Errors
970
+ * `invalid-op-log`, `unsupported-version`; as [`WasmDocument::apply`].
971
+ */
972
+ applyLog(json: string): EditedJs;
973
+ /**
974
+ * Applies `ops` (the op JSON of ADR 0006 §6) in order, as one transaction.
975
+ *
976
+ * # Errors
977
+ * `invalid-argument` / `unknown-option` for a value that isn't an op; the first op's
978
+ * error (nothing is applied).
979
+ */
980
+ apply(ops: Op[]): EditedJs;
981
+ /**
982
+ * Whether there are changes no save has written yet.
983
+ */
984
+ hasUnsavedChanges(): boolean;
985
+ /**
986
+ * The Info dictionary's text entries.
987
+ *
988
+ * # Errors
989
+ * Reading errors.
990
+ */
991
+ info(): DocumentInfoJs;
992
+ /**
993
+ * Opens a document from its bytes.
994
+ *
995
+ * # Errors
996
+ * The §1 object: `not-pdf`, `password-required`, `wrong-password`, `limit-exceeded`, …;
997
+ * `invalid-argument` / `unknown-option` for bad options.
998
+ */
999
+ static openBytes(bytes: Uint8Array, options: OpenOptionsInit | undefined): WasmDocument;
1000
+ /**
1001
+ * Opens a document over a sparse source whose bytes arrive later. Until the source holds
1002
+ * what a call needs, the call throws `data-pending` with `data.ranges` (`[offset, length]`
1003
+ * pairs): supply them and call again. Lazy reads on the document can do the same.
1004
+ *
1005
+ * # Errors
1006
+ * As `openBytes`, and `data-pending`.
1007
+ */
1008
+ static openSource(source: WasmSparseSource, options: OpenOptionsInit | undefined): WasmDocument;
1009
+ /**
1010
+ * A handle on the page with `id` (`p12.0`).
1011
+ *
1012
+ * # Errors
1013
+ * `invalid-argument` for a malformed ID; `unknown-page`.
1014
+ */
1015
+ pageById(id: string): WasmPage;
1016
+ /**
1017
+ * The number of pages.
1018
+ *
1019
+ * # Errors
1020
+ * Reading errors.
1021
+ */
1022
+ pageCount(): number;
1023
+ /**
1024
+ * Page `index`'s facts.
1025
+ *
1026
+ * # Errors
1027
+ * `page-index-out-of-range`; reading errors.
1028
+ */
1029
+ pageInfo(index: number): PageInfoJs;
1030
+ /**
1031
+ * Every page's facts, in order (one page-tree walk).
1032
+ *
1033
+ * # Errors
1034
+ * Reading errors.
1035
+ */
1036
+ pageInfos(): PageInfoJs[];
1037
+ /**
1038
+ * A handle on page `index` that follows the page by its ID (F2).
1039
+ *
1040
+ * # Errors
1041
+ * `page-index-out-of-range`; reading errors.
1042
+ */
1043
+ page(index: number): WasmPage;
1044
+ /**
1045
+ * Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
1046
+ *
1047
+ * # Errors
1048
+ * `no-pending-save`; reading errors in `bytes`.
1049
+ */
1050
+ rebase(bytes: Uint8Array): void;
1051
+ /**
1052
+ * Redoes the newest undone transaction; `undefined` when there is nothing to redo.
1053
+ *
1054
+ * # Errors
1055
+ * As [`WasmDocument::undo`].
1056
+ */
1057
+ redo(): UndoOutcomeJs | undefined;
1058
+ /**
1059
+ * A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
1060
+ *
1061
+ * # Errors
1062
+ * `invalid-argument` / `unknown-option` for bad options.
1063
+ */
1064
+ saveJob(options: SaveOptionsInit | undefined): WasmSaveJob;
1065
+ /**
1066
+ * Saves and rebases onto the output, running to completion: `{ bytes, report }`.
1067
+ *
1068
+ * # Errors
1069
+ * The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
1070
+ */
1071
+ save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
1072
+ /**
1073
+ * Undoes the newest transaction; `undefined` when there is nothing to undo.
1074
+ *
1075
+ * # Errors
1076
+ * `nested-transaction`, `saved-not-rebased`; reading errors.
1077
+ */
1078
+ undo(): UndoOutcomeJs | undefined;
1079
+ /**
1080
+ * A cursor over the warnings so far (build warnings first), each as the §1 object.
1081
+ */
1082
+ warnings(): WasmWarningCursor;
1083
+ }
1084
+
1085
+ /**
1086
+ * A font registered with a [`WasmBuilder`].
1087
+ */
1088
+ export class WasmFont {
1089
+ private constructor();
1090
+ free(): void;
1091
+ [Symbol.dispose](): void;
1092
+ /**
1093
+ * The family name.
1094
+ */
1095
+ readonly family: string;
1096
+ /**
1097
+ * Whether it is one of the standard 14 fonts (not embedded).
1098
+ */
1099
+ readonly isStandard: boolean;
1100
+ /**
1101
+ * The PostScript name.
1102
+ */
1103
+ readonly postscriptName: string;
1104
+ }
1105
+
1106
+ /**
1107
+ * An image to draw (decoded or passed through once, shared by every use).
1108
+ */
1109
+ export class WasmImage {
1110
+ private constructor();
1111
+ free(): void;
1112
+ [Symbol.dispose](): void;
1113
+ /**
1114
+ * A JPEG, passed through (`DCTDecode`).
1115
+ *
1116
+ * # Errors
1117
+ * `invalid-image`, `unsupported-image`.
1118
+ */
1119
+ static jpeg(bytes: Uint8Array): WasmImage;
1120
+ /**
1121
+ * A PNG (alpha as an `/SMask`).
1122
+ *
1123
+ * # Errors
1124
+ * `invalid-image`, `unsupported-image`, `image-too-large`.
1125
+ */
1126
+ static png(bytes: Uint8Array): WasmImage;
1127
+ /**
1128
+ * Raw 8-bit RGBA pixels, row by row.
1129
+ *
1130
+ * # Errors
1131
+ * `invalid-image` when the length isn't `width × height × 4`.
1132
+ */
1133
+ static rgba(width: number, height: number, rgba: Uint8Array): WasmImage;
1134
+ /**
1135
+ * Height in pixels.
1136
+ */
1137
+ readonly height: number;
1138
+ /**
1139
+ * Width in pixels.
1140
+ */
1141
+ readonly width: number;
1142
+ }
1143
+
1144
+ /**
1145
+ * A page of a [`WasmDocument`], held by its ID (F2): moving pages doesn't retarget it.
1146
+ */
1147
+ export class WasmPage {
1148
+ private constructor();
1149
+ free(): void;
1150
+ [Symbol.dispose](): void;
1151
+ /**
1152
+ * The page's current 0-based index.
1153
+ *
1154
+ * # Errors
1155
+ * `unknown-page` when the page is gone; reading errors.
1156
+ */
1157
+ index(): number;
1158
+ /**
1159
+ * The page's facts now.
1160
+ *
1161
+ * # Errors
1162
+ * As [`WasmPage::index`].
1163
+ */
1164
+ info(): PageInfoJs;
1165
+ /**
1166
+ * The page's text: lines, runs, glyph quads and glyph text (B9c; the extract and text
1167
+ * modules).
1168
+ *
1169
+ * # Errors
1170
+ * `unknown-page` when the page is gone; `data-pending` and the reading errors;
1171
+ * `unknown-option` / `invalid-argument` for bad options.
1172
+ */
1173
+ text(options: TextOptionsInit | undefined): PageTextJs;
1174
+ /**
1175
+ * The page's stable ID (`p12.0`).
1176
+ */
1177
+ readonly id: string;
1178
+ }
1179
+
1180
+ /**
1181
+ * One page being drawn, in page space (points from the top-left, y down; ADR 0027).
1182
+ * Invalid geometry is reported by [`WasmPageBuilder::finish`] (`invalid-geometry`).
1183
+ */
1184
+ export class WasmPageBuilder {
1185
+ private constructor();
1186
+ free(): void;
1187
+ [Symbol.dispose](): void;
1188
+ /**
1189
+ * Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
1190
+ * or `background`.
1191
+ *
1192
+ * # Errors
1193
+ * `invalid-argument` for another kind.
1194
+ */
1195
+ beginArtifact(kind: string): void;
1196
+ /**
1197
+ * Opens a structure element until the matching `endTag`: `kind` names a standard type
1198
+ * (`Document`, `Part`, `Sect`, `H1`–`H6`, `P`, `L`, `LI`, `Lbl`, `LBody`, `Table`, `TR`,
1199
+ * `TH`, `TD`, `Figure`, `Caption`, `Link`, `Span`, `Quote`, `Note`, `Code`), the role of
1200
+ * `custom` when given; `/Alt`, `/ActualText`, `/Lang`, `/E`; `scope` is `row`, `column` or
1201
+ * `both` when given.
1202
+ *
1203
+ * # Errors
1204
+ * `invalid-argument` for an unknown `kind` or `scope`.
1205
+ */
1206
+ beginTag(kind: string, custom?: string | null, alt?: string | null, actualText?: string | null, lang?: string | null, expansion?: string | null, scope?: string | null): void;
1207
+ /**
1208
+ * The blend mode, camelCase (`multiply`, `colorDodge`, …).
1209
+ *
1210
+ * # Errors
1211
+ * `invalid-argument` for an unknown mode.
1212
+ */
1213
+ blendMode(mode: string): void;
1214
+ /**
1215
+ * Clips to `path` (with `rule`) until the next `restore`.
1216
+ *
1217
+ * # Errors
1218
+ * As [`WasmPageBuilder::fill_path`].
1219
+ */
1220
+ clipPath(path: Float64Array, rule: string): void;
1221
+ /**
1222
+ * Ends the innermost open element or artifact (none open: nothing happens).
1223
+ *
1224
+ * # Errors
1225
+ * `builder-finished`.
1226
+ */
1227
+ endTag(): void;
1228
+ /**
1229
+ * The fill colour as `#rrggbb` or `#rgb` (`DeviceRGB`).
1230
+ *
1231
+ * # Errors
1232
+ * `invalid-color`.
1233
+ */
1234
+ fillColorHex(hex: string): void;
1235
+ /**
1236
+ * The colour fills use: 1 (gray), 3 (RGB) or 4 (CMYK) components, 0 to 1.
1237
+ *
1238
+ * # Errors
1239
+ * `invalid-argument` for another number of components.
1240
+ */
1241
+ fillColor(components: Float64Array): void;
1242
+ /**
1243
+ * Fills `path` (the flat path encoding) with `rule` (`nonZero` or `evenOdd`).
1244
+ *
1245
+ * # Errors
1246
+ * `invalid-argument` for a bad path or rule.
1247
+ */
1248
+ fillPath(path: Float64Array, rule: string): void;
1249
+ /**
1250
+ * Fills `path` with `rule`, then strokes it with the current stroke style.
1251
+ *
1252
+ * # Errors
1253
+ * As [`WasmPageBuilder::fill_path`].
1254
+ */
1255
+ fillStrokePath(path: Float64Array, rule: string): void;
1256
+ /**
1257
+ * Writes the page into its builder: content stream, resources and page dictionary.
1258
+ * Returns its page ID. The page is finished afterwards: every later call on it fails
1259
+ * with `builder-finished`.
1260
+ *
1261
+ * # Errors
1262
+ * `builder-finished` (the page or its builder already finished); `invalid-geometry` for
1263
+ * the first invalid value drawn; `unknown-font` for a font from another builder.
1264
+ */
1265
+ finish(): string;
1266
+ /**
1267
+ * Draws `image` scaled into the rectangle.
1268
+ *
1269
+ * # Errors
1270
+ * `builder-finished`.
1271
+ */
1272
+ image(image: WasmImage, x: number, y: number, width: number, height: number): void;
1273
+ /**
1274
+ * A link annotation over the rectangle, with `contents` as its alternate text.
1275
+ *
1276
+ * # Errors
1277
+ * `invalid-argument` / `unknown-option` for a bad target.
1278
+ */
1279
+ link(x: number, y: number, width: number, height: number, target: LinkTargetInit, contents?: string | null): void;
1280
+ /**
1281
+ * Fill and stroke opacity, 0 to 1 (an `ExtGState`).
1282
+ *
1283
+ * # Errors
1284
+ * `builder-finished`.
1285
+ */
1286
+ opacity(fill: number, stroke: number): void;
1287
+ /**
1288
+ * Restores the graphics state (`Q`); one without a matching save is ignored.
1289
+ *
1290
+ * # Errors
1291
+ * `builder-finished`.
1292
+ */
1293
+ restore(): void;
1294
+ /**
1295
+ * `/Rotate`: 0, 90, 180 or 270 degrees.
1296
+ *
1297
+ * # Errors
1298
+ * `invalid-argument` for another angle.
1299
+ */
1300
+ rotate(degrees: number): void;
1301
+ /**
1302
+ * Saves the graphics state (`q`).
1303
+ *
1304
+ * # Errors
1305
+ * `builder-finished` after [`WasmPageBuilder::finish`] (so does every drawing method).
1306
+ */
1307
+ save(): void;
1308
+ /**
1309
+ * `/CropBox`, `/BleedBox`, `/TrimBox` or `/ArtBox` (`kind`: `crop`, `bleed`, `trim`,
1310
+ * `art`), in the media box's page space.
1311
+ *
1312
+ * # Errors
1313
+ * `invalid-argument` for another kind.
1314
+ */
1315
+ setBox(kind: "crop" | "bleed" | "trim" | "art", x: number, y: number, width: number, height: number): void;
1316
+ /**
1317
+ * The stroke colour as `#rrggbb` or `#rgb`.
1318
+ *
1319
+ * # Errors
1320
+ * `invalid-color`.
1321
+ */
1322
+ strokeColorHex(hex: string): void;
1323
+ /**
1324
+ * The colour strokes use (as [`WasmPageBuilder::fill_color`]).
1325
+ *
1326
+ * # Errors
1327
+ * As [`WasmPageBuilder::fill_color`].
1328
+ */
1329
+ strokeColor(components: Float64Array): void;
1330
+ /**
1331
+ * Strokes `path` with the current stroke style.
1332
+ *
1333
+ * # Errors
1334
+ * `invalid-argument` for a bad path.
1335
+ */
1336
+ strokePath(path: Float64Array): void;
1337
+ /**
1338
+ * The style later strokes use: `width` (points), `cap` (`butt`, `round`, `square`),
1339
+ * `join` (`miter`, `round`, `bevel`), the miter limit and a dash pattern (empty: solid).
1340
+ *
1341
+ * # Errors
1342
+ * `invalid-argument` for an unknown cap or join.
1343
+ */
1344
+ strokeStyle(width: number, cap: string, join: string, miterLimit: number, dash: Float64Array, dashPhase: number): void;
1345
+ /**
1346
+ * Lays `text` out in `rect` (lines broken at Unicode line-break opportunities) and
1347
+ * draws it.
1348
+ *
1349
+ * # Errors
1350
+ * As [`WasmPageBuilder::text`]; `text-overflow` with `overflow: "error"`.
1351
+ */
1352
+ textBox(text: string, font: WasmFont, size: number, x: number, y: number, width: number, height: number, options: TextBoxOptionsInit | undefined): TextLayoutJs;
1353
+ /**
1354
+ * Draws `text` in `font` at `size` points with the baseline at `y` (ADR 0027 §5):
1355
+ * shaped, bidi-resolved, one line per line break.
1356
+ *
1357
+ * # Errors
1358
+ * `missing-glyph`, `font-not-shapable`, `invalid-feature`, `invalid-geometry`;
1359
+ * `invalid-argument` for bad options.
1360
+ */
1361
+ text(text: string, font: WasmFont, size: number, x: number, y: number, options: TextOptionsInit | undefined): TextRunJs;
1362
+ /**
1363
+ * Applies `[a, b, c, d, e, f]` (page space) to what is drawn next.
1364
+ *
1365
+ * # Errors
1366
+ * `invalid-argument` unless there are 6 numbers.
1367
+ */
1368
+ transform(m: Float64Array): void;
1369
+ /**
1370
+ * `/UserUnit`, for pages larger than 14,400 units.
1371
+ */
1372
+ userUnit(unit: number): void;
1373
+ }
1374
+
1375
+ /**
1376
+ * A save in progress (F10). Each `step` checks that the document is unchanged since the
1377
+ * job was created (`document-changed`).
1378
+ */
1379
+ export class WasmSaveJob {
1380
+ private constructor();
1381
+ free(): void;
1382
+ [Symbol.dispose](): void;
1383
+ /**
1384
+ * Stops the job: its next step fails with `cancelled`.
1385
+ */
1386
+ cancel(): void;
1387
+ /**
1388
+ * Runs at most `budget` work units: `{ state: "progress", done, total?, phase }` or
1389
+ * `{ state: "done", bytes, report }`.
1390
+ *
1391
+ * # Errors
1392
+ * `cancelled`, `document-changed`, `job-finished`, or the save's own errors.
1393
+ */
1394
+ step(budget: number): ({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
1395
+ }
1396
+
1397
+ /**
1398
+ * A PDF of known size whose bytes arrive later: give it to `WasmDocument.openSource`, and
1399
+ * after a `data-pending` error `supply` the ranges in its `data.ranges` and call again.
1400
+ */
1401
+ export class WasmSparseSource {
1402
+ free(): void;
1403
+ [Symbol.dispose](): void;
1404
+ /**
1405
+ * An empty source of `size` bytes holding at most `budget` bytes (no limit when omitted).
1406
+ *
1407
+ * # Errors
1408
+ * `invalid-argument` when a number isn't a whole number of bytes.
1409
+ */
1410
+ constructor(size: number, budget?: number | null);
1411
+ /**
1412
+ * Adds `bytes` at `offset` (bytes already held win over overlapping ones).
1413
+ *
1414
+ * # Errors
1415
+ * `invalid-argument` past the end; `source-budget-exceeded` over the budget.
1416
+ */
1417
+ supply(offset: number, bytes: Uint8Array): void;
1418
+ /**
1419
+ * What to fetch for the ranges a `data-pending` asked for (flat `[start, end, …]`): each
1420
+ * widened to blocks of `block` bytes (0: as asked) plus `readahead`, merged, minus what is
1421
+ * held, in the same flat form. The planning step of `laminapdf-source`'s `retry`, so every
1422
+ * loop plans the same way.
1423
+ *
1424
+ * # Errors
1425
+ * `invalid-argument` for an odd length or a value that isn't a whole number of bytes.
1426
+ */
1427
+ toFetch(asked: Float64Array, block: number, readahead: number): Float64Array;
1428
+ /**
1429
+ * The source's size in bytes.
1430
+ */
1431
+ readonly size: number;
1432
+ }
1433
+
1434
+ /**
1435
+ * The warnings of a document, read in batches (F8).
1436
+ */
1437
+ export class WasmWarningCursor {
1438
+ private constructor();
1439
+ free(): void;
1440
+ [Symbol.dispose](): void;
1441
+ /**
1442
+ * Up to `max` more warnings, each as the ADR 0026 §1 object; empty at the end.
1443
+ */
1444
+ nextBatch(max: number): Diagnostic[];
1445
+ /**
1446
+ * How many warnings are left.
1447
+ */
1448
+ remaining(): number;
1449
+ }
1450
+
1451
+ /**
1452
+ * Whether this module is the text module (fonts, `text`, `textBox`).
1453
+ */
1454
+ export function hasText(): boolean;
1455
+
1456
+ /**
1457
+ * The crate version (`@laminapdf/wasm`'s).
1458
+ */
1459
+ export function version(): string;
1460
+
1461
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1462
+
1463
+ export interface InitOutput {
1464
+ readonly memory: WebAssembly.Memory;
1465
+ readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
1466
+ readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
1467
+ readonly __wbg_wasmfont_free: (a: number, b: number) => void;
1468
+ readonly __wbg_wasmimage_free: (a: number, b: number) => void;
1469
+ readonly __wbg_wasmpage_free: (a: number, b: number) => void;
1470
+ readonly __wbg_wasmpagebuilder_free: (a: number, b: number) => void;
1471
+ readonly __wbg_wasmsavejob_free: (a: number, b: number) => void;
1472
+ readonly __wbg_wasmsparsesource_free: (a: number, b: number) => void;
1473
+ readonly __wbg_wasmwarningcursor_free: (a: number, b: number) => void;
1474
+ readonly hasText: () => number;
1475
+ readonly version: () => [number, number];
1476
+ readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
1477
+ readonly wasmbuilder_destination: (a: number, b: number, c: number, d: number, e: any) => [number, number];
1478
+ readonly wasmbuilder_finish: (a: number) => [number, number, number];
1479
+ readonly wasmbuilder_fontBytes: (a: number, b: number, c: number) => [number, number, number];
1480
+ readonly wasmbuilder_lang: (a: number, b: number, c: number) => [number, number];
1481
+ readonly wasmbuilder_metadata: (a: number, b: any) => [number, number];
1482
+ readonly wasmbuilder_new: (a: any) => [number, number, number];
1483
+ readonly wasmbuilder_outline: (a: number, b: any) => [number, number, number];
1484
+ readonly wasmbuilder_page: (a: number, b: number, c: number) => number;
1485
+ readonly wasmbuilder_pageLabels: (a: number, b: any) => [number, number];
1486
+ readonly wasmbuilder_standardFont: (a: number, b: number, c: number) => [number, number, number];
1487
+ readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
1488
+ readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
1489
+ readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
1490
+ readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
1491
+ readonly wasmdocument_info: (a: number) => [number, number, number];
1492
+ readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
1493
+ readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
1494
+ readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
1495
+ readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
1496
+ readonly wasmdocument_pageCount: (a: number) => [number, number, number];
1497
+ readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
1498
+ readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
1499
+ readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
1500
+ readonly wasmdocument_redo: (a: number) => [number, number, number];
1501
+ readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
1502
+ readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
1503
+ readonly wasmdocument_undo: (a: number) => [number, number, number];
1504
+ readonly wasmdocument_warnings: (a: number) => number;
1505
+ readonly wasmfont_family: (a: number) => [number, number];
1506
+ readonly wasmfont_isStandard: (a: number) => number;
1507
+ readonly wasmfont_postscriptName: (a: number) => [number, number];
1508
+ readonly wasmimage_height: (a: number) => number;
1509
+ readonly wasmimage_jpeg: (a: number, b: number) => [number, number, number];
1510
+ readonly wasmimage_png: (a: number, b: number) => [number, number, number];
1511
+ readonly wasmimage_rgba: (a: number, b: number, c: number, d: number) => [number, number, number];
1512
+ readonly wasmimage_width: (a: number) => number;
1513
+ readonly wasmpage_id: (a: number) => [number, number];
1514
+ readonly wasmpage_index: (a: number) => [number, number, number];
1515
+ readonly wasmpage_info: (a: number) => [number, number, number];
1516
+ readonly wasmpage_text: (a: number, b: any) => [number, number, number];
1517
+ readonly wasmpagebuilder_beginArtifact: (a: number, b: number, c: number) => [number, number];
1518
+ readonly wasmpagebuilder_beginTag: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => [number, number];
1519
+ readonly wasmpagebuilder_blendMode: (a: number, b: number, c: number) => [number, number];
1520
+ readonly wasmpagebuilder_clipPath: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1521
+ readonly wasmpagebuilder_endTag: (a: number) => [number, number];
1522
+ readonly wasmpagebuilder_fillColor: (a: number, b: number, c: number) => [number, number];
1523
+ readonly wasmpagebuilder_fillColorHex: (a: number, b: number, c: number) => [number, number];
1524
+ readonly wasmpagebuilder_fillPath: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1525
+ readonly wasmpagebuilder_fillStrokePath: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1526
+ readonly wasmpagebuilder_finish: (a: number) => [number, number, number, number];
1527
+ readonly wasmpagebuilder_image: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1528
+ readonly wasmpagebuilder_link: (a: number, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number];
1529
+ readonly wasmpagebuilder_opacity: (a: number, b: number, c: number) => [number, number];
1530
+ readonly wasmpagebuilder_restore: (a: number) => [number, number];
1531
+ readonly wasmpagebuilder_rotate: (a: number, b: number) => [number, number];
1532
+ readonly wasmpagebuilder_save: (a: number) => [number, number];
1533
+ readonly wasmpagebuilder_setBox: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1534
+ readonly wasmpagebuilder_strokeColor: (a: number, b: number, c: number) => [number, number];
1535
+ readonly wasmpagebuilder_strokeColorHex: (a: number, b: number, c: number) => [number, number];
1536
+ readonly wasmpagebuilder_strokePath: (a: number, b: number, c: number) => [number, number];
1537
+ readonly wasmpagebuilder_strokeStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
1538
+ readonly wasmpagebuilder_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
1539
+ readonly wasmpagebuilder_textBox: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any) => [number, number, number];
1540
+ readonly wasmpagebuilder_transform: (a: number, b: number, c: number) => [number, number];
1541
+ readonly wasmpagebuilder_userUnit: (a: number, b: number) => void;
1542
+ readonly wasmsavejob_cancel: (a: number) => void;
1543
+ readonly wasmsavejob_step: (a: number, b: number) => [number, number, number];
1544
+ readonly wasmsparsesource_new: (a: number, b: number, c: number) => [number, number, number];
1545
+ readonly wasmsparsesource_size: (a: number) => number;
1546
+ readonly wasmsparsesource_supply: (a: number, b: number, c: number, d: number) => [number, number];
1547
+ readonly wasmsparsesource_toFetch: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
1548
+ readonly wasmwarningcursor_nextBatch: (a: number, b: number) => any;
1549
+ readonly wasmwarningcursor_remaining: (a: number) => number;
1550
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
1551
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
1552
+ readonly __wbindgen_exn_store: (a: number) => void;
1553
+ readonly __externref_table_alloc: () => number;
1554
+ readonly __wbindgen_externrefs: WebAssembly.Table;
1555
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
1556
+ readonly __externref_table_dealloc: (a: number) => void;
1557
+ readonly __wbindgen_start: () => void;
1558
+ }
1559
+
1560
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1561
+
1562
+ /**
1563
+ * Instantiates the given `module`, which can either be bytes or
1564
+ * a precompiled `WebAssembly.Module`.
1565
+ *
1566
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1567
+ *
1568
+ * @returns {InitOutput}
1569
+ */
1570
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1571
+
1572
+ /**
1573
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1574
+ * for everything else, calls `WebAssembly.instantiate` directly.
1575
+ *
1576
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1577
+ *
1578
+ * @returns {Promise<InitOutput>}
1579
+ */
1580
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;