@openpresentation/opf 0.35.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +19 -19
- package/dist/{catalog-refs-BgotJhR5.d.ts → catalog-refs-BeRgtpZS.d.ts} +4 -4
- package/dist/{catalog-schemas-BX-VEc5Q.d.ts → catalog-schemas-CwY-3cCP.d.ts} +1 -1
- package/dist/{chunk-BN36KMXG.js → chunk-3A3PNYNP.js} +77 -15
- package/dist/{chunk-EGXHUIQ5.js → chunk-44IS6ZU2.js} +114 -9
- package/dist/{chunk-ZRTVPUYJ.js → chunk-4FA4ZABY.js} +6 -6
- package/dist/{chunk-OBNSVMNO.js → chunk-56BYOGIF.js} +1 -1
- package/dist/{chunk-MS2LPR7F.js → chunk-6WN6PRCI.js} +1 -1
- package/dist/{chunk-ZHLAMHSS.js → chunk-BHRCWV6B.js} +4 -4
- package/dist/{chunk-PWE6UY3Y.js → chunk-C5ACMFKB.js} +1440 -835
- package/dist/{chunk-PF3TVOMG.js → chunk-CYGQY6HH.js} +6 -6
- package/dist/{chunk-MIHW2IGO.js → chunk-EOMENOKY.js} +26 -7
- package/dist/{chunk-TRGSEXUR.js → chunk-HS2JQ3AO.js} +118 -19
- package/dist/chunk-IW4TXMJY.js +646 -0
- package/dist/{chunk-LLY5BZGF.js → chunk-JTNCBTEH.js} +4 -4
- package/dist/{chunk-3KPTVK77.js → chunk-KANQVJGK.js} +1244 -119
- package/dist/{chunk-VDZXNNZF.js → chunk-M4IPCFDV.js} +1 -1
- package/dist/{chunk-WPUV2223.js → chunk-ORVMHVOS.js} +86 -2
- package/dist/{chunk-B7XWF5RV.js → chunk-QFT4R2IL.js} +5304 -2991
- package/dist/chunk-QQBOI5XI.js +86 -0
- package/dist/{chunk-P6KRAHVG.js → chunk-TIVBO56G.js} +4 -4
- package/dist/{chunk-ZEVLLXSY.js → chunk-VD7WLE3C.js} +2 -2
- package/dist/{chunk-PXJZS4ZF.js → chunk-XJU2X5JM.js} +5 -4
- package/dist/chunk-YESKKKVE.js +1 -0
- package/dist/{chunk-XHWJI4O7.js → chunk-YZ4WMB5C.js} +26 -21
- package/dist/{composition-BmJfljJl.d.ts → composition-DiKC371V.d.ts} +844 -143
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +1 -1
- package/dist/{conversion-BIooTbt5.d.ts → conversion-DF_HgknQ.d.ts} +8 -6
- package/dist/conversion-XIWN7FMW.js +25 -0
- package/dist/convert.d.ts +5 -5
- package/dist/convert.js +63 -23
- package/dist/data.d.ts +41 -3
- package/dist/data.js +2 -2
- package/dist/{deck-report-BYkbL7uT.d.ts → deck-report-BwgsIRAf.d.ts} +3 -3
- package/dist/deck.d.ts +6 -6
- package/dist/deck.js +11 -11
- package/dist/diff.js +4 -4
- package/dist/docs.js +57 -33
- package/dist/examples.js +5349 -2989
- package/dist/font-policy.js +1 -1
- package/dist/format.js +2 -2
- package/dist/ids.d.ts +17 -4
- package/dist/ids.js +4 -4
- package/dist/index.d.ts +140 -23
- package/dist/index.js +22 -22
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +8 -8
- package/dist/metric-data-B4Q8RFRR.d.ts +382 -0
- package/dist/node-engine.d.ts +6 -6
- package/dist/node-engine.js +21 -21
- package/dist/{pagination-C0FPjO29.d.ts → pagination-C9qnH_n-.d.ts} +5 -5
- package/dist/pagination.d.ts +4 -4
- package/dist/pagination.js +4 -4
- package/dist/patch.js +3 -3
- package/dist/precompiled.js +2 -2
- package/dist/{presentation-Dx-kZC8Y.d.ts → presentation-DmOhusrX.d.ts} +541 -110
- package/dist/repo-readme.js +1 -1
- package/dist/schema-engine-ajv.js +1 -1
- package/dist/schema-engine-precompiled.js +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +3 -3
- package/dist/schemas.d.ts +46 -2
- package/dist/schemas.js +1 -1
- package/dist/shape-engine-eager.js +2 -2
- package/dist/shape-engine-lazy.js +1 -1
- package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
- package/dist/shape-geometry.js +1 -1
- package/dist/source.js +10 -10
- package/dist/spec/reference/engine-defaults.json +1 -1
- package/dist/spec/reference/engine-vocabularies.json +1 -0
- package/dist/spec/schemas/font-scheme.schema.json +5 -6
- package/dist/spec/schemas/layout.schema.json +5 -4
- package/dist/spec/schemas/narrative.schema.json +1 -0
- package/dist/spec/schemas/opf.schema.json +661 -98
- package/dist/types.d.ts +11 -12
- package/dist/{validation-types-DKIe1RQW.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
- package/dist/validator.d.ts +5 -5
- package/dist/validator.js +3 -3
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +7 -7
- package/package.json +5 -5
- package/dist/chart-data-B_k-WTex.d.ts +0 -194
- package/dist/chunk-6VGLE7C5.js +0 -3983
- package/dist/chunk-SEC4IOOS.js +0 -1
- package/dist/chunk-WCPDN7AY.js +0 -642
- package/dist/conversion-SB5CGD6Q.js +0 -25
|
@@ -1,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 };
|