@stll/docx-core 0.33.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,10 +7,12 @@ 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
- type DocxProjectionUnknownReason = "document-part-only" | "styles-part-unavailable" | "unsupported-styles" | "unsupported-numbering" | "incomplete-bookmark-ranges" | "unsupported-internal-references";
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];
15
17
  type DocxProjectionNumberingFact = readonly [paragraphOrdinal: number, parentParagraphOrdinal: number | null, childParagraphOrdinals: readonly number[]];
16
18
  type DocxProjectionOutlineLevelFact = readonly [paragraphOrdinal: number, outlineLevel: number];
@@ -20,7 +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];
26
+ type DocxParagraphFragmentFacts<T extends readonly unknown[]> = { readonly [Key in keyof T]: readonly [status: "unknown", reason: "paragraph-fragment"]; };
27
+ type DocxParagraphFragmentWire = readonly [schemaVersion: DocxProjectionWire[0], paragraphs: readonly [DocxProjectionParagraph], structuralFacts: DocxParagraphFragmentFacts<DocxProjectionStructuralFacts>, revisionStatus: DocxProjectionWire[3], formattingCompleteness: DocxProjectionWire[4]];
24
28
  type DocxReviewUnknownReason = "invalid-document" | "invalid-comments" | "invalid-comments-extended" | "resource-limit" | "unsupported-location";
25
29
  type DocxReviewFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
26
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";
@@ -65,7 +69,13 @@ type ProjectCompressedDocxWithReviewFactsOptions = {
65
69
  };
66
70
  /** Loads and caches the single-threaded WebAssembly runtime. */
67
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>;
68
74
  declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
75
+ /** Projects raw main-document XML or a Flat OPC package through Rust. */
76
+ declare const projectMainDocumentXml: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
77
+ /** Projects one Flat OPC paragraph; document structural facts remain unknown. */
78
+ declare const projectParagraphFragment: (bytes: Uint8Array) => Promise<DocxParagraphFragmentWire>;
69
79
  /**
70
80
  * Projects the document snapshot and attributed review facts through one
71
81
  * bounded package scan. Optional review-part failures remain explicit unknown
@@ -73,4 +83,4 @@ declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjecti
73
83
  */
74
84
  declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
75
85
  //#endregion
76
- export { type DocxAttributedComment, type DocxAttributedRevision, type DocxPackageProjectionWire, 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 };
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);
@@ -79,6 +86,50 @@ function projectCompressedDocxWithReviewFacts$1(bytes) {
79
86
  wasm.__wbindgen_add_to_stack_pointer(16);
80
87
  }
81
88
  }
89
+ /**
90
+ * Projects bounded main-document XML or a relationship-selected Flat OPC package.
91
+ *
92
+ * # Errors
93
+ * Returns a JavaScript `Error` for malformed input or a resource-limit violation.
94
+ * @param {Uint8Array} bytes
95
+ * @returns {DocxProjectionWire}
96
+ */
97
+ function projectMainDocumentXml$1(bytes) {
98
+ try {
99
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
100
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ wasm.projectMainDocumentXml(retptr, ptr0, len0);
103
+ var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
104
+ var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
105
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
106
+ return takeObject(r0);
107
+ } finally {
108
+ wasm.__wbindgen_add_to_stack_pointer(16);
109
+ }
110
+ }
111
+ /**
112
+ * Projects one bounded paragraph fragment with unknown document structural facts.
113
+ *
114
+ * # Errors
115
+ * Returns a JavaScript `Error` for malformed input or a resource-limit violation.
116
+ * @param {Uint8Array} bytes
117
+ * @returns {DocxParagraphFragmentWire}
118
+ */
119
+ function projectParagraphFragment$1(bytes) {
120
+ try {
121
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
122
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ wasm.projectParagraphFragment(retptr, ptr0, len0);
125
+ var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
126
+ var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
127
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
128
+ return takeObject(r0);
129
+ } finally {
130
+ wasm.__wbindgen_add_to_stack_pointer(16);
131
+ }
132
+ }
82
133
  function __wbg_get_imports() {
83
134
  return {
84
135
  __proto__: null,
@@ -93,12 +144,20 @@ function __wbg_get_imports() {
93
144
  __wbg_new_b667d279fd5aa943: function(arg0, arg1) {
94
145
  return addHeapObject(new Error(getStringFromWasm0(arg0, arg1)));
95
146
  },
147
+ __wbg_new_da52cf8fe3429cb2: function() {
148
+ return addHeapObject(/* @__PURE__ */ new Object());
149
+ },
96
150
  __wbg_new_with_length_f8cbc3a5b9ff9368: function(arg0) {
97
151
  return addHeapObject(new Array(arg0 >>> 0));
98
152
  },
99
153
  __wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
100
154
  return getObject(arg0).push(getObject(arg1));
101
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
+ },
102
161
  __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
103
162
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
104
163
  },
@@ -142,6 +201,13 @@ function getUint8ArrayMemory0() {
142
201
  function getObject(idx) {
143
202
  return heap[idx];
144
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
+ }
145
211
  let heap = new Array(1024).fill(void 0);
146
212
  heap.push(void 0, null, true, false);
147
213
  let heap_next = heap.length;
@@ -254,11 +320,28 @@ const projectWith = async ({ bytes, project, message }) => {
254
320
  });
255
321
  }
256
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
+ };
257
328
  const projectCompressedDocx = (bytes) => projectWith({
258
329
  bytes,
259
330
  project: projectCompressedDocx$1,
260
331
  message: DOCUMENT_PROJECTION_FAILURE_MESSAGE
261
332
  });
333
+ /** Projects raw main-document XML or a Flat OPC package through Rust. */
334
+ const projectMainDocumentXml = (bytes) => projectWith({
335
+ bytes,
336
+ project: projectMainDocumentXml$1,
337
+ message: DOCUMENT_PROJECTION_FAILURE_MESSAGE
338
+ });
339
+ /** Projects one Flat OPC paragraph; document structural facts remain unknown. */
340
+ const projectParagraphFragment = (bytes) => projectWith({
341
+ bytes,
342
+ project: projectParagraphFragment$1,
343
+ message: DOCUMENT_PROJECTION_FAILURE_MESSAGE
344
+ });
262
345
  /**
263
346
  * Projects the document snapshot and attributed review facts through one
264
347
  * bounded package scan. Optional review-part failures remain explicit unknown
@@ -270,4 +353,4 @@ const projectCompressedDocxWithReviewFacts = (bytes, { textMaterialization = "wo
270
353
  message: PACKAGE_PROJECTION_FAILURE_MESSAGE
271
354
  });
272
355
  //#endregion
273
- export { DocxProjectionError, DocxProjectionInitializationError, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts };
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.33.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",