@silurus/ooxml 0.1.0 → 0.3.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/pptx.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pptx-DrZBtOP1.cjs`);exports.PptxPresentation=e.r,exports.PptxViewer=e.n,exports.renderSlide=e.i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./pptx-D-l5vpjt.cjs`);exports.PptxPresentation=t.r,exports.PptxViewer=t.n,exports.autoResize=e.t,exports.renderSlide=t.i;
package/dist/pptx.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { i as e, n as t, r as n } from "./pptx-D3vSvVQ6.js";
2
- export { n as PptxPresentation, t as PptxViewer, e as renderSlide };
1
+ import { t as e } from "./autoResize-U2-IRmNE.js";
2
+ import { i as t, n, r } from "./pptx-BTI_RpCN.js";
3
+ export { r as PptxPresentation, n as PptxViewer, e as autoResize, t as renderSlide };
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Observe an element's size and invoke a render callback, coalescing bursts to
3
+ * one call per animation frame and serializing overlapping async renders.
4
+ *
5
+ * Framework-agnostic: call from any mount/setup hook and invoke the returned
6
+ * disposer in the corresponding teardown hook.
7
+ *
8
+ * @example
9
+ * const detach = autoResize(
10
+ * (width) => pres.renderSlide(canvas, 0, { width }),
11
+ * canvas,
12
+ * );
13
+ * // later
14
+ * detach();
15
+ */
16
+ export declare function autoResize(render: (width: number, height: number) => void | Promise<void>, element: Element, opts?: AutoResizeOptions): () => void;
17
+
18
+ export declare interface AutoResizeOptions {
19
+ /**
20
+ * Skip rendering while `document.hidden` is true and fire once with the latest
21
+ * observed size when the tab becomes visible again. Default: true.
22
+ */
23
+ pauseWhenHidden?: boolean;
24
+ }
25
+
1
26
  declare type BodyElement = {
2
27
  type: 'paragraph';
3
28
  } & DocParagraph | {
@@ -53,7 +78,9 @@ export declare type DocRun = {
53
78
  breakType: 'line' | 'page' | 'column';
54
79
  } | {
55
80
  type: 'field';
56
- } & FieldRun;
81
+ } & FieldRun | {
82
+ type: 'shape';
83
+ } & ShapeRun;
57
84
 
58
85
  declare interface DocTable {
59
86
  colWidths: number[];
@@ -142,6 +169,13 @@ declare interface FieldRun {
142
169
  highlight?: string | null;
143
170
  }
144
171
 
172
+ declare interface GradientStop {
173
+ /** 0.0–1.0 */
174
+ position: number;
175
+ /** hex 6-char */
176
+ color: string;
177
+ }
178
+
145
179
  declare interface HeaderFooter {
146
180
  body: BodyElement[];
147
181
  }
@@ -227,6 +261,32 @@ declare interface ParagraphBorders {
227
261
  between: ParaBorderEdge | null;
228
262
  }
229
263
 
264
+ declare type PathCmd = {
265
+ cmd: 'moveTo';
266
+ x: number;
267
+ y: number;
268
+ } | {
269
+ cmd: 'lineTo';
270
+ x: number;
271
+ y: number;
272
+ } | {
273
+ cmd: 'cubicBezTo';
274
+ x1: number;
275
+ y1: number;
276
+ x2: number;
277
+ y2: number;
278
+ x: number;
279
+ y: number;
280
+ } | {
281
+ cmd: 'arcTo';
282
+ wr: number;
283
+ hr: number;
284
+ stAng: number;
285
+ swAng: number;
286
+ } | {
287
+ cmd: 'close';
288
+ };
289
+
230
290
  export declare interface RenderPageOptions {
231
291
  /** Canvas CSS width in px; height is auto-computed from page aspect ratio */
232
292
  width?: number;
@@ -247,6 +307,38 @@ export declare interface SectionProps {
247
307
  evenAndOddHeaders: boolean;
248
308
  }
249
309
 
310
+ declare type ShapeFill = {
311
+ fillType: 'solid';
312
+ color: string;
313
+ } | {
314
+ fillType: 'gradient';
315
+ stops: GradientStop[];
316
+ angle: number;
317
+ gradType: string;
318
+ };
319
+
320
+ declare interface ShapeRun {
321
+ widthPt: number;
322
+ heightPt: number;
323
+ /** X offset in pt */
324
+ anchorXPt: number;
325
+ /** Y offset in pt */
326
+ anchorYPt: number;
327
+ anchorXFromMargin: boolean;
328
+ anchorYFromPara: boolean;
329
+ /** Draw behind text when true (wp:anchor behindDoc="1"). */
330
+ behindDoc?: boolean;
331
+ /** Document-order index within a group; lower values render first. */
332
+ zOrder: number;
333
+ /** Normalized [0,1] custom-geometry sub-paths */
334
+ subpaths: PathCmd[][];
335
+ fill: ShapeFill | null;
336
+ stroke: string | null;
337
+ strokeWidth?: number;
338
+ rotation?: number;
339
+ wrapMode?: string | null;
340
+ }
341
+
250
342
  declare interface TableBorders {
251
343
  top: BorderSpec | null;
252
344
  bottom: BorderSpec | null;
@@ -7,6 +7,31 @@ declare interface ArrowEnd {
7
7
  len: string;
8
8
  }
9
9
 
10
+ /**
11
+ * Observe an element's size and invoke a render callback, coalescing bursts to
12
+ * one call per animation frame and serializing overlapping async renders.
13
+ *
14
+ * Framework-agnostic: call from any mount/setup hook and invoke the returned
15
+ * disposer in the corresponding teardown hook.
16
+ *
17
+ * @example
18
+ * const detach = autoResize(
19
+ * (width) => pres.renderSlide(canvas, 0, { width }),
20
+ * canvas,
21
+ * );
22
+ * // later
23
+ * detach();
24
+ */
25
+ declare function autoResize(render: (width: number, height: number) => void | Promise<void>, element: Element, opts?: AutoResizeOptions): () => void;
26
+
27
+ declare interface AutoResizeOptions {
28
+ /**
29
+ * Skip rendering while `document.hidden` is true and fire once with the latest
30
+ * observed size when the tab becomes visible again. Default: true.
31
+ */
32
+ pauseWhenHidden?: boolean;
33
+ }
34
+
10
35
  declare type BodyElement = {
11
36
  type: 'paragraph';
12
37
  } & DocParagraph | {
@@ -282,7 +307,9 @@ declare type DocRun = {
282
307
  breakType: 'line' | 'page' | 'column';
283
308
  } | {
284
309
  type: 'field';
285
- } & FieldRun;
310
+ } & FieldRun | {
311
+ type: 'shape';
312
+ } & ShapeRun;
286
313
 
287
314
  declare interface DocTable {
288
315
  colWidths: number[];
@@ -321,6 +348,8 @@ export declare namespace docx {
321
348
  export {
322
349
  DocxDocument,
323
350
  DocxViewer,
351
+ autoResize,
352
+ AutoResizeOptions,
324
353
  Document_2 as Document,
325
354
  SectionProps,
326
355
  DocParagraph,
@@ -422,6 +451,13 @@ declare interface GradientStop {
422
451
  color: string;
423
452
  }
424
453
 
454
+ declare interface GradientStop_2 {
455
+ /** 0.0–1.0 */
456
+ position: number;
457
+ /** hex 6-char */
458
+ color: string;
459
+ }
460
+
425
461
  declare interface HeaderFooter {
426
462
  body: BodyElement[];
427
463
  }
@@ -508,6 +544,20 @@ declare interface LineSpacing {
508
544
  rule: 'auto' | 'exact' | 'atLeast';
509
545
  }
510
546
 
547
+ /** Options for {@link PptxPresentation.load}. */
548
+ declare interface LoadOptions {
549
+ /**
550
+ * Opt in to loading theme-declared webfonts from Google Fonts
551
+ * (`fonts.googleapis.com`). When enabled, end-user IP/User-Agent is sent to
552
+ * Google, which may have privacy/GDPR implications for your application.
553
+ *
554
+ * Default: `false` — the canvas falls back to locally available fonts. Host
555
+ * the required webfonts yourself and reference them via `@font-face` in your
556
+ * application CSS to match the document's theme fonts.
557
+ */
558
+ useGoogleFonts?: boolean;
559
+ }
560
+
511
561
  declare interface MergeCell {
512
562
  top: number;
513
563
  left: number;
@@ -607,6 +657,32 @@ declare type PathCmd = {
607
657
  cmd: 'close';
608
658
  };
609
659
 
660
+ declare type PathCmd_2 = {
661
+ cmd: 'moveTo';
662
+ x: number;
663
+ y: number;
664
+ } | {
665
+ cmd: 'lineTo';
666
+ x: number;
667
+ y: number;
668
+ } | {
669
+ cmd: 'cubicBezTo';
670
+ x1: number;
671
+ y1: number;
672
+ x2: number;
673
+ y2: number;
674
+ x: number;
675
+ y: number;
676
+ } | {
677
+ cmd: 'arcTo';
678
+ wr: number;
679
+ hr: number;
680
+ stAng: number;
681
+ swAng: number;
682
+ } | {
683
+ cmd: 'close';
684
+ };
685
+
610
686
  declare interface PictureElement {
611
687
  type: 'picture';
612
688
  x: number;
@@ -630,6 +706,8 @@ declare interface PictureElement {
630
706
  r?: number;
631
707
  b?: number;
632
708
  };
709
+ /** a:blip > a:alphaModFix@amt as 0..1. Undefined = fully opaque. */
710
+ alpha?: number;
633
711
  }
634
712
 
635
713
  export declare namespace pptx {
@@ -637,9 +715,12 @@ export declare namespace pptx {
637
715
  PptxViewer,
638
716
  PptxViewerOptions,
639
717
  PptxPresentation,
718
+ LoadOptions,
640
719
  RenderSlideOptions,
641
720
  renderSlide,
642
721
  RenderOptions,
722
+ autoResize,
723
+ AutoResizeOptions,
643
724
  Presentation,
644
725
  Slide,
645
726
  SlideElement,
@@ -681,7 +762,7 @@ declare class PptxPresentation {
681
762
  private _workerReadyCallbacks;
682
763
  private constructor();
683
764
  /** Parse a PPTX from URL or ArrayBuffer. */
684
- static load(source: string | ArrayBuffer): Promise<PptxPresentation>;
765
+ static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<PptxPresentation>;
685
766
  private _waitForWorker;
686
767
  private _parse;
687
768
  /** Total number of slides in the loaded presentation. */
@@ -730,6 +811,11 @@ declare interface PptxViewerOptions extends RenderOptions {
730
811
  onSlideChange?: (index: number, total: number) => void;
731
812
  /** Called on parse or render errors */
732
813
  onError?: (err: Error) => void;
814
+ /**
815
+ * Opt in to loading theme-declared webfonts from Google Fonts. Off by
816
+ * default — see {@link PptxPresentation.load} for privacy implications.
817
+ */
818
+ useGoogleFonts?: boolean;
733
819
  }
734
820
 
735
821
  declare interface Presentation {
@@ -866,6 +952,38 @@ declare interface ShapeElement {
866
952
  shadow: Shadow | null;
867
953
  }
868
954
 
955
+ declare type ShapeFill = {
956
+ fillType: 'solid';
957
+ color: string;
958
+ } | {
959
+ fillType: 'gradient';
960
+ stops: GradientStop_2[];
961
+ angle: number;
962
+ gradType: string;
963
+ };
964
+
965
+ declare interface ShapeRun {
966
+ widthPt: number;
967
+ heightPt: number;
968
+ /** X offset in pt */
969
+ anchorXPt: number;
970
+ /** Y offset in pt */
971
+ anchorYPt: number;
972
+ anchorXFromMargin: boolean;
973
+ anchorYFromPara: boolean;
974
+ /** Draw behind text when true (wp:anchor behindDoc="1"). */
975
+ behindDoc?: boolean;
976
+ /** Document-order index within a group; lower values render first. */
977
+ zOrder: number;
978
+ /** Normalized [0,1] custom-geometry sub-paths */
979
+ subpaths: PathCmd_2[][];
980
+ fill: ShapeFill | null;
981
+ stroke: string | null;
982
+ strokeWidth?: number;
983
+ rotation?: number;
984
+ wrapMode?: string | null;
985
+ }
986
+
869
987
  declare interface SharedString {
870
988
  text: string;
871
989
  runs?: Run[];
@@ -1086,6 +1204,8 @@ export declare namespace xlsx {
1086
1204
  XlsxWorkbook,
1087
1205
  XlsxViewer,
1088
1206
  XlsxViewerOptions,
1207
+ autoResize,
1208
+ AutoResizeOptions,
1089
1209
  Workbook,
1090
1210
  SheetMeta,
1091
1211
  Worksheet,
@@ -7,6 +7,31 @@ declare interface ArrowEnd {
7
7
  len: string;
8
8
  }
9
9
 
10
+ /**
11
+ * Observe an element's size and invoke a render callback, coalescing bursts to
12
+ * one call per animation frame and serializing overlapping async renders.
13
+ *
14
+ * Framework-agnostic: call from any mount/setup hook and invoke the returned
15
+ * disposer in the corresponding teardown hook.
16
+ *
17
+ * @example
18
+ * const detach = autoResize(
19
+ * (width) => pres.renderSlide(canvas, 0, { width }),
20
+ * canvas,
21
+ * );
22
+ * // later
23
+ * detach();
24
+ */
25
+ export declare function autoResize(render: (width: number, height: number) => void | Promise<void>, element: Element, opts?: AutoResizeOptions): () => void;
26
+
27
+ export declare interface AutoResizeOptions {
28
+ /**
29
+ * Skip rendering while `document.hidden` is true and fire once with the latest
30
+ * observed size when the tab becomes visible again. Default: true.
31
+ */
32
+ pauseWhenHidden?: boolean;
33
+ }
34
+
10
35
  declare type Bullet = {
11
36
  type: 'none';
12
37
  } | {
@@ -90,6 +115,20 @@ export declare interface LineBreak {
90
115
  type: 'break';
91
116
  }
92
117
 
118
+ /** Options for {@link PptxPresentation.load}. */
119
+ export declare interface LoadOptions {
120
+ /**
121
+ * Opt in to loading theme-declared webfonts from Google Fonts
122
+ * (`fonts.googleapis.com`). When enabled, end-user IP/User-Agent is sent to
123
+ * Google, which may have privacy/GDPR implications for your application.
124
+ *
125
+ * Default: `false` — the canvas falls back to locally available fonts. Host
126
+ * the required webfonts yourself and reference them via `@font-face` in your
127
+ * application CSS to match the document's theme fonts.
128
+ */
129
+ useGoogleFonts?: boolean;
130
+ }
131
+
93
132
  export declare interface NoFill {
94
133
  fillType: 'none';
95
134
  }
@@ -168,6 +207,8 @@ export declare interface PictureElement {
168
207
  r?: number;
169
208
  b?: number;
170
209
  };
210
+ /** a:blip > a:alphaModFix@amt as 0..1. Undefined = fully opaque. */
211
+ alpha?: number;
171
212
  }
172
213
 
173
214
  /**
@@ -194,7 +235,7 @@ export declare class PptxPresentation {
194
235
  private _workerReadyCallbacks;
195
236
  private constructor();
196
237
  /** Parse a PPTX from URL or ArrayBuffer. */
197
- static load(source: string | ArrayBuffer): Promise<PptxPresentation>;
238
+ static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<PptxPresentation>;
198
239
  private _waitForWorker;
199
240
  private _parse;
200
241
  /** Total number of slides in the loaded presentation. */
@@ -243,6 +284,11 @@ export declare interface PptxViewerOptions extends RenderOptions {
243
284
  onSlideChange?: (index: number, total: number) => void;
244
285
  /** Called on parse or render errors */
245
286
  onError?: (err: Error) => void;
287
+ /**
288
+ * Opt in to loading theme-declared webfonts from Google Fonts. Off by
289
+ * default — see {@link PptxPresentation.load} for privacy implications.
290
+ */
291
+ useGoogleFonts?: boolean;
246
292
  }
247
293
 
248
294
  export declare interface Presentation {
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Observe an element's size and invoke a render callback, coalescing bursts to
3
+ * one call per animation frame and serializing overlapping async renders.
4
+ *
5
+ * Framework-agnostic: call from any mount/setup hook and invoke the returned
6
+ * disposer in the corresponding teardown hook.
7
+ *
8
+ * @example
9
+ * const detach = autoResize(
10
+ * (width) => pres.renderSlide(canvas, 0, { width }),
11
+ * canvas,
12
+ * );
13
+ * // later
14
+ * detach();
15
+ */
16
+ export declare function autoResize(render: (width: number, height: number) => void | Promise<void>, element: Element, opts?: AutoResizeOptions): () => void;
17
+
18
+ export declare interface AutoResizeOptions {
19
+ /**
20
+ * Skip rendering while `document.hidden` is true and fire once with the latest
21
+ * observed size when the tab becomes visible again. Default: true.
22
+ */
23
+ pauseWhenHidden?: boolean;
24
+ }
25
+
1
26
  export declare interface Border {
2
27
  left: BorderEdge | null;
3
28
  right: BorderEdge | null;