@betteroffice/pptx 0.5.0 → 0.6.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.
Files changed (57) hide show
  1. package/LICENSES/MIT-ruzstd.txt +21 -0
  2. package/LICENSES/MIT-twox-hash.txt +21 -0
  3. package/LICENSES/MIT-wuff.txt +20 -0
  4. package/README.md +24 -5
  5. package/dist/chunk-2XA2UH2O.js +1 -0
  6. package/dist/chunk-4WP5ZWYV.js +1 -0
  7. package/dist/chunk-65A2TX24.js +1 -0
  8. package/dist/chunk-663FARNX.js +1 -0
  9. package/dist/chunk-AYLLA7XR.js +1 -0
  10. package/dist/chunk-AZDGFDN2.js +1 -0
  11. package/dist/chunk-CCVGR3MS.js +1 -0
  12. package/dist/chunk-COS6CTH7.js +2 -0
  13. package/dist/chunk-G54T5CXF.js +1 -0
  14. package/dist/chunk-GAM2OAAP.js +2 -0
  15. package/dist/chunk-GHET7GIK.js +1 -0
  16. package/dist/chunk-GR7EGQ2Z.js +1 -0
  17. package/dist/chunk-HZODDD5T.js +1 -0
  18. package/dist/chunk-J54GRQWZ.js +1 -0
  19. package/dist/chunk-JJV35WHH.js +2 -0
  20. package/dist/chunk-KGEED2XY.js +1 -0
  21. package/dist/chunk-O2XFH626.js +1 -0
  22. package/dist/chunk-OUNTNO7R.js +1 -0
  23. package/dist/chunk-QRAGGQDN.js +1 -0
  24. package/dist/chunk-QWRXUT7T.js +1 -0
  25. package/dist/chunk-RNJM2LKC.js +3 -0
  26. package/dist/chunk-S6HKAO2F.js +1 -0
  27. package/dist/chunk-S6UYP4BX.js +1 -0
  28. package/dist/chunk-T6VUFMNC.js +1 -0
  29. package/dist/chunk-TRT2B252.js +10 -0
  30. package/dist/collaboration.js +1 -1
  31. package/dist/{editorSession-Cuqxkg-B.d.ts → editorSession-qQaVvMVR.d.ts} +356 -18
  32. package/dist/generated/metafile_svg_wasm_bg.wasm +0 -0
  33. package/dist/generated/pptx_wasm_bg.wasm +0 -0
  34. package/dist/generated/pptx_wasm_lean_bg.wasm +0 -0
  35. package/dist/generated/preflight/pptx_preflight_bg.wasm +0 -0
  36. package/dist/index.d.ts +21 -18
  37. package/dist/index.js +1 -1
  38. package/dist/pptxSessionWorker.mjs +13 -9
  39. package/dist/pptxSessionWorker.node.mjs +1 -0
  40. package/dist/pptxWorkerStart.d.ts +5 -0
  41. package/dist/pptxWorkerStart.js +1 -0
  42. package/dist/sessionWorker.missing.d.ts +3 -0
  43. package/dist/sessionWorker.missing.js +1 -0
  44. package/dist/sessionWorker.node.d.ts +3 -0
  45. package/dist/sessionWorker.node.js +1 -0
  46. package/dist/transport-BcduBS8X.d.ts +16 -0
  47. package/dist/wasm-preflight.d.ts +26 -0
  48. package/dist/wasm-preflight.js +1 -0
  49. package/dist/worker.d.ts +122 -22
  50. package/dist/worker.js +1 -1
  51. package/package.json +18 -5
  52. package/dist/chunk-2NCQ2IE7.js +0 -3
  53. package/dist/chunk-4FWJR3UX.js +0 -1
  54. package/dist/chunk-H3SEEI4U.js +0 -1
  55. package/dist/chunk-LIYNXEQC.js +0 -1
  56. package/dist/chunk-NNSP5326.js +0 -1
  57. /package/dist/{pptxSessionWorker.d.ts → pptxSessionWorker.node.d.ts} +0 -0
@@ -7,6 +7,7 @@ interface TextStyle {
7
7
  color?: string;
8
8
  fontFamily?: string;
9
9
  underline?: string;
10
+ strike?: string;
10
11
  spacingPt?: number;
11
12
  baselinePct?: number;
12
13
  }
@@ -18,6 +19,7 @@ interface TextStyleSnapshot {
18
19
  color: string | null;
19
20
  fontFamily: string | null;
20
21
  underline: string | null;
22
+ strike?: string | null;
21
23
  spacingPt?: number | null;
22
24
  baselinePct?: number | null;
23
25
  /** `a:rPr@kern`: the smallest size, in points, the run is kerned at. */
@@ -142,6 +144,12 @@ interface ShapeSnapshot {
142
144
  sourceId: number;
143
145
  kind: ShapeKind;
144
146
  name: string;
147
+ /** `p:cNvPr/@title`, the alternative-text title. */
148
+ title?: string;
149
+ /** `p:cNvPr/@descr`, the alternative-text description. */
150
+ description?: string;
151
+ /** True when `p:cNvPr` carries the a16 decorative extension; omitted when false. */
152
+ decorative?: boolean;
145
153
  x: number;
146
154
  y: number;
147
155
  width: number;
@@ -183,7 +191,40 @@ interface InheritedGeometry {
183
191
  flipH: boolean;
184
192
  flipV: boolean;
185
193
  }
194
+ /** Stored layout or master settings; omitted boolean attributes default to true and do not gate slide placeholders. */
195
+ interface HeaderFooterSettings {
196
+ slideNumber: boolean;
197
+ footer: boolean;
198
+ date: boolean;
199
+ header: boolean;
200
+ }
201
+ /** Session shape id and text of the first visible slide placeholder in shape order, including groups; text joins stories with newlines and preserves empty text.
202
+ * Slide number fields use firstSlideNum (default 1) plus deck index, counting hidden slides; fixed text stays unchanged. */
203
+ interface SlideHeaderFooterText {
204
+ shapeId: string;
205
+ text: string;
206
+ }
207
+ /** Stored date text; field is the first datetime* field type (updates on display), or null for fixed text. */
208
+ interface SlideDateText extends SlideHeaderFooterText {
209
+ field: string | null;
210
+ }
211
+ /** Visible placeholders from the slide itself, independent of stored settings; missing placeholders are null. */
212
+ interface SlideHeaderFooter {
213
+ footer: SlideHeaderFooterText | null;
214
+ slideNumber: SlideHeaderFooterText | null;
215
+ date: SlideDateText | null;
216
+ }
217
+ interface SlideLayoutSnapshot {
218
+ /** Layout settings, falling back to the master; null when neither stores p:hf. */
219
+ headerFooter?: HeaderFooterSettings | null;
220
+ name: string | null;
221
+ type: string | null;
222
+ }
186
223
  interface SlideSnapshot {
224
+ headerFooter?: SlideHeaderFooter | null;
225
+ title?: string | null;
226
+ hidden?: boolean | null;
227
+ layout?: SlideLayoutSnapshot | null;
187
228
  id: string;
188
229
  sourcePartPath: string | null;
189
230
  layoutPartPath: string | null;
@@ -509,9 +550,12 @@ interface PositionedTextRun {
509
550
  bold: boolean;
510
551
  italic: boolean;
511
552
  underline: boolean;
553
+ strike?: string;
512
554
  color: string;
513
555
  letterSpacingPx?: number;
514
556
  baselineOffsetPx?: number;
557
+ /** `false` when layout shaped the run without kerning, below its `kern` threshold; absent when kerned. */
558
+ kerning?: false;
515
559
  glyphs: PositionedGlyph[];
516
560
  }
517
561
  interface PositionedTextLine {
@@ -533,6 +577,8 @@ interface TextBoxPrimitive extends PrimitiveBase {
533
577
  paragraphs: Array<{
534
578
  align?: 'left' | 'center' | 'right' | 'justify';
535
579
  level: number;
580
+ languages?: TextLanguage[];
581
+ links?: TextLink[];
536
582
  runs: Array<{
537
583
  text: string;
538
584
  fontFamily: string;
@@ -548,6 +594,28 @@ interface TextBoxPrimitive extends PrimitiveBase {
548
594
  /** `a:rPr/a:effectLst`: the shadow the box's glyphs are drawn with. */
549
595
  textShadow?: Shadow;
550
596
  }
597
+ /** UTF-16 offsets into the paragraph's concatenated run text. */
598
+ interface TextLanguage {
599
+ start: number;
600
+ end: number;
601
+ lang: string;
602
+ }
603
+ /** UTF-16 offsets into the paragraph's concatenated run text. */
604
+ interface TextLink {
605
+ start: number;
606
+ end: number;
607
+ target: TextLinkTarget;
608
+ }
609
+ type TextLinkTarget = {
610
+ kind: 'url';
611
+ href: string;
612
+ } | {
613
+ kind: 'slide';
614
+ index: number;
615
+ } | {
616
+ kind: 'jump';
617
+ jump: 'next' | 'previous' | 'first' | 'last';
618
+ };
551
619
  interface PlaceholderPrimitive extends PrimitiveBase {
552
620
  kind: 'placeholder';
553
621
  name: string;
@@ -560,6 +628,21 @@ interface ChartPrimitive extends PrimitiveBase {
560
628
  name: string;
561
629
  label: string;
562
630
  primitives: SlidePrimitive[];
631
+ /** The plotted values as text, for assistive technology, with no categories
632
+ * or series when the chart caches no points. Older engines and charts over
633
+ * the size cap leave it out. */
634
+ data?: ChartData;
635
+ }
636
+ /** What a chart plots: one row per category and one column per series. */
637
+ interface ChartData {
638
+ categories: string[];
639
+ series: ChartDataSeries[];
640
+ }
641
+ interface ChartDataSeries {
642
+ name?: string;
643
+ /** Each category's value as the chart's data labels would show it; `null`
644
+ * where the chart has no number. */
645
+ values: (string | null)[];
563
646
  }
564
647
  /** A laid-out table. Its cells paint clipped to the table rectangle, and
565
648
  * `label` is the screen-reader summary of the whole table. */
@@ -568,14 +651,51 @@ interface TablePrimitive extends PrimitiveBase {
568
651
  name: string;
569
652
  label: string;
570
653
  primitives: SlidePrimitive[];
654
+ /** The row and column structure, for assistive technology. Older engines
655
+ * leave it out. */
656
+ grid?: TableGrid;
657
+ }
658
+ interface TableGrid {
659
+ rows: number;
660
+ columns: number;
661
+ /** Cells that start a span, in row then column order; cells merged into
662
+ * another one are left out. */
663
+ cells: TableGridCell[];
664
+ }
665
+ interface TableGridCell {
666
+ row: number;
667
+ column: number;
668
+ rowSpan: number;
669
+ columnSpan: number;
670
+ /** `column` heads its column (the header row), `row` heads its row (the
671
+ * first column). */
672
+ header?: 'column' | 'row';
673
+ /** The `[start, end)` range of the table's `primitives` that hold the
674
+ * cell's text. */
675
+ primitives: [number, number];
571
676
  }
572
677
  type SlidePrimitive = ShapePrimitive | ImagePrimitive | TextBoxPrimitive | PlaceholderPrimitive | ChartPrimitive | TablePrimitive;
678
+ /** What `p:cNvPr` says about a shape for assistive technology. */
679
+ interface ShapeAltText {
680
+ title?: string;
681
+ description?: string;
682
+ /** The shape, or a group around it, is marked decorative. */
683
+ decorative?: boolean;
684
+ /** The nearest enclosing group with alternative text, by its key in `altText`. */
685
+ group?: string;
686
+ /** Where the shape starts in `primitives` when what paints it carries no shape id. */
687
+ primitive?: number;
688
+ }
573
689
  interface SlideDisplayList {
574
690
  contractVersion: number;
575
691
  width: number;
576
692
  height: number;
577
693
  background?: Paint;
578
694
  primitives: SlidePrimitive[];
695
+ /** Alternative text by shape id, for the shapes that have some. */
696
+ altText?: Record<string, ShapeAltText>;
697
+ /** The shape holding the slide's title placeholder. */
698
+ titleShape?: string;
579
699
  }
580
700
  type HitTestResult = {
581
701
  kind: 'shape';
@@ -592,7 +712,7 @@ interface UpdateEvent {
592
712
  }
593
713
  interface TextParagraphDraft {
594
714
  bullet?: boolean;
595
- alignment?: ParagraphAlignment | null;
715
+ alignment?: ParagraphAlignment | 'justLow' | 'dist' | 'thaiDist' | null;
596
716
  runs: Array<{
597
717
  text: string;
598
718
  style?: TextStyle;
@@ -607,6 +727,72 @@ interface TableReceipt {
607
727
  }
608
728
 
609
729
  type ProposalEdit = {
730
+ type: 'addTextBox';
731
+ ref?: string;
732
+ slideId: string;
733
+ draft: ShapeDraft;
734
+ } | {
735
+ type: 'addShape';
736
+ ref?: string;
737
+ slideId: string;
738
+ draft: PresetShapeDraft;
739
+ } | {
740
+ type: 'addPicture';
741
+ ref?: string;
742
+ slideId: string;
743
+ draft: PictureDraft;
744
+ } | {
745
+ type: 'removeShape';
746
+ slideId: string;
747
+ shapeId: string;
748
+ } | {
749
+ type: 'reorderShape';
750
+ slideId: string;
751
+ shapeId: string;
752
+ to: 'front' | 'back' | 'forward' | 'backward';
753
+ } | {
754
+ type: 'insertTableRow';
755
+ slideId: string;
756
+ shapeId: string;
757
+ index: number;
758
+ position: 'before' | 'after';
759
+ cells?: string[];
760
+ } | {
761
+ type: 'deleteTableRow';
762
+ slideId: string;
763
+ shapeId: string;
764
+ index: number;
765
+ } | {
766
+ type: 'insertTableColumn';
767
+ slideId: string;
768
+ shapeId: string;
769
+ index: number;
770
+ position: 'before' | 'after';
771
+ cells?: string[];
772
+ width?: 'split' | 'copy';
773
+ } | {
774
+ type: 'deleteTableColumn';
775
+ slideId: string;
776
+ shapeId: string;
777
+ index: number;
778
+ } | {
779
+ type: 'insertSlide';
780
+ ref?: string;
781
+ afterSlideId: string | null;
782
+ layoutPartPath?: string;
783
+ } | {
784
+ type: 'duplicateSlide';
785
+ ref?: string;
786
+ slideId: string;
787
+ afterSlideId?: string | null;
788
+ } | {
789
+ type: 'deleteSlide';
790
+ slideId: string;
791
+ } | {
792
+ type: 'moveSlide';
793
+ slideId: string;
794
+ afterSlideId: string | null;
795
+ } | {
610
796
  type: 'replaceText';
611
797
  storyId: string;
612
798
  start: number;
@@ -625,6 +811,10 @@ type ProposalEdit = {
625
811
  start: number;
626
812
  end: number;
627
813
  alignment: ParagraphAlignment | 'justLow' | 'dist' | 'thaiDist' | null;
814
+ } | {
815
+ type: 'setStoryParagraphs';
816
+ storyId: string;
817
+ paragraphs: TextParagraphDraft[];
628
818
  } | {
629
819
  type: 'setShapeRect';
630
820
  slideId: string;
@@ -647,12 +837,30 @@ type ProposalEdit = {
647
837
  slideId: string;
648
838
  shapeId: string;
649
839
  adjustments: Record<string, number>;
840
+ } | {
841
+ type: 'setSlideLayout';
842
+ slideId: string;
843
+ layoutPartPath: string;
844
+ mapping?: [string, number][];
845
+ } | {
846
+ type: 'setSlideBackground';
847
+ slideId: string;
848
+ background: ShapeFill | null;
650
849
  } | {
651
850
  type: 'setSlideNotes';
652
851
  slideId: string;
653
852
  text: string;
654
853
  };
854
+ interface ProposalStripEntry {
855
+ slideId: string;
856
+ status: 'unchanged' | 'changed' | 'inserted' | 'deleted' | 'moved';
857
+ liveIndex: number | null;
858
+ previewIndex: number | null;
859
+ }
655
860
  interface ProposalChange {
861
+ kind?: 'content' | 'inserted' | 'deleted' | 'moved';
862
+ beforeIndex?: number | null;
863
+ afterIndex?: number | null;
656
864
  slideId: string;
657
865
  shapeId: string | null;
658
866
  before: ShapeSnapshot | null;
@@ -667,6 +875,7 @@ interface Proposal {
667
875
  edits: ProposalEdit[];
668
876
  changes: ProposalChange[];
669
877
  staleTargets: string[];
878
+ refs?: Record<string, string>;
670
879
  }
671
880
  interface ProposalPreview {
672
881
  proposal: Proposal;
@@ -678,9 +887,18 @@ interface ProposalTextChange {
678
887
  end: number;
679
888
  kind: 'insertion' | 'deletion';
680
889
  }
890
+ interface ProposalShapeChange {
891
+ shapeId: string;
892
+ kind: 'inserted' | 'deleted' | 'moved' | 'resized' | 'changed' | 'reordered';
893
+ }
681
894
  interface ProposalDiffSlide extends ProposalPreview {
895
+ shapeChanges?: ProposalShapeChange[];
682
896
  frame: SlideDisplayList;
683
897
  textChanges: ProposalTextChange[];
898
+ media?: {
899
+ assetId: string;
900
+ bytes: ArrayBuffer;
901
+ }[];
684
902
  }
685
903
  interface ProposalAcceptance {
686
904
  proposalId: string;
@@ -691,6 +909,12 @@ declare class StaleProposalError extends Error {
691
909
  readonly targets: string[];
692
910
  constructor(targets: string[]);
693
911
  }
912
+ declare class ProposalPictureMediaTooLargeError extends Error {
913
+ readonly totalBytes: number;
914
+ readonly limitBytes: number;
915
+ readonly code = "proposalPictureMediaTooLarge";
916
+ constructor(totalBytes: number, limitBytes?: number);
917
+ }
694
918
 
695
919
  type CanvasImageResolver = ((assetId: string) => CanvasImageSource | Promise<CanvasImageSource | null> | null) & {
696
920
  acquire?(): CanvasImageResolver;
@@ -700,6 +924,31 @@ interface PaintSlideOptions {
700
924
  resolveImage?: CanvasImageResolver;
701
925
  maxShadowPixels?: number;
702
926
  textChanges?: readonly ProposalTextChange[];
927
+ shapeChanges?: readonly ProposalShapeChange[];
928
+ /** The family a run paints with in place of its own, e.g. an export's private face. */
929
+ fontFamily?: (font: {
930
+ family: string;
931
+ bold: boolean;
932
+ italic: boolean;
933
+ id: number;
934
+ }) => string | undefined;
935
+ /**
936
+ * Makes the faces a slide draws with ready before any text is painted. Without it, text draws with each run's own
937
+ * family, as the host installed it.
938
+ */
939
+ fontCoverage?: PaintFontCoverage;
940
+ }
941
+ /** Prepares the fonts a paint draws text with. */
942
+ interface PaintFontCoverage {
943
+ /**
944
+ * Resolves once every character of `text` can be drawn in `family`, with the family name to draw it with (for
945
+ * example a newer installed revision of the same face).
946
+ */
947
+ prepare(family: string, text: string): Promise<string>;
948
+ /** The newest family to draw prepared text with now; a newer revision holds everything an older one did. */
949
+ latest?(family: string): string | undefined;
950
+ /** False for a style that draws under its own name, whatever the family's other styles do. Defaults to true. */
951
+ covers?(family: string, bold: boolean, italic: boolean): boolean;
703
952
  }
704
953
  interface SlideCanvasLike {
705
954
  width: number;
@@ -712,8 +961,53 @@ interface SlideCanvasLike {
712
961
  declare function sizeCanvasForSlide(canvas: SlideCanvasLike, list: Pick<SlideDisplayList, 'width' | 'height'>, dpr: number, scale?: number): void;
713
962
  declare function paintSlide(ctx: CanvasRenderingContext2D, list: SlideDisplayList, dpr?: number, scale?: number, options?: PaintSlideOptions): Promise<void>;
714
963
 
964
+ interface PresentationImageDecodeOptions {
965
+ maxDimension?: number;
966
+ }
967
+ declare function needsElementDecode(blob: Blob): boolean;
968
+ declare function decodeBrowserPresentationImage(bytes: Uint8Array, errorMessage: string, options?: PresentationImageDecodeOptions): Promise<CanvasImageSource>;
969
+ /**
970
+ * A metafile's display bytes: `resolve`'s replay of it, unless the browser
971
+ * path already draws it (a plain bitmap wrapper). Other images are unchanged.
972
+ * @internal
973
+ */
974
+ declare function metafileImageBytes(bytes: Uint8Array, resolve?: () => Uint8Array | undefined): Uint8Array;
975
+
976
+ /** What `renderPng` draws: a slide by zero-based index or by its ID. */
977
+ type PptxPngTarget = {
978
+ slide: number | string;
979
+ };
980
+ interface PptxPngOptions {
981
+ /** Device pixels per slide pixel. Defaults to 1. */
982
+ scale?: number;
983
+ /** `'slide'` (default) paints white under the slide, as the editor shows it; `'transparent'` nothing; or a `#rrggbb` color. */
984
+ background?: 'slide' | 'transparent' | `#${string}`;
985
+ /** Scratch pixels every shadow on the slide may blur between them. */
986
+ maxShadowPixels?: number;
987
+ signal?: AbortSignal;
988
+ /**
989
+ * Faces to paint with besides those the presentation registered, matched by
990
+ * family and style. One that fails to load rejects with `PngExportError`
991
+ * `font-unavailable`.
992
+ */
993
+ fonts?: ReadonlyArray<PptxFontFace>;
994
+ }
995
+
715
996
  type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
716
997
 
998
+ type FontDecoder = (bytes: ArrayBuffer | Uint8Array, options: {
999
+ codec: string;
1000
+ dict?: ArrayBuffer | Uint8Array;
1001
+ maxOutput?: number;
1002
+ }) => Promise<{
1003
+ font: ArrayBuffer;
1004
+ payload?: ArrayBuffer;
1005
+ }>;
1006
+ type FontDecodeResult = Awaited<ReturnType<FontDecoder>>;
1007
+ type FontDecoderMethods = {
1008
+ decodeFontFace(bytes: ArrayBuffer, options: Parameters<FontDecoder>[1], wasm?: ArrayBuffer | WebAssembly.Module): FontDecodeResult;
1009
+ };
1010
+
717
1011
  /**
718
1012
  * Result envelopes shared by the formats' host edit APIs. Targets, steps, receipts and failure
719
1013
  * codes stay format-owned; these shapes only fix how every format reports success and refusal.
@@ -755,16 +1049,6 @@ interface ValidationSuccess<Preview> {
755
1049
  previews: Preview[];
756
1050
  }
757
1051
 
758
- /**
759
- * Versioned reads and version-checked edit batches over one presentation session. Every shape
760
- * here is plain JSON so it can cross a worker boundary unchanged; the semantics live in Rust.
761
- *
762
- * Text offsets are half-open, story-local UTF-16 positions. A story reads as its paragraphs'
763
- * text joined by `\n` with no trailing separator; soft line breaks read as `\n` too, and
764
- * `PptxParagraphText` tells them apart. Slide, shape, story and paragraph ids anchor targets
765
- * within one session; they are not promised to survive save and reopen.
766
- */
767
-
768
1052
  /** Provenance only: it selects neither permissions nor history. */
769
1053
  type PptxEditSource = 'host' | 'agent';
770
1054
  /** `separate`: exactly one undo step. `none`: outside undo history, keeping existing entries. */
@@ -922,6 +1206,7 @@ interface PptxTextField {
922
1206
  fieldType?: string;
923
1207
  }
924
1208
  interface PptxParagraphText {
1209
+ list?: PptxExportList | null;
925
1210
  paragraphId: string;
926
1211
  /** Story offsets of the paragraph's text; a following separator sits at `end`. */
927
1212
  start: number;
@@ -1281,10 +1566,21 @@ declare class PptxExportError extends Error {
1281
1566
  constructor(failure: PptxExportFailure);
1282
1567
  }
1283
1568
 
1569
+ declare const decodeFontFace: FontDecoder;
1570
+
1284
1571
  type WasmInitInput = InitInput | Promise<InitInput>;
1285
1572
  interface InspectPresentationOptions {
1286
1573
  includeMedia?: boolean;
1287
1574
  }
1575
+ /**
1576
+ * Faces a save lays out text with, in a renderer of its own, so the saved
1577
+ * bytes do not depend on the faces earlier renders registered with the handle.
1578
+ */
1579
+ interface SavePresentationOptions {
1580
+ fonts: ReadonlyArray<PptxFontFace>;
1581
+ /** Faces drawn only for characters the run's own face has no glyph for. */
1582
+ fallbackFonts?: ReadonlyArray<PptxFontFace>;
1583
+ }
1288
1584
  interface OpenPresentationOptions {
1289
1585
  clientId?: number;
1290
1586
  fonts?: ReadonlyArray<PptxFontFace>;
@@ -1297,6 +1593,8 @@ interface OpenPresentationOptions {
1297
1593
  * and `save()` throws.
1298
1594
  */
1299
1595
  initialUpdate?: Uint8Array;
1596
+ /** @internal Retains the source bytes for `fork()` and `layouts()`; worker sessions pass false. */
1597
+ retainSource?: boolean;
1300
1598
  }
1301
1599
  type UndoCaptureMode = 'auto' | 'manual';
1302
1600
  interface PresentationHistoryReceipt {
@@ -1321,12 +1619,21 @@ type PresentationCommandReadResult = Extract<PptxReadResult, {
1321
1619
  }[];
1322
1620
  });
1323
1621
  interface PresentationHandle extends CollaborationReplica {
1622
+ /**
1623
+ * Draws a slide as PNG bytes with the editor's painter on a canvas, with the
1624
+ * faces layout measured with. Rejects with `PngExportError` rather than
1625
+ * paint a substitute font, and where no canvas exists names
1626
+ * `@betteroffice/pptx-native`.
1627
+ */
1628
+ renderPng(target: PptxPngTarget, options?: PptxPngOptions): Promise<Uint8Array>;
1324
1629
  isProposalsAvailable(): boolean;
1325
1630
  propose(agentId: string, note: string | null, edits: readonly ProposalEdit[]): Proposal;
1326
1631
  listProposals(): Proposal[];
1327
1632
  previewProposal(id: string): ProposalPreview;
1328
1633
  layoutProposalSlide(id: string, slideIndex: number): SlideDisplayList;
1329
1634
  layoutProposalDiffSlide(id: string, slideIndex: number): ProposalDiffSlide;
1635
+ layoutProposalDiffSlideById(id: string, slideId: string): ProposalDiffSlide;
1636
+ proposalSlideStrip(id: string): ProposalStripEntry[];
1330
1637
  acceptProposal(id: string, options?: {
1331
1638
  force?: boolean;
1332
1639
  }): ProposalAcceptance;
@@ -1385,13 +1692,24 @@ interface PresentationHandle extends CollaborationReplica {
1385
1692
  registerFont(face: PptxFontFace): number;
1386
1693
  /** Registers a face drawn only where a run's own face has no glyph. */
1387
1694
  registerFallbackFont(face: PptxFontFace): number;
1695
+ /** Gives PNG export the complete bytes of a family layout measured with only part of. */
1696
+ replaceExportFace(family: string, bytes: Uint8Array, keep?: (face: {
1697
+ id: number;
1698
+ bold?: boolean;
1699
+ italic?: boolean;
1700
+ }) => boolean): void;
1388
1701
  layoutSlide(slideIndex: number): SlideDisplayList;
1389
1702
  /** `layoutSlide` with scope, layout and serialize time measured inside the renderer. */
1390
1703
  layoutSlideProfiled(slideIndex: number): ProfiledLayout;
1391
1704
  hitTest(x: number, y: number): HitTestResult | null;
1392
1705
  mediaBytes(partPath: string): Uint8Array;
1393
- /** serialize the presentation back to .pptx bytes, edits included. */
1394
- save(): Uint8Array;
1706
+ metafileSvg(partPath: string): Uint8Array | undefined;
1707
+ /**
1708
+ * serialize the presentation back to .pptx bytes, edits included. Normal
1709
+ * autofit text the edits changed is fitted with the registered faces, or
1710
+ * with `options.fonts` alone when given.
1711
+ */
1712
+ save(options?: SavePresentationOptions): Uint8Array;
1395
1713
  insertText(storyId: string, index: number, text: string, style?: TextStyle): TextReceipt;
1396
1714
  /** `insertText` with the boundary's stage timings attached. */
1397
1715
  insertTextProfiled(storyId: string, index: number, text: string, style?: TextStyle): Profiled<TextReceipt>;
@@ -1405,10 +1723,10 @@ interface PresentationHandle extends CollaborationReplica {
1405
1723
  setParagraphAlignment(storyId: string, start: number, end: number, alignment: ParagraphAlignment | null): TextReceipt;
1406
1724
  insertTableRow(slideId: string, shapeId: string, index: number, position: 'before' | 'after', cells?: readonly string[]): TableReceipt;
1407
1725
  deleteTableRow(slideId: string, shapeId: string, index: number): TableReceipt;
1408
- insertTableColumn(slideId: string, shapeId: string, index: number, position: 'before' | 'after', cells?: readonly string[]): TableReceipt;
1726
+ insertTableColumn(slideId: string, shapeId: string, index: number, position: 'before' | 'after', cells?: readonly string[], width?: 'split' | 'copy'): TableReceipt;
1409
1727
  deleteTableColumn(slideId: string, shapeId: string, index: number): TableReceipt;
1410
1728
  /** Throws the refusal the matching table edit would throw, without changing the deck. */
1411
- checkTableEdit(method: 'insertTableRow' | 'deleteTableRow' | 'insertTableColumn' | 'deleteTableColumn', slideId: string, shapeId: string, index: number, position?: 'before' | 'after', cells?: readonly string[]): void;
1729
+ checkTableEdit(method: 'insertTableRow' | 'deleteTableRow' | 'insertTableColumn' | 'deleteTableColumn', slideId: string, shapeId: string, index: number, position?: 'before' | 'after', cells?: readonly string[], width?: 'split' | 'copy'): void;
1412
1730
  insertSlide(index: number, layoutPartPath?: string): SlideReceipt;
1413
1731
  insertSlideProfiled(index: number, layoutPartPath?: string): Profiled<SlideReceipt>;
1414
1732
  duplicateSlide(slideId: string, toIndex: number): SlideReceipt;
@@ -1505,6 +1823,12 @@ interface PresentationReplayReply {
1505
1823
  consumed: boolean;
1506
1824
  outcome: PresentationReplayOutcome;
1507
1825
  }
1826
+ type PptxStoryFormattingTarget = {
1827
+ slideId: string;
1828
+ shapeId: string;
1829
+ storyId: string;
1830
+ };
1831
+ declare function presentationStoryFormatting(handle: PresentationHandle, target: PptxStoryFormattingTarget): StorySnapshot;
1508
1832
  declare function isProposalsAvailable(): boolean;
1509
1833
  declare function initWasm(input?: WasmInitInput): Promise<void>;
1510
1834
  declare function isWasmAvailable(): boolean;
@@ -1570,6 +1894,14 @@ declare class SessionFailure extends Error {
1570
1894
  constructor(code: SessionFailureCode, message: string, diagnostics?: string | undefined);
1571
1895
  }
1572
1896
 
1897
+ /** @internal */
1898
+ interface FontCdnConfiguration {
1899
+ baseUrl: string | false;
1900
+ timeoutMs: number;
1901
+ }
1902
+
1903
+ /** PNG options a session call carries; an abort signal stays on the caller's side. */
1904
+ type PresentationPngOptions = Omit<PptxPngOptions, 'signal'>;
1573
1905
  /** @experimental */
1574
1906
  interface PresentationFrame {
1575
1907
  displayList: SlideDisplayList;
@@ -1604,6 +1936,8 @@ interface PresentationSessionOpenOptions extends Omit<OpenPresentationOptions, '
1604
1936
  fonts?: readonly PresentationSessionFont[];
1605
1937
  fallbackFonts?: readonly PresentationSessionFont[];
1606
1938
  wasm?: ArrayBuffer | WebAssembly.Module;
1939
+ /** @internal */
1940
+ fontCdn?: FontCdnConfiguration;
1607
1941
  }
1608
1942
  /**
1609
1943
  * Slide metadata without layout; indices are zero-based.
@@ -1656,6 +1990,8 @@ type PresentationSessionMethods = {
1656
1990
  height: number;
1657
1991
  };
1658
1992
  save(): ArrayBuffer;
1993
+ /** Draws a slide as PNG bytes in the session's engine, with the faces it measured with. */
1994
+ renderPng(target: PptxPngTarget, options?: PresentationPngOptions): ArrayBuffer;
1659
1995
  dispose(): void;
1660
1996
  };
1661
1997
 
@@ -1682,12 +2018,14 @@ interface OpenPresentationSessionOptions extends OpenPresentationOptions {
1682
2018
  */
1683
2019
  interface PresentationSession {
1684
2020
  readonly state: PresentationSessionState;
1685
- readonly call: Promisified<Omit<PresentationSessionMethods, 'open' | 'dispose' | 'frame'>> & {
2021
+ readonly call: Promisified<Omit<PresentationSessionMethods, 'open' | 'dispose' | 'frame' | 'renderPng'>> & {
1686
2022
  /**
1687
2023
  * @experimental A newer frame call replaces a queued one, which rejects with an error
1688
2024
  * named SessionSuperseded.
1689
2025
  */
1690
2026
  frame(slideIndex: number): Promise<PresentationFrame>;
2027
+ /** Draws a slide as PNG bytes in the session's engine. */
2028
+ renderPng(target: PptxPngTarget, options?: PptxPngOptions): Promise<Uint8Array>;
1691
2029
  };
1692
2030
  save(): Promise<Uint8Array>;
1693
2031
  on<K extends keyof PresentationSessionEvents>(name: K, listener: (payload: PresentationSessionEvents[K]) => void): () => void;
@@ -1701,7 +2039,7 @@ interface PresentationSession {
1701
2039
  */
1702
2040
  declare function openPresentationSession(bytes: Uint8Array | ArrayBuffer, options?: OpenPresentationSessionOptions): Promise<PresentationSession>;
1703
2041
 
1704
- declare const readMethods: readonly ["snapshot", "story", "anchorCaret", "resolveCaretAnchor", "version", "readContent", "findText", "validateEdits", "searchText", "isProposalsAvailable", "listProposals", "layoutSlide", "hitTest", "mediaBytes", "comments", "canUndo", "canRedo", "undoCaptureMode", "onUpdate"];
2042
+ declare const readMethods: readonly ["snapshot", "story", "anchorCaret", "resolveCaretAnchor", "version", "readContent", "findText", "validateEdits", "searchText", "proposalSlideStrip", "layoutProposalDiffSlideById", "isProposalsAvailable", "listProposals", "layoutSlide", "hitTest", "mediaBytes", "metafileSvg", "comments", "canUndo", "canRedo", "undoCaptureMode", "onUpdate"];
1705
2043
  interface PptxWorkerEditorInteractionAccess {
1706
2044
  snapshot(): {
1707
2045
  snapshot: DeckSnapshot;
@@ -1750,4 +2088,4 @@ interface PptxWorkerEditorSession {
1750
2088
  }
1751
2089
  declare function createPptxWorkerEditorSession(bytes: Uint8Array | ArrayBuffer, options?: PptxWorkerEditorOptions): PptxWorkerEditorSession;
1752
2090
 
1753
- export { type PptxExportDiagnostic as $, type PptxAnchor as A, type BlipEffect as B, type CanvasImageResolver as C, type DeckSnapshot as D, type EditProfile as E, type PptxAnchorScope as F, type GeometryPathCommand as G, type HistoryProfile as H, type ImageCrop as I, type PptxCaretAnchor as J, type PptxEditFailure as K, type LayoutProfile as L, type MarkdownAnchor as M, type PptxEditFailureCode as N, type OpenPresentationOptions as O, type Paint as P, type PptxEditHistory as Q, type PptxEditPreview as R, type SlideDisplayList as S, type PptxEditReceipt as T, type PptxEditRefusal as U, type PptxEditRequest as V, type PptxEditResult as W, type PptxEditSource as X, type PptxEditStep as Y, type PptxEditTarget as Z, type PptxExportComment as _, type CaretStop as a, type ShapeKind as a$, type PptxExportDiagnosticCode as a0, PptxExportError as a1, type PptxExportFailure as a2, type PptxExportFailureCode as a3, type PptxExportList as a4, type PptxExportMark as a5, type PptxExportNotes as a6, type PptxExportObject as a7, type PptxExportObjectKind as a8, type PptxExportOptions as a9, type PptxStructuredContent as aA, type PptxTextField as aB, type PptxTextGuard as aC, type PptxTextMatch as aD, type PptxTextRange as aE, type PptxTextSearchOptions as aF, type PptxTextSpan as aG, type PptxTextTarget as aH, type PptxValidationResult as aI, PptxWorkerEditorDisposedError as aJ, type PresentationHandle as aK, type PresetShapeDraft as aL, type PrimitiveTransform as aM, type Profiled as aN, type ProfiledLayout as aO, type Proposal as aP, type ProposalAcceptance as aQ, type ProposalChange as aR, type ProposalDiffSlide as aS, type ProposalEdit as aT, type ProposalPreview as aU, type ProposalTextChange as aV, type ShapeAdjustReceipt as aW, type ShapeDraft as aX, type ShapeFill as aY, type ShapeFillReceipt as aZ, type ShapeGradient as a_, type PptxExportParagraph as aa, type PptxExportRefusal as ab, type PptxExportResult as ac, type PptxExportRun as ad, type PptxExportShape as ae, type PptxExportShapeKind as af, type PptxExportSlide as ag, type PptxExportStory as ah, type PptxExportTable as ai, type PptxExportTableCell as aj, type PptxFindMatch as ak, type PptxFindRequest as al, type PptxFindResult as am, type PptxFindScope as an, type PptxFontFace as ao, type PptxMarkdownContent as ap, type PptxMarkdownOptions as aq, type PptxParagraphText as ar, PptxPeerNotReadyError as as, type PptxReadRequest as at, type PptxReadResult as au, type PptxShapeTarget as av, type PptxSlideTarget as aw, type PptxSourceProvenance as ax, type PptxStoryTarget as ay, type PptxStoryText as az, type ColorTransform as b, type PresentationSessionEvents as b$, type ShapeLineEnd as b0, type ShapeOutline as b1, type ShapePrimitive as b2, type ShapeReceipt as b3, type ShapeRect as b4, type ShapeSnapshot as b5, type ShapeStroke as b6, type ShapeStrokeReceipt as b7, type ShapeZOrderReceipt as b8, type SlideCanvasLike as b9, isWasmAvailable as bA, openPresentation as bB, openPresentationSession as bC, paintSlide as bD, renderPptxMarkdown as bE, sizeCanvasForSlide as bF, wasmVersion as bG, type PresentationSlideSummary as bH, type PresentationWireFrame as bI, SessionFailure as bJ, type PresentationSessionOpenOptions as bK, type OpenPresentationSessionOptions as bL, PptxWorkerEditorFailedError as bM, PptxPeerHydrationError as bN, type PptxWorkerEditorAccess as bO, PptxWorkerEditorCollaborationError as bP, type PptxWorkerEditorFrame as bQ, type PptxWorkerEditorInteractionAccess as bR, type PptxWorkerEditorOperation as bS, type PptxWorkerEditorOptions as bT, type PptxWorkerEditorRecovery as bU, type PptxWorkerEditorReply as bV, type PptxWorkerEditorSession as bW, type PptxWorkerEditorStage as bX, type PptxWorkerEditorState as bY, type PresentationFrame as bZ, type PresentationSession as b_, type SlidePrimitive as ba, type SlideReceipt as bb, type SlideSnapshot as bc, StaleProposalError as bd, type StorySnapshot as be, type Stroke as bf, type StrokeEnd as bg, type TableReceipt as bh, type TextBoxPrimitive as bi, type TextParagraphDraft as bj, type TextReceipt as bk, type TextRunSnapshot as bl, type TextStyle as bm, type TextStylePatch as bn, type TextStyleSnapshot as bo, type TransformReceipt as bp, type UndoCaptureMode as bq, type UpdateEvent as br, type ValidationSuccess as bs, type WasmInitInput as bt, createPptxWorkerEditorSession as bu, exportPptxMarkdown as bv, exportPptxStructured as bw, initWasm as bx, inspectPresentation as by, isProposalsAvailable as bz, type ColorValue as c, type PresentationSessionFont as c0, type PresentationSessionMethods as c1, type PresentationSessionState as c2, type CommentFlavor as d, type CommentReceipt as e, type CommentSnapshot as f, type EditSuccess as g, type ExportCompletion as h, type ExportDiagnostic as i, type ExportSeverity as j, type HistoryResult as k, type HitTestResult as l, type ImageEffect as m, type ImagePrimitive as n, type InheritedGeometry as o, type InspectPresentationOptions as p, type OperationFailure as q, type OperationRefusal as r, type PaintSlideOptions as s, type ParagraphAlignment as t, type ParagraphSnapshot as u, type PictureDraft as v, type PlaceholderPrimitive as w, type PositionedGlyph as x, type PositionedTextLine as y, type PositionedTextRun as z };
2091
+ export { type PptxEditSource as $, type PictureDraft as A, type BlipEffect as B, type CanvasImageResolver as C, type DeckSnapshot as D, type EditProfile as E, type PlaceholderPrimitive as F, type GeometryPathCommand as G, type HeaderFooterSettings as H, type ImageCrop as I, type PositionedGlyph as J, type PositionedTextLine as K, type LayoutProfile as L, type MarkdownAnchor as M, type PositionedTextRun as N, type OpenPresentationOptions as O, type PresentationImageDecodeOptions as P, type PptxAnchor as Q, type PptxAnchorScope as R, type PptxCaretAnchor as S, type PptxEditFailure as T, type PptxEditFailureCode as U, type PptxEditHistory as V, type PptxEditPreview as W, type PptxEditReceipt as X, type PptxEditRefusal as Y, type PptxEditRequest as Z, type PptxEditResult as _, type CaretStop as a, type ProposalPreview as a$, type PptxEditStep as a0, type PptxEditTarget as a1, type PptxExportComment as a2, type PptxExportDiagnostic as a3, type PptxExportDiagnosticCode as a4, PptxExportError as a5, type PptxExportFailure as a6, type PptxExportFailureCode as a7, type PptxExportList as a8, type PptxExportMark as a9, type PptxReadResult as aA, type PptxShapeTarget as aB, type PptxSlideTarget as aC, type PptxSourceProvenance as aD, type PptxStoryTarget as aE, type PptxStoryText as aF, type PptxStructuredContent as aG, type PptxTextField as aH, type PptxTextGuard as aI, type PptxTextMatch as aJ, type PptxTextRange as aK, type PptxTextSearchOptions as aL, type PptxTextSpan as aM, type PptxTextTarget as aN, type PptxValidationResult as aO, PptxWorkerEditorDisposedError as aP, type PresentationHandle as aQ, type PresetShapeDraft as aR, type PrimitiveTransform as aS, type Profiled as aT, type ProfiledLayout as aU, type Proposal as aV, type ProposalAcceptance as aW, type ProposalChange as aX, type ProposalDiffSlide as aY, type ProposalEdit as aZ, ProposalPictureMediaTooLargeError as a_, type PptxExportNotes as aa, type PptxExportObject as ab, type PptxExportObjectKind as ac, type PptxExportOptions as ad, type PptxExportParagraph as ae, type PptxExportRefusal as af, type PptxExportResult as ag, type PptxExportRun as ah, type PptxExportShape as ai, type PptxExportShapeKind as aj, type PptxExportSlide as ak, type PptxExportStory as al, type PptxExportTable as am, type PptxExportTableCell as an, type PptxFindMatch as ao, type PptxFindRequest as ap, type PptxFindResult as aq, type PptxFindScope as ar, type PptxFontFace as as, type PptxMarkdownContent as at, type PptxMarkdownOptions as au, type PptxParagraphText as av, PptxPeerNotReadyError as aw, type PptxPngOptions as ax, type PptxPngTarget as ay, type PptxReadRequest as az, type ChartData as b, paintSlide as b$, type ProposalShapeChange as b0, type ProposalStripEntry as b1, type ProposalTextChange as b2, type SavePresentationOptions as b3, type ShapeAdjustReceipt as b4, type ShapeAltText as b5, type ShapeDraft as b6, type ShapeFill as b7, type ShapeFillReceipt as b8, type ShapeGradient as b9, type TextBoxPrimitive as bA, type TextLanguage as bB, type TextLink as bC, type TextLinkTarget as bD, type TextParagraphDraft as bE, type TextReceipt as bF, type TextRunSnapshot as bG, type TextStyle as bH, type TextStylePatch as bI, type TextStyleSnapshot as bJ, type TransformReceipt as bK, type UndoCaptureMode as bL, type UpdateEvent as bM, type ValidationSuccess as bN, type WasmInitInput as bO, createPptxWorkerEditorSession as bP, decodeFontFace as bQ, exportPptxMarkdown as bR, exportPptxStructured as bS, initWasm as bT, inspectPresentation as bU, isProposalsAvailable as bV, isWasmAvailable as bW, metafileImageBytes as bX, needsElementDecode as bY, openPresentation as bZ, openPresentationSession as b_, type ShapeKind as ba, type ShapeLineEnd as bb, type ShapeOutline as bc, type ShapePrimitive as bd, type ShapeReceipt as be, type ShapeRect as bf, type ShapeSnapshot as bg, type ShapeStroke as bh, type ShapeStrokeReceipt as bi, type ShapeZOrderReceipt as bj, type SlideCanvasLike as bk, type SlideDateText as bl, type SlideDisplayList as bm, type SlideHeaderFooter as bn, type SlideHeaderFooterText as bo, type SlideLayoutSnapshot as bp, type SlidePrimitive as bq, type SlideReceipt as br, type SlideSnapshot as bs, StaleProposalError as bt, type StorySnapshot as bu, type Stroke as bv, type StrokeEnd as bw, type TableGrid as bx, type TableGridCell as by, type TableReceipt as bz, type ChartDataSeries as c, renderPptxMarkdown as c0, sizeCanvasForSlide as c1, wasmVersion as c2, type FontDecoder as c3, type PresentationSlideSummary as c4, type PresentationWireFrame as c5, SessionFailure as c6, type FontDecoderMethods as c7, type FontCdnConfiguration as c8, type PresentationSessionOpenOptions as c9, type OpenPresentationSessionOptions as ca, PptxWorkerEditorFailedError as cb, PptxPeerHydrationError as cc, type PptxWorkerEditorAccess as cd, PptxWorkerEditorCollaborationError as ce, type PptxWorkerEditorFrame as cf, type PptxWorkerEditorInteractionAccess as cg, type PptxWorkerEditorOperation as ch, type PptxWorkerEditorOptions as ci, type PptxWorkerEditorRecovery as cj, type PptxWorkerEditorReply as ck, type PptxWorkerEditorSession as cl, type PptxWorkerEditorStage as cm, type PptxWorkerEditorState as cn, type PresentationFrame as co, type PresentationSession as cp, type PresentationSessionEvents as cq, type PresentationSessionFont as cr, type PresentationSessionMethods as cs, type PresentationSessionState as ct, decodeBrowserPresentationImage as cu, presentationStoryFormatting as cv, type ColorTransform as d, type ColorValue as e, type CommentFlavor as f, type CommentReceipt as g, type CommentSnapshot as h, type EditSuccess as i, type ExportCompletion as j, type ExportDiagnostic as k, type ExportSeverity as l, type HistoryProfile as m, type HistoryResult as n, type HitTestResult as o, type ImageEffect as p, type ImagePrimitive as q, type InheritedGeometry as r, type InspectPresentationOptions as s, type OperationFailure as t, type OperationRefusal as u, type Paint as v, type PaintFontCoverage as w, type PaintSlideOptions as x, type ParagraphAlignment as y, type ParagraphSnapshot as z };
Binary file