docxodus 9.9.0 → 10.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 (111) hide show
  1. package/README.md +178 -0
  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 +244 -3
  9. package/dist/docxodus.worker.js.map +1 -1
  10. package/dist/editor.bundle.js +1914 -419
  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 +2803 -469
  16. package/dist/embed.iife.js +2801 -467
  17. package/dist/export-assets.json +283 -0
  18. package/dist/export-browser.bundle.js +7990 -0
  19. package/dist/export-browser.d.ts +266 -0
  20. package/dist/export-browser.d.ts.map +1 -0
  21. package/dist/export-browser.js +2915 -0
  22. package/dist/export-browser.js.map +1 -0
  23. package/dist/export-resource-limits-v1.json +57 -0
  24. package/dist/font-contract.d.ts +150 -0
  25. package/dist/font-contract.d.ts.map +1 -0
  26. package/dist/font-contract.js +59 -0
  27. package/dist/font-contract.js.map +1 -0
  28. package/dist/font-runtime.d.ts +33 -0
  29. package/dist/font-runtime.d.ts.map +1 -0
  30. package/dist/font-runtime.js +1100 -0
  31. package/dist/font-runtime.js.map +1 -0
  32. package/dist/index.d.ts +62 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +130 -16
  35. package/dist/index.js.map +1 -1
  36. package/dist/page-geometry.d.ts +8 -1
  37. package/dist/page-geometry.d.ts.map +1 -1
  38. package/dist/page-geometry.js +37 -11
  39. package/dist/page-geometry.js.map +1 -1
  40. package/dist/pagination.bundle.js +1827 -410
  41. package/dist/pagination.d.ts +249 -15
  42. package/dist/pagination.d.ts.map +1 -1
  43. package/dist/pagination.js +1942 -453
  44. package/dist/pagination.js.map +1 -1
  45. package/dist/react.d.ts +11 -4
  46. package/dist/react.d.ts.map +1 -1
  47. package/dist/react.js +38 -5
  48. package/dist/react.js.map +1 -1
  49. package/dist/render-report-v2.schema.json +1581 -0
  50. package/dist/ribbon-chrome.d.ts +1 -1
  51. package/dist/ribbon-chrome.d.ts.map +1 -1
  52. package/dist/ribbon-chrome.js +45 -0
  53. package/dist/ribbon-chrome.js.map +1 -1
  54. package/dist/ribbon.js +70 -0
  55. package/dist/ribbon.js.map +1 -1
  56. package/dist/session.bundle.js +695 -29
  57. package/dist/session.d.ts +134 -19
  58. package/dist/session.d.ts.map +1 -1
  59. package/dist/session.js +562 -25
  60. package/dist/session.js.map +1 -1
  61. package/dist/types.d.ts +1207 -16
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/types.js.map +1 -1
  64. package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm +0 -0
  65. package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm.br +0 -0
  66. package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm +0 -0
  67. package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm.br +0 -0
  68. package/dist/wasm/_framework/Docxodus.wasm +0 -0
  69. package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
  70. package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
  71. package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
  72. package/dist/wasm/_framework/System.Collections.Concurrent.wasm +0 -0
  73. package/dist/wasm/_framework/System.Collections.Concurrent.wasm.br +0 -0
  74. package/dist/wasm/_framework/System.Collections.Immutable.wasm +0 -0
  75. package/dist/wasm/_framework/System.Collections.Immutable.wasm.br +0 -0
  76. package/dist/wasm/_framework/System.Collections.wasm +0 -0
  77. package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
  78. package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
  79. package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
  80. package/dist/wasm/_framework/System.IO.Packaging.wasm +0 -0
  81. package/dist/wasm/_framework/System.IO.Packaging.wasm.br +0 -0
  82. package/dist/wasm/_framework/System.Linq.wasm +0 -0
  83. package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
  84. package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
  85. package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
  86. package/dist/wasm/_framework/System.Private.Uri.wasm +0 -0
  87. package/dist/wasm/_framework/System.Private.Uri.wasm.br +0 -0
  88. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
  89. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
  90. package/dist/wasm/_framework/System.Private.Xml.wasm +0 -0
  91. package/dist/wasm/_framework/System.Private.Xml.wasm.br +0 -0
  92. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  93. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm.br +0 -0
  94. package/dist/wasm/_framework/System.Runtime.wasm +0 -0
  95. package/dist/wasm/_framework/System.Runtime.wasm.br +0 -0
  96. package/dist/wasm/_framework/System.Security.Cryptography.wasm +0 -0
  97. package/dist/wasm/_framework/System.Security.Cryptography.wasm.br +0 -0
  98. package/dist/wasm/_framework/System.Text.Json.wasm +0 -0
  99. package/dist/wasm/_framework/System.Text.Json.wasm.br +0 -0
  100. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
  101. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
  102. package/dist/wasm/_framework/dotnet.boot.js +21 -21
  103. package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
  104. package/dist/wasm/_framework/dotnet.native.wasm +0 -0
  105. package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
  106. package/dist/worker-proxy.bundle.js +196 -29
  107. package/dist/worker-proxy.d.ts +36 -3
  108. package/dist/worker-proxy.d.ts.map +1 -1
  109. package/dist/worker-proxy.js +186 -33
  110. package/dist/worker-proxy.js.map +1 -1
  111. package/package.json +22 -6
package/dist/types.d.ts CHANGED
@@ -529,6 +529,80 @@ export interface DocxDiffRevision {
529
529
  * also set for a token-level delete inside a modified block; undefined for a whole-block deletion. */
530
530
  rightAnchor?: string;
531
531
  }
532
+ /** A data product selectable in `docxDiffCompareProducts`. */
533
+ export type DocxDiffProduct = "redline" | "revisions" | "editScript" | "semanticChanges";
534
+ /**
535
+ * The requested products of ONE memoized comparison pass, from
536
+ * `docxDiffCompareProducts` (issue #594). Unrequested products are undefined.
537
+ * Each present product equals what the corresponding standalone function
538
+ * returns for the same inputs and settings — except `editScript`, which is
539
+ * handed over parsed (the standalone `docxDiffGetEditScript` returns the
540
+ * serialized string).
541
+ */
542
+ export interface DocxDiffProducts {
543
+ /** The native tracked-changes redline (what `docxDiffCompare` returns). */
544
+ redline?: Uint8Array;
545
+ /** The anchor-addressed revision list (what `docxDiffGetRevisions` returns). */
546
+ revisions?: DocxDiffRevision[];
547
+ /** The engine's edit script, parsed. */
548
+ editScript?: Record<string, unknown>;
549
+ /** The stable semantic-change schema (what `docxDiffGetSemanticChanges` returns). */
550
+ semanticChanges?: SemanticChangeSet;
551
+ }
552
+ /** Stable v1 operation names emitted by the semantic-change schema. */
553
+ export type SemanticChangeOperation = "insert" | "delete" | "move" | "modify";
554
+ /** Stable v1 semantic families. New schema versions may append families. */
555
+ 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";
556
+ /**
557
+ * Closed typed value used in {@link SemanticChange.before} and `after`.
558
+ * Schema v1 integers stay within `Number.MIN_SAFE_INTEGER..Number.MAX_SAFE_INTEGER`; a document
559
+ * value outside that range arrives as a decimal `string` rather than a rounded `integer`.
560
+ */
561
+ export type SemanticValue = {
562
+ kind: "absent";
563
+ } | {
564
+ kind: "string";
565
+ value: string;
566
+ } | {
567
+ kind: "boolean";
568
+ value: boolean;
569
+ } | {
570
+ kind: "integer";
571
+ value: number;
572
+ } | {
573
+ kind: "digest";
574
+ algorithm: string;
575
+ profile: string | null;
576
+ value: string;
577
+ } | {
578
+ kind: "object";
579
+ value: Record<string, SemanticValue>;
580
+ } | {
581
+ kind: "array";
582
+ value: SemanticValue[];
583
+ };
584
+ /** One deterministic, anchor-addressed semantic change. */
585
+ export interface SemanticChange {
586
+ id: string;
587
+ operation: SemanticChangeOperation;
588
+ family: SemanticChangeFamily;
589
+ partUri: string;
590
+ path: string;
591
+ leftAnchor: string | null;
592
+ rightAnchor: string | null;
593
+ leftScope: string | null;
594
+ rightScope: string | null;
595
+ moveId: string | null;
596
+ before: SemanticValue;
597
+ after: SemanticValue;
598
+ }
599
+ /** Public `docxodus.semantic-changes` schema returned by semantic comparison APIs. */
600
+ export interface SemanticChangeSet {
601
+ schema: "docxodus.semantic-changes";
602
+ schemaVersion: 1;
603
+ changeCount: number;
604
+ changes: SemanticChange[];
605
+ }
532
606
  /**
533
607
  * How overlapping reviewer edits at the same base token span are resolved.
534
608
  * Integer values match the .NET `ConflictResolution` enum positions.
@@ -706,11 +780,385 @@ export interface CompareResult {
706
780
  /** List of revisions found */
707
781
  revisions: Revision[];
708
782
  }
783
+ /** Algorithm-labelled digest in a verification artifact. */
784
+ export interface VerificationDigest {
785
+ algorithm: string;
786
+ /** Lower-case hexadecimal digest bytes. */
787
+ value: string;
788
+ }
789
+ /** Stable package location attached to a verification finding. */
790
+ export interface ChangeLocation {
791
+ entryUri: string | null;
792
+ ownerUri: string | null;
793
+ relationshipId: string | null;
794
+ targetUri: string | null;
795
+ propertyPath: string | null;
796
+ }
797
+ export type VerificationFindingSeverity = "info" | "warning" | "error";
798
+ /** Machine-readable package validation or safety finding. */
799
+ export interface VerificationFinding {
800
+ code: string;
801
+ severity: VerificationFindingSeverity;
802
+ message: string;
803
+ location: ChangeLocation | null;
804
+ }
805
+ /** One physical ZIP entry. Duplicate names remain separate occurrences. */
806
+ export interface PackageManifestEntry {
807
+ uri: string;
808
+ occurrence: number;
809
+ contentType: string | null;
810
+ contentTypeSource: "override" | "default" | "implicit" | "unresolved";
811
+ /** Exact declared uncompressed byte length as a base-10 integer string. */
812
+ size: string;
813
+ /** Exact compressed ZIP byte length as a base-10 integer string. */
814
+ compressedSize: string;
815
+ rawBytesDigest: VerificationDigest | null;
816
+ normalizedXmlDigest: VerificationDigest | null;
817
+ isXml: boolean;
818
+ /** null when central-directory encryption flags could not be parsed authoritatively. */
819
+ isEncrypted: boolean | null;
820
+ }
821
+ export interface PackageContentTypeDeclaration {
822
+ kind: "default" | "override";
823
+ key: string;
824
+ contentType: string;
825
+ occurrence: number;
826
+ }
827
+ export interface PackageRelationship {
828
+ ownerUri: string;
829
+ id: string;
830
+ type: string;
831
+ target: string;
832
+ targetMode: "Internal" | "External";
833
+ resolvedTargetUri: string | null;
834
+ isTargetPresent: boolean | null;
835
+ }
836
+ export interface PackageRevisionCounts {
837
+ insertions: number;
838
+ deletions: number;
839
+ moveFrom: number;
840
+ moveTo: number;
841
+ propertyChanges: number;
842
+ /** The `rPrChange` subset of `propertyChanges`; not added into `total`. */
843
+ runPropertyChanges: number;
844
+ structuralChanges: number;
845
+ otherChanges: number;
846
+ total: number;
847
+ }
848
+ export interface PackageAnnotationCounts {
849
+ comments: number;
850
+ commentReplies: number;
851
+ threadedCommentMetadata: number;
852
+ resolvedComments: number;
853
+ people: number;
854
+ docxodusAnnotations: number;
855
+ }
856
+ export interface PackageManifestFacts {
857
+ mainDocumentUri: string | null;
858
+ isStrictOoxml: boolean;
859
+ isMacroEnabled: boolean;
860
+ hasCoreProperties: boolean;
861
+ hasExtendedProperties: boolean;
862
+ hasCustomProperties: boolean;
863
+ sectionCount: number;
864
+ paragraphCount: number;
865
+ tableCount: number;
866
+ headerPartCount: number;
867
+ footerPartCount: number;
868
+ footnoteCount: number;
869
+ endnoteCount: number;
870
+ styleCount: number;
871
+ numberingDefinitionCount: number;
872
+ themePartCount: number;
873
+ mediaPartCount: number;
874
+ customXmlPartCount: number;
875
+ drawingCount: number;
876
+ altChunkCount: number;
877
+ fieldCount: number;
878
+ revisions: PackageRevisionCounts;
879
+ annotations: PackageAnnotationCounts;
880
+ }
881
+ /** Deterministic schema-v1 description of a DOCX/OPC package. */
882
+ export interface PackageManifest {
883
+ schema: "https://docxodus.dev/schemas/verification/package-manifest/v1";
884
+ schemaVersion: 1;
885
+ packageKind: "opc" | "zip" | "zip-encrypted" | "ole-encrypted" | "ole" | "malformed";
886
+ isValid: boolean;
887
+ rawPackageBytesDigest: VerificationDigest;
888
+ orderedOpcContentDigest: VerificationDigest | null;
889
+ normalizedSemanticDigest: VerificationDigest | null;
890
+ entries: readonly PackageManifestEntry[];
891
+ contentTypes: readonly PackageContentTypeDeclaration[];
892
+ relationships: readonly PackageRelationship[];
893
+ facts: PackageManifestFacts;
894
+ findings: readonly VerificationFinding[];
895
+ }
896
+ /** Policy preset used by the default deliverable gate. */
897
+ export type DeliverableVerificationMode = "standard" | "strict" | "reportOnly";
898
+ /** Final policy decision in a deliverable-verification report. */
899
+ export type DeliverableVerificationDecision = "passed" | "passedWithPreExistingFindings" | "failed" | "notEvaluated";
900
+ /** How a delivered finding relates to the exact opening/baseline package. */
901
+ export type DeliverableFindingDisposition = "new" | "preExisting" | "resolved" | "unclassified";
902
+ export type DeliverableFindingCategory = "package" | "openXml" | "relationship" | "structure" | "workflow" | "delta" | "render" | "artifact";
903
+ export type DeliverableCheckStatus = "completed" | "skippedPrerequisiteFailed" | "unavailableEvidence";
904
+ export type DeliverablePackageChangeKind = "entryAdded" | "entryRemoved" | "entryModified" | "relationshipAdded" | "relationshipRemoved" | "relationshipModified";
905
+ export type DeliverableArtifactRole = "html" | "pdf" | "pageMap" | "pageImage" | "renderReport" | "other";
906
+ export type DeliverableArtifactAvailability = "available" | "unavailable";
907
+ /** Camel-case enum values used by the deliverable report's semantic summary. */
908
+ 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";
909
+ export interface DeliverablePackageIdentity {
910
+ packageKind: string;
911
+ manifestValid: boolean;
912
+ rawPackageBytesDigest: VerificationDigest;
913
+ orderedOpcContentDigest: VerificationDigest | null;
914
+ normalizedSemanticDigest: VerificationDigest | null;
915
+ }
916
+ export interface DeliverableCheckResult {
917
+ check: string;
918
+ status: DeliverableCheckStatus;
919
+ findingCount: number;
920
+ diagnostic: string | null;
921
+ }
922
+ export interface DeliverableFinding {
923
+ findingId: string;
924
+ code: string;
925
+ category: DeliverableFindingCategory;
926
+ severity: VerificationFindingSeverity;
927
+ disposition: DeliverableFindingDisposition;
928
+ blocksDelivery: boolean;
929
+ message: string;
930
+ owningPartUri: string;
931
+ location: ChangeLocation | null;
932
+ anchorId: string | null;
933
+ scope: string | null;
934
+ xPath: string | null;
935
+ remediation: string;
936
+ }
937
+ export interface DeliverablePackageChange {
938
+ changeId: string;
939
+ kind: DeliverablePackageChangeKind;
940
+ location: ChangeLocation;
941
+ beforeDigest: VerificationDigest | null;
942
+ afterDigest: VerificationDigest | null;
943
+ beforeValue: string | null;
944
+ afterValue: string | null;
945
+ }
946
+ export interface DeliverableSemanticChange {
947
+ changeId: string;
948
+ fingerprint: string;
949
+ operation: SemanticChangeOperation;
950
+ family: DeliverableSemanticChangeFamily;
951
+ partUri: string;
952
+ path: string;
953
+ leftAnchor: string | null;
954
+ rightAnchor: string | null;
955
+ }
956
+ export interface DeliverableSemanticDelta {
957
+ schema: "docxodus.semantic-changes";
958
+ schemaVersion: 1;
959
+ changeCount: number;
960
+ canonicalDigest: VerificationDigest;
961
+ changes: readonly DeliverableSemanticChange[];
962
+ }
963
+ export interface DeliverableArtifactMetadata {
964
+ artifactId: string;
965
+ role: DeliverableArtifactRole;
966
+ mediaType: string;
967
+ availability: DeliverableArtifactAvailability;
968
+ byteLength: number | null;
969
+ digest: VerificationDigest | null;
970
+ unavailableReason: string | null;
971
+ pageCount: number | null;
972
+ rendererFingerprint: string | null;
973
+ sourcePackageDigest: VerificationDigest | null;
974
+ pageMapDigest: VerificationDigest | null;
975
+ renderDiagnosticCount: number;
976
+ }
977
+ /** Canonical schema-v1 report returned by every default verification transport. */
978
+ /** One recorded artifact's independent re-hash verdict from receipt verification. */
979
+ export type DeliveryArtifactVerificationStatus = "verified" | "unavailable" | "missing" | "length_mismatch" | "digest_mismatch" | "invalid_record";
980
+ export interface DeliveryArtifactVerification {
981
+ artifactId: string;
982
+ status: DeliveryArtifactVerificationStatus;
983
+ expectedLength?: number;
984
+ actualLength?: number;
985
+ expectedDigest?: VerificationDigest;
986
+ actualDigest?: VerificationDigest;
987
+ }
988
+ /**
989
+ * Portable delivery change receipt verification verdict — the shared facade wire
990
+ * shape every transport returns (issue #520).
991
+ */
992
+ export interface DeliveryReceiptVerificationResult {
993
+ isValid: boolean;
994
+ receiptDigestValid: boolean;
995
+ contractValid: boolean;
996
+ citationBindingsValid: boolean;
997
+ artifacts: DeliveryArtifactVerification[];
998
+ findings: string[];
999
+ }
1000
+ export interface DeliverableVerificationResult {
1001
+ schema: "https://docxodus.dev/schemas/verification/deliverable-verification/v1";
1002
+ schemaVersion: 1;
1003
+ mode: DeliverableVerificationMode;
1004
+ decision: DeliverableVerificationDecision;
1005
+ analysisCompleted: boolean;
1006
+ baselineCompared: boolean;
1007
+ baselinePackage: DeliverablePackageIdentity | null;
1008
+ deliverablePackage: DeliverablePackageIdentity;
1009
+ checks: readonly DeliverableCheckResult[];
1010
+ findings: readonly DeliverableFinding[];
1011
+ resolvedFindings: readonly DeliverableFinding[];
1012
+ semanticDelta: DeliverableSemanticDelta | null;
1013
+ packageChanges: readonly DeliverablePackageChange[];
1014
+ companionArtifacts: readonly DeliverableArtifactMetadata[];
1015
+ }
1016
+ /** How a revision in a redline relates to the selected baseline. */
1017
+ export type RedlineRevisionDisposition = "preExisting" | "intendedFinalPreExisting" | "generated" | "conflicted";
1018
+ /** Which of the two proof paths a result or finding belongs to. */
1019
+ export type RedlineProofDirection = "acceptToFinal" | "rejectToBaseline";
1020
+ /** How a package entry differs from a path's expected document. */
1021
+ export type RedlinePackageDivergenceKind = "added" | "removed" | "modified";
1022
+ /** Fail-closed resolution status of one native revision — the session registry's vocabulary. */
1023
+ export type RedlineRevisionResolutionStatus = RevisionResolutionStatus;
1024
+ /** Coarse family of one native revision. */
1025
+ export type RedlineRevisionFamily = "contentInsert" | "contentDelete" | "move" | "paragraphMark" | "rowInsert" | "rowDelete" | "cellInsert" | "cellDelete" | "cellMerge" | "contentControlInsert" | "contentControlDelete" | "numberingPropertiesInsert" | "numberingChange" | "propertiesChange" | "unsupported";
1026
+ /** Why a revision could not be resolved — the session registry's shape. */
1027
+ export type RedlineRevisionDiagnostic = RevisionDiagnostic;
1028
+ /** Input or output package identity recorded by the proof. */
1029
+ export interface RedlineProofPackageIdentity {
1030
+ rawPackageBytesDigest: VerificationDigest;
1031
+ orderedOpcContentDigest: VerificationDigest | null;
1032
+ normalizedWholePackageDigest: VerificationDigest | null;
1033
+ }
1034
+ /** A stable, part-qualified identity for one native Word revision. */
1035
+ export interface RedlineRevisionIdentity {
1036
+ id: string;
1037
+ partUri: string;
1038
+ scope: string;
1039
+ type: string;
1040
+ family: RedlineRevisionFamily;
1041
+ constituentIds: readonly string[];
1042
+ constituentKeys: readonly string[];
1043
+ author: string;
1044
+ date: string | null;
1045
+ dateUtc: string | null;
1046
+ text: string;
1047
+ anchorId: string | null;
1048
+ affectedAnchorIds: readonly string[];
1049
+ resolutionStatus: RedlineRevisionResolutionStatus;
1050
+ diagnostic: RedlineRevisionDiagnostic | null;
1051
+ }
1052
+ /** Classification of a baseline/intended-final/redline revision identity triple. */
1053
+ export interface RedlineRevisionClassification {
1054
+ disposition: RedlineRevisionDisposition;
1055
+ baseline: RedlineRevisionIdentity | null;
1056
+ intendedFinal: RedlineRevisionIdentity | null;
1057
+ redline: RedlineRevisionIdentity | null;
1058
+ reason: string;
1059
+ }
1060
+ /**
1061
+ * Modeled semantic comparison for one path. `available` and `changeCount` are explicit so an
1062
+ * empty modeled change set is never mistaken for complete package equality.
1063
+ */
1064
+ export interface RedlineModeledSemanticComparison {
1065
+ available: boolean;
1066
+ equivalent: boolean | null;
1067
+ schema: string | null;
1068
+ changeCount: number | null;
1069
+ diagnostic: string | null;
1070
+ }
1071
+ /** One added, removed, or modified package entry on a proof path. */
1072
+ export interface RedlinePackageDivergence {
1073
+ kind: RedlinePackageDivergenceKind;
1074
+ partUri: string;
1075
+ occurrence: number;
1076
+ anchorId: string | null;
1077
+ applicableRevisionIds: readonly string[];
1078
+ expectedRawDigest: VerificationDigest | null;
1079
+ actualRawDigest: VerificationDigest | null;
1080
+ expectedNormalizedDigest: VerificationDigest | null;
1081
+ actualNormalizedDigest: VerificationDigest | null;
1082
+ /** Whether the semantic change set reports a modeled change for this part. */
1083
+ hasModeledSemanticChange: boolean;
1084
+ /**
1085
+ * Conservatively true when the normalized difference may contain content outside the modeled
1086
+ * semantic projection. A modeled change in one part never proves every change in it was modeled.
1087
+ */
1088
+ unknownOrUnmodeled: boolean;
1089
+ }
1090
+ /** A structured, actionable proof finding. */
1091
+ export interface RedlineProofFinding {
1092
+ code: string;
1093
+ severity: VerificationFindingSeverity;
1094
+ message: string;
1095
+ direction: RedlineProofDirection | null;
1096
+ location: ChangeLocation | null;
1097
+ anchorId: string | null;
1098
+ revisionIds: readonly string[];
1099
+ remediation: string | null;
1100
+ }
1101
+ /** Result of accepting or rejecting only the generated revision set. */
1102
+ export interface RedlineProofPathResult {
1103
+ direction: RedlineProofDirection;
1104
+ completed: boolean;
1105
+ equivalent: boolean;
1106
+ requestedRevisionIds: readonly string[];
1107
+ resolvedRevisionIds: readonly string[];
1108
+ implicitlyResolvedRevisionIds: readonly string[];
1109
+ survivingPreExistingRevisions: readonly RedlineRevisionIdentity[];
1110
+ preExistingRevisionsPreserved: boolean;
1111
+ modeledSemantic: RedlineModeledSemanticComparison;
1112
+ normalizedWholePackageEquivalent: boolean;
1113
+ orderedOpcContentEquivalent: boolean;
1114
+ exactPackageBytesEquivalent: boolean;
1115
+ /**
1116
+ * Whether the complete bounded package delta was available. A false value never exposes a
1117
+ * potentially misleading prefix of `divergences`.
1118
+ */
1119
+ divergenceAnalysisCompleted: boolean;
1120
+ expectedPackage: RedlineProofPackageIdentity;
1121
+ actualPackage: RedlineProofPackageIdentity | null;
1122
+ firstDivergence: RedlinePackageDivergence | null;
1123
+ divergences: readonly RedlinePackageDivergence[];
1124
+ findings: readonly RedlineProofFinding[];
1125
+ }
1126
+ /**
1127
+ * Canonical schema-v1 proof that a redline's generated changes accept to the intended final and
1128
+ * reject to the baseline without consuming pre-existing review state.
1129
+ */
1130
+ export interface RedlineReversibilityProof {
1131
+ schema: "https://docxodus.dev/schemas/verification/redline-reversibility-proof/v1";
1132
+ schemaVersion: 1;
1133
+ success: boolean;
1134
+ requireExactPackageBytes: boolean;
1135
+ baselinePackage: RedlineProofPackageIdentity;
1136
+ intendedFinalPackage: RedlineProofPackageIdentity;
1137
+ redlinePackage: RedlineProofPackageIdentity;
1138
+ revisionClassifications: readonly RedlineRevisionClassification[];
1139
+ acceptToFinal: RedlineProofPathResult | null;
1140
+ rejectToBaseline: RedlineProofPathResult | null;
1141
+ findings: readonly RedlineProofFinding[];
1142
+ }
1143
+ /** Effective #493 inspection limits applied while the manifest is being generated. */
1144
+ export interface PackageManifestInspectionLimits {
1145
+ opcEntries: number;
1146
+ expandedOpcBytes: number;
1147
+ xmlPartBytes: number;
1148
+ opcUriCharacters: number;
1149
+ opcCompressionRatio: number;
1150
+ }
709
1151
  /**
710
1152
  * Internal WASM exports structure
711
1153
  */
712
1154
  export interface DocxodusWasmExports {
713
1155
  DocumentConverter: {
1156
+ GeneratePackageManifest: (bytes: Uint8Array) => string;
1157
+ VerifyDeliverable: (bytes: Uint8Array) => string;
1158
+ VerifyDeliveryReceipt: (receiptJson: string, artifactsJson: string) => string;
1159
+ VerifyDeliverableWithBaseline: (baselineBytes: Uint8Array, bytes: Uint8Array) => string;
1160
+ ProveRedlineReversibility: (baselineBytes: Uint8Array, intendedFinalBytes: Uint8Array, redlineBytes: Uint8Array) => string;
1161
+ GeneratePackageManifestWithOptions: (bytes: Uint8Array, maxEntryCount: number, maxTotalUncompressedBytes: number, maxXmlPartBytes: number, maxCompressionRatio: number, maxUriLength: number) => string;
714
1162
  ConvertDocxToHtml: (bytes: Uint8Array) => string;
715
1163
  RenderBlockHtml: (bytes: Uint8Array, anchorId: string, cssPrefix: string, fabricateClasses: boolean) => string;
716
1164
  ConvertDocxToHtmlWithOptions: (bytes: Uint8Array, pageTitle: string, cssPrefix: string, fabricateClasses: boolean, additionalCss: string, commentRenderMode: number, commentCssClassPrefix: string) => string;
@@ -764,6 +1212,11 @@ export interface DocxodusWasmExports {
764
1212
  GetRevisionsJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
765
1213
  /** Edit-script JSON (diff-as-data), or a JSON error object. */
766
1214
  GetEditScriptJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
1215
+ /** Canonical `docxodus.semantic-changes` JSON, or a JSON error object. */
1216
+ GetSemanticChangesJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string) => string;
1217
+ /** One memoized pass, every requested product: `{"redlineB64":…, "revisions":[…],
1218
+ * "editScript":…, "semanticChanges":…}` JSON (issue #594), or a JSON error object. */
1219
+ CompareProductsJson: (leftBytes: Uint8Array, rightBytes: Uint8Array, settingsJson: string, productsJson: string) => string;
767
1220
  /** Accept all tracked revisions in a redlined DOCX → "right"-side bytes, or empty array on error. */
768
1221
  AcceptRevisions: (bytes: Uint8Array) => Uint8Array;
769
1222
  /** Reject all tracked revisions in a redlined DOCX → "left"-side bytes, or empty array on error. */
@@ -779,10 +1232,24 @@ export interface DocxodusWasmExports {
779
1232
  };
780
1233
  DocxSessionBridge: {
781
1234
  OpenSession: (bytes: Uint8Array, settingsJson: string) => number;
1235
+ OpenPreviewSession?: (liveHandle: number) => number;
782
1236
  CloseSession: (handle: number) => void;
783
1237
  CreateBlankDocx: () => Uint8Array;
784
1238
  Project: (handle: number) => string;
1239
+ GetVersion: (handle: number) => string;
1240
+ RegisterPageMap: (handle: number, pageMapJson: string, expectedRendererFingerprint: string) => string;
1241
+ GetPageMapStatus: (handle: number, requestJson: string) => string;
1242
+ GetPageCitation: (handle: number, anchorId: string, requestJson: string) => string;
1243
+ GetPackageContentHash?: (handle: number) => string;
1244
+ GetPackageManifest: (handle: number) => string;
1245
+ RenderPreviewHtml?: (handle: number) => string;
1246
+ RenderPreviewBlockHtml?: (handle: number, anchorId: string) => string;
1247
+ CheckPreconditions: (handle: number, preconditionsJson: string) => string;
1248
+ BeginTransaction: (handle: number) => number;
1249
+ CommitTransaction: (transactionHandle: number) => void;
1250
+ RollbackTransaction: (transactionHandle: number) => void;
785
1251
  ProjectAnchor: (handle: number, anchorId: string, depth: number) => string;
1252
+ ProjectAnchorWithCitations: (handle: number, anchorId: string, depth: number, requestJson: string) => string;
786
1253
  /** Ordered top-level render units per scope container (JSON {@link RenderPlan}) —
787
1254
  * what the editor's incremental reconciler diffs its DOM against. Optional:
788
1255
  * absent on older WASM bundles. */
@@ -822,6 +1289,9 @@ export interface DocxodusWasmExports {
822
1289
  MergeParagraphs: (handle: number, first: string, second: string) => string;
823
1290
  InsertHorizontalRule: (handle: number, anchor: string, pos: string, ruleJson: string) => string;
824
1291
  InsertTable: (handle: number, anchor: string, pos: string, rows: number, cols: number, optionsJson: string) => string;
1292
+ GetTableMetadata: (handle: number, tableAnchor: string) => string;
1293
+ ResolveTableCellAnchor: (handle: number, cellAnchor: string) => string;
1294
+ ResolveTableCellCoordinate: (handle: number, tableAnchor: string, rowIndex: number, columnIndex: number) => string;
825
1295
  InsertTableRow: (handle: number, cellAnchor: string, pos: string) => string;
826
1296
  InsertTableColumn: (handle: number, cellAnchor: string, pos: string) => string;
827
1297
  DeleteTableRow: (handle: number, cellAnchor: string) => string;
@@ -832,6 +1302,7 @@ export interface DocxodusWasmExports {
832
1302
  SetTableBorders: (handle: number, cellAnchor: string, specJson: string) => string;
833
1303
  SetCellShading: (handle: number, cellAnchor: string, fill: string, scope: string) => string;
834
1304
  SetRepeatHeaderRow: (handle: number, cellAnchor: string, repeat: boolean) => string;
1305
+ SetTableRowOptions: (handle: number, cellAnchor: string, repeatHeader: boolean | null, allowBreakAcrossPages: boolean | null, heightTwips: number | null, heightRule: string) => string;
835
1306
  SetHeaderText: (handle: number, anchor: string, kind: string, markdown: string) => string;
836
1307
  SetFooterText: (handle: number, anchor: string, kind: string, markdown: string) => string;
837
1308
  InsertPageNumberField: (handle: number, anchor: string, field: string, format: string) => string;
@@ -839,6 +1310,7 @@ export interface DocxodusWasmExports {
839
1310
  ClearPageNumbering: (handle: number, anchor: string) => string;
840
1311
  EnsureHeaderFooterVisible: (handle: number, anchor: string, kind: string) => string;
841
1312
  InsertFootnote: (handle: number, anchor: string, characterOffset: number, markdown: string) => string;
1313
+ InsertCrossReference: (handle: number, anchor: string, characterOffset: number, bookmarkName: string, optionsJson: string) => string;
842
1314
  InsertEndnote: (handle: number, anchor: string, characterOffset: number, markdown: string) => string;
843
1315
  AddComment: (handle: number, anchor: string, spanJson: string, author: string, initials: string, date: string, markdown: string) => string;
844
1316
  AddCommentToRevision: (handle: number, revisionId: string, author: string, initials: string, date: string, markdown: string) => string;
@@ -847,9 +1319,37 @@ export interface DocxodusWasmExports {
847
1319
  SetCommentResolved: (handle: number, commentAnchor: string, resolved: boolean) => string;
848
1320
  RemoveComment: (handle: number, commentAnchor: string) => string;
849
1321
  ListComments: (handle: number) => string;
1322
+ ListHyperlinks: (handle: number, scopes: number) => string;
1323
+ AddHyperlink: (handle: number, anchor: string, start: number, length: number, kind: string, target: string) => string;
1324
+ UpdateHyperlink: (handle: number, hyperlinkId: string, kind: string, target: string) => string;
1325
+ RemoveHyperlink: (handle: number, hyperlinkId: string) => string;
1326
+ GetImageCapabilities: () => string;
1327
+ ListImages: (handle: number, scopes: number) => string;
1328
+ InsertImage: (handle: number, anchor: string, characterOffset: number, imageBase64: string, optionsJson: string) => string;
1329
+ ReplaceImage: (handle: number, imageId: string, imageBase64: string) => string;
1330
+ SetImageDimensions: (handle: number, imageId: string, dimensionsJson: string) => string;
1331
+ SetImageMetadata: (handle: number, imageId: string, altText: string | null, title: string | null) => string;
1332
+ SetImageFloatingLayout: (handle: number, imageId: string, layoutJson: string) => string;
1333
+ RemoveImage: (handle: number, imageId: string) => string;
1334
+ ListContentControls: (handle: number, scopes: number) => string;
1335
+ FillContentControlText: (handle: number, anchorId: string, text: string, optionsJson: string) => string;
1336
+ FillContentControlRichText: (handle: number, anchorId: string, markdown: string, optionsJson: string) => string;
1337
+ SetContentControlChecked: (handle: number, anchorId: string, isChecked: boolean, optionsJson: string) => string;
1338
+ SetContentControlDate: (handle: number, anchorId: string, value: string, displayText: string | null, optionsJson: string) => string;
1339
+ SelectContentControlItem: (handle: number, anchorId: string, value: string, optionsJson: string) => string;
1340
+ FillContentControlPicture: (handle: number, anchorId: string, imageBase64: string, optionsJson: string) => string;
1341
+ AddRepeatingSectionItem: (handle: number, sectionAnchorId: string, afterItemAnchorId: string, optionsJson: string) => string;
1342
+ RemoveRepeatingSectionItem: (handle: number, itemAnchorId: string) => string;
1343
+ ListBookmarks: (handle: number, scopes: number) => string;
1344
+ AddBookmark: (handle: number, name: string, startAnchor: string, startOffset: number, endAnchor: string, endOffset: number) => string;
1345
+ RenameBookmark: (handle: number, name: string, newName: string) => string;
1346
+ MoveBookmark: (handle: number, name: string, startAnchor: string, startOffset: number, endAnchor: string, endOffset: number) => string;
1347
+ RemoveBookmark: (handle: number, name: string) => string;
850
1348
  ListRevisions: (handle: number) => string;
851
1349
  AcceptRevision: (handle: number, revisionId: string) => string;
852
1350
  RejectRevision: (handle: number, revisionId: string) => string;
1351
+ AcceptAllRevisions: (handle: number) => string;
1352
+ RejectAllRevisions: (handle: number) => string;
853
1353
  ApplyFormat: (handle: number, anchor: string, spanJson: string, opJson: string) => string;
854
1354
  ApplyFormatBySubstring: (handle: number, anchor: string, substring: string, opJson: string) => string;
855
1355
  SetParagraphStyle: (handle: number, anchor: string, styleId: string) => string;
@@ -870,23 +1370,33 @@ export interface DocxodusWasmExports {
870
1370
  ReplaceTextAtSpan: (handle: number, anchor: string, spanStart: number, spanLength: number, replace: string) => string;
871
1371
  ReplaceInner: (handle: number, matchText: string, anchor: string, spanStart: number, spanLength: number, newInner: string) => string;
872
1372
  FindPlaceholders: (handle: number, kinds: number, scope: number, contextChars: number, boundary: number) => string;
1373
+ FindPlaceholdersWithCitations: (handle: number, kinds: number, scope: number, contextChars: number, boundary: number, requestJson: string) => string;
873
1374
  GetEditSummary: (handle: number) => string;
874
1375
  RemainingPlaceholders: (handle: number, kinds: number) => string;
875
1376
  GetDiff: (handle: number, format: number) => string;
1377
+ GetSemanticChanges: (handle: number) => string;
1378
+ VerifyDeliverable: (handle: number) => string;
876
1379
  FindByAnnotation: (handle: number, annotationId: string) => string;
1380
+ FindByAnnotationWithCitations: (handle: number, annotationId: string, requestJson: string) => string;
877
1381
  FindByLabel: (handle: number, labelId: string) => string;
1382
+ FindByLabelWithCitations: (handle: number, labelId: string, requestJson: string) => string;
878
1383
  FindByBookmark: (handle: number, bookmarkName: string) => string;
1384
+ FindByBookmarkWithCitations: (handle: number, bookmarkName: string, requestJson: string) => string;
879
1385
  Exists: (handle: number, anchorId: string) => boolean;
880
1386
  FindByText: (handle: number, needle: string, optionsJson: string) => string;
881
1387
  FindAllByText: (handle: number, needle: string, optionsJson: string) => string;
882
1388
  FindByRegex: (handle: number, pattern: string, regexOptions: number, optionsJson: string) => string;
883
1389
  FindByKind: (handle: number, kind: string, scope: string) => string;
1390
+ FindByKindWithCitations: (handle: number, kind: string, scope: string, requestJson: string) => string;
884
1391
  GetAnchorInfo: (handle: number, anchorId: string) => string;
885
1392
  GetAnchorInfos: (handle: number, anchorIdsJson: string) => string;
886
1393
  GetBlockMetadata: (handle: number, anchorId: string) => string;
887
1394
  GetBlockMetadatas: (handle: number, anchorIdsJson: string) => string;
888
1395
  GetListMembership: (handle: number, anchorId: string) => string;
889
1396
  GetSectionInfo: (handle: number, anchorId: string) => string;
1397
+ ListStyles: (handle: number) => string;
1398
+ GetFormatting: (handle: number, anchorId: string) => string;
1399
+ ListInlineSpans: (handle: number, anchorId: string) => string;
890
1400
  ListAnnotations: (handle: number) => string;
891
1401
  AddAnnotation: (handle: number, anchorId: string, spanJson: string, annotationJson: string) => string;
892
1402
  SessionRemoveAnnotation: (handle: number, annotationId: string) => string;
@@ -904,7 +1414,7 @@ export interface DocxodusWasmExports {
904
1414
  SaveWithAnchorIds: (handle: number) => Uint8Array;
905
1415
  };
906
1416
  }
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";
1417
+ 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_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
1418
  export interface AnchorRef {
909
1419
  id: string;
910
1420
  kind: string;
@@ -915,6 +1425,105 @@ export interface EditError {
915
1425
  code: EditErrorCode;
916
1426
  message: string;
917
1427
  anchorId?: string;
1428
+ precondition?: PreconditionFailure;
1429
+ }
1430
+ export interface PreconditionTarget {
1431
+ exists: boolean;
1432
+ anchorId?: string;
1433
+ kind?: string;
1434
+ scope?: string;
1435
+ contentHash?: string;
1436
+ visibleText?: string;
1437
+ }
1438
+ export interface PreconditionFailure {
1439
+ condition: string;
1440
+ expected: unknown;
1441
+ actual: unknown;
1442
+ currentVersion: number;
1443
+ currentTarget?: PreconditionTarget;
1444
+ }
1445
+ export interface TextRangePrecondition {
1446
+ start: number;
1447
+ length: number;
1448
+ text: string;
1449
+ }
1450
+ /** Optimistic guards checked immediately before a mutation. */
1451
+ export interface MutationPreconditions {
1452
+ expectedVersion?: number;
1453
+ /** Optional explicit target; target-addressed methods infer their own anchor when omitted. */
1454
+ anchorId?: string;
1455
+ expectedContentHash?: string;
1456
+ expectedText?: string;
1457
+ expectedTextRange?: TextRangePrecondition;
1458
+ expectedKind?: string;
1459
+ expectedScope?: string;
1460
+ expectedMatchCount?: number;
1461
+ }
1462
+ export type MutationBatchMode = "atomic" | "best_effort";
1463
+ /** One synchronous npm batch step. Atomic is the default execution mode. */
1464
+ export interface MutationBatchStep {
1465
+ tool: string;
1466
+ action: string;
1467
+ mutation: () => EditResult | readonly EditResult[];
1468
+ /** Optional read-only validation: all run up front in atomic mode, per-step in best-effort. */
1469
+ preflight?: () => EditError | undefined;
1470
+ }
1471
+ /** A preview callback receives the isolated shadow session it must mutate/read. */
1472
+ export interface MutationBatchPreviewStep {
1473
+ tool: string;
1474
+ action: string;
1475
+ mutation: (shadow: import("./session.js").DocxSession) => EditResult | readonly EditResult[];
1476
+ preflight?: (shadow: import("./session.js").DocxSession) => EditError | undefined;
1477
+ }
1478
+ export interface MutationBatchPreviewOptions {
1479
+ html?: "none" | "scoped" | "full";
1480
+ /** Required for scoped HTML. */
1481
+ htmlAnchorId?: string;
1482
+ }
1483
+ export interface MutationBatchStepResult {
1484
+ index: number;
1485
+ tool: string;
1486
+ action: string;
1487
+ success: boolean;
1488
+ rolledBack: boolean;
1489
+ results: readonly EditResult[];
1490
+ }
1491
+ export interface MutationBatchFailure {
1492
+ index: number;
1493
+ tool: string;
1494
+ action: string;
1495
+ error: EditError;
1496
+ rolledBack: boolean;
1497
+ }
1498
+ export interface MutationBatchChangeSet<T> {
1499
+ added: readonly T[];
1500
+ removed: readonly T[];
1501
+ modified: readonly T[];
1502
+ }
1503
+ export interface MutationBatchResult {
1504
+ mode: MutationBatchMode;
1505
+ status: "ok" | "failed" | "partial";
1506
+ preview: boolean;
1507
+ success: boolean;
1508
+ rolledBack: boolean;
1509
+ baseVersion: number;
1510
+ resultVersion: number;
1511
+ /**
1512
+ * Canonical SHA-256 of this result package, or `null` when it could not be computed.
1513
+ * Exact replay equality is guaranteed only for deterministic batches, so consult
1514
+ * {@link MutationBatchResult.warnings} before asserting on it — and note that `null`
1515
+ * never equals `null` for the purposes of a replay assertion: an absent hash proves
1516
+ * nothing and must be handled explicitly rather than compared.
1517
+ */
1518
+ packageHash: string | null;
1519
+ steps: readonly MutationBatchStepResult[];
1520
+ failure?: MutationBatchFailure;
1521
+ revisionChanges: MutationBatchChangeSet<RevisionListEntry>;
1522
+ commentChanges: MutationBatchChangeSet<CommentListEntry>;
1523
+ annotationChanges: MutationBatchChangeSet<DocumentAnnotation>;
1524
+ warnings: readonly string[];
1525
+ /** Shadow-only preview HTML when requested; null otherwise. */
1526
+ html: string | null;
918
1527
  }
919
1528
  export interface MarkdownPatch {
920
1529
  scopeAnchorId: string;
@@ -926,10 +1535,196 @@ export interface EditResult {
926
1535
  created: AnchorRef[];
927
1536
  removed: AnchorRef[];
928
1537
  modified: AnchorRef[];
1538
+ /** Deterministic structural identity map for table shape mutations. */
1539
+ tableAnchors?: TableAnchorMapping;
929
1540
  patch?: MarkdownPatch;
930
1541
  /** Set by the annotation ops (addAnnotation/removeAnnotation/updateAnnotation/
931
1542
  * moveAnnotation) with the affected annotation id; absent for every other op. */
932
1543
  annotationId?: string;
1544
+ hyperlinkId?: string;
1545
+ bookmarkName?: string;
1546
+ imageId?: string;
1547
+ }
1548
+ export type HyperlinkKind = "external" | "internal";
1549
+ export interface HyperlinkInfo {
1550
+ id: string;
1551
+ kind: HyperlinkKind;
1552
+ owningPartUri: string;
1553
+ scope: string;
1554
+ anchorId: string;
1555
+ span: CharSpan;
1556
+ text: string;
1557
+ target?: string;
1558
+ relationshipId?: string;
1559
+ relationshipIsExternal?: boolean;
1560
+ isBroken: boolean;
1561
+ }
1562
+ export type ImageBinaryFormat = "unknown" | "png" | "jpeg" | "gif" | "bmp" | "tiff" | "webp";
1563
+ export type ImageMarkupKind = "modern_drawing" | "legacy_vml" | "unsupported_drawing";
1564
+ export type ImagePlacement = "inline" | "floating";
1565
+ export type ImageWrapMode = "none" | "square" | "tight" | "through" | "top_and_bottom" | "unknown";
1566
+ export type ImageWrapSide = "both_sides" | "left" | "right" | "largest" | "unknown";
1567
+ export type ImageHorizontalReference = "page" | "margin" | "column" | "character" | "unknown";
1568
+ export type ImageVerticalReference = "page" | "margin" | "paragraph" | "line" | "unknown";
1569
+ export type ImageHorizontalAlignment = "left" | "center" | "right" | "inside" | "outside" | "unknown";
1570
+ export type ImageVerticalAlignment = "top" | "center" | "bottom" | "inside" | "outside" | "unknown";
1571
+ export interface FloatingImageLayout {
1572
+ horizontalRelativeFrom?: ImageHorizontalReference;
1573
+ horizontalOffsetEmu?: number | null;
1574
+ horizontalAlignment?: ImageHorizontalAlignment | null;
1575
+ verticalRelativeFrom?: ImageVerticalReference;
1576
+ verticalOffsetEmu?: number | null;
1577
+ verticalAlignment?: ImageVerticalAlignment | null;
1578
+ wrapMode?: ImageWrapMode;
1579
+ wrapSide?: ImageWrapSide;
1580
+ distanceTopEmu?: number;
1581
+ distanceBottomEmu?: number;
1582
+ distanceLeftEmu?: number;
1583
+ distanceRightEmu?: number;
1584
+ relativeHeight?: number;
1585
+ behindDocument?: boolean;
1586
+ locked?: boolean;
1587
+ layoutInCell?: boolean;
1588
+ allowOverlap?: boolean;
1589
+ rawHorizontalReference?: string;
1590
+ rawVerticalReference?: string;
1591
+ rawHorizontalPosition?: string;
1592
+ rawVerticalPosition?: string;
1593
+ rawWrapMode?: string;
1594
+ rawWrapSide?: string;
1595
+ rawRelativeSizeHorizontal?: string;
1596
+ rawRelativeSizeVertical?: string;
1597
+ rawFlagTokens?: Record<string, string>;
1598
+ }
1599
+ export interface ImageInsertOptions {
1600
+ placement?: ImagePlacement;
1601
+ widthPoints?: number;
1602
+ heightPoints?: number;
1603
+ preserveAspect?: boolean;
1604
+ altText?: string | null;
1605
+ title?: string | null;
1606
+ floatingLayout?: FloatingImageLayout;
1607
+ }
1608
+ export interface ImageDimensions {
1609
+ widthPoints?: number;
1610
+ heightPoints?: number;
1611
+ preserveAspect?: boolean;
1612
+ }
1613
+ export interface ImageOccurrence {
1614
+ id: string;
1615
+ markupKind: ImageMarkupKind;
1616
+ placement?: ImagePlacement;
1617
+ canMutate: boolean;
1618
+ unsupportedReason?: string;
1619
+ owningPartUri: string;
1620
+ scope: string;
1621
+ anchorId: string;
1622
+ span: CharSpan;
1623
+ relationshipId?: string;
1624
+ targetPartUri?: string;
1625
+ linkedRelationshipId?: string;
1626
+ linkedTarget?: string;
1627
+ isEmbedded: boolean;
1628
+ isLinked: boolean;
1629
+ isBroken: boolean;
1630
+ mediaFileName?: string;
1631
+ contentType?: string;
1632
+ format: ImageBinaryFormat;
1633
+ contentTypeMatchesBytes?: boolean;
1634
+ intrinsicWidthPixels?: number;
1635
+ intrinsicHeightPixels?: number;
1636
+ renderedWidthPoints?: number;
1637
+ renderedHeightPoints?: number;
1638
+ altText?: string;
1639
+ title?: string;
1640
+ floatingLayout?: FloatingImageLayout;
1641
+ floatingLayoutSupported: boolean;
1642
+ }
1643
+ export interface ImageFormatCapability {
1644
+ format: ImageBinaryFormat;
1645
+ contentType: string;
1646
+ canInspect: boolean;
1647
+ canInsert: boolean;
1648
+ canReplace: boolean;
1649
+ limitation?: string;
1650
+ }
1651
+ export interface ImageCapabilities {
1652
+ schemaVersion: number;
1653
+ runtime: string;
1654
+ formats: ImageFormatCapability[];
1655
+ operations: string[];
1656
+ mutableWrapModes: ImageWrapMode[];
1657
+ horizontalReferences: ImageHorizontalReference[];
1658
+ verticalReferences: ImageVerticalReference[];
1659
+ maxInputBytes: number;
1660
+ maxRenderedPoints: number;
1661
+ defaultDpi: number;
1662
+ usesHeaderParsingOnly: boolean;
1663
+ acceptsBinaryBytes: boolean;
1664
+ supportsNetworkFetch: boolean;
1665
+ supportsFileIo: boolean;
1666
+ }
1667
+ export type ContentControlType = "plain_text" | "rich_text" | "checkbox" | "date" | "drop_down_list" | "combo_box" | "picture" | "repeating_section" | "repeating_section_item" | "unsupported";
1668
+ export type ContentControlPlacement = "inline" | "block" | "row" | "cell" | "unknown";
1669
+ export type ContentControlBindingPolicy = "preserve" | "detach_target";
1670
+ export interface ContentControlFillOptions {
1671
+ bindingPolicy?: ContentControlBindingPolicy;
1672
+ }
1673
+ export interface ContentControlBindingInfo {
1674
+ storeItemId?: string;
1675
+ xpath?: string;
1676
+ prefixMappings?: string;
1677
+ }
1678
+ export interface ContentControlInfo {
1679
+ anchorId: string;
1680
+ type: ContentControlType;
1681
+ placement: ContentControlPlacement;
1682
+ nativeId?: string;
1683
+ tag?: string;
1684
+ alias?: string;
1685
+ lock?: string;
1686
+ isShowingPlaceholder: boolean;
1687
+ isBound: boolean;
1688
+ binding?: ContentControlBindingInfo;
1689
+ owningPartUri: string;
1690
+ scope: string;
1691
+ parentAnchorId?: string;
1692
+ depth: number;
1693
+ hasValidNativeId: boolean;
1694
+ hasDuplicateNativeId: boolean;
1695
+ canMutate: boolean;
1696
+ canDetachTargetBinding: boolean;
1697
+ unsupportedReason?: string;
1698
+ text: string;
1699
+ itemValues: string[];
1700
+ }
1701
+ export interface DocumentRange {
1702
+ startAnchorId: string;
1703
+ startOffset: number;
1704
+ endAnchorId: string;
1705
+ endOffset: number;
1706
+ }
1707
+ export interface BookmarkRangeSegment {
1708
+ owningPartUri: string;
1709
+ scope: string;
1710
+ anchorId: string;
1711
+ span: CharSpan;
1712
+ text: string;
1713
+ }
1714
+ export interface BookmarkInfo {
1715
+ name: string;
1716
+ bookmarkId: string;
1717
+ startPartUri: string;
1718
+ startScope: string;
1719
+ endPartUri?: string;
1720
+ endScope?: string;
1721
+ range?: DocumentRange;
1722
+ segments: BookmarkRangeSegment[];
1723
+ text: string;
1724
+ isPaired: boolean;
1725
+ isManaged: boolean;
1726
+ isValid: boolean;
1727
+ validationError?: string;
933
1728
  }
934
1729
  /**
935
1730
  * One native Word comment, in comments-part order — see {@link DocxSession.listComments}.
@@ -951,23 +1746,40 @@ export interface CommentListEntry {
951
1746
  }
952
1747
  /** Revision kind in a markup-native revision listing. A `move` entry is a linked
953
1748
  * move pair — both sides resolve together. */
954
- export type SessionRevisionType = "insert" | "delete" | "move" | "format";
1749
+ export type SessionRevisionType = "insert" | "delete" | "move" | "format" | "structure";
1750
+ 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";
1751
+ export type RevisionResolutionStatus = "supported" | "unsupported" | "malformed" | "ambiguous";
1752
+ export interface RevisionDiagnostic {
1753
+ code: string;
1754
+ message: string;
1755
+ }
955
1756
  /**
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.
1757
+ * One part-qualified atomic revision from the live registry. `id` is an opaque,
1758
+ * deterministic `rev2-…` identity; `constituentIds` exposes the native Word ids.
1759
+ * `family` identifies the exact operation, while `type` is its coarse display class.
1760
+ * Unsafe native topology remains listed through `resolutionStatus` and `diagnostic`.
963
1761
  */
964
1762
  export interface RevisionListEntry {
965
1763
  id: string;
966
1764
  type: SessionRevisionType;
1765
+ family: RevisionFamily;
1766
+ constituentIds: string[];
1767
+ /**
1768
+ * QName-qualified native carrier identities. Unlike `constituentIds`, these
1769
+ * distinguish revision roles which legally use the same numeric `w:id` value.
1770
+ */
1771
+ constituentKeys: string[];
967
1772
  author: string;
968
1773
  date?: string;
1774
+ /** The `w16du:dateUtc` timestamp, when the markup carries one. */
1775
+ dateUtc?: string;
969
1776
  text: string;
1777
+ partUri: string;
1778
+ scope: string;
970
1779
  anchorId?: string;
1780
+ affectedAnchors: AnchorRef[];
1781
+ resolutionStatus: RevisionResolutionStatus;
1782
+ diagnostic?: RevisionDiagnostic;
971
1783
  }
972
1784
  export interface CharSpan {
973
1785
  start: number;
@@ -1092,6 +1904,77 @@ export interface TableInsertOptions {
1092
1904
  * wide-left / narrow-right filing-header row. */
1093
1905
  columnWidths?: number[];
1094
1906
  }
1907
+ export type TableVerticalMergeRole = "none" | "restart" | "continue";
1908
+ export type TableAnchorEntityKind = "table" | "row" | "column" | "cell";
1909
+ export interface TableCellMetadata {
1910
+ anchor: AnchorRef;
1911
+ tableAnchorId: string;
1912
+ rowAnchorId: string;
1913
+ rowIndex: number;
1914
+ columnIndex: number;
1915
+ rowSpan: number;
1916
+ columnSpan: number;
1917
+ verticalMerge: TableVerticalMergeRole;
1918
+ /** Direct cell paragraphs only; nested-table paragraphs belong to their own cells. */
1919
+ paragraphAnchors: AnchorRef[];
1920
+ }
1921
+ export interface TableRowMetadata {
1922
+ anchor: AnchorRef;
1923
+ tableAnchorId: string;
1924
+ rowIndex: number;
1925
+ gridBefore: number;
1926
+ gridAfter: number;
1927
+ cells: TableCellMetadata[];
1928
+ }
1929
+ export interface TableColumnMetadata {
1930
+ anchor: AnchorRef;
1931
+ tableAnchorId: string;
1932
+ columnIndex: number;
1933
+ widthTwips: number;
1934
+ /** True when an absent/underspecified tblGrid required a read-only coordinate identity. */
1935
+ isVirtual: boolean;
1936
+ cellAnchorIds: string[];
1937
+ }
1938
+ export interface TableMetadata {
1939
+ anchor: AnchorRef;
1940
+ columns: TableColumnMetadata[];
1941
+ rows: TableRowMetadata[];
1942
+ }
1943
+ export interface TableMetadataResult {
1944
+ success: boolean;
1945
+ error?: EditError;
1946
+ metadata?: TableMetadata;
1947
+ }
1948
+ export interface TableCellResolutionResult {
1949
+ success: boolean;
1950
+ error?: EditError;
1951
+ cell?: TableCellMetadata;
1952
+ }
1953
+ export interface TableAnchorLocation {
1954
+ anchor: AnchorRef;
1955
+ entityKind: TableAnchorEntityKind;
1956
+ rowIndex?: number;
1957
+ columnIndex?: number;
1958
+ rowSpan?: number;
1959
+ columnSpan?: number;
1960
+ isVirtual?: boolean;
1961
+ }
1962
+ export interface TableAnchorMapping {
1963
+ retained: {
1964
+ before: TableAnchorLocation;
1965
+ after: TableAnchorLocation;
1966
+ }[];
1967
+ added: TableAnchorLocation[];
1968
+ invalidated: TableAnchorLocation[];
1969
+ }
1970
+ export type TableRowHeightRule = "auto" | "atLeast" | "exact";
1971
+ export interface TableRowOptions {
1972
+ repeatHeader?: boolean;
1973
+ allowBreakAcrossPages?: boolean;
1974
+ /** Zero removes an explicit height. */
1975
+ heightTwips?: number;
1976
+ heightRule?: TableRowHeightRule;
1977
+ }
1095
1978
  /** Which table edges `DocxSession.setTableBorders` targets: `"outside"` = top/left/bottom/right,
1096
1979
  * `"inside"` = the inner grid lines (`w:insideH`/`w:insideV`), `"all"` = both. */
1097
1980
  export type TableBorderScope = "all" | "outside" | "inside";
@@ -1117,7 +2000,21 @@ export interface TableBorderSpec {
1117
2000
  color?: string;
1118
2001
  }
1119
2002
  export interface DocxSessionSettings {
2003
+ /**
2004
+ * Maximum undo steps retained. Default 20 (was 50).
2005
+ *
2006
+ * Each step is a full snapshot of every snapshot-scoped part, so this is a STEP count and not
2007
+ * a memory bound — the cost of one step scales with the document. Use `undoMemoryBudgetBytes`
2008
+ * to bound the heap.
2009
+ */
1120
2010
  undoDepth?: number;
2011
+ /**
2012
+ * Approximate ceiling, in bytes, on memory held by undo/redo snapshots. Default 134217728
2013
+ * (128 MiB). When exceeded the oldest history is discarded, so on a large document undo may
2014
+ * not reach the full `undoDepth`; one step is always retained. Set to 0 to bound by depth
2015
+ * alone (the pre-9.10 behavior).
2016
+ */
2017
+ undoMemoryBudgetBytes?: number;
1121
2018
  validateRawOps?: boolean;
1122
2019
  trackedChanges?: "accept" | "render_inline" | "strip_deletions";
1123
2020
  revisionAuthor?: string;
@@ -1145,8 +2042,10 @@ export interface DocxSessionSettings {
1145
2042
  emitMarkdownPatch?: boolean;
1146
2043
  /**
1147
2044
  * 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.
2045
+ * time so {@link DocxSession.getDiff} can compare initial vs. current, and
2046
+ * retains the exact opening package for `getSemanticChanges()`.
2047
+ * Set to `false` to skip the upfront projection plus package-copy cost if you
2048
+ * do not plan to call either comparison API.
1150
2049
  */
1151
2050
  captureInitialProjection?: boolean;
1152
2051
  }
@@ -1179,6 +2078,56 @@ export interface DocxSessionProjection {
1179
2078
  scope: string;
1180
2079
  textPreview: string;
1181
2080
  }>;
2081
+ /** Present only when projectAnchor requested citations. */
2082
+ pageCitations?: Record<string, PageCitation>;
2083
+ }
2084
+ export interface PageCitationRequest {
2085
+ documentVersion: number;
2086
+ rendererFingerprint: string;
2087
+ }
2088
+ export type PageCitationUnavailableReason = "no_page_map" | "continuous_mode" | "stale_document_version" | "renderer_fingerprint_mismatch" | "anchor_not_mapped";
2089
+ export interface PageCitationFragment {
2090
+ fragmentId: string;
2091
+ anchorId: string;
2092
+ fragmentIndex: number;
2093
+ pageNumber: number;
2094
+ geometry: {
2095
+ x: number;
2096
+ y: number;
2097
+ width: number;
2098
+ height: number;
2099
+ };
2100
+ story: "body" | "header" | "footer" | "footnote" | "endnote" | "comment";
2101
+ inTableCell: boolean;
2102
+ }
2103
+ export interface PageCitationPage {
2104
+ pageNumber: number;
2105
+ pageInSection: number;
2106
+ width: number;
2107
+ height: number;
2108
+ sectionIndex?: number;
2109
+ pageName: string;
2110
+ }
2111
+ export interface PageCitation {
2112
+ anchorId: string;
2113
+ availability: "available" | "unavailable";
2114
+ unavailableReason?: PageCitationUnavailableReason;
2115
+ documentVersion: number;
2116
+ rendererFingerprint: string;
2117
+ pages: PageCitationPage[];
2118
+ fragments: PageCitationFragment[];
2119
+ }
2120
+ export interface PageMapRegistrationResult {
2121
+ success: boolean;
2122
+ error?: "unsupported_schema_version" | "stale_document_version" | "renderer_fingerprint_mismatch" | "invalid_map";
2123
+ message?: string;
2124
+ }
2125
+ export interface PageMapStatus {
2126
+ availability: "available" | "unavailable";
2127
+ unavailableReason?: PageCitationUnavailableReason;
2128
+ documentVersion: number;
2129
+ rendererFingerprint?: string;
2130
+ mode?: "paginated" | "continuous";
1182
2131
  }
1183
2132
  /**
1184
2133
  * Per-fragment visible formatting reported by {@link DocxSession.grep}.
@@ -1219,6 +2168,8 @@ export interface TextMatch {
1219
2168
  contextAfter: string;
1220
2169
  /** Regex capture groups; index 0 is always the whole match. */
1221
2170
  groups: string[];
2171
+ /** Present only when grep requested a citation for this exact render. */
2172
+ citation?: PageCitation;
1222
2173
  }
1223
2174
  /**
1224
2175
  * One block's contribution to a {@link CrossBlockMatch}. The slice's `fragments`
@@ -1249,6 +2200,18 @@ export interface CrossBlockMatch {
1249
2200
  contextAfter: string;
1250
2201
  /** Regex capture groups; index 0 is always the whole match. */
1251
2202
  groups: string[];
2203
+ /** One per enclosingAnchors entry when requested. */
2204
+ citations?: PageCitation[];
2205
+ }
2206
+ /**
2207
+ * Options for {@link DocxSession.insertCrossReference} — each flag is one of the REF
2208
+ * field's switches: `\r` (reference the target's auto-number), `\h` (hyperlink),
2209
+ * `\p` (relative position, cached as "above"/"below").
2210
+ */
2211
+ export interface CrossReferenceOptions {
2212
+ referenceNumber?: boolean;
2213
+ hyperlink?: boolean;
2214
+ includePosition?: boolean;
1252
2215
  }
1253
2216
  /**
1254
2217
  * Options for {@link DocxSession.replaceTextRange}.
@@ -1258,6 +2221,10 @@ export interface ReplaceOptions {
1258
2221
  ignoreCase?: boolean;
1259
2222
  /** Cap the number of replacements; omitted = unlimited. */
1260
2223
  maxReplacements?: number;
2224
+ /** Require exactly this many occurrences before applying any replacement. */
2225
+ expectedMatchCount?: number;
2226
+ /** Optional document/anchor guards evaluated before searching. */
2227
+ preconditions?: MutationPreconditions;
1261
2228
  }
1262
2229
  /**
1263
2230
  * Categories of bracketed placeholders {@link DocxSession.findPlaceholders} recognizes.
@@ -1431,6 +2398,8 @@ export interface GrepOptions {
1431
2398
  * `contextChars`.
1432
2399
  */
1433
2400
  boundary?: number;
2401
+ /** Attach citations only if this exact registered layout is still valid. */
2402
+ citation?: PageCitationRequest;
1434
2403
  }
1435
2404
  /**
1436
2405
  * Options that tune the `findBy*` helpers on {@link DocxSession}. Mirrors the
@@ -1456,6 +2425,8 @@ export interface FindOptions {
1456
2425
  * for whole-category filtering; this is for the rare single-part case.
1457
2426
  */
1458
2427
  scopeFilter?: string;
2428
+ /** Attach citations only if this exact registered layout is still valid. */
2429
+ citation?: PageCitationRequest;
1459
2430
  }
1460
2431
  /**
1461
2432
  * Resolved location of an anchor — what {@link DocxSession.findByAnnotation} and
@@ -1470,6 +2441,8 @@ export interface AnchorTargetRef extends AnchorRef {
1470
2441
  /** Resolved auto-numbering prefix (e.g. "1.", "First") when the element carries
1471
2442
  * numbering. Absent otherwise. See {@link MarkdownAnchorTarget.autoNumberPrefix}. */
1472
2443
  autoNumberPrefix?: string;
2444
+ /** Present only when the discovery call requested an exact page citation. */
2445
+ citation?: PageCitation;
1473
2446
  }
1474
2447
  /**
1475
2448
  * The shape returned by {@link DocxSession.getAnchorInfo}.
@@ -1481,6 +2454,10 @@ export interface AnchorInfo {
1481
2454
  kind: string;
1482
2455
  scope: string;
1483
2456
  textPreview: string;
2457
+ /** Exact live subtree hash suitable for expectedContentHash. */
2458
+ contentHash: string;
2459
+ /** Exact (untruncated) reader-visible text suitable for expectedText. */
2460
+ visibleText: string;
1484
2461
  /** Resolved auto-numbering prefix (e.g. "1.", "First") when the element carries
1485
2462
  * numbering. Absent for un-numbered paragraphs or non-paragraph kinds. */
1486
2463
  autoNumberPrefix?: string;
@@ -1492,6 +2469,8 @@ export type NumberFormat = "decimal" | "upperLetter" | "lowerLetter" | "upperRom
1492
2469
  /** Numbering facts for a list-item paragraph. Returned by
1493
2470
  * {@link DocxSession.getListMembership} and surfaced as {@link BlockMetadata.list}. */
1494
2471
  export interface ListMembership {
2472
+ /** Stable paragraph anchor accepted unchanged by every list mutation method. */
2473
+ anchorId: string;
1495
2474
  /** The w:numId the paragraph belongs to (the w:num instance). */
1496
2475
  numId: number;
1497
2476
  /** The w:abstractNumId the paragraph's w:num points at. */
@@ -1506,6 +2485,14 @@ export interface ListMembership {
1506
2485
  fromStyle: boolean;
1507
2486
  /** Start-override from w:lvlOverride/w:startOverride for this level, if any. */
1508
2487
  startOverride?: number;
2488
+ /** Level definition's w:start value (1 when omitted). */
2489
+ start: number;
2490
+ /** Marker template such as "%1." or "(%2)". */
2491
+ levelText?: string;
2492
+ leftIndentTwips?: number;
2493
+ rightIndentTwips?: number;
2494
+ firstLineIndentTwips?: number;
2495
+ hangingIndentTwips?: number;
1509
2496
  /** Resolved label (e.g. "1.", "(a)") — same value surfaced via AnchorInfo.autoNumberPrefix. */
1510
2497
  generatedLabel?: string;
1511
2498
  }
@@ -1538,6 +2525,8 @@ export interface HeaderFooterRef {
1538
2525
  /** Page-layout snapshot for the w:sectPr that governs an anchor.
1539
2526
  * Returned by {@link DocxSession.getSectionInfo}. */
1540
2527
  export interface SectionInfo {
2528
+ /** Body anchor used for the lookup; accepted unchanged by section mutation methods. */
2529
+ anchorId: string;
1541
2530
  sectionUnid: string;
1542
2531
  pageWidthTwips: number;
1543
2532
  pageHeightTwips: number;
@@ -1563,6 +2552,91 @@ export interface SectionInfo {
1563
2552
  * "explicitly decimal" and avoid writing an attribute the document never had. */
1564
2553
  pageNumberFormat?: NumberFormat;
1565
2554
  }
2555
+ /** High-signal paragraph properties. Optional fields are deliberately absent when a
2556
+ * direct formatting layer did not write them; effective layers include schema defaults. */
2557
+ export interface ParagraphFormatting {
2558
+ styleId?: string;
2559
+ alignment?: "left" | "center" | "right" | "justify";
2560
+ leftIndentTwips?: number;
2561
+ rightIndentTwips?: number;
2562
+ firstLineIndentTwips?: number;
2563
+ hangingIndentTwips?: number;
2564
+ spacingBeforeTwips?: number;
2565
+ spacingAfterTwips?: number;
2566
+ lineSpacing?: number;
2567
+ lineSpacingRule?: LineSpacingRule;
2568
+ keepNext?: boolean;
2569
+ keepLines?: boolean;
2570
+ pageBreakBefore?: boolean;
2571
+ outlineLevel?: number;
2572
+ shadingFill?: string;
2573
+ topBorder?: ParagraphBorderEdge;
2574
+ bottomBorder?: ParagraphBorderEdge;
2575
+ }
2576
+ /** High-signal character properties. Nullable-at-source fields are optional on the wire so
2577
+ * an absent direct property remains distinguishable from an explicit false/zero. */
2578
+ export interface RunFormattingInfo {
2579
+ styleId?: string;
2580
+ bold?: boolean;
2581
+ italic?: boolean;
2582
+ underline?: boolean;
2583
+ underlineStyle?: string;
2584
+ strike?: boolean;
2585
+ code?: boolean;
2586
+ color?: string;
2587
+ highlight?: string;
2588
+ vertAlign?: string;
2589
+ fontSizePts?: number;
2590
+ fontFamily?: string;
2591
+ caps?: boolean;
2592
+ smallCaps?: boolean;
2593
+ hidden?: boolean;
2594
+ }
2595
+ export interface TableStyleFormatting {
2596
+ alignment?: string;
2597
+ widthTwips?: number;
2598
+ indentTwips?: number;
2599
+ layout?: string;
2600
+ hasBorders?: boolean;
2601
+ cellShadingFill?: string;
2602
+ }
2603
+ /** One explicit document style. `id` is accepted unchanged by paragraph/run style mutations. */
2604
+ export interface StyleInfo {
2605
+ id: string;
2606
+ name: string;
2607
+ type: "paragraph" | "character" | "table" | "numbering" | string;
2608
+ basedOn?: string;
2609
+ next?: string;
2610
+ isDefault: boolean;
2611
+ isCustom: boolean;
2612
+ hasLatentException: boolean;
2613
+ uiPriority?: number;
2614
+ semiHidden?: boolean;
2615
+ unhideWhenUsed?: boolean;
2616
+ quickFormat?: boolean;
2617
+ locked?: boolean;
2618
+ resolvedParagraph?: ParagraphFormatting;
2619
+ resolvedRun?: RunFormattingInfo;
2620
+ resolvedTable?: TableStyleFormatting;
2621
+ }
2622
+ /** One text-bearing run. `anchorId` + `span` can be passed unchanged to applyFormat. */
2623
+ export interface InlineSpan {
2624
+ anchorId: string;
2625
+ runUnid: string;
2626
+ span: CharSpan;
2627
+ text: string;
2628
+ direct: RunFormattingInfo;
2629
+ effective: RunFormattingInfo;
2630
+ /** Outer-to-inner native content controls containing this run. */
2631
+ contentControlAnchorIds: string[];
2632
+ }
2633
+ /** Explicitly separated direct and effective formatting for one paragraph anchor. */
2634
+ export interface FormattingInspection {
2635
+ anchorId: string;
2636
+ directParagraph: ParagraphFormatting;
2637
+ effectiveParagraph: ParagraphFormatting;
2638
+ runs: InlineSpan[];
2639
+ }
1566
2640
  /**
1567
2641
  * A custom annotation persisted in the document via Docxodus' annotation system.
1568
2642
  * Returned by {@link DocxSession.listAnnotations}; mirrors the wire-relevant
@@ -1833,6 +2907,8 @@ export declare enum DocumentElementType {
1833
2907
  export interface DocumentElement {
1834
2908
  /** Unique element ID (path-based, e.g., "doc/tbl-0/tr-1/tc-2") */
1835
2909
  id: string;
2910
+ /** Canonical session anchor when this element is addressable. */
2911
+ anchorId?: string;
1836
2912
  /** Element type */
1837
2913
  type: DocumentElementType | string;
1838
2914
  /** Preview of text content (first ~100 characters) */
@@ -1856,10 +2932,17 @@ export interface DocumentElement {
1856
2932
  export interface TableColumnInfo {
1857
2933
  /** ID of the table this column belongs to */
1858
2934
  tableId: string;
2935
+ /** Canonical `col` anchor. */
2936
+ anchorId: string;
2937
+ /** Canonical owning `tbl` anchor. */
2938
+ tableAnchorId: string;
2939
+ isVirtual: boolean;
1859
2940
  /** Zero-based column index */
1860
2941
  columnIndex: number;
1861
2942
  /** IDs of all cells in this column */
1862
2943
  cellIds: string[];
2944
+ /** Canonical `tc` anchors for cells covering this column. */
2945
+ cellAnchorIds: string[];
1863
2946
  /** Total number of rows in this column */
1864
2947
  rowCount: number;
1865
2948
  }
@@ -2148,11 +3231,13 @@ export interface DocumentMetadata {
2148
3231
  hasComments: boolean;
2149
3232
  /** Estimated total page count (heuristic based on content volume and page sizes) */
2150
3233
  estimatedPageCount: number;
3234
+ /** Explicit provenance: always "heuristic"; use PageMap for authoritative pages. */
3235
+ estimatedPageCountSource: "heuristic";
2151
3236
  }
2152
3237
  /**
2153
3238
  * Message types sent from main thread to worker.
2154
3239
  */
2155
- export type WorkerRequestType = "init" | "convertDocxToHtml" | "compareDocuments" | "compareDocumentsToHtml" | "getRevisions" | "getDocumentMetadata" | "getVersion" | "prepare" | "sessionOpen" | "sessionClose" | "sessionAddAnnotation" | "sessionRemoveAnnotation" | "sessionUpdateAnnotation" | "sessionMoveAnnotation";
3240
+ 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
3241
  /**
2157
3242
  * Base structure for worker requests.
2158
3243
  */
@@ -2175,10 +3260,48 @@ export interface WorkerInitRequest extends WorkerRequestBase {
2175
3260
  */
2176
3261
  export interface WorkerConvertRequest extends WorkerRequestBase {
2177
3262
  type: "convertDocxToHtml";
2178
- /** Document bytes (transferred, not copied) */
3263
+ /** Private exact-view copy of the caller's document bytes, transferred to the worker. */
2179
3264
  documentBytes: Uint8Array;
2180
3265
  /** Conversion options */
2181
3266
  options?: ConversionOptions;
3267
+ /** Optional main-thread admission ceiling for the UTF-8 response. */
3268
+ maximumOutputBytes?: number;
3269
+ }
3270
+ /** Generate a deterministic package manifest without opening a live session. */
3271
+ export interface WorkerGeneratePackageManifestRequest extends WorkerRequestBase {
3272
+ type: "generatePackageManifest";
3273
+ documentBytes: Uint8Array;
3274
+ /** When present, these lower ceilings constrain #493 inspection itself. */
3275
+ limits?: PackageManifestInspectionLimits;
3276
+ /**
3277
+ * Which representation the caller needs. A manifest near the entry ceiling is multi-megabyte,
3278
+ * so returning both costs a parse plus a structured clone nobody reads. Defaults to `"both"`.
3279
+ */
3280
+ representation?: "object" | "json" | "both";
3281
+ }
3282
+ /** Derive exact final/original package bytes before conversion. */
3283
+ export interface WorkerProjectReviewProfileRequest extends WorkerRequestBase {
3284
+ type: "projectReviewProfile";
3285
+ documentBytes: Uint8Array;
3286
+ profile: "final" | "original";
3287
+ /** Do not transfer a derived package larger than this many bytes. */
3288
+ maximumOutputBytes?: number;
3289
+ }
3290
+ /** Run the default deliverable gate directly over exact supplied bytes. */
3291
+ export interface WorkerVerifyDeliverableRequest extends WorkerRequestBase {
3292
+ type: "verifyDeliverable";
3293
+ documentBytes: Uint8Array;
3294
+ baselineBytes?: Uint8Array;
3295
+ }
3296
+ /**
3297
+ * Prove redline accept/reject reversibility off the main thread. Three packages are inspected and
3298
+ * two are rebuilt, so this is the heaviest verification request the worker serves.
3299
+ */
3300
+ export interface WorkerProveRedlineReversibilityRequest extends WorkerRequestBase {
3301
+ type: "proveRedlineReversibility";
3302
+ baselineBytes: Uint8Array;
3303
+ intendedFinalBytes: Uint8Array;
3304
+ redlineBytes: Uint8Array;
2182
3305
  }
2183
3306
  /**
2184
3307
  * Compare two documents request.
@@ -2204,6 +3327,13 @@ export interface WorkerCompareToHtmlRequest extends WorkerRequestBase {
2204
3327
  /** Comparison options */
2205
3328
  options?: CompareOptions;
2206
3329
  }
3330
+ /** Compare two packages into the stable, versioned semantic-change schema. */
3331
+ export interface WorkerGetSemanticChangesRequest extends WorkerRequestBase {
3332
+ type: "getSemanticChanges";
3333
+ leftBytes: Uint8Array;
3334
+ rightBytes: Uint8Array;
3335
+ settings?: DocxDiffSettings;
3336
+ }
2207
3337
  /**
2208
3338
  * Get revisions from a document request.
2209
3339
  */
@@ -2240,11 +3370,26 @@ export interface WorkerPrepareRequest extends WorkerRequestBase {
2240
3370
  */
2241
3371
  export interface WorkerSessionOpenRequest extends WorkerRequestBase {
2242
3372
  type: "sessionOpen";
2243
- /** Document bytes transferred to the worker */
3373
+ /** Private exact-view copy of the caller's document bytes, transferred to the worker. */
2244
3374
  documentBytes: Uint8Array;
2245
3375
  /** Session settings as JSON */
2246
3376
  settingsJson?: string;
2247
3377
  }
3378
+ /** Generate a manifest from the current logical checkpoint of a worker session. */
3379
+ export interface WorkerSessionGetPackageManifestRequest extends WorkerRequestBase {
3380
+ type: "sessionGetPackageManifest";
3381
+ handle: number;
3382
+ }
3383
+ /** Compare a worker session's current checkpoint with its opening package. */
3384
+ export interface WorkerSessionGetSemanticChangesRequest extends WorkerRequestBase {
3385
+ type: "sessionGetSemanticChanges";
3386
+ handle: number;
3387
+ }
3388
+ /** Run the default deliverable gate over a worker session's clean-save checkpoint. */
3389
+ export interface WorkerSessionVerifyDeliverableRequest extends WorkerRequestBase {
3390
+ type: "sessionVerifyDeliverable";
3391
+ handle: number;
3392
+ }
2248
3393
  /**
2249
3394
  * Close a worker DocxSession.
2250
3395
  */
@@ -2295,7 +3440,7 @@ export interface WorkerSessionMoveAnnotationRequest extends WorkerRequestBase {
2295
3440
  /**
2296
3441
  * Union type of all possible worker requests.
2297
3442
  */
2298
- export type WorkerRequest = WorkerInitRequest | WorkerConvertRequest | WorkerCompareRequest | WorkerCompareToHtmlRequest | WorkerGetRevisionsRequest | WorkerGetDocumentMetadataRequest | WorkerGetVersionRequest | WorkerPrepareRequest | WorkerSessionOpenRequest | WorkerSessionCloseRequest | WorkerSessionAddAnnotationRequest | WorkerSessionRemoveAnnotationRequest | WorkerSessionUpdateAnnotationRequest | WorkerSessionMoveAnnotationRequest;
3443
+ 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
3444
  /**
2300
3445
  * Base structure for worker responses.
2301
3446
  */
@@ -2306,7 +3451,14 @@ export interface WorkerResponseBase {
2306
3451
  success: boolean;
2307
3452
  /** Error message if success is false */
2308
3453
  error?: string;
3454
+ /**
3455
+ * Machine-readable cause when success is false. Callers classify failures from this
3456
+ * rather than by matching `error`, whose wording is not a contract.
3457
+ */
3458
+ errorCode?: WorkerErrorCode;
2309
3459
  }
3460
+ /** Closed set of machine-readable worker failure causes. */
3461
+ export type WorkerErrorCode = "resource_limit";
2310
3462
  /**
2311
3463
  * Response from init request.
2312
3464
  */
@@ -2321,6 +3473,24 @@ export interface WorkerConvertResponse extends WorkerResponseBase {
2321
3473
  /** The converted HTML string */
2322
3474
  html?: string;
2323
3475
  }
3476
+ export interface WorkerGeneratePackageManifestResponse extends WorkerResponseBase {
3477
+ type: "generatePackageManifest";
3478
+ manifest?: PackageManifest;
3479
+ /** Exact canonical JSON, retained for strict duplicate-property/schema validation. */
3480
+ manifestJson?: string;
3481
+ }
3482
+ export interface WorkerProjectReviewProfileResponse extends WorkerResponseBase {
3483
+ type: "projectReviewProfile";
3484
+ documentBytes?: Uint8Array;
3485
+ }
3486
+ export interface WorkerVerifyDeliverableResponse extends WorkerResponseBase {
3487
+ type: "verifyDeliverable";
3488
+ verification?: DeliverableVerificationResult;
3489
+ }
3490
+ export interface WorkerProveRedlineReversibilityResponse extends WorkerResponseBase {
3491
+ type: "proveRedlineReversibility";
3492
+ proof?: RedlineReversibilityProof;
3493
+ }
2324
3494
  /**
2325
3495
  * Response from compareDocuments request.
2326
3496
  */
@@ -2337,6 +3507,11 @@ export interface WorkerCompareToHtmlResponse extends WorkerResponseBase {
2337
3507
  /** The HTML string with redlines */
2338
3508
  html?: string;
2339
3509
  }
3510
+ /** Response containing the public semantic-change schema. */
3511
+ export interface WorkerGetSemanticChangesResponse extends WorkerResponseBase {
3512
+ type: "getSemanticChanges";
3513
+ semanticChanges?: SemanticChangeSet;
3514
+ }
2340
3515
  /**
2341
3516
  * Response from getRevisions request.
2342
3517
  */
@@ -2375,6 +3550,20 @@ export interface WorkerSessionOpenResponse extends WorkerResponseBase {
2375
3550
  /** Integer handle identifying the session in the worker */
2376
3551
  handle?: number;
2377
3552
  }
3553
+ /** Response containing the current worker-session package manifest. */
3554
+ export interface WorkerSessionGetPackageManifestResponse extends WorkerResponseBase {
3555
+ type: "sessionGetPackageManifest";
3556
+ manifest?: PackageManifest;
3557
+ }
3558
+ /** Response containing a session's public semantic-change schema. */
3559
+ export interface WorkerSessionGetSemanticChangesResponse extends WorkerResponseBase {
3560
+ type: "sessionGetSemanticChanges";
3561
+ semanticChanges?: SemanticChangeSet;
3562
+ }
3563
+ export interface WorkerSessionVerifyDeliverableResponse extends WorkerResponseBase {
3564
+ type: "sessionVerifyDeliverable";
3565
+ verification?: DeliverableVerificationResult;
3566
+ }
2378
3567
  /**
2379
3568
  * Response from sessionClose request.
2380
3569
  */
@@ -2393,7 +3582,7 @@ export interface WorkerSessionEditResponse extends WorkerResponseBase {
2393
3582
  /**
2394
3583
  * Union type of all possible worker responses.
2395
3584
  */
2396
- export type WorkerResponse = WorkerInitResponse | WorkerConvertResponse | WorkerCompareResponse | WorkerCompareToHtmlResponse | WorkerGetRevisionsResponse | WorkerGetDocumentMetadataResponse | WorkerGetVersionResponse | WorkerPrepareResponse | WorkerSessionOpenResponse | WorkerSessionCloseResponse | WorkerSessionEditResponse;
3585
+ export type WorkerResponse = WorkerInitResponse | WorkerGeneratePackageManifestResponse | WorkerVerifyDeliverableResponse | WorkerProveRedlineReversibilityResponse | WorkerProjectReviewProfileResponse | WorkerConvertResponse | WorkerCompareResponse | WorkerCompareToHtmlResponse | WorkerGetSemanticChangesResponse | WorkerGetRevisionsResponse | WorkerGetDocumentMetadataResponse | WorkerGetVersionResponse | WorkerPrepareResponse | WorkerSessionOpenResponse | WorkerSessionGetPackageManifestResponse | WorkerSessionGetSemanticChangesResponse | WorkerSessionVerifyDeliverableResponse | WorkerSessionCloseResponse | WorkerSessionEditResponse;
2397
3586
  /**
2398
3587
  * Options for creating a worker-based Docxodus instance.
2399
3588
  */
@@ -2403,6 +3592,8 @@ export interface WorkerDocxodusOptions {
2403
3592
  * Defaults to auto-detection from module URL.
2404
3593
  */
2405
3594
  wasmBasePath?: string;
3595
+ /** Abort the owned worker, including an initialization that has not completed. */
3596
+ signal?: AbortSignal;
2406
3597
  }
2407
3598
  /**
2408
3599
  * OpenContracts document export format.