pptx-glimpse 1.1.1 → 2.0.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/dist/index.d.ts CHANGED
@@ -1,125 +1,133 @@
1
1
  /**
2
- * PPTX フォント名 OSS 代替フォント (Google Fonts) のマッピング。
3
- * ユーザーが拡張・上書き可能。
2
+ * Source handle related types.
3
+ *
4
+ * PptxSourceModel source node is a writer / editor / round-trip
5
+ * In order to do this, we can use ``which package part and which node it came from'' as a stable handle.
6
+ * A handle is not a direct mutable pointer, but a stable reference
7
+ * (see part path / relationship id / node id / order within siblings / raw sidecar)
8
+ * composes it.
4
9
  */
5
- /** フォントマッピングテーブルの型 */
6
- type FontMapping = Record<string, string>;
7
- /** デフォルトのフォントマッピングテーブル */
8
- declare const DEFAULT_FONT_MAPPING: Readonly<FontMapping>;
10
+ declare const PartPathBrand: unique symbol;
11
+ declare const RelationshipIdBrand: unique symbol;
12
+ declare const SourceNodeIdBrand: unique symbol;
13
+ declare const RawSidecarIdBrand: unique symbol;
14
+ /** Part path inside the OOXML package (Example: `ppt/slides/slide1.xml`). */
15
+ type PartPath = string & {
16
+ readonly [PartPathBrand]: typeof PartPathBrand;
17
+ };
18
+ /** Relationship id (Example: `rId1`).`_rels/*.rels` source. */
19
+ type RelationshipId = string & {
20
+ readonly [RelationshipIdBrand]: typeof RelationshipIdBrand;
21
+ };
22
+ /** An id that uniquely points to an element within the source part (spid / generation id, etc.). */
23
+ type SourceNodeId = string & {
24
+ readonly [SourceNodeIdBrand]: typeof SourceNodeIdBrand;
25
+ };
26
+ /** Id pointing to a raw sidecar. */
27
+ type RawSidecarId = string & {
28
+ readonly [RawSidecarIdBrand]: typeof RawSidecarIdBrand;
29
+ };
9
30
  /**
10
- * デフォルトマッピングとユーザーマッピングをマージしたテーブルを生成する。
11
- * ユーザー指定が優先される。
31
+ * Stable handle describing a source node's provenance. The writer uses the handle to decide whether a generated
32
+ * node can be spliced into an existing part or whether a broader scope must be regenerated.
33
+ *
12
34
  */
13
- declare function createFontMapping(userMapping?: FontMapping): FontMapping;
14
- declare function getMappedFont(fontFamily: string | null | undefined, mapping: FontMapping): string | null;
15
-
16
- type LogLevel = "off" | "warn" | "debug";
17
- interface WarningEntry {
18
- /** The feature key, e.g. "sp.style", "bodyPr@vert" */
19
- feature: string;
20
- /** Human-readable description */
21
- message: string;
22
- /** Location context, e.g. "Slide 1" */
23
- context?: string;
24
- }
25
- interface WarningSummary {
26
- totalCount: number;
27
- features: {
28
- feature: string;
29
- message: string;
30
- count: number;
31
- }[];
35
+ interface SourceHandle {
36
+ /** Package part that owns this node. */
37
+ readonly partPath: PartPath;
38
+ /** Node id inside the part (when available). */
39
+ readonly nodeId?: SourceNodeId;
40
+ /** The relationship id referencing this node (e.g. `r:embed` in blip). */
41
+ readonly relationshipId?: RelationshipId;
42
+ /** The child's order slot within the parent element. Used to restore order with raw sidecar. */
43
+ readonly orderingSlot?: number;
44
+ /** Raw sidecar ids associated with this node. */
45
+ readonly rawSidecarIds?: readonly RawSidecarId[];
32
46
  }
33
- declare function getWarningSummary(): WarningSummary;
34
- declare function getWarningEntries(): readonly WarningEntry[];
35
47
 
36
- interface ConvertOptions {
37
- /** 変換対象のスライド番号 (1始まり)。未指定で全スライド */
38
- slides?: number[];
39
- /** 出力画像の幅 (ピクセル)。デフォルト: 960 */
40
- width?: number;
41
- /** 出力画像の高さ (ピクセル)。widthと同時指定時はwidthが優先 */
42
- height?: number;
43
- /** 警告ログレベル。デフォルト: "off" */
44
- logLevel?: LogLevel;
45
- /** 追加のフォントディレクトリパス。システムフォントに加えて検索する */
46
- fontDirs?: string[];
47
- /** PPTX フォント名 → OSS 代替フォントのカスタムマッピング。デフォルトマッピングにマージされる */
48
- fontMapping?: FontMapping;
49
- /** true のとき OS のシステムフォントをスキャンせず fontDirs のみを使用する */
50
- skipSystemFonts?: boolean;
51
- /**
52
- * SVG でのテキスト出力方式。デフォルト: "path"
53
- * - "path": グリフをアウトライン化した <path> として出力する。フォント環境に依存しない
54
- * - "text": ネイティブ <text> 要素 + サブセット化フォントの @font-face (data URI) 埋め込みで出力する。
55
- * ブラウザでのインライン表示時にネイティブテキスト描画 (ヒンティング等) が効き、テキスト選択も可能になる。
56
- * <img src="...svg"> 参照やサニタイズ環境では期待どおり描画されないことがある。
57
- * convertPptxToPng では無視され、常に "path" で変換される (resvg は @font-face を解釈しないため)
58
- */
59
- textOutput?: "path" | "text";
48
+ /**
49
+ * Font resolver context for text-to-path conversion.
50
+ * Provides access to a Font object with the opentype.js getPath() method.
51
+ */
52
+ interface OpentypePath {
53
+ toPathData(decimalPlaces?: number): string;
60
54
  }
61
- interface SlideSvg {
62
- slideNumber: number;
63
- svg: string;
55
+ interface OpentypeFullFont {
56
+ unitsPerEm: number;
57
+ ascender: number;
58
+ descender: number;
59
+ getPath(text: string, x: number, y: number, fontSize: number): OpentypePath;
60
+ getAdvanceWidth(text: string, fontSize: number): number;
64
61
  }
65
- interface SlideImage {
66
- slideNumber: number;
67
- png: Buffer;
68
- width: number;
69
- height: number;
62
+ interface TextPathFontResolver {
63
+ resolveFont(fontFamily: string | null | undefined, fontFamilyEa: string | null | undefined, jpanFallback?: string | null): OpentypeFullFont | null;
70
64
  }
71
- declare function convertPptxToSvg(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideSvg[]>;
72
- declare function convertPptxToPng(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideImage[]>;
73
65
 
74
- /** フォント収集結果 */
75
- interface UsedFonts {
76
- /** テーマで定義されたフォント */
77
- theme: {
78
- majorFont: string;
79
- minorFont: string;
80
- majorFontEa: string | null;
81
- minorFontEa: string | null;
82
- majorFontCs: string | null;
83
- minorFontCs: string | null;
84
- };
85
- /** テキストランやテーマで使用されているフォント名の一覧(重複なし、ソート済み) */
86
- fonts: string[];
87
- }
88
66
  /**
89
- * PPTX をパースして使用されているフォント名を収集する。
90
- * レンダリングは行わないため軽量。
67
+ * Mapping from PPTX font family names to replacement font family names.
68
+ *
69
+ * Keys are font names found in PPTX files. Values are font names that should be
70
+ * present in the rendering environment, commonly open-source alternatives to
71
+ * proprietary Microsoft Office fonts.
91
72
  */
92
- declare function collectUsedFonts(input: Buffer | Uint8Array): UsedFonts;
73
+ type FontMapping = Record<string, string>;
74
+ /**
75
+ * Default replacement mapping for common Microsoft Office fonts.
76
+ *
77
+ * The table maps fonts such as Calibri, Arial, Meiryo, and MS Gothic to
78
+ * open-source alternatives used during text measurement, SVG path generation,
79
+ * and font lookup.
80
+ */
81
+ declare const DEFAULT_FONT_MAPPING: Readonly<FontMapping>;
82
+ /**
83
+ * Create a font mapping table by merging defaults with user overrides.
84
+ *
85
+ * @param userMapping Custom PPTX font name to replacement font name entries.
86
+ * User-specified entries take precedence over `DEFAULT_FONT_MAPPING`.
87
+ * @returns A new mutable mapping object.
88
+ */
89
+ declare function createFontMapping(userMapping?: FontMapping): FontMapping;
90
+ /**
91
+ * Look up the replacement font for a PPTX font family.
92
+ *
93
+ * Matching is case-insensitive and normalizes full-width alphanumeric
94
+ * characters used by some Japanese Office font names.
95
+ *
96
+ * @param fontFamily PPTX font family name to resolve.
97
+ * @param mapping Mapping table, usually from `createFontMapping`.
98
+ * @returns The replacement font name, or `null` when no mapping exists.
99
+ */
100
+ declare function getMappedFont(fontFamily: string | null | undefined, mapping: FontMapping): string | null;
93
101
 
94
102
  /**
95
- * テキストの幅と行高さを計測するインターフェース。
96
- * デフォルトでは静的フォントメトリクスによる計測が使われる。
97
- * ユーザーが独自の実装を ConvertOptions.textMeasurer に渡すことで、
98
- * Canvas API opentype.js など任意の計測バックエンドに差し替えられる。
103
+ * Interface for measuring text width and line height.
104
+ * By default, measurement uses static font metrics.
105
+ * Users can pass their own implementation to ConvertOptions.textMeasurer
106
+ * Can be replaced with any measurement backend such as Canvas API or opentype.js.
99
107
  */
100
108
  interface TextMeasurer {
101
109
  /**
102
- * テキストの推定幅をピクセル単位で返す。
103
- * @param text - 計測対象のテキスト
104
- * @param fontSizePt - フォントサイズ (ポイント)
105
- * @param bold - 太字かどうか
106
- * @param fontFamily - ラテン文字用フォントファミリー名
107
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
110
+ * Returns the estimated width of the text in pixels.
111
+ * @param text - text to measure
112
+ * @param fontSizePt - font size (points)
113
+ * @param bold - whether the text is bold
114
+ * @param fontFamily - font family name for Latin text
115
+ * @param fontFamilyEa - font family name for East Asian text
108
116
  */
109
117
  measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
110
118
  /**
111
- * フォントの自然な行高さ比率 (行高さ / フォントサイズ) を返す。
112
- * メトリクスが不明な場合は 1.2 をフォールバック値として返す。
113
- * @param fontFamily - ラテン文字用フォントファミリー名
114
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
119
+ * Returns the font's natural line height ratio (line height / font size).
120
+ * Returns 1.2 as a fallback value if the metric is unknown.
121
+ * @param fontFamily - font family name for Latin text
122
+ * @param fontFamilyEa - font family name for East Asian text
115
123
  */
116
124
  getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
117
125
  /**
118
- * フォントの ascender 比率 (ascender / unitsPerEm) を返す。
119
- * 1行目のベースラインオフセット計算に使用する。
120
- * メトリクスが不明な場合は 1.0 をフォールバック値として返す。
121
- * @param fontFamily - ラテン文字用フォントファミリー名
122
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
126
+ * Font ascender ratio (ascender / unitsPerEm) .
127
+ * Used for baseline offset calculation in the first row.
128
+ * Returns 1.0 as a fallback value if the metric is unknown.
129
+ * @param fontFamily - font family name for Latin text
130
+ * @param fontFamilyEa - font family name for East Asian text
123
131
  */
124
132
  getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
125
133
  }
@@ -138,8 +146,8 @@ declare class OpentypeTextMeasurer implements TextMeasurer {
138
146
  private defaultFont;
139
147
  private warnedFonts;
140
148
  /**
141
- * @param fonts - フォント名 opentype.js Font オブジェクトのマップ
142
- * @param defaultFont - フォールバックフォント(省略可)
149
+ * @param fonts - font name -> opentype.js Map of Font objects
150
+ * @param defaultFont - fallback font (optional)
143
151
  */
144
152
  constructor(fonts: Map<string, OpentypeFont>, defaultFont?: OpentypeFont);
145
153
  measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
@@ -150,58 +158,384 @@ declare class OpentypeTextMeasurer implements TextMeasurer {
150
158
  }
151
159
 
152
160
  /**
153
- * テキスト→パス変換用のフォントリゾルバーコンテキスト。
154
- * opentype.js の getPath() メソッドを持つ Font オブジェクトへのアクセスを提供する。
161
+ * Font file data supplied directly by the caller.
162
+ *
163
+ * Use this when system font scanning is unavailable or undesirable, such as in
164
+ * serverless environments. `name` is used to register TTF/OTF buffers under a
165
+ * specific family name; TTC buffers also read family names from their names
166
+ * table.
155
167
  */
156
- interface OpentypePath {
157
- toPathData(decimalPlaces?: number): string;
158
- }
159
- interface OpentypeFullFont {
160
- unitsPerEm: number;
161
- ascender: number;
162
- descender: number;
163
- getPath(text: string, x: number, y: number, fontSize: number): OpentypePath;
164
- getAdvanceWidth(text: string, fontSize: number): number;
165
- }
166
- interface TextPathFontResolver {
167
- resolveFont(fontFamily: string | null | undefined, fontFamilyEa: string | null | undefined, jpanFallback?: string | null): OpentypeFullFont | null;
168
- }
169
-
170
- /** フォントバッファの入力形式 */
171
168
  interface FontBuffer {
169
+ /**
170
+ * Optional font family name to register for this buffer.
171
+ */
172
172
  name?: string;
173
+ /**
174
+ * Raw TTF, OTF, or TTC font file bytes.
175
+ */
173
176
  data: ArrayBuffer | Uint8Array;
174
177
  }
175
178
  /**
176
- * フォントバッファ配列から OpentypeTextMeasurer を構築する。
179
+ * Create a text measurer from caller-provided font buffers.
180
+ *
181
+ * This low-level helper is useful when rendering in an environment where fonts
182
+ * are bundled as bytes instead of discovered from the OS. It dynamically imports
183
+ * `opentype.js` and returns `null` if no fonts can be parsed or the optional
184
+ * dependency is unavailable.
177
185
  *
178
- * 内部で opentype.js を動的 import してフォントをパースする。
179
- * opentype.js が利用不可な場合は null を返す。
186
+ * @param fontBuffers Font file bytes to parse.
187
+ * @param fontMapping Optional PPTX font name to replacement font mapping.
188
+ * @returns A text measurer, or `null` when setup is not possible.
180
189
  */
181
190
  declare function createOpentypeTextMeasurerFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeTextMeasurer | null>;
191
+ /**
192
+ * Font services created from OpenType font data.
193
+ */
182
194
  interface OpentypeSetup {
195
+ /**
196
+ * Measures text width for layout and wrapping.
197
+ */
183
198
  measurer: OpentypeTextMeasurer;
199
+ /**
200
+ * Resolves fonts for converting text to SVG path outlines.
201
+ */
184
202
  fontResolver: TextPathFontResolver;
185
203
  }
186
204
  /**
187
- * フォントバッファ配列から OpentypeTextMeasurer TextPathFontResolver を同時に構築する。
205
+ * Create font measurement and SVG path resolution services from font buffers.
188
206
  *
189
- * opentype.parse() が返すオブジェクトは OpentypeFont OpentypeFullFont の両方を満たすため、
190
- * 同じ Font オブジェクトを measurer fontResolver の両方に渡す。
207
+ * Use this for advanced integrations that need to provide fonts explicitly
208
+ * instead of relying on system font directories. Returned services can be wired
209
+ * into renderer internals; the public conversion APIs usually only need
210
+ * `fontDirs`, `skipSystemFonts`, and `fontMapping`.
211
+ *
212
+ * @param fontBuffers TTF, OTF, or TTC font file bytes.
213
+ * @param fontMapping Optional PPTX font name to replacement font mapping.
214
+ * @returns Font services, or `null` when no usable font setup can be created.
191
215
  */
192
216
  declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
193
217
  /**
194
- * フォントオブジェクトキャッシュをクリアする。
195
- * 通常は呼び出す必要はないが、フォントのインストール/アンインストール後に
196
- * 強制的に再読み込みしたい場合に使用する。
218
+ * Clear the module-level cache of parsed system fonts.
219
+ *
220
+ * Conversion APIs cache parsed font objects for repeated calls with the same
221
+ * font options. Call this after installing, removing, or replacing fonts in a
222
+ * long-running process when subsequent conversions must reload font files.
197
223
  */
198
224
  declare function clearFontCache(): void;
199
225
 
200
226
  /**
201
- * resvg-wasm WASM モジュールを初期化する。
202
- * 明示的に呼び出さなくても、初回の PNG 変換時に自動的に初期化される。
203
- * アプリケーション起動時に初期化しておきたい場合に使用する。
227
+ * Initialize the resvg-wasm module used for PNG conversion.
228
+ *
229
+ * Calling this is optional because `convertPptxToPng` initializes resvg-wasm on
230
+ * first use. Applications may call it during startup to pay the WASM loading
231
+ * cost before handling the first conversion request.
204
232
  */
205
233
  declare function initResvgWasm(): Promise<void>;
206
234
 
207
- export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
235
+ /**
236
+ * Controls how unsupported-feature warnings are collected and printed.
237
+ *
238
+ * `"off"` disables collection, `"warn"` collects entries and prints summaries,
239
+ * and `"debug"` also prints each warning as it is recorded.
240
+ */
241
+ type LogLevel = "off" | "warn" | "debug";
242
+ /**
243
+ * One unsupported or approximated feature encountered during conversion.
244
+ */
245
+ interface WarningEntry {
246
+ /**
247
+ * Stable feature key, for example `"sp.style"` or `"bodyPr@vert"`.
248
+ */
249
+ feature: string;
250
+ /**
251
+ * Human-readable warning message.
252
+ */
253
+ message: string;
254
+ /**
255
+ * Optional location context, for example `"Slide 1"`.
256
+ */
257
+ context?: string;
258
+ }
259
+ /**
260
+ * Aggregated warnings from the most recent conversion cycle.
261
+ */
262
+ interface WarningSummary {
263
+ /**
264
+ * Total number of warning entries.
265
+ */
266
+ totalCount: number;
267
+ /**
268
+ * Warning counts grouped by feature key.
269
+ */
270
+ features: {
271
+ feature: string;
272
+ message: string;
273
+ count: number;
274
+ }[];
275
+ }
276
+ /**
277
+ * Return a grouped summary of currently collected warnings.
278
+ *
279
+ * This reads the active warning logger state. The public conversion APIs flush
280
+ * warnings at the end of a conversion so summaries can be printed; after that
281
+ * flush, this returns an empty summary until new warnings are recorded. It is
282
+ * mainly useful for lower-level renderer workflows, tests, and integrations
283
+ * that manage the warning cycle directly.
284
+ */
285
+ declare function getWarningSummary(): WarningSummary;
286
+ /**
287
+ * Return individual warning entries collected in the current warning cycle.
288
+ *
289
+ * Entries include optional slide or element context when available. The public
290
+ * conversion APIs flush entries at the end of a conversion, so this is mainly
291
+ * useful for lower-level renderer workflows, tests, and integrations that
292
+ * manage the warning cycle directly.
293
+ */
294
+ declare function getWarningEntries(): readonly WarningEntry[];
295
+
296
+ /**
297
+ * Options shared by PPTX-to-SVG and PPTX-to-PNG conversion.
298
+ */
299
+ interface ConvertOptions {
300
+ /**
301
+ * Target slide numbers to convert, using PowerPoint-style 1-based numbering.
302
+ *
303
+ * When omitted, every slide in the presentation is converted. Missing or
304
+ * out-of-range slide numbers produce no output for those entries.
305
+ */
306
+ slides?: number[];
307
+ /**
308
+ * Output width in pixels.
309
+ *
310
+ * PNG output rasterizes to this width while preserving the slide aspect
311
+ * ratio. Defaults to 960. SVG output keeps the slide's native pixel size from
312
+ * the PPTX slide dimensions and does not use this option.
313
+ */
314
+ width?: number;
315
+ /**
316
+ * Output height in pixels.
317
+ *
318
+ * PNG rasterization currently always uses `width`, either the provided value
319
+ * or the default width, so this option is ignored by the public conversion
320
+ * APIs. SVG output keeps the slide's native pixel size and does not use this
321
+ * option.
322
+ */
323
+ height?: number;
324
+ /**
325
+ * Warning log level for unsupported or approximated PPTX features.
326
+ *
327
+ * Defaults to `"off"`. Diagnostics are always collected in the conversion
328
+ * report; this option only controls console output. Use `"warn"` to print
329
+ * summaries, or `"debug"` to print individual warning entries as they are
330
+ * recorded.
331
+ */
332
+ logLevel?: LogLevel;
333
+ /**
334
+ * Additional directories that are scanned for font files.
335
+ *
336
+ * These directories are searched in addition to system font directories unless
337
+ * `skipSystemFonts` is true.
338
+ */
339
+ fontDirs?: string[];
340
+ /**
341
+ * Custom PPTX font name to replacement font name mapping.
342
+ *
343
+ * Entries are merged with `DEFAULT_FONT_MAPPING`; user-provided entries take
344
+ * precedence. This is useful when a PPTX references proprietary or corporate
345
+ * fonts that should render with installed alternatives.
346
+ */
347
+ fontMapping?: FontMapping;
348
+ /**
349
+ * Skip OS system font directories and only scan `fontDirs`.
350
+ *
351
+ * This is useful in containers or serverless environments where bundled fonts
352
+ * should be the only fonts used.
353
+ */
354
+ skipSystemFonts?: boolean;
355
+ /**
356
+ * Text output mode for SVG conversion.
357
+ *
358
+ * Defaults to `"path"`, which emits glyph outlines as `<path>` elements and
359
+ * does not require fonts in the SVG viewing environment. `"text"` emits native
360
+ * `<text>` elements with subset-font `@font-face` data URIs, enabling browser
361
+ * text selection and native text rendering for inline SVG.
362
+ *
363
+ * Embedded fonts and native text may not render as expected when the SVG is
364
+ * loaded through `<img src="...svg">` or sanitized. `convertPptxToPng` ignores
365
+ * this option and always renders with `"path"` output because resvg does not
366
+ * interpret the embedded `@font-face` rules used by SVG text output.
367
+ */
368
+ textOutput?: "path" | "text";
369
+ }
370
+ /**
371
+ * SVG conversion result for one slide.
372
+ */
373
+ interface SlideSvg {
374
+ /**
375
+ * Original slide number in the PPTX file, using 1-based numbering.
376
+ */
377
+ slideNumber: number;
378
+ /**
379
+ * Complete SVG document string for the slide.
380
+ */
381
+ svg: string;
382
+ }
383
+ /**
384
+ * PNG conversion result for one slide.
385
+ */
386
+ interface SlideImage {
387
+ /**
388
+ * Original slide number in the PPTX file, using 1-based numbering.
389
+ */
390
+ slideNumber: number;
391
+ /**
392
+ * PNG image bytes for the rendered slide.
393
+ */
394
+ png: Buffer;
395
+ /**
396
+ * Actual output image width in pixels after rasterization.
397
+ */
398
+ width: number;
399
+ /**
400
+ * Actual output image height in pixels after rasterization.
401
+ */
402
+ height: number;
403
+ }
404
+ interface ConversionDiagnostic {
405
+ readonly source: "document" | "computed-view" | "renderer-adapter" | "renderer";
406
+ readonly severity: "info" | "warning" | "error";
407
+ readonly code: string;
408
+ readonly message: string;
409
+ readonly slideNumber?: number;
410
+ readonly sourcePartPath?: string;
411
+ readonly context?: string;
412
+ readonly handle?: SourceHandle;
413
+ }
414
+ interface SupportCoverageCounts {
415
+ /**
416
+ * Number of PPTX source/computed elements considered for rendering.
417
+ */
418
+ readonly inputElements: number;
419
+ /**
420
+ * Number of renderer-model elements produced for SVG / PNG output.
421
+ */
422
+ readonly outputElements: number;
423
+ /**
424
+ * Elements or raw nodes skipped because they are outside the supported render subset.
425
+ */
426
+ readonly skippedElements: number;
427
+ /**
428
+ * Elements skipped because a referenced PPTX part or relationship could not be resolved.
429
+ */
430
+ readonly unresolvedElements: number;
431
+ /**
432
+ * Elements or properties rendered with a fallback or ignored unsupported property.
433
+ */
434
+ readonly fallbackElements: number;
435
+ /**
436
+ * Diagnostics with warning severity that affect support/renderability confidence.
437
+ */
438
+ readonly warnings: number;
439
+ }
440
+ interface SlideSupportCoverage extends SupportCoverageCounts {
441
+ readonly slideNumber: number;
442
+ }
443
+ interface SupportCoverage {
444
+ /**
445
+ * Support/renderability coverage summary. This is not a visual-match or pixel accuracy metric.
446
+ */
447
+ readonly overall: SupportCoverageCounts;
448
+ readonly slides: readonly SlideSupportCoverage[];
449
+ }
450
+ interface SvgConversionReport {
451
+ readonly slides: readonly SlideSvg[];
452
+ readonly diagnostics: readonly ConversionDiagnostic[];
453
+ readonly supportCoverage: SupportCoverage;
454
+ }
455
+ interface PngConversionReport {
456
+ readonly slides: readonly SlideImage[];
457
+ readonly diagnostics: readonly ConversionDiagnostic[];
458
+ readonly supportCoverage: SupportCoverage;
459
+ }
460
+ /**
461
+ * Convert a PPTX file to SVG documents.
462
+ *
463
+ * @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
464
+ * @param options Conversion options. `slides` uses 1-based slide numbers; when
465
+ * omitted, all slides are converted.
466
+ * @returns A conversion report containing converted slides, diagnostics, and support coverage.
467
+ *
468
+ * Text is emitted as SVG paths by default for portable rendering. Set
469
+ * `textOutput: "text"` to emit native `<text>` elements with embedded subset
470
+ * fonts for inline browser SVG use. Font directories and font mapping options
471
+ * control how PPTX font names are resolved for text measurement and text output.
472
+ */
473
+ declare function convertPptxToSvg(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SvgConversionReport>;
474
+ /**
475
+ * Convert a PPTX file to PNG images.
476
+ *
477
+ * @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
478
+ * @param options Conversion options. `slides` uses 1-based slide numbers; when
479
+ * omitted, all slides are converted.
480
+ * @returns A conversion report containing converted PNG slides, diagnostics, and support coverage.
481
+ *
482
+ * PNG conversion first renders each slide to SVG and then rasterizes it with
483
+ * resvg. The `textOutput` option is intentionally ignored: PNG rendering always
484
+ * uses path-based text output because resvg does not interpret the embedded
485
+ * `@font-face` rules used by SVG text mode. Font directories and font mapping
486
+ * options are still used to resolve glyph outlines and text metrics.
487
+ */
488
+ declare function convertPptxToPng(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<PngConversionReport>;
489
+
490
+ /**
491
+ * Font names discovered in a PPTX file.
492
+ */
493
+ interface UsedFonts {
494
+ /**
495
+ * Theme font slots resolved from the presentation's default theme.
496
+ */
497
+ theme: {
498
+ /**
499
+ * Major Latin theme font.
500
+ */
501
+ majorFont: string;
502
+ /**
503
+ * Minor Latin theme font.
504
+ */
505
+ minorFont: string;
506
+ /**
507
+ * Major East Asian theme font, when present.
508
+ */
509
+ majorFontEa: string | null;
510
+ /**
511
+ * Minor East Asian theme font, when present.
512
+ */
513
+ minorFontEa: string | null;
514
+ /**
515
+ * Major complex-script theme font, when present.
516
+ */
517
+ majorFontCs: string | null;
518
+ /**
519
+ * Minor complex-script theme font, when present.
520
+ */
521
+ minorFontCs: string | null;
522
+ };
523
+ /**
524
+ * Unique sorted font names used by text runs, bullets, and theme font slots.
525
+ */
526
+ fonts: string[];
527
+ }
528
+ /**
529
+ * Parse a PPTX file and collect the font names it references.
530
+ *
531
+ * This is a lightweight preflight helper: it reads the document model and text
532
+ * styles but does not render slides or load font files. Use it to decide which
533
+ * fonts should be installed, bundled, or mapped before calling the conversion
534
+ * APIs.
535
+ *
536
+ * @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
537
+ * @returns Theme font slots and a unique sorted list of referenced font names.
538
+ */
539
+ declare function collectUsedFonts(input: Buffer | Uint8Array): UsedFonts;
540
+
541
+ export { type ConversionDiagnostic, type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type PngConversionReport, type SlideImage, type SlideSupportCoverage, type SlideSvg, type SupportCoverage, type SupportCoverageCounts, type SvgConversionReport, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };