@openpresentation/opf 0.33.0 → 0.34.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 (93) hide show
  1. package/README.md +3 -3
  2. package/dist/browser.js +20 -19
  3. package/dist/catalog-refs-CoIrOdAw.d.ts +937 -0
  4. package/dist/{catalog-schemas-CQTM-G8p.d.ts → catalog-schemas-FjLRPtjB.d.ts} +1 -1
  5. package/dist/{chart-data-oIZQlFGi.d.ts → chart-data-B_k-WTex.d.ts} +7 -4
  6. package/dist/{chunk-XIOC6N5P.js → chunk-244OPLAV.js} +1 -1
  7. package/dist/{chunk-S5QRGMUQ.js → chunk-2HX4BGAS.js} +6 -6
  8. package/dist/{chunk-Y557TYML.js → chunk-36DLVJGW.js} +19 -16
  9. package/dist/{chunk-VKEYV3ZK.js → chunk-3THGTDL2.js} +2 -2
  10. package/dist/{chunk-ABWEUXLV.js → chunk-42JBXJKW.js} +117 -21
  11. package/dist/chunk-BLCDUM7B.js +7 -0
  12. package/dist/{chunk-OPVJLL7H.js → chunk-CJVKOJ6B.js} +11841 -8687
  13. package/dist/{chunk-BI4ERFAA.js → chunk-DQ7QYOUV.js} +48 -13
  14. package/dist/{chunk-KVHNDHVS.js → chunk-F6BXO4AI.js} +1 -1
  15. package/dist/{chunk-UK3J6FSU.js → chunk-FAXO3SUE.js} +858 -268
  16. package/dist/{chunk-XANW7MB7.js → chunk-FIQMAIZV.js} +4 -4
  17. package/dist/{chunk-PJSPHHRK.js → chunk-FK5XG742.js} +3 -16
  18. package/dist/{chunk-R6C6BQOG.js → chunk-HHVQ2SDT.js} +1 -1
  19. package/dist/{chunk-DAS75LGR.js → chunk-HUGVYHZ2.js} +4 -4
  20. package/dist/{chunk-QF5RSRXU.js → chunk-LCT5ZV3Q.js} +750 -199
  21. package/dist/chunk-NLJFNCZ4.js +1560 -0
  22. package/dist/{chunk-VSBZC2PR.js → chunk-QGJVOPLG.js} +3 -3
  23. package/dist/{chunk-E7WQHMCL.js → chunk-QGTJF7HV.js} +16 -14
  24. package/dist/{chunk-VMBLNCX2.js → chunk-RUV7CCE6.js} +117 -30
  25. package/dist/{chunk-YS333HLA.js → chunk-U7TYSPYM.js} +2 -2
  26. package/dist/chunk-UJZN2ZH6.js +1 -0
  27. package/dist/{chunk-IJXKVM4W.js → chunk-VDZXNNZF.js} +1 -1
  28. package/dist/{chunk-YYT6N7AI.js → chunk-WCPDN7AY.js} +1 -1
  29. package/dist/{chunk-QD6DPS7X.js → chunk-WMFT5R7I.js} +2 -2
  30. package/dist/{chunk-INIMUBSE.js → chunk-XJUMFH33.js} +1 -1
  31. package/dist/{composition-zMiIgzip.d.ts → composition-CvtvgBDE.d.ts} +1360 -1531
  32. package/dist/composition.d.ts +3 -3
  33. package/dist/composition.js +2 -1
  34. package/dist/{conversion-mNth9XKm.d.ts → conversion-B_5AKTYQ.d.ts} +25 -7
  35. package/dist/conversion-CMBGOTAC.js +25 -0
  36. package/dist/convert.d.ts +4 -4
  37. package/dist/convert.js +15 -11
  38. package/dist/data.d.ts +2 -2
  39. package/dist/data.js +3 -2
  40. package/dist/{deck-report-BSlRiR0_.d.ts → deck-report-BVlQZ42f.d.ts} +3 -3
  41. package/dist/deck.d.ts +6 -6
  42. package/dist/deck.js +12 -11
  43. package/dist/diagram-engine-eager.js +5 -1
  44. package/dist/diagram-engine-lazy.js +13 -0
  45. package/dist/diagram-plantuml-XRZ6VAOL.js +3 -0
  46. package/dist/diff.js +5 -4
  47. package/dist/docs.js +64 -52
  48. package/dist/examples.js +4070 -1083
  49. package/dist/font-policy.js +1 -1
  50. package/dist/format.js +2 -2
  51. package/dist/ids.js +5 -4
  52. package/dist/index.d.ts +18 -16
  53. package/dist/index.js +35 -24
  54. package/dist/markdown.d.ts +2 -2
  55. package/dist/markdown.js +9 -8
  56. package/dist/node-engine.d.ts +43 -11
  57. package/dist/node-engine.js +45 -26
  58. package/dist/{pagination-CYzNMazO.d.ts → pagination-CZQQYk7L.d.ts} +4 -3
  59. package/dist/pagination.d.ts +4 -4
  60. package/dist/pagination.js +5 -4
  61. package/dist/patch.js +4 -3
  62. package/dist/precompiled.js +2 -2
  63. package/dist/{presentation-CXhfpB_z.d.ts → presentation-s9262acV.d.ts} +357 -230
  64. package/dist/repo-readme.js +1 -1
  65. package/dist/schema-engine-ajv.js +1 -1
  66. package/dist/schema-engine-precompiled.js +2 -2
  67. package/dist/schema.d.ts +3 -3
  68. package/dist/schema.js +4 -3
  69. package/dist/schemas.d.ts +16 -0
  70. package/dist/schemas.js +1 -1
  71. package/dist/shape-engine-eager.js +2 -2
  72. package/dist/shape-engine-lazy.js +1 -1
  73. package/dist/{shape-engine-module-BK7JNEUV.js → shape-engine-module-N74FCHGY.js} +2 -2
  74. package/dist/shape-geometry.js +1 -1
  75. package/dist/source.d.ts +10 -5
  76. package/dist/source.js +11 -10
  77. package/dist/spec/reference/engine-vocabularies.json +135 -0
  78. package/dist/spec/reference/font-policy.json +3 -16
  79. package/dist/spec/reference/preset-geometry.json +3 -3
  80. package/dist/spec/schemas/icon-set.schema.json +1 -1
  81. package/dist/spec/schemas/layout.schema.json +71 -25
  82. package/dist/spec/schemas/opf.schema.json +540 -168
  83. package/dist/spec/schemas/theme.schema.json +11 -5
  84. package/dist/types.d.ts +81 -73
  85. package/dist/{validation-types-COwTel3H.d.ts → validation-types-CYbsUuZ9.d.ts} +8 -5
  86. package/dist/validator.d.ts +34 -7
  87. package/dist/validator.js +4 -3
  88. package/dist/yaml.d.ts +2 -2
  89. package/dist/yaml.js +8 -7
  90. package/package.json +6 -6
  91. package/dist/catalog-refs-B_0_vZg0.d.ts +0 -134
  92. package/dist/chunk-ZXOIGUHX.js +0 -1
  93. package/dist/conversion-POHRAMSN.js +0 -24
@@ -1,5 +1,5 @@
1
- import { jsonEqual, formatPointer } from './chunk-UK3J6FSU.js';
2
- import { annotationText } from './chunk-OPVJLL7H.js';
1
+ import { jsonEqual, formatPointer } from './chunk-FAXO3SUE.js';
2
+ import { annotationText } from './chunk-CJVKOJ6B.js';
3
3
 
4
4
  // src/diff-match.ts
5
5
  var DEFAULT_MATCH_THRESHOLD = 0.5;
@@ -372,7 +372,7 @@ function merge(base, ours, theirs, options = {}) {
372
372
 
373
373
  // src/diff.ts
374
374
  var isObject3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
375
- var REGION_KEY = /^(top|middle|bottom|left|center|right)([:+].*)?$/u;
375
+ var REGION_KEY = /^(top|middle|bottom|start|center|end)([:+].*)?$/u;
376
376
  var ROOT_CATEGORIES = { design: "design", assets: "assets", datasets: "datasets", catalogs: "catalogs", variables: "variables", narrative: "narrative", extensions: "extensions" };
377
377
  function categoryOf(tokens) {
378
378
  const [root] = tokens;
@@ -1,10 +1,10 @@
1
1
  import { NOT_CHECKED } from './chunk-RYZPBJLB.js';
2
- import { readMarkdown, parseSlideText, escapeInline, serializeRuns } from './chunk-Y557TYML.js';
3
- import { fenceCode } from './chunk-KVHNDHVS.js';
4
- import { OPFMarkdownError, writeYaml, Ctx, readYamlMapping, csvField, scalarText } from './chunk-QD6DPS7X.js';
5
- import { same, isRecord, runText, isPlainRun, FORMATTING } from './chunk-VKEYV3ZK.js';
6
- import { validate } from './chunk-UK3J6FSU.js';
7
- import { checkCatalogsOption } from './chunk-OPVJLL7H.js';
2
+ import { readMarkdown, parseSlideText, escapeInline, serializeRuns } from './chunk-36DLVJGW.js';
3
+ import { fenceCode } from './chunk-F6BXO4AI.js';
4
+ import { OPFMarkdownError, writeYaml, Ctx, readYamlMapping, csvField, scalarText } from './chunk-WMFT5R7I.js';
5
+ import { same, isRecord, runText, isPlainRun, FORMATTING } from './chunk-3THGTDL2.js';
6
+ import { validate } from './chunk-FAXO3SUE.js';
7
+ import { checkCatalogsOption } from './chunk-CJVKOJ6B.js';
8
8
 
9
9
  // src/markdown/canon.ts
10
10
  var FORMAT_KEYS = FORMATTING;
@@ -109,9 +109,10 @@ function canonDiagram(value) {
109
109
  const source = typeof value === "string" ? value : isRecord(value) ? value.source : void 0;
110
110
  if (typeof source !== "string" || !source.trim() || source.includes("\r") || /^[ \t]*\n|\n[ \t]*$/.test(source)) return void 0;
111
111
  if (typeof value === "string") return value;
112
- if (!isRecord(value) || !only(value, ["source", "syntax", "alt"]) || value.syntax !== void 0 && value.syntax !== "mermaid") return void 0;
112
+ if (!isRecord(value) || !only(value, ["source", "syntax", "alt"]) || value.syntax !== void 0 && value.syntax !== "mermaid" && value.syntax !== "dot" && value.syntax !== "plantuml") return void 0;
113
113
  if (value.alt !== void 0 && typeof value.alt !== "string") return void 0;
114
- return value.alt === void 0 ? source : { source, alt: value.alt };
114
+ if (value.alt === void 0 && (value.syntax === void 0 || value.syntax === "mermaid")) return source;
115
+ return { source, ...value.syntax === "dot" || value.syntax === "plantuml" ? { syntax: value.syntax } : {}, ...value.alt === void 0 ? {} : { alt: value.alt } };
115
116
  }
116
117
  function canonMetric(value) {
117
118
  if (typeof value === "string" || typeof value === "number") return value;
@@ -230,9 +231,9 @@ function canonContent(key, value) {
230
231
  var CONTENT = ["text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram"];
231
232
  var isContent = (key) => CONTENT.includes(key);
232
233
  var ROWS = "(?:top|middle|bottom|top\\+middle|middle\\+bottom|top\\+middle\\+bottom)";
233
- var COLUMNS = "(?:left|center|right|left\\+center|center\\+right|left\\+center\\+right)";
234
+ var COLUMNS = "(?:start|center|end|start\\+center|center\\+end|start\\+center\\+end)";
234
235
  var REGION = new RegExp(`^(?:${ROWS}(?::${COLUMNS})?|${COLUMNS})$`);
235
- var NATIVE_SLIDE = /* @__PURE__ */ new Set(["id", "type", "layout", "section", "tag", "hidden", "beat", "title", "subtitle", "notes", "blocks", ...CONTENT]);
236
+ var NATIVE_SLIDE = /* @__PURE__ */ new Set(["id", "type", "layout", "section", "tag", "hidden", "beat", "language", "title", "subtitle", "notes", "blocks", ...CONTENT]);
236
237
  function fenceFor(body, char = "`") {
237
238
  let longest = 2;
238
239
  for (const line of body) for (const run of line.matchAll(char === "`" ? /`+/g : /~+/g)) longest = Math.max(longest, run[0].length);
@@ -327,6 +328,7 @@ function timelineLines(timeline) {
327
328
  const info = ["timeline", ...["name", "description"].filter((key) => meta[key] !== void 0).map((key) => `${key}=${JSON.stringify(meta[key])}`)].join(" ");
328
329
  const body = [];
329
330
  for (const event of events) {
331
+ if (event.duration !== void 0) return void 0;
330
332
  for (const key of ["when", "what", "description"]) if (typeof event[key] === "string" && (/[\r\n]/.test(event[key]) || event[key] !== event[key].trim() || event[key] === "")) return void 0;
331
333
  const line = event.when === void 0 ? event.what : `${event.when} \u2014 ${event.what}`;
332
334
  if (event.status === void 0 && /^\[[x> ]\]\s+\S/.test(line)) return void 0;
@@ -337,11 +339,11 @@ function timelineLines(timeline) {
337
339
  }
338
340
  function diagramLines(diagram) {
339
341
  const value = typeof diagram === "string" ? { source: diagram } : diagram;
340
- const source = value.source, alt = value.alt;
342
+ const source = value.source, alt = value.alt, syntax = value.syntax === "dot" || value.syntax === "plantuml" ? value.syntax : "mermaid";
341
343
  if (alt !== void 0 && (alt.includes("`") || /[\r\n]/.test(alt))) return void 0;
342
344
  const longest = Math.max(2, ...[...source.matchAll(/`+/g)].map((match) => match[0].length));
343
345
  const fence = "`".repeat(longest + 1);
344
- return [`${fence}mermaid${alt === void 0 ? "" : ` alt=${JSON.stringify(alt)}`}`, ...source.split("\n"), fence];
346
+ return [`${fence}${syntax}${alt === void 0 ? "" : ` alt=${JSON.stringify(alt)}`}`, ...source.split("\n"), fence];
345
347
  }
346
348
  function metricLines(metric) {
347
349
  const value = typeof metric === "object" ? metric : { value: metric };
@@ -395,7 +397,7 @@ function nativeLines(key, canon, marker) {
395
397
  case "code": {
396
398
  const code = typeof canon === "string" ? { source: canon } : canon;
397
399
  const language = code.language;
398
- if (language !== void 0 && (!/^[A-Za-z0-9_+#.-]+$/.test(language) || ["chart", "metric", "timeline", "mermaid", "opf-slide", "opf-block"].includes(language))) return void 0;
400
+ if (language !== void 0 && (!/^[A-Za-z0-9_+#.-]+$/.test(language) || ["chart", "metric", "timeline", "mermaid", "dot", "plantuml", "opf-slide", "opf-block"].includes(language))) return void 0;
399
401
  return fenceCode(code.source, language, code.filename);
400
402
  }
401
403
  case "metric":
@@ -458,7 +460,7 @@ function emitSlide(slide, index, mode) {
458
460
  } else loss.push({ path: where, message: reason });
459
461
  };
460
462
  const options = [];
461
- const optionFields = [["id", slide.id], ["type", slide.type], ["beat", slide.beat], ["layout", slide.layout], ["section", slide.section], ["tag", slide.tag]];
463
+ const optionFields = [["id", slide.id], ["type", slide.type], ["beat", slide.beat], ["layout", slide.layout], ["section", slide.section], ["tag", slide.tag], ["language", slide.language]];
462
464
  const failed = [];
463
465
  for (const [key, value] of optionFields) {
464
466
  if (value === void 0) continue;
@@ -1,9 +1,9 @@
1
- import { defaultCatalogs } from './chunk-INIMUBSE.js';
2
- import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-DAS75LGR.js';
3
- import { paginate, continueOverfull } from './chunk-ABWEUXLV.js';
4
- import { deckFormatOf, readDeckReport, stringify } from './chunk-XANW7MB7.js';
5
- import { validate, OPFValidationError } from './chunk-UK3J6FSU.js';
6
- import { ensureIcons } from './chunk-OPVJLL7H.js';
1
+ import { defaultCatalogs } from './chunk-XJUMFH33.js';
2
+ import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-HUGVYHZ2.js';
3
+ import { paginate, continueOverfull } from './chunk-42JBXJKW.js';
4
+ import { deckFormatOf, readDeckReport, stringify } from './chunk-FIQMAIZV.js';
5
+ import { validate, OPFValidationError } from './chunk-FAXO3SUE.js';
6
+ import { ensureIcons } from './chunk-CJVKOJ6B.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';
@@ -122,9 +122,16 @@ function localAssetProblems(deck, root) {
122
122
  }
123
123
  return problems;
124
124
  }
125
+ function iconSourceReader(root, resolver = createImageResolver(root, { add() {
126
+ } })) {
127
+ return async (source) => {
128
+ const uri = resolver.forMeasure(source);
129
+ return uri?.startsWith("data:image/svg+xml;base64,") ? Buffer.from(uri.slice(26), "base64").toString("utf8") : void 0;
130
+ };
131
+ }
125
132
  var RENDER_PACKAGE = "@openpresentation/opf-render";
126
133
  var PPTX_PACKAGE = "@openpresentation/opf-pptx";
127
- var PEER_RANGES = { [RENDER_PACKAGE]: "^0.33.0", [PPTX_PACKAGE]: "^0.33.0" };
134
+ var PEER_RANGES = { [RENDER_PACKAGE]: "^0.34.0", [PPTX_PACKAGE]: "^0.34.0" };
128
135
  var PPTX_TEXT_OPTIONS_FROM = "0.22.0";
129
136
  var numbers = (version) => version.replace(/[-+].*$/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
130
137
  function atLeast(version, minimum) {
@@ -160,7 +167,8 @@ var hint = (name) => `${name} is not installed. It is an optional peer of @openp
160
167
  npx -p @openpresentation/cli -p @openpresentation/opf-render -p @openpresentation/opf-pptx opf <command> ... (one run)` + (name === RENDER_PACKAGE ? `
161
168
  ${renderHint()}` : "");
162
169
  function bases() {
163
- return [import.meta.url, pathToFileURL(path6.join(process.cwd(), "noop.js")).href];
170
+ const here = import.meta.url;
171
+ return [...typeof here === "string" ? [here] : [], pathToFileURL(path6.join(process.cwd(), "noop.js")).href];
164
172
  }
165
173
  function locate(specifier) {
166
174
  for (const base of bases()) {
@@ -275,7 +283,7 @@ async function listFontDirectories(directories, label = "--fonts") {
275
283
  }
276
284
  return files;
277
285
  }
278
- async function prepareFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false) {
286
+ async function prepareFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false, renderOptions) {
279
287
  try {
280
288
  const handle = await renderer.fonts.loadFonts({
281
289
  pack: "office",
@@ -283,6 +291,7 @@ async function prepareFonts(renderer, presentation, userFonts, reporter, embedSc
283
291
  scripts: "auto",
284
292
  embedScriptFonts,
285
293
  presentation,
294
+ ...renderOptions ? { renderOptions } : {},
286
295
  faces: userFonts.map((file) => ({ path: file })),
287
296
  onDiagnostic: (diagnostic) => reporter.add("fonts", scriptDiagnostic(diagnostic))
288
297
  });
@@ -299,10 +308,10 @@ async function prepareFonts(renderer, presentation, userFonts, reporter, embedSc
299
308
  }
300
309
  var NEUTRAL_DECK = { slides: [] };
301
310
  var shared = /* @__PURE__ */ new Map();
302
- async function leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false) {
311
+ async function leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false, renderOptions) {
303
312
  const select = renderer.fonts.autoScriptSelection;
304
313
  if (typeof select !== "function") return void 0;
305
- const selection = select(presentation);
314
+ const selection = select(presentation, renderOptions);
306
315
  if (selection.detected?.length || selection.scripts?.length || selection.unavailable?.length) return void 0;
307
316
  const key = JSON.stringify([userFonts, embedScriptFonts]);
308
317
  let entry = shared.get(key);
@@ -324,14 +333,22 @@ async function leaseSharedFonts(renderer, presentation, userFonts, reporter, emb
324
333
  release = resolve;
325
334
  });
326
335
  await previous;
327
- const pending = handle.pending;
328
- if (typeof pending === "function" && pending.call(handle, presentation).length) {
336
+ try {
337
+ const prepared = handle;
338
+ if (typeof prepared.pending === "function" && prepared.pending(presentation, renderOptions).length) {
339
+ if (typeof prepared.ensure !== "function") {
340
+ release();
341
+ return void 0;
342
+ }
343
+ await prepared.ensure(presentation, { renderOptions, onDiagnostic: (diagnostic) => reporter.add("fonts", diagnostic) });
344
+ }
345
+ handle.registry?.clearSubstitutions?.();
346
+ for (const diagnostic of diagnostics) reporter.add("fonts", diagnostic);
347
+ return { handle, release };
348
+ } catch (error) {
329
349
  release();
330
- return void 0;
350
+ throw error;
331
351
  }
332
- handle.registry?.clearSubstitutions?.();
333
- for (const diagnostic of diagnostics) reporter.add("fonts", diagnostic);
334
- return { handle, release };
335
352
  }
336
353
  function scriptDiagnostic(diagnostic) {
337
354
  if (diagnostic.code !== "script-font-not-installed") return diagnostic;
@@ -470,7 +487,8 @@ var INFO = /* @__PURE__ */ new Set([
470
487
  "picture-not-measured",
471
488
  "diagram-shapes-unavailable",
472
489
  "smartart-unavailable",
473
- "arrangement-adapted"
490
+ "arrangement-adapted",
491
+ "prepared-late"
474
492
  ]);
475
493
  var HELP = {
476
494
  "text-overflow": "Shorten the text, or split the slide: add --paginate (measured with the same fonts) or run opf paginate.",
@@ -495,6 +513,7 @@ var HELP = {
495
513
  "typeface-replaced": "Drop --typefaces safe to keep the selected families in the file.",
496
514
  "diagram-shapes-unavailable": "The diagram stays one picture in PowerPoint (see the message). It looks the same; to edit it, change its source in OPF and export again.",
497
515
  "smartart-unavailable": "The pyramid, matrix or cycle is exported as editable native shapes, which look the same; live SmartArt is written only where PowerPoint draws it exactly as the preview (docs/smartart.md). Shorten the entries named in the message, or give the region other proportions, to get live SmartArt. When the message names the fallback picture, install @openpresentation/opf-render: every live SmartArt carries OPF's picture of it for apps without SmartArt.",
516
+ "prepared-late": "Nothing to change in the deck: the output is correct. OPF prepared this face only when the export measured it, which its font analysis should have foreseen; please report the deck so the analysis covers it.",
498
517
  "duplicate-font-face": "A --fonts face repeats a bundled family, weight and style; remove it or rename the family.",
499
518
  "shape-property-dropped": "OPF has no form for this property of a PowerPoint shape (3-D, preset shadows, autofit and the others in docs/shapes.md); it was dropped and the shape imported. Set it again in the PowerPoint file if it matters.",
500
519
  "shape-covers-content": "An overlay shape is always drawn over the content, and OPF has no layer behind it: give the content a card, or the slide a background, instead of a shape behind it.",
@@ -503,8 +522,29 @@ var HELP = {
503
522
  var Reporter = class {
504
523
  findings = [];
505
524
  seen = /* @__PURE__ */ new Set();
525
+ /** The identity key of each finding, by index ("" for the initial findings, which are not deduplicated). */
526
+ keys = [];
506
527
  constructor(initial = []) {
507
- for (const item of initial) this.findings.push(item);
528
+ for (const item of initial) {
529
+ this.findings.push(item);
530
+ this.keys.push("");
531
+ }
532
+ }
533
+ /** The point `withdrawErrors` looks back to: the number of findings so far. */
534
+ mark() {
535
+ return this.findings.length;
536
+ }
537
+ /**
538
+ * Withdraw the error findings added after `mark`: the failure of an attempt that is run again (RR-105). Its other findings stay; the
539
+ * next attempt repeats them and they are kept once.
540
+ */
541
+ withdrawErrors(mark) {
542
+ for (let index = this.findings.length - 1; index >= mark; index--) {
543
+ if (this.findings[index]?.severity !== "error") continue;
544
+ this.seen.delete(this.keys[index] ?? "");
545
+ this.findings.splice(index, 1);
546
+ this.keys.splice(index, 1);
547
+ }
508
548
  }
509
549
  /** Add a library diagnostic (`code`, `path`, `message` and details). Identical entries are kept once. */
510
550
  add(source, diagnostic, severity) {
@@ -522,6 +562,7 @@ var Reporter = class {
522
562
  const key = JSON.stringify([entry.ruleId, entry.path, entry.message, details]);
523
563
  if (this.seen.has(key)) return;
524
564
  this.seen.add(key);
565
+ this.keys.push(key);
525
566
  this.findings.push(entry);
526
567
  }
527
568
  /** Add a finding as the library made it (the `findings` of a thrown OPFRenderError, OPFPptxError or core validation error). Identical entries are kept once. */
@@ -529,6 +570,7 @@ var Reporter = class {
529
570
  const key = JSON.stringify(finding);
530
571
  if (this.seen.has(key)) return;
531
572
  this.seen.add(key);
573
+ this.keys.push(key);
532
574
  this.findings.push(finding);
533
575
  }
534
576
  error(source, code, message, where = "", details = {}) {
@@ -707,19 +749,53 @@ async function runExport(presentation, options, ctx) {
707
749
  const pptx = format === "pptx" ? ctx.pptx ?? await loadPptx() : void 0;
708
750
  const userFonts = options.fonts ? [] : ctx.userFonts ?? await listFontDirectories(options.fontFolders, ctx.flags ? "--fonts" : "fonts");
709
751
  const resolver = createImageResolver(assetRoot(options.assetDir, ctx.flags), reporter, ctx.flags ? "pass --asset-dir" : "pass assetDir");
710
- await ensureIcons(presentation, { catalogs, readSource: async (source) => {
711
- const uri = resolver.forMeasure(source);
712
- return uri?.startsWith("data:image/svg+xml;base64,") ? Buffer.from(uri.slice(26), "base64").toString("utf8") : void 0;
713
- } });
752
+ await ensureIcons(presentation, { catalogs, readSource: iconSourceReader(void 0, resolver) });
714
753
  const embedScripts = format === "svg" && options.text === "fonts";
715
- const lease = options.fonts ? void 0 : await leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScripts);
754
+ const lease = options.fonts ? void 0 : await leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScripts, { catalogs, ...date ? { date } : {} });
716
755
  try {
717
- const handle = options.fonts ?? lease?.handle ?? (await prepareFonts(renderer, presentation, userFonts, reporter, embedScripts)).handle;
718
- return await drawWith(presentation, handle, options, ctx, { reporter, catalogs, date, renderer, ...pptx ? { pptx } : {}, userFonts, resolver });
756
+ const handle = options.fonts ?? lease?.handle ?? (await prepareFonts(renderer, presentation, userFonts, reporter, embedScripts, { catalogs, ...date ? { date } : {} })).handle;
757
+ if (options.fonts && handle.registry?.fontNames) await handle.ensure?.(presentation, { renderOptions: { catalogs, ...date ? { date } : {} } });
758
+ const environment = { reporter, catalogs, date, renderer, ...pptx ? { pptx } : {}, userFonts, resolver };
759
+ const late = /* @__PURE__ */ new Set();
760
+ for (let round = 0; ; round++) {
761
+ const mark = reporter.mark();
762
+ const result = await drawWith(presentation, handle, options, ctx, environment);
763
+ const face = result.failure ? unpreparedFace(thrownBy.get(result)) : void 0;
764
+ if (!face || round >= LATE_FACE_ROUNDS || late.has(face.key) || typeof handle.ensure !== "function" || !handle.registry?.fontNames) return result;
765
+ late.add(face.key);
766
+ try {
767
+ await handle.ensure(presentation, { renderOptions: { catalogs, ...date ? { date } : {} }, measurementRequests: [{ text: " ", size: 16, style: face.style }] });
768
+ } catch {
769
+ return result;
770
+ }
771
+ reporter.withdrawErrors(mark);
772
+ reporter.add(
773
+ "fonts",
774
+ { code: "prepared-late", path: face.path, message: `${face.style.fontFamily} ${face.style.fontWeight}${face.style.italic ? " italic" : ""} was prepared only when the export measured it; the export ran again with it.`, fontFamily: face.style.fontFamily, fontWeight: face.style.fontWeight, italic: face.style.italic },
775
+ "info"
776
+ );
777
+ }
719
778
  } finally {
720
779
  lease?.release();
721
780
  }
722
781
  }
782
+ var LATE_FACE_ROUNDS = 4;
783
+ var thrownBy = /* @__PURE__ */ new WeakMap();
784
+ var failedWith = (run, error) => {
785
+ thrownBy.set(run, error);
786
+ return run;
787
+ };
788
+ function unpreparedFace(error) {
789
+ let current = error;
790
+ for (let depth = 0; current && depth < 3; depth++, current = current.cause) {
791
+ const details = current.details;
792
+ if (current.code !== "font-unavailable" || typeof current.message !== "string" || !current.message.startsWith("The selected face is not prepared") || !details) continue;
793
+ const { fontFamily, fontWeight, italic, path: path7 } = details;
794
+ if (typeof fontFamily !== "string" || !fontFamily.trim() || typeof fontWeight !== "number" || !Number.isFinite(fontWeight) || typeof italic !== "boolean") return void 0;
795
+ return { key: JSON.stringify([fontFamily.toLowerCase(), fontWeight, italic]), path: typeof path7 === "string" ? path7 : "", style: { fontFamily, fontWeight, italic } };
796
+ }
797
+ return void 0;
798
+ }
723
799
  async function drawWith(presentation, handle, options, ctx, environment) {
724
800
  const { format, scale } = options;
725
801
  const { reporter, catalogs, date, renderer, pptx, userFonts, resolver } = environment;
@@ -740,7 +816,7 @@ async function drawWith(presentation, handle, options, ctx, environment) {
740
816
  pagination = { pages: result.pages };
741
817
  } catch (error) {
742
818
  reportThrown(reporter, "render", error);
743
- return { files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) };
819
+ return failedWith({ files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) }, error);
744
820
  }
745
821
  } else if (options.paginate !== false) {
746
822
  const source = format === "pptx" ? "pptx" : "render";
@@ -766,9 +842,10 @@ async function drawWith(presentation, handle, options, ctx, environment) {
766
842
  }
767
843
  } catch (error) {
768
844
  reportThrown(reporter, source, error);
769
- return { files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) };
845
+ return failedWith({ files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) }, error);
770
846
  }
771
847
  }
848
+ if (deck !== presentation && handle.registry?.fontNames) await handle.ensure?.(deck, { renderOptions: { catalogs, ...date ? { date } : {} } });
772
849
  const pictureLuminance = options.measurePictures === false ? void 0 : await measurePictureBackgrounds(renderer, deck, resolver, catalogs, reporter);
773
850
  const slideCount = deck.slides?.length ?? 0;
774
851
  const isHidden = (number) => deck.slides?.[number - 1]?.hidden === true;
@@ -777,6 +854,16 @@ async function drawWith(presentation, handle, options, ctx, environment) {
777
854
  const named = options.slides === void 0 ? void 0 : parseSlideSelection(options.slides, slideCount, slidesLabel);
778
855
  const selected = format === "pptx" ? [] : named ?? (options.includeHidden ? everySlide : everySlide.filter((number) => !isHidden(number)));
779
856
  const skippedHidden = format === "pptx" || named || options.includeHidden ? [] : everySlide.filter(isHidden);
857
+ if (format !== "pptx" || options.as === "images") {
858
+ const rules = ["opf/chart-mapping-adapted", "opf/chart-series-dropped"];
859
+ const chartCheck = validate(deck, { only: rules, catalogs });
860
+ for (const finding of chartCheck.findings) {
861
+ if (finding.severity !== "warning" || !rules.includes(finding.ruleId)) continue;
862
+ const sourceIndex = /^\/slides\/(\d+)(?:\/|$)/.exec(finding.path)?.[1];
863
+ if (format !== "pptx" && (sourceIndex === void 0 || !selected.includes(Number(sourceIndex) + 1))) continue;
864
+ if (!reporter.findings.some((existing) => existing.ruleId === finding.ruleId && existing.path === finding.path && existing.message === finding.message)) reporter.addFinding(finding);
865
+ }
866
+ }
780
867
  if (format !== "pptx" && !selected.length)
781
868
  throw new OPFApiError(skippedHidden.length ? ctx.flags ? "Every slide is hidden. Use --include-hidden to write them, or --slides to name slides." : "Every slide is hidden. Use includeHidden to write them, or slides to name slides." : "The presentation has no slides.", skippedHidden.length ? "all-slides-hidden" : "no-slides");
782
869
  const stem = deckStem(options.name === void 0 ? deck : { filename: options.name }, "-");
@@ -871,7 +958,7 @@ async function drawWith(presentation, handle, options, ctx, environment) {
871
958
  const missing = missingPeerFrom(error);
872
959
  if (missing) throw missing;
873
960
  reportThrown(reporter, format === "pptx" ? "pptx" : "render", error);
874
- return { files: [], fonts: fontSummary(), ...pagination ? { pagination } : {}, skippedHidden: [], failure: failureOf(error) };
961
+ return failedWith({ files: [], fonts: fontSummary(), ...pagination ? { pagination } : {}, skippedHidden: [], failure: failureOf(error) }, error);
875
962
  }
876
963
  }
877
964
  async function measurePictureBackgrounds(renderer, deck, resolver, catalogs, reporter) {
@@ -1197,4 +1284,4 @@ async function saveDeck(presentation, file, options = {}) {
1197
1284
  return { path: file, format };
1198
1285
  }
1199
1286
 
1200
- export { EXPORT_FORMATS, EXPORT_TEXT, PEER_RANGES, PPTX_PACKAGE, RENDER_EXTRAS, RENDER_PACKAGE, Reporter, VERSIONS, assetRoot, checkDate, checkDestinations, checkOptions, checkOutputPattern, checkRenamedOptions, checkScale, convertFiles, createZip, deckFileFormat, deckStem, embeddedFor, exportFormatOf, finishReport, importPresentation, leaseSharedFonts, listFontDirectories, loadPptx, loadRenderer, localAssetProblems, locatePackage, missingPeerFrom, openDeck, padNumber, planConversion, pointerOf, prepareExport, prepareFonts, publishNew, reaches, readInput, reportThrown, resolveExportOptions, runExport, runImport, runPreparedExport, saveDeck, stemOf, writeFiles, writePlanned };
1287
+ export { EXPORT_FORMATS, EXPORT_TEXT, PEER_RANGES, PPTX_PACKAGE, RENDER_EXTRAS, RENDER_PACKAGE, Reporter, VERSIONS, assetRoot, checkDate, checkDestinations, checkOptions, checkOutputPattern, checkRenamedOptions, checkScale, convertFiles, createZip, deckFileFormat, deckStem, embeddedFor, exportFormatOf, finishReport, iconSourceReader, importPresentation, leaseSharedFonts, listFontDirectories, loadPptx, loadRenderer, localAssetProblems, locatePackage, missingPeerFrom, openDeck, padNumber, planConversion, pointerOf, prepareExport, prepareFonts, publishNew, reaches, readInput, reportThrown, resolveExportOptions, runExport, runImport, runPreparedExport, saveDeck, stemOf, writeFiles, writePlanned };
@@ -1,5 +1,5 @@
1
- import { applyPatch, normalizePatch, walkPatch, toIdPointer, resolveIdPointer, parsePointer, readPointer, idToken, formatPointer, isIdToken } from './chunk-UK3J6FSU.js';
2
- import { isRecord, visitContentPayloads, promotedRegionKeys } from './chunk-OPVJLL7H.js';
1
+ import { applyPatch, normalizePatch, walkPatch, toIdPointer, resolveIdPointer, parsePointer, readPointer, idToken, formatPointer, isIdToken } from './chunk-FAXO3SUE.js';
2
+ import { isRecord, visitContentPayloads, promotedRegionKeys } from './chunk-CJVKOJ6B.js';
3
3
 
4
4
  // src/ids.ts
5
5
  var INDEX_TOKEN = /^(0|[1-9][0-9]*)$/;