docxodus 9.9.0 → 11.0.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.
Files changed (124) hide show
  1. package/README.md +182 -4
  2. package/dist/canonical.d.ts +7 -0
  3. package/dist/canonical.d.ts.map +1 -0
  4. package/dist/canonical.js +56 -0
  5. package/dist/canonical.js.map +1 -0
  6. package/dist/docxodus.worker.d.ts +2 -1
  7. package/dist/docxodus.worker.d.ts.map +1 -1
  8. package/dist/docxodus.worker.js +250 -41
  9. package/dist/docxodus.worker.js.map +1 -1
  10. package/dist/editor.bundle.js +1980 -423
  11. package/dist/editor.d.ts +22 -2
  12. package/dist/editor.d.ts.map +1 -1
  13. package/dist/editor.js +94 -9
  14. package/dist/editor.js.map +1 -1
  15. package/dist/embed.bundle.js +2968 -597
  16. package/dist/embed.d.ts +1 -1
  17. package/dist/embed.iife.js +2969 -598
  18. package/dist/embed.js +1 -1
  19. package/dist/export-assets.json +277 -0
  20. package/dist/export-browser.bundle.js +7989 -0
  21. package/dist/export-browser.d.ts +266 -0
  22. package/dist/export-browser.d.ts.map +1 -0
  23. package/dist/export-browser.js +2915 -0
  24. package/dist/export-browser.js.map +1 -0
  25. package/dist/export-resource-limits-v1.json +57 -0
  26. package/dist/font-contract.d.ts +150 -0
  27. package/dist/font-contract.d.ts.map +1 -0
  28. package/dist/font-contract.js +59 -0
  29. package/dist/font-contract.js.map +1 -0
  30. package/dist/font-runtime.d.ts +33 -0
  31. package/dist/font-runtime.d.ts.map +1 -0
  32. package/dist/font-runtime.js +1100 -0
  33. package/dist/font-runtime.js.map +1 -0
  34. package/dist/index.d.ts +83 -65
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +194 -149
  37. package/dist/index.js.map +1 -1
  38. package/dist/page-geometry.d.ts +8 -1
  39. package/dist/page-geometry.d.ts.map +1 -1
  40. package/dist/page-geometry.js +37 -11
  41. package/dist/page-geometry.js.map +1 -1
  42. package/dist/pagination.bundle.js +1827 -410
  43. package/dist/pagination.d.ts +249 -15
  44. package/dist/pagination.d.ts.map +1 -1
  45. package/dist/pagination.js +1942 -453
  46. package/dist/pagination.js.map +1 -1
  47. package/dist/react.d.ts +13 -6
  48. package/dist/react.d.ts.map +1 -1
  49. package/dist/react.js +38 -5
  50. package/dist/react.js.map +1 -1
  51. package/dist/render-report-v2.schema.json +1581 -0
  52. package/dist/ribbon-chrome.d.ts +2 -2
  53. package/dist/ribbon-chrome.d.ts.map +1 -1
  54. package/dist/ribbon-chrome.js +72 -4
  55. package/dist/ribbon-chrome.js.map +1 -1
  56. package/dist/ribbon.js +119 -0
  57. package/dist/ribbon.js.map +1 -1
  58. package/dist/session.bundle.js +747 -29
  59. package/dist/session.d.ts +159 -19
  60. package/dist/session.d.ts.map +1 -1
  61. package/dist/session.js +593 -25
  62. package/dist/session.js.map +1 -1
  63. package/dist/types.d.ts +1287 -238
  64. package/dist/types.d.ts.map +1 -1
  65. package/dist/types.js +9 -75
  66. package/dist/types.js.map +1 -1
  67. package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm +0 -0
  68. package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm.br +0 -0
  69. package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm +0 -0
  70. package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm.br +0 -0
  71. package/dist/wasm/_framework/Docxodus.wasm +0 -0
  72. package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
  73. package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
  74. package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
  75. package/dist/wasm/_framework/System.Collections.Concurrent.wasm +0 -0
  76. package/dist/wasm/_framework/System.Collections.Concurrent.wasm.br +0 -0
  77. package/dist/wasm/_framework/System.Collections.Immutable.wasm +0 -0
  78. package/dist/wasm/_framework/System.Collections.Immutable.wasm.br +0 -0
  79. package/dist/wasm/_framework/System.Collections.wasm +0 -0
  80. package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
  81. package/dist/wasm/_framework/System.ComponentModel.Primitives.wasm +0 -0
  82. package/dist/wasm/_framework/System.ComponentModel.Primitives.wasm.br +0 -0
  83. package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
  84. package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
  85. package/dist/wasm/_framework/System.IO.Packaging.wasm +0 -0
  86. package/dist/wasm/_framework/System.IO.Packaging.wasm.br +0 -0
  87. package/dist/wasm/_framework/System.IO.Pipelines.wasm +0 -0
  88. package/dist/wasm/_framework/System.IO.Pipelines.wasm.br +0 -0
  89. package/dist/wasm/_framework/System.Linq.wasm +0 -0
  90. package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
  91. package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
  92. package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
  93. package/dist/wasm/_framework/System.Private.Uri.wasm +0 -0
  94. package/dist/wasm/_framework/System.Private.Uri.wasm.br +0 -0
  95. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
  96. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
  97. package/dist/wasm/_framework/System.Private.Xml.wasm +0 -0
  98. package/dist/wasm/_framework/System.Private.Xml.wasm.br +0 -0
  99. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  100. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm.br +0 -0
  101. package/dist/wasm/_framework/System.Runtime.wasm +0 -0
  102. package/dist/wasm/_framework/System.Runtime.wasm.br +0 -0
  103. package/dist/wasm/_framework/System.Security.Cryptography.wasm +0 -0
  104. package/dist/wasm/_framework/System.Security.Cryptography.wasm.br +0 -0
  105. package/dist/wasm/_framework/System.Text.Encodings.Web.wasm +0 -0
  106. package/dist/wasm/_framework/System.Text.Encodings.Web.wasm.br +0 -0
  107. package/dist/wasm/_framework/System.Text.Json.wasm +0 -0
  108. package/dist/wasm/_framework/System.Text.Json.wasm.br +0 -0
  109. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
  110. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
  111. package/dist/wasm/_framework/dotnet.boot.js +34 -40
  112. package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
  113. package/dist/wasm/_framework/dotnet.native.js +39 -3
  114. package/dist/wasm/_framework/dotnet.native.js.br +0 -0
  115. package/dist/wasm/_framework/dotnet.native.wasm +0 -0
  116. package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
  117. package/dist/worker-proxy.bundle.js +198 -32
  118. package/dist/worker-proxy.d.ts +37 -4
  119. package/dist/worker-proxy.d.ts.map +1 -1
  120. package/dist/worker-proxy.js +187 -35
  121. package/dist/worker-proxy.js.map +1 -1
  122. package/package.json +22 -6
  123. package/dist/wasm/_framework/System.Diagnostics.Process.wasm +0 -0
  124. package/dist/wasm/_framework/System.Diagnostics.Process.wasm.br +0 -0
package/dist/types.d.ts CHANGED
@@ -149,7 +149,10 @@ export interface MarkdownProjection {
149
149
  anchorIndex: Record<string, MarkdownAnchorTarget>;
150
150
  }
151
151
  /**
152
- * Revision type enum matching the .NET WmlComparerRevisionType
152
+ * Revision type enum matching the .NET `DocxDiffRevisionType`, as returned by the `docxDiff*`
153
+ * comparison APIs. NOT the shape {@link getRevisions} returns — that reads a document's own markup
154
+ * and reports the markup-level kind on `RevisionListEntry.type` (`ins`/`del`/`moveFrom`), with the
155
+ * grouped classification on `family`.
153
156
  */
154
157
  export declare enum RevisionType {
155
158
  /** Text or content that was added/inserted */
@@ -161,24 +164,6 @@ export declare enum RevisionType {
161
164
  /** Text content unchanged but formatting (bold, italic, etc.) changed */
162
165
  FormatChanged = "FormatChanged"
163
166
  }
164
- /**
165
- * Which comparison engine {@link compareDocuments} / {@link compareDocumentsToHtml}
166
- * use to redline two documents.
167
- *
168
- * The numeric values are the contract shared with the .NET `ComparisonEngine` enum
169
- * and the WASM boundary (marshalled as an int); `0` remains
170
- * {@link ComparisonEngine.WmlComparer} for wire compatibility. Omitted selectors use
171
- * {@link ComparisonEngine.DocxDiff}.
172
- *
173
- * `DocxDiff` is the default comparison engine. `WmlComparer` remains available for
174
- * callers that explicitly require its historical behavior.
175
- */
176
- export declare enum ComparisonEngine {
177
- /** The legacy WmlComparer engine (retained at wire value 0). */
178
- WmlComparer = 0,
179
- /** The default DocxDiff IR diff engine. */
180
- DocxDiff = 1
181
- }
182
167
  /**
183
168
  * Comment render mode
184
169
  * Use -1 (Disabled) to not render comments, or a positive value to enable with that mode
@@ -306,8 +291,6 @@ export interface ConversionOptions {
306
291
  export interface CompareOptions {
307
292
  /** Author name for tracked changes (default: "Docxodus") */
308
293
  authorName?: string;
309
- /** Detail threshold 0.0-1.0 (default: 0.15, lower = more detailed) */
310
- detailThreshold?: number;
311
294
  /** Whether comparison is case-insensitive (default: false) */
312
295
  caseInsensitive?: boolean;
313
296
  /**
@@ -316,68 +299,6 @@ export interface CompareOptions {
316
299
  * If false: changes are accepted, output shows final "clean" document
317
300
  */
318
301
  renderTrackedChanges?: boolean;
319
- /**
320
- * Which comparison engine to use (default: {@link ComparisonEngine.DocxDiff}).
321
- * Pass {@link ComparisonEngine.WmlComparer} only when its historical behavior is required.
322
- */
323
- engine?: ComparisonEngine;
324
- }
325
- /**
326
- * Information about a document revision extracted from a compared document.
327
- *
328
- * @example
329
- * ```typescript
330
- * const revisions = await getRevisions(comparedDoc);
331
- * for (const rev of revisions) {
332
- * if (rev.revisionType === RevisionType.Inserted) {
333
- * console.log(`${rev.author} added: "${rev.text}"`);
334
- * } else if (rev.revisionType === RevisionType.Deleted) {
335
- * console.log(`${rev.author} removed: "${rev.text}"`);
336
- * }
337
- * }
338
- * ```
339
- */
340
- export interface Revision {
341
- /**
342
- * Author who made the revision.
343
- * This comes from the Word document's tracked changes author attribute.
344
- * May be empty string if the document doesn't specify an author.
345
- */
346
- author: string;
347
- /**
348
- * ISO 8601 date string when the revision was made.
349
- * Format: "YYYY-MM-DDTHH:mm:ssZ" (e.g., "2024-01-15T10:30:00Z")
350
- * May be empty string if the document doesn't specify a date.
351
- */
352
- date: string;
353
- /**
354
- * Type of revision - "Inserted", "Deleted", or "Moved".
355
- * Use the RevisionType enum for type-safe comparisons.
356
- */
357
- revisionType: RevisionType | string;
358
- /**
359
- * Text content of the revision.
360
- * For paragraph breaks, this will be a newline character.
361
- * May be empty string for non-text elements (e.g., images, math equations).
362
- */
363
- text: string;
364
- /**
365
- * For Moved revisions, this ID links the source and destination.
366
- * Both the "from" and "to" revisions share the same moveGroupId.
367
- * Undefined for non-move revisions.
368
- */
369
- moveGroupId?: number;
370
- /**
371
- * For Moved revisions: true = source (content moved FROM here),
372
- * false = destination (content moved TO here).
373
- * Undefined for non-move revisions.
374
- */
375
- isMoveSource?: boolean;
376
- /**
377
- * For FormatChanged revisions: details about what formatting changed.
378
- * Undefined for non-format-change revisions.
379
- */
380
- formatChange?: FormatChangeDetails;
381
302
  }
382
303
  /**
383
304
  * Which property container a FormatChanged revision describes.
@@ -417,7 +338,7 @@ export interface FormatChangeDetails {
417
338
  export declare enum DocxDiffRevisionGranularity {
418
339
  /** The engine's native one-revision-per-token-span grain (the default). */
419
340
  Fine = 0,
420
- /** Coalesced to counts/texts comparable to the shipped WmlComparer's. */
341
+ /** Coalesced to the coarser contiguous-region grain the legacy comparer reported. */
421
342
  WmlComparerCompatible = 1
422
343
  }
423
344
  /**
@@ -529,6 +450,96 @@ export interface DocxDiffRevision {
529
450
  * also set for a token-level delete inside a modified block; undefined for a whole-block deletion. */
530
451
  rightAnchor?: string;
531
452
  }
453
+ /** A data product selectable in `docxDiffCompareProducts`. */
454
+ export type DocxDiffProduct = "redline" | "revisions" | "editScript" | "semanticChanges";
455
+ /**
456
+ * The requested products of ONE memoized comparison pass, from
457
+ * `docxDiffCompareProducts` (issue #594). Unrequested products are undefined.
458
+ * Each present product equals what the corresponding standalone function
459
+ * returns for the same inputs and settings — except `editScript`, which is
460
+ * handed over parsed (the standalone `docxDiffGetEditScript` returns the
461
+ * serialized string).
462
+ */
463
+ export interface DocxDiffProducts {
464
+ /** The native tracked-changes redline (what `docxDiffCompare` returns). */
465
+ redline?: Uint8Array;
466
+ /** The anchor-addressed revision list (what `docxDiffGetRevisions` returns). */
467
+ revisions?: DocxDiffRevision[];
468
+ /** The engine's edit script, parsed. */
469
+ editScript?: Record<string, unknown>;
470
+ /** The stable semantic-change schema (what `docxDiffGetSemanticChanges` returns). */
471
+ semanticChanges?: SemanticChangeSet;
472
+ }
473
+ /** One candidate of a {@link docxDiffCompareBatch} run: the products of comparing the shared
474
+ * baseline against it, or the error that comparing it produced. */
475
+ export interface DocxDiffBatchResult extends DocxDiffProducts {
476
+ /** The candidate's name, echoed from the request (its index when none was given). */
477
+ name: string;
478
+ /** Set when this candidate failed; its products are then absent. The rest of the batch is
479
+ * unaffected — one malformed counterparty markup must not cost the other ninety-nine. */
480
+ error?: string;
481
+ }
482
+ /** A candidate document for {@link docxDiffCompareBatch}. */
483
+ export interface DocxDiffBatchCandidate {
484
+ /** Echoed back on the matching result. Defaults to the candidate's index. */
485
+ name?: string;
486
+ /** The candidate document. */
487
+ document: File | Uint8Array;
488
+ }
489
+ /** Stable v1 operation names emitted by the semantic-change schema. */
490
+ export type SemanticChangeOperation = "insert" | "delete" | "move" | "modify";
491
+ /** Stable v1 semantic families. New schema versions may append families. */
492
+ export type SemanticChangeFamily = "text" | "block_structure" | "run_formatting" | "paragraph_formatting" | "style" | "numbering" | "list" | "table" | "table_row" | "table_cell" | "table_span" | "table_width" | "table_style" | "section" | "page_setup" | "header" | "footer" | "field" | "footnote" | "endnote" | "comment" | "hyperlink" | "bookmark" | "content_control" | "image" | "media" | "relationship" | "revision" | "annotation" | "opaque_package_part";
493
+ /**
494
+ * Closed typed value used in {@link SemanticChange.before} and `after`.
495
+ * Schema v1 integers stay within `Number.MIN_SAFE_INTEGER..Number.MAX_SAFE_INTEGER`; a document
496
+ * value outside that range arrives as a decimal `string` rather than a rounded `integer`.
497
+ */
498
+ export type SemanticValue = {
499
+ kind: "absent";
500
+ } | {
501
+ kind: "string";
502
+ value: string;
503
+ } | {
504
+ kind: "boolean";
505
+ value: boolean;
506
+ } | {
507
+ kind: "integer";
508
+ value: number;
509
+ } | {
510
+ kind: "digest";
511
+ algorithm: string;
512
+ profile: string | null;
513
+ value: string;
514
+ } | {
515
+ kind: "object";
516
+ value: Record<string, SemanticValue>;
517
+ } | {
518
+ kind: "array";
519
+ value: SemanticValue[];
520
+ };
521
+ /** One deterministic, anchor-addressed semantic change. */
522
+ export interface SemanticChange {
523
+ id: string;
524
+ operation: SemanticChangeOperation;
525
+ family: SemanticChangeFamily;
526
+ partUri: string;
527
+ path: string;
528
+ leftAnchor: string | null;
529
+ rightAnchor: string | null;
530
+ leftScope: string | null;
531
+ rightScope: string | null;
532
+ moveId: string | null;
533
+ before: SemanticValue;
534
+ after: SemanticValue;
535
+ }
536
+ /** Public `docxodus.semantic-changes` schema returned by semantic comparison APIs. */
537
+ export interface SemanticChangeSet {
538
+ schema: "docxodus.semantic-changes";
539
+ schemaVersion: 1;
540
+ changeCount: number;
541
+ changes: SemanticChange[];
542
+ }
532
543
  /**
533
544
  * How overlapping reviewer edits at the same base token span are resolved.
534
545
  * Integer values match the .NET `ConflictResolution` enum positions.
@@ -601,7 +612,7 @@ export interface DocxDiffConsolidatedRevision extends DocxDiffRevision {
601
612
  * const insertions = revisions.filter(isInsertion);
602
613
  * ```
603
614
  */
604
- export declare function isInsertion(revision: Revision): boolean;
615
+ export declare function isInsertion(revision: RevisionListEntry): boolean;
605
616
  /**
606
617
  * Type guard to check if a revision is a deletion.
607
618
  * @param revision - The revision to check
@@ -613,7 +624,7 @@ export declare function isInsertion(revision: Revision): boolean;
613
624
  * const deletions = revisions.filter(isDeletion);
614
625
  * ```
615
626
  */
616
- export declare function isDeletion(revision: Revision): boolean;
627
+ export declare function isDeletion(revision: RevisionListEntry): boolean;
617
628
  /**
618
629
  * Type guard to check if a revision is a move operation.
619
630
  * @param revision - The revision to check
@@ -625,7 +636,7 @@ export declare function isDeletion(revision: Revision): boolean;
625
636
  * const moves = revisions.filter(isMove);
626
637
  * ```
627
638
  */
628
- export declare function isMove(revision: Revision): boolean;
639
+ export declare function isMove(revision: RevisionListEntry): boolean;
629
640
  /**
630
641
  * Type guard to check if a revision is a format change.
631
642
  * @param revision - The revision to check
@@ -640,47 +651,7 @@ export declare function isMove(revision: Revision): boolean;
640
651
  * }
641
652
  * ```
642
653
  */
643
- export declare function isFormatChange(revision: Revision): boolean;
644
- /**
645
- * Type guard to check if a revision is a move source (content moved FROM here).
646
- * @param revision - The revision to check
647
- * @returns true if the revision is the source of a move
648
- *
649
- * @example
650
- * ```typescript
651
- * const revisions = await getRevisions(doc);
652
- * const moveSources = revisions.filter(isMoveSource);
653
- * ```
654
- */
655
- export declare function isMoveSource(revision: Revision): boolean;
656
- /**
657
- * Type guard to check if a revision is a move destination (content moved TO here).
658
- * @param revision - The revision to check
659
- * @returns true if the revision is the destination of a move
660
- *
661
- * @example
662
- * ```typescript
663
- * const revisions = await getRevisions(doc);
664
- * const moveDestinations = revisions.filter(isMoveDestination);
665
- * ```
666
- */
667
- export declare function isMoveDestination(revision: Revision): boolean;
668
- /**
669
- * Find the matching pair for a move revision.
670
- * @param revision - A move revision
671
- * @param allRevisions - All revisions from the document
672
- * @returns The matching move revision, or undefined if not found
673
- *
674
- * @example
675
- * ```typescript
676
- * const revisions = await getRevisions(doc);
677
- * for (const rev of revisions.filter(isMoveSource)) {
678
- * const destination = findMovePair(rev, revisions);
679
- * console.log(`"${rev.text}" moved to become "${destination?.text}"`);
680
- * }
681
- * ```
682
- */
683
- export declare function findMovePair(revision: Revision, allRevisions: Revision[]): Revision | undefined;
654
+ export declare function isFormatChange(revision: RevisionListEntry): boolean;
684
655
  /**
685
656
  * Version information for the library
686
657
  */
@@ -704,13 +675,387 @@ export interface CompareResult {
704
675
  /** The redlined document as a Uint8Array */
705
676
  document: Uint8Array;
706
677
  /** List of revisions found */
707
- revisions: Revision[];
678
+ revisions: RevisionListEntry[];
679
+ }
680
+ /** Algorithm-labelled digest in a verification artifact. */
681
+ export interface VerificationDigest {
682
+ algorithm: string;
683
+ /** Lower-case hexadecimal digest bytes. */
684
+ value: string;
685
+ }
686
+ /** Stable package location attached to a verification finding. */
687
+ export interface ChangeLocation {
688
+ entryUri: string | null;
689
+ ownerUri: string | null;
690
+ relationshipId: string | null;
691
+ targetUri: string | null;
692
+ propertyPath: string | null;
693
+ }
694
+ export type VerificationFindingSeverity = "info" | "warning" | "error";
695
+ /** Machine-readable package validation or safety finding. */
696
+ export interface VerificationFinding {
697
+ code: string;
698
+ severity: VerificationFindingSeverity;
699
+ message: string;
700
+ location: ChangeLocation | null;
701
+ }
702
+ /** One physical ZIP entry. Duplicate names remain separate occurrences. */
703
+ export interface PackageManifestEntry {
704
+ uri: string;
705
+ occurrence: number;
706
+ contentType: string | null;
707
+ contentTypeSource: "override" | "default" | "implicit" | "unresolved";
708
+ /** Exact declared uncompressed byte length as a base-10 integer string. */
709
+ size: string;
710
+ /** Exact compressed ZIP byte length as a base-10 integer string. */
711
+ compressedSize: string;
712
+ rawBytesDigest: VerificationDigest | null;
713
+ normalizedXmlDigest: VerificationDigest | null;
714
+ isXml: boolean;
715
+ /** null when central-directory encryption flags could not be parsed authoritatively. */
716
+ isEncrypted: boolean | null;
717
+ }
718
+ export interface PackageContentTypeDeclaration {
719
+ kind: "default" | "override";
720
+ key: string;
721
+ contentType: string;
722
+ occurrence: number;
723
+ }
724
+ export interface PackageRelationship {
725
+ ownerUri: string;
726
+ id: string;
727
+ type: string;
728
+ target: string;
729
+ targetMode: "Internal" | "External";
730
+ resolvedTargetUri: string | null;
731
+ isTargetPresent: boolean | null;
732
+ }
733
+ export interface PackageRevisionCounts {
734
+ insertions: number;
735
+ deletions: number;
736
+ moveFrom: number;
737
+ moveTo: number;
738
+ propertyChanges: number;
739
+ /** The `rPrChange` subset of `propertyChanges`; not added into `total`. */
740
+ runPropertyChanges: number;
741
+ structuralChanges: number;
742
+ otherChanges: number;
743
+ total: number;
744
+ }
745
+ export interface PackageAnnotationCounts {
746
+ comments: number;
747
+ commentReplies: number;
748
+ threadedCommentMetadata: number;
749
+ resolvedComments: number;
750
+ people: number;
751
+ docxodusAnnotations: number;
752
+ }
753
+ export interface PackageManifestFacts {
754
+ mainDocumentUri: string | null;
755
+ isStrictOoxml: boolean;
756
+ isMacroEnabled: boolean;
757
+ hasCoreProperties: boolean;
758
+ hasExtendedProperties: boolean;
759
+ hasCustomProperties: boolean;
760
+ sectionCount: number;
761
+ paragraphCount: number;
762
+ tableCount: number;
763
+ headerPartCount: number;
764
+ footerPartCount: number;
765
+ footnoteCount: number;
766
+ endnoteCount: number;
767
+ styleCount: number;
768
+ numberingDefinitionCount: number;
769
+ themePartCount: number;
770
+ mediaPartCount: number;
771
+ customXmlPartCount: number;
772
+ drawingCount: number;
773
+ altChunkCount: number;
774
+ fieldCount: number;
775
+ revisions: PackageRevisionCounts;
776
+ annotations: PackageAnnotationCounts;
777
+ }
778
+ /** Deterministic schema-v1 description of a DOCX/OPC package. */
779
+ export interface PackageManifest {
780
+ schema: "https://docxodus.dev/schemas/verification/package-manifest/v1";
781
+ schemaVersion: 1;
782
+ packageKind: "opc" | "zip" | "zip-encrypted" | "ole-encrypted" | "ole" | "malformed";
783
+ isValid: boolean;
784
+ rawPackageBytesDigest: VerificationDigest;
785
+ orderedOpcContentDigest: VerificationDigest | null;
786
+ normalizedSemanticDigest: VerificationDigest | null;
787
+ entries: readonly PackageManifestEntry[];
788
+ contentTypes: readonly PackageContentTypeDeclaration[];
789
+ relationships: readonly PackageRelationship[];
790
+ facts: PackageManifestFacts;
791
+ findings: readonly VerificationFinding[];
792
+ }
793
+ /** Policy preset used by the default deliverable gate. */
794
+ export type DeliverableVerificationMode = "standard" | "strict" | "reportOnly";
795
+ /** Final policy decision in a deliverable-verification report. */
796
+ export type DeliverableVerificationDecision = "passed" | "passedWithPreExistingFindings" | "failed" | "notEvaluated";
797
+ /** How a delivered finding relates to the exact opening/baseline package. */
798
+ export type DeliverableFindingDisposition = "new" | "preExisting" | "resolved" | "unclassified";
799
+ export type DeliverableFindingCategory = "package" | "openXml" | "relationship" | "structure" | "workflow" | "delta" | "render" | "artifact";
800
+ export type DeliverableCheckStatus = "completed" | "skippedPrerequisiteFailed" | "unavailableEvidence";
801
+ export type DeliverablePackageChangeKind = "entryAdded" | "entryRemoved" | "entryModified" | "relationshipAdded" | "relationshipRemoved" | "relationshipModified";
802
+ export type DeliverableArtifactRole = "html" | "pdf" | "pageMap" | "pageImage" | "renderReport" | "other";
803
+ export type DeliverableArtifactAvailability = "available" | "unavailable";
804
+ /** Camel-case enum values used by the deliverable report's semantic summary. */
805
+ export type DeliverableSemanticChangeFamily = "text" | "blockStructure" | "runFormatting" | "paragraphFormatting" | "style" | "numbering" | "list" | "table" | "tableRow" | "tableCell" | "tableSpan" | "tableWidth" | "tableStyle" | "section" | "pageSetup" | "header" | "footer" | "field" | "footnote" | "endnote" | "comment" | "hyperlink" | "bookmark" | "contentControl" | "image" | "media" | "relationship" | "revision" | "annotation" | "opaquePackagePart";
806
+ export interface DeliverablePackageIdentity {
807
+ packageKind: string;
808
+ manifestValid: boolean;
809
+ rawPackageBytesDigest: VerificationDigest;
810
+ orderedOpcContentDigest: VerificationDigest | null;
811
+ normalizedSemanticDigest: VerificationDigest | null;
812
+ }
813
+ export interface DeliverableCheckResult {
814
+ check: string;
815
+ status: DeliverableCheckStatus;
816
+ findingCount: number;
817
+ diagnostic: string | null;
818
+ }
819
+ export interface DeliverableFinding {
820
+ findingId: string;
821
+ code: string;
822
+ category: DeliverableFindingCategory;
823
+ severity: VerificationFindingSeverity;
824
+ disposition: DeliverableFindingDisposition;
825
+ blocksDelivery: boolean;
826
+ message: string;
827
+ owningPartUri: string;
828
+ location: ChangeLocation | null;
829
+ anchorId: string | null;
830
+ scope: string | null;
831
+ xPath: string | null;
832
+ remediation: string;
833
+ }
834
+ export interface DeliverablePackageChange {
835
+ changeId: string;
836
+ kind: DeliverablePackageChangeKind;
837
+ location: ChangeLocation;
838
+ beforeDigest: VerificationDigest | null;
839
+ afterDigest: VerificationDigest | null;
840
+ beforeValue: string | null;
841
+ afterValue: string | null;
842
+ }
843
+ export interface DeliverableSemanticChange {
844
+ changeId: string;
845
+ fingerprint: string;
846
+ operation: SemanticChangeOperation;
847
+ family: DeliverableSemanticChangeFamily;
848
+ partUri: string;
849
+ path: string;
850
+ leftAnchor: string | null;
851
+ rightAnchor: string | null;
852
+ }
853
+ export interface DeliverableSemanticDelta {
854
+ schema: "docxodus.semantic-changes";
855
+ schemaVersion: 1;
856
+ changeCount: number;
857
+ canonicalDigest: VerificationDigest;
858
+ changes: readonly DeliverableSemanticChange[];
859
+ }
860
+ export interface DeliverableArtifactMetadata {
861
+ artifactId: string;
862
+ role: DeliverableArtifactRole;
863
+ mediaType: string;
864
+ availability: DeliverableArtifactAvailability;
865
+ byteLength: number | null;
866
+ digest: VerificationDigest | null;
867
+ unavailableReason: string | null;
868
+ pageCount: number | null;
869
+ rendererFingerprint: string | null;
870
+ sourcePackageDigest: VerificationDigest | null;
871
+ pageMapDigest: VerificationDigest | null;
872
+ renderDiagnosticCount: number;
873
+ }
874
+ /** Canonical schema-v1 report returned by every default verification transport. */
875
+ /** One recorded artifact's independent re-hash verdict from receipt verification. */
876
+ export type DeliveryArtifactVerificationStatus = "verified" | "unavailable" | "missing" | "length_mismatch" | "digest_mismatch" | "invalid_record";
877
+ export interface DeliveryArtifactVerification {
878
+ artifactId: string;
879
+ status: DeliveryArtifactVerificationStatus;
880
+ expectedLength?: number;
881
+ actualLength?: number;
882
+ expectedDigest?: VerificationDigest;
883
+ actualDigest?: VerificationDigest;
884
+ }
885
+ /**
886
+ * Portable delivery change receipt verification verdict — the shared facade wire
887
+ * shape every transport returns (issue #520).
888
+ */
889
+ export interface DeliveryReceiptVerificationResult {
890
+ isValid: boolean;
891
+ receiptDigestValid: boolean;
892
+ contractValid: boolean;
893
+ citationBindingsValid: boolean;
894
+ artifacts: DeliveryArtifactVerification[];
895
+ findings: string[];
896
+ }
897
+ export interface DeliverableVerificationResult {
898
+ schema: "https://docxodus.dev/schemas/verification/deliverable-verification/v1";
899
+ schemaVersion: 1;
900
+ mode: DeliverableVerificationMode;
901
+ decision: DeliverableVerificationDecision;
902
+ analysisCompleted: boolean;
903
+ baselineCompared: boolean;
904
+ baselinePackage: DeliverablePackageIdentity | null;
905
+ deliverablePackage: DeliverablePackageIdentity;
906
+ checks: readonly DeliverableCheckResult[];
907
+ findings: readonly DeliverableFinding[];
908
+ resolvedFindings: readonly DeliverableFinding[];
909
+ semanticDelta: DeliverableSemanticDelta | null;
910
+ packageChanges: readonly DeliverablePackageChange[];
911
+ companionArtifacts: readonly DeliverableArtifactMetadata[];
912
+ }
913
+ /** How a revision in a redline relates to the selected baseline. */
914
+ export type RedlineRevisionDisposition = "preExisting" | "intendedFinalPreExisting" | "generated" | "conflicted";
915
+ /** Which of the two proof paths a result or finding belongs to. */
916
+ export type RedlineProofDirection = "acceptToFinal" | "rejectToBaseline";
917
+ /** How a package entry differs from a path's expected document. */
918
+ export type RedlinePackageDivergenceKind = "added" | "removed" | "modified";
919
+ /** Fail-closed resolution status of one native revision — the session registry's vocabulary. */
920
+ export type RedlineRevisionResolutionStatus = RevisionResolutionStatus;
921
+ /** Coarse family of one native revision. */
922
+ export type RedlineRevisionFamily = "contentInsert" | "contentDelete" | "move" | "paragraphMark" | "rowInsert" | "rowDelete" | "cellInsert" | "cellDelete" | "cellMerge" | "contentControlInsert" | "contentControlDelete" | "numberingPropertiesInsert" | "numberingChange" | "propertiesChange" | "unsupported";
923
+ /** Why a revision could not be resolved — the session registry's shape. */
924
+ export type RedlineRevisionDiagnostic = RevisionDiagnostic;
925
+ /** Input or output package identity recorded by the proof. */
926
+ export interface RedlineProofPackageIdentity {
927
+ rawPackageBytesDigest: VerificationDigest;
928
+ orderedOpcContentDigest: VerificationDigest | null;
929
+ normalizedWholePackageDigest: VerificationDigest | null;
930
+ }
931
+ /** A stable, part-qualified identity for one native Word revision. */
932
+ export interface RedlineRevisionIdentity {
933
+ id: string;
934
+ partUri: string;
935
+ scope: string;
936
+ type: string;
937
+ family: RedlineRevisionFamily;
938
+ constituentIds: readonly string[];
939
+ constituentKeys: readonly string[];
940
+ author: string;
941
+ date: string | null;
942
+ dateUtc: string | null;
943
+ text: string;
944
+ anchorId: string | null;
945
+ affectedAnchorIds: readonly string[];
946
+ resolutionStatus: RedlineRevisionResolutionStatus;
947
+ diagnostic: RedlineRevisionDiagnostic | null;
948
+ }
949
+ /** Classification of a baseline/intended-final/redline revision identity triple. */
950
+ export interface RedlineRevisionClassification {
951
+ disposition: RedlineRevisionDisposition;
952
+ baseline: RedlineRevisionIdentity | null;
953
+ intendedFinal: RedlineRevisionIdentity | null;
954
+ redline: RedlineRevisionIdentity | null;
955
+ reason: string;
956
+ }
957
+ /**
958
+ * Modeled semantic comparison for one path. `available` and `changeCount` are explicit so an
959
+ * empty modeled change set is never mistaken for complete package equality.
960
+ */
961
+ export interface RedlineModeledSemanticComparison {
962
+ available: boolean;
963
+ equivalent: boolean | null;
964
+ schema: string | null;
965
+ changeCount: number | null;
966
+ diagnostic: string | null;
967
+ }
968
+ /** One added, removed, or modified package entry on a proof path. */
969
+ export interface RedlinePackageDivergence {
970
+ kind: RedlinePackageDivergenceKind;
971
+ partUri: string;
972
+ occurrence: number;
973
+ anchorId: string | null;
974
+ applicableRevisionIds: readonly string[];
975
+ expectedRawDigest: VerificationDigest | null;
976
+ actualRawDigest: VerificationDigest | null;
977
+ expectedNormalizedDigest: VerificationDigest | null;
978
+ actualNormalizedDigest: VerificationDigest | null;
979
+ /** Whether the semantic change set reports a modeled change for this part. */
980
+ hasModeledSemanticChange: boolean;
981
+ /**
982
+ * Conservatively true when the normalized difference may contain content outside the modeled
983
+ * semantic projection. A modeled change in one part never proves every change in it was modeled.
984
+ */
985
+ unknownOrUnmodeled: boolean;
986
+ }
987
+ /** A structured, actionable proof finding. */
988
+ export interface RedlineProofFinding {
989
+ code: string;
990
+ severity: VerificationFindingSeverity;
991
+ message: string;
992
+ direction: RedlineProofDirection | null;
993
+ location: ChangeLocation | null;
994
+ anchorId: string | null;
995
+ revisionIds: readonly string[];
996
+ remediation: string | null;
997
+ }
998
+ /** Result of accepting or rejecting only the generated revision set. */
999
+ export interface RedlineProofPathResult {
1000
+ direction: RedlineProofDirection;
1001
+ completed: boolean;
1002
+ equivalent: boolean;
1003
+ requestedRevisionIds: readonly string[];
1004
+ resolvedRevisionIds: readonly string[];
1005
+ implicitlyResolvedRevisionIds: readonly string[];
1006
+ survivingPreExistingRevisions: readonly RedlineRevisionIdentity[];
1007
+ preExistingRevisionsPreserved: boolean;
1008
+ modeledSemantic: RedlineModeledSemanticComparison;
1009
+ normalizedWholePackageEquivalent: boolean;
1010
+ orderedOpcContentEquivalent: boolean;
1011
+ exactPackageBytesEquivalent: boolean;
1012
+ /**
1013
+ * Whether the complete bounded package delta was available. A false value never exposes a
1014
+ * potentially misleading prefix of `divergences`.
1015
+ */
1016
+ divergenceAnalysisCompleted: boolean;
1017
+ expectedPackage: RedlineProofPackageIdentity;
1018
+ actualPackage: RedlineProofPackageIdentity | null;
1019
+ firstDivergence: RedlinePackageDivergence | null;
1020
+ divergences: readonly RedlinePackageDivergence[];
1021
+ findings: readonly RedlineProofFinding[];
1022
+ }
1023
+ /**
1024
+ * Canonical schema-v1 proof that a redline's generated changes accept to the intended final and
1025
+ * reject to the baseline without consuming pre-existing review state.
1026
+ */
1027
+ export interface RedlineReversibilityProof {
1028
+ schema: "https://docxodus.dev/schemas/verification/redline-reversibility-proof/v1";
1029
+ schemaVersion: 1;
1030
+ success: boolean;
1031
+ requireExactPackageBytes: boolean;
1032
+ baselinePackage: RedlineProofPackageIdentity;
1033
+ intendedFinalPackage: RedlineProofPackageIdentity;
1034
+ redlinePackage: RedlineProofPackageIdentity;
1035
+ revisionClassifications: readonly RedlineRevisionClassification[];
1036
+ acceptToFinal: RedlineProofPathResult | null;
1037
+ rejectToBaseline: RedlineProofPathResult | null;
1038
+ findings: readonly RedlineProofFinding[];
1039
+ }
1040
+ /** Effective #493 inspection limits applied while the manifest is being generated. */
1041
+ export interface PackageManifestInspectionLimits {
1042
+ opcEntries: number;
1043
+ expandedOpcBytes: number;
1044
+ xmlPartBytes: number;
1045
+ opcUriCharacters: number;
1046
+ opcCompressionRatio: number;
708
1047
  }
709
1048
  /**
710
1049
  * Internal WASM exports structure
711
1050
  */
712
1051
  export interface DocxodusWasmExports {
713
1052
  DocumentConverter: {
1053
+ GeneratePackageManifest: (bytes: Uint8Array) => string;
1054
+ VerifyDeliverable: (bytes: Uint8Array) => string;
1055
+ VerifyDeliveryReceipt: (receiptJson: string, artifactsJson: string) => string;
1056
+ VerifyDeliverableWithBaseline: (baselineBytes: Uint8Array, bytes: Uint8Array) => string;
1057
+ ProveRedlineReversibility: (baselineBytes: Uint8Array, intendedFinalBytes: Uint8Array, redlineBytes: Uint8Array) => string;
1058
+ GeneratePackageManifestWithOptions: (bytes: Uint8Array, maxEntryCount: number, maxTotalUncompressedBytes: number, maxXmlPartBytes: number, maxCompressionRatio: number, maxUriLength: number) => string;
714
1059
  ConvertDocxToHtml: (bytes: Uint8Array) => string;
715
1060
  RenderBlockHtml: (bytes: Uint8Array, anchorId: string, cssPrefix: string, fabricateClasses: boolean) => string;
716
1061
  ConvertDocxToHtmlWithOptions: (bytes: Uint8Array, pageTitle: string, cssPrefix: string, fabricateClasses: boolean, additionalCss: string, commentRenderMode: number, commentCssClassPrefix: string) => string;
@@ -747,15 +1092,12 @@ export interface DocxodusWasmExports {
747
1092
  * Idempotent — assemblies load only once.
748
1093
  */
749
1094
  Warmup: () => string;
750
- CompareDocuments: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, engine: number) => Uint8Array;
1095
+ CompareDocuments: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string) => Uint8Array;
751
1096
  CompareDocumentsToHtml: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string) => string;
752
- CompareDocumentsToHtmlWithOptions: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, renderTrackedChanges: boolean, engine: number) => string;
753
- CompareDocumentsToHtmlFull: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, detailThreshold: number, caseInsensitive: boolean, renderTrackedChanges: boolean, engine: number) => string;
754
- CompareDocumentsWithOptions: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, detailThreshold: number, caseInsensitive: boolean, engine: number) => Uint8Array;
1097
+ CompareDocumentsToHtmlWithOptions: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, renderTrackedChanges: boolean) => string;
1098
+ CompareDocumentsToHtmlFull: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, caseInsensitive: boolean, renderTrackedChanges: boolean) => string;
1099
+ CompareDocumentsWithOptions: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, caseInsensitive: boolean) => Uint8Array;
755
1100
  GetRevisionsJson: (comparedDocBytes: Uint8Array) => string;
756
- GetRevisionsJsonWithOptions: (comparedDocBytes: Uint8Array, detectMoves: boolean, moveSimilarityThreshold: number, moveMinimumWordCount: number, caseInsensitive: boolean) => string;
757
- CompareDocumentsWithLog: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, detailThreshold: number, caseInsensitive: boolean) => string;
758
- CompareDocumentsToHtmlWithLog: (originalBytes: Uint8Array, modifiedBytes: Uint8Array, authorName: string, detailThreshold: number, caseInsensitive: boolean, renderTrackedChanges: boolean) => string;
759
1101
  };
760
1102
  DocxDiffBridge: {
761
1103
  /** Redlined DOCX bytes (native markup), or empty array on error. */
@@ -764,6 +1106,14 @@ export interface DocxodusWasmExports {
764
1106
  GetRevisionsJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
765
1107
  /** Edit-script JSON (diff-as-data), or a JSON error object. */
766
1108
  GetEditScriptJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
1109
+ /** Canonical `docxodus.semantic-changes` JSON, or a JSON error object. */
1110
+ GetSemanticChangesJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
1111
+ /** One memoized pass, every requested product: `{"redlineB64":…, "revisions":[…],
1112
+ * "editScript":…, "semanticChanges":…}` JSON (issue #594), or a JSON error object. */
1113
+ CompareProductsJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string, productsJson: string) => string;
1114
+ /** One baseline read once, compared against many candidates:
1115
+ * `{"results":[{"name":…, …products…}]}` JSON (issue #617), or a JSON error object. */
1116
+ CompareBatchJson: (baselineBytes: Uint8Array, candidatesJson: string, settingsJson: string, productsJson: string) => string;
767
1117
  /** Accept all tracked revisions in a redlined DOCX → "right"-side bytes, or empty array on error. */
768
1118
  AcceptRevisions: (bytes: Uint8Array) => Uint8Array;
769
1119
  /** Reject all tracked revisions in a redlined DOCX → "left"-side bytes, or empty array on error. */
@@ -779,10 +1129,24 @@ export interface DocxodusWasmExports {
779
1129
  };
780
1130
  DocxSessionBridge: {
781
1131
  OpenSession: (bytes: Uint8Array, settingsJson: string) => number;
1132
+ OpenPreviewSession?: (liveHandle: number) => number;
782
1133
  CloseSession: (handle: number) => void;
783
1134
  CreateBlankDocx: () => Uint8Array;
784
1135
  Project: (handle: number) => string;
1136
+ GetVersion: (handle: number) => string;
1137
+ RegisterPageMap: (handle: number, pageMapJson: string, expectedRendererFingerprint: string) => string;
1138
+ GetPageMapStatus: (handle: number, requestJson: string) => string;
1139
+ GetPageCitation: (handle: number, anchorId: string, requestJson: string) => string;
1140
+ GetPackageContentHash?: (handle: number) => string;
1141
+ GetPackageManifest: (handle: number) => string;
1142
+ RenderPreviewHtml?: (handle: number) => string;
1143
+ RenderPreviewBlockHtml?: (handle: number, anchorId: string) => string;
1144
+ CheckPreconditions: (handle: number, preconditionsJson: string) => string;
1145
+ BeginTransaction: (handle: number) => number;
1146
+ CommitTransaction: (transactionHandle: number) => void;
1147
+ RollbackTransaction: (transactionHandle: number) => void;
785
1148
  ProjectAnchor: (handle: number, anchorId: string, depth: number) => string;
1149
+ ProjectAnchorWithCitations: (handle: number, anchorId: string, depth: number, requestJson: string) => string;
786
1150
  /** Ordered top-level render units per scope container (JSON {@link RenderPlan}) —
787
1151
  * what the editor's incremental reconciler diffs its DOM against. Optional:
788
1152
  * absent on older WASM bundles. */
@@ -822,6 +1186,9 @@ export interface DocxodusWasmExports {
822
1186
  MergeParagraphs: (handle: number, first: string, second: string) => string;
823
1187
  InsertHorizontalRule: (handle: number, anchor: string, pos: string, ruleJson: string) => string;
824
1188
  InsertTable: (handle: number, anchor: string, pos: string, rows: number, cols: number, optionsJson: string) => string;
1189
+ GetTableMetadata: (handle: number, tableAnchor: string) => string;
1190
+ ResolveTableCellAnchor: (handle: number, cellAnchor: string) => string;
1191
+ ResolveTableCellCoordinate: (handle: number, tableAnchor: string, rowIndex: number, columnIndex: number) => string;
825
1192
  InsertTableRow: (handle: number, cellAnchor: string, pos: string) => string;
826
1193
  InsertTableColumn: (handle: number, cellAnchor: string, pos: string) => string;
827
1194
  DeleteTableRow: (handle: number, cellAnchor: string) => string;
@@ -832,13 +1199,18 @@ export interface DocxodusWasmExports {
832
1199
  SetTableBorders: (handle: number, cellAnchor: string, specJson: string) => string;
833
1200
  SetCellShading: (handle: number, cellAnchor: string, fill: string, scope: string) => string;
834
1201
  SetRepeatHeaderRow: (handle: number, cellAnchor: string, repeat: boolean) => string;
1202
+ SetTableRowOptions: (handle: number, cellAnchor: string, repeatHeader: boolean | null, allowBreakAcrossPages: boolean | null, heightTwips: number | null, heightRule: string) => string;
835
1203
  SetHeaderText: (handle: number, anchor: string, kind: string, markdown: string) => string;
836
1204
  SetFooterText: (handle: number, anchor: string, kind: string, markdown: string) => string;
837
1205
  InsertPageNumberField: (handle: number, anchor: string, field: string, format: string) => string;
838
1206
  SetPageNumbering: (handle: number, anchor: string, opJson: string) => string;
1207
+ InsertTableOfContents: (handle: number, anchor: string, pos: string, optionsJson: string) => string;
1208
+ InsertTableOfFigures: (handle: number, anchor: string, pos: string, optionsJson: string) => string;
1209
+ InsertTableOfAuthorities: (handle: number, anchor: string, pos: string, optionsJson: string) => string;
839
1210
  ClearPageNumbering: (handle: number, anchor: string) => string;
840
1211
  EnsureHeaderFooterVisible: (handle: number, anchor: string, kind: string) => string;
841
1212
  InsertFootnote: (handle: number, anchor: string, characterOffset: number, markdown: string) => string;
1213
+ InsertCrossReference: (handle: number, anchor: string, characterOffset: number, bookmarkName: string, optionsJson: string) => string;
842
1214
  InsertEndnote: (handle: number, anchor: string, characterOffset: number, markdown: string) => string;
843
1215
  AddComment: (handle: number, anchor: string, spanJson: string, author: string, initials: string, date: string, markdown: string) => string;
844
1216
  AddCommentToRevision: (handle: number, revisionId: string, author: string, initials: string, date: string, markdown: string) => string;
@@ -847,9 +1219,37 @@ export interface DocxodusWasmExports {
847
1219
  SetCommentResolved: (handle: number, commentAnchor: string, resolved: boolean) => string;
848
1220
  RemoveComment: (handle: number, commentAnchor: string) => string;
849
1221
  ListComments: (handle: number) => string;
1222
+ ListHyperlinks: (handle: number, scopes: number) => string;
1223
+ AddHyperlink: (handle: number, anchor: string, start: number, length: number, kind: string, target: string) => string;
1224
+ UpdateHyperlink: (handle: number, hyperlinkId: string, kind: string, target: string) => string;
1225
+ RemoveHyperlink: (handle: number, hyperlinkId: string) => string;
1226
+ GetImageCapabilities: () => string;
1227
+ ListImages: (handle: number, scopes: number) => string;
1228
+ InsertImage: (handle: number, anchor: string, characterOffset: number, imageBase64: string, optionsJson: string) => string;
1229
+ ReplaceImage: (handle: number, imageId: string, imageBase64: string) => string;
1230
+ SetImageDimensions: (handle: number, imageId: string, dimensionsJson: string) => string;
1231
+ SetImageMetadata: (handle: number, imageId: string, altText: string | null, title: string | null) => string;
1232
+ SetImageFloatingLayout: (handle: number, imageId: string, layoutJson: string) => string;
1233
+ RemoveImage: (handle: number, imageId: string) => string;
1234
+ ListContentControls: (handle: number, scopes: number) => string;
1235
+ FillContentControlText: (handle: number, anchorId: string, text: string, optionsJson: string) => string;
1236
+ FillContentControlRichText: (handle: number, anchorId: string, markdown: string, optionsJson: string) => string;
1237
+ SetContentControlChecked: (handle: number, anchorId: string, isChecked: boolean, optionsJson: string) => string;
1238
+ SetContentControlDate: (handle: number, anchorId: string, value: string, displayText: string | null, optionsJson: string) => string;
1239
+ SelectContentControlItem: (handle: number, anchorId: string, value: string, optionsJson: string) => string;
1240
+ FillContentControlPicture: (handle: number, anchorId: string, imageBase64: string, optionsJson: string) => string;
1241
+ AddRepeatingSectionItem: (handle: number, sectionAnchorId: string, afterItemAnchorId: string, optionsJson: string) => string;
1242
+ RemoveRepeatingSectionItem: (handle: number, itemAnchorId: string) => string;
1243
+ ListBookmarks: (handle: number, scopes: number) => string;
1244
+ AddBookmark: (handle: number, name: string, startAnchor: string, startOffset: number, endAnchor: string, endOffset: number) => string;
1245
+ RenameBookmark: (handle: number, name: string, newName: string) => string;
1246
+ MoveBookmark: (handle: number, name: string, startAnchor: string, startOffset: number, endAnchor: string, endOffset: number) => string;
1247
+ RemoveBookmark: (handle: number, name: string) => string;
850
1248
  ListRevisions: (handle: number) => string;
851
1249
  AcceptRevision: (handle: number, revisionId: string) => string;
852
1250
  RejectRevision: (handle: number, revisionId: string) => string;
1251
+ AcceptAllRevisions: (handle: number) => string;
1252
+ RejectAllRevisions: (handle: number) => string;
853
1253
  ApplyFormat: (handle: number, anchor: string, spanJson: string, opJson: string) => string;
854
1254
  ApplyFormatBySubstring: (handle: number, anchor: string, substring: string, opJson: string) => string;
855
1255
  SetParagraphStyle: (handle: number, anchor: string, styleId: string) => string;
@@ -870,23 +1270,33 @@ export interface DocxodusWasmExports {
870
1270
  ReplaceTextAtSpan: (handle: number, anchor: string, spanStart: number, spanLength: number, replace: string) => string;
871
1271
  ReplaceInner: (handle: number, matchText: string, anchor: string, spanStart: number, spanLength: number, newInner: string) => string;
872
1272
  FindPlaceholders: (handle: number, kinds: number, scope: number, contextChars: number, boundary: number) => string;
1273
+ FindPlaceholdersWithCitations: (handle: number, kinds: number, scope: number, contextChars: number, boundary: number, requestJson: string) => string;
873
1274
  GetEditSummary: (handle: number) => string;
874
1275
  RemainingPlaceholders: (handle: number, kinds: number) => string;
875
1276
  GetDiff: (handle: number, format: number) => string;
1277
+ GetSemanticChanges: (handle: number) => string;
1278
+ VerifyDeliverable: (handle: number) => string;
876
1279
  FindByAnnotation: (handle: number, annotationId: string) => string;
1280
+ FindByAnnotationWithCitations: (handle: number, annotationId: string, requestJson: string) => string;
877
1281
  FindByLabel: (handle: number, labelId: string) => string;
1282
+ FindByLabelWithCitations: (handle: number, labelId: string, requestJson: string) => string;
878
1283
  FindByBookmark: (handle: number, bookmarkName: string) => string;
1284
+ FindByBookmarkWithCitations: (handle: number, bookmarkName: string, requestJson: string) => string;
879
1285
  Exists: (handle: number, anchorId: string) => boolean;
880
1286
  FindByText: (handle: number, needle: string, optionsJson: string) => string;
881
1287
  FindAllByText: (handle: number, needle: string, optionsJson: string) => string;
882
1288
  FindByRegex: (handle: number, pattern: string, regexOptions: number, optionsJson: string) => string;
883
1289
  FindByKind: (handle: number, kind: string, scope: string) => string;
1290
+ FindByKindWithCitations: (handle: number, kind: string, scope: string, requestJson: string) => string;
884
1291
  GetAnchorInfo: (handle: number, anchorId: string) => string;
885
1292
  GetAnchorInfos: (handle: number, anchorIdsJson: string) => string;
886
1293
  GetBlockMetadata: (handle: number, anchorId: string) => string;
887
1294
  GetBlockMetadatas: (handle: number, anchorIdsJson: string) => string;
888
1295
  GetListMembership: (handle: number, anchorId: string) => string;
889
1296
  GetSectionInfo: (handle: number, anchorId: string) => string;
1297
+ ListStyles: (handle: number) => string;
1298
+ GetFormatting: (handle: number, anchorId: string) => string;
1299
+ ListInlineSpans: (handle: number, anchorId: string) => string;
890
1300
  ListAnnotations: (handle: number) => string;
891
1301
  AddAnnotation: (handle: number, anchorId: string, spanJson: string, annotationJson: string) => string;
892
1302
  SessionRemoveAnnotation: (handle: number, annotationId: string) => string;
@@ -904,7 +1314,7 @@ export interface DocxodusWasmExports {
904
1314
  SaveWithAnchorIds: (handle: number) => Uint8Array;
905
1315
  };
906
1316
  }
907
- export type EditErrorCode = "anchor_not_found" | "anchor_wrong_kind" | "anchors_not_adjacent" | "session_disposed" | "malformed_markdown" | "unsupported_markdown_syntax" | "table_insert_not_supported" | "footnote_ref_not_supported" | "comment_marker_not_supported" | "image_insert_not_supported" | "anchor_token_in_payload" | "offset_out_of_range" | "invalid_position" | "unknown_style" | "invalid_list_level" | "invalid_list_start_value" | "invalid_page_numbering" | "invalid_paragraph_format" | "invalid_table_styling" | "invalid_table_merge" | "malformed_xml" | "disallowed_namespace" | "incompatible_element_type" | "validation_failed" | "nothing_to_undo" | "nothing_to_redo" | "duplicate_annotation_id" | "annotation_not_found" | "empty_annotation_span" | "empty_comment_span" | "revision_not_found" | "internal_error";
1317
+ export type EditErrorCode = "anchor_not_found" | "anchor_wrong_kind" | "anchors_not_adjacent" | "session_disposed" | "malformed_markdown" | "unsupported_markdown_syntax" | "table_insert_not_supported" | "footnote_ref_not_supported" | "comment_marker_not_supported" | "image_insert_not_supported" | "anchor_token_in_payload" | "offset_out_of_range" | "invalid_position" | "text_not_found" | "unknown_style" | "invalid_list_level" | "invalid_list_start_value" | "invalid_page_numbering" | "invalid_reference_field" | "invalid_paragraph_format" | "invalid_table_styling" | "invalid_table_merge" | "table_anchor_migration_required" | "malformed_xml" | "disallowed_namespace" | "incompatible_element_type" | "validation_failed" | "nothing_to_undo" | "nothing_to_redo" | "duplicate_annotation_id" | "annotation_not_found" | "empty_annotation_span" | "empty_comment_span" | "revision_not_found" | "precondition_failed" | "invalid_batch_step" | "invalid_transaction" | "transaction_conflict" | "transaction_result_evicted" | "transaction_incomplete" | "hyperlink_not_found" | "bookmark_not_found" | "duplicate_bookmark_name" | "invalid_bookmark_name" | "invalid_hyperlink_target" | "missing_bookmark_target" | "bookmark_in_use" | "managed_bookmark" | "empty_hyperlink_span" | "unsupported_inline_boundary" | "revision_unsupported" | "revision_malformed" | "revision_ambiguous" | "tracked_operation_unsupported" | "unresolved_structural_revision" | "content_control_not_found" | "content_control_malformed" | "content_control_unsupported" | "content_control_locked" | "content_control_bound" | "content_control_wrong_type" | "invalid_content_control_value" | "content_control_placement_unsupported" | "content_control_nested_fill_unsupported" | "repeating_section_constraint" | "image_not_found" | "invalid_image_data" | "unsupported_image_format" | "image_too_large" | "invalid_image_dimensions" | "unsupported_image_markup" | "linked_image_read_only" | "invalid_image_layout" | "internal_error";
908
1318
  export interface AnchorRef {
909
1319
  id: string;
910
1320
  kind: string;
@@ -915,6 +1325,105 @@ export interface EditError {
915
1325
  code: EditErrorCode;
916
1326
  message: string;
917
1327
  anchorId?: string;
1328
+ precondition?: PreconditionFailure;
1329
+ }
1330
+ export interface PreconditionTarget {
1331
+ exists: boolean;
1332
+ anchorId?: string;
1333
+ kind?: string;
1334
+ scope?: string;
1335
+ contentHash?: string;
1336
+ visibleText?: string;
1337
+ }
1338
+ export interface PreconditionFailure {
1339
+ condition: string;
1340
+ expected: unknown;
1341
+ actual: unknown;
1342
+ currentVersion: number;
1343
+ currentTarget?: PreconditionTarget;
1344
+ }
1345
+ export interface TextRangePrecondition {
1346
+ start: number;
1347
+ length: number;
1348
+ text: string;
1349
+ }
1350
+ /** Optimistic guards checked immediately before a mutation. */
1351
+ export interface MutationPreconditions {
1352
+ expectedVersion?: number;
1353
+ /** Optional explicit target; target-addressed methods infer their own anchor when omitted. */
1354
+ anchorId?: string;
1355
+ expectedContentHash?: string;
1356
+ expectedText?: string;
1357
+ expectedTextRange?: TextRangePrecondition;
1358
+ expectedKind?: string;
1359
+ expectedScope?: string;
1360
+ expectedMatchCount?: number;
1361
+ }
1362
+ export type MutationBatchMode = "atomic" | "best_effort";
1363
+ /** One synchronous npm batch step. Atomic is the default execution mode. */
1364
+ export interface MutationBatchStep {
1365
+ tool: string;
1366
+ action: string;
1367
+ mutation: () => EditResult | readonly EditResult[];
1368
+ /** Optional read-only validation: all run up front in atomic mode, per-step in best-effort. */
1369
+ preflight?: () => EditError | undefined;
1370
+ }
1371
+ /** A preview callback receives the isolated shadow session it must mutate/read. */
1372
+ export interface MutationBatchPreviewStep {
1373
+ tool: string;
1374
+ action: string;
1375
+ mutation: (shadow: import("./session.js").DocxSession) => EditResult | readonly EditResult[];
1376
+ preflight?: (shadow: import("./session.js").DocxSession) => EditError | undefined;
1377
+ }
1378
+ export interface MutationBatchPreviewOptions {
1379
+ html?: "none" | "scoped" | "full";
1380
+ /** Required for scoped HTML. */
1381
+ htmlAnchorId?: string;
1382
+ }
1383
+ export interface MutationBatchStepResult {
1384
+ index: number;
1385
+ tool: string;
1386
+ action: string;
1387
+ success: boolean;
1388
+ rolledBack: boolean;
1389
+ results: readonly EditResult[];
1390
+ }
1391
+ export interface MutationBatchFailure {
1392
+ index: number;
1393
+ tool: string;
1394
+ action: string;
1395
+ error: EditError;
1396
+ rolledBack: boolean;
1397
+ }
1398
+ export interface MutationBatchChangeSet<T> {
1399
+ added: readonly T[];
1400
+ removed: readonly T[];
1401
+ modified: readonly T[];
1402
+ }
1403
+ export interface MutationBatchResult {
1404
+ mode: MutationBatchMode;
1405
+ status: "ok" | "failed" | "partial";
1406
+ preview: boolean;
1407
+ success: boolean;
1408
+ rolledBack: boolean;
1409
+ baseVersion: number;
1410
+ resultVersion: number;
1411
+ /**
1412
+ * Canonical SHA-256 of this result package, or `null` when it could not be computed.
1413
+ * Exact replay equality is guaranteed only for deterministic batches, so consult
1414
+ * {@link MutationBatchResult.warnings} before asserting on it — and note that `null`
1415
+ * never equals `null` for the purposes of a replay assertion: an absent hash proves
1416
+ * nothing and must be handled explicitly rather than compared.
1417
+ */
1418
+ packageHash: string | null;
1419
+ steps: readonly MutationBatchStepResult[];
1420
+ failure?: MutationBatchFailure;
1421
+ revisionChanges: MutationBatchChangeSet<RevisionListEntry>;
1422
+ commentChanges: MutationBatchChangeSet<CommentListEntry>;
1423
+ annotationChanges: MutationBatchChangeSet<DocumentAnnotation>;
1424
+ warnings: readonly string[];
1425
+ /** Shadow-only preview HTML when requested; null otherwise. */
1426
+ html: string | null;
918
1427
  }
919
1428
  export interface MarkdownPatch {
920
1429
  scopeAnchorId: string;
@@ -926,10 +1435,196 @@ export interface EditResult {
926
1435
  created: AnchorRef[];
927
1436
  removed: AnchorRef[];
928
1437
  modified: AnchorRef[];
1438
+ /** Deterministic structural identity map for table shape mutations. */
1439
+ tableAnchors?: TableAnchorMapping;
929
1440
  patch?: MarkdownPatch;
930
1441
  /** Set by the annotation ops (addAnnotation/removeAnnotation/updateAnnotation/
931
1442
  * moveAnnotation) with the affected annotation id; absent for every other op. */
932
1443
  annotationId?: string;
1444
+ hyperlinkId?: string;
1445
+ bookmarkName?: string;
1446
+ imageId?: string;
1447
+ }
1448
+ export type HyperlinkKind = "external" | "internal";
1449
+ export interface HyperlinkInfo {
1450
+ id: string;
1451
+ kind: HyperlinkKind;
1452
+ owningPartUri: string;
1453
+ scope: string;
1454
+ anchorId: string;
1455
+ span: CharSpan;
1456
+ text: string;
1457
+ target?: string;
1458
+ relationshipId?: string;
1459
+ relationshipIsExternal?: boolean;
1460
+ isBroken: boolean;
1461
+ }
1462
+ export type ImageBinaryFormat = "unknown" | "png" | "jpeg" | "gif" | "bmp" | "tiff" | "webp";
1463
+ export type ImageMarkupKind = "modern_drawing" | "legacy_vml" | "unsupported_drawing";
1464
+ export type ImagePlacement = "inline" | "floating";
1465
+ export type ImageWrapMode = "none" | "square" | "tight" | "through" | "top_and_bottom" | "unknown";
1466
+ export type ImageWrapSide = "both_sides" | "left" | "right" | "largest" | "unknown";
1467
+ export type ImageHorizontalReference = "page" | "margin" | "column" | "character" | "unknown";
1468
+ export type ImageVerticalReference = "page" | "margin" | "paragraph" | "line" | "unknown";
1469
+ export type ImageHorizontalAlignment = "left" | "center" | "right" | "inside" | "outside" | "unknown";
1470
+ export type ImageVerticalAlignment = "top" | "center" | "bottom" | "inside" | "outside" | "unknown";
1471
+ export interface FloatingImageLayout {
1472
+ horizontalRelativeFrom?: ImageHorizontalReference;
1473
+ horizontalOffsetEmu?: number | null;
1474
+ horizontalAlignment?: ImageHorizontalAlignment | null;
1475
+ verticalRelativeFrom?: ImageVerticalReference;
1476
+ verticalOffsetEmu?: number | null;
1477
+ verticalAlignment?: ImageVerticalAlignment | null;
1478
+ wrapMode?: ImageWrapMode;
1479
+ wrapSide?: ImageWrapSide;
1480
+ distanceTopEmu?: number;
1481
+ distanceBottomEmu?: number;
1482
+ distanceLeftEmu?: number;
1483
+ distanceRightEmu?: number;
1484
+ relativeHeight?: number;
1485
+ behindDocument?: boolean;
1486
+ locked?: boolean;
1487
+ layoutInCell?: boolean;
1488
+ allowOverlap?: boolean;
1489
+ rawHorizontalReference?: string;
1490
+ rawVerticalReference?: string;
1491
+ rawHorizontalPosition?: string;
1492
+ rawVerticalPosition?: string;
1493
+ rawWrapMode?: string;
1494
+ rawWrapSide?: string;
1495
+ rawRelativeSizeHorizontal?: string;
1496
+ rawRelativeSizeVertical?: string;
1497
+ rawFlagTokens?: Record<string, string>;
1498
+ }
1499
+ export interface ImageInsertOptions {
1500
+ placement?: ImagePlacement;
1501
+ widthPoints?: number;
1502
+ heightPoints?: number;
1503
+ preserveAspect?: boolean;
1504
+ altText?: string | null;
1505
+ title?: string | null;
1506
+ floatingLayout?: FloatingImageLayout;
1507
+ }
1508
+ export interface ImageDimensions {
1509
+ widthPoints?: number;
1510
+ heightPoints?: number;
1511
+ preserveAspect?: boolean;
1512
+ }
1513
+ export interface ImageOccurrence {
1514
+ id: string;
1515
+ markupKind: ImageMarkupKind;
1516
+ placement?: ImagePlacement;
1517
+ canMutate: boolean;
1518
+ unsupportedReason?: string;
1519
+ owningPartUri: string;
1520
+ scope: string;
1521
+ anchorId: string;
1522
+ span: CharSpan;
1523
+ relationshipId?: string;
1524
+ targetPartUri?: string;
1525
+ linkedRelationshipId?: string;
1526
+ linkedTarget?: string;
1527
+ isEmbedded: boolean;
1528
+ isLinked: boolean;
1529
+ isBroken: boolean;
1530
+ mediaFileName?: string;
1531
+ contentType?: string;
1532
+ format: ImageBinaryFormat;
1533
+ contentTypeMatchesBytes?: boolean;
1534
+ intrinsicWidthPixels?: number;
1535
+ intrinsicHeightPixels?: number;
1536
+ renderedWidthPoints?: number;
1537
+ renderedHeightPoints?: number;
1538
+ altText?: string;
1539
+ title?: string;
1540
+ floatingLayout?: FloatingImageLayout;
1541
+ floatingLayoutSupported: boolean;
1542
+ }
1543
+ export interface ImageFormatCapability {
1544
+ format: ImageBinaryFormat;
1545
+ contentType: string;
1546
+ canInspect: boolean;
1547
+ canInsert: boolean;
1548
+ canReplace: boolean;
1549
+ limitation?: string;
1550
+ }
1551
+ export interface ImageCapabilities {
1552
+ schemaVersion: number;
1553
+ runtime: string;
1554
+ formats: ImageFormatCapability[];
1555
+ operations: string[];
1556
+ mutableWrapModes: ImageWrapMode[];
1557
+ horizontalReferences: ImageHorizontalReference[];
1558
+ verticalReferences: ImageVerticalReference[];
1559
+ maxInputBytes: number;
1560
+ maxRenderedPoints: number;
1561
+ defaultDpi: number;
1562
+ usesHeaderParsingOnly: boolean;
1563
+ acceptsBinaryBytes: boolean;
1564
+ supportsNetworkFetch: boolean;
1565
+ supportsFileIo: boolean;
1566
+ }
1567
+ export type ContentControlType = "plain_text" | "rich_text" | "checkbox" | "date" | "drop_down_list" | "combo_box" | "picture" | "repeating_section" | "repeating_section_item" | "unsupported";
1568
+ export type ContentControlPlacement = "inline" | "block" | "row" | "cell" | "unknown";
1569
+ export type ContentControlBindingPolicy = "preserve" | "detach_target";
1570
+ export interface ContentControlFillOptions {
1571
+ bindingPolicy?: ContentControlBindingPolicy;
1572
+ }
1573
+ export interface ContentControlBindingInfo {
1574
+ storeItemId?: string;
1575
+ xpath?: string;
1576
+ prefixMappings?: string;
1577
+ }
1578
+ export interface ContentControlInfo {
1579
+ anchorId: string;
1580
+ type: ContentControlType;
1581
+ placement: ContentControlPlacement;
1582
+ nativeId?: string;
1583
+ tag?: string;
1584
+ alias?: string;
1585
+ lock?: string;
1586
+ isShowingPlaceholder: boolean;
1587
+ isBound: boolean;
1588
+ binding?: ContentControlBindingInfo;
1589
+ owningPartUri: string;
1590
+ scope: string;
1591
+ parentAnchorId?: string;
1592
+ depth: number;
1593
+ hasValidNativeId: boolean;
1594
+ hasDuplicateNativeId: boolean;
1595
+ canMutate: boolean;
1596
+ canDetachTargetBinding: boolean;
1597
+ unsupportedReason?: string;
1598
+ text: string;
1599
+ itemValues: string[];
1600
+ }
1601
+ export interface DocumentRange {
1602
+ startAnchorId: string;
1603
+ startOffset: number;
1604
+ endAnchorId: string;
1605
+ endOffset: number;
1606
+ }
1607
+ export interface BookmarkRangeSegment {
1608
+ owningPartUri: string;
1609
+ scope: string;
1610
+ anchorId: string;
1611
+ span: CharSpan;
1612
+ text: string;
1613
+ }
1614
+ export interface BookmarkInfo {
1615
+ name: string;
1616
+ bookmarkId: string;
1617
+ startPartUri: string;
1618
+ startScope: string;
1619
+ endPartUri?: string;
1620
+ endScope?: string;
1621
+ range?: DocumentRange;
1622
+ segments: BookmarkRangeSegment[];
1623
+ text: string;
1624
+ isPaired: boolean;
1625
+ isManaged: boolean;
1626
+ isValid: boolean;
1627
+ validationError?: string;
933
1628
  }
934
1629
  /**
935
1630
  * One native Word comment, in comments-part order — see {@link DocxSession.listComments}.
@@ -951,23 +1646,40 @@ export interface CommentListEntry {
951
1646
  }
952
1647
  /** Revision kind in a markup-native revision listing. A `move` entry is a linked
953
1648
  * move pair — both sides resolve together. */
954
- export type SessionRevisionType = "insert" | "delete" | "move" | "format";
1649
+ export type SessionRevisionType = "insert" | "delete" | "move" | "format" | "structure";
1650
+ export type RevisionFamily = "content_insert" | "content_delete" | "move" | "paragraph_mark" | "row_insert" | "row_delete" | "cell_insert" | "cell_delete" | "cell_merge" | "content_control_insert" | "content_control_delete" | "numbering_properties_insert" | "numbering_change" | "properties_change" | "unsupported";
1651
+ export type RevisionResolutionStatus = "supported" | "unsupported" | "malformed" | "ambiguous";
1652
+ export interface RevisionDiagnostic {
1653
+ code: string;
1654
+ message: string;
1655
+ }
955
1656
  /**
956
- * One tracked revision read directly off the live markup, in document order — see
957
- * {@link DocxSession.listRevisions}. `id` is stable while the underlying markup exists
958
- * (derived from the markup's own `w:id` attributes — resolving OTHER revisions never
959
- * renames it) and is what acceptRevision/rejectRevision address. `author`/`date` are
960
- * the markup's true `w:author`/`w:date`. `text` is the revision's visible text (deleted
961
- * text for deletions, `¶` for a revised paragraph mark, the affected text for format
962
- * changes). `anchorId` is the containing block's anchor when addressable.
1657
+ * One part-qualified atomic revision from the live registry. `id` is an opaque,
1658
+ * deterministic `rev2-…` identity; `constituentIds` exposes the native Word ids.
1659
+ * `family` identifies the exact operation, while `type` is its coarse display class.
1660
+ * Unsafe native topology remains listed through `resolutionStatus` and `diagnostic`.
963
1661
  */
964
1662
  export interface RevisionListEntry {
965
1663
  id: string;
966
1664
  type: SessionRevisionType;
1665
+ family: RevisionFamily;
1666
+ constituentIds: string[];
1667
+ /**
1668
+ * QName-qualified native carrier identities. Unlike `constituentIds`, these
1669
+ * distinguish revision roles which legally use the same numeric `w:id` value.
1670
+ */
1671
+ constituentKeys: string[];
967
1672
  author: string;
968
1673
  date?: string;
1674
+ /** The `w16du:dateUtc` timestamp, when the markup carries one. */
1675
+ dateUtc?: string;
969
1676
  text: string;
1677
+ partUri: string;
1678
+ scope: string;
970
1679
  anchorId?: string;
1680
+ affectedAnchors: AnchorRef[];
1681
+ resolutionStatus: RevisionResolutionStatus;
1682
+ diagnostic?: RevisionDiagnostic;
971
1683
  }
972
1684
  export interface CharSpan {
973
1685
  start: number;
@@ -1056,6 +1768,49 @@ export interface ParagraphFormatOp {
1056
1768
  * `"even"` (even pages; sets `w:evenAndOddHeaders`).
1057
1769
  */
1058
1770
  export type HeaderFooterKind = "default" | "first" | "even";
1771
+ /**
1772
+ * Options for {@link DocxSession.insertTableOfContents} (issue #607). Every field is a typed switch
1773
+ * on the underlying `TOC` field, so a caller never writes `\o "1-3"` by hand — a malformed switch
1774
+ * string renders as nothing in Word, silently, which is the failure these exist to prevent.
1775
+ */
1776
+ export interface TableOfContentsOptions {
1777
+ /** Heading levels to list (`\o`): a level or a range within 1-9, e.g. `"1-3"`. Default `"1-3"`. */
1778
+ levels?: string;
1779
+ /** Make each entry a hyperlink to its heading (`\h`). Default true. */
1780
+ hyperlinks?: boolean;
1781
+ /** Hide the leader tab and page numbers in Word's web view (`\z`). Default true. */
1782
+ hideTabAndPageNumbersInWeb?: boolean;
1783
+ /** Include paragraphs with an outline level but no heading style (`\u`). Default true. */
1784
+ useOutlineLevels?: boolean;
1785
+ /** Heading above the table, in Word's `TOCHeading` style. `null` or `""` inserts no heading.
1786
+ * Default `"Contents"`. */
1787
+ title?: string | null;
1788
+ /** Right-aligned dot-leader tab stop in twips. Default 9350 (US Letter, one-inch margins). */
1789
+ rightTabPos?: number;
1790
+ }
1791
+ /** Options for {@link DocxSession.insertTableOfFigures}. A table of figures is a `TOC` field
1792
+ * selecting by caption label rather than outline level — Word's own encoding. */
1793
+ export interface TableOfFiguresOptions {
1794
+ /** The caption label whose captions to list (`\c`) — `"Figure"`, `"Table"`, `"Exhibit"`. */
1795
+ captionLabel?: string;
1796
+ /** Make each entry a hyperlink to its caption (`\h`). Default true. */
1797
+ hyperlinks?: boolean;
1798
+ /** Right-aligned dot-leader tab stop in twips. Default 9350. */
1799
+ rightTabPos?: number;
1800
+ }
1801
+ /** Word's fixed table-of-authorities categories. */
1802
+ export type AuthorityCategory = "cases" | "statutes" | "other_authorities" | "rules" | "treatises" | "regulations" | "constitutional_provisions";
1803
+ /** Options for {@link DocxSession.insertTableOfAuthorities}. */
1804
+ export interface TableOfAuthoritiesOptions {
1805
+ /** Which category of authority to list (`\c`). Default `"cases"`. */
1806
+ category?: AuthorityCategory;
1807
+ /** Make each entry a hyperlink to its citation (`\h`). Default true. */
1808
+ hyperlinks?: boolean;
1809
+ /** Separator between an entry and its page numbers (`\e`), e.g. a tab. Default: Word's own. */
1810
+ entryPageSeparator?: string;
1811
+ /** Right-aligned dot-leader tab stop in twips. Default 9350. */
1812
+ rightTabPos?: number;
1813
+ }
1059
1814
  /** Which page-number field `DocxSession.insertPageNumberField` emits: `"currentPage"` → PAGE,
1060
1815
  * `"totalPages"` → NUMPAGES. */
1061
1816
  export type PageNumberField = "currentPage" | "totalPages";
@@ -1092,6 +1847,77 @@ export interface TableInsertOptions {
1092
1847
  * wide-left / narrow-right filing-header row. */
1093
1848
  columnWidths?: number[];
1094
1849
  }
1850
+ export type TableVerticalMergeRole = "none" | "restart" | "continue";
1851
+ export type TableAnchorEntityKind = "table" | "row" | "column" | "cell";
1852
+ export interface TableCellMetadata {
1853
+ anchor: AnchorRef;
1854
+ tableAnchorId: string;
1855
+ rowAnchorId: string;
1856
+ rowIndex: number;
1857
+ columnIndex: number;
1858
+ rowSpan: number;
1859
+ columnSpan: number;
1860
+ verticalMerge: TableVerticalMergeRole;
1861
+ /** Direct cell paragraphs only; nested-table paragraphs belong to their own cells. */
1862
+ paragraphAnchors: AnchorRef[];
1863
+ }
1864
+ export interface TableRowMetadata {
1865
+ anchor: AnchorRef;
1866
+ tableAnchorId: string;
1867
+ rowIndex: number;
1868
+ gridBefore: number;
1869
+ gridAfter: number;
1870
+ cells: TableCellMetadata[];
1871
+ }
1872
+ export interface TableColumnMetadata {
1873
+ anchor: AnchorRef;
1874
+ tableAnchorId: string;
1875
+ columnIndex: number;
1876
+ widthTwips: number;
1877
+ /** True when an absent/underspecified tblGrid required a read-only coordinate identity. */
1878
+ isVirtual: boolean;
1879
+ cellAnchorIds: string[];
1880
+ }
1881
+ export interface TableMetadata {
1882
+ anchor: AnchorRef;
1883
+ columns: TableColumnMetadata[];
1884
+ rows: TableRowMetadata[];
1885
+ }
1886
+ export interface TableMetadataResult {
1887
+ success: boolean;
1888
+ error?: EditError;
1889
+ metadata?: TableMetadata;
1890
+ }
1891
+ export interface TableCellResolutionResult {
1892
+ success: boolean;
1893
+ error?: EditError;
1894
+ cell?: TableCellMetadata;
1895
+ }
1896
+ export interface TableAnchorLocation {
1897
+ anchor: AnchorRef;
1898
+ entityKind: TableAnchorEntityKind;
1899
+ rowIndex?: number;
1900
+ columnIndex?: number;
1901
+ rowSpan?: number;
1902
+ columnSpan?: number;
1903
+ isVirtual?: boolean;
1904
+ }
1905
+ export interface TableAnchorMapping {
1906
+ retained: {
1907
+ before: TableAnchorLocation;
1908
+ after: TableAnchorLocation;
1909
+ }[];
1910
+ added: TableAnchorLocation[];
1911
+ invalidated: TableAnchorLocation[];
1912
+ }
1913
+ export type TableRowHeightRule = "auto" | "atLeast" | "exact";
1914
+ export interface TableRowOptions {
1915
+ repeatHeader?: boolean;
1916
+ allowBreakAcrossPages?: boolean;
1917
+ /** Zero removes an explicit height. */
1918
+ heightTwips?: number;
1919
+ heightRule?: TableRowHeightRule;
1920
+ }
1095
1921
  /** Which table edges `DocxSession.setTableBorders` targets: `"outside"` = top/left/bottom/right,
1096
1922
  * `"inside"` = the inner grid lines (`w:insideH`/`w:insideV`), `"all"` = both. */
1097
1923
  export type TableBorderScope = "all" | "outside" | "inside";
@@ -1117,7 +1943,21 @@ export interface TableBorderSpec {
1117
1943
  color?: string;
1118
1944
  }
1119
1945
  export interface DocxSessionSettings {
1946
+ /**
1947
+ * Maximum undo steps retained. Default 20 (was 50).
1948
+ *
1949
+ * Each step is a full snapshot of every snapshot-scoped part, so this is a STEP count and not
1950
+ * a memory bound — the cost of one step scales with the document. Use `undoMemoryBudgetBytes`
1951
+ * to bound the heap.
1952
+ */
1120
1953
  undoDepth?: number;
1954
+ /**
1955
+ * Approximate ceiling, in bytes, on memory held by undo/redo snapshots. Default 134217728
1956
+ * (128 MiB). When exceeded the oldest history is discarded, so on a large document undo may
1957
+ * not reach the full `undoDepth`; one step is always retained. Set to 0 to bound by depth
1958
+ * alone (the pre-9.10 behavior).
1959
+ */
1960
+ undoMemoryBudgetBytes?: number;
1121
1961
  validateRawOps?: boolean;
1122
1962
  trackedChanges?: "accept" | "render_inline" | "strip_deletions";
1123
1963
  revisionAuthor?: string;
@@ -1145,8 +1985,10 @@ export interface DocxSessionSettings {
1145
1985
  emitMarkdownPatch?: boolean;
1146
1986
  /**
1147
1987
  * When `true` (default), the session projects the document at construction
1148
- * time so {@link DocxSession.getDiff} can compare initial vs. current.
1149
- * Set to `false` to skip the ~200ms upfront cost if you don't plan to diff.
1988
+ * time so {@link DocxSession.getDiff} can compare initial vs. current, and
1989
+ * retains the exact opening package for `getSemanticChanges()`.
1990
+ * Set to `false` to skip the upfront projection plus package-copy cost if you
1991
+ * do not plan to call either comparison API.
1150
1992
  */
1151
1993
  captureInitialProjection?: boolean;
1152
1994
  }
@@ -1179,6 +2021,56 @@ export interface DocxSessionProjection {
1179
2021
  scope: string;
1180
2022
  textPreview: string;
1181
2023
  }>;
2024
+ /** Present only when projectAnchor requested citations. */
2025
+ pageCitations?: Record<string, PageCitation>;
2026
+ }
2027
+ export interface PageCitationRequest {
2028
+ documentVersion: number;
2029
+ rendererFingerprint: string;
2030
+ }
2031
+ export type PageCitationUnavailableReason = "no_page_map" | "continuous_mode" | "stale_document_version" | "renderer_fingerprint_mismatch" | "anchor_not_mapped";
2032
+ export interface PageCitationFragment {
2033
+ fragmentId: string;
2034
+ anchorId: string;
2035
+ fragmentIndex: number;
2036
+ pageNumber: number;
2037
+ geometry: {
2038
+ x: number;
2039
+ y: number;
2040
+ width: number;
2041
+ height: number;
2042
+ };
2043
+ story: "body" | "header" | "footer" | "footnote" | "endnote" | "comment";
2044
+ inTableCell: boolean;
2045
+ }
2046
+ export interface PageCitationPage {
2047
+ pageNumber: number;
2048
+ pageInSection: number;
2049
+ width: number;
2050
+ height: number;
2051
+ sectionIndex?: number;
2052
+ pageName: string;
2053
+ }
2054
+ export interface PageCitation {
2055
+ anchorId: string;
2056
+ availability: "available" | "unavailable";
2057
+ unavailableReason?: PageCitationUnavailableReason;
2058
+ documentVersion: number;
2059
+ rendererFingerprint: string;
2060
+ pages: PageCitationPage[];
2061
+ fragments: PageCitationFragment[];
2062
+ }
2063
+ export interface PageMapRegistrationResult {
2064
+ success: boolean;
2065
+ error?: "unsupported_schema_version" | "stale_document_version" | "renderer_fingerprint_mismatch" | "invalid_map";
2066
+ message?: string;
2067
+ }
2068
+ export interface PageMapStatus {
2069
+ availability: "available" | "unavailable";
2070
+ unavailableReason?: PageCitationUnavailableReason;
2071
+ documentVersion: number;
2072
+ rendererFingerprint?: string;
2073
+ mode?: "paginated" | "continuous";
1182
2074
  }
1183
2075
  /**
1184
2076
  * Per-fragment visible formatting reported by {@link DocxSession.grep}.
@@ -1219,6 +2111,8 @@ export interface TextMatch {
1219
2111
  contextAfter: string;
1220
2112
  /** Regex capture groups; index 0 is always the whole match. */
1221
2113
  groups: string[];
2114
+ /** Present only when grep requested a citation for this exact render. */
2115
+ citation?: PageCitation;
1222
2116
  }
1223
2117
  /**
1224
2118
  * One block's contribution to a {@link CrossBlockMatch}. The slice's `fragments`
@@ -1249,6 +2143,18 @@ export interface CrossBlockMatch {
1249
2143
  contextAfter: string;
1250
2144
  /** Regex capture groups; index 0 is always the whole match. */
1251
2145
  groups: string[];
2146
+ /** One per enclosingAnchors entry when requested. */
2147
+ citations?: PageCitation[];
2148
+ }
2149
+ /**
2150
+ * Options for {@link DocxSession.insertCrossReference} — each flag is one of the REF
2151
+ * field's switches: `\r` (reference the target's auto-number), `\h` (hyperlink),
2152
+ * `\p` (relative position, cached as "above"/"below").
2153
+ */
2154
+ export interface CrossReferenceOptions {
2155
+ referenceNumber?: boolean;
2156
+ hyperlink?: boolean;
2157
+ includePosition?: boolean;
1252
2158
  }
1253
2159
  /**
1254
2160
  * Options for {@link DocxSession.replaceTextRange}.
@@ -1258,6 +2164,10 @@ export interface ReplaceOptions {
1258
2164
  ignoreCase?: boolean;
1259
2165
  /** Cap the number of replacements; omitted = unlimited. */
1260
2166
  maxReplacements?: number;
2167
+ /** Require exactly this many occurrences before applying any replacement. */
2168
+ expectedMatchCount?: number;
2169
+ /** Optional document/anchor guards evaluated before searching. */
2170
+ preconditions?: MutationPreconditions;
1261
2171
  }
1262
2172
  /**
1263
2173
  * Categories of bracketed placeholders {@link DocxSession.findPlaceholders} recognizes.
@@ -1431,6 +2341,8 @@ export interface GrepOptions {
1431
2341
  * `contextChars`.
1432
2342
  */
1433
2343
  boundary?: number;
2344
+ /** Attach citations only if this exact registered layout is still valid. */
2345
+ citation?: PageCitationRequest;
1434
2346
  }
1435
2347
  /**
1436
2348
  * Options that tune the `findBy*` helpers on {@link DocxSession}. Mirrors the
@@ -1456,6 +2368,8 @@ export interface FindOptions {
1456
2368
  * for whole-category filtering; this is for the rare single-part case.
1457
2369
  */
1458
2370
  scopeFilter?: string;
2371
+ /** Attach citations only if this exact registered layout is still valid. */
2372
+ citation?: PageCitationRequest;
1459
2373
  }
1460
2374
  /**
1461
2375
  * Resolved location of an anchor — what {@link DocxSession.findByAnnotation} and
@@ -1470,6 +2384,8 @@ export interface AnchorTargetRef extends AnchorRef {
1470
2384
  /** Resolved auto-numbering prefix (e.g. "1.", "First") when the element carries
1471
2385
  * numbering. Absent otherwise. See {@link MarkdownAnchorTarget.autoNumberPrefix}. */
1472
2386
  autoNumberPrefix?: string;
2387
+ /** Present only when the discovery call requested an exact page citation. */
2388
+ citation?: PageCitation;
1473
2389
  }
1474
2390
  /**
1475
2391
  * The shape returned by {@link DocxSession.getAnchorInfo}.
@@ -1481,6 +2397,10 @@ export interface AnchorInfo {
1481
2397
  kind: string;
1482
2398
  scope: string;
1483
2399
  textPreview: string;
2400
+ /** Exact live subtree hash suitable for expectedContentHash. */
2401
+ contentHash: string;
2402
+ /** Exact (untruncated) reader-visible text suitable for expectedText. */
2403
+ visibleText: string;
1484
2404
  /** Resolved auto-numbering prefix (e.g. "1.", "First") when the element carries
1485
2405
  * numbering. Absent for un-numbered paragraphs or non-paragraph kinds. */
1486
2406
  autoNumberPrefix?: string;
@@ -1492,6 +2412,8 @@ export type NumberFormat = "decimal" | "upperLetter" | "lowerLetter" | "upperRom
1492
2412
  /** Numbering facts for a list-item paragraph. Returned by
1493
2413
  * {@link DocxSession.getListMembership} and surfaced as {@link BlockMetadata.list}. */
1494
2414
  export interface ListMembership {
2415
+ /** Stable paragraph anchor accepted unchanged by every list mutation method. */
2416
+ anchorId: string;
1495
2417
  /** The w:numId the paragraph belongs to (the w:num instance). */
1496
2418
  numId: number;
1497
2419
  /** The w:abstractNumId the paragraph's w:num points at. */
@@ -1506,6 +2428,14 @@ export interface ListMembership {
1506
2428
  fromStyle: boolean;
1507
2429
  /** Start-override from w:lvlOverride/w:startOverride for this level, if any. */
1508
2430
  startOverride?: number;
2431
+ /** Level definition's w:start value (1 when omitted). */
2432
+ start: number;
2433
+ /** Marker template such as "%1." or "(%2)". */
2434
+ levelText?: string;
2435
+ leftIndentTwips?: number;
2436
+ rightIndentTwips?: number;
2437
+ firstLineIndentTwips?: number;
2438
+ hangingIndentTwips?: number;
1509
2439
  /** Resolved label (e.g. "1.", "(a)") — same value surfaced via AnchorInfo.autoNumberPrefix. */
1510
2440
  generatedLabel?: string;
1511
2441
  }
@@ -1538,6 +2468,8 @@ export interface HeaderFooterRef {
1538
2468
  /** Page-layout snapshot for the w:sectPr that governs an anchor.
1539
2469
  * Returned by {@link DocxSession.getSectionInfo}. */
1540
2470
  export interface SectionInfo {
2471
+ /** Body anchor used for the lookup; accepted unchanged by section mutation methods. */
2472
+ anchorId: string;
1541
2473
  sectionUnid: string;
1542
2474
  pageWidthTwips: number;
1543
2475
  pageHeightTwips: number;
@@ -1563,6 +2495,91 @@ export interface SectionInfo {
1563
2495
  * "explicitly decimal" and avoid writing an attribute the document never had. */
1564
2496
  pageNumberFormat?: NumberFormat;
1565
2497
  }
2498
+ /** High-signal paragraph properties. Optional fields are deliberately absent when a
2499
+ * direct formatting layer did not write them; effective layers include schema defaults. */
2500
+ export interface ParagraphFormatting {
2501
+ styleId?: string;
2502
+ alignment?: "left" | "center" | "right" | "justify";
2503
+ leftIndentTwips?: number;
2504
+ rightIndentTwips?: number;
2505
+ firstLineIndentTwips?: number;
2506
+ hangingIndentTwips?: number;
2507
+ spacingBeforeTwips?: number;
2508
+ spacingAfterTwips?: number;
2509
+ lineSpacing?: number;
2510
+ lineSpacingRule?: LineSpacingRule;
2511
+ keepNext?: boolean;
2512
+ keepLines?: boolean;
2513
+ pageBreakBefore?: boolean;
2514
+ outlineLevel?: number;
2515
+ shadingFill?: string;
2516
+ topBorder?: ParagraphBorderEdge;
2517
+ bottomBorder?: ParagraphBorderEdge;
2518
+ }
2519
+ /** High-signal character properties. Nullable-at-source fields are optional on the wire so
2520
+ * an absent direct property remains distinguishable from an explicit false/zero. */
2521
+ export interface RunFormattingInfo {
2522
+ styleId?: string;
2523
+ bold?: boolean;
2524
+ italic?: boolean;
2525
+ underline?: boolean;
2526
+ underlineStyle?: string;
2527
+ strike?: boolean;
2528
+ code?: boolean;
2529
+ color?: string;
2530
+ highlight?: string;
2531
+ vertAlign?: string;
2532
+ fontSizePts?: number;
2533
+ fontFamily?: string;
2534
+ caps?: boolean;
2535
+ smallCaps?: boolean;
2536
+ hidden?: boolean;
2537
+ }
2538
+ export interface TableStyleFormatting {
2539
+ alignment?: string;
2540
+ widthTwips?: number;
2541
+ indentTwips?: number;
2542
+ layout?: string;
2543
+ hasBorders?: boolean;
2544
+ cellShadingFill?: string;
2545
+ }
2546
+ /** One explicit document style. `id` is accepted unchanged by paragraph/run style mutations. */
2547
+ export interface StyleInfo {
2548
+ id: string;
2549
+ name: string;
2550
+ type: "paragraph" | "character" | "table" | "numbering" | string;
2551
+ basedOn?: string;
2552
+ next?: string;
2553
+ isDefault: boolean;
2554
+ isCustom: boolean;
2555
+ hasLatentException: boolean;
2556
+ uiPriority?: number;
2557
+ semiHidden?: boolean;
2558
+ unhideWhenUsed?: boolean;
2559
+ quickFormat?: boolean;
2560
+ locked?: boolean;
2561
+ resolvedParagraph?: ParagraphFormatting;
2562
+ resolvedRun?: RunFormattingInfo;
2563
+ resolvedTable?: TableStyleFormatting;
2564
+ }
2565
+ /** One text-bearing run. `anchorId` + `span` can be passed unchanged to applyFormat. */
2566
+ export interface InlineSpan {
2567
+ anchorId: string;
2568
+ runUnid: string;
2569
+ span: CharSpan;
2570
+ text: string;
2571
+ direct: RunFormattingInfo;
2572
+ effective: RunFormattingInfo;
2573
+ /** Outer-to-inner native content controls containing this run. */
2574
+ contentControlAnchorIds: string[];
2575
+ }
2576
+ /** Explicitly separated direct and effective formatting for one paragraph anchor. */
2577
+ export interface FormattingInspection {
2578
+ anchorId: string;
2579
+ directParagraph: ParagraphFormatting;
2580
+ effectiveParagraph: ParagraphFormatting;
2581
+ runs: InlineSpan[];
2582
+ }
1566
2583
  /**
1567
2584
  * A custom annotation persisted in the document via Docxodus' annotation system.
1568
2585
  * Returned by {@link DocxSession.listAnnotations}; mirrors the wire-relevant
@@ -1617,61 +2634,6 @@ export declare enum ComparisonLogLevel {
1617
2634
  /** Error that may affect comparison results but didn't stop processing */
1618
2635
  Error = "Error"
1619
2636
  }
1620
- /**
1621
- * A single log entry from the comparison process.
1622
- */
1623
- export interface ComparisonLogEntry {
1624
- /** Severity level: "Info", "Warning", or "Error" */
1625
- level: ComparisonLogLevel | string;
1626
- /**
1627
- * Machine-readable code identifying the type of issue.
1628
- * Examples: "ORPHANED_FOOTNOTE_REFERENCE", "MISSING_STYLE"
1629
- */
1630
- code: string;
1631
- /** Human-readable description of the issue */
1632
- message: string;
1633
- /** Additional context or technical details (optional) */
1634
- details?: string;
1635
- /**
1636
- * Location in the document where the issue occurred (optional).
1637
- * Format: "part/xpath" e.g., "document.xml/w:footnoteReference[@w:id='3']"
1638
- */
1639
- location?: string;
1640
- }
1641
- /**
1642
- * Result from comparison operations that includes a log of warnings/errors.
1643
- */
1644
- export interface CompareResultWithLog {
1645
- /** Whether the comparison succeeded */
1646
- success: boolean;
1647
- /** The redlined document as a Uint8Array (only if success is true) */
1648
- document?: Uint8Array;
1649
- /** Error message if success is false */
1650
- error?: string;
1651
- /** Log entries from the comparison process */
1652
- log: ComparisonLogEntry[];
1653
- /** Whether the log contains any warnings */
1654
- hasWarnings: boolean;
1655
- /** Whether the log contains any errors */
1656
- hasErrors: boolean;
1657
- }
1658
- /**
1659
- * Result from HTML comparison operations that includes a log of warnings/errors.
1660
- */
1661
- export interface CompareToHtmlResultWithLog {
1662
- /** Whether the comparison succeeded */
1663
- success: boolean;
1664
- /** The HTML output (only if success is true) */
1665
- html?: string;
1666
- /** Error message if success is false */
1667
- error?: string;
1668
- /** Log entries from the comparison process */
1669
- log: ComparisonLogEntry[];
1670
- /** Whether the log contains any warnings */
1671
- hasWarnings: boolean;
1672
- /** Whether the log contains any errors */
1673
- hasErrors: boolean;
1674
- }
1675
2637
  /**
1676
2638
  * Well-known log entry codes used by the comparison engine.
1677
2639
  */
@@ -1693,34 +2655,6 @@ export declare const ComparisonLogCodes: {
1693
2655
  /** A bookmark reference has no corresponding bookmark start/end */
1694
2656
  readonly OrphanedBookmark: "ORPHANED_BOOKMARK";
1695
2657
  };
1696
- /**
1697
- * Options for revision extraction with move detection configuration.
1698
- */
1699
- export interface GetRevisionsOptions {
1700
- /**
1701
- * Whether to detect and mark moved content.
1702
- * When enabled, deletions and insertions with similar text are linked as move pairs.
1703
- * @default true
1704
- */
1705
- detectMoves?: boolean;
1706
- /**
1707
- * Jaccard similarity threshold for move detection (0.0 to 1.0).
1708
- * Higher values require more exact word overlap between deletion and insertion.
1709
- * @default 0.8
1710
- */
1711
- moveSimilarityThreshold?: number;
1712
- /**
1713
- * Minimum word count for content to be considered for move detection.
1714
- * Short phrases below this threshold are excluded to avoid false positives.
1715
- * @default 3
1716
- */
1717
- moveMinimumWordCount?: number;
1718
- /**
1719
- * Whether similarity matching ignores case differences.
1720
- * @default false
1721
- */
1722
- caseInsensitive?: boolean;
1723
- }
1724
2658
  /**
1725
2659
  * A custom annotation on a document range.
1726
2660
  */
@@ -1833,6 +2767,8 @@ export declare enum DocumentElementType {
1833
2767
  export interface DocumentElement {
1834
2768
  /** Unique element ID (path-based, e.g., "doc/tbl-0/tr-1/tc-2") */
1835
2769
  id: string;
2770
+ /** Canonical session anchor when this element is addressable. */
2771
+ anchorId?: string;
1836
2772
  /** Element type */
1837
2773
  type: DocumentElementType | string;
1838
2774
  /** Preview of text content (first ~100 characters) */
@@ -1856,10 +2792,17 @@ export interface DocumentElement {
1856
2792
  export interface TableColumnInfo {
1857
2793
  /** ID of the table this column belongs to */
1858
2794
  tableId: string;
2795
+ /** Canonical `col` anchor. */
2796
+ anchorId: string;
2797
+ /** Canonical owning `tbl` anchor. */
2798
+ tableAnchorId: string;
2799
+ isVirtual: boolean;
1859
2800
  /** Zero-based column index */
1860
2801
  columnIndex: number;
1861
2802
  /** IDs of all cells in this column */
1862
2803
  cellIds: string[];
2804
+ /** Canonical `tc` anchors for cells covering this column. */
2805
+ cellAnchorIds: string[];
1863
2806
  /** Total number of rows in this column */
1864
2807
  rowCount: number;
1865
2808
  }
@@ -2148,11 +3091,13 @@ export interface DocumentMetadata {
2148
3091
  hasComments: boolean;
2149
3092
  /** Estimated total page count (heuristic based on content volume and page sizes) */
2150
3093
  estimatedPageCount: number;
3094
+ /** Explicit provenance: always "heuristic"; use PageMap for authoritative pages. */
3095
+ estimatedPageCountSource: "heuristic";
2151
3096
  }
2152
3097
  /**
2153
3098
  * Message types sent from main thread to worker.
2154
3099
  */
2155
- export type WorkerRequestType = "init" | "convertDocxToHtml" | "compareDocuments" | "compareDocumentsToHtml" | "getRevisions" | "getDocumentMetadata" | "getVersion" | "prepare" | "sessionOpen" | "sessionClose" | "sessionAddAnnotation" | "sessionRemoveAnnotation" | "sessionUpdateAnnotation" | "sessionMoveAnnotation";
3100
+ export type WorkerRequestType = "init" | "generatePackageManifest" | "verifyDeliverable" | "proveRedlineReversibility" | "projectReviewProfile" | "convertDocxToHtml" | "compareDocuments" | "compareDocumentsToHtml" | "getSemanticChanges" | "getRevisions" | "getDocumentMetadata" | "getVersion" | "prepare" | "sessionOpen" | "sessionGetPackageManifest" | "sessionGetSemanticChanges" | "sessionVerifyDeliverable" | "sessionClose" | "sessionAddAnnotation" | "sessionRemoveAnnotation" | "sessionUpdateAnnotation" | "sessionMoveAnnotation";
2156
3101
  /**
2157
3102
  * Base structure for worker requests.
2158
3103
  */
@@ -2175,10 +3120,48 @@ export interface WorkerInitRequest extends WorkerRequestBase {
2175
3120
  */
2176
3121
  export interface WorkerConvertRequest extends WorkerRequestBase {
2177
3122
  type: "convertDocxToHtml";
2178
- /** Document bytes (transferred, not copied) */
3123
+ /** Private exact-view copy of the caller's document bytes, transferred to the worker. */
2179
3124
  documentBytes: Uint8Array;
2180
3125
  /** Conversion options */
2181
3126
  options?: ConversionOptions;
3127
+ /** Optional main-thread admission ceiling for the UTF-8 response. */
3128
+ maximumOutputBytes?: number;
3129
+ }
3130
+ /** Generate a deterministic package manifest without opening a live session. */
3131
+ export interface WorkerGeneratePackageManifestRequest extends WorkerRequestBase {
3132
+ type: "generatePackageManifest";
3133
+ documentBytes: Uint8Array;
3134
+ /** When present, these lower ceilings constrain #493 inspection itself. */
3135
+ limits?: PackageManifestInspectionLimits;
3136
+ /**
3137
+ * Which representation the caller needs. A manifest near the entry ceiling is multi-megabyte,
3138
+ * so returning both costs a parse plus a structured clone nobody reads. Defaults to `"both"`.
3139
+ */
3140
+ representation?: "object" | "json" | "both";
3141
+ }
3142
+ /** Derive exact final/original package bytes before conversion. */
3143
+ export interface WorkerProjectReviewProfileRequest extends WorkerRequestBase {
3144
+ type: "projectReviewProfile";
3145
+ documentBytes: Uint8Array;
3146
+ profile: "final" | "original";
3147
+ /** Do not transfer a derived package larger than this many bytes. */
3148
+ maximumOutputBytes?: number;
3149
+ }
3150
+ /** Run the default deliverable gate directly over exact supplied bytes. */
3151
+ export interface WorkerVerifyDeliverableRequest extends WorkerRequestBase {
3152
+ type: "verifyDeliverable";
3153
+ documentBytes: Uint8Array;
3154
+ baselineBytes?: Uint8Array;
3155
+ }
3156
+ /**
3157
+ * Prove redline accept/reject reversibility off the main thread. Three packages are inspected and
3158
+ * two are rebuilt, so this is the heaviest verification request the worker serves.
3159
+ */
3160
+ export interface WorkerProveRedlineReversibilityRequest extends WorkerRequestBase {
3161
+ type: "proveRedlineReversibility";
3162
+ baselineBytes: Uint8Array;
3163
+ intendedFinalBytes: Uint8Array;
3164
+ redlineBytes: Uint8Array;
2182
3165
  }
2183
3166
  /**
2184
3167
  * Compare two documents request.
@@ -2204,6 +3187,13 @@ export interface WorkerCompareToHtmlRequest extends WorkerRequestBase {
2204
3187
  /** Comparison options */
2205
3188
  options?: CompareOptions;
2206
3189
  }
3190
+ /** Compare two packages into the stable, versioned semantic-change schema. */
3191
+ export interface WorkerGetSemanticChangesRequest extends WorkerRequestBase {
3192
+ type: "getSemanticChanges";
3193
+ leftBytes: Uint8Array;
3194
+ rightBytes: Uint8Array;
3195
+ settings?: DocxDiffSettings;
3196
+ }
2207
3197
  /**
2208
3198
  * Get revisions from a document request.
2209
3199
  */
@@ -2211,8 +3201,6 @@ export interface WorkerGetRevisionsRequest extends WorkerRequestBase {
2211
3201
  type: "getRevisions";
2212
3202
  /** Document bytes */
2213
3203
  documentBytes: Uint8Array;
2214
- /** Revision extraction options */
2215
- options?: GetRevisionsOptions;
2216
3204
  }
2217
3205
  /**
2218
3206
  * Get document metadata for lazy loading request.
@@ -2240,11 +3228,26 @@ export interface WorkerPrepareRequest extends WorkerRequestBase {
2240
3228
  */
2241
3229
  export interface WorkerSessionOpenRequest extends WorkerRequestBase {
2242
3230
  type: "sessionOpen";
2243
- /** Document bytes transferred to the worker */
3231
+ /** Private exact-view copy of the caller's document bytes, transferred to the worker. */
2244
3232
  documentBytes: Uint8Array;
2245
3233
  /** Session settings as JSON */
2246
3234
  settingsJson?: string;
2247
3235
  }
3236
+ /** Generate a manifest from the current logical checkpoint of a worker session. */
3237
+ export interface WorkerSessionGetPackageManifestRequest extends WorkerRequestBase {
3238
+ type: "sessionGetPackageManifest";
3239
+ handle: number;
3240
+ }
3241
+ /** Compare a worker session's current checkpoint with its opening package. */
3242
+ export interface WorkerSessionGetSemanticChangesRequest extends WorkerRequestBase {
3243
+ type: "sessionGetSemanticChanges";
3244
+ handle: number;
3245
+ }
3246
+ /** Run the default deliverable gate over a worker session's clean-save checkpoint. */
3247
+ export interface WorkerSessionVerifyDeliverableRequest extends WorkerRequestBase {
3248
+ type: "sessionVerifyDeliverable";
3249
+ handle: number;
3250
+ }
2248
3251
  /**
2249
3252
  * Close a worker DocxSession.
2250
3253
  */
@@ -2295,7 +3298,7 @@ export interface WorkerSessionMoveAnnotationRequest extends WorkerRequestBase {
2295
3298
  /**
2296
3299
  * Union type of all possible worker requests.
2297
3300
  */
2298
- export type WorkerRequest = WorkerInitRequest | WorkerConvertRequest | WorkerCompareRequest | WorkerCompareToHtmlRequest | WorkerGetRevisionsRequest | WorkerGetDocumentMetadataRequest | WorkerGetVersionRequest | WorkerPrepareRequest | WorkerSessionOpenRequest | WorkerSessionCloseRequest | WorkerSessionAddAnnotationRequest | WorkerSessionRemoveAnnotationRequest | WorkerSessionUpdateAnnotationRequest | WorkerSessionMoveAnnotationRequest;
3301
+ export type WorkerRequest = WorkerInitRequest | WorkerGeneratePackageManifestRequest | WorkerVerifyDeliverableRequest | WorkerProveRedlineReversibilityRequest | WorkerProjectReviewProfileRequest | WorkerConvertRequest | WorkerCompareRequest | WorkerCompareToHtmlRequest | WorkerGetSemanticChangesRequest | WorkerGetRevisionsRequest | WorkerGetDocumentMetadataRequest | WorkerGetVersionRequest | WorkerPrepareRequest | WorkerSessionOpenRequest | WorkerSessionGetPackageManifestRequest | WorkerSessionGetSemanticChangesRequest | WorkerSessionVerifyDeliverableRequest | WorkerSessionCloseRequest | WorkerSessionAddAnnotationRequest | WorkerSessionRemoveAnnotationRequest | WorkerSessionUpdateAnnotationRequest | WorkerSessionMoveAnnotationRequest;
2299
3302
  /**
2300
3303
  * Base structure for worker responses.
2301
3304
  */
@@ -2306,7 +3309,14 @@ export interface WorkerResponseBase {
2306
3309
  success: boolean;
2307
3310
  /** Error message if success is false */
2308
3311
  error?: string;
3312
+ /**
3313
+ * Machine-readable cause when success is false. Callers classify failures from this
3314
+ * rather than by matching `error`, whose wording is not a contract.
3315
+ */
3316
+ errorCode?: WorkerErrorCode;
2309
3317
  }
3318
+ /** Closed set of machine-readable worker failure causes. */
3319
+ export type WorkerErrorCode = "resource_limit";
2310
3320
  /**
2311
3321
  * Response from init request.
2312
3322
  */
@@ -2321,6 +3331,24 @@ export interface WorkerConvertResponse extends WorkerResponseBase {
2321
3331
  /** The converted HTML string */
2322
3332
  html?: string;
2323
3333
  }
3334
+ export interface WorkerGeneratePackageManifestResponse extends WorkerResponseBase {
3335
+ type: "generatePackageManifest";
3336
+ manifest?: PackageManifest;
3337
+ /** Exact canonical JSON, retained for strict duplicate-property/schema validation. */
3338
+ manifestJson?: string;
3339
+ }
3340
+ export interface WorkerProjectReviewProfileResponse extends WorkerResponseBase {
3341
+ type: "projectReviewProfile";
3342
+ documentBytes?: Uint8Array;
3343
+ }
3344
+ export interface WorkerVerifyDeliverableResponse extends WorkerResponseBase {
3345
+ type: "verifyDeliverable";
3346
+ verification?: DeliverableVerificationResult;
3347
+ }
3348
+ export interface WorkerProveRedlineReversibilityResponse extends WorkerResponseBase {
3349
+ type: "proveRedlineReversibility";
3350
+ proof?: RedlineReversibilityProof;
3351
+ }
2324
3352
  /**
2325
3353
  * Response from compareDocuments request.
2326
3354
  */
@@ -2337,13 +3365,18 @@ export interface WorkerCompareToHtmlResponse extends WorkerResponseBase {
2337
3365
  /** The HTML string with redlines */
2338
3366
  html?: string;
2339
3367
  }
3368
+ /** Response containing the public semantic-change schema. */
3369
+ export interface WorkerGetSemanticChangesResponse extends WorkerResponseBase {
3370
+ type: "getSemanticChanges";
3371
+ semanticChanges?: SemanticChangeSet;
3372
+ }
2340
3373
  /**
2341
3374
  * Response from getRevisions request.
2342
3375
  */
2343
3376
  export interface WorkerGetRevisionsResponse extends WorkerResponseBase {
2344
3377
  type: "getRevisions";
2345
3378
  /** Array of revisions */
2346
- revisions?: Revision[];
3379
+ revisions?: RevisionListEntry[];
2347
3380
  }
2348
3381
  /**
2349
3382
  * Response from getDocumentMetadata request.
@@ -2375,6 +3408,20 @@ export interface WorkerSessionOpenResponse extends WorkerResponseBase {
2375
3408
  /** Integer handle identifying the session in the worker */
2376
3409
  handle?: number;
2377
3410
  }
3411
+ /** Response containing the current worker-session package manifest. */
3412
+ export interface WorkerSessionGetPackageManifestResponse extends WorkerResponseBase {
3413
+ type: "sessionGetPackageManifest";
3414
+ manifest?: PackageManifest;
3415
+ }
3416
+ /** Response containing a session's public semantic-change schema. */
3417
+ export interface WorkerSessionGetSemanticChangesResponse extends WorkerResponseBase {
3418
+ type: "sessionGetSemanticChanges";
3419
+ semanticChanges?: SemanticChangeSet;
3420
+ }
3421
+ export interface WorkerSessionVerifyDeliverableResponse extends WorkerResponseBase {
3422
+ type: "sessionVerifyDeliverable";
3423
+ verification?: DeliverableVerificationResult;
3424
+ }
2378
3425
  /**
2379
3426
  * Response from sessionClose request.
2380
3427
  */
@@ -2393,7 +3440,7 @@ export interface WorkerSessionEditResponse extends WorkerResponseBase {
2393
3440
  /**
2394
3441
  * Union type of all possible worker responses.
2395
3442
  */
2396
- export type WorkerResponse = WorkerInitResponse | WorkerConvertResponse | WorkerCompareResponse | WorkerCompareToHtmlResponse | WorkerGetRevisionsResponse | WorkerGetDocumentMetadataResponse | WorkerGetVersionResponse | WorkerPrepareResponse | WorkerSessionOpenResponse | WorkerSessionCloseResponse | WorkerSessionEditResponse;
3443
+ export type WorkerResponse = WorkerInitResponse | WorkerGeneratePackageManifestResponse | WorkerVerifyDeliverableResponse | WorkerProveRedlineReversibilityResponse | WorkerProjectReviewProfileResponse | WorkerConvertResponse | WorkerCompareResponse | WorkerCompareToHtmlResponse | WorkerGetSemanticChangesResponse | WorkerGetRevisionsResponse | WorkerGetDocumentMetadataResponse | WorkerGetVersionResponse | WorkerPrepareResponse | WorkerSessionOpenResponse | WorkerSessionGetPackageManifestResponse | WorkerSessionGetSemanticChangesResponse | WorkerSessionVerifyDeliverableResponse | WorkerSessionCloseResponse | WorkerSessionEditResponse;
2397
3444
  /**
2398
3445
  * Options for creating a worker-based Docxodus instance.
2399
3446
  */
@@ -2403,6 +3450,8 @@ export interface WorkerDocxodusOptions {
2403
3450
  * Defaults to auto-detection from module URL.
2404
3451
  */
2405
3452
  wasmBasePath?: string;
3453
+ /** Abort the owned worker, including an initialization that has not completed. */
3454
+ signal?: AbortSignal;
2406
3455
  }
2407
3456
  /**
2408
3457
  * OpenContracts document export format.