@openpresentation/opf 0.22.0 → 0.22.2

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.
@@ -117,7 +117,19 @@ function localAssetProblems(deck, root) {
117
117
  }
118
118
  var RENDER_PACKAGE = "@openpresentation/opf-render";
119
119
  var PPTX_PACKAGE = "@openpresentation/opf-pptx";
120
- var PEER_RANGES = { [RENDER_PACKAGE]: "^0.20.0", [PPTX_PACKAGE]: "^0.20.0" };
120
+ var PEER_RANGES = { [RENDER_PACKAGE]: "^0.22.0", [PPTX_PACKAGE]: "^0.22.0" };
121
+ var PPTX_TEXT_OPTIONS_FROM = "0.22.0";
122
+ var numbers = (version) => version.replace(/[-+].*$/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
123
+ function atLeast(version, minimum) {
124
+ const [a, b] = [numbers(version), numbers(minimum)];
125
+ for (let i = 0; i < 3; i++) if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) > (b[i] ?? 0);
126
+ return true;
127
+ }
128
+ function requirePptxOptions(pptx, options, flags = false) {
129
+ const asked = [options.bodyText === "native" ? flags ? "--body-text native" : 'bodyText: "native"' : void 0, options.slideNumbers ? flags ? "--slide-numbers" : "slideNumbers" : void 0].filter(Boolean);
130
+ if (asked.length && pptx.version !== "unknown" && !atLeast(pptx.version, PPTX_TEXT_OPTIONS_FROM))
131
+ throw new OPFApiError(`${asked.join(" and ")} needs ${pptx.name}@${PPTX_TEXT_OPTIONS_FROM} or later; ${pptx.version} is installed and would ignore it.`, "peer-too-old", { details: { package: pptx.name } });
132
+ }
121
133
  var RENDER_EXTRAS = {
122
134
  /** The faces of the office pack, which the CLI and `convert` always load (every format). */
123
135
  fonts: ["@expo-google-fonts/roboto@0.4.3", "@expo-google-fonts/roboto-mono@0.4.2", "@expo-google-fonts/caladea@0.4.2", "@expo-google-fonts/arimo@0.4.3", "@expo-google-fonts/tinos@0.4.2", "@expo-google-fonts/cousine@0.4.3", "@expo-google-fonts/gelasio@0.4.1", "@expo-google-fonts/noto-sans@0.4.2"],
@@ -618,9 +630,11 @@ function resolveExportOptions(options) {
618
630
  const charts = oneOf("charts", options.charts, ["auto", "native", "picture"]);
619
631
  const provenance = oneOf("provenance", options.provenance, ["full", "references-only", "none"]);
620
632
  const images = oneOf("images", options.images, ["compatible", "preserve"]);
633
+ const bodyText = oneOf("bodyText", options.bodyText, ["measured", "native"]);
634
+ const slideNumbers = oneOf("slideNumbers", options.slideNumbers, ["static", "live"]);
621
635
  const text = oneOf("text", options.text, EXPORT_TEXT);
622
636
  if (options.raster && format !== "pdf") throw invalid("raster applies to format pdf.");
623
- if ((charts !== void 0 || provenance !== void 0 || images !== void 0) && format !== "pptx") throw invalid("charts, provenance and images apply to format pptx.");
637
+ if ((charts !== void 0 || provenance !== void 0 || images !== void 0 || bodyText !== void 0 || slideNumbers !== void 0) && format !== "pptx") throw invalid("charts, provenance, images, bodyText and slideNumbers apply to format pptx.");
624
638
  if (options.scale !== void 0 && format !== "png" && format !== "pdf") throw invalid("scale applies to format png (and raster pdf).");
625
639
  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.");
626
640
  if (options.slides !== void 0 && format === "pptx") throw invalid("slides is not available for pptx: the whole presentation is exported.");
@@ -705,6 +719,7 @@ async function drawWith(presentation, handle, options, ctx, environment) {
705
719
  const run = (extra) => ({ fonts: fontSummary(), ...pagination ? { pagination } : {}, skippedHidden, ...extra });
706
720
  try {
707
721
  if (format === "pptx") {
722
+ requirePptxOptions(pptx, options, ctx.flags);
708
723
  const module = pptx.module;
709
724
  const bytes = await module.toPptx(deck, {
710
725
  fonts: handle,
@@ -718,6 +733,8 @@ async function drawWith(presentation, handle, options, ctx, environment) {
718
733
  ...options.charts ? { chartex: options.charts === "picture" ? "fallback" : options.charts } : {},
719
734
  ...options.provenance ? { provenance: options.provenance === "none" ? false : options.provenance } : {},
720
735
  ...options.images ? { imageFormat: options.images } : {},
736
+ ...options.bodyText ? { bodyText: options.bodyText } : {},
737
+ ...options.slideNumbers ? { slideNumberFields: options.slideNumbers } : {},
721
738
  ...date ? { date } : {}
722
739
  });
723
740
  return run({ files: [{ name: `${stem}.pptx`, type: MEDIA2.pptx, bytes }], skippedHidden: [] });
@@ -898,7 +915,7 @@ function targetOf(output, options, flags) {
898
915
  checkOutputPattern(output, exported === "png" || exported === "svg");
899
916
  return exported ? { kind: "export", format: exported, zip: false } : { kind: "deck", format: deck };
900
917
  }
901
- var EXPORT_ONLY = ["slides", "includeHidden", "paginate", "scale", "raster", "text", "charts", "provenance", "images", "date", "fonts", "assetDir"];
918
+ var EXPORT_ONLY = ["slides", "includeHidden", "paginate", "scale", "raster", "text", "charts", "provenance", "images", "bodyText", "slideNumbers", "date", "fonts", "assetDir"];
902
919
  var given = (value) => value !== void 0 && value !== false && !(Array.isArray(value) && value.length === 0);
903
920
  function checkApplicable(source, target, options, flags) {
904
921
  const name = (key) => flags ? `--${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}` : key;
@@ -911,7 +928,7 @@ function checkApplicable(source, target, options, flags) {
911
928
  }
912
929
  const format = target.format;
913
930
  if (given(options.raster) && format !== "pdf") throw invalid2(`${name("raster")} applies to pdf output.`);
914
- if ((options.charts !== void 0 || options.provenance !== void 0 || options.images !== void 0) && format !== "pptx") throw invalid2(`${names("charts", "provenance", "images")} apply to pptx output.`);
931
+ if ((options.charts !== void 0 || options.provenance !== void 0 || options.images !== void 0 || options.bodyText !== void 0 || options.slideNumbers !== void 0) && format !== "pptx") throw invalid2(`${names("charts", "provenance", "images", "bodyText", "slideNumbers")} apply to pptx output.`);
915
932
  if (options.scale !== void 0 && format !== "png" && format !== "pdf") throw invalid2(`${name("scale")} applies to png output (and raster pdf).`);
916
933
  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.`);
917
934
  if (options.slides !== void 0 && format === "pptx") throw invalid2(`${name("slides")} is not available for pptx output: the whole presentation is exported.`);
@@ -43,8 +43,8 @@ declare const RENDER_PACKAGE = "@openpresentation/opf-render";
43
43
  declare const PPTX_PACKAGE = "@openpresentation/opf-pptx";
44
44
  /** Peer ranges. The CLI checks the features it calls rather than the version, so a newer release in range keeps working. */
45
45
  declare const PEER_RANGES: {
46
- readonly "@openpresentation/opf-render": "^0.20.0";
47
- readonly "@openpresentation/opf-pptx": "^0.20.0";
46
+ readonly "@openpresentation/opf-render": "^0.22.0";
47
+ readonly "@openpresentation/opf-pptx": "^0.22.0";
48
48
  };
49
49
  interface Diagnostic {
50
50
  code: string;
@@ -221,6 +221,18 @@ interface ExportOptions {
221
221
  provenance?: "full" | "references-only" | "none";
222
222
  /** `pptx`: keep images as they are (`preserve`) or convert them for older PowerPoint (`compatible`). */
223
223
  images?: "compatible" | "preserve";
224
+ /**
225
+ * `pptx`: `measured` (the default) writes each wrapped line as its own text box, so the text lays out exactly as the preview draws it.
226
+ * `native` opts in to whole paragraphs: a wrapped title is one Title placeholder and a text, list or bullets region one body, which
227
+ * PowerPoint and Keynote re-wrap when edited. What native mode cannot carry keeps measured text, with a `native-body-fallback` finding.
228
+ */
229
+ bodyText?: "measured" | "native";
230
+ /**
231
+ * `pptx`: a footer or header text with words around the slide number (`{{slide.number}} / {{deck.slideCount}}`). `static` (opf-pptx's
232
+ * default) writes the number as fixed text, so Keynote shows the words too; `live` keeps the slide-number field, which Keynote
233
+ * draws as the digit alone. A text that is only `{{slide.number}}` stays a live field in both.
234
+ */
235
+ slideNumbers?: "static" | "live";
224
236
  /** `YYYY-MM-DD`, for date fields that show today's date. Nothing reads a clock: without it such a field reports `date-needs-value`. */
225
237
  date?: string;
226
238
  /** The directory a presentation's relative image paths resolve against. Omitted: no local file is read (data URIs and remote references work as the engines handle them). */
@@ -1,4 +1,4 @@
1
- export { convertFiles, deckFileFormat, exportFormatOf, openDeck, planConversion, readInput, saveDeck, writePlanned } from './chunk-DY7H4RG6.js';
1
+ export { convertFiles, deckFileFormat, exportFormatOf, openDeck, planConversion, readInput, saveDeck, writePlanned } from './chunk-AHKRJSCF.js';
2
2
  import './chunk-MG34DCDB.js';
3
3
  import './chunk-MAJHCGOW.js';
4
4
  import './chunk-UJSAR6GF.js';