@stll/docx-core 0.5.1 → 0.6.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-DfFH8YGu.d.ts → document-DI8X7aZy.d.ts} +20 -1
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/model/document.d.ts +2 -2
- package/dist/projection.d.ts +47 -0
- package/dist/projection.js +207 -0
- package/package.json +8 -2
|
@@ -652,8 +652,15 @@ type TextContent = {
|
|
|
652
652
|
/**
|
|
653
653
|
* Tab character
|
|
654
654
|
*/
|
|
655
|
+
type PositionalTab = {
|
|
656
|
+
relativeTo?: "margin" | "indent";
|
|
657
|
+
alignment?: "left" | "center" | "right";
|
|
658
|
+
leader?: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
|
|
659
|
+
};
|
|
655
660
|
type TabContent = {
|
|
656
661
|
type: "tab";
|
|
662
|
+
/** Word positional-tab properties (`w:ptab`); absent for a regular `w:tab`. */
|
|
663
|
+
positional?: PositionalTab;
|
|
657
664
|
};
|
|
658
665
|
/**
|
|
659
666
|
* Line break
|
|
@@ -1000,6 +1007,11 @@ type ShapeType = "rect" | "roundRect" | "ellipse" | "triangle" | "rtTriangle" |
|
|
|
1000
1007
|
*/
|
|
1001
1008
|
type ShapeFill = {
|
|
1002
1009
|
type: "none" | "solid" | "gradient" | "pattern" | "picture";
|
|
1010
|
+
/**
|
|
1011
|
+
* Authored DrawingML retained when the normalized projection is incomplete.
|
|
1012
|
+
* Serializers prefer this value; omit it when modifying the fill.
|
|
1013
|
+
*/
|
|
1014
|
+
rawXml?: string;
|
|
1003
1015
|
/** Solid fill color */
|
|
1004
1016
|
color?: ColorValue;
|
|
1005
1017
|
/** Gradient stops for gradient fill */
|
|
@@ -1016,6 +1028,11 @@ type ShapeFill = {
|
|
|
1016
1028
|
* Shape outline/stroke
|
|
1017
1029
|
*/
|
|
1018
1030
|
type ShapeOutline = {
|
|
1031
|
+
/**
|
|
1032
|
+
* Authored DrawingML retained for lossless round-trips. Serializers prefer
|
|
1033
|
+
* this value; callers modifying structured outline fields must omit it.
|
|
1034
|
+
*/
|
|
1035
|
+
rawXml?: string;
|
|
1019
1036
|
/** Line width in EMUs */
|
|
1020
1037
|
width?: number;
|
|
1021
1038
|
/** Line color */
|
|
@@ -1176,6 +1193,8 @@ type Comment = {
|
|
|
1176
1193
|
date?: string;
|
|
1177
1194
|
/** Comment content (paragraphs) */
|
|
1178
1195
|
content: Paragraph[];
|
|
1196
|
+
/** Formatting of the structural annotation-reference run in the first paragraph */
|
|
1197
|
+
annotationReferenceFormatting?: TextFormatting;
|
|
1179
1198
|
/** Parent comment ID (for replies) */
|
|
1180
1199
|
parentId?: number;
|
|
1181
1200
|
/** Whether the comment is resolved/done */
|
|
@@ -2257,4 +2276,4 @@ type Document = {
|
|
|
2257
2276
|
warnings?: string[];
|
|
2258
2277
|
};
|
|
2259
2278
|
//#endregion
|
|
2260
|
-
export { ImageTransform as $,
|
|
2279
|
+
export { ImageTransform as $, TrackedChangeInfo as $t, ComplexField as A, TextEffect as An, SectionProperties as At, FooterReference as B, SoftHyphenContent as Bt, BookmarkStart as C, TableCellBorders as Cn, PropertyChangeInfo as Ct, CommentRangeEnd as D, TableMeasurement as Dn, SdtProperties as Dt, Comment as E, TableLook as En, RunPropertyChange as Et, EndnotePosition as F, KnownBorderStyle as Fn, ShapeFill as Ft, HeaderFooterType as G, TableCellPropertyChange as Gt, FootnotePosition as H, TabContent as Ht, EndnoteProperties as I, ShadingProperties as In, ShapeOutline as It, Image as J, TableRowPropertyChange as Jt, HeaderReference as K, TablePropertyChange as Kt, Field as L, ThemeColorSlot as Ln, ShapeTextBody as Lt, DocumentBody as M, UnderlineStyle as Mn, SectionStart as Mt, DrawingContent as N, BorderSpec as Nn, Shape as Nt, CommentRangeStart as O, TableRowFormatting as On, SdtType as Ot, Endnote as P, ColorValue as Pn, ShapeContent as Pt, ImageSize as Q, TextWatermark as Qt, FieldCharContent as R, ShapeType as Rt, BookmarkEnd as S, TableBorders as Sn, PositionalTab as St, Column as T, TableFormatting 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 _, ParagraphFormatting as _n, Paragraph as _t, DocxPackage as a, LevelSuffix as an, MAX_REVISION_ID as at, BlockContent as b, TabStop as bn, ParagraphPropertyChange as bt, FontTable as c, NumberFormat as cn, MoveFromRangeEnd as ct, RelationshipMap as d, CellMargins as dn, MoveToRangeEnd as dt, TrackedRunChange as en, ImageWrap as et, RelationshipType as f, ConditionalFormatStyle as fn, MoveToRangeStart as ft, Theme as g, ParagraphAlignment as gn, PageOrientation as gt, StyleType as h, LineSpacingRule as hn, NoteReferenceContent as ht, DocxConformanceClass as i, AbstractNumbering as in, LineNumberRestart as it, Deletion as j, TextFormatting as jn, SectionPropertyChange as jt, CommentReference as k, TableWidthType as kn, Section as kt, MediaFile as l, NumberingDefinitions as ln, MoveFromRangeStart as lt, StyleDefinitions as m, FloatingTableProperties as mn, NoteNumberRestart as mt, Document as n, Watermark as nn, Insertion as nt, DocDefaults as o, ListLevel as on, MathEquation as ot, Style as p, EmphasisMark as pn, NoBreakHyphenContent as pt, Hyperlink as q, TableRow as qt, DocumentSettings as r, normalizeRevisionId as rn, InstrTextContent as rt, FontInfo as s, ListRendering as sn, MoveFrom as st, DOCX_CONFORMANCE_CLASSES as t, VerticalAlign as tn, InlineSdt as tt, Relationship as u, NumberingInstance as un, MoveTo as ut, ThemeFont as v, SpacingExplicit as vn, ParagraphContent as vt, BreakContent as w, TableCellFormatting as wn, Run as wt, BlockSdt as x, TabStopAlignment as xn, PictureWatermark as xt, ThemeFontScheme as y, TabLeader as yn, ParagraphMarkChange as yt, FieldType as z, SimpleField as zt };
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-DI8X7aZy.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";
|
|
@@ -140,4 +140,4 @@ declare const validateDocxPackage: (buffer: ArrayBuffer | Uint8Array) => Promise
|
|
|
140
140
|
declare const validateDocumentModel: (document: Document) => ValidateDocumentModelResult;
|
|
141
141
|
declare const assertValidDocumentModel: (document: Document) => void;
|
|
142
142
|
//#endregion
|
|
143
|
-
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, type Document, type DocumentBody, type DocxConformanceClass, type DocxPackage, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type Paragraph, type ParagraphContent, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
|
143
|
+
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, type Document, type DocumentBody, type DocxConformanceClass, type DocxPackage, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type Paragraph, type ParagraphContent, type PositionalTab, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
package/dist/index.js
CHANGED
|
@@ -182,7 +182,9 @@ const serializeRunProperties = (formatting) => {
|
|
|
182
182
|
const serializeRunContent = (content) => {
|
|
183
183
|
switch (content.type) {
|
|
184
184
|
case "text": return `<w:t${content.preserveSpace ? " xml:space=\"preserve\"" : ""}>${escapeXml(content.text)}</w:t>`;
|
|
185
|
-
case "tab":
|
|
185
|
+
case "tab":
|
|
186
|
+
if (!content.positional) return "<w:tab/>";
|
|
187
|
+
return `<w:ptab${attr("w:relativeTo", content.positional.relativeTo)}${attr("w:alignment", content.positional.alignment)}${attr("w:leader", content.positional.leader)}/>`;
|
|
186
188
|
case "break": return `<w:br${attr("w:type", content.breakType)}/>`;
|
|
187
189
|
case "renderedPageBreak": return "<w:lastRenderedPageBreak/>";
|
|
188
190
|
case "symbol": return `<w:sym w:font="${escapeXml(content.font)}" w:char="${escapeXml(content.char)}"/>`;
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ImageTransform, $t 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 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 TextEffect, At as SectionProperties, B as FooterReference, Bt as SoftHyphenContent, C as BookmarkStart, Cn as TableCellBorders, Ct as PropertyChangeInfo, D as CommentRangeEnd, Dn as TableMeasurement, Dt as SdtProperties, E as Comment, En as TableLook, Et as RunPropertyChange, F as EndnotePosition, Fn as KnownBorderStyle, Ft as ShapeFill, G as HeaderFooterType, Gt as TableCellPropertyChange, H as FootnotePosition, Ht as TabContent, I as EndnoteProperties, In as ShadingProperties, It as ShapeOutline, J as Image, Jt as TableRowPropertyChange, K as HeaderReference, Kt as TablePropertyChange, L as Field, Ln as ThemeColorSlot, Lt as ShapeTextBody, M as DocumentBody, Mn as UnderlineStyle, Mt as SectionStart, N as DrawingContent, Nn as BorderSpec, Nt as Shape, O as CommentRangeStart, On as TableRowFormatting, Ot as SdtType, P as Endnote, Pn as ColorValue, Pt as ShapeContent, Q as ImageSize, Qt as TextWatermark, R as FieldCharContent, Rt as ShapeType, S as BookmarkEnd, Sn as TableBorders, St as PositionalTab, T as Column, Tn as TableFormatting, 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 ParagraphFormatting, _t as Paragraph, a as DocxPackage, an as LevelSuffix, at as MAX_REVISION_ID, b as BlockContent, bn as TabStop, bt as ParagraphPropertyChange, c as FontTable, cn as NumberFormat, ct as MoveFromRangeEnd, d as RelationshipMap, dn as CellMargins, dt as MoveToRangeEnd, en as TrackedRunChange, et as ImageWrap, f as RelationshipType, fn as ConditionalFormatStyle, ft as MoveToRangeStart, g as Theme, gn as ParagraphAlignment, gt as PageOrientation, h as StyleType, hn as LineSpacingRule, ht as NoteReferenceContent, i as DocxConformanceClass, in as AbstractNumbering, it as LineNumberRestart, j as Deletion, jn as TextFormatting, jt as SectionPropertyChange, k as CommentReference, kn as TableWidthType, kt as Section, l as MediaFile, ln as NumberingDefinitions, lt as MoveFromRangeStart, m as StyleDefinitions, mn as FloatingTableProperties, mt as NoteNumberRestart, n as Document, nn as Watermark, nt as Insertion, o as DocDefaults, on as ListLevel, ot as MathEquation, p as Style, pn as EmphasisMark, pt as NoBreakHyphenContent, q as Hyperlink, qt as TableRow, r as DocumentSettings, rn as normalizeRevisionId, rt as InstrTextContent, s as FontInfo, sn as ListRendering, st as MoveFrom, t as DOCX_CONFORMANCE_CLASSES, tn as VerticalAlign, tt as InlineSdt, u as Relationship, un as NumberingInstance, ut as MoveTo, v as ThemeFont, vn as SpacingExplicit, vt as ParagraphContent, w as BreakContent, wn as TableCellFormatting, wt as Run, x as BlockSdt, xn as TabStopAlignment, xt as PictureWatermark, y as ThemeFontScheme, yn as TabLeader, yt as ParagraphMarkChange, z as FieldType, zt as SimpleField } from "../document-DI8X7aZy.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, normalizeRevisionId };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/generated/docx_kernel.d.ts
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
type DocxProjectionFormattingSpan = readonly [startUtf16: number, endUtf16: number, style: "bold" | "highlight"];
|
|
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];
|
|
7
|
+
type DocxProjectionFactSet<T> = readonly [status: "known", items: readonly T[]] | readonly [status: "unknown", reason: DocxProjectionUnknownReason];
|
|
8
|
+
type DocxProjectionUnknownReason = "document-part-only" | "styles-part-unavailable" | "unsupported-styles" | "unsupported-numbering" | "incomplete-bookmark-ranges" | "unsupported-internal-references";
|
|
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
|
+
type DocxProjectionNumberingFact = readonly [paragraphOrdinal: number, parentParagraphOrdinal: number | null, childParagraphOrdinals: readonly number[]];
|
|
11
|
+
type DocxProjectionBookmarkFact = readonly [paragraphOrdinal: number, bookmarkId: number, name: string, span: DocxProjectionStructuralSpan];
|
|
12
|
+
type DocxProjectionReferenceFact = readonly [paragraphOrdinal: number, referenceId: string, role: "source" | "target", span: DocxProjectionStructuralSpan];
|
|
13
|
+
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 DocxProjectionRevisionUnsupportedReason = "incompatible-paragraph-merge" | "structural-table-revision" | "unsupported-revision-markup";
|
|
16
|
+
type DocxProjectionRevisionStatus = readonly [status: "complete"] | readonly [status: "incomplete", reasons: readonly DocxProjectionRevisionUnsupportedReason[]];
|
|
17
|
+
type DocxProjectionWire = readonly [schemaVersion: 2, paragraphs: readonly DocxProjectionParagraph[], structuralFacts: DocxProjectionStructuralFacts, revisionStatus: DocxProjectionRevisionStatus];
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/projection.d.ts
|
|
20
|
+
declare const DocxProjectionInitializationError_base: import("better-result").TaggedErrorClass<"DocxProjectionInitializationError", {
|
|
21
|
+
message: string;
|
|
22
|
+
cause: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
declare class DocxProjectionInitializationError extends DocxProjectionInitializationError_base {}
|
|
25
|
+
declare const DocxProjectionError_base: import("better-result").TaggedErrorClass<"DocxProjectionError", {
|
|
26
|
+
message: string;
|
|
27
|
+
cause: unknown;
|
|
28
|
+
}>;
|
|
29
|
+
declare class DocxProjectionError extends DocxProjectionError_base {}
|
|
30
|
+
type DocxProjectionWasmSource = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
31
|
+
type InitializeDocxProjectionOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Optional explicit WebAssembly source for runtimes that do not load assets
|
|
34
|
+
* by URL. Browsers normally omit this and use the package-relative asset.
|
|
35
|
+
*/
|
|
36
|
+
wasm?: DocxProjectionWasmSource;
|
|
37
|
+
};
|
|
38
|
+
/** Loads and caches the single-threaded WebAssembly runtime. */
|
|
39
|
+
declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Projects compressed DOCX bytes through the canonical Rust implementation.
|
|
42
|
+
* The TypeScript boundary initializes WebAssembly and preserves its versioned
|
|
43
|
+
* result; it does not contain an alternate OOXML parser.
|
|
44
|
+
*/
|
|
45
|
+
declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
|
|
46
|
+
//#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 };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { TaggedError } from "better-result";
|
|
2
|
+
//#region src/generated/docx_kernel.js
|
|
3
|
+
/**
|
|
4
|
+
* Projects compressed DOCX bytes into a versioned host-independent snapshot.
|
|
5
|
+
*
|
|
6
|
+
* The ordinal is the paragraph's position in this immutable package snapshot.
|
|
7
|
+
* Package `w14:paraId` values are returned separately. Neither value is an
|
|
8
|
+
* application identity or a host navigation identity. A structural fact
|
|
9
|
+
* family is `unknown` when the package does not prove completeness; an empty
|
|
10
|
+
* `known` list is authoritative negative evidence.
|
|
11
|
+
*
|
|
12
|
+
* # Errors
|
|
13
|
+
*
|
|
14
|
+
* Returns a JavaScript `Error` when the package cannot be projected or a
|
|
15
|
+
* numeric wire value cannot be represented by the schema.
|
|
16
|
+
* @param {Uint8Array} bytes
|
|
17
|
+
* @returns {DocxProjectionWire}
|
|
18
|
+
*/
|
|
19
|
+
function projectCompressedDocx$1(bytes) {
|
|
20
|
+
try {
|
|
21
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
22
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
23
|
+
const len0 = WASM_VECTOR_LEN;
|
|
24
|
+
wasm.projectCompressedDocx(retptr, ptr0, len0);
|
|
25
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
|
|
26
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
|
|
27
|
+
if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
|
|
28
|
+
return takeObject(r0);
|
|
29
|
+
} finally {
|
|
30
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function __wbg_get_imports() {
|
|
34
|
+
return {
|
|
35
|
+
__proto__: null,
|
|
36
|
+
"./docx_kernel_bg.js": {
|
|
37
|
+
__proto__: null,
|
|
38
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
39
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
40
|
+
},
|
|
41
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
42
|
+
return addHeapObject(new Array());
|
|
43
|
+
},
|
|
44
|
+
__wbg_new_b667d279fd5aa943: function(arg0, arg1) {
|
|
45
|
+
return addHeapObject(new Error(getStringFromWasm0(arg0, arg1)));
|
|
46
|
+
},
|
|
47
|
+
__wbg_new_with_length_f8cbc3a5b9ff9368: function(arg0) {
|
|
48
|
+
return addHeapObject(new Array(arg0 >>> 0));
|
|
49
|
+
},
|
|
50
|
+
__wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
|
|
51
|
+
return getObject(arg0).push(getObject(arg1));
|
|
52
|
+
},
|
|
53
|
+
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
54
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
55
|
+
},
|
|
56
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
57
|
+
return addHeapObject(arg0);
|
|
58
|
+
},
|
|
59
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
60
|
+
return addHeapObject(getStringFromWasm0(arg0, arg1));
|
|
61
|
+
},
|
|
62
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
63
|
+
takeObject(arg0);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function addHeapObject(obj) {
|
|
69
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
70
|
+
const idx = heap_next;
|
|
71
|
+
heap_next = heap[idx];
|
|
72
|
+
heap[idx] = obj;
|
|
73
|
+
return idx;
|
|
74
|
+
}
|
|
75
|
+
function dropObject(idx) {
|
|
76
|
+
if (idx < 1028) return;
|
|
77
|
+
heap[idx] = heap_next;
|
|
78
|
+
heap_next = idx;
|
|
79
|
+
}
|
|
80
|
+
let cachedDataViewMemory0 = null;
|
|
81
|
+
function getDataViewMemory0() {
|
|
82
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
83
|
+
return cachedDataViewMemory0;
|
|
84
|
+
}
|
|
85
|
+
function getStringFromWasm0(ptr, len) {
|
|
86
|
+
return decodeText(ptr >>> 0, len);
|
|
87
|
+
}
|
|
88
|
+
let cachedUint8ArrayMemory0 = null;
|
|
89
|
+
function getUint8ArrayMemory0() {
|
|
90
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
91
|
+
return cachedUint8ArrayMemory0;
|
|
92
|
+
}
|
|
93
|
+
function getObject(idx) {
|
|
94
|
+
return heap[idx];
|
|
95
|
+
}
|
|
96
|
+
let heap = new Array(1024).fill(void 0);
|
|
97
|
+
heap.push(void 0, null, true, false);
|
|
98
|
+
let heap_next = heap.length;
|
|
99
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
100
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
101
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
102
|
+
WASM_VECTOR_LEN = arg.length;
|
|
103
|
+
return ptr;
|
|
104
|
+
}
|
|
105
|
+
function takeObject(idx) {
|
|
106
|
+
const ret = getObject(idx);
|
|
107
|
+
dropObject(idx);
|
|
108
|
+
return ret;
|
|
109
|
+
}
|
|
110
|
+
let cachedTextDecoder = new TextDecoder("utf-8", {
|
|
111
|
+
ignoreBOM: true,
|
|
112
|
+
fatal: true
|
|
113
|
+
});
|
|
114
|
+
cachedTextDecoder.decode();
|
|
115
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
116
|
+
let numBytesDecoded = 0;
|
|
117
|
+
function decodeText(ptr, len) {
|
|
118
|
+
numBytesDecoded += len;
|
|
119
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
120
|
+
cachedTextDecoder = new TextDecoder("utf-8", {
|
|
121
|
+
ignoreBOM: true,
|
|
122
|
+
fatal: true
|
|
123
|
+
});
|
|
124
|
+
cachedTextDecoder.decode();
|
|
125
|
+
numBytesDecoded = len;
|
|
126
|
+
}
|
|
127
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
128
|
+
}
|
|
129
|
+
let WASM_VECTOR_LEN = 0;
|
|
130
|
+
let wasm;
|
|
131
|
+
function __wbg_finalize_init(instance, module) {
|
|
132
|
+
wasm = instance.exports;
|
|
133
|
+
cachedDataViewMemory0 = null;
|
|
134
|
+
cachedUint8ArrayMemory0 = null;
|
|
135
|
+
return wasm;
|
|
136
|
+
}
|
|
137
|
+
async function __wbg_load(module, imports) {
|
|
138
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
139
|
+
if (typeof WebAssembly.instantiateStreaming === "function") try {
|
|
140
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
if (module.ok && expectedResponseType(module.type) && module.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
143
|
+
else throw e;
|
|
144
|
+
}
|
|
145
|
+
const bytes = await module.arrayBuffer();
|
|
146
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
147
|
+
} else {
|
|
148
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
149
|
+
if (instance instanceof WebAssembly.Instance) return {
|
|
150
|
+
instance,
|
|
151
|
+
module
|
|
152
|
+
};
|
|
153
|
+
else return instance;
|
|
154
|
+
}
|
|
155
|
+
function expectedResponseType(type) {
|
|
156
|
+
switch (type) {
|
|
157
|
+
case "basic":
|
|
158
|
+
case "cors":
|
|
159
|
+
case "default": return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function __wbg_init(module_or_path) {
|
|
165
|
+
if (wasm !== void 0) return wasm;
|
|
166
|
+
if (module_or_path !== void 0) if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
|
|
167
|
+
else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
168
|
+
if (module_or_path === void 0) module_or_path = new URL("./docx_kernel_bg.wasm", import.meta.url);
|
|
169
|
+
const imports = __wbg_get_imports();
|
|
170
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) module_or_path = fetch(module_or_path);
|
|
171
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
172
|
+
return __wbg_finalize_init(instance, module);
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/projection.ts
|
|
176
|
+
var DocxProjectionInitializationError = class extends TaggedError("DocxProjectionInitializationError")() {};
|
|
177
|
+
var DocxProjectionError = class extends TaggedError("DocxProjectionError")() {};
|
|
178
|
+
let initialization;
|
|
179
|
+
/** Loads and caches the single-threaded WebAssembly runtime. */
|
|
180
|
+
const initializeDocxProjection = ({ wasm } = {}) => {
|
|
181
|
+
initialization ??= __wbg_init(wasm === void 0 ? void 0 : { module_or_path: wasm }).then(() => void 0).catch((cause) => {
|
|
182
|
+
initialization = void 0;
|
|
183
|
+
throw new DocxProjectionInitializationError({
|
|
184
|
+
message: "Could not initialize the DOCX projection runtime",
|
|
185
|
+
cause
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
return initialization;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Projects compressed DOCX bytes through the canonical Rust implementation.
|
|
192
|
+
* The TypeScript boundary initializes WebAssembly and preserves its versioned
|
|
193
|
+
* result; it does not contain an alternate OOXML parser.
|
|
194
|
+
*/
|
|
195
|
+
const projectCompressedDocx = async (bytes) => {
|
|
196
|
+
await initializeDocxProjection();
|
|
197
|
+
try {
|
|
198
|
+
return projectCompressedDocx$1(bytes);
|
|
199
|
+
} catch (cause) {
|
|
200
|
+
throw new DocxProjectionError({
|
|
201
|
+
message: "Could not project the DOCX package",
|
|
202
|
+
cause
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
export { DocxProjectionError, DocxProjectionInitializationError, initializeDocxProjection, projectCompressedDocx };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/docx-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Typed OOXML/DOCX
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Typed OOXML/DOCX model, validation, serialization, legal-source compilation, and browser-native package projection.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
7
7
|
"docx",
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"./model": {
|
|
40
40
|
"types": "./dist/model/document.d.ts",
|
|
41
41
|
"import": "./dist/model/document.js"
|
|
42
|
+
},
|
|
43
|
+
"./projection": {
|
|
44
|
+
"types": "./dist/projection.d.ts",
|
|
45
|
+
"import": "./dist/projection.js"
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"publishConfig": {
|
|
@@ -50,6 +54,8 @@
|
|
|
50
54
|
"pack:dry-run": "bun pm pack --dry-run",
|
|
51
55
|
"test": "bun test src",
|
|
52
56
|
"typecheck": "bun ../../scripts/tsc-native.ts --noEmit -p tsconfig.build.json",
|
|
57
|
+
"wasm:check": "bun ../../scripts/build-docx-kernel-wasm.ts --check",
|
|
58
|
+
"wasm:generate": "bun ../../scripts/build-docx-kernel-wasm.ts --write",
|
|
53
59
|
"format": "oxfmt .",
|
|
54
60
|
"prepack": "bun run build"
|
|
55
61
|
},
|