@stll/docx-core 0.7.0 → 0.9.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/{document-D4XHQQIj.js → document-BO7h-LxY.js} +4 -1
- package/dist/{document-DI8X7aZy.d.ts → document-CMZ4oy9i.d.ts} +3 -1
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/model/document.d.ts +2 -2
- package/dist/model/document.js +2 -2
- package/dist/projection.d.ts +27 -5
- package/dist/projection.js +70 -4
- package/package.json +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
//#region src/model/content.ts
|
|
2
|
+
const OOXML_SYMBOL_CHARACTER_PATTERN = /^[\dA-Fa-f]{4}$/u;
|
|
3
|
+
/** Whether a symbol character is exactly four hexadecimal digits. */
|
|
4
|
+
const isOoxmlSymbolCharacter = (value) => OOXML_SYMBOL_CHARACTER_PATTERN.test(value);
|
|
2
5
|
/**
|
|
3
6
|
* Largest value a revision id (`w:id`) may carry: 2^31 - 1.
|
|
4
7
|
*
|
|
@@ -32,4 +35,4 @@ const DOCX_CONFORMANCE_CLASSES = Object.freeze({
|
|
|
32
35
|
UNKNOWN: "unknown"
|
|
33
36
|
});
|
|
34
37
|
//#endregion
|
|
35
|
-
export { MAX_REVISION_ID as n,
|
|
38
|
+
export { normalizeRevisionId as i, MAX_REVISION_ID as n, isOoxmlSymbolCharacter as r, DOCX_CONFORMANCE_CLASSES as t };
|
|
@@ -682,6 +682,8 @@ type SymbolContent = {
|
|
|
682
682
|
/** Character code */
|
|
683
683
|
char: string;
|
|
684
684
|
};
|
|
685
|
+
/** Whether a symbol character is exactly four hexadecimal digits. */
|
|
686
|
+
declare const isOoxmlSymbolCharacter: (value: string) => boolean;
|
|
685
687
|
/**
|
|
686
688
|
* Footnote or endnote reference
|
|
687
689
|
*/
|
|
@@ -2276,4 +2278,4 @@ type Document = {
|
|
|
2276
2278
|
warnings?: string[];
|
|
2277
2279
|
};
|
|
2278
2280
|
//#endregion
|
|
2279
|
-
export { ImageTransform as $, TrackedChangeInfo as $t, ComplexField as A,
|
|
2281
|
+
export { ImageTransform as $, TrackedChangeInfo as $t, ComplexField as A, TableWidthType as An, SectionProperties as At, FooterReference as B, SoftHyphenContent as Bt, BookmarkStart as C, TableBorders as Cn, PropertyChangeInfo as Ct, CommentRangeEnd as D, TableLook as Dn, SdtProperties as Dt, Comment as E, TableFormatting as En, RunPropertyChange as Et, EndnotePosition as F, ColorValue as Fn, ShapeFill as Ft, HeaderFooterType as G, TableCellPropertyChange as Gt, FootnotePosition as H, TabContent as Ht, EndnoteProperties as I, KnownBorderStyle as In, ShapeOutline as It, Image as J, TableRowPropertyChange as Jt, HeaderReference as K, TablePropertyChange as Kt, Field as L, ShadingProperties as Ln, ShapeTextBody as Lt, DocumentBody as M, TextFormatting as Mn, SectionStart as Mt, DrawingContent as N, UnderlineStyle as Nn, Shape as Nt, CommentRangeStart as O, TableMeasurement as On, SdtType as Ot, Endnote as P, BorderSpec as Pn, ShapeContent as Pt, ImageSize as Q, TextWatermark as Qt, FieldCharContent as R, ThemeColorSlot as Rn, ShapeType as Rt, BookmarkEnd as S, TabStopAlignment as Sn, PositionalTab as St, Column as T, TableCellFormatting as Tn, RunContent as Tt, FootnoteProperties as U, Table as Ut, Footnote as V, SymbolContent as Vt, HeaderFooter as W, TableCell as Wt, ImagePadding as X, TextBox as Xt, ImageCrop as Y, TableStructuralChangeInfo as Yt, ImagePosition as Z, TextContent as Zt, ThemeColorScheme as _, ParagraphAlignment as _n, Paragraph as _t, DocxPackage as a, AbstractNumbering as an, MAX_REVISION_ID as at, BlockContent as b, TabLeader as bn, ParagraphPropertyChange as bt, FontTable as c, ListRendering as cn, MoveFromRangeEnd as ct, RelationshipMap as d, NumberingInstance as dn, MoveToRangeEnd as dt, TrackedRunChange as en, ImageWrap as et, RelationshipType as f, CellMargins as fn, MoveToRangeStart as ft, Theme as g, LineSpacingRule as gn, PageOrientation as gt, StyleType as h, FloatingTableProperties as hn, NoteReferenceContent as ht, DocxConformanceClass as i, normalizeRevisionId as in, LineNumberRestart as it, Deletion as j, TextEffect as jn, SectionPropertyChange as jt, CommentReference as k, TableRowFormatting as kn, Section as kt, MediaFile as l, NumberFormat as ln, MoveFromRangeStart as lt, StyleDefinitions as m, EmphasisMark as mn, NoteNumberRestart as mt, Document as n, Watermark as nn, Insertion as nt, DocDefaults as o, LevelSuffix as on, MathEquation as ot, Style as p, ConditionalFormatStyle as pn, NoBreakHyphenContent as pt, Hyperlink as q, TableRow as qt, DocumentSettings as r, isOoxmlSymbolCharacter as rn, InstrTextContent as rt, FontInfo as s, ListLevel as sn, MoveFrom as st, DOCX_CONFORMANCE_CLASSES as t, VerticalAlign as tn, InlineSdt as tt, Relationship as u, NumberingDefinitions as un, MoveTo as ut, ThemeFont as v, ParagraphFormatting as vn, ParagraphContent as vt, BreakContent as w, TableCellBorders as wn, Run as wt, BlockSdt as x, TabStop as xn, PictureWatermark as xt, ThemeFontScheme as y, SpacingExplicit as yn, ParagraphMarkChange as yt, FieldType as z, SimpleField as zt };
|
package/dist/docx_kernel_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as SectionProperties, M as DocumentBody, St as PositionalTab, Tt as RunContent, Ut as Table, Wt as TableCell, Zt as TextContent, _t as Paragraph, a as DocxPackage, b as BlockContent, i as DocxConformanceClass, n as Document, p as Style, qt as TableRow, t as DOCX_CONFORMANCE_CLASSES, vt as ParagraphContent, w as BreakContent, wt as Run } from "./document-
|
|
1
|
+
import { At as SectionProperties, M as DocumentBody, St as PositionalTab, Tt as RunContent, Ut as Table, Wt as TableCell, Zt as TextContent, _t as Paragraph, a as DocxPackage, b as BlockContent, i as DocxConformanceClass, n as Document, p as Style, qt as TableRow, t as DOCX_CONFORMANCE_CLASSES, vt as ParagraphContent, w as BreakContent, wt as Run } from "./document-CMZ4oy9i.js";
|
|
2
2
|
//#region src/legal-source/types.d.ts
|
|
3
3
|
type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";
|
|
4
4
|
type LegalNumberingProfile = "legal" | "none" | "checklist";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DOCX_CONFORMANCE_CLASSES } from "./document-
|
|
1
|
+
import { r as isOoxmlSymbolCharacter, t as DOCX_CONFORMANCE_CLASSES } from "./document-BO7h-LxY.js";
|
|
2
2
|
import JSZip from "jszip";
|
|
3
3
|
import { panic } from "better-result";
|
|
4
4
|
//#region src/serialize/xml.ts
|
|
@@ -605,7 +605,10 @@ const validateRunContent = (content, path, ctx) => {
|
|
|
605
605
|
recordPath(ctx.noteRefs[noteType], content.id, path);
|
|
606
606
|
return;
|
|
607
607
|
}
|
|
608
|
-
if (content.type === "symbol"
|
|
608
|
+
if (content.type === "symbol") {
|
|
609
|
+
if (content.font.trim() === "") addError(ctx, `${path}.font`, "Symbol content must include a font name.");
|
|
610
|
+
if (!isOoxmlSymbolCharacter(content.char)) addError(ctx, `${path}.char`, "Symbol character must be exactly four hexadecimal digits.");
|
|
611
|
+
}
|
|
609
612
|
};
|
|
610
613
|
const validateHyperlink = (hyperlink, path, ctx) => {
|
|
611
614
|
if (!hyperlink.rId && !hyperlink.href && !hyperlink.anchor) addWarning(ctx, path, "Hyperlink has no relationship, href, or internal anchor.");
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ImageTransform, $t as TrackedChangeInfo, A as ComplexField, An as
|
|
2
|
-
export { type AbstractNumbering, type BlockContent, type BlockSdt, type BookmarkEnd, type BookmarkStart, type BorderSpec, type BreakContent, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, DOCX_CONFORMANCE_CLASSES, type Deletion, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingContent, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type Hyperlink, type Image, type ImageCrop, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type InlineSdt, type Insertion, type InstrTextContent, type KnownBorderStyle, type LevelSuffix, type LineNumberRestart, type LineSpacingRule, type ListLevel, type ListRendering, MAX_REVISION_ID, type MathEquation, type MediaFile, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphPropertyChange, type PictureWatermark, type PositionalTab, type PropertyChangeInfo, type Relationship, type RelationshipMap, type RelationshipType, type Run, type RunContent, type RunPropertyChange, type SdtProperties, type SdtType, type Section, type SectionProperties, type SectionPropertyChange, type SectionStart, type ShadingProperties, type Shape, type ShapeContent, type ShapeFill, type ShapeOutline, type ShapeTextBody, type ShapeType, type SimpleField, type SoftHyphenContent, type SpacingExplicit, type Style, type StyleDefinitions, type StyleType, type SymbolContent, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableBorders, type TableCell, type TableCellBorders, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableLook, type TableMeasurement, type TablePropertyChange, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColorScheme, type ThemeColorSlot, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type UnderlineStyle, type VerticalAlign, type Watermark, normalizeRevisionId };
|
|
1
|
+
import { $ as ImageTransform, $t as TrackedChangeInfo, A as ComplexField, An as TableWidthType, At as SectionProperties, B as FooterReference, Bt as SoftHyphenContent, C as BookmarkStart, Cn as TableBorders, Ct as PropertyChangeInfo, D as CommentRangeEnd, Dn as TableLook, Dt as SdtProperties, E as Comment, En as TableFormatting, Et as RunPropertyChange, F as EndnotePosition, Fn as ColorValue, Ft as ShapeFill, G as HeaderFooterType, Gt as TableCellPropertyChange, H as FootnotePosition, Ht as TabContent, I as EndnoteProperties, In as KnownBorderStyle, It as ShapeOutline, J as Image, Jt as TableRowPropertyChange, K as HeaderReference, Kt as TablePropertyChange, L as Field, Ln as ShadingProperties, Lt as ShapeTextBody, M as DocumentBody, Mn as TextFormatting, Mt as SectionStart, N as DrawingContent, Nn as UnderlineStyle, Nt as Shape, O as CommentRangeStart, On as TableMeasurement, Ot as SdtType, P as Endnote, Pn as BorderSpec, Pt as ShapeContent, Q as ImageSize, Qt as TextWatermark, R as FieldCharContent, Rn as ThemeColorSlot, Rt as ShapeType, S as BookmarkEnd, Sn as TabStopAlignment, St as PositionalTab, T as Column, Tn as TableCellFormatting, Tt as RunContent, U as FootnoteProperties, Ut as Table, V as Footnote, Vt as SymbolContent, W as HeaderFooter, Wt as TableCell, X as ImagePadding, Xt as TextBox, Y as ImageCrop, Yt as TableStructuralChangeInfo, Z as ImagePosition, Zt as TextContent, _ as ThemeColorScheme, _n as ParagraphAlignment, _t as Paragraph, a as DocxPackage, an as AbstractNumbering, at as MAX_REVISION_ID, b as BlockContent, bn as TabLeader, bt as ParagraphPropertyChange, c as FontTable, cn as ListRendering, ct as MoveFromRangeEnd, d as RelationshipMap, dn as NumberingInstance, dt as MoveToRangeEnd, en as TrackedRunChange, et as ImageWrap, f as RelationshipType, fn as CellMargins, ft as MoveToRangeStart, g as Theme, gn as LineSpacingRule, gt as PageOrientation, h as StyleType, hn as FloatingTableProperties, ht as NoteReferenceContent, i as DocxConformanceClass, in as normalizeRevisionId, it as LineNumberRestart, j as Deletion, jn as TextEffect, jt as SectionPropertyChange, k as CommentReference, kn as TableRowFormatting, kt as Section, l as MediaFile, ln as NumberFormat, lt as MoveFromRangeStart, m as StyleDefinitions, mn as EmphasisMark, mt as NoteNumberRestart, n as Document, nn as Watermark, nt as Insertion, o as DocDefaults, on as LevelSuffix, ot as MathEquation, p as Style, pn as ConditionalFormatStyle, pt as NoBreakHyphenContent, q as Hyperlink, qt as TableRow, r as DocumentSettings, rn as isOoxmlSymbolCharacter, rt as InstrTextContent, s as FontInfo, sn as ListLevel, st as MoveFrom, t as DOCX_CONFORMANCE_CLASSES, tn as VerticalAlign, tt as InlineSdt, u as Relationship, un as NumberingDefinitions, ut as MoveTo, v as ThemeFont, vn as ParagraphFormatting, vt as ParagraphContent, w as BreakContent, wn as TableCellBorders, wt as Run, x as BlockSdt, xn as TabStop, xt as PictureWatermark, y as ThemeFontScheme, yn as SpacingExplicit, yt as ParagraphMarkChange, z as FieldType, zt as SimpleField } from "../document-CMZ4oy9i.js";
|
|
2
|
+
export { type AbstractNumbering, type BlockContent, type BlockSdt, type BookmarkEnd, type BookmarkStart, type BorderSpec, type BreakContent, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, DOCX_CONFORMANCE_CLASSES, type Deletion, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingContent, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type Hyperlink, type Image, type ImageCrop, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type InlineSdt, type Insertion, type InstrTextContent, type KnownBorderStyle, type LevelSuffix, type LineNumberRestart, type LineSpacingRule, type ListLevel, type ListRendering, MAX_REVISION_ID, type MathEquation, type MediaFile, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphPropertyChange, type PictureWatermark, type PositionalTab, type PropertyChangeInfo, type Relationship, type RelationshipMap, type RelationshipType, type Run, type RunContent, type RunPropertyChange, type SdtProperties, type SdtType, type Section, type SectionProperties, type SectionPropertyChange, type SectionStart, type ShadingProperties, type Shape, type ShapeContent, type ShapeFill, type ShapeOutline, type ShapeTextBody, type ShapeType, type SimpleField, type SoftHyphenContent, type SpacingExplicit, type Style, type StyleDefinitions, type StyleType, type SymbolContent, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableBorders, type TableCell, type TableCellBorders, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableLook, type TableMeasurement, type TablePropertyChange, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColorScheme, type ThemeColorSlot, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type UnderlineStyle, type VerticalAlign, type Watermark, isOoxmlSymbolCharacter, normalizeRevisionId };
|
package/dist/model/document.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MAX_REVISION_ID, r as
|
|
2
|
-
export { DOCX_CONFORMANCE_CLASSES, MAX_REVISION_ID, normalizeRevisionId };
|
|
1
|
+
import { i as normalizeRevisionId, n as MAX_REVISION_ID, r as isOoxmlSymbolCharacter, t as DOCX_CONFORMANCE_CLASSES } from "../document-BO7h-LxY.js";
|
|
2
|
+
export { DOCX_CONFORMANCE_CLASSES, MAX_REVISION_ID, isOoxmlSymbolCharacter, normalizeRevisionId };
|
package/dist/projection.d.ts
CHANGED
|
@@ -15,6 +15,22 @@ type DocxProjectionStructuralFacts = readonly [indentation: DocxProjectionFactSe
|
|
|
15
15
|
type DocxProjectionRevisionUnsupportedReason = "incompatible-paragraph-merge" | "structural-table-revision" | "unsupported-revision-markup";
|
|
16
16
|
type DocxProjectionRevisionStatus = readonly [status: "complete"] | readonly [status: "incomplete", reasons: readonly DocxProjectionRevisionUnsupportedReason[]];
|
|
17
17
|
type DocxProjectionWire = readonly [schemaVersion: 2, paragraphs: readonly DocxProjectionParagraph[], structuralFacts: DocxProjectionStructuralFacts, revisionStatus: DocxProjectionRevisionStatus];
|
|
18
|
+
type DocxReviewUnknownReason = "invalid-document" | "invalid-comments" | "invalid-comments-extended" | "resource-limit" | "unsupported-location";
|
|
19
|
+
type DocxReviewFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
|
|
20
|
+
type DocxReviewDetail<T> = readonly [status: "known", value: T] | readonly [status: "unknown", reason: DocxReviewUnknownReason];
|
|
21
|
+
type DocxReviewPoint = readonly [paragraphOrdinal: number, utf8: number, utf16: number];
|
|
22
|
+
type DocxReviewSpan = readonly [start: DocxReviewPoint, end: DocxReviewPoint];
|
|
23
|
+
/** Compact versioned boundary tuple. Field order is stable within schema version 1. */
|
|
24
|
+
type DocxRevisionContent = readonly [span: DocxReviewSpan, text: string, contentKind: "text" | "formatting-only"];
|
|
25
|
+
type DocxCommentContent = readonly [anchor: DocxReviewSpan, commentText: string, referencedText: string];
|
|
26
|
+
/** Attributed revision wire tuple; positions are named and versioned by its container. */
|
|
27
|
+
type DocxAttributedRevision = readonly [type: "insertion" | "deletion" | "moveFrom" | "moveTo" | "cellIns" | "cellDel" | "cellMerge" | "pPrChange" | "rPrChange" | "sectPrChange" | "tblPrChange" | "trPrChange" | "tcPrChange" | "tblGridChange" | "customXmlDelRangeStart" | "customXmlDelRangeEnd" | "customXmlInsRangeStart" | "customXmlInsRangeEnd" | "customXmlMoveFromRangeStart" | "customXmlMoveFromRangeEnd" | "customXmlMoveToRangeStart" | "customXmlMoveToRangeEnd", author: string, date: string | null, revisionId: string | null, content: DocxReviewDetail<DocxRevisionContent>];
|
|
28
|
+
/** Attributed comment wire tuple; positions are named and versioned by its container. */
|
|
29
|
+
type DocxAttributedComment = readonly [commentId: string, author: string, initials: string | null, date: string | null, parentCommentId: string | null, threadState: "open" | "resolved", content: DocxReviewDetail<DocxCommentContent>];
|
|
30
|
+
/** Review-fact wire schema. A new tuple layout requires a schema-version bump. */
|
|
31
|
+
type DocxReviewFactsWire = readonly [schemaVersion: 1, revisions: DocxReviewFactSet<DocxAttributedRevision>, comments: DocxReviewFactSet<DocxAttributedComment>];
|
|
32
|
+
/** Fused package wire schema. A new tuple layout requires a schema-version bump. */
|
|
33
|
+
type DocxPackageProjectionWire = readonly [schemaVersion: 1, document: DocxProjectionWire, reviewFacts: DocxReviewFactsWire];
|
|
18
34
|
//#endregion
|
|
19
35
|
//#region src/projection.d.ts
|
|
20
36
|
declare const DocxProjectionInitializationError_base: import("better-result").TaggedErrorClass<"DocxProjectionInitializationError", {
|
|
@@ -35,13 +51,19 @@ type InitializeDocxProjectionOptions = {
|
|
|
35
51
|
*/
|
|
36
52
|
wasm?: DocxProjectionWasmSource;
|
|
37
53
|
};
|
|
54
|
+
/** Controls text materialization for fused document and review-fact projection. */
|
|
55
|
+
type ProjectCompressedDocxWithReviewFactsOptions = {
|
|
56
|
+
/** Selects host-coordinate controls or normalized readable text. */
|
|
57
|
+
textMaterialization?: "word-host" | "readable-plain-text";
|
|
58
|
+
};
|
|
38
59
|
/** Loads and caches the single-threaded WebAssembly runtime. */
|
|
39
60
|
declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
|
|
61
|
+
declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
|
|
40
62
|
/**
|
|
41
|
-
* Projects
|
|
42
|
-
*
|
|
43
|
-
*
|
|
63
|
+
* Projects the document snapshot and attributed review facts through one
|
|
64
|
+
* bounded package scan. Optional review-part failures remain explicit unknown
|
|
65
|
+
* fact families rather than invalidating the document snapshot.
|
|
44
66
|
*/
|
|
45
|
-
declare const
|
|
67
|
+
declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
|
|
46
68
|
//#endregion
|
|
47
|
-
export { 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, InitializeDocxProjectionOptions, initializeDocxProjection, projectCompressedDocx };
|
|
69
|
+
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, ProjectCompressedDocxWithReviewFactsOptions, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts };
|
package/dist/projection.js
CHANGED
|
@@ -30,6 +30,55 @@ function projectCompressedDocx$1(bytes) {
|
|
|
30
30
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
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
|
+
/**
|
|
58
|
+
* Projects the document snapshot and attributed review facts from one bounded
|
|
59
|
+
* package-directory scan.
|
|
60
|
+
*
|
|
61
|
+
* # Errors
|
|
62
|
+
*
|
|
63
|
+
* Returns a JavaScript `Error` when the document package itself cannot be
|
|
64
|
+
* projected. Invalid optional review parts are represented as unknown facts.
|
|
65
|
+
* @param {Uint8Array} bytes
|
|
66
|
+
* @returns {DocxPackageProjectionWire}
|
|
67
|
+
*/
|
|
68
|
+
function projectCompressedDocxWithReviewFacts$1(bytes) {
|
|
69
|
+
try {
|
|
70
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
71
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
72
|
+
const len0 = WASM_VECTOR_LEN;
|
|
73
|
+
wasm.projectCompressedDocxWithReviewFacts(retptr, ptr0, len0);
|
|
74
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
|
|
75
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
|
|
76
|
+
if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
|
|
77
|
+
return takeObject(r0);
|
|
78
|
+
} finally {
|
|
79
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
33
82
|
function __wbg_get_imports() {
|
|
34
83
|
return {
|
|
35
84
|
__proto__: null,
|
|
@@ -176,6 +225,8 @@ async function __wbg_init(module_or_path) {
|
|
|
176
225
|
var DocxProjectionInitializationError = class extends TaggedError("DocxProjectionInitializationError")() {};
|
|
177
226
|
var DocxProjectionError = class extends TaggedError("DocxProjectionError")() {};
|
|
178
227
|
let initialization;
|
|
228
|
+
const DOCUMENT_PROJECTION_FAILURE_MESSAGE = "Could not project the DOCX document";
|
|
229
|
+
const PACKAGE_PROJECTION_FAILURE_MESSAGE = "Could not project the DOCX package with review facts";
|
|
179
230
|
/** Loads and caches the single-threaded WebAssembly runtime. */
|
|
180
231
|
const initializeDocxProjection = ({ wasm } = {}) => {
|
|
181
232
|
initialization ??= __wbg_init(wasm === void 0 ? void 0 : { module_or_path: wasm }).then(() => void 0).catch((cause) => {
|
|
@@ -192,16 +243,31 @@ const initializeDocxProjection = ({ wasm } = {}) => {
|
|
|
192
243
|
* The TypeScript boundary initializes WebAssembly and preserves its versioned
|
|
193
244
|
* result; it does not contain an alternate OOXML parser.
|
|
194
245
|
*/
|
|
195
|
-
const
|
|
246
|
+
const projectWith = async ({ bytes, project, message }) => {
|
|
196
247
|
await initializeDocxProjection();
|
|
197
248
|
try {
|
|
198
|
-
return
|
|
249
|
+
return project(bytes);
|
|
199
250
|
} catch (cause) {
|
|
200
251
|
throw new DocxProjectionError({
|
|
201
|
-
message
|
|
252
|
+
message,
|
|
202
253
|
cause
|
|
203
254
|
});
|
|
204
255
|
}
|
|
205
256
|
};
|
|
257
|
+
const projectCompressedDocx = (bytes) => projectWith({
|
|
258
|
+
bytes,
|
|
259
|
+
project: projectCompressedDocx$1,
|
|
260
|
+
message: DOCUMENT_PROJECTION_FAILURE_MESSAGE
|
|
261
|
+
});
|
|
262
|
+
/**
|
|
263
|
+
* Projects the document snapshot and attributed review facts through one
|
|
264
|
+
* bounded package scan. Optional review-part failures remain explicit unknown
|
|
265
|
+
* fact families rather than invalidating the document snapshot.
|
|
266
|
+
*/
|
|
267
|
+
const projectCompressedDocxWithReviewFacts = (bytes, { textMaterialization = "word-host" } = {}) => projectWith({
|
|
268
|
+
bytes,
|
|
269
|
+
project: textMaterialization === "word-host" ? projectCompressedDocxWithReviewFacts$1 : projectCompressedDocxWithReadableReviewFacts,
|
|
270
|
+
message: PACKAGE_PROJECTION_FAILURE_MESSAGE
|
|
271
|
+
});
|
|
206
272
|
//#endregion
|
|
207
|
-
export { DocxProjectionError, DocxProjectionInitializationError, initializeDocxProjection, projectCompressedDocx };
|
|
273
|
+
export { DocxProjectionError, DocxProjectionInitializationError, initializeDocxProjection, projectCompressedDocx, projectCompressedDocxWithReviewFacts };
|
package/package.json
CHANGED