ooxml-core 1.24.0 → 1.24.1

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 (41) hide show
  1. package/README.md +2 -2
  2. package/dist/{PptxHandler-FSKKPZZC.mjs → PptxHandler-5TWAQWPK.mjs} +2 -2
  3. package/dist/{PptxHandler-H7MEWJJJ.mjs → PptxHandler-KBJ4TN3T.mjs} +1 -1
  4. package/dist/{PptxHandler-DNSXWTQV.cjs → PptxHandler-KFEE7O7W.cjs} +2 -2
  5. package/dist/{PresentationBuilder-7TSENZTX.mjs → PresentationBuilder-SCT5AQBP.mjs} +1 -1
  6. package/dist/{PresentationBuilder-RIJWQSEU.mjs → PresentationBuilder-SVHIKT4C.mjs} +2 -2
  7. package/dist/{PresentationBuilder-A5NI35VN.cjs → PresentationBuilder-SXLRXYDI.cjs} +4 -4
  8. package/dist/{chunk-4QPOJCJG.mjs → chunk-7N7C5BNM.mjs} +1 -1
  9. package/dist/{chunk-DLFMCZZT.mjs → chunk-CWCDFPKN.mjs} +1 -1
  10. package/dist/{chunk-LF5E5ZOH.mjs → chunk-GVP262WE.mjs} +25 -62
  11. package/dist/{chunk-VQF6HQEE.mjs → chunk-KVKTHGIY.mjs} +1 -1
  12. package/dist/{chunk-BA7Z6ATM.mjs → chunk-NE7626A4.mjs} +4 -4
  13. package/dist/{chunk-Q5PKBQXH.mjs → chunk-ON7XVRHQ.mjs} +26 -63
  14. package/dist/{chunk-HL3FBJ6X.cjs → chunk-XK55DEUD.cjs} +25 -62
  15. package/dist/pptx/automation/index.cjs +25 -67
  16. package/dist/pptx/automation/index.d.ts +3 -2
  17. package/dist/pptx/automation/index.d.ts.map +1 -1
  18. package/dist/pptx/automation/index.mjs +5 -5
  19. package/dist/pptx/chunks/{index-Q5mM8kIR.d.ts → index-4FmgJajb.d.ts} +3 -2
  20. package/dist/pptx/chunks/index-4FmgJajb.d.ts.map +1 -0
  21. package/dist/pptx/chunks/index-C3xhAMSa.d.ts +837 -0
  22. package/dist/pptx/chunks/index-C3xhAMSa.d.ts.map +1 -0
  23. package/dist/pptx/chunks/{index-CPhsd7Df.d.ts → index-nKQ4s7FA.d.ts} +24 -834
  24. package/dist/pptx/chunks/index-nKQ4s7FA.d.ts.map +1 -0
  25. package/dist/pptx/cli/index.cjs +25 -67
  26. package/dist/pptx/cli/index.mjs +4 -4
  27. package/dist/pptx/converter/index.d.ts +1 -1
  28. package/dist/pptx/converter/index.mjs +2 -2
  29. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  30. package/dist/pptx/editor/render/slide-operations.cjs +1 -1
  31. package/dist/pptx/editor/render/slide-operations.mjs +1 -1
  32. package/dist/pptx/index.cjs +25 -67
  33. package/dist/pptx/index.d.ts +4 -3
  34. package/dist/pptx/index.mjs +5 -5
  35. package/dist/pptx/node/index.cjs +40 -0
  36. package/dist/pptx/node/index.d.ts +13 -0
  37. package/dist/pptx/node/index.d.ts.map +1 -0
  38. package/dist/pptx/node/index.mjs +40 -0
  39. package/package.json +6 -1
  40. package/dist/pptx/chunks/index-CPhsd7Df.d.ts.map +0 -1
  41. package/dist/pptx/chunks/index-Q5mM8kIR.d.ts.map +0 -1
@@ -0,0 +1,837 @@
1
+ import { r as TextSegment } from "./text-D49FKllA.js";
2
+ import { m as PptxElement } from "./elements-iUzpAeqR.js";
3
+ import { C as PptxSlide, d as PptxData } from "./text-operations-CfLVZ7DK.js";
4
+ import "./index-nKQ4s7FA.js";
5
+ //#region pptx/converter/types.d.ts
6
+ /**
7
+ * Platform adapter for file system operations.
8
+ *
9
+ * Consumers must provide an implementation of this interface
10
+ * when using the converter with file output (writing markdown
11
+ * and extracting media to disk).
12
+ *
13
+ * For in-memory-only conversion (just getting the markdown string),
14
+ * no adapter is required.
15
+ */
16
+ interface FileSystemAdapter {
17
+ /**
18
+ * Writes a UTF-8 text file at the given path, creating or overwriting as needed.
19
+ * @param path - Absolute or relative path for the output file.
20
+ * @param content - Text content to write.
21
+ */
22
+ writeFile(path: string, content: string): Promise<void>;
23
+ /**
24
+ * Writes a binary file (e.g. an extracted image) at the given path.
25
+ * @param path - Absolute or relative path for the output file.
26
+ * @param data - Raw binary content as a typed array.
27
+ */
28
+ writeBinaryFile(path: string, data: Uint8Array): Promise<void>;
29
+ /**
30
+ * Creates a directory (and any missing parents) at the given path.
31
+ * Should be a no-op if the directory already exists.
32
+ * @param path - Absolute or relative path for the directory.
33
+ */
34
+ createFolder(path: string): Promise<void>;
35
+ }
36
+ /**
37
+ * Options shared by all document converters, controlling output paths,
38
+ * media extraction folder names, and metadata inclusion.
39
+ */
40
+ interface ConversionOptions {
41
+ /** Optional file path to write the generated markdown. When omitted, only the string is returned. */
42
+ outputPath?: string;
43
+ /** Name of the sub-folder (relative to outputDir) where extracted media will be stored. */
44
+ mediaFolderName: string;
45
+ /** When true, a YAML front-matter block with document metadata is prepended to the output. */
46
+ includeMetadata: boolean;
47
+ }
48
+ /**
49
+ * Summary of a completed conversion, including statistics about
50
+ * the generated output and extracted media.
51
+ */
52
+ interface ConversionResult {
53
+ /** Whether the conversion completed without errors. */
54
+ success: boolean;
55
+ /** Path where the markdown output was written. */
56
+ outputPath: string;
57
+ /** Character length of the generated markdown string. */
58
+ markdownLength: number;
59
+ /** Number of images extracted and saved to the media folder. */
60
+ imagesExtracted: number;
61
+ /** Absolute path to the media folder, or null if no images were extracted. */
62
+ mediaFolder: string | null;
63
+ /** Allows additional converter-specific metadata fields. */
64
+ [key: string]: unknown;
65
+ }
66
+ //#endregion
67
+ //#region pptx/converter/media-context.d.ts
68
+ /**
69
+ * Parses a Base64-encoded `data:` URL and returns the decoded binary
70
+ * content along with a suitable file extension.
71
+ *
72
+ * @param dataUrl - A complete `data:` URL in the form `data:<mime>;base64,<payload>`.
73
+ * @returns An object with `bytes` (the decoded binary data) and `ext` (the file extension).
74
+ * @throws Error if the data URL does not match the expected `data:<mime>;base64,<payload>` format.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const { bytes, ext } = dataUrlToMediaBytes('data:image/png;base64,iVBOR...');
79
+ * // bytes: Uint8Array of PNG data
80
+ * // ext: 'png'
81
+ * ```
82
+ */
83
+ declare function dataUrlToMediaBytes(dataUrl: string): {
84
+ bytes: Uint8Array;
85
+ ext: string;
86
+ };
87
+ /**
88
+ * Generates a deterministic, zero-padded filename for an extracted image.
89
+ *
90
+ * @param index - The 1-based ordinal of the image within the conversion session.
91
+ * @param ext - File extension (with or without leading dot).
92
+ * @returns A filename like `"image-001.png"`.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * generateMediaFilename(7, 'jpg'); // "image-007.jpg"
97
+ * ```
98
+ */
99
+ declare function generateMediaFilename(index: number, ext: string): string;
100
+ /**
101
+ * Manages the extraction and persistence of media files (images) during
102
+ * a PPTX-to-Markdown conversion session.
103
+ *
104
+ * Each `MediaContext` tracks a running count of saved images and ensures
105
+ * the target media directory is lazily created on first write. When no
106
+ * {@link FileSystemAdapter} is provided, filenames are still generated
107
+ * (for in-memory usage) but nothing is written to disk.
108
+ */
109
+ declare class MediaContext {
110
+ private readonly folderName;
111
+ private readonly fs?;
112
+ /** Running counter used to assign unique sequential filenames. */
113
+ private imageIndex;
114
+ /** Whether the media output directory has been created yet. */
115
+ private initialized;
116
+ /** Fully resolved path to the media output directory. */
117
+ private readonly resolvedMediaDir;
118
+ /**
119
+ * @param outputDir - Root output directory for the conversion.
120
+ * @param folderName - Sub-folder name for media files (e.g. `"media"`).
121
+ * @param fs - Optional file system adapter; omit for in-memory-only conversion.
122
+ */
123
+ constructor(outputDir: string, folderName: string, fs?: FileSystemAdapter | undefined);
124
+ /** Returns the total number of images saved so far in this session. */
125
+ get totalImages(): number;
126
+ /** Returns the absolute path to the media output directory. */
127
+ get mediaDir(): string;
128
+ /**
129
+ * Decodes a Base64 `data:` URL, saves the image to disk (if a FS adapter
130
+ * is available), and returns a relative path suitable for embedding in markdown.
131
+ *
132
+ * @param dataUrl - The Base64-encoded data URL of the image.
133
+ * @param prefix - Optional filename prefix (e.g. `"slide3"`) for disambiguation.
134
+ * @returns A relative path like `"./media/slide3-image-001.png"`.
135
+ * @throws Error if the data URL is malformed.
136
+ */
137
+ saveImage(dataUrl: string, prefix?: string): Promise<string>;
138
+ /**
139
+ * Saves raw image bytes to disk and returns a relative path for markdown embedding.
140
+ *
141
+ * @param bytes - Raw binary content of the image.
142
+ * @param ext - File extension (e.g. `"png"`, `"jpg"`).
143
+ * @param prefix - Optional filename prefix for disambiguation.
144
+ * @returns A relative path like `"./media/image-001.png"`.
145
+ */
146
+ saveImageBytes(bytes: Uint8Array, ext: string, prefix?: string): Promise<string>;
147
+ /**
148
+ * Lazily creates the media output directory on the first call.
149
+ * Subsequent calls are no-ops.
150
+ */
151
+ private ensureInitialized;
152
+ }
153
+ //#endregion
154
+ //#region pptx/converter/base.d.ts
155
+ /**
156
+ * Normalises a file path by trimming whitespace and converting
157
+ * backslashes to forward slashes for cross-platform consistency.
158
+ *
159
+ * @param pathValue - The raw file path string.
160
+ * @returns The normalised path with forward slashes.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * normalizePath(' C:\\Users\\docs\\file.md ');
165
+ * // "C:/Users/docs/file.md"
166
+ * ```
167
+ */
168
+ declare function normalizePath(pathValue: string): string;
169
+ /**
170
+ * Extracts the directory portion of a file path (everything before the
171
+ * last `/` separator).
172
+ *
173
+ * @param filePath - A file path (backslashes are normalised automatically).
174
+ * @returns The parent directory, `"."` if there is no separator, or `"/"` for root paths.
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * getDirectory('/home/user/doc.md'); // "/home/user"
179
+ * getDirectory('file.txt'); // "."
180
+ * ```
181
+ */
182
+ declare function getDirectory(filePath: string): string;
183
+ /**
184
+ * Derives a `.md` output path from a source file path when no explicit
185
+ * output path has been provided. Simply replaces the source extension
186
+ * with `.md`.
187
+ *
188
+ * @param sourcePath - Original source file path (e.g. `"presentation.pptx"`).
189
+ * @param explicitPath - An explicit output path; if provided, it is returned as-is.
190
+ * @returns The derived markdown path, the explicit path, or `undefined` if both inputs are absent.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * deriveOutputPath('slides.pptx', undefined); // "slides.md"
195
+ * deriveOutputPath('slides.pptx', '/tmp/out.md'); // "/tmp/out.md"
196
+ * ```
197
+ */
198
+ declare function deriveOutputPath(sourcePath: string | undefined, explicitPath: string | undefined): string | undefined;
199
+ /**
200
+ * Abstract base class for document-to-Markdown converters.
201
+ *
202
+ * Provides shared infrastructure for media extraction ({@link MediaContext}),
203
+ * YAML front-matter generation, and file output. Concrete subclasses implement
204
+ * the {@link convert} method to handle a specific document type.
205
+ *
206
+ * @typeParam TSource - The parsed document data structure that this converter consumes.
207
+ */
208
+ declare abstract class DocumentConverter<TSource> {
209
+ protected readonly outputDir: string;
210
+ protected readonly options: ConversionOptions;
211
+ protected readonly fs?: FileSystemAdapter | undefined;
212
+ /** Shared context for extracting and saving media (images) during conversion. */
213
+ protected readonly mediaContext: MediaContext;
214
+ /**
215
+ * @param outputDir - Root directory for all output files (markdown + media).
216
+ * @param options - Conversion options (output path, media folder name, metadata flag).
217
+ * @param fs - Optional file system adapter for writing files to disk.
218
+ */
219
+ protected constructor(outputDir: string, options: ConversionOptions, fs?: FileSystemAdapter | undefined);
220
+ /**
221
+ * Converts the given source document into a Markdown string.
222
+ *
223
+ * @param source - The parsed document data to convert.
224
+ * @returns The generated Markdown content.
225
+ */
226
+ abstract convert(source: TSource): Promise<string>;
227
+ /**
228
+ * Builds a YAML front-matter block from a key-value metadata dictionary.
229
+ * String values are quoted; numeric values are emitted bare.
230
+ *
231
+ * @param metadata - Key-value pairs to include in the front matter.
232
+ * @returns A complete front-matter string (including `---` delimiters and trailing blank lines).
233
+ */
234
+ protected buildFrontMatter(metadata: Record<string, string | number>): string;
235
+ /**
236
+ * Writes the generated markdown content to an output file using the
237
+ * configured {@link FileSystemAdapter}.
238
+ *
239
+ * @param content - The markdown string to write.
240
+ * @param outputPath - Destination file path.
241
+ * @throws Error if no `FileSystemAdapter` was provided at construction time.
242
+ */
243
+ protected writeOutput(content: string, outputPath: string): Promise<void>;
244
+ }
245
+ //#endregion
246
+ //#region pptx/converter/PptxMarkdownConverter.d.ts
247
+ /**
248
+ * Options specific to PPTX-to-Markdown conversion, extending the base
249
+ * {@link ConversionOptions} with presentation-aware settings.
250
+ */
251
+ interface PptxConverterOptions extends ConversionOptions {
252
+ /** Human-readable name of the source file, used in front-matter metadata. */
253
+ sourceName: string;
254
+ /** Whether to append speaker notes (as blockquotes) below each slide. */
255
+ includeSpeakerNotes: boolean;
256
+ /**
257
+ * Optional 1-based slide range to limit conversion to a subset of the deck.
258
+ * Omit or leave fields undefined to convert all slides.
259
+ */
260
+ slideRange?: {
261
+ /** First slide to include (1-based, default 1). */
262
+ start?: number;
263
+ /** Last slide to include (1-based, default = last slide). */
264
+ end?: number;
265
+ };
266
+ /**
267
+ * When true, emit clean semantic markdown instead of CSS-positioned HTML.
268
+ * Default is false (positioned HTML layout for slide fidelity).
269
+ */
270
+ semanticMode?: boolean;
271
+ }
272
+ /**
273
+ * Converts a parsed {@link PptxData} presentation into a Markdown document.
274
+ *
275
+ * This is the primary entry point for PPTX-to-Markdown conversion. It
276
+ * orchestrates slide processing, media extraction, metadata generation,
277
+ * and output assembly. Each slide element type is handled by a dedicated
278
+ * {@link ElementProcessor} registered in the internal registry.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * const converter = new PptxMarkdownConverter('/output', {
283
+ * sourceName: 'deck.pptx',
284
+ * includeSpeakerNotes: true,
285
+ * mediaFolderName: 'media',
286
+ * includeMetadata: true,
287
+ * });
288
+ * const markdown = await converter.convert(pptxData);
289
+ * ```
290
+ */
291
+ declare class PptxMarkdownConverter extends DocumentConverter<PptxData> {
292
+ /** Renderer for rich-text segments (bold, italic, hyperlinks, etc.). */
293
+ private readonly textRenderer;
294
+ /** Registry mapping element types to their dedicated processors. */
295
+ private readonly registry;
296
+ /** Delegate responsible for converting individual slides. */
297
+ private readonly slideProcessor;
298
+ /** Number of slides actually converted (after applying the slide range filter). */
299
+ private convertedSlides;
300
+ /** Total number of slides in the source presentation. */
301
+ private totalSlides;
302
+ /**
303
+ * @param outputDir - Root directory for output files.
304
+ * @param options - PPTX-specific conversion options.
305
+ * @param fs - Optional file system adapter for writing media to disk.
306
+ */
307
+ constructor(outputDir: string, options: PptxConverterOptions, fs?: FileSystemAdapter);
308
+ /** Returns the number of images extracted and saved during conversion. */
309
+ get imagesExtracted(): number;
310
+ /** Returns the media directory path, or `null` if no images were extracted. */
311
+ get mediaDir(): string | null;
312
+ /** Returns the number of slides that were actually converted. */
313
+ get slidesConverted(): number;
314
+ /** Returns the total number of slides in the source presentation. */
315
+ get presentationSlides(): number;
316
+ /**
317
+ * Converts the full PPTX presentation (or a slide subset) into Markdown.
318
+ *
319
+ * The conversion pipeline:
320
+ * 1. Resolves the slide range and selects the target slides.
321
+ * 2. Processes each slide through {@link SlideProcessor}, producing markdown sections.
322
+ * 3. Inserts section headings when slides belong to named sections.
323
+ * 4. Optionally prepends YAML front-matter with document metadata.
324
+ * 5. Appends header/footer information if present.
325
+ * 6. Writes the output file if an `outputPath` was configured.
326
+ *
327
+ * @param source - The parsed PPTX data structure.
328
+ * @returns The complete Markdown string.
329
+ */
330
+ convert(source: PptxData): Promise<string>;
331
+ /**
332
+ * Registers all element-type processors into the internal registry.
333
+ * Each processor handles one or more {@link PptxElement} types
334
+ * (text, image, table, chart, etc.).
335
+ */
336
+ private registerProcessors;
337
+ /**
338
+ * Assembles a YAML front-matter block containing presentation metadata
339
+ * such as title, author, slide count, theme, dimensions, and more.
340
+ *
341
+ * @param source - The parsed PPTX data.
342
+ * @returns A YAML front-matter string (including `---` delimiters).
343
+ */
344
+ private buildPptxFrontMatter;
345
+ /**
346
+ * Populates metadata entries from OPC core properties (title, author, subject, etc.).
347
+ *
348
+ * @param meta - The metadata dictionary to populate.
349
+ * @param props - Core document properties from the PPTX file.
350
+ */
351
+ private addCoreProperties;
352
+ /**
353
+ * Populates metadata entries from application-level properties
354
+ * (application name, editing time, word/paragraph counts).
355
+ *
356
+ * @param meta - The metadata dictionary to populate.
357
+ * @param props - Application properties from the PPTX file.
358
+ */
359
+ private addAppProperties;
360
+ /**
361
+ * Adds presentation-level metadata (custom properties, show type, theme,
362
+ * security warnings, embedded fonts, custom shows) to the front-matter dictionary.
363
+ *
364
+ * @param meta - The metadata dictionary to populate.
365
+ * @param source - The full parsed PPTX data.
366
+ */
367
+ private addPresentationMeta;
368
+ /**
369
+ * Renders the presentation-level header/footer settings (header text,
370
+ * footer text, date/time, slide numbers) into a pipe-delimited markdown string.
371
+ *
372
+ * @param hf - Header/footer configuration from the presentation.
373
+ * @returns A formatted string, or an empty string if no header/footer data is present.
374
+ */
375
+ private renderHeaderFooter;
376
+ /**
377
+ * Resolves and clamps the user-specified slide range to valid bounds.
378
+ * Defaults to the full deck if no range is configured.
379
+ *
380
+ * @param totalSlides - Total number of slides in the presentation.
381
+ * @returns A 1-based `{ start, end }` range guaranteed to be within bounds.
382
+ */
383
+ private resolveRange;
384
+ /** Casts the base `options` to the PPTX-specific options type. */
385
+ private getOptions;
386
+ }
387
+ //#endregion
388
+ //#region pptx/converter/elements/ElementProcessor.d.ts
389
+ interface ElementProcessorContext {
390
+ mediaContext: MediaContext;
391
+ slideNumber: number;
392
+ /** Slide canvas width in CSS pixels (for layout positioning). */
393
+ slideWidth: number;
394
+ /** Slide canvas height in CSS pixels (for layout positioning). */
395
+ slideHeight: number;
396
+ /** Scale factor applied to the layout container (for font/image sizing). */
397
+ layoutScale?: number;
398
+ /**
399
+ * When true, processors should emit clean markdown instead of HTML.
400
+ * Tables become markdown tables, images use `![alt](path)` syntax,
401
+ * and text uses markdown formatting (not `<strong>`, `<em>`, etc.).
402
+ */
403
+ semanticMode?: boolean;
404
+ processElements: (elements: PptxElement[]) => Promise<string[]>;
405
+ }
406
+ interface ElementProcessor {
407
+ readonly supportedTypes: ReadonlyArray<PptxElement['type']>;
408
+ process(element: PptxElement, ctx: ElementProcessorContext): Promise<string | null>;
409
+ }
410
+ declare class ElementProcessorRegistry {
411
+ private readonly processors;
412
+ register(processor: ElementProcessor): void;
413
+ getProcessor(type: PptxElement['type']): ElementProcessor | null;
414
+ processElement(element: PptxElement, ctx: ElementProcessorContext): Promise<string | null>;
415
+ private buildActionAnnotation;
416
+ }
417
+ //#endregion
418
+ //#region pptx/converter/TextSegmentRenderer.d.ts
419
+ /**
420
+ * Options controlling how text segments are rendered.
421
+ */
422
+ interface TextSegmentRenderOptions {
423
+ paragraphIndents?: Array<{
424
+ marginLeft?: number;
425
+ indent?: number;
426
+ }>;
427
+ slideNumber?: number;
428
+ dateTimeText?: string;
429
+ inlineMode?: boolean;
430
+ disableLists?: boolean;
431
+ disableAlignment?: boolean;
432
+ /**
433
+ * When true, emit HTML formatting tags instead of Markdown syntax.
434
+ */
435
+ htmlFormatting?: boolean;
436
+ }
437
+ declare class TextSegmentRenderer {
438
+ private readonly ommlConverter;
439
+ render(segments: TextSegment[], options?: TextSegmentRenderOptions): string;
440
+ renderInline(segments: TextSegment[], options?: TextSegmentRenderOptions): string;
441
+ plainText(segments: TextSegment[], options?: TextSegmentRenderOptions): string;
442
+ private groupParagraphs;
443
+ private renderParagraph;
444
+ private renderSegment;
445
+ private resolvePlainSegmentText;
446
+ private resolveFieldSegment;
447
+ private wrapCode;
448
+ private renderLinkDestination;
449
+ private escapeLinkTitle;
450
+ private escapeMarkdown;
451
+ private escapeHtml;
452
+ }
453
+ //#endregion
454
+ //#region pptx/converter/SlideProcessor.d.ts
455
+ /**
456
+ * Options controlling how a single slide is processed into Markdown.
457
+ */
458
+ interface SlideProcessorOptions {
459
+ /** Whether to include speaker notes below the slide content. */
460
+ includeSpeakerNotes: boolean;
461
+ /** Slide canvas width in CSS pixels (used for layout positioning). */
462
+ slideWidth: number;
463
+ /** Slide canvas height in CSS pixels (used for layout positioning). */
464
+ slideHeight: number;
465
+ /** When true, emit clean semantic markdown instead of positioned HTML. */
466
+ semanticMode?: boolean;
467
+ }
468
+ /**
469
+ * Converts a single {@link PptxSlide} into a Markdown section.
470
+ */
471
+ declare class SlideProcessor {
472
+ private readonly registry;
473
+ private readonly mediaContext;
474
+ private readonly textRenderer;
475
+ /** Delegate for rendering slide-level metadata sections. */
476
+ private readonly metadataRenderer;
477
+ /**
478
+ * @param registry - Registry of element-type processors.
479
+ * @param mediaContext - Shared media extraction context.
480
+ * @param textRenderer - Renderer for rich-text segments.
481
+ */
482
+ constructor(registry: ElementProcessorRegistry, mediaContext: MediaContext, textRenderer: TextSegmentRenderer);
483
+ /** Processes a slide into a complete Markdown section. */
484
+ processSlide(slide: PptxSlide, options: SlideProcessorOptions): Promise<string>;
485
+ /**
486
+ * Builds the Markdown heading line for a slide, including its number,
487
+ * detected title text, and flags (hidden, layout name).
488
+ */
489
+ private buildHeading;
490
+ /**
491
+ * Returns an HTML `<img>` for the slide background that can be
492
+ * placed as the bottom-most layer inside the positioned container.
493
+ */
494
+ private renderBackgroundHtml;
495
+ /** Detects the slide's title from placeholder or first text element. */
496
+ private detectTitle;
497
+ /**
498
+ * Extracts the placeholder type from an element, if present.
499
+ */
500
+ private getPlaceholderType;
501
+ /** Processes elements as clean semantic markdown. */
502
+ private processElementsSemantic;
503
+ /** Processes elements using CSS absolute positioning. */
504
+ private processElementsWithLayout;
505
+ /** Sorts elements into natural reading order (top-to-bottom, left-to-right). */
506
+ private sortElementsByReadingOrder;
507
+ }
508
+ //#endregion
509
+ //#region pptx/converter/SlideMetadataRenderer.d.ts
510
+ /**
511
+ * Renders slide-level metadata sections (transition, animations,
512
+ * warnings, comments, speaker notes) into Markdown strings.
513
+ */
514
+ declare class SlideMetadataRenderer {
515
+ private readonly textRenderer;
516
+ constructor(textRenderer: TextSegmentRenderer);
517
+ /**
518
+ * Renders the slide transition effect as a short metadata line.
519
+ */
520
+ renderTransition(slide: PptxSlide): string;
521
+ /**
522
+ * Renders the slide's animation effects grouped by click sequence.
523
+ */
524
+ renderAnimations(slide: PptxSlide): string;
525
+ /**
526
+ * Renders any compatibility warnings for the slide.
527
+ */
528
+ renderWarnings(slide: PptxSlide): string;
529
+ /**
530
+ * Renders any review comments attached to the slide.
531
+ */
532
+ renderComments(slide: PptxSlide): string;
533
+ /**
534
+ * Renders the slide's speaker notes as a Markdown blockquote.
535
+ */
536
+ renderNotes(slide: PptxSlide): string;
537
+ /**
538
+ * Groups animations by click sequence. Each `onClick` trigger starts
539
+ * a new group; `withPrevious` and `afterPrevious` are appended to the
540
+ * current group.
541
+ */
542
+ private groupByClickSequence;
543
+ /**
544
+ * Converts legacy animation data into the NativeAnimationLike shape.
545
+ */
546
+ private mapLegacyAnimations;
547
+ /**
548
+ * Produces a human-readable summary of a single animation effect.
549
+ */
550
+ private summariseAnimation;
551
+ }
552
+ //#endregion
553
+ //#region pptx/converter/svg-text-lines.d.ts
554
+ type SvgTextMeasurer = (text: string, font: {
555
+ family: string;
556
+ size: number;
557
+ bold: boolean;
558
+ italic: boolean;
559
+ }) => number;
560
+ //#endregion
561
+ //#region pptx/converter/SvgExporter.d.ts
562
+ /**
563
+ * Options controlling SVG export behaviour.
564
+ */
565
+ interface SvgExportOptions {
566
+ /** Include hidden slides when exporting all. Default `false`. */
567
+ includeHidden?: boolean;
568
+ /** Slide indices to export (0-based). If omitted, all slides are exported. */
569
+ slideIndices?: number[];
570
+ /** Default font family when the element does not specify one. */
571
+ defaultFontFamily?: string;
572
+ /** Default font size in points when the element does not specify one. */
573
+ defaultFontSize?: number;
574
+ /** Optional host font metrics. Headless exports fall back to measured font tables. */
575
+ measureText?: SvgTextMeasurer;
576
+ }
577
+ /**
578
+ * Pure-TypeScript SVG exporter for parsed PPTX data.
579
+ *
580
+ * Generates well-formed SVG XML strings without any DOM dependency.
581
+ *
582
+ * @example
583
+ * ```ts
584
+ * const svgs = SvgExporter.exportAll(pptxData);
585
+ * for (const [i, svg] of svgs.entries()) {
586
+ * fs.writeFileSync(`slide_${i + 1}.svg`, svg);
587
+ * }
588
+ * ```
589
+ */
590
+ declare class SvgExporter {
591
+ /**
592
+ * Export a single slide to an SVG XML string.
593
+ *
594
+ * @param slide - The parsed slide.
595
+ * @param width - SVG viewport width (pixels).
596
+ * @param height - SVG viewport height (pixels).
597
+ * @param options - Optional export settings.
598
+ * @returns A complete SVG document as a string.
599
+ */
600
+ static exportSlide(slide: PptxSlide, width: number, height: number, options?: SvgExportOptions): string;
601
+ /**
602
+ * Export all (or selected) slides to SVG XML strings.
603
+ *
604
+ * @param data - The fully parsed PPTX data.
605
+ * @param options - Optional export settings.
606
+ * @returns An array of SVG strings (one per exported slide).
607
+ */
608
+ static exportAll(data: PptxData, options?: SvgExportOptions): string[];
609
+ }
610
+ //#endregion
611
+ //#region pptx/converter/json/json-document.d.ts
612
+ /**
613
+ * The `pptx-viewer-json` document format: a portable, versioned,
614
+ * self-contained JSON representation of a parsed presentation
615
+ * ({@link PptxData}). Binary payloads are embedded (base64), so a document
616
+ * round-trips standalone without the original `.pptx` archive.
617
+ *
618
+ * Top-level shape (version 1):
619
+ *
620
+ * ```json
621
+ * {
622
+ * "format": "pptx-viewer-json",
623
+ * "version": 1,
624
+ * "generator": "pptx-viewer-core",
625
+ * "createdAt": "2026-01-01T00:00:00.000Z",
626
+ * "slideCount": 3,
627
+ * "assets": { "count": 2, "totalBytes": 51234 },
628
+ * "presentation": { "width": 960, "height": 540, ... },
629
+ * "slides": [ { "id": "...", "elements": [ ... ] }, ... ]
630
+ * }
631
+ * ```
632
+ *
633
+ * Field coverage mirrors the canonical inventories
634
+ * (`SLIDE_FIELD_KIND` / `ELEMENT_FIELD_KIND`) plus a TypeScript-enforced
635
+ * presentation-level key list, so no model field is silently dropped.
636
+ */
637
+ /** Discriminating marker stored in the top-level `format` field. */
638
+ declare const PPTX_JSON_FORMAT = "pptx-viewer-json";
639
+ /** Current (and only) supported document version. */
640
+ declare const PPTX_JSON_VERSION = 1;
641
+ /** Suggested file extension for exported documents. */
642
+ declare const PPTX_JSON_FILE_EXTENSION = ".json";
643
+ /** MIME type used when downloading an exported document. */
644
+ declare const PPTX_JSON_MIME_TYPE = "application/json";
645
+ /** Size accounting for binary assets embedded in the document. */
646
+ interface PptxJsonAssetStats {
647
+ /** Number of embedded binary assets (base64 data URLs + raw byte fields). */
648
+ count: number;
649
+ /** Total decoded byte size of all embedded binary assets. */
650
+ totalBytes: number;
651
+ }
652
+ /** A parsed and shape-validated `pptx-viewer-json` document. */
653
+ interface PptxJsonDocument {
654
+ format: typeof PPTX_JSON_FORMAT;
655
+ version: typeof PPTX_JSON_VERSION;
656
+ /** Producer identifier (informational, ignored on import). */
657
+ generator?: string;
658
+ /** ISO-8601 export timestamp (informational, ignored on import). */
659
+ createdAt?: string;
660
+ /** Convenience copy of `slides.length`; validated on import. */
661
+ slideCount: number;
662
+ /** Embedded-asset size accounting computed at export time. */
663
+ assets: PptxJsonAssetStats;
664
+ /** Presentation-level fields of `PptxData` (everything except `slides`). */
665
+ presentation: Record<string, unknown>;
666
+ /** JSON-encoded slides (see `SLIDE_FIELD_KIND` / `ELEMENT_FIELD_KIND`). */
667
+ slides: Array<Record<string, unknown>>;
668
+ }
669
+ /**
670
+ * Cheap text-level sniff: the text is a JSON object (leading `{` after
671
+ * optional whitespace) and carries the `pptx-viewer-json` format marker.
672
+ * Full validation happens in `parsePptxJsonDocument`.
673
+ */
674
+ declare function isPptxJsonText(text: string): boolean;
675
+ /**
676
+ * Byte-level sniff + decode: returns the decoded text when the buffer looks
677
+ * like a `pptx-viewer-json` document, or `null` for anything else (e.g. a
678
+ * ZIP/OLE2 `.pptx`). Safe to call on arbitrary binary input.
679
+ */
680
+ declare function decodePptxJsonText(data: ArrayBuffer | Uint8Array): string | null;
681
+ //#endregion
682
+ //#region pptx/converter/json/json-binary-codec.d.ts
683
+ /**
684
+ * Deep value codec for the `pptx-viewer-json` format.
685
+ *
686
+ * `PptxData` is almost entirely JSON-native, but a handful of fields carry
687
+ * raw bytes (`Uint8Array`: presentation thumbnails, embedded font binaries,
688
+ * embedded chart workbooks). This codec walks a value tree and:
689
+ *
690
+ * - encodes every `Uint8Array` as a tagged object `{ "$bytes": "<base64>" }`
691
+ * so the document stays valid, self-contained JSON,
692
+ * - escapes original object keys starting with `$` (prefixing one extra `$`)
693
+ * so a coincidental `{ $bytes: ... }` in source data can never be
694
+ * mis-decoded, and
695
+ * - accounts embedded binary assets (tagged byte fields plus base64
696
+ * `data:` URLs already stored as strings, e.g. `imageData`/`mediaData`).
697
+ */
698
+ /** Mutable accumulator for embedded-asset size accounting. */
699
+ interface JsonAssetAccumulator {
700
+ count: number;
701
+ totalBytes: number;
702
+ }
703
+ /** Encode raw bytes to base64 (Node `Buffer` when available, else `btoa`). */
704
+ declare function bytesToBase64(bytes: Uint8Array): string;
705
+ /** Decode base64 text to raw bytes (Node `Buffer` when available, else `atob`). */
706
+ declare function base64ToBytes(base64: string): Uint8Array;
707
+ /**
708
+ * Recursively encode a model value into a JSON-safe value.
709
+ * `undefined` entries inside objects are dropped (matching `JSON.stringify`).
710
+ */
711
+ declare function encodeJsonValue(value: unknown, stats?: JsonAssetAccumulator): unknown;
712
+ /** Recursively decode a JSON value produced by {@link encodeJsonValue}. */
713
+ declare function decodeJsonValue(value: unknown): unknown;
714
+ //#endregion
715
+ //#region pptx/converter/json/presentation-field-keys.d.ts
716
+ /**
717
+ * Canonical inventory of the presentation-level fields of {@link PptxData}
718
+ * (everything except `slides`, which the JSON document stores as its own
719
+ * top-level array).
720
+ *
721
+ * Mirrors the pattern of `ELEMENT_FIELD_KIND` / `SLIDE_FIELD_KIND`
722
+ * (`core/types/collaboration-field-schema.ts`): typed as
723
+ * `Record<keyof Omit<PptxData, 'slides'>, true>` so TypeScript forces this
724
+ * list to be updated whenever `PptxData` gains or loses a field, turning
725
+ * "forgot to serialize a new presentation field" into a compile error
726
+ * instead of silent JSON data loss.
727
+ */
728
+ declare const PRESENTATION_FIELD_KEYS: Record<keyof Omit<PptxData, 'slides'>, true>;
729
+ /** Ordered list of the presentation-level field names. */
730
+ declare const PRESENTATION_FIELD_NAMES: ReadonlyArray<string>;
731
+ //#endregion
732
+ //#region pptx/converter/json/json-serializer.d.ts
733
+ /** Options for {@link buildPptxJsonDocument}. */
734
+ interface PptxJsonSerializeOptions {
735
+ /** Producer identifier written into the `generator` field. */
736
+ generator?: string;
737
+ /**
738
+ * Whether to stamp `createdAt` with the current time. Defaults to `true`;
739
+ * disable for byte-stable output (e.g. snapshot tests).
740
+ */
741
+ includeTimestamp?: boolean;
742
+ }
743
+ /**
744
+ * Serialize a parsed presentation into a versioned, self-contained
745
+ * `pptx-viewer-json` document. Binary payloads (thumbnails, embedded fonts,
746
+ * chart workbooks) are embedded as tagged base64; images and media already
747
+ * live in the model as base64 data URLs and are carried verbatim. Field
748
+ * coverage is driven by the canonical inventories (`SLIDE_FIELD_KIND`,
749
+ * `ELEMENT_FIELD_KIND`, `PRESENTATION_FIELD_KEYS`) so no model field is
750
+ * silently dropped.
751
+ */
752
+ declare function buildPptxJsonDocument(data: PptxData, options?: PptxJsonSerializeOptions): PptxJsonDocument;
753
+ /** Serialize a presentation straight to JSON text. */
754
+ declare function serializePptxToJson(data: PptxData, options?: PptxJsonSerializeOptions & {
755
+ pretty?: boolean;
756
+ }): string;
757
+ //#endregion
758
+ //#region pptx/converter/json/json-deserializer.d.ts
759
+ /** Error thrown when a candidate document fails `pptx-viewer-json` validation. */
760
+ declare class PptxJsonFormatError extends Error {
761
+ constructor(message: string);
762
+ }
763
+ /**
764
+ * Validate an arbitrary parsed JSON value as a `pptx-viewer-json` document.
765
+ * Performs structural narrowing only (no `any`, no blind casts on the
766
+ * envelope): the format marker, version, slide array, per-slide element
767
+ * arrays, and per-element `type` discriminants are all checked.
768
+ */
769
+ declare function parsePptxJsonDocument(value: unknown): PptxJsonDocument;
770
+ /** Parse and validate JSON text as a `pptx-viewer-json` document. */
771
+ declare function parsePptxJson(text: string): PptxJsonDocument;
772
+ /**
773
+ * Rebuild a {@link PptxData} model from a validated document. Field coverage
774
+ * mirrors serialization: only fields present in the canonical inventories are
775
+ * accepted, and tagged binary payloads are decoded back to `Uint8Array`.
776
+ */
777
+ declare function pptxDataFromJsonDocument(document: PptxJsonDocument): PptxData;
778
+ /** Convenience: parse, validate, and rebuild in one step. */
779
+ declare function deserializePptxFromJson(text: string): PptxData;
780
+ //#endregion
781
+ //#region pptx/converter/json/PptxJsonConverter.d.ts
782
+ /** Options for a {@link PptxJsonConverter} instance. */
783
+ interface PptxJsonConverterOptions extends PptxJsonSerializeOptions {
784
+ /** Pretty-print JSON output with 2-space indentation. */
785
+ pretty?: boolean;
786
+ }
787
+ /**
788
+ * Converts a parsed {@link PptxData} presentation to and from the portable
789
+ * `pptx-viewer-json` document format.
790
+ *
791
+ * Sibling of {@link PptxMarkdownConverter}: where the markdown converter
792
+ * produces a lossy human-readable rendition, this converter produces a
793
+ * lossless (model-level), versioned, self-contained JSON document that can
794
+ * be re-imported without the original `.pptx` archive.
795
+ *
796
+ * @example
797
+ * ```ts
798
+ * const converter = new PptxJsonConverter({ generator: 'my-app' });
799
+ * const json = converter.toJson(pptxData);
800
+ * const roundTripped = converter.fromJson(json);
801
+ * ```
802
+ */
803
+ declare class PptxJsonConverter {
804
+ private readonly options;
805
+ constructor(options?: PptxJsonConverterOptions);
806
+ /** Serialize a presentation into a structured JSON document. */
807
+ toDocument(data: PptxData): PptxJsonDocument;
808
+ /** Serialize a presentation straight to JSON text. */
809
+ toJson(data: PptxData): string;
810
+ /** Validate an arbitrary parsed JSON value as a document. */
811
+ parseDocument(value: unknown): PptxJsonDocument;
812
+ /** Rebuild the presentation model from JSON text (parse + validate). */
813
+ fromJson(text: string): PptxData;
814
+ /** Rebuild the presentation model from a validated document. */
815
+ fromDocument(document: PptxJsonDocument): PptxData;
816
+ /** Static counterpart of {@link fromJson}. */
817
+ static fromJson(text: string): PptxData;
818
+ /** Static counterpart of {@link toJson}. */
819
+ static toJson(data: PptxData, options?: PptxJsonConverterOptions): string;
820
+ /** Parse and validate JSON text as a document without rebuilding the model. */
821
+ static parse(text: string): PptxJsonDocument;
822
+ /** Cheap text-level sniff for the format marker. */
823
+ static isPptxJsonText(text: string): boolean;
824
+ /** Byte-level sniff + decode; `null` for non-JSON (e.g. ZIP) input. */
825
+ static decodeText(data: ArrayBuffer | Uint8Array): string | null;
826
+ }
827
+ /**
828
+ * Overlay an imported presentation onto a freshly loaded base presentation
829
+ * (typically a blank one generated for JSON import): every presentation-level
830
+ * field defined on `imported` wins, fields it lacks keep the base value (so a
831
+ * blank deck's theme scaffolding survives when the document carries none),
832
+ * and the slide array is replaced wholesale. Mutates and returns `base`.
833
+ */
834
+ declare function applyImportedPptxData(base: PptxData, imported: PptxData): PptxData;
835
+ //#endregion
836
+ export { SlideProcessor as A, generateMediaFilename as B, PptxJsonAssetStats as C, SvgExportOptions as D, isPptxJsonText as E, deriveOutputPath as F, ConversionResult as H, getDirectory as I, normalizePath as L, PptxConverterOptions as M, PptxMarkdownConverter as N, SvgExporter as O, DocumentConverter as P, MediaContext as R, PPTX_JSON_VERSION as S, decodePptxJsonText as T, FileSystemAdapter as U, ConversionOptions as V, decodeJsonValue as _, deserializePptxFromJson as a, PPTX_JSON_FORMAT as b, pptxDataFromJsonDocument as c, serializePptxToJson as d, PRESENTATION_FIELD_KEYS as f, bytesToBase64 as g, base64ToBytes as h, PptxJsonFormatError as i, SlideProcessorOptions as j, SlideMetadataRenderer as k, PptxJsonSerializeOptions as l, JsonAssetAccumulator as m, PptxJsonConverterOptions as n, parsePptxJson as o, PRESENTATION_FIELD_NAMES as p, applyImportedPptxData as r, parsePptxJsonDocument as s, PptxJsonConverter as t, buildPptxJsonDocument as u, encodeJsonValue as v, PptxJsonDocument as w, PPTX_JSON_MIME_TYPE as x, PPTX_JSON_FILE_EXTENSION as y, dataUrlToMediaBytes as z };
837
+ //# sourceMappingURL=index-C3xhAMSa.d.ts.map