@stll/folio-core 0.63.0 → 0.63.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.
- package/dist/ai-edits/headless.d.ts +5 -4
- package/dist/ai-edits/headless.js +10 -67
- package/dist/compare/content.d.ts +7 -7
- package/dist/compare/content.js +6 -3
- package/dist/compare/types.d.ts +15 -14
- package/dist/compare/types.js +14 -7
- package/dist/content-controls/errors.d.ts +7 -6
- package/dist/content-controls/errors.js +6 -3
- package/dist/controller/canonicalComments.d.ts +4 -3
- package/dist/controller/canonicalComments.js +2 -1
- package/dist/controller/canonicalInlineProjection.d.ts +3 -3
- package/dist/controller/canonicalInlineProjection.js +2 -1
- package/dist/controller/canonicalListRendering.d.ts +5 -3
- package/dist/controller/canonicalPublicOperations.js +2 -1
- package/dist/controller/canonicalSession.d.ts +5 -5
- package/dist/controller/canonicalSession.js +2 -1
- package/dist/controller/hiddenEditorManager.d.ts +3 -2
- package/dist/controller/hiddenEditorManager.js +2 -1
- package/dist/document-operations.d.ts +5 -4
- package/dist/document-operations.js +4 -2
- package/dist/docx/appVersionNormalization.d.ts +3 -2
- package/dist/docx/appVersionNormalization.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +3 -2
- package/dist/docx/attributeRemainder.js +2 -1
- package/dist/docx/canonicalResourceSave.d.ts +3 -2
- package/dist/docx/canonicalResourceSave.js +2 -1
- package/dist/docx/canonicalSave.d.ts +6 -4
- package/dist/docx/canonicalSave.js +2 -1
- package/dist/docx/canonicalSessionInput.d.ts +4 -3
- package/dist/docx/canonicalSessionInput.js +2 -1
- package/dist/docx/encryption/errors.d.ts +3 -2
- package/dist/docx/encryption/errors.js +2 -1
- package/dist/docx/ensureParaIds.d.ts +3 -2
- package/dist/docx/ensureParaIds.js +2 -1
- package/dist/docx/headerFooterVerbatim.d.ts +2 -2
- package/dist/docx/imageParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -0
- package/dist/docx/linkedSdtPreservation.d.ts +5 -3
- package/dist/docx/linkedSdtPreservation.js +2 -1
- package/dist/docx/metadataPrivacy.d.ts +5 -4
- package/dist/docx/metadataPrivacy.js +4 -2
- package/dist/docx/numericIdAllocator.js +2 -1
- package/dist/docx/paragraphPropertySource.d.ts +3 -2
- package/dist/docx/paragraphPropertySource.js +2 -1
- package/dist/docx/parser.d.ts +3 -2
- package/dist/docx/parser.js +2 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
- package/dist/docx/reviewResolutionProvenance.js +2 -1
- package/dist/docx/revisionIdNormalization.d.ts +3 -2
- package/dist/docx/revisionIdNormalization.js +2 -1
- package/dist/docx/rezip.d.ts +5 -4
- package/dist/docx/rezip.js +4 -2
- package/dist/docx/sectionReferenceHistory.d.ts +3 -2
- package/dist/docx/sectionReferenceHistory.js +2 -1
- package/dist/docx/serializer/paragraphSerializer.js +6 -3
- package/dist/docx/serializer/partNamespaces.d.ts +3 -2
- package/dist/docx/serializer/partNamespaces.js +2 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.d.ts +5 -4
- package/dist/docx/server/applyDocxXmlPatchProposal.js +4 -2
- package/dist/docx/server/boundedArchive.d.ts +3 -2
- package/dist/docx/server/boundedArchive.js +2 -1
- package/dist/docx/server/build.d.ts +3 -2
- package/dist/docx/server/build.js +2 -1
- package/dist/docx/server/createBilingualDocument.d.ts +3 -2
- package/dist/docx/server/createBilingualDocument.js +4 -2
- package/dist/docx/server/evaluateDocxXmlPatchProposal.d.ts +5 -4
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +4 -2
- package/dist/docx/server/inspectDocxPackage.d.ts +3 -2
- package/dist/docx/server/inspectDocxPackage.js +2 -1
- package/dist/docx/server/materializeYjsDocx.d.ts +3 -2
- package/dist/docx/server/materializeYjsDocx.js +2 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +3 -3
- package/dist/docx/server/migrateYjsAttrSchema.js +2 -1
- package/dist/docx/tableParser.d.ts +4 -4
- package/dist/docx/verbatimCapture.d.ts +3 -2
- package/dist/docx/verbatimCapture.js +2 -1
- package/dist/docx/xmlResourceLimits.d.ts +3 -2
- package/dist/docx/xmlResourceLimits.js +5 -2
- package/dist/export-pdf.d.ts +3 -3
- package/dist/export-pdf.js +2 -1
- package/dist/fonts/headlessMeasure.d.ts +3 -3
- package/dist/fonts/headlessMeasure.js +2 -1
- package/dist/fonts/sfnt/parse.d.ts +3 -3
- package/dist/fonts/sfnt/parse.js +2 -1
- package/dist/fonts/sfnt/subset.d.ts +3 -3
- package/dist/fonts/sfnt/subset.js +2 -1
- package/dist/fonts/sfnt/tables.d.ts +3 -3
- package/dist/fonts/sfnt/tables.js +2 -1
- package/dist/fonts/sfnt/woff.d.ts +3 -3
- package/dist/fonts/sfnt/woff.js +2 -1
- package/dist/headless-layout.d.ts +3 -3
- package/dist/headless-layout.js +2 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +2 -1
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +3 -20
- package/dist/layout-engine/measure/hyphenationDictionaries.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +1 -1
- package/dist/pdf/fonts.js +2 -1
- package/dist/pdf/images.d.ts +3 -3
- package/dist/pdf/images.js +2 -1
- package/dist/pdf/paint.d.ts +3 -3
- package/dist/pdf/paint.js +2 -1
- package/dist/pdf/writePdf.d.ts +3 -3
- package/dist/pdf/writePdf.js +2 -1
- package/dist/prosemirror/canonicalCommands.d.ts +9 -9
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +15 -14
- package/dist/prosemirror/commentIdAllocator.d.ts +3 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +4 -2
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +2 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +0 -10
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +0 -10
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +0 -6
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +4 -4
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +0 -9
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +0 -6
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +0 -14
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +3 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +77 -46
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +2 -2
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +0 -17
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +0 -14
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +0 -8
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +0 -14
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +0 -6
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +0 -5
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +0 -17
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +0 -6
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +0 -7
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -7
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +0 -22
- package/dist/prosemirror/extensions/nodes/BlockMoveRangeBoundaryExtension.d.ts +0 -14
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +0 -17
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +0 -8
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +0 -7
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +0 -25
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +0 -9
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +0 -6
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +0 -3
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +0 -7
- package/dist/prosemirror/hyperlinkRemoval.d.ts +3 -2
- package/dist/prosemirror/hyperlinkRemoval.js +2 -1
- package/dist/prosemirror/markupViewProjection.d.ts +3 -3
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +6 -5
- package/dist/prosemirror/noteReferenceOccurrences.js +4 -2
- package/dist/prosemirror/numberingAttr.d.ts +5 -5
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +4 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +4 -4
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +2 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +2 -2
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +4 -4
- package/dist/prosemirror/plugins/documentStyleState.d.ts +4 -4
- package/dist/prosemirror/plugins/revisionIds.d.ts +3 -2
- package/dist/prosemirror/plugins/revisionIds.js +2 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +2 -2
- package/dist/prosemirror/plugins/suggestionMode.d.ts +2 -2
- package/dist/prosemirror/plugins/templateDirectives.d.ts +5 -5
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +4 -4
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +2 -2
- package/dist/prosemirror/preservedXmlReview.d.ts +2 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +7 -7
- package/dist/prosemirror/schema/index.d.ts +2 -1
- package/dist/prosemirror/schema/index.js +0 -7
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -1
- package/dist/prosemirror/textInput.d.ts +3 -2
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +8 -8
- package/dist/prosemirror/yjsDocumentMetadata.js +6 -3
- package/dist/redline.d.ts +5 -4
- package/dist/redline.js +4 -2
- package/dist/redlineOperationLimit.d.ts +3 -2
- package/dist/redlineOperationLimit.js +2 -1
- package/dist/render-dom/commentAnchorAttributes.d.ts +1 -1
- package/dist/shaping/shaper.d.ts +3 -21
- package/dist/shaping/shaper.js +2 -1
- package/dist/utils/clipboard.d.ts +2 -2
- package/dist/utils/clipboard.js +2 -2
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/units.d.ts +1 -1
- package/dist/version-comparison.d.ts +3 -2
- package/dist/version-comparison.js +2 -1
- package/package.json +3 -3
|
@@ -354,7 +354,8 @@ function serializeComplexField(field) {
|
|
|
354
354
|
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="end"/></w:r>`);
|
|
355
355
|
return parts.join("");
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
const UnrepresentableTrackedCaptureErrorBase = TaggedError("UnrepresentableTrackedCaptureError");
|
|
358
|
+
var UnrepresentableTrackedCaptureError = class extends UnrepresentableTrackedCaptureErrorBase {};
|
|
358
359
|
/**
|
|
359
360
|
* Preserved markup inside a removal. Markup captured from a removal already
|
|
360
361
|
* spells its text as deleted text. Markup captured outside one and put under
|
|
@@ -368,7 +369,8 @@ function serializeRemovedPreservedInline(item) {
|
|
|
368
369
|
if (item.foldedListNumber) throw new UnrepresentableTrackedCaptureError({ message: "A folded list-number field holds markup that cannot be written as deleted content." });
|
|
369
370
|
return item.xml;
|
|
370
371
|
}
|
|
371
|
-
|
|
372
|
+
const UnrepresentableTrackedFieldChildErrorBase = TaggedError("UnrepresentableTrackedFieldChildError");
|
|
373
|
+
var UnrepresentableTrackedFieldChildError = class extends UnrepresentableTrackedFieldChildErrorBase {};
|
|
372
374
|
const TRACKED_FIELD_CAPTURE_NAMES = new Set(TRACKED_RUN_WORDPROCESSING_CHILDREN);
|
|
373
375
|
const replayableFieldDataXml = createCapturedXmlSanitizer({
|
|
374
376
|
allowedLocalNames: /* @__PURE__ */ new Set(["fldData"]),
|
|
@@ -555,7 +557,8 @@ const trackedChangeSegments = ({ tag, change }) => {
|
|
|
555
557
|
const attrs = serializeTrackedChangeAttributes(change.info) + serializeResolutionJoins(change.resolutionJoins);
|
|
556
558
|
return wrapTrackedInlineSegments(segments, (xml) => `<w:${tag} ${attrs}>${xml}</w:${tag}>`);
|
|
557
559
|
};
|
|
558
|
-
|
|
560
|
+
const UnrepresentableNestedHyperlinkErrorBase = TaggedError("UnrepresentableNestedHyperlinkError");
|
|
561
|
+
var UnrepresentableNestedHyperlinkError = class extends UnrepresentableNestedHyperlinkErrorBase {};
|
|
559
562
|
/** One exhaustive recursive owner for all containers inside a tracked revision. */
|
|
560
563
|
const walkTrackedInlineContent = (content, disposition) => {
|
|
561
564
|
const segments = [];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TaggedErrorClass } from "better-result";
|
|
1
2
|
import { OoxmlPrefix } from "@stll/docx-utils";
|
|
2
3
|
//#region src/docx/serializer/partNamespaces.d.ts
|
|
4
|
+
declare const UnboundNamespacePrefixErrorBase: TaggedErrorClass<"UnboundNamespacePrefixError">;
|
|
3
5
|
/**
|
|
4
6
|
* A namespace a rebuilt WordprocessingML part may declare.
|
|
5
7
|
*
|
|
@@ -33,9 +35,8 @@ export type OoxmlNamespacePrefix = Exclude<OoxmlPrefix, PackagingPrefix> | "cx"
|
|
|
33
35
|
* the two cannot drift.
|
|
34
36
|
*/
|
|
35
37
|
export declare const OOXML_NAMESPACES: Readonly<Record<OoxmlNamespacePrefix, OoxmlNamespace>>;
|
|
36
|
-
declare const UnboundNamespacePrefixError_base: import("better-result").TaggedErrorClass<"UnboundNamespacePrefixError">;
|
|
37
38
|
/** A rebuilt part uses a prefix that resolves to no namespace URI. */
|
|
38
|
-
export declare class UnboundNamespacePrefixError extends
|
|
39
|
+
export declare class UnboundNamespacePrefixError extends UnboundNamespacePrefixErrorBase<{
|
|
39
40
|
message: string;
|
|
40
41
|
partPath: string;
|
|
41
42
|
prefixes: readonly string[];
|
|
@@ -17,6 +17,7 @@ import { OOXML_NS } from "@stll/docx-utils";
|
|
|
17
17
|
* falling back to what the source part bound, and a prefix that resolves to
|
|
18
18
|
* nothing fails the save instead of being written unbound.
|
|
19
19
|
*/
|
|
20
|
+
const UnboundNamespacePrefixErrorBase = TaggedError("UnboundNamespacePrefixError");
|
|
20
21
|
/**
|
|
21
22
|
* Every namespace a rebuilt part can declare, in the order producers write them.
|
|
22
23
|
*
|
|
@@ -176,7 +177,7 @@ const OOXML_NAMESPACES = {
|
|
|
176
177
|
/** {@link OOXML_NAMESPACES} keyed for lookup by a prefix read out of markup. */
|
|
177
178
|
const NAMESPACE_TABLE = new Map(Object.entries(OOXML_NAMESPACES));
|
|
178
179
|
/** A rebuilt part uses a prefix that resolves to no namespace URI. */
|
|
179
|
-
var UnboundNamespacePrefixError = class extends
|
|
180
|
+
var UnboundNamespacePrefixError = class extends UnboundNamespacePrefixErrorBase {};
|
|
180
181
|
const XMLNS_ATTRIBUTE_PREFIX = "xmlns:";
|
|
181
182
|
/** Bound by the XML specification itself; never declared. */
|
|
182
183
|
const RESERVED_PREFIX = "xml";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocxArchiveOptions } from "./boundedArchive.js";
|
|
2
2
|
import { FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FolioDocxPreparedXmlReplacement, FolioDocxXmlPatchProposalEvaluation, FolioDocxXmlPatchProposalLimits } from "./evaluateDocxXmlPatchProposal.js";
|
|
3
3
|
import { FOLIO_DOCX_CONFORMANCE_PROFILE, FolioDocxConformanceReport } from "./validateDocxConformance.js";
|
|
4
|
+
import { TaggedErrorClass } from "better-result";
|
|
4
5
|
//#region src/docx/server/applyDocxXmlPatchProposal.d.ts
|
|
5
6
|
export declare const FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION: 1;
|
|
6
7
|
export declare const FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE: "folio-xml-patch-application-v1";
|
|
@@ -62,13 +63,13 @@ export type FolioDocxXmlPatchApplication = {
|
|
|
62
63
|
readonly receipt: FolioDocxXmlPatchApplicationReceipt;
|
|
63
64
|
readonly bytes: Uint8Array;
|
|
64
65
|
};
|
|
65
|
-
declare const
|
|
66
|
-
export declare class UnsupportedFolioDocxXmlPatchApplicationProfileError extends
|
|
66
|
+
declare const UnsupportedFolioDocxXmlPatchApplicationProfileErrorBase: TaggedErrorClass<"UnsupportedFolioDocxXmlPatchApplicationProfileError">;
|
|
67
|
+
export declare class UnsupportedFolioDocxXmlPatchApplicationProfileError extends UnsupportedFolioDocxXmlPatchApplicationProfileErrorBase<{
|
|
67
68
|
message: string;
|
|
68
69
|
profile: unknown;
|
|
69
70
|
}> {}
|
|
70
|
-
declare const
|
|
71
|
-
export declare class FolioDocxXmlPatchApplicationError extends
|
|
71
|
+
declare const FolioDocxXmlPatchApplicationErrorBase: TaggedErrorClass<"FolioDocxXmlPatchApplicationError">;
|
|
72
|
+
export declare class FolioDocxXmlPatchApplicationError extends FolioDocxXmlPatchApplicationErrorBase<{
|
|
72
73
|
message: string;
|
|
73
74
|
stage: "verify" | "load" | "replace" | "generate";
|
|
74
75
|
part?: string;
|
|
@@ -10,8 +10,10 @@ import { writeZipPart } from "@stll/docx-core/zip";
|
|
|
10
10
|
const FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION = 1;
|
|
11
11
|
const FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE = "folio-xml-patch-application-v1";
|
|
12
12
|
const isConformantReport = (report) => report.status === "conformant";
|
|
13
|
-
|
|
14
|
-
var
|
|
13
|
+
const UnsupportedFolioDocxXmlPatchApplicationProfileErrorBase = TaggedError("UnsupportedFolioDocxXmlPatchApplicationProfileError");
|
|
14
|
+
var UnsupportedFolioDocxXmlPatchApplicationProfileError = class extends UnsupportedFolioDocxXmlPatchApplicationProfileErrorBase {};
|
|
15
|
+
const FolioDocxXmlPatchApplicationErrorBase = TaggedError("FolioDocxXmlPatchApplicationError");
|
|
16
|
+
var FolioDocxXmlPatchApplicationError = class extends FolioDocxXmlPatchApplicationErrorBase {};
|
|
15
17
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
16
18
|
const snapshotInput = (bytes) => Uint8Array.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes));
|
|
17
19
|
const snapshotArchiveOptions = (archive) => {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { XmlResourceLimits } from "../xmlResourceLimits.js";
|
|
2
|
+
import { TaggedErrorClass } from "better-result";
|
|
2
3
|
//#region src/docx/server/boundedArchive.d.ts
|
|
3
4
|
export declare const DOCX_MAX_ENTRY_BYTES: number;
|
|
4
5
|
export declare const DOCX_MAX_TOTAL_BYTES: number;
|
|
5
6
|
export declare const DOCX_MAX_ENTRIES = 4096;
|
|
6
7
|
export declare const DOCX_MAX_INPUT_BYTES: number;
|
|
7
|
-
declare const
|
|
8
|
+
declare const DocxArchiveErrorBase: TaggedErrorClass<"DocxArchiveError">;
|
|
8
9
|
/** Error raised when a DOCX archive cannot be loaded within configured limits. */
|
|
9
|
-
export declare class DocxArchiveError extends
|
|
10
|
+
export declare class DocxArchiveError extends DocxArchiveErrorBase<{
|
|
10
11
|
message: string;
|
|
11
12
|
reason: "load-failed" | "input-too-large" | "too-many-entries" | "entry-too-large" | "total-too-large" | "compression-ratio-exceeded" | "invalid-options";
|
|
12
13
|
cause?: unknown;
|
|
@@ -8,8 +8,9 @@ const DOCX_MAX_ENTRY_BYTES = 134217728;
|
|
|
8
8
|
const DOCX_MAX_TOTAL_BYTES = 268435456;
|
|
9
9
|
const DOCX_MAX_ENTRIES = 4096;
|
|
10
10
|
const DOCX_MAX_INPUT_BYTES = 52428800;
|
|
11
|
+
const DocxArchiveErrorBase = TaggedError("DocxArchiveError");
|
|
11
12
|
/** Error raised when a DOCX archive cannot be loaded within configured limits. */
|
|
12
|
-
var DocxArchiveError = class extends
|
|
13
|
+
var DocxArchiveError = class extends DocxArchiveErrorBase {};
|
|
13
14
|
const readLimitError = ({ limit, path, maxEntryBytes, maxTotalBytes, maxCompressionRatio }) => {
|
|
14
15
|
switch (limit) {
|
|
15
16
|
case "declared-size": return new DocxArchiveError({
|
|
@@ -2,16 +2,17 @@ import { ShadingProperties } from "../../types/colors.js";
|
|
|
2
2
|
import { document_d_exports } from "../../types/document.js";
|
|
3
3
|
import { ParagraphFormatting, TextFormatting } from "../../types/formatting.js";
|
|
4
4
|
import { Hyperlink, Paragraph, ParagraphContent, Run, Table } from "../../types/content.js";
|
|
5
|
+
import { TaggedErrorClass } from "better-result";
|
|
5
6
|
//#region src/docx/server/build.d.ts
|
|
7
|
+
declare const InvalidFolioReportBuilderOptionsErrorBase: TaggedErrorClass<"InvalidFolioReportBuilderOptionsError">;
|
|
6
8
|
export declare const HEADING_LEVELS: readonly [1, 2, 3, 4, 5, 6];
|
|
7
9
|
export type HeadingLevel = (typeof HEADING_LEVELS)[number];
|
|
8
|
-
declare const InvalidFolioReportBuilderOptionsError_base: import("better-result").TaggedErrorClass<"InvalidFolioReportBuilderOptionsError">;
|
|
9
10
|
/**
|
|
10
11
|
* A builder received a value outside the model's domain (a zero `gridSpan`,
|
|
11
12
|
* a negative column width, a reversed TOC range). Thrown at the boundary so
|
|
12
13
|
* the invalid value never reaches the serializer.
|
|
13
14
|
*/
|
|
14
|
-
export declare class InvalidFolioReportBuilderOptionsError extends
|
|
15
|
+
export declare class InvalidFolioReportBuilderOptionsError extends InvalidFolioReportBuilderOptionsErrorBase<{
|
|
15
16
|
message: string;
|
|
16
17
|
path: string;
|
|
17
18
|
}> {}
|
|
@@ -11,6 +11,7 @@ import { assertValidOoxmlNumericId, finalizeParagraphFormatting } from "@stll/do
|
|
|
11
11
|
* without hand-writing model literals. They build model values only; the
|
|
12
12
|
* serializer owns the OOXML.
|
|
13
13
|
*/
|
|
14
|
+
const InvalidFolioReportBuilderOptionsErrorBase = TaggedError("InvalidFolioReportBuilderOptionsError");
|
|
14
15
|
/** Character style applied to hyperlink text; present in the bundled style sets. */
|
|
15
16
|
const HYPERLINK_STYLE_ID = "Hyperlink";
|
|
16
17
|
/** Character style applied to the endnote reference mark. */
|
|
@@ -44,7 +45,7 @@ const TOC_LEVEL_MAX = 9;
|
|
|
44
45
|
* a negative column width, a reversed TOC range). Thrown at the boundary so
|
|
45
46
|
* the invalid value never reaches the serializer.
|
|
46
47
|
*/
|
|
47
|
-
var InvalidFolioReportBuilderOptionsError = class extends
|
|
48
|
+
var InvalidFolioReportBuilderOptionsError = class extends InvalidFolioReportBuilderOptionsErrorBase {};
|
|
48
49
|
const assertPositiveInteger = (value, path) => {
|
|
49
50
|
if (!Number.isInteger(value) || value < 1) throw new InvalidFolioReportBuilderOptionsError({
|
|
50
51
|
message: `${path} must be a positive integer, got ${String(value)}`,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { TaggedErrorClass } from "better-result";
|
|
2
3
|
//#region src/docx/server/createBilingualDocument.d.ts
|
|
3
4
|
export type BilingualRowKind = "paragraph" | "heading" | "listItem";
|
|
4
5
|
/** One translatable unit: a source paragraph and its right-column copy. */
|
|
@@ -66,8 +67,8 @@ export type CreateBilingualDocumentResult = {
|
|
|
66
67
|
/** Non-fatal fidelity notes (for example an unresolvable numbering style link). */
|
|
67
68
|
warnings: string[];
|
|
68
69
|
};
|
|
69
|
-
declare const
|
|
70
|
-
export declare class InvalidBilingualDocumentOptionsError extends
|
|
70
|
+
declare const InvalidBilingualDocumentOptionsErrorBase: TaggedErrorClass<"InvalidBilingualDocumentOptionsError">;
|
|
71
|
+
export declare class InvalidBilingualDocumentOptionsError extends InvalidBilingualDocumentOptionsErrorBase<{
|
|
71
72
|
message: string;
|
|
72
73
|
option: "tableLayout" | "targetStyleSuffix";
|
|
73
74
|
}> {}
|
|
@@ -35,8 +35,10 @@ import { finalizeParagraphFormatting } from "@stll/docx-core/model";
|
|
|
35
35
|
const BILINGUAL_TABLE_LAYOUTS = ["inline", "stacked"];
|
|
36
36
|
const STYLE_SUFFIX_PATTERN = /^[A-Za-z0-9-]+$/u;
|
|
37
37
|
const DEFAULT_TABLE_LAYOUT = BILINGUAL_TABLE_LAYOUTS[0];
|
|
38
|
-
|
|
39
|
-
var
|
|
38
|
+
const InvalidBilingualDocumentOptionsErrorBase = TaggedError("InvalidBilingualDocumentOptionsError");
|
|
39
|
+
var InvalidBilingualDocumentOptionsError = class extends InvalidBilingualDocumentOptionsErrorBase {};
|
|
40
|
+
const UneditableBilingualManifestErrorBase = TaggedError("UneditableBilingualManifestError");
|
|
41
|
+
var UneditableBilingualManifestError = class extends UneditableBilingualManifestErrorBase {};
|
|
40
42
|
const FULL_WIDTH_PCT = 5e3;
|
|
41
43
|
const HALF_WIDTH_PCT = 2500;
|
|
42
44
|
const A4_TEXT_WIDTH_TWIPS = 9072;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocxArchiveOptions } from "./boundedArchive.js";
|
|
2
|
+
import { TaggedErrorClass } from "better-result";
|
|
2
3
|
//#region src/docx/server/evaluateDocxXmlPatchProposal.d.ts
|
|
3
4
|
export declare const FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION: 1;
|
|
4
5
|
export declare const FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE: "folio-xml-patch-proposal-v1";
|
|
@@ -62,14 +63,14 @@ export type FolioDocxXmlPatchProposalEvaluation = {
|
|
|
62
63
|
readonly replacements: readonly [];
|
|
63
64
|
readonly limits: Required<FolioDocxXmlPatchProposalLimits>;
|
|
64
65
|
};
|
|
65
|
-
declare const
|
|
66
|
-
export declare class InvalidFolioDocxXmlPatchProposalError extends
|
|
66
|
+
declare const InvalidFolioDocxXmlPatchProposalErrorBase: TaggedErrorClass<"InvalidFolioDocxXmlPatchProposalError">;
|
|
67
|
+
export declare class InvalidFolioDocxXmlPatchProposalError extends InvalidFolioDocxXmlPatchProposalErrorBase<{
|
|
67
68
|
message: string;
|
|
68
69
|
path: string;
|
|
69
70
|
reason: string;
|
|
70
71
|
}> {}
|
|
71
|
-
declare const
|
|
72
|
-
export declare class InvalidFolioDocxXmlPatchProposalOptionsError extends
|
|
72
|
+
declare const InvalidFolioDocxXmlPatchProposalOptionsErrorBase: TaggedErrorClass<"InvalidFolioDocxXmlPatchProposalOptionsError">;
|
|
73
|
+
export declare class InvalidFolioDocxXmlPatchProposalOptionsError extends InvalidFolioDocxXmlPatchProposalOptionsErrorBase<{
|
|
73
74
|
message: string;
|
|
74
75
|
path: string;
|
|
75
76
|
}> {}
|
|
@@ -44,8 +44,10 @@ const XML_SAFETY_ISSUE = {
|
|
|
44
44
|
message: "Replacement XML must be well formed."
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
var
|
|
47
|
+
const InvalidFolioDocxXmlPatchProposalErrorBase = TaggedError("InvalidFolioDocxXmlPatchProposalError");
|
|
48
|
+
var InvalidFolioDocxXmlPatchProposalError = class extends InvalidFolioDocxXmlPatchProposalErrorBase {};
|
|
49
|
+
const InvalidFolioDocxXmlPatchProposalOptionsErrorBase = TaggedError("InvalidFolioDocxXmlPatchProposalOptionsError");
|
|
50
|
+
var InvalidFolioDocxXmlPatchProposalOptionsError = class extends InvalidFolioDocxXmlPatchProposalOptionsErrorBase {};
|
|
49
51
|
const SHA256_PATTERN = /^[\da-f]{64}$/u;
|
|
50
52
|
const XML_DECLARED_ENCODING_PATTERN = /^\uFEFF?<\?xml[^>]*\bencoding\s*=\s*["']([^"']+)["'][^>]*\?>/iu;
|
|
51
53
|
const MAX_PACKAGE_PATH_CODE_UNITS = 1024;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocxArchiveOptions } from "./boundedArchive.js";
|
|
2
|
+
import { TaggedErrorClass } from "better-result";
|
|
2
3
|
//#region src/docx/server/inspectDocxPackage.d.ts
|
|
3
4
|
export declare const FOLIO_DOCX_PACKAGE_INSPECTION_VERSION: 1;
|
|
4
5
|
export declare const FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS: Readonly<{
|
|
@@ -8,8 +9,8 @@ export declare const FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS: Readonly<{
|
|
|
8
9
|
}>;
|
|
9
10
|
export declare const FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES: readonly ["invalid-limits", "too-many-xml-parts", "duplicate-xml-part", "part-not-found", "part-not-xml", "xml-part-too-large", "xml-total-too-large", "xml-decode-failed"];
|
|
10
11
|
export type FolioDocxPackageInspectionErrorCode = (typeof FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES)[number];
|
|
11
|
-
declare const
|
|
12
|
-
export declare class FolioDocxPackageInspectionError extends
|
|
12
|
+
declare const FolioDocxPackageInspectionErrorBase: TaggedErrorClass<"FolioDocxPackageInspectionError">;
|
|
13
|
+
export declare class FolioDocxPackageInspectionError extends FolioDocxPackageInspectionErrorBase<{
|
|
13
14
|
message: string;
|
|
14
15
|
code: FolioDocxPackageInspectionErrorCode;
|
|
15
16
|
part?: string;
|
|
@@ -20,7 +20,8 @@ const FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES = Object.freeze([
|
|
|
20
20
|
"xml-total-too-large",
|
|
21
21
|
"xml-decode-failed"
|
|
22
22
|
]);
|
|
23
|
-
|
|
23
|
+
const FolioDocxPackageInspectionErrorBase = TaggedError("FolioDocxPackageInspectionError");
|
|
24
|
+
var FolioDocxPackageInspectionError = class extends FolioDocxPackageInspectionErrorBase {};
|
|
24
25
|
const CONTENT_TYPES_PATH = "[Content_Types].xml";
|
|
25
26
|
const CONTENT_TYPES_READ_LIMIT = 4194304;
|
|
26
27
|
const XML_PATH_PATTERN = /(?:\.xml|\.rels)$/iu;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { TaggedErrorClass } from "better-result";
|
|
1
2
|
//#region src/docx/server/materializeYjsDocx.d.ts
|
|
3
|
+
declare const FolioYjsDocxMaterializationErrorBase: TaggedErrorClass<"FolioYjsDocxMaterializationError">;
|
|
2
4
|
/** Yjs fragment that stores Folio's canonical ProseMirror document. */
|
|
3
5
|
export declare const FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME = "prosemirror";
|
|
4
6
|
/** Maximum accepted size of a complete Yjs collaboration state update. */
|
|
@@ -7,9 +9,8 @@ export declare const FOLIO_YJS_UPDATE_MAX_BYTES: number;
|
|
|
7
9
|
export declare const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES: readonly ["empty_update", "invalid_update", "missing_document", "source_mismatch", "stale_attr_schema", "update_too_large"];
|
|
8
10
|
/** Failure code for a rejected Yjs-to-DOCX materialization request. */
|
|
9
11
|
export type FolioYjsDocxMaterializationErrorCode = (typeof FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES)[number];
|
|
10
|
-
declare const FolioYjsDocxMaterializationError_base: import("better-result").TaggedErrorClass<"FolioYjsDocxMaterializationError">;
|
|
11
12
|
/** Typed failure raised when a collaboration snapshot cannot be materialized. */
|
|
12
|
-
export declare class FolioYjsDocxMaterializationError extends
|
|
13
|
+
export declare class FolioYjsDocxMaterializationError extends FolioYjsDocxMaterializationErrorBase<{
|
|
13
14
|
code: FolioYjsDocxMaterializationErrorCode;
|
|
14
15
|
message: string;
|
|
15
16
|
cause?: unknown;
|
|
@@ -8,6 +8,7 @@ import { Result, TaggedError } from "better-result";
|
|
|
8
8
|
import { initProseMirrorDoc } from "y-prosemirror";
|
|
9
9
|
import * as Y from "yjs";
|
|
10
10
|
//#region src/docx/server/materializeYjsDocx.ts
|
|
11
|
+
const FolioYjsDocxMaterializationErrorBase = TaggedError("FolioYjsDocxMaterializationError");
|
|
11
12
|
/** Yjs fragment that stores Folio's canonical ProseMirror document. */
|
|
12
13
|
const FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME = "prosemirror";
|
|
13
14
|
/** Maximum accepted size of a complete Yjs collaboration state update. */
|
|
@@ -22,7 +23,7 @@ const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES = [
|
|
|
22
23
|
"update_too_large"
|
|
23
24
|
];
|
|
24
25
|
/** Typed failure raised when a collaboration snapshot cannot be materialized. */
|
|
25
|
-
var FolioYjsDocxMaterializationError = class extends
|
|
26
|
+
var FolioYjsDocxMaterializationError = class extends FolioYjsDocxMaterializationErrorBase {};
|
|
26
27
|
const readProseMirrorDocument = (yjsUpdate) => {
|
|
27
28
|
if (yjsUpdate.byteLength === 0) throw new FolioYjsDocxMaterializationError({
|
|
28
29
|
code: "empty_update",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FolioYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
2
|
-
import { Result } from "better-result";
|
|
2
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
3
3
|
//#region src/docx/server/migrateYjsAttrSchema.d.ts
|
|
4
|
+
declare const FolioYjsSnapshotMigrationErrorBase: TaggedErrorClass<"FolioYjsSnapshotMigrationError">;
|
|
4
5
|
/** Stable failure codes returned by an offline snapshot migration. */
|
|
5
6
|
export declare const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES: readonly ["invalid_update", "unsupported_version", "update_too_large"];
|
|
6
7
|
/** Failure code for a snapshot that could not be migrated. */
|
|
7
8
|
export type FolioYjsSnapshotMigrationErrorCode = (typeof FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES)[number];
|
|
8
|
-
declare const FolioYjsSnapshotMigrationError_base: import("better-result").TaggedErrorClass<"FolioYjsSnapshotMigrationError">;
|
|
9
9
|
/** Typed failure raised when a collaboration snapshot cannot be migrated. */
|
|
10
|
-
export declare class FolioYjsSnapshotMigrationError extends
|
|
10
|
+
export declare class FolioYjsSnapshotMigrationError extends FolioYjsSnapshotMigrationErrorBase<{
|
|
11
11
|
code: FolioYjsSnapshotMigrationErrorCode;
|
|
12
12
|
message: string;
|
|
13
13
|
cause?: unknown;
|
|
@@ -3,6 +3,7 @@ import { FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME } from "./materializeYjsDocx.js";
|
|
|
3
3
|
import { Result, TaggedError } from "better-result";
|
|
4
4
|
import * as Y from "yjs";
|
|
5
5
|
//#region src/docx/server/migrateYjsAttrSchema.ts
|
|
6
|
+
const FolioYjsSnapshotMigrationErrorBase = TaggedError("FolioYjsSnapshotMigrationError");
|
|
6
7
|
/** Stable failure codes returned by an offline snapshot migration. */
|
|
7
8
|
const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES = [
|
|
8
9
|
"invalid_update",
|
|
@@ -10,7 +11,7 @@ const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES = [
|
|
|
10
11
|
"update_too_large"
|
|
11
12
|
];
|
|
12
13
|
/** Typed failure raised when a collaboration snapshot cannot be migrated. */
|
|
13
|
-
var FolioYjsSnapshotMigrationError = class extends
|
|
14
|
+
var FolioYjsSnapshotMigrationError = class extends FolioYjsSnapshotMigrationErrorBase {};
|
|
14
15
|
/**
|
|
15
16
|
* Carry a stored collaboration snapshot forward to the attr schema this build
|
|
16
17
|
* writes, without a ProseMirror schema and without rebuilding a single node.
|
|
@@ -166,16 +166,16 @@ export declare const CELL_CONTENT_HANDLERS: {
|
|
|
166
166
|
readonly permStart: "capture";
|
|
167
167
|
readonly proofErr: "capture";
|
|
168
168
|
readonly moveFromRangeStart: (child: XmlElement, walk: {
|
|
169
|
-
modelled:
|
|
169
|
+
modelled: document_d_exports.BlockContent[];
|
|
170
170
|
}) => void;
|
|
171
171
|
readonly moveFromRangeEnd: (child: XmlElement, walk: {
|
|
172
|
-
modelled:
|
|
172
|
+
modelled: document_d_exports.BlockContent[];
|
|
173
173
|
}) => void;
|
|
174
174
|
readonly moveToRangeStart: (child: XmlElement, walk: {
|
|
175
|
-
modelled:
|
|
175
|
+
modelled: document_d_exports.BlockContent[];
|
|
176
176
|
}) => void;
|
|
177
177
|
readonly moveToRangeEnd: (child: XmlElement, walk: {
|
|
178
|
-
modelled:
|
|
178
|
+
modelled: document_d_exports.BlockContent[];
|
|
179
179
|
}) => void;
|
|
180
180
|
readonly p: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, options, modelled }: CellChildrenWalk) => void;
|
|
181
181
|
readonly tbl: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, options, modelled }: CellChildrenWalk) => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement, XmlNamespaceScope } from "./xmlParser.js";
|
|
3
|
+
import { TaggedErrorClass } from "better-result";
|
|
3
4
|
//#region src/docx/verbatimCapture.d.ts
|
|
4
|
-
declare const
|
|
5
|
+
declare const UntranslatableStrictNamespaceErrorBase: TaggedErrorClass<"UntranslatableStrictNamespaceError">;
|
|
5
6
|
/** A Strict fragment uses a namespace that has no Transitional counterpart. */
|
|
6
|
-
export declare class UntranslatableStrictNamespaceError extends
|
|
7
|
+
export declare class UntranslatableStrictNamespaceError extends UntranslatableStrictNamespaceErrorBase<{
|
|
7
8
|
message: string;
|
|
8
9
|
uri: string;
|
|
9
10
|
}> {}
|
|
@@ -24,8 +24,9 @@ import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
|
24
24
|
* to know: {@link captureVerbatimXml} is the only producer of replayed markup,
|
|
25
25
|
* and a fragment that carries no Strict namespace passes through byte for byte.
|
|
26
26
|
*/
|
|
27
|
+
const UntranslatableStrictNamespaceErrorBase = TaggedError("UntranslatableStrictNamespaceError");
|
|
27
28
|
/** A Strict fragment uses a namespace that has no Transitional counterpart. */
|
|
28
|
-
var UntranslatableStrictNamespaceError = class extends
|
|
29
|
+
var UntranslatableStrictNamespaceError = class extends UntranslatableStrictNamespaceErrorBase {};
|
|
29
30
|
const TRANSITIONAL_URIS = new Set(TRANSITIONAL_NAMESPACE_BY_STRICT_URI.values());
|
|
30
31
|
const XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
|
|
31
32
|
const XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { TaggedErrorClass } from "better-result";
|
|
1
2
|
//#region src/docx/xmlResourceLimits.d.ts
|
|
3
|
+
declare const XmlResourceLimitErrorBase: TaggedErrorClass<"XmlResourceLimitError">;
|
|
2
4
|
/**
|
|
3
5
|
* Shared bounds for XML parts parsed by Folio.
|
|
4
6
|
*
|
|
@@ -58,9 +60,8 @@ export type XmlResourceLimits = {
|
|
|
58
60
|
maxAttributesPerPackage: number;
|
|
59
61
|
};
|
|
60
62
|
type XmlResourceLimitKind = "bytes" | "depth" | "elements" | "attributes" | "package-elements" | "package-attributes" | "syntax";
|
|
61
|
-
declare const XmlResourceLimitError_base: import("better-result").TaggedErrorClass<"XmlResourceLimitError">;
|
|
62
63
|
/** XML input exceeded a parser resource bound or could not be scanned safely. */
|
|
63
|
-
export declare class XmlResourceLimitError extends
|
|
64
|
+
export declare class XmlResourceLimitError extends XmlResourceLimitErrorBase<{
|
|
64
65
|
message: string;
|
|
65
66
|
limit: XmlResourceLimitKind;
|
|
66
67
|
/** The package part being scanned, when the caller named one. */
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { TaggedError } from "better-result";
|
|
2
|
+
//#region src/docx/xmlResourceLimits.ts
|
|
3
|
+
const MEBIBYTE = 1048576;
|
|
4
|
+
const XmlResourceLimitErrorBase = TaggedError("XmlResourceLimitError");
|
|
2
5
|
/**
|
|
3
6
|
* Shared bounds for XML parts parsed by Folio.
|
|
4
7
|
*
|
|
@@ -38,7 +41,7 @@ import { TaggedError } from "better-result";
|
|
|
38
41
|
* every bound. Lower these to trade format reach for a smaller ceiling.
|
|
39
42
|
*/
|
|
40
43
|
const FOLIO_XML_RESOURCE_LIMITS = {
|
|
41
|
-
maxBytes:
|
|
44
|
+
maxBytes: 128 * MEBIBYTE,
|
|
42
45
|
maxDepth: 100,
|
|
43
46
|
/** 1.68x the corpus maximum (596,668). Unchanged; a shipped bound is not loosened. */
|
|
44
47
|
maxElementsPerPart: 1e6,
|
|
@@ -50,7 +53,7 @@ const FOLIO_XML_RESOURCE_LIMITS = {
|
|
|
50
53
|
maxAttributesPerPackage: 3e6
|
|
51
54
|
};
|
|
52
55
|
/** XML input exceeded a parser resource bound or could not be scanned safely. */
|
|
53
|
-
var XmlResourceLimitError = class extends
|
|
56
|
+
var XmlResourceLimitError = class extends XmlResourceLimitErrorBase {};
|
|
54
57
|
const createXmlPackageBudget = () => ({
|
|
55
58
|
elements: 0,
|
|
56
59
|
attributes: 0
|
package/dist/export-pdf.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { HeadlessFontSource, HeadlessFontSubstitution } from "./fonts/headlessMe
|
|
|
4
4
|
import { HeadlessLayoutGap } from "./headless-layout.js";
|
|
5
5
|
import { PdfSubstitution } from "./pdf/fonts.js";
|
|
6
6
|
import { PdfUnencodable } from "./pdf/writePdf.js";
|
|
7
|
-
import { Result } from "better-result";
|
|
7
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
8
8
|
//#region src/export-pdf.d.ts
|
|
9
|
-
declare const
|
|
10
|
-
export declare class ExportPdfError extends
|
|
9
|
+
declare const ExportPdfErrorBase: TaggedErrorClass<"ExportPdfError">;
|
|
10
|
+
export declare class ExportPdfError extends ExportPdfErrorBase<{
|
|
11
11
|
message: string;
|
|
12
12
|
cause?: unknown;
|
|
13
13
|
}> {}
|
package/dist/export-pdf.js
CHANGED
|
@@ -31,7 +31,8 @@ import { survivingComments } from "@stll/docx-core/ops";
|
|
|
31
31
|
* `compareDocx` uses, so a caller cannot get nondeterministic output by
|
|
32
32
|
* omission.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
const ExportPdfErrorBase = TaggedError("ExportPdfError");
|
|
35
|
+
var ExportPdfError = class extends ExportPdfErrorBase {};
|
|
35
36
|
const toFontRequest = ({ family, weight, italic }) => ({
|
|
36
37
|
family,
|
|
37
38
|
bold: weight >= 700,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MeasureProvider } from "../layout-engine/measure/measureProvider.js";
|
|
2
2
|
import { Shaper } from "../shaping/shaper.js";
|
|
3
|
-
import { Result } from "better-result";
|
|
3
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
4
4
|
//#region src/fonts/headlessMeasure.d.ts
|
|
5
5
|
/** One concrete face, as a font source is asked for it. */
|
|
6
6
|
export type HeadlessFontRequest = {
|
|
@@ -30,8 +30,8 @@ export type HeadlessFontSubstitution = {
|
|
|
30
30
|
readonly requested: HeadlessFontRequest;
|
|
31
31
|
readonly reason: string;
|
|
32
32
|
};
|
|
33
|
-
declare const
|
|
34
|
-
export declare class HeadlessMeasureError extends
|
|
33
|
+
declare const HeadlessMeasureErrorBase: TaggedErrorClass<"HeadlessMeasureError">;
|
|
34
|
+
export declare class HeadlessMeasureError extends HeadlessMeasureErrorBase<{
|
|
35
35
|
message: string;
|
|
36
36
|
}> {}
|
|
37
37
|
export type HeadlessMeasureOptions = {
|
|
@@ -23,7 +23,8 @@ import { Result, TaggedError } from "better-result";
|
|
|
23
23
|
* That residue is measured rather than assumed, by the differential tests
|
|
24
24
|
* beside this file and by the paint-equivalence harness.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
const HeadlessMeasureErrorBase = TaggedError("HeadlessMeasureError");
|
|
27
|
+
var HeadlessMeasureError = class extends HeadlessMeasureErrorBase {};
|
|
27
28
|
/**
|
|
28
29
|
* Ink-bounds probe characters. The canvas backend takes its ink ascent and
|
|
29
30
|
* descent from `measureText("Hg")`, so this backend reads those same two
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result } from "better-result";
|
|
1
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
2
2
|
//#region src/fonts/sfnt/parse.d.ts
|
|
3
3
|
export type SfntFont = {
|
|
4
4
|
readonly unitsPerEm: number;
|
|
@@ -42,8 +42,8 @@ export type SfntGlyphBounds = {
|
|
|
42
42
|
readonly xMax: number;
|
|
43
43
|
readonly yMax: number;
|
|
44
44
|
};
|
|
45
|
-
declare const
|
|
46
|
-
export declare class SfntParseError extends
|
|
45
|
+
declare const SfntParseErrorBase: TaggedErrorClass<"SfntParseError">;
|
|
46
|
+
export declare class SfntParseError extends SfntParseErrorBase<{
|
|
47
47
|
message: string;
|
|
48
48
|
}> {}
|
|
49
49
|
export declare const parseSfnt: (bytes: Uint8Array) => Result<SfntFont, SfntParseError>;
|
package/dist/fonts/sfnt/parse.js
CHANGED
|
@@ -14,7 +14,8 @@ import { Result, TaggedError } from "better-result";
|
|
|
14
14
|
* before it is read, so a truncated or lying font yields an `Err` rather than
|
|
15
15
|
* a throw, and no field is ever `NaN`.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
const SfntParseErrorBase = TaggedError("SfntParseError");
|
|
18
|
+
var SfntParseError = class extends SfntParseErrorBase {};
|
|
18
19
|
const fail = (message) => Result.err(new SfntParseError({ message }));
|
|
19
20
|
/** Byte offsets inside `head`. */
|
|
20
21
|
const HEAD = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SfntFont } from "./parse.js";
|
|
2
|
-
import { Result } from "better-result";
|
|
2
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
3
3
|
//#region src/fonts/sfnt/subset.d.ts
|
|
4
|
-
declare const
|
|
5
|
-
export declare class SubsetError extends
|
|
4
|
+
declare const SubsetErrorBase: TaggedErrorClass<"SubsetError">;
|
|
5
|
+
export declare class SubsetError extends SubsetErrorBase<{
|
|
6
6
|
message: string;
|
|
7
7
|
}> {}
|
|
8
8
|
export type TrueTypeSubset = {
|
|
@@ -16,7 +16,8 @@ import { Result, TaggedError, panic } from "better-result";
|
|
|
16
16
|
* iterated in ascending numeric order and tables are written in tag order, so
|
|
17
17
|
* nothing depends on a Set's or Map's insertion order.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
const SubsetErrorBase = TaggedError("SubsetError");
|
|
20
|
+
var SubsetError = class extends SubsetErrorBase {};
|
|
20
21
|
const fail = (message) => Result.err(new SubsetError({ message }));
|
|
21
22
|
/** .notdef is glyph 0 in every font and is always kept. */
|
|
22
23
|
const NOTDEF_GLYPH_ID = 0;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Result } from "better-result";
|
|
1
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
2
2
|
//#region src/fonts/sfnt/tables.d.ts
|
|
3
|
+
declare const SfntDirectoryErrorBase: TaggedErrorClass<"SfntDirectoryError">;
|
|
3
4
|
/** Four-character table tags this package addresses by name. */
|
|
4
5
|
export declare const SFNT_TABLE: {
|
|
5
6
|
readonly cff: "CFF ";
|
|
@@ -41,9 +42,8 @@ export declare const SFNT_HEADER_SIZE = 12;
|
|
|
41
42
|
export declare const SFNT_DIRECTORY_ENTRY_SIZE = 16;
|
|
42
43
|
/** Every table starts on a four-byte boundary and is zero-padded to one. */
|
|
43
44
|
export declare const SFNT_TABLE_ALIGNMENT = 4;
|
|
44
|
-
declare const SfntDirectoryError_base: import("better-result").TaggedErrorClass<"SfntDirectoryError">;
|
|
45
45
|
/** A structural problem in the container: bad header, or a table out of bounds. */
|
|
46
|
-
export declare class SfntDirectoryError extends
|
|
46
|
+
export declare class SfntDirectoryError extends SfntDirectoryErrorBase<{
|
|
47
47
|
message: string;
|
|
48
48
|
}> {}
|
|
49
49
|
/** One entry of the table directory, already bounds-checked against the buffer. */
|
|
@@ -11,6 +11,7 @@ import { Result, TaggedError } from "better-result";
|
|
|
11
11
|
* means the two cannot disagree about what a truncated or non-monotonic
|
|
12
12
|
* table means.
|
|
13
13
|
*/
|
|
14
|
+
const SfntDirectoryErrorBase = TaggedError("SfntDirectoryError");
|
|
14
15
|
/** Four-character table tags this package addresses by name. */
|
|
15
16
|
const SFNT_TABLE = {
|
|
16
17
|
cff: "CFF ",
|
|
@@ -60,7 +61,7 @@ const DIRECTORY_ENTRY = {
|
|
|
60
61
|
};
|
|
61
62
|
const TAG_LENGTH = 4;
|
|
62
63
|
/** A structural problem in the container: bad header, or a table out of bounds. */
|
|
63
|
-
var SfntDirectoryError = class extends
|
|
64
|
+
var SfntDirectoryError = class extends SfntDirectoryErrorBase {};
|
|
64
65
|
/** Whether `[offset, offset + length)` lies wholly inside `view`. */
|
|
65
66
|
const fitsInView = (view, offset, length) => Number.isInteger(offset) && Number.isInteger(length) && offset >= 0 && length >= 0 && offset + length <= view.byteLength;
|
|
66
67
|
/** The four-byte tag at `offset`, or `""` when it does not fit. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Result } from "better-result";
|
|
1
|
+
import { Result, TaggedErrorClass } from "better-result";
|
|
2
2
|
//#region src/fonts/sfnt/woff.d.ts
|
|
3
|
-
declare const
|
|
4
|
-
export declare class WoffDecodeError extends
|
|
3
|
+
declare const WoffDecodeErrorBase: TaggedErrorClass<"WoffDecodeError">;
|
|
4
|
+
export declare class WoffDecodeError extends WoffDecodeErrorBase<{
|
|
5
5
|
message: string;
|
|
6
6
|
}> {}
|
|
7
7
|
export declare const decodeWoff: (bytes: Uint8Array) => Result<Uint8Array, WoffDecodeError>;
|