@openpresentation/opf 0.36.0 → 0.37.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/THIRD-PARTY-NOTICES.md +99 -0
- package/dist/browser.js +19 -19
- package/dist/{catalog-refs-BgotJhR5.d.ts → catalog-refs-BeRgtpZS.d.ts} +4 -4
- package/dist/{catalog-schemas-BX-VEc5Q.d.ts → catalog-schemas-CwY-3cCP.d.ts} +1 -1
- package/dist/{chunk-6WVPFWPD.js → chunk-434E2RWO.js} +4 -4
- package/dist/{chunk-OFL3WY6F.js → chunk-63Y75CCK.js} +77 -15
- package/dist/{chunk-O65COLKF.js → chunk-BPILTZUJ.js} +118 -19
- package/dist/{chunk-4FA4AZXY.js → chunk-DDD4WUEH.js} +2375 -825
- package/dist/{chunk-MS2LPR7F.js → chunk-DMV3G65U.js} +1 -1
- package/dist/{chunk-AZELWKG2.js → chunk-EHYAVRL3.js} +5 -4
- package/dist/{chunk-7JE3XTL7.js → chunk-HBO64RWP.js} +4 -4
- package/dist/{chunk-J7FUSZZ5.js → chunk-HOK3DZA6.js} +6 -6
- package/dist/chunk-I4NQP7Z4.js +1 -0
- package/dist/{chunk-2NIID3QD.js → chunk-ITGR2RW2.js} +6 -6
- package/dist/chunk-IW4TXMJY.js +646 -0
- package/dist/{chunk-SER6GJTT.js → chunk-KB7TPZQI.js} +23 -6
- package/dist/{chunk-VDZXNNZF.js → chunk-M4IPCFDV.js} +1 -1
- package/dist/{chunk-F5SY7MSA.js → chunk-MNJ4JV7I.js} +1 -1
- package/dist/{chunk-XRMYP4JD.js → chunk-ORVMHVOS.js} +86 -2
- package/dist/{chunk-BPSZ7OWD.js → chunk-PDBZN7EJ.js} +26 -21
- package/dist/{chunk-3KPTVK77.js → chunk-Q2L5ERNK.js} +1248 -120
- package/dist/{chunk-HHQROUYC.js → chunk-QFT4R2IL.js} +4405 -2808
- package/dist/chunk-QQBOI5XI.js +86 -0
- package/dist/{chunk-TJMESSBQ.js → chunk-SIF5JDZC.js} +109 -9
- package/dist/{chunk-GNKOQ6NA.js → chunk-XY332BQP.js} +4 -4
- package/dist/{chunk-APCNAAA7.js → chunk-ZB427MLO.js} +2 -2
- package/dist/{composition-CSM7YfBl.d.ts → composition-DiKC371V.d.ts} +707 -134
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +1 -1
- package/dist/{conversion-CL7ipVGO.d.ts → conversion-DBkC9Y2e.d.ts} +6 -6
- package/dist/conversion-P56LOOE2.js +25 -0
- package/dist/convert.d.ts +5 -5
- package/dist/convert.js +63 -23
- package/dist/data.d.ts +41 -3
- package/dist/data.js +2 -2
- package/dist/{deck-report-DhsB0SUz.d.ts → deck-report-BwgsIRAf.d.ts} +3 -3
- package/dist/deck.d.ts +6 -6
- package/dist/deck.js +11 -11
- package/dist/diff.js +4 -4
- package/dist/docs.js +43 -31
- package/dist/examples.js +2338 -392
- package/dist/font-policy.js +1 -1
- package/dist/format.js +2 -2
- package/dist/ids.d.ts +17 -4
- package/dist/ids.js +4 -4
- package/dist/index.d.ts +140 -23
- package/dist/index.js +22 -22
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +8 -8
- package/dist/metric-data-B4Q8RFRR.d.ts +382 -0
- package/dist/node-engine.d.ts +6 -6
- package/dist/node-engine.js +21 -21
- package/dist/{pagination-BSqq32xt.d.ts → pagination-C9qnH_n-.d.ts} +5 -5
- package/dist/pagination.d.ts +4 -4
- package/dist/pagination.js +4 -4
- package/dist/patch.js +3 -3
- package/dist/precompiled.js +2 -2
- package/dist/{presentation-Dx-kZC8Y.d.ts → presentation-DmOhusrX.d.ts} +541 -110
- package/dist/schema-engine-ajv.js +1 -1
- package/dist/schema-engine-precompiled.js +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +3 -3
- package/dist/schemas.d.ts +46 -2
- package/dist/schemas.js +1 -1
- package/dist/shape-engine-eager.js +2 -2
- package/dist/shape-engine-lazy.js +1 -1
- package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
- package/dist/shape-geometry.js +1 -1
- package/dist/source.js +10 -11
- package/dist/spec/reference/engine-defaults.json +1 -1
- package/dist/spec/reference/engine-vocabularies.json +1 -0
- package/dist/spec/schemas/font-scheme.schema.json +9 -7
- package/dist/spec/schemas/layout.schema.json +5 -4
- package/dist/spec/schemas/narrative.schema.json +1 -0
- package/dist/spec/schemas/opf.schema.json +661 -98
- package/dist/types.d.ts +16 -12
- package/dist/{validation-types-bnrso0JL.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
- package/dist/validator.d.ts +5 -5
- package/dist/validator.js +3 -3
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +7 -7
- package/package.json +7 -6
- package/dist/chart-data-B_k-WTex.d.ts +0 -194
- package/dist/chunk-6VGLE7C5.js +0 -3983
- package/dist/chunk-SEC4IOOS.js +0 -1
- package/dist/chunk-WCPDN7AY.js +0 -642
- package/dist/conversion-FTGQLJK7.js +0 -25
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defaultCatalogs } from './chunk-XJUMFH33.js';
|
|
2
|
-
import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-
|
|
3
|
-
import { paginate, continueOverfull } from './chunk-
|
|
4
|
-
import { deckFormatOf, readDeckReport, stringify } from './chunk-
|
|
5
|
-
import { validate, OPFValidationError } from './chunk-
|
|
6
|
-
import { ensureIcons } from './chunk-
|
|
2
|
+
import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-BPILTZUJ.js';
|
|
3
|
+
import { paginate, continueOverfull } from './chunk-PDBZN7EJ.js';
|
|
4
|
+
import { deckFormatOf, readDeckReport, stringify } from './chunk-XY332BQP.js';
|
|
5
|
+
import { validate, OPFValidationError } from './chunk-DDD4WUEH.js';
|
|
6
|
+
import { ensureIcons } from './chunk-QFT4R2IL.js';
|
|
7
7
|
import { link, stat, readdir, lstat, readFile, open, unlink, mkdir, rename } from 'fs/promises';
|
|
8
8
|
import path6 from 'path';
|
|
9
9
|
import { readFileSync, statSync, realpathSync } from 'fs';
|
|
@@ -131,7 +131,7 @@ function iconSourceReader(root, resolver = createImageResolver(root, { add() {
|
|
|
131
131
|
}
|
|
132
132
|
var RENDER_PACKAGE = "@openpresentation/opf-render";
|
|
133
133
|
var PPTX_PACKAGE = "@openpresentation/opf-pptx";
|
|
134
|
-
var PEER_RANGES = { [RENDER_PACKAGE]: "^0.
|
|
134
|
+
var PEER_RANGES = { [RENDER_PACKAGE]: "^0.37.1", [PPTX_PACKAGE]: "^0.37.1" };
|
|
135
135
|
var PPTX_TEXT_OPTIONS_FROM = "0.22.0";
|
|
136
136
|
var numbers = (version) => version.replace(/[-+].*$/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
137
137
|
function atLeast(version, minimum) {
|
|
@@ -561,7 +561,15 @@ var HELP = {
|
|
|
561
561
|
"chart-map-geodata": "PowerPoint fetches the region shapes of a map chart from its online map service, so the chart draws only when it is online. Use another chart type if the deck must open offline.",
|
|
562
562
|
"chart-reference-overlay": "These reference lines and labels are editable shapes over the chart, not part of it: they do not follow the chart when it is moved or its data or axis is edited in PowerPoint. To change a reference line, change it in the OPF source and export again.",
|
|
563
563
|
"chart-mapping-adapted": "The chart's data mapping was adapted to draw the chart (the message says how). Choose a chart type or mapping that fits the data if the result is not what you meant.",
|
|
564
|
+
"text-contrast": "A band label stays below 4.5:1 on its band even in the primary text color, so it is hard to read. Choose a lighter scheme color for that band, or leave its color to the neutrals.",
|
|
565
|
+
"chart-bands-order": "The bands are not in increasing order of their to values; every engine draws them sorted. Write them in increasing order.",
|
|
566
|
+
"chart-bands-unsupported": "This chart type does not draw bands, so they are ignored. Use a bar, column, line, area or bullet chart, or remove the bands.",
|
|
567
|
+
"metric-gauge-range": "The gauge's range is empty, or its value, target or a band lies outside it. Write max above min and keep the rest between them; a value outside still prints its real number.",
|
|
568
|
+
"metric-gauge-value": "A gauge draws a number, and this metric's value is text, so it is drawn without its gauge. Give it a number value or remove the gauge.",
|
|
569
|
+
"metric-gauge-dropped": "The metric's region is too small for a gauge, so it is drawn as a plain metric. Give it a larger region to draw the gauge.",
|
|
564
570
|
"chart-highlight-adapted": "The highlight names a column that is not plotted as a series, so it was adapted (the message says how). Name a plotted series or a category, or remove the entry.",
|
|
571
|
+
"table-color-scale-no-data": "None of the color scale's columns holds a number, so no cell is shaded. Name columns that hold numbers, or remove the scale.",
|
|
572
|
+
"table-color-scale-range": "The color scale's pinned range is empty or its center lies outside it. Pin min below max and keep center between them, or leave the range to the data.",
|
|
565
573
|
"variable-example-used": "The template variable has no value, so its example was exported. Supply a value for it when exporting if the example should not ship.",
|
|
566
574
|
"variable-builtin-missing": "The token's deck, speaker or organization field is not set, so it exports as a gap (or no logo). Set that field in the deck, or remove the token.",
|
|
567
575
|
"furniture-date-fixed": "The date was exported as fixed text that PowerPoint will not update: its dateFormat is not one of PowerPoint's date field formats for the deck language (or en-US). Use one of those formats for a live date, or accept the fixed text.",
|
|
@@ -586,6 +594,7 @@ var HELP = {
|
|
|
586
594
|
"invalid-card-provenance": INVALID_TAG,
|
|
587
595
|
"invalid-code-provenance": INVALID_TAG,
|
|
588
596
|
"invalid-data-provenance": INVALID_TAG,
|
|
597
|
+
"embed-provenance-changed": "The embed was imported as what the file shows (a linked picture, or its shapes): its link, picture or title text was changed after the export, so the stored embed no longer matches. Add the embed again in OPF, or restore the link and picture in PowerPoint.",
|
|
589
598
|
"invalid-diagram-provenance": INVALID_TAG,
|
|
590
599
|
"invalid-document-provenance": INVALID_TAG,
|
|
591
600
|
"invalid-furniture-provenance": INVALID_TAG,
|
|
@@ -623,17 +632,22 @@ var HELP = {
|
|
|
623
632
|
"reference-text-changed": EDITED,
|
|
624
633
|
"chart-data-provenance-changed": EDITED,
|
|
625
634
|
"table-data-provenance-changed": EDITED,
|
|
635
|
+
"table-color-scale-not-restored": "A shaded cell was refilled in PowerPoint (or a column the scale names is gone), so the table imports its cell fills as plain fills and the color scale is not restored. Nothing needs to change if the new fills are wanted; to keep the scale, remove the fill you added or change the table in the OPF source and export again.",
|
|
626
636
|
"design-reference-changed": EDITED,
|
|
627
637
|
"layout-reference-changed": EDITED,
|
|
628
638
|
"list-line-break-changed": EDITED,
|
|
629
639
|
"list-line-role-changed": EDITED,
|
|
630
640
|
"list-scalar-reference-changed": EDITED,
|
|
641
|
+
"entry-ids-not-restored": EDITED,
|
|
631
642
|
"slide-reference-changed": EDITED,
|
|
632
643
|
"content-structure-changed": EDITED,
|
|
633
644
|
"metadata-reference-changed": EDITED,
|
|
634
645
|
"color-reference-changed": EDITED,
|
|
635
646
|
"media-source-changed": EDITED,
|
|
636
647
|
"metric-value-type-changed": EDITED,
|
|
648
|
+
"metric-data-dropped": EDITED,
|
|
649
|
+
"metric-gauge-not-restored": EDITED,
|
|
650
|
+
"metric-link-omitted": "The PPTX is written with partial or no provenance, so the metric's data link, direction and number format are not stored in it: reimport shows the numbers as drawn. To keep them, export with full provenance (the default).",
|
|
637
651
|
"quote-footer-merged": EDITED,
|
|
638
652
|
"chart-dataset-unavailable": "The chart's values were imported inline, without its dataset reference: the package's datasets record lacks that dataset or holds other data (as after pasting the slide from another deck). Point the chart at the dataset again in OPF if it should follow it.",
|
|
639
653
|
"table-dataset-unavailable": "The table's cells were imported inline, without its dataset reference, because the package's datasets record lacks that dataset. Point the table at the dataset again in OPF if it should follow it.",
|
|
@@ -651,6 +665,9 @@ var HELP = {
|
|
|
651
665
|
"chart-point-series-uncertain": "The series the export split off so that PowerPoint's legend names the chart's one series were moved, removed or edited, so the chart imports as the file holds it (separate series, or gaps where the points of a removed series were) and the highlight is not restored. Fix the chart data in OPF (merge the extra series back, or fill the gaps) and set its highlight again, or export the original OPF source again.",
|
|
652
666
|
"chart-number-format-adapted": "The values were imported as numbers without their PowerPoint number format, which has no OPF equivalent. Set a format on that column of the chart data in OPF if the display matters.",
|
|
653
667
|
"chart-option-adapted": "The chart option at this path was adapted (the message says how): on export to what the chart can draw, on import to what OPF can express. Change the option in OPF if the difference matters.",
|
|
668
|
+
"chart-cache-repaired": "The chart's cached data declared fewer points than its highest point index needs (Keynote writes this for a series with a gap), so the points were read at their own indexes and the missing positions are gaps. Nothing is needed unless a value looks wrong: then fix that cell in the chart data.",
|
|
669
|
+
"chart-categories-flattened": "The chart's category cache came in several levels (Keynote splits labels such as 'Month: place' at the colon), so each category was read as one label (the message says whether the cached whole label or the joined levels). Check the labels, and edit them in the chart data in OPF if a separator is wrong.",
|
|
670
|
+
"chart-unreadable": "The chart's cached data could not be read, so the chart was imported as a text placeholder and the rest of the deck as usual (the message names the reason). Repair the chart's data in the source application and import again, or recreate the chart in OPF.",
|
|
654
671
|
"chart-value-not-numeric": "Each value that is not a number is plotted as a gap, never guessed. In an OPF deck, write chart values as numbers and put currency, percent and units in the column format; in a PPTX, make the chart's cached values numbers (Edit Data in PowerPoint).",
|
|
655
672
|
"unsupported-background-fill": "The slide's PowerPoint background was not imported (the message says why: an unresolved style or theme color, a pattern without a DrawingML preset and colors, or another fill). Set the background in the imported OPF as a color, gradient, pattern or image.",
|
|
656
673
|
"unsupported-background-image": "Embed the background as a PNG, JPEG, GIF or WebP picture in the PPTX (not linked), or set it in OPF.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { presetGeometry, presetAdjustments, isPresetShape, flattenShapePath, evaluateGuideFormula, customGeometry, adjustToDrawingML, adjustFromDrawingML, PRESET_SHAPES } from './chunk-
|
|
1
|
+
import { presetGeometry, presetAdjustments, isPresetShape, flattenShapePath, evaluateGuideFormula, customGeometry, adjustToDrawingML, adjustFromDrawingML, PRESET_SHAPES } from './chunk-IW4TXMJY.js';
|
|
2
2
|
import { __export } from './chunk-PRXZD2II.js';
|
|
3
3
|
|
|
4
4
|
// src/shape-engine-module.ts
|
|
@@ -1,4 +1,88 @@
|
|
|
1
|
-
import { chartNumber } from './chunk-
|
|
1
|
+
import { isTimeLabel, resolveMetric, chartNumber } from './chunk-QFT4R2IL.js';
|
|
2
|
+
|
|
3
|
+
// src/metric-literals.ts
|
|
4
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
var MAX_DEPTH = 32;
|
|
6
|
+
function updateMetricLiterals(document) {
|
|
7
|
+
if (!isRecord(document) || !Array.isArray(document.slides) || !isRecord(document.datasets)) return document;
|
|
8
|
+
const edits = [];
|
|
9
|
+
const language = typeof document.language === "string" ? { language: document.language } : {};
|
|
10
|
+
const walk = (payload, path, depth, ancestors) => {
|
|
11
|
+
if (isRecord(payload.metric) && isRecord(payload.metric.data)) {
|
|
12
|
+
for (const entry of resolveMetric(payload.metric, document, { path: `${path}/metric`, ...language }).diagnostics)
|
|
13
|
+
for (const patch of entry.fix?.patch ?? []) edits.push({ keys: patch.path.split("/").slice(1).map((key) => key.replaceAll("~1", "/").replaceAll("~0", "~")), value: patch.value });
|
|
14
|
+
}
|
|
15
|
+
if (depth >= MAX_DEPTH || ancestors.includes(payload) || !Array.isArray(payload.blocks)) return;
|
|
16
|
+
payload.blocks.forEach((block, index) => {
|
|
17
|
+
if (isRecord(block)) walk(block, `${path}/blocks/${index}`, depth + 1, [...ancestors, payload]);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
document.slides.forEach((slide, index) => {
|
|
21
|
+
if (isRecord(slide)) walk(slide, `/slides/${index}`, 0, []);
|
|
22
|
+
});
|
|
23
|
+
if (!edits.length) return document;
|
|
24
|
+
const copy = structuredClone(document);
|
|
25
|
+
for (const edit of edits) {
|
|
26
|
+
let at = copy;
|
|
27
|
+
for (const key of edit.keys.slice(0, -1)) at = Array.isArray(at) ? at[Number(key)] : isRecord(at) ? at[key] : void 0;
|
|
28
|
+
if (isRecord(at)) at[edit.keys[edit.keys.length - 1]] = edit.value;
|
|
29
|
+
}
|
|
30
|
+
return copy;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/column-inference.ts
|
|
34
|
+
var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35
|
+
var blank = (cell2) => cell2 === null || cell2 === void 0 || typeof cell2 === "string" && cell2.trim() === "";
|
|
36
|
+
function losslessNumber(text) {
|
|
37
|
+
const trimmed = text.trim();
|
|
38
|
+
const number = chartNumber(trimmed);
|
|
39
|
+
return number !== null && String(number) === trimmed ? number : void 0;
|
|
40
|
+
}
|
|
41
|
+
var numberLike = (cell2) => typeof cell2 === "string" && chartNumber(cell2) !== null && losslessNumber(cell2) === void 0;
|
|
42
|
+
var isNumberCell = (cell2) => typeof cell2 === "number" && Number.isFinite(cell2) || typeof cell2 === "string" && losslessNumber(cell2) !== void 0;
|
|
43
|
+
var isBooleanCell = (cell2) => typeof cell2 === "boolean" || cell2 === "true" || cell2 === "false";
|
|
44
|
+
function inferColumnDeclaration(cells, options = {}) {
|
|
45
|
+
const filled = cells.filter((cell2) => !blank(cell2));
|
|
46
|
+
if (!filled.length) return void 0;
|
|
47
|
+
if (filled.every(isNumberCell)) {
|
|
48
|
+
const time = filled.every((cell2) => isTimeLabel(cell2, options.language));
|
|
49
|
+
return { type: "number", role: options.first || time ? "dimension" : "measure" };
|
|
50
|
+
}
|
|
51
|
+
if (filled.some(numberLike)) return void 0;
|
|
52
|
+
if (filled.every(isBooleanCell) && filled.some((cell2) => typeof cell2 === "boolean" || cell2 === "true" || cell2 === "false")) return { type: "boolean", role: "dimension" };
|
|
53
|
+
if (filled.every((cell2) => typeof cell2 === "string" && isTimeLabel(cell2, options.language))) return { type: "date", role: "dimension" };
|
|
54
|
+
if (filled.every((cell2) => typeof cell2 === "string")) return { type: "text", role: "dimension" };
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
function storeCell(cell2, type) {
|
|
58
|
+
if (type === void 0 || type === "text") return cell2;
|
|
59
|
+
if (blank(cell2)) return null;
|
|
60
|
+
if (type === "number" && typeof cell2 === "string") return losslessNumber(cell2) ?? cell2;
|
|
61
|
+
if (type === "boolean" && (cell2 === "true" || cell2 === "false")) return cell2 === "true";
|
|
62
|
+
return cell2;
|
|
63
|
+
}
|
|
64
|
+
function declareColumns(data, previous = [], options = {}) {
|
|
65
|
+
const known = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const column of previous) {
|
|
67
|
+
if (typeof column === "string") known.set(column, column);
|
|
68
|
+
else if (record(column) && typeof column.name === "string") known.set(column.name, column);
|
|
69
|
+
}
|
|
70
|
+
const columns = [];
|
|
71
|
+
const types = [];
|
|
72
|
+
data.columns.forEach((name, index) => {
|
|
73
|
+
const before = known.get(name);
|
|
74
|
+
if (before !== void 0) {
|
|
75
|
+
columns.push(structuredClone(before));
|
|
76
|
+
const type = record(before) && typeof before.type === "string" ? before.type : void 0;
|
|
77
|
+
types.push(type);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const inferred = inferColumnDeclaration(data.rows.map((row) => row[index]), { first: index === 0, language: options.language });
|
|
81
|
+
columns.push(inferred ? { name, type: inferred.type, role: inferred.role } : name);
|
|
82
|
+
types.push(inferred?.type);
|
|
83
|
+
});
|
|
84
|
+
return { columns, rows: data.rows.map((row) => row.map((cell2, index) => storeCell(cell2, types[index]))) };
|
|
85
|
+
}
|
|
2
86
|
|
|
3
87
|
// src/data.ts
|
|
4
88
|
var OPFDataImportError = class extends Error {
|
|
@@ -144,4 +228,4 @@ function ingest(input, options) {
|
|
|
144
228
|
} } };
|
|
145
229
|
}
|
|
146
230
|
|
|
147
|
-
export { OPFDataImportError, ingest, parseTabularData };
|
|
231
|
+
export { OPFDataImportError, declareColumns, inferColumnDeclaration, ingest, parseTabularData, storeCell, updateMetricLiterals };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertValid, resolveSlideScriptMeasurement, resolveDrawnFontFamilies, resolveSlideContext } from './chunk-
|
|
2
|
-
import { composeSlide, resolveSlideVariables, slideBlockIds, cellBlocks, OPFCompositionError, checkCatalogsOption, usesSlideBuiltin, isOverlayConnector, codeHighlightSlice, tableRowBoundaries, visitContentPayloads, layoutTable, regionAccepts, slideTokenSpans, sliceNumberedItems, isShapeBlock } from './chunk-
|
|
1
|
+
import { assertValid, resolveSlideScriptMeasurement, resolveDrawnFontFamilies, resolveSlideContext } from './chunk-DDD4WUEH.js';
|
|
2
|
+
import { composeSlide, resolveSlideVariables, slideBlockIds, cellBlocks, OPFCompositionError, checkCatalogsOption, usesSlideBuiltin, isOverlayConnector, codeHighlightSlice, tableRowBoundaries, pinTableColorScale, visitContentPayloads, layoutTable, regionAccepts, slideTokenSpans, sliceNumberedItems, isShapeBlock } from './chunk-QFT4R2IL.js';
|
|
3
3
|
|
|
4
4
|
// src/continuation-fonts.ts
|
|
5
5
|
var record = (value) => value && typeof value === "object" ? value : {};
|
|
@@ -10,7 +10,7 @@ function continuationFonts(composed, options = {}, sourcePath = (path) => path)
|
|
|
10
10
|
for (const item of composed.items) {
|
|
11
11
|
if (["title", "subtitle", "tag"].includes(item.field) || item.eyebrow) continue;
|
|
12
12
|
const kind = item.field === "items" || item.field === "bullets" ? "list" : item.field;
|
|
13
|
-
const constraints = JSON.stringify([item.composition.
|
|
13
|
+
const constraints = JSON.stringify([item.composition.minFontSizePx ?? 16, item.composition.maxFontSizePx ?? null]);
|
|
14
14
|
const add = (size, part, role, style, run = {}, automatic = true) => {
|
|
15
15
|
if (!Number.isFinite(size) || size <= 0) return;
|
|
16
16
|
const family = record(style).sourceFontFamily ?? record(style).fontFamily;
|
|
@@ -48,7 +48,7 @@ function continuationFonts(composed, options = {}, sourcePath = (path) => path)
|
|
|
48
48
|
fit(part.fit, String(part.path).slice(item.path.length), part.role, part.style);
|
|
49
49
|
}
|
|
50
50
|
else if (item.field === "table") {
|
|
51
|
-
const table = layoutTable(item.value, item.box, { scale,
|
|
51
|
+
const table = layoutTable(item.value, item.box, { scale, minFontSizePx: item.composition.minFontSizePx, fontFamily: options.fontFamilies?.body, ...options.fontFamilies?.code ? { codeFontFamily: options.fontFamilies.code } : {}, textMeasurement: options.textMeasurement, path: item.path, presentation: options.presentation, ...item.tableGrowth ? { growth: item.tableGrowth } : {} });
|
|
52
52
|
for (const [rowIndex, row] of table.rows.entries()) for (const [columnIndex, cell] of row.cells.entries()) fit(cell.fit, `cell.${rowIndex}.${columnIndex}`, "cell", item.textStyle);
|
|
53
53
|
} else if (item.listColumns?.length) {
|
|
54
54
|
for (const column of item.listColumns) fit(column.text, "body", "body", item.textStyle);
|
|
@@ -68,7 +68,7 @@ var OPFPaginationError = class extends Error {
|
|
|
68
68
|
diagnostics;
|
|
69
69
|
code = "pagination-unresolved";
|
|
70
70
|
};
|
|
71
|
-
var contentFields = /* @__PURE__ */ new Set(["text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram"]);
|
|
71
|
+
var contentFields = /* @__PURE__ */ new Set(["text", "items", "bullets", "image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram"]);
|
|
72
72
|
var headingFields = /* @__PURE__ */ new Set(["title", "subtitle", "tag"]);
|
|
73
73
|
var isRecord = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
74
74
|
var clone = (value) => structuredClone(value);
|
|
@@ -104,9 +104,14 @@ function sentenceEnds(text) {
|
|
|
104
104
|
}
|
|
105
105
|
return ends;
|
|
106
106
|
}
|
|
107
|
+
var otherSlideIds = (presentation) => {
|
|
108
|
+
const slides = presentation?.slides;
|
|
109
|
+
if (!Array.isArray(slides)) return false;
|
|
110
|
+
return slides.flatMap((slide) => slide && typeof slide.id === "string" ? [slide.id] : []);
|
|
111
|
+
};
|
|
107
112
|
var deckContext = (presentation) => {
|
|
108
113
|
const deck = isRecord(presentation) ? presentation : {};
|
|
109
|
-
return { ...Array.isArray(deck.references) ? { references: deck.references } : {}, ...isRecord(deck.datasets) ? { datasets: deck.datasets } : {} };
|
|
114
|
+
return { ...Array.isArray(deck.references) ? { references: deck.references } : {}, ...isRecord(deck.datasets) ? { datasets: deck.datasets } : {}, ...isRecord(deck.datasources) ? { datasources: deck.datasources } : {} };
|
|
110
115
|
};
|
|
111
116
|
function keepTokensWhole(boundaries, text) {
|
|
112
117
|
const spans = slideTokenSpans(text);
|
|
@@ -146,7 +151,7 @@ function leafFor(path, field, value) {
|
|
|
146
151
|
if (Array.isArray(values)) {
|
|
147
152
|
leaf.unit = "items";
|
|
148
153
|
leaf.boundaries = field === "table" ? tableRowBoundaries(value) : Array.from({ length: values.length + 1 }, (_, i) => i);
|
|
149
|
-
leaf.slice = (a, b) => Array.isArray(value) ? value.slice(a, b) : { ...value, [key]: values.slice(a, b) };
|
|
154
|
+
leaf.slice = (a, b) => Array.isArray(value) ? value.slice(a, b) : { ...field === "table" && (a > 0 || b < values.length) ? pinTableColorScale(value) : value, [key]: values.slice(a, b) };
|
|
150
155
|
}
|
|
151
156
|
}
|
|
152
157
|
return leaf;
|
|
@@ -160,20 +165,20 @@ function bodySizes(composed, options = {}) {
|
|
|
160
165
|
return sizes;
|
|
161
166
|
}
|
|
162
167
|
function paginateSlide(input, options = {}) {
|
|
163
|
-
assertValid({ ...deckContext(options.presentation), slides: [input] }, { only: ["format"] });
|
|
168
|
+
assertValid({ ...deckContext(options.presentation), slides: [input] }, { only: ["format"], slideLinks: otherSlideIds(options.presentation) });
|
|
164
169
|
let source = clone(input);
|
|
165
170
|
const maxSlides = options.maxSlides ?? 100;
|
|
166
171
|
if (!Number.isInteger(maxSlides) || maxSlides < 1 || maxSlides > 1e4) throw new RangeError("maxSlides must be an integer between 1 and 10000.");
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
172
|
+
const minFontSizePx = options.minFontSizePx ?? (options.wholeBlocks ? void 0 : 24);
|
|
173
|
+
if (minFontSizePx !== void 0 && (!Number.isFinite(minFontSizePx) || minFontSizePx < 8 || minFontSizePx > 32)) throw new RangeError("Pagination minFontSizePx must be between 8 and 32.");
|
|
169
174
|
const sourceIndex = options.slideIndex ?? 0, sourceBase = `slides.${sourceIndex}`;
|
|
170
175
|
const withReadability = (slide, warn = false) => {
|
|
171
176
|
const result = clone(slide);
|
|
172
|
-
const rootMinimum = Math.max(
|
|
173
|
-
result.composition = { ...result.composition,
|
|
177
|
+
const rootMinimum = Math.max(minFontSizePx ?? 0, result.composition?.minFontSizePx ?? options.layout?.composition?.minFontSizePx ?? 16);
|
|
178
|
+
result.composition = { ...result.composition, minFontSizePx: rootMinimum };
|
|
174
179
|
const visit = (node, inheritedMinimum) => {
|
|
175
|
-
const minimum = Math.max(
|
|
176
|
-
if (node.composition) node.composition = { ...node.composition,
|
|
180
|
+
const minimum = Math.max(minFontSizePx ?? 0, node.composition?.minFontSizePx ?? inheritedMinimum);
|
|
181
|
+
if (node.composition) node.composition = { ...node.composition, minFontSizePx: minimum, ...warn ? { overflow: "warn" } : {} };
|
|
177
182
|
if (Array.isArray(node.blocks)) node.blocks.forEach((child) => {
|
|
178
183
|
visit(child, minimum);
|
|
179
184
|
});
|
|
@@ -182,9 +187,9 @@ function paginateSlide(input, options = {}) {
|
|
|
182
187
|
for (const [key, value] of Object.entries(result)) if (isRecord(value) && /^(top|middle|bottom|start|center|end)([+:]|$)/.test(key)) visit(value, rootMinimum);
|
|
183
188
|
return result;
|
|
184
189
|
};
|
|
185
|
-
if (
|
|
190
|
+
if (minFontSizePx !== void 0) source = withReadability(source);
|
|
186
191
|
let evaluations = 0;
|
|
187
|
-
const { fonts, catalogs,
|
|
192
|
+
const { fonts, catalogs, minFontSizePx: _minFontSize, maxSlides: _maxSlides, reservedIds: _reservedIds, ...engineOptions } = options;
|
|
188
193
|
const textMeasurement = fonts?.textMeasurement && options.presentation !== void 0 ? resolveSlideScriptMeasurement(options.presentation, sourceIndex, fonts.textMeasurement, { ...catalogs !== void 0 ? { catalogs } : {}, ...options.fontFamilies ? { fontFamilies: options.fontFamilies } : {} }) : fonts?.textMeasurement;
|
|
189
194
|
const composeOptions = { ...engineOptions, ...textMeasurement ? { textMeasurement } : {}, ...textMeasurement && engineOptions.fontFamilies ? { fontFamilies: resolveDrawnFontFamilies(engineOptions.fontFamilies, textMeasurement) } : {} };
|
|
190
195
|
const presentationSlides = options.presentation?.slides;
|
|
@@ -369,7 +374,7 @@ function paginateSlide(input, options = {}) {
|
|
|
369
374
|
if (issues.length) throw new OPFPaginationError("A continuation page does not fit at its final page number. No partial result was returned.", issues);
|
|
370
375
|
drawnSizes.push({ kinds: new Set([...selected.values()].map((portion) => kindOf(portion.leaf.field))), sizes: bodySizes(drawn, composeOptions) });
|
|
371
376
|
assignPageIds(slide, slides.length);
|
|
372
|
-
assertValid({ ...deckContext(options.presentation), slides: [slide] }, { only: ["format"] });
|
|
377
|
+
assertValid({ ...deckContext(options.presentation), slides: [slide] }, { only: ["format"], slideLinks: otherSlideIds(options.presentation) });
|
|
373
378
|
slides.push(slide);
|
|
374
379
|
pages.push({ slideIndex: sourceIndex + slides.length - 1, mappings, ...initial.furniture ? { repeatedMappings: repeatedMappings(slides.length - 1) } : {} });
|
|
375
380
|
pageConnectors.push(overlay);
|
|
@@ -382,7 +387,7 @@ function paginateSlide(input, options = {}) {
|
|
|
382
387
|
for (let index = 1; index < slides.length; index++) {
|
|
383
388
|
const slide = slides[index], cap = Math.max(0, ...[...drawnSizes[index].kinds].map((kind) => Math.max(first.get(kind) ?? 0, shared.get(kind) ?? 0)));
|
|
384
389
|
if (!cap) continue;
|
|
385
|
-
slide.composition = { ...slide.composition,
|
|
390
|
+
slide.composition = { ...slide.composition, maxFontSizePx: Math.min(Math.max(8, cap), 200, slide.composition?.maxFontSizePx ?? Infinity) };
|
|
386
391
|
const issues = fit(geometry(slide, index).diagnostics);
|
|
387
392
|
if (issues.length) throw new OPFPaginationError("A continuation page does not fit at its final page number. No partial result was returned.", issues);
|
|
388
393
|
}
|
|
@@ -408,7 +413,7 @@ function paginateSlide(input, options = {}) {
|
|
|
408
413
|
const inspect = (from, to, pageIndex, caps) => {
|
|
409
414
|
const selected2 = portions(from, to), projection = project(selected2, pageIndex);
|
|
410
415
|
const cap = caps && Math.max(0, ...[...selected2.values()].map((portion) => caps.get(kindOf(portion.leaf.field)) ?? 0));
|
|
411
|
-
if (cap) projection.slide.composition = { ...projection.slide.composition,
|
|
416
|
+
if (cap) projection.slide.composition = { ...projection.slide.composition, maxFontSizePx: Math.min(Math.max(8, cap), 200, projection.slide.composition?.maxFontSizePx ?? Infinity) };
|
|
412
417
|
const drawn = geometry(projection.slide, pageIndex), issues = fit(drawn.diagnostics);
|
|
413
418
|
const mappings = projection.mappings;
|
|
414
419
|
const composedPath = (output) => sourceBase + output.slice(output.indexOf(".", 7));
|
|
@@ -537,7 +542,7 @@ function continueOverfull(input, options = {}) {
|
|
|
537
542
|
const units = blockUnits(slide);
|
|
538
543
|
if (!units) return void 0;
|
|
539
544
|
try {
|
|
540
|
-
const split = paginateSlide(slide, { ...slideOptions, wholeBlocks: true,
|
|
545
|
+
const split = paginateSlide(slide, { ...slideOptions, wholeBlocks: true, minFontSizePx: options.minFontSizePx });
|
|
541
546
|
if (split.slides.length < 2) return void 0;
|
|
542
547
|
found.set(index, units);
|
|
543
548
|
return split;
|
|
@@ -590,7 +595,7 @@ function paginateSlides(input, options, name, maxSlides, split) {
|
|
|
590
595
|
}
|
|
591
596
|
}
|
|
592
597
|
if (output2.length >= maxSlides) throw new OPFPaginationError(`Pagination needs more than ${maxSlides} slides. No partial result was returned.`);
|
|
593
|
-
const slideOptions = { ...context.options, textRasterPadding: options.textRasterPadding, fonts: options.fonts, ...options.catalogs ? { catalogs: options.catalogs } : {}, presentation, slideIndex: index, slideNumber: output2.length + 1, slideCount: slideCount2, date: options.date, maxSlides: maxSlides - output2.length,
|
|
598
|
+
const slideOptions = { ...context.options, textRasterPadding: options.textRasterPadding, fonts: options.fonts, ...options.catalogs ? { catalogs: options.catalogs } : {}, presentation, slideIndex: index, slideNumber: output2.length + 1, slideCount: slideCount2, date: options.date, maxSlides: maxSlides - output2.length, minFontSizePx: options.minFontSizePx, reservedIds };
|
|
594
599
|
const result2 = split(slide, slideOptions, index);
|
|
595
600
|
if (!result2) {
|
|
596
601
|
output2.push(slide);
|