@stll/docx-core 0.39.2 → 0.41.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/archive-yBR7X-Qc.js +456 -0
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/errors-Dm3jsb5q.d.ts +57 -0
- package/dist/format-DXPXB02u.js +378 -0
- package/dist/index.d.ts +6 -13
- package/dist/index.js +192 -354
- package/dist/schema/sequenceChildren.js +1 -1
- package/dist/{sequenceChildren-CrMcryEF.js → sequenceChildren-CSn0-1ov.js} +17 -45
- package/dist/streamingXmlParser-GnKxUuw_.js +743 -0
- package/dist/xml/streamingXmlParser.d.ts +109 -0
- package/dist/xml/streamingXmlParser.js +1 -0
- package/dist/xml/xmlNamespaceContext.d.ts +6 -0
- package/dist/xml/xmlNamespaceContext.js +53 -0
- package/dist/xml/xmlResourceLimits.d.ts +107 -0
- package/dist/xml/xmlResourceLimits.js +194 -0
- package/dist/xmlElement-C-vuKoul.d.ts +31 -0
- package/dist/zip/archive.d.ts +114 -0
- package/dist/zip/archive.js +3 -0
- package/dist/zip/stream.d.ts +30 -0
- package/dist/zip/stream.js +117 -0
- package/package.json +25 -8
- package/dist/zip/writeZipPart.d.ts +0 -10
- package/dist/zip/writeZipPart.js +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as SEQUENCE_CHILDREN, o as SETTINGS_CHILDREN, t as assertSafePreservedMarkup, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, i as serializeSequenceChildren } from "../sequenceChildren-
|
|
1
|
+
export { a as SEQUENCE_CHILDREN, o as SETTINGS_CHILDREN, t as assertSafePreservedMarkup, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, i as serializeSequenceChildren } from "../sequenceChildren-CSn0-1ov.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { o as readXml } from "./streamingXmlParser-GnKxUuw_.js";
|
|
1
2
|
import { TaggedError } from "better-result";
|
|
2
|
-
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
|
3
3
|
import { OOXML_NS } from "@stll/docx-utils";
|
|
4
4
|
// src/schema/sequenceChildren.gen.ts
|
|
5
5
|
/**
|
|
@@ -375,18 +375,6 @@ const MAX_PRESERVED_CHILD_XML_CHARACTERS = 1048576;
|
|
|
375
375
|
const MAX_PRESERVED_CHILD_COUNT = 4096;
|
|
376
376
|
const MAX_PRESERVED_MARKUP_CHARACTERS = 4194304;
|
|
377
377
|
const PRESERVED_CHILD_WRAPPER = "folio-preserved-child-root";
|
|
378
|
-
const preservedChildParser = new XMLParser({
|
|
379
|
-
preserveOrder: true,
|
|
380
|
-
ignoreAttributes: false,
|
|
381
|
-
attributeNamePrefix: "",
|
|
382
|
-
trimValues: false,
|
|
383
|
-
parseTagValue: false,
|
|
384
|
-
parseAttributeValue: false,
|
|
385
|
-
ignoreDeclaration: false,
|
|
386
|
-
ignorePiTags: false,
|
|
387
|
-
processEntities: false,
|
|
388
|
-
htmlEntities: false
|
|
389
|
-
});
|
|
390
378
|
const InvalidPreservedChildXmlErrorBase = TaggedError("InvalidPreservedChildXmlError");
|
|
391
379
|
var InvalidPreservedChildXmlError = class extends InvalidPreservedChildXmlErrorBase {};
|
|
392
380
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -467,12 +455,9 @@ const hasValidNamespaces = (root, inherited) => {
|
|
|
467
455
|
const current = pending.pop();
|
|
468
456
|
if (current === void 0) continue;
|
|
469
457
|
const { node, bindings: parentBindings } = current;
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
if (name.startsWith("#") || name.startsWith("?") || name.startsWith("!")) continue;
|
|
474
|
-
const rawAttributes = node[":@"];
|
|
475
|
-
const attributes = isRecord(rawAttributes) ? rawAttributes : {};
|
|
458
|
+
const name = node.name;
|
|
459
|
+
if (node.type !== "element" || name === void 0) continue;
|
|
460
|
+
const attributes = node.attributes ?? {};
|
|
476
461
|
const bindings = applyNamespaceDeclarations(attributes, parentBindings);
|
|
477
462
|
if (bindings === void 0) return false;
|
|
478
463
|
const elementPrefix = namespacePrefix(name);
|
|
@@ -489,15 +474,10 @@ const hasValidNamespaces = (root, inherited) => {
|
|
|
489
474
|
if (expandedAttributeNames.has(expandedName)) return false;
|
|
490
475
|
expandedAttributeNames.add(expandedName);
|
|
491
476
|
}
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
pending.push({
|
|
497
|
-
node: child,
|
|
498
|
-
bindings
|
|
499
|
-
});
|
|
500
|
-
}
|
|
477
|
+
for (const child of node.elements ?? []) pending.push({
|
|
478
|
+
node: child,
|
|
479
|
+
bindings
|
|
480
|
+
});
|
|
501
481
|
}
|
|
502
482
|
return true;
|
|
503
483
|
};
|
|
@@ -506,23 +486,15 @@ const isSafePreservedChildXml = (xml) => {
|
|
|
506
486
|
const trimmed = xml.trim();
|
|
507
487
|
if (trimmed.length === 0 || trimmed.length > MAX_PRESERVED_CHILD_XML_CHARACTERS || /<!\s*(?:DOCTYPE|ENTITY)\b/iu.test(trimmed) || !hasOnlyValidXmlReferences(trimmed)) return false;
|
|
508
488
|
const wrapped = `<${PRESERVED_CHILD_WRAPPER}>${trimmed}</${PRESERVED_CHILD_WRAPPER}>`;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (!isRecord(wrapper)) return false;
|
|
519
|
-
const children = wrapper[PRESERVED_CHILD_WRAPPER];
|
|
520
|
-
if (!Array.isArray(children) || children.length !== 1) return false;
|
|
521
|
-
const child = children[0];
|
|
522
|
-
if (!isRecord(child)) return false;
|
|
523
|
-
const nodeNames = Object.keys(child).filter((name) => name !== ":@");
|
|
524
|
-
const nodeName = nodeNames[0];
|
|
525
|
-
return nodeNames.length === 1 && nodeName !== void 0 && !nodeName.startsWith("#") && !nodeName.startsWith("?") && !nodeName.startsWith("!") && hasValidNamespaces(child, INHERITED_NAMESPACE_BINDINGS);
|
|
489
|
+
const read = readXml(wrapped, {
|
|
490
|
+
conformance: "well-formed",
|
|
491
|
+
references: "raw",
|
|
492
|
+
instructions: "retain"
|
|
493
|
+
});
|
|
494
|
+
if (read.status === "rejected") return false;
|
|
495
|
+
const children = read.value.elements?.at(0)?.elements ?? [];
|
|
496
|
+
const child = children.at(0);
|
|
497
|
+
return children.length === 1 && child?.type === "element" && hasValidNamespaces(child, INHERITED_NAMESPACE_BINDINGS);
|
|
526
498
|
};
|
|
527
499
|
/** Whether a capture collection stays within its aggregate resource budget. */
|
|
528
500
|
const isWithinPreservedMarkupBudget = (children) => {
|