pptx-ts 3.7.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -269
- package/dist/autopage-odPz7zZO.js +536 -0
- package/dist/autopage-odPz7zZO.js.map +1 -0
- package/dist/binary-string-CKVAYI3M.js +24 -0
- package/dist/binary-string-CKVAYI3M.js.map +1 -0
- package/dist/body-insets-Dw_BeWD_.js +54 -0
- package/dist/body-insets-Dw_BeWD_.js.map +1 -0
- package/dist/browser.d.ts +29 -9
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +41 -14
- package/dist/browser.js.map +1 -1
- package/dist/clip-Bl01BPcN.d.ts +67 -0
- package/dist/clip-Bl01BPcN.d.ts.map +1 -0
- package/dist/diagnostics-D8ot4Ei7.d.ts +244 -0
- package/dist/diagnostics-D8ot4Ei7.d.ts.map +1 -0
- package/dist/embedded-fonts-DarT9aoa.d.ts +20 -0
- package/dist/embedded-fonts-DarT9aoa.d.ts.map +1 -0
- package/dist/entry-compose-DCnvBZz2.d.ts +1046 -0
- package/dist/entry-compose-DCnvBZz2.d.ts.map +1 -0
- package/dist/{enums-CvRYniUA.d.ts → enums-BUKTUB6V.d.ts} +21 -13
- package/dist/{enums-CvRYniUA.d.ts.map → enums-BUKTUB6V.d.ts.map} +1 -1
- package/dist/{errors-Bvln0H-7.js → errors-C4oENPcu.js} +92 -2
- package/dist/errors-C4oENPcu.js.map +1 -0
- package/dist/families.d.ts +260 -0
- package/dist/families.d.ts.map +1 -0
- package/dist/families.js +57 -0
- package/dist/families.js.map +1 -0
- package/dist/{fit-BKs0zxMI.js → fit-Cb7naFj6.js} +249 -167
- package/dist/fit-Cb7naFj6.js.map +1 -0
- package/dist/font-metrics-v5fn7s7e.d.ts +613 -0
- package/dist/font-metrics-v5fn7s7e.d.ts.map +1 -0
- package/dist/grid-DikTjFey.js +187 -0
- package/dist/grid-DikTjFey.js.map +1 -0
- package/dist/{html-dom-B0I0QSbU.js → html-dom-Iuog2wdK.js} +121 -91
- package/dist/html-dom-Iuog2wdK.js.map +1 -0
- package/dist/html.d.ts +6 -6
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +7 -6
- package/dist/html.js.map +1 -1
- package/dist/image-size-CvN2iCA4.js +1611 -0
- package/dist/image-size-CvN2iCA4.js.map +1 -0
- package/dist/index.d.ts +24 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +40 -31
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +40 -48
- package/dist/inspect.js.map +1 -1
- package/dist/math.d.ts +7 -5
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +16 -7
- package/dist/math.js.map +1 -1
- package/dist/measure.d.ts +12 -225
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +3 -3
- package/dist/node.d.ts +22 -8
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +27 -7
- package/dist/node.js.map +1 -1
- package/dist/notes-Dh12JAbn.js +3264 -0
- package/dist/notes-Dh12JAbn.js.map +1 -0
- package/dist/options-internal-WqgMf720.js +43 -0
- package/dist/options-internal-WqgMf720.js.map +1 -0
- package/dist/{package-CaOLXSNi.d.ts → package-J49Ck6S2.d.ts} +27 -12
- package/dist/package-J49Ck6S2.d.ts.map +1 -0
- package/dist/playbtn-CUqQdoDf.js +22 -0
- package/dist/playbtn-CUqQdoDf.js.map +1 -0
- package/dist/{slide-ZqAdVvHV.d.ts → pres-C6qgOFAa.d.ts} +1021 -1423
- package/dist/pres-C6qgOFAa.d.ts.map +1 -0
- package/dist/{presentation-DrJtj3-C.js → presentation-DGYlAWhl.js} +3208 -2727
- package/dist/presentation-DGYlAWhl.js.map +1 -0
- package/dist/{presentation-types-CDjScsev.d.ts → presentation-types-8jLQHI4M.d.ts} +1070 -683
- package/dist/presentation-types-8jLQHI4M.d.ts.map +1 -0
- package/dist/read.d.ts +9 -9
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +4 -4
- package/dist/script.d.ts +80 -66
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +2399 -1139
- package/dist/script.js.map +1 -1
- package/dist/{shapes-BemroU-z.js → shapes-re0KyQk_.js} +2807 -1609
- package/dist/shapes-re0KyQk_.js.map +1 -0
- package/dist/slide-Dx2ZeVZ6.d.ts +1256 -0
- package/dist/slide-Dx2ZeVZ6.d.ts.map +1 -0
- package/dist/slide-size-BalTjFuv.js +88 -0
- package/dist/slide-size-BalTjFuv.js.map +1 -0
- package/dist/{units-internal-Dg95w_YD.js → table-cell-margins-EVg0EwxT.js} +235 -273
- package/dist/table-cell-margins-EVg0EwxT.js.map +1 -0
- package/dist/table-dom-BTDP3lEP.js +21 -0
- package/dist/table-dom-BTDP3lEP.js.map +1 -0
- package/dist/text-KnLOtEEu.js +3980 -0
- package/dist/text-KnLOtEEu.js.map +1 -0
- package/dist/text-anchor-CrYXAfUu.js +176 -0
- package/dist/text-anchor-CrYXAfUu.js.map +1 -0
- package/dist/transition-speed-kUEWDWTx.js +14 -0
- package/dist/transition-speed-kUEWDWTx.js.map +1 -0
- package/dist/units-internal-XJlf-hOl.js +649 -0
- package/dist/units-internal-XJlf-hOl.js.map +1 -0
- package/dist/zip-C0leZZMj.d.ts +67 -0
- package/dist/zip-C0leZZMj.d.ts.map +1 -0
- package/dist/zip-CKd8ihcf.js +177 -0
- package/dist/zip-CKd8ihcf.js.map +1 -0
- package/dist/zip.d.ts +3 -68
- package/dist/zip.js +3 -163
- package/dist/zoom-cX9sllpH.js +8865 -0
- package/dist/zoom-cX9sllpH.js.map +1 -0
- package/package.json +106 -19
- package/skills/ts-pptx-upstream/SKILL.md +58 -57
- package/dist/autopage-DkjYZUFD.js +0 -423
- package/dist/autopage-DkjYZUFD.js.map +0 -1
- package/dist/diagnostics-DfBdDHre.d.ts +0 -829
- package/dist/diagnostics-DfBdDHre.d.ts.map +0 -1
- package/dist/errors-Bvln0H-7.js.map +0 -1
- package/dist/errors-PflMPWBn.d.ts +0 -182
- package/dist/errors-PflMPWBn.d.ts.map +0 -1
- package/dist/fit-BKs0zxMI.js.map +0 -1
- package/dist/html-dom-B0I0QSbU.js.map +0 -1
- package/dist/namespaces-BVnNu7sg.js +0 -666
- package/dist/namespaces-BVnNu7sg.js.map +0 -1
- package/dist/notes-CJFJaG6M.js +0 -1724
- package/dist/notes-CJFJaG6M.js.map +0 -1
- package/dist/package-CaOLXSNi.d.ts.map +0 -1
- package/dist/pres-BcBR3CSM.d.ts +0 -202
- package/dist/pres-BcBR3CSM.d.ts.map +0 -1
- package/dist/presentation-DrJtj3-C.js.map +0 -1
- package/dist/presentation-types-CDjScsev.d.ts.map +0 -1
- package/dist/shapes-BemroU-z.js.map +0 -1
- package/dist/slide-ZqAdVvHV.d.ts.map +0 -1
- package/dist/text-B8SLEaZx.js +0 -11327
- package/dist/text-B8SLEaZx.js.map +0 -1
- package/dist/units-1kRzYShk.js +0 -231
- package/dist/units-1kRzYShk.js.map +0 -1
- package/dist/units-internal-Dg95w_YD.js.map +0 -1
- package/dist/zip.d.ts.map +0 -1
- package/dist/zip.js.map +0 -1
|
@@ -1,829 +0,0 @@
|
|
|
1
|
-
import { f as SHAPE_NAME, h as SlideObjectType, i as CHART_NAME, s as ChartType, y as WRITE_OUTPUT_TYPE } from "./enums-CvRYniUA.js";
|
|
2
|
-
import { $t as MeasureTextOptions, Ct as ChartOpts, K as Margin, Kt as OptsChartData, O as TableProps, P as BackgroundProps, St as ChartMulti, Y as PositionProps, Yt as ObjectLockProps, _ as SlideNumberProps, _n as MediaProps, a as Slide, dn as TextProps, g as SlideMasterProps, i as ObjectOptions, in as SlideComment, it as HyperlinkProps, k as TableRow, nn as OverflowBoxOptions, o as SlideLayout, on as TableLayoutResult, p as MasterTextStyleProps, t as AddSlideProps, un as TextMeasurement, vn as MediaType, w as TableCell, z as GeometryPoint } from "./slide-ZqAdVvHV.js";
|
|
3
|
-
import { c as WriteFileProps, d as ThemeProps, i as PresLayout, l as WriteProps, n as PackagePart, o as SectionProps, r as PartsProps, s as WriteBaseProps, t as CustomPropertyValue } from "./pres-BcBR3CSM.js";
|
|
4
|
-
import { a as ExtractedSlides, gn as EmbeddedFontSlot } from "./presentation-types-CDjScsev.js";
|
|
5
|
-
import { c as DiagnosticCode } from "./errors-PflMPWBn.js";
|
|
6
|
-
//#region src/types/zoom.d.ts
|
|
7
|
-
/** Options shared by all three zoom kinds. */
|
|
8
|
-
interface ZoomBaseProps extends PositionProps {
|
|
9
|
-
/** Object name (PowerPoint selection-pane label). Auto-named (e.g. `Slide Zoom 3`) when omitted. */
|
|
10
|
-
objectName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Ship a caller-supplied thumbnail instead of the gray placeholder — a raster image `path`
|
|
13
|
-
* (Node/local) or base64 `data:` URI. Shown as-authored (not auto-refreshed by PowerPoint).
|
|
14
|
-
*/
|
|
15
|
-
coverImage?: {
|
|
16
|
-
path?: string;
|
|
17
|
-
data?: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* After the zoom animates to its target, return to this (parent) slide when the target's
|
|
21
|
-
* content finishes. Maps to `zmPr@returnToParent`. Default `false`.
|
|
22
|
-
*/
|
|
23
|
-
returnToParent?: boolean;
|
|
24
|
-
/** Zoom transition duration in milliseconds (`zmPr@transitionDur`). Default `1000`. */
|
|
25
|
-
transitionDur?: number;
|
|
26
|
-
/**
|
|
27
|
-
* Object lock flags ({@link ObjectLockProps}), as `objectLock` on every other object type.
|
|
28
|
-
*
|
|
29
|
-
* A zoom is a `p:graphicFrame`, so these land on its `a:graphicFrameLocks` and the flags that
|
|
30
|
-
* apply are the graphic-frame ones (`noGrp`, `noDrilldown`, `noSelect`, `noChangeAspect`,
|
|
31
|
-
* `noMove`, `noResize`); a picture-only flag warns and is dropped, as everywhere else. The
|
|
32
|
-
* `mc:Fallback` picture keeps its own fixed lock set — it is what pre-2016 consumers draw, and
|
|
33
|
-
* folding a graphic-frame flag set onto a `a:picLocks` element would warn about every flag the
|
|
34
|
-
* two element types do not share.
|
|
35
|
-
*
|
|
36
|
-
* `noChangeAspect` is on by default (a zoom tile mirrors its target slide's aspect); pass it
|
|
37
|
-
* `false` to lift it.
|
|
38
|
-
* @example { noMove: true, noResize: true } // pin the tile in place
|
|
39
|
-
*/
|
|
40
|
-
objectLock?: ObjectLockProps;
|
|
41
|
-
}
|
|
42
|
-
/** Slide Zoom: a tile that zooms to a single target slide. */
|
|
43
|
-
interface SlideZoomProps extends ZoomBaseProps {
|
|
44
|
-
/** Target slide — a `Slide` returned by `addSlide()`, or its 1-based slide number. */
|
|
45
|
-
target: Slide | number;
|
|
46
|
-
}
|
|
47
|
-
/** Section Zoom: a tile that zooms to the start of a named section. */
|
|
48
|
-
interface SectionZoomProps extends ZoomBaseProps {
|
|
49
|
-
/** Title of the target section (as passed to `addSection({ title })`). */
|
|
50
|
-
sectionTitle: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Summary Zoom: a grid of tiles, one per section, that navigates to each section's start.
|
|
54
|
-
* The section containing the host slide is excluded (a summary does not link to itself).
|
|
55
|
-
*/
|
|
56
|
-
type SummaryZoomProps = ZoomBaseProps;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/types/internal.d.ts
|
|
59
|
-
interface OptsChartDataInternal extends OptsChartData {
|
|
60
|
-
labels?: string[][];
|
|
61
|
-
/** Series index; always assigned by addChartDefinition() before this internal shape is built. */
|
|
62
|
-
_dataIndex: number;
|
|
63
|
-
}
|
|
64
|
-
interface ChartOptsInternal extends ChartOpts {
|
|
65
|
-
_type?: ChartType | ChartMulti[];
|
|
66
|
-
}
|
|
67
|
-
interface SlideRelChart extends OptsChartData {
|
|
68
|
-
type: CHART_NAME | ChartMulti[];
|
|
69
|
-
opts: ChartOptsInternal;
|
|
70
|
-
data: OptsChartDataInternal[];
|
|
71
|
-
rId: number;
|
|
72
|
-
Target: string;
|
|
73
|
-
globalId: number;
|
|
74
|
-
fileName: string;
|
|
75
|
-
/**
|
|
76
|
-
* True when `type` is a chartEx (cx:) chart (e.g. waterfall): the part is emitted as
|
|
77
|
-
* `chartEx{globalId}.xml` in the chart-extension namespace, gets the `chartex+xml` content
|
|
78
|
-
* type and the MS `.../2014/relationships/chartEx` rel type, and is referenced from the slide
|
|
79
|
-
* via `<mc:AlternateContent>`. Set at define time from {@link isChartExType}.
|
|
80
|
-
*/
|
|
81
|
-
isChartEx?: boolean;
|
|
82
|
-
}
|
|
83
|
-
interface SlideRel {
|
|
84
|
-
type: SlideObjectType;
|
|
85
|
-
/**
|
|
86
|
-
* Relationship target, stored **unescaped**. Every emitter escapes it on the way out
|
|
87
|
-
* (`gen/slide/object.ts`, `gen/slide/notes.ts`, and `read/opc/relationships.ts` for the
|
|
88
|
-
* append path). Escaping at definition time instead would double-escape on append,
|
|
89
|
-
* where the serializer escapes again — so `&` in a hyperlink or online-video URL must
|
|
90
|
-
* arrive here verbatim.
|
|
91
|
-
*/
|
|
92
|
-
Target: string;
|
|
93
|
-
fileName?: string;
|
|
94
|
-
data: any[] | string;
|
|
95
|
-
opts?: ChartOpts;
|
|
96
|
-
path?: string;
|
|
97
|
-
extn?: string;
|
|
98
|
-
globalId?: number;
|
|
99
|
-
rId: number;
|
|
100
|
-
}
|
|
101
|
-
interface SlideRelMedia {
|
|
102
|
-
type: string;
|
|
103
|
-
opts?: MediaProps;
|
|
104
|
-
path?: string;
|
|
105
|
-
extn?: string;
|
|
106
|
-
data?: string | ArrayBuffer;
|
|
107
|
-
/** used to indicate that a media file has already been read/enocded (PERF) */
|
|
108
|
-
isDuplicate?: boolean;
|
|
109
|
-
isSvgPng?: boolean;
|
|
110
|
-
svgSize?: {
|
|
111
|
-
w: number;
|
|
112
|
-
h: number;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Embedded OLE object part (`addOleObject`): the `.rels` `Type` URI to emit — `.../package` for
|
|
116
|
-
* an embedded OPC package (xlsx/docx/pptx, themselves zips) or `.../oleObject` for a generic OLE
|
|
117
|
-
* server blob (ECMA-376 Part 1 §15.2.10). Present only on OLE payload rels, where it takes
|
|
118
|
-
* precedence over the image/audio/video branch in `slideObjectRelationsToXml` and `type` carries
|
|
119
|
-
* the part's content type verbatim for `[Content_Types].xml`. The object's preview picture is a
|
|
120
|
-
* separate, perfectly ordinary image rel.
|
|
121
|
-
*/
|
|
122
|
-
oleRelType?: string;
|
|
123
|
-
/**
|
|
124
|
-
* Embedded 3D model part (`addModel3d`): the `.rels` `Type` URI to emit — the Microsoft
|
|
125
|
-
* `…/office/2017/06/relationships/model3d` type, which no `includes('image'|'audio'|'video')`
|
|
126
|
-
* sniff would ever reach. Present only on the `.glb` payload rel, where it takes precedence
|
|
127
|
-
* over the image/audio/video branch in `slideObjectRelationsToXml` and `type` carries the
|
|
128
|
-
* part's content type verbatim for `[Content_Types].xml`. The model's preview picture is a
|
|
129
|
-
* separate, perfectly ordinary image rel. Same escape hatch as {@link oleRelType}.
|
|
130
|
-
*/
|
|
131
|
-
model3dRelType?: string;
|
|
132
|
-
rId: number;
|
|
133
|
-
/** Unescaped — see {@link SlideRel.Target}. Doubles as the zip entry name for embedded media. */
|
|
134
|
-
Target: string;
|
|
135
|
-
}
|
|
136
|
-
interface SlideObject {
|
|
137
|
-
_type: SlideObjectType;
|
|
138
|
-
options?: ObjectOptions;
|
|
139
|
-
text?: TextProps[];
|
|
140
|
-
arrTabRows?: TableCell[][];
|
|
141
|
-
chartRid?: number;
|
|
142
|
-
image?: string;
|
|
143
|
-
imageRid?: number;
|
|
144
|
-
hyperlink?: HyperlinkProps;
|
|
145
|
-
media?: string;
|
|
146
|
-
mtype?: MediaType;
|
|
147
|
-
mediaRid?: number;
|
|
148
|
-
loop?: boolean;
|
|
149
|
-
loopCount?: number;
|
|
150
|
-
shape?: SHAPE_NAME;
|
|
151
|
-
_groupObjects?: SlideObject[];
|
|
152
|
-
zoom?: ZoomInternal;
|
|
153
|
-
ole?: OleInternal;
|
|
154
|
-
model3d?: Model3dInternal;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Resolved 3D-model payload carried on a {@link SlideObject} until `gen/slide/objects/model3d.ts`
|
|
158
|
-
* emits it. Camera values are already in `am3d`'s wire units so the emitter does no arithmetic:
|
|
159
|
-
* positions in 1/36,000,000ths of a metre, `fov` in 60000ths of a degree, and
|
|
160
|
-
* `meterPerModelUnitN` over a fixed denominator of 1,000,000.
|
|
161
|
-
*/
|
|
162
|
-
interface Model3dInternal {
|
|
163
|
-
/** rId of the embedded `.glb` part rel (see {@link SlideRelMedia.model3dRelType}). */
|
|
164
|
-
modelRid: number;
|
|
165
|
-
/** rId of the preview picture's image rel — shared by `am3d:blip` and the `mc:Fallback` `p:pic`. */
|
|
166
|
-
previewRid: number;
|
|
167
|
-
/** `am3d:camera/am3d:pos` (`@x`/`@y`/`@z`). */
|
|
168
|
-
pos: {
|
|
169
|
-
x: number;
|
|
170
|
-
y: number;
|
|
171
|
-
z: number;
|
|
172
|
-
};
|
|
173
|
-
/** `am3d:camera/am3d:lookAt` (`@x`/`@y`/`@z`). */
|
|
174
|
-
lookAt: {
|
|
175
|
-
x: number;
|
|
176
|
-
y: number;
|
|
177
|
-
z: number;
|
|
178
|
-
};
|
|
179
|
-
/** `am3d:camera/am3d:up` (`@dx`/`@dy`/`@dz`). */
|
|
180
|
-
up: {
|
|
181
|
-
dx: number;
|
|
182
|
-
dy: number;
|
|
183
|
-
dz: number;
|
|
184
|
-
};
|
|
185
|
-
/** `am3d:perspective@fov`, in 60000ths of a degree. */
|
|
186
|
-
fov: number;
|
|
187
|
-
/** `am3d:meterPerModelUnit@n`; `@d` is always 1,000,000. */
|
|
188
|
-
meterPerModelUnitN: number;
|
|
189
|
-
}
|
|
190
|
-
/** Resolved OLE payload carried on a {@link SlideObject} until `gen/slide/objects/ole.ts` emits it. */
|
|
191
|
-
interface OleInternal {
|
|
192
|
-
/** rId of the embedded object part rel (see {@link SlideRelMedia.oleRelType}). */
|
|
193
|
-
objectRid: number;
|
|
194
|
-
/** rId of the preview picture's image rel (`p:pic > a:blip@r:embed`). */
|
|
195
|
-
previewRid: number;
|
|
196
|
-
/** `p:oleObj@progId` — the OLE server PowerPoint launches on double-click. */
|
|
197
|
-
progId: string;
|
|
198
|
-
/** `p:oleObj@name` — the object's kind as PowerPoint labels it (`Worksheet`, `Document`, …). */
|
|
199
|
-
name: string;
|
|
200
|
-
/** `p:oleObj@showAsIcon`; omitted when false, matching PowerPoint. */
|
|
201
|
-
showAsIcon: boolean;
|
|
202
|
-
/** `p:oleObj@imgW`/`@imgH` (EMU). Undefined means "use the frame's own extent". */
|
|
203
|
-
imgW?: number;
|
|
204
|
-
imgH?: number;
|
|
205
|
-
}
|
|
206
|
-
/** One tile inside a zoom object (a Slide/Section Zoom has one; a Summary Zoom has N). */
|
|
207
|
-
interface ZoomTileInternal {
|
|
208
|
-
/** Slide Zoom: target slide id (= `PresSlideInternal._slideId`, emitted as `sldZmObj@sldId`). */
|
|
209
|
-
sldId?: number;
|
|
210
|
-
/** Section/Summary Zoom: target section GUID (`{...}`, emitted as `sectionZmObj@sectionId`). */
|
|
211
|
-
sectionId?: string;
|
|
212
|
-
/** rId of the preview/cover image blip (`zmPr>blipFill>a:blip@r:embed`). Shared across tiles when identical. */
|
|
213
|
-
previewRid: number;
|
|
214
|
-
/** rId of the `.../slide` rel used by the `mc:Fallback` picture's `hlinkClick` (target/section-start slide). */
|
|
215
|
-
fallbackSlideRid: number;
|
|
216
|
-
/** Per-tile `zmPr@id` GUID (`{...}`). */
|
|
217
|
-
zmPrId: string;
|
|
218
|
-
/** Summary Zoom only: this tile's grid cell within the graphic-frame coordinate space (EMU). */
|
|
219
|
-
grid?: {
|
|
220
|
-
x: number;
|
|
221
|
-
y: number;
|
|
222
|
-
cx: number;
|
|
223
|
-
cy: number;
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
/** Resolved zoom payload carried on a {@link SlideObject} until `gen/slide/objects/zoom.ts` emits it. */
|
|
227
|
-
interface ZoomInternal {
|
|
228
|
-
variant: 'slide' | 'section' | 'summary';
|
|
229
|
-
tiles: ZoomTileInternal[];
|
|
230
|
-
/** `zmPr@returnToParent`; emitted as `"0"`/`"1"` for Slide Zoom, omitted for Section/Summary. */
|
|
231
|
-
returnToParent: boolean;
|
|
232
|
-
/** `zmPr@transitionDur` (ms). */
|
|
233
|
-
transitionDur: number;
|
|
234
|
-
}
|
|
235
|
-
interface SlideBaseProps {
|
|
236
|
-
_bkgdImgRid?: number;
|
|
237
|
-
_margin?: Margin;
|
|
238
|
-
_name?: string;
|
|
239
|
-
_presLayout: PresLayout;
|
|
240
|
-
_rels: SlideRel[];
|
|
241
|
-
_relsChart: SlideRelChart[];
|
|
242
|
-
_relsMedia: SlideRelMedia[];
|
|
243
|
-
_relsNotes?: SlideRel[];
|
|
244
|
-
_comments?: SlideComment[];
|
|
245
|
-
_txStyles?: MasterTextStyleProps;
|
|
246
|
-
_slideNum: number;
|
|
247
|
-
_slideNumberProps?: SlideNumberProps | null;
|
|
248
|
-
_slideObjects: SlideObject[];
|
|
249
|
-
/**
|
|
250
|
-
* Per-kind counters backing default Selection Pane names (`Shape 0`, `Image 1`, `Group 1`, …),
|
|
251
|
-
* keyed by `SlideObjectType`. Monotonic for the life of the slide: an object consumes its index
|
|
252
|
-
* when it is added, whether it stays top-level or is moved into a group's `_groupObjects`.
|
|
253
|
-
* Lazily created by `nextObjectNameIdx` (`gen/define/object-name.ts`).
|
|
254
|
-
*/
|
|
255
|
-
_objectNameCounts?: Partial<Record<SlideObjectType, number>>;
|
|
256
|
-
background?: BackgroundProps;
|
|
257
|
-
}
|
|
258
|
-
interface SlideLayoutInternal extends SlideBaseProps, SlideLayout {
|
|
259
|
-
_slide?: {
|
|
260
|
-
_bkgdImgRid?: number;
|
|
261
|
-
back: string;
|
|
262
|
-
color: string;
|
|
263
|
-
hidden?: boolean;
|
|
264
|
-
} | null;
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/runtime/types.d.ts
|
|
268
|
-
type RuntimeAdapter = {
|
|
269
|
-
readonly writeFileOutputType: WRITE_OUTPUT_TYPE | null;
|
|
270
|
-
/**
|
|
271
|
-
* Load a media file into a base64 payload for `rel.data`.
|
|
272
|
-
*
|
|
273
|
-
* **Two encodings are accepted, deliberately.** Either raw base64 (`iVBORw0…`) or a full
|
|
274
|
-
* data URI (`data:image/png;base64,iVBORw0…`). The browser adapter returns the second
|
|
275
|
-
* because `FileReader.readAsDataURL` is what decodes a blob without blocking; Node and the
|
|
276
|
-
* neutral adapter return the first because neither has a `FileReader`. So an adapter may
|
|
277
|
-
* return whichever its host makes cheap: `gen/media.ts` puts the result through
|
|
278
|
-
* {@link toMediaDataUri} on the way into `rel.data`, and everything past that point sees one
|
|
279
|
-
* form. Do not add a third: that helper recognizes exactly these two.
|
|
280
|
-
*/
|
|
281
|
-
loadMedia: (rel: SlideRelMedia & {
|
|
282
|
-
path: string;
|
|
283
|
-
}) => Promise<string>;
|
|
284
|
-
createSvgPngPreview: (rel: SlideRelMedia) => Promise<string>;
|
|
285
|
-
writeFile: (fileName: string, data: string | ArrayBuffer | Blob | Uint8Array) => Promise<string>;
|
|
286
|
-
/**
|
|
287
|
-
* Load a font file into raw bytes for `registerFontMetrics`.
|
|
288
|
-
*
|
|
289
|
-
* An `http:`/`https:` URL is fetched by every adapter. Anything else is a filesystem path,
|
|
290
|
-
* which only the Node adapter can read; elsewhere it is a load failure naming the path.
|
|
291
|
-
*/
|
|
292
|
-
loadFontData: (source: string) => Promise<Uint8Array>;
|
|
293
|
-
};
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region src/units.d.ts
|
|
296
|
-
/**
|
|
297
|
-
* Public unit conversion helpers and standard PowerPoint slide-layout constants.
|
|
298
|
-
*/
|
|
299
|
-
declare const EMU_PER_INCH = 914400;
|
|
300
|
-
declare const EMU_PER_POINT = 12700;
|
|
301
|
-
declare const POINTS_PER_INCH = 72;
|
|
302
|
-
/**
|
|
303
|
-
* DrawingML angle unit. `ST_Angle` (`rot`, shadow `dir`, gradient `ang`, …) is measured in
|
|
304
|
-
* sixtieths-of-a-thousandth of a degree, i.e. 60000 units per degree. Multiply a value in
|
|
305
|
-
* degrees by this to get the OOXML integer.
|
|
306
|
-
*/
|
|
307
|
-
declare const ANGLE_UNITS_PER_DEGREE = 60000;
|
|
308
|
-
/**
|
|
309
|
-
* DrawingML fixed-point percentage scale. `ST_Percentage` / `ST_PositiveFixedPercentage` and
|
|
310
|
-
* related types (`<a:alpha>`, `<a:spcPct>`, shape adjustment guides, `<p:tav tm>`, …) encode
|
|
311
|
-
* 100% as the integer 100000. Multiply a 0-1 fraction by this to get the OOXML value.
|
|
312
|
-
*/
|
|
313
|
-
declare const PERCENT_SCALE = 100000;
|
|
314
|
-
/**
|
|
315
|
-
* Scale for a percentage supplied as 0-100 (rather than a 0-1 fraction) into the same
|
|
316
|
-
* fixed-point percentage integer as {@link PERCENT_SCALE} (1% = 1000 units, i.e. thousandths
|
|
317
|
-
* of a percent). Use for inputs documented as percents: transparency/alpha, image crop insets,
|
|
318
|
-
* gradient stops, bullet size, connector adjust, etc.
|
|
319
|
-
*/
|
|
320
|
-
declare const FIXED_PCT_PER_PERCENT: number;
|
|
321
|
-
/**
|
|
322
|
-
* DrawingML text measures font size (`sz`), character spacing (`spc`) and point line/paragraph
|
|
323
|
-
* spacing (`<a:spcPts val>`) in hundredths of a point. Multiply a value in points by this to get
|
|
324
|
-
* the OOXML integer.
|
|
325
|
-
*/
|
|
326
|
-
declare const HUNDREDTHS_PER_POINT = 100;
|
|
327
|
-
/**
|
|
328
|
-
* Convert a value in points to hundredths of a point (rounded), the integer unit DrawingML uses
|
|
329
|
-
* for `sz`, `spc`, and `<a:spcPts val>`. See {@link HUNDREDTHS_PER_POINT}.
|
|
330
|
-
*/
|
|
331
|
-
declare function ptToHundredths(pt: number): number;
|
|
332
|
-
/**
|
|
333
|
-
* English Metric Units — the integer unit OOXML serializes geometry in (914400 per inch).
|
|
334
|
-
*
|
|
335
|
-
* Branded so a value that has already been resolved to EMU cannot be silently fed back into a
|
|
336
|
-
* unit converter: {@link coordToEmu} only accepts a user `Coord`, so passing an `Emu` into it is
|
|
337
|
-
* a compile-time error. This replaces the old runtime "a number ≥ 100 must already be EMU"
|
|
338
|
-
* magnitude guess, which silently mis-rendered values near the threshold.
|
|
339
|
-
*/
|
|
340
|
-
type Emu = number & {
|
|
341
|
-
readonly __unit: 'emu';
|
|
342
|
-
};
|
|
343
|
-
/** Default pixel density for the `"<n>px"` coordinate unit: CSS reference pixels, also the
|
|
344
|
-
* density ts-pptx assumes when reading an image header's pixel dimensions. */
|
|
345
|
-
declare const DEFAULT_PX_PER_INCH = 96;
|
|
346
|
-
type StandardLayoutName = 'LAYOUT_4x3' | 'LAYOUT_16x9' | 'LAYOUT_16x10' | 'LAYOUT_WIDE';
|
|
347
|
-
interface StandardLayout {
|
|
348
|
-
/** ts-pptx layout key used with `pptx.layout`. */
|
|
349
|
-
readonly layout: StandardLayoutName;
|
|
350
|
-
/** PresentationML slide-size preset name, or `custom` for PowerPoint widescreen. */
|
|
351
|
-
readonly name: string;
|
|
352
|
-
/** Slide width in inches — inches is ts-pptx's default coordinate unit, so this is the value to use for `addText`/`addShape` math. */
|
|
353
|
-
readonly widthIn: number;
|
|
354
|
-
/** Slide height in inches. */
|
|
355
|
-
readonly heightIn: number;
|
|
356
|
-
/** Slide width in English Metric Units. */
|
|
357
|
-
readonly widthEmu: number;
|
|
358
|
-
/** Slide height in English Metric Units. */
|
|
359
|
-
readonly heightEmu: number;
|
|
360
|
-
}
|
|
361
|
-
declare function inchesToEmu(inches: number): Emu;
|
|
362
|
-
declare function pointsToEmu(points: number): Emu;
|
|
363
|
-
declare function pixelsToEmu(pixels: number, dpi: number): Emu;
|
|
364
|
-
/**
|
|
365
|
-
* Resolve a percentage of an axis length to EMU.
|
|
366
|
-
* @param percent - percentage value (e.g. `50` for 50%)
|
|
367
|
-
* @param axisEmu - the axis length in EMU (slide width for x/w, height for y/h)
|
|
368
|
-
*/
|
|
369
|
-
declare function percentToEmu(percent: number, axisEmu: number): Emu;
|
|
370
|
-
/**
|
|
371
|
-
* The single user-coordinate → EMU boundary. Convert each user-supplied coordinate exactly once.
|
|
372
|
-
*
|
|
373
|
-
* Accepts (see {@link Coord}):
|
|
374
|
-
* - a bare `number` → **always inches** (the documented unit); no magnitude guessing
|
|
375
|
-
* - `"<n>%"` → percentage of `axisEmu`
|
|
376
|
-
* - `"<n>in"` / `"<n>pt"` / `"<n>px"` / `"<n>emu"` → explicit units (the escape hatch for non-inch
|
|
377
|
-
* values). `px` is resolved at {@link DEFAULT_PX_PER_INCH} (96), for authoring against a known
|
|
378
|
-
* web/source canvas size.
|
|
379
|
-
*
|
|
380
|
-
* Throws on non-finite or unparseable input rather than silently emitting a degenerate 0-size.
|
|
381
|
-
* @param value - user coordinate
|
|
382
|
-
* @param axisEmu - axis length in EMU, used only to resolve percentages
|
|
383
|
-
*/
|
|
384
|
-
declare function coordToEmu(value: number | string, axisEmu: number): Emu;
|
|
385
|
-
declare function emuToInches(emu: number): number;
|
|
386
|
-
declare function emuToPoints(emu: number): number;
|
|
387
|
-
declare function emuToPixels(emu: number, dpi: number): number;
|
|
388
|
-
declare const STANDARD_LAYOUTS: Readonly<Record<StandardLayoutName, StandardLayout>>;
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region src/presentation.d.ts
|
|
391
|
-
/**
|
|
392
|
-
* Main presentation class and package export flow — the public entry point consumers
|
|
393
|
-
* instantiate (`new TsPptx()`). Owns presentation-level state and metadata, collects
|
|
394
|
-
* slides, and drives `write`/`writeFile`/`stream`. The actual OOXML string building is
|
|
395
|
-
* delegated to the `gen-*` modules; runtime file/stream output goes through the injected
|
|
396
|
-
* `RuntimeAdapter`. Enums (`AlignH`, `ChartType`, `ShapeType`, …) are imported from the
|
|
397
|
-
* package entry, not read off the instance.
|
|
398
|
-
*
|
|
399
|
-
* Rough layout of the class body:
|
|
400
|
-
* - Metadata accessors layout / author / company / title / theme / sections getters+setters
|
|
401
|
-
* - Private slide helpers addNewSlide, getSlide, setSlideNumber
|
|
402
|
-
* - Public export methods stream / write / writeFile — delegate packaging to `writePackage`
|
|
403
|
-
* - Public authoring methods addSlide / defineLayout / defineSlideMaster / defineTableStyle
|
|
404
|
-
*
|
|
405
|
-
* Package assembly (`[Content_Types].xml`, the rels graph, per-part XML, the ZIP) lives in
|
|
406
|
-
* `package/assemble.ts`; this class provides the deck state via {@link PresentationCore.packageSource}.
|
|
407
|
-
* The live-DOM `tableToSlides()` is NOT here — it is added by the browser entry subclass
|
|
408
|
-
* (`browser.ts`) so it stays out of the Node build and out of the core chunk.
|
|
409
|
-
*/
|
|
410
|
-
declare class PresentationCore {
|
|
411
|
-
/**
|
|
412
|
-
* Presentation layout name
|
|
413
|
-
* Standard layouts:
|
|
414
|
-
* - 'LAYOUT_4x3' (10" x 7.5")
|
|
415
|
-
* - 'LAYOUT_16x9' (10" x 5.625")
|
|
416
|
-
* - 'LAYOUT_16x10' (10" x 6.25")
|
|
417
|
-
* - 'LAYOUT_WIDE' (13.333" x 7.5")
|
|
418
|
-
* Custom layouts:
|
|
419
|
-
* Use `pptx.defineLayout()` to create custom layouts (e.g.: 'A4')
|
|
420
|
-
* @type {string}
|
|
421
|
-
* @see https://support.office.com/en-us/article/Change-the-size-of-your-slides-040a811c-be43-40b9-8d04-0de5ed79987e
|
|
422
|
-
*/
|
|
423
|
-
private _layout;
|
|
424
|
-
set layout(value: string | StandardLayout);
|
|
425
|
-
get layout(): string;
|
|
426
|
-
/**
|
|
427
|
-
* ts-pptx Library Version
|
|
428
|
-
*/
|
|
429
|
-
private readonly _version;
|
|
430
|
-
get version(): string;
|
|
431
|
-
/**
|
|
432
|
-
* @type {string}
|
|
433
|
-
*/
|
|
434
|
-
private _author;
|
|
435
|
-
set author(value: string);
|
|
436
|
-
get author(): string;
|
|
437
|
-
/**
|
|
438
|
-
* @type {string}
|
|
439
|
-
*/
|
|
440
|
-
private _company;
|
|
441
|
-
set company(value: string);
|
|
442
|
-
get company(): string;
|
|
443
|
-
/**
|
|
444
|
-
* @type {string}
|
|
445
|
-
* @note the `revision` value must be a whole number only (without "." or "," - otherwise, PPT will throw errors upon opening!)
|
|
446
|
-
*/
|
|
447
|
-
private _revision;
|
|
448
|
-
set revision(value: string);
|
|
449
|
-
get revision(): string;
|
|
450
|
-
/**
|
|
451
|
-
* @type {string}
|
|
452
|
-
*/
|
|
453
|
-
private _subject;
|
|
454
|
-
set subject(value: string);
|
|
455
|
-
get subject(): string;
|
|
456
|
-
/**
|
|
457
|
-
* @type {ThemeProps}
|
|
458
|
-
*/
|
|
459
|
-
private _theme;
|
|
460
|
-
set theme(value: ThemeProps);
|
|
461
|
-
get theme(): ThemeProps;
|
|
462
|
-
/**
|
|
463
|
-
* @type {string}
|
|
464
|
-
*/
|
|
465
|
-
private _title;
|
|
466
|
-
set title(value: string);
|
|
467
|
-
get title(): string;
|
|
468
|
-
/** Slide number shown on the first slide (maps to firstSlideNum in presentation.xml) */
|
|
469
|
-
private _firstSlideNum;
|
|
470
|
-
set firstSlideNum(value: number);
|
|
471
|
-
get firstSlideNum(): number;
|
|
472
|
-
/**
|
|
473
|
-
* Whether Right-to-Left (RTL) mode is enabled
|
|
474
|
-
* @type {boolean}
|
|
475
|
-
*/
|
|
476
|
-
private _rtlMode;
|
|
477
|
-
set rtlMode(value: boolean);
|
|
478
|
-
get rtlMode(): boolean;
|
|
479
|
-
/** master slide layout object */
|
|
480
|
-
private readonly _masterSlide;
|
|
481
|
-
get masterSlide(): Slide;
|
|
482
|
-
/** this Presentation's Slide objects */
|
|
483
|
-
private readonly _slides;
|
|
484
|
-
get slides(): Slide[];
|
|
485
|
-
/** this Presentation's sections */
|
|
486
|
-
private readonly _sections;
|
|
487
|
-
get sections(): SectionProps[];
|
|
488
|
-
/** custom document properties stored in docProps/custom.xml */
|
|
489
|
-
private _customProperties;
|
|
490
|
-
/**
|
|
491
|
-
* slide layout definition objects, used for generating slide layout files.
|
|
492
|
-
* `protected` (not `private`) so the browser entry subclass can resolve
|
|
493
|
-
* `tableToSlides({ masterTitle })` against them — that method lives on the
|
|
494
|
-
* browser build only (it reads a live DOM), see `browser.ts`.
|
|
495
|
-
*/
|
|
496
|
-
protected readonly _slideLayouts: SlideLayoutInternal[];
|
|
497
|
-
get slideLayouts(): SlideLayout[];
|
|
498
|
-
private get internalPresentation();
|
|
499
|
-
private LAYOUTS;
|
|
500
|
-
private _presLayout;
|
|
501
|
-
get presLayout(): PresLayout;
|
|
502
|
-
private readonly _runtime;
|
|
503
|
-
/** Write-side font metrics for measured text fit (`fit:'shrink'`). @see registerFontMetrics */
|
|
504
|
-
private readonly _fontMetrics;
|
|
505
|
-
/** Author-side embedded font faces, accumulated by {@link embedFont} and emitted at write time. */
|
|
506
|
-
private readonly _embeddedFonts;
|
|
507
|
-
constructor(runtime: RuntimeAdapter);
|
|
508
|
-
/**
|
|
509
|
-
* Provides an API for `addTableDefinition` to create slides as needed for auto-paging
|
|
510
|
-
* @param {AddSlideProps} options - slide masterTitle and/or sectionTitle
|
|
511
|
-
* @return {Slide} new Slide
|
|
512
|
-
*/
|
|
513
|
-
private readonly addNewSlide;
|
|
514
|
-
/**
|
|
515
|
-
* Provides an API for `addTableDefinition` to get slide reference by number
|
|
516
|
-
* @param {number} slideNum - slide number
|
|
517
|
-
* @return {Slide} Slide
|
|
518
|
-
*/
|
|
519
|
-
private readonly getSlide;
|
|
520
|
-
/**
|
|
521
|
-
* Provides the live section list to the `Slide` class so Section/Summary Zoom can resolve
|
|
522
|
-
* a section title to its stable GUID and enumerate sections in order.
|
|
523
|
-
* @return {SectionInternalProps[]} the presentation's sections
|
|
524
|
-
*/
|
|
525
|
-
private readonly getSections;
|
|
526
|
-
/**
|
|
527
|
-
* Enables the `Slide` class to set ts-pptx [Presentation] master/layout slidenumbers
|
|
528
|
-
* @param {SlideNumberProps} slideNum - slide number config
|
|
529
|
-
*/
|
|
530
|
-
private readonly setSlideNumber;
|
|
531
|
-
/**
|
|
532
|
-
* Assemble the slice of internal state the packaging layer reads. `PresentationCore` owns the
|
|
533
|
-
* authored deck; `writePackage` (in `package/assemble.ts`) turns it into OOXML parts.
|
|
534
|
-
*/
|
|
535
|
-
private packageSource;
|
|
536
|
-
/**
|
|
537
|
-
* Author + serialize this presentation's slides as injectable descriptors,
|
|
538
|
-
* WITHOUT producing a `.pptx` package. Runs the same media-encode, placeholder
|
|
539
|
-
* backfill, and measured-fit passes `write()` uses, then serializes each slide
|
|
540
|
-
* body and resolves its image media to decoded bytes — so a loaded deck can
|
|
541
|
-
* splice the slides in via `Presentation.appendSlides()` (see `ts-pptx/read`)
|
|
542
|
-
* while keeping its own masters/layouts/theme byte-identical.
|
|
543
|
-
*
|
|
544
|
-
* Returns the deck's slide size (EMU, for the destination size check) and one
|
|
545
|
-
* descriptor per authored slide. Charts, audio/video media, online media, and
|
|
546
|
-
* internal slide-to-slide hyperlinks are surfaced as descriptors alongside the
|
|
547
|
-
* serialized body — this method does not resolve them into a package; the append
|
|
548
|
-
* path consumes each descriptor to reserve the parts and rebuild the rel graph.
|
|
549
|
-
*/
|
|
550
|
-
extractSlides: (opts?: {
|
|
551
|
-
onMediaError?: 'throw' | 'placeholder';
|
|
552
|
-
}) => Promise<ExtractedSlides>;
|
|
553
|
-
/**
|
|
554
|
-
* Register a font's metrics so `fit:'shrink'` text boxes are measured and a real
|
|
555
|
-
* `fontScale` is baked at export time (text renders pre-shrunk in headless
|
|
556
|
-
* renderers and on plain file-open, with no manual edit/resize).
|
|
557
|
-
*
|
|
558
|
-
* Without registered metrics, `fit:'shrink'` keeps its current behavior (a bare
|
|
559
|
-
* `<a:normAutofit/>` that only PowerPoint recomputes on edit). Register the same
|
|
560
|
-
* face once per weight/style you use; bold/italic advances differ.
|
|
561
|
-
*
|
|
562
|
-
* **Font collections** (`.ttc`/`.otc`, how MS Gothic, Yu Gothic, SimSun, Microsoft
|
|
563
|
-
* YaHei and Cambria ship on Windows) hold several fonts in one file, so one has to be
|
|
564
|
-
* chosen. With no `font` option, `face` is used as the selector, which is usually what
|
|
565
|
-
* you meant; a `face` that names no font in the collection throws rather than falling
|
|
566
|
-
* back to the first, since measuring the wrong member is invisible downstream. Pass
|
|
567
|
-
* `font` when the deck-side name differs from the name inside the file, and use
|
|
568
|
-
* `listFontFaces` from `ts-pptx/measure` to see what a file holds.
|
|
569
|
-
* @param {string} face - font family name as used in `fontFace` (e.g. 'Aptos')
|
|
570
|
-
* @param {string | Uint8Array | ArrayBuffer} source - font file path/URL (Node/web) or raw TTF/OTF/TTC bytes
|
|
571
|
-
* @param {object} [opts] - variant flags (advances differ per weight/style) and collection selection
|
|
572
|
-
* @param {boolean} [opts.bold] - these are the bold advances
|
|
573
|
-
* @param {boolean} [opts.italic] - these are the italic advances
|
|
574
|
-
* @param {number | string} [opts.font] - which font inside a collection: 0-based index, or a name
|
|
575
|
-
* @example await pptx.registerFontMetrics('Aptos', '/usr/share/fonts/Aptos.ttf')
|
|
576
|
-
* @example await pptx.registerFontMetrics('Aptos', aptosBoldBytes, { bold: true })
|
|
577
|
-
* @example await pptx.registerFontMetrics('MS PGothic', 'C:/Windows/Fonts/msgothic.ttc')
|
|
578
|
-
* @example await pptx.registerFontMetrics('Cambria Math', 'C:/Windows/Fonts/cambria.ttc', { font: 1 })
|
|
579
|
-
*/
|
|
580
|
-
registerFontMetrics(face: string, source: string | Uint8Array | ArrayBuffer, opts?: {
|
|
581
|
-
bold?: boolean;
|
|
582
|
-
italic?: boolean;
|
|
583
|
-
font?: number | string;
|
|
584
|
-
}): Promise<void>;
|
|
585
|
-
/**
|
|
586
|
-
* Embed a font face so the deck renders with it even on machines that do not
|
|
587
|
-
* have it installed. The **whole** face is embedded (not glyph-subset) under
|
|
588
|
-
* `/ppt/fonts/` and wired into `presentation.xml` (`p:embeddedFontLst` +
|
|
589
|
-
* `embedTrueTypeFonts="1"`), exactly as PowerPoint's "Embed fonts in the file"
|
|
590
|
-
* does. Call once per face/weight you use.
|
|
591
|
-
*
|
|
592
|
-
* The declared `typeface` MUST match the family name used in your run/`fontFace`
|
|
593
|
-
* typefaces (e.g. `addText('hi', { fontFace: 'Silkscreen' })`) or PowerPoint
|
|
594
|
-
* will not bind the embedded bytes to the text. Repeated calls with the same
|
|
595
|
-
* `typeface` and different `style` accumulate into one `p:embeddedFont` entry.
|
|
596
|
-
*
|
|
597
|
-
* Font licensing is the caller's responsibility: the bytes are embedded as
|
|
598
|
-
* handed over; `OS/2.fsType` embedding-permission bits are not enforced.
|
|
599
|
-
* @param {object} opts - font source + identity
|
|
600
|
-
* @param {string} [opts.path] - font file path (Node) or URL (web) to a `.ttf`/`.otf`
|
|
601
|
-
* @param {ArrayBuffer | Uint8Array | string} [opts.data] - raw font bytes, or a base64 string, in lieu of `path`
|
|
602
|
-
* @param {string} opts.typeface - family name as referenced by run/`fontFace` typefaces
|
|
603
|
-
* @param {EmbeddedFontSlot} [opts.style] - face slot; defaults to `'regular'`
|
|
604
|
-
* @example await pptx.embedFont({ path: '/fonts/Silkscreen-Regular.ttf', typeface: 'Silkscreen' })
|
|
605
|
-
* @example await pptx.embedFont({ path: '/fonts/Silkscreen-Bold.ttf', typeface: 'Silkscreen', style: 'bold' })
|
|
606
|
-
*/
|
|
607
|
-
embedFont(opts: {
|
|
608
|
-
path?: string;
|
|
609
|
-
data?: ArrayBuffer | Uint8Array | string;
|
|
610
|
-
typeface: string;
|
|
611
|
-
style?: EmbeddedFontSlot;
|
|
612
|
-
}): Promise<void>;
|
|
613
|
-
/**
|
|
614
|
-
* Measure how tall text wraps at a given width, using the **same** calibrated wrap
|
|
615
|
-
* model the export-time autofit bake uses — so a layout-time prediction matches the
|
|
616
|
-
* value `fit:'shrink'`/`'resize'` would bake. Synchronous: register the face's metrics
|
|
617
|
-
* first with {@link TsPptx.registerFontMetrics} (lookup is sync).
|
|
618
|
-
*
|
|
619
|
-
* Lets a consumer size its own geometry before export — grow a card to fit its text,
|
|
620
|
-
* reflow a grid, or detect overflow at layout time. Heights err **tall** (conservative),
|
|
621
|
-
* so the returned height is ≥ what PowerPoint/LibreOffice render.
|
|
622
|
-
* @param {string | TextProps[]} text - a string or run array (per-run options override the defaults in `opts`)
|
|
623
|
-
* @param {MeasureTextOptions} opts - width (inches), font size/face (points), and spacing
|
|
624
|
-
* @returns {TextMeasurement} laid-out height + line count + fit helpers
|
|
625
|
-
* @example const m = pptx.measureText('Long heading…', { wIn: 3, fontSize: 18, fontFace: 'Aptos' })
|
|
626
|
-
* @example if (pptx.measureText(runs, { wIn, fontSize, fontFace }).heightIn > cardHeightIn) growCard()
|
|
627
|
-
*/
|
|
628
|
-
measureText(text: string | TextProps[], opts: MeasureTextOptions): TextMeasurement;
|
|
629
|
-
/**
|
|
630
|
-
* Convenience overflow check: `true` if `text` does not fit a box of inner size
|
|
631
|
-
* `wIn`×`hIn` (inches) at full size. Because the model errs tall, this is a
|
|
632
|
-
* **conservative** (slightly over-reporting) check — appropriate for a build-time
|
|
633
|
-
* warning, not a hard gate. An unmeasurable (unnamed theme-default) face reports
|
|
634
|
-
* `false` (no overflow) so the linter does not false-positive on faces it cannot measure.
|
|
635
|
-
* @param {string | TextProps[]} text - a string or run array
|
|
636
|
-
* @param {OverflowBoxOptions} opts - {@link MeasureTextOptions} plus the box inner height `hIn`
|
|
637
|
-
* @returns {boolean} true if the text overflows the box
|
|
638
|
-
*/
|
|
639
|
-
overflowsBox(text: string | TextProps[], opts: OverflowBoxOptions): boolean;
|
|
640
|
-
/**
|
|
641
|
-
* Compute the per-cell geometry of a table laid out at `opts.x`/`y`/`w`, without
|
|
642
|
-
* adding it to a slide — so a consumer can place images or shapes precisely over
|
|
643
|
-
* cells. Column widths (cell `x`/`w`) are exact, derived from the same logic the
|
|
644
|
-
* writer uses. Row heights (`y`/`h`) are exact when pinned by `rowH` (array or
|
|
645
|
-
* scalar) or table `h`; an auto-height row is estimated with the same conservative
|
|
646
|
-
* (tall) text model as {@link TsPptx.measureText} and flagged `heightExact:false`
|
|
647
|
-
* (register the cell font via {@link TsPptx.registerFontMetrics} for an exact
|
|
648
|
-
* estimate). Geometry is for a single, un-paginated table — `autoPage` paging is
|
|
649
|
-
* not modeled.
|
|
650
|
-
* @param {TableRow[]} rows - the same `rows` passed to `slide.addTable`
|
|
651
|
-
* @param {TableProps} opts - the same table options (`x`, `y`, `w`, `colW`, `rowH`, `h`, …)
|
|
652
|
-
* @returns {TableLayoutResult} per-cell rectangles (inches) plus overall table bounds
|
|
653
|
-
* @example
|
|
654
|
-
* const g = pptx.tableLayout(rows, { x: 1, y: 1, w: 8, colW: [2, 3, 3] })
|
|
655
|
-
* const c = g.cells.find(c => c.row === 0 && c.col === 2)
|
|
656
|
-
* slide.addImage({ path: 'logo.png', x: c.xIn, y: c.yIn, w: c.wIn, h: c.hIn })
|
|
657
|
-
*/
|
|
658
|
-
tableLayout(rows: TableRow[], opts: TableProps): TableLayoutResult;
|
|
659
|
-
/**
|
|
660
|
-
* Export the current presentation as portable ZIP bytes. Unlike the former
|
|
661
|
-
* `stream()` method, this does not imply incremental output or convert the
|
|
662
|
-
* archive to a Node `Buffer`: package assembly is synchronous and the returned
|
|
663
|
-
* `Uint8Array` works unchanged in Node, browsers, and workers.
|
|
664
|
-
* @param {WriteBaseProps} props - output properties
|
|
665
|
-
* @returns {Promise<Uint8Array>} complete `.pptx` archive bytes
|
|
666
|
-
*/
|
|
667
|
-
toBytes(props?: WriteBaseProps): Promise<Uint8Array>;
|
|
668
|
-
/**
|
|
669
|
-
* Export the current Presentation as ZIP content with the selected type
|
|
670
|
-
* @param {WriteProps} props output properties
|
|
671
|
-
* @returns {Promise<string | ArrayBuffer | Blob | Uint8Array>} file content in selected type
|
|
672
|
-
*/
|
|
673
|
-
write(props?: WriteProps): Promise<string | ArrayBuffer | Blob | Uint8Array>;
|
|
674
|
-
/**
|
|
675
|
-
* Assemble the current Presentation into its OOXML package parts WITHOUT zipping — the raw
|
|
676
|
-
* `path → bytes` contents `write()` would compress into the `.pptx`. Use this to stream parts
|
|
677
|
-
* into a custom container, inspect individual parts, or feed a pipeline that does its own
|
|
678
|
-
* archiving. To produce a real `.pptx` file, use {@link write} / {@link writeFile} instead.
|
|
679
|
-
*
|
|
680
|
-
* The returned parts are byte-identical, per part, to what `write()` emits for the same deck,
|
|
681
|
-
* and their order is the package's emission order. Both are a stability-guaranteed observable
|
|
682
|
-
* contract: adding a new part in a later release is backward-compatible as long as existing
|
|
683
|
-
* part paths and their relative order do not shift; renaming or reordering an existing part is
|
|
684
|
-
* a breaking change. Each call returns fresh `Uint8Array` views over per-call buffers (a new
|
|
685
|
-
* assembly runs each time), so callers may retain or transfer them without defensive copying.
|
|
686
|
-
* @param {PartsProps} props - assembly options (`onMediaError` only; compression/output shape
|
|
687
|
-
* are zip concerns that do not apply to unzipped parts)
|
|
688
|
-
* @returns {Promise<PackagePart[]>} the package parts in emission order
|
|
689
|
-
*/
|
|
690
|
-
toParts(props?: PartsProps): Promise<PackagePart[]>;
|
|
691
|
-
/**
|
|
692
|
-
* Export the current Presentation.
|
|
693
|
-
* Write the generated presentation to disk (Node) or trigger a download (browser).
|
|
694
|
-
* @param {WriteFileProps} props - output file properties
|
|
695
|
-
* @returns {Promise<string>} the presentation name
|
|
696
|
-
*/
|
|
697
|
-
writeFile(props?: WriteFileProps): Promise<string>;
|
|
698
|
-
/**
|
|
699
|
-
* Set a custom document property stored in `docProps/custom.xml`.
|
|
700
|
-
* Calling with the same name replaces the existing value.
|
|
701
|
-
* @param name - property name
|
|
702
|
-
* @param value - string, integer/float number, boolean, or Date
|
|
703
|
-
*/
|
|
704
|
-
setCustomProperty(name: string, value: CustomPropertyValue): void;
|
|
705
|
-
/**
|
|
706
|
-
* Add a new Section to Presentation
|
|
707
|
-
* @param {SectionProps} section - section properties
|
|
708
|
-
* @example pptx.addSection({ title:'Charts' });
|
|
709
|
-
*/
|
|
710
|
-
addSection(section: SectionProps): void;
|
|
711
|
-
/**
|
|
712
|
-
* Add a new Slide to Presentation
|
|
713
|
-
* @param {AddSlideProps} options - slide options
|
|
714
|
-
* @returns {Slide} the new Slide
|
|
715
|
-
*/
|
|
716
|
-
addSlide(options?: AddSlideProps): Slide;
|
|
717
|
-
/**
|
|
718
|
-
* Create a custom Slide Layout in any size
|
|
719
|
-
* @param {PresLayout} layout - layout properties
|
|
720
|
-
* @example pptx.defineLayout({ name:'A3', width:16.5, height:11.7 });
|
|
721
|
-
*/
|
|
722
|
-
defineLayout(layout: PresLayout): void;
|
|
723
|
-
/**
|
|
724
|
-
* Create a new slide master [layout] for the Presentation
|
|
725
|
-
* @param {SlideMasterProps} props - layout properties
|
|
726
|
-
*/
|
|
727
|
-
defineSlideMaster(props: SlideMasterProps): void;
|
|
728
|
-
}
|
|
729
|
-
//#endregion
|
|
730
|
-
//#region src/clip.d.ts
|
|
731
|
-
/**
|
|
732
|
-
* Which edge of the box is the half-disc's FLAT side; the arc bulges toward the opposite edge.
|
|
733
|
-
* `'right'` = flat right edge, arc bulging left.
|
|
734
|
-
*/
|
|
735
|
-
type FlatSide = 'left' | 'right';
|
|
736
|
-
/**
|
|
737
|
-
* Which half-disc proportion to trace. Both are flat-on-one-edge, bulging half-discs whose arc
|
|
738
|
-
* reaches the opposite edge near mid-height; they differ only in how far the arc reaches.
|
|
739
|
-
* - `'deep'` — the arc spans about 32% of the box width, symmetric about mid-height (the default).
|
|
740
|
-
* - `'shallow'` — the arc spans about 13%, slightly asymmetric, with its apex just below mid-height.
|
|
741
|
-
*/
|
|
742
|
-
type HalfDiscPreset = 'deep' | 'shallow';
|
|
743
|
-
/** A named clip silhouette, resolved to a `points` path by {@link clipPath}. */
|
|
744
|
-
type ClipShape =
|
|
745
|
-
/**
|
|
746
|
-
* A rectangle with one side replaced by an elliptical arc that bulges toward the opposite
|
|
747
|
-
* edge, reaching it near mid-height — the "D" a picture placeholder cuts on a cover slide.
|
|
748
|
-
*/
|
|
749
|
-
{
|
|
750
|
-
kind: 'half-disc';
|
|
751
|
-
flat: FlatSide;
|
|
752
|
-
preset?: HalfDiscPreset;
|
|
753
|
-
};
|
|
754
|
-
/**
|
|
755
|
-
* Resolve a {@link ClipShape} to a freeform `points` path filling a `w × h` box, ready to hand
|
|
756
|
-
* to `addImage({ points })`.
|
|
757
|
-
*
|
|
758
|
-
* `w`/`h` are the image box's size **in inches** and must match the `w`/`h` the picture is drawn
|
|
759
|
-
* at — the path is emitted in the box's own coordinate space, not normalized (see the module
|
|
760
|
-
* note above).
|
|
761
|
-
* @param {ClipShape} shape - the named silhouette and its options
|
|
762
|
-
* @param {number} w - image box width (inches)
|
|
763
|
-
* @param {number} h - image box height (inches)
|
|
764
|
-
* @returns {GeometryPoint[]} the freeform path, for `addImage({ points })`
|
|
765
|
-
* @example
|
|
766
|
-
* const w = 5.22, h = 7.5
|
|
767
|
-
* slide.addImage({
|
|
768
|
-
* path: 'cover.jpg', x: 0, y: 0, w, h,
|
|
769
|
-
* points: clipPath({ kind: 'half-disc', flat: 'right' }, w, h),
|
|
770
|
-
* sizing: { type: 'cover' }, // center-crop the photo into the "D"
|
|
771
|
-
* })
|
|
772
|
-
*/
|
|
773
|
-
declare function clipPath(shape: ClipShape, w: number, h: number): GeometryPoint[];
|
|
774
|
-
//#endregion
|
|
775
|
-
//#region src/diagnostics.d.ts
|
|
776
|
-
/** One diagnostic emitted by the library. */
|
|
777
|
-
interface Diagnostic {
|
|
778
|
-
/** Stable condition identifier — see {@link DiagnosticCode}. Branch on this, not on the text. */
|
|
779
|
-
readonly code: DiagnosticCode;
|
|
780
|
-
/** Human-readable explanation. Free to change in any release; do not parse it. */
|
|
781
|
-
readonly message: string;
|
|
782
|
-
/**
|
|
783
|
-
* Structured context for the condition, when a site has any to give. No site populates it
|
|
784
|
-
* today; it exists so one can start to without a breaking signature change.
|
|
785
|
-
*/
|
|
786
|
-
readonly detail?: Readonly<Record<string, unknown>>;
|
|
787
|
-
}
|
|
788
|
-
/** Receives every {@link Diagnostic} the library emits. See {@link setDiagnosticHandler}. */
|
|
789
|
-
type DiagnosticHandler = (diagnostic: Diagnostic) => void;
|
|
790
|
-
/**
|
|
791
|
-
* Route every library diagnostic to `handler`, or pass `null` to restore the default
|
|
792
|
-
* (one prefixed `console.warn` per diagnostic).
|
|
793
|
-
*
|
|
794
|
-
* This is process-global rather than per-presentation, deliberately: the emitting code is a tree
|
|
795
|
-
* of free functions in `gen/**` with no presentation in scope, and threading a handler through
|
|
796
|
-
* every signature would be a far larger and worse change than the problem warrants. The practical
|
|
797
|
-
* consequence is that a process building several decks concurrently cannot attribute a diagnostic
|
|
798
|
-
* to one of them; if that matters, correlate on `code` or set the handler around each build.
|
|
799
|
-
*
|
|
800
|
-
* A throwing handler propagates out of whatever library call emitted the diagnostic, which is the
|
|
801
|
-
* supported way to make a specific condition fatal:
|
|
802
|
-
*
|
|
803
|
-
* ```ts
|
|
804
|
-
* setDiagnosticHandler((d) => {
|
|
805
|
-
* if (d.code === 'coord/bare-number-is-inches') throw new Error(d.message)
|
|
806
|
-
* })
|
|
807
|
-
* ```
|
|
808
|
-
* @param next - the receiver, or `null` to restore the console default
|
|
809
|
-
*/
|
|
810
|
-
declare function setDiagnosticHandler(next: DiagnosticHandler | null): void;
|
|
811
|
-
/**
|
|
812
|
-
* Clear the {@link warnOnce} dedupe set, so a condition already reported reports again.
|
|
813
|
-
*
|
|
814
|
-
* Call it between builds in a host that builds more than one deck per process and wants each
|
|
815
|
-
* build's diagnostics complete. Without it, deck two is silent about anything deck one already
|
|
816
|
-
* warned for, which reads as "no problems found" rather than as "already mentioned".
|
|
817
|
-
*
|
|
818
|
-
* It also bounds the set. Most `warnOnce` messages interpolate the offending value, so a server
|
|
819
|
-
* building decks from user input accumulates one entry per distinct bad value with no way to
|
|
820
|
-
* release them.
|
|
821
|
-
*
|
|
822
|
-
* This does not touch the handler — {@link setDiagnosticHandler} owns that, and the two are
|
|
823
|
-
* reset independently on purpose: a host usually installs its handler once and wants it to
|
|
824
|
-
* survive.
|
|
825
|
-
*/
|
|
826
|
-
declare function resetDiagnosticState(): void;
|
|
827
|
-
//#endregion
|
|
828
|
-
export { ptToHundredths as A, emuToInches as C, percentToEmu as D, inchesToEmu as E, SlideZoomProps as M, SummaryZoomProps as N, pixelsToEmu as O, ZoomBaseProps as P, coordToEmu as S, emuToPoints as T, PERCENT_SCALE as _, ClipShape as a, StandardLayout as b, clipPath as c, DEFAULT_PX_PER_INCH as d, EMU_PER_INCH as f, HUNDREDTHS_PER_POINT as g, FIXED_PCT_PER_PERCENT as h, setDiagnosticHandler as i, SectionZoomProps as j, pointsToEmu as k, PresentationCore as l, Emu as m, DiagnosticHandler as n, FlatSide as o, EMU_PER_POINT as p, resetDiagnosticState as r, HalfDiscPreset as s, Diagnostic as t, ANGLE_UNITS_PER_DEGREE as u, POINTS_PER_INCH as v, emuToPixels as w, StandardLayoutName as x, STANDARD_LAYOUTS as y };
|
|
829
|
-
//# sourceMappingURL=diagnostics-DfBdDHre.d.ts.map
|