@silurus/ooxml 0.3.0 → 0.4.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.
@@ -70,6 +70,24 @@ declare interface ChartElement {
70
70
  catAxisHidden: boolean;
71
71
  valAxisHidden: boolean;
72
72
  plotAreaBg: string | null;
73
+ /** Outer chartSpace background (hex without '#'). null when noFill/absent. */
74
+ chartBg: string | null;
75
+ /** True when <c:legend> is declared; false suppresses the legend entirely. */
76
+ showLegend: boolean;
77
+ /** catAx crossBetween: "between" (default, 0.5-step padding) or "midCat". */
78
+ catAxisCrossBetween: 'between' | 'midCat' | string;
79
+ /** `<c:valAx><c:majorTickMark>`. "cross" (default) | "out" | "in" | "none". */
80
+ valAxisMajorTickMark: 'cross' | 'out' | 'in' | 'none' | string;
81
+ /** `<c:catAx><c:majorTickMark>`. */
82
+ catAxisMajorTickMark: 'cross' | 'out' | 'in' | 'none' | string;
83
+ /** Title font size in OOXML hundredths of a point (1600 = 16pt). null = default. */
84
+ titleFontSizeHpt: number | null;
85
+ /** `<c:catAx><c:txPr>` font size (hpt). null = proportional default. */
86
+ catAxisFontSizeHpt: number | null;
87
+ /** `<c:valAx><c:txPr>` font size (hpt). null = proportional default. */
88
+ valAxisFontSizeHpt: number | null;
89
+ /** `<c:dLbls><c:txPr>` font size (hpt) for data-point value labels. */
90
+ dataLabelFontSizeHpt: number | null;
73
91
  }
74
92
 
75
93
  declare interface ChartSeries {
@@ -129,6 +147,24 @@ export declare interface LoadOptions {
129
147
  useGoogleFonts?: boolean;
130
148
  }
131
149
 
150
+ declare interface MediaElement {
151
+ type: 'media';
152
+ x: number;
153
+ y: number;
154
+ width: number;
155
+ height: number;
156
+ /** "audio" or "video" */
157
+ mediaKind: 'audio' | 'video';
158
+ /** Poster image zip path (e.g. "ppt/media/image2.png"). Empty when no poster. */
159
+ posterPath: string;
160
+ /** Poster image MIME type (empty when no poster). */
161
+ posterMimeType: string;
162
+ /** Path inside the pptx zip (e.g. "ppt/media/media2.mp4"). Used by getMedia. */
163
+ mediaPath: string;
164
+ /** MIME type of the underlying media (e.g. "audio/mpeg", "video/mp4"). */
165
+ mimeType: string;
166
+ }
167
+
132
168
  export declare interface NoFill {
133
169
  fillType: 'none';
134
170
  }
@@ -230,6 +266,8 @@ export declare class PptxPresentation {
230
266
  private readonly _worker;
231
267
  private _presentation;
232
268
  private _pendingParseCallbacks;
269
+ private _pendingMediaCallbacks;
270
+ private _mediaCache;
233
271
  private _nextId;
234
272
  private _workerReady;
235
273
  private _workerReadyCallbacks;
@@ -246,6 +284,19 @@ export declare class PptxPresentation {
246
284
  get slideHeight(): number;
247
285
  /** Render a slide onto the given canvas. */
248
286
  renderSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
287
+ /**
288
+ * Extract raw media bytes for a zip path referenced by {@link MediaElement}.
289
+ * Results are cached by path for the lifetime of this instance.
290
+ */
291
+ getMedia(mediaPath: string): Promise<Blob>;
292
+ private _findMimeTypeForPath;
293
+ /**
294
+ * Render a slide and attach canvas-native playback controls for any
295
+ * embedded audio/video. Returns a disposable handle that owns the RAF loop,
296
+ * media elements, and object URLs. Unlike {@link renderSlide}, this method
297
+ * is stateful — always call `handle.dispose()` when leaving the slide.
298
+ */
299
+ presentSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<PresentationHandle>;
249
300
  /** Terminate the worker and release all resources. */
250
301
  destroy(): void;
251
302
  }
@@ -303,12 +354,31 @@ export declare interface Presentation {
303
354
  minorFont: string | null;
304
355
  }
305
356
 
357
+ declare interface PresentationHandle {
358
+ play(mediaPath?: string): void;
359
+ pause(mediaPath?: string): void;
360
+ dispose(): void;
361
+ }
362
+
306
363
  export declare interface RenderOptions {
307
364
  width?: number;
308
365
  defaultTextColor?: string | null;
309
366
  dpr?: number;
310
367
  majorFont?: string | null;
311
368
  minorFont?: string | null;
369
+ /**
370
+ * Lazily resolve an archive-internal asset (by zip path) to a Blob. The
371
+ * renderer uses this to fetch posters and other large embedded assets on
372
+ * demand, keeping the parse output free of inlined base64.
373
+ */
374
+ fetchMedia?: (path: string) => Promise<Blob>;
375
+ /**
376
+ * When true, renderMedia draws only the poster frame — play/pause badges
377
+ * and progress bars are left to the caller. Set by the pptx presentSlide
378
+ * API so its interactive handle can own all control chrome without
379
+ * the static renderer drawing a duplicate play badge.
380
+ */
381
+ skipMediaControls?: boolean;
312
382
  }
313
383
 
314
384
  /**
@@ -323,6 +393,12 @@ export declare interface RenderSlideOptions {
323
393
  width?: number;
324
394
  /** Device pixel ratio. Defaults to window.devicePixelRatio or 1. */
325
395
  dpr?: number;
396
+ /**
397
+ * Skip drawing the play badge overlay on media elements. Used internally by
398
+ * {@link PptxPresentation.presentSlide} so its interactive handle can draw
399
+ * its own play/pause chrome without duplication.
400
+ */
401
+ skipMediaControls?: boolean;
326
402
  }
327
403
 
328
404
  declare interface Shadow {
@@ -376,7 +452,7 @@ export declare interface Slide {
376
452
  elements: SlideElement[];
377
453
  }
378
454
 
379
- export declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement;
455
+ export declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement | MediaElement;
380
456
 
381
457
  export declare interface SolidFill {
382
458
  fillType: 'solid';