@stll/folio-core 0.8.0 → 0.10.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/README.md +39 -0
- package/dist/ai-edits/apply.js +18 -4
- package/dist/ai-edits/headless.d.ts +73 -6
- package/dist/ai-edits/headless.js +299 -60
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/snapshot.js +40 -3
- package/dist/ai-edits/types.d.ts +2 -1
- package/dist/compat/eigenpal.d.ts +6 -4
- package/dist/compat/eigenpal.js +5 -3
- package/dist/controller/latestRequestGate.d.ts +13 -0
- package/dist/controller/latestRequestGate.js +16 -0
- package/dist/controller/layoutPipeline.js +13 -1
- package/dist/document-operations.d.ts +20 -4
- package/dist/document-operations.js +36 -15
- package/dist/document-stories.d.ts +10 -0
- package/dist/document-stories.js +27 -0
- package/dist/docx/blockContentParser.js +2 -2
- package/dist/docx/commentParser.js +1 -1
- package/dist/docx/compatibility.d.ts +3 -7
- package/dist/docx/compatibility.js +0 -11
- package/dist/docx/corePropertiesParser.d.ts +8 -0
- package/dist/docx/corePropertiesParser.js +53 -0
- package/dist/docx/encryption/agileDecryption.js +1 -1
- package/dist/docx/encryption/encryptionInfo.js +1 -1
- package/dist/docx/encryption/openEncryptedDocx.js +1 -1
- package/dist/docx/fontTableParser.d.ts +6 -0
- package/dist/docx/fontTableParser.js +72 -0
- package/dist/docx/groupDrawingParser.js +7 -2
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/metadataPrivacy.d.ts +40 -0
- package/dist/docx/metadataPrivacy.js +131 -0
- package/dist/docx/normalizeBaseDirection.js +1 -1
- package/dist/docx/numberingParser.js +1 -0
- package/dist/docx/paragraphParser.js +12 -1
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +16 -10
- package/dist/docx/rezip.d.ts +5 -4
- package/dist/docx/rezip.js +76 -13
- package/dist/docx/runConsolidator.js +4 -0
- package/dist/docx/runParser.js +19 -1
- package/dist/docx/selectiveSave.js +3 -3
- package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
- package/dist/docx/serializer/fontTableSerializer.js +26 -0
- package/dist/docx/serializer/headerFooterSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +4 -0
- package/dist/docx/serializer/runSerializer.js +7 -0
- package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
- package/dist/docx/serializer/settingsSerializer.js +16 -0
- package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
- package/dist/docx/serializer/stylesSerializer.js +56 -0
- package/dist/docx/serializer/tableSerializer.js +25 -26
- package/dist/docx/serializer/themeSerializer.d.ts +6 -0
- package/dist/docx/serializer/themeSerializer.js +36 -0
- package/dist/docx/settingsParser.js +46 -0
- package/dist/docx/styleParser.js +26 -1
- package/dist/docx/tableParser.js +11 -1
- package/dist/docx/vmlImageParser.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
- package/dist/i18n/messages/catalogs.gen.js +5910 -5910
- package/dist/index.d.ts +6 -4
- package/dist/index.js +5 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +52 -14
- package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
- package/dist/layout-bridge/engine/measuring/index.js +2 -1
- package/dist/layout-engine/index.js +36 -28
- package/dist/layout-engine/measure/cache.js +6 -3
- package/dist/layout-engine/measure/effectiveLineBreakPolicy.d.ts +29 -0
- package/dist/layout-engine/measure/effectiveLineBreakPolicy.js +60 -0
- package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
- package/dist/layout-engine/measure/index.d.ts +2 -1
- package/dist/layout-engine/measure/index.js +2 -1
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
- package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
- package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
- package/dist/layout-engine/measure/lineBreaks.js +11 -18
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +12 -6
- package/dist/layout-engine/measure/measureBlocks.d.ts +1 -2
- package/dist/layout-engine/measure/measureBlocks.js +6 -36
- package/dist/layout-engine/measure/measureContainer.js +32 -9
- package/dist/layout-engine/measure/measureHelpers.js +5 -2
- package/dist/layout-engine/measure/measureParagraph.js +332 -73
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
- package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
- package/dist/layout-engine/measure/measureWorker.js +8 -19
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
- package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
- package/dist/layout-engine/measure/tableCellFloating.js +51 -37
- package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
- package/dist/layout-engine/measure/tableCellFlow.js +73 -0
- package/dist/layout-engine/measure/tableCellGrid.js +1 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +6 -1
- package/dist/layout-engine/renderedBreakReconciliation.js +34 -11
- package/dist/layout-engine/tableRowBreak.d.ts +5 -2
- package/dist/layout-engine/tableRowBreak.js +62 -29
- package/dist/layout-engine/types.d.ts +43 -8
- package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
- package/dist/layout-painter/anchoredImagePosition.js +95 -0
- package/dist/layout-painter/borderStroke.d.ts +23 -0
- package/dist/layout-painter/borderStroke.js +39 -0
- package/dist/layout-painter/renderImage.d.ts +5 -4
- package/dist/layout-painter/renderImage.js +18 -4
- package/dist/layout-painter/renderPage.d.ts +2 -27
- package/dist/layout-painter/renderPage.js +13 -99
- package/dist/layout-painter/renderParagraph.js +41 -23
- package/dist/layout-painter/renderTable.d.ts +2 -0
- package/dist/layout-painter/renderTable.js +223 -43
- package/dist/managers/DocumentLoaderManager.d.ts +1 -1
- package/dist/managers/DocumentLoaderManager.js +2 -2
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +22 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +62 -0
- package/dist/prosemirror/conversion/effectiveTableCellFormatting.js +131 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +34 -18
- package/dist/prosemirror/conversion/toProseDoc.js +81 -77
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +7 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +6 -1
- package/dist/prosemirror/schema/nodes.d.ts +15 -12
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
- package/dist/prosemirror/utils/tabCalculator.js +12 -10
- package/dist/prosemirror/validation.js +4 -1
- package/dist/redline.d.ts +26 -11
- package/dist/redline.js +107 -64
- package/dist/server.d.ts +9 -5
- package/dist/server.js +8 -4
- package/dist/style-sets/extract.d.ts +35 -0
- package/dist/style-sets/extract.js +123 -0
- package/dist/style-sets/stellaStyle.d.ts +13 -0
- package/dist/style-sets/stellaStyle.js +516 -0
- package/dist/style-sets/types.d.ts +31 -0
- package/dist/style-sets/types.js +5 -0
- package/dist/utils/createDocument.d.ts +12 -2
- package/dist/utils/createDocument.js +42 -31
- package/dist/utils/fontResolver.js +6 -6
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
- package/dist/utils/paragraphFormattingMerge.js +14 -4
- package/dist/version-comparison.d.ts +65 -11
- package/dist/version-comparison.js +187 -29
- package/package.json +5 -1
- package/dist/docx/capabilities.d.ts +0 -41
- package/dist/docx/capabilities.js +0 -322
|
@@ -59,9 +59,9 @@ const APTOS_MEASURED_LINE_HEIGHT = {
|
|
|
59
59
|
* font's `FontLineHeight`, never hand-written. For "hhea" entries the raw
|
|
60
60
|
* `hheaAscent`/`hheaDescent`/`hheaLineGap`/`unitsPerEm` fields below are read
|
|
61
61
|
* directly from the real font files' `hhea` table; the ratio is whatever
|
|
62
|
-
* falls out of the formula in `singleLineRatioOf`. "legacy"
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* falls out of the formula in `singleLineRatioOf`. The remaining "legacy"
|
|
63
|
+
* entry (lucida sans) is an unverified hand-transcribed ratio carried over
|
|
64
|
+
* unchanged, pending measurement.
|
|
65
65
|
*/
|
|
66
66
|
const FONT_MAPPINGS = {
|
|
67
67
|
aptos: {
|
|
@@ -355,9 +355,9 @@ const FONT_MAPPINGS = {
|
|
|
355
355
|
"serif"
|
|
356
356
|
],
|
|
357
357
|
singleLineRatio: singleLineRatioOf({
|
|
358
|
-
source: "
|
|
359
|
-
ratio: 1.
|
|
360
|
-
note: "
|
|
358
|
+
source: "measured",
|
|
359
|
+
ratio: 1.1273,
|
|
360
|
+
note: "Measured at 11pt against a 12.4pt reference-layout line pitch."
|
|
361
361
|
})
|
|
362
362
|
},
|
|
363
363
|
"century gothic": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AUTO_PARAGRAPH_SPACING_PX, eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
|
|
2
|
-
import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
|
|
3
2
|
import { resolveColor, resolveHighlightToCss, resolveShadingColor } from "./colorResolver.js";
|
|
3
|
+
import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
|
|
4
4
|
//#region src/utils/formatToStyle.ts
|
|
5
5
|
/**
|
|
6
6
|
* Convert TextFormatting to CSS properties for a run/span
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/paragraphFormattingMerge.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Merge custom tab stops across OOXML paragraph-property layers.
|
|
6
|
+
*
|
|
7
|
+
* Tabs cascade by position rather than replacing the inherited collection:
|
|
8
|
+
* a higher-priority stop supersedes the stop at the same position, while a
|
|
9
|
+
* `clear` stop removes that inherited position during layout. Keeping the
|
|
10
|
+
* clear entry also lets the tab calculator suppress an automatic stop at the
|
|
11
|
+
* same position.
|
|
12
|
+
*/
|
|
13
|
+
declare function mergeParagraphTabStops(inherited: document_d_exports.TabStop[] | undefined, direct: document_d_exports.TabStop[]): document_d_exports.TabStop[];
|
|
14
|
+
declare function mergeParagraphTabStops(inherited: document_d_exports.TabStop[] | undefined, direct: document_d_exports.TabStop[] | undefined): document_d_exports.TabStop[] | undefined;
|
|
4
15
|
/**
|
|
5
16
|
* Merge paragraph properties for OOXML style cascade resolution.
|
|
6
17
|
*
|
|
7
18
|
* The source is the higher-priority layer. Most `w:pPr` properties replace an
|
|
8
19
|
* inherited value when present; nested child containers merge by child field;
|
|
9
|
-
* tabs
|
|
10
|
-
*
|
|
20
|
+
* tabs merge by position; paragraph mark `w:rPr` uses the run-formatting
|
|
21
|
+
* merge rules.
|
|
11
22
|
*/
|
|
12
23
|
declare function mergeParagraphFormatting(target: document_d_exports.ParagraphFormatting | undefined, source: document_d_exports.ParagraphFormatting | undefined): document_d_exports.ParagraphFormatting | undefined;
|
|
13
24
|
//#endregion
|
|
14
|
-
export { mergeParagraphFormatting };
|
|
25
|
+
export { mergeParagraphFormatting, mergeParagraphTabStops };
|
|
@@ -3,6 +3,8 @@ import { mergeTextFormatting } from "./textFormattingMerge.js";
|
|
|
3
3
|
const PARAGRAPH_REPLACE_KEYS = [
|
|
4
4
|
"alignment",
|
|
5
5
|
"bidi",
|
|
6
|
+
"kinsoku",
|
|
7
|
+
"overflowPunctuation",
|
|
6
8
|
"spaceBefore",
|
|
7
9
|
"spaceAfter",
|
|
8
10
|
"lineSpacing",
|
|
@@ -30,13 +32,20 @@ const copyDefinedParagraphProperty = (target, source, key) => {
|
|
|
30
32
|
const value = source[key];
|
|
31
33
|
if (value !== void 0) target[key] = value;
|
|
32
34
|
};
|
|
35
|
+
function mergeParagraphTabStops(inherited, direct) {
|
|
36
|
+
if (direct === void 0) return inherited === void 0 ? void 0 : [...inherited];
|
|
37
|
+
const stopsByPosition = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const stop of inherited ?? []) stopsByPosition.set(stop.position, stop);
|
|
39
|
+
for (const stop of direct) stopsByPosition.set(stop.position, stop);
|
|
40
|
+
return [...stopsByPosition.values()].toSorted((a, b) => a.position - b.position);
|
|
41
|
+
}
|
|
33
42
|
/**
|
|
34
43
|
* Merge paragraph properties for OOXML style cascade resolution.
|
|
35
44
|
*
|
|
36
45
|
* The source is the higher-priority layer. Most `w:pPr` properties replace an
|
|
37
46
|
* inherited value when present; nested child containers merge by child field;
|
|
38
|
-
* tabs
|
|
39
|
-
*
|
|
47
|
+
* tabs merge by position; paragraph mark `w:rPr` uses the run-formatting
|
|
48
|
+
* merge rules.
|
|
40
49
|
*/
|
|
41
50
|
function mergeParagraphFormatting(target, source) {
|
|
42
51
|
if (!source) return target;
|
|
@@ -47,6 +56,7 @@ function mergeParagraphFormatting(target, source) {
|
|
|
47
56
|
}
|
|
48
57
|
const result = { ...target };
|
|
49
58
|
for (const key of PARAGRAPH_REPLACE_KEYS) copyDefinedParagraphProperty(result, source, key);
|
|
59
|
+
if (source.indentFirstLine !== void 0) result.hangingIndent = source.hangingIndent === true;
|
|
50
60
|
const mergedRunProperties = mergeTextFormatting(result.runProperties, source.runProperties);
|
|
51
61
|
if (mergedRunProperties) result.runProperties = mergedRunProperties;
|
|
52
62
|
if (source.borders !== void 0) result.borders = {
|
|
@@ -61,8 +71,8 @@ function mergeParagraphFormatting(target, source) {
|
|
|
61
71
|
...result.frame,
|
|
62
72
|
...source.frame
|
|
63
73
|
};
|
|
64
|
-
if (source.tabs !== void 0) result.tabs =
|
|
74
|
+
if (source.tabs !== void 0) result.tabs = mergeParagraphTabStops(result.tabs, source.tabs);
|
|
65
75
|
return result;
|
|
66
76
|
}
|
|
67
77
|
//#endregion
|
|
68
|
-
export { mergeParagraphFormatting };
|
|
78
|
+
export { mergeParagraphFormatting, mergeParagraphTabStops };
|
|
@@ -1,59 +1,111 @@
|
|
|
1
1
|
import { FolioAIBlock } from "./ai-edits/types.js";
|
|
2
|
+
import { FolioDocumentStoryHandle } from "./ai-edits/headless.js";
|
|
2
3
|
import { WordDiffSegment } from "./ai-edits/word-diff.js";
|
|
4
|
+
import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FolioDocumentMetadataProperty, FolioDocumentPrivacyOptions, FolioDocumentPrivacyReport, FolioDocumentPrivacyTransform } from "./docx/metadataPrivacy.js";
|
|
3
5
|
|
|
4
6
|
//#region src/version-comparison.d.ts
|
|
5
7
|
/** One word-level diff segment within a `modified` block. Mirrors {@link WordDiffSegment}. */
|
|
6
8
|
type FolioVersionDiffSegment = WordDiffSegment;
|
|
9
|
+
/** Independently selectable comparison scopes. */
|
|
10
|
+
declare const FOLIO_VERSION_COMPARISON_SCOPES: readonly ["text", "formatting", "metadata"];
|
|
11
|
+
type FolioVersionComparisonScope = (typeof FOLIO_VERSION_COMPARISON_SCOPES)[number];
|
|
12
|
+
declare const isFolioVersionComparisonScope: (value: unknown) => value is FolioVersionComparisonScope;
|
|
13
|
+
type FolioCompareDocxVersionsOptions = {
|
|
14
|
+
/** Selected scopes; defaults to text and formatting. */include?: readonly FolioVersionComparisonScope[]; /** Optional output-only privacy transforms. Source buffers are never mutated. */
|
|
15
|
+
privacy?: FolioVersionDiffPrivacyOptions;
|
|
16
|
+
};
|
|
17
|
+
declare const InvalidFolioVersionComparisonOptionsError_base: import("better-result").TaggedErrorClass<"InvalidFolioVersionComparisonOptionsError", {
|
|
18
|
+
message: string;
|
|
19
|
+
option: "include" | "privacy.transforms";
|
|
20
|
+
receivedValue: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
declare class InvalidFolioVersionComparisonOptionsError extends InvalidFolioVersionComparisonOptionsError_base {}
|
|
23
|
+
type FolioDocumentMetadataValue = string | number | null;
|
|
24
|
+
type FolioMetadataDiff = {
|
|
25
|
+
property: FolioDocumentMetadataProperty;
|
|
26
|
+
baseValue: FolioDocumentMetadataValue;
|
|
27
|
+
revisedValue: FolioDocumentMetadataValue;
|
|
28
|
+
};
|
|
29
|
+
declare const FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS: readonly ["remove-attribution", "remove-timestamps", "remove-descriptive-metadata"];
|
|
30
|
+
type FolioVersionComparisonPrivacyTransform = FolioDocumentPrivacyTransform;
|
|
31
|
+
declare const isFolioVersionComparisonPrivacyTransform: (value: unknown) => value is FolioVersionComparisonPrivacyTransform;
|
|
32
|
+
type FolioVersionDiffPrivacyOptions = FolioDocumentPrivacyOptions;
|
|
33
|
+
type FolioVersionDiffPrivacyReport = FolioDocumentPrivacyReport;
|
|
7
34
|
/** Run-level formatting properties compared for `formatChanged` detection. */
|
|
8
35
|
declare const FORMAT_PROPERTIES: readonly ["bold", "italic", "underline", "strike", "fontFamily", "fontSizePt", "color"];
|
|
9
36
|
/** A run-level formatting property that can differ in a `formatChanged` block. */
|
|
10
37
|
type FolioFormatProperty = (typeof FORMAT_PROPERTIES)[number];
|
|
38
|
+
/** Stable location of one compared block within its source document. */
|
|
39
|
+
type FolioVersionBlockHandle = {
|
|
40
|
+
story: FolioDocumentStoryHandle;
|
|
41
|
+
blockId: string;
|
|
42
|
+
};
|
|
11
43
|
/** One block-level change between two document versions, in revised-side document order. */
|
|
12
44
|
type FolioBlockDiff = {
|
|
13
45
|
type: "added";
|
|
14
46
|
blockId: string;
|
|
15
47
|
kind: string;
|
|
16
48
|
text: string;
|
|
49
|
+
revisedHandle: FolioVersionBlockHandle;
|
|
17
50
|
} | {
|
|
18
51
|
type: "deleted";
|
|
19
52
|
blockId: string;
|
|
20
53
|
kind: string;
|
|
21
54
|
text: string;
|
|
55
|
+
baseHandle: FolioVersionBlockHandle;
|
|
22
56
|
} | {
|
|
23
57
|
type: "modified";
|
|
24
58
|
blockId: string;
|
|
25
59
|
kind: string;
|
|
26
60
|
segments: FolioVersionDiffSegment[];
|
|
61
|
+
baseHandle: FolioVersionBlockHandle;
|
|
62
|
+
revisedHandle: FolioVersionBlockHandle;
|
|
27
63
|
} | {
|
|
28
64
|
type: "formatChanged";
|
|
29
65
|
blockId: string;
|
|
30
66
|
kind: string;
|
|
31
67
|
text: string;
|
|
32
68
|
changedProperties: FolioFormatProperty[];
|
|
69
|
+
baseHandle: FolioVersionBlockHandle;
|
|
70
|
+
revisedHandle: FolioVersionBlockHandle;
|
|
33
71
|
} | {
|
|
34
72
|
type: "movedFrom";
|
|
35
73
|
blockId: string;
|
|
36
74
|
kind: string;
|
|
37
75
|
text: string;
|
|
38
76
|
moveGroupId: number;
|
|
77
|
+
baseHandle: FolioVersionBlockHandle;
|
|
39
78
|
} | {
|
|
40
79
|
type: "movedTo";
|
|
41
80
|
blockId: string;
|
|
42
81
|
kind: string;
|
|
43
82
|
text: string;
|
|
44
83
|
moveGroupId: number;
|
|
84
|
+
revisedHandle: FolioVersionBlockHandle;
|
|
85
|
+
};
|
|
86
|
+
type FolioVersionDiffSummaryCounts = {
|
|
87
|
+
added: number;
|
|
88
|
+
deleted: number;
|
|
89
|
+
modified: number;
|
|
90
|
+
formatChanged: number;
|
|
91
|
+
moved: number;
|
|
92
|
+
metadataChanged: number;
|
|
93
|
+
unchanged: number;
|
|
94
|
+
};
|
|
95
|
+
/** Changes within one matched, added, or deleted document story. */
|
|
96
|
+
type FolioStoryDiff = {
|
|
97
|
+
baseStory: FolioDocumentStoryHandle | null;
|
|
98
|
+
revisedStory: FolioDocumentStoryHandle | null;
|
|
99
|
+
changes: FolioBlockDiff[];
|
|
100
|
+
summaryCounts: FolioVersionDiffSummaryCounts;
|
|
45
101
|
};
|
|
46
102
|
/** Result of {@link compareDocxVersions}. */
|
|
47
103
|
type FolioVersionDiff = {
|
|
48
|
-
/** Every changed block, in revised-side document order (deletions and move sources slotted where they sat). */changes: FolioBlockDiff[]; /**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
formatChanged: number;
|
|
54
|
-
moved: number;
|
|
55
|
-
unchanged: number;
|
|
56
|
-
};
|
|
104
|
+
/** Every changed block, in revised-side document order (deletions and move sources slotted where they sat). */changes: FolioBlockDiff[]; /** Per-story results in base order followed by stories added in the revised document. */
|
|
105
|
+
stories: FolioStoryDiff[]; /** Changed package metadata fields in stable property order. */
|
|
106
|
+
metadataChanges: FolioMetadataDiff[]; /** Applied privacy policy and the fields it removed from this result. */
|
|
107
|
+
privacyReport: FolioVersionDiffPrivacyReport; /** Counts across every paired/unpaired block, including the unchanged blocks `changes` omits. `moved` counts pairs, not entries. */
|
|
108
|
+
summaryCounts: FolioVersionDiffSummaryCounts;
|
|
57
109
|
};
|
|
58
110
|
/** True when an `unpairedBaseCount * unpairedRevisedCount` LCS table would exceed {@link MAX_LCS_CELLS}. */
|
|
59
111
|
declare const exceedsLcsBudget: (unpairedBaseCount: number, unpairedRevisedCount: number) => boolean;
|
|
@@ -81,12 +133,14 @@ type FolioAlignedBlockEvent = {
|
|
|
81
133
|
* one document walk instead of re-deriving it.
|
|
82
134
|
*/
|
|
83
135
|
declare const alignFolioBlocks: (baseBlocks: readonly FolioAIBlock[], revisedBlocks: readonly FolioAIBlock[]) => FolioAlignedBlockEvent[];
|
|
136
|
+
/** Apply auditable, output-only privacy transforms to a structured version diff. */
|
|
137
|
+
declare const applyFolioVersionDiffPrivacy: (diff: FolioVersionDiff, options: FolioVersionDiffPrivacyOptions) => FolioVersionDiff;
|
|
84
138
|
/**
|
|
85
139
|
* Compare two `.docx` buffers and return a structured, block-level diff.
|
|
86
140
|
* See the module doc comment for the as-accepted comparison semantics, the
|
|
87
141
|
* three-pass alignment algorithm, move detection, and format-only change
|
|
88
142
|
* detection.
|
|
89
143
|
*/
|
|
90
|
-
declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer) => Promise<FolioVersionDiff>;
|
|
144
|
+
declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioCompareDocxVersionsOptions) => Promise<FolioVersionDiff>;
|
|
91
145
|
//#endregion
|
|
92
|
-
export { FolioAlignedBlockEvent, FolioBlockDiff, FolioFormatProperty, FolioVersionDiff, FolioVersionDiffSegment, alignFolioBlocks, compareDocxVersions, exceedsLcsBudget };
|
|
146
|
+
export { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioAlignedBlockEvent, FolioBlockDiff, FolioCompareDocxVersionsOptions, type FolioDocumentMetadataProperty, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, alignFolioBlocks, applyFolioVersionDiffPrivacy, compareDocxVersions, exceedsLcsBudget, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getFolioParaIdFromBlockId } from "./types/block-id.js";
|
|
2
2
|
import { diffWordSegments } from "./ai-edits/word-diff.js";
|
|
3
|
+
import { pairFolioDocumentStories } from "./document-stories.js";
|
|
3
4
|
import { FolioDocxReviewer } from "./ai-edits/headless.js";
|
|
5
|
+
import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, PRIVATE_METADATA_PROPERTIES_BY_TRANSFORM, isFolioDocumentPrivacyTransform } from "./docx/metadataPrivacy.js";
|
|
6
|
+
import { TaggedError, panic } from "better-result";
|
|
4
7
|
//#region src/version-comparison.ts
|
|
5
8
|
/**
|
|
6
9
|
* Document version-diff engine: compare two `.docx` buffers block by block
|
|
@@ -76,6 +79,16 @@ import { FolioDocxReviewer } from "./ai-edits/headless.js";
|
|
|
76
79
|
* content that makes the preview texts disagree, detection backs off to
|
|
77
80
|
* `unchanged` rather than misattribute properties.
|
|
78
81
|
*/
|
|
82
|
+
/** Independently selectable comparison scopes. */
|
|
83
|
+
const FOLIO_VERSION_COMPARISON_SCOPES = Object.freeze([
|
|
84
|
+
"text",
|
|
85
|
+
"formatting",
|
|
86
|
+
"metadata"
|
|
87
|
+
]);
|
|
88
|
+
const isFolioVersionComparisonScope = (value) => FOLIO_VERSION_COMPARISON_SCOPES.some((scope) => scope === value);
|
|
89
|
+
var InvalidFolioVersionComparisonOptionsError = class extends TaggedError("InvalidFolioVersionComparisonOptionsError")() {};
|
|
90
|
+
const FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS = FOLIO_DOCUMENT_PRIVACY_TRANSFORMS;
|
|
91
|
+
const isFolioVersionComparisonPrivacyTransform = (value) => isFolioDocumentPrivacyTransform(value);
|
|
79
92
|
/** Run-level formatting properties compared for `formatChanged` detection. */
|
|
80
93
|
const FORMAT_PROPERTIES = [
|
|
81
94
|
"bold",
|
|
@@ -324,7 +337,7 @@ const meetsMoveWordCount = (text) => {
|
|
|
324
337
|
* per text, so duplicated boilerplate above the word floor pairs
|
|
325
338
|
* first-to-first rather than fanning out.
|
|
326
339
|
*/
|
|
327
|
-
const detectMoves = (changes, counts) => {
|
|
340
|
+
const detectMoves = (changes, counts, firstMoveGroupId) => {
|
|
328
341
|
const deletedIndexesByText = /* @__PURE__ */ new Map();
|
|
329
342
|
changes.forEach((change, index) => {
|
|
330
343
|
if (change.type === "deleted" && meetsMoveWordCount(change.text)) {
|
|
@@ -334,7 +347,7 @@ const detectMoves = (changes, counts) => {
|
|
|
334
347
|
}
|
|
335
348
|
});
|
|
336
349
|
if (deletedIndexesByText.size === 0) return;
|
|
337
|
-
let moveGroupId =
|
|
350
|
+
let moveGroupId = firstMoveGroupId - 1;
|
|
338
351
|
changes.forEach((change, index) => {
|
|
339
352
|
if (change.type !== "added") return;
|
|
340
353
|
const deletedIndex = deletedIndexesByText.get(change.text)?.shift();
|
|
@@ -347,53 +360,72 @@ const detectMoves = (changes, counts) => {
|
|
|
347
360
|
blockId: deleted.blockId,
|
|
348
361
|
kind: deleted.kind,
|
|
349
362
|
text: deleted.text,
|
|
350
|
-
moveGroupId
|
|
363
|
+
moveGroupId,
|
|
364
|
+
baseHandle: deleted.baseHandle
|
|
351
365
|
};
|
|
352
366
|
changes[index] = {
|
|
353
367
|
type: "movedTo",
|
|
354
368
|
blockId: change.blockId,
|
|
355
369
|
kind: change.kind,
|
|
356
370
|
text: change.text,
|
|
357
|
-
moveGroupId
|
|
371
|
+
moveGroupId,
|
|
372
|
+
revisedHandle: change.revisedHandle
|
|
358
373
|
};
|
|
359
374
|
counts.deleted--;
|
|
360
375
|
counts.added--;
|
|
361
376
|
counts.moved++;
|
|
362
377
|
});
|
|
363
378
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
379
|
+
const createSummaryCounts = () => ({
|
|
380
|
+
added: 0,
|
|
381
|
+
deleted: 0,
|
|
382
|
+
modified: 0,
|
|
383
|
+
formatChanged: 0,
|
|
384
|
+
moved: 0,
|
|
385
|
+
metadataChanged: 0,
|
|
386
|
+
unchanged: 0
|
|
387
|
+
});
|
|
388
|
+
const addSummaryCounts = (target, source) => {
|
|
389
|
+
target.added += source.added;
|
|
390
|
+
target.deleted += source.deleted;
|
|
391
|
+
target.modified += source.modified;
|
|
392
|
+
target.formatChanged += source.formatChanged;
|
|
393
|
+
target.moved += source.moved;
|
|
394
|
+
target.metadataChanged += source.metadataChanged;
|
|
395
|
+
target.unchanged += source.unchanged;
|
|
396
|
+
};
|
|
397
|
+
const compareStoryBlocks = ({ baseStory, revisedStory, baseBlocks, revisedBlocks, firstMoveGroupId, includeText, includeFormatting }) => {
|
|
374
398
|
const changes = [];
|
|
375
|
-
const counts =
|
|
376
|
-
added: 0,
|
|
377
|
-
deleted: 0,
|
|
378
|
-
modified: 0,
|
|
379
|
-
formatChanged: 0,
|
|
380
|
-
moved: 0,
|
|
381
|
-
unchanged: 0
|
|
382
|
-
};
|
|
399
|
+
const counts = createSummaryCounts();
|
|
383
400
|
for (const event of alignFolioBlocks(baseBlocks, revisedBlocks)) {
|
|
384
401
|
if (event.type === "pair") {
|
|
402
|
+
if (!baseStory || !revisedStory) panic("A paired comparison event requires both story handles");
|
|
385
403
|
const { baseBlock, revisedBlock } = event;
|
|
404
|
+
const baseHandle = {
|
|
405
|
+
story: baseStory,
|
|
406
|
+
blockId: baseBlock.id
|
|
407
|
+
};
|
|
408
|
+
const revisedHandle = {
|
|
409
|
+
story: revisedStory,
|
|
410
|
+
blockId: revisedBlock.id
|
|
411
|
+
};
|
|
386
412
|
if (baseBlock.text !== revisedBlock.text) {
|
|
413
|
+
if (!includeText) {
|
|
414
|
+
counts.unchanged++;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
387
417
|
counts.modified++;
|
|
388
418
|
changes.push({
|
|
389
419
|
type: "modified",
|
|
390
420
|
blockId: revisedBlock.id,
|
|
391
421
|
kind: revisedBlock.kind,
|
|
392
|
-
segments: diffWordSegments(baseBlock.text, revisedBlock.text)
|
|
422
|
+
segments: diffWordSegments(baseBlock.text, revisedBlock.text),
|
|
423
|
+
baseHandle,
|
|
424
|
+
revisedHandle
|
|
393
425
|
});
|
|
394
426
|
continue;
|
|
395
427
|
}
|
|
396
|
-
const changedProperties = diffPreviewRunFormatting(baseBlock, revisedBlock);
|
|
428
|
+
const changedProperties = includeFormatting ? diffPreviewRunFormatting(baseBlock, revisedBlock) : [];
|
|
397
429
|
if (changedProperties.length > 0) {
|
|
398
430
|
counts.formatChanged++;
|
|
399
431
|
changes.push({
|
|
@@ -401,7 +433,9 @@ const compareDocxVersions = async (base, revised) => {
|
|
|
401
433
|
blockId: revisedBlock.id,
|
|
402
434
|
kind: revisedBlock.kind,
|
|
403
435
|
text: revisedBlock.text,
|
|
404
|
-
changedProperties
|
|
436
|
+
changedProperties,
|
|
437
|
+
baseHandle,
|
|
438
|
+
revisedHandle
|
|
405
439
|
});
|
|
406
440
|
continue;
|
|
407
441
|
}
|
|
@@ -409,28 +443,152 @@ const compareDocxVersions = async (base, revised) => {
|
|
|
409
443
|
continue;
|
|
410
444
|
}
|
|
411
445
|
if (event.type === "baseOnly") {
|
|
446
|
+
if (!includeText) continue;
|
|
447
|
+
if (!baseStory) panic("A base-only comparison event requires a base story handle");
|
|
412
448
|
counts.deleted++;
|
|
413
449
|
changes.push({
|
|
414
450
|
type: "deleted",
|
|
415
451
|
blockId: event.block.id,
|
|
416
452
|
kind: event.block.kind,
|
|
417
|
-
text: event.block.text
|
|
453
|
+
text: event.block.text,
|
|
454
|
+
baseHandle: {
|
|
455
|
+
story: baseStory,
|
|
456
|
+
blockId: event.block.id
|
|
457
|
+
}
|
|
418
458
|
});
|
|
419
459
|
continue;
|
|
420
460
|
}
|
|
461
|
+
if (!includeText) continue;
|
|
462
|
+
if (!revisedStory) panic("A revised-only comparison event requires a revised story handle");
|
|
421
463
|
counts.added++;
|
|
422
464
|
changes.push({
|
|
423
465
|
type: "added",
|
|
424
466
|
blockId: event.block.id,
|
|
425
467
|
kind: event.block.kind,
|
|
426
|
-
text: event.block.text
|
|
468
|
+
text: event.block.text,
|
|
469
|
+
revisedHandle: {
|
|
470
|
+
story: revisedStory,
|
|
471
|
+
blockId: event.block.id
|
|
472
|
+
}
|
|
427
473
|
});
|
|
428
474
|
}
|
|
429
|
-
detectMoves(changes, counts);
|
|
475
|
+
detectMoves(changes, counts, firstMoveGroupId);
|
|
476
|
+
return {
|
|
477
|
+
baseStory,
|
|
478
|
+
revisedStory,
|
|
479
|
+
changes,
|
|
480
|
+
summaryCounts: counts
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
const DEFAULT_COMPARISON_SCOPES = Object.freeze(["text", "formatting"]);
|
|
484
|
+
const resolveComparisonScopes = (options) => {
|
|
485
|
+
const include = options.include ?? DEFAULT_COMPARISON_SCOPES;
|
|
486
|
+
if (include.length === 0 || include.some((scope) => !isFolioVersionComparisonScope(scope))) throw new InvalidFolioVersionComparisonOptionsError({
|
|
487
|
+
message: "Version comparison requires at least one recognized scope",
|
|
488
|
+
option: "include",
|
|
489
|
+
receivedValue: include
|
|
490
|
+
});
|
|
491
|
+
return new Set(include);
|
|
492
|
+
};
|
|
493
|
+
const resolvePrivacyTransforms = (transforms) => {
|
|
494
|
+
if (!Array.isArray(transforms) || transforms.some((transform) => !isFolioVersionComparisonPrivacyTransform(transform))) throw new InvalidFolioVersionComparisonOptionsError({
|
|
495
|
+
message: "Version comparison received an unrecognized privacy transform",
|
|
496
|
+
option: "privacy.transforms",
|
|
497
|
+
receivedValue: transforms
|
|
498
|
+
});
|
|
499
|
+
const requested = new Set(transforms);
|
|
500
|
+
return FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS.filter((transform) => requested.has(transform));
|
|
501
|
+
};
|
|
502
|
+
/** Apply auditable, output-only privacy transforms to a structured version diff. */
|
|
503
|
+
const applyFolioVersionDiffPrivacy = (diff, options) => {
|
|
504
|
+
const requestedTransforms = resolvePrivacyTransforms(options.transforms);
|
|
505
|
+
const appliedTransformSet = /* @__PURE__ */ new Set([...diff.privacyReport.appliedTransforms, ...requestedTransforms]);
|
|
506
|
+
const appliedTransforms = FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS.filter((transform) => appliedTransformSet.has(transform));
|
|
507
|
+
const removedPropertySet = /* @__PURE__ */ new Set();
|
|
508
|
+
for (const transform of appliedTransforms) for (const property of PRIVATE_METADATA_PROPERTIES_BY_TRANSFORM[transform]) removedPropertySet.add(property);
|
|
509
|
+
const actuallyRemovedPropertySet = /* @__PURE__ */ new Set([...diff.privacyReport.removedMetadataProperties, ...diff.metadataChanges.filter(({ property }) => removedPropertySet.has(property)).map(({ property }) => property)]);
|
|
510
|
+
const removedMetadataProperties = FOLIO_DOCUMENT_METADATA_PROPERTIES.filter((property) => actuallyRemovedPropertySet.has(property));
|
|
511
|
+
const metadataChanges = diff.metadataChanges.filter(({ property }) => !removedPropertySet.has(property));
|
|
430
512
|
return {
|
|
513
|
+
...diff,
|
|
514
|
+
metadataChanges,
|
|
515
|
+
privacyReport: {
|
|
516
|
+
appliedTransforms,
|
|
517
|
+
removedMetadataProperties
|
|
518
|
+
},
|
|
519
|
+
summaryCounts: {
|
|
520
|
+
...diff.summaryCounts,
|
|
521
|
+
metadataChanged: metadataChanges.length
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
const normalizeMetadataValue = (properties, property) => {
|
|
526
|
+
const value = properties?.[property];
|
|
527
|
+
return value instanceof Date ? value.toISOString() : value ?? null;
|
|
528
|
+
};
|
|
529
|
+
const compareMetadata = (base, revised) => {
|
|
530
|
+
const changes = [];
|
|
531
|
+
for (const property of FOLIO_DOCUMENT_METADATA_PROPERTIES) {
|
|
532
|
+
const baseValue = normalizeMetadataValue(base, property);
|
|
533
|
+
const revisedValue = normalizeMetadataValue(revised, property);
|
|
534
|
+
if (baseValue !== revisedValue) changes.push({
|
|
535
|
+
property,
|
|
536
|
+
baseValue,
|
|
537
|
+
revisedValue
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return changes;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Compare two `.docx` buffers and return a structured, block-level diff.
|
|
544
|
+
* See the module doc comment for the as-accepted comparison semantics, the
|
|
545
|
+
* three-pass alignment algorithm, move detection, and format-only change
|
|
546
|
+
* detection.
|
|
547
|
+
*/
|
|
548
|
+
const compareDocxVersions = async (base, revised, options = {}) => {
|
|
549
|
+
const scopes = resolveComparisonScopes(options);
|
|
550
|
+
const [baseReviewer, revisedReviewer] = await Promise.all([FolioDocxReviewer.fromBuffer(base), FolioDocxReviewer.fromBuffer(revised)]);
|
|
551
|
+
const changes = [];
|
|
552
|
+
const stories = [];
|
|
553
|
+
const counts = createSummaryCounts();
|
|
554
|
+
const baseStories = baseReviewer.listStories().map(({ handle }) => handle);
|
|
555
|
+
const revisedStories = revisedReviewer.listStories().map(({ handle }) => handle);
|
|
556
|
+
let nextMoveGroupId = 1;
|
|
557
|
+
for (const pair of pairFolioDocumentStories(baseStories, revisedStories)) {
|
|
558
|
+
const baseBlocks = pair.baseStory ? baseReviewer.readReviewedStory({
|
|
559
|
+
story: pair.baseStory,
|
|
560
|
+
view: "final"
|
|
561
|
+
})?.snapshot.blocks ?? [] : [];
|
|
562
|
+
const revisedBlocks = pair.revisedStory ? revisedReviewer.readReviewedStory({
|
|
563
|
+
story: pair.revisedStory,
|
|
564
|
+
view: "final"
|
|
565
|
+
})?.snapshot.blocks ?? [] : [];
|
|
566
|
+
const storyDiff = compareStoryBlocks({
|
|
567
|
+
...pair,
|
|
568
|
+
baseBlocks,
|
|
569
|
+
revisedBlocks,
|
|
570
|
+
firstMoveGroupId: nextMoveGroupId,
|
|
571
|
+
includeText: scopes.has("text"),
|
|
572
|
+
includeFormatting: scopes.has("formatting")
|
|
573
|
+
});
|
|
574
|
+
stories.push(storyDiff);
|
|
575
|
+
for (const change of storyDiff.changes) changes.push(change);
|
|
576
|
+
addSummaryCounts(counts, storyDiff.summaryCounts);
|
|
577
|
+
nextMoveGroupId += storyDiff.summaryCounts.moved;
|
|
578
|
+
}
|
|
579
|
+
const metadataChanges = scopes.has("metadata") ? compareMetadata(baseReviewer.getDocumentProperties(), revisedReviewer.getDocumentProperties()) : [];
|
|
580
|
+
counts.metadataChanged = metadataChanges.length;
|
|
581
|
+
const diff = {
|
|
431
582
|
changes,
|
|
583
|
+
stories,
|
|
584
|
+
metadataChanges,
|
|
585
|
+
privacyReport: {
|
|
586
|
+
appliedTransforms: [],
|
|
587
|
+
removedMetadataProperties: []
|
|
588
|
+
},
|
|
432
589
|
summaryCounts: counts
|
|
433
590
|
};
|
|
591
|
+
return options.privacy ? applyFolioVersionDiffPrivacy(diff, options.privacy) : diff;
|
|
434
592
|
};
|
|
435
593
|
//#endregion
|
|
436
|
-
export { alignFolioBlocks, compareDocxVersions, exceedsLcsBudget };
|
|
594
|
+
export { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, InvalidFolioVersionComparisonOptionsError, alignFolioBlocks, applyFolioVersionDiffPrivacy, compareDocxVersions, exceedsLcsBudget, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"better-result": "2.9.2",
|
|
114
114
|
"csstype": "^3.1.3",
|
|
115
115
|
"fast-xml-parser": "^5.9.3",
|
|
116
|
+
"hyphen": "1.14.1",
|
|
116
117
|
"jszip": "3.10.1",
|
|
117
118
|
"marked": "^18.0.5",
|
|
118
119
|
"prosemirror-commands": "^1.7.1",
|
|
@@ -130,6 +131,9 @@
|
|
|
130
131
|
"y-prosemirror": "^1.3.7",
|
|
131
132
|
"yjs": "^13.6.31"
|
|
132
133
|
},
|
|
134
|
+
"devDependencies": {
|
|
135
|
+
"@types/hyphen": "1.14.0"
|
|
136
|
+
},
|
|
133
137
|
"main": "./dist/index.js",
|
|
134
138
|
"types": "./dist/index.d.ts",
|
|
135
139
|
"files": [
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/docx/capabilities.d.ts
|
|
2
|
-
declare const FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION: 1;
|
|
3
|
-
declare const FOLIO_DOCX_CAPABILITY_HOSTS: readonly ["browser", "server"];
|
|
4
|
-
declare const FOLIO_DOCX_COMPATIBILITY_HOSTS: readonly ["browser", "server", "unknown"];
|
|
5
|
-
declare const FOLIO_DOCX_PROFILES: readonly ["strict", "transitional"];
|
|
6
|
-
declare const FOLIO_DOCX_COMPATIBILITY_PROFILES: readonly ["strict", "transitional", "unknown"];
|
|
7
|
-
declare const FOLIO_DOCX_CAPABILITY_OPERATIONS: readonly ["create", "edit", "preserve", "read", "render"];
|
|
8
|
-
declare const FOLIO_DOCX_SUPPORT_STATES: readonly ["supported", "partial", "unsupported"];
|
|
9
|
-
declare const FOLIO_DOCX_CAPABILITY_IDS: readonly ["comments", "contentControls", "fields", "headersFooters", "hyperlinks", "images", "math", "notes", "numbering", "opaqueDrawing", "paragraphs", "sections", "styles", "tables", "trackedChanges"];
|
|
10
|
-
type FolioDocxCapabilityHost = (typeof FOLIO_DOCX_CAPABILITY_HOSTS)[number];
|
|
11
|
-
type FolioDocxCompatibilityHost = (typeof FOLIO_DOCX_COMPATIBILITY_HOSTS)[number];
|
|
12
|
-
type FolioDocxProfile = (typeof FOLIO_DOCX_PROFILES)[number];
|
|
13
|
-
type FolioDocxCompatibilityProfile = (typeof FOLIO_DOCX_COMPATIBILITY_PROFILES)[number];
|
|
14
|
-
type FolioDocxCapabilityOperation = (typeof FOLIO_DOCX_CAPABILITY_OPERATIONS)[number];
|
|
15
|
-
type FolioDocxSupportState = (typeof FOLIO_DOCX_SUPPORT_STATES)[number];
|
|
16
|
-
type FolioDocxCapabilityId = (typeof FOLIO_DOCX_CAPABILITY_IDS)[number];
|
|
17
|
-
type FolioDocxFeatureCapability = {
|
|
18
|
-
readonly id: FolioDocxCapabilityId;
|
|
19
|
-
readonly feature: "comments" | "contentControls" | "drawings" | "fields" | "headersFooters" | "hyperlinks" | "images" | "math" | "notes" | "numbering" | "paragraphs" | "revisions" | "sections" | "styles" | "tables";
|
|
20
|
-
readonly hosts: readonly FolioDocxCapabilityHost[];
|
|
21
|
-
readonly profiles: readonly FolioDocxProfile[];
|
|
22
|
-
readonly support: Readonly<Record<FolioDocxCapabilityOperation, FolioDocxSupportState>>;
|
|
23
|
-
readonly evidence: readonly {
|
|
24
|
-
readonly type: "test";
|
|
25
|
-
readonly path: string;
|
|
26
|
-
}[];
|
|
27
|
-
};
|
|
28
|
-
type FolioDocxCapabilityManifest = {
|
|
29
|
-
readonly version: typeof FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION;
|
|
30
|
-
readonly capabilities: Readonly<Record<FolioDocxCapabilityId, FolioDocxFeatureCapability>>;
|
|
31
|
-
};
|
|
32
|
-
declare const FOLIO_DOCX_CAPABILITY_MANIFEST: FolioDocxCapabilityManifest;
|
|
33
|
-
declare const InvalidFolioDocxCapabilityIdError_base: import("better-result").TaggedErrorClass<"InvalidFolioDocxCapabilityIdError", {
|
|
34
|
-
message: string;
|
|
35
|
-
receivedId: unknown;
|
|
36
|
-
}>;
|
|
37
|
-
declare class InvalidFolioDocxCapabilityIdError extends InvalidFolioDocxCapabilityIdError_base {}
|
|
38
|
-
declare const isFolioDocxCapabilityId: (value: unknown) => value is FolioDocxCapabilityId;
|
|
39
|
-
declare const getFolioDocxCapability: (id: unknown) => FolioDocxFeatureCapability;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { FOLIO_DOCX_CAPABILITY_HOSTS, FOLIO_DOCX_CAPABILITY_IDS, FOLIO_DOCX_CAPABILITY_MANIFEST, FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION, FOLIO_DOCX_CAPABILITY_OPERATIONS, FOLIO_DOCX_COMPATIBILITY_HOSTS, FOLIO_DOCX_COMPATIBILITY_PROFILES, FOLIO_DOCX_PROFILES, FOLIO_DOCX_SUPPORT_STATES, FolioDocxCapabilityHost, FolioDocxCapabilityId, FolioDocxCapabilityManifest, FolioDocxCapabilityOperation, FolioDocxCompatibilityHost, FolioDocxCompatibilityProfile, FolioDocxFeatureCapability, FolioDocxProfile, FolioDocxSupportState, InvalidFolioDocxCapabilityIdError, getFolioDocxCapability, isFolioDocxCapabilityId };
|