@openpresentation/opf 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +19 -1
  2. package/dist/{catalog-refs-BSfGELpt.d.ts → catalog-refs-C4K4y-vh.d.ts} +1 -1
  3. package/dist/{catalog-schemas-CinPh5WA.d.ts → catalog-schemas-g7RFQBdc.d.ts} +1 -1
  4. package/dist/catalog.d.ts +2 -2
  5. package/dist/catalog.js +3 -23224
  6. package/dist/{chart-data-BnNqgnC-.d.ts → chart-data-DTxdRRT1.d.ts} +1 -1
  7. package/dist/{chunk-3JG4YXWF.js → chunk-BIC3SWPK.js} +12 -5
  8. package/dist/{chunk-O744SXXA.js → chunk-CW7GEAV3.js} +350 -141
  9. package/dist/{chunk-374R35TJ.js → chunk-ESRYBYLY.js} +1 -1
  10. package/dist/chunk-IPW5BS3X.js +973 -0
  11. package/dist/{chunk-3RKB4RDJ.js → chunk-IS5H5JKH.js} +4 -2
  12. package/dist/{chunk-TWQJLI6E.js → chunk-M4UR3NPN.js} +2 -2
  13. package/dist/chunk-N4EVOFEA.js +58 -0
  14. package/dist/{chunk-QDI75P2M.js → chunk-NLNYNBTS.js} +217 -20
  15. package/dist/{chunk-U4J75TRG.js → chunk-O263APNI.js} +5 -2
  16. package/dist/{chunk-UBFJ2QHH.js → chunk-O2CX5NEH.js} +36 -14
  17. package/dist/{chunk-5FTUIDUH.js → chunk-O3CVNJTL.js} +1 -1
  18. package/dist/{chunk-VGAOJEY7.js → chunk-PPROJP2E.js} +1 -1
  19. package/dist/{chunk-2CJPC4HI.js → chunk-RA64UQKI.js} +203 -53
  20. package/dist/chunk-TCD2FB2K.js +319 -0
  21. package/dist/chunk-WCG3THTD.js +23712 -0
  22. package/dist/chunk-WWYWFVOI.js +793 -0
  23. package/dist/{chunk-ZPU46TFA.js → chunk-YT7FMQER.js} +1 -1
  24. package/dist/{composition-D2tghM82.d.ts → composition-BbZ_9C-c.d.ts} +238 -139
  25. package/dist/composition.d.ts +3 -3
  26. package/dist/composition.js +1 -1
  27. package/dist/conversion-SBpTOwdg.d.ts +444 -0
  28. package/dist/convert.d.ts +4 -4
  29. package/dist/convert.js +7 -7
  30. package/dist/data.d.ts +28 -11
  31. package/dist/data.js +2 -2
  32. package/dist/deck-report-Bx3naFlF.d.ts +40 -0
  33. package/dist/deck.d.ts +47 -0
  34. package/dist/deck.js +12 -0
  35. package/dist/diff.d.ts +1 -1
  36. package/dist/diff.js +5 -5
  37. package/dist/docs.js +33 -27
  38. package/dist/examples.d.ts +1 -1
  39. package/dist/examples.js +3229 -985
  40. package/dist/{finding-CT_f_vbD.d.ts → finding-CDQ_wH8j.d.ts} +1 -1
  41. package/dist/format.js +2 -2
  42. package/dist/index.d.ts +43 -12
  43. package/dist/index.js +15 -805
  44. package/dist/markdown.d.ts +7 -8
  45. package/dist/markdown.js +7 -7
  46. package/dist/node-engine.d.ts +94 -0
  47. package/dist/node-engine.js +21 -0
  48. package/dist/node.d.ts +60 -0
  49. package/dist/node.js +54 -0
  50. package/dist/{pagination-wedbe7eq.d.ts → pagination-BhX4M48Y.d.ts} +21 -7
  51. package/dist/pagination.d.ts +4 -4
  52. package/dist/pagination.js +4 -4
  53. package/dist/patch.d.ts +1 -1
  54. package/dist/patch.js +4 -4
  55. package/dist/{presentation-CDKQVkyI.d.ts → presentation-fb8CZmRq.d.ts} +28 -83
  56. package/dist/repo-readme.js +1 -1
  57. package/dist/schemas.d.ts +14 -0
  58. package/dist/schemas.js +1 -1
  59. package/dist/spec/catalogs/layouts/business-model-canvas.json +66 -1
  60. package/dist/spec/catalogs/layouts/capability-map.json +53 -3
  61. package/dist/spec/catalogs/layouts/chart-2x.json +32 -8
  62. package/dist/spec/catalogs/layouts/chart-3x-bottom-vertical-title-left.json +16 -10
  63. package/dist/spec/catalogs/layouts/chart-3x-left-title-center.json +16 -10
  64. package/dist/spec/catalogs/layouts/chart-3x-left.json +16 -10
  65. package/dist/spec/catalogs/layouts/chart-3x-right-title-center.json +16 -10
  66. package/dist/spec/catalogs/layouts/chart-3x-right.json +16 -10
  67. package/dist/spec/catalogs/layouts/chart-3x-top-vertical-title-left.json +16 -10
  68. package/dist/spec/catalogs/layouts/chart-3x.json +48 -12
  69. package/dist/spec/catalogs/layouts/dashboard.json +37 -5
  70. package/dist/spec/catalogs/layouts/image-2x.json +32 -8
  71. package/dist/spec/catalogs/layouts/image-3x.json +48 -12
  72. package/dist/spec/catalogs/layouts/index.json +1 -1
  73. package/dist/spec/catalogs/layouts/kpi-scorecard.json +48 -3
  74. package/dist/spec/catalogs/layouts/logic-tree.json +69 -0
  75. package/dist/spec/catalogs/layouts/market-size.json +26 -2
  76. package/dist/spec/catalogs/layouts/org-chart.json +53 -6
  77. package/dist/spec/catalogs/manifest.json +3 -3
  78. package/dist/spec/schemas/layout.schema.json +172 -5
  79. package/dist/spec/schemas/opf.schema.json +27 -43
  80. package/dist/types.d.ts +10 -32
  81. package/dist/{validation-types-BOcY9GTs.d.ts → validation-types-iZbXfES6.d.ts} +19 -8
  82. package/dist/validator.d.ts +8 -8
  83. package/dist/validator.js +3 -3
  84. package/dist/yaml.d.ts +6 -6
  85. package/dist/yaml.js +8 -321
  86. package/package.json +38 -1
@@ -0,0 +1,444 @@
1
+ import { a as DeckFormat } from './deck-report-Bx3naFlF.js';
2
+ import { F as Finding, f as FindingSeverity } from './finding-CDQ_wH8j.js';
3
+ import { P as Presentation } from './presentation-fb8CZmRq.js';
4
+ import { f as ValidationReport, e as ValidationChecks, c as ValidateOptions } from './validation-types-iZbXfES6.js';
5
+ import { b as Catalog } from './catalog-refs-C4K4y-vh.js';
6
+
7
+ /** The base class: thrown for the request and the files (`invalid-option`, `input-not-found`, `input-unreadable`, `invalid-presentation`, `output-exists`, `output-not-file`, `output-unwritable`). */
8
+ declare class OPFApiError extends Error {
9
+ readonly code: string;
10
+ readonly details: Record<string, unknown>;
11
+ readonly findings: Finding[];
12
+ constructor(message: string, code: string, extra?: {
13
+ details?: Record<string, unknown>;
14
+ findings?: Finding[];
15
+ cause?: unknown;
16
+ });
17
+ }
18
+ /** Thrown by the export step of `convert`: `peer-not-installed`, `peer-too-old`, `peer-load-failed`, `invalid-option`, `invalid-presentation`, `no-slides`, `all-slides-hidden`, `font-failed`, `export-failed`. */
19
+ declare class OPFExportError extends OPFApiError {
20
+ }
21
+ /** Thrown by the import step of `convert` and by `open` for a PowerPoint file: `peer-not-installed`, `peer-too-old`, `peer-load-failed`, `invalid-option`, `invalid-presentation`, `import-failed`. */
22
+ declare class OPFImportError extends OPFApiError {
23
+ }
24
+ /** The error as `Class`, whatever was thrown below: an error of that class is returned as it is, another API error keeps its code, details and findings. */
25
+ declare function asApiError<T extends OPFApiError>(Class: new (message: string, code: string, extra?: {
26
+ details?: Record<string, unknown>;
27
+ findings?: Finding[];
28
+ cause?: unknown;
29
+ }) => T, error: unknown, fallbackCode: string): T;
30
+
31
+ declare const RENDER_PACKAGE = "@openpresentation/opf-render";
32
+ declare const PPTX_PACKAGE = "@openpresentation/opf-pptx";
33
+ /** Peer ranges. The CLI checks the features it calls rather than the version, so a newer release in range keeps working. */
34
+ declare const PEER_RANGES: {
35
+ readonly "@openpresentation/opf-render": "^0.17.0";
36
+ readonly "@openpresentation/opf-pptx": "^0.17.0";
37
+ };
38
+ interface Diagnostic {
39
+ code: string;
40
+ path?: string;
41
+ message: string;
42
+ [detail: string]: unknown;
43
+ }
44
+ interface EmbeddedFace {
45
+ family: string;
46
+ weight: number;
47
+ italic?: boolean;
48
+ dataUrl: string;
49
+ }
50
+ /** What the renderer's deck-level functions read from `{ fonts }` (opf-render `RenderFonts`). */
51
+ interface RenderFonts {
52
+ textMeasurement?: unknown;
53
+ embeddedFonts?: readonly EmbeddedFace[];
54
+ fontFiles?: readonly string[];
55
+ useBundledFonts?: boolean;
56
+ loadSystemFonts?: boolean;
57
+ }
58
+ interface FontRegistry {
59
+ scriptSelection?: {
60
+ detected: string[];
61
+ scripts: string[];
62
+ unavailable: string[];
63
+ packages?: string[];
64
+ notInstalled?: string[];
65
+ uncovered?: string[];
66
+ };
67
+ }
68
+ /** The handle `loadFonts()` of opf-render `/fonts-node` returns: pass it as `{ fonts }` to every deck-level call. */
69
+ interface FontsHandle extends RenderFonts {
70
+ textMeasurement: unknown;
71
+ embeddedFonts: EmbeddedFace[];
72
+ fontFiles: string[];
73
+ useBundledFonts: false;
74
+ loadSystemFonts: false;
75
+ registry: FontRegistry;
76
+ substitutions: {
77
+ requestedFamily: string;
78
+ resolvedFamily: string;
79
+ compatibility: string;
80
+ substitute: boolean;
81
+ }[];
82
+ }
83
+ interface RenderModule {
84
+ renderSlideSvg(presentation: unknown, index: number, options?: Record<string, unknown>): string;
85
+ svgToPng(svg: string, options?: Record<string, unknown>): Promise<Uint8Array>;
86
+ svgToPdf(svgs: string | string[], options?: Record<string, unknown>): Promise<Uint8Array>;
87
+ }
88
+ interface FontsNodeModule {
89
+ loadFonts(options?: Record<string, unknown>): Promise<FontsHandle>;
90
+ }
91
+ interface PptxModule {
92
+ toPptx(presentation: unknown, options?: Record<string, unknown>): Promise<Uint8Array>;
93
+ /** Without `signals` the presentation itself; with `signals: true`, `{ presentation, signals }`. */
94
+ fromPptx(input: Uint8Array, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
95
+ }
96
+ interface Peer<T> {
97
+ module: T;
98
+ version: string;
99
+ name: string;
100
+ }
101
+ /**
102
+ * The missing-peer error for a renderer failure that says a package it loads lazily is absent (RR-63): `converter-missing` (pdf-lib,
103
+ * @resvg/resvg-js, sharp) or `font-resource-unavailable` naming font packages. The renderer's message, with its install command, is kept;
104
+ * `details` has `package` (or `packages`), `range`, `install` and `purpose` where the renderer gave them. A converter that is installed but
105
+ * did not load is `peer-load-failed`. Undefined for any other error.
106
+ */
107
+ declare function missingPeerFrom(error: unknown): OPFApiError | undefined;
108
+ interface Renderer {
109
+ render: Peer<RenderModule>;
110
+ fonts: FontsNodeModule;
111
+ }
112
+ declare function loadRenderer(): Promise<Renderer>;
113
+ declare function loadPptx(): Promise<Peer<PptxModule>>;
114
+
115
+ /** True when any finding is at or above the level (the `--fail-on` rule). */
116
+ declare const reaches: (findings: readonly {
117
+ severity: FindingSeverity;
118
+ }[], level: FindingSeverity) => boolean;
119
+ type Source = "render" | "pptx" | "pdf" | "fonts" | "import" | "cli";
120
+ /** A finding of the shared format, with the library's details (font family, package, ...) alongside. */
121
+ interface ReportFinding extends Finding {
122
+ [detail: string]: unknown;
123
+ }
124
+ declare class Reporter {
125
+ readonly findings: ReportFinding[];
126
+ private readonly seen;
127
+ constructor(initial?: readonly Finding[]);
128
+ /** Add a library diagnostic (`code`, `path`, `message` and details). Identical entries are kept once. */
129
+ add(source: Source, diagnostic: Diagnostic, severity?: FindingSeverity): void;
130
+ /** Add a finding as the library made it (the `findings` of a thrown OPFRenderError, OPFPptxError or core validation error). Identical entries are kept once. */
131
+ addFinding(finding: Finding): void;
132
+ error(source: Source, code: string, message: string, where?: string, details?: Record<string, unknown>): void;
133
+ get counts(): Record<FindingSeverity, number>;
134
+ get failed(): boolean;
135
+ }
136
+ /**
137
+ * Convert a thrown library error into the report. An error that carries `findings` (the error findings of the format check,
138
+ * on OPFRenderError, OPFPptxError and core's OPFValidationError) is reported as those findings; any other error becomes one
139
+ * diagnostic that keeps its code and the path it names.
140
+ */
141
+ declare function reportThrown(reporter: Reporter, source: Source, error: unknown): void;
142
+ declare function finishReport(base: Pick<ValidationReport, "valid" | "schemaValid" | "checks">, reporter: Reporter, failOn: FindingSeverity): {
143
+ ok: boolean;
144
+ valid: boolean;
145
+ schemaValid: boolean | null;
146
+ findings: ReportFinding[];
147
+ counts: Record<FindingSeverity, number>;
148
+ checks: ValidationChecks;
149
+ };
150
+
151
+ type ExportFormat = "svg" | "png" | "pdf" | "pptx";
152
+ declare const EXPORT_FORMATS: readonly ExportFormat[];
153
+ interface ExportOptions {
154
+ /** What to write. `svg` and `png` give one file per slide (or one zip), `pdf` and `pptx` one file. */
155
+ format: ExportFormat;
156
+ /** A prepared fonts handle (`loadFonts()` of `@openpresentation/opf-render/fonts-node`), reused across calls. Omitted: the bundled open font pack plus `fontDirs`. */
157
+ fonts?: FontsHandle;
158
+ /** Directories of `.ttf` and `.otf` files to load before the bundled pack (not recursive). Ignored when `fonts` is given. */
159
+ fontDirs?: readonly string[];
160
+ /** The catalogs the presentation's references resolve in. Omitted: core's default catalog. */
161
+ catalogs?: readonly Catalog[];
162
+ /** The slides to write, one-based: numbers or a selection such as `"1,3-5"`. Omitted: every slide that is not hidden. Not for `pptx`. */
163
+ slides?: readonly number[] | string;
164
+ /** Write hidden slides too (`svg`, `png`, `pdf`). */
165
+ includeHidden?: boolean;
166
+ /** Split overflowing slides with the same fonts before drawing, as `opf paginate` does. */
167
+ paginate?: boolean;
168
+ /** Pixel scale of `png` and of a raster `pdf` (0.1 to 8; 1 draws the 1280 x 720 reference slide at 1280 x 720 pixels). */
169
+ scale?: number;
170
+ /** `pdf`: `vector` (selectable text, the default) or `raster`. */
171
+ pdfMode?: "vector" | "raster";
172
+ /** `svg`: embed the faces the slide's text uses (`used`, the default) or none (`none`). */
173
+ svgFonts?: "used" | "none";
174
+ /** `pptx`: native charts (`native`), picture fallbacks (`fallback`) or opf-pptx's choice (`auto`). */
175
+ chartex?: "auto" | "native" | "fallback";
176
+ /** `pptx`: what the file records about where media came from. */
177
+ provenance?: "full" | "references-only" | "none";
178
+ /** `pptx`: keep images as they are (`preserve`) or convert them for older PowerPoint (`compatible`). */
179
+ imageFormat?: "compatible" | "preserve";
180
+ /** `YYYY-MM-DD`, for date fields that show today's date. Nothing reads a clock: without it such a field reports `date-needs-value`. */
181
+ date?: string;
182
+ /** 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). */
183
+ assetDir?: string;
184
+ /** `svg` and `png`: one zip of the slides instead of one file per slide. */
185
+ zip?: boolean;
186
+ /** The source file name, for naming the output when the presentation has no `filename` or `name`. */
187
+ filename?: string;
188
+ }
189
+ interface ExportFile {
190
+ /** The file name: the presentation's `filename`, else its slugified `name`, else the source name, then `-001.png` for slide 1 and so on. */
191
+ name: string;
192
+ /** The media type. */
193
+ type: string;
194
+ bytes: Uint8Array;
195
+ /** `svg` and `png`: the slide number (one-based) and its id. */
196
+ slide?: number;
197
+ id?: string;
198
+ /** `svg` and `png`: the picture's size in pixels. */
199
+ width?: number;
200
+ height?: number;
201
+ /** `pdf`: the number of pages and the slide numbers they show. */
202
+ pages?: number;
203
+ slides?: number[];
204
+ /** `zip`: the names of the entries. */
205
+ entries?: string[];
206
+ }
207
+ interface ExportFontSummary {
208
+ pack: "office";
209
+ substitutionPolicy: "visual";
210
+ /** The `fontDirs` files, in load order. */
211
+ userFonts: string[];
212
+ substitutions: {
213
+ requested: string;
214
+ resolved: string;
215
+ compatibility: string;
216
+ }[];
217
+ scripts?: unknown;
218
+ }
219
+ interface ExportRun {
220
+ files: ExportFile[];
221
+ fonts?: ExportFontSummary;
222
+ pagination?: {
223
+ pages: unknown;
224
+ };
225
+ pdf?: {
226
+ mode: "vector" | "raster";
227
+ };
228
+ skippedHidden: number[];
229
+ /** Set when drawing or paginating threw: the reporter holds the error finding and `files` is empty. */
230
+ failure?: {
231
+ code: string;
232
+ message: string;
233
+ };
234
+ }
235
+ /** What a caller that has already done some of the work passes in, so the engine does not repeat it. */
236
+ interface ExportContext {
237
+ reporter: Reporter;
238
+ renderer?: Renderer;
239
+ pptx?: Peer<PptxModule>;
240
+ /** Absolute font file paths already listed from `fontDirs`. */
241
+ userFonts?: string[];
242
+ /** Name options as the command line does (`--slides`, `--font-dir`, `--asset-dir`) in the messages of errors the engine throws. */
243
+ flags?: boolean;
244
+ }
245
+ /** `YYYY-MM-DD` and a real calendar date, or undefined. `label` names the option in the message (`--date` for the command, `date` for the function). */
246
+ declare function checkDate(value: unknown, label?: string): string | undefined;
247
+ /** A scale from 0.1 to 8, 1 when absent. */
248
+ declare function checkScale(value: unknown, label?: string): number;
249
+ /** The options of a call, checked against each other. Throws `invalid-option` (an OPFApiError) for a value out of range or an option that does not apply to the format. */
250
+ declare function resolveExportOptions(options: ExportOptions): Required<Pick<ExportOptions, "format" | "svgFonts" | "scale">> & ExportOptions;
251
+ /**
252
+ * Draw a presentation that has already passed the format and references check (`ctx.reporter` holds that check's findings).
253
+ * Diagnostics from fonts, layout, the SVG, PDF and PPTX writers are added to `ctx.reporter`. Throws an `OPFApiError` for an
254
+ * option, a missing or old peer, a font directory or a selection that names no slide; a failure while drawing is returned in
255
+ * `failure` after the reporter has the error finding.
256
+ */
257
+ declare function runExport(presentation: unknown, options: ReturnType<typeof resolveExportOptions>, ctx: ExportContext): Promise<ExportRun>;
258
+ declare const VERSIONS: (renderer: Renderer, pptx?: Peer<PptxModule>) => {
259
+ pptx?: {
260
+ package: string;
261
+ version: string;
262
+ } | undefined;
263
+ renderer: {
264
+ package: string;
265
+ version: string;
266
+ };
267
+ };
268
+
269
+ /** The check a presentation passes before it is exported or after it is imported: format and references, so a contrast warning never blocks a write. */
270
+ declare const checkOptions: (catalogs: readonly Catalog[] | undefined) => ValidateOptions;
271
+ interface ExportResult {
272
+ /** The files, in slide order: one per slide for `svg` and `png`, otherwise one. */
273
+ files: ExportFile[];
274
+ /** The findings of the format and references check (warnings and notes; errors throw) and the diagnostics of the engines: fonts, layout, SVG, PDF and PPTX, each with a `render/`, `pptx/`, `pdf/`, `fonts/` or `cli/` rule prefix. */
275
+ findings: Finding[];
276
+ /** The bundled fonts and font files used, and the substitutions made. */
277
+ fonts: ExportFontSummary;
278
+ /** Slide numbers left out because they are hidden (`svg`, `png`, `pdf` without `includeHidden` or `slides`). */
279
+ skippedHidden: number[];
280
+ /** With `paginate`: the pages the slides were split into. */
281
+ pagination?: {
282
+ pages: unknown;
283
+ };
284
+ /** `pdf`: the mode used. */
285
+ pdf?: {
286
+ mode: "vector" | "raster";
287
+ };
288
+ /** The engines that drew the files. */
289
+ renderer: {
290
+ package: string;
291
+ version: string;
292
+ };
293
+ pptx?: {
294
+ package: string;
295
+ version: string;
296
+ };
297
+ }
298
+ interface ImportOptions {
299
+ /** The catalogs the imported presentation's references resolve in. Omitted: core's default catalog. */
300
+ catalogs?: readonly Catalog[];
301
+ /** Also return the raw per-shape layout and style signals of the file (`signals`). */
302
+ signals?: boolean;
303
+ }
304
+ interface ImportResult {
305
+ /** The presentation. It passed the format and references check. */
306
+ presentation: Presentation;
307
+ /** What the conversion could not keep or had to change, and the findings of the check. */
308
+ findings: Finding[];
309
+ /** With `signals: true`. */
310
+ signals?: {
311
+ version?: number;
312
+ };
313
+ /** The importer that read the file. */
314
+ pptx: {
315
+ package: string;
316
+ version: string;
317
+ };
318
+ }
319
+ /** An export whose options are checked and whose engines and font files are loaded, before any document is read. */
320
+ interface PreparedExport {
321
+ options: ReturnType<typeof resolveExportOptions>;
322
+ renderer: Renderer;
323
+ pptx?: Peer<PptxModule>;
324
+ userFonts: string[];
325
+ /** Name options as the command's flags (`--slides`, `--font-dir`, `--asset-dir`) in messages. */
326
+ flags: boolean;
327
+ }
328
+ /** Check the options, then load the engines and list the font directories, so a missing install is reported before the document is looked at. */
329
+ declare function prepareExport(options: ExportOptions, flags?: boolean): Promise<PreparedExport>;
330
+ /**
331
+ * Draw a presentation. Without `checked` it is checked first (`invalid-presentation` when it fails); with `checked`, the findings
332
+ * of a check already made (located in the text it was read from, or the findings of an import) start the report instead.
333
+ */
334
+ declare function runPreparedExport(prepared: PreparedExport, presentation: Presentation, checked?: readonly Finding[]): Promise<ExportResult>;
335
+ /** Read a PowerPoint file and check the presentation (`import-failed`, `invalid-presentation`). `check` is the report of that check. */
336
+ declare function importPresentation(bytes: Uint8Array, options: ImportOptions, loaded?: Peer<PptxModule>): Promise<{
337
+ result: ImportResult;
338
+ check: ValidationReport;
339
+ }>;
340
+
341
+ /** What `convert` makes: an export format, or a deck form. */
342
+ type ConvertFormat = ExportFormat | DeckFormat;
343
+ /** What `convert` reads: a file path (`.pptx`, `.opf.md`, `.yaml`/`.yml`, `.json`), a deck, or the bytes of a `.pptx` file. */
344
+ type ConvertInput = string | Presentation | Uint8Array | ArrayBuffer;
345
+ interface ConvertOptions extends Omit<ExportOptions, "format" | "filename"> {
346
+ /**
347
+ * What to make. With an output path the path's extension names it, and `format` is needed only for a `.zip` (the slides in
348
+ * it: `png`, the default, or `svg`); a `format` that disagrees with the extension is refused. Without an output path it is
349
+ * required: `pdf`, `pptx`, `png`, `svg`, `json`, `yaml` or `markdown`.
350
+ */
351
+ format?: ConvertFormat;
352
+ /** One archive of the slides instead of one file per slide (`png`, `svg`). With an output path, the path must end `.zip`, and a `.zip` path implies it. */
353
+ zip?: boolean;
354
+ /** A `.pptx` input: also return the raw per-shape layout and style signals of the file (`signals` in the result). */
355
+ signals?: boolean;
356
+ /**
357
+ * Replace outputs that exist (the default, as `save` and `fs.writeFile` do), atomically. `false` refuses: an existing output
358
+ * rejects with `output-exists` before anything is written, the rule the opf commands apply without `--force`. A symlink, a
359
+ * directory or another non-regular file is never replaced (`output-not-file`).
360
+ */
361
+ overwrite?: boolean;
362
+ }
363
+ interface ConvertedFile {
364
+ /** The file name: the output's base name, or without an output path the deck's `filename`, else its slugified `name`, else the input file's stem, then `-001.png` for slide 1 and so on. */
365
+ name: string;
366
+ /** With an output path, the file written: the path itself, or for one file per slide the path's folder and stem plus the slide number (`slides/deck-001.png`). */
367
+ path?: string;
368
+ /** The media type. */
369
+ type: string;
370
+ bytes: Uint8Array;
371
+ /** `png` and `svg`: the slide number (one-based), its id and the picture's size in pixels. */
372
+ slide?: number;
373
+ id?: string;
374
+ width?: number;
375
+ height?: number;
376
+ /** `pdf`: the number of pages and the slide numbers they show. */
377
+ pages?: number;
378
+ slides?: number[];
379
+ /** `zip`: the names of the entries. */
380
+ entries?: string[];
381
+ }
382
+ interface ConvertResult {
383
+ /** The files, in slide order: written when an output path was given, otherwise only returned. */
384
+ files: ConvertedFile[];
385
+ /** The findings of every step: the import (`import/` rules), the format and references check, and the export engines (`render/`, `pptx/`, `pdf/`, `fonts/`, `cli/`). Errors throw instead. */
386
+ findings: Finding[];
387
+ /** With `signals: true` and a `.pptx` input. */
388
+ signals?: {
389
+ version?: number;
390
+ };
391
+ }
392
+ interface OpenOptions {
393
+ /** The catalogs the deck's references resolve in. Omitted: the default catalog. */
394
+ catalogs?: ExportOptions["catalogs"];
395
+ }
396
+ interface SaveOptions {
397
+ /** Check format and references first and refuse an invalid deck (`OPFValidationError`). Default true; `false` writes work in progress, as an editor's autosave does. */
398
+ validate?: boolean;
399
+ /** The catalogs the deck's references resolve in. Omitted: the default catalog. */
400
+ catalogs?: ExportOptions["catalogs"];
401
+ /** YAML: start with a `# yaml-language-server: $schema=...` line so editors validate the file. */
402
+ schemaComment?: boolean;
403
+ }
404
+ interface SaveResult {
405
+ /** The file, as it was given. */
406
+ path: string;
407
+ /** The form written, from the file name. */
408
+ format: DeckFormat;
409
+ }
410
+ /** A planned conversion: everything `convert` would write, and what `opf convert` reports about it. */
411
+ interface ConversionPlan {
412
+ files: ConvertedFile[];
413
+ findings: Finding[];
414
+ /** The format and references check of the deck that was drawn or written. */
415
+ check: Pick<ValidationReport, "valid" | "schemaValid" | "checks">;
416
+ format: ConvertFormat;
417
+ zip: boolean;
418
+ input?: {
419
+ file: string;
420
+ bytes: Uint8Array;
421
+ };
422
+ exported?: ExportResult;
423
+ imported?: ImportResult;
424
+ }
425
+ /** The deck form a file name stands for (core's `deckFormatOf`: `.opf.md`, `.yaml`, `.yml`), or JSON for `.json`; undefined for any other name. A plain `.md` file is not a deck. */
426
+ declare function deckFileFormat(file: string): DeckFormat | undefined;
427
+ /** The export format a file name stands for (`.pdf`, `.pptx`, `.png`, `.svg`, any case), else undefined. `opf render` and `opf export` read `--out` with the same rule. */
428
+ declare function exportFormatOf(file: string): ExportFormat | undefined;
429
+ /** Read an input file: `input-not-found` when there is none, `input-unreadable` for any other failure. */
430
+ declare function readInput(file: string): Promise<Uint8Array>;
431
+ /**
432
+ * Plan a conversion: check the request, read the input, then import, check, export or serialize. Nothing is written. Throws
433
+ * `OPFApiError` for the request and the files (`invalid-option`, `input-not-found`, `input-unreadable`, and
434
+ * `invalid-presentation` for a deck written as a deck), `OPFImportError` for the import step and `OPFExportError` for the export
435
+ * step (`invalid-presentation` included). `flags` names options as the command's flags in messages.
436
+ */
437
+ declare function planConversion(input: ConvertInput, output: string | undefined, options?: ConvertOptions, flags?: boolean): Promise<ConversionPlan>;
438
+ /**
439
+ * Write planned files atomically (temporary sibling, then rename), creating folders. `overwrite` false refuses an existing output
440
+ * (`output-exists`): the opf commands pass it unless `--force`; `convert` passes its `overwrite` option, true by default.
441
+ */
442
+ declare function writePlanned(files: readonly ConvertedFile[], overwrite: boolean, flags?: boolean): Promise<void>;
443
+
444
+ export { runExport as $, asApiError as A, checkDate as B, type ConvertInput as C, type Diagnostic as D, type ExportFormat as E, type FontsHandle as F, checkOptions as G, checkScale as H, type ImportOptions as I, deckFileFormat as J, exportFormatOf as K, finishReport as L, importPresentation as M, loadPptx as N, type OpenOptions as O, type Peer as P, loadRenderer as Q, type Renderer as R, type SaveOptions as S, missingPeerFrom as T, planConversion as U, VERSIONS as V, prepareExport as W, reaches as X, readInput as Y, reportThrown as Z, resolveExportOptions as _, type ConvertOptions as a, runPreparedExport as a0, writePlanned as a1, type ConvertResult as b, type ConvertFormat as c, type SaveResult as d, type ConvertedFile as e, OPFApiError as f, OPFExportError as g, OPFImportError as h, type EmbeddedFace as i, Reporter as j, type PptxModule as k, type ConversionPlan as l, EXPORT_FORMATS as m, type ExportContext as n, type ExportFile as o, type ExportFontSummary as p, type ExportOptions as q, type ExportResult as r, type ExportRun as s, type ImportResult as t, PEER_RANGES as u, PPTX_PACKAGE as v, type PreparedExport as w, RENDER_PACKAGE as x, type ReportFinding as y, type Source as z };
package/dist/convert.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as PaginatedPage, d as PresentationPaginationOptions } from './pagination-wedbe7eq.js';
2
- import './composition-D2tghM82.js';
3
- import './catalog-refs-BSfGELpt.js';
4
- import './chart-data-BnNqgnC-.js';
1
+ import { P as PaginatedPage, d as PresentationPaginationOptions } from './pagination-BhX4M48Y.js';
2
+ import './composition-BbZ_9C-c.js';
3
+ import './catalog-refs-C4K4y-vh.js';
4
+ import './chart-data-DTxdRRT1.js';
5
5
 
6
6
  type Json = any;
7
7
  type Obj = Record<string, any>;
package/dist/convert.js CHANGED
@@ -1,12 +1,12 @@
1
- import { paginate, OPFPaginationError } from './chunk-UBFJ2QHH.js';
2
- import { parseQuoteLines, parseCodeFence, splitWhen, parseListLine, levelsFromIndents, fenceCode } from './chunk-374R35TJ.js';
3
- import { CONTENT_KEYS, isRecord, contentKeysOf, refuse, clone, Loss, isSlideLike, assertValidOwner, report, OPFConversionError, plainOf, assertValidOutput, same, splitRuns, runsOf, lineIsPlain, linePlain, concatText, lineValue, joinLines, hasFormatting } from './chunk-VGAOJEY7.js';
4
- export { OPFConversionError } from './chunk-VGAOJEY7.js';
5
- import './chunk-QDI75P2M.js';
6
- import { promotedRegionKeys, isDatasetRef, inlineTableData, visitContentPayloads, chartNumber } from './chunk-O744SXXA.js';
1
+ import { paginate, OPFPaginationError } from './chunk-O2CX5NEH.js';
2
+ import { parseQuoteLines, parseCodeFence, splitWhen, parseListLine, levelsFromIndents, fenceCode } from './chunk-ESRYBYLY.js';
3
+ import { CONTENT_KEYS, isRecord, contentKeysOf, refuse, clone, Loss, isSlideLike, assertValidOwner, report, OPFConversionError, plainOf, assertValidOutput, same, splitRuns, runsOf, lineIsPlain, linePlain, concatText, lineValue, joinLines, hasFormatting } from './chunk-PPROJP2E.js';
4
+ export { OPFConversionError } from './chunk-PPROJP2E.js';
5
+ import './chunk-NLNYNBTS.js';
6
+ import { promotedRegionKeys, isDatasetRef, inlineTableData, visitContentPayloads, chartNumber } from './chunk-CW7GEAV3.js';
7
7
  import './chunk-TRDXRRQK.js';
8
8
  import './chunk-SPFV27O5.js';
9
- import './chunk-2CJPC4HI.js';
9
+ import './chunk-RA64UQKI.js';
10
10
 
11
11
  // src/convert/tables.ts
12
12
  function cellOf(raw) {
package/dist/data.d.ts CHANGED
@@ -1,10 +1,27 @@
1
- export { C as ChartMapping, a as ChartNumberFix, b as ChartNumberFixOperation, c as ChartNumberFixOptions, D as DataCellValue, d as DataColumn, e as DataDiagnostic, f as DataDiagnosticCode, g as DataResolveOptions, h as DataSourceRef, i as DataStyledCell, j as DataTableCell, k as DataTableHeader, l as DataTableValue, m as DataTextRun, n as Dataset, o as DatasetRef, R as ResolvedChartData, p as ResolvedTableData, q as chartNumber, r as datasetDiagnostics, s as formatDataNumber, t as fromExcelNumberFormat, u as inlineChartData, v as inlineDatasets, w as inlineTableData, x as isDatasetRef, y as isXYChartType, z as numberFormatError, A as resolveChartData, B as resolveTableData, E as suggestChartNumberFix, F as tableCellDisplayValue, G as toExcelNumberFormat, H as unusedDatasets } from './chart-data-BnNqgnC-.js';
1
+ import { C as Chart } from './presentation-fb8CZmRq.js';
2
+ export { a as ChartMapping, b as ChartNumberFix, c as ChartNumberFixOperation, d as ChartNumberFixOptions, D as DataCellValue, e as DataColumn, f as DataDiagnostic, g as DataDiagnosticCode, h as DataResolveOptions, i as DataSourceRef, j as DataStyledCell, k as DataTableCell, l as DataTableHeader, m as DataTableValue, n as DataTextRun, o as Dataset, p as DatasetRef, R as ResolvedChartData, q as ResolvedTableData, r as chartNumber, s as datasetDiagnostics, t as formatDataNumber, u as fromExcelNumberFormat, v as inlineChartData, w as inlineDatasets, x as inlineTableData, y as isDatasetRef, z as isXYChartType, A as numberFormatError, B as resolveChartData, E as resolveTableData, F as suggestChartNumberFix, G as tableCellDisplayValue, H as toExcelNumberFormat, I as unusedDatasets } from './chart-data-DTxdRRT1.js';
2
3
 
3
4
  type DataCell = string | number | boolean | null;
4
5
  interface TabularData {
5
6
  columns: string[];
6
7
  rows: DataCell[][];
7
8
  }
9
+ /** Chart import rejects empty columns and rows before returning a schema-compatible payload. */
10
+ interface ImportedChartData extends TabularData {
11
+ columns: [string, ...string[]];
12
+ rows: [DataCell[], ...DataCell[][]];
13
+ }
14
+ /** A `chart.type` value (OPF 0.15: an engine vocabulary, `CHART_TYPES`). */
15
+ type ImportedChartType = Chart['type'];
16
+ interface ImportedTable {
17
+ table: TabularData;
18
+ }
19
+ interface ImportedChart {
20
+ chart: {
21
+ type: ImportedChartType;
22
+ data: ImportedChartData;
23
+ };
24
+ }
8
25
  interface DataImportOptions {
9
26
  format?: 'csv' | 'tsv' | 'json';
10
27
  delimiter?: string;
@@ -13,7 +30,8 @@ interface DataImportOptions {
13
30
  }
14
31
  interface ImportDataOptions extends DataImportOptions {
15
32
  as: 'table' | 'chart';
16
- chartType?: string;
33
+ /** Default `column`. Values outside `CHART_TYPES` make an invalid chart; the CLI checks `--chart-type` first. */
34
+ chartType?: ImportedChartType;
17
35
  category?: string;
18
36
  series?: string[];
19
37
  }
@@ -21,13 +39,12 @@ declare class OPFDataImportError extends Error {
21
39
  constructor(message: string);
22
40
  }
23
41
  declare function parseTabularData(input: unknown, options?: DataImportOptions): TabularData;
24
- declare function importData(input: unknown, options: ImportDataOptions): {
25
- table: TabularData;
26
- } | {
27
- chart: {
28
- type: string;
29
- data: TabularData;
30
- };
31
- };
42
+ declare function importData(input: unknown, options: ImportDataOptions & {
43
+ as: 'table';
44
+ }): ImportedTable;
45
+ declare function importData(input: unknown, options: ImportDataOptions & {
46
+ as: 'chart';
47
+ }): ImportedChart;
48
+ declare function importData(input: unknown, options: ImportDataOptions): ImportedTable | ImportedChart;
32
49
 
33
- export { type DataCell, type DataImportOptions, type ImportDataOptions, OPFDataImportError, type TabularData, importData, parseTabularData };
50
+ export { type DataCell, type DataImportOptions, type ImportDataOptions, type ImportedChart, type ImportedChartData, type ImportedChartType, type ImportedTable, OPFDataImportError, type TabularData, importData, parseTabularData };
package/dist/data.js CHANGED
@@ -1,3 +1,3 @@
1
- export { OPFDataImportError, importData, parseTabularData } from './chunk-U4J75TRG.js';
2
- export { chartNumber, datasetDiagnostics, formatDataNumber, fromExcelNumberFormat, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isXYChartType, numberFormatError, resolveChartData, resolveTableData, suggestChartNumberFix, tableCellDisplayValue, toExcelNumberFormat, unusedDatasets } from './chunk-O744SXXA.js';
1
+ export { OPFDataImportError, importData, parseTabularData } from './chunk-O263APNI.js';
2
+ export { chartNumber, datasetDiagnostics, formatDataNumber, fromExcelNumberFormat, inlineChartData, inlineDatasets, inlineTableData, isDatasetRef, isXYChartType, numberFormatError, resolveChartData, resolveTableData, suggestChartNumberFix, tableCellDisplayValue, toExcelNumberFormat, unusedDatasets } from './chunk-CW7GEAV3.js';
3
3
  import './chunk-SPFV27O5.js';
@@ -0,0 +1,40 @@
1
+ import { b as Catalog } from './catalog-refs-C4K4y-vh.js';
2
+ import { P as Presentation } from './presentation-fb8CZmRq.js';
3
+ import { f as ValidationReport, c as ValidateOptions } from './validation-types-iZbXfES6.js';
4
+
5
+ /** The serializations of a deck: `json` (canonical), `yaml` (`.opf.yaml`) and `markdown` (`.opf.md`). */
6
+ type DeckFormat = "json" | "yaml" | "markdown";
7
+ /** Every deck format, in the order JSON, YAML, Markdown. */
8
+ declare const DECK_FORMATS: readonly DeckFormat[];
9
+ /**
10
+ * The format a file name stands for: `.opf.md` is Markdown, `.yaml` and `.yml` are YAML (any case), every other name is JSON.
11
+ * A plain `.md` file is not a deck: it is Markdown that `fromMarkdown` converts when asked, so it is never detected.
12
+ */
13
+ declare function deckFormatOf(filename: string | undefined): DeckFormat;
14
+ /** Where a deck's text comes from: its format, or the file name that names it, and the catalogs its references resolve in. */
15
+ interface ParseOptions {
16
+ /** The format of the text. Wins over `filename`. */
17
+ format?: DeckFormat;
18
+ /** The file name, for the format only: `.opf.md` is Markdown, `.yaml` and `.yml` are YAML, anything else is JSON. The content is never sniffed. */
19
+ filename?: string;
20
+ /** Catalogs the host registered, for the references check. Nothing is fetched. */
21
+ catalogs?: readonly Catalog[];
22
+ }
23
+ /** The options of `readDeckReport`: `parse`'s, plus the check to run. */
24
+ interface DeckReportOptions extends ParseOptions {
25
+ /** `true` (the default) checks `format` and `references`; options pick other rules; `false` reports only syntax errors. */
26
+ validate?: boolean | ValidateOptions;
27
+ }
28
+ /** A deck read from text with the report of its check, whatever the format. */
29
+ interface DeckReport extends ValidationReport {
30
+ /** The deck; a best effort (an empty object after a syntax error) when `valid` is false. */
31
+ presentation: Presentation;
32
+ format: DeckFormat;
33
+ }
34
+ /**
35
+ * The reader behind `parse` that never throws for content: the deck and the `validate` report of it, every finding
36
+ * located in the text. Not exported from the package entries; `@openpresentation/opf/node` and `parse` use it.
37
+ */
38
+ declare function readDeckReport(text: string, options?: DeckReportOptions, caller?: string): DeckReport;
39
+
40
+ export { DECK_FORMATS as D, type ParseOptions as P, type DeckFormat as a, type DeckReport as b, type DeckReportOptions as c, deckFormatOf as d, readDeckReport as r };
package/dist/deck.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ import { a as DeckFormat, P as ParseOptions } from './deck-report-Bx3naFlF.js';
2
+ export { D as DECK_FORMATS, d as deckFormatOf } from './deck-report-Bx3naFlF.js';
3
+ import { P as Presentation } from './presentation-fb8CZmRq.js';
4
+ import './catalog-refs-C4K4y-vh.js';
5
+ import './validation-types-iZbXfES6.js';
6
+ import './composition-BbZ_9C-c.js';
7
+ import './chart-data-DTxdRRT1.js';
8
+ import './finding-CDQ_wH8j.js';
9
+ import './json-BFSdESOE.js';
10
+
11
+ /**
12
+ * One entry point to read and write a deck in any of its three serializations (RR-60): JSON, the canonical and interchange
13
+ * form, and the two authoring forms of the same data, YAML (`.opf.yaml`, RR-56) and Markdown (`.opf.md`, RR-30). `parse`
14
+ * turns text into a deck (a deck that fails the format and references check throws, with every finding located in the text
15
+ * that was read); `stringify` turns a deck into text.
16
+ *
17
+ * The format comes from the `format` option, else from the file name, and never from the content: a string that starts with
18
+ * `{` is JSON only because JSON is the default. No renderer, fonts, DOM, network or model calls, and no Node APIs, so it runs in
19
+ * a browser. The same input always gives the same output.
20
+ */
21
+
22
+ /**
23
+ * Read a deck from JSON, YAML or Markdown text and return it. The format comes from `format`, else from `filename`, never from the
24
+ * content. The deck is checked for format and references (in `catalogs`); a syntax, schema or reference error throws
25
+ * `OPFValidationError`, whose `report.findings` carry `location` (the UTF-16 offset and length, and the one-based line and column
26
+ * of the text that caused them; a JSON syntax error is `opf/json-syntax`, a YAML one `yaml/<rule>`, a Markdown one
27
+ * `markdown/<rule>`). Warnings do not throw: `validate` reports them. Throws a `TypeError` for text that is not a string, a
28
+ * format that is none of the three, or a bad option.
29
+ */
30
+ declare function parse(text: string, options?: ParseOptions): Presentation;
31
+ interface StringifyOptions {
32
+ /** The format to write. Wins over `filename`. */
33
+ format?: DeckFormat;
34
+ /** The file name the text is for, for the format only (see `parse`). */
35
+ filename?: string;
36
+ /** YAML: start with `# yaml-language-server: $schema=...` so editors validate and complete the file. */
37
+ schemaComment?: boolean;
38
+ }
39
+ /**
40
+ * Write a deck as text: JSON as two-space JSON with a final newline, YAML in canonical form (`toYaml`) and Markdown in canonical
41
+ * form (`toMarkdown`, with anything the dialect has no syntax for embedded in `opf-slide` and `opf-block` fences so nothing is
42
+ * lost). `parse` reads each result back to the same deck. YAML and Markdown throw `OPFYamlError` or `OPFMarkdownError`
43
+ * (`invalid-document`) for a document that is not valid OPF; JSON writes whatever it is given.
44
+ */
45
+ declare function stringify(presentation: unknown, options?: StringifyOptions): string;
46
+
47
+ export { DeckFormat, ParseOptions, type StringifyOptions, parse, stringify };
package/dist/deck.js ADDED
@@ -0,0 +1,12 @@
1
+ export { DECK_FORMATS, deckFormatOf, parse, stringify } from './chunk-N4EVOFEA.js';
2
+ import './chunk-BIC3SWPK.js';
3
+ import './chunk-TCD2FB2K.js';
4
+ import './chunk-IS5H5JKH.js';
5
+ import './chunk-YT7FMQER.js';
6
+ import './chunk-ESRYBYLY.js';
7
+ import './chunk-PPROJP2E.js';
8
+ import './chunk-NLNYNBTS.js';
9
+ import './chunk-CW7GEAV3.js';
10
+ import './chunk-TRDXRRQK.js';
11
+ import './chunk-SPFV27O5.js';
12
+ import './chunk-RA64UQKI.js';
package/dist/diff.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as JsonPatchOperation } from './finding-CT_f_vbD.js';
1
+ import { J as JsonPatchOperation } from './finding-CDQ_wH8j.js';
2
2
 
3
3
  type MatchedBy = "id" | "equal" | "similar" | "position";
4
4
  interface MatchPair {