@stll/docx-core 0.34.0 → 0.35.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.
Binary file
@@ -7,8 +7,10 @@ type DocxProjectionAlignmentValue = "center" | "justify" | "left" | "right";
7
7
  type DocxProjectionAlignmentSource = "direct" | "style";
8
8
  type DocxProjectionAlignment = readonly [value: DocxProjectionAlignmentValue, source: DocxProjectionAlignmentSource] | null;
9
9
  type DocxProjectionParagraph = readonly [ordinal: number, text: string, packageParagraphId: string | null, formatting: readonly DocxProjectionFormattingSpan[], structure: DocxProjectionStructure, styleId: string | null, alignment: DocxProjectionAlignment];
10
+ type DocxProjectionFormattingFamily = DocxProjectionFormattingSpan[2];
10
11
  type DocxProjectionFormattingUnknownReason = "document-part-only" | "styles-part-unavailable" | "unsupported-styles";
11
- type DocxProjectionFormattingStatus = readonly [status: "complete"] | readonly [status: "incomplete", reason: DocxProjectionFormattingUnknownReason];
12
+ type DocxProjectionFormattingFamilyStatus = readonly [status: "known"] | readonly [status: "unknown-missing-styles", reason: "document-part-only" | "styles-part-unavailable"] | readonly [status: "unknown-unread", reason: "unsupported-styles"];
13
+ type DocxProjectionFormattingCompleteness = Readonly<Record<DocxProjectionFormattingFamily, DocxProjectionFormattingFamilyStatus>>;
12
14
  type DocxProjectionFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxProjectionUnknownReason];
13
15
  type DocxProjectionUnknownReason = "paragraph-fragment" | "document-part-only" | "styles-part-unavailable" | "unsupported-styles" | "unsupported-numbering" | "incomplete-bookmark-ranges" | "unsupported-internal-references";
14
16
  type DocxProjectionIndentationFact = readonly [paragraphOrdinal: number, firstLineTwips: number | null, hangingTwips: number | null, leftTwips: number | null, rightTwips: number | null, startTwips: number | null, endTwips: number | null, firstLineCharsHundredths: number | null, hangingCharsHundredths: number | null, leftCharsHundredths: number | null, rightCharsHundredths: number | null, startCharsHundredths: number | null, endCharsHundredths: number | null];
@@ -20,9 +22,9 @@ type DocxProjectionStructuralSpan = readonly [startUtf8: number, endUtf8: number
20
22
  type DocxProjectionStructuralFacts = readonly [indentation: DocxProjectionFactSet<DocxProjectionIndentationFact>, numberingHierarchy: DocxProjectionFactSet<DocxProjectionNumberingFact>, bookmarks: DocxProjectionFactSet<DocxProjectionBookmarkFact>, internalReferences: DocxProjectionFactSet<DocxProjectionReferenceFact>, outlineLevels: DocxProjectionFactSet<DocxProjectionOutlineLevelFact>];
21
23
  type DocxProjectionRevisionUnsupportedReason = "incompatible-paragraph-merge" | "structural-table-revision" | "unsupported-revision-markup";
22
24
  type DocxProjectionRevisionStatus = readonly [status: "complete"] | readonly [status: "incomplete", reasons: readonly DocxProjectionRevisionUnsupportedReason[]];
23
- type DocxProjectionWire = readonly [schemaVersion: 5, paragraphs: readonly DocxProjectionParagraph[], structuralFacts: DocxProjectionStructuralFacts, revisionStatus: DocxProjectionRevisionStatus, formattingStatus: DocxProjectionFormattingStatus];
25
+ type DocxProjectionWire = readonly [schemaVersion: 6, paragraphs: readonly DocxProjectionParagraph[], structuralFacts: DocxProjectionStructuralFacts, revisionStatus: DocxProjectionRevisionStatus, formattingCompleteness: DocxProjectionFormattingCompleteness];
24
26
  type DocxParagraphFragmentFacts<T extends readonly unknown[]> = { readonly [Key in keyof T]: readonly [status: "unknown", reason: "paragraph-fragment"]; };
25
- type DocxParagraphFragmentWire = readonly [schemaVersion: DocxProjectionWire[0], paragraphs: readonly [DocxProjectionParagraph], structuralFacts: DocxParagraphFragmentFacts<DocxProjectionStructuralFacts>, revisionStatus: DocxProjectionWire[3], formattingStatus: DocxProjectionWire[4]];
27
+ type DocxParagraphFragmentWire = readonly [schemaVersion: DocxProjectionWire[0], paragraphs: readonly [DocxProjectionParagraph], structuralFacts: DocxParagraphFragmentFacts<DocxProjectionStructuralFacts>, revisionStatus: DocxProjectionWire[3], formattingCompleteness: DocxProjectionWire[4]];
26
28
  type DocxReviewUnknownReason = "invalid-document" | "invalid-comments" | "invalid-comments-extended" | "resource-limit" | "unsupported-location";
27
29
  type DocxReviewFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
28
30
  type DocxRevisionKind = "insertion" | "deletion" | "moveFrom" | "moveTo" | "cellIns" | "cellDel" | "cellMerge" | "pPrChange" | "rPrChange" | "sectPrChange" | "tblPrChange" | "tblPrExChange" | "trPrChange" | "tcPrChange" | "tblGridChange" | "customXmlDelRangeStart" | "customXmlDelRangeEnd" | "customXmlInsRangeStart" | "customXmlInsRangeEnd" | "customXmlMoveFromRangeStart" | "customXmlMoveFromRangeEnd" | "customXmlMoveToRangeStart" | "customXmlMoveToRangeEnd";
@@ -67,6 +69,8 @@ type ProjectCompressedDocxWithReviewFactsOptions = {
67
69
  };
68
70
  /** Loads and caches the single-threaded WebAssembly runtime. */
69
71
  declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
72
+ /** Returns the wire schema version owned by the initialized Rust runtime. */
73
+ declare const docxProjectionSchemaVersion: () => Promise<number>;
70
74
  declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
71
75
  /** Projects raw main-document XML or a Flat OPC package through Rust. */
72
76
  declare const projectMainDocumentXml: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
@@ -79,4 +83,4 @@ declare const projectParagraphFragment: (bytes: Uint8Array) => Promise<DocxParag
79
83
  */
80
84
  declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
81
85
  //#endregion
82
- export { type DocxAttributedComment, type DocxAttributedRevision, type DocxPackageProjectionWire, type DocxParagraphFragmentWire, type DocxProjectionAlignment, type DocxProjectionAlignmentSource, type DocxProjectionAlignmentValue, type DocxProjectionBookmarkFact, DocxProjectionError, type DocxProjectionFactSet, type DocxProjectionFormattingSpan, type DocxProjectionFormattingStatus, type DocxProjectionFormattingUnknownReason, type DocxProjectionIndentationFact, DocxProjectionInitializationError, type DocxProjectionNumberingFact, type DocxProjectionOutlineLevelFact, type DocxProjectionParagraph, type DocxProjectionReferenceFact, type DocxProjectionRevisionStatus, type DocxProjectionRevisionUnsupportedReason, type DocxProjectionStructuralFacts, type DocxProjectionStructuralSpan, type DocxProjectionStructure, type DocxProjectionUnknownReason, DocxProjectionWasmSource, type DocxProjectionWire, type DocxReviewFactSet, type DocxReviewFactsWire, type DocxReviewUnknownReason, type DocxRevisionKind, InitializeDocxProjectionOptions, ProjectCompressedDocxWithReviewFactsOptions, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts, projectMainDocumentXml, projectParagraphFragment };
86
+ export { type DocxAttributedComment, type DocxAttributedRevision, type DocxPackageProjectionWire, type DocxParagraphFragmentWire, type DocxProjectionAlignment, type DocxProjectionAlignmentSource, type DocxProjectionAlignmentValue, type DocxProjectionBookmarkFact, DocxProjectionError, type DocxProjectionFactSet, type DocxProjectionFormattingCompleteness, type DocxProjectionFormattingFamily, type DocxProjectionFormattingFamilyStatus, type DocxProjectionFormattingSpan, type DocxProjectionFormattingUnknownReason, type DocxProjectionIndentationFact, DocxProjectionInitializationError, type DocxProjectionNumberingFact, type DocxProjectionOutlineLevelFact, type DocxProjectionParagraph, type DocxProjectionReferenceFact, type DocxProjectionRevisionStatus, type DocxProjectionRevisionUnsupportedReason, type DocxProjectionStructuralFacts, type DocxProjectionStructuralSpan, type DocxProjectionStructure, type DocxProjectionUnknownReason, DocxProjectionWasmSource, type DocxProjectionWire, type DocxReviewFactSet, type DocxReviewFactsWire, type DocxReviewUnknownReason, type DocxRevisionKind, InitializeDocxProjectionOptions, ProjectCompressedDocxWithReviewFactsOptions, docxProjectionSchemaVersion, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts, projectMainDocumentXml, projectParagraphFragment };
@@ -1,6 +1,13 @@
1
1
  import { TaggedError } from "better-result";
2
2
  //#region src/generated/docx_kernel.js
3
3
  /**
4
+ * The version used by the document projection serializer.
5
+ * @returns {number}
6
+ */
7
+ function docxProjectionSchemaVersion$1() {
8
+ return wasm.docxProjectionSchemaVersion() >>> 0;
9
+ }
10
+ /**
4
11
  * Projects compressed DOCX bytes into a versioned host-independent snapshot.
5
12
  *
6
13
  * The ordinal is the paragraph's position in this immutable package snapshot.
@@ -19,7 +26,7 @@ import { TaggedError } from "better-result";
19
26
  function projectCompressedDocx$1(bytes) {
20
27
  try {
21
28
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
22
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
29
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
23
30
  const len0 = WASM_VECTOR_LEN;
24
31
  wasm.projectCompressedDocx(retptr, ptr0, len0);
25
32
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
@@ -43,7 +50,7 @@ function projectCompressedDocx$1(bytes) {
43
50
  function projectCompressedDocxWithReadableReviewFacts(bytes) {
44
51
  try {
45
52
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
46
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
53
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
47
54
  const len0 = WASM_VECTOR_LEN;
48
55
  wasm.projectCompressedDocxWithReadableReviewFacts(retptr, ptr0, len0);
49
56
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
@@ -68,7 +75,7 @@ function projectCompressedDocxWithReadableReviewFacts(bytes) {
68
75
  function projectCompressedDocxWithReviewFacts$1(bytes) {
69
76
  try {
70
77
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
71
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
78
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
72
79
  const len0 = WASM_VECTOR_LEN;
73
80
  wasm.projectCompressedDocxWithReviewFacts(retptr, ptr0, len0);
74
81
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
@@ -90,7 +97,7 @@ function projectCompressedDocxWithReviewFacts$1(bytes) {
90
97
  function projectMainDocumentXml$1(bytes) {
91
98
  try {
92
99
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
93
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
100
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
94
101
  const len0 = WASM_VECTOR_LEN;
95
102
  wasm.projectMainDocumentXml(retptr, ptr0, len0);
96
103
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
@@ -112,7 +119,7 @@ function projectMainDocumentXml$1(bytes) {
112
119
  function projectParagraphFragment$1(bytes) {
113
120
  try {
114
121
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
115
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
122
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
116
123
  const len0 = WASM_VECTOR_LEN;
117
124
  wasm.projectParagraphFragment(retptr, ptr0, len0);
118
125
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
@@ -137,12 +144,20 @@ function __wbg_get_imports() {
137
144
  __wbg_new_b667d279fd5aa943: function(arg0, arg1) {
138
145
  return addHeapObject(new Error(getStringFromWasm0(arg0, arg1)));
139
146
  },
147
+ __wbg_new_da52cf8fe3429cb2: function() {
148
+ return addHeapObject(/* @__PURE__ */ new Object());
149
+ },
140
150
  __wbg_new_with_length_f8cbc3a5b9ff9368: function(arg0) {
141
151
  return addHeapObject(new Array(arg0 >>> 0));
142
152
  },
143
153
  __wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
144
154
  return getObject(arg0).push(getObject(arg1));
145
155
  },
156
+ __wbg_set_8535240470bf2500: function() {
157
+ return handleError(function(arg0, arg1, arg2) {
158
+ return Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
159
+ }, arguments);
160
+ },
146
161
  __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
147
162
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
148
163
  },
@@ -186,6 +201,13 @@ function getUint8ArrayMemory0() {
186
201
  function getObject(idx) {
187
202
  return heap[idx];
188
203
  }
204
+ function handleError(f, args) {
205
+ try {
206
+ return f.apply(this, args);
207
+ } catch (e) {
208
+ wasm.__wbindgen_export(addHeapObject(e));
209
+ }
210
+ }
189
211
  let heap = new Array(1024).fill(void 0);
190
212
  heap.push(void 0, null, true, false);
191
213
  let heap_next = heap.length;
@@ -298,6 +320,11 @@ const projectWith = async ({ bytes, project, message }) => {
298
320
  });
299
321
  }
300
322
  };
323
+ /** Returns the wire schema version owned by the initialized Rust runtime. */
324
+ const docxProjectionSchemaVersion = async () => {
325
+ await initializeDocxProjection();
326
+ return docxProjectionSchemaVersion$1();
327
+ };
301
328
  const projectCompressedDocx = (bytes) => projectWith({
302
329
  bytes,
303
330
  project: projectCompressedDocx$1,
@@ -326,4 +353,4 @@ const projectCompressedDocxWithReviewFacts = (bytes, { textMaterialization = "wo
326
353
  message: PACKAGE_PROJECTION_FAILURE_MESSAGE
327
354
  });
328
355
  //#endregion
329
- export { DocxProjectionError, DocxProjectionInitializationError, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts, projectMainDocumentXml, projectParagraphFragment };
356
+ export { DocxProjectionError, DocxProjectionInitializationError, docxProjectionSchemaVersion, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts, projectMainDocumentXml, projectParagraphFragment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/docx-core",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Typed OOXML/DOCX model, validation, serialization, legal-source compilation, and browser-native package projection.",
5
5
  "keywords": [
6
6
  "document-model",