@openpresentation/opf-pptx 0.9.1 → 0.11.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/DEPENDENCY-NOTES.md +1 -1
- package/README.md +108 -17
- package/dist/background-import.js +59 -3
- package/dist/background.js +86 -1
- package/dist/body-text-import.js +86 -0
- package/dist/code-provenance.js +9 -3
- package/dist/document-provenance.js +998 -0
- package/dist/font-weights.js +63 -0
- package/dist/furniture-fields.js +176 -0
- package/dist/furniture-provenance.js +138 -18
- package/dist/image-geometry.js +77 -5
- package/dist/index.d.ts +112 -2
- package/dist/index.js +873 -110
- package/dist/media-provenance.js +237 -0
- package/dist/native-text-style.js +71 -0
- package/dist/package-fonts.js +161 -0
- package/dist/script-fonts.js +290 -0
- package/dist/slide-image-provenance.js +169 -0
- package/dist/table-import.js +1 -53
- package/dist/theme-colors.js +204 -0
- package/dist/typeface-inventory.js +227 -0
- package/package.json +15 -7
package/dist/index.d.ts
CHANGED
|
@@ -33,27 +33,67 @@ 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
|
+
export interface MediaProvenanceDiagnostic { code: "media-provenance-omitted"; path: string; message: string }
|
|
38
|
+
/** 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: "data-not-inline" | "no-rows" | "no-columns" | "single-column-not-numeric" }
|
|
40
|
+
/** Content with no PowerPoint export (an empty table, an unsupported payload) is replaced by a plain-language placeholder frame. */
|
|
41
|
+
export interface ContentPlaceholderDiagnostic { code: "content-placeholder"; path: string; message: string; reason: "table-has-no-rows" | "unsupported-payload" }
|
|
42
|
+
/** The chart data was reshaped to export a native chart: a histogram's values were binned, or a single value column was plotted against row numbers. */
|
|
43
|
+
export interface ChartDataAdaptedDiagnostic { code: "chart-data-adapted"; path: string; message: string; adaptation: "histogram-binned" | "row-numbers" }
|
|
44
|
+
|
|
36
45
|
export interface ToPptxOptions {
|
|
37
46
|
/** Default compatible converts WebP to a static PNG. Preserve embeds original WebP bytes. */
|
|
38
47
|
imageFormat?: "compatible" | "preserve";
|
|
48
|
+
/**
|
|
49
|
+
* OPF_DOCUMENT_V1 / OPF_SLIDE_V1 customer-data tags that let fromPptx restore
|
|
50
|
+
* catalog references, layout ids and authoring metadata (docs/document-roundtrip.md).
|
|
51
|
+
* Tags are not shown in PowerPoint's UI. Default "full"; "references-only"
|
|
52
|
+
* stores catalog references without organization, speaker, free text, slide ids
|
|
53
|
+
* or assets; false writes no tags.
|
|
54
|
+
*/
|
|
55
|
+
provenance?: "full" | "references-only" | false;
|
|
39
56
|
textMeasurement?: TextMeasurement;
|
|
40
57
|
/** Match preview/pagination clearance around supplied vector text outlines; default 1. */
|
|
41
58
|
textRasterPadding?: number;
|
|
42
|
-
|
|
59
|
+
/** Layout diagnostics, `media-provenance-omitted` when video data cannot be stored, plus `unresolved-font-scheme` (once per reference path) when a font-scheme id matches no record and the default `aptos` scheme is used as the base. */
|
|
60
|
+
onDiagnostic?: (diagnostic: LayoutDiagnostic | FontSchemeDiagnostic | MediaProvenanceDiagnostic | ChartDataUnplottableDiagnostic | ChartDataAdaptedDiagnostic | ContentPlaceholderDiagnostic) => void;
|
|
43
61
|
baseDir?: string;
|
|
44
62
|
compressionLevel?: number;
|
|
45
63
|
imageResolver?: (src: string, context: ImageResolverContext) => ImageResolverResult | Promise<ImageResolverResult | null | undefined> | null | undefined;
|
|
46
64
|
seed?: number;
|
|
47
65
|
strictAssets?: boolean;
|
|
48
66
|
timestamp?: string;
|
|
67
|
+
/**
|
|
68
|
+
* ZIP calendar timestamps, including embedded workbooks, use UTC fields at
|
|
69
|
+
* two-second resolution. Omitted/undefined retains the fixed 1980 default.
|
|
70
|
+
* Accepts a valid Date, finite epoch milliseconds, YYYY-MM-DD (UTC midnight),
|
|
71
|
+
* or YYYY-MM-DDTHH:mm[:ss[.fraction]] with Z or ±HH:mm. UTC years 1980–2099 only.
|
|
72
|
+
* Ambiguous/legacy strings and invalid/out-of-range values throw OPFPptxError
|
|
73
|
+
* at options.zipDate; null, empty string and zero no longer choose the default.
|
|
74
|
+
*/
|
|
49
75
|
zipDate?: string | number | Date;
|
|
76
|
+
/**
|
|
77
|
+
* Today's calendar date (ISO YYYY-MM-DD) for `date: true` header/footer fields. The exporter never
|
|
78
|
+
* reads a clock: it lays out this date as the cached text of a native PowerPoint date field, which
|
|
79
|
+
* PowerPoint updates on open. Without it a current date is reported as unresolved content.
|
|
80
|
+
*/
|
|
81
|
+
date?: string;
|
|
82
|
+
/** Host-supplied catalog records, as in opf-render. Currently consulted for socialPlatforms (generated socials furniture). */
|
|
83
|
+
catalogs?: Record<string, { records?: unknown[] } | unknown[]>;
|
|
84
|
+
/** Records for document `catalogs.<kind>.source` URLs, as in opf-render. Currently consulted for socialPlatforms. */
|
|
85
|
+
catalogSources?: Record<string, { records?: unknown[] } | unknown[]>;
|
|
50
86
|
}
|
|
51
87
|
|
|
52
88
|
export interface FromPptxOptions {
|
|
53
|
-
/** 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). */
|
|
89
|
+
/** 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 id that resolves to no inline or bundled record reports `unresolved-layout-reference` (docs/document-roundtrip.md). */
|
|
54
90
|
onDiagnostic?: (diagnostic: {code: string; path: string; message: string}) => void;
|
|
55
91
|
fallbackName?: string;
|
|
56
92
|
schema?: string;
|
|
93
|
+
/** The export's host catalog records (as in ToPptxOptions). Currently used to recognize unedited socials lines, so authored handles return. */
|
|
94
|
+
catalogs?: Record<string, { records?: unknown[] } | unknown[]>;
|
|
95
|
+
/** The export's records for document `catalogs.<kind>.source` URLs (as in ToPptxOptions). Currently used for socialPlatforms. */
|
|
96
|
+
catalogSources?: Record<string, { records?: unknown[] } | unknown[]>;
|
|
57
97
|
}
|
|
58
98
|
|
|
59
99
|
export declare class OPFPptxError extends Error {
|
|
@@ -67,3 +107,73 @@ export declare class OPFPptxError extends Error {
|
|
|
67
107
|
export declare function toPptx(input: unknown, options?: ToPptxOptions): Promise<Uint8Array>;
|
|
68
108
|
|
|
69
109
|
export declare function fromPptx(input: Uint8Array | ArrayBuffer, options?: FromPptxOptions): Promise<Record<string, unknown>>;
|
|
110
|
+
|
|
111
|
+
export interface TypefaceEntry {
|
|
112
|
+
/** Part path; parts of nested packages use "outer.xlsx!/inner/part.xml". */
|
|
113
|
+
part: string;
|
|
114
|
+
kind: "drawingml" | "spreadsheetml";
|
|
115
|
+
/** Local element name, for example latin, ea, cs, sym, buFont, font, name or rFont. */
|
|
116
|
+
element: string;
|
|
117
|
+
typeface: string;
|
|
118
|
+
/** Theme font collection for theme parts. */
|
|
119
|
+
theme?: "major" | "minor";
|
|
120
|
+
/** Script tag of a theme script supplement (`<a:font script="…">`). */
|
|
121
|
+
script?: string;
|
|
122
|
+
pitchFamily?: number;
|
|
123
|
+
/** Theme reference (+mj-lt, +mn-ea, …) resolved against the package theme; null when unresolved. */
|
|
124
|
+
resolved?: string | null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface TypefaceInventory {
|
|
128
|
+
typefaces: TypefaceEntry[];
|
|
129
|
+
themes: Record<string, {major: Partial<Record<"latin" | "ea" | "cs", string>>; minor: Partial<Record<"latin" | "ea" | "cs", string>>}>;
|
|
130
|
+
/** docProps/app.xml "Fonts Used", or null when the package has no readable list. */
|
|
131
|
+
fontsUsed: string[] | null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface CheckPptxTypefacesOptions {
|
|
135
|
+
/** Family names the document chose (heading, body, code, run fonts). Required. */
|
|
136
|
+
fonts: string[];
|
|
137
|
+
/** Chosen families that are monospace; their pitchFamily must be fixed pitch, and only theirs. */
|
|
138
|
+
monospace?: string[];
|
|
139
|
+
/** Allow empty theme ea/cs slots and references to them (FF-05). Default true. */
|
|
140
|
+
allowEmptyThemeScripts?: boolean;
|
|
141
|
+
/** Allowed theme script supplements; defaults to THEME_SCRIPT_SUPPLEMENTS. */
|
|
142
|
+
scriptSupplements?: Readonly<Record<"major" | "minor", Readonly<Record<string, string>>>>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type TypefaceViolationReason =
|
|
146
|
+
| "foreign-typeface"
|
|
147
|
+
| "foreign-theme-reference"
|
|
148
|
+
| "unresolved-theme-reference"
|
|
149
|
+
| "empty-theme-reference"
|
|
150
|
+
| "empty-typeface"
|
|
151
|
+
| "foreign-script-supplement"
|
|
152
|
+
| "monospace-not-fixed-pitch"
|
|
153
|
+
| "fixed-pitch-not-monospace"
|
|
154
|
+
| "inconsistent-pitch-family"
|
|
155
|
+
| "missing-fonts-used"
|
|
156
|
+
| "foreign-fonts-used"
|
|
157
|
+
| "fonts-used-mismatch";
|
|
158
|
+
|
|
159
|
+
export interface TypefaceViolation {
|
|
160
|
+
reason: TypefaceViolationReason;
|
|
161
|
+
part: string;
|
|
162
|
+
element?: string;
|
|
163
|
+
typeface?: string;
|
|
164
|
+
[detail: string]: unknown;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export declare const THEME_SCRIPT_SUPPLEMENTS: Readonly<Record<"major" | "minor", Readonly<Record<string, string>>>>;
|
|
168
|
+
|
|
169
|
+
export declare function inventoryPptxTypefaces(input: Uint8Array | ArrayBuffer | Record<string, Uint8Array>, options?: {nested?: boolean}): TypefaceInventory;
|
|
170
|
+
|
|
171
|
+
export declare function packageFontsUsed(inventory: TypefaceInventory): string[];
|
|
172
|
+
|
|
173
|
+
export declare function checkPptxTypefaces(input: Uint8Array | ArrayBuffer | Record<string, Uint8Array>, options: CheckPptxTypefacesOptions): {
|
|
174
|
+
ok: boolean;
|
|
175
|
+
violations: TypefaceViolation[];
|
|
176
|
+
inventory: TypefaceInventory;
|
|
177
|
+
/** The "Fonts Used" list the package's own fonts imply. */
|
|
178
|
+
fontsUsed: string[];
|
|
179
|
+
};
|