@openpresentation/opf 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +19 -19
- package/dist/{catalog-refs-BgotJhR5.d.ts → catalog-refs-BeRgtpZS.d.ts} +4 -4
- package/dist/{catalog-schemas-BX-VEc5Q.d.ts → catalog-schemas-CwY-3cCP.d.ts} +1 -1
- package/dist/{chunk-OFL3WY6F.js → chunk-3A3PNYNP.js} +77 -15
- package/dist/{chunk-TJMESSBQ.js → chunk-44IS6ZU2.js} +109 -9
- package/dist/{chunk-J7FUSZZ5.js → chunk-4FA4ZABY.js} +6 -6
- package/dist/{chunk-F5SY7MSA.js → chunk-56BYOGIF.js} +1 -1
- package/dist/{chunk-MS2LPR7F.js → chunk-6WN6PRCI.js} +1 -1
- package/dist/{chunk-7JE3XTL7.js → chunk-BHRCWV6B.js} +4 -4
- package/dist/{chunk-4FA4AZXY.js → chunk-C5ACMFKB.js} +1392 -808
- package/dist/{chunk-2NIID3QD.js → chunk-CYGQY6HH.js} +6 -6
- package/dist/{chunk-SER6GJTT.js → chunk-EOMENOKY.js} +23 -6
- package/dist/{chunk-O65COLKF.js → chunk-HS2JQ3AO.js} +118 -19
- package/dist/chunk-IW4TXMJY.js +646 -0
- package/dist/{chunk-6WVPFWPD.js → chunk-JTNCBTEH.js} +4 -4
- package/dist/{chunk-3KPTVK77.js → chunk-KANQVJGK.js} +1244 -119
- package/dist/{chunk-VDZXNNZF.js → chunk-M4IPCFDV.js} +1 -1
- package/dist/{chunk-XRMYP4JD.js → chunk-ORVMHVOS.js} +86 -2
- package/dist/{chunk-HHQROUYC.js → chunk-QFT4R2IL.js} +4405 -2808
- package/dist/chunk-QQBOI5XI.js +86 -0
- package/dist/{chunk-GNKOQ6NA.js → chunk-TIVBO56G.js} +4 -4
- package/dist/{chunk-APCNAAA7.js → chunk-VD7WLE3C.js} +2 -2
- package/dist/{chunk-AZELWKG2.js → chunk-XJU2X5JM.js} +5 -4
- package/dist/chunk-YESKKKVE.js +1 -0
- package/dist/{chunk-BPSZ7OWD.js → chunk-YZ4WMB5C.js} +26 -21
- package/dist/{composition-CSM7YfBl.d.ts → composition-DiKC371V.d.ts} +707 -134
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +1 -1
- package/dist/{conversion-CL7ipVGO.d.ts → conversion-DF_HgknQ.d.ts} +6 -6
- package/dist/conversion-XIWN7FMW.js +25 -0
- package/dist/convert.d.ts +5 -5
- package/dist/convert.js +63 -23
- package/dist/data.d.ts +41 -3
- package/dist/data.js +2 -2
- package/dist/{deck-report-DhsB0SUz.d.ts → deck-report-BwgsIRAf.d.ts} +3 -3
- package/dist/deck.d.ts +6 -6
- package/dist/deck.js +11 -11
- package/dist/diff.js +4 -4
- package/dist/docs.js +43 -31
- package/dist/examples.js +2338 -392
- package/dist/font-policy.js +1 -1
- package/dist/format.js +2 -2
- package/dist/ids.d.ts +17 -4
- package/dist/ids.js +4 -4
- package/dist/index.d.ts +140 -23
- package/dist/index.js +22 -22
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +8 -8
- package/dist/metric-data-B4Q8RFRR.d.ts +382 -0
- package/dist/node-engine.d.ts +6 -6
- package/dist/node-engine.js +21 -21
- package/dist/{pagination-BSqq32xt.d.ts → pagination-C9qnH_n-.d.ts} +5 -5
- package/dist/pagination.d.ts +4 -4
- package/dist/pagination.js +4 -4
- package/dist/patch.js +3 -3
- package/dist/precompiled.js +2 -2
- package/dist/{presentation-Dx-kZC8Y.d.ts → presentation-DmOhusrX.d.ts} +541 -110
- package/dist/schema-engine-ajv.js +1 -1
- package/dist/schema-engine-precompiled.js +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +3 -3
- package/dist/schemas.d.ts +46 -2
- package/dist/schemas.js +1 -1
- package/dist/shape-engine-eager.js +2 -2
- package/dist/shape-engine-lazy.js +1 -1
- package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
- package/dist/shape-geometry.js +1 -1
- package/dist/source.js +10 -10
- package/dist/spec/reference/engine-defaults.json +1 -1
- package/dist/spec/reference/engine-vocabularies.json +1 -0
- package/dist/spec/schemas/font-scheme.schema.json +5 -6
- package/dist/spec/schemas/layout.schema.json +5 -4
- package/dist/spec/schemas/narrative.schema.json +1 -0
- package/dist/spec/schemas/opf.schema.json +661 -98
- package/dist/types.d.ts +11 -12
- package/dist/{validation-types-bnrso0JL.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
- package/dist/validator.d.ts +5 -5
- package/dist/validator.js +3 -3
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +7 -7
- package/package.json +5 -5
- package/dist/chart-data-B_k-WTex.d.ts +0 -194
- package/dist/chunk-6VGLE7C5.js +0 -3983
- package/dist/chunk-SEC4IOOS.js +0 -1
- package/dist/chunk-WCPDN7AY.js +0 -642
- package/dist/conversion-FTGQLJK7.js +0 -25
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { original } from './chunk-JBARNYFR.js';
|
|
2
|
-
import { schemas, schemaEntries } from './chunk-
|
|
3
|
-
import { SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, languageOfText, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE,
|
|
2
|
+
import { schemas, schemaEntries } from './chunk-KANQVJGK.js';
|
|
3
|
+
import { SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, languageOfText, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, variableDeclarations, isTemplate, resolveVariables, listVariables, instantiateForValidation, translationAt, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads, resolveReference, intrinsicImageSize, layoutTable, coerceVariableValue, nearestGridCell, colorTransform, applyColorTransform, resolveColorRef, tableRows, readingRows, visualReadingOrder, numberingSystemExtension, isSupportedNumberingSystem, plainLanguageTag, supportedNumberingSystems, catalogGroupSource, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveScriptFonts, isRecord, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, registeredCatalog, embeddedCopy, renamedLayout, renamedLayoutTitlePosition, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, OPFCompositionError, inlineDatasets, hasBuiltinDependency, hasContentVariables, layoutTemplateIssues, REMOVED_DESIGN_KEYS, deckBackgroundIsFixed, lonePayload, annotationText, isLayoutTemplate, layoutTemplate, statementMessage, messageWords, SHORT_MESSAGE_WORDS, defaultSlideBackground, suggestCellTypeFix, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, documentIcons, iconIssue, walkCitationRuns, HALF_STEPPED, MAX_COMPOSITION_DEPTH, isOverlayConnector, connectorAdjustPreset, shapeIssues, pathFor, overlayIssues, datasetDiagnostics, removedLayoutAuto, renamedLayoutChangesDrawing, catalogRecords, collectCitations, visitPayloadItems, entryId, resolveSlideDirection, isGridCell, gridCellSpan, numberingFindings, dataSourcesOf, resolveDataSource, isDatasetRef, chartDrawDiagnostics, resolveTableData, resolveMetric, resolveChartOptions, chartOptionTarget, codeHighlightLines, relatedName, chartNumberFixesByCell, catalogKinds, representablePositionBox, PositionRangeError, cellsInReadingOrder, isShapeBlock, rowCells } from './chunk-QFT4R2IL.js';
|
|
4
4
|
import { schemaEngine } from '#schema-engine';
|
|
5
5
|
import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
|
|
6
6
|
|
|
@@ -23,6 +23,91 @@ var catalogSchemaNames = {
|
|
|
23
23
|
iconSets: "iconSet"
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
// src/data-source-checks.ts
|
|
27
|
+
var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
var segment = (key3) => String(key3).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
29
|
+
var at = (base, ...keys) => `${base}${keys.map((key3) => `/${segment(key3)}`).join("")}`;
|
|
30
|
+
var DURATION = /^P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?=\d)(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
|
|
31
|
+
var INSTANT = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
32
|
+
function parseInstant(text2) {
|
|
33
|
+
if (typeof text2 !== "string") return void 0;
|
|
34
|
+
const match2 = INSTANT.exec(text2.trim());
|
|
35
|
+
if (!match2) return void 0;
|
|
36
|
+
const [, year, month, day, hour = "0", minute = "0", second = "0", zone] = match2;
|
|
37
|
+
const parts2 = [Number(year), Number(month), Number(day), Number(hour), Number(minute), Number(second)];
|
|
38
|
+
const ms = Date.UTC(parts2[0], parts2[1] - 1, parts2[2], parts2[3], parts2[4], parts2[5]);
|
|
39
|
+
const check = new Date(ms);
|
|
40
|
+
if (check.getUTCFullYear() !== parts2[0] || check.getUTCMonth() !== parts2[1] - 1 || check.getUTCDate() !== parts2[2] || parts2[3] > 23 || parts2[4] > 59 || parts2[5] > 59) return void 0;
|
|
41
|
+
if (zone === void 0 || zone === "Z") return ms;
|
|
42
|
+
const sign = zone[0] === "-" ? -1 : 1;
|
|
43
|
+
return ms - sign * (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4, 6))) * 6e4;
|
|
44
|
+
}
|
|
45
|
+
function addDuration(start, duration) {
|
|
46
|
+
if (typeof duration !== "string") return void 0;
|
|
47
|
+
const match2 = DURATION.exec(duration.trim());
|
|
48
|
+
if (!match2) return void 0;
|
|
49
|
+
const [, years = "0", months = "0", weeks = "0", days = "0", hours = "0", minutes = "0", seconds = "0"] = match2;
|
|
50
|
+
const date = new Date(start);
|
|
51
|
+
const total = date.getUTCFullYear() * 12 + date.getUTCMonth() + Number(years) * 12 + Number(months);
|
|
52
|
+
const year = Math.floor(total / 12), month = total % 12;
|
|
53
|
+
const last = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
54
|
+
const moved = Date.UTC(year, month, Math.min(date.getUTCDate(), last), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());
|
|
55
|
+
return moved + ((Number(weeks) * 7 + Number(days)) * 24 * 60 * 60 + Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds)) * 1e3;
|
|
56
|
+
}
|
|
57
|
+
var SECRET_NAME_TOKENS = /* @__PURE__ */ new Set(["key", "apikey", "token", "secret", "password", "passwd", "pwd", "signature", "sig", "auth", "authorization", "authentication", "oauth", "credential", "credentials", "bearer", "sas"]);
|
|
58
|
+
var SECRET_COMPOUND = /^(?:api|access|secret|private|public|client|auth|refresh|session|bearer|id|app|license)(?:key|token|secret|password|signature)$/;
|
|
59
|
+
function nameTokens(name) {
|
|
60
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((token) => token.toLowerCase());
|
|
61
|
+
}
|
|
62
|
+
function credentialInSrc(src) {
|
|
63
|
+
if (typeof src !== "string") return void 0;
|
|
64
|
+
const authority = /^[a-z][a-z0-9+.-]*:\/\/([^/?#]*)/i.exec(src.trim());
|
|
65
|
+
if (!authority) return void 0;
|
|
66
|
+
const host = authority[1], userEnd = host.lastIndexOf("@");
|
|
67
|
+
if (userEnd >= 0) {
|
|
68
|
+
const separator = host.indexOf(":");
|
|
69
|
+
if (separator >= 0 && separator < userEnd && host.slice(separator + 1, userEnd).length > 0) return "a user and password";
|
|
70
|
+
}
|
|
71
|
+
const query = /\?([^#]*)/.exec(src)?.[1];
|
|
72
|
+
if (query) {
|
|
73
|
+
for (const pair of query.split("&")) {
|
|
74
|
+
const raw = pair.split("=")[0];
|
|
75
|
+
let name = raw;
|
|
76
|
+
try {
|
|
77
|
+
name = decodeURIComponent(raw.replaceAll("+", " "));
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
if (name && nameTokens(name).some((token) => SECRET_NAME_TOKENS.has(token) || SECRET_COMPOUND.test(token))) return `a query parameter named ${JSON.stringify(name)}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
function credentialDiagnostics(source, path, diagnostics) {
|
|
86
|
+
if (!record(source)) return;
|
|
87
|
+
const reason = credentialInSrc(source.src);
|
|
88
|
+
if (reason) diagnostics.push({ code: "datasource-credentials", severity: "warning", path: at(path, "src"), message: `the data source's src carries ${reason}; a data source never holds credentials, so remove it and keep the secret in the host's own store` });
|
|
89
|
+
}
|
|
90
|
+
function provenanceDiagnostics(node, path, document, options2 = {}) {
|
|
91
|
+
const diagnostics = [];
|
|
92
|
+
if (!record(node)) return diagnostics;
|
|
93
|
+
const { datasource } = node;
|
|
94
|
+
if (record(datasource)) credentialDiagnostics(datasource, at(path, "datasource"), diagnostics);
|
|
95
|
+
if (options2.asOf !== void 0 && typeof node.retrieved === "string") {
|
|
96
|
+
const source = resolveDataSource(datasource, document);
|
|
97
|
+
const asOf = parseInstant(options2.asOf), retrieved = parseInstant(node.retrieved);
|
|
98
|
+
const due = source?.refreshEvery !== void 0 && retrieved !== void 0 ? addDuration(retrieved, source.refreshEvery) : void 0;
|
|
99
|
+
if (asOf !== void 0 && due !== void 0 && due < asOf) {
|
|
100
|
+
diagnostics.push({ code: "dataset-stale", severity: "warning", path: at(path, "retrieved"), message: `retrieved ${node.retrieved}, and its data source refreshes every ${source.refreshEvery}, so as of ${options2.asOf} the data is stale; take it from the data source again and update retrieved` });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return diagnostics;
|
|
104
|
+
}
|
|
105
|
+
function dataSourceDiagnostics(document) {
|
|
106
|
+
const diagnostics = [];
|
|
107
|
+
for (const [id, source] of Object.entries(dataSourcesOf(document))) credentialDiagnostics(source, at("/datasources", id), diagnostics);
|
|
108
|
+
return diagnostics;
|
|
109
|
+
}
|
|
110
|
+
|
|
26
111
|
// src/annotation-validation.ts
|
|
27
112
|
var issue = (path, message, params2) => ({ path, message, keyword: "opf", schemaPath: "#/x-opf-semantics", params: params2 });
|
|
28
113
|
var pointer = (dotted2) => `/${dotted2.split(".").map((part2) => part2.replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
|
|
@@ -53,9 +138,9 @@ function annotationIssues(value) {
|
|
|
53
138
|
if (Array.isArray(table.columns)) table.columns.forEach((column, index) => {
|
|
54
139
|
cell(column, `${pathFor(tablePath, "columns")}/${index}`);
|
|
55
140
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
cell(entry2, `${pathFor(tablePath, "rows")}/${rowIndex}/${cellIndex}`);
|
|
141
|
+
tableRows(table).forEach((row, rowIndex) => {
|
|
142
|
+
row.cells.forEach((entry2, cellIndex) => {
|
|
143
|
+
cell(entry2, `${pathFor(tablePath, "rows")}/${rowIndex}${row.object ? "/cells" : ""}/${cellIndex}`);
|
|
59
144
|
});
|
|
60
145
|
});
|
|
61
146
|
}
|
|
@@ -89,6 +174,57 @@ function unusedReferenceWarnings(value) {
|
|
|
89
174
|
return value.references.flatMap((reference, index) => isRecord(reference) && typeof reference.id === "string" && unused.includes(reference.id) ? [issue(`/references/${index}`, `reference '${reference.id}' is never cited; cite it with a run's cite field or remove it`, { code: "unused-reference", id: reference.id })] : []);
|
|
90
175
|
}
|
|
91
176
|
|
|
177
|
+
// src/slide-links.ts
|
|
178
|
+
var PREFIX = "slide:";
|
|
179
|
+
function slideLinkId(link) {
|
|
180
|
+
return typeof link === "string" && link.startsWith(PREFIX) && link.length > PREFIX.length ? link.slice(PREFIX.length) : void 0;
|
|
181
|
+
}
|
|
182
|
+
function slideLink(id) {
|
|
183
|
+
return `${PREFIX}${id}`;
|
|
184
|
+
}
|
|
185
|
+
var pointerToken = (key3) => String(key3).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
186
|
+
function collectSlideLinks(value, base = "") {
|
|
187
|
+
const found = [];
|
|
188
|
+
const visit = (node, pointer5, depth2) => {
|
|
189
|
+
if (depth2 > 64) return;
|
|
190
|
+
if (Array.isArray(node)) {
|
|
191
|
+
for (const [index, child] of node.entries()) visit(child, `${pointer5}/${index}`, depth2 + 1);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!isRecord(node)) return;
|
|
195
|
+
for (const [key3, child] of Object.entries(node)) {
|
|
196
|
+
if (key3 === "extensions") continue;
|
|
197
|
+
if (key3 === "link") {
|
|
198
|
+
const id = slideLinkId(child);
|
|
199
|
+
if (id !== void 0) found.push({ pointer: `${pointer5}/link`, id });
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
visit(child, `${pointer5}/${pointerToken(key3)}`, depth2 + 1);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
visit(value, base, 0);
|
|
206
|
+
return found;
|
|
207
|
+
}
|
|
208
|
+
function slideLinkIssues(value, otherSlides = []) {
|
|
209
|
+
if (!isRecord(value) || !Array.isArray(value.slides)) return [];
|
|
210
|
+
const ids = new Set(otherSlides);
|
|
211
|
+
for (const slide of value.slides) if (isRecord(slide) && typeof slide.id === "string") ids.add(slide.id);
|
|
212
|
+
const issues = [];
|
|
213
|
+
value.slides.forEach((slide, index) => {
|
|
214
|
+
for (const { pointer: pointer5, id } of collectSlideLinks(slide, `/slides/${index}`)) {
|
|
215
|
+
if (ids.has(id)) continue;
|
|
216
|
+
issues.push({
|
|
217
|
+
path: pointer5,
|
|
218
|
+
message: `unknown slide '${id}'; a slide link names the 'id' of a slide of this document (assignIds gives every slide one)`,
|
|
219
|
+
keyword: "opf",
|
|
220
|
+
schemaPath: "#/x-opf-semantics",
|
|
221
|
+
params: { code: "slide-link-unknown", id }
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return issues;
|
|
226
|
+
}
|
|
227
|
+
|
|
92
228
|
// src/finding-text-util.ts
|
|
93
229
|
var WORDS = { object: "an object", array: "a list", string: "text", number: "a number", integer: "a whole number", boolean: "true or false", null: "null" };
|
|
94
230
|
var KIND_WORDS = { layouts: "layout", themes: "theme", colorSchemes: "color scheme", fontSchemes: "font scheme", narratives: "narrative", audiences: "audience", purposes: "purpose", tones: "tone", languages: "language" };
|
|
@@ -103,7 +239,7 @@ function pointerOf(segments) {
|
|
|
103
239
|
return segments.map((part2) => `/${String(part2).replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
|
|
104
240
|
}
|
|
105
241
|
var code = (value) => `\`${String(value)}\``;
|
|
106
|
-
var isIndex = (
|
|
242
|
+
var isIndex = (segment2) => /^\d+$/.test(String(segment2));
|
|
107
243
|
function cap(text2) {
|
|
108
244
|
return text2.startsWith("`") ? text2 : text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
109
245
|
}
|
|
@@ -111,7 +247,7 @@ function fieldLabel(segments) {
|
|
|
111
247
|
if (!segments.length) return "the deck";
|
|
112
248
|
const last = segments[segments.length - 1];
|
|
113
249
|
if (isIndex(last)) {
|
|
114
|
-
const owner = [...segments].reverse().find((
|
|
250
|
+
const owner = [...segments].reverse().find((segment2) => !isIndex(segment2));
|
|
115
251
|
return owner === "slides" ? `slide ${Number(last) + 1}` : owner ? `${owner} entry ${Number(last) + 1}` : `entry ${Number(last) + 1}`;
|
|
116
252
|
}
|
|
117
253
|
return code(last);
|
|
@@ -183,9 +319,9 @@ function asNext(text2) {
|
|
|
183
319
|
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
184
320
|
function readAt(document, segments) {
|
|
185
321
|
let value = document;
|
|
186
|
-
for (const
|
|
187
|
-
if (Array.isArray(value)) value = value[Number(
|
|
188
|
-
else if (isRecord2(value)) value = value[
|
|
322
|
+
for (const segment2 of segments) {
|
|
323
|
+
if (Array.isArray(value)) value = value[Number(segment2)];
|
|
324
|
+
else if (isRecord2(value)) value = value[segment2];
|
|
189
325
|
else return void 0;
|
|
190
326
|
}
|
|
191
327
|
return value;
|
|
@@ -261,9 +397,9 @@ function analyze(engine, rootId, union) {
|
|
|
261
397
|
const lead = ranked[0];
|
|
262
398
|
if (!lead) {
|
|
263
399
|
const rootTypes = reduced.map((result) => result.errors.filter((error) => depth(error.instancePath) === base && error.keyword === "type"));
|
|
264
|
-
const
|
|
400
|
+
const plain2 = rootTypes.every((list, index) => list.length === reduced[index]?.errors.length && list.length > 0);
|
|
265
401
|
const types = [...new Set(rootTypes.flatMap((list) => list.flatMap((error) => [error.params.type].flat())))].map(String);
|
|
266
|
-
return { union, span, replacement: [{ ...union, message:
|
|
402
|
+
return { union, span, replacement: [{ ...union, message: plain2 ? `must be ${named(types)}` : union.message, alternatives: summary(reduced) }] };
|
|
267
403
|
}
|
|
268
404
|
let top = ranked.filter((result) => reach(result.errors) === reach(lead.errors));
|
|
269
405
|
const keys = isObject(union.data) ? Object.keys(union.data) : [];
|
|
@@ -295,7 +431,8 @@ function analyze(engine, rootId, union) {
|
|
|
295
431
|
}
|
|
296
432
|
const chosen = top.flatMap((result) => result.errors).map((error, index) => {
|
|
297
433
|
const mapped = { ...error, parentSchema: original(error.parentSchema), schema: original(error.schema) };
|
|
298
|
-
|
|
434
|
+
const rowUnion = /\/table\/rows\/\d+$/.test(union.instancePath);
|
|
435
|
+
if (index === 0 && others.length && !(rowUnion && mapped.alternatives !== void 0)) mapped.alternatives = summary(others);
|
|
299
436
|
return mapped;
|
|
300
437
|
});
|
|
301
438
|
return { union, span, replacement: chosen };
|
|
@@ -402,8 +539,8 @@ function rememberValidationDefinition(issue2, parentSchema, keyword) {
|
|
|
402
539
|
uri: `${entry2.schema.$id}#${current.pointer}`
|
|
403
540
|
});
|
|
404
541
|
for (const [key3, value] of Object.entries(current.value)) {
|
|
405
|
-
const
|
|
406
|
-
stack.push({ value, pointer: `${current.pointer}/${
|
|
542
|
+
const segment2 = key3.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
543
|
+
stack.push({ value, pointer: `${current.pointer}/${segment2}` });
|
|
407
544
|
}
|
|
408
545
|
}
|
|
409
546
|
}
|
|
@@ -430,6 +567,7 @@ var rootPayloadFields = [
|
|
|
430
567
|
"bullets",
|
|
431
568
|
"image",
|
|
432
569
|
"video",
|
|
570
|
+
"embed",
|
|
433
571
|
"chart",
|
|
434
572
|
"table",
|
|
435
573
|
"code",
|
|
@@ -467,6 +605,10 @@ var contentKindSpecs = {
|
|
|
467
605
|
fields: ["video"],
|
|
468
606
|
required: ["video"]
|
|
469
607
|
},
|
|
608
|
+
embed: {
|
|
609
|
+
fields: ["embed"],
|
|
610
|
+
required: ["embed"]
|
|
611
|
+
},
|
|
470
612
|
code: {
|
|
471
613
|
fields: ["code"],
|
|
472
614
|
required: ["code"]
|
|
@@ -494,7 +636,7 @@ var contentKindSpecs = {
|
|
|
494
636
|
requireAny: ["shape", "path"]
|
|
495
637
|
}
|
|
496
638
|
};
|
|
497
|
-
var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video", "diagram"]);
|
|
639
|
+
var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video", "embed", "diagram"]);
|
|
498
640
|
var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "adjust", "stroke", "opacity", "recolor", "overlay", "placement", "portrait"];
|
|
499
641
|
var shapeImageFields = /* @__PURE__ */ new Set(["aspectRatio", "shape", "adjust", "stroke", "opacity"]);
|
|
500
642
|
var shapeOptionFields = SHAPE_BLOCK_KEYS.filter((field) => field !== "path");
|
|
@@ -546,17 +688,17 @@ function isEnUkTag(value) {
|
|
|
546
688
|
}
|
|
547
689
|
var EN_UK_MESSAGE = "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag";
|
|
548
690
|
function enUkIssues(language, path) {
|
|
549
|
-
const
|
|
550
|
-
return
|
|
691
|
+
const at3 = isEnUkTag(language) ? path : isRecord(language) && isEnUkTag(language.bcp47) ? `${path}/bcp47` : void 0;
|
|
692
|
+
return at3 ? [semanticIssue(at3, EN_UK_MESSAGE, { replacement: "en-GB" })] : [];
|
|
551
693
|
}
|
|
552
694
|
function overlayAnchorSizeWarnings(value) {
|
|
553
695
|
const issues = [];
|
|
554
696
|
if (isRecord(value) && Array.isArray(value.slides)) value.slides.forEach((slide, index) => {
|
|
555
697
|
if (isRecord(slide) && Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
|
|
556
|
-
const
|
|
557
|
-
if (isRecord(
|
|
558
|
-
const size =
|
|
559
|
-
if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(
|
|
698
|
+
const at3 = isRecord(entry2) ? entry2.at : void 0;
|
|
699
|
+
if (isRecord(at3)) for (const key3 of ["width", "height"]) {
|
|
700
|
+
const size = at3[key3];
|
|
701
|
+
if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(at3, `${key3}Px`))
|
|
560
702
|
issues.push(semanticIssue(`/slides/${index}/shapes/${shapeIndex}/at/${key3}`, `at.${key3} is ${size}, a fraction; pixels are ${key3}Px`, { code: "shape-anchor-size-unit", key: key3, size }));
|
|
561
703
|
}
|
|
562
704
|
});
|
|
@@ -577,6 +719,7 @@ function inferredKinds(value) {
|
|
|
577
719
|
if (hasOwn(value, "items")) kinds.push("list");
|
|
578
720
|
if (hasOwn(value, "image")) kinds.push("image");
|
|
579
721
|
if (hasOwn(value, "video")) kinds.push("video");
|
|
722
|
+
if (hasOwn(value, "embed")) kinds.push("embed");
|
|
580
723
|
if (hasOwn(value, "chart")) kinds.push("chart");
|
|
581
724
|
if (hasOwn(value, "table")) kinds.push("table");
|
|
582
725
|
if (hasOwn(value, "code")) kinds.push("code");
|
|
@@ -597,7 +740,7 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
597
740
|
const explicitType = value.type;
|
|
598
741
|
const payloadFields = presentFields(value, rootPayloadFields);
|
|
599
742
|
const hasBlocks = hasOwn(value, "blocks");
|
|
600
|
-
const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table, video or diagram payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
|
|
743
|
+
const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table, video, embed or diagram payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
|
|
601
744
|
const imageOptionIssues = (reason, params2 = {}, except = /* @__PURE__ */ new Set()) => {
|
|
602
745
|
for (const field of imageOptionFields) if (hasOwn(value, field) && !except.has(field)) issues.push(semanticIssue(pathFor(path, field), `${field} is only valid on an image payload; ${reason}`, { code: "image-option-unsupported-payload", field, ...params2 }));
|
|
603
746
|
};
|
|
@@ -662,19 +805,19 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
662
805
|
if (resolvedKind !== "image") imageOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind }, resolvedKind === "shape" ? shapeImageFields : void 0);
|
|
663
806
|
if (resolvedKind !== "shape") shapeOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind });
|
|
664
807
|
if (resolvedKind === "shape" || resolvedKind === "image")
|
|
665
|
-
for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((
|
|
808
|
+
for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at3, key3) => pathFor(at3, key3), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
|
|
666
809
|
if (resolvedKind === "image" && isRecord(value.image) && Array.isArray(value.image.callouts)) {
|
|
667
810
|
value.image.callouts.forEach((callout, index) => {
|
|
668
811
|
if (!isRecord(callout)) return;
|
|
669
812
|
for (const key3 of ["x", "y"]) if (typeof callout[key3] === "number" && !Number.isFinite(callout[key3])) issues.push(semanticIssue(`${pathFor(path, "image")}/callouts/${index}/${key3}`, "an image callout origin must be a finite signed fraction", { key: key3 }));
|
|
670
813
|
const canvas = options2.canvas;
|
|
671
814
|
if (canvas && ["x", "y", "width", "height"].every((key3) => typeof callout[key3] === "number" && Number.isFinite(callout[key3]))) {
|
|
672
|
-
const
|
|
815
|
+
const at3 = `${pathFor(path, "image")}/callouts/${index}`, frame = callout;
|
|
673
816
|
try {
|
|
674
|
-
representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height },
|
|
817
|
+
representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height }, at3.replace(/^\//, "").replaceAll("/", "."));
|
|
675
818
|
} catch (error) {
|
|
676
819
|
if (!(error instanceof PositionRangeError)) throw error;
|
|
677
|
-
issues.push(semanticIssue(`${
|
|
820
|
+
issues.push(semanticIssue(`${at3}/${error.coordinate}`, error.message, { key: error.coordinate }));
|
|
678
821
|
}
|
|
679
822
|
}
|
|
680
823
|
});
|
|
@@ -733,8 +876,8 @@ function validateSlideCells(slide, slidePath) {
|
|
|
733
876
|
for (let right = left + 1; right < cells.length; right += 1) {
|
|
734
877
|
const a = gridCellSpan(cells[left]), b = gridCellSpan(cells[right]);
|
|
735
878
|
if (!a || !b || !intersects(a.rows, b.rows) || !intersects(a.columns, b.columns)) continue;
|
|
736
|
-
const
|
|
737
|
-
issues.push(semanticIssue(pathFor(pathFor(pathFor(slidePath, "blocks"), String(
|
|
879
|
+
const at3 = placed.find(({ block }) => block.region === cells[right]);
|
|
880
|
+
issues.push(semanticIssue(pathFor(pathFor(pathFor(slidePath, "blocks"), String(at3.index)), "region"), `cells '${cells[left]}' and '${cells[right]}' overlap`, { cells: [cells[left], cells[right]] }));
|
|
738
881
|
}
|
|
739
882
|
}
|
|
740
883
|
return issues;
|
|
@@ -757,13 +900,13 @@ function deckMetadataIssues(value) {
|
|
|
757
900
|
}
|
|
758
901
|
}
|
|
759
902
|
for (const { entry: entry2, path } of entries("speaker")) {
|
|
760
|
-
if (typeof entry2.
|
|
761
|
-
issues.push(semanticIssue(`${path}/
|
|
903
|
+
if (typeof entry2.organization === "string" && !organizationIds.has(entry2.organization)) {
|
|
904
|
+
issues.push(semanticIssue(`${path}/organization`, `organization '${entry2.organization}' names no organization in the presentation; use the id of an entry in organization`, { id: entry2.organization }));
|
|
762
905
|
}
|
|
763
906
|
}
|
|
764
907
|
return issues;
|
|
765
908
|
}
|
|
766
|
-
function presentationSemanticIssues(value, catalogs) {
|
|
909
|
+
function presentationSemanticIssues(value, catalogs, slideLinks) {
|
|
767
910
|
if (!isRecord(value) || !Array.isArray(value.slides)) {
|
|
768
911
|
return [];
|
|
769
912
|
}
|
|
@@ -800,13 +943,22 @@ function presentationSemanticIssues(value, catalogs) {
|
|
|
800
943
|
const seen = documentIds.get(slide.id);
|
|
801
944
|
if (seen === "slide") issues.push(semanticIssue(`${slidePath}/id`, "slide ids must be unique within a presentation", { id: slide.id }));
|
|
802
945
|
else if (seen === "payload") issues.push(semanticIssue(`${slidePath}/id`, "slide id duplicates a content payload id; ids must be unique among slide and payload ids within a presentation", { id: slide.id }));
|
|
946
|
+
else if (seen === "entry") issues.push(semanticIssue(`${slidePath}/id`, "slide id duplicates a list item, bullet, timeline event or table row id; ids are unique across the whole presentation", { id: slide.id }));
|
|
803
947
|
else documentIds.set(slide.id, "slide");
|
|
804
948
|
}
|
|
949
|
+
const claimEntries = (owner, path) => visitPayloadItems(owner, path, (kind, entry2, entryPath) => {
|
|
950
|
+
const id = entryId(entry2);
|
|
951
|
+
if (id === void 0) return;
|
|
952
|
+
if (documentIds.has(id)) issues.push(semanticIssue(`${entryPath}/id`, `${kind === "event" ? "timeline event" : kind === "row" ? "table row" : kind} ids must be unique among every slide, payload, overlay, list item, bullet, timeline event and table row id within a presentation`, { id }));
|
|
953
|
+
else documentIds.set(id, "entry");
|
|
954
|
+
});
|
|
955
|
+
claimEntries(slide, slidePath);
|
|
805
956
|
visitContentPayloads(slide, slidePath, (payload, path) => {
|
|
806
957
|
if (typeof payload.id === "string") {
|
|
807
958
|
if (documentIds.has(payload.id)) issues.push(semanticIssue(`${path}/id`, "content payload ids must be unique among slide and payload ids within a presentation", { id: payload.id }));
|
|
808
959
|
else documentIds.set(payload.id, "payload");
|
|
809
960
|
}
|
|
961
|
+
claimEntries(payload, path);
|
|
810
962
|
});
|
|
811
963
|
if (Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
|
|
812
964
|
if (!isRecord(entry2)) return;
|
|
@@ -816,7 +968,7 @@ function presentationSemanticIssues(value, catalogs) {
|
|
|
816
968
|
else documentIds.set(entry2.id, "payload");
|
|
817
969
|
}
|
|
818
970
|
const checked = isOverlayConnector(entry2) ? isRecord(entry2.adjust) ? { shape: connectorAdjustPreset(entry2), adjust: entry2.adjust } : void 0 : entry2;
|
|
819
|
-
if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((
|
|
971
|
+
if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at3, key3) => pathFor(at3, key3), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
|
|
820
972
|
});
|
|
821
973
|
for (const issue2 of overlayIssues(slide, slidePath, value, canvasForOverlays(slide, index))) issues.push(semanticIssue(issue2.path, issue2.message, { ...issue2.code ? { code: issue2.code } : {}, ...issue2.params }));
|
|
822
974
|
issues.push(...enUkIssues(slide.language, `${slidePath}/language`));
|
|
@@ -831,9 +983,16 @@ function presentationSemanticIssues(value, catalogs) {
|
|
|
831
983
|
};
|
|
832
984
|
payloadNumberingIssues(slide, slidePath);
|
|
833
985
|
visitContentPayloads(slide, slidePath, payloadNumberingIssues);
|
|
986
|
+
const payloadEmbedIssues = (payload, path) => {
|
|
987
|
+
const embed = payload.embed, address = isRecord(embed) ? embed.src : embed, part2 = credentialInSrc(address);
|
|
988
|
+
if (part2 !== void 0) issues.push(semanticIssue(isRecord(embed) ? pathFor(pathFor(path, "embed"), "src") : pathFor(path, "embed"), `This embed's address carries what looks like a credential (${part2}). Anyone with the deck can read it.`, { code: "embed-credentials", credential: part2 }));
|
|
989
|
+
};
|
|
990
|
+
payloadEmbedIssues(slide, slidePath);
|
|
991
|
+
visitContentPayloads(slide, slidePath, payloadEmbedIssues);
|
|
834
992
|
}
|
|
835
993
|
});
|
|
836
994
|
issues.push(...annotationIssues(value));
|
|
995
|
+
if (slideLinks !== false) issues.push(...slideLinkIssues(value, slideLinks));
|
|
837
996
|
return issues;
|
|
838
997
|
}
|
|
839
998
|
function canvasSize(dimensions) {
|
|
@@ -924,7 +1083,7 @@ function chartTypeWarnings(payload, path) {
|
|
|
924
1083
|
}
|
|
925
1084
|
return issues;
|
|
926
1085
|
}
|
|
927
|
-
function dataIssues(value) {
|
|
1086
|
+
function dataIssues(value, asOf) {
|
|
928
1087
|
const out = { errors: [], warnings: [] };
|
|
929
1088
|
if (!isRecord(value) || !Array.isArray(value.slides)) return out;
|
|
930
1089
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -933,17 +1092,22 @@ function dataIssues(value) {
|
|
|
933
1092
|
const key3 = `${diagnostic.code}|${diagnostic.path}`;
|
|
934
1093
|
if (seen.has(key3)) continue;
|
|
935
1094
|
seen.add(key3);
|
|
936
|
-
|
|
1095
|
+
const fix = diagnostic.fix;
|
|
1096
|
+
(diagnostic.severity === "error" ? out.errors : out.warnings).push(semanticIssue(diagnostic.path, diagnostic.message, { code: diagnostic.code, ...diagnostic.aggregate ? { aggregate: true } : {}, ...fix ? { fix } : {} }));
|
|
937
1097
|
}
|
|
938
1098
|
};
|
|
939
1099
|
add(datasetDiagnostics(value));
|
|
1100
|
+
add(dataSourceDiagnostics(value));
|
|
1101
|
+
for (const [id, dataset] of Object.entries(isRecord(value.datasets) ? value.datasets : {})) add(provenanceDiagnostics(dataset, `/datasets/${id.replaceAll("~", "~0").replaceAll("/", "~1")}`, value, { asOf }));
|
|
940
1102
|
const payload = (node, path) => {
|
|
941
1103
|
if (isRecord(node.chart)) {
|
|
942
1104
|
const resolved2 = resolveChartData(node.chart, value, { path: pathFor(path, "chart") });
|
|
1105
|
+
if (isRecord(node.chart.data) && !isDatasetRef(node.chart.data)) add(provenanceDiagnostics(node.chart.data, pathFor(pathFor(path, "chart"), "data"), value, { asOf }));
|
|
943
1106
|
add(resolved2.diagnostics);
|
|
944
1107
|
add(chartDrawDiagnostics(node.chart, resolved2, pathFor(path, "chart"), { language: typeof value.language === "string" ? value.language : void 0 }));
|
|
945
1108
|
}
|
|
946
1109
|
if (isRecord(node.table)) add(resolveTableData(node.table, value, { path: pathFor(path, "table") }).diagnostics);
|
|
1110
|
+
if (isRecord(node.metric)) add(resolveMetric(node.metric, value, { path: pathFor(path, "metric"), ...typeof value.language === "string" ? { language: value.language } : {} }).diagnostics);
|
|
947
1111
|
};
|
|
948
1112
|
value.slides.forEach((slide, index) => {
|
|
949
1113
|
if (!isRecord(slide)) return;
|
|
@@ -1047,9 +1211,9 @@ function variableReferenceWarnings(value) {
|
|
|
1047
1211
|
if (Array.isArray(node.rows)) {
|
|
1048
1212
|
const rowsPath = pathFor(path, "rows");
|
|
1049
1213
|
node.rows.forEach((row, rowIndex) => {
|
|
1050
|
-
|
|
1051
|
-
row.forEach((cell, cellIndex) => {
|
|
1052
|
-
tableCell(cell, `${
|
|
1214
|
+
const cellsPath = isRecord(row) ? `${rowsPath}/${rowIndex}/cells` : `${rowsPath}/${rowIndex}`;
|
|
1215
|
+
rowCells(row).forEach((cell, cellIndex) => {
|
|
1216
|
+
tableCell(cell, `${cellsPath}/${cellIndex}`);
|
|
1053
1217
|
});
|
|
1054
1218
|
});
|
|
1055
1219
|
}
|
|
@@ -1210,6 +1374,15 @@ var datasetTableMessage = (field) => `'${field}' is not allowed on a dataset-bac
|
|
|
1210
1374
|
function dataUnionErrors(errors, value) {
|
|
1211
1375
|
let kept = errors;
|
|
1212
1376
|
for (const union of errors) {
|
|
1377
|
+
if (union.keyword !== "oneOf" || !/\/table\/rows\/\d+$/.test(union.instancePath) || !union.schemaPath.endsWith("/$defs/TableRow/oneOf")) continue;
|
|
1378
|
+
const target = pointerValue(value, union.instancePath);
|
|
1379
|
+
const other = Array.isArray(target) ? 1 : isRecord(target) ? 0 : void 0;
|
|
1380
|
+
if (other === void 0) continue;
|
|
1381
|
+
const prefix = `${union.instancePath}/`;
|
|
1382
|
+
const otherBranch = `/$defs/TableRow/oneOf/${other}/`;
|
|
1383
|
+
kept = kept.filter((error) => error !== union && !(error.schemaPath.includes(otherBranch) && (error.instancePath === union.instancePath || error.instancePath.startsWith(prefix))));
|
|
1384
|
+
}
|
|
1385
|
+
for (const union of kept) {
|
|
1213
1386
|
if (union.keyword !== "oneOf") continue;
|
|
1214
1387
|
const chartData = /\/chart\/data$/.test(union.instancePath) && /\/properties\/data\/oneOf$/.test(union.schemaPath);
|
|
1215
1388
|
const header = /\/table\/columns\/\d+$/.test(union.instancePath) && /\/properties\/columns\/items\/oneOf$/.test(union.schemaPath);
|
|
@@ -1249,7 +1422,8 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
|
|
|
1249
1422
|
subject = view.presentation;
|
|
1250
1423
|
unfilledVariables = view.unfilled;
|
|
1251
1424
|
for (const entry2 of view.diagnostics) {
|
|
1252
|
-
if (entry2.code === "variable-example-used" || entry2.code === "variable-rich-flattened" || entry2.code === "variable-unfilled") continue;
|
|
1425
|
+
if (entry2.code === "variable-example-used" || entry2.code === "variable-rich-flattened" || entry2.code === "variable-unfilled" || entry2.code === "variable-translations-removed") continue;
|
|
1426
|
+
if (entry2.code === "variable-overflow") continue;
|
|
1253
1427
|
const issue2 = semanticIssue(entry2.path, entry2.message, { id: entry2.id, code: entry2.code });
|
|
1254
1428
|
(entry2.severity === "error" ? variableIssues.errors : variableIssues.warnings).push(issue2);
|
|
1255
1429
|
}
|
|
@@ -1269,9 +1443,9 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
|
|
|
1269
1443
|
if (resolved2.schemaName === "layout" && valid) for (const issue2 of layoutTemplateIssues(subject)) errors.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code }));
|
|
1270
1444
|
const warnings = [];
|
|
1271
1445
|
if (resolved2.schemaName === "presentation") {
|
|
1272
|
-
errors.push(...presentationSemanticIssues(subject, options2.catalogs));
|
|
1446
|
+
errors.push(...presentationSemanticIssues(subject, options2.catalogs, options2.slideLinks));
|
|
1273
1447
|
errors.push(...variableIssues.errors);
|
|
1274
|
-
const data = dataIssues(subject);
|
|
1448
|
+
const data = dataIssues(subject, options2.asOf);
|
|
1275
1449
|
errors.push(...data.errors);
|
|
1276
1450
|
warnings.push(...presentationReferenceWarnings(subject, options2.catalogs));
|
|
1277
1451
|
warnings.push(...data.warnings);
|
|
@@ -1297,9 +1471,9 @@ function recordIssues(kind, id, value) {
|
|
|
1297
1471
|
const schemaName = catalogSchemaNames[kind];
|
|
1298
1472
|
return validateAgainstSchema(object(value) ? { $schema: schemas[schemaName].$id, id, ...value } : value, kind);
|
|
1299
1473
|
}
|
|
1300
|
-
function embeddedRecordInvalid(kind, id,
|
|
1301
|
-
if (object(
|
|
1302
|
-
return !recordIssues(kind, id,
|
|
1474
|
+
function embeddedRecordInvalid(kind, id, record2) {
|
|
1475
|
+
if (object(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) return false;
|
|
1476
|
+
return !recordIssues(kind, id, record2).valid;
|
|
1303
1477
|
}
|
|
1304
1478
|
function resolvesToValidRecord(document, kind, reference, options2 = {}) {
|
|
1305
1479
|
const found = resolveReference(document, kind, reference, options2);
|
|
@@ -1312,9 +1486,9 @@ function resolveNarrative(document, options2 = {}) {
|
|
|
1312
1486
|
if (!isRec(document) || typeof document.narrative !== "string") return void 0;
|
|
1313
1487
|
const found = resolveReference(document, "narratives", document.narrative, { catalogs: options2.catalogs ?? [] });
|
|
1314
1488
|
if (!found) return void 0;
|
|
1315
|
-
const
|
|
1316
|
-
const beats = Array.isArray(
|
|
1317
|
-
return { record, origin: found.origin, beats };
|
|
1489
|
+
const record2 = found.record;
|
|
1490
|
+
const beats = Array.isArray(record2.beats) ? record2.beats.flatMap((beat) => isRec(beat) && typeof beat.id === "string" ? [beat.id] : []) : [];
|
|
1491
|
+
return { record: record2, origin: found.origin, beats };
|
|
1318
1492
|
}
|
|
1319
1493
|
function slideBeatReferences(document) {
|
|
1320
1494
|
if (!isRec(document) || !Array.isArray(document.slides)) return [];
|
|
@@ -1324,8 +1498,8 @@ function slideBeatReferences(document) {
|
|
|
1324
1498
|
const path = `/slides/${index}/beat`;
|
|
1325
1499
|
if (typeof slide.beat === "string") references.push({ path, slide: index, beat: slide.beat });
|
|
1326
1500
|
else if (Array.isArray(slide.beat))
|
|
1327
|
-
slide.beat.forEach((beat,
|
|
1328
|
-
if (typeof beat === "string") references.push({ path: `${path}/${
|
|
1501
|
+
slide.beat.forEach((beat, at3) => {
|
|
1502
|
+
if (typeof beat === "string") references.push({ path: `${path}/${at3}`, slide: index, beat });
|
|
1329
1503
|
});
|
|
1330
1504
|
});
|
|
1331
1505
|
return references;
|
|
@@ -1339,14 +1513,14 @@ function unreferencedBeats(document, narrative) {
|
|
|
1339
1513
|
if (referenced.size === 0) return [];
|
|
1340
1514
|
return narrative.beats.flatMap((beat, index) => referenced.has(beat) ? [] : [{ beat, index }]);
|
|
1341
1515
|
}
|
|
1342
|
-
function durationRange(
|
|
1343
|
-
if (!isRec(
|
|
1516
|
+
function durationRange(record2) {
|
|
1517
|
+
if (!isRec(record2) || !isRec(record2.duration)) return void 0;
|
|
1344
1518
|
const bound = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
1345
|
-
const min = bound(
|
|
1519
|
+
const min = bound(record2.duration.min), max = bound(record2.duration.max);
|
|
1346
1520
|
return min === void 0 && max === void 0 ? void 0 : { ...min !== void 0 ? { min } : {}, ...max !== void 0 ? { max } : {} };
|
|
1347
1521
|
}
|
|
1348
|
-
function durationRangeInverted(
|
|
1349
|
-
const range = durationRange(
|
|
1522
|
+
function durationRangeInverted(record2) {
|
|
1523
|
+
const range = durationRange(record2);
|
|
1350
1524
|
return range?.min !== void 0 && range.max !== void 0 && range.min > range.max;
|
|
1351
1525
|
}
|
|
1352
1526
|
function durationOutsideNarrative(document, narrative) {
|
|
@@ -1366,7 +1540,7 @@ function describeDurationRange(range) {
|
|
|
1366
1540
|
var rec = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1367
1541
|
var toRgb = (hex) => {
|
|
1368
1542
|
const n = normalizeHexColor(hex) ?? "#000000";
|
|
1369
|
-
return [1, 3, 5].map((
|
|
1543
|
+
return [1, 3, 5].map((at3) => Number.parseInt(n.slice(at3, at3 + 2), 16));
|
|
1370
1544
|
};
|
|
1371
1545
|
var toHex = (rgb) => `#${rgb.map((c) => Math.max(0, Math.min(255, Math.round(c))).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
1372
1546
|
var linear = (c) => {
|
|
@@ -1548,7 +1722,7 @@ function colorChoice(levels, scheme, variables = {}) {
|
|
|
1548
1722
|
if (variantOnly || definition === void 0 || definition === null || definition === false) continue;
|
|
1549
1723
|
if (themeSlot) return { variant: { background: themeSlot } };
|
|
1550
1724
|
if (isPicture) {
|
|
1551
|
-
const tone = rec(definition).
|
|
1725
|
+
const tone = rec(definition).appearance ?? pictureTone(definition, scheme, variables);
|
|
1552
1726
|
if (tone === "dark" || tone === "light") return { variant: { background: tone === "dark" ? "dark1" : "light1" } };
|
|
1553
1727
|
variantOnly = true;
|
|
1554
1728
|
picture = { definition };
|
|
@@ -1700,64 +1874,62 @@ function textValues(slide, slidePath) {
|
|
|
1700
1874
|
for (const field of ["title", "subtitle", "tag"])
|
|
1701
1875
|
if (isText(slide[field])) out.push({ path: pointer2(...splitPointer(slidePath), field), value: slide[field], role: field, payload: slidePath, field });
|
|
1702
1876
|
for (const payload of slidePayloads(slide, slidePath)) {
|
|
1703
|
-
const node = payload.node,
|
|
1877
|
+
const node = payload.node, at3 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
|
|
1704
1878
|
const push = (path, value, role, field) => {
|
|
1705
1879
|
if (isText(value)) out.push({ path, value, role, payload: payload.path, field });
|
|
1706
1880
|
};
|
|
1707
|
-
push(
|
|
1881
|
+
push(at3("text"), node.text, "body", "text");
|
|
1708
1882
|
for (const field of ["items", "bullets"])
|
|
1709
1883
|
if (Array.isArray(node[field]))
|
|
1710
1884
|
node[field].forEach((entry2, index) => {
|
|
1711
|
-
if (isText(entry2)) push(
|
|
1885
|
+
if (isText(entry2)) push(at3(field, index), entry2, "list", field);
|
|
1712
1886
|
else if (entry2 && typeof entry2 === "object") {
|
|
1713
|
-
push(
|
|
1714
|
-
push(
|
|
1887
|
+
push(at3(field, index, "text"), entry2.text, "list", field);
|
|
1888
|
+
push(at3(field, index, "description"), entry2.description, "list-description", field);
|
|
1715
1889
|
}
|
|
1716
1890
|
});
|
|
1717
1891
|
const table = rec(node.table);
|
|
1718
1892
|
if (Array.isArray(table.columns))
|
|
1719
1893
|
table.columns.forEach((cell, c) => {
|
|
1720
1894
|
const styled = rec(cell);
|
|
1721
|
-
if (!Object.hasOwn(styled, "value") && typeof styled.name === "string") push(
|
|
1895
|
+
if (!Object.hasOwn(styled, "value") && typeof styled.name === "string") push(at3("table", "columns", c, "name"), styled.name, "table-header", "table");
|
|
1722
1896
|
else {
|
|
1723
1897
|
const value = Object.hasOwn(styled, "value") ? styled.value : cell;
|
|
1724
|
-
push(
|
|
1898
|
+
push(at3("table", "columns", c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table-header", "table");
|
|
1725
1899
|
}
|
|
1726
1900
|
});
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
const value = Object.hasOwn(styled, "value") ? styled.value : cell;
|
|
1733
|
-
push(at2("table", "rows", r, c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
|
|
1734
|
-
});
|
|
1901
|
+
tableRows(table).forEach((row, r) => {
|
|
1902
|
+
row.cells.forEach((cell, c) => {
|
|
1903
|
+
const styled = rec(cell);
|
|
1904
|
+
const value = Object.hasOwn(styled, "value") ? styled.value : cell;
|
|
1905
|
+
push(at3("table", "rows", r, ...row.object ? ["cells"] : [], c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
|
|
1735
1906
|
});
|
|
1907
|
+
});
|
|
1736
1908
|
const callouts = rec(node.image).callouts;
|
|
1737
1909
|
if (Array.isArray(callouts)) callouts.forEach((callout, index) => {
|
|
1738
|
-
push(
|
|
1910
|
+
push(at3("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
|
|
1739
1911
|
});
|
|
1740
1912
|
const quote = node.quote;
|
|
1741
|
-
if (typeof quote === "string") push(
|
|
1913
|
+
if (typeof quote === "string") push(at3("quote"), quote, "quote", "quote");
|
|
1742
1914
|
else if (quote && typeof quote === "object") {
|
|
1743
|
-
push(
|
|
1744
|
-
push(
|
|
1745
|
-
push(
|
|
1746
|
-
push(
|
|
1915
|
+
push(at3("quote", "text"), quote.text, "quote", "quote");
|
|
1916
|
+
push(at3("quote", "attribution"), quote.attribution, "quote-footer", "quote");
|
|
1917
|
+
push(at3("quote", "role"), quote.role, "quote-footer", "quote");
|
|
1918
|
+
push(at3("quote", "source"), quote.source, "quote-footer", "quote");
|
|
1747
1919
|
}
|
|
1748
1920
|
const metric = node.metric;
|
|
1749
|
-
if (typeof metric === "string") push(
|
|
1921
|
+
if (typeof metric === "string") push(at3("metric"), metric, "metric", "metric");
|
|
1750
1922
|
else if (metric && typeof metric === "object")
|
|
1751
1923
|
for (const key3 of ["value", "label", "unit", "delta"]) {
|
|
1752
1924
|
const value = metric[key3];
|
|
1753
|
-
if (typeof value === "string") push(
|
|
1925
|
+
if (typeof value === "string") push(at3("metric", key3), value, "metric", "metric");
|
|
1754
1926
|
}
|
|
1755
1927
|
const timeline = node.timeline, events = Array.isArray(timeline) ? timeline : Array.isArray(rec(timeline).events) ? rec(timeline).events : [];
|
|
1756
|
-
if (typeof rec(timeline).name === "string") push(
|
|
1928
|
+
if (typeof rec(timeline).name === "string") push(at3("timeline", "name"), rec(timeline).name, "timeline", "timeline");
|
|
1757
1929
|
events.forEach((event, index) => {
|
|
1758
1930
|
const base = Array.isArray(timeline) ? ["timeline", index] : ["timeline", "events", index];
|
|
1759
|
-
push(
|
|
1760
|
-
push(
|
|
1931
|
+
push(at3(...base, "when"), event?.when, "timeline", "timeline");
|
|
1932
|
+
push(at3(...base, "what"), event?.what, "timeline", "timeline");
|
|
1761
1933
|
});
|
|
1762
1934
|
}
|
|
1763
1935
|
return out;
|
|
@@ -1800,10 +1972,10 @@ var isLogoReference = (value) => typeof value === "string" && value.startsWith("
|
|
|
1800
1972
|
function assetRefs(document, slide, slidePath, includeDeck) {
|
|
1801
1973
|
const out = [];
|
|
1802
1974
|
for (const payload of slidePayloads(slide, slidePath)) {
|
|
1803
|
-
const
|
|
1804
|
-
if (payload.node.image !== void 0 && !isLogoReference(payload.node.image)) out.push({ path:
|
|
1805
|
-
if (payload.node.video !== void 0) out.push({ path:
|
|
1806
|
-
if (rec(payload.node.quote).photo !== void 0) out.push({ path:
|
|
1975
|
+
const at3 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
|
|
1976
|
+
if (payload.node.image !== void 0 && !isLogoReference(payload.node.image)) out.push({ path: at3("image"), value: payload.node.image, kind: "image" });
|
|
1977
|
+
if (payload.node.video !== void 0) out.push({ path: at3("video"), value: payload.node.video, kind: "video" });
|
|
1978
|
+
if (rec(payload.node.quote).photo !== void 0) out.push({ path: at3("quote", "photo"), value: rec(payload.node.quote).photo, kind: "quote-photo" });
|
|
1807
1979
|
}
|
|
1808
1980
|
const designRefs = (design, base) => {
|
|
1809
1981
|
for (const kind of ["header", "footer"])
|
|
@@ -1890,6 +2062,8 @@ var formatRules = [
|
|
|
1890
2062
|
rule("reference-id-duplicate", "format", "error", "Two references share an id.", "A citation names a reference by id; a repeated id makes it ambiguous which entry is cited.", { standard: SCHEMA }),
|
|
1891
2063
|
rule("cite-unknown-reference", "format", "error", "A citation names a reference that does not exist.", "A cited id with no entry in `references` has nothing to show in the footnote area.", { standard: SCHEMA }),
|
|
1892
2064
|
rule("cite-unsupported-location", "format", "error", "A citation or footnote sits where no engine draws it.", "`cite` and `footnote` apply to runs in text, bullets and list items; table cells, captions, and reference and footnote texts have no marker.", { standard: SCHEMA }),
|
|
2065
|
+
rule("embed-credentials", "content", "warning", "An embed address carries what looks like a credential.", "An embed `src` is stored in the deck and linked from every export, so anyone who has the deck can read a user name and password in it, or a query parameter named like a secret (`key`, `token`, `secret`, `password`, `sig`, `signature`, `auth`, alone or in a longer name such as `api_key`). Put the secret where the host that shows the page holds it.", { standard: SCHEMA, approximations: "Matches the parameter names by word, not by letters: `api_key` and `accessToken` match, `monkey` does not. The value is never read, and nothing is fetched." }),
|
|
2066
|
+
rule("slide-link-unknown", "format", "error", "A link names a slide the document does not have.", "A `slide:<id>` link jumps to the slide with that `id`; an id no slide has leaves the link with nowhere to go in the preview, in PDF and in PowerPoint. A slide with no `id` cannot be linked to; `assignIds` gives every slide one.", { standard: SCHEMA }),
|
|
1893
2067
|
rule("caption-unsupported-payload", "format", "error", "A caption is on a payload that cannot carry one.", "A caption belongs to exactly one image, chart, table, video or diagram; a group, text or code block has no place to draw it.", { standard: SCHEMA }),
|
|
1894
2068
|
rule("image-option-unsupported-payload", "format", "error", "An image option is on a payload that is not an image.", "`fit`, `focus`, the image treatments (`shape`, `adjust`, `stroke`, `opacity`, `recolor`, `overlay`, `aspectRatio`), `placement` and `portrait` describe how a picture is drawn; a group, text or chart block has no picture for them to apply to. A shape block takes `shape`, `adjust`, `stroke`, `opacity` and `aspectRatio` too.", { standard: SCHEMA }),
|
|
1895
2069
|
rule("shape-option-unsupported-payload", "format", "error", "A shape option is on a payload that is not a shape block.", "`fill`, `style`, `rotate`, `flip`, `anchor`, `padding`, `textDirection`, `alt`, `decorative`, `hidden`, `link` and the effects (`shadow`, `innerShadow`, `glow`, `softEdge`, `reflection`, `blur`) describe how a shape block is drawn; a text, chart or image block, or a group, has no shape for them to apply to.", { standard: SCHEMA }),
|
|
@@ -1903,6 +2077,7 @@ var formatRules = [
|
|
|
1903
2077
|
rule("image-placement-invalid", "format", "error", "An image placement cannot be honored.", "A placed image bleeds to a slide edge and the rest of the slide composes beside it. Only a top-level block (slides.N.blocks.I) can do that, and a slide edge holds one placed image; a block in a group or in a cell of the slide grid, or a second block on the same edge, has nowhere to go.", { standard: SCHEMA }),
|
|
1904
2078
|
rule("layout-placeholder-group", "format", "error", "A layout record's placeholder group breaks a nesting rule.", "A placeholder group arranges body regions inside one cell of its layout record. Groups nest at most three levels inside a record, and a group holds body regions and groups only: the headings (title, subtitle, tag) stay at the record's top level, where the engine places them. Composition cannot use a record that breaks either rule.", { standard: SCHEMA }),
|
|
1905
2079
|
rule("dataset-unknown", "format", "error", "A chart or table names a dataset that does not exist.", "The data cannot be drawn without the dataset it refers to.", { standard: SCHEMA }),
|
|
2080
|
+
rule("datasource-unknown", "format", "error", "A dataset or chart data names a data source that does not exist.", 'A string `datasource` is the id of an entry in the top-level `datasources` map. An id that is not there says nothing about where the data came from. A file or a URL is written as an inline data source object, `{ "src": "./revenue.csv" }`.', { standard: SCHEMA }),
|
|
1906
2081
|
rule("dataset-field-unknown", "format", "error", "A table asks a dataset for a column it does not have.", "The column cannot be shown when the dataset has no column of that name.", { standard: SCHEMA }),
|
|
1907
2082
|
rule("data-column-duplicate", "format", "error", "A dataset or table has two columns with the same name.", "Series, mappings and fields address columns by name, so a repeated name makes them ambiguous.", { standard: SCHEMA }),
|
|
1908
2083
|
rule("chart-mapping-unknown-column", "format", "error", "A chart mapping names a column the data does not have.", "The series cannot be built from a column that is not there.", { standard: SCHEMA }),
|
|
@@ -1912,6 +2087,7 @@ var formatRules = [
|
|
|
1912
2087
|
rule("variable-invalid-value", "format", "error", "A variable value does not match its declared type.", "A number variable given text, or a date given a non-date, cannot be filled into the deck.", { standard: SCHEMA }),
|
|
1913
2088
|
rule("variable-unknown-builtin", "format", "error", "A token names a built-in variable that does not exist.", "The `deck.`, `speaker.`, `organization.` and `slide.` names (and `speakers`) are reserved for built-in variables; a name under them that is not a built-in can never be filled, so the token would show literally. The slide-scoped `slide.number`, `slide.section` and `deck.slideCount` are inline tokens only, so `var:slide.*` and `var:deck.slideCount` are reported too; organization logos are whole-field references only (`var:organization.logo.icon`), so a `{{organization.logo}}` token, an unknown logo shape or an unknown organization id is reported.", { standard: SCHEMA }),
|
|
1914
2089
|
rule("table-highlight-unknown-name", "format", "error", "A table highlight names a row the table does not have.", "`table.highlight` emphasizes body rows by their first-column text; a name that matches no row highlights nothing, so the table is not drawn as authored.", { standard: SCHEMA }),
|
|
2090
|
+
rule("table-color-scale-unknown-column", "format", "error", "A table color scale names a column the table does not have.", "`table.colorScale.columns` names the columns to shade by header text (a dataset-backed table by dataset column name after `fields`); a name that matches no column shades nothing, so the table is not drawn as authored.", { standard: SCHEMA }),
|
|
1915
2091
|
rule("chart-highlight-unknown-name", "format", "error", "A chart highlight names a series or category the chart does not have.", "`chart.highlight` emphasizes marks by name; a name that matches no series or category in the chart data highlights nothing, so the chart is not drawn as authored.", { standard: SCHEMA }),
|
|
1916
2092
|
rule("variable-format", "format", "error", "A variable cannot be formatted.", "A number or date format that does not apply to the value leaves the token unreadable.", { standard: SCHEMA }),
|
|
1917
2093
|
rule(
|
|
@@ -1998,6 +2174,8 @@ var referenceRules = [
|
|
|
1998
2174
|
rule("variable-unknown", "references", "warning", "A `{{token}}` names a variable that is not declared.", "An undeclared token is shown literally.", { standard: SCHEMA }),
|
|
1999
2175
|
rule("variable-unknown-value", "references", "warning", "A value was supplied for a variable that is not declared.", "The value is never used.", { standard: SCHEMA }),
|
|
2000
2176
|
rule("variable-unused", "references", "warning", "A variable is declared but never used.", "A declaration nothing refers to has no effect.", { standard: SCHEMA }),
|
|
2177
|
+
rule("variable-translation-duplicate", "references", "warning", "Two translations of a variable have the same language tag.", "Language tags compare without regard to case, so 'de-AT' and 'de-at' name one language. The first in document order is used; the other is never drawn.", { standard: SCHEMA }),
|
|
2178
|
+
rule("variable-translation-unused", "references", "warning", "A translation of a variable is never drawn.", "A translation is drawn on a slide whose declared language (else the deck's) selects it. When no slide and not the deck declares a language that selects it, it has no effect. A language read from the text does not select a translation.", { standard: SCHEMA, approximations: "Reads the declared language of the deck and of each slide, not where the variable is used." }),
|
|
2001
2179
|
rule("variable-reference-unknown", "references", "warning", "A `var:` color names a variable that is not declared.", "An undeclared color variable falls back to a default color.", { standard: SCHEMA })
|
|
2002
2180
|
];
|
|
2003
2181
|
var policyRules = [
|
|
@@ -2020,8 +2198,22 @@ var dataRules = [
|
|
|
2020
2198
|
'A chart plots numbers. A text cell such as "12%" is plotted as a gap. When every text value of a column is written in one display style the finding carries the fix that stores the numbers and gives the column the matching format.',
|
|
2021
2199
|
{ standard: SCHEMA }
|
|
2022
2200
|
),
|
|
2201
|
+
rule("data-cell-type", "content", "warning", "A data cell does not match its column's declared type.", 'A dataset or chart data column may declare what its cells hold (`type`: text, number, date or boolean). A cell of another kind is reported; null is a gap in any type. A number is a finite number, so the string "12" is not one (the safe fix stores it as 12), and a date is any time label the time-order rule reads (2026-03, Q1 2026, Jan). Nothing is drawn differently: it is advice that the column says one thing and holds another. More than five mismatches in a column are one finding for the column.', { standard: SCHEMA }),
|
|
2202
|
+
rule("metric-data-stale", "content", "warning", "A metric's written value or change differs from the one its data computes.", "A metric linked to data draws the computed number, and keeps the last computed number as its written value and delta for readers that do not compute. When the two differ, those readers show a number the data no longer gives. The safe fix writes the computed number.", { standard: SCHEMA }),
|
|
2203
|
+
rule("metric-data-aggregate", "content", "warning", "A metric asks an aggregate that its column refuses.", "Sum, mean, minimum and maximum read numbers, and a column typed text or boolean has none. The written value is drawn instead.", { standard: SCHEMA }),
|
|
2204
|
+
rule("metric-data-empty", "content", "warning", "A metric's data link gives no value.", "No row of the dataset meets the filter, or none of the kept cells is usable for the aggregate. The written value is drawn instead.", { standard: SCHEMA }),
|
|
2205
|
+
rule("metric-data-delta", "content", "warning", "A metric's change cannot be computed.", "A previous row needs two kept rows, a baseline needs a row that meets its filter, a percent needs a comparison value other than 0, and the value must be a number. The value is still drawn, with no change.", { standard: SCHEMA }),
|
|
2206
|
+
rule("metric-unit-repeated", "content", "warning", "A metric's unit is already printed by its number format.", "The unit is printed after the value, so a format that already writes the same text as a prefix or suffix draws it twice.", { standard: SCHEMA }),
|
|
2207
|
+
rule("datasource-credentials", "content", "warning", "A data source holds a credential.", "A data source says where data lives and never holds credentials. A `src` with a user and password, or a query parameter named like a key or a token, writes a secret into a document that is shared, versioned and exported. Keep the secret in the host's own store and name the connection in `connector` or `extensions`.", { standard: SCHEMA }),
|
|
2208
|
+
rule("dataset-stale", "content", "warning", "A dataset is older than its data source says it should be.", "A data source may say how often it is meant to be taken again (`refreshEvery`, an ISO 8601 duration). Given a date to check as of, a dataset whose `retrieved` is older than that is reported. Core has no clock, so without a date nothing is reported, and no engine takes the data again.", { standard: SCHEMA }),
|
|
2023
2209
|
rule("chart-mapping-adapted", "content", "warning", "A chart mapping entry is ignored.", "A mapping that names a column the chart type cannot use is left out of the chart.", { standard: SCHEMA }),
|
|
2024
2210
|
rule("chart-highlight-adapted", "content", "warning", "A chart highlight is adapted by the chart type.", "A highlight the chart type cannot show as authored (a category highlight on a chart without categories, for example) is adapted by every engine, so the emphasis is not exactly what was written.", { standard: SCHEMA }),
|
|
2211
|
+
rule("table-color-scale-no-data", "content", "warning", "A table color scale has no numbers to shade.", "None of the named columns holds a number cell, so no cell is shaded. A dataset-backed table can lose its numbers on a refresh; the scale returns when they do.", { standard: SCHEMA }),
|
|
2212
|
+
rule("table-color-scale-range", "content", "warning", "A table color scale has an empty range or a center outside it.", "A pinned `min` that is not below `max`, or a `center` outside the range, leaves part of the scale unused: every value draws in one end color.", { standard: SCHEMA }),
|
|
2213
|
+
rule("chart-bands-order", "content", "warning", "Chart bands are not in increasing order.", "Each band runs from the previous band's `to` to its own, so the `to` values must increase. Every engine draws unordered bands sorted by `to`; the warning says the list does not read as it draws.", { standard: SCHEMA }),
|
|
2214
|
+
rule("metric-gauge-range", "content", "warning", "A metric gauge has an empty range, or a value, target or band outside it.", "A gauge draws its value on an arc from `min` to `max`. A `max` not above `min` draws no gauge; a value outside the range keeps its real number while its arc stops at the end, a target outside it is not drawn, and a band end outside it is drawn to the end of the range.", { standard: SCHEMA }),
|
|
2215
|
+
rule("metric-gauge-value", "content", "warning", "A metric with a gauge has no number to draw.", "A gauge draws a number on its arc. A metric whose drawn value is text (a string literal, or a computed value that is not a number) is drawn without its gauge.", { standard: SCHEMA }),
|
|
2216
|
+
rule("chart-bands-unsupported", "content", "warning", "A chart has bands but its type does not draw them.", "Bands shade ranges of a value axis behind the data: bar, column, line and area charts (and their stacked forms) and the bullet chart draw them. On a pie, doughnut, scatter, radar, combo or Office 2016 construct they are ignored by every engine.", { standard: SCHEMA }),
|
|
2025
2217
|
rule("chart-series-dropped", "content", "warning", "A chart series is not drawn by the chart type.", "A treemap, histogram, one-series Pareto, waterfall, funnel, map or single-series pie plots one value series, and a scatter plots no X column without numbers. Every engine leaves the same columns out (LH-60), so the warning names them instead of losing them silently.", { standard: SCHEMA, approximations: "Read from the drawn chart (chartDrawPlan): a world chart over categories that are mostly not places and a Pareto chart of several series are drawn as columns, a box-and-whisker chart with one value per category as one box per series and a pie or doughnut of several series as nested rings, and none of those drops a series." }),
|
|
2026
2218
|
rule("code-highlight-out-of-range", "content", "warning", "A code highlight marks a line the code does not have.", "Marked lines count from 1 by line break in code.source; an entry past the last line marks nothing.", { standard: SCHEMA }),
|
|
2027
2219
|
rule("code-highlight-range-reversed", "content", "warning", "A code highlight range ends before it starts.", "A range written end before start marks nothing; write the smaller line number first.", { standard: SCHEMA }),
|
|
@@ -2391,15 +2583,16 @@ var layoutMonotonyRule = rule(
|
|
|
2391
2583
|
approximations: "Compares the layout reference of each slide (a catalog prefix is ignored). Cover, section and closing slides, slides with no body content and slides without a layout record (automatic composition) break a run and are not counted; hidden slides are skipped. One finding per run, at its first slide."
|
|
2392
2584
|
}
|
|
2393
2585
|
);
|
|
2394
|
-
var
|
|
2395
|
-
"
|
|
2396
|
-
"
|
|
2397
|
-
"
|
|
2398
|
-
|
|
2399
|
-
"
|
|
2586
|
+
var variableOverflowRule = rule(
|
|
2587
|
+
"variable-overflow",
|
|
2588
|
+
"layout",
|
|
2589
|
+
"warning",
|
|
2590
|
+
"A variable's value is longer than the room its declaration allows.",
|
|
2591
|
+
"A template slot is sized for a short value. A value over the declaration's maxLength, a list over its maxItems, or text that takes more lines than maxLines where it is drawn still draws, but not as the template was designed; the finding is raised before the deck is exported, not found on one slide of a batch.",
|
|
2400
2592
|
{
|
|
2401
|
-
|
|
2402
|
-
|
|
2593
|
+
cost: "composition",
|
|
2594
|
+
standard: "The variable declaration's maxLength, maxLines and maxItems (spec/schemas/opf.schema.json, TextVariable and ListVariable).",
|
|
2595
|
+
approximations: "maxLength counts characters as a reader sees them (grapheme clusters, Intl.Segmenter), not code units, and maxItems counts entries; both are read on the value (the declared value, or the value given to the check with `values`) and reported once at the declaration. maxLines is read from composition at each place the variable is drawn, with the fonts and measurement of the check: a title, a subtitle, a tag, a text block or a list entry, on its own or inside longer text (then the lines are those the variable's own characters occupy). One finding per place, naming the slide. A place composition does not break into lines (a table cell, a chart label, text in a shape) and a value the layout reshapes are not measured. A variable with no value or example is not measured, and neither is a type sample."
|
|
2403
2596
|
}
|
|
2404
2597
|
);
|
|
2405
2598
|
var PIE_MAX_SLICES = 5;
|
|
@@ -2463,7 +2656,7 @@ var implementedRules = [
|
|
|
2463
2656
|
centeredBodyRule,
|
|
2464
2657
|
tightSpacingRule,
|
|
2465
2658
|
layoutMonotonyRule,
|
|
2466
|
-
|
|
2659
|
+
variableOverflowRule,
|
|
2467
2660
|
chartDualAxisRule,
|
|
2468
2661
|
chartPieManySlicesRule
|
|
2469
2662
|
];
|
|
@@ -2523,7 +2716,7 @@ function collectSamples(context) {
|
|
|
2523
2716
|
const scale = Math.min(design.dimensions.width, design.dimensions.height) / 720;
|
|
2524
2717
|
for (const item of composition.items) {
|
|
2525
2718
|
const itemDesign = item.emphasis && surfaceDesign ? surfaceDesign : design;
|
|
2526
|
-
if (["chart", "image", "video", "code"].includes(item.field) || item.type === "chart" || item.type === "image" || item.type === "video" || item.type === "code") continue;
|
|
2719
|
+
if (["chart", "image", "video", "embed", "code"].includes(item.field) || item.type === "chart" || item.type === "image" || item.type === "video" || item.type === "embed" || item.type === "code") continue;
|
|
2527
2720
|
const backdrop = item.emphasis && emphasisBackdrop ? emphasisBackdrop : item.frameBox ? surface : slideBackdrop(context, textInkBox(item, measurement));
|
|
2528
2721
|
const itemPath = pointerOfDotted(item.path);
|
|
2529
2722
|
const heading = item.field === "title" || item.field === "subtitle" || item.field === "tag";
|
|
@@ -3177,10 +3370,10 @@ function canonicalJson(value) {
|
|
|
3177
3370
|
if (Array.isArray(item)) {
|
|
3178
3371
|
text2 = `[${item.map((entry2) => write(entry2) ?? "null").join(",")}]`;
|
|
3179
3372
|
} else {
|
|
3180
|
-
const
|
|
3373
|
+
const record2 = item;
|
|
3181
3374
|
const members = [];
|
|
3182
|
-
for (const key3 of Object.keys(
|
|
3183
|
-
const member = write(
|
|
3375
|
+
for (const key3 of Object.keys(record2).sort()) {
|
|
3376
|
+
const member = write(record2[key3]);
|
|
3184
3377
|
if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
|
|
3185
3378
|
}
|
|
3186
3379
|
text2 = `{${members.join(",")}}`;
|
|
@@ -3363,7 +3556,7 @@ function renamedRegion(layout, region) {
|
|
|
3363
3556
|
const names2 = Object.hasOwn(RENAMED_REGIONS, layout) ? RENAMED_REGIONS[layout] : void 0;
|
|
3364
3557
|
return names2 && Object.hasOwn(names2, region) ? names2[region] : void 0;
|
|
3365
3558
|
}
|
|
3366
|
-
function layoutRegionNames(
|
|
3559
|
+
function layoutRegionNames(record2) {
|
|
3367
3560
|
const names2 = /* @__PURE__ */ new Set();
|
|
3368
3561
|
const walk2 = (regions) => {
|
|
3369
3562
|
if (!Array.isArray(regions)) return;
|
|
@@ -3373,16 +3566,16 @@ function layoutRegionNames(record) {
|
|
|
3373
3566
|
walk2(region.regions);
|
|
3374
3567
|
}
|
|
3375
3568
|
};
|
|
3376
|
-
walk2(rec2(
|
|
3569
|
+
walk2(rec2(record2).regions);
|
|
3377
3570
|
return names2;
|
|
3378
3571
|
}
|
|
3379
|
-
function layoutRecordIssues(id,
|
|
3380
|
-
return validateAgainstSchema(isRec2(
|
|
3572
|
+
function layoutRecordIssues(id, record2) {
|
|
3573
|
+
return validateAgainstSchema(isRec2(record2) ? { $schema: schemas[catalogSchemaNames.layouts].$id, id, ...record2 } : record2, "layouts").errors;
|
|
3381
3574
|
}
|
|
3382
3575
|
function staleLayoutCopy(document, group, id, options2 = {}) {
|
|
3383
3576
|
if (group === "custom") return void 0;
|
|
3384
|
-
const
|
|
3385
|
-
if (!isRec2(
|
|
3577
|
+
const record2 = embeddedLayouts(document, group)[id];
|
|
3578
|
+
if (!isRec2(record2)) return void 0;
|
|
3386
3579
|
const registered = rec2(registeredCatalog(catalogGroupSource(document, group, options2), options2)?.layouts);
|
|
3387
3580
|
const base = { group, id, path: pointer3(["catalogs", group, "layouts", id]) };
|
|
3388
3581
|
if (isRec2(registered[id])) return { ...base, current: embeddedCopy(registered[id]) };
|
|
@@ -3412,11 +3605,11 @@ function pinOperations(document, index, layout, before, next) {
|
|
|
3412
3605
|
const names2 = layoutRegionNames(next);
|
|
3413
3606
|
const blocks = slideAt(document, index).blocks;
|
|
3414
3607
|
const ops = [];
|
|
3415
|
-
(Array.isArray(blocks) ? blocks : []).forEach((block,
|
|
3608
|
+
(Array.isArray(blocks) ? blocks : []).forEach((block, at3) => {
|
|
3416
3609
|
const pin = rec2(block).region;
|
|
3417
3610
|
if (typeof pin !== "string" || names2.has(pin) || !before.has(pin)) return;
|
|
3418
3611
|
const renamed = renamedRegion(layout, pin);
|
|
3419
|
-
if (renamed !== void 0 && names2.has(renamed)) ops.push({ op: "replace", path: pointer3(["slides", index, "blocks",
|
|
3612
|
+
if (renamed !== void 0 && names2.has(renamed)) ops.push({ op: "replace", path: pointer3(["slides", index, "blocks", at3, "region"]), value: renamed });
|
|
3420
3613
|
});
|
|
3421
3614
|
return ops;
|
|
3422
3615
|
}
|
|
@@ -3457,8 +3650,8 @@ function staleCopyFix(document, copy, options2 = {}) {
|
|
|
3457
3650
|
return copy.renamed ? { id: "rename-layout", title: `Use layout ${copy.renamed.id} and drop the old copy of ${copy.id}`, ...marks } : { id: "use-current-record", title: `Take the current ${copy.id} record`, ...marks };
|
|
3458
3651
|
}
|
|
3459
3652
|
var applyOperation = (root, operation) => {
|
|
3460
|
-
const segmentsOf2 = (path) => path.slice(1).split("/").map((
|
|
3461
|
-
const parentOf2 = (segments2) => segments2.slice(0, -1).reduce((node,
|
|
3653
|
+
const segmentsOf2 = (path) => path.slice(1).split("/").map((segment2) => segment2.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
3654
|
+
const parentOf2 = (segments2) => segments2.slice(0, -1).reduce((node, segment2) => node[segment2], root);
|
|
3462
3655
|
const segments = segmentsOf2(operation.path);
|
|
3463
3656
|
if (operation.op === "move") {
|
|
3464
3657
|
const from = segmentsOf2(operation.from);
|
|
@@ -3472,8 +3665,8 @@ function refreshStaleLayouts(document, options2 = {}) {
|
|
|
3472
3665
|
const refreshed = [];
|
|
3473
3666
|
for (const [group, value] of Object.entries(rec2(document.catalogs))) {
|
|
3474
3667
|
if (group === "custom" || !isRec2(value) || !isRec2(value.layouts)) continue;
|
|
3475
|
-
for (const [id,
|
|
3476
|
-
if (!layoutRecordIssues(id,
|
|
3668
|
+
for (const [id, record2] of Object.entries(value.layouts)) {
|
|
3669
|
+
if (!layoutRecordIssues(id, record2).length) continue;
|
|
3477
3670
|
const copy = staleLayoutCopy(document, group, id, options2);
|
|
3478
3671
|
if (!copy || !(copy.current || copy.renamed?.current)) continue;
|
|
3479
3672
|
const patch2 = staleCopyPatch(document, copy, options2);
|
|
@@ -3534,6 +3727,8 @@ var layoutRules = [
|
|
|
3534
3727
|
context.report(shapeOffSlideRule, { path, slide, message: diagnostic.message, help: "Write the position as fractions (0.2 for 20%), move the shape so part of it is on the slide, or remove it. A shape may hang over an edge; only one with nothing on the slide is reported." });
|
|
3535
3728
|
else if (diagnostic.code === "chart-label-collision")
|
|
3536
3729
|
context.report(chartLabelCollisionRule, { path, slide, message: diagnostic.message, help: "Put the label at the other end of its line (labelPosition 'start' or 'end'), shorten it, or give the chart more room. Its text and value are kept." });
|
|
3730
|
+
else if (diagnostic.code === "chart-band-labels-in-legend") continue;
|
|
3731
|
+
else if (diagnostic.code === "metric-gauge-dropped") continue;
|
|
3537
3732
|
else if (diagnostic.code === "timeline-period-short")
|
|
3538
3733
|
context.report(timelinePeriodShortRule, { path, slide, message: diagnostic.message, help: "Give the timeline more room, or make its shortest period longer relative to the others." });
|
|
3539
3734
|
else if (Object.hasOwn(REGION_RULES, diagnostic.code)) {
|
|
@@ -3566,7 +3761,7 @@ var layoutRules = [
|
|
|
3566
3761
|
path,
|
|
3567
3762
|
slide,
|
|
3568
3763
|
message: `${label} is drawn at ${round2(sizePx * PX_TO_PT2)} pt${scale === 1 ? "" : " (reference slide size)"}, below the ${context.thresholds.minFontSizePt} pt minimum.`,
|
|
3569
|
-
help: "Shorten the text or give it more room so it can be drawn larger; check composition.
|
|
3764
|
+
help: "Shorten the text or give it more room so it can be drawn larger; check composition.minFontSizePx and run fontSize settings that force small type.",
|
|
3570
3765
|
measured: { sizePt: round2(sizePx * PX_TO_PT2, 2), minimumPt: context.thresholds.minFontSizePt }
|
|
3571
3766
|
});
|
|
3572
3767
|
};
|
|
@@ -3725,7 +3920,7 @@ var contentRules = [
|
|
|
3725
3920
|
if (slide.slide.layout === "blank") continue;
|
|
3726
3921
|
const has = (value) => value !== void 0 && value !== null && !(typeof value === "string" && value.trim() === "") && !(Array.isArray(value) && value.length === 0);
|
|
3727
3922
|
const hasText = slide.texts.some((tv) => plainText(tv.value).trim() !== "");
|
|
3728
|
-
const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram"].some((field) => has(p.node[field])));
|
|
3923
|
+
const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram"].some((field) => has(p.node[field])));
|
|
3729
3924
|
const hasBackgroundImage = imageBackground(rec(slide.slide.design).background) !== void 0;
|
|
3730
3925
|
if (hasText || hasObject || hasBackgroundImage) continue;
|
|
3731
3926
|
context.report(emptySlideRule, { path: slide.path, slide, message: `Slide ${slide.index + 1} has no title and no content.`, help: "Add content, delete the slide, or give it the blank layout if it is intentionally empty." });
|
|
@@ -3764,7 +3959,7 @@ function fittedSize(item, slide, document) {
|
|
|
3764
3959
|
if (item.field === "code") return body(item.codeLayout?.parts);
|
|
3765
3960
|
if (item.field === "table") {
|
|
3766
3961
|
try {
|
|
3767
|
-
const table = layoutTable(item.value, item.box, { scale: canvasScale(slide.composition),
|
|
3962
|
+
const table = layoutTable(item.value, item.box, { scale: canvasScale(slide.composition), minFontSizePx: item.composition.minFontSizePx, fontFamily: slide.design.fonts.body, textMeasurement: slide.measurement, path: item.path, presentation: document });
|
|
3768
3963
|
if (table.overflow) return void 0;
|
|
3769
3964
|
const sizes = table.rows.flatMap((row) => row.cells.filter((cell) => !cell.header).map((cell) => cell.fit.fontSize));
|
|
3770
3965
|
return sizes.length ? Math.min(...sizes) : void 0;
|
|
@@ -3913,7 +4108,7 @@ var tightSpacing = {
|
|
|
3913
4108
|
}
|
|
3914
4109
|
}
|
|
3915
4110
|
};
|
|
3916
|
-
var hasBody = (slide) => slide.payloads.some((payload) => ["text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "blocks"].some((field) => {
|
|
4111
|
+
var hasBody = (slide) => slide.payloads.some((payload) => ["text", "items", "bullets", "image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "blocks"].some((field) => {
|
|
3917
4112
|
const value = payload.node[field];
|
|
3918
4113
|
return value !== void 0 && value !== null && !(Array.isArray(value) && value.length === 0) && !(typeof value === "string" && value.trim() === "");
|
|
3919
4114
|
}));
|
|
@@ -3947,63 +4142,7 @@ var layoutMonotony = {
|
|
|
3947
4142
|
flush();
|
|
3948
4143
|
}
|
|
3949
4144
|
};
|
|
3950
|
-
var
|
|
3951
|
-
var LETTER = /[\p{L}\p{N}]/u;
|
|
3952
|
-
var OPENING = /[\s([{—–-]/u;
|
|
3953
|
-
function straightQuoteMarks(text2) {
|
|
3954
|
-
let double = 0, single = 0, open = false;
|
|
3955
|
-
for (let i = 0; i < text2.length; i++) {
|
|
3956
|
-
const char = text2[i], before = text2[i - 1] ?? "", after = text2[i + 1] ?? "";
|
|
3957
|
-
if (char === '"') {
|
|
3958
|
-
if (!/\d/.test(before)) double++;
|
|
3959
|
-
} else if (char === "'") {
|
|
3960
|
-
const wordAfter = LETTER.test(after), opens = before === "" || OPENING.test(before);
|
|
3961
|
-
if (LETTER.test(before) && wordAfter || /\d/.test(before)) continue;
|
|
3962
|
-
if (opens && wordAfter && !/\d/.test(after)) open = true;
|
|
3963
|
-
else if (!opens && !wordAfter && open) {
|
|
3964
|
-
single += 2;
|
|
3965
|
-
open = false;
|
|
3966
|
-
}
|
|
3967
|
-
}
|
|
3968
|
-
}
|
|
3969
|
-
return { double, single };
|
|
3970
|
-
}
|
|
3971
|
-
function curlDoubleQuotes(text2, marks) {
|
|
3972
|
-
return text2.replace(/(^|.)"/gsu, (whole, before) => /\d/.test(before) ? whole : `${before}${before === "" || OPENING.test(before) ? marks.open : marks.close}`);
|
|
3973
|
-
}
|
|
3974
|
-
var straightQuotes = {
|
|
3975
|
-
info: straightQuotesRule,
|
|
3976
|
-
run(context) {
|
|
3977
|
-
for (const slide of context.slides) {
|
|
3978
|
-
const marks = quoteMarksFor(quoteLanguage(context.document, slide.index));
|
|
3979
|
-
if (marks.open === '"') continue;
|
|
3980
|
-
for (const tv of slide.texts) {
|
|
3981
|
-
if (!PROSE_ROLES.has(tv.role)) continue;
|
|
3982
|
-
let double = 0, single = 0;
|
|
3983
|
-
const fixes = [];
|
|
3984
|
-
for (const run of runsOf(tv)) {
|
|
3985
|
-
if (run.style.code === true) continue;
|
|
3986
|
-
const found = straightQuoteMarks(run.text);
|
|
3987
|
-
double += found.double;
|
|
3988
|
-
single += found.single;
|
|
3989
|
-
if (found.double) fixes.push({ op: "replace", path: run.index === -1 ? run.path : `${run.path}${typeof tv.value !== "string" && typeof tv.value[run.index] === "string" ? "" : "/text"}`, value: curlDoubleQuotes(run.text, marks) });
|
|
3990
|
-
}
|
|
3991
|
-
if (!double && !single) continue;
|
|
3992
|
-
const kinds = [double ? `${double} straight double quote${double === 1 ? "" : "s"} (")` : "", single ? `${single} straight single quotes (')` : ""].filter(Boolean).join(" and ");
|
|
3993
|
-
const text2 = plainText(tv.value);
|
|
3994
|
-
context.report(straightQuotesRule, {
|
|
3995
|
-
path: tv.path,
|
|
3996
|
-
slide,
|
|
3997
|
-
message: `Text has ${kinds}: ${JSON.stringify(text2.length > 60 ? `${text2.slice(0, 57)}...` : text2)}.`,
|
|
3998
|
-
help: `Use the typographic quotation marks of the deck's language (${marks.open}...${marks.close}).${tv.role === "quote" ? " A quote payload adds its own marks around the whole quote." : ""}`,
|
|
3999
|
-
measured: { double, single, open: marks.open, close: marks.close },
|
|
4000
|
-
...!single && fixes.length ? { fixes: [{ id: "use-typographic-quotes", title: `Use ${marks.open}${marks.close}`, kind: "patch", safe: false, patch: fixes }] } : {}
|
|
4001
|
-
});
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
}
|
|
4005
|
-
};
|
|
4006
|
-
var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony, straightQuotes];
|
|
4145
|
+
var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony];
|
|
4007
4146
|
|
|
4008
4147
|
// src/rules-chart-findings.ts
|
|
4009
4148
|
var chartPath = (payloadPath, slidePath) => `${payloadPath === slidePath ? slidePath : payloadPath}/chart`;
|
|
@@ -4050,109 +4189,609 @@ var chartPieManySlices = {
|
|
|
4050
4189
|
};
|
|
4051
4190
|
var chartFindingRules = [chartDualAxis, chartPieManySlices];
|
|
4052
4191
|
|
|
4053
|
-
// src/
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
const list = entry2.values ?? entry2.data;
|
|
4074
|
-
const name = entry2.name ?? entry2.label;
|
|
4075
|
-
if (!Array.isArray(list) || list.length !== labels.length || !list.every(isCell)) return void 0;
|
|
4076
|
-
columns.push(typeof name === "string" && name ? name : `Series ${index + 1}`);
|
|
4077
|
-
values.push(list);
|
|
4192
|
+
// src/drawn-font-families.ts
|
|
4193
|
+
function resolveDrawnFontFamilies(families, measurement, keepsName) {
|
|
4194
|
+
const resolve2 = measurement?.resolveStyle;
|
|
4195
|
+
if (typeof resolve2 !== "function") return families;
|
|
4196
|
+
const drawn = { ...families };
|
|
4197
|
+
for (const role of ["heading", "body", "code", "accent"]) {
|
|
4198
|
+
const named = families[role];
|
|
4199
|
+
if (typeof named !== "string" || !named) continue;
|
|
4200
|
+
try {
|
|
4201
|
+
const resolved2 = resolve2.call(measurement, { fontFamily: named, fontWeight: role === "heading" ? 700 : 400 });
|
|
4202
|
+
let keep3;
|
|
4203
|
+
if (keepsName) keep3 = keepsName(named, resolved2.fontFamily);
|
|
4204
|
+
else {
|
|
4205
|
+
const regular = role === "heading" ? resolve2.call(measurement, { fontFamily: named, fontWeight: 400 }) : resolved2;
|
|
4206
|
+
const encoded = resolved2.symbolEncoding != null;
|
|
4207
|
+
keep3 = encoded || regular.fontWeight !== void 0 && regular.fontWeight !== 400 && resolved2.fontFamily.toLowerCase() !== named.toLowerCase();
|
|
4208
|
+
}
|
|
4209
|
+
if (!keep3) drawn[role] = resolved2.fontFamily;
|
|
4210
|
+
} catch {
|
|
4211
|
+
}
|
|
4078
4212
|
}
|
|
4079
|
-
|
|
4080
|
-
return { columns, rows: labels.map((label, row) => [label, ...values.map((list) => list[row])]) };
|
|
4081
|
-
}
|
|
4082
|
-
function chartShapePatch(chart, path) {
|
|
4083
|
-
if (!isRecord3(chart)) return void 0;
|
|
4084
|
-
const data = convertChartData(chart);
|
|
4085
|
-
const keys = foreignChartKeys(chart);
|
|
4086
|
-
if (!data || !keys.length) return void 0;
|
|
4087
|
-
return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
|
|
4088
|
-
}
|
|
4089
|
-
var SHOWN_ROWS = 3;
|
|
4090
|
-
var json = (value) => JSON.stringify(value);
|
|
4091
|
-
function dataExample(chart) {
|
|
4092
|
-
const data = convertChartData(chart);
|
|
4093
|
-
if (!data) return '"data": { "columns": ["Category", "Series name"], "rows": [["Q1", 3], ["Q2", 8]] }';
|
|
4094
|
-
const rows = data.rows.slice(0, SHOWN_ROWS).map(json);
|
|
4095
|
-
return `"data": { "columns": ${json(data.columns)}, "rows": [${rows.join(",")}${data.rows.length > SHOWN_ROWS ? ",..." : ""}] }`;
|
|
4213
|
+
return drawn;
|
|
4096
4214
|
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4215
|
+
|
|
4216
|
+
// src/script-measurement.ts
|
|
4217
|
+
function scriptProfile(presentation, slideIndex, options2, language) {
|
|
4218
|
+
let resolved2;
|
|
4219
|
+
try {
|
|
4220
|
+
resolved2 = resolveScriptFonts(presentation, { slideIndex, ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, ...language === void 0 ? {} : { language } });
|
|
4221
|
+
} catch {
|
|
4222
|
+
resolved2 = void 0;
|
|
4223
|
+
}
|
|
4224
|
+
const slots = (role) => {
|
|
4225
|
+
const latin = options2.fontFamilies[role];
|
|
4226
|
+
const slot = (key3) => !resolved2 || resolved2.sources[key3] === "latin" || resolved2.sources[key3] === "schemeFamily" ? latin : resolved2[role][key3] ?? latin;
|
|
4227
|
+
return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
|
|
4228
|
+
};
|
|
4103
4229
|
return {
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4230
|
+
heading: slots("heading"),
|
|
4231
|
+
body: slots("body"),
|
|
4232
|
+
...resolved2?.supplement ? { supplement: resolved2.supplement } : {},
|
|
4233
|
+
script: resolved2?.script ?? "Zzzz",
|
|
4234
|
+
...resolved2 ? { scriptRole: resolved2.scriptRole, bcp47: resolved2.bcp47, lang: resolved2.lang, languageSource: resolved2.languageSource, direction: resolved2.direction } : {},
|
|
4235
|
+
rtl: resolved2?.rtl === true,
|
|
4236
|
+
serif: options2.serif
|
|
4107
4237
|
};
|
|
4108
4238
|
}
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4239
|
+
function slideScriptMeasurement(presentation, slideIndex, measurement, options2) {
|
|
4240
|
+
const forScripts = measurement.forScripts;
|
|
4241
|
+
if (typeof forScripts !== "function") return measurement;
|
|
4242
|
+
const deckProfile = scriptProfile(presentation, slideIndex, options2);
|
|
4243
|
+
const deck = forScripts.call(measurement, deckProfile);
|
|
4244
|
+
const languages = /* @__PURE__ */ new Map();
|
|
4245
|
+
const forLanguage = (lang) => {
|
|
4246
|
+
if (typeof lang !== "string" || !lang) return void 0;
|
|
4247
|
+
if (!languages.has(lang)) {
|
|
4248
|
+
let own4;
|
|
4249
|
+
try {
|
|
4250
|
+
const profile = scriptProfile(presentation, slideIndex, options2, lang);
|
|
4251
|
+
own4 = profile.languageSource === "option" && profile.bcp47?.toLowerCase() !== deckProfile.bcp47?.toLowerCase() ? forScripts.call(measurement, profile) : void 0;
|
|
4252
|
+
} catch {
|
|
4253
|
+
own4 = void 0;
|
|
4254
|
+
}
|
|
4255
|
+
languages.set(lang, own4);
|
|
4256
|
+
}
|
|
4257
|
+
return languages.get(lang);
|
|
4258
|
+
};
|
|
4259
|
+
const pick = (style) => forLanguage(style?.lang) ?? deck;
|
|
4260
|
+
const scripted = { ...deck, measure: (text2, size, style) => pick(style).measure(text2, size, style) };
|
|
4261
|
+
if (typeof deck.resolveStyle === "function") scripted.resolveStyle = (style) => deck.resolveStyle.call(deck, style);
|
|
4262
|
+
if (typeof deck.outlineBounds === "function")
|
|
4263
|
+
scripted.outlineBounds = (text2, size, style) => {
|
|
4264
|
+
const own4 = pick(style);
|
|
4265
|
+
return typeof own4.outlineBounds === "function" ? own4.outlineBounds(text2, size, style) : deck.outlineBounds.call(deck, text2, size, style);
|
|
4266
|
+
};
|
|
4267
|
+
return scripted;
|
|
4120
4268
|
}
|
|
4121
|
-
function
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4269
|
+
function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, options2 = {}) {
|
|
4270
|
+
if (typeof measurement.forScripts !== "function") return measurement;
|
|
4271
|
+
const { fontScheme } = resolveDesignRecords(presentation, slideIndex, options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {});
|
|
4272
|
+
const resolved2 = resolveFontFamilies(fontScheme);
|
|
4273
|
+
const fontFamilies = { heading: options2.fontFamilies?.heading ?? resolved2.heading, body: options2.fontFamilies?.body ?? resolved2.body };
|
|
4274
|
+
return slideScriptMeasurement(presentation, slideIndex, measurement, { ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, fontFamilies, serif: fontScheme.type === "serif" });
|
|
4126
4275
|
}
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
) || typeof contract2.path !== "string" || !Array.isArray(contract2.allowedValues) || !contract2.allowedValues.every(primitive) || contract2.severity !== void 0 && (typeof contract2.severity !== "string" || !["error", "warning", "info"].includes(contract2.severity)) || contract2.message !== void 0 && typeof contract2.message !== "string" || contract2.documentation !== void 0 && typeof contract2.documentation !== "string")
|
|
4141
|
-
throw new TypeError(
|
|
4142
|
-
"Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
|
|
4143
|
-
);
|
|
4144
|
-
parts(contract2.path);
|
|
4276
|
+
|
|
4277
|
+
// src/message-surface.ts
|
|
4278
|
+
var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
4279
|
+
var MESSAGE_SURFACE_SLOT = "accent1";
|
|
4280
|
+
var MESSAGE_SURFACE_CONTRAST = 4.5;
|
|
4281
|
+
function messageKind(slide, layout) {
|
|
4282
|
+
const lone = lonePayload(slide);
|
|
4283
|
+
if (lone?.field !== "text" || annotationText(slide.subtitle).trim()) return void 0;
|
|
4284
|
+
let plan;
|
|
4285
|
+
try {
|
|
4286
|
+
plan = isLayoutTemplate(layout) ? layoutTemplate(layout) : void 0;
|
|
4287
|
+
} catch {
|
|
4288
|
+
return void 0;
|
|
4145
4289
|
}
|
|
4290
|
+
if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
|
|
4291
|
+
if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
|
|
4292
|
+
const value = lone.host.text;
|
|
4293
|
+
const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
|
|
4294
|
+
return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
|
|
4146
4295
|
}
|
|
4147
|
-
function
|
|
4148
|
-
const
|
|
4149
|
-
|
|
4150
|
-
|
|
4296
|
+
function lchOf(hex) {
|
|
4297
|
+
const lin = (at3) => {
|
|
4298
|
+
const value = Number.parseInt(hex.slice(at3, at3 + 2), 16) / 255;
|
|
4299
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
4300
|
+
};
|
|
4301
|
+
const [r, g, b] = [lin(1), lin(3), lin(5)];
|
|
4302
|
+
const x = (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / 0.95047, y = 0.2126729 * r + 0.7151522 * g + 0.072175 * b, z = (0.0193339 * r + 0.119192 * g + 0.9503041 * b) / 1.08883;
|
|
4303
|
+
const f = (t) => t > 216 / 24389 ? Math.cbrt(t) : (24389 / 27 * t + 16) / 116;
|
|
4304
|
+
const [fx, fy, fz] = [f(x), f(y), f(z)];
|
|
4305
|
+
return { L: 116 * fy - 16, C: Math.hypot(500 * (fx - fy), 200 * (fy - fz)) };
|
|
4151
4306
|
}
|
|
4152
|
-
var
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4307
|
+
var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
|
|
4308
|
+
var MESSAGE_SURFACE_MAX_CHROMA = 80;
|
|
4309
|
+
function resolveMessageSurface(presentation, slide, layout, context) {
|
|
4310
|
+
const deckDesign = rec3(rec3(presentation).design);
|
|
4311
|
+
const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
|
|
4312
|
+
if (kind === void 0 || !(named === void 0 || named === "surface") || deckBackgroundIsChosen(deckDesign, context.theme.background) || !layoutVariantApplies(slide.design, layout, deckDesign, context.theme.background, true)) return void 0;
|
|
4313
|
+
const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
|
|
4314
|
+
const variant = { background: MESSAGE_SURFACE_SLOT, ...below.variant?.accents ? { accents: below.variant.accents } : {} };
|
|
4315
|
+
const plain2 = resolveColorRoles(context.colorScheme, { background: below.background, variant: below.variant });
|
|
4316
|
+
const deliberate = [deckDesign, ...context.themeChosen ? [context.theme] : []].some((level) => level.background !== void 0 || level.variant !== void 0);
|
|
4317
|
+
if (plain2.dark && deliberate) return void 0;
|
|
4318
|
+
const accent = resolveColorRoles(context.colorScheme, { variant }), shade = lchOf(accent.background.slice(0, 7).toUpperCase());
|
|
4319
|
+
if (accent.background.toUpperCase() === plain2.background.toUpperCase() || (colorContrast(accent.text, accent.background) ?? 0) < MESSAGE_SURFACE_CONTRAST || shade.L > MESSAGE_SURFACE_MAX_LIGHTNESS || shade.C > MESSAGE_SURFACE_MAX_CHROMA) return void 0;
|
|
4320
|
+
return { kind, variant };
|
|
4321
|
+
}
|
|
4322
|
+
function drawsAccentByDesign(presentation, host, record2, theme) {
|
|
4323
|
+
const deckDesign = rec3(rec3(presentation).design), own4 = normalizeColorVariant(rec3(host.design).variant), named = layoutColorVariant(record2);
|
|
4324
|
+
if (own4) return own4.background.startsWith("accent");
|
|
4325
|
+
return named !== void 0 && layoutVariantApplies(host.design, record2, deckDesign, theme.background) && named.background.startsWith("accent");
|
|
4326
|
+
}
|
|
4327
|
+
function messageDisplayed(result, kind) {
|
|
4328
|
+
const scale = Math.min(result.width, result.height) / 720, size = (field) => result.items.find((item) => item.field === field)?.text?.fontSize;
|
|
4329
|
+
const text2 = size("text"), title = size("title");
|
|
4330
|
+
if (kind === "statement-message") return text2 !== void 0 && text2 / scale >= LONE_DISPLAY_SIZES.text - 1e-6 || title !== void 0 && title / scale > 54 + 1e-6;
|
|
4331
|
+
return text2 !== void 0 && text2 / scale > LONE_DISPLAY_SIZES.text + 1e-6;
|
|
4332
|
+
}
|
|
4333
|
+
|
|
4334
|
+
// src/slide-context.ts
|
|
4335
|
+
var rec4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
4336
|
+
function unpathed(measurement) {
|
|
4337
|
+
const bare = (style) => ({ ...style, path: void 0 });
|
|
4338
|
+
return {
|
|
4339
|
+
...measurement,
|
|
4340
|
+
measure: (text2, size, style) => measurement.measure(text2, size, bare(style)),
|
|
4341
|
+
...measurement.resolveStyle ? { resolveStyle: (style) => measurement.resolveStyle(bare(style)) } : {},
|
|
4342
|
+
...measurement.outlineBounds ? { outlineBounds: (text2, size, style) => measurement.outlineBounds(text2, size, bare(style)) } : {},
|
|
4343
|
+
...measurement.forScripts ? { forScripts: (profile) => unpathed(measurement.forScripts(profile)) } : {}
|
|
4344
|
+
};
|
|
4345
|
+
}
|
|
4346
|
+
function resolveSlideContext(presentation, index, options2 = {}) {
|
|
4347
|
+
const deck = rec4(presentation);
|
|
4348
|
+
const slides = Array.isArray(deck.slides) ? deck.slides : [];
|
|
4349
|
+
if (!Number.isInteger(index) || index < 0 || index >= slides.length) throw new RangeError(`Slide index ${String(index)} is outside the presentation's ${slides.length} slides.`);
|
|
4350
|
+
const slide = rec4(slides[index]);
|
|
4351
|
+
const catalogs = { catalogs: checkCatalogsOption(options2.catalogs, "resolveSlideContext") };
|
|
4352
|
+
const records = resolveDesignRecords(presentation, index, catalogs);
|
|
4353
|
+
const diagnostics = [...records.diagnostics];
|
|
4354
|
+
const { theme, colorScheme, fontScheme } = records;
|
|
4355
|
+
const design = { ...rec4(deck.design), ...rec4(slide.design) };
|
|
4356
|
+
let layout;
|
|
4357
|
+
let layoutProvenance;
|
|
4358
|
+
if (typeof slide.layout === "string") {
|
|
4359
|
+
const found = resolveReference(presentation, "layouts", slide.layout, catalogs);
|
|
4360
|
+
if (found) {
|
|
4361
|
+
layout = { ...found.record };
|
|
4362
|
+
layoutProvenance = provenanceOf(found);
|
|
4363
|
+
} else diagnostics.push(unresolvedReference(presentation, "layouts", slide.layout, `slides.${index}.layout`, catalogs));
|
|
4364
|
+
}
|
|
4365
|
+
if (options2.strictReferences && diagnostics.length) throw new OPFUnresolvedReferenceError(diagnostics);
|
|
4366
|
+
const candidate = resolveMessageSurface(presentation, slide, layout, { theme, colorScheme, variables: rec4(deck.variables), themeChosen: records.provenance.theme !== void 0 });
|
|
4367
|
+
const build = (surface) => {
|
|
4368
|
+
const levels = colorLevels(rec4(slide.design), layout, rec4(deck.design), theme, colorScheme, rec4(deck.variables), surface?.variant);
|
|
4369
|
+
const roles2 = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec4(deck.variables)));
|
|
4370
|
+
const layoutVariant2 = levels.length > 3 && layoutVariantApplies(slide.design, layout, deck.design, theme.background, surface) ? levels[1].variant : void 0;
|
|
4371
|
+
const composeOptions2 = {
|
|
4372
|
+
...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
|
|
4373
|
+
...layout ? { layout } : {},
|
|
4374
|
+
presentation,
|
|
4375
|
+
slideIndex: index,
|
|
4376
|
+
slideNumber: options2.slideNumber ?? index + 1,
|
|
4377
|
+
slideCount: options2.slideCount ?? slides.length,
|
|
4378
|
+
fontFamilies: resolveFontFamilies(fontScheme),
|
|
4379
|
+
darkBackground: roles2.dark,
|
|
4380
|
+
...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
|
|
4381
|
+
// LH-02: the colors the automatic scrim of a picture background is sized for.
|
|
4382
|
+
roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
|
|
4383
|
+
...theme.background !== void 0 ? { themeBackground: theme.background } : {},
|
|
4384
|
+
// OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
|
|
4385
|
+
...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
|
|
4386
|
+
...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
|
|
4387
|
+
...options2.date !== void 0 ? { date: options2.date } : {}
|
|
4388
|
+
};
|
|
4389
|
+
return { levels, roles: roles2, layoutVariant: layoutVariant2, composeOptions: composeOptions2 };
|
|
4390
|
+
};
|
|
4391
|
+
const variablesOf = (made) => resolveSlideVariables(slide, { slideNumber: made.composeOptions.slideNumber, slideCount: made.composeOptions.slideCount, presentation, darkBackground: made.composeOptions.darkBackground === true });
|
|
4392
|
+
let messageSurface = candidate, built = build(candidate);
|
|
4393
|
+
if (candidate) {
|
|
4394
|
+
const plain2 = build(void 0);
|
|
4395
|
+
const host = plain2.composeOptions.textMeasurement;
|
|
4396
|
+
const measurement = host ? unpathed(slideScriptMeasurement(presentation, index, host, { ...catalogs, fontFamilies: resolveFontFamilies(fontScheme), serif: fontScheme.type === "serif" })) : host;
|
|
4397
|
+
let displayed = false;
|
|
4398
|
+
try {
|
|
4399
|
+
displayed = messageDisplayed(composeSlide(variablesOf(plain2), { ...plain2.composeOptions, ...measurement ? { textMeasurement: measurement } : {} }), candidate.kind);
|
|
4400
|
+
} catch {
|
|
4401
|
+
displayed = false;
|
|
4402
|
+
}
|
|
4403
|
+
if (displayed && index > 0) {
|
|
4404
|
+
const before = rec4(slides[index - 1]), record2 = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
|
|
4405
|
+
if (drawsAccentByDesign(presentation, before, record2, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
|
|
4406
|
+
}
|
|
4407
|
+
if (!displayed) {
|
|
4408
|
+
messageSurface = void 0;
|
|
4409
|
+
built = plain2;
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
const { roles, layoutVariant, composeOptions } = built;
|
|
4413
|
+
const resolvedSlide = variablesOf(built);
|
|
4414
|
+
return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, ...layoutVariant ? { layoutVariant } : {}, ...messageSurface ? { messageSurface } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
|
|
4415
|
+
}
|
|
4416
|
+
|
|
4417
|
+
// src/rule-slides.ts
|
|
4418
|
+
var measurementFor = (options2, index) => {
|
|
4419
|
+
const measurement = options2.fonts?.textMeasurement;
|
|
4420
|
+
return typeof measurement === "function" ? measurement(index) : measurement;
|
|
4421
|
+
};
|
|
4422
|
+
var lazy = (compute) => {
|
|
4423
|
+
let done = false;
|
|
4424
|
+
let value;
|
|
4425
|
+
return () => {
|
|
4426
|
+
if (!done) {
|
|
4427
|
+
value = compute();
|
|
4428
|
+
done = true;
|
|
4429
|
+
}
|
|
4430
|
+
return value;
|
|
4431
|
+
};
|
|
4432
|
+
};
|
|
4433
|
+
function relax(value) {
|
|
4434
|
+
const copy = JSON.parse(JSON.stringify(value));
|
|
4435
|
+
const walk2 = (node) => {
|
|
4436
|
+
if (Array.isArray(node)) return node.forEach(walk2);
|
|
4437
|
+
if (node && typeof node === "object") {
|
|
4438
|
+
const object3 = node;
|
|
4439
|
+
if (object3.overflow === "error") object3.overflow = "warn";
|
|
4440
|
+
for (const child of Object.values(object3)) walk2(child);
|
|
4441
|
+
}
|
|
4442
|
+
};
|
|
4443
|
+
walk2(copy);
|
|
4444
|
+
return copy;
|
|
4445
|
+
}
|
|
4446
|
+
function buildSlides(document, options2, memo) {
|
|
4447
|
+
const slides = Array.isArray(document.slides) ? document.slides : [];
|
|
4448
|
+
return slides.map((slide, index) => {
|
|
4449
|
+
const path = pointer2("slides", index);
|
|
4450
|
+
const baseContext = lazy(() => resolveSlideContext(document, index, { catalogs: options2.catalogs, date: "2000-01-01" }));
|
|
4451
|
+
const measurement = lazy(() => {
|
|
4452
|
+
const host = measurementFor(options2, index);
|
|
4453
|
+
if (!host) return void 0;
|
|
4454
|
+
const { resolved: resolved3 } = baseContext();
|
|
4455
|
+
return slideScriptMeasurement(document, index, host, { catalogs: options2.catalogs, fontFamilies: resolveFontFamilies(resolved3.fontScheme), serif: resolved3.fontScheme.type === "serif" });
|
|
4456
|
+
});
|
|
4457
|
+
const resolved2 = lazy(() => {
|
|
4458
|
+
const textMeasurement = measurement();
|
|
4459
|
+
const slideContext = baseContext();
|
|
4460
|
+
return textMeasurement ? { ...slideContext, options: { ...slideContext.options, textMeasurement } } : slideContext;
|
|
4461
|
+
});
|
|
4462
|
+
const design = lazy(() => resolveDesign(document, index, resolved2()));
|
|
4463
|
+
const layout = lazy(() => resolved2().options.layout);
|
|
4464
|
+
const compute = () => {
|
|
4465
|
+
const result = { layoutDiagnostics: [] };
|
|
4466
|
+
let fontFamilies;
|
|
4467
|
+
const compose = (input, withLayout) => {
|
|
4468
|
+
const options3 = resolved2().options;
|
|
4469
|
+
fontFamilies ??= options3.fontFamilies && resolveDrawnFontFamilies(options3.fontFamilies, options3.textMeasurement);
|
|
4470
|
+
return composeSlide(input, { ...options3, ...fontFamilies ? { fontFamilies } : {}, layout: withLayout });
|
|
4471
|
+
};
|
|
4472
|
+
try {
|
|
4473
|
+
result.composition = compose(resolved2().slide, layout());
|
|
4474
|
+
result.layoutDiagnostics.push(...result.composition.diagnostics.map((diagnostic) => ({ diagnostic, strict: false })));
|
|
4475
|
+
} catch (error) {
|
|
4476
|
+
if (error instanceof OPFCompositionError) {
|
|
4477
|
+
result.layoutDiagnostics.push(...error.diagnostics.map((diagnostic) => ({ diagnostic, strict: true })));
|
|
4478
|
+
try {
|
|
4479
|
+
const relaxedLayout = layout();
|
|
4480
|
+
result.composition = compose(relax(resolved2().slide), relaxedLayout ? relax(relaxedLayout) : void 0);
|
|
4481
|
+
} catch (second) {
|
|
4482
|
+
result.layoutError = second instanceof Error ? second.message : String(second);
|
|
4483
|
+
}
|
|
4484
|
+
} else result.layoutError = error instanceof Error ? error.message : String(error);
|
|
4485
|
+
}
|
|
4486
|
+
return result;
|
|
4487
|
+
};
|
|
4488
|
+
const composed = lazy(() => memo ? memo(index, compute) : compute());
|
|
4489
|
+
const payloads = lazy(() => slidePayloads(slide, path));
|
|
4490
|
+
const texts = lazy(() => textValues(slide, path));
|
|
4491
|
+
const rtl = lazy(() => {
|
|
4492
|
+
try {
|
|
4493
|
+
return resolveScriptFonts(document, { slideIndex: index }).rtl === true;
|
|
4494
|
+
} catch {
|
|
4495
|
+
return false;
|
|
4496
|
+
}
|
|
4497
|
+
});
|
|
4498
|
+
const context = { index, slide, path, ...typeof slide.id === "string" ? { id: slide.id } : {} };
|
|
4499
|
+
return Object.defineProperties(context, {
|
|
4500
|
+
design: { get: design, enumerable: true },
|
|
4501
|
+
layout: { get: layout, enumerable: true },
|
|
4502
|
+
composition: { get: () => composed().composition, enumerable: true },
|
|
4503
|
+
layoutDiagnostics: { get: () => composed().layoutDiagnostics, enumerable: true },
|
|
4504
|
+
layoutError: { get: () => composed().layoutError, enumerable: true },
|
|
4505
|
+
measurement: { get: measurement, enumerable: true },
|
|
4506
|
+
payloads: { get: payloads, enumerable: true },
|
|
4507
|
+
texts: { get: texts, enumerable: true },
|
|
4508
|
+
rtl: { get: rtl, enumerable: true }
|
|
4509
|
+
});
|
|
4510
|
+
});
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
// src/rules-variable-overflow.ts
|
|
4514
|
+
var plain = (value) => typeof value === "string" ? value : Array.isArray(value) ? value.map((run) => typeof run === "string" ? run : typeof rec(run).text === "string" ? rec(run).text : "").join("") : "";
|
|
4515
|
+
function drawnValue(declaration, values) {
|
|
4516
|
+
if (Object.hasOwn(values, declaration.id) && values[declaration.id] !== null && values[declaration.id] !== void 0) {
|
|
4517
|
+
const coerced = coerceVariableValue(declaration.kind, values[declaration.id]);
|
|
4518
|
+
if (coerced.ok) return coerced.value;
|
|
4519
|
+
}
|
|
4520
|
+
return declaration.value ?? declaration.example;
|
|
4521
|
+
}
|
|
4522
|
+
function composedLines(slide, place) {
|
|
4523
|
+
const composition = slide.composition;
|
|
4524
|
+
if (!composition) return void 0;
|
|
4525
|
+
let best = [];
|
|
4526
|
+
let bestDepth = -1;
|
|
4527
|
+
const offer = (path, lines) => {
|
|
4528
|
+
if (!lines || lines.length === 0) return;
|
|
4529
|
+
const at3 = pointerOfDotted(path);
|
|
4530
|
+
if (at3 !== place && !place.startsWith(`${at3}/`)) return;
|
|
4531
|
+
if (at3.length > bestDepth) {
|
|
4532
|
+
bestDepth = at3.length;
|
|
4533
|
+
best = [];
|
|
4534
|
+
}
|
|
4535
|
+
if (at3.length === bestDepth) best.push([...lines]);
|
|
4536
|
+
};
|
|
4537
|
+
for (const item of composition.items) {
|
|
4538
|
+
const text2 = item.text;
|
|
4539
|
+
if (!text2) continue;
|
|
4540
|
+
if (text2.listEntries) {
|
|
4541
|
+
for (const entry2 of text2.listEntries) {
|
|
4542
|
+
if (entry2.textPath) offer(entry2.textPath, entry2.text.lines);
|
|
4543
|
+
if (entry2.descriptionPath && entry2.description) offer(entry2.descriptionPath, entry2.description.lines);
|
|
4544
|
+
}
|
|
4545
|
+
continue;
|
|
4546
|
+
}
|
|
4547
|
+
offer(item.path, text2.lines);
|
|
4548
|
+
}
|
|
4549
|
+
return best.length ? best.flat() : void 0;
|
|
4550
|
+
}
|
|
4551
|
+
function linesOfValue(lines, value, occurrence) {
|
|
4552
|
+
const squash = (text2) => text2.replace(/\s+/gu, "").toLowerCase();
|
|
4553
|
+
const needle = squash(value);
|
|
4554
|
+
if (!needle) return void 0;
|
|
4555
|
+
const spans = [];
|
|
4556
|
+
let at3 = 0;
|
|
4557
|
+
for (const line2 of lines) {
|
|
4558
|
+
const length = squash(line2).length;
|
|
4559
|
+
spans.push({ start: at3, end: at3 + length });
|
|
4560
|
+
at3 += length;
|
|
4561
|
+
}
|
|
4562
|
+
const hay = lines.map(squash).join("");
|
|
4563
|
+
let start = -1;
|
|
4564
|
+
for (let found = 0, from = 0; found <= occurrence; found++) {
|
|
4565
|
+
start = hay.indexOf(needle, from);
|
|
4566
|
+
if (start < 0) return void 0;
|
|
4567
|
+
from = start + needle.length;
|
|
4568
|
+
}
|
|
4569
|
+
const end = start + needle.length;
|
|
4570
|
+
return spans.filter((span) => span.end > span.start && span.start < end && span.end > start).length;
|
|
4571
|
+
}
|
|
4572
|
+
var slideOf = (path) => {
|
|
4573
|
+
const match2 = /^\/slides\/(\d+)(?:\/|$)/.exec(path);
|
|
4574
|
+
return match2 ? Number(match2[1]) : void 0;
|
|
4575
|
+
};
|
|
4576
|
+
function measuredOf(message) {
|
|
4577
|
+
const found = /has (\d+) (characters|items); its (maxLength|maxItems) is (\d+)/.exec(message);
|
|
4578
|
+
return found ? { [found[2]]: Number(found[1]), [found[3]]: Number(found[4]) } : void 0;
|
|
4579
|
+
}
|
|
4580
|
+
function overflow(context) {
|
|
4581
|
+
const document = context.document;
|
|
4582
|
+
const declared = variableDeclarations(document).filter((entry2) => entry2.maxLength !== void 0 || entry2.maxLines !== void 0 || entry2.maxItems !== void 0);
|
|
4583
|
+
if (!declared.length) return;
|
|
4584
|
+
const values = context.options.values ?? {};
|
|
4585
|
+
const template = context.options.template ?? isTemplate(document);
|
|
4586
|
+
for (const entry2 of resolveVariables(document, values, { template, partial: true }).diagnostics) {
|
|
4587
|
+
if (entry2.code !== "variable-overflow") continue;
|
|
4588
|
+
const measured = measuredOf(entry2.message);
|
|
4589
|
+
context.report(variableOverflowRule, {
|
|
4590
|
+
path: entry2.path,
|
|
4591
|
+
message: entry2.message,
|
|
4592
|
+
help: "Shorten the value, or raise the limit in the declaration if the layout has the room.",
|
|
4593
|
+
...measured ? { measured } : {}
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
const limited = declared.filter((entry2) => entry2.kind === "text" && entry2.maxLines !== void 0);
|
|
4597
|
+
if (!limited.length) return;
|
|
4598
|
+
const uses = /* @__PURE__ */ new Map();
|
|
4599
|
+
for (const info of listVariables(document, values)) if (info.uses.length && info.maxLines !== void 0 && info.kind === "text") uses.set(info.id, info.uses);
|
|
4600
|
+
if (!uses.size) return;
|
|
4601
|
+
const view = instantiateForValidation(document, values, template).presentation;
|
|
4602
|
+
const drawn = buildSlides(view, context.options);
|
|
4603
|
+
const seen = /* @__PURE__ */ new Map();
|
|
4604
|
+
for (const declaration of limited) {
|
|
4605
|
+
const value = drawnValue(declaration, values);
|
|
4606
|
+
if (declaration.maxLines === void 0) continue;
|
|
4607
|
+
for (const use of uses.get(declaration.id) ?? []) {
|
|
4608
|
+
const index = slideOf(use.path);
|
|
4609
|
+
if (index === void 0) continue;
|
|
4610
|
+
const given = Object.hasOwn(values, declaration.id) && values[declaration.id] !== null && values[declaration.id] !== void 0;
|
|
4611
|
+
const picked = given ? void 0 : translationAt(declaration, document, use.path);
|
|
4612
|
+
const drawnHere = picked ? picked.value : value;
|
|
4613
|
+
if (drawnHere === void 0) continue;
|
|
4614
|
+
const text2 = plain(drawnHere);
|
|
4615
|
+
const slide = drawn[index];
|
|
4616
|
+
const source = context.slides[index];
|
|
4617
|
+
if (!slide || !source) continue;
|
|
4618
|
+
const key3 = `${declaration.id}\0${use.path}`;
|
|
4619
|
+
const occurrence = seen.get(key3) ?? 0;
|
|
4620
|
+
seen.set(key3, occurrence + 1);
|
|
4621
|
+
const lines = composedLines(slide, use.path);
|
|
4622
|
+
if (!lines) continue;
|
|
4623
|
+
const taken = linesOfValue(lines, text2, occurrence);
|
|
4624
|
+
if (taken === void 0 || taken <= declaration.maxLines) continue;
|
|
4625
|
+
context.report(variableOverflowRule, {
|
|
4626
|
+
path: use.path,
|
|
4627
|
+
slide: source,
|
|
4628
|
+
message: `'${declaration.id}' takes ${taken} lines here; its maxLines is ${declaration.maxLines}.`,
|
|
4629
|
+
help: "Shorten the value, widen the place it is drawn in, or raise maxLines in the declaration if the slide has the room.",
|
|
4630
|
+
measured: { lines: taken, maxLines: declaration.maxLines }
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
var variableOverflow = { info: variableOverflowRule, run: overflow };
|
|
4636
|
+
var variableOverflowRules = [variableOverflow];
|
|
4637
|
+
|
|
4638
|
+
// src/validation-rules.ts
|
|
4639
|
+
var ruleImplementations = [...accessibilityRules, ...layoutContentRules, ...languageTagRules, ...layoutFindingRules, ...variableOverflowRules, ...chartFindingRules];
|
|
4640
|
+
|
|
4641
|
+
// src/chart-shape.ts
|
|
4642
|
+
var FOREIGN_CHART_KEYS = ["categories", "series", "labels", "datasets"];
|
|
4643
|
+
var CHART_DEFINITION = "https://openpresentation.org/schema/opf/v1#/$defs/Chart";
|
|
4644
|
+
var isRecord3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4645
|
+
var isCell = (value) => value === null || ["string", "number", "boolean"].includes(typeof value);
|
|
4646
|
+
function foreignChartKeys(chart) {
|
|
4647
|
+
if (!isRecord3(chart) || Object.hasOwn(chart, "data")) return [];
|
|
4648
|
+
return FOREIGN_CHART_KEYS.filter((key3) => Object.hasOwn(chart, key3));
|
|
4649
|
+
}
|
|
4650
|
+
function convertChartData(chart) {
|
|
4651
|
+
const labels = chart.categories ?? chart.labels;
|
|
4652
|
+
const series = chart.series ?? chart.datasets;
|
|
4653
|
+
if (!Array.isArray(labels) || !labels.length || !labels.every(isCell) || !Array.isArray(series) || !series.length) return void 0;
|
|
4654
|
+
const columns = ["Category"];
|
|
4655
|
+
const values = [];
|
|
4656
|
+
for (const [index, entry2] of series.entries()) {
|
|
4657
|
+
if (!isRecord3(entry2)) return void 0;
|
|
4658
|
+
const list = entry2.values ?? entry2.data;
|
|
4659
|
+
const name = entry2.name ?? entry2.label;
|
|
4660
|
+
if (!Array.isArray(list) || list.length !== labels.length || !list.every(isCell)) return void 0;
|
|
4661
|
+
columns.push(typeof name === "string" && name ? name : `Series ${index + 1}`);
|
|
4662
|
+
values.push(list);
|
|
4663
|
+
}
|
|
4664
|
+
if (new Set(columns).size !== columns.length) return void 0;
|
|
4665
|
+
return { columns, rows: labels.map((label, row) => [label, ...values.map((list) => list[row])]) };
|
|
4666
|
+
}
|
|
4667
|
+
function chartShapePatch(chart, path) {
|
|
4668
|
+
if (!isRecord3(chart)) return void 0;
|
|
4669
|
+
const data = convertChartData(chart);
|
|
4670
|
+
const keys = foreignChartKeys(chart);
|
|
4671
|
+
if (!data || !keys.length) return void 0;
|
|
4672
|
+
return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
|
|
4673
|
+
}
|
|
4674
|
+
var SHOWN_ROWS = 3;
|
|
4675
|
+
var json = (value) => JSON.stringify(value);
|
|
4676
|
+
function dataExample(chart) {
|
|
4677
|
+
const data = convertChartData(chart);
|
|
4678
|
+
if (!data) return '"data": { "columns": ["Category", "Series name"], "rows": [["Q1", 3], ["Q2", 8]] }';
|
|
4679
|
+
const rows = data.rows.slice(0, SHOWN_ROWS).map(json);
|
|
4680
|
+
return `"data": { "columns": ${json(data.columns)}, "rows": [${rows.join(",")}${data.rows.length > SHOWN_ROWS ? ",..." : ""}] }`;
|
|
4681
|
+
}
|
|
4682
|
+
function chartShapeHelp(chart) {
|
|
4683
|
+
const keys = foreignChartKeys(chart);
|
|
4684
|
+
if (!keys.length || !isRecord3(chart)) return void 0;
|
|
4685
|
+
const names2 = keys.map((key3) => `"${key3}"`).join(" and ");
|
|
4686
|
+
const example = dataExample(chart);
|
|
4687
|
+
const next = `replace ${names2} with ${example}. The first column holds the category labels and each further column is one series.`;
|
|
4688
|
+
return {
|
|
4689
|
+
message: `The chart has ${names2} (the Chart.js and ECharts shape), but an OPF chart keeps its values in "data": { "columns", "rows" }.`,
|
|
4690
|
+
next,
|
|
4691
|
+
help: `OPF charts use "data": { "columns", "rows" }, not ${names2}. Replace ${names2} with ${example}; the first column holds the category labels and each further column is one series. See the Chart definition: ${CHART_DEFINITION} (opf schema presentation '/$defs/Chart').`
|
|
4692
|
+
};
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4695
|
+
// src/generated/version.ts
|
|
4696
|
+
var OPF_CORE_VERSION = "0.37.0";
|
|
4697
|
+
|
|
4698
|
+
// src/renamed-keys.ts
|
|
4699
|
+
var KEY_RENAMES = Object.freeze([
|
|
4700
|
+
{ from: "languageFamily", to: "scriptGroup", note: 'Its values are "latin", "eastAsian" and "complexScript"; "ea" and "cs" are no longer accepted.' },
|
|
4701
|
+
{ from: "verticalAlign", to: "anchor" },
|
|
4702
|
+
{ from: "organizationId", to: "organization" },
|
|
4703
|
+
{ from: "minFontSize", to: "minFontSizePx", note: "The numbers are unchanged: reference pixels." },
|
|
4704
|
+
{ from: "maxFontSize", to: "maxFontSizePx", note: "The numbers are unchanged: reference pixels." },
|
|
4705
|
+
{ from: "url", to: "link", at: (segments) => segments.at(-3) === "references", note: 'A reference link is an http or https address, a "mailto:" or a "tel:" link.' },
|
|
4706
|
+
{ from: "tone", to: "appearance", at: (segments) => segments.at(-2) === "background" },
|
|
4707
|
+
{ from: "line", to: "lineSeries", at: (segments) => segments.at(-2) === "chart" }
|
|
4708
|
+
]);
|
|
4709
|
+
function renamedKeyAt(segments) {
|
|
4710
|
+
const name = segments.at(-1);
|
|
4711
|
+
return name === void 0 ? void 0 : KEY_RENAMES.find((entry2) => entry2.from === name && (entry2.at === void 0 || entry2.at(segments)));
|
|
4712
|
+
}
|
|
4713
|
+
var AUTHORED_KEYS = /* @__PURE__ */ new Set(["extensions", "datasets"]);
|
|
4714
|
+
var RENAMED_SCRIPT_GROUP_VALUES = Object.freeze({ ea: "eastAsian", cs: "complexScript" });
|
|
4715
|
+
function renamedScriptGroupValue(value) {
|
|
4716
|
+
return typeof value === "string" && Object.hasOwn(RENAMED_SCRIPT_GROUP_VALUES, value) ? RENAMED_SCRIPT_GROUP_VALUES[value] : void 0;
|
|
4717
|
+
}
|
|
4718
|
+
var renamedKeyMessage = (entry2, bothPresent) => `"${entry2.from}" was renamed "${entry2.to}" in OPF 0.37${bothPresent ? `, and this object has both: remove one` : ""}.`;
|
|
4719
|
+
var renamedValueMessage = (from, to) => `"${from}" is written "${to}" since OPF 0.37.`;
|
|
4720
|
+
var LOOKS_LIKE_HOST_AND_PATH = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+(:\d+)?([/?#]\S*)?$/;
|
|
4721
|
+
function renameRecordKeys(value, segments = []) {
|
|
4722
|
+
if (Array.isArray(value)) {
|
|
4723
|
+
let changed2 = false;
|
|
4724
|
+
const next = value.map((entry2, index) => {
|
|
4725
|
+
const rewritten = renameRecordKeys(entry2, [...segments, String(index)]);
|
|
4726
|
+
if (rewritten !== entry2) changed2 = true;
|
|
4727
|
+
return rewritten;
|
|
4728
|
+
});
|
|
4729
|
+
return changed2 ? next : value;
|
|
4730
|
+
}
|
|
4731
|
+
if (!isRecord2(value)) return value;
|
|
4732
|
+
let changed = false;
|
|
4733
|
+
const entries = [];
|
|
4734
|
+
for (const [key3, child] of Object.entries(value)) {
|
|
4735
|
+
const path = [...segments, key3];
|
|
4736
|
+
const rename = renamedKeyAt(path);
|
|
4737
|
+
const name = rename && !Object.hasOwn(value, rename.to) ? rename.to : key3;
|
|
4738
|
+
let rewritten = AUTHORED_KEYS.has(key3) ? child : renameRecordKeys(child, path);
|
|
4739
|
+
if (name === "scriptGroup") {
|
|
4740
|
+
const long = renamedScriptGroupValue(rewritten);
|
|
4741
|
+
if (long !== void 0) rewritten = long;
|
|
4742
|
+
}
|
|
4743
|
+
if (name !== key3 || rewritten !== child) changed = true;
|
|
4744
|
+
entries.push([name, rewritten]);
|
|
4745
|
+
}
|
|
4746
|
+
return changed ? Object.fromEntries(entries) : value;
|
|
4747
|
+
}
|
|
4748
|
+
|
|
4749
|
+
// src/check-document.ts
|
|
4750
|
+
var own = (value, key3) => Object.hasOwn(value, key3);
|
|
4751
|
+
var object2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4752
|
+
var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
4753
|
+
var pointer4 = (parts2) => parts2.length ? "/" + parts2.map((part2) => String(part2).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
|
|
4754
|
+
function parts(path) {
|
|
4755
|
+
if (path === "") return [];
|
|
4756
|
+
if (!path.startsWith("/") || /~(?![01])/.test(path))
|
|
4757
|
+
throw new TypeError(`Invalid contract JSON Pointer: ${path}`);
|
|
4758
|
+
return path.slice(1).split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
4759
|
+
}
|
|
4760
|
+
function at2(value, path) {
|
|
4761
|
+
return parts(path).reduce(
|
|
4762
|
+
(current, key3) => object2(current) || Array.isArray(current) ? own(current, key3) ? current[key3] : void 0 : void 0,
|
|
4763
|
+
value
|
|
4764
|
+
);
|
|
4765
|
+
}
|
|
4766
|
+
function checkDocumentOptions(options2) {
|
|
4767
|
+
checkCatalogsOption(options2.catalogs, "validate");
|
|
4768
|
+
if (options2.contracts !== void 0 && !Array.isArray(options2.contracts))
|
|
4769
|
+
throw new TypeError("Validate contracts must be an array.");
|
|
4770
|
+
for (const contract2 of options2.contracts ?? []) {
|
|
4771
|
+
if (!object2(contract2) || Object.keys(contract2).some(
|
|
4772
|
+
(key3) => ![
|
|
4773
|
+
"path",
|
|
4774
|
+
"allowedValues",
|
|
4775
|
+
"severity",
|
|
4776
|
+
"message",
|
|
4777
|
+
"documentation"
|
|
4778
|
+
].includes(key3)
|
|
4779
|
+
) || typeof contract2.path !== "string" || !Array.isArray(contract2.allowedValues) || !contract2.allowedValues.every(primitive) || contract2.severity !== void 0 && (typeof contract2.severity !== "string" || !["error", "warning", "info"].includes(contract2.severity)) || contract2.message !== void 0 && typeof contract2.message !== "string" || contract2.documentation !== void 0 && typeof contract2.documentation !== "string")
|
|
4780
|
+
throw new TypeError(
|
|
4781
|
+
"Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
|
|
4782
|
+
);
|
|
4783
|
+
parts(contract2.path);
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4786
|
+
function finding(ruleId, data) {
|
|
4787
|
+
const info = ruleInfo(ruleId);
|
|
4788
|
+
const { severity, scope, ...rest } = data;
|
|
4789
|
+
return { ruleId, severity: severity ?? info.severity, category: info.category, scope: scope ?? "document", ...rest };
|
|
4790
|
+
}
|
|
4791
|
+
var issueRuleId = (issue2) => typeof issue2.params.code === "string" && issue2.keyword === "opf" ? `opf/${issue2.params.code}` : "opf/schema";
|
|
4792
|
+
function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presentation", prefix = "", scope = "document", severity) {
|
|
4793
|
+
const path = prefix + (issue2.path === "/" ? "" : issue2.path) + (issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? pointer4([issue2.params.additionalProperty]) : ""), entry2 = schemaEntries.find((entry3) => entry3.name === schemaName);
|
|
4794
|
+
if (!entry2) throw new TypeError(`Unknown schema ${schemaName}`);
|
|
4156
4795
|
const precise = validationDefinition(issue2);
|
|
4157
4796
|
const definition = precise?.uri ?? (issue2.keyword === "opf" ? "packages/javascript/src/schema-check.ts" : issue2.schemaPath.startsWith("#") ? entry2.schema.$id + issue2.schemaPath : issue2.schemaPath);
|
|
4158
4797
|
const lookup = [
|
|
@@ -4163,7 +4802,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4163
4802
|
];
|
|
4164
4803
|
let help = "Inspect this schema constraint and preserve unrelated content. Errors inside oneOf/anyOf branches may describe alternatives; retain the intended form.";
|
|
4165
4804
|
if (issue2.keyword === "required" && issue2.params.missingProperty === "id" && /^\/(organization|speaker)(\/\d+)?$/.test(issue2.path))
|
|
4166
|
-
help = `Add an "id" next to "name": organizations and speakers are found by id (speaker.
|
|
4805
|
+
help = `Add an "id" next to "name": organizations and speakers are found by id (speaker.organization, {{organization.<id>.name}}, the editor and the PPTX round trip), for example "id": "acme" (letters, digits, "-" and "_", unique in the deck).`;
|
|
4167
4806
|
else if (issue2.keyword === "required")
|
|
4168
4807
|
help = `Add the required ${JSON.stringify(issue2.params.missingProperty)} field in this object, using the intended schema form.`;
|
|
4169
4808
|
else if (issue2.keyword === "additionalProperties")
|
|
@@ -4184,6 +4823,8 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4184
4823
|
help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
|
|
4185
4824
|
else if (typedName !== void 0 && typeof nearest2[0]?.value === "string")
|
|
4186
4825
|
help = `Did you mean ${JSON.stringify(nearest2[0].value)}? ${JSON.stringify(typedName)} is not a field of this object. To keep custom metadata, put it in extensions; do not delete authored content to clear this error.`;
|
|
4826
|
+
const unknownKey = typedName !== void 0 && nearest2.length === 0 && renamedKeyAt(splitPointer(path)) === void 0;
|
|
4827
|
+
if (unknownKey) help = `${help} This validator is OPF ${OPF_CORE_VERSION}; a later OPF release may define ${JSON.stringify(typedName)}.`;
|
|
4187
4828
|
return finding(ruleId, {
|
|
4188
4829
|
...severity ? { severity } : {},
|
|
4189
4830
|
path,
|
|
@@ -4192,7 +4833,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4192
4833
|
help,
|
|
4193
4834
|
definition,
|
|
4194
4835
|
lookup,
|
|
4195
|
-
validation: issue2,
|
|
4836
|
+
validation: unknownKey ? { ...issue2, params: { ...issue2.params, validatorVersion: OPF_CORE_VERSION } } : issue2,
|
|
4196
4837
|
...allowed.length ? {
|
|
4197
4838
|
suggestions: allowed.map((value) => ({
|
|
4198
4839
|
value,
|
|
@@ -4244,7 +4885,7 @@ function resolve(cursor, seen = /* @__PURE__ */ new Set()) {
|
|
|
4244
4885
|
seen.add(id);
|
|
4245
4886
|
const [base, fragment = ""] = ref.split("#"), root = base ? schemaEntries.find((entry2) => entry2.schema.$id === base)?.schema : cursor.root;
|
|
4246
4887
|
if (!root) return { ...cursor, schema: {} };
|
|
4247
|
-
const target =
|
|
4888
|
+
const target = at2(root, fragment);
|
|
4248
4889
|
if (!object2(target)) return { ...cursor, schema: {} };
|
|
4249
4890
|
const resolved2 = resolve(
|
|
4250
4891
|
{ schema: target, root, path: fragment },
|
|
@@ -4378,16 +5019,16 @@ function embeddedRecordFindings(document, options2, findings) {
|
|
|
4378
5019
|
if (!object2(document) || !object2(document.catalogs)) return invalid;
|
|
4379
5020
|
for (const [group, value] of Object.entries(document.catalogs)) {
|
|
4380
5021
|
if (!object2(value)) continue;
|
|
4381
|
-
for (const [id,
|
|
4382
|
-
if (object2(
|
|
4383
|
-
const validation = validateAgainstSchema(object2(
|
|
5022
|
+
for (const [id, record2] of Object.entries(object2(value.iconSets) ? value.iconSets : {})) {
|
|
5023
|
+
if (object2(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) continue;
|
|
5024
|
+
const validation = validateAgainstSchema(object2(record2) ? { $schema: schemas.iconSet.$id, id, ...record2 } : record2, "iconSets");
|
|
4384
5025
|
for (const issue2 of validation.errors) findings.push(issueFinding(issue2, "opf/catalog-record", "iconSet", pointer4(["catalogs", group, "iconSets", id]), "document"));
|
|
4385
5026
|
}
|
|
4386
5027
|
for (const kind of catalogKinds)
|
|
4387
|
-
for (const [id,
|
|
5028
|
+
for (const [id, record2] of Object.entries(object2(value[kind]) ? value[kind] : {})) {
|
|
4388
5029
|
const path = pointer4(["catalogs", group, kind, id]);
|
|
4389
|
-
if (object2(
|
|
4390
|
-
const validation = recordIssues(kind, id,
|
|
5030
|
+
if (object2(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) continue;
|
|
5031
|
+
const validation = recordIssues(kind, id, record2);
|
|
4391
5032
|
for (const issue2 of validation.errors) findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[kind], path, "document"));
|
|
4392
5033
|
if (!validation.valid) invalid.add(recordKey(group, kind, id));
|
|
4393
5034
|
if (group === "custom") continue;
|
|
@@ -4441,9 +5082,23 @@ function chartNumberFixPaths(document) {
|
|
|
4441
5082
|
}
|
|
4442
5083
|
var HELP = {
|
|
4443
5084
|
"chart-value-not-numeric": 'Write chart values as numbers (or strict decimal strings such as "12.5" or "1e6"); put currency, percent and units in the column format ({ "name": "Revenue", "format": "$#,##0" }). The value is plotted as a gap.',
|
|
5085
|
+
"data-cell-type": "Write the cell as the column declares (a number as a number, text as text, a date as a time label, a boolean as true or false), or change the column's `type` to what it holds. A mismatched cell is still read as it was before; nothing is drawn differently.",
|
|
5086
|
+
"metric-data-stale": "Write the computed number as the metric's value or delta (apply the fix), or change the data link so it computes what the slide says. Readers that do not compute draw the written number.",
|
|
5087
|
+
"metric-data-aggregate": "Use an aggregate that fits the column (first, last or count work on any column), or link a column typed number.",
|
|
5088
|
+
"metric-data-empty": "Check the filter and the field: no row meets the filter, or none of the cells is usable for the aggregate. The written value is shown until the link computes a number.",
|
|
5089
|
+
"metric-data-delta": 'Give the change something to compare with: two rows for "previous", a baseline filter that meets a row, a comparison value other than 0 for a percent, or write the change in a column and use `field`. No change is shown until then.',
|
|
5090
|
+
"metric-unit-repeated": "Drop the unit, or take the unit's text out of the number format: the unit is printed after the value, and the format already prints it.",
|
|
5091
|
+
"datasource-credentials": "Remove the user, password, key or token from the data source and keep the secret in your own store; name the connection in `connector` or `extensions`. A data source never holds credentials.",
|
|
5092
|
+
"dataset-stale": "Take the data from its data source again and update `retrieved`, or change the data source's `refreshEvery` to how often the data really needs taking.",
|
|
4444
5093
|
"chart-mapping-adapted": "Choose a compatible chart type or mapping for the selected data. The message explains how the mapping or drawing was adapted.",
|
|
5094
|
+
"chart-bands-order": "Write the bands in increasing order of their to values. Every engine draws them sorted.",
|
|
5095
|
+
"chart-bands-unsupported": "Use a bar, column, line, area or bullet chart for bands, or remove the bands.",
|
|
5096
|
+
"metric-gauge-range": "Write the gauge's max above its min, and keep the value, the target and each band's to between them. A value outside the range still prints its real number; its arc stops at the end.",
|
|
5097
|
+
"metric-gauge-value": "Give the metric a number value (a number, or a data link that computes one), or remove the gauge.",
|
|
4445
5098
|
"chart-series-dropped": "The chart type plots one series. Use a chart type that plots every series (column, bar, line), or one chart per series.",
|
|
4446
5099
|
"chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasize, or remove the entry.",
|
|
5100
|
+
"table-color-scale-no-data": "Name columns that hold numbers, or remove the color scale. A cell is shaded only when its value is a finite number.",
|
|
5101
|
+
"table-color-scale-range": "Pin min below max, and keep center between them, or leave the range to the data.",
|
|
4447
5102
|
"slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
|
|
4448
5103
|
"code-highlight-out-of-range": "Marked lines count from 1 by line break in code.source. The entry marks nothing past the last line; change it to a line the code has, or remove it.",
|
|
4449
5104
|
"code-highlight-range-reversed": "Write the range with the smaller line number first, or remove it. A reversed range marks nothing.",
|
|
@@ -4451,6 +5106,8 @@ var HELP = {
|
|
|
4451
5106
|
"variable-unknown": "Declare the variable in the top-level variables map, or write '\\{{' for literal braces.",
|
|
4452
5107
|
"variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
|
|
4453
5108
|
"variable-unused": "Reference the variable as {{id}} or var:id where it belongs, or remove its declaration.",
|
|
5109
|
+
"variable-translation-duplicate": "Remove one of the two keys: the language tag compares without regard to case, and the first in the document is the one drawn.",
|
|
5110
|
+
"variable-translation-unused": "Declare the language ('language' on the deck or a slide) that selects the translation, fix its tag, or remove it.",
|
|
4454
5111
|
"variable-group-omitted": "Give one of the variables a value to draw the group, make one of them required, or move the content that should always show out of the group.",
|
|
4455
5112
|
"variable-reference-unknown": "Declare the variable in the top-level variables map, or use another color.",
|
|
4456
5113
|
"run-color-unrecognized": "Use a #RRGGBB hex color, a color-scheme name or a var: reference to a declared color variable.",
|
|
@@ -4463,7 +5120,7 @@ function semanticHelp(issue2) {
|
|
|
4463
5120
|
if (params2.code === "shape-option-unsupported-payload" && field === "alt" && params2.type === "image") return `A picture's alt text goes inside its image object: { "image": { "src": "...", "alt": "..." } }.`;
|
|
4464
5121
|
if (params2.code === "shape-option-unsupported-payload" && field) return `Remove ${quoted3}, or draw this as a shape: a shape block ({ "shape": ... } with no "image") or an overlay shape in the slide's "shapes".`;
|
|
4465
5122
|
if (params2.code === "number-format-invalid") return 'Write a pattern with a numeric part, such as "0%", "0.0", "#,##0" or "$#,##0.00", optionally followed by a negative and a zero section after ";" ("+0%;-0%", "0;(0);0"; at most three, each with a numeric part). A negative section prints no minus of its own. There is no text section, color or condition.';
|
|
4466
|
-
if (params2.code === "caption-unsupported-payload") return "Put the caption on the image, chart, table, video or diagram it describes, or write it as a text block of its own.";
|
|
5123
|
+
if (params2.code === "caption-unsupported-payload") return "Put the caption on the image, chart, table, video, embed or diagram it describes, or write it as a text block of its own.";
|
|
4467
5124
|
if (Array.isArray(params2.incompatible) && params2.incompatible.includes("bullets") && params2.type === "list") return 'For a list, write the entries under "items". To keep "bullets" (talking points, which belong to a text payload), remove "type" or write "type": "text".';
|
|
4468
5125
|
return "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
|
|
4469
5126
|
}
|
|
@@ -4472,27 +5129,27 @@ var BACKGROUND_HELP = `A background is a string (a theme slot such as "light1",
|
|
|
4472
5129
|
function collapseAuthoringShapes(document, findings) {
|
|
4473
5130
|
const valueAt = (path) => {
|
|
4474
5131
|
let node = document;
|
|
4475
|
-
for (const
|
|
5132
|
+
for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
|
|
4476
5133
|
return node;
|
|
4477
5134
|
};
|
|
4478
5135
|
const schema = (entry2) => entry2?.ruleId === "opf/schema";
|
|
4479
5136
|
const fills = /* @__PURE__ */ new Map();
|
|
4480
5137
|
for (const entry2 of findings) {
|
|
4481
5138
|
if (!schema(entry2)) continue;
|
|
4482
|
-
const
|
|
4483
|
-
if (!
|
|
4484
|
-
const fill = valueAt(
|
|
5139
|
+
const at3 = /^(.*\/fill)(?:\/[^/]+)?$/.exec(entry2.path)?.[1];
|
|
5140
|
+
if (!at3 || fills.has(at3) || at3.endsWith("/style/fill")) continue;
|
|
5141
|
+
const fill = valueAt(at3);
|
|
4485
5142
|
if (!isRecord(fill) || Object.hasOwn(fill, "lighten") || Object.hasOwn(fill, "darken")) continue;
|
|
4486
5143
|
const solid = (fill.type === "solid" || fill.type === void 0) && fill.color !== void 0 && !Object.hasOwn(fill, "gradient") && !Object.hasOwn(fill, "pattern");
|
|
4487
5144
|
const typed = fill.type === "gradient" && isRecord(fill.gradient) || fill.type === "pattern" && isRecord(fill.pattern);
|
|
4488
5145
|
if (!solid && !typed) continue;
|
|
4489
5146
|
const color = typeof fill.color === "string" ? JSON.stringify(fill.color) : '"accent1"';
|
|
4490
|
-
fills.set(
|
|
5147
|
+
fills.set(at3, {
|
|
4491
5148
|
...entry2,
|
|
4492
|
-
path:
|
|
5149
|
+
path: at3,
|
|
4493
5150
|
message: solid ? `A shape's solid fill is the color itself, not an object: write "fill": ${color}.` : `A shape's fill has no "type": write "fill": { ${JSON.stringify(fill.type)}: { ... } }.`,
|
|
4494
5151
|
help: solid ? `Write "fill": ${color}. A fill is "none", a color ("accent1", "#1E40AF", or { "color": "accent1", "lighten": 0.4 }), { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes { "type": "solid", ... }.` : `Remove "type": a fill is told apart by its key, { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes "type".`,
|
|
4495
|
-
fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path:
|
|
5152
|
+
fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path: at3, value: fill.color }] } : { id: "fill-remove-type", title: 'Remove "type"', kind: "patch", safe: false, patch: [{ op: "remove", path: `${at3}/type` }] }]
|
|
4496
5153
|
});
|
|
4497
5154
|
}
|
|
4498
5155
|
if (fills.size) {
|
|
@@ -4500,38 +5157,38 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4500
5157
|
for (let index = 0; index < findings.length; index++) {
|
|
4501
5158
|
const entry2 = findings[index];
|
|
4502
5159
|
if (!schema(entry2)) continue;
|
|
4503
|
-
const
|
|
4504
|
-
if (!
|
|
4505
|
-
if (seen.has(
|
|
5160
|
+
const at3 = [...fills.keys()].find((path) => entry2.path === path || entry2.path.startsWith(`${path}/`));
|
|
5161
|
+
if (!at3) continue;
|
|
5162
|
+
if (seen.has(at3)) {
|
|
4506
5163
|
findings.splice(index--, 1);
|
|
4507
5164
|
continue;
|
|
4508
5165
|
}
|
|
4509
|
-
seen.add(
|
|
4510
|
-
findings[index] = fills.get(
|
|
5166
|
+
seen.add(at3);
|
|
5167
|
+
findings[index] = fills.get(at3);
|
|
4511
5168
|
}
|
|
4512
5169
|
}
|
|
4513
5170
|
const backgrounds = /* @__PURE__ */ new Set();
|
|
4514
5171
|
for (const entry2 of findings) {
|
|
4515
5172
|
if (!schema(entry2)) continue;
|
|
4516
|
-
const
|
|
4517
|
-
if (!
|
|
4518
|
-
const background = valueAt(
|
|
5173
|
+
const at3 = /^((?:.*\/)?design\/background)(?:\/.*)?$/.exec(entry2.path)?.[1];
|
|
5174
|
+
if (!at3 || backgrounds.has(at3)) continue;
|
|
5175
|
+
const background = valueAt(at3), type = isRecord(background) ? background.type : void 0;
|
|
4519
5176
|
if (typeof background === "string" || isRecord(background) && typeof type === "string" && BACKGROUND_TYPES.includes(type)) continue;
|
|
4520
|
-
backgrounds.add(
|
|
5177
|
+
backgrounds.add(at3);
|
|
4521
5178
|
}
|
|
4522
|
-
for (const
|
|
4523
|
-
const background = valueAt(
|
|
4524
|
-
const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path ===
|
|
5179
|
+
for (const at3 of backgrounds) {
|
|
5180
|
+
const background = valueAt(at3), type = isRecord(background) ? background.type : void 0;
|
|
5181
|
+
const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path === at3 || entry2.path.startsWith(`${at3}/`)));
|
|
4525
5182
|
const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
|
|
4526
5183
|
const one = {
|
|
4527
5184
|
...kept,
|
|
4528
|
-
path:
|
|
5185
|
+
path: at3,
|
|
4529
5186
|
message: isRecord(background) ? type === void 0 ? 'A background object needs a "type".' : `${JSON.stringify(type)} is not a background type.` : "This is not a background OPF can read.",
|
|
4530
5187
|
help: BACKGROUND_HELP
|
|
4531
5188
|
};
|
|
4532
5189
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4533
5190
|
const entry2 = findings[index];
|
|
4534
|
-
if (schema(entry2) && (entry2.path ===
|
|
5191
|
+
if (schema(entry2) && (entry2.path === at3 || entry2.path.startsWith(`${at3}/`))) findings.splice(index, 1);
|
|
4535
5192
|
}
|
|
4536
5193
|
findings.splice(first, 0, one);
|
|
4537
5194
|
}
|
|
@@ -4544,8 +5201,8 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4544
5201
|
for (const [index, entry2] of findings.entries()) {
|
|
4545
5202
|
if (!schema(entry2) || entry2.validation?.keyword !== "maximum") continue;
|
|
4546
5203
|
const match2 = /^(\/slides\/\d+\/shapes\/\d+\/at)\/(width|height)$/.exec(entry2.path);
|
|
4547
|
-
const
|
|
4548
|
-
if (!key3 || !isRecord(
|
|
5204
|
+
const at3 = match2?.[1] ? valueAt(match2[1]) : void 0, key3 = match2?.[2], size = key3 && isRecord(at3) ? at3[key3] : void 0;
|
|
5205
|
+
if (!key3 || !isRecord(at3) || typeof size !== "number" || !(size > 8 && size <= 1280) || Object.hasOwn(at3, `${key3}Px`)) continue;
|
|
4549
5206
|
const px = `${key3}Px`;
|
|
4550
5207
|
findings[index] = {
|
|
4551
5208
|
...entry2,
|
|
@@ -4561,7 +5218,7 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4561
5218
|
if (isRecord(payload) && payload.type === "list" && Object.hasOwn(payload, "bullets")) findings.splice(index, 1);
|
|
4562
5219
|
}
|
|
4563
5220
|
const OPTION_RULES = ["opf/image-option-unsupported-payload", "opf/shape-option-unsupported-payload", "opf/caption-unsupported-payload"];
|
|
4564
|
-
const optionDefinition = (entry2) => entry2.validation?.keyword === "required" && /^must have required property '(?:image|shape|path|chart|table|video|diagram)'/.test(entry2.message) || entry2.validation?.keyword === "not" && entry2.message === "must NOT be valid" || (entry2.validation?.keyword === "anyOf" || entry2.validation?.keyword === "oneOf") && /must match a schema in anyOf|must match exactly one schema/.test(entry2.message);
|
|
5221
|
+
const optionDefinition = (entry2) => entry2.validation?.keyword === "required" && /^must have required property '(?:image|shape|path|chart|table|video|embed|diagram)'/.test(entry2.message) || entry2.validation?.keyword === "not" && entry2.message === "must NOT be valid" || (entry2.validation?.keyword === "anyOf" || entry2.validation?.keyword === "oneOf") && /must match a schema in anyOf|must match exactly one schema/.test(entry2.message);
|
|
4565
5222
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4566
5223
|
const entry2 = findings[index];
|
|
4567
5224
|
if (!schema(entry2) || !optionDefinition(entry2)) continue;
|
|
@@ -4575,8 +5232,8 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4575
5232
|
const value = valueAt(entry2.path);
|
|
4576
5233
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value)) payloadSlots.set(entry2.path, value);
|
|
4577
5234
|
}
|
|
4578
|
-
for (const [
|
|
4579
|
-
const first = findings.findIndex((entry2) => schema(entry2) && entry2.path ===
|
|
5235
|
+
for (const [at3, value] of payloadSlots) {
|
|
5236
|
+
const first = findings.findIndex((entry2) => schema(entry2) && entry2.path === at3);
|
|
4580
5237
|
const text2 = typeof value === "string";
|
|
4581
5238
|
const write = text2 ? `{ "text": ${JSON.stringify(value)} }` : Array.isArray(value) ? '{ "items": [ ... ] } for a list, or { "blocks": [ ... ] } for several blocks' : '{ "text": "..." }';
|
|
4582
5239
|
const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
|
|
@@ -4584,11 +5241,11 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4584
5241
|
...kept,
|
|
4585
5242
|
message: `A block holds a content payload (an object), not ${text2 ? "a bare string" : Array.isArray(value) ? "a list" : "a " + typeof value}.`,
|
|
4586
5243
|
help: `Write ${write}. A payload names its kind by its key: "text", "items" (a list), "image", "chart", "table", or "blocks" to stack several; see docs/dynamic-composition.md.`,
|
|
4587
|
-
...text2 ? { fixes: [{ id: "wrap-text", title: 'Write the string as { "text": ... }', kind: "patch", safe: false, patch: [{ op: "replace", path:
|
|
5244
|
+
...text2 ? { fixes: [{ id: "wrap-text", title: 'Write the string as { "text": ... }', kind: "patch", safe: false, patch: [{ op: "replace", path: at3, value: { text: value } }] }] } : {}
|
|
4588
5245
|
};
|
|
4589
5246
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4590
5247
|
const entry2 = findings[index];
|
|
4591
|
-
if (schema(entry2) && entry2.path ===
|
|
5248
|
+
if (schema(entry2) && entry2.path === at3) findings.splice(index, 1);
|
|
4592
5249
|
}
|
|
4593
5250
|
findings.splice(first, 0, one);
|
|
4594
5251
|
}
|
|
@@ -4596,7 +5253,7 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4596
5253
|
function collapseChartShape(document, findings) {
|
|
4597
5254
|
const chartAt = (path) => {
|
|
4598
5255
|
let node = document;
|
|
4599
|
-
for (const
|
|
5256
|
+
for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
|
|
4600
5257
|
return node;
|
|
4601
5258
|
};
|
|
4602
5259
|
const collapsed = /* @__PURE__ */ new Set();
|
|
@@ -4618,8 +5275,8 @@ function collapseChartShape(document, findings) {
|
|
|
4618
5275
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4619
5276
|
const entry2 = findings[index];
|
|
4620
5277
|
if (entry2?.ruleId !== "opf/schema" || entry2.validation?.keyword !== "additionalProperties") continue;
|
|
4621
|
-
const
|
|
4622
|
-
if (collapsed.has(entry2.path.slice(0,
|
|
5278
|
+
const at3 = entry2.path.lastIndexOf("/");
|
|
5279
|
+
if (collapsed.has(entry2.path.slice(0, at3)) && FOREIGN_CHART_KEYS.includes(entry2.path.slice(at3 + 1))) findings.splice(index, 1);
|
|
4623
5280
|
}
|
|
4624
5281
|
}
|
|
4625
5282
|
function engineFindings(document, engine, enabled) {
|
|
@@ -4652,6 +5309,12 @@ function engineFindings(document, engine, enabled) {
|
|
|
4652
5309
|
const found = issueFinding(issue2, ruleId, "presentation", "", "document", code2 === "variable-group-omitted" ? "info" : "warning");
|
|
4653
5310
|
const help = HELP[code2];
|
|
4654
5311
|
if (help) found.help = help;
|
|
5312
|
+
if (code2 === "data-cell-type") {
|
|
5313
|
+
const fix = suggestCellTypeFix(document, issue2.path, issue2.params.aggregate === true);
|
|
5314
|
+
if (fix) found.fixes = [{ id: "store-cell-type", title: fix.title, kind: "patch", safe: true, patch: fix.patches }];
|
|
5315
|
+
}
|
|
5316
|
+
const metricFix = issue2.params.fix;
|
|
5317
|
+
if (code2 === "metric-data-stale" && metricFix) found.fixes = [{ id: "update-metric-data", title: metricFix.title, kind: "patch", safe: true, patch: metricFix.patch }];
|
|
4655
5318
|
if (code2 === "shape-anchor-size-unit") {
|
|
4656
5319
|
const key3 = String(issue2.params.key), px = `${key3}Px`;
|
|
4657
5320
|
found.help = `Did you mean "${px}"? "${key3}" is a fraction of the block.`;
|
|
@@ -4768,14 +5431,23 @@ function contentReferenceFindings(document, options2, findings) {
|
|
|
4768
5431
|
const stale = embeddedInvalid && site.kind === "layouts" ? staleLayoutCopy(document, embeddedInvalid.group, embeddedInvalid.id, options2) : void 0;
|
|
4769
5432
|
const diagnostic = unresolvedReference(document, site.kind, site.reference, path, options2);
|
|
4770
5433
|
if (removedLayoutAuto(site.kind, site.reference)) {
|
|
5434
|
+
const dropRecord = embeddedInvalid !== void 0 && embeddedInvalid.id === "auto" && lastLayoutAutoSite(document, embeddedInvalid.group, options2, site.path);
|
|
4771
5435
|
findings.push(
|
|
4772
5436
|
finding("opf/unresolved-reference", {
|
|
4773
5437
|
path,
|
|
4774
5438
|
message: diagnostic.message,
|
|
4775
|
-
help:
|
|
5439
|
+
help: `OPF 0.35 removed layout "auto". Delete the layout key: a slide without one is composed automatically, which is what "auto" did.${dropRecord ? ` The fix also removes the embedded layout "auto" in catalogs.${embeddedInvalid.group}, which fails the layout schema and which no slide names after it.` : ""}`,
|
|
4776
5440
|
definition: `${schemas.presentation.$id}#/$defs/Slide`,
|
|
4777
5441
|
lookup: ["opf", "catalog", site.kind],
|
|
4778
|
-
fixes: [
|
|
5442
|
+
fixes: [
|
|
5443
|
+
{
|
|
5444
|
+
id: "remove-layout-auto",
|
|
5445
|
+
title: dropRecord ? 'Delete layout (automatic composition) and the embedded layout record "auto"' : "Delete layout (automatic composition)",
|
|
5446
|
+
kind: "patch",
|
|
5447
|
+
safe: true,
|
|
5448
|
+
patch: [{ op: "remove", path }, ...dropRecord ? [{ op: "remove", path: pointer4(["catalogs", embeddedInvalid.group, "layouts", "auto"]) }] : []]
|
|
5449
|
+
}
|
|
5450
|
+
]
|
|
4779
5451
|
})
|
|
4780
5452
|
);
|
|
4781
5453
|
continue;
|
|
@@ -4803,14 +5475,14 @@ function contentReferenceFindings(document, options2, findings) {
|
|
|
4803
5475
|
continue;
|
|
4804
5476
|
}
|
|
4805
5477
|
if (embeddedInvalid) {
|
|
4806
|
-
const
|
|
5478
|
+
const at3 = pointer4(["catalogs", embeddedInvalid.group, site.kind, embeddedInvalid.id]);
|
|
4807
5479
|
const fix = stale ? staleCopyFix(document, stale, options2) : void 0;
|
|
4808
5480
|
const noun = KIND_SINGULAR[site.kind];
|
|
4809
5481
|
findings.push(
|
|
4810
5482
|
finding("opf/unresolved-reference", {
|
|
4811
5483
|
path,
|
|
4812
|
-
message: `${noun[0].toUpperCase()}${noun.slice(1)} '${site.reference}' is embedded in catalogs.${embeddedInvalid.group}, but the record fails the ${noun} schema: see the opf/catalog-record findings at ${
|
|
4813
|
-
help: stale ? staleCopyCause(stale) : `Fix the record with the fixes of its findings at ${
|
|
5484
|
+
message: `${noun[0].toUpperCase()}${noun.slice(1)} '${site.reference}' is embedded in catalogs.${embeddedInvalid.group}, but the record fails the ${noun} schema: see the opf/catalog-record findings at ${at3}.`,
|
|
5485
|
+
help: stale ? staleCopyCause(stale) : `Fix the record with the fixes of its findings at ${at3}, then validate again.`,
|
|
4814
5486
|
definition: `${schemas.presentation.$id}#/$defs/Catalogs`,
|
|
4815
5487
|
lookup: ["opf", "catalog", site.kind],
|
|
4816
5488
|
...fix ? { fixes: [fix] } : {}
|
|
@@ -4958,8 +5630,8 @@ function narrativeFindings(document, options2) {
|
|
|
4958
5630
|
);
|
|
4959
5631
|
}
|
|
4960
5632
|
for (const [group, value] of Object.entries(object2(document.catalogs) ? document.catalogs : {}))
|
|
4961
|
-
for (const [id,
|
|
4962
|
-
if (durationRangeInverted(
|
|
5633
|
+
for (const [id, record2] of Object.entries(object2(value) && object2(value.narratives) ? value.narratives : {})) {
|
|
5634
|
+
if (durationRangeInverted(record2))
|
|
4963
5635
|
findings.push(
|
|
4964
5636
|
finding("opf/narrative-duration-range", {
|
|
4965
5637
|
path: pointer4(["catalogs", group, "narratives", id, "duration"]),
|
|
@@ -5021,6 +5693,17 @@ function contractFindings(document, contracts) {
|
|
|
5021
5693
|
}
|
|
5022
5694
|
return findings;
|
|
5023
5695
|
}
|
|
5696
|
+
function lastLayoutAutoSite(document, group, options2, last) {
|
|
5697
|
+
let latest;
|
|
5698
|
+
for (const site of catalogReferenceSites(document)) {
|
|
5699
|
+
if (site.kind !== "layouts") continue;
|
|
5700
|
+
const found = resolveReference(document, site.kind, site.reference, { ...options2, ...site.group !== void 0 ? { group: site.group } : {} });
|
|
5701
|
+
if (found?.origin !== "document" || found.group !== group || found.id !== "auto") continue;
|
|
5702
|
+
if (!removedLayoutAuto(site.kind, site.reference)) return false;
|
|
5703
|
+
latest = site.path;
|
|
5704
|
+
}
|
|
5705
|
+
return latest !== void 0 && latest.length === last.length && latest.every((key3, at3) => key3 === last[at3]);
|
|
5706
|
+
}
|
|
5024
5707
|
|
|
5025
5708
|
// src/patch.ts
|
|
5026
5709
|
var OPFPatchError = class extends Error {
|
|
@@ -5119,10 +5802,10 @@ function indexOfId(array, id) {
|
|
|
5119
5802
|
}
|
|
5120
5803
|
return found;
|
|
5121
5804
|
}
|
|
5122
|
-
function uniqueIdAt(array,
|
|
5123
|
-
const item = array[
|
|
5805
|
+
function uniqueIdAt(array, at3) {
|
|
5806
|
+
const item = array[at3];
|
|
5124
5807
|
if (!isObject2(item) || !own2(item, "id") || typeof item.id !== "string" || item.id === "") return void 0;
|
|
5125
|
-
return indexOfId(array, item.id) ===
|
|
5808
|
+
return indexOfId(array, item.id) === at3 ? item.id : void 0;
|
|
5126
5809
|
}
|
|
5127
5810
|
function resolveTokens(document, tokens, pointer5) {
|
|
5128
5811
|
const out = [];
|
|
@@ -5130,10 +5813,10 @@ function resolveTokens(document, tokens, pointer5) {
|
|
|
5130
5813
|
for (const token of tokens) {
|
|
5131
5814
|
let resolved2 = token;
|
|
5132
5815
|
if (walking && Array.isArray(cursor) && isIdToken(token)) {
|
|
5133
|
-
const
|
|
5134
|
-
if (
|
|
5135
|
-
if (
|
|
5136
|
-
resolved2 = String(
|
|
5816
|
+
const at3 = indexOfId(cursor, token.slice(1));
|
|
5817
|
+
if (at3 === -1) throw new OPFPatchError("patch-id-not-found", `No element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
|
|
5818
|
+
if (at3 === -2) throw new OPFPatchError("patch-id-ambiguous", `More than one element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
|
|
5819
|
+
resolved2 = String(at3);
|
|
5137
5820
|
}
|
|
5138
5821
|
out.push(resolved2);
|
|
5139
5822
|
if (walking) {
|
|
@@ -5174,16 +5857,16 @@ function readPointer(document, pointer5) {
|
|
|
5174
5857
|
let value = document;
|
|
5175
5858
|
for (const token of tokens) {
|
|
5176
5859
|
if (Array.isArray(value)) {
|
|
5177
|
-
let
|
|
5860
|
+
let at3;
|
|
5178
5861
|
if (isIdToken(token)) {
|
|
5179
|
-
|
|
5180
|
-
if (
|
|
5862
|
+
at3 = indexOfId(value, token.slice(1));
|
|
5863
|
+
if (at3 < 0) return { found: false };
|
|
5181
5864
|
} else {
|
|
5182
5865
|
if (!INDEX_TOKEN.test(token)) return { found: false };
|
|
5183
|
-
|
|
5866
|
+
at3 = Number(token);
|
|
5184
5867
|
}
|
|
5185
|
-
if (!Number.isSafeInteger(
|
|
5186
|
-
value = value[
|
|
5868
|
+
if (!Number.isSafeInteger(at3) || at3 >= value.length) return { found: false };
|
|
5869
|
+
value = value[at3];
|
|
5187
5870
|
} else if (value && typeof value === "object" && own2(value, token)) value = value[token];
|
|
5188
5871
|
else return { found: false };
|
|
5189
5872
|
}
|
|
@@ -5201,9 +5884,9 @@ var hasPointer = (document, pointer5) => readPointer(document, pointer5).found;
|
|
|
5201
5884
|
function arrayIndex(token, length, allowEnd, path) {
|
|
5202
5885
|
if (allowEnd && token === "-") return length;
|
|
5203
5886
|
if (!INDEX_TOKEN.test(token)) throw new OPFPatchError("invalid-array-index", `Invalid array index: ${token}`, { path });
|
|
5204
|
-
const
|
|
5205
|
-
if (!Number.isSafeInteger(
|
|
5206
|
-
return
|
|
5887
|
+
const at3 = Number(token);
|
|
5888
|
+
if (!Number.isSafeInteger(at3) || at3 > length || !allowEnd && at3 >= length) throw new OPFPatchError("invalid-array-index", `Array index out of bounds: ${token}`, { path });
|
|
5889
|
+
return at3;
|
|
5207
5890
|
}
|
|
5208
5891
|
function normalizePatch(patch2) {
|
|
5209
5892
|
if (!Array.isArray(patch2)) throw new OPFPatchError("invalid-patch", "A JSON Patch must be an array of operations.");
|
|
@@ -5249,14 +5932,14 @@ function addAt(document, path, value) {
|
|
|
5249
5932
|
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
|
|
5250
5933
|
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
5251
5934
|
if (Array.isArray(parent)) {
|
|
5252
|
-
const
|
|
5253
|
-
parent.splice(
|
|
5254
|
-
const pointer6 = formatPointer([...tokens.slice(0, -1),
|
|
5935
|
+
const at3 = arrayIndex(key3, parent.length, true, path);
|
|
5936
|
+
parent.splice(at3, 0, clone(value));
|
|
5937
|
+
const pointer6 = formatPointer([...tokens.slice(0, -1), at3]);
|
|
5255
5938
|
return { document, inverse: { op: "remove", path: pointer6 }, pointer: pointer6 };
|
|
5256
5939
|
}
|
|
5257
|
-
const
|
|
5258
|
-
const previous = own2(
|
|
5259
|
-
Object.defineProperty(
|
|
5940
|
+
const record2 = parent;
|
|
5941
|
+
const previous = own2(record2, key3) ? record2[key3] : NONE;
|
|
5942
|
+
Object.defineProperty(record2, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
5260
5943
|
const pointer5 = formatPointer(tokens);
|
|
5261
5944
|
return { document, inverse: previous === NONE ? { op: "remove", path: pointer5 } : { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5262
5945
|
}
|
|
@@ -5267,15 +5950,15 @@ function replaceAt(document, path, value) {
|
|
|
5267
5950
|
let previous;
|
|
5268
5951
|
let pointer5 = formatPointer(tokens);
|
|
5269
5952
|
if (Array.isArray(parent)) {
|
|
5270
|
-
const
|
|
5271
|
-
previous = parent[
|
|
5272
|
-
parent[
|
|
5273
|
-
pointer5 = formatPointer([...tokens.slice(0, -1),
|
|
5953
|
+
const at3 = arrayIndex(key3, parent.length, false, path);
|
|
5954
|
+
previous = parent[at3];
|
|
5955
|
+
parent[at3] = clone(value);
|
|
5956
|
+
pointer5 = formatPointer([...tokens.slice(0, -1), at3]);
|
|
5274
5957
|
} else {
|
|
5275
|
-
const
|
|
5276
|
-
if (!own2(
|
|
5277
|
-
previous =
|
|
5278
|
-
Object.defineProperty(
|
|
5958
|
+
const record2 = parent;
|
|
5959
|
+
if (!own2(record2, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
5960
|
+
previous = record2[key3];
|
|
5961
|
+
Object.defineProperty(record2, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
5279
5962
|
}
|
|
5280
5963
|
return { document, inverse: { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5281
5964
|
}
|
|
@@ -5285,16 +5968,16 @@ function removeAt(document, path) {
|
|
|
5285
5968
|
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
5286
5969
|
let previous;
|
|
5287
5970
|
if (Array.isArray(parent)) {
|
|
5288
|
-
const
|
|
5289
|
-
previous = parent[
|
|
5290
|
-
parent.splice(
|
|
5291
|
-
const pointer6 = formatPointer([...tokens.slice(0, -1),
|
|
5971
|
+
const at3 = arrayIndex(key3, parent.length, false, path);
|
|
5972
|
+
previous = parent[at3];
|
|
5973
|
+
parent.splice(at3, 1);
|
|
5974
|
+
const pointer6 = formatPointer([...tokens.slice(0, -1), at3]);
|
|
5292
5975
|
return { document, inverse: { op: "add", path: pointer6, value: clone(previous) }, pointer: pointer6 };
|
|
5293
5976
|
}
|
|
5294
|
-
const
|
|
5295
|
-
if (!own2(
|
|
5296
|
-
previous =
|
|
5297
|
-
delete
|
|
5977
|
+
const record2 = parent;
|
|
5978
|
+
if (!own2(record2, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
5979
|
+
previous = record2[key3];
|
|
5980
|
+
delete record2[key3];
|
|
5298
5981
|
const pointer5 = formatPointer(tokens);
|
|
5299
5982
|
return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5300
5983
|
}
|
|
@@ -5462,7 +6145,7 @@ var CATALOG_KIND = /* @__PURE__ */ Symbol.for("@openpresentation/opf:catalog-kin
|
|
|
5462
6145
|
var catalogKindOfNode = /* @__PURE__ */ new WeakMap();
|
|
5463
6146
|
var kindOfNode = (node) => catalogKindOfNode.get(node) ?? node[CATALOG_KIND];
|
|
5464
6147
|
function splitOpfPath(path) {
|
|
5465
|
-
if (Array.isArray(path)) return path.map((
|
|
6148
|
+
if (Array.isArray(path)) return path.map((segment2) => String(segment2));
|
|
5466
6149
|
if (typeof path !== "string") throw new TypeError("An OPF path must be a string or an array of segments.");
|
|
5467
6150
|
if (path === "") return [];
|
|
5468
6151
|
if (path.startsWith("/")) return parsePointer(path);
|
|
@@ -5554,13 +6237,13 @@ function score2(schema, value) {
|
|
|
5554
6237
|
if (own3(schema, "const")) return JSON.stringify(schema.const) === JSON.stringify(value) ? 100 : -100;
|
|
5555
6238
|
if (schema.enum && !schema.enum.includes(value)) return -100;
|
|
5556
6239
|
let result = 1;
|
|
5557
|
-
const
|
|
6240
|
+
const record2 = value;
|
|
5558
6241
|
for (const [key3, child] of Object.entries(schema.properties ?? {})) {
|
|
5559
|
-
if (!
|
|
5560
|
-
if (own3(child, "const")) result +=
|
|
6242
|
+
if (!record2 || !own3(record2, key3)) continue;
|
|
6243
|
+
if (own3(child, "const")) result += record2[key3] === child.const ? 100 : -1e3;
|
|
5561
6244
|
else result += 1;
|
|
5562
6245
|
}
|
|
5563
|
-
for (const key3 of schema.required ?? []) if (!
|
|
6246
|
+
for (const key3 of schema.required ?? []) if (!record2 || !own3(record2, key3)) result -= 2;
|
|
5564
6247
|
return result;
|
|
5565
6248
|
}
|
|
5566
6249
|
function activeSchema(schema, value, root = presentationSchema) {
|
|
@@ -5911,9 +6594,9 @@ function applyTextEdits(text2, edits) {
|
|
|
5911
6594
|
function rememberByText(read, size = 2) {
|
|
5912
6595
|
const kept = [];
|
|
5913
6596
|
return (text2) => {
|
|
5914
|
-
const
|
|
5915
|
-
if (
|
|
5916
|
-
const [entry2] = kept.splice(
|
|
6597
|
+
const at3 = kept.findIndex((entry2) => entry2.text === text2);
|
|
6598
|
+
if (at3 >= 0) {
|
|
6599
|
+
const [entry2] = kept.splice(at3, 1);
|
|
5917
6600
|
kept.unshift(entry2);
|
|
5918
6601
|
return entry2.value;
|
|
5919
6602
|
}
|
|
@@ -6708,10 +7391,10 @@ var Analyzer = class {
|
|
|
6708
7391
|
})();
|
|
6709
7392
|
const hint = valueHint(path);
|
|
6710
7393
|
const gap = this.text[colon.end] === " " || this.text[colon.end] === " " ? 0 : 1;
|
|
6711
|
-
const
|
|
6712
|
-
const edits = [{ offset:
|
|
6713
|
-
if (needsComma) edits.push({ offset:
|
|
6714
|
-
const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret:
|
|
7394
|
+
const at3 = colon.end + (gap === 0 ? 1 : 0);
|
|
7395
|
+
const edits = [{ offset: at3, length: 0, insert: `${gap ? " " : ""}${hint.insert}` }];
|
|
7396
|
+
if (needsComma) edits.push({ offset: at3, length: 0, insert: "," });
|
|
7397
|
+
const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret: at3 + (gap ? 1 : 0) + hint.caret }];
|
|
6715
7398
|
fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
|
|
6716
7399
|
this.structural({
|
|
6717
7400
|
code: "missing-value",
|
|
@@ -7078,9 +7761,9 @@ function slideRef(finding2, helpers) {
|
|
|
7078
7761
|
if (typeof layout === "string" && layout) return `Slide ${number} (layout ${code(layout)})`;
|
|
7079
7762
|
return `Slide ${number}`;
|
|
7080
7763
|
}
|
|
7081
|
-
var lastName = (segments) => [...segments].reverse().find((
|
|
7764
|
+
var lastName = (segments) => [...segments].reverse().find((segment2) => !isIndex(segment2));
|
|
7082
7765
|
function dotted(segments) {
|
|
7083
|
-
return segments.reduce((out,
|
|
7766
|
+
return segments.reduce((out, segment2) => isIndex(segment2) ? `${out}[${segment2}]` : out ? `${out}.${segment2}` : segment2, "");
|
|
7084
7767
|
}
|
|
7085
7768
|
function keysAt(helpers, path) {
|
|
7086
7769
|
const value = helpers.valueAt(path);
|
|
@@ -7116,7 +7799,7 @@ function chooseNext(value, candidates, alternative = "", max = 3) {
|
|
|
7116
7799
|
return alternative ? sentence(alternative) : "choose a different value.";
|
|
7117
7800
|
}
|
|
7118
7801
|
function kindPhrase(kind) {
|
|
7119
|
-
const phrases = { text: "text", code: "code", list: "a list", chart: "a chart", table: "a table", image: "an image", video: "a video", metric: "a metric", quote: "a quote", timeline: "a timeline", shape: "a shape", group: "a group" };
|
|
7802
|
+
const phrases = { text: "text", code: "code", list: "a list", chart: "a chart", table: "a table", image: "an image", video: "a video", embed: "an embed", metric: "a metric", quote: "a quote", timeline: "a timeline", shape: "a shape", group: "a group" };
|
|
7120
7803
|
return phrases[kind] ?? `${/^[aeiou]/i.test(kind) ? "an" : "a"} ${kind}`;
|
|
7121
7804
|
}
|
|
7122
7805
|
function freshName(base, taken = []) {
|
|
@@ -7127,7 +7810,7 @@ function freshName(base, taken = []) {
|
|
|
7127
7810
|
}
|
|
7128
7811
|
return `${base}-2`;
|
|
7129
7812
|
}
|
|
7130
|
-
var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote", "timeline", "diagram", "items", "bullets", "text"];
|
|
7813
|
+
var BLOCK_KINDS = ["chart", "image", "video", "embed", "table", "code", "metric", "quote", "timeline", "diagram", "items", "bullets", "text"];
|
|
7131
7814
|
function blockKind(node) {
|
|
7132
7815
|
if (!isRecord2(node)) return void 0;
|
|
7133
7816
|
if (typeof node.type === "string" && node.type !== "group") return node.type;
|
|
@@ -7182,7 +7865,7 @@ var textOnImage = (finding2) => {
|
|
|
7182
7865
|
if (best !== void 0)
|
|
7183
7866
|
return {
|
|
7184
7867
|
message: `This text is too faint on the picture: at most ${num(best, 1)}:1 over any part of it here${needed !== void 0 ? `, and ${num(needed)}:1 is needed` : ""}.`,
|
|
7185
|
-
next: `set the background's ${code("
|
|
7868
|
+
next: `set the background's ${code("appearance")} so the text color follows the picture, or give the text a readable color.`
|
|
7186
7869
|
};
|
|
7187
7870
|
if (scrim !== void 0)
|
|
7188
7871
|
return {
|
|
@@ -7304,10 +7987,10 @@ var missingLanguage = (_finding, context, helpers) => ({
|
|
|
7304
7987
|
next: (context.format ?? helpers.format) === "json" ? `add ${code('"language": "en-US"')} (or the language the text is written in) to the deck.` : `add ${code("language: en-US")} (or the language the text is written in) to the deck.`
|
|
7305
7988
|
});
|
|
7306
7989
|
var chartOptionAdapted = (finding2, _context, helpers) => {
|
|
7307
|
-
const
|
|
7308
|
-
const option =
|
|
7990
|
+
const at3 = helpers.segments.indexOf("chart");
|
|
7991
|
+
const option = at3 >= 0 ? helpers.segments.slice(at3 + 1).join(".") : lastName(helpers.segments) ?? "";
|
|
7309
7992
|
if (!option) return void 0;
|
|
7310
|
-
const type =
|
|
7993
|
+
const type = at3 >= 0 ? helpers.valueAt([...helpers.segments.slice(0, at3 + 1), "type"]) : void 0;
|
|
7311
7994
|
const typeName = typeof type === "string" ? type : match(finding2.message, /^A '(.+?)' chart/)?.[1];
|
|
7312
7995
|
const adaptation = finding2.message.includes(";") ? cap(finding2.message.slice(finding2.message.indexOf(";") + 1).trim()) : "";
|
|
7313
7996
|
return {
|
|
@@ -7334,7 +8017,7 @@ var layoutFailed = (finding2, _context, helpers) => {
|
|
|
7334
8017
|
next: "fix the composition setting or content named above."
|
|
7335
8018
|
};
|
|
7336
8019
|
};
|
|
7337
|
-
var
|
|
8020
|
+
var minFontSizePx = (finding2) => {
|
|
7338
8021
|
const size = measuredNumber(finding2, "sizePt");
|
|
7339
8022
|
const minimum = measuredNumber(finding2, "minimumPt");
|
|
7340
8023
|
if (size === void 0 || minimum === void 0) return void 0;
|
|
@@ -7350,8 +8033,8 @@ function regionNamesOf(slideLayout, helpers) {
|
|
|
7350
8033
|
const colon = slideLayout.indexOf(":");
|
|
7351
8034
|
const group = colon > 0 ? slideLayout.slice(0, colon) : void 0;
|
|
7352
8035
|
const id = colon > 0 ? slideLayout.slice(colon + 1) : slideLayout;
|
|
7353
|
-
const
|
|
7354
|
-
if (!
|
|
8036
|
+
const record2 = (group ? [group] : ["custom", "default"]).map((name) => helpers.valueAt(["catalogs", name, "layouts", id])).find(isRecord2);
|
|
8037
|
+
if (!record2) return void 0;
|
|
7355
8038
|
const names2 = [];
|
|
7356
8039
|
const walk2 = (list) => {
|
|
7357
8040
|
if (!Array.isArray(list)) return;
|
|
@@ -7361,7 +8044,7 @@ function regionNamesOf(slideLayout, helpers) {
|
|
|
7361
8044
|
walk2(entry2.regions);
|
|
7362
8045
|
}
|
|
7363
8046
|
};
|
|
7364
|
-
walk2(
|
|
8047
|
+
walk2(record2.regions);
|
|
7365
8048
|
return { id: slideLayout, names: names2 };
|
|
7366
8049
|
}
|
|
7367
8050
|
var regionUnknown = (finding2, _context, helpers) => {
|
|
@@ -7430,9 +8113,9 @@ var regionFull = (finding2) => {
|
|
|
7430
8113
|
var layoutUnplaced = (finding2, _context, helpers) => {
|
|
7431
8114
|
const kind = blockKind(helpers.valueAt(helpers.segments));
|
|
7432
8115
|
const what = kind ? `this ${kind} block` : "this block";
|
|
7433
|
-
const
|
|
8116
|
+
const overflow2 = match(finding2.message, /drawn in '(.+?)' beyond its (\d+) block/);
|
|
7434
8117
|
return {
|
|
7435
|
-
message:
|
|
8118
|
+
message: overflow2 ? `No region has room for ${what}; it is drawn in ${code(overflow2[1])}, beyond its ${overflow2[2]} block${overflow2[2] === "1" ? "" : "s"}.` : `No region has room for ${what}; it is drawn in the overflow area.`,
|
|
7436
8119
|
next: "paginate the slide, choose a layout with more room, or remove a block."
|
|
7437
8120
|
};
|
|
7438
8121
|
};
|
|
@@ -7481,6 +8164,27 @@ var textShrunk2 = (finding2) => {
|
|
|
7481
8164
|
next: `split it with ${code("opf paginate")}, move detail to the speaker notes, or shorten the text.`
|
|
7482
8165
|
};
|
|
7483
8166
|
};
|
|
8167
|
+
var variableOverflow2 = (finding2) => {
|
|
8168
|
+
const id = match(finding2.message, /^'([a-z][a-z0-9-]*)'/)?.[1];
|
|
8169
|
+
if (!id) return void 0;
|
|
8170
|
+
const lines = measuredNumber(finding2, "lines");
|
|
8171
|
+
const maxLines = measuredNumber(finding2, "maxLines");
|
|
8172
|
+
if (lines !== void 0 && maxLines !== void 0) {
|
|
8173
|
+
return {
|
|
8174
|
+
message: `Variable ${code(id)} takes ${lines} lines${onSlide(finding2)}, over its ${code("maxLines")} of ${maxLines}.`,
|
|
8175
|
+
next: `shorten the value, draw it in a wider place, or raise ${code("maxLines")} if the slide has the room.`
|
|
8176
|
+
};
|
|
8177
|
+
}
|
|
8178
|
+
const characters = measuredNumber(finding2, "characters");
|
|
8179
|
+
const maxLength = measuredNumber(finding2, "maxLength");
|
|
8180
|
+
if (characters !== void 0 && maxLength !== void 0) {
|
|
8181
|
+
return { message: `Variable ${code(id)} has ${characters} characters, over its ${code("maxLength")} of ${maxLength}.`, next: `shorten the value to ${maxLength} characters or fewer, or raise ${code("maxLength")}.` };
|
|
8182
|
+
}
|
|
8183
|
+
const items = measuredNumber(finding2, "items");
|
|
8184
|
+
const maxItems = measuredNumber(finding2, "maxItems");
|
|
8185
|
+
if (items === void 0 || maxItems === void 0) return void 0;
|
|
8186
|
+
return { message: `Variable ${code(id)} has ${items} items, over its ${code("maxItems")} of ${maxItems}.`, next: `give it ${maxItems} items or fewer, or raise ${code("maxItems")}.` };
|
|
8187
|
+
};
|
|
7484
8188
|
var centeredBody2 = (finding2) => {
|
|
7485
8189
|
const lines = measuredNumber(finding2, "lines");
|
|
7486
8190
|
const characters = measuredNumber(finding2, "characters");
|
|
@@ -7522,17 +8226,6 @@ var layoutMonotony2 = (finding2) => {
|
|
|
7522
8226
|
next: "give some of them the layout their content asks for (a comparison, a chart, a statement, a picture), or merge or split slides."
|
|
7523
8227
|
};
|
|
7524
8228
|
};
|
|
7525
|
-
var straightQuotes2 = (finding2) => {
|
|
7526
|
-
const open = measuredText(finding2, "open");
|
|
7527
|
-
const close = measuredText(finding2, "close");
|
|
7528
|
-
const text2 = unquote(match(finding2.message, /: ("(?:[^"\\]|\\.)*")\.$/)?.[1]);
|
|
7529
|
-
if (!open || !close) return void 0;
|
|
7530
|
-
const fix = finding2.fixes?.find((entry2) => entry2.id === "use-typographic-quotes");
|
|
7531
|
-
return {
|
|
7532
|
-
message: `${text2 ? `${code(brief(text2, 50))} uses` : "This text uses"} straight quotation marks; this deck's language uses ${open}\u2026${close}.`,
|
|
7533
|
-
next: fix ? `apply the quick fix, or type ${open} and ${close} instead.` : `type ${open} and ${close} instead, and the matching single marks.`
|
|
7534
|
-
};
|
|
7535
|
-
};
|
|
7536
8229
|
var chartDualAxis2 = (finding2) => {
|
|
7537
8230
|
const names2 = match(finding2.message, /^The combo chart plots (.+) on a second value axis/)?.[1];
|
|
7538
8231
|
return {
|
|
@@ -7554,10 +8247,45 @@ var chartValueNotNumeric = (finding2) => {
|
|
|
7554
8247
|
const fix = finding2.fixes?.find((entry2) => entry2.id === "store-chart-numbers");
|
|
7555
8248
|
if (!value) return void 0;
|
|
7556
8249
|
return {
|
|
7557
|
-
message: `${code(value)} is text, so it is plotted as a gap.`,
|
|
7558
|
-
next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}` : `write a number (12, -3.5, 1e6) and put units, currency or percent in the column ${code("format")}.`
|
|
8250
|
+
message: `${code(value)} is text, so it is plotted as a gap.`,
|
|
8251
|
+
next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}` : `write a number (12, -3.5, 1e6) and put units, currency or percent in the column ${code("format")}.`
|
|
8252
|
+
};
|
|
8253
|
+
};
|
|
8254
|
+
var dataCellType = (finding2) => {
|
|
8255
|
+
const fix = finding2.fixes?.find((entry2) => entry2.id === "store-cell-type");
|
|
8256
|
+
return {
|
|
8257
|
+
message: keep(cap(finding2.message)),
|
|
8258
|
+
next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}, or change the column's ${code("type")} to what it holds.` : `write the cell as the column declares, or change the column's ${code("type")} to what it holds.`
|
|
7559
8259
|
};
|
|
7560
8260
|
};
|
|
8261
|
+
var datasourceCredentials = (finding2) => ({
|
|
8262
|
+
message: keep(cap(finding2.message)),
|
|
8263
|
+
next: "remove the credential from the data source and keep the secret in your own store; name the connection in `connector` or `extensions`."
|
|
8264
|
+
});
|
|
8265
|
+
var datasetStale = (finding2) => ({
|
|
8266
|
+
message: keep(cap(finding2.message)),
|
|
8267
|
+
next: "take the data from its data source again and update `retrieved`, or change the data source's `refreshEvery`."
|
|
8268
|
+
});
|
|
8269
|
+
var metricDataStale = (finding2) => ({
|
|
8270
|
+
message: keep(cap(finding2.message)),
|
|
8271
|
+
next: "apply the fix, which writes the computed number; or change the data link to compute what the slide says."
|
|
8272
|
+
});
|
|
8273
|
+
var metricDataAggregate = (finding2) => ({
|
|
8274
|
+
message: keep(cap(finding2.message)),
|
|
8275
|
+
next: "use first, last or count, which fit any column, or link a column typed number."
|
|
8276
|
+
});
|
|
8277
|
+
var metricDataEmpty = (finding2) => ({
|
|
8278
|
+
message: keep(cap(finding2.message)),
|
|
8279
|
+
next: "check the filter and the field: a row has to meet the filter and give a usable cell."
|
|
8280
|
+
});
|
|
8281
|
+
var metricDataDelta = (finding2) => ({
|
|
8282
|
+
message: keep(cap(finding2.message)),
|
|
8283
|
+
next: "give the change something to compare with, or write the change in a column and use `field`."
|
|
8284
|
+
});
|
|
8285
|
+
var metricUnitRepeated = (finding2) => ({
|
|
8286
|
+
message: keep(cap(finding2.message)),
|
|
8287
|
+
next: "drop the unit, or take its text out of the number format."
|
|
8288
|
+
});
|
|
7561
8289
|
var chartMappingAdapted = (finding2) => ({
|
|
7562
8290
|
message: keep(cap(finding2.message)),
|
|
7563
8291
|
next: "remove that mapping entry, or name a different column."
|
|
@@ -7566,6 +8294,13 @@ var chartSeriesDropped = (finding2) => ({
|
|
|
7566
8294
|
message: keep(cap(finding2.message)),
|
|
7567
8295
|
next: "use a chart type that plots every series, or one chart per series."
|
|
7568
8296
|
});
|
|
8297
|
+
var embedCredentials = (finding2) => {
|
|
8298
|
+
const part2 = match(finding2.message, /carries what looks like a credential \((.+?)\)\./)?.[1];
|
|
8299
|
+
return {
|
|
8300
|
+
message: `This embed's address carries what looks like a credential${part2 ? ` (${part2})` : ""}, and anyone with the deck can read it.`,
|
|
8301
|
+
next: "take the credential out of `src`: the host that shows the page holds it."
|
|
8302
|
+
};
|
|
8303
|
+
};
|
|
7569
8304
|
var chartHighlightAdapted = (finding2) => {
|
|
7570
8305
|
const name = unquote(match(finding2.message, /^highlight names \w+ ("(?:[^"\\]|\\.)*"), which is not plotted as a series/)?.[1]);
|
|
7571
8306
|
if (!name) return void 0;
|
|
@@ -7574,6 +8309,30 @@ var chartHighlightAdapted = (finding2) => {
|
|
|
7574
8309
|
next: "name a series the chart plots, or remove the entry."
|
|
7575
8310
|
};
|
|
7576
8311
|
};
|
|
8312
|
+
var chartBandsOrder = (finding2) => finding2.message.startsWith("The bands are not in increasing order") ? {
|
|
8313
|
+
message: "The bands are not in increasing order of their `to` values, so they are drawn sorted.",
|
|
8314
|
+
next: "write each band's `to` above the previous one."
|
|
8315
|
+
} : void 0;
|
|
8316
|
+
var chartBandsUnsupported = (finding2) => finding2.message.startsWith("This chart type does not draw bands") ? {
|
|
8317
|
+
message: "This chart type does not draw bands, so they are ignored.",
|
|
8318
|
+
next: "use a bar, column, line, area or bullet chart, or remove the bands."
|
|
8319
|
+
} : void 0;
|
|
8320
|
+
var metricGaugeRange = (finding2) => finding2.message.startsWith("The gauge's") ? {
|
|
8321
|
+
message: finding2.message,
|
|
8322
|
+
next: "write the gauge's max above its min, and keep the value, the target and the bands between them."
|
|
8323
|
+
} : void 0;
|
|
8324
|
+
var metricGaugeValue = (finding2) => finding2.message.startsWith("A gauge needs a number") ? {
|
|
8325
|
+
message: "A gauge needs a number, and this metric's value is text, so it is drawn without its gauge.",
|
|
8326
|
+
next: "give the metric a number value, or remove the gauge."
|
|
8327
|
+
} : void 0;
|
|
8328
|
+
var tableColorScaleNoData = (finding2) => finding2.message.startsWith("The color scale's columns hold no numbers") ? {
|
|
8329
|
+
message: "None of the color scale's columns holds a number, so no cell is shaded.",
|
|
8330
|
+
next: "name columns that hold numbers, or remove the color scale."
|
|
8331
|
+
} : void 0;
|
|
8332
|
+
var tableColorScaleRange = (finding2) => finding2.message.startsWith("The color scale's range is empty") ? {
|
|
8333
|
+
message: "The color scale's range is empty or its center is outside it, so part of the scale is unused.",
|
|
8334
|
+
next: "pin min below max and keep center between them, or leave the range to the data."
|
|
8335
|
+
} : void 0;
|
|
7577
8336
|
var codeHighlightOutOfRange = (finding2) => {
|
|
7578
8337
|
const found = match(finding2.message, /line (\d+) is past the last line \(the code has (\d+) lines?\)/);
|
|
7579
8338
|
if (!found) return void 0;
|
|
@@ -7693,7 +8452,7 @@ var AUDIT_TEXT = {
|
|
|
7693
8452
|
"opf/text-overflow": textOverflow,
|
|
7694
8453
|
"opf/unresolved-content": unresolvedContent,
|
|
7695
8454
|
"opf/layout-failed": layoutFailed,
|
|
7696
|
-
"opf/min-font-size":
|
|
8455
|
+
"opf/min-font-size": minFontSizePx,
|
|
7697
8456
|
"opf/region-unknown": regionUnknown,
|
|
7698
8457
|
"opf/region-kind": regionKind,
|
|
7699
8458
|
"opf/region-full": regionFull,
|
|
@@ -7708,8 +8467,23 @@ var AUDIT_TEXT = {
|
|
|
7708
8467
|
"opf/image-resolution": imageResolution,
|
|
7709
8468
|
"opf/chart-value-not-numeric": chartValueNotNumeric,
|
|
7710
8469
|
"opf/chart-mapping-adapted": chartMappingAdapted,
|
|
8470
|
+
"opf/data-cell-type": dataCellType,
|
|
8471
|
+
"opf/datasource-credentials": datasourceCredentials,
|
|
8472
|
+
"opf/dataset-stale": datasetStale,
|
|
8473
|
+
"opf/metric-data-stale": metricDataStale,
|
|
8474
|
+
"opf/metric-data-aggregate": metricDataAggregate,
|
|
8475
|
+
"opf/metric-data-empty": metricDataEmpty,
|
|
8476
|
+
"opf/metric-data-delta": metricDataDelta,
|
|
8477
|
+
"opf/metric-unit-repeated": metricUnitRepeated,
|
|
7711
8478
|
"opf/chart-highlight-adapted": chartHighlightAdapted,
|
|
8479
|
+
"opf/table-color-scale-no-data": tableColorScaleNoData,
|
|
8480
|
+
"opf/table-color-scale-range": tableColorScaleRange,
|
|
7712
8481
|
"opf/chart-series-dropped": chartSeriesDropped,
|
|
8482
|
+
"opf/embed-credentials": embedCredentials,
|
|
8483
|
+
"opf/chart-bands-order": chartBandsOrder,
|
|
8484
|
+
"opf/chart-bands-unsupported": chartBandsUnsupported,
|
|
8485
|
+
"opf/metric-gauge-range": metricGaugeRange,
|
|
8486
|
+
"opf/metric-gauge-value": metricGaugeValue,
|
|
7713
8487
|
"opf/code-highlight-out-of-range": codeHighlightOutOfRange,
|
|
7714
8488
|
"opf/code-highlight-range-reversed": codeHighlightRangeReversed,
|
|
7715
8489
|
"opf/variable-builtin-missing": variableBuiltinMissing,
|
|
@@ -7722,10 +8496,10 @@ var AUDIT_TEXT = {
|
|
|
7722
8496
|
"opf/empty-slide": emptySlide,
|
|
7723
8497
|
"opf/language-tag": languageTag,
|
|
7724
8498
|
"opf/text-shrunk": textShrunk2,
|
|
8499
|
+
"opf/variable-overflow": variableOverflow2,
|
|
7725
8500
|
"opf/centered-body": centeredBody2,
|
|
7726
8501
|
"opf/tight-spacing": tightSpacing2,
|
|
7727
8502
|
"opf/layout-monotony": layoutMonotony2,
|
|
7728
|
-
"opf/straight-quotes": straightQuotes2,
|
|
7729
8503
|
"opf/chart-dual-axis": chartDualAxis2,
|
|
7730
8504
|
"opf/chart-pie-many-slices": chartPieManySlices2
|
|
7731
8505
|
};
|
|
@@ -7769,6 +8543,15 @@ var citeUnknownReference = (finding2, _context, helpers) => {
|
|
|
7769
8543
|
next: chooseNext(id, ids, add)
|
|
7770
8544
|
};
|
|
7771
8545
|
};
|
|
8546
|
+
var slideLinkUnknown = (finding2, _context, helpers) => {
|
|
8547
|
+
const id = text(params(finding2).id) ?? unquote(match(finding2.message, /^unknown slide '(.+?)'/)?.[1]);
|
|
8548
|
+
const ids = idsAt(helpers, ["slides"]);
|
|
8549
|
+
const add = `give a slide the id ${code(id)}`;
|
|
8550
|
+
return {
|
|
8551
|
+
message: `${code(`link: "slide:${id}"`)} names a slide the document does not have.`,
|
|
8552
|
+
next: ids.length ? chooseNext(id, ids, add) : `${add} (assignIds gives every slide one), or link to another target.`
|
|
8553
|
+
};
|
|
8554
|
+
};
|
|
7772
8555
|
var citeUnsupportedLocation = (finding2) => {
|
|
7773
8556
|
const where = match(finding2.message, /^cite and footnote are not supported in ([^;]+);/)?.[1];
|
|
7774
8557
|
const inReferences = /^reference text cannot cite/.test(finding2.message);
|
|
@@ -7784,8 +8567,8 @@ var captionUnsupportedPayload = (finding2) => {
|
|
|
7784
8567
|
const kind = type ?? (/a group cannot carry one/.test(finding2.message) ? "group" : void 0);
|
|
7785
8568
|
const is = kind ? kindPhrase(kind) : "not one of those";
|
|
7786
8569
|
return {
|
|
7787
|
-
message: `A ${code("caption")} belongs to one image, chart, table, video or diagram; this block is ${is}.`,
|
|
7788
|
-
next: `put the ${code("caption")} on the image, chart, table, video or diagram it describes, or remove it.`
|
|
8570
|
+
message: `A ${code("caption")} belongs to one image, chart, table, video, embed or diagram; this block is ${is}.`,
|
|
8571
|
+
next: `put the ${code("caption")} on the image, chart, table, video, embed or diagram it describes, or remove it.`
|
|
7789
8572
|
};
|
|
7790
8573
|
};
|
|
7791
8574
|
var imageOptionUnsupportedPayload = (finding2) => {
|
|
@@ -7884,8 +8667,13 @@ var layoutPlaceholderGroup = (finding2) => {
|
|
|
7884
8667
|
};
|
|
7885
8668
|
};
|
|
7886
8669
|
function datasetOf(helpers) {
|
|
7887
|
-
const
|
|
7888
|
-
|
|
8670
|
+
const link = helpers.segments.lastIndexOf("data");
|
|
8671
|
+
if (link > 0 && helpers.segments[link - 1] === "metric") {
|
|
8672
|
+
const value = helpers.valueAt([...helpers.segments.slice(0, link + 1), "dataset"]);
|
|
8673
|
+
if (isText2(value)) return value;
|
|
8674
|
+
}
|
|
8675
|
+
const at3 = helpers.segments.findIndex((segment2) => segment2 === "fields" || segment2 === "columns" || segment2 === "mapping" || segment2 === "highlight");
|
|
8676
|
+
const parent = at3 > 0 ? helpers.segments.slice(0, at3) : helpers.segments.slice(0, -1);
|
|
7889
8677
|
for (const candidate of [parent, [...parent, "data"]]) {
|
|
7890
8678
|
const value = helpers.valueAt([...candidate, "dataset"]);
|
|
7891
8679
|
if (isText2(value)) return value;
|
|
@@ -7902,6 +8690,16 @@ var datasetUnknown = (finding2, _context, helpers) => {
|
|
|
7902
8690
|
next: chooseNext(id, ids, `add ${code(`datasets.${id}`)}`)
|
|
7903
8691
|
};
|
|
7904
8692
|
};
|
|
8693
|
+
var datasourceUnknown = (finding2, _context, helpers) => {
|
|
8694
|
+
const id = unquote(match(finding2.message, /^unknown data source '(.+?)'/)?.[1]) || String(helpers.valueAt(helpers.segments) ?? "");
|
|
8695
|
+
if (!id) return void 0;
|
|
8696
|
+
const ids = keysAt(helpers, ["datasources"]);
|
|
8697
|
+
const here = ids.length ? `Data sources in this deck: ${plainList(ids)}.` : "This deck has no data sources.";
|
|
8698
|
+
return {
|
|
8699
|
+
message: `${code(`datasource: "${id}"`)} does not exist. ${here}`,
|
|
8700
|
+
next: chooseNext(id, ids, `add ${code(`datasources.${id}`)}, or write the data source inline as an object such as ${code('{ "src": "./data.csv" }')}`)
|
|
8701
|
+
};
|
|
8702
|
+
};
|
|
7905
8703
|
var datasetFieldUnknown = (finding2, _context, helpers) => {
|
|
7906
8704
|
const found = match(finding2.message, /^field ("(?:[^"\\]|\\.)*") is not a column of the dataset; use one of (.+)$/);
|
|
7907
8705
|
if (!found) return void 0;
|
|
@@ -7981,6 +8779,16 @@ var tableHighlightUnknownName = (finding2) => {
|
|
|
7981
8779
|
next: keys.length ? chooseNext(name, keys) : "name a row by the text of its first cell, or remove the entry."
|
|
7982
8780
|
};
|
|
7983
8781
|
};
|
|
8782
|
+
var tableColorScaleUnknownColumn = (finding2) => {
|
|
8783
|
+
const column = match(finding2.message, /^The color scale names ("(?:[^"\\]|\\.)*"), which is no column of this table\. Columns: (.+)\.$/);
|
|
8784
|
+
if (!column) return void 0;
|
|
8785
|
+
const name = unquote(column[1]);
|
|
8786
|
+
const columns = column[2] === "none" ? [] : unquoteList(column[2]);
|
|
8787
|
+
return {
|
|
8788
|
+
message: `${code(`colorScale.columns: "${name}"`)} matches no column.${columns.length ? ` Available: ${plainList(columns)}.` : ""}`,
|
|
8789
|
+
next: columns.length ? chooseNext(name, columns) : "give the table a header row, or remove the color scale."
|
|
8790
|
+
};
|
|
8791
|
+
};
|
|
7984
8792
|
var tokenOf = (finding2, id) => finding2.message.includes(`var:${id}`) ? code(`var:${id}`) : code(`{{${id}}}`);
|
|
7985
8793
|
var SAMPLE_BY_KIND = {
|
|
7986
8794
|
number: "a plain number such as 42",
|
|
@@ -8076,6 +8884,17 @@ var variableUnused = (finding2, _context, helpers) => {
|
|
|
8076
8884
|
next: `use it as ${code(`{{${id}}}`)} or ${code(`var:${id}`)} where it belongs, or remove its declaration.`
|
|
8077
8885
|
};
|
|
8078
8886
|
};
|
|
8887
|
+
var variableTranslationDuplicate = (finding2, _context, helpers) => {
|
|
8888
|
+
const id = text(params(finding2).id) ?? helpers.segments.at(-2);
|
|
8889
|
+
if (!id) return void 0;
|
|
8890
|
+
return { message: `Variable ${code(id)} has two translations whose language tags differ only in case.`, next: "remove one of the two keys: the first in the document is the one that is drawn." };
|
|
8891
|
+
};
|
|
8892
|
+
var variableTranslationUnused = (finding2, _context, helpers) => {
|
|
8893
|
+
const id = text(params(finding2).id) ?? helpers.segments.at(-3);
|
|
8894
|
+
const tag = helpers.segments.at(-1);
|
|
8895
|
+
if (!id || !tag) return void 0;
|
|
8896
|
+
return { message: `The ${code(tag)} translation of ${code(id)} is never drawn: no slide and not the deck declares a language that selects it.`, next: `set ${code("language")} on the deck or on a slide, fix the tag, or remove the translation.` };
|
|
8897
|
+
};
|
|
8079
8898
|
var variableReferenceUnknown = (finding2, _context, helpers) => {
|
|
8080
8899
|
const id = text(params(finding2).id) ?? match(finding2.message, /^unknown variable '(.+?)'/)?.[1];
|
|
8081
8900
|
if (!id) return void 0;
|
|
@@ -8153,9 +8972,9 @@ var catalogRecord = (finding2, context) => {
|
|
|
8153
8972
|
if (root !== "catalogs" || !kind || !id) return void 0;
|
|
8154
8973
|
const inner = describeFinding({ ...finding2, ruleId: "opf/schema" }, context);
|
|
8155
8974
|
const registered = finding2.scope === "context";
|
|
8156
|
-
const
|
|
8975
|
+
const record2 = `${registered ? "The registered" : "The embedded"} ${KIND_SINGULAR2(kind)} ${code(id)}`;
|
|
8157
8976
|
return {
|
|
8158
|
-
message: `${
|
|
8977
|
+
message: `${record2} is invalid: ${inner.message.charAt(0).toLowerCase()}${inner.message.slice(1)}`,
|
|
8159
8978
|
next: inner.next ?? `fix the record; references to it are reported too.`
|
|
8160
8979
|
};
|
|
8161
8980
|
};
|
|
@@ -8342,6 +9161,7 @@ var FORMAT_TEXT = {
|
|
|
8342
9161
|
"opf/schema": schemaPlain,
|
|
8343
9162
|
"opf/reference-id-duplicate": referenceIdDuplicate,
|
|
8344
9163
|
"opf/cite-unknown-reference": citeUnknownReference,
|
|
9164
|
+
"opf/slide-link-unknown": slideLinkUnknown,
|
|
8345
9165
|
"opf/cite-unsupported-location": citeUnsupportedLocation,
|
|
8346
9166
|
"opf/caption-unsupported-payload": captionUnsupportedPayload,
|
|
8347
9167
|
"opf/image-option-unsupported-payload": imageOptionUnsupportedPayload,
|
|
@@ -8356,6 +9176,7 @@ var FORMAT_TEXT = {
|
|
|
8356
9176
|
"opf/connector-end-missing": connectorEndMissing,
|
|
8357
9177
|
"opf/layout-placeholder-group": layoutPlaceholderGroup,
|
|
8358
9178
|
"opf/dataset-unknown": datasetUnknown,
|
|
9179
|
+
"opf/datasource-unknown": datasourceUnknown,
|
|
8359
9180
|
"opf/dataset-field-unknown": datasetFieldUnknown,
|
|
8360
9181
|
"opf/data-column-duplicate": dataColumnDuplicate,
|
|
8361
9182
|
"opf/chart-mapping-unknown-column": chartMappingUnknownColumn,
|
|
@@ -8366,6 +9187,7 @@ var FORMAT_TEXT = {
|
|
|
8366
9187
|
"opf/variable-unknown-builtin": variableUnknownBuiltin,
|
|
8367
9188
|
"opf/chart-highlight-unknown-name": chartHighlightUnknownName,
|
|
8368
9189
|
"opf/table-highlight-unknown-name": tableHighlightUnknownName,
|
|
9190
|
+
"opf/table-color-scale-unknown-column": tableColorScaleUnknownColumn,
|
|
8369
9191
|
"opf/variable-format": variableFormat,
|
|
8370
9192
|
"opf/variable-unfilled": variableUnfilled,
|
|
8371
9193
|
"opf/run-color-unrecognized": runColorUnrecognized,
|
|
@@ -8388,6 +9210,8 @@ var FORMAT_TEXT = {
|
|
|
8388
9210
|
"opf/variable-unknown": variableUnknown,
|
|
8389
9211
|
"opf/variable-unknown-value": variableUnknownValue,
|
|
8390
9212
|
"opf/variable-unused": variableUnused,
|
|
9213
|
+
"opf/variable-translation-duplicate": variableTranslationDuplicate,
|
|
9214
|
+
"opf/variable-translation-unused": variableTranslationUnused,
|
|
8391
9215
|
"opf/variable-reference-unknown": variableReferenceUnknown,
|
|
8392
9216
|
"opf/contract": contract
|
|
8393
9217
|
};
|
|
@@ -8587,9 +9411,12 @@ var PATTERN_PHRASES = Object.freeze({
|
|
|
8587
9411
|
"^\\s*-?[0-9.]+([ ,]+-?[0-9.]+){3}\\s*$": { what: "a viewBox of four numbers, `minX minY width height`, like `0 0 24 24`", next: "write four numbers separated by spaces." },
|
|
8588
9412
|
"^[a-z][A-Za-z0-9]*$": { what: "an adjust value name like `adj` or `adj1` (a letter, then letters and digits)", next: "use the name of one of the preset's adjust values (docs/shapes.md lists them)." },
|
|
8589
9413
|
"^\\d{4}-\\d{2}-\\d{2}$": { what: "a date written year-month-day, like `2026-10-24`", next: "write the date as YYYY-MM-DD." },
|
|
8590
|
-
"^(?:https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
|
|
8591
9414
|
"^(https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
|
|
9415
|
+
"^P(?=\\d|T\\d)(?:\\d+Y)?(?:\\d+M)?(?:\\d+W)?(?:\\d+D)?(?:T(?=\\d)(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?$": { what: "an ISO 8601 duration like `P1D` (a day), `P1W`, `P3M` or `PT6H`", next: "write `P`, then the amount and a unit letter (Y, M, W, D), and after a `T` any hours, minutes or seconds." },
|
|
9416
|
+
"^(?:https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
|
|
9417
|
+
"^(https?://|mailto:|tel:|slide:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`) or a slide of this deck (`slide:pricing`)", next: "start with https://, mailto:, tel: or slide:, and leave out spaces." },
|
|
8592
9418
|
"^(?:[a-z][a-z0-9-]*:[a-z0-9][a-z0-9-]*|[a-z][a-z0-9-]*|(?:asset:|https://|data:|\\./|\\.\\./)\\S+)$": { what: "an icon like `lucide:truck` (a set and a name), the name of one of the deck's `icons`, or an SVG source (`asset:`, `https://`, `data:`, `./`)", next: "write the set and the icon name, such as lucide:truck (search_icons finds names), or the name of one of the deck's icons." },
|
|
9419
|
+
"^https://[^\\s/?#]+[^\\s]*$": { what: "an `https://` address of a web page, without spaces", next: "write the page's address starting with https://; http:, relative paths and other schemes are not embedded." },
|
|
8593
9420
|
"^(asset:|https://|data:|\\./|\\.\\./)": { what: "a source that starts with `asset:`, `https://`, `data:`, `./` or `../`", next: "register the file under `assets` and write `asset:` and its id, or give an https:// address." },
|
|
8594
9421
|
"^(?:https://[^\\s]+|pkg:[^\\s]+)$": { what: "an `https://` address or a `pkg:` reference", next: "write an address that starts with https:// or pkg:, without spaces." },
|
|
8595
9422
|
"^(?:[A-Za-z]{2,3}|[iIxX])(?:-[A-Za-z0-9]{1,8})*$": { what: LANGUAGE, next: "write a language and, if needed, a region: `en-US`, `pt-BR`, `de`." },
|
|
@@ -8865,417 +9692,173 @@ function schemaFixes(finding2, document) {
|
|
|
8865
9692
|
function listColumnsChangeDrawing(region) {
|
|
8866
9693
|
if (!isRecord2(region) || region.listColumns !== "auto") return true;
|
|
8867
9694
|
const accepts = Array.isArray(region.accepts) ? region.accepts : [];
|
|
8868
|
-
const arrangement = region.arrangement ?? region.sequence;
|
|
8869
|
-
return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
|
|
8870
|
-
}
|
|
8871
|
-
var REMOVED_LIST_COLUMNS = `OPF 0.35 removed the region key listColumns. Delete it: a list of more than 6 entries flows into up to three columns in any region without an arrangement (or with the numbered one) when that sets it at least as large as one column; a list payload's own columns (1, 2, 3 or "auto") still chooses.`;
|
|
8872
|
-
function removedKeyRepair(finding2, document, options2) {
|
|
8873
|
-
const validation = finding2.validation;
|
|
8874
|
-
if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
|
|
8875
|
-
const segments = segmentsOf(finding2.path);
|
|
8876
|
-
if (validation.keyword === "additionalProperties" && segments.length === 3 && segments[0] === "slides" && readAt(document, segments) !== void 0 && nearestGridCell(segments[2]) !== void 0) return cellKeyRepair(document, segments.slice(0, 2), segments[2], options2);
|
|
8877
|
-
const inRegion = segments.at(-3) === "regions";
|
|
8878
|
-
if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
|
|
8879
|
-
const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
|
|
8880
|
-
if (!isRecord2(region) || value === void 0) return void 0;
|
|
8881
|
-
const arrangement = region.arrangement;
|
|
8882
|
-
if (segments.at(-1) === "sequence") {
|
|
8883
|
-
const help2 = `OPF 0.35 replaced the region key sequence with arrangement: a region has one arrangement, a sequence ("steps" or "numbered") or a diagram. Write "arrangement": ${JSON.stringify(value)} in its place.`;
|
|
8884
|
-
if (arrangement !== void 0 || value !== "steps" && value !== "numbered") return { help: `${help2}${arrangement !== void 0 ? ` This region also has "arrangement": ${JSON.stringify(arrangement)}; keep one of the two.` : ""}`, fixes: [] };
|
|
8885
|
-
return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
|
|
8886
|
-
}
|
|
8887
|
-
const help = 'OPF 0.35 removed the region key pyramidDirection: "arrangement": "inverted-pyramid" draws the pyramid upside down (what "down" did), and "arrangement": "pyramid" draws it upright ("up", the default).';
|
|
8888
|
-
if (arrangement !== "pyramid") return { help, fixes: [] };
|
|
8889
|
-
if (value === "down") return { help, fixes: [patch("use-inverted-pyramid", "Write arrangement inverted-pyramid", [{ op: "remove", path: finding2.path }, { op: "replace", path: pointerOf([...parent, "arrangement"]), value: "inverted-pyramid" }], true)] };
|
|
8890
|
-
if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
|
|
8891
|
-
return { help, fixes: [] };
|
|
8892
|
-
}
|
|
8893
|
-
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
|
|
8894
|
-
const value = readAt(document, segments), renamed = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
|
|
8895
|
-
if (renamed === void 0) return void 0;
|
|
8896
|
-
return { help: `OPF 0.35 renamed the arrangement "${String(value)}" to "${renamed}", PowerPoint's name (${renamed === "process" ? "Basic Process" : "Vertical Process"}); it draws the same.`, fixes: [patch("rename-arrangement", `Write arrangement ${renamed}`, [{ op: "replace", path: finding2.path, value: renamed }], true)] };
|
|
8897
|
-
}
|
|
8898
|
-
const alignment = segments.at(-1);
|
|
8899
|
-
if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
|
|
8900
|
-
const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
|
|
8901
|
-
if (next === void 0) return void 0;
|
|
8902
|
-
return { help: `OPF 0.34 renamed the alignment "${String(value)}" to "${next}" (the start and end of the reading direction; the left and right edges of a left-to-right deck).`, fixes: [patch(`change-to:${next}`, `Change to ${next}`, [{ op: "replace", path: finding2.path, value: next }], true)] };
|
|
8903
|
-
}
|
|
8904
|
-
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
|
|
8905
|
-
return {
|
|
8906
|
-
help: `OPF 0.35 removed the role "secondary" (bound after primary, before supporting): a region's role is "primary" (the default), "media" or "supporting". Write "supporting" for a region that takes what the primary regions leave, or "primary".`,
|
|
8907
|
-
fixes: [patch("change-to:supporting", "Change to supporting", [{ op: "replace", path: finding2.path, value: "supporting" }]), patch("change-to:primary", "Change to primary", [{ op: "replace", path: finding2.path, value: "primary" }])]
|
|
8908
|
-
};
|
|
8909
|
-
}
|
|
8910
|
-
if (validation.keyword === "additionalProperties") {
|
|
8911
|
-
const name = segments.at(-1) ?? "";
|
|
8912
|
-
if (name === "listColumns" && segments.at(-3) === "regions" && readAt(document, segments) !== void 0) return { help: REMOVED_LIST_COLUMNS, fixes: [patch("remove:listColumns", "Delete listColumns", [{ op: "remove", path: finding2.path }], true, listColumnsChangeDrawing(readAt(document, segments.slice(0, -1))))] };
|
|
8913
|
-
if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
|
|
8914
|
-
const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
|
|
8915
|
-
return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
|
|
8916
|
-
}
|
|
8917
|
-
if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
|
|
8918
|
-
const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
|
|
8919
|
-
if (!near?.help) return void 0;
|
|
8920
|
-
return { help: `${JSON.stringify(typed)} is no cell of the slide's grid. ${near.help}`, fixes: near.cell ? [patch(`change-to:${near.cell}`, `Change to ${near.cell}`, [{ op: "replace", path: finding2.path, value: near.cell }])] : [] };
|
|
8921
|
-
}
|
|
8922
|
-
if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
|
|
8923
|
-
const parent = segments.slice(0, -1), region = readAt(document, parent);
|
|
8924
|
-
const help = 'OPF 0.35 removed flow "none": a region of one block says "max": 1 (blocks no region had room for still join it), and its flow is "auto", "grid", "row" or "column".';
|
|
8925
|
-
if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
|
|
8926
|
-
return { help, fixes: [patch("use-max-1", "Write max 1 (a region of one block)", [{ op: "remove", path: finding2.path }, { op: "add", path: pointerOf([...parent, "max"]), value: 1 }], true)] };
|
|
8927
|
-
}
|
|
8928
|
-
return void 0;
|
|
8929
|
-
}
|
|
8930
|
-
var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
|
|
8931
|
-
function removedCellKeys(slide) {
|
|
8932
|
-
if (!isRecord2(slide)) return [];
|
|
8933
|
-
const found = Object.keys(slide).flatMap((key3) => {
|
|
8934
|
-
const cell = nearestGridCell(key3)?.cell;
|
|
8935
|
-
return cell ? [{ key: key3, cell }] : [];
|
|
8936
|
-
});
|
|
8937
|
-
const order2 = cellsInReadingOrder(found);
|
|
8938
|
-
return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
|
|
8939
|
-
}
|
|
8940
|
-
function cellKeysAsBlocks(slide, placed) {
|
|
8941
|
-
const keys = removedCellKeys(slide);
|
|
8942
|
-
if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
|
|
8943
|
-
const blocks = keys.map(({ key: key3, cell }) => {
|
|
8944
|
-
const { id, region: _ignored, ...rest } = slide[key3];
|
|
8945
|
-
return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
|
|
8946
|
-
});
|
|
8947
|
-
return { keys: keys.map(({ key: key3 }) => key3), blocks };
|
|
8948
|
-
}
|
|
8949
|
-
function cellKeyRepair(document, slideSegments, key3, options2) {
|
|
8950
|
-
const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
|
|
8951
|
-
const layout = isRecord2(slide) && slide.layout !== void 0 && (slide.layout !== "auto" || resolvesToValidRecord(document, "layouts", "auto", options2));
|
|
8952
|
-
const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
|
|
8953
|
-
const help = `OPF 0.35 removed the slide keys that placed content in the cells of a slide's 3 x 3 grid (the promoted regions): a block of the slide's blocks names its cell with "region", as ${example}. Blocks that name the same cell stack in it, and a slide places every block in a cell or none.` + (layout ? " This slide also has a layout, and a cell word names no region of a layout: the fix keeps the layout and moves each cell's content into a block without region, which binds to the layout's regions by kind, so the slide draws on its layout. To keep a grid of cells instead, remove layout and name the cells on the blocks." : "") + (near.help ? ` ${near.help}` : "");
|
|
8954
|
-
const moved = near.cell ? cellKeysAsBlocks(slide, !layout) : void 0;
|
|
8955
|
-
if (!moved) return { help, fixes: [], dropSuggestions: true };
|
|
8956
|
-
const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
|
|
8957
|
-
return { help, fixes: [layout ? patch("cells-to-layout-blocks", "Move the regions into blocks of the layout", operations, true, true) : patch("cells-to-blocks", "Move the regions into blocks with region", operations, true)], dropSuggestions: true };
|
|
8958
|
-
}
|
|
8959
|
-
|
|
8960
|
-
// src/drawn-font-families.ts
|
|
8961
|
-
function resolveDrawnFontFamilies(families, measurement, keepsName) {
|
|
8962
|
-
const resolve2 = measurement?.resolveStyle;
|
|
8963
|
-
if (typeof resolve2 !== "function") return families;
|
|
8964
|
-
const drawn = { ...families };
|
|
8965
|
-
for (const role of ["heading", "body", "code", "accent"]) {
|
|
8966
|
-
const named = families[role];
|
|
8967
|
-
if (typeof named !== "string" || !named) continue;
|
|
8968
|
-
try {
|
|
8969
|
-
const resolved2 = resolve2.call(measurement, { fontFamily: named, fontWeight: role === "heading" ? 700 : 400 });
|
|
8970
|
-
let keep3;
|
|
8971
|
-
if (keepsName) keep3 = keepsName(named, resolved2.fontFamily);
|
|
8972
|
-
else {
|
|
8973
|
-
const regular = role === "heading" ? resolve2.call(measurement, { fontFamily: named, fontWeight: 400 }) : resolved2;
|
|
8974
|
-
const encoded = resolved2.symbolEncoding != null;
|
|
8975
|
-
keep3 = encoded || regular.fontWeight !== void 0 && regular.fontWeight !== 400 && resolved2.fontFamily.toLowerCase() !== named.toLowerCase();
|
|
8976
|
-
}
|
|
8977
|
-
if (!keep3) drawn[role] = resolved2.fontFamily;
|
|
8978
|
-
} catch {
|
|
8979
|
-
}
|
|
8980
|
-
}
|
|
8981
|
-
return drawn;
|
|
8982
|
-
}
|
|
8983
|
-
|
|
8984
|
-
// src/script-measurement.ts
|
|
8985
|
-
function scriptProfile(presentation, slideIndex, options2, language) {
|
|
8986
|
-
let resolved2;
|
|
8987
|
-
try {
|
|
8988
|
-
resolved2 = resolveScriptFonts(presentation, { slideIndex, ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, ...language === void 0 ? {} : { language } });
|
|
8989
|
-
} catch {
|
|
8990
|
-
resolved2 = void 0;
|
|
8991
|
-
}
|
|
8992
|
-
const slots = (role) => {
|
|
8993
|
-
const latin = options2.fontFamilies[role];
|
|
8994
|
-
const slot = (key3) => !resolved2 || resolved2.sources[key3] === "latin" || resolved2.sources[key3] === "schemeFamily" ? latin : resolved2[role][key3] ?? latin;
|
|
8995
|
-
return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
|
|
8996
|
-
};
|
|
8997
|
-
return {
|
|
8998
|
-
heading: slots("heading"),
|
|
8999
|
-
body: slots("body"),
|
|
9000
|
-
...resolved2?.supplement ? { supplement: resolved2.supplement } : {},
|
|
9001
|
-
script: resolved2?.script ?? "Zzzz",
|
|
9002
|
-
...resolved2 ? { scriptRole: resolved2.scriptRole, bcp47: resolved2.bcp47, lang: resolved2.lang, languageSource: resolved2.languageSource, direction: resolved2.direction } : {},
|
|
9003
|
-
rtl: resolved2?.rtl === true,
|
|
9004
|
-
serif: options2.serif
|
|
9005
|
-
};
|
|
9006
|
-
}
|
|
9007
|
-
function slideScriptMeasurement(presentation, slideIndex, measurement, options2) {
|
|
9008
|
-
const forScripts = measurement.forScripts;
|
|
9009
|
-
if (typeof forScripts !== "function") return measurement;
|
|
9010
|
-
const deckProfile = scriptProfile(presentation, slideIndex, options2);
|
|
9011
|
-
const deck = forScripts.call(measurement, deckProfile);
|
|
9012
|
-
const languages = /* @__PURE__ */ new Map();
|
|
9013
|
-
const forLanguage = (lang) => {
|
|
9014
|
-
if (typeof lang !== "string" || !lang) return void 0;
|
|
9015
|
-
if (!languages.has(lang)) {
|
|
9016
|
-
let own4;
|
|
9017
|
-
try {
|
|
9018
|
-
const profile = scriptProfile(presentation, slideIndex, options2, lang);
|
|
9019
|
-
own4 = profile.languageSource === "option" && profile.bcp47?.toLowerCase() !== deckProfile.bcp47?.toLowerCase() ? forScripts.call(measurement, profile) : void 0;
|
|
9020
|
-
} catch {
|
|
9021
|
-
own4 = void 0;
|
|
9022
|
-
}
|
|
9023
|
-
languages.set(lang, own4);
|
|
9024
|
-
}
|
|
9025
|
-
return languages.get(lang);
|
|
9026
|
-
};
|
|
9027
|
-
const pick = (style) => forLanguage(style?.lang) ?? deck;
|
|
9028
|
-
const scripted = { ...deck, measure: (text2, size, style) => pick(style).measure(text2, size, style) };
|
|
9029
|
-
if (typeof deck.resolveStyle === "function") scripted.resolveStyle = (style) => deck.resolveStyle.call(deck, style);
|
|
9030
|
-
if (typeof deck.outlineBounds === "function")
|
|
9031
|
-
scripted.outlineBounds = (text2, size, style) => {
|
|
9032
|
-
const own4 = pick(style);
|
|
9033
|
-
return typeof own4.outlineBounds === "function" ? own4.outlineBounds(text2, size, style) : deck.outlineBounds.call(deck, text2, size, style);
|
|
9034
|
-
};
|
|
9035
|
-
return scripted;
|
|
9036
|
-
}
|
|
9037
|
-
function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, options2 = {}) {
|
|
9038
|
-
if (typeof measurement.forScripts !== "function") return measurement;
|
|
9039
|
-
const { fontScheme } = resolveDesignRecords(presentation, slideIndex, options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {});
|
|
9040
|
-
const resolved2 = resolveFontFamilies(fontScheme);
|
|
9041
|
-
const fontFamilies = { heading: options2.fontFamilies?.heading ?? resolved2.heading, body: options2.fontFamilies?.body ?? resolved2.body };
|
|
9042
|
-
return slideScriptMeasurement(presentation, slideIndex, measurement, { ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, fontFamilies, serif: fontScheme.type === "serif" });
|
|
9043
|
-
}
|
|
9044
|
-
|
|
9045
|
-
// src/message-surface.ts
|
|
9046
|
-
var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9047
|
-
var MESSAGE_SURFACE_SLOT = "accent1";
|
|
9048
|
-
var MESSAGE_SURFACE_CONTRAST = 4.5;
|
|
9049
|
-
function messageKind(slide, layout) {
|
|
9050
|
-
const lone = lonePayload(slide);
|
|
9051
|
-
if (lone?.field !== "text" || annotationText(slide.subtitle).trim()) return void 0;
|
|
9052
|
-
let plan;
|
|
9053
|
-
try {
|
|
9054
|
-
plan = isLayoutTemplate(layout) ? layoutTemplate(layout) : void 0;
|
|
9055
|
-
} catch {
|
|
9056
|
-
return void 0;
|
|
9057
|
-
}
|
|
9058
|
-
if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
|
|
9059
|
-
if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
|
|
9060
|
-
const value = lone.host.text;
|
|
9061
|
-
const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
|
|
9062
|
-
return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
|
|
9063
|
-
}
|
|
9064
|
-
function lchOf(hex) {
|
|
9065
|
-
const lin = (at2) => {
|
|
9066
|
-
const value = Number.parseInt(hex.slice(at2, at2 + 2), 16) / 255;
|
|
9067
|
-
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
9068
|
-
};
|
|
9069
|
-
const [r, g, b] = [lin(1), lin(3), lin(5)];
|
|
9070
|
-
const x = (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / 0.95047, y = 0.2126729 * r + 0.7151522 * g + 0.072175 * b, z = (0.0193339 * r + 0.119192 * g + 0.9503041 * b) / 1.08883;
|
|
9071
|
-
const f = (t) => t > 216 / 24389 ? Math.cbrt(t) : (24389 / 27 * t + 16) / 116;
|
|
9072
|
-
const [fx, fy, fz] = [f(x), f(y), f(z)];
|
|
9073
|
-
return { L: 116 * fy - 16, C: Math.hypot(500 * (fx - fy), 200 * (fy - fz)) };
|
|
9074
|
-
}
|
|
9075
|
-
var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
|
|
9076
|
-
var MESSAGE_SURFACE_MAX_CHROMA = 80;
|
|
9077
|
-
function resolveMessageSurface(presentation, slide, layout, context) {
|
|
9078
|
-
const deckDesign = rec3(rec3(presentation).design);
|
|
9079
|
-
const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
|
|
9080
|
-
if (kind === void 0 || !(named === void 0 || named === "surface") || deckBackgroundIsChosen(deckDesign, context.theme.background) || !layoutVariantApplies(slide.design, layout, deckDesign, context.theme.background, true)) return void 0;
|
|
9081
|
-
const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
|
|
9082
|
-
const variant = { background: MESSAGE_SURFACE_SLOT, ...below.variant?.accents ? { accents: below.variant.accents } : {} };
|
|
9083
|
-
const plain = resolveColorRoles(context.colorScheme, { background: below.background, variant: below.variant });
|
|
9084
|
-
const deliberate = [deckDesign, ...context.themeChosen ? [context.theme] : []].some((level) => level.background !== void 0 || level.variant !== void 0);
|
|
9085
|
-
if (plain.dark && deliberate) return void 0;
|
|
9086
|
-
const accent = resolveColorRoles(context.colorScheme, { variant }), shade = lchOf(accent.background.slice(0, 7).toUpperCase());
|
|
9087
|
-
if (accent.background.toUpperCase() === plain.background.toUpperCase() || (colorContrast(accent.text, accent.background) ?? 0) < MESSAGE_SURFACE_CONTRAST || shade.L > MESSAGE_SURFACE_MAX_LIGHTNESS || shade.C > MESSAGE_SURFACE_MAX_CHROMA) return void 0;
|
|
9088
|
-
return { kind, variant };
|
|
9089
|
-
}
|
|
9090
|
-
function drawsAccentByDesign(presentation, host, record, theme) {
|
|
9091
|
-
const deckDesign = rec3(rec3(presentation).design), own4 = normalizeColorVariant(rec3(host.design).variant), named = layoutColorVariant(record);
|
|
9092
|
-
if (own4) return own4.background.startsWith("accent");
|
|
9093
|
-
return named !== void 0 && layoutVariantApplies(host.design, record, deckDesign, theme.background) && named.background.startsWith("accent");
|
|
9094
|
-
}
|
|
9095
|
-
function messageDisplayed(result, kind) {
|
|
9096
|
-
const scale = Math.min(result.width, result.height) / 720, size = (field) => result.items.find((item) => item.field === field)?.text?.fontSize;
|
|
9097
|
-
const text2 = size("text"), title = size("title");
|
|
9098
|
-
if (kind === "statement-message") return text2 !== void 0 && text2 / scale >= LONE_DISPLAY_SIZES.text - 1e-6 || title !== void 0 && title / scale > 54 + 1e-6;
|
|
9099
|
-
return text2 !== void 0 && text2 / scale > LONE_DISPLAY_SIZES.text + 1e-6;
|
|
9695
|
+
const arrangement = region.arrangement ?? region.sequence;
|
|
9696
|
+
return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
|
|
9100
9697
|
}
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
function
|
|
9105
|
-
const
|
|
9698
|
+
function sheetReference(name) {
|
|
9699
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : `'${name.replaceAll("'", "''")}'`;
|
|
9700
|
+
}
|
|
9701
|
+
function datasourceStringRepair(finding2, document, segments) {
|
|
9702
|
+
const parent = segments.slice(0, -1), owner = readAt(document, parent), value = readAt(document, segments);
|
|
9703
|
+
const where = parent.length === 2 && parent[0] === "datasets" ? "dataset" : parent.at(-1) === "data" && parent.at(-2) === "chart" ? "chart data" : void 0;
|
|
9704
|
+
if (where === void 0 || !isRecord2(owner) || typeof value !== "string") return void 0;
|
|
9106
9705
|
return {
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9706
|
+
help: `A string \`datasource\` is only ever the id of an entry of the root \`datasources\` map (letters, digits, dots, hyphens and underscores). A file or a URL is written as an inline data source: { "src": ${JSON.stringify(value)} }.`,
|
|
9707
|
+
fixes: [patch("datasource-to-src", `Write the ${where}'s datasource as { "src": ${JSON.stringify(value)} }`, [{ op: "replace", path: finding2.path, value: { src: value } }])]
|
|
9708
|
+
};
|
|
9709
|
+
}
|
|
9710
|
+
var REMOVED_SOURCE = 'OPF 0.37 removed the nested `source` object. Where the data came from is written in the keys of the dataset or chart data itself: `datasource` (the id of an entry of the root `datasources` map, or an inline data source such as { "src": "./revenue.csv" }), `query` (the sheet and range, "FY26!A1:C13"), `retrieved`, `version`, `sha256` and `generator`.';
|
|
9711
|
+
function sourceRepair(finding2, document, segments) {
|
|
9712
|
+
const parent = segments.slice(0, -1), owner = readAt(document, parent), old = readAt(document, segments);
|
|
9713
|
+
const where = parent.length === 2 && parent[0] === "datasets" ? "dataset" : parent.at(-1) === "data" && parent.at(-2) === "chart" ? "chart data" : void 0;
|
|
9714
|
+
if (where === void 0 || !isRecord2(owner) || !isRecord2(old)) return void 0;
|
|
9715
|
+
const text2 = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
9716
|
+
const src = text2(old.src), description = text2(old.description), retrieved = text2(old.retrieved), sheet = text2(old.sheet), range = text2(old.range);
|
|
9717
|
+
const query = sheet !== void 0 && range !== void 0 ? `${sheetReference(sheet)}!${range}` : sheet !== void 0 ? sheetReference(sheet) : range;
|
|
9718
|
+
const dropped = Array.isArray(old.fields) && old.fields.length ? " Its `fields` list is dropped: the data holds its own columns." : "";
|
|
9719
|
+
const help = `${REMOVED_SOURCE}${dropped}`;
|
|
9720
|
+
const writes = [];
|
|
9721
|
+
if (src !== void 0) writes.push(["datasource", { src, ...description !== void 0 ? { description } : {} }]);
|
|
9722
|
+
if (query !== void 0) writes.push(["query", query]);
|
|
9723
|
+
if (retrieved !== void 0) writes.push(["retrieved", retrieved]);
|
|
9724
|
+
if (writes.some(([key3]) => Object.hasOwn(owner, key3))) return { help, fixes: [] };
|
|
9725
|
+
const operations = [{ op: "remove", path: finding2.path }, ...writes.map(([key3, value]) => ({ op: "add", path: pointerOf([...parent, key3]), value }))];
|
|
9726
|
+
const title = `Write the ${where}'s ${writes.map(([key3]) => key3).join(", ") || "provenance"} keys in place of source${dropped ? " (fields is dropped)" : ""}`;
|
|
9727
|
+
return { help, fixes: [patch("use-datasource", title, operations, true)] };
|
|
9113
9728
|
}
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
const
|
|
9117
|
-
if (!
|
|
9118
|
-
const
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
const
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9729
|
+
var REMOVED_LIST_COLUMNS = `OPF 0.35 removed the region key listColumns. Delete it: a list of more than 6 entries flows into up to three columns in any region without an arrangement (or with the numbered one) when that sets it at least as large as one column; a list payload's own columns (1, 2, 3 or "auto") still chooses.`;
|
|
9730
|
+
function renamedKeyRepair(finding2, document) {
|
|
9731
|
+
const validation = finding2.validation;
|
|
9732
|
+
if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
|
|
9733
|
+
const segments = segmentsOf(finding2.path);
|
|
9734
|
+
if (validation.keyword === "additionalProperties") {
|
|
9735
|
+
const rename = renamedKeyAt(segments);
|
|
9736
|
+
if (!rename) return void 0;
|
|
9737
|
+
const parent = segments.slice(0, -1), owner = readAt(document, parent);
|
|
9738
|
+
if (!isRecord2(owner) || !Object.hasOwn(owner, rename.from)) return void 0;
|
|
9739
|
+
const both = Object.hasOwn(owner, rename.to);
|
|
9740
|
+
const note = rename.note ? ` ${rename.note}` : "";
|
|
9741
|
+
const help = both ? `OPF 0.37 renamed "${rename.from}" to "${rename.to}".${note} This object has both: keep "${rename.to}" and remove "${rename.from}".` : `OPF 0.37 renamed "${rename.from}" to "${rename.to}".${note} It draws the same; the fix renames it.`;
|
|
9742
|
+
const fixes = both ? [] : [patch("rename-key", `Rename ${rename.from} to ${rename.to}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, rename.to]) }], true)];
|
|
9743
|
+
return { help, message: renamedKeyMessage(rename, both), dropSuggestions: true, exclusive: true, fixes };
|
|
9744
|
+
}
|
|
9745
|
+
if (validation.keyword === "enum" && segments.at(-1) === "scriptGroup") {
|
|
9746
|
+
const old = readAt(document, segments), long = renamedScriptGroupValue(old);
|
|
9747
|
+
if (long === void 0) return void 0;
|
|
9748
|
+
return {
|
|
9749
|
+
help: `OPF 0.37 writes the script groups of a font scheme "latin", "eastAsian" and "complexScript"; "${String(old)}" is "${long}". It draws the same.`,
|
|
9750
|
+
message: renamedValueMessage(String(old), long),
|
|
9751
|
+
exclusive: true,
|
|
9752
|
+
fixes: [patch("rename-value", `Write ${long}`, [{ op: "replace", path: finding2.path, value: long }], true)]
|
|
9753
|
+
};
|
|
9132
9754
|
}
|
|
9133
|
-
if (
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
|
|
9141
|
-
...layout ? { layout } : {},
|
|
9142
|
-
presentation,
|
|
9143
|
-
slideIndex: index,
|
|
9144
|
-
slideNumber: options2.slideNumber ?? index + 1,
|
|
9145
|
-
slideCount: options2.slideCount ?? slides.length,
|
|
9146
|
-
fontFamilies: resolveFontFamilies(fontScheme),
|
|
9147
|
-
darkBackground: roles2.dark,
|
|
9148
|
-
...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
|
|
9149
|
-
// LH-02: the colors the automatic scrim of a picture background is sized for.
|
|
9150
|
-
roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
|
|
9151
|
-
...theme.background !== void 0 ? { themeBackground: theme.background } : {},
|
|
9152
|
-
// OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
|
|
9153
|
-
...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
|
|
9154
|
-
...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
|
|
9155
|
-
...options2.date !== void 0 ? { date: options2.date } : {}
|
|
9755
|
+
if (validation.keyword === "pattern" && segments.at(-1) === "link" && segments.at(-3) === "references") {
|
|
9756
|
+
const value = readAt(document, segments);
|
|
9757
|
+
if (typeof value !== "string" || !LOOKS_LIKE_HOST_AND_PATH.test(value)) return void 0;
|
|
9758
|
+
return {
|
|
9759
|
+
help: `A reference's link is an http or https address, a "mailto:" or a "tel:" link. "${value}" looks like an address without its scheme; "https://${value}" is a guess the author confirms, so the fix is not applied by default.`,
|
|
9760
|
+
exclusive: true,
|
|
9761
|
+
fixes: [patch("add-https", "Add https://", [{ op: "replace", path: finding2.path, value: `https://${value}` }])]
|
|
9156
9762
|
};
|
|
9157
|
-
return { levels, roles: roles2, layoutVariant: layoutVariant2, composeOptions: composeOptions2 };
|
|
9158
|
-
};
|
|
9159
|
-
const variablesOf = (made) => resolveSlideVariables(slide, { slideNumber: made.composeOptions.slideNumber, slideCount: made.composeOptions.slideCount, presentation, darkBackground: made.composeOptions.darkBackground === true });
|
|
9160
|
-
let messageSurface = candidate, built = build(candidate);
|
|
9161
|
-
if (candidate) {
|
|
9162
|
-
const plain = build(void 0);
|
|
9163
|
-
const host = plain.composeOptions.textMeasurement;
|
|
9164
|
-
const measurement = host ? unpathed(slideScriptMeasurement(presentation, index, host, { ...catalogs, fontFamilies: resolveFontFamilies(fontScheme), serif: fontScheme.type === "serif" })) : host;
|
|
9165
|
-
let displayed = false;
|
|
9166
|
-
try {
|
|
9167
|
-
displayed = messageDisplayed(composeSlide(variablesOf(plain), { ...plain.composeOptions, ...measurement ? { textMeasurement: measurement } : {} }), candidate.kind);
|
|
9168
|
-
} catch {
|
|
9169
|
-
displayed = false;
|
|
9170
|
-
}
|
|
9171
|
-
if (displayed && index > 0) {
|
|
9172
|
-
const before = rec4(slides[index - 1]), record = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
|
|
9173
|
-
if (drawsAccentByDesign(presentation, before, record, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
|
|
9174
|
-
}
|
|
9175
|
-
if (!displayed) {
|
|
9176
|
-
messageSurface = void 0;
|
|
9177
|
-
built = plain;
|
|
9178
|
-
}
|
|
9179
9763
|
}
|
|
9180
|
-
|
|
9181
|
-
const resolvedSlide = variablesOf(built);
|
|
9182
|
-
return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, ...layoutVariant ? { layoutVariant } : {}, ...messageSurface ? { messageSurface } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
|
|
9764
|
+
return void 0;
|
|
9183
9765
|
}
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
const
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
if (
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
for (const child of Object.values(object3)) walk2(child);
|
|
9766
|
+
function removedKeyRepair(finding2, document, options2) {
|
|
9767
|
+
const validation = finding2.validation;
|
|
9768
|
+
if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
|
|
9769
|
+
const renamed = renamedKeyRepair(finding2, document);
|
|
9770
|
+
if (renamed) return renamed;
|
|
9771
|
+
const segments = segmentsOf(finding2.path);
|
|
9772
|
+
if (validation.keyword === "additionalProperties" && segments.length === 3 && segments[0] === "slides" && readAt(document, segments) !== void 0 && nearestGridCell(segments[2]) !== void 0) return cellKeyRepair(document, segments.slice(0, 2), segments[2], options2);
|
|
9773
|
+
if (validation.keyword === "pattern" && finding2.ruleId === "opf/schema" && segments.at(-1) === "datasource") {
|
|
9774
|
+
const repaired = datasourceStringRepair(finding2, document, segments);
|
|
9775
|
+
if (repaired) return repaired;
|
|
9776
|
+
}
|
|
9777
|
+
if (validation.keyword === "additionalProperties" && finding2.ruleId === "opf/schema" && segments.at(-1) === "source") {
|
|
9778
|
+
const repaired = sourceRepair(finding2, document, segments);
|
|
9779
|
+
if (repaired) return repaired;
|
|
9780
|
+
}
|
|
9781
|
+
const inRegion = segments.at(-3) === "regions";
|
|
9782
|
+
if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
|
|
9783
|
+
const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
|
|
9784
|
+
if (!isRecord2(region) || value === void 0) return void 0;
|
|
9785
|
+
const arrangement = region.arrangement;
|
|
9786
|
+
if (segments.at(-1) === "sequence") {
|
|
9787
|
+
const help2 = `OPF 0.35 replaced the region key sequence with arrangement: a region has one arrangement, a sequence ("steps" or "numbered") or a diagram. Write "arrangement": ${JSON.stringify(value)} in its place.`;
|
|
9788
|
+
if (arrangement !== void 0 || value !== "steps" && value !== "numbered") return { help: `${help2}${arrangement !== void 0 ? ` This region also has "arrangement": ${JSON.stringify(arrangement)}; keep one of the two.` : ""}`, fixes: [] };
|
|
9789
|
+
return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
|
|
9209
9790
|
}
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
}
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
const
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
const layout = lazy(() => resolved2().options.layout);
|
|
9232
|
-
const compute = () => {
|
|
9233
|
-
const result = { layoutDiagnostics: [] };
|
|
9234
|
-
let fontFamilies;
|
|
9235
|
-
const compose = (input, withLayout) => {
|
|
9236
|
-
const options3 = resolved2().options;
|
|
9237
|
-
fontFamilies ??= options3.fontFamilies && resolveDrawnFontFamilies(options3.fontFamilies, options3.textMeasurement);
|
|
9238
|
-
return composeSlide(input, { ...options3, ...fontFamilies ? { fontFamilies } : {}, layout: withLayout });
|
|
9239
|
-
};
|
|
9240
|
-
try {
|
|
9241
|
-
result.composition = compose(resolved2().slide, layout());
|
|
9242
|
-
result.layoutDiagnostics.push(...result.composition.diagnostics.map((diagnostic) => ({ diagnostic, strict: false })));
|
|
9243
|
-
} catch (error) {
|
|
9244
|
-
if (error instanceof OPFCompositionError) {
|
|
9245
|
-
result.layoutDiagnostics.push(...error.diagnostics.map((diagnostic) => ({ diagnostic, strict: true })));
|
|
9246
|
-
try {
|
|
9247
|
-
const relaxedLayout = layout();
|
|
9248
|
-
result.composition = compose(relax(resolved2().slide), relaxedLayout ? relax(relaxedLayout) : void 0);
|
|
9249
|
-
} catch (second) {
|
|
9250
|
-
result.layoutError = second instanceof Error ? second.message : String(second);
|
|
9251
|
-
}
|
|
9252
|
-
} else result.layoutError = error instanceof Error ? error.message : String(error);
|
|
9253
|
-
}
|
|
9254
|
-
return result;
|
|
9791
|
+
const help = 'OPF 0.35 removed the region key pyramidDirection: "arrangement": "inverted-pyramid" draws the pyramid upside down (what "down" did), and "arrangement": "pyramid" draws it upright ("up", the default).';
|
|
9792
|
+
if (arrangement !== "pyramid") return { help, fixes: [] };
|
|
9793
|
+
if (value === "down") return { help, fixes: [patch("use-inverted-pyramid", "Write arrangement inverted-pyramid", [{ op: "remove", path: finding2.path }, { op: "replace", path: pointerOf([...parent, "arrangement"]), value: "inverted-pyramid" }], true)] };
|
|
9794
|
+
if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
|
|
9795
|
+
return { help, fixes: [] };
|
|
9796
|
+
}
|
|
9797
|
+
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
|
|
9798
|
+
const value = readAt(document, segments), renamed2 = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
|
|
9799
|
+
if (renamed2 === void 0) return void 0;
|
|
9800
|
+
return { help: `OPF 0.35 renamed the arrangement "${String(value)}" to "${renamed2}", PowerPoint's name (${renamed2 === "process" ? "Basic Process" : "Vertical Process"}); it draws the same.`, fixes: [patch("rename-arrangement", `Write arrangement ${renamed2}`, [{ op: "replace", path: finding2.path, value: renamed2 }], true)] };
|
|
9801
|
+
}
|
|
9802
|
+
const alignment = segments.at(-1);
|
|
9803
|
+
if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
|
|
9804
|
+
const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
|
|
9805
|
+
if (next === void 0) return void 0;
|
|
9806
|
+
return { help: `OPF 0.34 renamed the alignment "${String(value)}" to "${next}" (the start and end of the reading direction; the left and right edges of a left-to-right deck).`, fixes: [patch(`change-to:${next}`, `Change to ${next}`, [{ op: "replace", path: finding2.path, value: next }], true)] };
|
|
9807
|
+
}
|
|
9808
|
+
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
|
|
9809
|
+
return {
|
|
9810
|
+
help: `OPF 0.35 removed the role "secondary" (bound after primary, before supporting): a region's role is "primary" (the default), "media" or "supporting". Write "supporting" for a region that takes what the primary regions leave, or "primary".`,
|
|
9811
|
+
fixes: [patch("change-to:supporting", "Change to supporting", [{ op: "replace", path: finding2.path, value: "supporting" }]), patch("change-to:primary", "Change to primary", [{ op: "replace", path: finding2.path, value: "primary" }])]
|
|
9255
9812
|
};
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
const
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
return
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9813
|
+
}
|
|
9814
|
+
if (validation.keyword === "additionalProperties") {
|
|
9815
|
+
const name = segments.at(-1) ?? "";
|
|
9816
|
+
if (name === "listColumns" && segments.at(-3) === "regions" && readAt(document, segments) !== void 0) return { help: REMOVED_LIST_COLUMNS, fixes: [patch("remove:listColumns", "Delete listColumns", [{ op: "remove", path: finding2.path }], true, listColumnsChangeDrawing(readAt(document, segments.slice(0, -1))))] };
|
|
9817
|
+
if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
|
|
9818
|
+
const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
|
|
9819
|
+
return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
|
|
9820
|
+
}
|
|
9821
|
+
if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
|
|
9822
|
+
const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
|
|
9823
|
+
if (!near?.help) return void 0;
|
|
9824
|
+
return { help: `${JSON.stringify(typed)} is no cell of the slide's grid. ${near.help}`, fixes: near.cell ? [patch(`change-to:${near.cell}`, `Change to ${near.cell}`, [{ op: "replace", path: finding2.path, value: near.cell }])] : [] };
|
|
9825
|
+
}
|
|
9826
|
+
if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
|
|
9827
|
+
const parent = segments.slice(0, -1), region = readAt(document, parent);
|
|
9828
|
+
const help = 'OPF 0.35 removed flow "none": a region of one block says "max": 1 (blocks no region had room for still join it), and its flow is "auto", "grid", "row" or "column".';
|
|
9829
|
+
if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
|
|
9830
|
+
return { help, fixes: [patch("use-max-1", "Write max 1 (a region of one block)", [{ op: "remove", path: finding2.path }, { op: "add", path: pointerOf([...parent, "max"]), value: 1 }], true)] };
|
|
9831
|
+
}
|
|
9832
|
+
return void 0;
|
|
9833
|
+
}
|
|
9834
|
+
var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
|
|
9835
|
+
function removedCellKeys(slide) {
|
|
9836
|
+
if (!isRecord2(slide)) return [];
|
|
9837
|
+
const found = Object.keys(slide).flatMap((key3) => {
|
|
9838
|
+
const cell = nearestGridCell(key3)?.cell;
|
|
9839
|
+
return cell ? [{ key: key3, cell }] : [];
|
|
9840
|
+
});
|
|
9841
|
+
const order2 = cellsInReadingOrder(found);
|
|
9842
|
+
return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
|
|
9843
|
+
}
|
|
9844
|
+
function cellKeysAsBlocks(slide, placed) {
|
|
9845
|
+
const keys = removedCellKeys(slide);
|
|
9846
|
+
if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
|
|
9847
|
+
const blocks = keys.map(({ key: key3, cell }) => {
|
|
9848
|
+
const { id, region: _ignored, ...rest } = slide[key3];
|
|
9849
|
+
return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
|
|
9278
9850
|
});
|
|
9851
|
+
return { keys: keys.map(({ key: key3 }) => key3), blocks };
|
|
9852
|
+
}
|
|
9853
|
+
function cellKeyRepair(document, slideSegments, key3, options2) {
|
|
9854
|
+
const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
|
|
9855
|
+
const layout = isRecord2(slide) && slide.layout !== void 0 && (slide.layout !== "auto" || resolvesToValidRecord(document, "layouts", "auto", options2));
|
|
9856
|
+
const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
|
|
9857
|
+
const help = `OPF 0.35 removed the slide keys that placed content in the cells of a slide's 3 x 3 grid (the promoted regions): a block of the slide's blocks names its cell with "region", as ${example}. Blocks that name the same cell stack in it, and a slide places every block in a cell or none.` + (layout ? " This slide also has a layout, and a cell word names no region of a layout: the fix keeps the layout and moves each cell's content into a block without region, which binds to the layout's regions by kind, so the slide draws on its layout. To keep a grid of cells instead, remove layout and name the cells on the blocks." : "") + (near.help ? ` ${near.help}` : "");
|
|
9858
|
+
const moved = near.cell ? cellKeysAsBlocks(slide, !layout) : void 0;
|
|
9859
|
+
if (!moved) return { help, fixes: [], dropSuggestions: true };
|
|
9860
|
+
const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
|
|
9861
|
+
return { help, fixes: [layout ? patch("cells-to-layout-blocks", "Move the regions into blocks of the layout", operations, true, true) : patch("cells-to-blocks", "Move the regions into blocks with region", operations, true)], dropSuggestions: true };
|
|
9279
9862
|
}
|
|
9280
9863
|
|
|
9281
9864
|
// src/validation-cache.ts
|
|
@@ -9488,7 +10071,7 @@ var ValidationCompositionCache = class {
|
|
|
9488
10071
|
|
|
9489
10072
|
// src/validator.ts
|
|
9490
10073
|
var SEVERITIES = ["error", "warning", "info"];
|
|
9491
|
-
var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values"];
|
|
10074
|
+
var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values", "asOf", "slideLinks"];
|
|
9492
10075
|
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9493
10076
|
var OPFValidationError = class extends Error {
|
|
9494
10077
|
/** The full report that failed. */
|
|
@@ -9567,6 +10150,7 @@ function resolveOptions(options2) {
|
|
|
9567
10150
|
throw new TypeError("Validate chartPalette must be an array of #RRGGBB colors.");
|
|
9568
10151
|
if (options2.template !== void 0 && typeof options2.template !== "boolean") throw new TypeError("Validate template must be true or false.");
|
|
9569
10152
|
if (options2.values !== void 0 && !isObject3(options2.values)) throw new TypeError("Validate values must be an object keyed by variable id.");
|
|
10153
|
+
if (options2.asOf !== void 0 && parseInstant(options2.asOf) === void 0) throw new TypeError("Validate asOf must be an ISO 8601 date (2026-11-25) or date-time (2026-11-25T09:30:00Z).");
|
|
9570
10154
|
const level = (info) => severity.get(info.id) ?? severity.get(info.category);
|
|
9571
10155
|
const off = (info) => level(info) === "off" || !!ignore?.rules.has(info.id) || !!ignore?.categories.has(info.category);
|
|
9572
10156
|
return {
|
|
@@ -9590,7 +10174,7 @@ var categoryOrder = (category) => {
|
|
|
9590
10174
|
};
|
|
9591
10175
|
var auditInfos = ruleImplementations.flatMap((entry2) => [entry2.info, ...entry2.also ?? []]);
|
|
9592
10176
|
var isLayoutRule = (info) => info.category === "layout" && info.cost === "composition";
|
|
9593
|
-
function
|
|
10177
|
+
function slideOf2(path) {
|
|
9594
10178
|
const match2 = /^\/slides\/(\d+)(?:\/|$)/.exec(path);
|
|
9595
10179
|
return match2 ? Number(match2[1]) : void 0;
|
|
9596
10180
|
}
|
|
@@ -9622,7 +10206,7 @@ function syntaxReport(parsed, run) {
|
|
|
9622
10206
|
return { valid: tally.error === 0, schemaValid: null, findings, counts: tally, checks };
|
|
9623
10207
|
}
|
|
9624
10208
|
function validateDocument(document, run, parsed, cache) {
|
|
9625
|
-
const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {} });
|
|
10209
|
+
const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.asOf !== void 0 ? { asOf: run.options.asOf } : {}, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {}, ...run.options.slideLinks !== void 0 ? { slideLinks: run.options.slideLinks } : {} });
|
|
9626
10210
|
const schemaValid = engine.errors.length === 0;
|
|
9627
10211
|
const slides = isObject3(document) && Array.isArray(document.slides) ? document.slides : [];
|
|
9628
10212
|
const auditWanted = auditInfos.some((info) => run.enabled(info));
|
|
@@ -9686,7 +10270,7 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9686
10270
|
if (!STALE_RECORD_RULES.has(entry2.ruleId) || entry2.scope === "context") return void 0;
|
|
9687
10271
|
const match2 = /^\/catalogs\/([^/]+)\/layouts\/([^/]+)(?:\/|$)/.exec(entry2.path);
|
|
9688
10272
|
if (!match2) return void 0;
|
|
9689
|
-
const [group, id] = [match2[1], match2[2]].map((
|
|
10273
|
+
const [group, id] = [match2[1], match2[2]].map((segment2) => segment2.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
9690
10274
|
let found = staleCopies.get(`${group}/${id}`);
|
|
9691
10275
|
if (!found) {
|
|
9692
10276
|
const copy = staleLayoutCopy(document, group, id, run.options);
|
|
@@ -9702,7 +10286,7 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9702
10286
|
const override = info ? run.severity(info) : void 0;
|
|
9703
10287
|
let next = override && override !== entry2.severity ? { ...entry2, severity: override } : entry2;
|
|
9704
10288
|
if (info && run.ignored(info, splitPointer(next.path))) continue;
|
|
9705
|
-
const index =
|
|
10289
|
+
const index = slideOf2(next.path);
|
|
9706
10290
|
if (next.slide === void 0 && index !== void 0 && next.scope !== "context") {
|
|
9707
10291
|
const id = isObject3(slides[index]) ? slides[index].id : void 0;
|
|
9708
10292
|
next.slide = index;
|
|
@@ -9714,7 +10298,7 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9714
10298
|
}
|
|
9715
10299
|
const removed = next.scope !== "context" ? removedKeyRepair(next, document, run.options) : void 0;
|
|
9716
10300
|
if (removed) next = withRepair(next, removed);
|
|
9717
|
-
if (next.ruleId === "opf/schema" && next.fixes === void 0 && next.scope !== "context") {
|
|
10301
|
+
if (next.ruleId === "opf/schema" && next.fixes === void 0 && next.scope !== "context" && !removed?.exclusive) {
|
|
9718
10302
|
const fixes = schemaFixes(next, document);
|
|
9719
10303
|
if (fixes.length) next.fixes = fixes;
|
|
9720
10304
|
}
|
|
@@ -9784,7 +10368,7 @@ function assertValid(value, options2 = {}) {
|
|
|
9784
10368
|
}
|
|
9785
10369
|
function withRepair(finding2, removed) {
|
|
9786
10370
|
const { suggestions, ...rest } = finding2;
|
|
9787
|
-
return { ...removed.dropSuggestions ? rest : { ...rest, ...suggestions ? { suggestions } : {} }, help: removed.help, ...removed.fixes.length ? { fixes: removed.fixes } : {} };
|
|
10371
|
+
return { ...removed.dropSuggestions ? rest : { ...rest, ...suggestions ? { suggestions } : {} }, ...removed.message ? { message: removed.message } : {}, help: removed.help, ...removed.fixes.length ? { fixes: removed.fixes } : {} };
|
|
9788
10372
|
}
|
|
9789
10373
|
function validateCatalogRecord(kind, value) {
|
|
9790
10374
|
const kinds = Object.keys(catalogSchemaNames);
|
|
@@ -9812,4 +10396,4 @@ function assertValidCatalogRecord(kind, value) {
|
|
|
9812
10396
|
if (!report2.valid) throw new OPFValidationError(report2);
|
|
9813
10397
|
}
|
|
9814
10398
|
|
|
9815
|
-
export { BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, CATALOG_SCHEMA, COMMON_KEYS, DEFAULT_VALIDATION_THRESHOLDS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, METRIC_KEYS, OPFPatchError, OPFPatchHashError, OPFPatchValidationError, OPFValidationError, PATTERN_PHRASES, SLIDE_OPTION_KEYS, SOURCE_EXPLAIN, SPAN_FLAGS, SPAN_VALUES, UNRANKED_PRIORITY, activeSchema, analyzeJsonSyntax, applyPatch, applyPatchWithInverse, applyTextEdits, assertValid, assertValidCatalogRecord, catalogDisplayKinds, catalogIconKinds, catalogKindAt, catalogSchemaNames, createLocator, createSchemaValue, createValidator, describeField, describeFinding, distance, documentHash, escapePointerToken, findValidationRule, formatPointer, getAtPointer, hasPointer, idToken, invertPatch, isIdToken, jsonEqual, listSchemaFields, nearest, normalizePatch, parsePointer, parseSource, pointerFromPath, readPointer, refreshStaleLayouts, rememberByText, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
|
|
10399
|
+
export { BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, CATALOG_SCHEMA, COMMON_KEYS, DEFAULT_VALIDATION_THRESHOLDS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, METRIC_KEYS, OPFPatchError, OPFPatchHashError, OPFPatchValidationError, OPFValidationError, PATTERN_PHRASES, SLIDE_OPTION_KEYS, SOURCE_EXPLAIN, SPAN_FLAGS, SPAN_VALUES, UNRANKED_PRIORITY, activeSchema, analyzeJsonSyntax, applyPatch, applyPatchWithInverse, applyTextEdits, assertValid, assertValidCatalogRecord, catalogDisplayKinds, catalogIconKinds, catalogKindAt, catalogSchemaNames, collectSlideLinks, createLocator, createSchemaValue, createValidator, credentialInSrc, describeField, describeFinding, distance, documentHash, escapePointerToken, findValidationRule, formatPointer, getAtPointer, hasPointer, idToken, invertPatch, isIdToken, jsonEqual, listSchemaFields, nearest, normalizePatch, parseInstant, parsePointer, parseSource, pointerFromPath, readPointer, refreshStaleLayouts, rememberByText, renameRecordKeys, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, slideLink, slideLinkId, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
|