@stll/docx-core 0.38.0 → 0.39.1

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.
@@ -1,3 +1,4 @@
1
+ import { TaggedErrorClass } from "better-result";
1
2
  //#region src/generated/docx_kernel.d.ts
2
3
  /* tslint:disable */
3
4
  /* eslint-disable */
@@ -45,18 +46,18 @@ type DocxPackageProjectionWire = readonly [schemaVersion: 2, document: DocxProje
45
46
  type DocxProjectionContainer = "body" | "tableCell";
46
47
  //#endregion
47
48
  //#region src/projection.d.ts
48
- declare const DocxProjectionInitializationError_base: import("better-result").TaggedErrorClass<"DocxProjectionInitializationError">;
49
- declare class DocxProjectionInitializationError extends DocxProjectionInitializationError_base<{
49
+ declare const DocxProjectionInitializationErrorBase: TaggedErrorClass<"DocxProjectionInitializationError">;
50
+ export declare class DocxProjectionInitializationError extends DocxProjectionInitializationErrorBase<{
50
51
  message: string;
51
52
  cause: unknown;
52
53
  }> {}
53
- declare const DocxProjectionError_base: import("better-result").TaggedErrorClass<"DocxProjectionError">;
54
- declare class DocxProjectionError extends DocxProjectionError_base<{
54
+ declare const DocxProjectionErrorBase: TaggedErrorClass<"DocxProjectionError">;
55
+ export declare class DocxProjectionError extends DocxProjectionErrorBase<{
55
56
  message: string;
56
57
  cause: unknown;
57
58
  }> {}
58
- type DocxProjectionWasmSource = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
59
- type InitializeDocxProjectionOptions = {
59
+ export type DocxProjectionWasmSource = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
60
+ export type InitializeDocxProjectionOptions = {
60
61
  /**
61
62
  * Optional explicit WebAssembly source for runtimes that do not load assets
62
63
  * by URL. Browsers normally omit this and use the package-relative asset.
@@ -64,24 +65,24 @@ type InitializeDocxProjectionOptions = {
64
65
  wasm?: DocxProjectionWasmSource;
65
66
  };
66
67
  /** Controls text materialization for fused document and review-fact projection. */
67
- type ProjectCompressedDocxWithReviewFactsOptions = {
68
+ export type ProjectCompressedDocxWithReviewFactsOptions = {
68
69
  /** Selects host-coordinate controls or normalized readable text. */
69
70
  textMaterialization?: "word-host" | "readable-plain-text";
70
71
  };
71
72
  /** Loads and caches the single-threaded WebAssembly runtime. */
72
- declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
73
+ export declare const initializeDocxProjection: ({ wasm }?: InitializeDocxProjectionOptions) => Promise<void>;
73
74
  /** Returns the wire schema version owned by the initialized Rust runtime. */
74
- declare const docxProjectionSchemaVersion: () => Promise<number>;
75
- declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
75
+ export declare const docxProjectionSchemaVersion: () => Promise<number>;
76
+ export declare const projectCompressedDocx: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
76
77
  /** Projects raw main-document XML or a Flat OPC package through Rust. */
77
- declare const projectMainDocumentXml: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
78
+ export declare const projectMainDocumentXml: (bytes: Uint8Array) => Promise<DocxProjectionWire>;
78
79
  /** Projects one Flat OPC paragraph; document structural facts remain unknown. */
79
- declare const projectParagraphFragment: (bytes: Uint8Array) => Promise<DocxParagraphFragmentWire>;
80
+ export declare const projectParagraphFragment: (bytes: Uint8Array) => Promise<DocxParagraphFragmentWire>;
80
81
  /**
81
82
  * Projects the document snapshot and attributed review facts through one
82
83
  * bounded package scan. Optional review-part failures remain explicit unknown
83
84
  * fact families rather than invalidating the document snapshot.
84
85
  */
85
- declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
86
+ export declare const projectCompressedDocxWithReviewFacts: (bytes: Uint8Array, { textMaterialization }?: ProjectCompressedDocxWithReviewFactsOptions) => Promise<DocxPackageProjectionWire>;
86
87
  //#endregion
87
- export { type DocxAttributedComment, type DocxAttributedRevision, type DocxPackageProjectionWire, type DocxParagraphFragmentWire, type DocxProjectionAlignment, type DocxProjectionAlignmentSource, type DocxProjectionAlignmentValue, type DocxProjectionBookmarkFact, type DocxProjectionContainer, 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 };
88
+ export type { DocxAttributedComment, DocxAttributedRevision, DocxPackageProjectionWire, DocxParagraphFragmentWire, DocxProjectionAlignment, DocxProjectionAlignmentSource, DocxProjectionAlignmentValue, DocxProjectionBookmarkFact, DocxProjectionContainer, DocxProjectionFactSet, DocxProjectionFormattingCompleteness, DocxProjectionFormattingFamily, DocxProjectionFormattingFamilyStatus, DocxProjectionFormattingSpan, DocxProjectionFormattingUnknownReason, DocxProjectionIndentationFact, DocxProjectionNumberingFact, DocxProjectionOutlineLevelFact, DocxProjectionParagraph, DocxProjectionReferenceFact, DocxProjectionRevisionStatus, DocxProjectionRevisionUnsupportedReason, DocxProjectionStructuralFacts, DocxProjectionStructuralSpan, DocxProjectionStructure, DocxProjectionUnknownReason, DocxProjectionWire, DocxReviewFactSet, DocxReviewFactsWire, DocxReviewUnknownReason, DocxRevisionKind };
@@ -279,8 +279,10 @@ async function __wbg_load(module, imports) {
279
279
  }
280
280
  async function __wbg_init(module_or_path) {
281
281
  if (wasm !== void 0) return wasm;
282
- if (module_or_path !== void 0) if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
283
- else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
282
+ if (module_or_path !== void 0) {
283
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
284
+ else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
285
+ }
284
286
  if (module_or_path === void 0) module_or_path = new URL("./docx_kernel_bg.wasm", import.meta.url);
285
287
  const imports = __wbg_get_imports();
286
288
  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);
@@ -289,8 +291,10 @@ async function __wbg_init(module_or_path) {
289
291
  }
290
292
  //#endregion
291
293
  //#region src/projection.ts
292
- var DocxProjectionInitializationError = class extends TaggedError("DocxProjectionInitializationError") {};
293
- var DocxProjectionError = class extends TaggedError("DocxProjectionError") {};
294
+ const DocxProjectionInitializationErrorBase = TaggedError("DocxProjectionInitializationError");
295
+ var DocxProjectionInitializationError = class extends DocxProjectionInitializationErrorBase {};
296
+ const DocxProjectionErrorBase = TaggedError("DocxProjectionError");
297
+ var DocxProjectionError = class extends DocxProjectionErrorBase {};
294
298
  let initialization;
295
299
  const DOCUMENT_PROJECTION_FAILURE_MESSAGE = "Could not project the DOCX document";
296
300
  const PACKAGE_PROJECTION_FAILURE_MESSAGE = "Could not project the DOCX package with review facts";
@@ -17,7 +17,7 @@ import { r as PreservedMarkup } from "../preservedMarkup-G8XjWhs2.js";
17
17
  *
18
18
  * bun run generate:container-children
19
19
  */
20
- declare const SEQUENCE_CHILDREN: {
20
+ export declare const SEQUENCE_CHILDREN: {
21
21
  readonly "w:numbering": readonly ["numPicBullet", "abstractNum", "num", "numIdMacAtCleanup"];
22
22
  readonly "w:abstractNum": readonly ["nsid", "multiLevelType", "tmpl", "name", "styleLink", "numStyleLink", "lvl"];
23
23
  readonly "w:lvl": readonly ["start", "numFmt", "lvlRestart", "pStyle", "isLgl", "suff", "lvlText", "lvlPicBulletId", "legacy", "lvlJc", "pPr", "rPr"];
@@ -32,7 +32,7 @@ declare const SEQUENCE_CHILDREN: {
32
32
  readonly "content-control-properties": readonly ["rPr", "alias", "tag", "id", "lock", "placeholder", "temporary", "showingPlcHdr", "dataBinding", "label", "tabIndex", "equation", "comboBox", "date", "docPartObj", "docPartList", "dropDownList", "picture", "richText", "text", "citation", "group", "bibliography"];
33
33
  readonly "section-properties": readonly ["headerReference", "footerReference", "footnotePr", "endnotePr", "type", "pgSz", "pgMar", "paperSrc", "pgBorders", "lnNumType", "pgNumType", "cols", "formProt", "vAlign", "noEndnote", "titlePg", "textDirection", "bidi", "rtlGutter", "docGrid", "printerSettings", "sectPrChange"];
34
34
  };
35
- declare const SETTINGS_CHILDREN: readonly ["writeProtection", "view", "zoom", "removePersonalInformation", "removeDateAndTime", "doNotDisplayPageBoundaries", "displayBackgroundShape", "printPostScriptOverText", "printFractionalCharacterWidth", "printFormsData", "embedTrueTypeFonts", "embedSystemFonts", "saveSubsetFonts", "saveFormsData", "mirrorMargins", "alignBordersAndEdges", "bordersDoNotSurroundHeader", "bordersDoNotSurroundFooter", "gutterAtTop", "hideSpellingErrors", "hideGrammaticalErrors", "activeWritingStyle", "proofState", "formsDesign", "attachedTemplate", "linkStyles", "stylePaneFormatFilter", "stylePaneSortMethod", "documentType", "mailMerge", "revisionView", "trackRevisions", "doNotTrackMoves", "doNotTrackFormatting", "documentProtection", "autoFormatOverride", "styleLockTheme", "styleLockQFSet", "defaultTabStop", "autoHyphenation", "consecutiveHyphenLimit", "hyphenationZone", "doNotHyphenateCaps", "showEnvelope", "summaryLength", "clickAndTypeStyle", "defaultTableStyle", "evenAndOddHeaders", "bookFoldRevPrinting", "bookFoldPrinting", "bookFoldPrintingSheets", "drawingGridHorizontalSpacing", "drawingGridVerticalSpacing", "displayHorizontalDrawingGridEvery", "displayVerticalDrawingGridEvery", "doNotUseMarginsForDrawingGridOrigin", "drawingGridHorizontalOrigin", "drawingGridVerticalOrigin", "doNotShadeFormData", "noPunctuationKerning", "characterSpacingControl", "printTwoOnOne", "strictFirstAndLastChars", "noLineBreaksAfter", "noLineBreaksBefore", "savePreviewPicture", "doNotValidateAgainstSchema", "saveInvalidXml", "ignoreMixedContent", "alwaysShowPlaceholderText", "doNotDemarcateInvalidXml", "saveXmlDataOnly", "useXSLTWhenSaving", "saveThroughXslt", "showXMLTags", "alwaysMergeEmptyNamespace", "updateFields", "hdrShapeDefaults", "footnotePr", "endnotePr", "compat", "docVars", "rsids", "attachedSchema", "themeFontLang", "clrSchemeMapping", "doNotIncludeSubdocsInStats", "doNotAutoCompressPictures", "forceUpgrade", "captions", "readModeInkLockDown", "smartTagType", "shapeDefaults", "doNotEmbedSmartTags", "decimalSymbol", "listSeparator"];
35
+ export declare const SETTINGS_CHILDREN: readonly ["writeProtection", "view", "zoom", "removePersonalInformation", "removeDateAndTime", "doNotDisplayPageBoundaries", "displayBackgroundShape", "printPostScriptOverText", "printFractionalCharacterWidth", "printFormsData", "embedTrueTypeFonts", "embedSystemFonts", "saveSubsetFonts", "saveFormsData", "mirrorMargins", "alignBordersAndEdges", "bordersDoNotSurroundHeader", "bordersDoNotSurroundFooter", "gutterAtTop", "hideSpellingErrors", "hideGrammaticalErrors", "activeWritingStyle", "proofState", "formsDesign", "attachedTemplate", "linkStyles", "stylePaneFormatFilter", "stylePaneSortMethod", "documentType", "mailMerge", "revisionView", "trackRevisions", "doNotTrackMoves", "doNotTrackFormatting", "documentProtection", "autoFormatOverride", "styleLockTheme", "styleLockQFSet", "defaultTabStop", "autoHyphenation", "consecutiveHyphenLimit", "hyphenationZone", "doNotHyphenateCaps", "showEnvelope", "summaryLength", "clickAndTypeStyle", "defaultTableStyle", "evenAndOddHeaders", "bookFoldRevPrinting", "bookFoldPrinting", "bookFoldPrintingSheets", "drawingGridHorizontalSpacing", "drawingGridVerticalSpacing", "displayHorizontalDrawingGridEvery", "displayVerticalDrawingGridEvery", "doNotUseMarginsForDrawingGridOrigin", "drawingGridHorizontalOrigin", "drawingGridVerticalOrigin", "doNotShadeFormData", "noPunctuationKerning", "characterSpacingControl", "printTwoOnOne", "strictFirstAndLastChars", "noLineBreaksAfter", "noLineBreaksBefore", "savePreviewPicture", "doNotValidateAgainstSchema", "saveInvalidXml", "ignoreMixedContent", "alwaysShowPlaceholderText", "doNotDemarcateInvalidXml", "saveXmlDataOnly", "useXSLTWhenSaving", "saveThroughXslt", "showXMLTags", "alwaysMergeEmptyNamespace", "updateFields", "hdrShapeDefaults", "footnotePr", "endnotePr", "compat", "docVars", "rsids", "attachedSchema", "themeFontLang", "clrSchemeMapping", "doNotIncludeSubdocsInStats", "doNotAutoCompressPictures", "forceUpgrade", "captions", "readModeInkLockDown", "smartTagType", "shapeDefaults", "doNotEmbedSmartTags", "decimalSymbol", "listSeparator"];
36
36
  /** A container whose declared children have an order. */
37
37
  type SequenceContainer = keyof typeof SEQUENCE_CHILDREN;
38
38
  /** Every child the schema declares for `Container`, in declaration order. */
@@ -57,11 +57,11 @@ type SerializeSequenceChildrenOptions<Container extends SequenceContainer> = {
57
57
  preserved?: PreservedMarkup | undefined;
58
58
  };
59
59
  /** Whether a captured child is exactly one bounded, well-formed XML element. */
60
- declare const isSafePreservedChildXml: (xml: string) => boolean;
60
+ export declare const isSafePreservedChildXml: (xml: string) => boolean;
61
61
  /** Whether a capture collection stays within its aggregate resource budget. */
62
- declare const isWithinPreservedMarkupBudget: (children: Iterable<unknown>) => boolean;
62
+ export declare const isWithinPreservedMarkupBudget: (children: Iterable<unknown>) => boolean;
63
63
  /** Reject unsafe captured children before a caller performs any transformation. */
64
- declare const assertSafePreservedMarkup: (preserved: PreservedMarkup | undefined) => void;
64
+ export declare const assertSafePreservedMarkup: (preserved: PreservedMarkup | undefined) => void;
65
65
  /**
66
66
  * A property set's children, modelled and captured, in schema order.
67
67
  *
@@ -69,6 +69,6 @@ declare const assertSafePreservedMarkup: (preserved: PreservedMarkup | undefined
69
69
  * slot — an undeclared name takes the place of the last declared child before
70
70
  * it. The sort is stable and the modelled child leads.
71
71
  */
72
- declare const serializeSequenceChildren: <Container extends SequenceContainer>({ container, modelled, preserved }: SerializeSequenceChildrenOptions<Container>) => string[];
72
+ export declare const serializeSequenceChildren: <Container extends SequenceContainer>({ container, modelled, preserved }: SerializeSequenceChildrenOptions<Container>) => string[];
73
73
  //#endregion
74
- export { SEQUENCE_CHILDREN, SETTINGS_CHILDREN, type SequenceChild, type SequenceContainer, assertSafePreservedMarkup, isSafePreservedChildXml, isWithinPreservedMarkupBudget, serializeSequenceChildren };
74
+ export type { SequenceChild, SequenceContainer };
@@ -1,2 +1 @@
1
- import { a as SEQUENCE_CHILDREN, i as serializeSequenceChildren, n as isSafePreservedChildXml, o as SETTINGS_CHILDREN, r as isWithinPreservedMarkupBudget, t as assertSafePreservedMarkup } from "../sequenceChildren-B8ODeI3J.js";
2
- export { SEQUENCE_CHILDREN, SETTINGS_CHILDREN, assertSafePreservedMarkup, isSafePreservedChildXml, isWithinPreservedMarkupBudget, serializeSequenceChildren };
1
+ export { a as SEQUENCE_CHILDREN, o as SETTINGS_CHILDREN, t as assertSafePreservedMarkup, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, i as serializeSequenceChildren } from "../sequenceChildren-9SUK1Tm1.js";
@@ -1,6 +1,6 @@
1
1
  import { TaggedError } from "better-result";
2
- import { OOXML_NS } from "@stll/docx-utils";
3
2
  import { XMLParser, XMLValidator } from "fast-xml-parser";
3
+ import { OOXML_NS } from "@stll/docx-utils";
4
4
  //#region src/schema/sequenceChildren.gen.ts
5
5
  /**
6
6
  * GENERATED FILE — do not edit.
@@ -354,9 +354,27 @@ const SETTINGS_CHILDREN = [
354
354
  ];
355
355
  //#endregion
356
356
  //#region src/schema/sequenceChildren.ts
357
- const MAX_PRESERVED_CHILD_XML_CHARACTERS = 1024 * 1024;
357
+ /**
358
+ * The one writer of a property set's children, in the order the schema
359
+ * declares them.
360
+ *
361
+ * `w:rPr`, `w:tblPr` and `w:sectPr` each declare their children in one order,
362
+ * and folio writes them in it. How binding that order is differs by container:
363
+ * `CT_TblPrBase` is an `xsd:sequence` of distinct names and a validating
364
+ * consumer refuses a `w:tblPr` written in any other order, while `EG_RPrBase`
365
+ * is an `xsd:choice` referenced `maxOccurs="unbounded"`, so a `w:rPr` in any
366
+ * order is valid. Writing the canonical order anyway is what keeps two
367
+ * serializers of the same element from disagreeing, and it is what Word
368
+ * writes.
369
+ *
370
+ * The order is read from the generated list rather than restated as the order
371
+ * of a list of `if` statements — the restatement is what drifted, twice: once
372
+ * inside folio-core, and once as a second `w:rPr` writer in this package that
373
+ * put `w:sz` and `w:highlight` before `w:rFonts`.
374
+ */
375
+ const MAX_PRESERVED_CHILD_XML_CHARACTERS = 1048576;
358
376
  const MAX_PRESERVED_CHILD_COUNT = 4096;
359
- const MAX_PRESERVED_MARKUP_CHARACTERS = 4 * 1024 * 1024;
377
+ const MAX_PRESERVED_MARKUP_CHARACTERS = 4194304;
360
378
  const PRESERVED_CHILD_WRAPPER = "folio-preserved-child-root";
361
379
  const preservedChildParser = new XMLParser({
362
380
  preserveOrder: true,
@@ -370,7 +388,8 @@ const preservedChildParser = new XMLParser({
370
388
  processEntities: false,
371
389
  htmlEntities: false
372
390
  });
373
- var InvalidPreservedChildXmlError = class extends TaggedError("InvalidPreservedChildXmlError") {};
391
+ const InvalidPreservedChildXmlErrorBase = TaggedError("InvalidPreservedChildXmlError");
392
+ var InvalidPreservedChildXmlError = class extends InvalidPreservedChildXmlErrorBase {};
374
393
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
375
394
  const XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
376
395
  const XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
@@ -7,6 +7,6 @@ type WriteZipPartOptions = {
7
7
  options?: Omit<JSZip.JSZipFileOptions, "createFolders">;
8
8
  };
9
9
  /** Write exactly one entry, without synthesizing parent directory entries. */
10
- declare const writeZipPart: ({ zip, path, data, options }: WriteZipPartOptions) => void;
10
+ export declare const writeZipPart: ({ zip, path, data, options }: WriteZipPartOptions) => void;
11
11
  //#endregion
12
- export { writeZipPart };
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/docx-core",
3
- "version": "0.38.0",
3
+ "version": "0.39.1",
4
4
  "description": "Typed OOXML/DOCX model, validation, serialization, legal-source compilation, and browser-native package projection.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -74,21 +74,20 @@
74
74
  "typecheck": "bun check --no-pretty --all --project=tsconfig.build.json",
75
75
  "wasm:check": "bun ../../scripts/build-docx-kernel-wasm.ts --check",
76
76
  "wasm:generate": "bun ../../scripts/build-docx-kernel-wasm.ts --write",
77
- "format": "oxfmt .",
78
77
  "prepack": "bun run build"
79
78
  },
80
79
  "dependencies": {
81
80
  "@nodable/entities": "^3.0.0",
82
- "@stll/docx-utils": "^0.1.0",
83
- "@stll/utf8-boundaries": "0.1.0",
81
+ "@stll/docx-utils": "^0.2.0",
82
+ "@stll/utf8-boundaries": "0.1.2",
84
83
  "better-result": "3.0.1",
85
- "fast-xml-parser": "^5.10.1",
84
+ "fast-xml-parser": "^5.11.2",
86
85
  "jszip": "3.10.2",
87
- "marked": "^18.0.5"
86
+ "marked": "^18.1.1"
88
87
  },
89
88
  "devDependencies": {
90
- "bun-types": "1.4.3",
91
- "tsdown": "0.22.9"
89
+ "bun-types": "1.4.4",
90
+ "tsdown": "0.23.1"
92
91
  },
93
92
  "main": "./dist/index.js",
94
93
  "types": "./dist/index.d.ts"