@openpresentation/opf 0.33.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/browser.js +20 -19
- package/dist/catalog-refs-CoIrOdAw.d.ts +937 -0
- package/dist/{catalog-schemas-CQTM-G8p.d.ts → catalog-schemas-FjLRPtjB.d.ts} +1 -1
- package/dist/{chart-data-oIZQlFGi.d.ts → chart-data-B_k-WTex.d.ts} +7 -4
- package/dist/{chunk-XIOC6N5P.js → chunk-244OPLAV.js} +1 -1
- package/dist/{chunk-KVHNDHVS.js → chunk-2B6GLT2O.js} +1 -1
- package/dist/{chunk-VMBLNCX2.js → chunk-6PMXVP5G.js} +117 -30
- package/dist/{chunk-BI4ERFAA.js → chunk-AAWHOCXS.js} +48 -13
- package/dist/{chunk-QD6DPS7X.js → chunk-ABA2D6X5.js} +2 -2
- package/dist/{chunk-UK3J6FSU.js → chunk-AEHDXNZX.js} +862 -269
- package/dist/{chunk-DAS75LGR.js → chunk-AGYPRTEC.js} +4 -4
- package/dist/chunk-BLCDUM7B.js +7 -0
- package/dist/{chunk-OPVJLL7H.js → chunk-CJVKOJ6B.js} +11841 -8687
- package/dist/{chunk-Y557TYML.js → chunk-CQXBGZQP.js} +19 -16
- package/dist/{chunk-VKEYV3ZK.js → chunk-FCSYIBVR.js} +2 -2
- package/dist/{chunk-PJSPHHRK.js → chunk-FK5XG742.js} +3 -16
- package/dist/{chunk-R6C6BQOG.js → chunk-HHVQ2SDT.js} +1 -1
- package/dist/{chunk-ABWEUXLV.js → chunk-L3MCLD3X.js} +117 -21
- package/dist/{chunk-QF5RSRXU.js → chunk-LCT5ZV3Q.js} +750 -199
- package/dist/{chunk-E7WQHMCL.js → chunk-MAFJ5O2D.js} +16 -14
- package/dist/{chunk-XANW7MB7.js → chunk-MUILZGRY.js} +4 -4
- package/dist/chunk-NLJFNCZ4.js +1560 -0
- package/dist/{chunk-VSBZC2PR.js → chunk-SR6T4LKI.js} +3 -3
- package/dist/chunk-UJZN2ZH6.js +1 -0
- package/dist/{chunk-IJXKVM4W.js → chunk-VDZXNNZF.js} +1 -1
- package/dist/{chunk-YYT6N7AI.js → chunk-WCPDN7AY.js} +1 -1
- package/dist/{chunk-S5QRGMUQ.js → chunk-X72WPTST.js} +6 -6
- package/dist/{chunk-INIMUBSE.js → chunk-XJUMFH33.js} +1 -1
- package/dist/{chunk-YS333HLA.js → chunk-XLSWZSQS.js} +2 -2
- package/dist/{composition-zMiIgzip.d.ts → composition-CvtvgBDE.d.ts} +1360 -1531
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +2 -1
- package/dist/conversion-CSQ5EHD2.js +25 -0
- package/dist/{conversion-mNth9XKm.d.ts → conversion-CyNRlWGw.d.ts} +25 -7
- package/dist/convert.d.ts +4 -4
- package/dist/convert.js +15 -11
- package/dist/data.d.ts +2 -2
- package/dist/data.js +3 -2
- package/dist/{deck-report-BSlRiR0_.d.ts → deck-report-BVlQZ42f.d.ts} +3 -3
- package/dist/deck.d.ts +6 -6
- package/dist/deck.js +12 -11
- package/dist/diagram-engine-eager.js +5 -1
- package/dist/diagram-engine-lazy.js +13 -0
- package/dist/diagram-plantuml-XRZ6VAOL.js +3 -0
- package/dist/diff.js +5 -4
- package/dist/docs.js +65 -53
- package/dist/examples.js +4070 -1083
- package/dist/font-policy.js +1 -1
- package/dist/format.js +2 -2
- package/dist/ids.js +5 -4
- package/dist/index.d.ts +18 -16
- package/dist/index.js +35 -24
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +9 -8
- package/dist/node-engine.d.ts +43 -11
- package/dist/node-engine.js +45 -26
- package/dist/{pagination-CYzNMazO.d.ts → pagination-CZQQYk7L.d.ts} +4 -3
- package/dist/pagination.d.ts +4 -4
- package/dist/pagination.js +5 -4
- package/dist/patch.js +4 -3
- package/dist/precompiled.js +2 -2
- package/dist/{presentation-CXhfpB_z.d.ts → presentation-s9262acV.d.ts} +357 -230
- 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 +3 -3
- package/dist/schema.js +4 -3
- package/dist/schemas.d.ts +16 -0
- 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-BK7JNEUV.js → shape-engine-module-N74FCHGY.js} +2 -2
- package/dist/shape-geometry.js +1 -1
- package/dist/source.d.ts +10 -5
- package/dist/source.js +11 -10
- package/dist/spec/reference/engine-vocabularies.json +135 -0
- package/dist/spec/reference/font-policy.json +3 -16
- package/dist/spec/reference/preset-geometry.json +3 -3
- package/dist/spec/schemas/icon-set.schema.json +1 -1
- package/dist/spec/schemas/layout.schema.json +71 -25
- package/dist/spec/schemas/opf.schema.json +540 -168
- package/dist/spec/schemas/theme.schema.json +11 -5
- package/dist/types.d.ts +81 -73
- package/dist/{validation-types-COwTel3H.d.ts → validation-types-CYbsUuZ9.d.ts} +8 -5
- package/dist/validator.d.ts +34 -7
- package/dist/validator.js +4 -3
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +8 -7
- package/package.json +6 -6
- package/dist/catalog-refs-B_0_vZg0.d.ts +0 -134
- package/dist/chunk-ZXOIGUHX.js +0 -1
- package/dist/conversion-POHRAMSN.js +0 -24
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { original } from './chunk-JBARNYFR.js';
|
|
2
|
-
import { schemas, schemaEntries } from './chunk-
|
|
3
|
-
import { promotedRegionKeys, SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, quoteMarksFor, quoteLanguage, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads,
|
|
2
|
+
import { schemas, schemaEntries } from './chunk-LCT5ZV3Q.js';
|
|
3
|
+
import { promotedRegionKeys, SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, quoteMarksFor, quoteLanguage, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads, intrinsicImageSize, resolveReference, layoutTable, colorTransform, applyColorTransform, resolveColorRef, readingRows, visualReadingOrder, numberingSystemExtension, isSupportedNumberingSystem, plainLanguageTag, supportedNumberingSystems, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, inlineDatasets, hasBuiltinDependency, isRecord, hasContentVariables, isTemplate, instantiateForValidation, layoutTemplateIssues, deckBackgroundIsFixed, resolveScriptFonts, lonePayload, annotationText, isLayoutTemplate, layoutTemplate, statementMessage, messageWords, SHORT_MESSAGE_WORDS, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, documentIcons, iconIssue, walkCitationRuns, HALF_STEPPED, MAX_COMPOSITION_DEPTH, isOverlayConnector, connectorAdjustPreset, shapeIssues, pathFor, overlayIssues, datasetDiagnostics, defaultSlideBackground, catalogRecords, collectCitations, resolveSlideDirection, numberingFindings, chartDrawDiagnostics, resolveTableData, resolveChartOptions, chartOptionTarget, codeHighlightLines, chartNumberFixesByCell, catalogKinds, catalogGroupSource, registeredCatalog, representablePositionBox, PositionRangeError, isShapeBlock, OPFCompositionError } from './chunk-CJVKOJ6B.js';
|
|
4
4
|
import { schemaEngine } from '#schema-engine';
|
|
5
5
|
import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
|
|
6
6
|
|
|
@@ -200,8 +200,8 @@ function rememberValidationDefinition(issue2, parentSchema, keyword) {
|
|
|
200
200
|
pointer: current.pointer,
|
|
201
201
|
uri: `${entry2.schema.$id}#${current.pointer}`
|
|
202
202
|
});
|
|
203
|
-
for (const [
|
|
204
|
-
const segment =
|
|
203
|
+
for (const [key3, value] of Object.entries(current.value)) {
|
|
204
|
+
const segment = key3.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
205
205
|
stack.push({ value, pointer: `${current.pointer}/${segment}` });
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -299,12 +299,12 @@ var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "adjust", "stro
|
|
|
299
299
|
var shapeImageFields = /* @__PURE__ */ new Set(["aspectRatio", "shape", "adjust", "stroke", "opacity"]);
|
|
300
300
|
var shapeOptionFields = SHAPE_BLOCK_KEYS.filter((field) => field !== "path");
|
|
301
301
|
var columnSpans = {
|
|
302
|
-
|
|
302
|
+
start: [0],
|
|
303
303
|
center: [1],
|
|
304
|
-
|
|
305
|
-
"
|
|
306
|
-
"center+
|
|
307
|
-
"
|
|
304
|
+
end: [2],
|
|
305
|
+
"start+center": [0, 1],
|
|
306
|
+
"center+end": [1, 2],
|
|
307
|
+
"start+center+end": [0, 1, 2]
|
|
308
308
|
};
|
|
309
309
|
var rowSpans = {
|
|
310
310
|
top: [0],
|
|
@@ -354,12 +354,31 @@ function semanticIssue(path, message, params2 = {}) {
|
|
|
354
354
|
params: params2
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
|
-
function hasOwn(value,
|
|
358
|
-
return Object.hasOwn(value,
|
|
357
|
+
function hasOwn(value, key3) {
|
|
358
|
+
return Object.hasOwn(value, key3);
|
|
359
359
|
}
|
|
360
360
|
function isEnUkTag(value) {
|
|
361
361
|
return typeof value === "string" && value.toLowerCase() === "en-uk";
|
|
362
362
|
}
|
|
363
|
+
var EN_UK_MESSAGE = "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag";
|
|
364
|
+
function enUkIssues(language, path) {
|
|
365
|
+
const at2 = isEnUkTag(language) ? path : isRecord(language) && isEnUkTag(language.bcp47) ? `${path}/bcp47` : void 0;
|
|
366
|
+
return at2 ? [semanticIssue(at2, EN_UK_MESSAGE, { replacement: "en-GB" })] : [];
|
|
367
|
+
}
|
|
368
|
+
function overlayAnchorSizeWarnings(value) {
|
|
369
|
+
const issues = [];
|
|
370
|
+
if (isRecord(value) && Array.isArray(value.slides)) value.slides.forEach((slide, index) => {
|
|
371
|
+
if (isRecord(slide) && Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
|
|
372
|
+
const at2 = isRecord(entry2) ? entry2.at : void 0;
|
|
373
|
+
if (isRecord(at2)) for (const key3 of ["width", "height"]) {
|
|
374
|
+
const size = at2[key3];
|
|
375
|
+
if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(at2, `${key3}Px`))
|
|
376
|
+
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 }));
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
return issues;
|
|
381
|
+
}
|
|
363
382
|
function presentFields(value, fields2) {
|
|
364
383
|
return fields2.filter((field) => hasOwn(value, field));
|
|
365
384
|
}
|
|
@@ -394,7 +413,7 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
394
413
|
const explicitType = value.type;
|
|
395
414
|
const payloadFields = presentFields(value, rootPayloadFields);
|
|
396
415
|
const hasBlocks = hasOwn(value, "blocks");
|
|
397
|
-
const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table or
|
|
416
|
+
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 });
|
|
398
417
|
const imageOptionIssues = (reason, params2 = {}, except = /* @__PURE__ */ new Set()) => {
|
|
399
418
|
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 }));
|
|
400
419
|
};
|
|
@@ -413,7 +432,7 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
413
432
|
if (incompatible2.length) issues.push(semanticIssue(path, "blocks cannot be mixed with leaf payload fields", { fields: incompatible2 }));
|
|
414
433
|
if (!Array.isArray(value.blocks) || value.blocks.length === 0 && !options2.slideRoot) issues.push(semanticIssue(pathFor(path, "blocks"), "a group requires at least one block"));
|
|
415
434
|
if (Array.isArray(value.blocks)) value.blocks.forEach((block, index) => {
|
|
416
|
-
if (isRecord(block)) issues.push(...validateContentPayload(block, `${pathFor(path, "blocks")}/${index}`, { topLevel: options2.slideRoot === true }));
|
|
435
|
+
if (isRecord(block)) issues.push(...validateContentPayload(block, `${pathFor(path, "blocks")}/${index}`, { topLevel: options2.slideRoot === true, ...options2.canvas ? { canvas: options2.canvas } : {} }));
|
|
417
436
|
});
|
|
418
437
|
if (options2.slideRoot && Array.isArray(value.blocks)) {
|
|
419
438
|
const edges = /* @__PURE__ */ new Map();
|
|
@@ -459,13 +478,30 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
459
478
|
if (resolvedKind !== "image") imageOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind }, resolvedKind === "shape" ? shapeImageFields : void 0);
|
|
460
479
|
if (resolvedKind !== "shape") shapeOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind });
|
|
461
480
|
if (resolvedKind === "shape" || resolvedKind === "image")
|
|
462
|
-
for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at2,
|
|
481
|
+
for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
|
|
482
|
+
if (resolvedKind === "image" && isRecord(value.image) && Array.isArray(value.image.callouts)) {
|
|
483
|
+
value.image.callouts.forEach((callout, index) => {
|
|
484
|
+
if (!isRecord(callout)) return;
|
|
485
|
+
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 }));
|
|
486
|
+
const canvas = options2.canvas;
|
|
487
|
+
if (canvas && ["x", "y", "width", "height"].every((key3) => typeof callout[key3] === "number" && Number.isFinite(callout[key3]))) {
|
|
488
|
+
const at2 = `${pathFor(path, "image")}/callouts/${index}`, frame = callout;
|
|
489
|
+
try {
|
|
490
|
+
representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height }, at2.replace(/^\//, "").replaceAll("/", "."));
|
|
491
|
+
} catch (error) {
|
|
492
|
+
if (!(error instanceof PositionRangeError)) throw error;
|
|
493
|
+
issues.push(semanticIssue(`${at2}/${error.coordinate}`, error.message, { key: error.coordinate }));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
463
498
|
const allowedFields = /* @__PURE__ */ new Set([
|
|
464
499
|
"type",
|
|
465
500
|
...spec.fields
|
|
466
501
|
]);
|
|
502
|
+
const listOfBullets = resolvedKind === "list" && hasOwn(value, "bullets") && !hasOwn(value, "items");
|
|
467
503
|
for (const required of spec.required) {
|
|
468
|
-
if (!hasOwn(value, required)) {
|
|
504
|
+
if (!hasOwn(value, required) && !listOfBullets) {
|
|
469
505
|
issues.push(semanticIssue(path, `content payload type '${resolvedKind}' requires '${required}'`, {
|
|
470
506
|
type: resolvedKind,
|
|
471
507
|
required
|
|
@@ -480,27 +516,27 @@ function validateContentPayload(value, path, options2 = {}) {
|
|
|
480
516
|
}
|
|
481
517
|
const incompatible = payloadFields.filter((field) => !allowedFields.has(field));
|
|
482
518
|
if (incompatible.length > 0) {
|
|
483
|
-
issues.push(semanticIssue(path, `content payload type '${resolvedKind}' cannot include incompatible fields: ${incompatible.join(", ")}`, {
|
|
519
|
+
issues.push(semanticIssue(path, listOfBullets && incompatible.length === 1 ? "'bullets' belongs to a text payload, so it cannot be a 'list': write the entries under 'items', or remove 'type'" : `content payload type '${resolvedKind}' cannot include incompatible fields: ${incompatible.join(", ")}`, {
|
|
484
520
|
type: resolvedKind,
|
|
485
521
|
incompatible
|
|
486
522
|
}));
|
|
487
523
|
}
|
|
488
524
|
return issues;
|
|
489
525
|
}
|
|
490
|
-
function slideRegion(
|
|
491
|
-
if (
|
|
492
|
-
const [rowPart, columnPart] =
|
|
526
|
+
function slideRegion(key3) {
|
|
527
|
+
if (key3.includes(":")) {
|
|
528
|
+
const [rowPart, columnPart] = key3.split(":");
|
|
493
529
|
if (!rowPart || !columnPart) return void 0;
|
|
494
530
|
const rows = rowSpans[rowPart];
|
|
495
531
|
const columns = columnSpans[columnPart];
|
|
496
532
|
return rows && columns ? { rows, columns } : void 0;
|
|
497
533
|
}
|
|
498
|
-
if (
|
|
499
|
-
const columns = columnSpans[
|
|
534
|
+
if (key3 in columnSpans) {
|
|
535
|
+
const columns = columnSpans[key3];
|
|
500
536
|
return columns ? { rows: [0, 1, 2], columns } : void 0;
|
|
501
537
|
}
|
|
502
|
-
if (
|
|
503
|
-
const rows = rowSpans[
|
|
538
|
+
if (key3 in rowSpans) {
|
|
539
|
+
const rows = rowSpans[key3];
|
|
504
540
|
return rows ? { rows, columns: [0, 1, 2] } : void 0;
|
|
505
541
|
}
|
|
506
542
|
return void 0;
|
|
@@ -511,9 +547,9 @@ function intersects(left, right) {
|
|
|
511
547
|
function regionsOverlap(left, right) {
|
|
512
548
|
return intersects(left.rows, right.rows) && intersects(left.columns, right.columns);
|
|
513
549
|
}
|
|
514
|
-
function validateSlideRegions(slide, slidePath) {
|
|
550
|
+
function validateSlideRegions(slide, slidePath, canvas) {
|
|
515
551
|
const issues = [];
|
|
516
|
-
const regionKeys = Object.keys(slide).filter((
|
|
552
|
+
const regionKeys = Object.keys(slide).filter((key3) => promotedRegionKeySet.has(key3));
|
|
517
553
|
const rootFields = presentFields(slide, rootPayloadFields);
|
|
518
554
|
if (regionKeys.length > 0 && rootFields.length > 0) {
|
|
519
555
|
issues.push(semanticIssue(slidePath, "root content payload fields cannot be mixed with promoted region keys", {
|
|
@@ -522,12 +558,12 @@ function validateSlideRegions(slide, slidePath) {
|
|
|
522
558
|
}));
|
|
523
559
|
}
|
|
524
560
|
if (regionKeys.length === 0 && rootFields.length > 0) {
|
|
525
|
-
issues.push(...validateContentPayload(slide, slidePath, { slideRoot: true }));
|
|
561
|
+
issues.push(...validateContentPayload(slide, slidePath, { slideRoot: true, ...canvas ? { canvas } : {} }));
|
|
526
562
|
}
|
|
527
|
-
for (const
|
|
528
|
-
const value = slide[
|
|
563
|
+
for (const key3 of regionKeys) {
|
|
564
|
+
const value = slide[key3];
|
|
529
565
|
if (isRecord(value)) {
|
|
530
|
-
issues.push(...validateContentPayload(value, pathFor(slidePath,
|
|
566
|
+
issues.push(...validateContentPayload(value, pathFor(slidePath, key3), canvas ? { canvas } : {}));
|
|
531
567
|
}
|
|
532
568
|
}
|
|
533
569
|
for (let leftIndex = 0; leftIndex < regionKeys.length; leftIndex += 1) {
|
|
@@ -551,19 +587,19 @@ function validateSlideRegions(slide, slidePath) {
|
|
|
551
587
|
}
|
|
552
588
|
function deckMetadataIssues(value) {
|
|
553
589
|
const issues = [];
|
|
554
|
-
const entries = (
|
|
555
|
-
const field = value[
|
|
556
|
-
if (Array.isArray(field)) return field.flatMap((entry2, index) => isRecord(entry2) ? [{ entry: entry2, path: `/${
|
|
557
|
-
return isRecord(field) ? [{ entry: field, path: `/${
|
|
590
|
+
const entries = (key3) => {
|
|
591
|
+
const field = value[key3];
|
|
592
|
+
if (Array.isArray(field)) return field.flatMap((entry2, index) => isRecord(entry2) ? [{ entry: entry2, path: `/${key3}/${index}` }] : []);
|
|
593
|
+
return isRecord(field) ? [{ entry: field, path: `/${key3}` }] : [];
|
|
558
594
|
};
|
|
559
595
|
const organizationIds = /* @__PURE__ */ new Set();
|
|
560
|
-
for (const
|
|
596
|
+
for (const key3 of ["organization", "speaker"]) {
|
|
561
597
|
const seen = /* @__PURE__ */ new Set();
|
|
562
|
-
for (const { entry: entry2, path } of entries(
|
|
598
|
+
for (const { entry: entry2, path } of entries(key3)) {
|
|
563
599
|
if (typeof entry2.id !== "string") continue;
|
|
564
|
-
if (seen.has(entry2.id)) issues.push(semanticIssue(`${path}/id`, `${
|
|
600
|
+
if (seen.has(entry2.id)) issues.push(semanticIssue(`${path}/id`, `${key3} ids must be unique within a presentation`, { id: entry2.id }));
|
|
565
601
|
seen.add(entry2.id);
|
|
566
|
-
if (
|
|
602
|
+
if (key3 === "organization") organizationIds.add(entry2.id);
|
|
567
603
|
}
|
|
568
604
|
}
|
|
569
605
|
for (const { entry: entry2, path } of entries("speaker")) {
|
|
@@ -573,25 +609,36 @@ function deckMetadataIssues(value) {
|
|
|
573
609
|
}
|
|
574
610
|
return issues;
|
|
575
611
|
}
|
|
576
|
-
function presentationSemanticIssues(value) {
|
|
612
|
+
function presentationSemanticIssues(value, catalogs) {
|
|
577
613
|
if (!isRecord(value) || !Array.isArray(value.slides)) {
|
|
578
614
|
return [];
|
|
579
615
|
}
|
|
580
616
|
const issues = [];
|
|
581
|
-
|
|
582
|
-
issues.push(semanticIssue("/language", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
|
|
583
|
-
replacement: "en-GB"
|
|
584
|
-
}));
|
|
585
|
-
} else if (isRecord(value.language) && isEnUkTag(value.language.bcp47)) {
|
|
586
|
-
issues.push(semanticIssue("/language/bcp47", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
|
|
587
|
-
replacement: "en-GB"
|
|
588
|
-
}));
|
|
589
|
-
}
|
|
617
|
+
issues.push(...enUkIssues(value.language, "/language"));
|
|
590
618
|
issues.push(...deckMetadataIssues(value));
|
|
591
619
|
if (isRecord(value.variables) && hasOwn(value.variables, "speakers")) {
|
|
592
620
|
issues.push(semanticIssue("/variables/speakers", "'speakers' is reserved for the built-in list of speaker names; choose another variable id", { id: "speakers" }));
|
|
593
621
|
}
|
|
594
622
|
const documentIds = /* @__PURE__ */ new Map();
|
|
623
|
+
let overlayCanvas, overlayCanvasResolved = false;
|
|
624
|
+
const deckCanvas = () => {
|
|
625
|
+
if (!overlayCanvasResolved) {
|
|
626
|
+
overlayCanvasResolved = true;
|
|
627
|
+
const design = isRecord(value.design) ? value.design : {};
|
|
628
|
+
const dimensions = design.dimensions ?? resolveDesignRecords(value, void 0, { catalogs: catalogs ?? [] }).theme.dimensions;
|
|
629
|
+
try {
|
|
630
|
+
overlayCanvas = resolveCanvasDimensions(dimensions);
|
|
631
|
+
} catch {
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return overlayCanvas;
|
|
635
|
+
};
|
|
636
|
+
const canvasForOverlays = (slide, index) => {
|
|
637
|
+
if (!Array.isArray(slide.shapes) || !slide.shapes.some((shape) => isRecord(shape) && shape.connector === void 0 && ["x", "y", "width", "height"].every((key3) => typeof shape[key3] === "number" && Number.isFinite(shape[key3])))) return void 0;
|
|
638
|
+
const canvas = deckCanvas();
|
|
639
|
+
return canvas ? { ...canvas, rtl: resolveSlideDirection(value, index) === "rtl" } : void 0;
|
|
640
|
+
};
|
|
641
|
+
const hasCallouts = (node, depth2 = 0) => isRecord(node) && depth2 <= 34 && Object.entries(node).some(([key3, entry2]) => key3 === "callouts" ? Array.isArray(entry2) && entry2.length > 0 : key3 === "image" || key3 === "blocks" || promotedRegionKeySet.has(key3) ? Array.isArray(entry2) ? entry2.some((item) => hasCallouts(item, depth2 + 1)) : hasCallouts(entry2, depth2 + 1) : false);
|
|
595
642
|
value.slides.forEach((slide, index) => {
|
|
596
643
|
if (isRecord(slide)) {
|
|
597
644
|
const slidePath = `/slides/${index}`;
|
|
@@ -615,10 +662,11 @@ function presentationSemanticIssues(value) {
|
|
|
615
662
|
else documentIds.set(entry2.id, "payload");
|
|
616
663
|
}
|
|
617
664
|
const checked = isOverlayConnector(entry2) ? isRecord(entry2.adjust) ? { shape: connectorAdjustPreset(entry2), adjust: entry2.adjust } : void 0 : entry2;
|
|
618
|
-
if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at2,
|
|
665
|
+
if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
|
|
619
666
|
});
|
|
620
|
-
for (const issue2 of overlayIssues(slide, slidePath)) issues.push(semanticIssue(issue2.path, issue2.message, { ...issue2.code ? { code: issue2.code } : {}, ...issue2.params }));
|
|
621
|
-
issues.push(...
|
|
667
|
+
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 }));
|
|
668
|
+
issues.push(...enUkIssues(slide.language, `${slidePath}/language`));
|
|
669
|
+
issues.push(...validateSlideRegions(slide, slidePath, hasCallouts(slide) ? deckCanvas() : void 0));
|
|
622
670
|
const payloadTableIssues = (payload, path) => {
|
|
623
671
|
if (isRecord(payload.table)) for (const issue2 of tableGrid(payload.table).issues) issues.push(semanticIssue(pathFor(path, "table") + issue2.path.slice(5).replaceAll(".", "/"), issue2.message));
|
|
624
672
|
};
|
|
@@ -728,9 +776,9 @@ function dataIssues(value) {
|
|
|
728
776
|
const seen = /* @__PURE__ */ new Set();
|
|
729
777
|
const add = (diagnostics) => {
|
|
730
778
|
for (const diagnostic of diagnostics) {
|
|
731
|
-
const
|
|
732
|
-
if (seen.has(
|
|
733
|
-
seen.add(
|
|
779
|
+
const key3 = `${diagnostic.code}|${diagnostic.path}`;
|
|
780
|
+
if (seen.has(key3)) continue;
|
|
781
|
+
seen.add(key3);
|
|
734
782
|
(diagnostic.severity === "error" ? out.errors : out.warnings).push(semanticIssue(diagnostic.path, diagnostic.message, { code: diagnostic.code }));
|
|
735
783
|
}
|
|
736
784
|
};
|
|
@@ -888,6 +936,9 @@ function variableReferenceWarnings(value) {
|
|
|
888
936
|
textEntries(node.items, pathFor(path, "items"));
|
|
889
937
|
textEntries(node.bullets, pathFor(path, "bullets"));
|
|
890
938
|
table(node.table, pathFor(path, "table"));
|
|
939
|
+
if (isRecord(node.chart) && Array.isArray(node.chart.referenceLines)) node.chart.referenceLines.forEach((line2, index) => {
|
|
940
|
+
if (isRecord(line2) && isRecord(line2.stroke)) colorRef(line2.stroke.color, `${path}/chart/referenceLines/${index}/stroke/color`);
|
|
941
|
+
});
|
|
891
942
|
};
|
|
892
943
|
value.slides.forEach((slide, index) => {
|
|
893
944
|
if (!isRecord(slide)) return;
|
|
@@ -927,24 +978,16 @@ function presentationReferenceWarnings(value, catalogs) {
|
|
|
927
978
|
};
|
|
928
979
|
highlightWarnings(slide, slidePath);
|
|
929
980
|
visitContentPayloads(slide, slidePath, highlightWarnings);
|
|
930
|
-
for (const
|
|
931
|
-
if (promotedRegionKeySet.has(
|
|
932
|
-
issues.push(...chartTypeWarnings(slide[
|
|
981
|
+
for (const key3 of Object.keys(slide)) {
|
|
982
|
+
if (promotedRegionKeySet.has(key3)) {
|
|
983
|
+
issues.push(...chartTypeWarnings(slide[key3], pathFor(slidePath, key3)));
|
|
933
984
|
}
|
|
934
985
|
}
|
|
935
986
|
});
|
|
936
987
|
return issues;
|
|
937
988
|
}
|
|
938
989
|
function validateLanguageSemantics(value) {
|
|
939
|
-
|
|
940
|
-
return [];
|
|
941
|
-
}
|
|
942
|
-
if (isEnUkTag(value.bcp47)) {
|
|
943
|
-
return [semanticIssue("/bcp47", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
|
|
944
|
-
replacement: "en-GB"
|
|
945
|
-
})];
|
|
946
|
-
}
|
|
947
|
-
return [];
|
|
990
|
+
return isRecord(value) ? enUkIssues(value.bcp47, "/bcp47") : [];
|
|
948
991
|
}
|
|
949
992
|
function contentDepthIssues(value) {
|
|
950
993
|
if (!isRecord(value) || !Array.isArray(value.slides)) return [];
|
|
@@ -954,7 +997,7 @@ function contentDepthIssues(value) {
|
|
|
954
997
|
if (Array.isArray(slide.blocks)) slide.blocks.forEach((block, i) => {
|
|
955
998
|
stack.push({ value: block, path: `/slides/${index}/blocks/${i}`, depth: 0, ancestors: [] });
|
|
956
999
|
});
|
|
957
|
-
for (const
|
|
1000
|
+
for (const key3 of promotedRegionKeys) if (hasOwn(slide, key3)) stack.push({ value: slide[key3], path: `/slides/${index}/${key3}`, depth: 0, ancestors: [] });
|
|
958
1001
|
});
|
|
959
1002
|
while (stack.length) {
|
|
960
1003
|
const entry2 = stack.pop();
|
|
@@ -1008,9 +1051,9 @@ function typedVariableErrors(errors, value) {
|
|
|
1008
1051
|
function pointerValue(root, pointer4) {
|
|
1009
1052
|
let current = root;
|
|
1010
1053
|
for (const token of pointer4.split("/").slice(1)) {
|
|
1011
|
-
const
|
|
1012
|
-
if (Array.isArray(current)) current = current[Number(
|
|
1013
|
-
else if (isRecord(current) && hasOwn(current,
|
|
1054
|
+
const key3 = token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
1055
|
+
if (Array.isArray(current)) current = current[Number(key3)];
|
|
1056
|
+
else if (isRecord(current) && hasOwn(current, key3)) current = current[key3];
|
|
1014
1057
|
else return void 0;
|
|
1015
1058
|
}
|
|
1016
1059
|
return current;
|
|
@@ -1078,12 +1121,13 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
|
|
|
1078
1121
|
if (resolved.schemaName === "layout" && valid) for (const issue2 of layoutTemplateIssues(subject)) errors.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code }));
|
|
1079
1122
|
const warnings = [];
|
|
1080
1123
|
if (resolved.schemaName === "presentation") {
|
|
1081
|
-
errors.push(...presentationSemanticIssues(subject));
|
|
1124
|
+
errors.push(...presentationSemanticIssues(subject, options2.catalogs));
|
|
1082
1125
|
errors.push(...variableIssues.errors);
|
|
1083
1126
|
const data = dataIssues(subject);
|
|
1084
1127
|
errors.push(...data.errors);
|
|
1085
1128
|
warnings.push(...presentationReferenceWarnings(subject, options2.catalogs));
|
|
1086
1129
|
warnings.push(...data.warnings);
|
|
1130
|
+
warnings.push(...overlayAnchorSizeWarnings(subject));
|
|
1087
1131
|
warnings.push(...variableIssues.warnings);
|
|
1088
1132
|
} else if (resolved.schemaName === "language") {
|
|
1089
1133
|
errors.push(...validateLanguageSemantics(value));
|
|
@@ -1299,6 +1343,31 @@ function decisionColor(definition, scheme, variables = {}) {
|
|
|
1299
1343
|
}
|
|
1300
1344
|
}
|
|
1301
1345
|
var THEME_SLOTS = /* @__PURE__ */ new Set(["light1", "light2", "dark1", "dark2"]);
|
|
1346
|
+
var PICTURE_STEPS = [0, 32, 64, 96, 128, 160, 192, 224, 255];
|
|
1347
|
+
var TONE_MARGIN = 1.2;
|
|
1348
|
+
function pictureColors(definition, scheme, variables = {}, grays) {
|
|
1349
|
+
const picture = imageBackground(definition);
|
|
1350
|
+
if (!picture) return [];
|
|
1351
|
+
const resolve2 = (value, fallback) => backgroundColorRef(value, scheme, variables, fallback);
|
|
1352
|
+
const recolor = rec(picture.recolor);
|
|
1353
|
+
const steps = PICTURE_STEPS;
|
|
1354
|
+
const duotone = recolor.dark !== void 0 && recolor.light !== void 0;
|
|
1355
|
+
const dark = duotone ? resolve2(recolor.dark, "#000000") : "#000000", light = duotone ? resolve2(recolor.light, "#FFFFFF") : "#FFFFFF";
|
|
1356
|
+
const base = defaultSlideBackground(scheme), opacity = picture.opacity ?? 1;
|
|
1357
|
+
const pixels = steps.map((step) => blend(blend(light, dark, step / 255), base, opacity));
|
|
1358
|
+
const overlay = rec(picture.overlay), alpha = typeof overlay.opacity === "number" ? Math.max(0, Math.min(1, overlay.opacity)) : void 0;
|
|
1359
|
+
if (overlay.color === void 0 || alpha === void 0) return pixels;
|
|
1360
|
+
const color = resolve2(overlay.color, "#000000"), covered = pixels.map((pixel) => blend(color, pixel, alpha));
|
|
1361
|
+
return overlay.edge === void 0 ? covered : [...pixels, ...covered];
|
|
1362
|
+
}
|
|
1363
|
+
function pictureTone(definition, scheme, variables = {}, grays) {
|
|
1364
|
+
const picture = imageBackground(definition);
|
|
1365
|
+
if (!picture || picture.recolor === void 0 && picture.overlay === void 0 && picture.opacity === void 0 && true) return void 0;
|
|
1366
|
+
const colors = pictureColors(definition, scheme, variables);
|
|
1367
|
+
const worst = (text2) => Math.min(...colors.map((color) => contrastRatio(text2, color)));
|
|
1368
|
+
const onDark = worst(resolveColorRoles(scheme, { variant: { background: "dark1" } }).text), onLight = worst(resolveColorRoles(scheme, { variant: { background: "light1" } }).text);
|
|
1369
|
+
return onDark >= onLight * TONE_MARGIN ? "dark" : onLight >= onDark * TONE_MARGIN ? "light" : void 0;
|
|
1370
|
+
}
|
|
1302
1371
|
function colorChoice(levels, scheme, variables = {}) {
|
|
1303
1372
|
let variantOnly = false;
|
|
1304
1373
|
let picture;
|
|
@@ -1316,7 +1385,7 @@ function colorChoice(levels, scheme, variables = {}) {
|
|
|
1316
1385
|
if (variantOnly || definition === void 0 || definition === null || definition === false) continue;
|
|
1317
1386
|
if (themeSlot) return { variant: { background: themeSlot } };
|
|
1318
1387
|
if (isPicture) {
|
|
1319
|
-
const tone = rec(definition).tone;
|
|
1388
|
+
const tone = rec(definition).tone ?? pictureTone(definition, scheme, variables);
|
|
1320
1389
|
if (tone === "dark" || tone === "light") return { variant: { background: tone === "dark" ? "dark1" : "light1" } };
|
|
1321
1390
|
variantOnly = true;
|
|
1322
1391
|
picture = { definition };
|
|
@@ -1429,10 +1498,13 @@ function backdropColors(backdrop, box, size, layer) {
|
|
|
1429
1498
|
const opacity = layer?.opacity ?? backdrop.opacity;
|
|
1430
1499
|
const ramp = layer?.grays ? [.../* @__PURE__ */ new Set([layer.grays[0], ...[0, 32, 64, 96, 128, 160, 192, 224, 255].filter((v) => v > layer.grays[0] && v < layer.grays[1]), layer.grays[1]])].map((v) => toHex([v, v, v])) : GREY_RAMP;
|
|
1431
1500
|
const colors = ramp.map((grey) => {
|
|
1432
|
-
|
|
1501
|
+
const pixel = layer?.duotone ? blend(layer.duotone[1], layer.duotone[0], toRgb(grey)[0] / 255) : grey;
|
|
1502
|
+
let color = blend(pixel, backdrop.base, opacity);
|
|
1433
1503
|
if (layer?.overlay) color = blend(layer.overlay.color, color, layer.overlay.opacity);
|
|
1434
1504
|
return color;
|
|
1435
1505
|
});
|
|
1506
|
+
const band = layer?.band;
|
|
1507
|
+
if (band) return { colors: [...band.whole ? [] : colors, ...colors.map((color) => blend(band.color, color, band.opacity))], unknown: true };
|
|
1436
1508
|
return { colors, unknown: true };
|
|
1437
1509
|
}
|
|
1438
1510
|
}
|
|
@@ -1498,6 +1570,10 @@ function textValues(slide, slidePath) {
|
|
|
1498
1570
|
push(at2("table", "rows", r, c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
|
|
1499
1571
|
});
|
|
1500
1572
|
});
|
|
1573
|
+
const callouts = rec(node.image).callouts;
|
|
1574
|
+
if (Array.isArray(callouts)) callouts.forEach((callout, index) => {
|
|
1575
|
+
push(at2("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
|
|
1576
|
+
});
|
|
1501
1577
|
const quote = node.quote;
|
|
1502
1578
|
if (typeof quote === "string") push(at2("quote"), quote, "quote", "quote");
|
|
1503
1579
|
else if (quote && typeof quote === "object") {
|
|
@@ -1509,9 +1585,9 @@ function textValues(slide, slidePath) {
|
|
|
1509
1585
|
const metric = node.metric;
|
|
1510
1586
|
if (typeof metric === "string") push(at2("metric"), metric, "metric", "metric");
|
|
1511
1587
|
else if (metric && typeof metric === "object")
|
|
1512
|
-
for (const
|
|
1513
|
-
const value = metric[
|
|
1514
|
-
if (typeof value === "string") push(at2("metric",
|
|
1588
|
+
for (const key3 of ["value", "label", "unit", "delta"]) {
|
|
1589
|
+
const value = metric[key3];
|
|
1590
|
+
if (typeof value === "string") push(at2("metric", key3), value, "metric", "metric");
|
|
1515
1591
|
}
|
|
1516
1592
|
const timeline = node.timeline, events = Array.isArray(timeline) ? timeline : Array.isArray(rec(timeline).events) ? rec(timeline).events : [];
|
|
1517
1593
|
if (typeof rec(timeline).name === "string") push(at2("timeline", "name"), rec(timeline).name, "timeline", "timeline");
|
|
@@ -1537,7 +1613,12 @@ function runsOf(tv) {
|
|
|
1537
1613
|
valuePath: tv.path
|
|
1538
1614
|
}));
|
|
1539
1615
|
}
|
|
1540
|
-
function altOf(value, assets) {
|
|
1616
|
+
function altOf(value, assets, variables, template) {
|
|
1617
|
+
if (typeof value === "string" && value.startsWith("var:")) {
|
|
1618
|
+
const variable = rec(rec(variables)[value.slice(4)]);
|
|
1619
|
+
const resolved = variable.type === "image" ? variable.value ?? (template === true ? variable.example : void 0) : void 0;
|
|
1620
|
+
return resolved === void 0 || typeof resolved === "string" && resolved.startsWith("var:") ? void 0 : altOf(resolved, assets);
|
|
1621
|
+
}
|
|
1541
1622
|
const own4 = typeof value === "object" && value !== null ? value.alt : void 0;
|
|
1542
1623
|
if (typeof own4 === "string") return own4;
|
|
1543
1624
|
let source = typeof value === "string" ? value : rec(value).src;
|
|
@@ -1563,7 +1644,7 @@ function assetRefs(document, slide, slidePath, includeDeck) {
|
|
|
1563
1644
|
}
|
|
1564
1645
|
const designRefs = (design, base) => {
|
|
1565
1646
|
for (const kind of ["header", "footer"])
|
|
1566
|
-
for (const zone of ["
|
|
1647
|
+
for (const zone of ["start", "center", "end"]) {
|
|
1567
1648
|
const item = rec(rec(design[kind])[zone]);
|
|
1568
1649
|
if (item.image !== void 0 && !isLogoReference(item.image)) out.push({ path: `${base}/${kind}/${zone}/image`, value: item.image, kind: "furniture" });
|
|
1569
1650
|
}
|
|
@@ -1646,13 +1727,14 @@ var formatRules = [
|
|
|
1646
1727
|
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 }),
|
|
1647
1728
|
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 }),
|
|
1648
1729
|
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 }),
|
|
1649
|
-
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 or
|
|
1730
|
+
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 }),
|
|
1650
1731
|
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 }),
|
|
1651
1732
|
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 }),
|
|
1652
1733
|
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" }),
|
|
1653
1734
|
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." }),
|
|
1654
1735
|
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 }),
|
|
1655
|
-
rule("shape-anchor-missing", "format", "error", "An overlay shape
|
|
1736
|
+
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 }),
|
|
1737
|
+
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 }),
|
|
1656
1738
|
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 }),
|
|
1657
1739
|
rule("image-placement-invalid", "format", "error", "An image placement cannot be honoured.", "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 a promoted region, or a second block on the same edge, has nowhere to go.", { standard: SCHEMA }),
|
|
1658
1740
|
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 }),
|
|
@@ -1660,6 +1742,8 @@ var formatRules = [
|
|
|
1660
1742
|
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 }),
|
|
1661
1743
|
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 }),
|
|
1662
1744
|
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 }),
|
|
1745
|
+
rule("chart-reference-axis-unavailable", "format", "error", "A reference names a value axis the chart does not have.", "Secondary references require an actual secondary line series on a combo chart.", { standard: SCHEMA }),
|
|
1746
|
+
rule("chart-reference-unsupported-type", "format", "error", "A chart has reference lines but its type has no single value axis to draw them on.", "An explicit reference line is never dropped silently, so a chart type that cannot draw it is an error. Column, bar, line, line-with-markers, area and combo charts draw references; the stacked, 100% stacked and every other type do not.", { standard: SCHEMA }),
|
|
1663
1747
|
rule("number-format-invalid", "format", "error", "A number format cannot be read.", "A format code that no engine can parse is drawn as the plain number or fails to export.", { standard: "Excel number format codes, as far as OPF supports them" }),
|
|
1664
1748
|
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 }),
|
|
1665
1749
|
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 }),
|
|
@@ -1721,7 +1805,7 @@ var referenceRules = [
|
|
|
1721
1805
|
"references",
|
|
1722
1806
|
"error",
|
|
1723
1807
|
"A layout template's regions are not valid.",
|
|
1724
|
-
"Region names are unique across the whole record and may not be tag, auto or a promoted-region word (
|
|
1808
|
+
"Region names are unique across the whole record and may not be tag, auto or a promoted-region word (start, center, end, top, middle, bottom), so a Markdown block's region= stays unambiguous; title and subtitle name the heading regions, which take only a size, an anchor and (the title) a rule; a subtitle region needs a title region; a region accepts at least one content kind; a region with flow 'none' holds one block; overflowRegion must name a body region. composeSlide refuses such a record.",
|
|
1725
1809
|
{ standard: "spec/schemas/layout.schema.json and the region rules (docs/layout-templates.md)" }
|
|
1726
1810
|
),
|
|
1727
1811
|
rule(
|
|
@@ -1778,6 +1862,7 @@ var dataRules = [
|
|
|
1778
1862
|
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 }),
|
|
1779
1863
|
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 }),
|
|
1780
1864
|
rule("variable-builtin-missing", "content", "warning", "A built-in variable has no value in this document.", "A `{{deck.*}}`, `{{speaker.*}}` or `{{organization.*}}` token whose field the document does not set resolves to nothing, so the text shows a gap; a `var:organization.logo` reference to an organization without a logo draws no image. `{{slide.section}}` is checked per slide: a slide without a `section` that uses it, in its own text or in the header or footer it inherits, is reported at that slide.", { standard: SCHEMA }),
|
|
1865
|
+
rule("variable-group-omitted", "content", "info", "A group is drawn only when one of its optional variables has a value.", "A group (a block or promoted region with `blocks`) whose content variables are all optional (`required: false`) and all unfilled is left out whole when the deck is filled: its pictures, cards and other text go with the fields the variables would fill, so a slide never draws a card around a picture with no text. Validation fills every variable with its example or a sample, so it reports the group here instead.", { standard: SCHEMA, approximations: "Counts the declared text, number, date, image, url and list variables the group uses as `{{id}}` or `var:id`, at any depth; color variables and built-ins do not count. A group that uses none, or any required or filled one, is kept and not reported." }),
|
|
1781
1866
|
rule("duration-outside-narrative", "content", "warning", "The target duration is outside the range the narrative suits.", "A narrative records the talk lengths it suits. A deck whose duration is outside that range probably needs a different narrative or a different length; nothing is drawn or exported differently.", { standard: SCHEMA }),
|
|
1782
1867
|
rule("narrative-duration-range", "content", "warning", "An inline narrative duration range has min greater than max.", "A range with its bounds swapped matches no duration, so the duration check cannot help.", { standard: "spec/schemas/narrative.schema.json" })
|
|
1783
1868
|
];
|
|
@@ -1798,13 +1883,13 @@ var onImageRule = rule(
|
|
|
1798
1883
|
"text-on-image",
|
|
1799
1884
|
"accessibility",
|
|
1800
1885
|
"info",
|
|
1801
|
-
"Text sits on a background picture: a note when core draws its automatic scrim behind it, otherwise its contrast cannot be guaranteed.",
|
|
1802
|
-
"Contrast over a photograph depends on the photograph. Core draws an automatic scrim behind text on a picture background that has no overlay, at the lowest opacity that keeps it at 4.5:1 over any picture, and this note names it. With an edge-band overlay, or the scrim turned off (overlay: false), only a full-frame overlay that guarantees readability for every possible image certifies the result from the document.",
|
|
1886
|
+
"Text sits on a background picture: a note when core draws its automatic scrim behind it, a warning when the text is too faint over every color the picture can show, otherwise its contrast cannot be guaranteed.",
|
|
1887
|
+
"Contrast over a photograph depends on the photograph. Core draws an automatic scrim behind text on a picture background that has no overlay, at the lowest opacity that keeps it at 4.5:1 over any picture, and this note names it. With an edge-band overlay, or the scrim turned off (overlay: false), only a full-frame overlay that guarantees readability for every possible image certifies the result from the document. Text that stays below the threshold over every color the picture can show (a duotone in dark colors under dark text, for one) is a warning: it is low contrast whatever the picture.",
|
|
1803
1888
|
{
|
|
1804
1889
|
standard: "WCAG 2.2 SC 1.4.3 Contrast (Minimum), level AA",
|
|
1805
1890
|
thresholds: ["contrastNormal", "contrastLarge"],
|
|
1806
1891
|
cost: "composition",
|
|
1807
|
-
approximations: "Core reads picture pixels only through a host that measures them (ComposeSlideOptions.pictureLuminance). Otherwise the picture is bounded by a gray ramp from black to white, composited through the image opacity and a full-frame design.background overlay or the automatic scrim over the text it covers; the text passes only when every step of that ramp passes.
|
|
1892
|
+
approximations: "Core reads picture pixels only through a host that measures them (ComposeSlideOptions.pictureLuminance). Otherwise the picture is bounded by a gray ramp from black to white, composited through the image opacity and a full-frame design.background overlay or the automatic scrim over the text it covers; the text passes only when every step of that ramp passes. A duotone recolor bounds the ramp to its own two colors, and an edge-banded overlay counts over the text it reaches, beside the uncovered picture where the text reaches past it."
|
|
1808
1893
|
}
|
|
1809
1894
|
);
|
|
1810
1895
|
var altRule = rule(
|
|
@@ -1815,7 +1900,7 @@ var altRule = rule(
|
|
|
1815
1900
|
'People using a screen reader get nothing for a picture without alternative text. A picture that is purely decorative should say so with an empty alt (alt: ""), which is an explicit, reviewed choice instead of an omission.',
|
|
1816
1901
|
{
|
|
1817
1902
|
standard: "WCAG 2.2 SC 1.1.1 Non-text Content, level A",
|
|
1818
|
-
approximations: "Checks the alt field of images (image blocks, Slide.image and region images, placed or not), video, organization logos (each shape and background), header/footer images (a logo reference such as var:organization.logo.icon is checked on the organization), quote photos and speaker photos, following asset: references to the assets registry. Whether the text describes the picture well is not judged here (see opf/poor-alt-text). Charts carry `chart.alt` and are checked by opf/chart-text-alternative. Picture backgrounds are decorative unless they carry their own alt, and watermarks are decorative, so neither is checked."
|
|
1903
|
+
approximations: "Checks the alt field of images (image blocks, Slide.image and region images, placed or not), video, organization logos (each shape and background), header/footer images (a logo reference such as var:organization.logo.icon is checked on the organization), quote photos and speaker photos, following asset: references to the assets registry and image variables (var:<id>, RR-105) to their value (a template's unfilled variable to its example). Whether the text describes the picture well is not judged here (see opf/poor-alt-text). Charts carry `chart.alt` and are checked by opf/chart-text-alternative. Picture backgrounds are decorative unless they carry their own alt, and watermarks are decorative, so neither is checked."
|
|
1819
1904
|
}
|
|
1820
1905
|
);
|
|
1821
1906
|
var poorAltRule = rule(
|
|
@@ -1851,7 +1936,7 @@ var readingOrderRule = rule(
|
|
|
1851
1936
|
{
|
|
1852
1937
|
standard: 'WCAG 2.2 SC 1.3.2 Meaningful Sequence, level A (PowerPoint: "Check reading order")',
|
|
1853
1938
|
cost: "composition",
|
|
1854
|
-
approximations: "Compares the composed content order with a visual order recomputed from the composed boxes: items whose vertical centres fall in the same row are ordered along the reading direction (a right-to-left deck is checked by rows only), rows from top to bottom. Headings are expected first. Content drawn entirely above the title, over the columns of the title, is reported; content in a column beside the title is read after it. Free-form overlap is not analysed. On a slide with a template layout (OPF 0.19) the expected order is the binding order instead (the regions in reading order, then the blocks of each region), and items outside a region (placed images, the row below the grid) are not compared."
|
|
1939
|
+
approximations: "Compares the composed content order with a visual order recomputed from the composed boxes: items whose vertical centres fall in the same row are ordered along the reading direction (a right-to-left deck is checked by rows only), rows from top to bottom. A block is one unit (RR-105): blocks are ordered by the boxes that hold them, and a group's own items are read, in their own visual order, before the next block, so cards side by side (a picture over a name) read card by card. Headings are expected first. Content drawn entirely above the title, over the columns of the title, is reported; content in a column beside the title is read after it. Free-form overlap is not analysed. On a slide with a template layout (OPF 0.19) the expected order is the binding order instead (the regions in reading order, then the blocks of each region), and items outside a region (placed images, the row below the grid) are not compared."
|
|
1855
1940
|
}
|
|
1856
1941
|
);
|
|
1857
1942
|
var linkRule = rule(
|
|
@@ -1899,7 +1984,7 @@ var languageRule = rule(
|
|
|
1899
1984
|
"info",
|
|
1900
1985
|
"The presentation does not declare its language.",
|
|
1901
1986
|
"Screen readers and text-to-speech choose pronunciation and hyphenation from the declared language; spell checkers and translation tools use it too.",
|
|
1902
|
-
{ standard: "WCAG 2.2 SC 3.1.1 Language of Page, level A", approximations: "Only the presentation-level `language` is checked, not the language of individual runs (`TextRun.
|
|
1987
|
+
{ standard: "WCAG 2.2 SC 3.1.1 Language of Page, level A", approximations: "Only the presentation-level `language` is checked, not the language of individual runs (`TextRun.language`; opf/language-tag checks how those tags are written)." }
|
|
1903
1988
|
);
|
|
1904
1989
|
var MAX_FURNITURE_LINES = 2;
|
|
1905
1990
|
var overflowRule = rule(
|
|
@@ -1982,6 +2067,30 @@ var arrangementAdaptedRule = rule(
|
|
|
1982
2067
|
"A `pyramid`, `matrix`, `cycle`, `chevrons`, `flow` or `vertical-flow` region draws a list of one level of short entries as that diagram (docs/smartart.md). A matrix needs exactly four entries for its quadrants; with another count its entries are drawn as a grid of cards. A list the arrangement does not draw (nested entries, descriptions, icons, numbering, too many entries), or whose entries fit neither PowerPoint's design nor OPF's at the list's size, is drawn as a list.",
|
|
1983
2068
|
{ cost: "composition" }
|
|
1984
2069
|
);
|
|
2070
|
+
var shapeOffSlideRule = rule(
|
|
2071
|
+
"shape-off-slide",
|
|
2072
|
+
"layout",
|
|
2073
|
+
"warning",
|
|
2074
|
+
"A shape or image callout lies wholly outside the slide.",
|
|
2075
|
+
"Overlay shapes and image callouts may straddle or leave the slide on purpose, so a position outside it is valid. One with no part on the slide draws nothing, which is nearly always a percent or a pixel written where a fraction belongs.",
|
|
2076
|
+
{ cost: "composition" }
|
|
2077
|
+
);
|
|
2078
|
+
var chartLabelCollisionRule = rule(
|
|
2079
|
+
"chart-label-collision",
|
|
2080
|
+
"layout",
|
|
2081
|
+
"warning",
|
|
2082
|
+
"A reference label meets another label, a data line or a mark at both ends of its line.",
|
|
2083
|
+
"A reference label is tried above and below its line (beside it on a bar chart), at its own end and then at the other end of the line. When all four places meet another reference label, a data line, a bar or an area, it is drawn at the first and reported; its text and value are kept, and on a bar or an area it stands on a plate of the chart background.",
|
|
2084
|
+
{ cost: "composition" }
|
|
2085
|
+
);
|
|
2086
|
+
var timelinePeriodShortRule = rule(
|
|
2087
|
+
"timeline-period-short",
|
|
2088
|
+
"layout",
|
|
2089
|
+
"warning",
|
|
2090
|
+
"A timeline period is too short to read.",
|
|
2091
|
+
'A timeline period keeps the proportion its `duration` gives it, whatever the size. A period shorter than its marker is drawn as it is and reported; it is not text overflow, so a strict composition (`overflow: "error"`) does not refuse the slide.',
|
|
2092
|
+
{ cost: "composition" }
|
|
2093
|
+
);
|
|
1985
2094
|
var unplacedRule = rule(
|
|
1986
2095
|
"layout-unplaced",
|
|
1987
2096
|
"layout",
|
|
@@ -2057,11 +2166,11 @@ var languageTagRule = rule(
|
|
|
2057
2166
|
"language-tag",
|
|
2058
2167
|
"content",
|
|
2059
2168
|
"warning",
|
|
2060
|
-
"A language tag is malformed, uses an unassigned region
|
|
2061
|
-
"Engines read the deck language and each run's `
|
|
2169
|
+
"A language tag is malformed, uses an unassigned region, is not in canonical case or names a numbering system OPF does not draw.",
|
|
2170
|
+
"Engines read the deck and slide language and each run's `language` as BCP 47 tags to choose script fonts, text direction, proofing language and the PowerPoint `lang` attribute. A tag such as `en-a`, or a region that does not exist (`en-UK`; the United Kingdom is `GB`), is guessed at or dropped, and a wrong-case tag (`EN-us`) is not what a locale lookup expects.",
|
|
2062
2171
|
{
|
|
2063
2172
|
standard: "BCP 47 (RFC 5646, section 2.1) and the platform locale data (Intl.getCanonicalLocales, Intl.DisplayNames)",
|
|
2064
|
-
approximations: "Checks the root `language` (a tag string, or the `bcp47` of an inline Language object) and `
|
|
2173
|
+
approximations: "Checks the root and slide `language` (a tag string, or the `bcp47` of an inline Language object) and `language` on the TextRun objects of titles, subtitles, tags, text, lists, tables, quotes, metrics and timelines. A region is assigned when the runtime's CLDR data names it (ISO 3166-1 codes and UN M.49 areas such as 419); private-use regions (`AA`, `QM`-`QZ`, `XA`-`XZ`) and `ZZ` are accepted, as are private-use (`x-...`) tags. Only the spelling of a tag is checked, not whether the language subtag is assigned or whether the language suits the text. The schema rejects tags with characters other than letters, digits and hyphens (`en_US` is a schema error, with no suggestion), and `en-UK` as the deck language is already an error of the schema rule, so those are not reported twice."
|
|
2065
2174
|
}
|
|
2066
2175
|
);
|
|
2067
2176
|
var SHRUNK_RATIO = 0.7;
|
|
@@ -2175,6 +2284,9 @@ var implementedRules = [
|
|
|
2175
2284
|
unplacedRule,
|
|
2176
2285
|
iconDroppedRule,
|
|
2177
2286
|
arrangementAdaptedRule,
|
|
2287
|
+
chartLabelCollisionRule,
|
|
2288
|
+
timelinePeriodShortRule,
|
|
2289
|
+
shapeOffSlideRule,
|
|
2178
2290
|
furnitureWrapsRule,
|
|
2179
2291
|
outsideRule,
|
|
2180
2292
|
resolutionRule,
|
|
@@ -2221,13 +2333,17 @@ var isLarge = (sizePx, bold) => {
|
|
|
2221
2333
|
return pt >= 18 || bold && pt >= 14;
|
|
2222
2334
|
};
|
|
2223
2335
|
var within = (box, area) => box.x >= area.x - 0.5 && box.y >= area.y - 0.5 && box.x + box.width <= area.x + area.width + 0.5 && box.y + box.height <= area.y + area.height + 0.5;
|
|
2336
|
+
var overlaps = (box, area) => box.x < area.x + area.width && area.x < box.x + box.width && box.y < area.y + area.height && area.y < box.y + box.height;
|
|
2224
2337
|
function slideBackdrop(context, box) {
|
|
2225
2338
|
const { design, composition } = context;
|
|
2226
2339
|
const image = composition?.backgroundImage;
|
|
2227
2340
|
if (image) {
|
|
2228
2341
|
const scrim = box ? image.scrims?.find((entry2) => within(box, entry2.text)) : void 0;
|
|
2229
2342
|
const overlay = image.overlay && !image.overlay.edge ? { color: resolveTextColor(image.overlay.color, design, "#000000") ?? "#000000", opacity: image.overlay.opacity } : scrim ? { color: scrim.color, opacity: scrim.opacity } : void 0;
|
|
2230
|
-
|
|
2343
|
+
const duotone = image.recolor?.type === "duotone" ? [resolveTextColor(image.recolor.dark, design, "#000000") ?? "#000000", resolveTextColor(image.recolor.light, design, "#FFFFFF") ?? "#FFFFFF"] : void 0;
|
|
2344
|
+
const edge = image.overlay?.edge ? image.overlay : void 0, reach = box ?? { x: 0, y: 0, ...design.dimensions };
|
|
2345
|
+
const band = edge && overlaps(reach, edge.box) ? { color: resolveTextColor(edge.color, design, "#000000") ?? "#000000", opacity: edge.opacity, whole: within(reach, edge.box) } : void 0;
|
|
2346
|
+
return backdropColors({ kind: "image", opacity: image.opacity ?? 1, base: "#FFFFFF" }, box, design.dimensions, { overlay, ...scrim?.grays ? { grays: scrim.grays } : {}, ...duotone ? { duotone } : {}, ...band ? { band } : {} });
|
|
2231
2347
|
}
|
|
2232
2348
|
return backdropColors(design.backdrop, box, design.dimensions);
|
|
2233
2349
|
}
|
|
@@ -2323,6 +2439,18 @@ var contrastRules = [
|
|
|
2323
2439
|
const worst = worstContrast(sample.color, sample.backdrop);
|
|
2324
2440
|
if (worst.ratio >= needed) continue;
|
|
2325
2441
|
if (sample.backdrop.unknown) {
|
|
2442
|
+
const best = Math.max(...sample.backdrop.colors.map((color) => contrastRatio(sample.color, color)));
|
|
2443
|
+
if (best < needed) {
|
|
2444
|
+
context.report(onImageRule, {
|
|
2445
|
+
path: sample.path,
|
|
2446
|
+
slide,
|
|
2447
|
+
severity: "warning",
|
|
2448
|
+
message: `${sample.label} colour ${sample.color} is too faint on this background picture: over every colour the picture can show here its contrast is at most ${best.toFixed(1)}:1, and ${needed}:1 is needed at this size.`,
|
|
2449
|
+
help: "Set the background's tone (dark or light) so the text color follows the picture, give the text a readable color, or make the overlay strong enough for the text to read.",
|
|
2450
|
+
measured: { ratio: round(worst.ratio), best: round(best), needed, textColor: sample.color }
|
|
2451
|
+
});
|
|
2452
|
+
continue;
|
|
2453
|
+
}
|
|
2326
2454
|
if (!imageReported.done) {
|
|
2327
2455
|
imageReported.done = true;
|
|
2328
2456
|
context.report(onImageRule, {
|
|
@@ -2335,8 +2463,8 @@ var contrastRules = [
|
|
|
2335
2463
|
}
|
|
2336
2464
|
continue;
|
|
2337
2465
|
}
|
|
2338
|
-
const
|
|
2339
|
-
const known = aggregated.get(
|
|
2466
|
+
const key3 = `${sample.source === "default" ? "default" : sample.path}|${sample.color}|${worst.against}|${large}`;
|
|
2467
|
+
const known = aggregated.get(key3);
|
|
2340
2468
|
if (known && sample.source === "default") {
|
|
2341
2469
|
known.extra++;
|
|
2342
2470
|
continue;
|
|
@@ -2357,7 +2485,7 @@ var contrastRules = [
|
|
|
2357
2485
|
measured: { ratio: round(worst.ratio), needed, large, sizePt: round(sample.sizePx * PX_TO_PT), textColor: sample.color, backgroundColor: worst.against },
|
|
2358
2486
|
fixes
|
|
2359
2487
|
});
|
|
2360
|
-
if (sample.source === "default") aggregated.set(
|
|
2488
|
+
if (sample.source === "default") aggregated.set(key3, { diagnostic, extra: 0 });
|
|
2361
2489
|
}
|
|
2362
2490
|
const scrim = slide.composition?.backgroundImage?.scrims?.[0];
|
|
2363
2491
|
if (scrim && !imageReported.done) {
|
|
@@ -2397,7 +2525,7 @@ var altRules = [
|
|
|
2397
2525
|
for (const ref of assetRefs(context.document, slide.slide, slide.path, index === 0)) {
|
|
2398
2526
|
if (seen.has(ref.path)) continue;
|
|
2399
2527
|
seen.add(ref.path);
|
|
2400
|
-
let alt = altOf(ref.value, context.document.assets);
|
|
2528
|
+
let alt = altOf(ref.value, context.document.assets, context.document.variables, context.document.template === true);
|
|
2401
2529
|
if (ref.kind === "video" && !alt) alt = typeof rec(ref.value).title === "string" ? rec(ref.value).title : void 0;
|
|
2402
2530
|
if (alt !== void 0 && alt.trim() !== "") continue;
|
|
2403
2531
|
if (alt === "") continue;
|
|
@@ -2422,7 +2550,7 @@ var altRules = [
|
|
|
2422
2550
|
for (const ref of assetRefs(context.document, slide.slide, slide.path, index === 0)) {
|
|
2423
2551
|
if (seen.has(ref.path)) continue;
|
|
2424
2552
|
seen.add(ref.path);
|
|
2425
|
-
const alt = altOf(ref.value, context.document.assets)?.trim();
|
|
2553
|
+
const alt = altOf(ref.value, context.document.assets, context.document.variables, context.document.template === true)?.trim();
|
|
2426
2554
|
if (!alt) continue;
|
|
2427
2555
|
const source = sourceOfAsset(ref.value);
|
|
2428
2556
|
const problem = GENERIC_ALT.test(alt) ? "is a generic word" : FILE_ALT.test(alt) ? "looks like a file name" : /^(https?:\/\/|data:|www\.)/i.test(alt) || source && alt === source ? "is a URL" : /^(image|picture|photo|graphic) of\b/i.test(alt) ? 'starts with "image of", which a screen reader already announces' : alt.length > 250 ? `is ${alt.length} characters long; aim for a sentence or two` : void 0;
|
|
@@ -2543,7 +2671,27 @@ function bindingOrder(items, regions) {
|
|
|
2543
2671
|
};
|
|
2544
2672
|
return items.map((item, index) => ({ item, index, region: rank.get(item.region ?? "") ?? regions.length, block: blockRank(item) })).sort((a, b) => a.region - b.region || a.block - b.block || a.index - b.index).map((entry2) => entry2.item.path);
|
|
2545
2673
|
}
|
|
2546
|
-
function visualOrder(items, rtl) {
|
|
2674
|
+
function visualOrder(items, rtl, base = items[0]?.path.match(/^slides\.\d+/)?.[0] ?? "") {
|
|
2675
|
+
const units = /* @__PURE__ */ new Map();
|
|
2676
|
+
for (const item of items) {
|
|
2677
|
+
const rest = item.path.startsWith(`${base}.`) ? item.path.slice(base.length + 1) : "";
|
|
2678
|
+
const key3 = /^blocks\.\d+/.exec(rest)?.[0] ?? rest.split(".")[0] ?? "";
|
|
2679
|
+
(units.get(key3) ?? units.set(key3, []).get(key3)).push(item);
|
|
2680
|
+
}
|
|
2681
|
+
if (units.has("")) return flatOrder(items, rtl);
|
|
2682
|
+
if (units.size === 1) return visualOrder(items, rtl, `${base}.${[...units.keys()][0]}`);
|
|
2683
|
+
const placed = [...units].map(([key3, members]) => {
|
|
2684
|
+
const left = Math.min(...members.map((item) => item.box.x)), top = Math.min(...members.map((item) => item.box.y));
|
|
2685
|
+
const right = Math.max(...members.map((item) => item.box.x + item.box.width)), bottom = Math.max(...members.map((item) => item.box.y + item.box.height));
|
|
2686
|
+
return { path: key3, members, box: { x: left, y: top, width: right - left, height: bottom - top } };
|
|
2687
|
+
});
|
|
2688
|
+
const order2 = flatOrder(placed, rtl);
|
|
2689
|
+
return order2.flatMap((key3) => {
|
|
2690
|
+
const unit = placed.find((entry2) => entry2.path === key3);
|
|
2691
|
+
return unit.members.length > 1 ? visualOrder(unit.members, rtl, `${base}.${key3}`) : unit.members.map((item) => item.path);
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
function flatOrder(items, rtl) {
|
|
2547
2695
|
if (rtl) return readingRows(items).flatMap((row) => row.map((item) => item.path));
|
|
2548
2696
|
return visualReadingOrder(items).map((item) => item.path);
|
|
2549
2697
|
}
|
|
@@ -2783,6 +2931,15 @@ function languageTagProblem(tag) {
|
|
|
2783
2931
|
};
|
|
2784
2932
|
}
|
|
2785
2933
|
}
|
|
2934
|
+
const system = numberingSystemExtension(tag);
|
|
2935
|
+
if (system !== void 0 && !isSupportedNumberingSystem(system)) {
|
|
2936
|
+
const only = /-u-nu-[a-z0-9]+$/i.test(tag) && tag.toLowerCase().split("-u-").length === 2;
|
|
2937
|
+
return {
|
|
2938
|
+
message: `'${tag}' names the numbering system '${system}', which OPF does not draw; generated numbers use the language's own digits, or Latin ones. OPF draws only the systems PowerPoint also draws in a native chart: ${supportedNumberingSystems().map((name) => `'${name}'`).join(", ")}.`,
|
|
2939
|
+
...only ? { suggestion: plainLanguageTag(tag) } : {},
|
|
2940
|
+
caseOnly: false
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2786
2943
|
if (parsed === tag) return void 0;
|
|
2787
2944
|
if (parsed.toLowerCase() === tag.toLowerCase())
|
|
2788
2945
|
return { message: `'${tag}' is not in canonical case; the canonical form is '${parsed}' (language lower case, script title case, region upper case).`, suggestion: parsed, caseOnly: true };
|
|
@@ -2796,30 +2953,35 @@ function languageTagProblem(tag) {
|
|
|
2796
2953
|
}
|
|
2797
2954
|
|
|
2798
2955
|
// src/rules-language.ts
|
|
2799
|
-
var
|
|
2800
|
-
|
|
2956
|
+
var isEnUk = (tag) => typeof tag === "string" && tag.toLowerCase() === "en-uk";
|
|
2957
|
+
var report = (context, tag, path, slide, owned = false) => {
|
|
2958
|
+
if (typeof tag !== "string" || owned && isEnUk(tag)) return;
|
|
2801
2959
|
const problem = languageTagProblem(tag);
|
|
2802
2960
|
if (!problem) return;
|
|
2803
2961
|
context.report(languageTagRule, {
|
|
2804
2962
|
path,
|
|
2805
2963
|
slide,
|
|
2806
2964
|
message: problem.message,
|
|
2965
|
+
...isEnUk(tag) ? { severity: "error" } : {},
|
|
2807
2966
|
help: problem.suggestion ? `Write '${problem.suggestion}'.` : 'Write a well-formed BCP 47 tag with an assigned region, such as "en-US", "pt-BR" or "es-419".',
|
|
2808
2967
|
...problem.suggestion ? { fixes: [{ id: "use-canonical-tag", title: `Use '${problem.suggestion}'`, kind: "patch", safe: problem.caseOnly, patch: [{ op: "replace", path, value: problem.suggestion }] }] } : {}
|
|
2809
2968
|
});
|
|
2810
2969
|
};
|
|
2811
|
-
var isEnUk = (tag) => typeof tag === "string" && tag.toLowerCase() === "en-uk";
|
|
2812
2970
|
var languageTagRules = [
|
|
2813
2971
|
{
|
|
2814
2972
|
info: languageTagRule,
|
|
2815
2973
|
run(context) {
|
|
2816
2974
|
const language = context.document.language;
|
|
2817
|
-
if (typeof language === "string")
|
|
2818
|
-
|
|
2819
|
-
|
|
2975
|
+
if (typeof language === "string") report(context, language, "/language", void 0, true);
|
|
2976
|
+
else if (language !== void 0) report(context, rec(language).bcp47, "/language/bcp47", void 0, true);
|
|
2977
|
+
for (const slide of context.slides) {
|
|
2978
|
+
const language2 = slide.slide.language;
|
|
2979
|
+
if (typeof language2 === "string") report(context, language2, `${slide.path}/language`, slide, true);
|
|
2980
|
+
else if (language2 !== void 0) report(context, rec(language2).bcp47, `${slide.path}/language/bcp47`, slide, true);
|
|
2981
|
+
}
|
|
2820
2982
|
for (const slide of context.slides)
|
|
2821
2983
|
for (const tv of slide.texts)
|
|
2822
|
-
if (typeof tv.value !== "string") for (const run of runsOf(tv)) report(context, run.style.
|
|
2984
|
+
if (typeof tv.value !== "string") for (const run of runsOf(tv)) report(context, run.style.language, `${run.path}/language`, slide);
|
|
2823
2985
|
}
|
|
2824
2986
|
}
|
|
2825
2987
|
];
|
|
@@ -2827,11 +2989,14 @@ var languageTagRules = [
|
|
|
2827
2989
|
// src/rules-layout-content.ts
|
|
2828
2990
|
var PX_TO_PT2 = 0.75;
|
|
2829
2991
|
var round2 = (value, places = 1) => Math.round(value * 10 ** places) / 10 ** places;
|
|
2992
|
+
var pointAnchorRule = ruleInfo("opf/shape-anchor-missing");
|
|
2830
2993
|
var REGION_RULES = { "region-unknown": regionUnknownRule, "region-kind": regionKindRule, "region-full": regionFullRule, "layout-unplaced": unplacedRule };
|
|
2831
2994
|
var layoutRules = [
|
|
2832
2995
|
{
|
|
2833
2996
|
info: overflowRule,
|
|
2834
|
-
|
|
2997
|
+
// Format validates anchor identities in schema-check without composition. Geometry may add
|
|
2998
|
+
// the same located finding during an enabled layout audit, but must not trigger one.
|
|
2999
|
+
also: [unresolvedRule, layoutFailedRule, minFontRule, regionUnknownRule, regionKindRule, regionFullRule, unplacedRule, iconDroppedRule, arrangementAdaptedRule, chartLabelCollisionRule, timelinePeriodShortRule, shapeOffSlideRule],
|
|
2835
3000
|
run(context) {
|
|
2836
3001
|
const deckLevel = /* @__PURE__ */ new Set();
|
|
2837
3002
|
for (const slide of context.slides) {
|
|
@@ -2840,19 +3005,28 @@ var layoutRules = [
|
|
|
2840
3005
|
for (const { diagnostic } of slide.layoutDiagnostics) {
|
|
2841
3006
|
const path = pointerOfDotted(diagnostic.path);
|
|
2842
3007
|
if (!path.startsWith("/slides/")) {
|
|
2843
|
-
const
|
|
2844
|
-
if (deckLevel.has(
|
|
2845
|
-
deckLevel.add(
|
|
3008
|
+
const key3 = `${diagnostic.code}|${path}|${diagnostic.message}`;
|
|
3009
|
+
if (deckLevel.has(key3)) continue;
|
|
3010
|
+
deckLevel.add(key3);
|
|
2846
3011
|
}
|
|
2847
3012
|
if (diagnostic.code === "text-overflow")
|
|
2848
3013
|
context.report(overflowRule, { path, slide, message: diagnostic.message, help: "Shorten the text, give it more space (fewer blocks, a different composition) or split the slide (paginate); raising the readable minimum makes it worse." });
|
|
3014
|
+
else if (diagnostic.code === "shape-anchor-missing") context.report(pointAnchorRule, { path, slide, message: diagnostic.message, help: "Choose a plotted point in a qualified classic chart, or use a whole-block anchor." });
|
|
2849
3015
|
else if (diagnostic.code === "small-cell") continue;
|
|
2850
3016
|
else if (diagnostic.code === "icon-dropped")
|
|
2851
3017
|
context.report(iconDroppedRule, { path, slide, message: diagnostic.message, help: "Shorten the text or give the slide more room so the chips fit at the same text size, or remove the icon. An icon draws on the first-level entries of an unnumbered list, on a metric and on a group." });
|
|
2852
3018
|
else if (diagnostic.code === "arrangement-adapted")
|
|
2853
3019
|
context.report(arrangementAdaptedRule, { path, slide, message: diagnostic.message, help: /four entries/.test(diagnostic.message) ? "Write four entries for the quadrants, or choose another layout for this many." : "Shorten the entries, write one level without descriptions, or choose another layout." });
|
|
3020
|
+
else if (diagnostic.code === "shape-off-slide")
|
|
3021
|
+
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." });
|
|
3022
|
+
else if (diagnostic.code === "chart-label-collision")
|
|
3023
|
+
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." });
|
|
3024
|
+
else if (diagnostic.code === "timeline-period-short")
|
|
3025
|
+
context.report(timelinePeriodShortRule, { path, slide, message: diagnostic.message, help: "Give the timeline more room, or make its shortest period longer relative to the others." });
|
|
2854
3026
|
else if (Object.hasOwn(REGION_RULES, diagnostic.code))
|
|
2855
3027
|
context.report(REGION_RULES[diagnostic.code], { path, slide, message: diagnostic.message, help: diagnostic.code === "layout-unplaced" ? "Paginate the slide, choose a layout with more room, pin the block to a region with room, or remove a block." : "Pin the block to a region of the layout that accepts it and has room, or remove the pin." });
|
|
3028
|
+
else if (diagnostic.message.startsWith("The diagram cannot be drawn"))
|
|
3029
|
+
context.report(unresolvedRule, { path, slide: path.startsWith("/slides/") ? slide : void 0, message: diagnostic.message, help: "Fix the diagram source where the message points. OPF refuses what it does not draw: write it in the form the diagrams guide lists for that syntax, or remove it." });
|
|
2856
3030
|
else context.report(unresolvedRule, { path, slide: path.startsWith("/slides/") ? slide : void 0, message: diagnostic.message, help: "Supply what the message asks for, or remove the setting that cannot be honoured." });
|
|
2857
3031
|
}
|
|
2858
3032
|
for (const tv of slide.texts)
|
|
@@ -3003,7 +3177,7 @@ var contentRules = [
|
|
|
3003
3177
|
run(context) {
|
|
3004
3178
|
for (const slide of context.slides)
|
|
3005
3179
|
for (const tv of slide.texts) {
|
|
3006
|
-
if (["table", "table-header", "list-description"].includes(tv.role)) continue;
|
|
3180
|
+
if (["table", "table-header", "list-description", "callout"].includes(tv.role)) continue;
|
|
3007
3181
|
if (plainText(tv.value).trim() !== "") continue;
|
|
3008
3182
|
context.report(emptyTextRule, {
|
|
3009
3183
|
path: tv.path,
|
|
@@ -3064,7 +3238,7 @@ function setsRunSize(value, depth2 = 0) {
|
|
|
3064
3238
|
if (Array.isArray(value)) return value.some((entry2) => setsRunSize(entry2, depth2 + 1));
|
|
3065
3239
|
const object2 = value;
|
|
3066
3240
|
if (typeof object2.fontSize === "number") return true;
|
|
3067
|
-
return ["text", "description", "rows", "columns", "value"].some((
|
|
3241
|
+
return ["text", "description", "rows", "columns", "value"].some((key3) => setsRunSize(object2[key3], depth2 + 1));
|
|
3068
3242
|
}
|
|
3069
3243
|
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 };
|
|
3070
3244
|
function fittedSize(item, slide, document) {
|
|
@@ -3154,7 +3328,7 @@ var centeredBody = {
|
|
|
3154
3328
|
path: pointerOfDotted(item.path),
|
|
3155
3329
|
slide,
|
|
3156
3330
|
message: `A centered ${item.field === "text" ? "paragraph" : "list"} of ${lines} line${lines === 1 ? "" : "s"} (${characters} characters); every line starts at a different place, which is harder to read.${others}`,
|
|
3157
|
-
help: 'Align body text to the start (contentAlignment "
|
|
3331
|
+
help: 'Align body text to the start (contentAlignment "start" on the slide or block design), or shorten it to a statement of one or two lines.',
|
|
3158
3332
|
measured: { lines, characters, maximumLines: CENTERED_BODY_LINES, maximumCharacters: CENTERED_BODY_CHARACTERS, blocks: count }
|
|
3159
3333
|
});
|
|
3160
3334
|
}
|
|
@@ -3372,7 +3546,7 @@ var isRecord2 = (value) => value !== null && typeof value === "object" && !Array
|
|
|
3372
3546
|
var isCell = (value) => value === null || ["string", "number", "boolean"].includes(typeof value);
|
|
3373
3547
|
function foreignChartKeys(chart) {
|
|
3374
3548
|
if (!isRecord2(chart) || Object.hasOwn(chart, "data")) return [];
|
|
3375
|
-
return FOREIGN_CHART_KEYS.filter((
|
|
3549
|
+
return FOREIGN_CHART_KEYS.filter((key3) => Object.hasOwn(chart, key3));
|
|
3376
3550
|
}
|
|
3377
3551
|
function convertChartData(chart) {
|
|
3378
3552
|
const labels = chart.categories ?? chart.labels;
|
|
@@ -3396,7 +3570,7 @@ function chartShapePatch(chart, path) {
|
|
|
3396
3570
|
const data = convertChartData(chart);
|
|
3397
3571
|
const keys = foreignChartKeys(chart);
|
|
3398
3572
|
if (!data || !keys.length) return void 0;
|
|
3399
|
-
return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((
|
|
3573
|
+
return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
|
|
3400
3574
|
}
|
|
3401
3575
|
var SHOWN_ROWS = 3;
|
|
3402
3576
|
var json = (value) => JSON.stringify(value);
|
|
@@ -3409,7 +3583,7 @@ function dataExample(chart) {
|
|
|
3409
3583
|
function chartShapeHelp(chart) {
|
|
3410
3584
|
const keys = foreignChartKeys(chart);
|
|
3411
3585
|
if (!keys.length || !isRecord2(chart)) return void 0;
|
|
3412
|
-
const names2 = keys.map((
|
|
3586
|
+
const names2 = keys.map((key3) => `"${key3}"`).join(" and ");
|
|
3413
3587
|
const example = dataExample(chart);
|
|
3414
3588
|
const next = `replace ${names2} with ${example}. The first column holds the category labels and each further column is one series.`;
|
|
3415
3589
|
return {
|
|
@@ -3420,7 +3594,7 @@ function chartShapeHelp(chart) {
|
|
|
3420
3594
|
}
|
|
3421
3595
|
|
|
3422
3596
|
// src/check-document.ts
|
|
3423
|
-
var own = (value,
|
|
3597
|
+
var own = (value, key3) => Object.hasOwn(value, key3);
|
|
3424
3598
|
var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3425
3599
|
var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
3426
3600
|
var pointer3 = (parts2) => parts2.length ? "/" + parts2.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
|
|
@@ -3432,7 +3606,7 @@ function parts(path) {
|
|
|
3432
3606
|
}
|
|
3433
3607
|
function at(value, path) {
|
|
3434
3608
|
return parts(path).reduce(
|
|
3435
|
-
(current,
|
|
3609
|
+
(current, key3) => object(current) || Array.isArray(current) ? own(current, key3) ? current[key3] : void 0 : void 0,
|
|
3436
3610
|
value
|
|
3437
3611
|
);
|
|
3438
3612
|
}
|
|
@@ -3442,13 +3616,13 @@ function checkDocumentOptions(options2) {
|
|
|
3442
3616
|
throw new TypeError("Validate contracts must be an array.");
|
|
3443
3617
|
for (const contract2 of options2.contracts ?? []) {
|
|
3444
3618
|
if (!object(contract2) || Object.keys(contract2).some(
|
|
3445
|
-
(
|
|
3619
|
+
(key3) => ![
|
|
3446
3620
|
"path",
|
|
3447
3621
|
"allowedValues",
|
|
3448
3622
|
"severity",
|
|
3449
3623
|
"message",
|
|
3450
3624
|
"documentation"
|
|
3451
|
-
].includes(
|
|
3625
|
+
].includes(key3)
|
|
3452
3626
|
) || 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")
|
|
3453
3627
|
throw new TypeError(
|
|
3454
3628
|
"Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
|
|
@@ -3478,12 +3652,21 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
3478
3652
|
help = `Add the required ${JSON.stringify(issue2.params.missingProperty)} field in this object, using the intended schema form.`;
|
|
3479
3653
|
else if (issue2.keyword === "additionalProperties")
|
|
3480
3654
|
help = `Review ${JSON.stringify(issue2.params.additionalProperty)} against this object's schema. Preserve custom metadata in document.extensions where appropriate; do not delete authored content to clear this error.`;
|
|
3481
|
-
else if (issue2.keyword === "enum")
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3655
|
+
else if (issue2.keyword === "enum") {
|
|
3656
|
+
const values = Array.isArray(issue2.params.allowedValues) ? issue2.params.allowedValues.filter(primitive) : [];
|
|
3657
|
+
help = values.length > 0 && values.length <= 12 ? `Use one of: ${values.map((value) => JSON.stringify(value)).join(", ")}.` : "Choose one of this schema branch\u2019s allowed values; inspect the other alternatives if the field uses another form.";
|
|
3658
|
+
} else if (issue2.keyword === "dependentRequired")
|
|
3659
|
+
help = `${JSON.stringify(issue2.params.property)} only applies together with ${JSON.stringify(issue2.params.missingProperty)}: add ${JSON.stringify(issue2.params.missingProperty)}, or remove ${JSON.stringify(issue2.params.property)}.`;
|
|
3660
|
+
else if (issue2.keyword === "opf") help = semanticHelp(issue2);
|
|
3485
3661
|
const allowed = Array.isArray(issue2.params.allowedValues) ? issue2.params.allowedValues.filter(primitive) : [];
|
|
3486
3662
|
const nearest2 = issue2.keyword === "additionalProperties" ? nearestProperties(issue2, entry2.schema, precise?.pointer, precise?.schemaName) : [];
|
|
3663
|
+
const typedName = issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? issue2.params.additionalProperty : void 0;
|
|
3664
|
+
if (typedName !== void 0 && nearest2[0]?.value === logicalName(typedName) && nearest2[0].value !== typedName)
|
|
3665
|
+
help = `Write ${JSON.stringify(nearest2[0].value)}: layout words follow the deck's direction, so the sides are "start" and "end", not "left" and "right".`;
|
|
3666
|
+
else if (typedName !== void 0 && typeof nearest2[0]?.value === "string" && nearest2[0].value.startsWith(typedName))
|
|
3667
|
+
help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
|
|
3668
|
+
else if (typedName !== void 0 && typeof nearest2[0]?.value === "string")
|
|
3669
|
+
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.`;
|
|
3487
3670
|
return finding(ruleId, {
|
|
3488
3671
|
...severity ? { severity } : {},
|
|
3489
3672
|
path,
|
|
@@ -3504,6 +3687,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
|
|
|
3504
3687
|
});
|
|
3505
3688
|
}
|
|
3506
3689
|
var NEAREST_PROPERTIES = 3;
|
|
3690
|
+
var logicalName = (name) => name.split(":").map((part) => part.split("+").map((word) => word === "left" ? "start" : word === "right" ? "end" : word).join("+")).join(":");
|
|
3507
3691
|
function nearestProperties(issue2, fallbackRoot, pointerToKeyword, schemaName) {
|
|
3508
3692
|
const typed = issue2.params.additionalProperty;
|
|
3509
3693
|
if (typeof typed !== "string" || pointerToKeyword === void 0) return [];
|
|
@@ -3511,12 +3695,15 @@ function nearestProperties(issue2, fallbackRoot, pointerToKeyword, schemaName) {
|
|
|
3511
3695
|
let node = rootEntry?.schema ?? fallbackRoot;
|
|
3512
3696
|
const base = pointerToKeyword.split("/").slice(0, -1);
|
|
3513
3697
|
for (const token of base.slice(1)) {
|
|
3514
|
-
if (
|
|
3515
|
-
node = node[token.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
3698
|
+
if (Array.isArray(node)) node = /^\d+$/.test(token) ? node[Number(token)] : void 0;
|
|
3699
|
+
else if (isRecord(node)) node = node[token.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
3700
|
+
else return [];
|
|
3516
3701
|
}
|
|
3517
3702
|
if (!isRecord(node) || !isRecord(node.properties)) return [];
|
|
3518
3703
|
const root = rootEntry?.schema ?? fallbackRoot, limit = typed.length <= 3 ? 1 : 2, lower = typed.toLowerCase();
|
|
3519
|
-
|
|
3704
|
+
const declared = Object.keys(node.properties), logical = logicalName(typed), longer = typed.length >= 3 ? declared.filter((name) => name !== typed && name.toLowerCase().startsWith(lower)) : [], exact = logical !== typed && declared.includes(logical) ? [logical] : longer.length === 1 ? longer : [];
|
|
3705
|
+
const near = declared.map((name) => ({ name, away: distance(lower, name.toLowerCase()) })).filter(({ name, away }) => name !== typed && away <= limit && !exact.includes(name)).sort((a, b) => a.away - b.away || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)).map(({ name }) => name);
|
|
3706
|
+
return [...exact, ...near].slice(0, NEAREST_PROPERTIES).map((name) => ({
|
|
3520
3707
|
value: name,
|
|
3521
3708
|
label: name,
|
|
3522
3709
|
origin: "schema",
|
|
@@ -3547,13 +3734,13 @@ function score(schema, value) {
|
|
|
3547
3734
|
if (own(schema, "const")) return schema.const === value ? 100 : -1e4;
|
|
3548
3735
|
let result = 1;
|
|
3549
3736
|
if (object(value) && object(schema.properties)) {
|
|
3550
|
-
for (const [
|
|
3551
|
-
if (own(value,
|
|
3552
|
-
result += own(child, "const") ? child.const === value[
|
|
3737
|
+
for (const [key3, child] of Object.entries(schema.properties))
|
|
3738
|
+
if (own(value, key3) && object(child))
|
|
3739
|
+
result += own(child, "const") ? child.const === value[key3] ? 100 : -1e3 : 1;
|
|
3553
3740
|
}
|
|
3554
3741
|
if (Array.isArray(schema.required)) {
|
|
3555
|
-
for (const
|
|
3556
|
-
if (typeof
|
|
3742
|
+
for (const key3 of schema.required)
|
|
3743
|
+
if (typeof key3 === "string" && (!object(value) || !own(value, key3)))
|
|
3557
3744
|
result -= 2;
|
|
3558
3745
|
}
|
|
3559
3746
|
return result;
|
|
@@ -3575,7 +3762,7 @@ function active(cursor, value) {
|
|
|
3575
3762
|
const selected = candidates.sort((a, b) => score(b.schema, value) - score(a.schema, value))[0];
|
|
3576
3763
|
return selected ? { ...selected, baseSchemas: [...selected.baseSchemas ?? [], resolved] } : resolved;
|
|
3577
3764
|
}
|
|
3578
|
-
function childCursor(cursors,
|
|
3765
|
+
function childCursor(cursors, key3) {
|
|
3579
3766
|
for (const keyword of [
|
|
3580
3767
|
"properties",
|
|
3581
3768
|
"patternProperties",
|
|
@@ -3584,8 +3771,8 @@ function childCursor(cursors, key2) {
|
|
|
3584
3771
|
for (const cursor of cursors) {
|
|
3585
3772
|
const declarations = cursor.schema[keyword];
|
|
3586
3773
|
if (!object(declarations)) continue;
|
|
3587
|
-
const name = keyword === "properties" ?
|
|
3588
|
-
(pattern) => new RegExp(pattern).test(
|
|
3774
|
+
const name = keyword === "properties" ? key3 : keyword === "patternProperties" ? Object.keys(declarations).find(
|
|
3775
|
+
(pattern) => new RegExp(pattern).test(key3)
|
|
3589
3776
|
) : void 0;
|
|
3590
3777
|
const schema = keyword === "additionalProperties" ? declarations : name === void 0 ? void 0 : declarations[name];
|
|
3591
3778
|
if (object(schema))
|
|
@@ -3644,13 +3831,13 @@ function fields(document) {
|
|
|
3644
3831
|
});
|
|
3645
3832
|
});
|
|
3646
3833
|
else if (object(entry2.value))
|
|
3647
|
-
for (const [
|
|
3648
|
-
if (entry2.path.length === 0 &&
|
|
3649
|
-
const cursor = childCursor(cursors,
|
|
3834
|
+
for (const [key3, value] of Object.entries(entry2.value)) {
|
|
3835
|
+
if (entry2.path.length === 0 && key3 === "catalogs") continue;
|
|
3836
|
+
const cursor = childCursor(cursors, key3);
|
|
3650
3837
|
if (!cursor) continue;
|
|
3651
3838
|
stack.push({
|
|
3652
3839
|
value,
|
|
3653
|
-
path: [...entry2.path,
|
|
3840
|
+
path: [...entry2.path, key3],
|
|
3654
3841
|
cursor,
|
|
3655
3842
|
ancestors
|
|
3656
3843
|
});
|
|
@@ -3732,7 +3919,7 @@ function chartNumberFixPaths(document) {
|
|
|
3732
3919
|
}
|
|
3733
3920
|
var HELP = {
|
|
3734
3921
|
"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.',
|
|
3735
|
-
"chart-mapping-adapted": "
|
|
3922
|
+
"chart-mapping-adapted": "Choose a compatible chart type or mapping for the selected data. The message explains how the mapping or drawing was adapted.",
|
|
3736
3923
|
"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.",
|
|
3737
3924
|
"chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasise, or remove the entry.",
|
|
3738
3925
|
"slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
|
|
@@ -3742,11 +3929,123 @@ var HELP = {
|
|
|
3742
3929
|
"variable-unknown": "Declare the variable in the top-level variables map, or write '\\{{' for literal braces.",
|
|
3743
3930
|
"variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
|
|
3744
3931
|
"variable-unused": "Reference the variable as {{id}} or var:id where it belongs, or remove its declaration.",
|
|
3932
|
+
"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.",
|
|
3745
3933
|
"variable-reference-unknown": "Declare the variable in the top-level variables map, or use another colour.",
|
|
3746
3934
|
"run-color-unrecognized": "Use a #RRGGBB hex colour, a colour-scheme name or a var: reference to a declared colour variable.",
|
|
3747
3935
|
"numbering-start-ignored": "Add a 'numbering' field to the payload, or remove 'start'.",
|
|
3748
3936
|
"slide-size-out-of-range": "Use a custom widthInches and heightInches between 1 and 56, or a preset. PowerPoint stores the slide size in 914400 to 51206400 EMU per side."
|
|
3749
3937
|
};
|
|
3938
|
+
function semanticHelp(issue2) {
|
|
3939
|
+
const params2 = issue2.params ?? {}, field = typeof params2.field === "string" ? params2.field : void 0, quoted2 = JSON.stringify(field);
|
|
3940
|
+
if (params2.code === "image-option-unsupported-payload" && field) return `Remove ${quoted2}, or put it on an image block ({ "image": ... }); it has no meaning on another kind of content.`;
|
|
3941
|
+
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": "..." } }.`;
|
|
3942
|
+
if (params2.code === "shape-option-unsupported-payload" && field) return `Remove ${quoted2}, or draw this as a shape: a shape block ({ "shape": ... } with no "image") or an overlay shape in the slide's "shapes".`;
|
|
3943
|
+
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.";
|
|
3944
|
+
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".';
|
|
3945
|
+
return "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
|
|
3946
|
+
}
|
|
3947
|
+
var BACKGROUND_TYPES = ["theme", "solid", "gradient", "image", "pattern"];
|
|
3948
|
+
var BACKGROUND_HELP = `A background is a string (a theme slot such as "light1", a hex color, or an image source such as "asset:hero" or "./photo.jpg") or an object with "type": ${BACKGROUND_TYPES.map((type) => JSON.stringify(type)).join(", ")}, for example { "type": "solid", "color": "accent1" }.`;
|
|
3949
|
+
function collapseAuthoringShapes(document, findings) {
|
|
3950
|
+
const valueAt = (path) => {
|
|
3951
|
+
let node = document;
|
|
3952
|
+
for (const segment of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment)] : isRecord(node) ? node[segment] : void 0;
|
|
3953
|
+
return node;
|
|
3954
|
+
};
|
|
3955
|
+
const schema = (entry2) => entry2?.ruleId === "opf/schema";
|
|
3956
|
+
const fills = /* @__PURE__ */ new Map();
|
|
3957
|
+
for (const entry2 of findings) {
|
|
3958
|
+
if (!schema(entry2)) continue;
|
|
3959
|
+
const at2 = /^(.*\/fill)(?:\/[^/]+)?$/.exec(entry2.path)?.[1];
|
|
3960
|
+
if (!at2 || fills.has(at2) || at2.endsWith("/style/fill")) continue;
|
|
3961
|
+
const fill = valueAt(at2);
|
|
3962
|
+
if (!isRecord(fill) || Object.hasOwn(fill, "lighten") || Object.hasOwn(fill, "darken")) continue;
|
|
3963
|
+
const solid = (fill.type === "solid" || fill.type === void 0) && fill.color !== void 0 && !Object.hasOwn(fill, "gradient") && !Object.hasOwn(fill, "pattern");
|
|
3964
|
+
const typed = fill.type === "gradient" && isRecord(fill.gradient) || fill.type === "pattern" && isRecord(fill.pattern);
|
|
3965
|
+
if (!solid && !typed) continue;
|
|
3966
|
+
const color = typeof fill.color === "string" ? JSON.stringify(fill.color) : '"accent1"';
|
|
3967
|
+
fills.set(at2, {
|
|
3968
|
+
...entry2,
|
|
3969
|
+
path: at2,
|
|
3970
|
+
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)}: { ... } }.`,
|
|
3971
|
+
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".`,
|
|
3972
|
+
fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path: at2, value: fill.color }] } : { id: "fill-remove-type", title: 'Remove "type"', kind: "patch", safe: false, patch: [{ op: "remove", path: `${at2}/type` }] }]
|
|
3973
|
+
});
|
|
3974
|
+
}
|
|
3975
|
+
if (fills.size) {
|
|
3976
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3977
|
+
for (let index = 0; index < findings.length; index++) {
|
|
3978
|
+
const entry2 = findings[index];
|
|
3979
|
+
if (!schema(entry2)) continue;
|
|
3980
|
+
const at2 = [...fills.keys()].find((path) => entry2.path === path || entry2.path.startsWith(`${path}/`));
|
|
3981
|
+
if (!at2) continue;
|
|
3982
|
+
if (seen.has(at2)) {
|
|
3983
|
+
findings.splice(index--, 1);
|
|
3984
|
+
continue;
|
|
3985
|
+
}
|
|
3986
|
+
seen.add(at2);
|
|
3987
|
+
findings[index] = fills.get(at2);
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
const backgrounds = /* @__PURE__ */ new Set();
|
|
3991
|
+
for (const entry2 of findings) {
|
|
3992
|
+
if (!schema(entry2)) continue;
|
|
3993
|
+
const at2 = /^((?:.*\/)?design\/background)(?:\/.*)?$/.exec(entry2.path)?.[1];
|
|
3994
|
+
if (!at2 || backgrounds.has(at2)) continue;
|
|
3995
|
+
const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
|
|
3996
|
+
if (typeof background === "string" || isRecord(background) && typeof type === "string" && BACKGROUND_TYPES.includes(type)) continue;
|
|
3997
|
+
backgrounds.add(at2);
|
|
3998
|
+
}
|
|
3999
|
+
for (const at2 of backgrounds) {
|
|
4000
|
+
const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
|
|
4001
|
+
const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`)));
|
|
4002
|
+
const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
|
|
4003
|
+
const one = {
|
|
4004
|
+
...kept,
|
|
4005
|
+
path: at2,
|
|
4006
|
+
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.",
|
|
4007
|
+
help: BACKGROUND_HELP
|
|
4008
|
+
};
|
|
4009
|
+
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4010
|
+
const entry2 = findings[index];
|
|
4011
|
+
if (schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`))) findings.splice(index, 1);
|
|
4012
|
+
}
|
|
4013
|
+
findings.splice(first, 0, one);
|
|
4014
|
+
}
|
|
4015
|
+
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4016
|
+
const entry2 = findings[index];
|
|
4017
|
+
if (!schema(entry2) || entry2.validation?.keyword !== "if") continue;
|
|
4018
|
+
const stem = entry2.validation.schemaPath.replace(/if$/, "");
|
|
4019
|
+
if (findings.some((other) => other !== entry2 && schema(other) && other.path.startsWith(entry2.path) && typeof other.validation?.schemaPath === "string" && (other.validation.schemaPath.startsWith(`${stem}then`) || other.validation.schemaPath.startsWith(`${stem}else`)))) findings.splice(index, 1);
|
|
4020
|
+
}
|
|
4021
|
+
for (const [index, entry2] of findings.entries()) {
|
|
4022
|
+
if (!schema(entry2) || entry2.validation?.keyword !== "maximum") continue;
|
|
4023
|
+
const match2 = /^(\/slides\/\d+\/shapes\/\d+\/at)\/(width|height)$/.exec(entry2.path);
|
|
4024
|
+
const at2 = match2?.[1] ? valueAt(match2[1]) : void 0, key3 = match2?.[2], size = key3 && isRecord(at2) ? at2[key3] : void 0;
|
|
4025
|
+
if (!key3 || !isRecord(at2) || typeof size !== "number" || !(size > 8 && size <= 1280) || Object.hasOwn(at2, `${key3}Px`)) continue;
|
|
4026
|
+
const px = `${key3}Px`;
|
|
4027
|
+
findings[index] = {
|
|
4028
|
+
...entry2,
|
|
4029
|
+
message: `at.${key3} is ${size}, but it is a fraction of the block, at most 8: did you mean "${px}"?`,
|
|
4030
|
+
help: `Did you mean "${px}"? "${key3}" is a fraction of the block (1 is its own size, up to 8); a size in pixels is "${px}". A 0.33 deck wrote pixels under "${key3}".`,
|
|
4031
|
+
fixes: [{ id: "rename", title: `Rename ${key3} to ${px}`, kind: "patch", safe: false, patch: [{ op: "move", from: entry2.path, path: `${entry2.path}Px` }] }]
|
|
4032
|
+
};
|
|
4033
|
+
}
|
|
4034
|
+
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4035
|
+
const entry2 = findings[index];
|
|
4036
|
+
if (!schema(entry2) || entry2.validation?.keyword !== "required" || entry2.validation.params.missingProperty !== "items") continue;
|
|
4037
|
+
const payload = valueAt(entry2.path);
|
|
4038
|
+
if (isRecord(payload) && payload.type === "list" && Object.hasOwn(payload, "bullets")) findings.splice(index, 1);
|
|
4039
|
+
}
|
|
4040
|
+
const OPTION_RULES = ["opf/image-option-unsupported-payload", "opf/shape-option-unsupported-payload", "opf/caption-unsupported-payload"];
|
|
4041
|
+
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);
|
|
4042
|
+
for (let index = findings.length - 1; index >= 0; index--) {
|
|
4043
|
+
const entry2 = findings[index];
|
|
4044
|
+
if (!schema(entry2) || !optionDefinition(entry2)) continue;
|
|
4045
|
+
const prefix = `${entry2.path}/`;
|
|
4046
|
+
if (findings.some((other) => other !== entry2 && other.path.startsWith(prefix) && !other.path.slice(prefix.length).includes("/") && OPTION_RULES.includes(other.ruleId))) findings.splice(index, 1);
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
3750
4049
|
function collapseChartShape(document, findings) {
|
|
3751
4050
|
const chartAt = (path) => {
|
|
3752
4051
|
let node = document;
|
|
@@ -3780,9 +4079,11 @@ function engineFindings(document, engine, enabled) {
|
|
|
3780
4079
|
const findings = [];
|
|
3781
4080
|
for (const issue2 of engine.errors) {
|
|
3782
4081
|
const ruleId = issueRuleId(issue2);
|
|
3783
|
-
if (enabled(ruleId))
|
|
4082
|
+
if (!enabled(ruleId)) continue;
|
|
4083
|
+
findings.push(issueFinding(issue2, ruleId));
|
|
3784
4084
|
}
|
|
3785
4085
|
collapseChartShape(document, findings);
|
|
4086
|
+
collapseAuthoringShapes(document, findings);
|
|
3786
4087
|
let numberFixes;
|
|
3787
4088
|
for (const issue2 of engine.warnings) {
|
|
3788
4089
|
const code2 = issue2.params.code;
|
|
@@ -3801,9 +4102,14 @@ function engineFindings(document, engine, enabled) {
|
|
|
3801
4102
|
continue;
|
|
3802
4103
|
}
|
|
3803
4104
|
}
|
|
3804
|
-
const found = issueFinding(issue2, ruleId, "presentation", "", "document", "warning");
|
|
4105
|
+
const found = issueFinding(issue2, ruleId, "presentation", "", "document", code2 === "variable-group-omitted" ? "info" : "warning");
|
|
3805
4106
|
const help = HELP[code2];
|
|
3806
4107
|
if (help) found.help = help;
|
|
4108
|
+
if (code2 === "shape-anchor-size-unit") {
|
|
4109
|
+
const key3 = String(issue2.params.key), px = `${key3}Px`;
|
|
4110
|
+
found.help = `Did you mean "${px}"? "${key3}" is a fraction of the block.`;
|
|
4111
|
+
found.fixes = [{ id: "rename", title: `Rename ${key3} to ${px}`, kind: "patch", safe: false, patch: [{ op: "move", from: found.path, path: `${found.path}Px` }] }];
|
|
4112
|
+
}
|
|
3807
4113
|
findings.push(found);
|
|
3808
4114
|
}
|
|
3809
4115
|
return findings;
|
|
@@ -3855,9 +4161,9 @@ function variableFindings(document, engine, schemaValid) {
|
|
|
3855
4161
|
return;
|
|
3856
4162
|
}
|
|
3857
4163
|
if (value && typeof value === "object")
|
|
3858
|
-
for (const [
|
|
3859
|
-
if (path.length === 0 && ["variables", "extensions", "catalogs", "assets"].includes(
|
|
3860
|
-
walk2(entry2, [...path,
|
|
4164
|
+
for (const [key3, entry2] of Object.entries(value)) {
|
|
4165
|
+
if (path.length === 0 && ["variables", "extensions", "catalogs", "assets"].includes(key3)) continue;
|
|
4166
|
+
walk2(entry2, [...path, key3], depth2 + 1);
|
|
3861
4167
|
}
|
|
3862
4168
|
};
|
|
3863
4169
|
walk2(document, [], 0);
|
|
@@ -4074,7 +4380,7 @@ function contractFindings(document, contracts) {
|
|
|
4074
4380
|
};
|
|
4075
4381
|
const message = (contract2.message ?? "This value is outside the allowed values for {{path}}.").replace(
|
|
4076
4382
|
/\{\{(path|value|allowed|file)\}\}/g,
|
|
4077
|
-
(_,
|
|
4383
|
+
(_, key3) => values[key3] ?? ""
|
|
4078
4384
|
);
|
|
4079
4385
|
findings.push(
|
|
4080
4386
|
finding("opf/contract", {
|
|
@@ -4092,9 +4398,9 @@ function contractFindings(document, contracts) {
|
|
|
4092
4398
|
})
|
|
4093
4399
|
);
|
|
4094
4400
|
} else if (object(entry2.value) || Array.isArray(entry2.value)) {
|
|
4095
|
-
const
|
|
4401
|
+
const key3 = pattern[entry2.depth];
|
|
4096
4402
|
for (const [name, value] of Object.entries(entry2.value))
|
|
4097
|
-
if (
|
|
4403
|
+
if (key3 === "*" || key3 === name)
|
|
4098
4404
|
stack.push({
|
|
4099
4405
|
value,
|
|
4100
4406
|
path: [...entry2.path, name],
|
|
@@ -4122,9 +4428,9 @@ function canonicalJson(value) {
|
|
|
4122
4428
|
} else {
|
|
4123
4429
|
const record = item;
|
|
4124
4430
|
const members = [];
|
|
4125
|
-
for (const
|
|
4126
|
-
const member = write(record[
|
|
4127
|
-
if (member !== void 0) members.push(`${JSON.stringify(
|
|
4431
|
+
for (const key3 of Object.keys(record).sort()) {
|
|
4432
|
+
const member = write(record[key3]);
|
|
4433
|
+
if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
|
|
4128
4434
|
}
|
|
4129
4435
|
text2 = `{${members.join(",")}}`;
|
|
4130
4436
|
}
|
|
@@ -4295,7 +4601,7 @@ var OPFPatchHashError = class extends OPFPatchError {
|
|
|
4295
4601
|
this.actual = actual;
|
|
4296
4602
|
}
|
|
4297
4603
|
};
|
|
4298
|
-
var own2 = (value,
|
|
4604
|
+
var own2 = (value, key3) => Object.prototype.hasOwnProperty.call(value, key3);
|
|
4299
4605
|
var isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
4300
4606
|
var clone = (value) => structuredClone(value);
|
|
4301
4607
|
function jsonEqual(a, b) {
|
|
@@ -4308,7 +4614,7 @@ function jsonEqual(a, b) {
|
|
|
4308
4614
|
}
|
|
4309
4615
|
const left = a, right = b;
|
|
4310
4616
|
const keys = Object.keys(left);
|
|
4311
|
-
return keys.length === Object.keys(right).length && keys.every((
|
|
4617
|
+
return keys.length === Object.keys(right).length && keys.every((key3) => own2(right, key3) && jsonEqual(left[key3], right[key3]));
|
|
4312
4618
|
}
|
|
4313
4619
|
function escapePointerToken(token) {
|
|
4314
4620
|
return String(token).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
@@ -4471,65 +4777,65 @@ function normalizeOperation(operation, index) {
|
|
|
4471
4777
|
return { op, path: operation.path, value: clone(operation.value) };
|
|
4472
4778
|
}
|
|
4473
4779
|
function parentOf(document, tokens, path) {
|
|
4474
|
-
const
|
|
4780
|
+
const key3 = tokens[tokens.length - 1];
|
|
4475
4781
|
const found = readPointer(document, tokens.slice(0, -1));
|
|
4476
4782
|
if (!found.found || !found.value || typeof found.value !== "object") {
|
|
4477
4783
|
throw new OPFPatchError("patch-parent-missing", `Patch parent does not exist for ${path}.`, { path });
|
|
4478
4784
|
}
|
|
4479
|
-
return { parent: found.value, key:
|
|
4785
|
+
return { parent: found.value, key: key3 };
|
|
4480
4786
|
}
|
|
4481
4787
|
var NONE = /* @__PURE__ */ Symbol("none");
|
|
4482
4788
|
function addAt(document, path, value) {
|
|
4483
4789
|
const tokens = resolveTokens(document, parsePointer(path), path);
|
|
4484
4790
|
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
|
|
4485
|
-
const { parent, key:
|
|
4791
|
+
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
4486
4792
|
if (Array.isArray(parent)) {
|
|
4487
|
-
const at2 = arrayIndex(
|
|
4793
|
+
const at2 = arrayIndex(key3, parent.length, true, path);
|
|
4488
4794
|
parent.splice(at2, 0, clone(value));
|
|
4489
4795
|
const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
|
|
4490
4796
|
return { document, inverse: { op: "remove", path: pointer5 }, pointer: pointer5 };
|
|
4491
4797
|
}
|
|
4492
4798
|
const record = parent;
|
|
4493
|
-
const previous = own2(record,
|
|
4494
|
-
Object.defineProperty(record,
|
|
4799
|
+
const previous = own2(record, key3) ? record[key3] : NONE;
|
|
4800
|
+
Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
4495
4801
|
const pointer4 = formatPointer(tokens);
|
|
4496
4802
|
return { document, inverse: previous === NONE ? { op: "remove", path: pointer4 } : { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
|
|
4497
4803
|
}
|
|
4498
4804
|
function replaceAt(document, path, value) {
|
|
4499
4805
|
const tokens = resolveTokens(document, parsePointer(path), path);
|
|
4500
4806
|
if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
|
|
4501
|
-
const { parent, key:
|
|
4807
|
+
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
4502
4808
|
let previous;
|
|
4503
4809
|
let pointer4 = formatPointer(tokens);
|
|
4504
4810
|
if (Array.isArray(parent)) {
|
|
4505
|
-
const at2 = arrayIndex(
|
|
4811
|
+
const at2 = arrayIndex(key3, parent.length, false, path);
|
|
4506
4812
|
previous = parent[at2];
|
|
4507
4813
|
parent[at2] = clone(value);
|
|
4508
4814
|
pointer4 = formatPointer([...tokens.slice(0, -1), at2]);
|
|
4509
4815
|
} else {
|
|
4510
4816
|
const record = parent;
|
|
4511
|
-
if (!own2(record,
|
|
4512
|
-
previous = record[
|
|
4513
|
-
Object.defineProperty(record,
|
|
4817
|
+
if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
4818
|
+
previous = record[key3];
|
|
4819
|
+
Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
|
|
4514
4820
|
}
|
|
4515
4821
|
return { document, inverse: { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
|
|
4516
4822
|
}
|
|
4517
4823
|
function removeAt(document, path) {
|
|
4518
4824
|
const tokens = resolveTokens(document, parsePointer(path), path);
|
|
4519
4825
|
if (!tokens.length) throw new OPFPatchError("patch-root-remove", "The document root cannot be removed.", { path });
|
|
4520
|
-
const { parent, key:
|
|
4826
|
+
const { parent, key: key3 } = parentOf(document, tokens, path);
|
|
4521
4827
|
let previous;
|
|
4522
4828
|
if (Array.isArray(parent)) {
|
|
4523
|
-
const at2 = arrayIndex(
|
|
4829
|
+
const at2 = arrayIndex(key3, parent.length, false, path);
|
|
4524
4830
|
previous = parent[at2];
|
|
4525
4831
|
parent.splice(at2, 1);
|
|
4526
4832
|
const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
|
|
4527
4833
|
return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
|
|
4528
4834
|
}
|
|
4529
4835
|
const record = parent;
|
|
4530
|
-
if (!own2(record,
|
|
4531
|
-
previous = record[
|
|
4532
|
-
delete record[
|
|
4836
|
+
if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
|
|
4837
|
+
previous = record[key3];
|
|
4838
|
+
delete record[key3];
|
|
4533
4839
|
const pointer4 = formatPointer(tokens);
|
|
4534
4840
|
return { document, inverse: { op: "add", path: pointer4, value: clone(previous) }, pointer: pointer4 };
|
|
4535
4841
|
}
|
|
@@ -4690,7 +4996,7 @@ var schemaCatalogKinds = {
|
|
|
4690
4996
|
};
|
|
4691
4997
|
|
|
4692
4998
|
// src/schema-navigation.ts
|
|
4693
|
-
var own3 = (object2,
|
|
4999
|
+
var own3 = (object2, key3) => object2 !== null && typeof object2 === "object" && Object.hasOwn(object2, key3);
|
|
4694
5000
|
var documents = new Map(Object.values(schemas).map((schema) => [schema.$id, schema]));
|
|
4695
5001
|
var presentationSchema = schemas.presentation;
|
|
4696
5002
|
var CATALOG_KIND = /* @__PURE__ */ Symbol.for("@openpresentation/opf:catalog-kind");
|
|
@@ -4711,10 +5017,10 @@ function readSchemaPointer(target, pointer4) {
|
|
|
4711
5017
|
}
|
|
4712
5018
|
return current;
|
|
4713
5019
|
}
|
|
4714
|
-
for (const [
|
|
4715
|
-
const [name = "", pointer4 = ""] =
|
|
5020
|
+
for (const [key3, kind] of Object.entries(schemaCatalogKinds)) {
|
|
5021
|
+
const [name = "", pointer4 = ""] = key3.split("#");
|
|
4716
5022
|
const node = readSchemaPointer(schemas[name], pointer4);
|
|
4717
|
-
if (node === void 0 || node === null || typeof node !== "object") throw new Error(`schemaCatalogKinds: ${
|
|
5023
|
+
if (node === void 0 || node === null || typeof node !== "object") throw new Error(`schemaCatalogKinds: ${key3} is not a schema node.`);
|
|
4718
5024
|
catalogKindOfNode.set(node, kind);
|
|
4719
5025
|
}
|
|
4720
5026
|
function absolutize(schema, id) {
|
|
@@ -4723,7 +5029,7 @@ function absolutize(schema, id) {
|
|
|
4723
5029
|
const copy = {};
|
|
4724
5030
|
const kind = kindOfNode(schema);
|
|
4725
5031
|
if (kind !== void 0) copy[CATALOG_KIND] = kind;
|
|
4726
|
-
for (const [
|
|
5032
|
+
for (const [key3, value] of Object.entries(schema)) copy[key3] = key3 === "$ref" && typeof value === "string" && value.startsWith("#") ? `${id}${value}` : absolutize(value, id);
|
|
4727
5033
|
return copy;
|
|
4728
5034
|
}
|
|
4729
5035
|
function mergeAllOf(schema, root, seen) {
|
|
@@ -4790,36 +5096,36 @@ function score2(schema, value) {
|
|
|
4790
5096
|
if (schema.enum && !schema.enum.includes(value)) return -100;
|
|
4791
5097
|
let result = 1;
|
|
4792
5098
|
const record = value;
|
|
4793
|
-
for (const [
|
|
4794
|
-
if (!record || !own3(record,
|
|
4795
|
-
if (own3(child, "const")) result += record[
|
|
5099
|
+
for (const [key3, child] of Object.entries(schema.properties ?? {})) {
|
|
5100
|
+
if (!record || !own3(record, key3)) continue;
|
|
5101
|
+
if (own3(child, "const")) result += record[key3] === child.const ? 100 : -1e3;
|
|
4796
5102
|
else result += 1;
|
|
4797
5103
|
}
|
|
4798
|
-
for (const
|
|
5104
|
+
for (const key3 of schema.required ?? []) if (!record || !own3(record, key3)) result -= 2;
|
|
4799
5105
|
return result;
|
|
4800
5106
|
}
|
|
4801
5107
|
function activeSchema(schema, value, root = presentationSchema) {
|
|
4802
5108
|
return schemaVariants(schema, root).sort((a, b) => score2(b, value) - score2(a, value))[0] ?? {};
|
|
4803
5109
|
}
|
|
4804
5110
|
var INDEX = /^(?:0|[1-9][0-9]*|-)$/;
|
|
4805
|
-
function patternChild(schema,
|
|
5111
|
+
function patternChild(schema, key3) {
|
|
4806
5112
|
for (const [pattern, child] of Object.entries(schema.patternProperties ?? {})) {
|
|
4807
5113
|
try {
|
|
4808
|
-
if (new RegExp(pattern).test(
|
|
5114
|
+
if (new RegExp(pattern).test(key3)) return child;
|
|
4809
5115
|
} catch {
|
|
4810
5116
|
}
|
|
4811
5117
|
}
|
|
4812
5118
|
return void 0;
|
|
4813
5119
|
}
|
|
4814
|
-
function childSchema(schema,
|
|
5120
|
+
function childSchema(schema, key3, value) {
|
|
4815
5121
|
if (Array.isArray(value) || schema.type === "array") return schema.items ?? void 0;
|
|
4816
|
-
return schema.properties?.[
|
|
5122
|
+
return schema.properties?.[key3] ?? patternChild(schema, key3) ?? (typeof schema.additionalProperties === "object" ? schema.additionalProperties : void 0);
|
|
4817
5123
|
}
|
|
4818
|
-
function stepSchema(schema, value,
|
|
5124
|
+
function stepSchema(schema, value, key3, root) {
|
|
4819
5125
|
const variants = schemaVariants(schema, root).sort((a, b) => score2(b, value) - score2(a, value));
|
|
4820
5126
|
const first = variants[0] ?? {};
|
|
4821
|
-
if (value !== void 0 || variants.length < 2 || childSchema(first,
|
|
4822
|
-
return variants.find((variant) => variant.type === "array" ? INDEX.test(
|
|
5127
|
+
if (value !== void 0 || variants.length < 2 || childSchema(first, key3, value) !== void 0) return first;
|
|
5128
|
+
return variants.find((variant) => variant.type === "array" ? INDEX.test(key3) && childSchema(variant, key3, value) !== void 0 : childSchema(variant, key3, value) !== void 0) ?? first;
|
|
4823
5129
|
}
|
|
4824
5130
|
function walk(presentation, parts2, rootSchema) {
|
|
4825
5131
|
let current = rootSchema;
|
|
@@ -4828,21 +5134,21 @@ function walk(presentation, parts2, rootSchema) {
|
|
|
4828
5134
|
let parent;
|
|
4829
5135
|
let known = true;
|
|
4830
5136
|
for (let index = 0; index < parts2.length; index++) {
|
|
4831
|
-
const
|
|
4832
|
-
const resolved = stepSchema(current, value,
|
|
5137
|
+
const key3 = parts2[index];
|
|
5138
|
+
const resolved = stepSchema(current, value, key3, root);
|
|
4833
5139
|
parent = resolved;
|
|
4834
5140
|
let next;
|
|
4835
5141
|
const recordSchema = parts2[0] === "catalogs" && index === 3 ? catalogSchemaNames[parts2[2]] : void 0;
|
|
4836
5142
|
if (recordSchema) {
|
|
4837
5143
|
next = schemas[recordSchema] ?? {};
|
|
4838
5144
|
root = next;
|
|
4839
|
-
} else next = childSchema(resolved,
|
|
5145
|
+
} else next = childSchema(resolved, key3, value);
|
|
4840
5146
|
if (next === void 0) {
|
|
4841
5147
|
known = false;
|
|
4842
5148
|
next = {};
|
|
4843
5149
|
}
|
|
4844
5150
|
current = next;
|
|
4845
|
-
value = value !== null && typeof value === "object" ? value[
|
|
5151
|
+
value = value !== null && typeof value === "object" ? value[key3] : void 0;
|
|
4846
5152
|
}
|
|
4847
5153
|
return { raw: current, schema: resolveSchema(current, root), root, parent, value, known };
|
|
4848
5154
|
}
|
|
@@ -4864,7 +5170,7 @@ function createSchemaValue(schema, root = presentationSchema, depth2 = 0) {
|
|
|
4864
5170
|
if (type === "object") {
|
|
4865
5171
|
const value = {};
|
|
4866
5172
|
const properties = s.properties ?? {};
|
|
4867
|
-
for (const
|
|
5173
|
+
for (const key3 of /* @__PURE__ */ new Set([...s.required ?? [], ...Object.keys(properties).filter((name) => own3(properties[name], "const"))])) value[key3] = createSchemaValue(properties[key3] ?? {}, root, depth2 + 1);
|
|
4868
5174
|
return value;
|
|
4869
5175
|
}
|
|
4870
5176
|
if (type === "array") return Array.from({ length: Math.min(s.minItems ?? 0, 100) }, () => createSchemaValue(s.items ?? {}, root, depth2 + 1));
|
|
@@ -4881,26 +5187,26 @@ function listSchemaFields() {
|
|
|
4881
5187
|
for (const [name, root] of Object.entries(schemas)) {
|
|
4882
5188
|
const visit = (schema, path) => {
|
|
4883
5189
|
if (!schema || typeof schema !== "object") return;
|
|
4884
|
-
for (const [
|
|
5190
|
+
for (const [key3, child] of Object.entries(schema.properties ?? {})) {
|
|
4885
5191
|
result.push({
|
|
4886
5192
|
schema: name,
|
|
4887
|
-
path: formatPointer([...path, "properties",
|
|
4888
|
-
name:
|
|
5193
|
+
path: formatPointer([...path, "properties", key3]),
|
|
5194
|
+
name: key3,
|
|
4889
5195
|
description: child.description ?? "",
|
|
4890
5196
|
reference: child.$ref ?? null,
|
|
4891
5197
|
type: child.type ?? null,
|
|
4892
5198
|
values: child.enum ?? (own3(child, "const") ? [child.const] : null)
|
|
4893
5199
|
});
|
|
4894
|
-
visit(child, [...path, "properties",
|
|
5200
|
+
visit(child, [...path, "properties", key3]);
|
|
4895
5201
|
}
|
|
4896
|
-
for (const [
|
|
5202
|
+
for (const [key3, child] of Object.entries(schema.$defs ?? {})) visit(child, [...path, "$defs", key3]);
|
|
4897
5203
|
for (const keyword of ["oneOf", "anyOf", "allOf"]) {
|
|
4898
5204
|
const members = schema[keyword] ?? [];
|
|
4899
5205
|
for (let index = 0; index < members.length; index++) visit(members[index], [...path, keyword, String(index)]);
|
|
4900
5206
|
}
|
|
4901
5207
|
if (schema.items) visit(schema.items, [...path, "items"]);
|
|
4902
5208
|
if (typeof schema.additionalProperties === "object") visit(schema.additionalProperties, [...path, "additionalProperties"]);
|
|
4903
|
-
for (const [
|
|
5209
|
+
for (const [key3, child] of Object.entries(schema.patternProperties ?? {})) visit(child, [...path, "patternProperties", key3]);
|
|
4904
5210
|
};
|
|
4905
5211
|
visit(root, []);
|
|
4906
5212
|
}
|
|
@@ -4910,16 +5216,16 @@ var COMMON_KEYS = Object.freeze({
|
|
|
4910
5216
|
/** The root of a document. */
|
|
4911
5217
|
deck: Object.freeze(["name", "slides", "design", "language", "audience", "purpose", "tone", "narrative", "organization", "speaker"]),
|
|
4912
5218
|
/** A slide (`slides[n]`). */
|
|
4913
|
-
slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "diagram", "blocks", "design", "id", "section", "tag", "hidden", "beat"]),
|
|
5219
|
+
slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "diagram", "blocks", "design", "id", "section", "tag", "hidden", "beat", "language"]),
|
|
4914
5220
|
/** `design`, on the deck and on a slide. */
|
|
4915
5221
|
design: Object.freeze(["theme", "colorScheme", "fontScheme", "dimensions", "background", "header", "footer"])
|
|
4916
5222
|
});
|
|
4917
5223
|
var UNRANKED_PRIORITY = 1e6;
|
|
4918
5224
|
var DEFINITION_LISTS = { Slide: COMMON_KEYS.slide, Design: COMMON_KEYS.design, SlideDesign: COMMON_KEYS.design };
|
|
4919
5225
|
var ADVANCED_KEYS = /* @__PURE__ */ new Set(["extensions", "$schema"]);
|
|
4920
|
-
var REGION_KEY = /^(?:(?:top|middle|bottom)(?:\+(?:top|middle|bottom))*)?(?::)?(?:(?:
|
|
4921
|
-
function isPromotedRegionKey(
|
|
4922
|
-
return
|
|
5226
|
+
var REGION_KEY = /^(?:(?:top|middle|bottom)(?:\+(?:top|middle|bottom))*)?(?::)?(?:(?:start|center|end)(?:\+(?:start|center|end))*)?$/;
|
|
5227
|
+
function isPromotedRegionKey(key3) {
|
|
5228
|
+
return key3 !== "" && key3 !== ":" && REGION_KEY.test(key3);
|
|
4923
5229
|
}
|
|
4924
5230
|
var uniq = (items) => [...new Set(items)];
|
|
4925
5231
|
function variantType(variant) {
|
|
@@ -4978,8 +5284,8 @@ function typeLabelOf(raw, variants, root) {
|
|
|
4978
5284
|
if (type === "object") return definitionOf(raw) ?? "object";
|
|
4979
5285
|
return type;
|
|
4980
5286
|
}
|
|
4981
|
-
function priorityOf(list,
|
|
4982
|
-
const index = list ? list.indexOf(
|
|
5287
|
+
function priorityOf(list, key3) {
|
|
5288
|
+
const index = list ? list.indexOf(key3) : -1;
|
|
4983
5289
|
return index < 0 ? UNRANKED_PRIORITY : index;
|
|
4984
5290
|
}
|
|
4985
5291
|
function objectForm(variants, value) {
|
|
@@ -4990,24 +5296,24 @@ function objectForm(variants, value) {
|
|
|
4990
5296
|
if (best) used = [best];
|
|
4991
5297
|
}
|
|
4992
5298
|
const properties = /* @__PURE__ */ new Map();
|
|
4993
|
-
for (const variant of used) for (const [
|
|
4994
|
-
const required = used.length ? (used[0]?.required ?? []).filter((
|
|
5299
|
+
for (const variant of used) for (const [key3, child] of Object.entries(variant.properties ?? {})) if (!properties.has(key3)) properties.set(key3, child);
|
|
5300
|
+
const required = used.length ? (used[0]?.required ?? []).filter((key3) => used.every((variant) => (variant.required ?? []).includes(key3))) : [];
|
|
4995
5301
|
return { properties, required };
|
|
4996
5302
|
}
|
|
4997
5303
|
function childrenOf(form, list, isSlide, root) {
|
|
4998
5304
|
const children = [];
|
|
4999
|
-
for (const [
|
|
5305
|
+
for (const [key3, raw] of form.properties) {
|
|
5000
5306
|
const resolved = resolveSchema(raw, root);
|
|
5001
5307
|
const variants = schemaVariants(raw, root);
|
|
5002
5308
|
const description = firstParagraph(resolved.description);
|
|
5003
5309
|
const catalogKind = catalogKindOf(resolved, variants);
|
|
5004
5310
|
children.push({
|
|
5005
|
-
key:
|
|
5311
|
+
key: key3,
|
|
5006
5312
|
types: uniq(variants.map(variantType)),
|
|
5007
5313
|
typeLabel: typeLabelOf(raw, variants, root),
|
|
5008
|
-
required: form.required.includes(
|
|
5009
|
-
advanced: ADVANCED_KEYS.has(
|
|
5010
|
-
priority: priorityOf(list,
|
|
5314
|
+
required: form.required.includes(key3),
|
|
5315
|
+
advanced: ADVANCED_KEYS.has(key3) || isSlide && isPromotedRegionKey(key3),
|
|
5316
|
+
priority: priorityOf(list, key3),
|
|
5011
5317
|
...description ? { description } : {},
|
|
5012
5318
|
...catalogKind ? { catalogKind } : {},
|
|
5013
5319
|
...resolved.deprecated === true ? { deprecated: true } : {},
|
|
@@ -5040,7 +5346,7 @@ function describeAt(presentation, path, depth2) {
|
|
|
5040
5346
|
const inherited = schema.description;
|
|
5041
5347
|
const last = parts2.at(-1);
|
|
5042
5348
|
const parentIsArray = parent !== void 0 && variantType(parent) === "array";
|
|
5043
|
-
const
|
|
5349
|
+
const key3 = last !== void 0 && !parentIsArray ? last : void 0;
|
|
5044
5350
|
const definition = definitionOf(raw);
|
|
5045
5351
|
const description = firstParagraph(schema.description);
|
|
5046
5352
|
const enumList = enumValues(variants, inherited);
|
|
@@ -5070,12 +5376,12 @@ function describeAt(presentation, path, depth2) {
|
|
|
5070
5376
|
known: true,
|
|
5071
5377
|
path: shown,
|
|
5072
5378
|
pointer: pointer4,
|
|
5073
|
-
...
|
|
5379
|
+
...key3 !== void 0 ? { key: key3 } : {},
|
|
5074
5380
|
types: uniq(infos2.map((variant) => variant.type)),
|
|
5075
5381
|
...description ? { description } : {},
|
|
5076
5382
|
...typeof schema.description === "string" && schema.description.trim() ? { fullDescription: schema.description.trim() } : {},
|
|
5077
5383
|
...definition ? { definition } : {},
|
|
5078
|
-
required:
|
|
5384
|
+
required: key3 !== void 0 && Array.isArray(parent?.required) && parent.required.includes(key3),
|
|
5079
5385
|
...schema.deprecated === true ? { deprecated: true } : {},
|
|
5080
5386
|
examples: Array.isArray(schema.examples) ? [...schema.examples] : [],
|
|
5081
5387
|
...own3(schema, "default") ? { default: schema.default } : {},
|
|
@@ -5654,7 +5960,7 @@ var Analyzer = class {
|
|
|
5654
5960
|
});
|
|
5655
5961
|
}
|
|
5656
5962
|
// -- values --
|
|
5657
|
-
parseValue(path,
|
|
5963
|
+
parseValue(path, key3) {
|
|
5658
5964
|
const token = this.peek();
|
|
5659
5965
|
switch (token.kind) {
|
|
5660
5966
|
case "lbrace":
|
|
@@ -5673,7 +5979,7 @@ var Analyzer = class {
|
|
|
5673
5979
|
return { start: token.start, end: token.end, kind: "scalar" };
|
|
5674
5980
|
case "word":
|
|
5675
5981
|
this.take();
|
|
5676
|
-
this.bareWord(token, path,
|
|
5982
|
+
this.bareWord(token, path, key3);
|
|
5677
5983
|
return { start: token.start, end: token.end, kind: "scalar" };
|
|
5678
5984
|
case "unknown":
|
|
5679
5985
|
this.take();
|
|
@@ -5682,7 +5988,7 @@ var Analyzer = class {
|
|
|
5682
5988
|
return void 0;
|
|
5683
5989
|
}
|
|
5684
5990
|
}
|
|
5685
|
-
bareWord(token, path,
|
|
5991
|
+
bareWord(token, path, key3) {
|
|
5686
5992
|
const word = token.text;
|
|
5687
5993
|
const lower = word.toLowerCase();
|
|
5688
5994
|
const edit = (insert) => [{ offset: token.start, length: token.end - token.start, insert }];
|
|
@@ -5698,7 +6004,7 @@ var Analyzer = class {
|
|
|
5698
6004
|
next = "write null, or put it in quotes if it is text. JSON has no NaN, Infinity or undefined.";
|
|
5699
6005
|
fixes.push({ id: "use-null", title: "Use null", safe: lower === "null", edits: edit("null") });
|
|
5700
6006
|
} else {
|
|
5701
|
-
message =
|
|
6007
|
+
message = key3 !== void 0 ? `\`${key3}\` needs a quoted string: ${JSON.stringify(word)}.` : `\`${clip(word, 24)}\` needs quotes to be text: ${JSON.stringify(word)}.`;
|
|
5702
6008
|
next = `put it in double quotes: ${JSON.stringify(word)}.`;
|
|
5703
6009
|
}
|
|
5704
6010
|
fixes.push({ id: "quote-value", title: "Quote the value", safe: false, edits: edit(JSON.stringify(word)) });
|
|
@@ -5922,23 +6228,23 @@ var Analyzer = class {
|
|
|
5922
6228
|
fixes: [{ id: "remove-token", title: `Remove ${clip(token.text, 12)}`, safe: false, edits: [{ offset: token.start, length: token.end - token.start, insert: "" }] }]
|
|
5923
6229
|
});
|
|
5924
6230
|
}
|
|
5925
|
-
missingColon(keyToken,
|
|
6231
|
+
missingColon(keyToken, key3, path, valueFollows, container) {
|
|
5926
6232
|
const keyEnd = keyToken.end;
|
|
5927
|
-
const shown = clip(
|
|
6233
|
+
const shown = clip(key3, 30);
|
|
5928
6234
|
const removal = this.removeEntry(keyToken.start, keyEnd);
|
|
5929
6235
|
this.structural({
|
|
5930
6236
|
code: "missing-colon",
|
|
5931
6237
|
range: this.range(keyToken.start, keyToken.end),
|
|
5932
6238
|
path,
|
|
5933
6239
|
message: valueFollows ? `\`${shown}\` is missing a colon.` : `\`${shown}\` has no colon and value.`,
|
|
5934
|
-
next: valueFollows ? "add `:` after the property name." : `write ${JSON.stringify(
|
|
6240
|
+
next: valueFollows ? "add `:` after the property name." : `write ${JSON.stringify(key3)}: and a value, or remove the property.`,
|
|
5935
6241
|
fixes: [
|
|
5936
6242
|
{ id: "insert-colon", title: "Add colon", safe: valueFollows, edits: [{ offset: keyEnd, length: 0, insert: valueFollows ? ":" : ": " }], caret: keyEnd + (valueFollows ? 1 : 2) },
|
|
5937
|
-
...valueFollows ? [] : [{ id: "remove-key", title: `Remove ${JSON.stringify(
|
|
6243
|
+
...valueFollows ? [] : [{ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: removal }]
|
|
5938
6244
|
]
|
|
5939
6245
|
});
|
|
5940
6246
|
}
|
|
5941
|
-
missingValue(keyToken, colon,
|
|
6247
|
+
missingValue(keyToken, colon, key3, path) {
|
|
5942
6248
|
const needsComma = (() => {
|
|
5943
6249
|
const next = this.peek();
|
|
5944
6250
|
return (next.kind === "string" || next.kind === "word") && this.peek(1).kind === "colon";
|
|
@@ -5949,12 +6255,12 @@ var Analyzer = class {
|
|
|
5949
6255
|
const edits = [{ offset: at2, length: 0, insert: `${gap ? " " : ""}${hint.insert}` }];
|
|
5950
6256
|
if (needsComma) edits.push({ offset: at2, length: 0, insert: "," });
|
|
5951
6257
|
const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret: at2 + (gap ? 1 : 0) + hint.caret }];
|
|
5952
|
-
fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(
|
|
6258
|
+
fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
|
|
5953
6259
|
this.structural({
|
|
5954
6260
|
code: "missing-value",
|
|
5955
6261
|
range: this.range(keyToken.start, colon.end),
|
|
5956
6262
|
path,
|
|
5957
|
-
message: `\`${
|
|
6263
|
+
message: `\`${key3}\` needs a value.`,
|
|
5958
6264
|
next: `${hint.next} Press Ctrl+Space after the colon for options.`,
|
|
5959
6265
|
fixes
|
|
5960
6266
|
});
|
|
@@ -6011,8 +6317,8 @@ ${indentOf(text2, open.start)}${closer}`;
|
|
|
6011
6317
|
const insert = inner.join("") + own4;
|
|
6012
6318
|
this.cascade = { last: this.last, inserts: [...inner, own4] };
|
|
6013
6319
|
const closers = insert.replace(/\s/g, "");
|
|
6014
|
-
const
|
|
6015
|
-
const entry2 = typeof
|
|
6320
|
+
const key3 = container.path.at(-1);
|
|
6321
|
+
const entry2 = typeof key3 === "string" ? `"${key3}": ${open.text}` : open.text;
|
|
6016
6322
|
const context = container.type === "{" ? firstEntryOf(text2, open) : void 0;
|
|
6017
6323
|
const what = container.type === "{" ? "property" : "item";
|
|
6018
6324
|
this.add({
|
|
@@ -6223,18 +6529,18 @@ function parseSource(source) {
|
|
|
6223
6529
|
if (node.type === "object") {
|
|
6224
6530
|
const keys = /* @__PURE__ */ new Set();
|
|
6225
6531
|
for (const property of node.children ?? []) {
|
|
6226
|
-
const
|
|
6227
|
-
if (!
|
|
6228
|
-
if (keys.has(
|
|
6532
|
+
const key3 = property.children?.[0];
|
|
6533
|
+
if (!key3) continue;
|
|
6534
|
+
if (keys.has(key3.value))
|
|
6229
6535
|
duplicates.push(
|
|
6230
6536
|
finding("opf/duplicate-key", {
|
|
6231
|
-
path: pointer3(getNodePath(
|
|
6232
|
-
message: `Duplicate JSON property ${JSON.stringify(
|
|
6537
|
+
path: pointer3(getNodePath(key3)),
|
|
6538
|
+
message: `Duplicate JSON property ${JSON.stringify(key3.value)}.`,
|
|
6233
6539
|
help: "Resolve the duplicate explicitly, preserving the intended content from both occurrences. JSON.parse would otherwise hide an earlier value.",
|
|
6234
|
-
location: location(
|
|
6540
|
+
location: location(key3.offset, key3.length)
|
|
6235
6541
|
})
|
|
6236
6542
|
);
|
|
6237
|
-
keys.add(
|
|
6543
|
+
keys.add(key3.value);
|
|
6238
6544
|
}
|
|
6239
6545
|
}
|
|
6240
6546
|
stack.push(...node.children ?? []);
|
|
@@ -6269,7 +6575,7 @@ function parseSource(source) {
|
|
|
6269
6575
|
var WORDS = { object: "an object", array: "a list", string: "text", number: "a number", integer: "a whole number", boolean: "true or false", null: "null" };
|
|
6270
6576
|
var KIND_WORDS = { layouts: "layout", themes: "theme", colorSchemes: "color scheme", fontSchemes: "font scheme", narratives: "narrative", audiences: "audience", purposes: "purpose", tones: "tone", languages: "language" };
|
|
6271
6577
|
var KIND_EXAMPLES = { layouts: "`pillars` or `acme:hero`", themes: "`minimal` or `acme:bold`", colorSchemes: "`boost` or `acme:night`", fontSchemes: "`aptos` or `acme:brand`", narratives: "`classic-story`", audiences: "`board`", purposes: "`inform`", tones: "`formal`" };
|
|
6272
|
-
var ALIASES = { middle: "center", centre: "center", centered: "center", centred: "center", justify: "left", col: "column", cols: "column", pic: "image", picture: "image", photo: "image", paragraph: "text", bullets: "list", bullet: "list" };
|
|
6578
|
+
var ALIASES = { middle: "center", centre: "center", centered: "center", centred: "center", justify: "start", left: "start", right: "end", col: "column", cols: "column", pic: "image", picture: "image", photo: "image", paragraph: "text", bullets: "list", bullet: "list" };
|
|
6273
6579
|
function segmentsOf(path) {
|
|
6274
6580
|
if (Array.isArray(path)) return path.map(String);
|
|
6275
6581
|
if (typeof path !== "string" || path === "" || path === "/") return [];
|
|
@@ -6473,7 +6779,7 @@ var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote"
|
|
|
6473
6779
|
function blockKind(node) {
|
|
6474
6780
|
if (!isRecord3(node)) return void 0;
|
|
6475
6781
|
if (typeof node.type === "string" && node.type !== "group") return node.type;
|
|
6476
|
-
const found = BLOCK_KINDS.find((
|
|
6782
|
+
const found = BLOCK_KINDS.find((key3) => node[key3] !== void 0);
|
|
6477
6783
|
if (found === "items" || found === "bullets") return "list";
|
|
6478
6784
|
return found;
|
|
6479
6785
|
}
|
|
@@ -6488,12 +6794,12 @@ function brief(text2, max = 40) {
|
|
|
6488
6794
|
}
|
|
6489
6795
|
|
|
6490
6796
|
// src/finding-text-audit.ts
|
|
6491
|
-
var measuredNumber = (finding2,
|
|
6492
|
-
const value = finding2.measured?.[
|
|
6797
|
+
var measuredNumber = (finding2, key3) => {
|
|
6798
|
+
const value = finding2.measured?.[key3];
|
|
6493
6799
|
return typeof value === "number" ? value : void 0;
|
|
6494
6800
|
};
|
|
6495
|
-
var measuredText = (finding2,
|
|
6496
|
-
const value = finding2.measured?.[
|
|
6801
|
+
var measuredText = (finding2, key3) => {
|
|
6802
|
+
const value = finding2.measured?.[key3];
|
|
6497
6803
|
return typeof value === "string" ? value : void 0;
|
|
6498
6804
|
};
|
|
6499
6805
|
var num = (value, digits = 2) => String(Math.round(value * 10 ** digits) / 10 ** digits);
|
|
@@ -6520,6 +6826,12 @@ var textOnImage = (finding2) => {
|
|
|
6520
6826
|
const ratio = measuredNumber(finding2, "ratio");
|
|
6521
6827
|
const needed = measuredNumber(finding2, "needed");
|
|
6522
6828
|
const scrim = measuredNumber(finding2, "scrimOpacity");
|
|
6829
|
+
const best = measuredNumber(finding2, "best");
|
|
6830
|
+
if (best !== void 0)
|
|
6831
|
+
return {
|
|
6832
|
+
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` : ""}.`,
|
|
6833
|
+
next: `set the background's ${code("tone")} so the text color follows the picture, or give the text a readable color.`
|
|
6834
|
+
};
|
|
6523
6835
|
if (scrim !== void 0)
|
|
6524
6836
|
return {
|
|
6525
6837
|
message: `Text sits on this picture, so a scrim at ${num(scrim * 100)}% is drawn behind it to keep it readable${needed !== void 0 ? ` at ${num(needed)}:1` : ""}.`,
|
|
@@ -6726,6 +7038,18 @@ var iconDropped = (finding2) => {
|
|
|
6726
7038
|
next: room ? "shorten the text or give the slide more room, or remove the icon." : "move the icon to an entry, metric or group it can mark, or remove it."
|
|
6727
7039
|
};
|
|
6728
7040
|
};
|
|
7041
|
+
var shapeOffSlide = (finding2) => ({
|
|
7042
|
+
message: /callout/.test(finding2.message) ? "An image callout lies wholly outside the slide, so it is not drawn." : "A shape lies wholly outside the slide, so it is not drawn.",
|
|
7043
|
+
next: "write its position as fractions (0.2 for 20%), or move it so part of it is on the slide."
|
|
7044
|
+
});
|
|
7045
|
+
var chartLabelCollision = () => ({
|
|
7046
|
+
message: "A reference label meets another label, a data line or a mark at both ends of its line.",
|
|
7047
|
+
next: "shorten the label, give the chart more room, or set the line where a bar or the area leaves room beside it."
|
|
7048
|
+
});
|
|
7049
|
+
var timelinePeriodShort = () => ({
|
|
7050
|
+
message: "A timeline period is too short to read: its duration gives it less room than its marker.",
|
|
7051
|
+
next: "give the timeline more room, or make its shortest period longer."
|
|
7052
|
+
});
|
|
6729
7053
|
var arrangementAdapted = (finding2) => {
|
|
6730
7054
|
const cards = /needs four entries/.test(finding2.message);
|
|
6731
7055
|
return {
|
|
@@ -6803,7 +7127,7 @@ var centeredBody2 = (finding2) => {
|
|
|
6803
7127
|
const blocks = measuredNumber(finding2, "blocks") ?? 1;
|
|
6804
7128
|
return {
|
|
6805
7129
|
message: `A centered ${what}${onSlide(finding2)} runs ${lines} line${lines === 1 ? "" : "s"} (${characters} characters)${blocks > 1 ? `, with ${blocks - 1} more like it` : ""}; each line starts at a different place, which is harder to read.`,
|
|
6806
|
-
next: `set ${code('contentAlignment: "
|
|
7130
|
+
next: `set ${code('contentAlignment: "start"')} in the slide's design, or cut it to a line or two.`
|
|
6807
7131
|
};
|
|
6808
7132
|
};
|
|
6809
7133
|
var tightSpacing2 = (finding2) => {
|
|
@@ -6904,6 +7228,17 @@ var codeHighlightRangeReversed = (finding2) => {
|
|
|
6904
7228
|
next: `write [${found[3]}, ${found[4]}].`
|
|
6905
7229
|
};
|
|
6906
7230
|
};
|
|
7231
|
+
var variableGroupOmitted = (finding2) => {
|
|
7232
|
+
const ids = [...finding2.message.matchAll(/'([a-z][a-z0-9-]*)'/g)].map((found) => found[1]);
|
|
7233
|
+
const idParam = isRecord3(finding2.validation?.params) ? finding2.validation.params.id : void 0;
|
|
7234
|
+
const names2 = [...new Set(ids.length ? ids : typeof idParam === "string" ? [idParam] : [])];
|
|
7235
|
+
if (!names2.length) return void 0;
|
|
7236
|
+
const list = names2.length === 1 ? code(names2[0]) : `${names2.slice(0, -1).map((id) => code(id)).join(", ")} and ${code(names2.at(-1))}`;
|
|
7237
|
+
return {
|
|
7238
|
+
message: `A group${onSlide(finding2)} is left out when ${list} ${names2.length === 1 ? "has" : "have"} no value, with its pictures, cards and other text.`,
|
|
7239
|
+
next: `give ${names2.length === 1 ? "it" : "one of them"} a value to draw the group, or move what should always show out of the group.`
|
|
7240
|
+
};
|
|
7241
|
+
};
|
|
6907
7242
|
var variableBuiltinMissing = (finding2, _context, helpers) => {
|
|
6908
7243
|
const idParam = isRecord3(finding2.validation?.params) ? finding2.validation.params.id : void 0;
|
|
6909
7244
|
const id = (typeof idParam === "string" ? idParam : void 0) ?? match(finding2.message, /^Built-in '(.+?)' has no value/)?.[1] ?? match(finding2.message, /'\{\{(.+?)\}\}'/)?.[1];
|
|
@@ -7002,6 +7337,9 @@ var AUDIT_TEXT = {
|
|
|
7002
7337
|
"opf/region-full": regionFull,
|
|
7003
7338
|
"opf/icon-dropped": iconDropped,
|
|
7004
7339
|
"opf/arrangement-adapted": arrangementAdapted,
|
|
7340
|
+
"opf/chart-label-collision": chartLabelCollision,
|
|
7341
|
+
"opf/shape-off-slide": shapeOffSlide,
|
|
7342
|
+
"opf/timeline-period-short": timelinePeriodShort,
|
|
7005
7343
|
"opf/layout-unplaced": layoutUnplaced,
|
|
7006
7344
|
"opf/furniture-wraps": furnitureWraps,
|
|
7007
7345
|
"opf/font-outside-scheme": fontOutsideScheme,
|
|
@@ -7013,6 +7351,7 @@ var AUDIT_TEXT = {
|
|
|
7013
7351
|
"opf/code-highlight-out-of-range": codeHighlightOutOfRange,
|
|
7014
7352
|
"opf/code-highlight-range-reversed": codeHighlightRangeReversed,
|
|
7015
7353
|
"opf/variable-builtin-missing": variableBuiltinMissing,
|
|
7354
|
+
"opf/variable-group-omitted": variableGroupOmitted,
|
|
7016
7355
|
"opf/duration-outside-narrative": durationOutsideNarrative2,
|
|
7017
7356
|
"opf/narrative-duration-range": narrativeDurationRange,
|
|
7018
7357
|
"opf/placeholder-text": placeholderText,
|
|
@@ -7037,10 +7376,10 @@ var jsonSyntax = (finding2) => ({
|
|
|
7037
7376
|
next: helpAsNext(finding2, "fix the syntax error at the marked position.")
|
|
7038
7377
|
});
|
|
7039
7378
|
var duplicateKey = (finding2, _context, helpers) => {
|
|
7040
|
-
const
|
|
7379
|
+
const key3 = helpers.segments.at(-1) ?? unquote(match(finding2.message, /^Duplicate JSON property (".*")\.$/)?.[1]);
|
|
7041
7380
|
const owner = placeWords(helpers.segments.slice(0, -1));
|
|
7042
7381
|
return {
|
|
7043
|
-
message: `${code(
|
|
7382
|
+
message: `${code(key3)} appears twice ${owner}. JSON keeps only the last value, so the earlier one is ignored.`,
|
|
7044
7383
|
next: "keep one of them, or merge their values into one."
|
|
7045
7384
|
};
|
|
7046
7385
|
};
|
|
@@ -7083,8 +7422,8 @@ var captionUnsupportedPayload = (finding2) => {
|
|
|
7083
7422
|
const kind = type ?? (/a group cannot carry one/.test(finding2.message) ? "group" : void 0);
|
|
7084
7423
|
const is = kind ? kindPhrase(kind) : "not one of those";
|
|
7085
7424
|
return {
|
|
7086
|
-
message: `A ${code("caption")} belongs to one image, chart, table or
|
|
7087
|
-
next: `put the ${code("caption")} on the image, chart, table or
|
|
7425
|
+
message: `A ${code("caption")} belongs to one image, chart, table, video or diagram; this block is ${is}.`,
|
|
7426
|
+
next: `put the ${code("caption")} on the image, chart, table, video or diagram it describes, or remove it.`
|
|
7088
7427
|
};
|
|
7089
7428
|
};
|
|
7090
7429
|
var imageOptionUnsupportedPayload = (finding2) => {
|
|
@@ -7130,6 +7469,10 @@ var shapeLinkHidden = () => ({
|
|
|
7130
7469
|
message: "This shape is hidden, so its `link` can never be clicked.",
|
|
7131
7470
|
next: "remove `hidden`, or remove the `link`."
|
|
7132
7471
|
});
|
|
7472
|
+
var shapeAnchorSizeUnit = (finding2) => {
|
|
7473
|
+
const { key: key3, size } = params(finding2);
|
|
7474
|
+
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;
|
|
7475
|
+
};
|
|
7133
7476
|
var shapeAnchorMissing = (finding2) => {
|
|
7134
7477
|
const { id, known } = params(finding2);
|
|
7135
7478
|
if (typeof id !== "string") return void 0;
|
|
@@ -7219,6 +7562,17 @@ var chartMappingUnknownColumn = (finding2) => {
|
|
|
7219
7562
|
next: chooseNext(name, columns)
|
|
7220
7563
|
};
|
|
7221
7564
|
};
|
|
7565
|
+
var chartReferenceAxisUnavailable = () => ({
|
|
7566
|
+
message: "This reference uses a secondary value axis that the chart does not have.",
|
|
7567
|
+
next: "use the value axis, or put a line series on a combo chart's secondary axis."
|
|
7568
|
+
});
|
|
7569
|
+
var chartReferenceUnsupportedType = (finding2) => {
|
|
7570
|
+
const type = match(finding2.message, /a '(.+?)' chart has none/)?.[1];
|
|
7571
|
+
return {
|
|
7572
|
+
message: type ? `A ${code(type)} chart cannot draw reference lines: it has no single value axis.` : "This chart type cannot draw reference lines: it has no single value axis.",
|
|
7573
|
+
next: "remove `referenceLines`, or use a column, bar, line, line-with-markers, area or combo chart."
|
|
7574
|
+
};
|
|
7575
|
+
};
|
|
7222
7576
|
var numberFormatInvalid = (finding2, _context, helpers) => {
|
|
7223
7577
|
const value = helpers.valueAt(helpers.segments);
|
|
7224
7578
|
const reason = match(finding2.message, /^Number format '.*?' ((?:needs|scales|has|uses|asks|allows|is)\b.+)$/)?.[1];
|
|
@@ -7603,6 +7957,7 @@ var FORMAT_TEXT = {
|
|
|
7603
7957
|
"opf/shape-adjust-unknown": shapeAdjustUnknown,
|
|
7604
7958
|
"opf/shape-adjust-range": shapeAdjustRange,
|
|
7605
7959
|
"opf/shape-link-hidden": shapeLinkHidden,
|
|
7960
|
+
"opf/shape-anchor-size-unit": shapeAnchorSizeUnit,
|
|
7606
7961
|
"opf/shape-anchor-missing": shapeAnchorMissing,
|
|
7607
7962
|
"opf/connector-end-missing": connectorEndMissing,
|
|
7608
7963
|
"opf/layout-placeholder-group": layoutPlaceholderGroup,
|
|
@@ -7610,6 +7965,8 @@ var FORMAT_TEXT = {
|
|
|
7610
7965
|
"opf/dataset-field-unknown": datasetFieldUnknown,
|
|
7611
7966
|
"opf/data-column-duplicate": dataColumnDuplicate,
|
|
7612
7967
|
"opf/chart-mapping-unknown-column": chartMappingUnknownColumn,
|
|
7968
|
+
"opf/chart-reference-axis-unavailable": chartReferenceAxisUnavailable,
|
|
7969
|
+
"opf/chart-reference-unsupported-type": chartReferenceUnsupportedType,
|
|
7613
7970
|
"opf/number-format-invalid": numberFormatInvalid,
|
|
7614
7971
|
"opf/variable-invalid-value": variableInvalidValue,
|
|
7615
7972
|
"opf/variable-unknown-builtin": variableUnknownBuiltin,
|
|
@@ -7658,12 +8015,12 @@ var RULE_TEXT = Object.freeze(
|
|
|
7658
8015
|
);
|
|
7659
8016
|
|
|
7660
8017
|
// src/markdown/dialect.ts
|
|
7661
|
-
var SLIDE_OPTION_KEYS = ["id", "type", "layout", "section", "tag", "hidden", "beat"];
|
|
8018
|
+
var SLIDE_OPTION_KEYS = ["id", "type", "layout", "section", "tag", "hidden", "beat", "language"];
|
|
7662
8019
|
var BLOCK_OPTION_KEYS = ["id", "type", "as", "region"];
|
|
7663
8020
|
var BLOCK_AS_VALUES = ["bullets", "video"];
|
|
7664
|
-
var FENCE_KINDS = ["chart", "metric", "timeline", "mermaid", "opf-block", "opf-slide"];
|
|
8021
|
+
var FENCE_KINDS = ["chart", "metric", "timeline", "mermaid", "dot", "plantuml", "opf-block", "opf-slide"];
|
|
7665
8022
|
var METRIC_KEYS = ["value", "label", "description", "unit", "delta", "trend", "sentiment"];
|
|
7666
|
-
var FENCE_ATTRIBUTES = { chart: ["alt"], mermaid: ["alt"], timeline: ["name", "description"], code: ["title"] };
|
|
8023
|
+
var FENCE_ATTRIBUTES = { chart: ["alt"], mermaid: ["alt"], dot: ["alt"], plantuml: ["alt"], timeline: ["name", "description"], code: ["title"] };
|
|
7667
8024
|
var SPAN_FLAGS = ["bold", "italic", "underline", "strike", "sup", "sub"];
|
|
7668
8025
|
var SPAN_VALUES = ["color", "size", "font", "lang"];
|
|
7669
8026
|
var LINE_KEYWORDS = ["Note:", "Notes:"];
|
|
@@ -7677,25 +8034,25 @@ var optionKeys = (kind) => kind === "block" ? BLOCK_OPTION_KEYS : SLIDE_OPTION_K
|
|
|
7677
8034
|
var options = {
|
|
7678
8035
|
"markdown/options-unknown-key": (finding2) => {
|
|
7679
8036
|
const kind = quoted(finding2.message, /^Unknown (slide|block) option/) ?? "slide";
|
|
7680
|
-
const
|
|
8037
|
+
const key3 = quoted(finding2.message, /option "(.*)"\.$/) ?? "";
|
|
7681
8038
|
const guess = finding2.suggestions?.[0]?.value;
|
|
7682
8039
|
const keys = optionKeys(kind).join(", ");
|
|
7683
8040
|
return {
|
|
7684
|
-
message: `${code(
|
|
8041
|
+
message: `${code(key3)} is not a ${kind} option.`,
|
|
7685
8042
|
next: guess !== void 0 ? `did you mean ${code(guess)}? The keys are ${keys}. Anything else goes in an \`opf-${kind}\` fence.` : `use one of ${keys}. Anything else goes in an \`opf-${kind}\` fence.`
|
|
7686
8043
|
};
|
|
7687
8044
|
},
|
|
7688
8045
|
"markdown/options-value": (finding2) => {
|
|
7689
8046
|
if (/^hidden takes/.test(finding2.message)) return keep2(finding2, "write `hidden=true`, `hidden=false` or just `hidden`.");
|
|
7690
|
-
const
|
|
7691
|
-
if (
|
|
8047
|
+
const key3 = quoted(finding2.message, /^Option (\w+) needs a value/);
|
|
8048
|
+
if (key3) return keep2(finding2, `write ${code(`${key3}=value`)}, for example ${code(key3 === "layout" ? "layout=title" : key3 === "id" ? "id=cover" : `${key3}=name`)}.`);
|
|
7692
8049
|
if (/^as takes/.test(finding2.message)) return keep2(finding2, "write `as=bullets` before a list or `as=video` before an image line.");
|
|
7693
8050
|
return keep2(finding2, "put `as=bullets` before a list and `as=video` before an image line, or remove `as`.");
|
|
7694
8051
|
},
|
|
7695
8052
|
"markdown/options-syntax": (finding2) => keep2(finding2, `write options as ${code("key=value")} pairs, with text in double quotes: ${code('<!-- slide: layout=title section="Part 1" -->')}.`),
|
|
7696
8053
|
"markdown/options-duplicate": (finding2) => {
|
|
7697
|
-
const
|
|
7698
|
-
if (
|
|
8054
|
+
const key3 = quoted(finding2.message, /^Option (\w+) is given twice/);
|
|
8055
|
+
if (key3) return keep2(finding2, `keep one ${code(`${key3}=`)} in the comment.`);
|
|
7699
8056
|
return keep2(finding2, "merge them into one.");
|
|
7700
8057
|
},
|
|
7701
8058
|
"markdown/options-orphan": (finding2) => keep2(finding2, "put the `<!-- block: \u2026 -->` comment directly before the block it describes, or remove it."),
|
|
@@ -7720,7 +8077,7 @@ var markdown = {
|
|
|
7720
8077
|
"markdown/chart-attributes": (finding2) => keep2(finding2, 'write ```chart column alt="What the data shows" (`alt` is optional).'),
|
|
7721
8078
|
"markdown/chart-data": wholeHelp,
|
|
7722
8079
|
"markdown/chart-ragged": (finding2) => keep2(finding2, "give every row one value per column."),
|
|
7723
|
-
"markdown/diagram-attributes": (finding2) => keep2(finding2,
|
|
8080
|
+
"markdown/diagram-attributes": (finding2) => keep2(finding2, `write \`\`\`${/\b(dot|plantuml) fence/.exec(finding2.help ?? "")?.[1] ?? "mermaid"} alt="What the diagram shows" (\`alt\` is optional).`),
|
|
7724
8081
|
"markdown/diagram-source": wholeHelp,
|
|
7725
8082
|
"markdown/metric-block": (finding2) => keep2(finding2, `write ${code("key: value")} lines using ${METRIC_KEYS.join(", ")}; a value is plain text or a JSON string in double quotes.`),
|
|
7726
8083
|
"markdown/timeline-attributes": (finding2) => keep2(finding2, 'write ```timeline name="Roadmap" description="\u2026" (both are optional).'),
|
|
@@ -7795,8 +8152,8 @@ var SOURCE_EXPLAIN = {
|
|
|
7795
8152
|
"markdown/chart-attributes": entry("format", "error", "A chart fence has an attribute it cannot take.", "A chart fence takes `alt`, a text alternative in double quotes.", 'Write ```chart column alt="What the data shows".'),
|
|
7796
8153
|
"markdown/chart-data": entry("format", "error", "A chart fence has no usable data.", "The chart is drawn from CSV with a header row, or a JSON object with `columns` and `rows`.", "Write CSV with a header row and at least one data row."),
|
|
7797
8154
|
"markdown/chart-ragged": entry("format", "warning", "A chart row has a different number of values than the header.", "Missing cells plot as gaps.", "Give every row one value per column."),
|
|
7798
|
-
"markdown/diagram-attributes": entry("format", "error", "A
|
|
7799
|
-
"markdown/diagram-source": entry("format", "error", "A
|
|
8155
|
+
"markdown/diagram-attributes": entry("format", "error", "A diagram fence (mermaid, dot or plantuml) has an attribute it cannot take.", "A diagram fence takes `alt`, a text alternative in double quotes.", 'Write ```mermaid alt="What the diagram shows" (or ```dot alt=...).'),
|
|
8156
|
+
"markdown/diagram-source": entry("format", "error", "A diagram fence (mermaid, dot or plantuml) has no source.", "A diagram is drawn from its Mermaid, DOT or PlantUML source.", "Write the diagram between the fences: Mermaid starting with its type (`flowchart LR`, `sequenceDiagram`, `mindmap`, ...), DOT as one graph (`digraph { a -> b }`), PlantUML from `@startuml` to `@enduml`."),
|
|
7800
8157
|
"markdown/metric-block": entry("format", "error", "A metric fence is malformed.", "A metric is `key: value` lines using a fixed set of keys.", "Write `value:` and, if you like, `label:`, `unit:`, `delta:`, `trend:` and `sentiment:`.", "```metric\nlabel: Revenue\n```", "```metric\nvalue: 42\nlabel: Revenue\n```"),
|
|
7801
8158
|
"markdown/timeline-attributes": entry("format", "error", "A timeline fence has an attribute it cannot take.", "A timeline fence takes `name` and `description`.", "Remove the attribute, or use `name=` or `description=`."),
|
|
7802
8159
|
"markdown/timeline-description": entry("format", "error", "An indented line has no event above it.", "A description belongs to the event before it.", "Put the event first, then its description indented below it."),
|
|
@@ -7823,6 +8180,7 @@ var ID = "an id of lowercase letters, digits and hyphens that starts with a lett
|
|
|
7823
8180
|
var ID_NEXT = "use lowercase letters, digits and hyphens, and start with a letter.";
|
|
7824
8181
|
var LANGUAGE = "a language tag like `en-US` or `de`";
|
|
7825
8182
|
var PATTERN_PHRASES = Object.freeze({
|
|
8183
|
+
"\\S": { what: "a label with at least one non-whitespace character", next: "write a nonblank label, or omit it." },
|
|
7826
8184
|
"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$": { what: "a hex color like `#1F4E79` (3, 6 or 8 hex digits)", next: "write the color as #RRGGBB." },
|
|
7827
8185
|
"^[a-z][a-z0-9-]*$": { what: ID, next: ID_NEXT },
|
|
7828
8186
|
"^[a-z0-9][a-z0-9-]*$": { what: "an id of lowercase letters, digits and hyphens, like `my-chart`", next: ID_NEXT },
|
|
@@ -7952,7 +8310,8 @@ function describeSchema(finding2, context, helpers) {
|
|
|
7952
8310
|
const name = String(params2.additionalProperty ?? segments.at(-1) ?? "");
|
|
7953
8311
|
const parent = segments.slice(0, -1);
|
|
7954
8312
|
const allowed = schemaKeys(parent, context);
|
|
7955
|
-
const
|
|
8313
|
+
const suggested = finding2.suggestions?.[0]?.value;
|
|
8314
|
+
const hint = typeof suggested === "string" && allowed.includes(suggested) ? suggested : nearest(name, allowed).close[0];
|
|
7956
8315
|
return {
|
|
7957
8316
|
message: `${code(name)} is not a property of ${containerName(parent)}.`,
|
|
7958
8317
|
next: `${hint ? `did you mean ${code(hint)}? ` : ""}To keep custom data, put it under ${code("extensions")}.`.trim()
|
|
@@ -7974,6 +8333,9 @@ function describeSchema(finding2, context, helpers) {
|
|
|
7974
8333
|
case "exclusiveMinimum":
|
|
7975
8334
|
case "maximum":
|
|
7976
8335
|
case "exclusiveMaximum": {
|
|
8336
|
+
const key3 = segments.at(-1);
|
|
8337
|
+
if (keyword === "maximum" && segments.at(-2) === "at" && (key3 === "width" || key3 === "height") && finding2.fixes?.some((fix) => fix.id === "rename"))
|
|
8338
|
+
return { message: `${cap(label)} is a fraction of the block, at most ${params2.limit}, but is ${describeValue(actual)}.`, next: `did you mean ${code(`${key3}Px`)}? Rename the key to keep the size in pixels.` };
|
|
7977
8339
|
const bound = /minimum/i.test(keyword) ? "at least" : "at most";
|
|
7978
8340
|
return {
|
|
7979
8341
|
message: `${cap(label)} must be ${keyword.startsWith("exclusive") ? bound === "at least" ? "greater than" : "less than" : bound} ${params2.limit}, but is ${describeValue(actual)}.`,
|
|
@@ -8018,9 +8380,9 @@ function starterValue(document, segments, property) {
|
|
|
8018
8380
|
// src/schema-fixes.ts
|
|
8019
8381
|
var MAX_CHANGES = 5;
|
|
8020
8382
|
var patch = (id, title, operations, safe2 = false) => ({ id, title, kind: "patch", safe: safe2, patch: operations });
|
|
8021
|
-
var allowsKey = (document, segments,
|
|
8383
|
+
var allowsKey = (document, segments, key3) => {
|
|
8022
8384
|
try {
|
|
8023
|
-
return schemaVariants(schemaAtPath(document, segments)).some((variant) => Object.hasOwn(variant.properties ?? {},
|
|
8385
|
+
return schemaVariants(schemaAtPath(document, segments)).some((variant) => Object.hasOwn(variant.properties ?? {}, key3));
|
|
8024
8386
|
} catch {
|
|
8025
8387
|
return false;
|
|
8026
8388
|
}
|
|
@@ -8118,7 +8480,7 @@ function scriptProfile(presentation, slideIndex, options2, language) {
|
|
|
8118
8480
|
}
|
|
8119
8481
|
const slots = (role) => {
|
|
8120
8482
|
const latin = options2.fontFamilies[role];
|
|
8121
|
-
const slot = (
|
|
8483
|
+
const slot = (key3) => !resolved || resolved.sources[key3] === "latin" || resolved.sources[key3] === "schemeFamily" ? latin : resolved[role][key3] ?? latin;
|
|
8122
8484
|
return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
|
|
8123
8485
|
};
|
|
8124
8486
|
return {
|
|
@@ -8338,7 +8700,7 @@ function relax(value) {
|
|
|
8338
8700
|
walk2(copy);
|
|
8339
8701
|
return copy;
|
|
8340
8702
|
}
|
|
8341
|
-
function buildSlides(document, options2) {
|
|
8703
|
+
function buildSlides(document, options2, memo) {
|
|
8342
8704
|
const slides = Array.isArray(document.slides) ? document.slides : [];
|
|
8343
8705
|
return slides.map((slide, index) => {
|
|
8344
8706
|
const path = pointer2("slides", index);
|
|
@@ -8356,7 +8718,7 @@ function buildSlides(document, options2) {
|
|
|
8356
8718
|
});
|
|
8357
8719
|
const design = lazy(() => resolveDesign(document, index, resolved()));
|
|
8358
8720
|
const layout = lazy(() => resolved().options.layout);
|
|
8359
|
-
const
|
|
8721
|
+
const compute = () => {
|
|
8360
8722
|
const result = { layoutDiagnostics: [] };
|
|
8361
8723
|
let fontFamilies;
|
|
8362
8724
|
const compose = (input, withLayout) => {
|
|
@@ -8379,7 +8741,8 @@ function buildSlides(document, options2) {
|
|
|
8379
8741
|
} else result.layoutError = error instanceof Error ? error.message : String(error);
|
|
8380
8742
|
}
|
|
8381
8743
|
return result;
|
|
8382
|
-
}
|
|
8744
|
+
};
|
|
8745
|
+
const composed = lazy(() => memo ? memo(index, compute) : compute());
|
|
8383
8746
|
const payloads = lazy(() => slidePayloads(slide, path));
|
|
8384
8747
|
const texts = lazy(() => textValues(slide, path));
|
|
8385
8748
|
const rtl = lazy(() => {
|
|
@@ -8404,6 +8767,214 @@ function buildSlides(document, options2) {
|
|
|
8404
8767
|
});
|
|
8405
8768
|
}
|
|
8406
8769
|
|
|
8770
|
+
// src/validation-cache.ts
|
|
8771
|
+
var MAX_ENTRIES = 64;
|
|
8772
|
+
var MAX_BYTES = 8 * 1024 * 1024;
|
|
8773
|
+
var MAX_KEY_BYTES = 2 * 1024 * 1024;
|
|
8774
|
+
function key2(value, opaque) {
|
|
8775
|
+
let bytes = 0;
|
|
8776
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8777
|
+
const part = (text2) => {
|
|
8778
|
+
bytes += text2.length * 2;
|
|
8779
|
+
if (bytes > MAX_KEY_BYTES) throw new RangeError("Review cache key budget exceeded.");
|
|
8780
|
+
return text2;
|
|
8781
|
+
};
|
|
8782
|
+
const walk2 = (node, depth2) => {
|
|
8783
|
+
if (depth2 > 128) throw new RangeError("Review cache key depth exceeded.");
|
|
8784
|
+
if (node === null) return part("null;");
|
|
8785
|
+
if (node === void 0) return part("undefined;");
|
|
8786
|
+
if (typeof node === "string") return part(`s${JSON.stringify(node)}`);
|
|
8787
|
+
if (typeof node === "boolean") return part(node ? "true;" : "false;");
|
|
8788
|
+
if (typeof node === "number" && Number.isFinite(node)) return part(`n${Object.is(node, -0) ? "-0" : node};`);
|
|
8789
|
+
if (typeof node === "function" && opaque) {
|
|
8790
|
+
opaque.push(node);
|
|
8791
|
+
return part(`f${opaque.length};`);
|
|
8792
|
+
}
|
|
8793
|
+
if (typeof node !== "object" || seen.has(node) || !Array.isArray(node) && ![Object.prototype, null].includes(Object.getPrototypeOf(node))) throw new TypeError("Opaque review cache input.");
|
|
8794
|
+
seen.add(node);
|
|
8795
|
+
const descriptors = Object.getOwnPropertyDescriptors(node);
|
|
8796
|
+
if (Array.isArray(node) ? Reflect.ownKeys(node).length !== node.length + 1 || Object.keys(node).some((name, i) => name !== String(i)) : Object.values(descriptors).some((descriptor) => !descriptor.enumerable)) throw new TypeError("Non-JSON review cache input.");
|
|
8797
|
+
if (Reflect.ownKeys(node).some((name) => typeof name === "symbol") || Object.values(descriptors).some((descriptor) => !("value" in descriptor))) throw new TypeError("Opaque review cache input.");
|
|
8798
|
+
const result = Array.isArray(node) ? part("a[") + Array.from({ length: node.length }, (_, i) => Object.hasOwn(node, i) ? walk2(node[i], depth2 + 1) : part("hole;")).join("") + part("]") : part("o{") + Object.keys(node).map((name) => part(JSON.stringify(name)) + walk2(node[name], depth2 + 1)).join("") + part("}");
|
|
8799
|
+
seen.delete(node);
|
|
8800
|
+
return result;
|
|
8801
|
+
};
|
|
8802
|
+
return walk2(value, 0);
|
|
8803
|
+
}
|
|
8804
|
+
var hasCallable = (value) => typeof value === "function" || !!value && typeof value === "object" && Object.values(value).some(hasCallable);
|
|
8805
|
+
function boundedDependencyInput(value) {
|
|
8806
|
+
let bytes = 0;
|
|
8807
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8808
|
+
const charge = (count) => {
|
|
8809
|
+
bytes += count;
|
|
8810
|
+
if (bytes > MAX_KEY_BYTES) throw new RangeError("Dependency input budget exceeded.");
|
|
8811
|
+
};
|
|
8812
|
+
const walk2 = (node, depth2) => {
|
|
8813
|
+
if (depth2 > 128) throw new RangeError("Dependency input depth exceeded.");
|
|
8814
|
+
if (typeof node === "string") {
|
|
8815
|
+
charge(node.length * 2 + 8);
|
|
8816
|
+
return;
|
|
8817
|
+
}
|
|
8818
|
+
if (node === null || node === void 0 || typeof node === "boolean" || typeof node === "number" && Number.isFinite(node)) {
|
|
8819
|
+
charge(16);
|
|
8820
|
+
return;
|
|
8821
|
+
}
|
|
8822
|
+
if (typeof node !== "object" || seen.has(node)) throw new TypeError("Opaque dependency input.");
|
|
8823
|
+
const array = Array.isArray(node);
|
|
8824
|
+
if (array ? Object.getPrototypeOf(node) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(node))) throw new TypeError("Opaque dependency prototype.");
|
|
8825
|
+
seen.add(node);
|
|
8826
|
+
charge(16);
|
|
8827
|
+
const length = array ? Object.getOwnPropertyDescriptor(node, "length")?.value : 0;
|
|
8828
|
+
if (array && (!Number.isSafeInteger(length) || length < 0 || length * 8 > MAX_KEY_BYTES - bytes)) throw new RangeError("Dependency input count exceeded.");
|
|
8829
|
+
const names2 = Reflect.ownKeys(node);
|
|
8830
|
+
if (names2.length * 8 > MAX_KEY_BYTES - bytes || array && names2.length !== length + 1) throw new RangeError("Dependency input count exceeded.");
|
|
8831
|
+
let index = 0;
|
|
8832
|
+
for (const name of names2) {
|
|
8833
|
+
if (typeof name !== "string") throw new TypeError("Opaque dependency key.");
|
|
8834
|
+
const descriptor = Object.getOwnPropertyDescriptor(node, name);
|
|
8835
|
+
if (!descriptor || !("value" in descriptor)) throw new TypeError("Accessor dependency input.");
|
|
8836
|
+
if (array && name === "length") continue;
|
|
8837
|
+
if (!descriptor.enumerable || array && name !== String(index++)) throw new TypeError("Non-JSON dependency input.");
|
|
8838
|
+
charge(name.length * 2 + 8);
|
|
8839
|
+
walk2(descriptor.value, depth2 + 1);
|
|
8840
|
+
}
|
|
8841
|
+
seen.delete(node);
|
|
8842
|
+
};
|
|
8843
|
+
try {
|
|
8844
|
+
walk2(value, 0);
|
|
8845
|
+
return true;
|
|
8846
|
+
} catch {
|
|
8847
|
+
return false;
|
|
8848
|
+
}
|
|
8849
|
+
}
|
|
8850
|
+
function upstreamKey(slide, raw, conservative) {
|
|
8851
|
+
try {
|
|
8852
|
+
if (conservative || lonePayload(slide)?.field === "text") return raw;
|
|
8853
|
+
const notes = [];
|
|
8854
|
+
walkCitationRuns(slide, "", (entry2) => {
|
|
8855
|
+
notes.push([entry2.path, entry2.cite, entry2.footnote]);
|
|
8856
|
+
});
|
|
8857
|
+
return key2(["non-message-upstream", slide.section, slide.design, slide.layout, notes]);
|
|
8858
|
+
} catch {
|
|
8859
|
+
return raw;
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
function snapshotValue(value) {
|
|
8863
|
+
try {
|
|
8864
|
+
let candidate = value;
|
|
8865
|
+
const rootDescriptors = Object.getOwnPropertyDescriptors(value);
|
|
8866
|
+
const composition = rootDescriptors.composition;
|
|
8867
|
+
if (composition && "value" in composition && composition.value && Object.hasOwn(composition.value, HALF_STEPPED)) {
|
|
8868
|
+
const marker = Object.getOwnPropertyDescriptor(composition.value, HALF_STEPPED);
|
|
8869
|
+
const paths = marker && "value" in marker ? marker.value : void 0;
|
|
8870
|
+
if (marker?.enumerable && paths && typeof paths === "object" && Object.getPrototypeOf(paths) === Set.prototype && Reflect.ownKeys(paths).length === 0 && Array.from(Set.prototype.values.call(paths)).every((path) => typeof path === "string")) {
|
|
8871
|
+
const descriptors = Object.getOwnPropertyDescriptors(composition.value);
|
|
8872
|
+
Reflect.deleteProperty(descriptors, HALF_STEPPED);
|
|
8873
|
+
rootDescriptors.composition = { ...composition, value: Object.create(Object.getPrototypeOf(composition.value), descriptors) };
|
|
8874
|
+
candidate = Object.create(Object.getPrototypeOf(value), rootDescriptors);
|
|
8875
|
+
}
|
|
8876
|
+
}
|
|
8877
|
+
const encoded = key2(candidate);
|
|
8878
|
+
return { value: structuredClone(candidate), bytes: encoded.length * 4 + 256 };
|
|
8879
|
+
} catch {
|
|
8880
|
+
return void 0;
|
|
8881
|
+
}
|
|
8882
|
+
}
|
|
8883
|
+
var ValidationCompositionCache = class {
|
|
8884
|
+
snapshot;
|
|
8885
|
+
entries = /* @__PURE__ */ new Map();
|
|
8886
|
+
valueBytes = 0;
|
|
8887
|
+
get info() {
|
|
8888
|
+
return { entries: this.entries.size, bytes: (this.snapshot?.bytes ?? 0) + this.valueBytes, maxEntries: MAX_ENTRIES, maxBytes: MAX_BYTES };
|
|
8889
|
+
}
|
|
8890
|
+
clear() {
|
|
8891
|
+
this.snapshot = void 0;
|
|
8892
|
+
this.entries.clear();
|
|
8893
|
+
this.valueBytes = 0;
|
|
8894
|
+
}
|
|
8895
|
+
drop(index) {
|
|
8896
|
+
const entry2 = this.entries.get(index);
|
|
8897
|
+
if (entry2) this.valueBytes -= entry2.bytes;
|
|
8898
|
+
this.entries.delete(index);
|
|
8899
|
+
}
|
|
8900
|
+
trim() {
|
|
8901
|
+
while (this.entries.size > MAX_ENTRIES || this.info.bytes > MAX_BYTES) {
|
|
8902
|
+
const oldest = this.entries.keys().next().value;
|
|
8903
|
+
if (oldest === void 0) break;
|
|
8904
|
+
this.drop(oldest);
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
begin(document, options2) {
|
|
8908
|
+
let next;
|
|
8909
|
+
try {
|
|
8910
|
+
if (![Object.prototype, null].includes(Object.getPrototypeOf(document)) || Reflect.ownKeys(document).length !== Object.keys(document).length || Object.values(Object.getOwnPropertyDescriptors(document)).some((descriptor) => !("value" in descriptor))) throw new TypeError("Non-JSON review document.");
|
|
8911
|
+
const { slides, datasets, ...metadata } = document;
|
|
8912
|
+
const opaque = [];
|
|
8913
|
+
const ids = slides.map((slide) => slide.id);
|
|
8914
|
+
const rawContext = key2([metadata, ids, options2], opaque);
|
|
8915
|
+
const raw = slides.map((slide) => key2(slide));
|
|
8916
|
+
const inlined = datasets ? inlineDatasets({ datasets, slides }).slides : slides;
|
|
8917
|
+
const data = datasets ? inlined.map((slide) => key2(slide)) : raw;
|
|
8918
|
+
const otherOptions = Object.fromEntries(Object.entries(options2).filter(([name]) => name !== "fonts"));
|
|
8919
|
+
const conservative = metadata.variables !== void 0 || metadata.template === true || options2.values !== void 0 || options2.template !== void 0 || hasCallable(metadata) || hasCallable(otherOptions);
|
|
8920
|
+
const upstream = slides.map((slide, i) => upstreamKey(slide, raw[i], conservative));
|
|
8921
|
+
const bytes = 256 + rawContext.length * 2 + raw.reduce((sum, text2) => sum + text2.length * 2 + 32, 0) + (data === raw ? 0 : data.reduce((sum, text2) => sum + text2.length * 2 + 16, 0)) + upstream.reduce((sum, text2, i) => sum + (text2 === raw[i] ? 16 : text2.length * 2 + 16), 0) + opaque.length * 16;
|
|
8922
|
+
if (bytes > MAX_KEY_BYTES) throw new RangeError("Review cache shared key budget exceeded.");
|
|
8923
|
+
let context = rawContext;
|
|
8924
|
+
if (!conservative && metadata.template === void 0) {
|
|
8925
|
+
let nameUnused = false;
|
|
8926
|
+
try {
|
|
8927
|
+
if (boundedDependencyInput(document)) {
|
|
8928
|
+
key2(document);
|
|
8929
|
+
nameUnused = !hasBuiltinDependency(document, "deck.name");
|
|
8930
|
+
}
|
|
8931
|
+
} catch {
|
|
8932
|
+
}
|
|
8933
|
+
if (nameUnused) {
|
|
8934
|
+
const { name: _name, ...geometryMetadata } = metadata;
|
|
8935
|
+
context = key2([geometryMetadata, ids, options2], []);
|
|
8936
|
+
}
|
|
8937
|
+
}
|
|
8938
|
+
const previous = this.snapshot;
|
|
8939
|
+
const same = previous?.context === context && previous.opaque.length === opaque.length && opaque.every((value, i) => value === previous.opaque[i]);
|
|
8940
|
+
if (!same) this.clear();
|
|
8941
|
+
let prefixEqual = !!same;
|
|
8942
|
+
const prefix = upstream.map((text2, i) => {
|
|
8943
|
+
prefixEqual = prefixEqual && text2 === previous?.upstream[i];
|
|
8944
|
+
return prefixEqual && previous?.prefix[i] || /* @__PURE__ */ Symbol();
|
|
8945
|
+
});
|
|
8946
|
+
next = { context, opaque, raw, data, upstream, prefix, bytes };
|
|
8947
|
+
} catch {
|
|
8948
|
+
this.clear();
|
|
8949
|
+
return void 0;
|
|
8950
|
+
}
|
|
8951
|
+
this.snapshot = next;
|
|
8952
|
+
for (const [i, entry2] of this.entries) if (entry2.prefix !== next.prefix[i] || entry2.data !== next.data[i]) this.drop(i);
|
|
8953
|
+
this.trim();
|
|
8954
|
+
return (index, compute) => {
|
|
8955
|
+
if (this.snapshot !== next) return compute();
|
|
8956
|
+
const hit = this.entries.get(index);
|
|
8957
|
+
if (hit) {
|
|
8958
|
+
this.entries.delete(index);
|
|
8959
|
+
this.entries.set(index, hit);
|
|
8960
|
+
return structuredClone(hit.value);
|
|
8961
|
+
}
|
|
8962
|
+
const value = compute();
|
|
8963
|
+
const saved = !value.layoutError && !value.layoutDiagnostics.some((entry2) => entry2.strict) && snapshotValue(value);
|
|
8964
|
+
const data = next.data[index], prefix = next.prefix[index];
|
|
8965
|
+
if (saved && data !== void 0 && prefix !== void 0 && this.snapshot === next) {
|
|
8966
|
+
const bytes = saved.bytes + data.length * 2 + 64;
|
|
8967
|
+
if (bytes + next.bytes <= MAX_BYTES) {
|
|
8968
|
+
this.entries.set(index, { prefix, data, value: saved.value, bytes });
|
|
8969
|
+
this.valueBytes += bytes;
|
|
8970
|
+
this.trim();
|
|
8971
|
+
}
|
|
8972
|
+
}
|
|
8973
|
+
return value;
|
|
8974
|
+
};
|
|
8975
|
+
}
|
|
8976
|
+
};
|
|
8977
|
+
|
|
8407
8978
|
// src/validator.ts
|
|
8408
8979
|
var SEVERITIES = ["error", "warning", "info"];
|
|
8409
8980
|
var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values"];
|
|
@@ -8441,7 +9012,7 @@ function names(list, what) {
|
|
|
8441
9012
|
}
|
|
8442
9013
|
function resolveOptions(options2) {
|
|
8443
9014
|
if (!isObject2(options2)) throw new TypeError("Validate options must be an object.");
|
|
8444
|
-
for (const
|
|
9015
|
+
for (const key3 of Object.keys(options2)) if (!OPTION_KEYS.includes(key3)) throw new TypeError(`Unknown validate option ${JSON.stringify(key3)}. Options: ${OPTION_KEYS.join(", ")}.`);
|
|
8445
9016
|
checkDocumentOptions(options2);
|
|
8446
9017
|
const only = names(options2.only, "only");
|
|
8447
9018
|
const ignore = names(options2.ignore, "ignore");
|
|
@@ -8470,10 +9041,10 @@ function resolveOptions(options2) {
|
|
|
8470
9041
|
const thresholds = { ...DEFAULT_VALIDATION_THRESHOLDS };
|
|
8471
9042
|
if (options2.thresholds !== void 0) {
|
|
8472
9043
|
if (!isObject2(options2.thresholds)) throw new TypeError("Validate thresholds must be an object.");
|
|
8473
|
-
for (const [
|
|
8474
|
-
if (!(
|
|
8475
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new TypeError(`Validate threshold ${
|
|
8476
|
-
thresholds[
|
|
9044
|
+
for (const [key3, value] of Object.entries(options2.thresholds)) {
|
|
9045
|
+
if (!(key3 in DEFAULT_VALIDATION_THRESHOLDS)) throw new TypeError(`Unknown validate threshold ${JSON.stringify(key3)}. Thresholds: ${Object.keys(DEFAULT_VALIDATION_THRESHOLDS).join(", ")}.`);
|
|
9046
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new TypeError(`Validate threshold ${key3} must be a positive number.`);
|
|
9047
|
+
thresholds[key3] = value;
|
|
8477
9048
|
}
|
|
8478
9049
|
}
|
|
8479
9050
|
if (options2.fonts !== void 0) {
|
|
@@ -8538,7 +9109,7 @@ function syntaxReport(parsed, run) {
|
|
|
8538
9109
|
const tally = counts(findings);
|
|
8539
9110
|
return { valid: tally.error === 0, schemaValid: null, findings, counts: tally, checks };
|
|
8540
9111
|
}
|
|
8541
|
-
function validateDocument(document, run, parsed) {
|
|
9112
|
+
function validateDocument(document, run, parsed, cache) {
|
|
8542
9113
|
const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {} });
|
|
8543
9114
|
const schemaValid = engine.errors.length === 0;
|
|
8544
9115
|
const slides = isObject2(document) && Array.isArray(document.slides) ? document.slides : [];
|
|
@@ -8567,7 +9138,7 @@ function validateDocument(document, run, parsed) {
|
|
|
8567
9138
|
const doc = document;
|
|
8568
9139
|
const context = {
|
|
8569
9140
|
document: doc,
|
|
8570
|
-
slides: buildSlides(doc, run.options),
|
|
9141
|
+
slides: buildSlides(doc, run.options, cache?.begin(doc, run.options)),
|
|
8571
9142
|
thresholds: run.thresholds,
|
|
8572
9143
|
options: run.options,
|
|
8573
9144
|
chartPalette: run.chartPalette,
|
|
@@ -8646,12 +9217,34 @@ function validateDocument(document, run, parsed) {
|
|
|
8646
9217
|
};
|
|
8647
9218
|
}
|
|
8648
9219
|
function validate(input, options2 = {}) {
|
|
9220
|
+
return validateInput(input, options2);
|
|
9221
|
+
}
|
|
9222
|
+
function validateInput(input, options2, cache) {
|
|
8649
9223
|
const run = resolveOptions(options2);
|
|
8650
9224
|
if (typeof input === "string") {
|
|
8651
9225
|
const parsed = parseSource(input);
|
|
8652
|
-
return parsed.syntax.length ? syntaxReport(parsed, run) : validateDocument(parsed.value, run, parsed);
|
|
9226
|
+
return parsed.syntax.length ? syntaxReport(parsed, run) : validateDocument(parsed.value, run, parsed, cache);
|
|
8653
9227
|
}
|
|
8654
|
-
return validateDocument(input, run);
|
|
9228
|
+
return validateDocument(input, run, void 0, cache);
|
|
9229
|
+
}
|
|
9230
|
+
function createValidator() {
|
|
9231
|
+
const cache = new ValidationCompositionCache();
|
|
9232
|
+
return {
|
|
9233
|
+
validate(input, options2 = {}) {
|
|
9234
|
+
try {
|
|
9235
|
+
const report2 = validateInput(input, options2, cache);
|
|
9236
|
+
if (!report2.schemaValid) cache.clear();
|
|
9237
|
+
return report2;
|
|
9238
|
+
} catch (error) {
|
|
9239
|
+
cache.clear();
|
|
9240
|
+
throw error;
|
|
9241
|
+
}
|
|
9242
|
+
},
|
|
9243
|
+
clear: () => cache.clear(),
|
|
9244
|
+
get cache() {
|
|
9245
|
+
return cache.info;
|
|
9246
|
+
}
|
|
9247
|
+
};
|
|
8655
9248
|
}
|
|
8656
9249
|
function assertValid(value, options2 = {}) {
|
|
8657
9250
|
if (typeof value === "string") throw new TypeError("assertValid takes a parsed presentation. Use validate(text) for JSON text.");
|
|
@@ -8681,4 +9274,4 @@ function assertValidCatalogRecord(kind, value) {
|
|
|
8681
9274
|
if (!report2.valid) throw new OPFValidationError(report2);
|
|
8682
9275
|
}
|
|
8683
9276
|
|
|
8684
|
-
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, describeField, describeFinding, distance2 as distance, documentHash, escapePointerToken, findValidationRule, formatPointer, getAtPointer, hasPointer, idToken, invertPatch, isIdToken, isPromotedRegionKey, jsonEqual, listSchemaFields, nearest, normalizePatch, parsePointer, parseSource, pointerFromPath, readPointer, rememberByText, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, us, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
|
|
9277
|
+
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, distance2 as distance, documentHash, escapePointerToken, findValidationRule, formatPointer, getAtPointer, hasPointer, idToken, invertPatch, isIdToken, isPromotedRegionKey, jsonEqual, listSchemaFields, nearest, normalizePatch, parsePointer, parseSource, pointerFromPath, readPointer, rememberByText, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, us, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
|