@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.
Files changed (87) 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-BN36KMXG.js → chunk-3A3PNYNP.js} +77 -15
  5. package/dist/{chunk-EGXHUIQ5.js → chunk-44IS6ZU2.js} +114 -9
  6. package/dist/{chunk-ZRTVPUYJ.js → chunk-4FA4ZABY.js} +6 -6
  7. package/dist/{chunk-OBNSVMNO.js → chunk-56BYOGIF.js} +1 -1
  8. package/dist/{chunk-MS2LPR7F.js → chunk-6WN6PRCI.js} +1 -1
  9. package/dist/{chunk-ZHLAMHSS.js → chunk-BHRCWV6B.js} +4 -4
  10. package/dist/{chunk-PWE6UY3Y.js → chunk-C5ACMFKB.js} +1440 -835
  11. package/dist/{chunk-PF3TVOMG.js → chunk-CYGQY6HH.js} +6 -6
  12. package/dist/{chunk-MIHW2IGO.js → chunk-EOMENOKY.js} +26 -7
  13. package/dist/{chunk-TRGSEXUR.js → chunk-HS2JQ3AO.js} +118 -19
  14. package/dist/chunk-IW4TXMJY.js +646 -0
  15. package/dist/{chunk-LLY5BZGF.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-WPUV2223.js → chunk-ORVMHVOS.js} +86 -2
  19. package/dist/{chunk-B7XWF5RV.js → chunk-QFT4R2IL.js} +5304 -2991
  20. package/dist/chunk-QQBOI5XI.js +86 -0
  21. package/dist/{chunk-P6KRAHVG.js → chunk-TIVBO56G.js} +4 -4
  22. package/dist/{chunk-ZEVLLXSY.js → chunk-VD7WLE3C.js} +2 -2
  23. package/dist/{chunk-PXJZS4ZF.js → chunk-XJU2X5JM.js} +5 -4
  24. package/dist/chunk-YESKKKVE.js +1 -0
  25. package/dist/{chunk-XHWJI4O7.js → chunk-YZ4WMB5C.js} +26 -21
  26. package/dist/{composition-BmJfljJl.d.ts → composition-DiKC371V.d.ts} +844 -143
  27. package/dist/composition.d.ts +3 -3
  28. package/dist/composition.js +1 -1
  29. package/dist/{conversion-BIooTbt5.d.ts → conversion-DF_HgknQ.d.ts} +8 -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-BYkbL7uT.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 +57 -33
  40. package/dist/examples.js +5349 -2989
  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-C0FPjO29.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/repo-readme.js +1 -1
  59. package/dist/schema-engine-ajv.js +1 -1
  60. package/dist/schema-engine-precompiled.js +2 -2
  61. package/dist/schema.d.ts +2 -2
  62. package/dist/schema.js +3 -3
  63. package/dist/schemas.d.ts +46 -2
  64. package/dist/schemas.js +1 -1
  65. package/dist/shape-engine-eager.js +2 -2
  66. package/dist/shape-engine-lazy.js +1 -1
  67. package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
  68. package/dist/shape-geometry.js +1 -1
  69. package/dist/source.js +10 -10
  70. package/dist/spec/reference/engine-defaults.json +1 -1
  71. package/dist/spec/reference/engine-vocabularies.json +1 -0
  72. package/dist/spec/schemas/font-scheme.schema.json +5 -6
  73. package/dist/spec/schemas/layout.schema.json +5 -4
  74. package/dist/spec/schemas/narrative.schema.json +1 -0
  75. package/dist/spec/schemas/opf.schema.json +661 -98
  76. package/dist/types.d.ts +11 -12
  77. package/dist/{validation-types-DKIe1RQW.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
  78. package/dist/validator.d.ts +5 -5
  79. package/dist/validator.js +3 -3
  80. package/dist/yaml.d.ts +2 -2
  81. package/dist/yaml.js +7 -7
  82. package/package.json +5 -5
  83. package/dist/chart-data-B_k-WTex.d.ts +0 -194
  84. package/dist/chunk-6VGLE7C5.js +0 -3983
  85. package/dist/chunk-SEC4IOOS.js +0 -1
  86. package/dist/chunk-WCPDN7AY.js +0 -642
  87. package/dist/conversion-SB5CGD6Q.js +0 -25
@@ -1,10 +1,10 @@
1
1
  import { NOT_CHECKED } from './chunk-RYZPBJLB.js';
2
- import { readMarkdown, parseSlideText, escapeInline, serializeRuns } from './chunk-ZHLAMHSS.js';
3
- import { fenceCode } from './chunk-OBNSVMNO.js';
4
- import { OPFMarkdownError, writeYaml, Ctx, readYamlMapping, csvField, scalarText } from './chunk-ZEVLLXSY.js';
5
- import { same, isRecord, runText, isPlainRun, FORMATTING } from './chunk-PXJZS4ZF.js';
6
- import { validate } from './chunk-PWE6UY3Y.js';
7
- import { checkCatalogsOption } from './chunk-B7XWF5RV.js';
2
+ import { readMarkdown, parseSlideText, escapeInline, serializeRuns } from './chunk-BHRCWV6B.js';
3
+ import { fenceCode } from './chunk-56BYOGIF.js';
4
+ import { OPFMarkdownError, writeYaml, Ctx, readYamlMapping, csvField, scalarText } from './chunk-VD7WLE3C.js';
5
+ import { same, isRecord, runText, isPlainRun, FORMATTING } from './chunk-XJU2X5JM.js';
6
+ import { validate } from './chunk-C5ACMFKB.js';
7
+ import { checkCatalogsOption } from './chunk-QFT4R2IL.js';
8
8
 
9
9
  // src/markdown/canon.ts
10
10
  var FORMAT_KEYS = FORMATTING;
@@ -1,9 +1,9 @@
1
1
  import { defaultCatalogs } from './chunk-XJUMFH33.js';
2
- import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-TRGSEXUR.js';
3
- import { paginate, continueOverfull } from './chunk-XHWJI4O7.js';
4
- import { deckFormatOf, readDeckReport, stringify } from './chunk-P6KRAHVG.js';
5
- import { validate, OPFValidationError } from './chunk-PWE6UY3Y.js';
6
- import { ensureIcons } from './chunk-B7XWF5RV.js';
2
+ import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-HS2JQ3AO.js';
3
+ import { paginate, continueOverfull } from './chunk-YZ4WMB5C.js';
4
+ import { deckFormatOf, readDeckReport, stringify } from './chunk-TIVBO56G.js';
5
+ import { validate, OPFValidationError } from './chunk-C5ACMFKB.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.35.1", [PPTX_PACKAGE]: "^0.35.1" };
134
+ var PEER_RANGES = { [RENDER_PACKAGE]: "^0.37.0", [PPTX_PACKAGE]: "^0.37.0" };
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.",
@@ -648,8 +662,12 @@ var HELP = {
648
662
  "chart-reference-style-uncertain": "The reference line was restored with the stroke the PPTX shows now, because the stored stroke is not valid. Set its stroke in OPF if it should differ.",
649
663
  "chart-reference-ownership-uncertain": REFERENCE_UNCERTAIN,
650
664
  "chart-reference-overlay-uncertain": REFERENCE_UNCERTAIN,
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.",
651
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.",
652
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.",
653
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).",
654
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.",
655
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.",
@@ -1087,7 +1105,8 @@ async function drawWith(presentation, handle, options, ctx, environment) {
1087
1105
  code: "typeface-not-office-safe",
1088
1106
  path: "",
1089
1107
  families: unsafe,
1090
- message: `The PPTX names ${unsafe.join(", ")}, which ${unsafe.length === 1 ? "is" : "are"} not on every Windows and macOS machine or not measured exactly by OPF. A viewer without ${unsafe.length === 1 ? "it" : "them"} substitutes another font, and lines can break differently from the preview.`
1108
+ // The sentence is opf-pptx's (the MCP viewer shows the same one); an opf-pptx that predates it gets a short form.
1109
+ message: module.typefacesNotOfficeSafeMessage?.(unsafe) ?? `The PPTX names ${unsafe.join(", ")}, which a viewer's PowerPoint may not have.`
1091
1110
  },
1092
1111
  "info"
1093
1112
  );
@@ -1,6 +1,6 @@
1
- import { OPFDataImportError, parseTabularData } from './chunk-WPUV2223.js';
2
- import { refreshStaleLayouts, applyPatchWithInverse, validate, OPFValidationError, createValidator, documentHash, applyPatch, OPFPatchError, parsePointer } from './chunk-PWE6UY3Y.js';
3
- import { embeddedCopy, checkCatalogsOption, catalogReferenceSites, parseReference, catalogGroupDeclared, resolveReference, dottedPath, unresolvedReference, recordReferenceSites, catalogGroupSource, registeredCatalog, catalogKinds, CATALOG_GROUP_PATTERN, isRecord, visitContentPayloads, cellBlocks, annotationText, listVariables, resolveVariables, LOGO_SHAPES, resolveDesignRecords, resolveFontFamilies, resolveCanvasDimensions, imageBackground } from './chunk-B7XWF5RV.js';
1
+ import { OPFDataImportError, parseTabularData, updateMetricLiterals } from './chunk-ORVMHVOS.js';
2
+ import { refreshStaleLayouts, applyPatchWithInverse, validate, OPFValidationError, createValidator, documentHash, applyPatch, OPFPatchError, parsePointer } from './chunk-C5ACMFKB.js';
3
+ import { embeddedCopy, checkCatalogsOption, catalogReferenceSites, parseReference, catalogGroupDeclared, resolveReference, dottedPath, unresolvedReference, recordReferenceSites, catalogGroupSource, registeredCatalog, catalogKinds, CATALOG_GROUP_PATTERN, isRecord, visitContentPayloads, cellBlocks, annotationText, listVariables, resolveTextStyle, textWidthMeasurer, resolveVariables, snapFontSizeDown, LOGO_SHAPES, embedValue, tableRows, resolveDesignRecords, resolveFontFamilies, resolveCanvasDimensions, fitText, imageBackground } from './chunk-QFT4R2IL.js';
4
4
 
5
5
  // src/api-errors.ts
6
6
  var OPFApiError = class extends Error {
@@ -348,7 +348,7 @@ function moveToCustom(document, ref, options = {}) {
348
348
 
349
349
  // src/stats.ts
350
350
  var DEFAULT_WORDS_PER_MINUTE = 130;
351
- var KIND_ORDER = ["text", "items", "bullets", "quote", "metric", "code", "timeline", "diagram", "chart", "table", "image", "video"];
351
+ var KIND_ORDER = ["text", "items", "bullets", "quote", "metric", "code", "timeline", "diagram", "chart", "table", "image", "video", "embed"];
352
352
  var FURNITURE_FIELDS = ["image", "text", "socials", "date"];
353
353
  var ZONES = ["start", "center", "end"];
354
354
  var WORD = /[\p{L}\p{N}\p{M}]+(?:['’.,-][\p{L}\p{N}\p{M}]+)*/gu;
@@ -549,7 +549,7 @@ function compute(presentation2, options, onFile) {
549
549
  useAsset(entry.photo);
550
550
  images.speakerPhotos++;
551
551
  }
552
- return { id: str(entry.id) ?? "", name: str(entry.name) ?? "", title: str(entry.title), organizationId: str(entry.organizationId), hasPhoto };
552
+ return { id: str(entry.id) ?? "", name: str(entry.name) ?? "", title: str(entry.title), organization: str(entry.organization), hasPhoto };
553
553
  });
554
554
  designAssets(design, "deck");
555
555
  for (const variable of Object.values(isRecord(deck.variables) ? deck.variables : {})) if (isRecord(variable) && variable.type === "image") useAsset(variable.value);
@@ -573,11 +573,11 @@ function compute(presentation2, options, onFile) {
573
573
  };
574
574
  const datasetRecords = isRecord(deck.datasets) ? Object.entries(deck.datasets).filter(([, value]) => isRecord(value)) : [];
575
575
  const datasetUse = /* @__PURE__ */ new Map();
576
- const payloadCounts = { text: 0, items: 0, bullets: 0, quote: 0, metric: 0, code: 0, timeline: 0, diagram: 0, chart: 0, table: 0, image: 0, video: 0, blocks: 0, cells: 0, groups: 0, maxDepth: 0 };
576
+ const payloadCounts = { text: 0, items: 0, bullets: 0, quote: 0, metric: 0, code: 0, timeline: 0, diagram: 0, chart: 0, table: 0, image: 0, video: 0, embed: 0, blocks: 0, cells: 0, groups: 0, maxDepth: 0 };
577
577
  const layouts = /* @__PURE__ */ new Map(), chartTypes = /* @__PURE__ */ new Map(), extensions = /* @__PURE__ */ new Set();
578
- const chartData = { inline: 0, dataset: 0, withSource: 0 };
578
+ const chartData = { inline: 0, dataset: 0, withDatasource: 0 };
579
579
  const tableItems = [];
580
- let tableRows = 0, tableColumns = 0, datasetBackedTables = 0, chartTotal = 0, captions = 0;
580
+ let tableRows2 = 0, tableColumns = 0, datasetBackedTables = 0, chartTotal = 0, captions = 0;
581
581
  const hidden = [], withoutNotes = [], sections = [];
582
582
  let withTitle = 0, withBeat = 0, unsectioned = 0, withoutLayout = 0, withOwnDesign = 0, withNotes = 0, contentWords = 0, notesWords = 0;
583
583
  const headerOverrides = { header: 0, headerSuppressed: 0, footer: 0, footerSuppressed: 0 };
@@ -656,6 +656,10 @@ function compute(presentation2, options, onFile) {
656
656
  useAsset(node.video, true);
657
657
  images.videos++;
658
658
  }
659
+ if (node.embed !== void 0) {
660
+ const preview = embedValue(node.embed)?.preview;
661
+ if (preview !== void 0) useAsset(preview);
662
+ }
659
663
  if (isRecord(node.chart)) {
660
664
  chartTotal++;
661
665
  slideCharts++;
@@ -666,7 +670,7 @@ function compute(presentation2, options, onFile) {
666
670
  chartData.dataset++;
667
671
  bump(datasetUse, data.dataset);
668
672
  } else if (Array.isArray(data.columns) || Array.isArray(data.rows)) chartData.inline++;
669
- if (isRecord(data.source)) chartData.withSource++;
673
+ if (data.datasource !== void 0) chartData.withDatasource++;
670
674
  }
671
675
  }
672
676
  if (isRecord(node.table)) {
@@ -681,13 +685,13 @@ function compute(presentation2, options, onFile) {
681
685
  rows = Array.isArray(source?.rows) ? source.rows.length : 0;
682
686
  columns = Array.isArray(table.fields) ? table.fields.length : Array.isArray(source?.columns) ? source.columns.length : 0;
683
687
  } else {
684
- const body = Array.isArray(table.rows) ? table.rows : [];
685
- rows = body.length;
686
- columns = Array.isArray(table.columns) ? table.columns.length : body.reduce((widest, row) => Math.max(widest, Array.isArray(row) ? row.length : 0), 0);
688
+ const body = tableRows(table).map((row) => row.cells);
689
+ rows = Array.isArray(table.rows) ? table.rows.length : 0;
690
+ columns = Array.isArray(table.columns) ? table.columns.length : body.reduce((widest, row) => Math.max(widest, row.length), 0);
687
691
  run(table.columns);
688
692
  for (const row of body) run(row);
689
693
  }
690
- tableRows += rows;
694
+ tableRows2 += rows;
691
695
  tableColumns += columns;
692
696
  tableItems.push({ slide: index, path: `${path}/table`, rows, columns, dataset });
693
697
  }
@@ -761,7 +765,7 @@ function compute(presentation2, options, onFile) {
761
765
  title: str(value.title),
762
766
  columns: Array.isArray(value.columns) ? value.columns.length : 0,
763
767
  rows: Array.isArray(value.rows) ? value.rows.length : 0,
764
- source: isRecord(value.source) ? str(value.source.src) : null,
768
+ datasource: typeof value.datasource === "string" ? value.datasource : isRecord(value.datasource) ? str(value.datasource.src) : null,
765
769
  referencedBy: datasetUse.get(id) ?? 0
766
770
  }));
767
771
  const references = Array.isArray(deck.references) ? deck.references.filter(isRecord) : [];
@@ -830,8 +834,8 @@ function compute(presentation2, options, onFile) {
830
834
  speakingTime: { basis: "estimate", wordsPerMinute, notesWords, minutes: decimals(notesWords / wordsPerMinute, 1), declaredMinutes: deckFacts.declaredMinutes },
831
835
  images,
832
836
  charts: { total: chartTotal, byType: sortedCounts(chartTypes), data: chartData },
833
- tables: { total: tableItems.length, datasetBacked: datasetBackedTables, rows: tableRows, columns: tableColumns, items: tableItems },
834
- datasets: { count: datasetItems.length, withSource: datasetItems.filter((item) => item.source !== null).length, items: datasetItems },
837
+ tables: { total: tableItems.length, datasetBacked: datasetBackedTables, rows: tableRows2, columns: tableColumns, items: tableItems },
838
+ datasets: { count: datasetItems.length, withDatasource: datasetRecords.filter(([, value]) => value.datasource !== void 0).length, items: datasetItems },
835
839
  citations: { references: references.length, cited, citations: total.citations, footnotes: total.footnotes, captions, links: total.links },
836
840
  variables: variableFacts,
837
841
  assets: { registry: registryFacts, uses, embeddedBytes: embeddedTotal },
@@ -849,6 +853,93 @@ function compute(presentation2, options, onFile) {
849
853
  return result;
850
854
  }
851
855
 
856
+ // src/embed-card.ts
857
+ function embedArrowPoints(box) {
858
+ const size = Math.min(box.width, box.height), left = box.x + (box.width - size) / 2, top = box.y + (box.height - size) / 2;
859
+ const local = [[0, 0.25], [0.5, 0.25], [0.5, 0], [1, 0.5], [0.5, 1], [0.5, 0.75], [0, 0.75]];
860
+ const cx = left + size / 2, cy = top + size / 2, cos = Math.SQRT1_2, sin = -Math.SQRT1_2;
861
+ return local.map(([u, v]) => {
862
+ const dx = left + u * size - cx, dy = top + v * size - cy;
863
+ return [round(cx + dx * cos - dy * sin), round(cy + dx * sin + dy * cos)];
864
+ });
865
+ }
866
+ var round = (value) => Math.round(value * 1e3) / 1e3;
867
+ var TITLE_SIZE = 28;
868
+ var TITLE_CEILING = 40;
869
+ var TITLE_SHARE = 0.1;
870
+ var SITE_SIZE = 18;
871
+ var MAX_TITLE_LINES = 3;
872
+ function embedCardTitleSize(short, scale) {
873
+ return snapFontSizeDown(Math.min(TITLE_CEILING * scale, Math.max(TITLE_SIZE * scale, TITLE_SHARE * short)));
874
+ }
875
+ function embedCardLayout(input) {
876
+ const { frame, scale: s } = input, floor = (input.minFontSizePx ?? 16) * s;
877
+ const short = Math.min(frame.width, frame.height);
878
+ const pad = Math.max(Math.min(6 * s, short / 4), Math.min(24 * s, short * 0.08));
879
+ const centerX = frame.x + frame.width / 2, centerY = frame.y + frame.height / 2;
880
+ const radius = Math.min(12 * s, short / 6);
881
+ const sizes = (grow) => {
882
+ const badge = Math.max(Math.min(short - 2 * pad, 40 * s * grow), Math.min(short / 2, 12 * s));
883
+ return { badge, gap: 10 * s * grow, siteGap: 6 * s * grow, siteSize: Math.max(floor, snapFontSizeDown(SITE_SIZE * s * grow)) };
884
+ };
885
+ const badgeLayout = (size, top2) => {
886
+ const badge = { x: round(centerX - size / 2), y: round(top2), width: round(size), height: round(size) };
887
+ const glyph = size * 0.56, arrow = { x: round(centerX - glyph / 2), y: round(top2 + (size - glyph) / 2), width: round(glyph), height: round(glyph) };
888
+ return { frame, radius, icon: { badge, arrow, points: embedArrowPoints(arrow) } };
889
+ };
890
+ const only = sizes(1).badge;
891
+ const badgeOnly = badgeLayout(only, centerY - only / 2);
892
+ const width = frame.width - 2 * pad, room = frame.height - 2 * pad;
893
+ if (!(width > 0) || !(room > 0)) return badgeOnly;
894
+ const headingStyle = resolveTextStyle({ fontFamily: input.headingFamily, fontWeight: 700 }, input.measurement);
895
+ const bodyStyle = resolveTextStyle({ fontFamily: input.bodyFamily, fontWeight: 400 }, input.measurement);
896
+ const measureTitle = textWidthMeasurer(headingStyle, input.measurement), measureSite = textWidthMeasurer(bodyStyle, input.measurement);
897
+ const left = frame.x + pad;
898
+ const clip = (text2, size, measure) => {
899
+ if (measure(text2, size) <= width) return text2;
900
+ let end = text2.length;
901
+ while (end > 0 && measure(`${text2.slice(0, end).trimEnd()}\u2026`, size) > width) end--;
902
+ return `${text2.slice(0, end).trimEnd()}\u2026`;
903
+ };
904
+ const text = (lines, size, lineHeight, clipped, style, measure) => ({ box: { x: left, y: 0, width, height: round(lines.length * lineHeight) }, lines, lineWidths: lines.map((line) => round(measure(line, size))), align: "center", fontSize: size, lineHeight, clipped, style });
905
+ const titleAt = (size, avail) => {
906
+ const fit = fitText(input.title, { x: left, y: 0, width, height: 1e6 }, size, size, measureTitle);
907
+ if (fit.lines.length <= MAX_TITLE_LINES && fit.lines.length * fit.lineHeight <= avail + 1e-6) return text(fit.lines, fit.fontSize, fit.lineHeight, false, headingStyle, measureTitle);
908
+ if (size > floor + 1e-9) return void 0;
909
+ const allowed = Math.min(MAX_TITLE_LINES, Math.floor((avail + 1e-6) / fit.lineHeight));
910
+ if (allowed < 1) return void 0;
911
+ const lines = fit.lines.slice(0, allowed);
912
+ lines[allowed - 1] = clip(fit.lines.slice(allowed - 1).join(" "), fit.fontSize, measureTitle);
913
+ return text(lines, fit.fontSize, fit.lineHeight, true, headingStyle, measureTitle);
914
+ };
915
+ const nominal = embedCardTitleSize(short, s);
916
+ const block = (withSite2) => {
917
+ for (let size = nominal; ; size = Math.max(floor, snapFontSizeDown(size - s))) {
918
+ const grow = Math.max(1, size / (TITLE_SIZE * s)), p2 = sizes(grow), siteLine2 = p2.siteSize * 1.3;
919
+ const title2 = titleAt(size, room - p2.badge - p2.gap - (withSite2 ? siteLine2 + p2.siteGap : 0));
920
+ if (title2 && (!title2.clipped || size <= floor + 1e-9)) return { title: title2, p: p2, siteLine: siteLine2, size };
921
+ if (size <= floor + 1e-9) return void 0;
922
+ }
923
+ };
924
+ let chosen = input.site === input.title ? void 0 : block(true), withSite = true;
925
+ if (!chosen || chosen.title.clipped) {
926
+ chosen = block(false);
927
+ withSite = false;
928
+ }
929
+ if (!chosen) return badgeOnly;
930
+ const { title, p, siteLine } = chosen;
931
+ const height = p.badge + p.gap + title.box.height + (withSite ? p.siteGap + siteLine : 0), top = centerY - height / 2;
932
+ const layout2 = badgeLayout(p.badge, top);
933
+ title.box.y = round(top + p.badge + p.gap);
934
+ layout2.title = title;
935
+ if (withSite) {
936
+ const site = text([clip(input.site, p.siteSize, measureSite)], p.siteSize, siteLine, false, bodyStyle, measureSite);
937
+ site.box.y = round(title.box.y + title.box.height + p.siteGap);
938
+ layout2.site = site;
939
+ }
940
+ return layout2;
941
+ }
942
+
852
943
  // src/edit.ts
853
944
  function edit(deck, patch, options = {}) {
854
945
  const result = applyPatchWithInverse(deck, patch, options.expectHash === void 0 ? {} : { expectHash: options.expectHash });
@@ -965,13 +1056,21 @@ function fill(template, data, options = {}) {
965
1056
  const records = data === void 0 ? [{}] : typeof data === "string" ? fillRecords(data, options) : Array.isArray(data) ? [...data] : [data];
966
1057
  if (!records.length) throw new OPFDataImportError("Data contains no records.");
967
1058
  if (!records.every(isRecord2)) throw new OPFDataImportError("Each record must be an object keyed by variable id.");
968
- const decks = records.map((record, offset) => ({ index: offset + 1, record, ...resolveVariables(template, record, { template: false, partial: options.partial === true, examples: options.examples === true }) }));
1059
+ const decks = records.map((record, offset) => {
1060
+ const resolved = resolveVariables(template, record, { template: false, partial: options.partial === true, examples: options.examples === true });
1061
+ const { id: _template, ...filled } = resolved.presentation;
1062
+ const presentation2 = updateMetricLiterals(filled);
1063
+ return { index: offset + 1, record, ...resolved, presentation: presentation2 };
1064
+ });
1065
+ const removed = /* @__PURE__ */ new Map();
1066
+ for (const deck of decks) for (const entry of deck.diagnostics) if (entry.code === "variable-translations-removed") removed.set(entry.id, [...removed.get(entry.id) ?? [], deck.index]);
969
1067
  return {
970
1068
  decks: decks.map(({ index, record, presentation: presentation2, diagnostics, unfilled, complete }) => ({ index, record, presentation: presentation2, diagnostics, unfilled, complete })),
971
1069
  ...options.combine ? { presentation: combine(decks) } : {},
972
1070
  complete: decks.every((deck) => deck.complete),
973
1071
  unfilled: [...new Set(decks.flatMap((deck) => deck.unfilled))],
974
- diagnostics: summarize(decks)
1072
+ diagnostics: summarize(decks),
1073
+ ...removed.size ? { translationsRemoved: [...removed].map(([id, records2]) => ({ id, records: records2 })) } : {}
975
1074
  };
976
1075
  }
977
1076
  function combine(decks) {
@@ -1011,4 +1110,4 @@ function summarize(decks) {
1011
1110
  return [...merged.values()];
1012
1111
  }
1013
1112
 
1014
- export { DEFAULT_FIX_ROUNDS, FIX_REPAIR_CATEGORIES, OPFApiError, OPFExportError, OPFImportError, OPFMoveToCustomError, asApiError, copySlides, edit, embed, fill, fillRecords, fix, isSafePatch, localAssetSources, moveToCustom, parseSlideSelection, sameRecord, stats, updateFromCatalog };
1113
+ export { DEFAULT_FIX_ROUNDS, FIX_REPAIR_CATEGORIES, OPFApiError, OPFExportError, OPFImportError, OPFMoveToCustomError, asApiError, copySlides, edit, embed, embedArrowPoints, embedCardLayout, fill, fillRecords, fix, isSafePatch, localAssetSources, moveToCustom, parseSlideSelection, sameRecord, stats, updateFromCatalog };