@laminapdf/wasm 0.2.0-alpha.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,16 +44,122 @@ export type PageLinkJs = {
44
44
  } & LinkToJs;
45
45
 
46
46
 
47
+ /**
48
+ * A change a signature's restriction forbids.
49
+ */
50
+ export interface ViolationJs {
51
+ /**
52
+ * The kind of change.
53
+ */
54
+ class: ModificationClass;
55
+ /**
56
+ * `docMdp`, `fieldMdp`, `usageRights`, `signedBytes` or `signedWidget`.
57
+ */
58
+ restriction: string;
59
+ /**
60
+ * The certification's `/P` (1, 2 or 3), for a `docMdp` restriction.
61
+ */
62
+ permission?: number;
63
+ /**
64
+ * The signature that carries the restriction.
65
+ */
66
+ signature: SignatureJs;
67
+ /**
68
+ * The form field whose widget a page edit deletes or reshows (its ID), for a
69
+ * `signedWidget` restriction or a `fieldMdp` one that a page edit breaks.
70
+ */
71
+ field?: string;
72
+ }
73
+
47
74
  /**
48
75
  * A colour for text options (the text module's records).
49
76
  */
50
77
  export type ColorInit = number[] | string;
51
78
 
79
+ /**
80
+ * A conformance claim the document's metadata no longer meets.
81
+ *
82
+ * Added in 0.2.0.
83
+ */
84
+ export type ConformanceWarning = { code: "pdfa-one-author"; authors: number } | { code: "pdfua-title-missing" } | { code: "pdfa-info-mismatch"; keys: MetadataKey[] };
85
+
52
86
  /**
53
87
  * A conformance profile.
54
88
  */
55
89
  export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
56
90
 
91
+ /**
92
+ * A document's metadata as one record, read from the Info dictionary and the XMP packet.
93
+ *
94
+ * When the two disagree, the values come from the XMP packet in a PDF 2.0 file (ISO 32000-2
95
+ * §14.3.3 deprecates the Info entries) or a file that claims PDF/A (whose packet is
96
+ * authoritative, ISO 19005-2 §6.6.2.3.1), and otherwise from the side whose modification date
97
+ * is newer, Info winning a tie. A field the winning side lacks is taken from the other.
98
+ * [`disagreements`](DocumentMetadata::disagreements) names the fields where the two differ, so
99
+ * a properties view can say so.
100
+ *
101
+ * Added in 0.2.0.
102
+ */
103
+ export interface DocumentMetadata {
104
+ /**
105
+ * The title.
106
+ */
107
+ title?: string;
108
+ /**
109
+ * The authors, in order (Info's `/Author` split at `;`).
110
+ */
111
+ authors: string[];
112
+ /**
113
+ * The subject.
114
+ */
115
+ subject?: string;
116
+ /**
117
+ * The keywords.
118
+ */
119
+ keywords?: string;
120
+ /**
121
+ * The application the content came from.
122
+ */
123
+ creator?: string;
124
+ /**
125
+ * The application that wrote the PDF.
126
+ */
127
+ producer?: string;
128
+ /**
129
+ * The creation date (a PDF date string on the wire).
130
+ */
131
+ created?: string;
132
+ /**
133
+ * The modification date.
134
+ */
135
+ modified?: string;
136
+ /**
137
+ * Which side the values come from.
138
+ */
139
+ source: MetadataSource;
140
+ /**
141
+ * The fields where Info and XMP hold different values.
142
+ */
143
+ disagreements: MetadataKey[];
144
+ /**
145
+ * What `/Metadata` holds.
146
+ */
147
+ packet: PacketStatus;
148
+ /**
149
+ * The PDF/A part and conformance the packet claims (`pdfaid:`), e.g. `"2B"`.
150
+ */
151
+ pdfa?: string;
152
+ /**
153
+ * The PDF/UA part the packet claims (`pdfuaid:part`).
154
+ */
155
+ pdfua?: number;
156
+ /**
157
+ * In a PDF 2.0 file, the Info entries besides the two dates: deprecated, kept as they
158
+ * were for older readers, and never written by an edit.
159
+ */
160
+ keptInfoKeys: MetadataKey[];
161
+ }
162
+
57
163
  /**
58
164
  * A document's properties, for a properties view.
59
165
  */
@@ -231,12 +337,33 @@ export interface TextLinkInit {
231
337
  * ```
232
338
  *
233
339
  * [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
340
+ *
341
+ * Added in 0.2.0.
234
342
  */
235
343
  export interface OpLog {
236
344
  v: 1;
237
345
  ops: Op[];
238
346
  }
239
347
 
348
+ /**
349
+ * A metadata field Lamina PDF keeps in step in the Info dictionary and the XMP packet: what
350
+ * [`RemoveMetadata`] removes and [`DocumentMetadata::disagreements`] names.
351
+ *
352
+ * | Key | Info | XMP |
353
+ * | --- | --- | --- |
354
+ * | `title` | `/Title` | `dc:title` |
355
+ * | `authors` | `/Author` (joined with `; `) | `dc:creator` |
356
+ * | `subject` | `/Subject` | `dc:description` |
357
+ * | `keywords` | `/Keywords` | `pdf:Keywords` |
358
+ * | `creator` | `/Creator` | `xmp:CreatorTool` |
359
+ * | `producer` | `/Producer` | `pdf:Producer` |
360
+ * | `created` | `/CreationDate` | `xmp:CreateDate` |
361
+ * | `modified` | `/ModDate` | `xmp:ModifyDate` |
362
+ *
363
+ * Added in 0.2.0.
364
+ */
365
+ export type MetadataKey = "title" | "authors" | "subject" | "keywords" | "creator" | "producer" | "created" | "modified";
366
+
240
367
  /**
241
368
  * A model result the job waits for.
242
369
  */
@@ -327,6 +454,24 @@ export interface RectJs {
327
454
  */
328
455
  export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
329
456
 
457
+ /**
458
+ * A signature the planner found.
459
+ */
460
+ export interface SignatureJs {
461
+ /**
462
+ * `approval`, `certification`, `docTimeStamp` or `usageRights`.
463
+ */
464
+ kind: string;
465
+ /**
466
+ * The signature field's ID, when a field holds it.
467
+ */
468
+ field?: string;
469
+ /**
470
+ * The 1-based revision the signature closes, when known.
471
+ */
472
+ revision?: number;
473
+ }
474
+
330
475
  /**
331
476
  * A step's progress, and the model result the job waits for, if any.
332
477
  */
@@ -410,8 +555,10 @@ export interface AttachmentInit {
410
555
  * ```
411
556
  *
412
557
  * [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
558
+ *
559
+ * Added in 0.2.0.
413
560
  */
414
- export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage };
561
+ export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage } | { op: "setMetadata"; args: SetMetadata } | { op: "removeMetadata"; args: RemoveMetadata };
415
562
 
416
563
  /**
417
564
  * Changes to the Info dictionary's text entries. For each field, `None` leaves the entry
@@ -420,6 +567,8 @@ export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: Ro
420
567
  *
421
568
  * On the wire an absent field is left alone and `null` clears: `{ "title": "Report",
422
569
  * "author": null }`.
570
+ *
571
+ * Added in 0.2.0.
423
572
  */
424
573
  export interface InfoPatch {
425
574
  /**
@@ -448,13 +597,75 @@ export interface InfoPatch {
448
597
  producer?: string | null;
449
598
  }
450
599
 
600
+ /**
601
+ * Changes to the document's metadata. For each field, `None` leaves it alone, `Some(None)`
602
+ * removes it and `Some(Some(value))` sets it, in Info and XMP alike.
603
+ *
604
+ * On the wire an absent field is left alone and `null` removes: `{ "title": "Report",
605
+ * "authors": ["Ada Lovelace", "Charles Babbage"], "keywords": null }`; dates are PDF date
606
+ * strings (`"D:20261110093000+01'00'"`).
607
+ *
608
+ * ```
609
+ * use laminapdf_ops::MetadataPatch;
610
+ *
611
+ * let patch = MetadataPatch::new().title(Some("Quarterly figures")).authors(&["Ada Lovelace", "Charles Babbage"]);
612
+ * assert_eq!(patch.authors, Some(Some(vec!["Ada Lovelace".to_owned(), "Charles Babbage".to_owned()])));
613
+ * assert_eq!(serde_json::to_string(&patch)?, r#"{"title":"Quarterly figures","authors":["Ada Lovelace","Charles Babbage"]}"#);
614
+ * # Ok::<(), serde_json::Error>(())
615
+ * ```
616
+ *
617
+ * Added in 0.2.0.
618
+ */
619
+ export interface MetadataPatch {
620
+ /**
621
+ * `/Title`, `dc:title`.
622
+ */
623
+ title?: string | null;
624
+ /**
625
+ * `/Author` (joined with `; `), `dc:creator` (in order). An empty list removes them.
626
+ */
627
+ authors?: string[] | null;
628
+ /**
629
+ * `/Subject`, `dc:description`.
630
+ */
631
+ subject?: string | null;
632
+ /**
633
+ * `/Keywords`, `pdf:Keywords`.
634
+ */
635
+ keywords?: string | null;
636
+ /**
637
+ * `/Creator`, `xmp:CreatorTool`: the application the content came from.
638
+ */
639
+ creator?: string | null;
640
+ /**
641
+ * `/Producer`, `pdf:Producer`: the application that wrote the PDF.
642
+ */
643
+ producer?: string | null;
644
+ /**
645
+ * `/CreationDate`, `xmp:CreateDate`.
646
+ */
647
+ created?: string | null;
648
+ /**
649
+ * `/ModDate`, `xmp:ModifyDate`.
650
+ */
651
+ modified?: string | null;
652
+ }
653
+
451
654
  /**
452
655
  * Edits the Info dictionary: applies `patch` and, when `at` is given, sets `/ModDate` to it.
656
+ *
657
+ * **Deprecated:** use [`SetMetadata`](crate::SetMetadata), which writes authors as a list and
658
+ * the dates, and edits files whose metadata is in XMP alone. `SetInfo` stays, with its v1 wire
659
+ * form (`setInfo`) and meaning, so op logs already written still apply (ADR 0006 §6). It now
660
+ * goes through the same writer, so a document's XMP packet, when it has one, changes with it.
661
+ * It adds a packet only to a PDF 2.0 file, where the fields other than the dates belong in XMP.
453
662
  * The date is part of the op, never read from a clock, so the same op gives the same bytes
454
663
  * everywhere (ADR 0006 §1).
455
664
  *
456
665
  * An Info dictionary written directly in the trailer, or missing, becomes a new indirect
457
666
  * object that the trailer's `/Info` points to (the first time the op changes something).
667
+ *
668
+ * Added in 0.2.0.
458
669
  */
459
670
  export interface SetInfo {
460
671
  /**
@@ -467,6 +678,53 @@ export interface SetInfo {
467
678
  at?: string;
468
679
  }
469
680
 
681
+ /**
682
+ * Edits the document's metadata: applies `patch` to the Info dictionary and the XMP packet
683
+ * together and, when `at` is given, records it as the modification date (`/ModDate`,
684
+ * `xmp:ModifyDate`) and as `xmp:MetadataDate`, unless the patch sets the modification date
685
+ * itself. The date is part of the op, never read from a clock (ADR 0006 §1).
686
+ *
687
+ * ```
688
+ * use laminapdf_ops::{MetadataPatch, Op, SetMetadata};
689
+ *
690
+ * let op = Op::from(SetMetadata::new(MetadataPatch::new().title(Some("Minutes")), Some("D:20261110093000Z".parse()?)));
691
+ * assert_eq!(
692
+ * serde_json::to_string(&op)?,
693
+ * r#"{"op":"setMetadata","args":{"patch":{"title":"Minutes"},"at":"D:20261110093000Z"}}"#
694
+ * );
695
+ * # Ok::<(), Box<dyn std::error::Error>>(())
696
+ * ```
697
+ *
698
+ * Added in 0.2.0.
699
+ */
700
+ export interface SetMetadata {
701
+ /**
702
+ * The fields to set or remove.
703
+ */
704
+ patch?: MetadataPatch;
705
+ /**
706
+ * The modification date the edit writes.
707
+ */
708
+ at?: string;
709
+ /**
710
+ * Replace an XMP packet that can't be read with a new one, losing whatever it held.
711
+ * Without it, such a packet makes the op fail with `malformed-xmp`, so nothing is lost
712
+ * without the user saying so.
713
+ */
714
+ replaceMalformed?: boolean;
715
+ }
716
+
717
+ /**
718
+ * How `flow` reads its document.
719
+ */
720
+ export interface FlowOptionsInit {
721
+ /**
722
+ * The values a template's `$data`, `$each` and `$item` placeholders read; without it, the
723
+ * document is read as it is.
724
+ */
725
+ data?: unknown;
726
+ }
727
+
470
728
  /**
471
729
  * How `markdown` lays a document out.
472
730
  */
@@ -546,6 +804,65 @@ export interface TextOptionsInit {
546
804
  direction?: DirectionInit;
547
805
  }
548
806
 
807
+ /**
808
+ * How a save would go (`laminapdf::PlannedSave`).
809
+ */
810
+ export interface PlannedSaveJs {
811
+ /**
812
+ * The mode the save resolves to; absent when it would be refused.
813
+ */
814
+ mode?: SaveModeJs;
815
+ /**
816
+ * The code the save would be refused with.
817
+ */
818
+ refusal?: string;
819
+ /**
820
+ * `free`, `appendOnly`, `requiresRewrite` or `conflict`.
821
+ */
822
+ constraint: string;
823
+ /**
824
+ * Every signature, in the order found.
825
+ */
826
+ signatures: SignatureJs[];
827
+ /**
828
+ * The certification's `/P` (1, 2 or 3), when the document is certified.
829
+ */
830
+ docMdp?: number;
831
+ /**
832
+ * Why only a full rewrite is safe: `repairedBase`, `encryptedBase`, `noBase`,
833
+ * `opRequiresRewrite`.
834
+ */
835
+ rewriteReasons: string[];
836
+ /**
837
+ * The pending changes a signature's restriction forbids.
838
+ */
839
+ violations: ViolationJs[];
840
+ /**
841
+ * The signatures the save would invalidate (only with `invalidateSignatures`).
842
+ */
843
+ wouldInvalidate: SignatureJs[];
844
+ /**
845
+ * Whether the save writes an encrypted document as plaintext.
846
+ */
847
+ removesEncryption: boolean;
848
+ /**
849
+ * What the save does with the save-time metadata: `none`, `stamp` or `skipped`.
850
+ */
851
+ metadata: string;
852
+ /**
853
+ * Whether an edit to save rewrote the XMP packet whole.
854
+ */
855
+ packetRewritten: boolean;
856
+ /**
857
+ * The PDF/A and PDF/UA claims the edited metadata breaks (warnings that never block).
858
+ */
859
+ conformanceWarnings: Diagnostic[];
860
+ /**
861
+ * The document has no changes.
862
+ */
863
+ unchanged: boolean;
864
+ }
865
+
549
866
  /**
550
867
  * How a target shows its page, in page space; an unset coordinate is left out.
551
868
  */
@@ -1022,6 +1339,17 @@ export interface SaveOptionsInit {
1022
1339
  * The cross-reference form.
1023
1340
  */
1024
1341
  xref?: XrefJs;
1342
+ /**
1343
+ * When the save happens, as the app's clock reads it: a PDF date (`D:20261110093000Z`)
1344
+ * or an ISO 8601 date-time. A save that writes changes stamps it as the modification and
1345
+ * metadata dates and gives the XMP packet a new instance ID.
1346
+ */
1347
+ metadataDate?: string;
1348
+ /**
1349
+ * The XMP instance ID the save writes, a UUID (`uuid:` optional); without it, one is
1350
+ * derived from the content.
1351
+ */
1352
+ instanceId?: string;
1025
1353
  }
1026
1354
 
1027
1355
  /**
@@ -1029,6 +1357,37 @@ export interface SaveOptionsInit {
1029
1357
  */
1030
1358
  export type DirectionInit = "ltr" | "rtl";
1031
1359
 
1360
+ /**
1361
+ * Removes metadata fields from the Info dictionary and the XMP packet; the packet's other
1362
+ * properties stay (J.10).
1363
+ *
1364
+ * The values stay in the file's earlier revisions until a full rewrite: an incremental save
1365
+ * appends the change and keeps the original bytes. When it removed anything, the op's result
1366
+ * says so ([`Applied::still_in_earlier_revisions`](crate::Applied::still_in_earlier_revisions)),
1367
+ * so the caller can offer a full rewrite (on a signed file, the override that removes the
1368
+ * signatures).
1369
+ *
1370
+ * ```
1371
+ * use laminapdf_ops::{MetadataKey, Op, RemoveMetadata};
1372
+ *
1373
+ * let op = Op::from(RemoveMetadata::new(vec![MetadataKey::Authors, MetadataKey::Creator]));
1374
+ * assert_eq!(serde_json::to_string(&op)?, r#"{"op":"removeMetadata","args":{"keys":["authors","creator"]}}"#);
1375
+ * # Ok::<(), serde_json::Error>(())
1376
+ * ```
1377
+ *
1378
+ * Added in 0.2.0.
1379
+ */
1380
+ export interface RemoveMetadata {
1381
+ /**
1382
+ * The fields to remove.
1383
+ */
1384
+ keys: MetadataKey[];
1385
+ /**
1386
+ * As [`SetMetadata::replace_malformed`].
1387
+ */
1388
+ replaceMalformed?: boolean;
1389
+ }
1390
+
1032
1391
  /**
1033
1392
  * Sets a page's rotation to `rotate` (absolute, not relative to the current value).
1034
1393
  *
@@ -1041,6 +1400,8 @@ export type DirectionInit = "ltr" | "rtl";
1041
1400
  * On the wire: `{ "op": "rotatePage", "args": { "page": "p12.0", "rotate": 90 } }`.
1042
1401
  *
1043
1402
  * [ADR 0005]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0005-document-model.md
1403
+ *
1404
+ * Added in 0.2.0.
1044
1405
  */
1045
1406
  export interface RotatePage {
1046
1407
  /**
@@ -1146,6 +1507,8 @@ export interface MetadataInit {
1146
1507
  * permissions and the document's `SaveConstraint` ([ADR 0007]).
1147
1508
  *
1148
1509
  * [ADR 0007]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0007-save-planner.md
1510
+ *
1511
+ * Added in 0.2.0.
1149
1512
  */
1150
1513
  export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
1151
1514
 
@@ -1205,6 +1568,15 @@ export interface EditedJs {
1205
1568
  * IDs of the pages whose content or attributes changed.
1206
1569
  */
1207
1570
  touchedPages: string[];
1571
+ /**
1572
+ * A metadata edit rewrote the XMP packet whole (UTF-16, or marked read-only).
1573
+ */
1574
+ packetRewritten: boolean;
1575
+ /**
1576
+ * A metadata edit removed values the file's earlier revisions still hold, which only a
1577
+ * full rewrite drops.
1578
+ */
1579
+ stillInEarlierRevisions: boolean;
1208
1580
  /**
1209
1581
  * Whether the edit changed the document: one that only set values they already had leaves
1210
1582
  * no step to undo.
@@ -1227,6 +1599,16 @@ export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
1227
1599
  */
1228
1600
  export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
1229
1601
 
1602
+ /**
1603
+ * What `flow` added.
1604
+ */
1605
+ export interface FlowReportJs {
1606
+ /**
1607
+ * The pages it added, in order, by ID.
1608
+ */
1609
+ pages: string[];
1610
+ }
1611
+
1230
1612
  /**
1231
1613
  * What `markdown` added.
1232
1614
  */
@@ -1350,6 +1732,24 @@ export interface SaveReportJs {
1350
1732
  * Whether encryption was removed.
1351
1733
  */
1352
1734
  encryptionRemoved: boolean;
1735
+ /**
1736
+ * Whether the save stamped the save-time metadata (`metadataDate`, `instanceId`).
1737
+ */
1738
+ metadataUpdated: boolean;
1739
+ /**
1740
+ * Whether the options asked for the stamp and the save left it out, because it would have
1741
+ * broken a signature's restriction the saved changes keep.
1742
+ */
1743
+ metadataNotUpdated: boolean;
1744
+ /**
1745
+ * Whether an edit saved here rewrote the XMP packet whole.
1746
+ */
1747
+ packetRewritten: boolean;
1748
+ /**
1749
+ * Whether the save emptied the undo history (a full rewrite, or an incremental save that
1750
+ * freed objects); for a copy, whether adopting it would.
1751
+ */
1752
+ historyCleared: boolean;
1353
1753
  }
1354
1754
 
1355
1755
  /**
@@ -1396,6 +1796,13 @@ export interface DropInit {
1396
1796
  */
1397
1797
  export type OverflowInit = "clip" | "error";
1398
1798
 
1799
+ /**
1800
+ * What the document's `/Metadata` holds.
1801
+ *
1802
+ * Added in 0.2.0.
1803
+ */
1804
+ export type PacketStatus = "absent" | "parsed" | "malformed";
1805
+
1399
1806
  /**
1400
1807
  * Where a link or outline item goes.
1401
1808
  */
@@ -1411,6 +1818,13 @@ export type SplitOnName = "headings" | "blocks" | "pages";
1411
1818
  */
1412
1819
  export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
1413
1820
 
1821
+ /**
1822
+ * Which side [`DocumentMetadata`]'s values come from.
1823
+ *
1824
+ * Added in 0.2.0.
1825
+ */
1826
+ export type MetadataSource = "info" | "xmp";
1827
+
1414
1828
  /**
1415
1829
  * Which table detectors run.
1416
1830
  */
@@ -1514,6 +1928,18 @@ export class WasmBuilder {
1514
1928
  * `invalid-page-labels`, `invalid-geometry`, `subset-failed`.
1515
1929
  */
1516
1930
  finish(): WasmDocument;
1931
+ /**
1932
+ * Lays `document` out as tagged pages that flow, after any pages already added, filled from
1933
+ * `options.data` first when it is given. The document's profiles are the builder's to set
1934
+ * (`profiles` in its options); its warnings are the finished document's.
1935
+ *
1936
+ * # Errors
1937
+ * `builder-finished`; `unknown-option`, `invalid-argument`; `invalid-document` with the JSON
1938
+ * Pointer at fault and the closest keys in `didYouMean`; `template-data-missing`,
1939
+ * `template-data-type`, `template-too-large`; `unknown-font` and `unknown-image` for a name
1940
+ * `resources` lacks; `missing-glyph`, `flow-content-too-large`.
1941
+ */
1942
+ flow(document: unknown, resources: WasmFlowResources, options: FlowOptionsInit | undefined): FlowReportJs;
1517
1943
  /**
1518
1944
  * Loads a font from its bytes (TrueType or OpenType/CFF) and registers it; it is
1519
1945
  * subset to the glyphs drawn.
@@ -1604,6 +2030,15 @@ export class WasmDocument {
1604
2030
  private constructor();
1605
2031
  free(): void;
1606
2032
  [Symbol.dispose](): void;
2033
+ /**
2034
+ * Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
2035
+ * them), once they are written where the document lives; `historyCleared` is the copy's
2036
+ * report's.
2037
+ *
2038
+ * # Errors
2039
+ * `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
2040
+ */
2041
+ adoptCopy(bytes: Uint8Array, historyCleared: boolean): void;
1607
2042
  /**
1608
2043
  * Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
1609
2044
  *
@@ -1660,6 +2095,14 @@ export class WasmDocument {
1660
2095
  * Reading errors.
1661
2096
  */
1662
2097
  isTagged(): boolean;
2098
+ /**
2099
+ * The document's metadata, read from Info and XMP together, with the fields where they
2100
+ * disagree.
2101
+ *
2102
+ * # Errors
2103
+ * Reading errors.
2104
+ */
2105
+ metadata(): DocumentMetadata;
1663
2106
  /**
1664
2107
  * The named destination `name`, or `undefined` when the document has none by that name or
1665
2108
  * it names no page here (the extract and text modules).
@@ -1735,6 +2178,13 @@ export class WasmDocument {
1735
2178
  * `page-index-out-of-range`; reading errors.
1736
2179
  */
1737
2180
  page(index: number): WasmPage;
2181
+ /**
2182
+ * How a save with `options` would go, without saving.
2183
+ *
2184
+ * # Errors
2185
+ * `invalid-argument` / `unknown-option` for bad options; reading errors.
2186
+ */
2187
+ plan(options: SaveOptionsInit | undefined): PlannedSaveJs;
1738
2188
  /**
1739
2189
  * The document's properties (the extract and text modules). Reads every object once.
1740
2190
  *
@@ -1757,6 +2207,14 @@ export class WasmDocument {
1757
2207
  * As [`WasmDocument::undo`].
1758
2208
  */
1759
2209
  redo(): RevertedJs | undefined;
2210
+ /**
2211
+ * Writes what `save` would and leaves the document as it was: not rebased, its changes
2212
+ * still unsaved, the save-time stamp in the copy only (Save a copy).
2213
+ *
2214
+ * # Errors
2215
+ * As `save`; the document is unchanged either way.
2216
+ */
2217
+ saveCopy(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
1760
2218
  /**
1761
2219
  * A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
1762
2220
  *
@@ -1791,6 +2249,13 @@ export class WasmDocument {
1791
2249
  * A cursor over the warnings so far (build warnings first), each as the §1 object.
1792
2250
  */
1793
2251
  warnings(): WasmWarningCursor;
2252
+ /**
2253
+ * The signature restrictions `op` would break if it were applied and saved.
2254
+ *
2255
+ * # Errors
2256
+ * `invalid-argument` for a value that isn't an op; reading errors.
2257
+ */
2258
+ wouldViolate(op: Op): ViolationJs[];
1794
2259
  }
1795
2260
 
1796
2261
  /**
@@ -1825,6 +2290,26 @@ export class WasmExtractJob {
1825
2290
  step(budget: number): ({ state: "progress" } & ExtractProgressJs) | { state: "done"; output: string };
1826
2291
  }
1827
2292
 
2293
+ /**
2294
+ * The fonts and images a document names, by the names it gives them.
2295
+ */
2296
+ export class WasmFlowResources {
2297
+ free(): void;
2298
+ [Symbol.dispose](): void;
2299
+ /**
2300
+ * `font` for the styles that name `name`; the same name again replaces it.
2301
+ */
2302
+ font(name: string, font: WasmFont): void;
2303
+ /**
2304
+ * `image` for the figures that name `name`; the same name again replaces it.
2305
+ */
2306
+ image(name: string, image: WasmImage): void;
2307
+ /**
2308
+ * No fonts and no images.
2309
+ */
2310
+ constructor();
2311
+ }
2312
+
1828
2313
  /**
1829
2314
  * A font registered with a [`WasmBuilder`].
1830
2315
  */
@@ -2243,6 +2728,7 @@ export interface InitOutput {
2243
2728
  readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
2244
2729
  readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
2245
2730
  readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
2731
+ readonly __wbg_wasmflowresources_free: (a: number, b: number) => void;
2246
2732
  readonly __wbg_wasmfont_free: (a: number, b: number) => void;
2247
2733
  readonly __wbg_wasmimage_free: (a: number, b: number) => void;
2248
2734
  readonly __wbg_wasmmarkdownoptions_free: (a: number, b: number) => void;
@@ -2257,6 +2743,7 @@ export interface InitOutput {
2257
2743
  readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
2258
2744
  readonly wasmbuilder_destination: (a: number, b: number, c: number, d: number, e: any) => [number, number];
2259
2745
  readonly wasmbuilder_finish: (a: number) => [number, number, number];
2746
+ readonly wasmbuilder_flow: (a: number, b: any, c: number, d: any) => [number, number, number];
2260
2747
  readonly wasmbuilder_fontBytes: (a: number, b: number, c: number) => [number, number, number];
2261
2748
  readonly wasmbuilder_fontCollection: (a: number, b: number, c: number, d: number) => [number, number, number];
2262
2749
  readonly wasmbuilder_lang: (a: number, b: number, c: number) => [number, number];
@@ -2268,6 +2755,7 @@ export interface InitOutput {
2268
2755
  readonly wasmbuilder_pageLabels: (a: number, b: any) => [number, number];
2269
2756
  readonly wasmbuilder_standardFont: (a: number, b: number, c: number) => [number, number, number];
2270
2757
  readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
2758
+ readonly wasmdocument_adoptCopy: (a: number, b: number, c: number, d: number) => [number, number];
2271
2759
  readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
2272
2760
  readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
2273
2761
  readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
@@ -2276,6 +2764,7 @@ export interface InitOutput {
2276
2764
  readonly wasmdocument_info: (a: number) => [number, number, number];
2277
2765
  readonly wasmdocument_isEncrypted: (a: number) => number;
2278
2766
  readonly wasmdocument_isTagged: (a: number) => [number, number, number];
2767
+ readonly wasmdocument_metadata: (a: number) => [number, number, number];
2279
2768
  readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
2280
2769
  readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
2281
2770
  readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
@@ -2286,17 +2775,23 @@ export interface InitOutput {
2286
2775
  readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
2287
2776
  readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
2288
2777
  readonly wasmdocument_pageLinks: (a: number, b: number) => [number, number, number];
2778
+ readonly wasmdocument_plan: (a: number, b: any) => [number, number, number];
2289
2779
  readonly wasmdocument_properties: (a: number) => [number, number, number];
2290
2780
  readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
2291
2781
  readonly wasmdocument_redo: (a: number) => [number, number, number];
2292
2782
  readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
2783
+ readonly wasmdocument_saveCopy: (a: number, b: any) => [number, number, number];
2293
2784
  readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
2294
2785
  readonly wasmdocument_structureTree: (a: number) => [number, number, number];
2295
2786
  readonly wasmdocument_undo: (a: number) => [number, number, number];
2296
2787
  readonly wasmdocument_warnings: (a: number) => number;
2788
+ readonly wasmdocument_wouldViolate: (a: number, b: any) => [number, number, number];
2297
2789
  readonly wasmextractjob_cancel: (a: number) => void;
2298
2790
  readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
2299
2791
  readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
2792
+ readonly wasmflowresources_font: (a: number, b: number, c: number, d: number) => void;
2793
+ readonly wasmflowresources_image: (a: number, b: number, c: number, d: number) => void;
2794
+ readonly wasmflowresources_new: () => number;
2300
2795
  readonly wasmfont_family: (a: number) => [number, number];
2301
2796
  readonly wasmfont_isStandard: (a: number) => number;
2302
2797
  readonly wasmfont_postscriptName: (a: number) => [number, number];