@openpresentation/opf 0.35.1 → 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-BN36KMXG.js → chunk-3A3PNYNP.js} +77 -15
- package/dist/{chunk-EGXHUIQ5.js → chunk-44IS6ZU2.js} +114 -9
- package/dist/{chunk-ZRTVPUYJ.js → chunk-4FA4ZABY.js} +6 -6
- package/dist/{chunk-OBNSVMNO.js → chunk-56BYOGIF.js} +1 -1
- package/dist/{chunk-MS2LPR7F.js → chunk-6WN6PRCI.js} +1 -1
- package/dist/{chunk-ZHLAMHSS.js → chunk-BHRCWV6B.js} +4 -4
- package/dist/{chunk-PWE6UY3Y.js → chunk-C5ACMFKB.js} +1440 -835
- package/dist/{chunk-PF3TVOMG.js → chunk-CYGQY6HH.js} +6 -6
- package/dist/{chunk-MIHW2IGO.js → chunk-EOMENOKY.js} +26 -7
- package/dist/{chunk-TRGSEXUR.js → chunk-HS2JQ3AO.js} +118 -19
- package/dist/chunk-IW4TXMJY.js +646 -0
- package/dist/{chunk-LLY5BZGF.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-WPUV2223.js → chunk-ORVMHVOS.js} +86 -2
- package/dist/{chunk-B7XWF5RV.js → chunk-QFT4R2IL.js} +5304 -2991
- package/dist/chunk-QQBOI5XI.js +86 -0
- package/dist/{chunk-P6KRAHVG.js → chunk-TIVBO56G.js} +4 -4
- package/dist/{chunk-ZEVLLXSY.js → chunk-VD7WLE3C.js} +2 -2
- package/dist/{chunk-PXJZS4ZF.js → chunk-XJU2X5JM.js} +5 -4
- package/dist/chunk-YESKKKVE.js +1 -0
- package/dist/{chunk-XHWJI4O7.js → chunk-YZ4WMB5C.js} +26 -21
- package/dist/{composition-BmJfljJl.d.ts → composition-DiKC371V.d.ts} +844 -143
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +1 -1
- package/dist/{conversion-BIooTbt5.d.ts → conversion-DF_HgknQ.d.ts} +8 -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-BYkbL7uT.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 +57 -33
- package/dist/examples.js +5349 -2989
- 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-C0FPjO29.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/repo-readme.js +1 -1
- 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-DKIe1RQW.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-SB5CGD6Q.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);
|
|
@@ -1291,15 +1465,30 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
|
|
|
1291
1465
|
};
|
|
1292
1466
|
}
|
|
1293
1467
|
|
|
1468
|
+
// src/record-validity.ts
|
|
1469
|
+
var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1470
|
+
function recordIssues(kind, id, value) {
|
|
1471
|
+
const schemaName = catalogSchemaNames[kind];
|
|
1472
|
+
return validateAgainstSchema(object(value) ? { $schema: schemas[schemaName].$id, id, ...value } : value, kind);
|
|
1473
|
+
}
|
|
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;
|
|
1477
|
+
}
|
|
1478
|
+
function resolvesToValidRecord(document, kind, reference, options2 = {}) {
|
|
1479
|
+
const found = resolveReference(document, kind, reference, options2);
|
|
1480
|
+
return !!found && !(found.origin === "document" && embeddedRecordInvalid(kind, found.id, found.record));
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1294
1483
|
// src/narrative-plan.ts
|
|
1295
1484
|
var isRec = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1296
1485
|
function resolveNarrative(document, options2 = {}) {
|
|
1297
1486
|
if (!isRec(document) || typeof document.narrative !== "string") return void 0;
|
|
1298
1487
|
const found = resolveReference(document, "narratives", document.narrative, { catalogs: options2.catalogs ?? [] });
|
|
1299
1488
|
if (!found) return void 0;
|
|
1300
|
-
const
|
|
1301
|
-
const beats = Array.isArray(
|
|
1302
|
-
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 };
|
|
1303
1492
|
}
|
|
1304
1493
|
function slideBeatReferences(document) {
|
|
1305
1494
|
if (!isRec(document) || !Array.isArray(document.slides)) return [];
|
|
@@ -1309,8 +1498,8 @@ function slideBeatReferences(document) {
|
|
|
1309
1498
|
const path = `/slides/${index}/beat`;
|
|
1310
1499
|
if (typeof slide.beat === "string") references.push({ path, slide: index, beat: slide.beat });
|
|
1311
1500
|
else if (Array.isArray(slide.beat))
|
|
1312
|
-
slide.beat.forEach((beat,
|
|
1313
|
-
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 });
|
|
1314
1503
|
});
|
|
1315
1504
|
});
|
|
1316
1505
|
return references;
|
|
@@ -1324,14 +1513,14 @@ function unreferencedBeats(document, narrative) {
|
|
|
1324
1513
|
if (referenced.size === 0) return [];
|
|
1325
1514
|
return narrative.beats.flatMap((beat, index) => referenced.has(beat) ? [] : [{ beat, index }]);
|
|
1326
1515
|
}
|
|
1327
|
-
function durationRange(
|
|
1328
|
-
if (!isRec(
|
|
1516
|
+
function durationRange(record2) {
|
|
1517
|
+
if (!isRec(record2) || !isRec(record2.duration)) return void 0;
|
|
1329
1518
|
const bound = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
1330
|
-
const min = bound(
|
|
1519
|
+
const min = bound(record2.duration.min), max = bound(record2.duration.max);
|
|
1331
1520
|
return min === void 0 && max === void 0 ? void 0 : { ...min !== void 0 ? { min } : {}, ...max !== void 0 ? { max } : {} };
|
|
1332
1521
|
}
|
|
1333
|
-
function durationRangeInverted(
|
|
1334
|
-
const range = durationRange(
|
|
1522
|
+
function durationRangeInverted(record2) {
|
|
1523
|
+
const range = durationRange(record2);
|
|
1335
1524
|
return range?.min !== void 0 && range.max !== void 0 && range.min > range.max;
|
|
1336
1525
|
}
|
|
1337
1526
|
function durationOutsideNarrative(document, narrative) {
|
|
@@ -1351,7 +1540,7 @@ function describeDurationRange(range) {
|
|
|
1351
1540
|
var rec = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1352
1541
|
var toRgb = (hex) => {
|
|
1353
1542
|
const n = normalizeHexColor(hex) ?? "#000000";
|
|
1354
|
-
return [1, 3, 5].map((
|
|
1543
|
+
return [1, 3, 5].map((at3) => Number.parseInt(n.slice(at3, at3 + 2), 16));
|
|
1355
1544
|
};
|
|
1356
1545
|
var toHex = (rgb) => `#${rgb.map((c) => Math.max(0, Math.min(255, Math.round(c))).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
1357
1546
|
var linear = (c) => {
|
|
@@ -1533,7 +1722,7 @@ function colorChoice(levels, scheme, variables = {}) {
|
|
|
1533
1722
|
if (variantOnly || definition === void 0 || definition === null || definition === false) continue;
|
|
1534
1723
|
if (themeSlot) return { variant: { background: themeSlot } };
|
|
1535
1724
|
if (isPicture) {
|
|
1536
|
-
const tone = rec(definition).
|
|
1725
|
+
const tone = rec(definition).appearance ?? pictureTone(definition, scheme, variables);
|
|
1537
1726
|
if (tone === "dark" || tone === "light") return { variant: { background: tone === "dark" ? "dark1" : "light1" } };
|
|
1538
1727
|
variantOnly = true;
|
|
1539
1728
|
picture = { definition };
|
|
@@ -1685,64 +1874,62 @@ function textValues(slide, slidePath) {
|
|
|
1685
1874
|
for (const field of ["title", "subtitle", "tag"])
|
|
1686
1875
|
if (isText(slide[field])) out.push({ path: pointer2(...splitPointer(slidePath), field), value: slide[field], role: field, payload: slidePath, field });
|
|
1687
1876
|
for (const payload of slidePayloads(slide, slidePath)) {
|
|
1688
|
-
const node = payload.node,
|
|
1877
|
+
const node = payload.node, at3 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
|
|
1689
1878
|
const push = (path, value, role, field) => {
|
|
1690
1879
|
if (isText(value)) out.push({ path, value, role, payload: payload.path, field });
|
|
1691
1880
|
};
|
|
1692
|
-
push(
|
|
1881
|
+
push(at3("text"), node.text, "body", "text");
|
|
1693
1882
|
for (const field of ["items", "bullets"])
|
|
1694
1883
|
if (Array.isArray(node[field]))
|
|
1695
1884
|
node[field].forEach((entry2, index) => {
|
|
1696
|
-
if (isText(entry2)) push(
|
|
1885
|
+
if (isText(entry2)) push(at3(field, index), entry2, "list", field);
|
|
1697
1886
|
else if (entry2 && typeof entry2 === "object") {
|
|
1698
|
-
push(
|
|
1699
|
-
push(
|
|
1887
|
+
push(at3(field, index, "text"), entry2.text, "list", field);
|
|
1888
|
+
push(at3(field, index, "description"), entry2.description, "list-description", field);
|
|
1700
1889
|
}
|
|
1701
1890
|
});
|
|
1702
1891
|
const table = rec(node.table);
|
|
1703
1892
|
if (Array.isArray(table.columns))
|
|
1704
1893
|
table.columns.forEach((cell, c) => {
|
|
1705
1894
|
const styled = rec(cell);
|
|
1706
|
-
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");
|
|
1707
1896
|
else {
|
|
1708
1897
|
const value = Object.hasOwn(styled, "value") ? styled.value : cell;
|
|
1709
|
-
push(
|
|
1898
|
+
push(at3("table", "columns", c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table-header", "table");
|
|
1710
1899
|
}
|
|
1711
1900
|
});
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
const value = Object.hasOwn(styled, "value") ? styled.value : cell;
|
|
1718
|
-
push(at2("table", "rows", r, c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
|
|
1719
|
-
});
|
|
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");
|
|
1720
1906
|
});
|
|
1907
|
+
});
|
|
1721
1908
|
const callouts = rec(node.image).callouts;
|
|
1722
1909
|
if (Array.isArray(callouts)) callouts.forEach((callout, index) => {
|
|
1723
|
-
push(
|
|
1910
|
+
push(at3("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
|
|
1724
1911
|
});
|
|
1725
1912
|
const quote = node.quote;
|
|
1726
|
-
if (typeof quote === "string") push(
|
|
1913
|
+
if (typeof quote === "string") push(at3("quote"), quote, "quote", "quote");
|
|
1727
1914
|
else if (quote && typeof quote === "object") {
|
|
1728
|
-
push(
|
|
1729
|
-
push(
|
|
1730
|
-
push(
|
|
1731
|
-
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");
|
|
1732
1919
|
}
|
|
1733
1920
|
const metric = node.metric;
|
|
1734
|
-
if (typeof metric === "string") push(
|
|
1921
|
+
if (typeof metric === "string") push(at3("metric"), metric, "metric", "metric");
|
|
1735
1922
|
else if (metric && typeof metric === "object")
|
|
1736
1923
|
for (const key3 of ["value", "label", "unit", "delta"]) {
|
|
1737
1924
|
const value = metric[key3];
|
|
1738
|
-
if (typeof value === "string") push(
|
|
1925
|
+
if (typeof value === "string") push(at3("metric", key3), value, "metric", "metric");
|
|
1739
1926
|
}
|
|
1740
1927
|
const timeline = node.timeline, events = Array.isArray(timeline) ? timeline : Array.isArray(rec(timeline).events) ? rec(timeline).events : [];
|
|
1741
|
-
if (typeof rec(timeline).name === "string") push(
|
|
1928
|
+
if (typeof rec(timeline).name === "string") push(at3("timeline", "name"), rec(timeline).name, "timeline", "timeline");
|
|
1742
1929
|
events.forEach((event, index) => {
|
|
1743
1930
|
const base = Array.isArray(timeline) ? ["timeline", index] : ["timeline", "events", index];
|
|
1744
|
-
push(
|
|
1745
|
-
push(
|
|
1931
|
+
push(at3(...base, "when"), event?.when, "timeline", "timeline");
|
|
1932
|
+
push(at3(...base, "what"), event?.what, "timeline", "timeline");
|
|
1746
1933
|
});
|
|
1747
1934
|
}
|
|
1748
1935
|
return out;
|
|
@@ -1785,10 +1972,10 @@ var isLogoReference = (value) => typeof value === "string" && value.startsWith("
|
|
|
1785
1972
|
function assetRefs(document, slide, slidePath, includeDeck) {
|
|
1786
1973
|
const out = [];
|
|
1787
1974
|
for (const payload of slidePayloads(slide, slidePath)) {
|
|
1788
|
-
const
|
|
1789
|
-
if (payload.node.image !== void 0 && !isLogoReference(payload.node.image)) out.push({ path:
|
|
1790
|
-
if (payload.node.video !== void 0) out.push({ path:
|
|
1791
|
-
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" });
|
|
1792
1979
|
}
|
|
1793
1980
|
const designRefs = (design, base) => {
|
|
1794
1981
|
for (const kind of ["header", "footer"])
|
|
@@ -1875,18 +2062,22 @@ var formatRules = [
|
|
|
1875
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 }),
|
|
1876
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 }),
|
|
1877
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 }),
|
|
1878
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 }),
|
|
1879
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 }),
|
|
1880
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 }),
|
|
1881
2070
|
rule("shape-adjust-unknown", "format", "warning", "An adjust value names a guide the preset does not have.", "Each preset has its own adjust handles (DrawingML's avLst guides: `adj`, `adj1`, `adj2`, ...); a name the preset does not have changes nothing, and a custom `path` has none. The preset's default is drawn.", { standard: "ECMA-376 Part 1, 20.1.10.56 (ST_ShapeType) and presetShapeDefinitions.xml" }),
|
|
1882
2071
|
rule("shape-adjust-range", "format", "warning", "An adjust value is outside the range of the preset's handle.", "An adjust value outside the range its handle allows is pinned by the preset's own formulas, so the shape is not drawn as the value says; core draws the preset's default instead and both engines agree.", { standard: "ECMA-376 Part 1, 20.1.10.56 (ST_ShapeType) and presetShapeDefinitions.xml", approximations: "Ranges are checked at a square shape of the default size; a handle whose range depends on the shape's proportions is checked at those proportions when the shape is drawn." }),
|
|
1883
2072
|
rule("shape-link-hidden", "format", "warning", "A hidden shape carries a link.", "A hidden shape (`hidden: true`) is not drawn, so its `link` can never be clicked in a slide show.", { standard: SCHEMA }),
|
|
2073
|
+
rule("shape-path-units", "format", "warning", "A custom path is written on a grid far larger than the 0 to 1 box.", "A custom `path` without a `viewBox` is drawn in a 0 to 1 box stretched to the frame. Coordinates from 0 to 100 (or an icon's 0 to 24) put the outline far outside the frame, so it floods the slide or is not seen, with no other sign. Give the path a `viewBox` for its own grid, or write it from 0 to 1.", { standard: SCHEMA, approximations: "The extent is read from the path's end points and control points (an arc by its end point). A path whose width or height is at most three times the box is taken as a deliberate overshoot and not reported." }),
|
|
1884
2074
|
rule("shape-anchor-missing", "format", "error", "An overlay shape has no resolvable block or qualified plotted chart point.", "An overlay shape placed with `at` sits against a composed block of its slide, named by the block's `id`. A chart point also requires a unique plotted category and series in a qualified shared plot. When an identity or geometry is missing, the shape is not drawn.", { standard: SCHEMA }),
|
|
1885
2075
|
rule("shape-anchor-size-unit", "format", "warning", "A pixel size is under a fraction key.", "In `at`, `width` and `height` are fractions of the block (up to 8); pixels are `widthPx` and `heightPx`. A value above 4 and up to 8 is reported here; above 8 it is a schema error that offers the same rename.", { standard: SCHEMA }),
|
|
1886
2076
|
rule("connector-end-missing", "format", "error", "A connector end names no block or overlay shape on the slide.", "A connector joins two shapes of its slide, each named by the `id` of a block or an overlay shape. With an end that names nothing (or names a connector) there is nothing to glue it to, so it is not drawn.", { standard: SCHEMA }),
|
|
1887
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 }),
|
|
1888
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 }),
|
|
1889
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 }),
|
|
1890
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 }),
|
|
1891
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 }),
|
|
1892
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 }),
|
|
@@ -1896,6 +2087,7 @@ var formatRules = [
|
|
|
1896
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 }),
|
|
1897
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 }),
|
|
1898
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 }),
|
|
1899
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 }),
|
|
1900
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 }),
|
|
1901
2093
|
rule(
|
|
@@ -1982,6 +2174,8 @@ var referenceRules = [
|
|
|
1982
2174
|
rule("variable-unknown", "references", "warning", "A `{{token}}` names a variable that is not declared.", "An undeclared token is shown literally.", { standard: SCHEMA }),
|
|
1983
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 }),
|
|
1984
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." }),
|
|
1985
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 })
|
|
1986
2180
|
];
|
|
1987
2181
|
var policyRules = [
|
|
@@ -2004,8 +2198,22 @@ var dataRules = [
|
|
|
2004
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.',
|
|
2005
2199
|
{ standard: SCHEMA }
|
|
2006
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 }),
|
|
2007
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 }),
|
|
2008
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 }),
|
|
2009
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." }),
|
|
2010
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 }),
|
|
2011
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 }),
|
|
@@ -2375,15 +2583,16 @@ var layoutMonotonyRule = rule(
|
|
|
2375
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."
|
|
2376
2584
|
}
|
|
2377
2585
|
);
|
|
2378
|
-
var
|
|
2379
|
-
"
|
|
2380
|
-
"
|
|
2381
|
-
"
|
|
2382
|
-
|
|
2383
|
-
"
|
|
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.",
|
|
2384
2592
|
{
|
|
2385
|
-
|
|
2386
|
-
|
|
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."
|
|
2387
2596
|
}
|
|
2388
2597
|
);
|
|
2389
2598
|
var PIE_MAX_SLICES = 5;
|
|
@@ -2447,7 +2656,7 @@ var implementedRules = [
|
|
|
2447
2656
|
centeredBodyRule,
|
|
2448
2657
|
tightSpacingRule,
|
|
2449
2658
|
layoutMonotonyRule,
|
|
2450
|
-
|
|
2659
|
+
variableOverflowRule,
|
|
2451
2660
|
chartDualAxisRule,
|
|
2452
2661
|
chartPieManySlicesRule
|
|
2453
2662
|
];
|
|
@@ -2507,7 +2716,7 @@ function collectSamples(context) {
|
|
|
2507
2716
|
const scale = Math.min(design.dimensions.width, design.dimensions.height) / 720;
|
|
2508
2717
|
for (const item of composition.items) {
|
|
2509
2718
|
const itemDesign = item.emphasis && surfaceDesign ? surfaceDesign : design;
|
|
2510
|
-
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;
|
|
2511
2720
|
const backdrop = item.emphasis && emphasisBackdrop ? emphasisBackdrop : item.frameBox ? surface : slideBackdrop(context, textInkBox(item, measurement));
|
|
2512
2721
|
const itemPath = pointerOfDotted(item.path);
|
|
2513
2722
|
const heading = item.field === "title" || item.field === "subtitle" || item.field === "tag";
|
|
@@ -3161,10 +3370,10 @@ function canonicalJson(value) {
|
|
|
3161
3370
|
if (Array.isArray(item)) {
|
|
3162
3371
|
text2 = `[${item.map((entry2) => write(entry2) ?? "null").join(",")}]`;
|
|
3163
3372
|
} else {
|
|
3164
|
-
const
|
|
3373
|
+
const record2 = item;
|
|
3165
3374
|
const members = [];
|
|
3166
|
-
for (const key3 of Object.keys(
|
|
3167
|
-
const member = write(
|
|
3375
|
+
for (const key3 of Object.keys(record2).sort()) {
|
|
3376
|
+
const member = write(record2[key3]);
|
|
3168
3377
|
if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
|
|
3169
3378
|
}
|
|
3170
3379
|
text2 = `{${members.join(",")}}`;
|
|
@@ -3347,7 +3556,7 @@ function renamedRegion(layout, region) {
|
|
|
3347
3556
|
const names2 = Object.hasOwn(RENAMED_REGIONS, layout) ? RENAMED_REGIONS[layout] : void 0;
|
|
3348
3557
|
return names2 && Object.hasOwn(names2, region) ? names2[region] : void 0;
|
|
3349
3558
|
}
|
|
3350
|
-
function layoutRegionNames(
|
|
3559
|
+
function layoutRegionNames(record2) {
|
|
3351
3560
|
const names2 = /* @__PURE__ */ new Set();
|
|
3352
3561
|
const walk2 = (regions) => {
|
|
3353
3562
|
if (!Array.isArray(regions)) return;
|
|
@@ -3357,16 +3566,16 @@ function layoutRegionNames(record) {
|
|
|
3357
3566
|
walk2(region.regions);
|
|
3358
3567
|
}
|
|
3359
3568
|
};
|
|
3360
|
-
walk2(rec2(
|
|
3569
|
+
walk2(rec2(record2).regions);
|
|
3361
3570
|
return names2;
|
|
3362
3571
|
}
|
|
3363
|
-
function layoutRecordIssues(id,
|
|
3364
|
-
return validateAgainstSchema(isRec2(
|
|
3572
|
+
function layoutRecordIssues(id, record2) {
|
|
3573
|
+
return validateAgainstSchema(isRec2(record2) ? { $schema: schemas[catalogSchemaNames.layouts].$id, id, ...record2 } : record2, "layouts").errors;
|
|
3365
3574
|
}
|
|
3366
3575
|
function staleLayoutCopy(document, group, id, options2 = {}) {
|
|
3367
3576
|
if (group === "custom") return void 0;
|
|
3368
|
-
const
|
|
3369
|
-
if (!isRec2(
|
|
3577
|
+
const record2 = embeddedLayouts(document, group)[id];
|
|
3578
|
+
if (!isRec2(record2)) return void 0;
|
|
3370
3579
|
const registered = rec2(registeredCatalog(catalogGroupSource(document, group, options2), options2)?.layouts);
|
|
3371
3580
|
const base = { group, id, path: pointer3(["catalogs", group, "layouts", id]) };
|
|
3372
3581
|
if (isRec2(registered[id])) return { ...base, current: embeddedCopy(registered[id]) };
|
|
@@ -3396,11 +3605,11 @@ function pinOperations(document, index, layout, before, next) {
|
|
|
3396
3605
|
const names2 = layoutRegionNames(next);
|
|
3397
3606
|
const blocks = slideAt(document, index).blocks;
|
|
3398
3607
|
const ops = [];
|
|
3399
|
-
(Array.isArray(blocks) ? blocks : []).forEach((block,
|
|
3608
|
+
(Array.isArray(blocks) ? blocks : []).forEach((block, at3) => {
|
|
3400
3609
|
const pin = rec2(block).region;
|
|
3401
3610
|
if (typeof pin !== "string" || names2.has(pin) || !before.has(pin)) return;
|
|
3402
3611
|
const renamed = renamedRegion(layout, pin);
|
|
3403
|
-
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 });
|
|
3404
3613
|
});
|
|
3405
3614
|
return ops;
|
|
3406
3615
|
}
|
|
@@ -3441,8 +3650,8 @@ function staleCopyFix(document, copy, options2 = {}) {
|
|
|
3441
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 };
|
|
3442
3651
|
}
|
|
3443
3652
|
var applyOperation = (root, operation) => {
|
|
3444
|
-
const segmentsOf2 = (path) => path.slice(1).split("/").map((
|
|
3445
|
-
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);
|
|
3446
3655
|
const segments = segmentsOf2(operation.path);
|
|
3447
3656
|
if (operation.op === "move") {
|
|
3448
3657
|
const from = segmentsOf2(operation.from);
|
|
@@ -3456,8 +3665,8 @@ function refreshStaleLayouts(document, options2 = {}) {
|
|
|
3456
3665
|
const refreshed = [];
|
|
3457
3666
|
for (const [group, value] of Object.entries(rec2(document.catalogs))) {
|
|
3458
3667
|
if (group === "custom" || !isRec2(value) || !isRec2(value.layouts)) continue;
|
|
3459
|
-
for (const [id,
|
|
3460
|
-
if (!layoutRecordIssues(id,
|
|
3668
|
+
for (const [id, record2] of Object.entries(value.layouts)) {
|
|
3669
|
+
if (!layoutRecordIssues(id, record2).length) continue;
|
|
3461
3670
|
const copy = staleLayoutCopy(document, group, id, options2);
|
|
3462
3671
|
if (!copy || !(copy.current || copy.renamed?.current)) continue;
|
|
3463
3672
|
const patch2 = staleCopyPatch(document, copy, options2);
|
|
@@ -3518,6 +3727,8 @@ var layoutRules = [
|
|
|
3518
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." });
|
|
3519
3728
|
else if (diagnostic.code === "chart-label-collision")
|
|
3520
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;
|
|
3521
3732
|
else if (diagnostic.code === "timeline-period-short")
|
|
3522
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." });
|
|
3523
3734
|
else if (Object.hasOwn(REGION_RULES, diagnostic.code)) {
|
|
@@ -3550,7 +3761,7 @@ var layoutRules = [
|
|
|
3550
3761
|
path,
|
|
3551
3762
|
slide,
|
|
3552
3763
|
message: `${label} is drawn at ${round2(sizePx * PX_TO_PT2)} pt${scale === 1 ? "" : " (reference slide size)"}, below the ${context.thresholds.minFontSizePt} pt minimum.`,
|
|
3553
|
-
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.",
|
|
3554
3765
|
measured: { sizePt: round2(sizePx * PX_TO_PT2, 2), minimumPt: context.thresholds.minFontSizePt }
|
|
3555
3766
|
});
|
|
3556
3767
|
};
|
|
@@ -3709,7 +3920,7 @@ var contentRules = [
|
|
|
3709
3920
|
if (slide.slide.layout === "blank") continue;
|
|
3710
3921
|
const has = (value) => value !== void 0 && value !== null && !(typeof value === "string" && value.trim() === "") && !(Array.isArray(value) && value.length === 0);
|
|
3711
3922
|
const hasText = slide.texts.some((tv) => plainText(tv.value).trim() !== "");
|
|
3712
|
-
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])));
|
|
3713
3924
|
const hasBackgroundImage = imageBackground(rec(slide.slide.design).background) !== void 0;
|
|
3714
3925
|
if (hasText || hasObject || hasBackgroundImage) continue;
|
|
3715
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." });
|
|
@@ -3734,9 +3945,9 @@ var FRAMING_LAYOUTS = /* @__PURE__ */ new Set(["cover", "section", "closing"]);
|
|
|
3734
3945
|
function setsRunSize(value, depth2 = 0) {
|
|
3735
3946
|
if (depth2 > 6 || value === null || typeof value !== "object") return false;
|
|
3736
3947
|
if (Array.isArray(value)) return value.some((entry2) => setsRunSize(entry2, depth2 + 1));
|
|
3737
|
-
const
|
|
3738
|
-
if (typeof
|
|
3739
|
-
return ["text", "description", "rows", "columns", "value"].some((key3) => setsRunSize(
|
|
3948
|
+
const object3 = value;
|
|
3949
|
+
if (typeof object3.fontSize === "number") return true;
|
|
3950
|
+
return ["text", "description", "rows", "columns", "value"].some((key3) => setsRunSize(object3[key3], depth2 + 1));
|
|
3740
3951
|
}
|
|
3741
3952
|
var ROLE_SIZE = { text: PROSE_NOMINAL_SIZE, items: LIST_NOMINAL_SIZE, bullets: LIST_NOMINAL_SIZE, table: TABLE_NOMINAL_SIZE, quote: QUOTE_NOMINAL_SIZE, code: CODE_NOMINAL_SIZE };
|
|
3742
3953
|
function fittedSize(item, slide, document) {
|
|
@@ -3748,7 +3959,7 @@ function fittedSize(item, slide, document) {
|
|
|
3748
3959
|
if (item.field === "code") return body(item.codeLayout?.parts);
|
|
3749
3960
|
if (item.field === "table") {
|
|
3750
3961
|
try {
|
|
3751
|
-
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 });
|
|
3752
3963
|
if (table.overflow) return void 0;
|
|
3753
3964
|
const sizes = table.rows.flatMap((row) => row.cells.filter((cell) => !cell.header).map((cell) => cell.fit.fontSize));
|
|
3754
3965
|
return sizes.length ? Math.min(...sizes) : void 0;
|
|
@@ -3897,7 +4108,7 @@ var tightSpacing = {
|
|
|
3897
4108
|
}
|
|
3898
4109
|
}
|
|
3899
4110
|
};
|
|
3900
|
-
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) => {
|
|
3901
4112
|
const value = payload.node[field];
|
|
3902
4113
|
return value !== void 0 && value !== null && !(Array.isArray(value) && value.length === 0) && !(typeof value === "string" && value.trim() === "");
|
|
3903
4114
|
}));
|
|
@@ -3931,63 +4142,7 @@ var layoutMonotony = {
|
|
|
3931
4142
|
flush();
|
|
3932
4143
|
}
|
|
3933
4144
|
};
|
|
3934
|
-
var
|
|
3935
|
-
var LETTER = /[\p{L}\p{N}]/u;
|
|
3936
|
-
var OPENING = /[\s([{—–-]/u;
|
|
3937
|
-
function straightQuoteMarks(text2) {
|
|
3938
|
-
let double = 0, single = 0, open = false;
|
|
3939
|
-
for (let i = 0; i < text2.length; i++) {
|
|
3940
|
-
const char = text2[i], before = text2[i - 1] ?? "", after = text2[i + 1] ?? "";
|
|
3941
|
-
if (char === '"') {
|
|
3942
|
-
if (!/\d/.test(before)) double++;
|
|
3943
|
-
} else if (char === "'") {
|
|
3944
|
-
const wordAfter = LETTER.test(after), opens = before === "" || OPENING.test(before);
|
|
3945
|
-
if (LETTER.test(before) && wordAfter || /\d/.test(before)) continue;
|
|
3946
|
-
if (opens && wordAfter && !/\d/.test(after)) open = true;
|
|
3947
|
-
else if (!opens && !wordAfter && open) {
|
|
3948
|
-
single += 2;
|
|
3949
|
-
open = false;
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
}
|
|
3953
|
-
return { double, single };
|
|
3954
|
-
}
|
|
3955
|
-
function curlDoubleQuotes(text2, marks) {
|
|
3956
|
-
return text2.replace(/(^|.)"/gsu, (whole, before) => /\d/.test(before) ? whole : `${before}${before === "" || OPENING.test(before) ? marks.open : marks.close}`);
|
|
3957
|
-
}
|
|
3958
|
-
var straightQuotes = {
|
|
3959
|
-
info: straightQuotesRule,
|
|
3960
|
-
run(context) {
|
|
3961
|
-
for (const slide of context.slides) {
|
|
3962
|
-
const marks = quoteMarksFor(quoteLanguage(context.document, slide.index));
|
|
3963
|
-
if (marks.open === '"') continue;
|
|
3964
|
-
for (const tv of slide.texts) {
|
|
3965
|
-
if (!PROSE_ROLES.has(tv.role)) continue;
|
|
3966
|
-
let double = 0, single = 0;
|
|
3967
|
-
const fixes = [];
|
|
3968
|
-
for (const run of runsOf(tv)) {
|
|
3969
|
-
if (run.style.code === true) continue;
|
|
3970
|
-
const found = straightQuoteMarks(run.text);
|
|
3971
|
-
double += found.double;
|
|
3972
|
-
single += found.single;
|
|
3973
|
-
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) });
|
|
3974
|
-
}
|
|
3975
|
-
if (!double && !single) continue;
|
|
3976
|
-
const kinds = [double ? `${double} straight double quote${double === 1 ? "" : "s"} (")` : "", single ? `${single} straight single quotes (')` : ""].filter(Boolean).join(" and ");
|
|
3977
|
-
const text2 = plainText(tv.value);
|
|
3978
|
-
context.report(straightQuotesRule, {
|
|
3979
|
-
path: tv.path,
|
|
3980
|
-
slide,
|
|
3981
|
-
message: `Text has ${kinds}: ${JSON.stringify(text2.length > 60 ? `${text2.slice(0, 57)}...` : text2)}.`,
|
|
3982
|
-
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." : ""}`,
|
|
3983
|
-
measured: { double, single, open: marks.open, close: marks.close },
|
|
3984
|
-
...!single && fixes.length ? { fixes: [{ id: "use-typographic-quotes", title: `Use ${marks.open}${marks.close}`, kind: "patch", safe: false, patch: fixes }] } : {}
|
|
3985
|
-
});
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
};
|
|
3990
|
-
var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony, straightQuotes];
|
|
4145
|
+
var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony];
|
|
3991
4146
|
|
|
3992
4147
|
// src/rules-chart-findings.ts
|
|
3993
4148
|
var chartPath = (payloadPath, slidePath) => `${payloadPath === slidePath ? slidePath : payloadPath}/chart`;
|
|
@@ -4034,110 +4189,610 @@ var chartPieManySlices = {
|
|
|
4034
4189
|
};
|
|
4035
4190
|
var chartFindingRules = [chartDualAxis, chartPieManySlices];
|
|
4036
4191
|
|
|
4037
|
-
// src/
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
const list = entry2.values ?? entry2.data;
|
|
4058
|
-
const name = entry2.name ?? entry2.label;
|
|
4059
|
-
if (!Array.isArray(list) || list.length !== labels.length || !list.every(isCell)) return void 0;
|
|
4060
|
-
columns.push(typeof name === "string" && name ? name : `Series ${index + 1}`);
|
|
4061
|
-
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
|
+
}
|
|
4062
4212
|
}
|
|
4063
|
-
|
|
4064
|
-
return { columns, rows: labels.map((label, row) => [label, ...values.map((list) => list[row])]) };
|
|
4065
|
-
}
|
|
4066
|
-
function chartShapePatch(chart, path) {
|
|
4067
|
-
if (!isRecord3(chart)) return void 0;
|
|
4068
|
-
const data = convertChartData(chart);
|
|
4069
|
-
const keys = foreignChartKeys(chart);
|
|
4070
|
-
if (!data || !keys.length) return void 0;
|
|
4071
|
-
return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
|
|
4072
|
-
}
|
|
4073
|
-
var SHOWN_ROWS = 3;
|
|
4074
|
-
var json = (value) => JSON.stringify(value);
|
|
4075
|
-
function dataExample(chart) {
|
|
4076
|
-
const data = convertChartData(chart);
|
|
4077
|
-
if (!data) return '"data": { "columns": ["Category", "Series name"], "rows": [["Q1", 3], ["Q2", 8]] }';
|
|
4078
|
-
const rows = data.rows.slice(0, SHOWN_ROWS).map(json);
|
|
4079
|
-
return `"data": { "columns": ${json(data.columns)}, "rows": [${rows.join(",")}${data.rows.length > SHOWN_ROWS ? ",..." : ""}] }`;
|
|
4213
|
+
return drawn;
|
|
4080
4214
|
}
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
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
|
+
};
|
|
4087
4229
|
return {
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
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
|
|
4091
4237
|
};
|
|
4092
4238
|
}
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
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;
|
|
4104
4268
|
}
|
|
4105
|
-
function
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
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" });
|
|
4110
4275
|
}
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
) || 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")
|
|
4125
|
-
throw new TypeError(
|
|
4126
|
-
"Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
|
|
4127
|
-
);
|
|
4128
|
-
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;
|
|
4129
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;
|
|
4130
4295
|
}
|
|
4131
|
-
function
|
|
4132
|
-
const
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
}
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
const
|
|
4139
|
-
|
|
4140
|
-
|
|
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)) };
|
|
4306
|
+
}
|
|
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}`);
|
|
4795
|
+
const precise = validationDefinition(issue2);
|
|
4141
4796
|
const definition = precise?.uri ?? (issue2.keyword === "opf" ? "packages/javascript/src/schema-check.ts" : issue2.schemaPath.startsWith("#") ? entry2.schema.$id + issue2.schemaPath : issue2.schemaPath);
|
|
4142
4797
|
const lookup = [
|
|
4143
4798
|
"opf",
|
|
@@ -4147,7 +4802,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4147
4802
|
];
|
|
4148
4803
|
let help = "Inspect this schema constraint and preserve unrelated content. Errors inside oneOf/anyOf branches may describe alternatives; retain the intended form.";
|
|
4149
4804
|
if (issue2.keyword === "required" && issue2.params.missingProperty === "id" && /^\/(organization|speaker)(\/\d+)?$/.test(issue2.path))
|
|
4150
|
-
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).`;
|
|
4151
4806
|
else if (issue2.keyword === "required")
|
|
4152
4807
|
help = `Add the required ${JSON.stringify(issue2.params.missingProperty)} field in this object, using the intended schema form.`;
|
|
4153
4808
|
else if (issue2.keyword === "additionalProperties")
|
|
@@ -4168,6 +4823,8 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4168
4823
|
help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
|
|
4169
4824
|
else if (typedName !== void 0 && typeof nearest2[0]?.value === "string")
|
|
4170
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)}.`;
|
|
4171
4828
|
return finding(ruleId, {
|
|
4172
4829
|
...severity ? { severity } : {},
|
|
4173
4830
|
path,
|
|
@@ -4176,7 +4833,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
4176
4833
|
help,
|
|
4177
4834
|
definition,
|
|
4178
4835
|
lookup,
|
|
4179
|
-
validation: issue2,
|
|
4836
|
+
validation: unknownKey ? { ...issue2, params: { ...issue2.params, validatorVersion: OPF_CORE_VERSION } } : issue2,
|
|
4180
4837
|
...allowed.length ? {
|
|
4181
4838
|
suggestions: allowed.map((value) => ({
|
|
4182
4839
|
value,
|
|
@@ -4228,8 +4885,8 @@ function resolve(cursor, seen = /* @__PURE__ */ new Set()) {
|
|
|
4228
4885
|
seen.add(id);
|
|
4229
4886
|
const [base, fragment = ""] = ref.split("#"), root = base ? schemaEntries.find((entry2) => entry2.schema.$id === base)?.schema : cursor.root;
|
|
4230
4887
|
if (!root) return { ...cursor, schema: {} };
|
|
4231
|
-
const target =
|
|
4232
|
-
if (!
|
|
4888
|
+
const target = at2(root, fragment);
|
|
4889
|
+
if (!object2(target)) return { ...cursor, schema: {} };
|
|
4233
4890
|
const resolved2 = resolve(
|
|
4234
4891
|
{ schema: target, root, path: fragment },
|
|
4235
4892
|
seen
|
|
@@ -4239,18 +4896,18 @@ function resolve(cursor, seen = /* @__PURE__ */ new Set()) {
|
|
|
4239
4896
|
}
|
|
4240
4897
|
function score(schema, value) {
|
|
4241
4898
|
const type = schema.type;
|
|
4242
|
-
if (typeof type === "string" && (type === "array" ? !Array.isArray(value) : type === "object" ? !
|
|
4899
|
+
if (typeof type === "string" && (type === "array" ? !Array.isArray(value) : type === "object" ? !object2(value) : type === "null" ? value !== null : type === "integer" ? !Number.isInteger(value) : typeof value !== type))
|
|
4243
4900
|
return -1e4;
|
|
4244
4901
|
if (own(schema, "const")) return schema.const === value ? 100 : -1e4;
|
|
4245
4902
|
let result = 1;
|
|
4246
|
-
if (
|
|
4903
|
+
if (object2(value) && object2(schema.properties)) {
|
|
4247
4904
|
for (const [key3, child] of Object.entries(schema.properties))
|
|
4248
|
-
if (own(value, key3) &&
|
|
4905
|
+
if (own(value, key3) && object2(child))
|
|
4249
4906
|
result += own(child, "const") ? child.const === value[key3] ? 100 : -1e3 : 1;
|
|
4250
4907
|
}
|
|
4251
4908
|
if (Array.isArray(schema.required)) {
|
|
4252
4909
|
for (const key3 of schema.required)
|
|
4253
|
-
if (typeof key3 === "string" && (!
|
|
4910
|
+
if (typeof key3 === "string" && (!object2(value) || !own(value, key3)))
|
|
4254
4911
|
result -= 2;
|
|
4255
4912
|
}
|
|
4256
4913
|
return result;
|
|
@@ -4259,7 +4916,7 @@ function active(cursor, value) {
|
|
|
4259
4916
|
const resolved2 = resolve(cursor), alternatives = resolved2.schema.oneOf ?? resolved2.schema.anyOf;
|
|
4260
4917
|
if (!Array.isArray(alternatives)) return resolved2;
|
|
4261
4918
|
const keyword = resolved2.schema.oneOf ? "oneOf" : "anyOf";
|
|
4262
|
-
const candidates = alternatives.filter(
|
|
4919
|
+
const candidates = alternatives.filter(object2).map(
|
|
4263
4920
|
(schema, index) => active(
|
|
4264
4921
|
{
|
|
4265
4922
|
schema,
|
|
@@ -4280,12 +4937,12 @@ function childCursor(cursors, key3) {
|
|
|
4280
4937
|
]) {
|
|
4281
4938
|
for (const cursor of cursors) {
|
|
4282
4939
|
const declarations = cursor.schema[keyword];
|
|
4283
|
-
if (!
|
|
4940
|
+
if (!object2(declarations)) continue;
|
|
4284
4941
|
const name = keyword === "properties" ? key3 : keyword === "patternProperties" ? Object.keys(declarations).find(
|
|
4285
4942
|
(pattern) => new RegExp(pattern).test(key3)
|
|
4286
4943
|
) : void 0;
|
|
4287
4944
|
const schema = keyword === "additionalProperties" ? declarations : name === void 0 ? void 0 : declarations[name];
|
|
4288
|
-
if (
|
|
4945
|
+
if (object2(schema))
|
|
4289
4946
|
return {
|
|
4290
4947
|
schema,
|
|
4291
4948
|
root: cursor.root,
|
|
@@ -4326,7 +4983,7 @@ function fields(document) {
|
|
|
4326
4983
|
});
|
|
4327
4984
|
const ancestors = [...entry2.ancestors, entry2.value];
|
|
4328
4985
|
const cursors = [selected, ...selected.baseSchemas ?? [], resolved2];
|
|
4329
|
-
const arrayCursor = cursors.find((cursor) =>
|
|
4986
|
+
const arrayCursor = cursors.find((cursor) => object2(cursor.schema.items));
|
|
4330
4987
|
if (Array.isArray(entry2.value) && arrayCursor)
|
|
4331
4988
|
entry2.value.forEach((value, index) => {
|
|
4332
4989
|
stack.push({
|
|
@@ -4340,7 +4997,7 @@ function fields(document) {
|
|
|
4340
4997
|
ancestors
|
|
4341
4998
|
});
|
|
4342
4999
|
});
|
|
4343
|
-
else if (
|
|
5000
|
+
else if (object2(entry2.value))
|
|
4344
5001
|
for (const [key3, value] of Object.entries(entry2.value)) {
|
|
4345
5002
|
if (entry2.path.length === 0 && key3 === "catalogs") continue;
|
|
4346
5003
|
const cursor = childCursor(cursors, key3);
|
|
@@ -4357,25 +5014,21 @@ function fields(document) {
|
|
|
4357
5014
|
}
|
|
4358
5015
|
var recordRuleId = (issue2) => issue2.keyword === "opf" && (issue2.params.code === "layout-template" || issue2.params.code === "layout-region") ? `opf/${issue2.params.code}` : "opf/catalog-record";
|
|
4359
5016
|
var recordKey = (group, kind, id) => `${group}/${kind}/${id}`;
|
|
4360
|
-
function recordIssues(kind, id, value) {
|
|
4361
|
-
const schemaName = catalogSchemaNames[kind];
|
|
4362
|
-
return validateAgainstSchema(object(value) ? { $schema: schemas[schemaName].$id, id, ...value } : value, kind);
|
|
4363
|
-
}
|
|
4364
5017
|
function embeddedRecordFindings(document, options2, findings) {
|
|
4365
5018
|
const invalid = /* @__PURE__ */ new Set();
|
|
4366
|
-
if (!
|
|
5019
|
+
if (!object2(document) || !object2(document.catalogs)) return invalid;
|
|
4367
5020
|
for (const [group, value] of Object.entries(document.catalogs)) {
|
|
4368
|
-
if (!
|
|
4369
|
-
for (const [id,
|
|
4370
|
-
if (
|
|
4371
|
-
const validation = validateAgainstSchema(
|
|
5021
|
+
if (!object2(value)) continue;
|
|
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");
|
|
4372
5025
|
for (const issue2 of validation.errors) findings.push(issueFinding(issue2, "opf/catalog-record", "iconSet", pointer4(["catalogs", group, "iconSets", id]), "document"));
|
|
4373
5026
|
}
|
|
4374
5027
|
for (const kind of catalogKinds)
|
|
4375
|
-
for (const [id,
|
|
5028
|
+
for (const [id, record2] of Object.entries(object2(value[kind]) ? value[kind] : {})) {
|
|
4376
5029
|
const path = pointer4(["catalogs", group, kind, id]);
|
|
4377
|
-
if (
|
|
4378
|
-
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);
|
|
4379
5032
|
for (const issue2 of validation.errors) findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[kind], path, "document"));
|
|
4380
5033
|
if (!validation.valid) invalid.add(recordKey(group, kind, id));
|
|
4381
5034
|
if (group === "custom") continue;
|
|
@@ -4429,9 +5082,23 @@ function chartNumberFixPaths(document) {
|
|
|
4429
5082
|
}
|
|
4430
5083
|
var HELP = {
|
|
4431
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.",
|
|
4432
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.",
|
|
4433
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.",
|
|
4434
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.",
|
|
4435
5102
|
"slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
|
|
4436
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.",
|
|
4437
5104
|
"code-highlight-range-reversed": "Write the range with the smaller line number first, or remove it. A reversed range marks nothing.",
|
|
@@ -4439,6 +5106,8 @@ var HELP = {
|
|
|
4439
5106
|
"variable-unknown": "Declare the variable in the top-level variables map, or write '\\{{' for literal braces.",
|
|
4440
5107
|
"variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
|
|
4441
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.",
|
|
4442
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.",
|
|
4443
5112
|
"variable-reference-unknown": "Declare the variable in the top-level variables map, or use another color.",
|
|
4444
5113
|
"run-color-unrecognized": "Use a #RRGGBB hex color, a color-scheme name or a var: reference to a declared color variable.",
|
|
@@ -4451,7 +5120,7 @@ function semanticHelp(issue2) {
|
|
|
4451
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": "..." } }.`;
|
|
4452
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".`;
|
|
4453
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.';
|
|
4454
|
-
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.";
|
|
4455
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".';
|
|
4456
5125
|
return "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
|
|
4457
5126
|
}
|
|
@@ -4460,27 +5129,27 @@ var BACKGROUND_HELP = `A background is a string (a theme slot such as "light1",
|
|
|
4460
5129
|
function collapseAuthoringShapes(document, findings) {
|
|
4461
5130
|
const valueAt = (path) => {
|
|
4462
5131
|
let node = document;
|
|
4463
|
-
for (const
|
|
5132
|
+
for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
|
|
4464
5133
|
return node;
|
|
4465
5134
|
};
|
|
4466
5135
|
const schema = (entry2) => entry2?.ruleId === "opf/schema";
|
|
4467
5136
|
const fills = /* @__PURE__ */ new Map();
|
|
4468
5137
|
for (const entry2 of findings) {
|
|
4469
5138
|
if (!schema(entry2)) continue;
|
|
4470
|
-
const
|
|
4471
|
-
if (!
|
|
4472
|
-
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);
|
|
4473
5142
|
if (!isRecord(fill) || Object.hasOwn(fill, "lighten") || Object.hasOwn(fill, "darken")) continue;
|
|
4474
5143
|
const solid = (fill.type === "solid" || fill.type === void 0) && fill.color !== void 0 && !Object.hasOwn(fill, "gradient") && !Object.hasOwn(fill, "pattern");
|
|
4475
5144
|
const typed = fill.type === "gradient" && isRecord(fill.gradient) || fill.type === "pattern" && isRecord(fill.pattern);
|
|
4476
5145
|
if (!solid && !typed) continue;
|
|
4477
5146
|
const color = typeof fill.color === "string" ? JSON.stringify(fill.color) : '"accent1"';
|
|
4478
|
-
fills.set(
|
|
5147
|
+
fills.set(at3, {
|
|
4479
5148
|
...entry2,
|
|
4480
|
-
path:
|
|
5149
|
+
path: at3,
|
|
4481
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)}: { ... } }.`,
|
|
4482
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".`,
|
|
4483
|
-
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` }] }]
|
|
4484
5153
|
});
|
|
4485
5154
|
}
|
|
4486
5155
|
if (fills.size) {
|
|
@@ -4488,38 +5157,38 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4488
5157
|
for (let index = 0; index < findings.length; index++) {
|
|
4489
5158
|
const entry2 = findings[index];
|
|
4490
5159
|
if (!schema(entry2)) continue;
|
|
4491
|
-
const
|
|
4492
|
-
if (!
|
|
4493
|
-
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)) {
|
|
4494
5163
|
findings.splice(index--, 1);
|
|
4495
5164
|
continue;
|
|
4496
5165
|
}
|
|
4497
|
-
seen.add(
|
|
4498
|
-
findings[index] = fills.get(
|
|
5166
|
+
seen.add(at3);
|
|
5167
|
+
findings[index] = fills.get(at3);
|
|
4499
5168
|
}
|
|
4500
5169
|
}
|
|
4501
5170
|
const backgrounds = /* @__PURE__ */ new Set();
|
|
4502
5171
|
for (const entry2 of findings) {
|
|
4503
5172
|
if (!schema(entry2)) continue;
|
|
4504
|
-
const
|
|
4505
|
-
if (!
|
|
4506
|
-
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;
|
|
4507
5176
|
if (typeof background === "string" || isRecord(background) && typeof type === "string" && BACKGROUND_TYPES.includes(type)) continue;
|
|
4508
|
-
backgrounds.add(
|
|
5177
|
+
backgrounds.add(at3);
|
|
4509
5178
|
}
|
|
4510
|
-
for (const
|
|
4511
|
-
const background = valueAt(
|
|
4512
|
-
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}/`)));
|
|
4513
5182
|
const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
|
|
4514
5183
|
const one = {
|
|
4515
5184
|
...kept,
|
|
4516
|
-
path:
|
|
5185
|
+
path: at3,
|
|
4517
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.",
|
|
4518
5187
|
help: BACKGROUND_HELP
|
|
4519
5188
|
};
|
|
4520
5189
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4521
5190
|
const entry2 = findings[index];
|
|
4522
|
-
if (schema(entry2) && (entry2.path ===
|
|
5191
|
+
if (schema(entry2) && (entry2.path === at3 || entry2.path.startsWith(`${at3}/`))) findings.splice(index, 1);
|
|
4523
5192
|
}
|
|
4524
5193
|
findings.splice(first, 0, one);
|
|
4525
5194
|
}
|
|
@@ -4532,8 +5201,8 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4532
5201
|
for (const [index, entry2] of findings.entries()) {
|
|
4533
5202
|
if (!schema(entry2) || entry2.validation?.keyword !== "maximum") continue;
|
|
4534
5203
|
const match2 = /^(\/slides\/\d+\/shapes\/\d+\/at)\/(width|height)$/.exec(entry2.path);
|
|
4535
|
-
const
|
|
4536
|
-
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;
|
|
4537
5206
|
const px = `${key3}Px`;
|
|
4538
5207
|
findings[index] = {
|
|
4539
5208
|
...entry2,
|
|
@@ -4549,7 +5218,7 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4549
5218
|
if (isRecord(payload) && payload.type === "list" && Object.hasOwn(payload, "bullets")) findings.splice(index, 1);
|
|
4550
5219
|
}
|
|
4551
5220
|
const OPTION_RULES = ["opf/image-option-unsupported-payload", "opf/shape-option-unsupported-payload", "opf/caption-unsupported-payload"];
|
|
4552
|
-
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);
|
|
4553
5222
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4554
5223
|
const entry2 = findings[index];
|
|
4555
5224
|
if (!schema(entry2) || !optionDefinition(entry2)) continue;
|
|
@@ -4563,8 +5232,8 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4563
5232
|
const value = valueAt(entry2.path);
|
|
4564
5233
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value)) payloadSlots.set(entry2.path, value);
|
|
4565
5234
|
}
|
|
4566
|
-
for (const [
|
|
4567
|
-
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);
|
|
4568
5237
|
const text2 = typeof value === "string";
|
|
4569
5238
|
const write = text2 ? `{ "text": ${JSON.stringify(value)} }` : Array.isArray(value) ? '{ "items": [ ... ] } for a list, or { "blocks": [ ... ] } for several blocks' : '{ "text": "..." }';
|
|
4570
5239
|
const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
|
|
@@ -4572,11 +5241,11 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4572
5241
|
...kept,
|
|
4573
5242
|
message: `A block holds a content payload (an object), not ${text2 ? "a bare string" : Array.isArray(value) ? "a list" : "a " + typeof value}.`,
|
|
4574
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.`,
|
|
4575
|
-
...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 } }] }] } : {}
|
|
4576
5245
|
};
|
|
4577
5246
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4578
5247
|
const entry2 = findings[index];
|
|
4579
|
-
if (schema(entry2) && entry2.path ===
|
|
5248
|
+
if (schema(entry2) && entry2.path === at3) findings.splice(index, 1);
|
|
4580
5249
|
}
|
|
4581
5250
|
findings.splice(first, 0, one);
|
|
4582
5251
|
}
|
|
@@ -4584,7 +5253,7 @@ function collapseAuthoringShapes(document, findings) {
|
|
|
4584
5253
|
function collapseChartShape(document, findings) {
|
|
4585
5254
|
const chartAt = (path) => {
|
|
4586
5255
|
let node = document;
|
|
4587
|
-
for (const
|
|
5256
|
+
for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
|
|
4588
5257
|
return node;
|
|
4589
5258
|
};
|
|
4590
5259
|
const collapsed = /* @__PURE__ */ new Set();
|
|
@@ -4606,8 +5275,8 @@ function collapseChartShape(document, findings) {
|
|
|
4606
5275
|
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4607
5276
|
const entry2 = findings[index];
|
|
4608
5277
|
if (entry2?.ruleId !== "opf/schema" || entry2.validation?.keyword !== "additionalProperties") continue;
|
|
4609
|
-
const
|
|
4610
|
-
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);
|
|
4611
5280
|
}
|
|
4612
5281
|
}
|
|
4613
5282
|
function engineFindings(document, engine, enabled) {
|
|
@@ -4640,6 +5309,12 @@ function engineFindings(document, engine, enabled) {
|
|
|
4640
5309
|
const found = issueFinding(issue2, ruleId, "presentation", "", "document", code2 === "variable-group-omitted" ? "info" : "warning");
|
|
4641
5310
|
const help = HELP[code2];
|
|
4642
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 }];
|
|
4643
5318
|
if (code2 === "shape-anchor-size-unit") {
|
|
4644
5319
|
const key3 = String(issue2.params.key), px = `${key3}Px`;
|
|
4645
5320
|
found.help = `Did you mean "${px}"? "${key3}" is a fraction of the block.`;
|
|
@@ -4756,14 +5431,23 @@ function contentReferenceFindings(document, options2, findings) {
|
|
|
4756
5431
|
const stale = embeddedInvalid && site.kind === "layouts" ? staleLayoutCopy(document, embeddedInvalid.group, embeddedInvalid.id, options2) : void 0;
|
|
4757
5432
|
const diagnostic = unresolvedReference(document, site.kind, site.reference, path, options2);
|
|
4758
5433
|
if (removedLayoutAuto(site.kind, site.reference)) {
|
|
5434
|
+
const dropRecord = embeddedInvalid !== void 0 && embeddedInvalid.id === "auto" && lastLayoutAutoSite(document, embeddedInvalid.group, options2, site.path);
|
|
4759
5435
|
findings.push(
|
|
4760
5436
|
finding("opf/unresolved-reference", {
|
|
4761
5437
|
path,
|
|
4762
5438
|
message: diagnostic.message,
|
|
4763
|
-
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.` : ""}`,
|
|
4764
5440
|
definition: `${schemas.presentation.$id}#/$defs/Slide`,
|
|
4765
5441
|
lookup: ["opf", "catalog", site.kind],
|
|
4766
|
-
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
|
+
]
|
|
4767
5451
|
})
|
|
4768
5452
|
);
|
|
4769
5453
|
continue;
|
|
@@ -4791,14 +5475,14 @@ function contentReferenceFindings(document, options2, findings) {
|
|
|
4791
5475
|
continue;
|
|
4792
5476
|
}
|
|
4793
5477
|
if (embeddedInvalid) {
|
|
4794
|
-
const
|
|
5478
|
+
const at3 = pointer4(["catalogs", embeddedInvalid.group, site.kind, embeddedInvalid.id]);
|
|
4795
5479
|
const fix = stale ? staleCopyFix(document, stale, options2) : void 0;
|
|
4796
5480
|
const noun = KIND_SINGULAR[site.kind];
|
|
4797
5481
|
findings.push(
|
|
4798
5482
|
finding("opf/unresolved-reference", {
|
|
4799
5483
|
path,
|
|
4800
|
-
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 ${
|
|
4801
|
-
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.`,
|
|
4802
5486
|
definition: `${schemas.presentation.$id}#/$defs/Catalogs`,
|
|
4803
5487
|
lookup: ["opf", "catalog", site.kind],
|
|
4804
5488
|
...fix ? { fixes: [fix] } : {}
|
|
@@ -4826,7 +5510,7 @@ function referenceFindings(document, engine, options2) {
|
|
|
4826
5510
|
const findings = [];
|
|
4827
5511
|
const catalogs = { catalogs: options2.catalogs ?? [] };
|
|
4828
5512
|
contentReferenceFindings(document, catalogs, findings);
|
|
4829
|
-
const assetValues =
|
|
5513
|
+
const assetValues = object2(document) && object2(document.assets) ? document.assets : {};
|
|
4830
5514
|
for (const field of fields(document)) {
|
|
4831
5515
|
if (typeof field.value === "string" && field.value.startsWith("asset:") && field.assetReference) {
|
|
4832
5516
|
const id = field.value.slice(6);
|
|
@@ -4871,7 +5555,7 @@ function referenceFindings(document, engine, options2) {
|
|
|
4871
5555
|
}
|
|
4872
5556
|
seenIds.add(current);
|
|
4873
5557
|
chain.push(current);
|
|
4874
|
-
const value = assetValues[current], source =
|
|
5558
|
+
const value = assetValues[current], source = object2(value) ? value.src : value;
|
|
4875
5559
|
current = typeof source === "string" && source.startsWith("asset:") ? source.slice(6) : void 0;
|
|
4876
5560
|
}
|
|
4877
5561
|
}
|
|
@@ -4917,7 +5601,7 @@ function referenceFindings(document, engine, options2) {
|
|
|
4917
5601
|
}
|
|
4918
5602
|
function narrativeFindings(document, options2) {
|
|
4919
5603
|
const findings = [];
|
|
4920
|
-
if (!
|
|
5604
|
+
if (!object2(document)) return findings;
|
|
4921
5605
|
const narrative = resolveNarrative(document, options2);
|
|
4922
5606
|
if (narrative) {
|
|
4923
5607
|
const id = String(document.narrative);
|
|
@@ -4945,9 +5629,9 @@ function narrativeFindings(document, options2) {
|
|
|
4945
5629
|
})
|
|
4946
5630
|
);
|
|
4947
5631
|
}
|
|
4948
|
-
for (const [group, value] of Object.entries(
|
|
4949
|
-
for (const [id,
|
|
4950
|
-
if (durationRangeInverted(
|
|
5632
|
+
for (const [group, value] of Object.entries(object2(document.catalogs) ? document.catalogs : {}))
|
|
5633
|
+
for (const [id, record2] of Object.entries(object2(value) && object2(value.narratives) ? value.narratives : {})) {
|
|
5634
|
+
if (durationRangeInverted(record2))
|
|
4951
5635
|
findings.push(
|
|
4952
5636
|
finding("opf/narrative-duration-range", {
|
|
4953
5637
|
path: pointer4(["catalogs", group, "narratives", id, "duration"]),
|
|
@@ -4995,7 +5679,7 @@ function contractFindings(document, contracts) {
|
|
|
4995
5679
|
}))
|
|
4996
5680
|
})
|
|
4997
5681
|
);
|
|
4998
|
-
} else if (
|
|
5682
|
+
} else if (object2(entry2.value) || Array.isArray(entry2.value)) {
|
|
4999
5683
|
const key3 = pattern[entry2.depth];
|
|
5000
5684
|
for (const [name, value] of Object.entries(entry2.value))
|
|
5001
5685
|
if (key3 === "*" || key3 === name)
|
|
@@ -5009,6 +5693,17 @@ function contractFindings(document, contracts) {
|
|
|
5009
5693
|
}
|
|
5010
5694
|
return findings;
|
|
5011
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
|
+
}
|
|
5012
5707
|
|
|
5013
5708
|
// src/patch.ts
|
|
5014
5709
|
var OPFPatchError = class extends Error {
|
|
@@ -5107,10 +5802,10 @@ function indexOfId(array, id) {
|
|
|
5107
5802
|
}
|
|
5108
5803
|
return found;
|
|
5109
5804
|
}
|
|
5110
|
-
function uniqueIdAt(array,
|
|
5111
|
-
const item = array[
|
|
5805
|
+
function uniqueIdAt(array, at3) {
|
|
5806
|
+
const item = array[at3];
|
|
5112
5807
|
if (!isObject2(item) || !own2(item, "id") || typeof item.id !== "string" || item.id === "") return void 0;
|
|
5113
|
-
return indexOfId(array, item.id) ===
|
|
5808
|
+
return indexOfId(array, item.id) === at3 ? item.id : void 0;
|
|
5114
5809
|
}
|
|
5115
5810
|
function resolveTokens(document, tokens, pointer5) {
|
|
5116
5811
|
const out = [];
|
|
@@ -5118,10 +5813,10 @@ function resolveTokens(document, tokens, pointer5) {
|
|
|
5118
5813
|
for (const token of tokens) {
|
|
5119
5814
|
let resolved2 = token;
|
|
5120
5815
|
if (walking && Array.isArray(cursor) && isIdToken(token)) {
|
|
5121
|
-
const
|
|
5122
|
-
if (
|
|
5123
|
-
if (
|
|
5124
|
-
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);
|
|
5125
5820
|
}
|
|
5126
5821
|
out.push(resolved2);
|
|
5127
5822
|
if (walking) {
|
|
@@ -5162,16 +5857,16 @@ function readPointer(document, pointer5) {
|
|
|
5162
5857
|
let value = document;
|
|
5163
5858
|
for (const token of tokens) {
|
|
5164
5859
|
if (Array.isArray(value)) {
|
|
5165
|
-
let
|
|
5860
|
+
let at3;
|
|
5166
5861
|
if (isIdToken(token)) {
|
|
5167
|
-
|
|
5168
|
-
if (
|
|
5862
|
+
at3 = indexOfId(value, token.slice(1));
|
|
5863
|
+
if (at3 < 0) return { found: false };
|
|
5169
5864
|
} else {
|
|
5170
5865
|
if (!INDEX_TOKEN.test(token)) return { found: false };
|
|
5171
|
-
|
|
5866
|
+
at3 = Number(token);
|
|
5172
5867
|
}
|
|
5173
|
-
if (!Number.isSafeInteger(
|
|
5174
|
-
value = value[
|
|
5868
|
+
if (!Number.isSafeInteger(at3) || at3 >= value.length) return { found: false };
|
|
5869
|
+
value = value[at3];
|
|
5175
5870
|
} else if (value && typeof value === "object" && own2(value, token)) value = value[token];
|
|
5176
5871
|
else return { found: false };
|
|
5177
5872
|
}
|
|
@@ -5189,9 +5884,9 @@ var hasPointer = (document, pointer5) => readPointer(document, pointer5).found;
|
|
|
5189
5884
|
function arrayIndex(token, length, allowEnd, path) {
|
|
5190
5885
|
if (allowEnd && token === "-") return length;
|
|
5191
5886
|
if (!INDEX_TOKEN.test(token)) throw new OPFPatchError("invalid-array-index", `Invalid array index: ${token}`, { path });
|
|
5192
|
-
const
|
|
5193
|
-
if (!Number.isSafeInteger(
|
|
5194
|
-
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;
|
|
5195
5890
|
}
|
|
5196
5891
|
function normalizePatch(patch2) {
|
|
5197
5892
|
if (!Array.isArray(patch2)) throw new OPFPatchError("invalid-patch", "A JSON Patch must be an array of operations.");
|
|
@@ -5237,14 +5932,14 @@ function addAt(document, path, value) {
|
|
|
5237
5932
|
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
|
|
5238
5933
|
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
5239
5934
|
if (Array.isArray(parent)) {
|
|
5240
|
-
const
|
|
5241
|
-
parent.splice(
|
|
5242
|
-
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]);
|
|
5243
5938
|
return { document, inverse: { op: "remove", path: pointer6 }, pointer: pointer6 };
|
|
5244
5939
|
}
|
|
5245
|
-
const
|
|
5246
|
-
const previous = own2(
|
|
5247
|
-
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 });
|
|
5248
5943
|
const pointer5 = formatPointer(tokens);
|
|
5249
5944
|
return { document, inverse: previous === NONE ? { op: "remove", path: pointer5 } : { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5250
5945
|
}
|
|
@@ -5255,15 +5950,15 @@ function replaceAt(document, path, value) {
|
|
|
5255
5950
|
let previous;
|
|
5256
5951
|
let pointer5 = formatPointer(tokens);
|
|
5257
5952
|
if (Array.isArray(parent)) {
|
|
5258
|
-
const
|
|
5259
|
-
previous = parent[
|
|
5260
|
-
parent[
|
|
5261
|
-
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]);
|
|
5262
5957
|
} else {
|
|
5263
|
-
const
|
|
5264
|
-
if (!own2(
|
|
5265
|
-
previous =
|
|
5266
|
-
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 });
|
|
5267
5962
|
}
|
|
5268
5963
|
return { document, inverse: { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5269
5964
|
}
|
|
@@ -5273,16 +5968,16 @@ function removeAt(document, path) {
|
|
|
5273
5968
|
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
5274
5969
|
let previous;
|
|
5275
5970
|
if (Array.isArray(parent)) {
|
|
5276
|
-
const
|
|
5277
|
-
previous = parent[
|
|
5278
|
-
parent.splice(
|
|
5279
|
-
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]);
|
|
5280
5975
|
return { document, inverse: { op: "add", path: pointer6, value: clone(previous) }, pointer: pointer6 };
|
|
5281
5976
|
}
|
|
5282
|
-
const
|
|
5283
|
-
if (!own2(
|
|
5284
|
-
previous =
|
|
5285
|
-
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];
|
|
5286
5981
|
const pointer5 = formatPointer(tokens);
|
|
5287
5982
|
return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
5288
5983
|
}
|
|
@@ -5443,14 +6138,14 @@ var schemaCatalogKinds = {
|
|
|
5443
6138
|
};
|
|
5444
6139
|
|
|
5445
6140
|
// src/schema-navigation.ts
|
|
5446
|
-
var own3 = (
|
|
6141
|
+
var own3 = (object3, key3) => object3 !== null && typeof object3 === "object" && Object.hasOwn(object3, key3);
|
|
5447
6142
|
var documents = new Map(Object.values(schemas).map((schema) => [schema.$id, schema]));
|
|
5448
6143
|
var presentationSchema = schemas.presentation;
|
|
5449
6144
|
var CATALOG_KIND = /* @__PURE__ */ Symbol.for("@openpresentation/opf:catalog-kind");
|
|
5450
6145
|
var catalogKindOfNode = /* @__PURE__ */ new WeakMap();
|
|
5451
6146
|
var kindOfNode = (node) => catalogKindOfNode.get(node) ?? node[CATALOG_KIND];
|
|
5452
6147
|
function splitOpfPath(path) {
|
|
5453
|
-
if (Array.isArray(path)) return path.map((
|
|
6148
|
+
if (Array.isArray(path)) return path.map((segment2) => String(segment2));
|
|
5454
6149
|
if (typeof path !== "string") throw new TypeError("An OPF path must be a string or an array of segments.");
|
|
5455
6150
|
if (path === "") return [];
|
|
5456
6151
|
if (path.startsWith("/")) return parsePointer(path);
|
|
@@ -5542,13 +6237,13 @@ function score2(schema, value) {
|
|
|
5542
6237
|
if (own3(schema, "const")) return JSON.stringify(schema.const) === JSON.stringify(value) ? 100 : -100;
|
|
5543
6238
|
if (schema.enum && !schema.enum.includes(value)) return -100;
|
|
5544
6239
|
let result = 1;
|
|
5545
|
-
const
|
|
6240
|
+
const record2 = value;
|
|
5546
6241
|
for (const [key3, child] of Object.entries(schema.properties ?? {})) {
|
|
5547
|
-
if (!
|
|
5548
|
-
if (own3(child, "const")) result +=
|
|
6242
|
+
if (!record2 || !own3(record2, key3)) continue;
|
|
6243
|
+
if (own3(child, "const")) result += record2[key3] === child.const ? 100 : -1e3;
|
|
5549
6244
|
else result += 1;
|
|
5550
6245
|
}
|
|
5551
|
-
for (const key3 of schema.required ?? []) if (!
|
|
6246
|
+
for (const key3 of schema.required ?? []) if (!record2 || !own3(record2, key3)) result -= 2;
|
|
5552
6247
|
return result;
|
|
5553
6248
|
}
|
|
5554
6249
|
function activeSchema(schema, value, root = presentationSchema) {
|
|
@@ -5899,9 +6594,9 @@ function applyTextEdits(text2, edits) {
|
|
|
5899
6594
|
function rememberByText(read, size = 2) {
|
|
5900
6595
|
const kept = [];
|
|
5901
6596
|
return (text2) => {
|
|
5902
|
-
const
|
|
5903
|
-
if (
|
|
5904
|
-
const [entry2] = kept.splice(
|
|
6597
|
+
const at3 = kept.findIndex((entry2) => entry2.text === text2);
|
|
6598
|
+
if (at3 >= 0) {
|
|
6599
|
+
const [entry2] = kept.splice(at3, 1);
|
|
5905
6600
|
kept.unshift(entry2);
|
|
5906
6601
|
return entry2.value;
|
|
5907
6602
|
}
|
|
@@ -6696,10 +7391,10 @@ var Analyzer = class {
|
|
|
6696
7391
|
})();
|
|
6697
7392
|
const hint = valueHint(path);
|
|
6698
7393
|
const gap = this.text[colon.end] === " " || this.text[colon.end] === " " ? 0 : 1;
|
|
6699
|
-
const
|
|
6700
|
-
const edits = [{ offset:
|
|
6701
|
-
if (needsComma) edits.push({ offset:
|
|
6702
|
-
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 }];
|
|
6703
7398
|
fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
|
|
6704
7399
|
this.structural({
|
|
6705
7400
|
code: "missing-value",
|
|
@@ -7066,9 +7761,9 @@ function slideRef(finding2, helpers) {
|
|
|
7066
7761
|
if (typeof layout === "string" && layout) return `Slide ${number} (layout ${code(layout)})`;
|
|
7067
7762
|
return `Slide ${number}`;
|
|
7068
7763
|
}
|
|
7069
|
-
var lastName = (segments) => [...segments].reverse().find((
|
|
7764
|
+
var lastName = (segments) => [...segments].reverse().find((segment2) => !isIndex(segment2));
|
|
7070
7765
|
function dotted(segments) {
|
|
7071
|
-
return segments.reduce((out,
|
|
7766
|
+
return segments.reduce((out, segment2) => isIndex(segment2) ? `${out}[${segment2}]` : out ? `${out}.${segment2}` : segment2, "");
|
|
7072
7767
|
}
|
|
7073
7768
|
function keysAt(helpers, path) {
|
|
7074
7769
|
const value = helpers.valueAt(path);
|
|
@@ -7104,7 +7799,7 @@ function chooseNext(value, candidates, alternative = "", max = 3) {
|
|
|
7104
7799
|
return alternative ? sentence(alternative) : "choose a different value.";
|
|
7105
7800
|
}
|
|
7106
7801
|
function kindPhrase(kind) {
|
|
7107
|
-
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" };
|
|
7108
7803
|
return phrases[kind] ?? `${/^[aeiou]/i.test(kind) ? "an" : "a"} ${kind}`;
|
|
7109
7804
|
}
|
|
7110
7805
|
function freshName(base, taken = []) {
|
|
@@ -7115,7 +7810,7 @@ function freshName(base, taken = []) {
|
|
|
7115
7810
|
}
|
|
7116
7811
|
return `${base}-2`;
|
|
7117
7812
|
}
|
|
7118
|
-
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"];
|
|
7119
7814
|
function blockKind(node) {
|
|
7120
7815
|
if (!isRecord2(node)) return void 0;
|
|
7121
7816
|
if (typeof node.type === "string" && node.type !== "group") return node.type;
|
|
@@ -7170,7 +7865,7 @@ var textOnImage = (finding2) => {
|
|
|
7170
7865
|
if (best !== void 0)
|
|
7171
7866
|
return {
|
|
7172
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` : ""}.`,
|
|
7173
|
-
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.`
|
|
7174
7869
|
};
|
|
7175
7870
|
if (scrim !== void 0)
|
|
7176
7871
|
return {
|
|
@@ -7292,10 +7987,10 @@ var missingLanguage = (_finding, context, helpers) => ({
|
|
|
7292
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.`
|
|
7293
7988
|
});
|
|
7294
7989
|
var chartOptionAdapted = (finding2, _context, helpers) => {
|
|
7295
|
-
const
|
|
7296
|
-
const option =
|
|
7990
|
+
const at3 = helpers.segments.indexOf("chart");
|
|
7991
|
+
const option = at3 >= 0 ? helpers.segments.slice(at3 + 1).join(".") : lastName(helpers.segments) ?? "";
|
|
7297
7992
|
if (!option) return void 0;
|
|
7298
|
-
const type =
|
|
7993
|
+
const type = at3 >= 0 ? helpers.valueAt([...helpers.segments.slice(0, at3 + 1), "type"]) : void 0;
|
|
7299
7994
|
const typeName = typeof type === "string" ? type : match(finding2.message, /^A '(.+?)' chart/)?.[1];
|
|
7300
7995
|
const adaptation = finding2.message.includes(";") ? cap(finding2.message.slice(finding2.message.indexOf(";") + 1).trim()) : "";
|
|
7301
7996
|
return {
|
|
@@ -7322,7 +8017,7 @@ var layoutFailed = (finding2, _context, helpers) => {
|
|
|
7322
8017
|
next: "fix the composition setting or content named above."
|
|
7323
8018
|
};
|
|
7324
8019
|
};
|
|
7325
|
-
var
|
|
8020
|
+
var minFontSizePx = (finding2) => {
|
|
7326
8021
|
const size = measuredNumber(finding2, "sizePt");
|
|
7327
8022
|
const minimum = measuredNumber(finding2, "minimumPt");
|
|
7328
8023
|
if (size === void 0 || minimum === void 0) return void 0;
|
|
@@ -7338,8 +8033,8 @@ function regionNamesOf(slideLayout, helpers) {
|
|
|
7338
8033
|
const colon = slideLayout.indexOf(":");
|
|
7339
8034
|
const group = colon > 0 ? slideLayout.slice(0, colon) : void 0;
|
|
7340
8035
|
const id = colon > 0 ? slideLayout.slice(colon + 1) : slideLayout;
|
|
7341
|
-
const
|
|
7342
|
-
if (!
|
|
8036
|
+
const record2 = (group ? [group] : ["custom", "default"]).map((name) => helpers.valueAt(["catalogs", name, "layouts", id])).find(isRecord2);
|
|
8037
|
+
if (!record2) return void 0;
|
|
7343
8038
|
const names2 = [];
|
|
7344
8039
|
const walk2 = (list) => {
|
|
7345
8040
|
if (!Array.isArray(list)) return;
|
|
@@ -7349,7 +8044,7 @@ function regionNamesOf(slideLayout, helpers) {
|
|
|
7349
8044
|
walk2(entry2.regions);
|
|
7350
8045
|
}
|
|
7351
8046
|
};
|
|
7352
|
-
walk2(
|
|
8047
|
+
walk2(record2.regions);
|
|
7353
8048
|
return { id: slideLayout, names: names2 };
|
|
7354
8049
|
}
|
|
7355
8050
|
var regionUnknown = (finding2, _context, helpers) => {
|
|
@@ -7418,9 +8113,9 @@ var regionFull = (finding2) => {
|
|
|
7418
8113
|
var layoutUnplaced = (finding2, _context, helpers) => {
|
|
7419
8114
|
const kind = blockKind(helpers.valueAt(helpers.segments));
|
|
7420
8115
|
const what = kind ? `this ${kind} block` : "this block";
|
|
7421
|
-
const
|
|
8116
|
+
const overflow2 = match(finding2.message, /drawn in '(.+?)' beyond its (\d+) block/);
|
|
7422
8117
|
return {
|
|
7423
|
-
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.`,
|
|
7424
8119
|
next: "paginate the slide, choose a layout with more room, or remove a block."
|
|
7425
8120
|
};
|
|
7426
8121
|
};
|
|
@@ -7469,6 +8164,27 @@ var textShrunk2 = (finding2) => {
|
|
|
7469
8164
|
next: `split it with ${code("opf paginate")}, move detail to the speaker notes, or shorten the text.`
|
|
7470
8165
|
};
|
|
7471
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
|
+
};
|
|
7472
8188
|
var centeredBody2 = (finding2) => {
|
|
7473
8189
|
const lines = measuredNumber(finding2, "lines");
|
|
7474
8190
|
const characters = measuredNumber(finding2, "characters");
|
|
@@ -7510,17 +8226,6 @@ var layoutMonotony2 = (finding2) => {
|
|
|
7510
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."
|
|
7511
8227
|
};
|
|
7512
8228
|
};
|
|
7513
|
-
var straightQuotes2 = (finding2) => {
|
|
7514
|
-
const open = measuredText(finding2, "open");
|
|
7515
|
-
const close = measuredText(finding2, "close");
|
|
7516
|
-
const text2 = unquote(match(finding2.message, /: ("(?:[^"\\]|\\.)*")\.$/)?.[1]);
|
|
7517
|
-
if (!open || !close) return void 0;
|
|
7518
|
-
const fix = finding2.fixes?.find((entry2) => entry2.id === "use-typographic-quotes");
|
|
7519
|
-
return {
|
|
7520
|
-
message: `${text2 ? `${code(brief(text2, 50))} uses` : "This text uses"} straight quotation marks; this deck's language uses ${open}\u2026${close}.`,
|
|
7521
|
-
next: fix ? `apply the quick fix, or type ${open} and ${close} instead.` : `type ${open} and ${close} instead, and the matching single marks.`
|
|
7522
|
-
};
|
|
7523
|
-
};
|
|
7524
8229
|
var chartDualAxis2 = (finding2) => {
|
|
7525
8230
|
const names2 = match(finding2.message, /^The combo chart plots (.+) on a second value axis/)?.[1];
|
|
7526
8231
|
return {
|
|
@@ -7546,6 +8251,41 @@ var chartValueNotNumeric = (finding2) => {
|
|
|
7546
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")}.`
|
|
7547
8252
|
};
|
|
7548
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.`
|
|
8259
|
+
};
|
|
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
|
+
});
|
|
7549
8289
|
var chartMappingAdapted = (finding2) => ({
|
|
7550
8290
|
message: keep(cap(finding2.message)),
|
|
7551
8291
|
next: "remove that mapping entry, or name a different column."
|
|
@@ -7554,6 +8294,13 @@ var chartSeriesDropped = (finding2) => ({
|
|
|
7554
8294
|
message: keep(cap(finding2.message)),
|
|
7555
8295
|
next: "use a chart type that plots every series, or one chart per series."
|
|
7556
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
|
+
};
|
|
7557
8304
|
var chartHighlightAdapted = (finding2) => {
|
|
7558
8305
|
const name = unquote(match(finding2.message, /^highlight names \w+ ("(?:[^"\\]|\\.)*"), which is not plotted as a series/)?.[1]);
|
|
7559
8306
|
if (!name) return void 0;
|
|
@@ -7562,6 +8309,30 @@ var chartHighlightAdapted = (finding2) => {
|
|
|
7562
8309
|
next: "name a series the chart plots, or remove the entry."
|
|
7563
8310
|
};
|
|
7564
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;
|
|
7565
8336
|
var codeHighlightOutOfRange = (finding2) => {
|
|
7566
8337
|
const found = match(finding2.message, /line (\d+) is past the last line \(the code has (\d+) lines?\)/);
|
|
7567
8338
|
if (!found) return void 0;
|
|
@@ -7681,7 +8452,7 @@ var AUDIT_TEXT = {
|
|
|
7681
8452
|
"opf/text-overflow": textOverflow,
|
|
7682
8453
|
"opf/unresolved-content": unresolvedContent,
|
|
7683
8454
|
"opf/layout-failed": layoutFailed,
|
|
7684
|
-
"opf/min-font-size":
|
|
8455
|
+
"opf/min-font-size": minFontSizePx,
|
|
7685
8456
|
"opf/region-unknown": regionUnknown,
|
|
7686
8457
|
"opf/region-kind": regionKind,
|
|
7687
8458
|
"opf/region-full": regionFull,
|
|
@@ -7696,8 +8467,23 @@ var AUDIT_TEXT = {
|
|
|
7696
8467
|
"opf/image-resolution": imageResolution,
|
|
7697
8468
|
"opf/chart-value-not-numeric": chartValueNotNumeric,
|
|
7698
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,
|
|
7699
8478
|
"opf/chart-highlight-adapted": chartHighlightAdapted,
|
|
8479
|
+
"opf/table-color-scale-no-data": tableColorScaleNoData,
|
|
8480
|
+
"opf/table-color-scale-range": tableColorScaleRange,
|
|
7700
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,
|
|
7701
8487
|
"opf/code-highlight-out-of-range": codeHighlightOutOfRange,
|
|
7702
8488
|
"opf/code-highlight-range-reversed": codeHighlightRangeReversed,
|
|
7703
8489
|
"opf/variable-builtin-missing": variableBuiltinMissing,
|
|
@@ -7710,10 +8496,10 @@ var AUDIT_TEXT = {
|
|
|
7710
8496
|
"opf/empty-slide": emptySlide,
|
|
7711
8497
|
"opf/language-tag": languageTag,
|
|
7712
8498
|
"opf/text-shrunk": textShrunk2,
|
|
8499
|
+
"opf/variable-overflow": variableOverflow2,
|
|
7713
8500
|
"opf/centered-body": centeredBody2,
|
|
7714
8501
|
"opf/tight-spacing": tightSpacing2,
|
|
7715
8502
|
"opf/layout-monotony": layoutMonotony2,
|
|
7716
|
-
"opf/straight-quotes": straightQuotes2,
|
|
7717
8503
|
"opf/chart-dual-axis": chartDualAxis2,
|
|
7718
8504
|
"opf/chart-pie-many-slices": chartPieManySlices2
|
|
7719
8505
|
};
|
|
@@ -7757,6 +8543,15 @@ var citeUnknownReference = (finding2, _context, helpers) => {
|
|
|
7757
8543
|
next: chooseNext(id, ids, add)
|
|
7758
8544
|
};
|
|
7759
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
|
+
};
|
|
7760
8555
|
var citeUnsupportedLocation = (finding2) => {
|
|
7761
8556
|
const where = match(finding2.message, /^cite and footnote are not supported in ([^;]+);/)?.[1];
|
|
7762
8557
|
const inReferences = /^reference text cannot cite/.test(finding2.message);
|
|
@@ -7772,8 +8567,8 @@ var captionUnsupportedPayload = (finding2) => {
|
|
|
7772
8567
|
const kind = type ?? (/a group cannot carry one/.test(finding2.message) ? "group" : void 0);
|
|
7773
8568
|
const is = kind ? kindPhrase(kind) : "not one of those";
|
|
7774
8569
|
return {
|
|
7775
|
-
message: `A ${code("caption")} belongs to one image, chart, table, video or diagram; this block is ${is}.`,
|
|
7776
|
-
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.`
|
|
7777
8572
|
};
|
|
7778
8573
|
};
|
|
7779
8574
|
var imageOptionUnsupportedPayload = (finding2) => {
|
|
@@ -7819,6 +8614,15 @@ var shapeLinkHidden = () => ({
|
|
|
7819
8614
|
message: "This shape is hidden, so its `link` can never be clicked.",
|
|
7820
8615
|
next: "remove `hidden`, or remove the `link`."
|
|
7821
8616
|
});
|
|
8617
|
+
var shapePathUnits = (finding2) => {
|
|
8618
|
+
const { width, height } = params(finding2);
|
|
8619
|
+
if (typeof width !== "number" || typeof height !== "number") return void 0;
|
|
8620
|
+
const round4 = (value) => Number(value.toPrecision(3));
|
|
8621
|
+
return {
|
|
8622
|
+
message: `The ${code("path")} spans ${round4(width)} by ${round4(height)} units, but a path without a ${code("viewBox")} is drawn in a 0 to 1 box, so the outline is far outside its frame.`,
|
|
8623
|
+
next: `add a ${code("viewBox")} for the grid the path is written on (for example ${code('{ "d": ..., "viewBox": "0 0 100 100" }')}), or write its coordinates from 0 to 1.`
|
|
8624
|
+
};
|
|
8625
|
+
};
|
|
7822
8626
|
var shapeAnchorSizeUnit = (finding2) => {
|
|
7823
8627
|
const { key: key3, size } = params(finding2);
|
|
7824
8628
|
return typeof key3 === "string" ? { message: `${code(`at.${key3}: ${String(size)}`)} is a fraction, not pixels.`, next: `rename ${code(key3)} to ${code(`${key3}Px`)} if it is pixels.` } : void 0;
|
|
@@ -7863,8 +8667,13 @@ var layoutPlaceholderGroup = (finding2) => {
|
|
|
7863
8667
|
};
|
|
7864
8668
|
};
|
|
7865
8669
|
function datasetOf(helpers) {
|
|
7866
|
-
const
|
|
7867
|
-
|
|
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);
|
|
7868
8677
|
for (const candidate of [parent, [...parent, "data"]]) {
|
|
7869
8678
|
const value = helpers.valueAt([...candidate, "dataset"]);
|
|
7870
8679
|
if (isText2(value)) return value;
|
|
@@ -7881,6 +8690,16 @@ var datasetUnknown = (finding2, _context, helpers) => {
|
|
|
7881
8690
|
next: chooseNext(id, ids, `add ${code(`datasets.${id}`)}`)
|
|
7882
8691
|
};
|
|
7883
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
|
+
};
|
|
7884
8703
|
var datasetFieldUnknown = (finding2, _context, helpers) => {
|
|
7885
8704
|
const found = match(finding2.message, /^field ("(?:[^"\\]|\\.)*") is not a column of the dataset; use one of (.+)$/);
|
|
7886
8705
|
if (!found) return void 0;
|
|
@@ -7960,6 +8779,16 @@ var tableHighlightUnknownName = (finding2) => {
|
|
|
7960
8779
|
next: keys.length ? chooseNext(name, keys) : "name a row by the text of its first cell, or remove the entry."
|
|
7961
8780
|
};
|
|
7962
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
|
+
};
|
|
7963
8792
|
var tokenOf = (finding2, id) => finding2.message.includes(`var:${id}`) ? code(`var:${id}`) : code(`{{${id}}}`);
|
|
7964
8793
|
var SAMPLE_BY_KIND = {
|
|
7965
8794
|
number: "a plain number such as 42",
|
|
@@ -8055,6 +8884,17 @@ var variableUnused = (finding2, _context, helpers) => {
|
|
|
8055
8884
|
next: `use it as ${code(`{{${id}}}`)} or ${code(`var:${id}`)} where it belongs, or remove its declaration.`
|
|
8056
8885
|
};
|
|
8057
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
|
+
};
|
|
8058
8898
|
var variableReferenceUnknown = (finding2, _context, helpers) => {
|
|
8059
8899
|
const id = text(params(finding2).id) ?? match(finding2.message, /^unknown variable '(.+?)'/)?.[1];
|
|
8060
8900
|
if (!id) return void 0;
|
|
@@ -8132,9 +8972,9 @@ var catalogRecord = (finding2, context) => {
|
|
|
8132
8972
|
if (root !== "catalogs" || !kind || !id) return void 0;
|
|
8133
8973
|
const inner = describeFinding({ ...finding2, ruleId: "opf/schema" }, context);
|
|
8134
8974
|
const registered = finding2.scope === "context";
|
|
8135
|
-
const
|
|
8975
|
+
const record2 = `${registered ? "The registered" : "The embedded"} ${KIND_SINGULAR2(kind)} ${code(id)}`;
|
|
8136
8976
|
return {
|
|
8137
|
-
message: `${
|
|
8977
|
+
message: `${record2} is invalid: ${inner.message.charAt(0).toLowerCase()}${inner.message.slice(1)}`,
|
|
8138
8978
|
next: inner.next ?? `fix the record; references to it are reported too.`
|
|
8139
8979
|
};
|
|
8140
8980
|
};
|
|
@@ -8321,6 +9161,7 @@ var FORMAT_TEXT = {
|
|
|
8321
9161
|
"opf/schema": schemaPlain,
|
|
8322
9162
|
"opf/reference-id-duplicate": referenceIdDuplicate,
|
|
8323
9163
|
"opf/cite-unknown-reference": citeUnknownReference,
|
|
9164
|
+
"opf/slide-link-unknown": slideLinkUnknown,
|
|
8324
9165
|
"opf/cite-unsupported-location": citeUnsupportedLocation,
|
|
8325
9166
|
"opf/caption-unsupported-payload": captionUnsupportedPayload,
|
|
8326
9167
|
"opf/image-option-unsupported-payload": imageOptionUnsupportedPayload,
|
|
@@ -8329,11 +9170,13 @@ var FORMAT_TEXT = {
|
|
|
8329
9170
|
"opf/shape-adjust-unknown": shapeAdjustUnknown,
|
|
8330
9171
|
"opf/shape-adjust-range": shapeAdjustRange,
|
|
8331
9172
|
"opf/shape-link-hidden": shapeLinkHidden,
|
|
9173
|
+
"opf/shape-path-units": shapePathUnits,
|
|
8332
9174
|
"opf/shape-anchor-size-unit": shapeAnchorSizeUnit,
|
|
8333
9175
|
"opf/shape-anchor-missing": shapeAnchorMissing,
|
|
8334
9176
|
"opf/connector-end-missing": connectorEndMissing,
|
|
8335
9177
|
"opf/layout-placeholder-group": layoutPlaceholderGroup,
|
|
8336
9178
|
"opf/dataset-unknown": datasetUnknown,
|
|
9179
|
+
"opf/datasource-unknown": datasourceUnknown,
|
|
8337
9180
|
"opf/dataset-field-unknown": datasetFieldUnknown,
|
|
8338
9181
|
"opf/data-column-duplicate": dataColumnDuplicate,
|
|
8339
9182
|
"opf/chart-mapping-unknown-column": chartMappingUnknownColumn,
|
|
@@ -8344,6 +9187,7 @@ var FORMAT_TEXT = {
|
|
|
8344
9187
|
"opf/variable-unknown-builtin": variableUnknownBuiltin,
|
|
8345
9188
|
"opf/chart-highlight-unknown-name": chartHighlightUnknownName,
|
|
8346
9189
|
"opf/table-highlight-unknown-name": tableHighlightUnknownName,
|
|
9190
|
+
"opf/table-color-scale-unknown-column": tableColorScaleUnknownColumn,
|
|
8347
9191
|
"opf/variable-format": variableFormat,
|
|
8348
9192
|
"opf/variable-unfilled": variableUnfilled,
|
|
8349
9193
|
"opf/run-color-unrecognized": runColorUnrecognized,
|
|
@@ -8366,6 +9210,8 @@ var FORMAT_TEXT = {
|
|
|
8366
9210
|
"opf/variable-unknown": variableUnknown,
|
|
8367
9211
|
"opf/variable-unknown-value": variableUnknownValue,
|
|
8368
9212
|
"opf/variable-unused": variableUnused,
|
|
9213
|
+
"opf/variable-translation-duplicate": variableTranslationDuplicate,
|
|
9214
|
+
"opf/variable-translation-unused": variableTranslationUnused,
|
|
8369
9215
|
"opf/variable-reference-unknown": variableReferenceUnknown,
|
|
8370
9216
|
"opf/contract": contract
|
|
8371
9217
|
};
|
|
@@ -8565,9 +9411,12 @@ var PATTERN_PHRASES = Object.freeze({
|
|
|
8565
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." },
|
|
8566
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)." },
|
|
8567
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." },
|
|
8568
|
-
"^(?: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." },
|
|
8569
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." },
|
|
8570
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." },
|
|
8571
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." },
|
|
8572
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." },
|
|
8573
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`." },
|
|
@@ -8838,423 +9687,178 @@ function schemaFixes(finding2, document) {
|
|
|
8838
9687
|
return [];
|
|
8839
9688
|
default:
|
|
8840
9689
|
return [];
|
|
8841
|
-
}
|
|
8842
|
-
}
|
|
8843
|
-
function listColumnsChangeDrawing(region) {
|
|
8844
|
-
if (!isRecord2(region) || region.listColumns !== "auto") return true;
|
|
8845
|
-
const accepts = Array.isArray(region.accepts) ? region.accepts : [];
|
|
8846
|
-
const arrangement = region.arrangement ?? region.sequence;
|
|
8847
|
-
return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
|
|
8848
|
-
}
|
|
8849
|
-
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.`;
|
|
8850
|
-
function removedKeyRepair(finding2, document) {
|
|
8851
|
-
const validation = finding2.validation;
|
|
8852
|
-
if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
|
|
8853
|
-
const segments = segmentsOf(finding2.path);
|
|
8854
|
-
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]);
|
|
8855
|
-
const inRegion = segments.at(-3) === "regions";
|
|
8856
|
-
if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
|
|
8857
|
-
const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
|
|
8858
|
-
if (!isRecord2(region) || value === void 0) return void 0;
|
|
8859
|
-
const arrangement = region.arrangement;
|
|
8860
|
-
if (segments.at(-1) === "sequence") {
|
|
8861
|
-
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.`;
|
|
8862
|
-
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: [] };
|
|
8863
|
-
return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
|
|
8864
|
-
}
|
|
8865
|
-
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).';
|
|
8866
|
-
if (arrangement !== "pyramid") return { help, fixes: [] };
|
|
8867
|
-
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)] };
|
|
8868
|
-
if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
|
|
8869
|
-
return { help, fixes: [] };
|
|
8870
|
-
}
|
|
8871
|
-
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
|
|
8872
|
-
const value = readAt(document, segments), renamed = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
|
|
8873
|
-
if (renamed === void 0) return void 0;
|
|
8874
|
-
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)] };
|
|
8875
|
-
}
|
|
8876
|
-
const alignment = segments.at(-1);
|
|
8877
|
-
if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
|
|
8878
|
-
const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
|
|
8879
|
-
if (next === void 0) return void 0;
|
|
8880
|
-
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)] };
|
|
8881
|
-
}
|
|
8882
|
-
if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
|
|
8883
|
-
return {
|
|
8884
|
-
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".`,
|
|
8885
|
-
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" }])]
|
|
8886
|
-
};
|
|
8887
|
-
}
|
|
8888
|
-
if (validation.keyword === "additionalProperties") {
|
|
8889
|
-
const name = segments.at(-1) ?? "";
|
|
8890
|
-
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))))] };
|
|
8891
|
-
if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
|
|
8892
|
-
const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
|
|
8893
|
-
return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
|
|
8894
|
-
}
|
|
8895
|
-
if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
|
|
8896
|
-
const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
|
|
8897
|
-
if (!near?.help) return void 0;
|
|
8898
|
-
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 }])] : [] };
|
|
8899
|
-
}
|
|
8900
|
-
if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
|
|
8901
|
-
const parent = segments.slice(0, -1), region = readAt(document, parent);
|
|
8902
|
-
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".';
|
|
8903
|
-
if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
|
|
8904
|
-
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)] };
|
|
8905
|
-
}
|
|
8906
|
-
return void 0;
|
|
8907
|
-
}
|
|
8908
|
-
var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
|
|
8909
|
-
function removedCellKeys(slide) {
|
|
8910
|
-
if (!isRecord2(slide)) return [];
|
|
8911
|
-
const found = Object.keys(slide).flatMap((key3) => {
|
|
8912
|
-
const cell = nearestGridCell(key3)?.cell;
|
|
8913
|
-
return cell ? [{ key: key3, cell }] : [];
|
|
8914
|
-
});
|
|
8915
|
-
const order2 = cellsInReadingOrder(found);
|
|
8916
|
-
return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
|
|
8917
|
-
}
|
|
8918
|
-
function cellKeysAsBlocks(slide) {
|
|
8919
|
-
const keys = removedCellKeys(slide);
|
|
8920
|
-
if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
|
|
8921
|
-
const placed = slide.layout === void 0;
|
|
8922
|
-
const blocks = keys.map(({ key: key3, cell }) => {
|
|
8923
|
-
const { id, region: _ignored, ...rest } = slide[key3];
|
|
8924
|
-
return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
|
|
8925
|
-
});
|
|
8926
|
-
return { keys: keys.map(({ key: key3 }) => key3), blocks };
|
|
8927
|
-
}
|
|
8928
|
-
function cellKeyRepair(document, slideSegments, key3) {
|
|
8929
|
-
const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
|
|
8930
|
-
const layout = isRecord2(slide) && slide.layout !== void 0;
|
|
8931
|
-
const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
|
|
8932
|
-
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}` : "");
|
|
8933
|
-
const moved = near.cell ? cellKeysAsBlocks(slide) : void 0;
|
|
8934
|
-
if (!moved) return { help, fixes: [], dropSuggestions: true };
|
|
8935
|
-
const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
|
|
8936
|
-
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 };
|
|
8937
|
-
}
|
|
8938
|
-
|
|
8939
|
-
// src/drawn-font-families.ts
|
|
8940
|
-
function resolveDrawnFontFamilies(families, measurement, keepsName) {
|
|
8941
|
-
const resolve2 = measurement?.resolveStyle;
|
|
8942
|
-
if (typeof resolve2 !== "function") return families;
|
|
8943
|
-
const drawn = { ...families };
|
|
8944
|
-
for (const role of ["heading", "body", "code", "accent"]) {
|
|
8945
|
-
const named = families[role];
|
|
8946
|
-
if (typeof named !== "string" || !named) continue;
|
|
8947
|
-
try {
|
|
8948
|
-
const resolved2 = resolve2.call(measurement, { fontFamily: named, fontWeight: role === "heading" ? 700 : 400 });
|
|
8949
|
-
let keep3;
|
|
8950
|
-
if (keepsName) keep3 = keepsName(named, resolved2.fontFamily);
|
|
8951
|
-
else {
|
|
8952
|
-
const regular = role === "heading" ? resolve2.call(measurement, { fontFamily: named, fontWeight: 400 }) : resolved2;
|
|
8953
|
-
const encoded = resolved2.symbolEncoding != null;
|
|
8954
|
-
keep3 = encoded || regular.fontWeight !== void 0 && regular.fontWeight !== 400 && resolved2.fontFamily.toLowerCase() !== named.toLowerCase();
|
|
8955
|
-
}
|
|
8956
|
-
if (!keep3) drawn[role] = resolved2.fontFamily;
|
|
8957
|
-
} catch {
|
|
8958
|
-
}
|
|
8959
|
-
}
|
|
8960
|
-
return drawn;
|
|
8961
|
-
}
|
|
8962
|
-
|
|
8963
|
-
// src/script-measurement.ts
|
|
8964
|
-
function scriptProfile(presentation, slideIndex, options2, language) {
|
|
8965
|
-
let resolved2;
|
|
8966
|
-
try {
|
|
8967
|
-
resolved2 = resolveScriptFonts(presentation, { slideIndex, ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, ...language === void 0 ? {} : { language } });
|
|
8968
|
-
} catch {
|
|
8969
|
-
resolved2 = void 0;
|
|
8970
|
-
}
|
|
8971
|
-
const slots = (role) => {
|
|
8972
|
-
const latin = options2.fontFamilies[role];
|
|
8973
|
-
const slot = (key3) => !resolved2 || resolved2.sources[key3] === "latin" || resolved2.sources[key3] === "schemeFamily" ? latin : resolved2[role][key3] ?? latin;
|
|
8974
|
-
return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
|
|
8975
|
-
};
|
|
8976
|
-
return {
|
|
8977
|
-
heading: slots("heading"),
|
|
8978
|
-
body: slots("body"),
|
|
8979
|
-
...resolved2?.supplement ? { supplement: resolved2.supplement } : {},
|
|
8980
|
-
script: resolved2?.script ?? "Zzzz",
|
|
8981
|
-
...resolved2 ? { scriptRole: resolved2.scriptRole, bcp47: resolved2.bcp47, lang: resolved2.lang, languageSource: resolved2.languageSource, direction: resolved2.direction } : {},
|
|
8982
|
-
rtl: resolved2?.rtl === true,
|
|
8983
|
-
serif: options2.serif
|
|
8984
|
-
};
|
|
8985
|
-
}
|
|
8986
|
-
function slideScriptMeasurement(presentation, slideIndex, measurement, options2) {
|
|
8987
|
-
const forScripts = measurement.forScripts;
|
|
8988
|
-
if (typeof forScripts !== "function") return measurement;
|
|
8989
|
-
const deckProfile = scriptProfile(presentation, slideIndex, options2);
|
|
8990
|
-
const deck = forScripts.call(measurement, deckProfile);
|
|
8991
|
-
const languages = /* @__PURE__ */ new Map();
|
|
8992
|
-
const forLanguage = (lang) => {
|
|
8993
|
-
if (typeof lang !== "string" || !lang) return void 0;
|
|
8994
|
-
if (!languages.has(lang)) {
|
|
8995
|
-
let own4;
|
|
8996
|
-
try {
|
|
8997
|
-
const profile = scriptProfile(presentation, slideIndex, options2, lang);
|
|
8998
|
-
own4 = profile.languageSource === "option" && profile.bcp47?.toLowerCase() !== deckProfile.bcp47?.toLowerCase() ? forScripts.call(measurement, profile) : void 0;
|
|
8999
|
-
} catch {
|
|
9000
|
-
own4 = void 0;
|
|
9001
|
-
}
|
|
9002
|
-
languages.set(lang, own4);
|
|
9003
|
-
}
|
|
9004
|
-
return languages.get(lang);
|
|
9005
|
-
};
|
|
9006
|
-
const pick = (style) => forLanguage(style?.lang) ?? deck;
|
|
9007
|
-
const scripted = { ...deck, measure: (text2, size, style) => pick(style).measure(text2, size, style) };
|
|
9008
|
-
if (typeof deck.resolveStyle === "function") scripted.resolveStyle = (style) => deck.resolveStyle.call(deck, style);
|
|
9009
|
-
if (typeof deck.outlineBounds === "function")
|
|
9010
|
-
scripted.outlineBounds = (text2, size, style) => {
|
|
9011
|
-
const own4 = pick(style);
|
|
9012
|
-
return typeof own4.outlineBounds === "function" ? own4.outlineBounds(text2, size, style) : deck.outlineBounds.call(deck, text2, size, style);
|
|
9013
|
-
};
|
|
9014
|
-
return scripted;
|
|
9015
|
-
}
|
|
9016
|
-
function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, options2 = {}) {
|
|
9017
|
-
if (typeof measurement.forScripts !== "function") return measurement;
|
|
9018
|
-
const { fontScheme } = resolveDesignRecords(presentation, slideIndex, options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {});
|
|
9019
|
-
const resolved2 = resolveFontFamilies(fontScheme);
|
|
9020
|
-
const fontFamilies = { heading: options2.fontFamilies?.heading ?? resolved2.heading, body: options2.fontFamilies?.body ?? resolved2.body };
|
|
9021
|
-
return slideScriptMeasurement(presentation, slideIndex, measurement, { ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, fontFamilies, serif: fontScheme.type === "serif" });
|
|
9022
|
-
}
|
|
9023
|
-
|
|
9024
|
-
// src/message-surface.ts
|
|
9025
|
-
var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9026
|
-
var MESSAGE_SURFACE_SLOT = "accent1";
|
|
9027
|
-
var MESSAGE_SURFACE_CONTRAST = 4.5;
|
|
9028
|
-
function messageKind(slide, layout) {
|
|
9029
|
-
const lone = lonePayload(slide);
|
|
9030
|
-
if (lone?.field !== "text" || annotationText(slide.subtitle).trim()) return void 0;
|
|
9031
|
-
let plan;
|
|
9032
|
-
try {
|
|
9033
|
-
plan = isLayoutTemplate(layout) ? layoutTemplate(layout) : void 0;
|
|
9034
|
-
} catch {
|
|
9035
|
-
return void 0;
|
|
9036
|
-
}
|
|
9037
|
-
if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
|
|
9038
|
-
if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
|
|
9039
|
-
const value = lone.host.text;
|
|
9040
|
-
const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
|
|
9041
|
-
return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
|
|
9042
|
-
}
|
|
9043
|
-
function lchOf(hex) {
|
|
9044
|
-
const lin = (at2) => {
|
|
9045
|
-
const value = Number.parseInt(hex.slice(at2, at2 + 2), 16) / 255;
|
|
9046
|
-
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
9047
|
-
};
|
|
9048
|
-
const [r, g, b] = [lin(1), lin(3), lin(5)];
|
|
9049
|
-
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;
|
|
9050
|
-
const f = (t) => t > 216 / 24389 ? Math.cbrt(t) : (24389 / 27 * t + 16) / 116;
|
|
9051
|
-
const [fx, fy, fz] = [f(x), f(y), f(z)];
|
|
9052
|
-
return { L: 116 * fy - 16, C: Math.hypot(500 * (fx - fy), 200 * (fy - fz)) };
|
|
9053
|
-
}
|
|
9054
|
-
var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
|
|
9055
|
-
var MESSAGE_SURFACE_MAX_CHROMA = 80;
|
|
9056
|
-
function resolveMessageSurface(presentation, slide, layout, context) {
|
|
9057
|
-
const deckDesign = rec3(rec3(presentation).design);
|
|
9058
|
-
const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
|
|
9059
|
-
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;
|
|
9060
|
-
const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
|
|
9061
|
-
const variant = { background: MESSAGE_SURFACE_SLOT, ...below.variant?.accents ? { accents: below.variant.accents } : {} };
|
|
9062
|
-
const plain = resolveColorRoles(context.colorScheme, { background: below.background, variant: below.variant });
|
|
9063
|
-
const deliberate = [deckDesign, ...context.themeChosen ? [context.theme] : []].some((level) => level.background !== void 0 || level.variant !== void 0);
|
|
9064
|
-
if (plain.dark && deliberate) return void 0;
|
|
9065
|
-
const accent = resolveColorRoles(context.colorScheme, { variant }), shade = lchOf(accent.background.slice(0, 7).toUpperCase());
|
|
9066
|
-
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;
|
|
9067
|
-
return { kind, variant };
|
|
9690
|
+
}
|
|
9068
9691
|
}
|
|
9069
|
-
function
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9692
|
+
function listColumnsChangeDrawing(region) {
|
|
9693
|
+
if (!isRecord2(region) || region.listColumns !== "auto") return true;
|
|
9694
|
+
const accepts = Array.isArray(region.accepts) ? region.accepts : [];
|
|
9695
|
+
const arrangement = region.arrangement ?? region.sequence;
|
|
9696
|
+
return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
|
|
9073
9697
|
}
|
|
9074
|
-
function
|
|
9075
|
-
|
|
9076
|
-
const text2 = size("text"), title = size("title");
|
|
9077
|
-
if (kind === "statement-message") return text2 !== void 0 && text2 / scale >= LONE_DISPLAY_SIZES.text - 1e-6 || title !== void 0 && title / scale > 54 + 1e-6;
|
|
9078
|
-
return text2 !== void 0 && text2 / scale > LONE_DISPLAY_SIZES.text + 1e-6;
|
|
9698
|
+
function sheetReference(name) {
|
|
9699
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : `'${name.replaceAll("'", "''")}'`;
|
|
9079
9700
|
}
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
const bare = (style) => ({ ...style, path: void 0 });
|
|
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;
|
|
9085
9705
|
return {
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
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)] };
|
|
9092
9728
|
}
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
const
|
|
9096
|
-
if (!
|
|
9097
|
-
const
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
const
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
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
|
+
};
|
|
9111
9754
|
}
|
|
9112
|
-
if (
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
|
|
9120
|
-
...layout ? { layout } : {},
|
|
9121
|
-
presentation,
|
|
9122
|
-
slideIndex: index,
|
|
9123
|
-
slideNumber: options2.slideNumber ?? index + 1,
|
|
9124
|
-
slideCount: options2.slideCount ?? slides.length,
|
|
9125
|
-
fontFamilies: resolveFontFamilies(fontScheme),
|
|
9126
|
-
darkBackground: roles2.dark,
|
|
9127
|
-
...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
|
|
9128
|
-
// LH-02: the colors the automatic scrim of a picture background is sized for.
|
|
9129
|
-
roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
|
|
9130
|
-
...theme.background !== void 0 ? { themeBackground: theme.background } : {},
|
|
9131
|
-
// OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
|
|
9132
|
-
...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
|
|
9133
|
-
...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
|
|
9134
|
-
...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}` }])]
|
|
9135
9762
|
};
|
|
9136
|
-
return { levels, roles: roles2, layoutVariant: layoutVariant2, composeOptions: composeOptions2 };
|
|
9137
|
-
};
|
|
9138
|
-
const variablesOf = (made) => resolveSlideVariables(slide, { slideNumber: made.composeOptions.slideNumber, slideCount: made.composeOptions.slideCount, presentation, darkBackground: made.composeOptions.darkBackground === true });
|
|
9139
|
-
let messageSurface = candidate, built = build(candidate);
|
|
9140
|
-
if (candidate) {
|
|
9141
|
-
const plain = build(void 0);
|
|
9142
|
-
const host = plain.composeOptions.textMeasurement;
|
|
9143
|
-
const measurement = host ? unpathed(slideScriptMeasurement(presentation, index, host, { ...catalogs, fontFamilies: resolveFontFamilies(fontScheme), serif: fontScheme.type === "serif" })) : host;
|
|
9144
|
-
let displayed = false;
|
|
9145
|
-
try {
|
|
9146
|
-
displayed = messageDisplayed(composeSlide(variablesOf(plain), { ...plain.composeOptions, ...measurement ? { textMeasurement: measurement } : {} }), candidate.kind);
|
|
9147
|
-
} catch {
|
|
9148
|
-
displayed = false;
|
|
9149
|
-
}
|
|
9150
|
-
if (displayed && index > 0) {
|
|
9151
|
-
const before = rec4(slides[index - 1]), record = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
|
|
9152
|
-
if (drawsAccentByDesign(presentation, before, record, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
|
|
9153
|
-
}
|
|
9154
|
-
if (!displayed) {
|
|
9155
|
-
messageSurface = void 0;
|
|
9156
|
-
built = plain;
|
|
9157
|
-
}
|
|
9158
9763
|
}
|
|
9159
|
-
|
|
9160
|
-
const resolvedSlide = variablesOf(built);
|
|
9161
|
-
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;
|
|
9162
9765
|
}
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
const
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
if (
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
for (const child of Object.values(object2)) 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)] };
|
|
9188
9790
|
}
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
}
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
const
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
const layout = lazy(() => resolved2().options.layout);
|
|
9211
|
-
const compute = () => {
|
|
9212
|
-
const result = { layoutDiagnostics: [] };
|
|
9213
|
-
let fontFamilies;
|
|
9214
|
-
const compose = (input, withLayout) => {
|
|
9215
|
-
const options3 = resolved2().options;
|
|
9216
|
-
fontFamilies ??= options3.fontFamilies && resolveDrawnFontFamilies(options3.fontFamilies, options3.textMeasurement);
|
|
9217
|
-
return composeSlide(input, { ...options3, ...fontFamilies ? { fontFamilies } : {}, layout: withLayout });
|
|
9218
|
-
};
|
|
9219
|
-
try {
|
|
9220
|
-
result.composition = compose(resolved2().slide, layout());
|
|
9221
|
-
result.layoutDiagnostics.push(...result.composition.diagnostics.map((diagnostic) => ({ diagnostic, strict: false })));
|
|
9222
|
-
} catch (error) {
|
|
9223
|
-
if (error instanceof OPFCompositionError) {
|
|
9224
|
-
result.layoutDiagnostics.push(...error.diagnostics.map((diagnostic) => ({ diagnostic, strict: true })));
|
|
9225
|
-
try {
|
|
9226
|
-
const relaxedLayout = layout();
|
|
9227
|
-
result.composition = compose(relax(resolved2().slide), relaxedLayout ? relax(relaxedLayout) : void 0);
|
|
9228
|
-
} catch (second) {
|
|
9229
|
-
result.layoutError = second instanceof Error ? second.message : String(second);
|
|
9230
|
-
}
|
|
9231
|
-
} else result.layoutError = error instanceof Error ? error.message : String(error);
|
|
9232
|
-
}
|
|
9233
|
-
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" }])]
|
|
9234
9812
|
};
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
const
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
return
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
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 };
|
|
9257
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 };
|
|
9258
9862
|
}
|
|
9259
9863
|
|
|
9260
9864
|
// src/validation-cache.ts
|
|
@@ -9467,7 +10071,7 @@ var ValidationCompositionCache = class {
|
|
|
9467
10071
|
|
|
9468
10072
|
// src/validator.ts
|
|
9469
10073
|
var SEVERITIES = ["error", "warning", "info"];
|
|
9470
|
-
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"];
|
|
9471
10075
|
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9472
10076
|
var OPFValidationError = class extends Error {
|
|
9473
10077
|
/** The full report that failed. */
|
|
@@ -9546,6 +10150,7 @@ function resolveOptions(options2) {
|
|
|
9546
10150
|
throw new TypeError("Validate chartPalette must be an array of #RRGGBB colors.");
|
|
9547
10151
|
if (options2.template !== void 0 && typeof options2.template !== "boolean") throw new TypeError("Validate template must be true or false.");
|
|
9548
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).");
|
|
9549
10154
|
const level = (info) => severity.get(info.id) ?? severity.get(info.category);
|
|
9550
10155
|
const off = (info) => level(info) === "off" || !!ignore?.rules.has(info.id) || !!ignore?.categories.has(info.category);
|
|
9551
10156
|
return {
|
|
@@ -9569,7 +10174,7 @@ var categoryOrder = (category) => {
|
|
|
9569
10174
|
};
|
|
9570
10175
|
var auditInfos = ruleImplementations.flatMap((entry2) => [entry2.info, ...entry2.also ?? []]);
|
|
9571
10176
|
var isLayoutRule = (info) => info.category === "layout" && info.cost === "composition";
|
|
9572
|
-
function
|
|
10177
|
+
function slideOf2(path) {
|
|
9573
10178
|
const match2 = /^\/slides\/(\d+)(?:\/|$)/.exec(path);
|
|
9574
10179
|
return match2 ? Number(match2[1]) : void 0;
|
|
9575
10180
|
}
|
|
@@ -9601,7 +10206,7 @@ function syntaxReport(parsed, run) {
|
|
|
9601
10206
|
return { valid: tally.error === 0, schemaValid: null, findings, counts: tally, checks };
|
|
9602
10207
|
}
|
|
9603
10208
|
function validateDocument(document, run, parsed, cache) {
|
|
9604
|
-
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 } : {} });
|
|
9605
10210
|
const schemaValid = engine.errors.length === 0;
|
|
9606
10211
|
const slides = isObject3(document) && Array.isArray(document.slides) ? document.slides : [];
|
|
9607
10212
|
const auditWanted = auditInfos.some((info) => run.enabled(info));
|
|
@@ -9665,7 +10270,7 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9665
10270
|
if (!STALE_RECORD_RULES.has(entry2.ruleId) || entry2.scope === "context") return void 0;
|
|
9666
10271
|
const match2 = /^\/catalogs\/([^/]+)\/layouts\/([^/]+)(?:\/|$)/.exec(entry2.path);
|
|
9667
10272
|
if (!match2) return void 0;
|
|
9668
|
-
const [group, id] = [match2[1], match2[2]].map((
|
|
10273
|
+
const [group, id] = [match2[1], match2[2]].map((segment2) => segment2.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
9669
10274
|
let found = staleCopies.get(`${group}/${id}`);
|
|
9670
10275
|
if (!found) {
|
|
9671
10276
|
const copy = staleLayoutCopy(document, group, id, run.options);
|
|
@@ -9681,7 +10286,7 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9681
10286
|
const override = info ? run.severity(info) : void 0;
|
|
9682
10287
|
let next = override && override !== entry2.severity ? { ...entry2, severity: override } : entry2;
|
|
9683
10288
|
if (info && run.ignored(info, splitPointer(next.path))) continue;
|
|
9684
|
-
const index =
|
|
10289
|
+
const index = slideOf2(next.path);
|
|
9685
10290
|
if (next.slide === void 0 && index !== void 0 && next.scope !== "context") {
|
|
9686
10291
|
const id = isObject3(slides[index]) ? slides[index].id : void 0;
|
|
9687
10292
|
next.slide = index;
|
|
@@ -9691,9 +10296,9 @@ function validateDocument(document, run, parsed, cache) {
|
|
|
9691
10296
|
const location = parsed.locate(next.path);
|
|
9692
10297
|
if (location) next.location = location;
|
|
9693
10298
|
}
|
|
9694
|
-
const removed = next.scope !== "context" ? removedKeyRepair(next, document) : void 0;
|
|
10299
|
+
const removed = next.scope !== "context" ? removedKeyRepair(next, document, run.options) : void 0;
|
|
9695
10300
|
if (removed) next = withRepair(next, removed);
|
|
9696
|
-
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) {
|
|
9697
10302
|
const fixes = schemaFixes(next, document);
|
|
9698
10303
|
if (fixes.length) next.fixes = fixes;
|
|
9699
10304
|
}
|
|
@@ -9763,7 +10368,7 @@ function assertValid(value, options2 = {}) {
|
|
|
9763
10368
|
}
|
|
9764
10369
|
function withRepair(finding2, removed) {
|
|
9765
10370
|
const { suggestions, ...rest } = finding2;
|
|
9766
|
-
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 } : {} };
|
|
9767
10372
|
}
|
|
9768
10373
|
function validateCatalogRecord(kind, value) {
|
|
9769
10374
|
const kinds = Object.keys(catalogSchemaNames);
|
|
@@ -9791,4 +10396,4 @@ function assertValidCatalogRecord(kind, value) {
|
|
|
9791
10396
|
if (!report2.valid) throw new OPFValidationError(report2);
|
|
9792
10397
|
}
|
|
9793
10398
|
|
|
9794
|
-
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 };
|