@openpresentation/opf 0.32.1 → 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 (105) hide show
  1. package/README.md +9 -0
  2. package/dist/browser.js +22 -21
  3. package/dist/catalog-refs-CoIrOdAw.d.ts +937 -0
  4. package/dist/{catalog-schemas-LdqOPebq.d.ts → catalog-schemas-FjLRPtjB.d.ts} +10 -4
  5. package/dist/{chart-data-oIZQlFGi.d.ts → chart-data-B_k-WTex.d.ts} +7 -4
  6. package/dist/{chunk-PB7ME64J.js → chunk-244OPLAV.js} +1 -1
  7. package/dist/{chunk-IT7FQKED.js → chunk-2HX4BGAS.js} +6 -6
  8. package/dist/{chunk-2E6CDYL2.js → chunk-36DLVJGW.js} +19 -16
  9. package/dist/{chunk-XQO2CT6Q.js → chunk-3THGTDL2.js} +2 -2
  10. package/dist/{chunk-CLRYHWQN.js → chunk-42JBXJKW.js} +187 -25
  11. package/dist/chunk-BLCDUM7B.js +7 -0
  12. package/dist/{chunk-NVAJASOD.js → chunk-CJVKOJ6B.js} +10195 -2036
  13. package/dist/{chunk-XFHXQCXL.js → chunk-DQ7QYOUV.js} +99 -13
  14. package/dist/{chunk-NEJ32O7X.js → chunk-F6BXO4AI.js} +1 -1
  15. package/dist/{chunk-OXLA4HXQ.js → chunk-FAXO3SUE.js} +1196 -313
  16. package/dist/{chunk-J63CIRIV.js → chunk-FIQMAIZV.js} +4 -4
  17. package/dist/{chunk-PJSPHHRK.js → chunk-FK5XG742.js} +3 -16
  18. package/dist/{chunk-HKUV7NEN.js → chunk-HHVQ2SDT.js} +1 -1
  19. package/dist/{chunk-SZFO3MAJ.js → chunk-HUGVYHZ2.js} +4 -4
  20. package/dist/{chunk-LEF4X4KI.js → chunk-LCT5ZV3Q.js} +2400 -222
  21. package/dist/chunk-NLJFNCZ4.js +1560 -0
  22. package/dist/{chunk-GM7WFPGG.js → chunk-PRXZD2II.js} +6 -1
  23. package/dist/{chunk-YFJIIIOL.js → chunk-QGJVOPLG.js} +3 -3
  24. package/dist/{chunk-F7DN33UL.js → chunk-QGTJF7HV.js} +16 -14
  25. package/dist/{chunk-ONVFUVQ5.js → chunk-RUV7CCE6.js} +136 -31
  26. package/dist/{chunk-SW676APJ.js → chunk-U7TYSPYM.js} +2 -2
  27. package/dist/chunk-UJZN2ZH6.js +1 -0
  28. package/dist/chunk-VDZXNNZF.js +221 -0
  29. package/dist/{chunk-UJSAR6GF.js → chunk-W4DYDRV2.js} +21 -0
  30. package/dist/chunk-WCPDN7AY.js +642 -0
  31. package/dist/{chunk-BBVW5ZC2.js → chunk-WMFT5R7I.js} +2 -2
  32. package/dist/{chunk-AQEAZDL2.js → chunk-XJUMFH33.js} +2 -1
  33. package/dist/{composition-Ds6WHyO7.d.ts → composition-CvtvgBDE.d.ts} +2783 -873
  34. package/dist/composition.d.ts +4 -3
  35. package/dist/composition.js +3 -2
  36. package/dist/{conversion-CdzrTxib.d.ts → conversion-B_5AKTYQ.d.ts} +39 -10
  37. package/dist/conversion-CMBGOTAC.js +25 -0
  38. package/dist/convert.d.ts +5 -4
  39. package/dist/convert.js +17 -13
  40. package/dist/data.d.ts +2 -2
  41. package/dist/data.js +4 -3
  42. package/dist/{deck-report-CKDNQ2t4.d.ts → deck-report-BVlQZ42f.d.ts} +3 -3
  43. package/dist/deck.d.ts +7 -6
  44. package/dist/deck.js +13 -12
  45. package/dist/diagram-engine-eager.js +6 -2
  46. package/dist/diagram-engine-lazy.js +14 -1
  47. package/dist/diagram-plantuml-XRZ6VAOL.js +3 -0
  48. package/dist/diff.js +6 -5
  49. package/dist/docs.js +88 -52
  50. package/dist/examples.js +28745 -18393
  51. package/dist/font-policy.js +2 -2
  52. package/dist/format.js +3 -3
  53. package/dist/ids.js +6 -5
  54. package/dist/index.d.ts +19 -16
  55. package/dist/index.js +37 -26
  56. package/dist/markdown.d.ts +3 -2
  57. package/dist/markdown.js +10 -9
  58. package/dist/node-engine.d.ts +44 -11
  59. package/dist/node-engine.js +47 -28
  60. package/dist/{pagination-DRZ_JNFY.d.ts → pagination-CZQQYk7L.d.ts} +22 -4
  61. package/dist/pagination.d.ts +5 -4
  62. package/dist/pagination.js +6 -5
  63. package/dist/patch.js +5 -4
  64. package/dist/precompiled.js +3 -3
  65. package/dist/{presentation-DnD7mfmf.d.ts → presentation-s9262acV.d.ts} +1172 -208
  66. package/dist/repo-readme.js +2 -2
  67. package/dist/schema-engine-ajv.js +2 -2
  68. package/dist/schema-engine-precompiled.js +3 -3
  69. package/dist/schema.d.ts +3 -3
  70. package/dist/schema.js +5 -4
  71. package/dist/schemas.d.ts +56 -4
  72. package/dist/schemas.js +2 -2
  73. package/dist/shape-catalog.d.ts +98 -0
  74. package/dist/shape-catalog.js +302 -0
  75. package/dist/shape-engine-eager.js +9 -0
  76. package/dist/shape-engine-lazy.js +12 -0
  77. package/dist/shape-engine-module-N74FCHGY.js +3 -0
  78. package/dist/shape-geometry.d.ts +126 -0
  79. package/dist/shape-geometry.js +2 -0
  80. package/dist/source.d.ts +10 -5
  81. package/dist/source.js +12 -11
  82. package/dist/spec/README.md +1 -1
  83. package/dist/spec/reference/engine-vocabularies.json +135 -0
  84. package/dist/spec/reference/font-policy.json +3 -16
  85. package/dist/spec/reference/preset-geometry.json +10699 -0
  86. package/dist/spec/reference/preset-geometry.schema.json +126 -0
  87. package/dist/spec/schemas/catalog-index.schema.json +1 -0
  88. package/dist/spec/schemas/chart-type.schema.json +4 -4
  89. package/dist/spec/schemas/icon-set.schema.json +75 -0
  90. package/dist/spec/schemas/layout.schema.json +82 -23
  91. package/dist/spec/schemas/opf.schema.json +1616 -296
  92. package/dist/spec/schemas/theme.schema.json +11 -5
  93. package/dist/spec-files.d.ts +1 -1
  94. package/dist/spec-files.js +2 -2
  95. package/dist/symbol-font-encodings.js +1 -1
  96. package/dist/types.d.ts +83 -71
  97. package/dist/{validation-types-DxyYPebs.d.ts → validation-types-CYbsUuZ9.d.ts} +8 -5
  98. package/dist/validator.d.ts +35 -7
  99. package/dist/validator.js +5 -4
  100. package/dist/yaml.d.ts +3 -2
  101. package/dist/yaml.js +9 -8
  102. package/package.json +22 -6
  103. package/dist/catalog-refs-kAefsZWT.d.ts +0 -129
  104. package/dist/chunk-DGS47ONG.js +0 -1
  105. package/dist/conversion-5FUDQPED.js +0 -24
@@ -1,3 +1,4 @@
1
+ var __defProp = Object.defineProperty;
1
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
3
  var __commonJS = (cb, mod) => function __require() {
3
4
  try {
@@ -6,5 +7,9 @@ var __commonJS = (cb, mod) => function __require() {
6
7
  throw mod = 0, e;
7
8
  }
8
9
  };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
9
14
 
10
- export { __commonJS };
15
+ export { __commonJS, __export };
@@ -1,5 +1,5 @@
1
- import { jsonEqual, formatPointer } from './chunk-OXLA4HXQ.js';
2
- import { annotationText } from './chunk-NVAJASOD.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-2E6CDYL2.js';
3
- import { fenceCode } from './chunk-NEJ32O7X.js';
4
- import { OPFMarkdownError, writeYaml, Ctx, readYamlMapping, csvField, scalarText } from './chunk-BBVW5ZC2.js';
5
- import { same, isRecord, runText, isPlainRun, FORMATTING } from './chunk-XQO2CT6Q.js';
6
- import { validate } from './chunk-OXLA4HXQ.js';
7
- import { checkCatalogsOption } from './chunk-NVAJASOD.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,8 +1,9 @@
1
- import { defaultCatalogs } from './chunk-AQEAZDL2.js';
2
- import { localAssetSources, OPFApiError, parseSlideSelection, OPFExportError, asApiError, OPFImportError } from './chunk-SZFO3MAJ.js';
3
- import { paginate, continueOverfull } from './chunk-CLRYHWQN.js';
4
- import { deckFormatOf, readDeckReport, stringify } from './chunk-J63CIRIV.js';
5
- import { validate, OPFValidationError } from './chunk-OXLA4HXQ.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';
6
7
  import { link, stat, readdir, lstat, readFile, open, unlink, mkdir, rename } from 'fs/promises';
7
8
  import path6 from 'path';
8
9
  import { readFileSync, statSync, realpathSync } from 'fs';
@@ -121,9 +122,16 @@ function localAssetProblems(deck, root) {
121
122
  }
122
123
  return problems;
123
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
+ }
124
132
  var RENDER_PACKAGE = "@openpresentation/opf-render";
125
133
  var PPTX_PACKAGE = "@openpresentation/opf-pptx";
126
- var PEER_RANGES = { [RENDER_PACKAGE]: "^0.32.1", [PPTX_PACKAGE]: "^0.32.1" };
134
+ var PEER_RANGES = { [RENDER_PACKAGE]: "^0.34.0", [PPTX_PACKAGE]: "^0.34.0" };
127
135
  var PPTX_TEXT_OPTIONS_FROM = "0.22.0";
128
136
  var numbers = (version) => version.replace(/[-+].*$/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
129
137
  function atLeast(version, minimum) {
@@ -159,7 +167,8 @@ var hint = (name) => `${name} is not installed. It is an optional peer of @openp
159
167
  npx -p @openpresentation/cli -p @openpresentation/opf-render -p @openpresentation/opf-pptx opf <command> ... (one run)` + (name === RENDER_PACKAGE ? `
160
168
  ${renderHint()}` : "");
161
169
  function bases() {
162
- 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];
163
172
  }
164
173
  function locate(specifier) {
165
174
  for (const base of bases()) {
@@ -274,7 +283,7 @@ async function listFontDirectories(directories, label = "--fonts") {
274
283
  }
275
284
  return files;
276
285
  }
277
- async function prepareFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false) {
286
+ async function prepareFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false, renderOptions) {
278
287
  try {
279
288
  const handle = await renderer.fonts.loadFonts({
280
289
  pack: "office",
@@ -282,6 +291,7 @@ async function prepareFonts(renderer, presentation, userFonts, reporter, embedSc
282
291
  scripts: "auto",
283
292
  embedScriptFonts,
284
293
  presentation,
294
+ ...renderOptions ? { renderOptions } : {},
285
295
  faces: userFonts.map((file) => ({ path: file })),
286
296
  onDiagnostic: (diagnostic) => reporter.add("fonts", scriptDiagnostic(diagnostic))
287
297
  });
@@ -298,10 +308,10 @@ async function prepareFonts(renderer, presentation, userFonts, reporter, embedSc
298
308
  }
299
309
  var NEUTRAL_DECK = { slides: [] };
300
310
  var shared = /* @__PURE__ */ new Map();
301
- async function leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false) {
311
+ async function leaseSharedFonts(renderer, presentation, userFonts, reporter, embedScriptFonts = false, renderOptions) {
302
312
  const select = renderer.fonts.autoScriptSelection;
303
313
  if (typeof select !== "function") return void 0;
304
- const selection = select(presentation);
314
+ const selection = select(presentation, renderOptions);
305
315
  if (selection.detected?.length || selection.scripts?.length || selection.unavailable?.length) return void 0;
306
316
  const key = JSON.stringify([userFonts, embedScriptFonts]);
307
317
  let entry = shared.get(key);
@@ -323,14 +333,22 @@ async function leaseSharedFonts(renderer, presentation, userFonts, reporter, emb
323
333
  release = resolve;
324
334
  });
325
335
  await previous;
326
- const pending = handle.pending;
327
- 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) {
328
349
  release();
329
- return void 0;
350
+ throw error;
330
351
  }
331
- handle.registry?.clearSubstitutions?.();
332
- for (const diagnostic of diagnostics) reporter.add("fonts", diagnostic);
333
- return { handle, release };
334
352
  }
335
353
  function scriptDiagnostic(diagnostic) {
336
354
  if (diagnostic.code !== "script-font-not-installed") return diagnostic;
@@ -466,7 +484,11 @@ var INFO = /* @__PURE__ */ new Set([
466
484
  "svg-sanitized",
467
485
  "script-font-unavailable",
468
486
  "media-provenance-omitted",
469
- "picture-not-measured"
487
+ "picture-not-measured",
488
+ "diagram-shapes-unavailable",
489
+ "smartart-unavailable",
490
+ "arrangement-adapted",
491
+ "prepared-late"
470
492
  ]);
471
493
  var HELP = {
472
494
  "text-overflow": "Shorten the text, or split the slide: add --paginate (measured with the same fonts) or run opf paginate.",
@@ -489,13 +511,40 @@ var HELP = {
489
511
  "export-lossy": "The PowerPoint file draws this with its nearest native form (see feature and the message). Change the content if the difference matters, or export with --as images for an exact picture.",
490
512
  "typeface-not-office-safe": 'Export with --typefaces safe (typefaces: "safe") to write Office-safe families and lay the text out with them, or install the fonts on the machines that open the file.',
491
513
  "typeface-replaced": "Drop --typefaces safe to keep the selected families in the file.",
492
- "duplicate-font-face": "A --fonts face repeats a bundled family, weight and style; remove it or rename the family."
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.",
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.",
517
+ "duplicate-font-face": "A --fonts face repeats a bundled family, weight and style; remove it or rename the family.",
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.",
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.",
520
+ "shape-not-imported": "A filled shape across the whole slide is a background, and an overlay shape is drawn over the content; set the slide's background in OPF instead."
493
521
  };
494
522
  var Reporter = class {
495
523
  findings = [];
496
524
  seen = /* @__PURE__ */ new Set();
525
+ /** The identity key of each finding, by index ("" for the initial findings, which are not deduplicated). */
526
+ keys = [];
497
527
  constructor(initial = []) {
498
- 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
+ }
499
548
  }
500
549
  /** Add a library diagnostic (`code`, `path`, `message` and details). Identical entries are kept once. */
501
550
  add(source, diagnostic, severity) {
@@ -513,6 +562,7 @@ var Reporter = class {
513
562
  const key = JSON.stringify([entry.ruleId, entry.path, entry.message, details]);
514
563
  if (this.seen.has(key)) return;
515
564
  this.seen.add(key);
565
+ this.keys.push(key);
516
566
  this.findings.push(entry);
517
567
  }
518
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. */
@@ -520,6 +570,7 @@ var Reporter = class {
520
570
  const key = JSON.stringify(finding);
521
571
  if (this.seen.has(key)) return;
522
572
  this.seen.add(key);
573
+ this.keys.push(key);
523
574
  this.findings.push(finding);
524
575
  }
525
576
  error(source, code, message, where = "", details = {}) {
@@ -646,16 +697,18 @@ function resolveExportOptions(options) {
646
697
  if (options.raster !== void 0 && typeof options.raster !== "boolean") throw invalid("raster must be true or false.");
647
698
  if (options.paginate !== void 0 && typeof options.paginate !== "boolean" && options.paginate !== "blocks") throw invalid('paginate must be true, false or "blocks".');
648
699
  const charts = oneOf("charts", options.charts, ["auto", "native", "picture"]);
700
+ const diagrams = oneOf("diagrams", options.diagrams, ["picture", "shapes"]);
649
701
  const provenance = oneOf("provenance", options.provenance, ["full", "references-only", "none"]);
650
702
  const images = oneOf("images", options.images, ["compatible", "preserve"]);
651
703
  const bodyText = oneOf("bodyText", options.bodyText, ["measured", "native"]);
704
+ const smartArt = oneOf("smartArt", options.smartArt, ["live", "shapes"]);
652
705
  const slideNumbers = oneOf("slideNumbers", options.slideNumbers, ["static", "live"]);
653
706
  const text = oneOf("text", options.text, EXPORT_TEXT);
654
707
  const typefaces = oneOf("typefaces", options.typefaces, ["selected", "safe"]);
655
708
  const as = oneOf("as", options.as, ["native", "images"]);
656
709
  if (options.raster && format !== "pdf") throw invalid("raster applies to format pdf.");
657
- if ((charts !== void 0 || provenance !== void 0 || images !== void 0 || bodyText !== void 0 || slideNumbers !== void 0 || typefaces !== void 0 || as !== void 0) && format !== "pptx") throw invalid("charts, provenance, images, bodyText, slideNumbers, typefaces and as apply to format pptx.");
658
- if (as === "images" && (charts !== void 0 || provenance !== void 0 || images !== void 0 || bodyText !== void 0 || slideNumbers !== void 0 || typefaces !== void 0)) throw invalid('charts, provenance, images, bodyText, slideNumbers and typefaces do not apply to as: "images", where each slide is one picture.');
710
+ if ((charts !== void 0 || diagrams !== void 0 || provenance !== void 0 || images !== void 0 || bodyText !== void 0 || smartArt !== void 0 || slideNumbers !== void 0 || typefaces !== void 0 || as !== void 0) && format !== "pptx") throw invalid("charts, diagrams, provenance, images, bodyText, smartArt, slideNumbers, typefaces and as apply to format pptx.");
711
+ if (as === "images" && (charts !== void 0 || diagrams !== void 0 || provenance !== void 0 || images !== void 0 || bodyText !== void 0 || smartArt !== void 0 || slideNumbers !== void 0 || typefaces !== void 0)) throw invalid('charts, diagrams, provenance, images, bodyText, smartArt, slideNumbers and typefaces do not apply to as: "images", where each slide is one picture.');
659
712
  if (options.scale !== void 0 && format !== "png" && format !== "pdf" && !(format === "pptx" && as === "images")) throw invalid('scale applies to format png (and raster pdf, and pptx with as: "images").');
660
713
  if (options.includeHidden && format === "pptx") throw invalid("includeHidden applies to per-slide image and PDF output; the PPTX keeps a hidden slide as a hidden slide.");
661
714
  if (options.slides !== void 0 && format === "pptx") throw invalid("slides is not available for pptx: the whole presentation is exported.");
@@ -696,15 +749,53 @@ async function runExport(presentation, options, ctx) {
696
749
  const pptx = format === "pptx" ? ctx.pptx ?? await loadPptx() : void 0;
697
750
  const userFonts = options.fonts ? [] : ctx.userFonts ?? await listFontDirectories(options.fontFolders, ctx.flags ? "--fonts" : "fonts");
698
751
  const resolver = createImageResolver(assetRoot(options.assetDir, ctx.flags), reporter, ctx.flags ? "pass --asset-dir" : "pass assetDir");
752
+ await ensureIcons(presentation, { catalogs, readSource: iconSourceReader(void 0, resolver) });
699
753
  const embedScripts = format === "svg" && options.text === "fonts";
700
- 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 } : {} });
701
755
  try {
702
- const handle = options.fonts ?? lease?.handle ?? (await prepareFonts(renderer, presentation, userFonts, reporter, embedScripts)).handle;
703
- 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
+ }
704
778
  } finally {
705
779
  lease?.release();
706
780
  }
707
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
+ }
708
799
  async function drawWith(presentation, handle, options, ctx, environment) {
709
800
  const { format, scale } = options;
710
801
  const { reporter, catalogs, date, renderer, pptx, userFonts, resolver } = environment;
@@ -725,7 +816,7 @@ async function drawWith(presentation, handle, options, ctx, environment) {
725
816
  pagination = { pages: result.pages };
726
817
  } catch (error) {
727
818
  reportThrown(reporter, "render", error);
728
- return { files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) };
819
+ return failedWith({ files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) }, error);
729
820
  }
730
821
  } else if (options.paginate !== false) {
731
822
  const source = format === "pptx" ? "pptx" : "render";
@@ -751,9 +842,10 @@ async function drawWith(presentation, handle, options, ctx, environment) {
751
842
  }
752
843
  } catch (error) {
753
844
  reportThrown(reporter, source, error);
754
- return { files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) };
845
+ return failedWith({ files: [], fonts: fontSummary(), skippedHidden: [], failure: failureOf(error) }, error);
755
846
  }
756
847
  }
848
+ if (deck !== presentation && handle.registry?.fontNames) await handle.ensure?.(deck, { renderOptions: { catalogs, ...date ? { date } : {} } });
757
849
  const pictureLuminance = options.measurePictures === false ? void 0 : await measurePictureBackgrounds(renderer, deck, resolver, catalogs, reporter);
758
850
  const slideCount = deck.slides?.length ?? 0;
759
851
  const isHidden = (number) => deck.slides?.[number - 1]?.hidden === true;
@@ -762,6 +854,16 @@ async function drawWith(presentation, handle, options, ctx, environment) {
762
854
  const named = options.slides === void 0 ? void 0 : parseSlideSelection(options.slides, slideCount, slidesLabel);
763
855
  const selected = format === "pptx" ? [] : named ?? (options.includeHidden ? everySlide : everySlide.filter((number) => !isHidden(number)));
764
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
+ }
765
867
  if (format !== "pptx" && !selected.length)
766
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");
767
869
  const stem = deckStem(options.name === void 0 ? deck : { filename: options.name }, "-");
@@ -786,9 +888,11 @@ async function drawWith(presentation, handle, options, ctx, environment) {
786
888
  ...pictureLuminance ? { pictureLuminance } : {},
787
889
  // opf-pptx still names its option `chartex` and its picture choice `fallback`.
788
890
  ...options.charts ? { chartex: options.charts === "picture" ? "fallback" : options.charts } : {},
891
+ ...options.diagrams ? { diagrams: options.diagrams } : {},
789
892
  ...options.provenance ? { provenance: options.provenance === "none" ? false : options.provenance } : {},
790
893
  ...options.images ? { imageFormat: options.images } : {},
791
894
  ...options.bodyText ? { bodyText: options.bodyText } : {},
895
+ ...options.smartArt ? { smartArt: options.smartArt } : {},
792
896
  ...options.slideNumbers ? { slideNumberFields: options.slideNumbers } : {},
793
897
  ...options.typefaces ? { typefaces: options.typefaces } : {},
794
898
  ...pictures ? { as: "images", scale: options.pictureScale, slideRasterizer } : {},
@@ -854,7 +958,7 @@ async function drawWith(presentation, handle, options, ctx, environment) {
854
958
  const missing = missingPeerFrom(error);
855
959
  if (missing) throw missing;
856
960
  reportThrown(reporter, format === "pptx" ? "pptx" : "render", error);
857
- return { files: [], fonts: fontSummary(), ...pagination ? { pagination } : {}, skippedHidden: [], failure: failureOf(error) };
961
+ return failedWith({ files: [], fonts: fontSummary(), ...pagination ? { pagination } : {}, skippedHidden: [], failure: failureOf(error) }, error);
858
962
  }
859
963
  }
860
964
  async function measurePictureBackgrounds(renderer, deck, resolver, catalogs, reporter) {
@@ -910,6 +1014,7 @@ async function prepareExport(options, flags = false) {
910
1014
  }
911
1015
  async function runPreparedExport(prepared, presentation, checked) {
912
1016
  let initial = checked;
1017
+ await ensureIcons(presentation, { catalogs: prepared.options.catalogs ?? defaultCatalogs() });
913
1018
  if (!initial) {
914
1019
  const check = validate(presentation, checkOptions(prepared.options.catalogs));
915
1020
  if (!check.valid) throw new OPFApiError(`The presentation is not valid OPF: ${firstError(check.findings)}`, "invalid-presentation", { findings: check.findings });
@@ -997,7 +1102,7 @@ function targetOf(output, options, flags) {
997
1102
  checkOutputPattern(output, exported === "png" || exported === "svg");
998
1103
  return exported ? { kind: "export", format: exported, zip: false } : { kind: "deck", format: deck };
999
1104
  }
1000
- var EXPORT_ONLY = ["slides", "includeHidden", "paginate", "scale", "raster", "text", "charts", "provenance", "images", "bodyText", "slideNumbers", "typefaces", "as", "date", "fonts", "assetDir"];
1105
+ var EXPORT_ONLY = ["slides", "includeHidden", "paginate", "scale", "raster", "text", "charts", "diagrams", "provenance", "images", "bodyText", "smartArt", "slideNumbers", "typefaces", "as", "date", "fonts", "assetDir"];
1001
1106
  var given = (value) => value !== void 0 && value !== false && !(Array.isArray(value) && value.length === 0);
1002
1107
  function checkApplicable(source, target, options, flags) {
1003
1108
  const name = (key) => flags ? `--${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}` : key;
@@ -1010,8 +1115,8 @@ function checkApplicable(source, target, options, flags) {
1010
1115
  }
1011
1116
  const format = target.format;
1012
1117
  if (given(options.raster) && format !== "pdf") throw invalid2(`${name("raster")} applies to pdf output.`);
1013
- const pptxOnly = ["charts", "provenance", "images", "bodyText", "slideNumbers", "typefaces"].filter((key) => options[key] !== void 0);
1014
- if ((pptxOnly.length || options.as !== void 0) && format !== "pptx") throw invalid2(`${names("charts", "provenance", "images", "bodyText", "slideNumbers", "typefaces", "as")} apply to pptx output.`);
1118
+ const pptxOnly = ["charts", "diagrams", "provenance", "images", "bodyText", "smartArt", "slideNumbers", "typefaces"].filter((key) => options[key] !== void 0);
1119
+ if ((pptxOnly.length || options.as !== void 0) && format !== "pptx") throw invalid2(`${names("charts", "diagrams", "provenance", "images", "bodyText", "smartArt", "slideNumbers", "typefaces", "as")} apply to pptx output.`);
1015
1120
  if (options.as === "images" && pptxOnly.length) throw invalid2(`${names(...pptxOnly)} ${pptxOnly.length === 1 ? "does" : "do"} not apply to ${flags ? "--as images" : 'as: "images"'}, where each slide is one picture.`);
1016
1121
  if (options.scale !== void 0 && format !== "png" && format !== "pdf" && !(format === "pptx" && options.as === "images")) throw invalid2(`${name("scale")} applies to png output (and raster pdf, and pptx ${flags ? "--as images" : 'with as: "images"'}).`);
1017
1122
  if (given(options.includeHidden) && format === "pptx") throw invalid2(`${name("includeHidden")} applies to per-slide image and PDF output; the PPTX keeps a hidden slide as a hidden slide.`);
@@ -1179,4 +1284,4 @@ async function saveDeck(presentation, file, options = {}) {
1179
1284
  return { path: file, format };
1180
1285
  }
1181
1286
 
1182
- 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-OXLA4HXQ.js';
2
- import { isRecord, visitContentPayloads, promotedRegionKeys } from './chunk-NVAJASOD.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]*)$/;