@openpresentation/opf-pptx 0.13.2 → 0.15.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.
- package/README.md +57 -37
- package/dist/annotation-export.js +1 -1
- package/dist/annotation-provenance.js +4 -0
- package/dist/background-import.js +33 -17
- package/dist/background.js +30 -28
- package/dist/body-text-import.js +16 -4
- package/dist/chart-alt.js +54 -0
- package/dist/chart-data.js +29 -54
- package/dist/chart-highlight.js +113 -0
- package/dist/chart-options.js +46 -24
- package/dist/chart-types.js +61 -75
- package/dist/code-provenance.js +20 -4
- package/dist/color-ref.js +12 -6
- package/dist/data-provenance.js +18 -14
- package/dist/document-provenance.js +208 -129
- package/dist/format-check.js +10 -0
- package/dist/furniture-provenance.js +30 -3
- package/dist/heading-provenance.js +10 -3
- package/dist/image-fallback-node.js +4 -1
- package/dist/image-provenance.js +273 -0
- package/dist/index.d.ts +57 -35
- package/dist/index.js +724 -399
- package/dist/media-provenance.js +3 -3
- package/dist/metric-provenance.js +3 -3
- package/dist/native-text-style.js +2 -0
- package/dist/package-fonts.js +2 -2
- package/dist/quote-provenance.js +70 -26
- package/dist/rich-heading.js +119 -0
- package/dist/run-colors.js +3 -0
- package/dist/script-fonts.js +102 -101
- package/dist/theme-colors.js +16 -11
- package/dist/timeline-provenance.js +17 -6
- package/dist/typeface-inventory.js +8 -8
- package/dist/watermark-provenance.js +65 -3
- package/package.json +4 -4
- package/dist/slide-image-provenance.js +0 -177
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LayoutDiagnostic,
|
|
1
|
+
import type { Catalog, Finding, Fonts, LayoutDiagnostic, UnresolvedReferenceDiagnostic } from "@openpresentation/opf";
|
|
2
2
|
export declare const packageName = "@openpresentation/opf-pptx";
|
|
3
3
|
|
|
4
4
|
export declare const releaseLane: Readonly<{
|
|
@@ -33,10 +33,9 @@ export interface ImageResolverContext {
|
|
|
33
33
|
path: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface FontSchemeDiagnostic { code: "unresolved-font-scheme"; path: string; message: string; id: string; fallback: string }
|
|
37
36
|
export interface MediaProvenanceDiagnostic { code: "media-provenance-omitted"; path: string; message: string }
|
|
38
37
|
/** The chart data cannot be plotted, so a placeholder frame stands in for the chart. */
|
|
39
|
-
export interface ChartDataUnplottableDiagnostic { code: "chart-data-unplottable"; path: string; message: string; reason: "
|
|
38
|
+
export interface ChartDataUnplottableDiagnostic { code: "chart-data-unplottable"; path: string; message: string; reason: "dataset-unknown" | "no-rows" | "no-columns" | "single-column-not-numeric" }
|
|
40
39
|
/** Content with no PowerPoint export (an empty table, an unsupported payload) is replaced by a plain-language placeholder frame. */
|
|
41
40
|
export interface ContentPlaceholderDiagnostic { code: "content-placeholder"; path: string; message: string; reason: "table-has-no-rows" | "unsupported-payload" }
|
|
42
41
|
/**
|
|
@@ -51,9 +50,8 @@ export interface ContentPlaceholderDiagnostic { code: "content-placeholder"; pat
|
|
|
51
50
|
export interface UnresolvedAssetDiagnostic { code: "unresolved-asset"; path: string; message: string; reason?: "unsupported-format" | "svg-malformed" | "svg-no-size" | "svg-too-large" | "svg-unsafe" | "svg-rasterizer-unavailable" | "svg-render-failed" | "svg-unreadable" }
|
|
52
51
|
/** An SVG picture had scripts, `foreignObject`, event handlers, references outside the file, `@import` rules or a DOCTYPE; they were removed from the embedded SVG (on import too). Nothing in an SVG is run or fetched. */
|
|
53
52
|
export interface SvgSanitizedDiagnostic { code: "svg-sanitized"; path: string; message: string }
|
|
54
|
-
/** An SVG
|
|
53
|
+
/** An SVG image block with a duotone recolor or a non-rectangular shape (or an SVG image background with the tile fit) exports as its PNG raster, not as a native SVG picture, so the effect applies as in the preview (PowerPoint applies opacity, grayscale and a border to an SVG picture, and those stay native). */
|
|
55
54
|
export interface SvgImageRasterizedDiagnostic { code: "svg-image-rasterized"; path: string; message: string }
|
|
56
|
-
export interface WatermarkNotExportedDiagnostic { code: "watermark-not-exported"; path: string; message: string }
|
|
57
55
|
/**
|
|
58
56
|
* The chart data was reshaped to export a native chart: a single value column was plotted against row numbers; a one-series construct
|
|
59
57
|
* (pie, doughnut, and with `chartex: "native"` treemap, histogram, pareto, waterfall, funnel, map) kept only its first series; by default
|
|
@@ -70,9 +68,9 @@ export interface ChartMappingAdaptedDiagnostic { code: "chart-mapping-adapted";
|
|
|
70
68
|
/** RR-54 (`full` provenance): a chart or table data record, or the datasets map (`path: "datasets"`), is over the 16 MiB tag limit and is not stored; the native values still export. */
|
|
71
69
|
export interface DataProvenanceOmittedDiagnostic { code: "data-provenance-omitted"; path: string; message: string }
|
|
72
70
|
|
|
73
|
-
/** A template variable was unfilled and its `example` was used (template export only). */
|
|
71
|
+
/** A template variable was unfilled and its `example` was used (template export only), or a built-in variable such as `{{speaker.name}}` has no source value in the document (`variable-builtin-missing`; it exports as nothing). */
|
|
74
72
|
export interface VariableExampleUsedDiagnostic {
|
|
75
|
-
code: "variable-example-used";
|
|
73
|
+
code: "variable-example-used" | "variable-builtin-missing";
|
|
76
74
|
/** JSON pointer of the variable's declaration. */
|
|
77
75
|
path: string;
|
|
78
76
|
message: string;
|
|
@@ -112,11 +110,17 @@ export interface ToPptxOptions {
|
|
|
112
110
|
* unfilled required variable throws `unfilled-variables`, and a value of the wrong kind throws `invalid-variables`.
|
|
113
111
|
*/
|
|
114
112
|
variables?: Record<string, unknown>;
|
|
115
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The fonts handle: what the renderer's `loadFonts()` returns (`@openpresentation/opf-render/fonts-node`), or any object with a
|
|
115
|
+
* `textMeasurement` (core's `Fonts`). The exporter lays text out with `fonts.textMeasurement` and always names the chosen
|
|
116
|
+
* families, never a substitute face. Without it, layout uses core's portable estimate. This is the only way to pass a measurement:
|
|
117
|
+
* a top-level `textMeasurement` option is not read.
|
|
118
|
+
*/
|
|
119
|
+
fonts?: Fonts;
|
|
116
120
|
/** Match preview/pagination clearance around supplied vector text outlines; default 1. */
|
|
117
121
|
textRasterPadding?: number;
|
|
118
|
-
/** Layout diagnostics, `media-provenance-omitted` when video data cannot be stored,
|
|
119
|
-
onDiagnostic?: (diagnostic: LayoutDiagnostic |
|
|
122
|
+
/** Layout diagnostics, `media-provenance-omitted` when video data cannot be stored, and, from core's slide context, `unresolved-reference` (once per reference path) when a layout, theme, colour-scheme or font-scheme reference resolves nowhere (not embedded in the document's `catalogs` and not in a registered catalog): core's engine defaults are drawn instead, and a slide whose layout resolves nowhere, like one with no layout, composes automatically. None of them refuses the export unless `strictReferences` is set. */
|
|
123
|
+
onDiagnostic?: (diagnostic: LayoutDiagnostic | UnresolvedReferenceDiagnostic | MediaProvenanceDiagnostic | ChartDataUnplottableDiagnostic | ChartDataAdaptedDiagnostic | ChartMapGeodataDiagnostic | ChartValueNotNumericDiagnostic | ChartMappingAdaptedDiagnostic | DataProvenanceOmittedDiagnostic | ContentPlaceholderDiagnostic | UnresolvedAssetDiagnostic | SvgSanitizedDiagnostic | SvgImageRasterizedDiagnostic | VariableExampleUsedDiagnostic) => void;
|
|
120
124
|
baseDir?: string;
|
|
121
125
|
compressionLevel?: number;
|
|
122
126
|
imageResolver?: (src: string, context: ImageResolverContext) => ImageResolverResult | Promise<ImageResolverResult | null | undefined> | null | undefined;
|
|
@@ -130,6 +134,13 @@ export interface ToPptxOptions {
|
|
|
130
134
|
svgRasterizer?: (svg: string, size: { width: number; height: number; scale: number; text: boolean }) => Uint8Array | Promise<Uint8Array>;
|
|
131
135
|
seed?: number;
|
|
132
136
|
strictAssets?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Strict reference policy (OPF 0.15). When true, a layout, theme, colour-scheme or font-scheme reference that resolves
|
|
139
|
+
* nowhere throws `OPFPptxError` with code `unresolved-reference` (its `path` is the first reference's, its `diagnostics`
|
|
140
|
+
* core's `unresolved-reference` diagnostics) instead of composing automatically or drawing with the engine default.
|
|
141
|
+
* Default: the value of `strictAssets`.
|
|
142
|
+
*/
|
|
143
|
+
strictReferences?: boolean;
|
|
133
144
|
timestamp?: string;
|
|
134
145
|
/**
|
|
135
146
|
* ZIP calendar timestamps, including embedded workbooks, use UTC fields at
|
|
@@ -146,25 +157,32 @@ export interface ToPptxOptions {
|
|
|
146
157
|
* PowerPoint updates on open. Without it a current date is reported as unresolved content.
|
|
147
158
|
*/
|
|
148
159
|
date?: string;
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
/**
|
|
161
|
+
* The catalogs the host registered (core `Catalog[]`, as for opf-render and core's `resolveSlideContext`): each is matched
|
|
162
|
+
* against a document group's `catalogs.<group>.source`, and the first is the host default that bare ids use when the document
|
|
163
|
+
* omits `catalogs.default`. Never fetched. Every reference (slide layouts, themes, colour and font schemes) resolves in the
|
|
164
|
+
* document's embedded records first, then here; omitted or `[]`, only embedded records resolve. Register the gallery snapshot
|
|
165
|
+
* explicitly with `catalogs: [defaultCatalog]` from `@openpresentation/opf/catalog`.
|
|
166
|
+
*/
|
|
167
|
+
catalogs?: readonly Catalog[];
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
export interface FromPptxOptions {
|
|
156
|
-
/** Reports native details that import cannot preserve, including code provenance fallback/reflow and grouped text transforms. Table paths identify native frame and row/cell indexes (including headers). Stored catalog references that no longer match the package report `design-reference-changed` / `layout-reference-changed` at the reference path; a slide layout
|
|
171
|
+
/** Reports native details that import cannot preserve, including code provenance fallback/reflow and grouped text transforms. Table paths identify native frame and row/cell indexes (including headers). Stored catalog references that no longer match the package report `design-reference-changed` / `layout-reference-changed` at the reference path; a stored slide layout reference that resolves neither in the stored document catalogs, nor in the slide's own stored record, nor in `catalogs` reports `unresolved-reference`; a slide whose imported blocks no longer fit the stored content structure reports `content-structure-changed` at `slides.N`, a block id repeated by a duplicated slide `duplicate-block-id`, and a footer section text that disagrees with PowerPoint's section list `section-reference-changed` (docs/document-roundtrip.md). */
|
|
157
172
|
onDiagnostic?: (diagnostic: {code: string; path: string; message: string}) => void;
|
|
158
173
|
fallbackName?: string;
|
|
159
174
|
schema?: string;
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
/**
|
|
176
|
+
* The catalogs the host registered (core `Catalog[]`, as in ToPptxOptions; never fetched). Theme and colour-scheme recovery
|
|
177
|
+
* (FF-24) matches the package's theme against the first one, the host default: an exact colour-scheme match imports as its
|
|
178
|
+
* bare id and a corroborated theme name as `design.theme`. Without catalogs the colour scheme imports as an inline object and
|
|
179
|
+
* no theme id is recovered. A stored slide layout reference also resolves here.
|
|
180
|
+
*/
|
|
181
|
+
catalogs?: readonly Catalog[];
|
|
164
182
|
/**
|
|
165
183
|
* Opt in to raw per-shape signals (see PptxSignals). `true` uses the default limits; an object lowers or raises them.
|
|
166
|
-
* With it, `fromPptx` resolves to `{
|
|
167
|
-
* to the
|
|
184
|
+
* With it, `fromPptx` resolves to `{presentation, signals}`; without it (the default, also `false`/`null`) it resolves
|
|
185
|
+
* to the presentation alone. The presentation is the same either way.
|
|
168
186
|
*/
|
|
169
187
|
signals?: boolean | PptxSignalOptions | null;
|
|
170
188
|
}
|
|
@@ -172,7 +190,10 @@ export interface FromPptxOptions {
|
|
|
172
190
|
export declare class OPFPptxError extends Error {
|
|
173
191
|
readonly code: string;
|
|
174
192
|
readonly details: Record<string, unknown>;
|
|
175
|
-
|
|
193
|
+
/** The `error` findings of the `format` check that refused the input or the imported presentation (`invalid-opf`, `invalid-import-opf`), or the variable errors (`unfilled-variables`, `invalid-variables`). */
|
|
194
|
+
readonly findings?: Finding[];
|
|
195
|
+
/** The layout diagnostics behind a `layout-overflow` error, or core's `unresolved-reference` diagnostics behind a strict-export `unresolved-reference` error. */
|
|
196
|
+
readonly diagnostics?: LayoutDiagnostic[] | UnresolvedReferenceDiagnostic[];
|
|
176
197
|
readonly path?: string;
|
|
177
198
|
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
178
199
|
}
|
|
@@ -195,7 +216,7 @@ export declare function fromPptx(input: Uint8Array | ArrayBuffer, options?: From
|
|
|
195
216
|
|
|
196
217
|
/** Bounds on the signals. Each is an integer from 1 up to the cap in parentheses; the defaults are DEFAULT_SIGNAL_LIMITS. */
|
|
197
218
|
export interface PptxSignalOptions {
|
|
198
|
-
/** Slides reported (5000). The
|
|
219
|
+
/** Slides reported (5000). The presentation always has every slide. Default 300. */
|
|
199
220
|
maxSlides?: number;
|
|
200
221
|
/** Shapes reported per slide, groups and their members each counting one (5000). Default 300. */
|
|
201
222
|
maxShapesPerSlide?: number;
|
|
@@ -221,8 +242,8 @@ export declare const SIGNALS_VERSION: 1;
|
|
|
221
242
|
export declare function isMonospaceFamily(family: string | undefined): boolean;
|
|
222
243
|
|
|
223
244
|
export interface PptxImportWithSignals {
|
|
224
|
-
/** The same
|
|
225
|
-
|
|
245
|
+
/** The same presentation `fromPptx` returns without the option. */
|
|
246
|
+
presentation: Record<string, unknown>;
|
|
226
247
|
signals: PptxSignals;
|
|
227
248
|
}
|
|
228
249
|
|
|
@@ -252,7 +273,7 @@ export interface PptxSignals {
|
|
|
252
273
|
}
|
|
253
274
|
|
|
254
275
|
export interface PptxSlideSignals {
|
|
255
|
-
/** Slide position, the same index as `
|
|
276
|
+
/** Slide position, the same index as `presentation.slides`. */
|
|
256
277
|
index: number;
|
|
257
278
|
/** Package part, for example "ppt/slides/slide1.xml". */
|
|
258
279
|
part: string;
|
|
@@ -379,15 +400,16 @@ export interface PptxOutlineSignal extends PptxColor {
|
|
|
379
400
|
tailArrow?: string;
|
|
380
401
|
}
|
|
381
402
|
|
|
382
|
-
/** Where a shape went in the
|
|
403
|
+
/** Where a shape went in the presentation `fromPptx` returned. */
|
|
383
404
|
export interface PptxOpfLink {
|
|
384
405
|
/**
|
|
385
406
|
* "block" fed a block (`path`, `blockType`); "title", "subtitle" and "tag" fed that slide field. Other roles name a shape the
|
|
386
|
-
* importer consumed without a block of its own: "furniture" (footer, date, number, section), "
|
|
407
|
+
* importer consumed without a block of its own: "furniture" (footer, date, number, section), "background" (the picture of an image background),
|
|
408
|
+
* "image-overlay" (the overlay shape of an image background or image block), "watermark", "logo",
|
|
387
409
|
* and the members of an OPF-tagged group ("code", "metric", "quote", "timeline", "media", "card-frame").
|
|
388
410
|
*/
|
|
389
411
|
role: string;
|
|
390
|
-
/** Path in the
|
|
412
|
+
/** Path in the presentation, for example "slides.2.blocks.1", "slides.0.title", or "slides.1.left" after a tagged round trip. */
|
|
391
413
|
path?: string;
|
|
392
414
|
blockType?: string;
|
|
393
415
|
}
|
|
@@ -462,9 +484,9 @@ export interface TypefaceInventory {
|
|
|
462
484
|
fontsUsed: string[] | null;
|
|
463
485
|
}
|
|
464
486
|
|
|
465
|
-
export interface
|
|
466
|
-
/** Family names the
|
|
467
|
-
|
|
487
|
+
export interface CheckTypefacesOptions {
|
|
488
|
+
/** Family names the presentation chose (heading, body, code, run fonts). Required. */
|
|
489
|
+
families: string[];
|
|
468
490
|
/** Chosen families that are monospace; their pitchFamily must be fixed pitch, and only theirs. */
|
|
469
491
|
monospace?: string[];
|
|
470
492
|
/** Allow empty theme ea/cs slots and references to them (FF-05). Default true. */
|
|
@@ -482,7 +504,7 @@ export type ThemeScriptSelection = Partial<Record<"major" | "minor", Partial<Rec
|
|
|
482
504
|
export type TypefaceViolationReason =
|
|
483
505
|
| "foreign-typeface"
|
|
484
506
|
| "foreign-theme-reference"
|
|
485
|
-
| "
|
|
507
|
+
| "theme-reference-unresolved"
|
|
486
508
|
| "empty-theme-reference"
|
|
487
509
|
| "empty-typeface"
|
|
488
510
|
| "foreign-script-supplement"
|
|
@@ -504,11 +526,11 @@ export interface TypefaceViolation {
|
|
|
504
526
|
|
|
505
527
|
export declare const THEME_SCRIPT_SUPPLEMENTS: Readonly<Record<"major" | "minor", Readonly<Record<string, string>>>>;
|
|
506
528
|
|
|
507
|
-
export declare function
|
|
529
|
+
export declare function inventoryTypefaces(input: Uint8Array | ArrayBuffer | Record<string, Uint8Array>, options?: {nested?: boolean}): TypefaceInventory;
|
|
508
530
|
|
|
509
531
|
export declare function packageFontsUsed(inventory: TypefaceInventory): string[];
|
|
510
532
|
|
|
511
|
-
export declare function
|
|
533
|
+
export declare function checkTypefaces(input: Uint8Array | ArrayBuffer | Record<string, Uint8Array>, options: CheckTypefacesOptions): {
|
|
512
534
|
ok: boolean;
|
|
513
535
|
violations: TypefaceViolation[];
|
|
514
536
|
inventory: TypefaceInventory;
|