@openpresentation/opf 0.26.0 → 0.26.2
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 +4 -0
- package/dist/browser.js +14 -15
- package/dist/{catalog-refs-CSHevLn1.d.ts → catalog-refs-BSfGELpt.d.ts} +1 -1
- package/dist/catalog-schemas-DoxA2BgY.d.ts +19 -0
- package/dist/{chunk-F7USLFZE.js → chunk-5VJCLUUA.js} +6 -6
- package/dist/{chunk-GS37EBPQ.js → chunk-6JAFSZVL.js} +1 -1
- package/dist/{chunk-F5ABHDUX.js → chunk-7YZ72FRP.js} +5 -5
- package/dist/{chunk-IWFXFWGD.js → chunk-CRCOQ4K2.js} +1 -1
- package/dist/{chunk-EQ6S5SEZ.js → chunk-JI3PHXPJ.js} +1 -1
- package/dist/{chunk-FITOGMR3.js → chunk-L65YNP4J.js} +1 -1
- package/dist/{chunk-X7RANZWP.js → chunk-LN2ASLMF.js} +1 -1
- package/dist/{chunk-P7S3ORB4.js → chunk-LUQYSUXS.js} +1790 -69
- package/dist/{chunk-F4HFDP6I.js → chunk-N6CNJCIF.js} +18 -0
- package/dist/{chunk-3OE6PZIC.js → chunk-NWO6HT4F.js} +4 -4
- package/dist/{chunk-LU6XM5JQ.js → chunk-O2ST5ZKL.js} +1 -1
- package/dist/{chunk-WW62PPYV.js → chunk-OFWBICDO.js} +1 -2
- package/dist/{chunk-MJ57RSYO.js → chunk-Q6KMKTEH.js} +4 -4
- package/dist/{chunk-IC6OPLMU.js → chunk-XFK4KPKK.js} +2 -2
- package/dist/{composition-Daqvi-GV.d.ts → composition-DIftf6iP.d.ts} +1 -1
- package/dist/composition.d.ts +2 -2
- package/dist/conversion-BKCKBECG.js +18 -0
- package/dist/{conversion-DyR-2OkM.d.ts → conversion-CX_I6Vna.d.ts} +5 -5
- package/dist/convert.d.ts +3 -3
- package/dist/convert.js +6 -6
- package/dist/{deck-report-DHaboWbM.d.ts → deck-report-5vwMGcQz.d.ts} +2 -2
- package/dist/deck.d.ts +5 -5
- package/dist/deck.js +9 -9
- package/dist/diff.js +3 -4
- package/dist/docs.js +5 -5
- package/dist/format.js +2 -2
- package/dist/index.d.ts +13 -12
- package/dist/index.js +18 -19
- package/dist/markdown.d.ts +3 -3
- package/dist/markdown.js +6 -6
- package/dist/node-engine.d.ts +7 -7
- package/dist/node-engine.js +18 -19
- package/dist/{pagination-R8YFwVj7.d.ts → pagination-D_kJe4jH.d.ts} +2 -2
- package/dist/pagination.d.ts +3 -3
- package/dist/pagination.js +3 -3
- package/dist/patch.js +2 -3
- package/dist/repo-readme.js +1 -1
- package/dist/schema.d.ts +151 -0
- package/dist/schema.js +3 -0
- package/dist/schemas.js +1 -1
- package/dist/source.d.ts +97 -0
- package/dist/source.js +90 -0
- package/dist/spec/schemas/opf.schema.json +16 -0
- package/dist/spec/schemas/theme.schema.json +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/{validation-types-JW8e06ee.d.ts → validation-types-3ARvTsB0.d.ts} +2 -2
- package/dist/validator.d.ts +54 -6
- package/dist/validator.js +2 -2
- package/dist/yaml.d.ts +3 -3
- package/dist/yaml.js +6 -6
- package/package.json +13 -5
- package/dist/chunk-IY5SCRTV.js +0 -261
- package/dist/conversion-ZPBLP2K6.js +0 -19
- package/dist/validator-Dym2zYVK.d.ts +0 -67
package/dist/chunk-IY5SCRTV.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { validate } from './chunk-P7S3ORB4.js';
|
|
2
|
-
|
|
3
|
-
// src/patch.ts
|
|
4
|
-
var OPFPatchError = class extends Error {
|
|
5
|
-
code;
|
|
6
|
-
/** The JSON Pointer the failing operation addressed, when known. */
|
|
7
|
-
path;
|
|
8
|
-
/** The index of the failing operation within the patch, when known. */
|
|
9
|
-
index;
|
|
10
|
-
/** The failing operation, when known. */
|
|
11
|
-
operation;
|
|
12
|
-
constructor(code, message, details = {}) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = "OPFPatchError";
|
|
15
|
-
this.code = code;
|
|
16
|
-
if (details.path !== void 0) this.path = details.path;
|
|
17
|
-
if (details.index !== void 0) this.index = details.index;
|
|
18
|
-
if (details.operation !== void 0) this.operation = details.operation;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var OPFPatchValidationError = class extends OPFPatchError {
|
|
22
|
-
validation;
|
|
23
|
-
constructor(validation) {
|
|
24
|
-
super("patch-invalid-document", "The patched document is not a valid OPF presentation.");
|
|
25
|
-
this.name = "OPFPatchValidationError";
|
|
26
|
-
this.validation = validation;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
30
|
-
var isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
31
|
-
var clone = (value) => structuredClone(value);
|
|
32
|
-
function jsonEqual(a, b) {
|
|
33
|
-
if (a === b) return true;
|
|
34
|
-
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
35
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
36
|
-
if (Array.isArray(a)) {
|
|
37
|
-
const other = b;
|
|
38
|
-
return a.length === other.length && a.every((item, i) => jsonEqual(item, other[i]));
|
|
39
|
-
}
|
|
40
|
-
const left = a, right = b;
|
|
41
|
-
const keys = Object.keys(left);
|
|
42
|
-
return keys.length === Object.keys(right).length && keys.every((key) => own(right, key) && jsonEqual(left[key], right[key]));
|
|
43
|
-
}
|
|
44
|
-
function escapePointerToken(token) {
|
|
45
|
-
return String(token).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
46
|
-
}
|
|
47
|
-
function unescapePointerToken(token) {
|
|
48
|
-
return token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
49
|
-
}
|
|
50
|
-
function parsePointer(pointer) {
|
|
51
|
-
if (typeof pointer !== "string" || pointer !== "" && !pointer.startsWith("/") || /~(?![01])/u.test(pointer)) {
|
|
52
|
-
throw new OPFPatchError("invalid-json-pointer", "Expected a JSON Pointer (empty string or /path with ~0 and ~1 escapes).", { path: typeof pointer === "string" ? pointer : void 0 });
|
|
53
|
-
}
|
|
54
|
-
return pointer === "" ? [] : pointer.slice(1).split("/").map(unescapePointerToken);
|
|
55
|
-
}
|
|
56
|
-
function formatPointer(tokens) {
|
|
57
|
-
return tokens.length ? `/${tokens.map(escapePointerToken).join("/")}` : "";
|
|
58
|
-
}
|
|
59
|
-
function pointerFromPath(path) {
|
|
60
|
-
if (Array.isArray(path)) return formatPointer(path);
|
|
61
|
-
if (typeof path !== "string") throw new OPFPatchError("invalid-json-pointer", "A path must be a string or an array of segments.");
|
|
62
|
-
if (path === "") return "";
|
|
63
|
-
if (path.startsWith("/")) {
|
|
64
|
-
parsePointer(path);
|
|
65
|
-
return path;
|
|
66
|
-
}
|
|
67
|
-
return formatPointer(path.split(".").filter(Boolean));
|
|
68
|
-
}
|
|
69
|
-
function splitPointer(pointer) {
|
|
70
|
-
const tokens = parsePointer(pointer);
|
|
71
|
-
if (!tokens.length) throw new OPFPatchError("invalid-json-pointer", "The root pointer has no parent.", { path: pointer });
|
|
72
|
-
return { parent: formatPointer(tokens.slice(0, -1)), token: tokens[tokens.length - 1] };
|
|
73
|
-
}
|
|
74
|
-
function readPointer(document, pointer) {
|
|
75
|
-
const tokens = typeof pointer === "string" ? parsePointer(pointer) : pointer;
|
|
76
|
-
let value = document;
|
|
77
|
-
for (const token of tokens) {
|
|
78
|
-
if (Array.isArray(value)) {
|
|
79
|
-
if (!/^(0|[1-9][0-9]*)$/.test(token)) return { found: false };
|
|
80
|
-
const at = Number(token);
|
|
81
|
-
if (!Number.isSafeInteger(at) || at >= value.length) return { found: false };
|
|
82
|
-
value = value[at];
|
|
83
|
-
} else if (value && typeof value === "object" && own(value, token)) value = value[token];
|
|
84
|
-
else return { found: false };
|
|
85
|
-
}
|
|
86
|
-
return { found: true, value };
|
|
87
|
-
}
|
|
88
|
-
function getAtPointer(document, pointer) {
|
|
89
|
-
const result = readPointer(document, pointer);
|
|
90
|
-
if (!result.found) {
|
|
91
|
-
const shown = typeof pointer === "string" ? pointer : formatPointer(pointer);
|
|
92
|
-
throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${shown || "/"}`, { path: shown });
|
|
93
|
-
}
|
|
94
|
-
return result.value;
|
|
95
|
-
}
|
|
96
|
-
var hasPointer = (document, pointer) => readPointer(document, pointer).found;
|
|
97
|
-
function arrayIndex(token, length, allowEnd, path) {
|
|
98
|
-
if (allowEnd && token === "-") return length;
|
|
99
|
-
if (!/^(0|[1-9][0-9]*)$/.test(token)) throw new OPFPatchError("invalid-array-index", `Invalid array index: ${token}`, { path });
|
|
100
|
-
const at = Number(token);
|
|
101
|
-
if (!Number.isSafeInteger(at) || at > length || !allowEnd && at >= length) throw new OPFPatchError("invalid-array-index", `Array index out of bounds: ${token}`, { path });
|
|
102
|
-
return at;
|
|
103
|
-
}
|
|
104
|
-
function normalizePatch(patch) {
|
|
105
|
-
if (!Array.isArray(patch)) throw new OPFPatchError("invalid-patch", "A JSON Patch must be an array of operations.");
|
|
106
|
-
return patch.map((operation, index) => normalizeOperation(operation, index));
|
|
107
|
-
}
|
|
108
|
-
function normalizeOperation(operation, index) {
|
|
109
|
-
const fail = (code, message, path) => new OPFPatchError(code, index === void 0 ? message : `Operation ${index}: ${message}`, { index, operation, path });
|
|
110
|
-
if (!isObject(operation)) throw fail("invalid-patch-operation", "Expected an operation object.");
|
|
111
|
-
const op = operation.op;
|
|
112
|
-
if (typeof op !== "string" || !["add", "remove", "replace", "move", "copy", "test"].includes(op)) {
|
|
113
|
-
throw fail("unsupported-patch-operation", `Unknown operation: ${String(op)}`);
|
|
114
|
-
}
|
|
115
|
-
if (typeof operation.path !== "string") throw fail("invalid-patch-operation", "An operation needs a string path.");
|
|
116
|
-
try {
|
|
117
|
-
parsePointer(operation.path);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
throw fail("invalid-json-pointer", error.message, operation.path);
|
|
120
|
-
}
|
|
121
|
-
if (op === "move" || op === "copy") {
|
|
122
|
-
if (typeof operation.from !== "string") throw fail("invalid-patch-operation", `${op} requires a string from.`, operation.path);
|
|
123
|
-
try {
|
|
124
|
-
parsePointer(operation.from);
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw fail("invalid-json-pointer", error.message, operation.from);
|
|
127
|
-
}
|
|
128
|
-
return { op, from: operation.from, path: operation.path };
|
|
129
|
-
}
|
|
130
|
-
if (op === "remove") return { op, path: operation.path };
|
|
131
|
-
if (!own(operation, "value")) throw fail("invalid-patch-operation", `${op} requires value.`, operation.path);
|
|
132
|
-
return { op, path: operation.path, value: clone(operation.value) };
|
|
133
|
-
}
|
|
134
|
-
function parentOf(document, tokens, path) {
|
|
135
|
-
const key = tokens[tokens.length - 1];
|
|
136
|
-
const found = readPointer(document, tokens.slice(0, -1));
|
|
137
|
-
if (!found.found || !found.value || typeof found.value !== "object") {
|
|
138
|
-
throw new OPFPatchError("patch-parent-missing", `Patch parent does not exist for ${path}.`, { path });
|
|
139
|
-
}
|
|
140
|
-
return { parent: found.value, key };
|
|
141
|
-
}
|
|
142
|
-
var NONE = /* @__PURE__ */ Symbol("none");
|
|
143
|
-
function addAt(document, path, value) {
|
|
144
|
-
const tokens = parsePointer(path);
|
|
145
|
-
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) } };
|
|
146
|
-
const { parent, key } = parentOf(document, tokens, path);
|
|
147
|
-
if (Array.isArray(parent)) {
|
|
148
|
-
const at = arrayIndex(key, parent.length, true, path);
|
|
149
|
-
parent.splice(at, 0, clone(value));
|
|
150
|
-
return { document, inverse: { op: "remove", path: formatPointer([...tokens.slice(0, -1), at]) } };
|
|
151
|
-
}
|
|
152
|
-
const record = parent;
|
|
153
|
-
const previous = own(record, key) ? record[key] : NONE;
|
|
154
|
-
Object.defineProperty(record, key, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
155
|
-
return { document, inverse: previous === NONE ? { op: "remove", path } : { op: "replace", path, value: clone(previous) } };
|
|
156
|
-
}
|
|
157
|
-
function replaceAt(document, path, value) {
|
|
158
|
-
const tokens = parsePointer(path);
|
|
159
|
-
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) } };
|
|
160
|
-
const { parent, key } = parentOf(document, tokens, path);
|
|
161
|
-
let previous;
|
|
162
|
-
if (Array.isArray(parent)) {
|
|
163
|
-
const at = arrayIndex(key, parent.length, false, path);
|
|
164
|
-
previous = parent[at];
|
|
165
|
-
parent[at] = clone(value);
|
|
166
|
-
} else {
|
|
167
|
-
const record = parent;
|
|
168
|
-
if (!own(record, key)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
169
|
-
previous = record[key];
|
|
170
|
-
Object.defineProperty(record, key, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
171
|
-
}
|
|
172
|
-
return { document, inverse: { op: "replace", path, value: clone(previous) } };
|
|
173
|
-
}
|
|
174
|
-
function removeAt(document, path) {
|
|
175
|
-
const tokens = parsePointer(path);
|
|
176
|
-
if (!tokens.length) throw new OPFPatchError("patch-root-remove", "The document root cannot be removed.", { path });
|
|
177
|
-
const { parent, key } = parentOf(document, tokens, path);
|
|
178
|
-
let previous;
|
|
179
|
-
if (Array.isArray(parent)) {
|
|
180
|
-
const at = arrayIndex(key, parent.length, false, path);
|
|
181
|
-
previous = parent[at];
|
|
182
|
-
parent.splice(at, 1);
|
|
183
|
-
return { document, inverse: { op: "add", path: formatPointer([...tokens.slice(0, -1), at]), value: clone(previous) } };
|
|
184
|
-
}
|
|
185
|
-
const record = parent;
|
|
186
|
-
if (!own(record, key)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
187
|
-
previous = record[key];
|
|
188
|
-
delete record[key];
|
|
189
|
-
return { document, inverse: { op: "add", path, value: clone(previous) } };
|
|
190
|
-
}
|
|
191
|
-
function applyOne(document, operation) {
|
|
192
|
-
switch (operation.op) {
|
|
193
|
-
case "add": {
|
|
194
|
-
const r = addAt(document, operation.path, operation.value);
|
|
195
|
-
return { document: r.document, inverse: [r.inverse] };
|
|
196
|
-
}
|
|
197
|
-
case "replace": {
|
|
198
|
-
const r = replaceAt(document, operation.path, operation.value);
|
|
199
|
-
return { document: r.document, inverse: [r.inverse] };
|
|
200
|
-
}
|
|
201
|
-
case "remove": {
|
|
202
|
-
const r = removeAt(document, operation.path);
|
|
203
|
-
return { document: r.document, inverse: [r.inverse] };
|
|
204
|
-
}
|
|
205
|
-
case "test": {
|
|
206
|
-
const found = readPointer(document, operation.path);
|
|
207
|
-
if (!found.found || !jsonEqual(found.value, operation.value)) throw new OPFPatchError("patch-test-failed", `Test failed at ${operation.path || "/"}: the value changed.`, { path: operation.path });
|
|
208
|
-
return { document, inverse: [] };
|
|
209
|
-
}
|
|
210
|
-
case "copy": {
|
|
211
|
-
const value = clone(getAtPointer(document, operation.from));
|
|
212
|
-
const r = addAt(document, operation.path, value);
|
|
213
|
-
return { document: r.document, inverse: [r.inverse] };
|
|
214
|
-
}
|
|
215
|
-
case "move": {
|
|
216
|
-
const from = parsePointer(operation.from), to = parsePointer(operation.path);
|
|
217
|
-
const value = clone(getAtPointer(document, from));
|
|
218
|
-
if (from.length === to.length && from.every((token, i) => token === to[i])) return { document, inverse: [] };
|
|
219
|
-
if (to.length > from.length && from.every((token, i) => to[i] === token)) {
|
|
220
|
-
throw new OPFPatchError("patch-invalid-move", "Cannot move a value into its descendant.", { path: operation.path });
|
|
221
|
-
}
|
|
222
|
-
const removed = removeAt(document, operation.from);
|
|
223
|
-
const added = addAt(removed.document, operation.path, value);
|
|
224
|
-
return { document: added.document, inverse: [added.inverse, removed.inverse] };
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function applyPatchWithInverse(document, patch, options = {}) {
|
|
229
|
-
const operations = normalizePatch(patch);
|
|
230
|
-
let working = clone(document);
|
|
231
|
-
const inverse = [];
|
|
232
|
-
for (const [index, operation] of operations.entries()) {
|
|
233
|
-
try {
|
|
234
|
-
const step = applyOne(working, operation);
|
|
235
|
-
working = step.document;
|
|
236
|
-
inverse.unshift(...step.inverse);
|
|
237
|
-
} catch (error) {
|
|
238
|
-
if (error instanceof OPFPatchError && error.index === void 0) {
|
|
239
|
-
const wrapped = new OPFPatchError(error.code, `Operation ${index}: ${error.message}`, { path: error.path, index, operation });
|
|
240
|
-
throw wrapped;
|
|
241
|
-
}
|
|
242
|
-
throw error;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const result = { presentation: working, inverse, patch: operations };
|
|
246
|
-
if (options.validate) {
|
|
247
|
-
const validator = typeof options.validate === "function" ? options.validate : (value) => validate(value, { only: options.strict ? ["format", "references"] : ["format"] });
|
|
248
|
-
const validation = validator(working);
|
|
249
|
-
if (!validation.valid || options.strict && validation.findings?.some((entry) => entry.severity === "warning")) throw new OPFPatchValidationError(validation);
|
|
250
|
-
result.validation = validation;
|
|
251
|
-
}
|
|
252
|
-
return result;
|
|
253
|
-
}
|
|
254
|
-
function applyPatch(document, patch, options = {}) {
|
|
255
|
-
return applyPatchWithInverse(document, patch, options).presentation;
|
|
256
|
-
}
|
|
257
|
-
function invertPatch(document, patch) {
|
|
258
|
-
return applyPatchWithInverse(document, patch).inverse;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export { OPFPatchError, OPFPatchValidationError, applyPatch, applyPatchWithInverse, escapePointerToken, formatPointer, getAtPointer, hasPointer, invertPatch, jsonEqual, normalizePatch, parsePointer, pointerFromPath, readPointer, splitPointer, unescapePointerToken };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export { convertFiles, deckFileFormat, exportFormatOf, openDeck, planConversion, readInput, saveDeck, writePlanned } from './chunk-F7USLFZE.js';
|
|
2
|
-
import './chunk-IC6OPLMU.js';
|
|
3
|
-
import './chunk-WW62PPYV.js';
|
|
4
|
-
import './chunk-UJSAR6GF.js';
|
|
5
|
-
import './chunk-TKQ2VFV5.js';
|
|
6
|
-
import './chunk-3OE6PZIC.js';
|
|
7
|
-
import './chunk-MJ57RSYO.js';
|
|
8
|
-
import './chunk-F5ABHDUX.js';
|
|
9
|
-
import './chunk-GS37EBPQ.js';
|
|
10
|
-
import './chunk-X7RANZWP.js';
|
|
11
|
-
import './chunk-IY5SCRTV.js';
|
|
12
|
-
import './chunk-EQ6S5SEZ.js';
|
|
13
|
-
import './chunk-FITOGMR3.js';
|
|
14
|
-
import './chunk-IWFXFWGD.js';
|
|
15
|
-
import './chunk-LU6XM5JQ.js';
|
|
16
|
-
import './chunk-P7S3ORB4.js';
|
|
17
|
-
import './chunk-XRMV2GMB.js';
|
|
18
|
-
import './chunk-F4HFDP6I.js';
|
|
19
|
-
import './chunk-PJSPHHRK.js';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { b as CatalogKind } from './catalog-refs-CSHevLn1.js';
|
|
2
|
-
import { SchemaName } from './schemas.js';
|
|
3
|
-
import { a as Finding } from './finding-l9dlQ2NF.js';
|
|
4
|
-
import { P as Presentation } from './presentation-Bwo8Ko6D.js';
|
|
5
|
-
import { b as ValidationThresholds, c as ValidationRuleInfo, V as ValidationReport, a as ValidateOptions } from './validation-types-JW8e06ee.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* RR-78: the version of the catalog record schemas (spec/schemas/<kind>.schema.json) this core reads. A catalog package
|
|
9
|
-
* declares the version its records target (`opf.catalogSchema` in its package.json, `CATALOG_SCHEMA` in its exports, as
|
|
10
|
-
* @openpresentation/gallery does); the Node defaults refuse a gallery that targets another one. A record schema change that
|
|
11
|
-
* old records no longer validate against raises it.
|
|
12
|
-
*/
|
|
13
|
-
declare const CATALOG_SCHEMA = 4;
|
|
14
|
-
/** Kinds of catalog display metadata: published by catalogs for pickers, never referenced by documents. */
|
|
15
|
-
declare const catalogDisplayKinds: readonly ["chartTypes", "languages", "socialPlatforms"];
|
|
16
|
-
type CatalogDisplayKind = (typeof catalogDisplayKinds)[number];
|
|
17
|
-
/** Every kind of record a catalog publishes: the content kinds documents reference, and the display kinds. */
|
|
18
|
-
type CatalogRecordKind = CatalogKind | CatalogDisplayKind;
|
|
19
|
-
/** The companion schema each catalog record kind validates against. */
|
|
20
|
-
declare const catalogSchemaNames: Readonly<Record<CatalogRecordKind, SchemaName>>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The rule registry: every rule `validate` can report, with its category, default severity, cost, rationale and the
|
|
24
|
-
* standard it follows. The format, references and policy rules are produced by the schema and reference checks; the
|
|
25
|
-
* accessibility, layout and content rules are implemented in `rules-*.ts`. Each rule has a stable `opf/<name>` id.
|
|
26
|
-
*/
|
|
27
|
-
declare const DEFAULT_VALIDATION_THRESHOLDS: Readonly<ValidationThresholds>;
|
|
28
|
-
/**
|
|
29
|
-
* Every rule `validate` can report, with its category, default severity, cost, rationale and approximations, ordered by
|
|
30
|
-
* category (format, references, policy, accessibility, layout, content) and, within one, in report order.
|
|
31
|
-
*/
|
|
32
|
-
declare const validationRules: readonly ValidationRuleInfo[];
|
|
33
|
-
/** The rule a full id (`opf/text-contrast`) or bare name (`text-contrast`) names, or undefined. */
|
|
34
|
-
declare function findValidationRule(name: string): ValidationRuleInfo | undefined;
|
|
35
|
-
|
|
36
|
-
declare const promotedRegionKeys: readonly ["left", "center", "right", "left+center", "center+right", "left+center+right", "top", "middle", "bottom", "top+middle", "middle+bottom", "top+middle+bottom", "top:left", "top:center", "top:right", "top:left+center", "top:center+right", "top:left+center+right", "middle:left", "middle:center", "middle:right", "middle:left+center", "middle:center+right", "middle:left+center+right", "bottom:left", "bottom:center", "bottom:right", "bottom:left+center", "bottom:center+right", "bottom:left+center+right", "top+middle:left", "top+middle:center", "top+middle:right", "top+middle:left+center", "top+middle:center+right", "top+middle:left+center+right", "middle+bottom:left", "middle+bottom:center", "middle+bottom:right", "middle+bottom:left+center", "middle+bottom:center+right", "middle+bottom:left+center+right", "top+middle+bottom:left", "top+middle+bottom:center", "top+middle+bottom:right", "top+middle+bottom:left+center", "top+middle+bottom:center+right", "top+middle+bottom:left+center+right"];
|
|
37
|
-
|
|
38
|
-
declare class OPFValidationError extends Error {
|
|
39
|
-
/** The full report that failed. */
|
|
40
|
-
readonly report: ValidationReport;
|
|
41
|
-
/** The error-severity findings of the report. */
|
|
42
|
-
readonly findings: Finding[];
|
|
43
|
-
constructor(report: ValidationReport);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Check a presentation. `input` is a parsed presentation (an object) or the text of one, which is read as strict JSON and nothing
|
|
47
|
-
* else: syntax errors and duplicate keys come back with line and column, and findings carry the range of the value they are
|
|
48
|
-
* about. YAML and Markdown go through `fromYaml` and `fromMarkdown`, which call this for you.
|
|
49
|
-
*
|
|
50
|
-
* Never throws for a bad document, only for bad options (a `TypeError` naming the unknown rule, threshold or option, so a
|
|
51
|
-
* typo cannot silently disable a check).
|
|
52
|
-
*/
|
|
53
|
-
declare function validate(input: unknown, options?: ValidateOptions): ValidationReport;
|
|
54
|
-
/**
|
|
55
|
-
* Throw `OPFValidationError` (carrying the `report`) unless `validate(value, options)` is valid; afterwards TypeScript
|
|
56
|
-
* knows `value` is a `Presentation`. It takes a parsed value, not text. Pass `{ only: ['format'] }` for the cheap check.
|
|
57
|
-
*/
|
|
58
|
-
declare function assertValid(value: unknown, options?: ValidateOptions): asserts value is Presentation;
|
|
59
|
-
/**
|
|
60
|
-
* Check one published catalog record file (an audience, theme, layout, font scheme, chart type and so on) against its
|
|
61
|
-
* companion schema, `$schema` and `id` included. The report has the same shape as `validate`'s; every finding is `format`.
|
|
62
|
-
* A record a document embeds is checked by `validate`, keyed by its id and without `$schema`.
|
|
63
|
-
*/
|
|
64
|
-
declare function validateCatalogRecord(kind: CatalogRecordKind, value: unknown): ValidationReport;
|
|
65
|
-
declare function assertValidCatalogRecord(kind: CatalogRecordKind, value: unknown): void;
|
|
66
|
-
|
|
67
|
-
export { CATALOG_SCHEMA as C, DEFAULT_VALIDATION_THRESHOLDS as D, OPFValidationError as O, type CatalogDisplayKind as a, type CatalogRecordKind as b, assertValid as c, assertValidCatalogRecord as d, catalogDisplayKinds as e, catalogSchemaNames as f, findValidationRule as g, validateCatalogRecord as h, validationRules as i, promotedRegionKeys as p, validate as v };
|