@openpresentation/opf 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/browser.js +19 -19
  2. package/dist/{catalog-refs-BgotJhR5.d.ts → catalog-refs-BeRgtpZS.d.ts} +4 -4
  3. package/dist/{catalog-schemas-BX-VEc5Q.d.ts → catalog-schemas-CwY-3cCP.d.ts} +1 -1
  4. package/dist/{chunk-OFL3WY6F.js → chunk-3A3PNYNP.js} +77 -15
  5. package/dist/{chunk-TJMESSBQ.js → chunk-44IS6ZU2.js} +109 -9
  6. package/dist/{chunk-J7FUSZZ5.js → chunk-4FA4ZABY.js} +6 -6
  7. package/dist/{chunk-F5SY7MSA.js → chunk-56BYOGIF.js} +1 -1
  8. package/dist/{chunk-MS2LPR7F.js → chunk-6WN6PRCI.js} +1 -1
  9. package/dist/{chunk-7JE3XTL7.js → chunk-BHRCWV6B.js} +4 -4
  10. package/dist/{chunk-4FA4AZXY.js → chunk-C5ACMFKB.js} +1392 -808
  11. package/dist/{chunk-2NIID3QD.js → chunk-CYGQY6HH.js} +6 -6
  12. package/dist/{chunk-SER6GJTT.js → chunk-EOMENOKY.js} +23 -6
  13. package/dist/{chunk-O65COLKF.js → chunk-HS2JQ3AO.js} +118 -19
  14. package/dist/chunk-IW4TXMJY.js +646 -0
  15. package/dist/{chunk-6WVPFWPD.js → chunk-JTNCBTEH.js} +4 -4
  16. package/dist/{chunk-3KPTVK77.js → chunk-KANQVJGK.js} +1244 -119
  17. package/dist/{chunk-VDZXNNZF.js → chunk-M4IPCFDV.js} +1 -1
  18. package/dist/{chunk-XRMYP4JD.js → chunk-ORVMHVOS.js} +86 -2
  19. package/dist/{chunk-HHQROUYC.js → chunk-QFT4R2IL.js} +4405 -2808
  20. package/dist/chunk-QQBOI5XI.js +86 -0
  21. package/dist/{chunk-GNKOQ6NA.js → chunk-TIVBO56G.js} +4 -4
  22. package/dist/{chunk-APCNAAA7.js → chunk-VD7WLE3C.js} +2 -2
  23. package/dist/{chunk-AZELWKG2.js → chunk-XJU2X5JM.js} +5 -4
  24. package/dist/chunk-YESKKKVE.js +1 -0
  25. package/dist/{chunk-BPSZ7OWD.js → chunk-YZ4WMB5C.js} +26 -21
  26. package/dist/{composition-CSM7YfBl.d.ts → composition-DiKC371V.d.ts} +707 -134
  27. package/dist/composition.d.ts +3 -3
  28. package/dist/composition.js +1 -1
  29. package/dist/{conversion-CL7ipVGO.d.ts → conversion-DF_HgknQ.d.ts} +6 -6
  30. package/dist/conversion-XIWN7FMW.js +25 -0
  31. package/dist/convert.d.ts +5 -5
  32. package/dist/convert.js +63 -23
  33. package/dist/data.d.ts +41 -3
  34. package/dist/data.js +2 -2
  35. package/dist/{deck-report-DhsB0SUz.d.ts → deck-report-BwgsIRAf.d.ts} +3 -3
  36. package/dist/deck.d.ts +6 -6
  37. package/dist/deck.js +11 -11
  38. package/dist/diff.js +4 -4
  39. package/dist/docs.js +43 -31
  40. package/dist/examples.js +2338 -392
  41. package/dist/font-policy.js +1 -1
  42. package/dist/format.js +2 -2
  43. package/dist/ids.d.ts +17 -4
  44. package/dist/ids.js +4 -4
  45. package/dist/index.d.ts +140 -23
  46. package/dist/index.js +22 -22
  47. package/dist/markdown.d.ts +2 -2
  48. package/dist/markdown.js +8 -8
  49. package/dist/metric-data-B4Q8RFRR.d.ts +382 -0
  50. package/dist/node-engine.d.ts +6 -6
  51. package/dist/node-engine.js +21 -21
  52. package/dist/{pagination-BSqq32xt.d.ts → pagination-C9qnH_n-.d.ts} +5 -5
  53. package/dist/pagination.d.ts +4 -4
  54. package/dist/pagination.js +4 -4
  55. package/dist/patch.js +3 -3
  56. package/dist/precompiled.js +2 -2
  57. package/dist/{presentation-Dx-kZC8Y.d.ts → presentation-DmOhusrX.d.ts} +541 -110
  58. package/dist/schema-engine-ajv.js +1 -1
  59. package/dist/schema-engine-precompiled.js +2 -2
  60. package/dist/schema.d.ts +2 -2
  61. package/dist/schema.js +3 -3
  62. package/dist/schemas.d.ts +46 -2
  63. package/dist/schemas.js +1 -1
  64. package/dist/shape-engine-eager.js +2 -2
  65. package/dist/shape-engine-lazy.js +1 -1
  66. package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
  67. package/dist/shape-geometry.js +1 -1
  68. package/dist/source.js +10 -10
  69. package/dist/spec/reference/engine-defaults.json +1 -1
  70. package/dist/spec/reference/engine-vocabularies.json +1 -0
  71. package/dist/spec/schemas/font-scheme.schema.json +5 -6
  72. package/dist/spec/schemas/layout.schema.json +5 -4
  73. package/dist/spec/schemas/narrative.schema.json +1 -0
  74. package/dist/spec/schemas/opf.schema.json +661 -98
  75. package/dist/types.d.ts +11 -12
  76. package/dist/{validation-types-bnrso0JL.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
  77. package/dist/validator.d.ts +5 -5
  78. package/dist/validator.js +3 -3
  79. package/dist/yaml.d.ts +2 -2
  80. package/dist/yaml.js +7 -7
  81. package/package.json +5 -5
  82. package/dist/chart-data-B_k-WTex.d.ts +0 -194
  83. package/dist/chunk-6VGLE7C5.js +0 -3983
  84. package/dist/chunk-SEC4IOOS.js +0 -1
  85. package/dist/chunk-WCPDN7AY.js +0 -642
  86. package/dist/conversion-FTGQLJK7.js +0 -25
@@ -1,4 +1,4 @@
1
- import { presetGeometry, presetAdjustments, isPresetShape, flattenShapePath, evaluateGuideFormula, customGeometry, adjustToDrawingML, adjustFromDrawingML, PRESET_SHAPES } from './chunk-WCPDN7AY.js';
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-HHQROUYC.js';
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 };