@stll/docx-core 0.8.0 → 0.10.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.
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/projection.d.ts +11 -5
- package/dist/projection.js +26 -2
- package/package.json +1 -1
package/dist/docx_kernel_bg.wasm
CHANGED
|
Binary file
|
package/dist/projection.d.ts
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
type DocxProjectionFormattingSpan = readonly [startUtf16: number, endUtf16: number, style: "bold" | "highlight"];
|
|
5
5
|
type DocxProjectionStructure = readonly [] | readonly [type: "table", tableId: string, row: number, column: number];
|
|
6
|
-
type DocxProjectionParagraph = readonly [ordinal: number, text: string, packageParagraphId: string | null, formatting: readonly DocxProjectionFormattingSpan[], structure: DocxProjectionStructure];
|
|
6
|
+
type DocxProjectionParagraph = readonly [ordinal: number, text: string, packageParagraphId: string | null, formatting: readonly DocxProjectionFormattingSpan[], structure: DocxProjectionStructure, styleId: string | null];
|
|
7
7
|
type DocxProjectionFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxProjectionUnknownReason];
|
|
8
8
|
type DocxProjectionUnknownReason = "document-part-only" | "styles-part-unavailable" | "unsupported-styles" | "unsupported-numbering" | "incomplete-bookmark-ranges" | "unsupported-internal-references";
|
|
9
9
|
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];
|
|
10
10
|
type DocxProjectionNumberingFact = readonly [paragraphOrdinal: number, parentParagraphOrdinal: number | null, childParagraphOrdinals: readonly number[]];
|
|
11
|
+
type DocxProjectionOutlineLevelFact = readonly [paragraphOrdinal: number, outlineLevel: number];
|
|
11
12
|
type DocxProjectionBookmarkFact = readonly [paragraphOrdinal: number, bookmarkId: number, name: string, span: DocxProjectionStructuralSpan];
|
|
12
13
|
type DocxProjectionReferenceFact = readonly [paragraphOrdinal: number, referenceId: string, role: "source" | "target", span: DocxProjectionStructuralSpan];
|
|
13
14
|
type DocxProjectionStructuralSpan = readonly [startUtf8: number, endUtf8: number, startUtf16: number, endUtf16: number, coverage: "complete" | "continues-before" | "continues-after" | "continues-before-and-after"];
|
|
14
|
-
type DocxProjectionStructuralFacts = readonly [indentation: DocxProjectionFactSet<DocxProjectionIndentationFact>, numberingHierarchy: DocxProjectionFactSet<DocxProjectionNumberingFact>, bookmarks: DocxProjectionFactSet<DocxProjectionBookmarkFact>, internalReferences: DocxProjectionFactSet<DocxProjectionReferenceFact>];
|
|
15
|
+
type DocxProjectionStructuralFacts = readonly [indentation: DocxProjectionFactSet<DocxProjectionIndentationFact>, numberingHierarchy: DocxProjectionFactSet<DocxProjectionNumberingFact>, bookmarks: DocxProjectionFactSet<DocxProjectionBookmarkFact>, internalReferences: DocxProjectionFactSet<DocxProjectionReferenceFact>, outlineLevels: DocxProjectionFactSet<DocxProjectionOutlineLevelFact>];
|
|
15
16
|
type DocxProjectionRevisionUnsupportedReason = "incompatible-paragraph-merge" | "structural-table-revision" | "unsupported-revision-markup";
|
|
16
17
|
type DocxProjectionRevisionStatus = readonly [status: "complete"] | readonly [status: "incomplete", reasons: readonly DocxProjectionRevisionUnsupportedReason[]];
|
|
17
|
-
type DocxProjectionWire = readonly [schemaVersion:
|
|
18
|
+
type DocxProjectionWire = readonly [schemaVersion: 3, paragraphs: readonly DocxProjectionParagraph[], structuralFacts: DocxProjectionStructuralFacts, revisionStatus: DocxProjectionRevisionStatus];
|
|
18
19
|
type DocxReviewUnknownReason = "invalid-document" | "invalid-comments" | "invalid-comments-extended" | "resource-limit" | "unsupported-location";
|
|
19
20
|
type DocxReviewFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
|
|
20
21
|
type DocxReviewDetail<T> = readonly [status: "known", value: T] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
|
|
@@ -51,6 +52,11 @@ type InitializeDocxProjectionOptions = {
|
|
|
51
52
|
*/
|
|
52
53
|
wasm?: DocxProjectionWasmSource;
|
|
53
54
|
};
|
|
55
|
+
/** Controls text materialization for fused document and review-fact projection. */
|
|
56
|
+
type ProjectCompressedDocxWithReviewFactsOptions = {
|
|
57
|
+
/** Selects host-coordinate controls or normalized readable text. */
|
|
58
|
+
textMaterialization?: "word-host" | "readable-plain-text";
|
|
59
|
+
};
|
|
54
60
|
/** Loads and caches the single-threaded WebAssembly runtime. */
|
|
55
61
|
declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
|
|
56
62
|
declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
|
|
@@ -59,6 +65,6 @@ declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjecti
|
|
|
59
65
|
* bounded package scan. Optional review-part failures remain explicit unknown
|
|
60
66
|
* fact families rather than invalidating the document snapshot.
|
|
61
67
|
*/
|
|
62
|
-
declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array) => Promise<DocxPackageProjectionWire>;
|
|
68
|
+
declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
|
|
63
69
|
//#endregion
|
|
64
|
-
export { type DocxAttributedComment, type DocxAttributedRevision, type DocxCommentContent, type DocxPackageProjectionWire, type DocxProjectionBookmarkFact, DocxProjectionError, type DocxProjectionFactSet, type DocxProjectionFormattingSpan, type DocxProjectionIndentationFact, DocxProjectionInitializationError, type DocxProjectionNumberingFact, type DocxProjectionParagraph, type DocxProjectionReferenceFact, type DocxProjectionRevisionStatus, type DocxProjectionRevisionUnsupportedReason, type DocxProjectionStructuralFacts, type DocxProjectionStructuralSpan, type DocxProjectionStructure, type DocxProjectionUnknownReason, DocxProjectionWasmSource, type DocxProjectionWire, type DocxReviewDetail, type DocxReviewFactSet, type DocxReviewFactsWire, type DocxReviewPoint, type DocxReviewSpan, type DocxReviewUnknownReason, type DocxRevisionContent, InitializeDocxProjectionOptions, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts };
|
|
70
|
+
export { type DocxAttributedComment, type DocxAttributedRevision, type DocxCommentContent, type DocxPackageProjectionWire, type DocxProjectionBookmarkFact, DocxProjectionError, type DocxProjectionFactSet, type DocxProjectionFormattingSpan, 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 DocxReviewDetail, type DocxReviewFactSet, type DocxReviewFactsWire, type DocxReviewPoint, type DocxReviewSpan, type DocxReviewUnknownReason, type DocxRevisionContent, InitializeDocxProjectionOptions, ProjectCompressedDocxWithReviewFactsOptions, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts };
|
package/dist/projection.js
CHANGED
|
@@ -31,6 +31,30 @@ function projectCompressedDocx$1(bytes) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
+
* Projects the same fused snapshot with controls normalized for readable text.
|
|
35
|
+
*
|
|
36
|
+
* # Errors
|
|
37
|
+
*
|
|
38
|
+
* Returns a JavaScript `Error` under the same conditions as
|
|
39
|
+
* [`project_compressed_docx_with_review_facts`].
|
|
40
|
+
* @param {Uint8Array} bytes
|
|
41
|
+
* @returns {DocxPackageProjectionWire}
|
|
42
|
+
*/
|
|
43
|
+
function projectCompressedDocxWithReadableReviewFacts(bytes) {
|
|
44
|
+
try {
|
|
45
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
46
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
47
|
+
const len0 = WASM_VECTOR_LEN;
|
|
48
|
+
wasm.projectCompressedDocxWithReadableReviewFacts(retptr, ptr0, len0);
|
|
49
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
|
|
50
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
|
|
51
|
+
if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
|
|
52
|
+
return takeObject(r0);
|
|
53
|
+
} finally {
|
|
54
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
34
58
|
* Projects the document snapshot and attributed review facts from one bounded
|
|
35
59
|
* package-directory scan.
|
|
36
60
|
*
|
|
@@ -240,9 +264,9 @@ const projectCompressedDocx = (bytes) => projectWith({
|
|
|
240
264
|
* bounded package scan. Optional review-part failures remain explicit unknown
|
|
241
265
|
* fact families rather than invalidating the document snapshot.
|
|
242
266
|
*/
|
|
243
|
-
const projectCompressedDocxWithReviewFacts = (bytes) => projectWith({
|
|
267
|
+
const projectCompressedDocxWithReviewFacts = (bytes, { textMaterialization = "word-host" } = {}) => projectWith({
|
|
244
268
|
bytes,
|
|
245
|
-
project: projectCompressedDocxWithReviewFacts$1,
|
|
269
|
+
project: textMaterialization === "word-host" ? projectCompressedDocxWithReviewFacts$1 : projectCompressedDocxWithReadableReviewFacts,
|
|
246
270
|
message: PACKAGE_PROJECTION_FAILURE_MESSAGE
|
|
247
271
|
});
|
|
248
272
|
//#endregion
|
package/package.json
CHANGED