@openpresentation/opf 0.11.4 → 0.12.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 +16 -0
- package/dist/audit.d.ts +156 -0
- package/dist/audit.js +7 -0
- package/dist/{catalogs-CUClB3nl.d.ts → catalogs-u6TEeMcz.d.ts} +1 -1
- package/dist/catalogs.d.ts +2 -2
- package/dist/catalogs.js +2 -1
- package/dist/{chunk-NSVVQ52O.js → chunk-32DIB5BN.js} +8 -6
- package/dist/chunk-4FWCY4ZV.js +198 -0
- package/dist/{chunk-3H2U7FDR.js → chunk-6TSDIPSH.js} +1861 -247
- package/dist/chunk-FYLJVF7X.js +18448 -0
- package/dist/{chunk-HJL64ETN.js → chunk-GJKJL4YY.js} +14 -0
- package/dist/chunk-JENJZR3F.js +1690 -0
- package/dist/{chunk-3OJN7QAW.js → chunk-JVTN3HPP.js} +18 -4
- package/dist/{chunk-KJKASEPE.js → chunk-RVN5C2FX.js} +737 -26
- package/dist/chunk-S5W34SIJ.js +1 -0
- package/dist/chunk-S667QI3M.js +261 -0
- package/dist/chunk-UQKJWHSS.js +1332 -0
- package/dist/{chunk-RXNFDGPC.js → chunk-WXSPETQ6.js} +311 -40
- package/dist/{composition-Dl-d9FRj.d.ts → composition-DWbCiMwF.d.ts} +559 -10
- package/dist/composition.d.ts +1 -1
- package/dist/composition.js +2 -1
- package/dist/convert.d.ts +261 -0
- package/dist/convert.js +1107 -0
- package/dist/diff.d.ts +145 -0
- package/dist/diff.js +604 -0
- package/dist/docs.js +68 -14
- package/dist/examples.d.ts +1 -1
- package/dist/font-policy.d.ts +15 -0
- package/dist/font-policy.js +1 -1
- package/dist/format.d.ts +20 -0
- package/dist/format.js +83 -0
- package/dist/index.d.ts +173 -24
- package/dist/index.js +926 -262
- package/dist/lint.d.ts +4 -4
- package/dist/lint.js +6 -5
- package/dist/markdown.d.ts +74 -0
- package/dist/markdown.js +1941 -0
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +6 -5
- package/dist/patch.d.ts +99 -0
- package/dist/patch.js +6 -0
- package/dist/{presentation-j5PVrqfV.d.ts → presentation-DRx4hpNZ.d.ts} +451 -16
- package/dist/repo-readme.js +1 -1
- package/dist/{schemas-X_NniU4A.d.ts → schemas-BSjlG8-R.d.ts} +28 -0
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- package/dist/spec/reference/font-policy.json +311 -40
- package/dist/spec/reference/font-policy.schema.json +40 -0
- package/dist/spec/reference/symbol-font-encodings.json +18354 -0
- package/dist/spec/reference/symbol-font-encodings.schema.json +156 -0
- package/dist/spec/schemas/opf.schema.json +591 -22
- package/dist/spec-files.d.ts +1 -1
- package/dist/spec-files.js +1 -1
- package/dist/symbol-font-encodings.d.ts +128 -0
- package/dist/symbol-font-encodings.js +1 -0
- package/dist/types.d.ts +4 -4
- package/dist/validator-bu396ffT.d.ts +172 -0
- package/dist/validator.d.ts +4 -36
- package/dist/validator.js +5 -4
- package/package.json +31 -2
- package/dist/chunk-FDCWQHWO.js +0 -1366
- /package/dist/{chunk-AEUSVEUY.js → chunk-3ZGSWEHK.js} +0 -0
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { JsonPatchOperation } from './patch.js';
|
|
2
|
+
|
|
3
|
+
type MatchedBy = "id" | "equal" | "similar" | "position";
|
|
4
|
+
interface MatchPair {
|
|
5
|
+
/** Index in A. */
|
|
6
|
+
a: number;
|
|
7
|
+
/** Index in B. */
|
|
8
|
+
b: number;
|
|
9
|
+
by: MatchedBy;
|
|
10
|
+
/** Similarity score for `similar` pairs. */
|
|
11
|
+
similarity?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ArrayMatch {
|
|
14
|
+
/** Pairs sorted by `a`. */
|
|
15
|
+
pairs: MatchPair[];
|
|
16
|
+
/** A indexes with no counterpart, ascending. */
|
|
17
|
+
removed: number[];
|
|
18
|
+
/** B indexes with no counterpart, ascending. */
|
|
19
|
+
added: number[];
|
|
20
|
+
/** `a` indexes of pairs that are out of order relative to the longest order-preserving chain. */
|
|
21
|
+
moved: Set<number>;
|
|
22
|
+
}
|
|
23
|
+
interface MatchOptions {
|
|
24
|
+
/** Minimum similarity (0..1) to treat two unequal elements as the same. Default 0.5. */
|
|
25
|
+
threshold?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Content similarity in [0, 1]: matching scalar leaves at the same path, with partial credit for similar text. */
|
|
28
|
+
declare function similarity(a: unknown, b: unknown): number;
|
|
29
|
+
/** Match the elements of two arrays. Pure and deterministic. */
|
|
30
|
+
declare function matchArrays(a: readonly unknown[], b: readonly unknown[], options?: MatchOptions): ArrayMatch;
|
|
31
|
+
|
|
32
|
+
type MergeConflictKind = "modify-modify" | "modify-delete" | "delete-modify" | "add-add" | "move-move";
|
|
33
|
+
interface MergeConflict {
|
|
34
|
+
kind: MergeConflictKind;
|
|
35
|
+
/** JSON Pointer in the merged document where the resolved value lives (or would live if it was deleted). */
|
|
36
|
+
path: string;
|
|
37
|
+
/** The value in the base document, when it had one. */
|
|
38
|
+
base?: unknown;
|
|
39
|
+
/** Our value; absent when we deleted it. */
|
|
40
|
+
ours?: unknown;
|
|
41
|
+
/** Their value; absent when they deleted it. */
|
|
42
|
+
theirs?: unknown;
|
|
43
|
+
/** Which side deleted the value, for `modify-delete` and `delete-modify`. */
|
|
44
|
+
deletedBy?: "ours" | "theirs";
|
|
45
|
+
/** Which side the merged document took. */
|
|
46
|
+
resolution: "ours" | "theirs";
|
|
47
|
+
/** The slide the conflict is inside, when it is inside one. */
|
|
48
|
+
slide?: {
|
|
49
|
+
id?: string;
|
|
50
|
+
title?: string;
|
|
51
|
+
index: number;
|
|
52
|
+
};
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
interface MergeOptions extends MatchOptions {
|
|
56
|
+
/** Which side the merged document takes where the sides collide. Default "ours". Conflicts are reported either way. */
|
|
57
|
+
prefer?: "ours" | "theirs";
|
|
58
|
+
}
|
|
59
|
+
interface MergeResult {
|
|
60
|
+
/** The merged document. Conflicting places hold the preferred side's value. */
|
|
61
|
+
merged: unknown;
|
|
62
|
+
conflicts: MergeConflict[];
|
|
63
|
+
/** True when there are no conflicts. */
|
|
64
|
+
clean: boolean;
|
|
65
|
+
/** How many places changed on only one side (applied automatically) or identically on both. */
|
|
66
|
+
applied: {
|
|
67
|
+
ours: number;
|
|
68
|
+
theirs: number;
|
|
69
|
+
both: number;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Three-way merge of OPF documents. Never discards a side silently: every
|
|
74
|
+
* collision is listed in `conflicts` with the base, our value and their value.
|
|
75
|
+
* The merged document is not validated; callers validate it before saving.
|
|
76
|
+
*/
|
|
77
|
+
declare function mergePresentations(base: unknown, ours: unknown, theirs: unknown, options?: MergeOptions): MergeResult;
|
|
78
|
+
|
|
79
|
+
type DiffChangeType = "added" | "removed" | "changed" | "moved";
|
|
80
|
+
/** What kind of thing changed. */
|
|
81
|
+
type DiffCategory = "slide" | "block" | "field" | "design" | "metadata" | "assets" | "catalogs" | "variables" | "narrative" | "extensions";
|
|
82
|
+
interface DiffSlideRef {
|
|
83
|
+
id?: string;
|
|
84
|
+
title?: string;
|
|
85
|
+
/** Index in the first document, when the slide exists there. */
|
|
86
|
+
aIndex?: number;
|
|
87
|
+
/** Index in the second document, when the slide exists there. */
|
|
88
|
+
bIndex?: number;
|
|
89
|
+
}
|
|
90
|
+
interface DiffChange {
|
|
91
|
+
type: DiffChangeType;
|
|
92
|
+
category: DiffCategory;
|
|
93
|
+
/** JSON Pointer in document A (absent for additions). */
|
|
94
|
+
aPath?: string;
|
|
95
|
+
/** JSON Pointer in document B (absent for removals). */
|
|
96
|
+
bPath?: string;
|
|
97
|
+
/** Value in A (removed and changed). */
|
|
98
|
+
before?: unknown;
|
|
99
|
+
/** Value in B (added and changed). */
|
|
100
|
+
after?: unknown;
|
|
101
|
+
/** The slide the change belongs to, for slide-scoped changes. */
|
|
102
|
+
slide?: DiffSlideRef;
|
|
103
|
+
}
|
|
104
|
+
interface SlideMatchInfo extends DiffSlideRef {
|
|
105
|
+
/** How the slide was identified across the documents; absent for added/removed slides. */
|
|
106
|
+
matchedBy?: MatchedBy;
|
|
107
|
+
similarity?: number;
|
|
108
|
+
status: "unchanged" | "modified" | "moved" | "moved-modified" | "added" | "removed";
|
|
109
|
+
}
|
|
110
|
+
interface DiffSummary {
|
|
111
|
+
total: number;
|
|
112
|
+
byCategory: Partial<Record<DiffCategory, number>>;
|
|
113
|
+
byType: Partial<Record<DiffChangeType, number>>;
|
|
114
|
+
slides: {
|
|
115
|
+
added: number;
|
|
116
|
+
removed: number;
|
|
117
|
+
moved: number;
|
|
118
|
+
modified: number;
|
|
119
|
+
unchanged: number;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
interface PresentationDiff {
|
|
123
|
+
equal: boolean;
|
|
124
|
+
changes: DiffChange[];
|
|
125
|
+
/** RFC 6902 patch: `applyPatch(a, patch)` deep-equals `b`. */
|
|
126
|
+
patch: JsonPatchOperation[];
|
|
127
|
+
slides: SlideMatchInfo[];
|
|
128
|
+
summary: DiffSummary;
|
|
129
|
+
}
|
|
130
|
+
type DiffOptions = MatchOptions;
|
|
131
|
+
/** The category a change at `tokens` belongs to. */
|
|
132
|
+
declare function categoryOf(tokens: readonly string[]): DiffCategory;
|
|
133
|
+
/**
|
|
134
|
+
* Diff two OPF documents. Slides are matched by `id`, then by identical
|
|
135
|
+
* content, then by content similarity (`threshold`, default 0.5); the same
|
|
136
|
+
* rule matches blocks, list items and every other array element. The result
|
|
137
|
+
* lists categorised changes and a JSON Patch from `a` to `b`.
|
|
138
|
+
*/
|
|
139
|
+
declare function diffPresentations(a: unknown, b: unknown, options?: DiffOptions): PresentationDiff;
|
|
140
|
+
/** A short, single-line description of a value for reports. */
|
|
141
|
+
declare function describeValue(value: unknown): string;
|
|
142
|
+
/** Render a diff as a plain-text report (no colour, stable ordering). */
|
|
143
|
+
declare function formatDiffReport(diff: PresentationDiff): string;
|
|
144
|
+
|
|
145
|
+
export { type ArrayMatch, type DiffCategory, type DiffChange, type DiffChangeType, type DiffOptions, type DiffSlideRef, type DiffSummary, type MatchOptions, type MatchPair, type MatchedBy, type MergeConflict, type MergeConflictKind, type MergeOptions, type MergeResult, type PresentationDiff, type SlideMatchInfo, categoryOf, describeValue, diffPresentations, formatDiffReport, matchArrays, mergePresentations, similarity };
|