@shbernal/ts-pptx 4.1.0 → 5.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 +11 -11
- package/dist/anim-presets-Qbgh8uut.js +55 -0
- package/dist/anim-presets-Qbgh8uut.js.map +1 -0
- package/dist/{autopage-D4kyVp11.js → autopage-DqZ37VpL.js} +11 -12
- package/dist/autopage-DqZ37VpL.js.map +1 -0
- package/dist/{binary-string-CKVAYI3M.js → binary-string-Ba8VM3b9.js} +3 -4
- package/dist/binary-string-Ba8VM3b9.js.map +1 -0
- package/dist/{body-insets-kVHmjGc6.js → body-insets-BDHymJvz.js} +7 -9
- package/dist/body-insets-BDHymJvz.js.map +1 -0
- package/dist/browser.d.ts +24 -16
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +19 -19
- package/dist/browser.js.map +1 -1
- package/dist/{image-size-DwDbakcl.js → chart-metadata-CwiTTcJq.js} +576 -538
- package/dist/chart-metadata-CwiTTcJq.js.map +1 -0
- package/dist/{clip-DHDlnHUq.d.ts → clip-ISfCMtWA.d.ts} +6 -10
- package/dist/clip-ISfCMtWA.d.ts.map +1 -0
- package/dist/{notes-BcT571R4.js → comments-CKIZYRbZ.js} +517 -389
- package/dist/comments-CKIZYRbZ.js.map +1 -0
- package/dist/{diagnostics-DiMmBU8P.d.ts → diagnostics-MoA4MBq5.d.ts} +52 -50
- package/dist/diagnostics-MoA4MBq5.d.ts.map +1 -0
- package/dist/{embedded-fonts-CI_YGW2d.d.ts → embedded-fonts-U7HIIhPO.d.ts} +4 -6
- package/dist/embedded-fonts-U7HIIhPO.d.ts.map +1 -0
- package/dist/{entry-compose-6hF9aTmT.d.ts → entry-compose-CiakSt-f.d.ts} +53 -74
- package/dist/entry-compose-CiakSt-f.d.ts.map +1 -0
- package/dist/{errors-Da2nXCJm.js → entry-errors-JMthgJ2g.js} +41 -25
- package/dist/entry-errors-JMthgJ2g.js.map +1 -0
- package/dist/{table-cell-margins-PDshga8T.js → enums-BP9wsb9Q.js} +42 -45
- package/dist/enums-BP9wsb9Q.js.map +1 -0
- package/dist/{enums-DQRpVOLh.d.ts → enums-PcXr3o3J.d.ts} +11 -12
- package/dist/{enums-DQRpVOLh.d.ts.map → enums-PcXr3o3J.d.ts.map} +1 -1
- package/dist/families.d.ts +24 -26
- package/dist/families.d.ts.map +1 -1
- package/dist/families.js +3 -4
- package/dist/{fit-CcXbg__l.js → fit-Bpmzep6O.js} +60 -52
- package/dist/fit-Bpmzep6O.js.map +1 -0
- package/dist/{font-metrics-CBGmhLo0.d.ts → font-metrics-DTppw4t3.d.ts} +61 -37
- package/dist/font-metrics-DTppw4t3.d.ts.map +1 -0
- package/dist/{grid-9B2w5EaY.js → grid-DUIMxjfl.js} +23 -26
- package/dist/grid-DUIMxjfl.js.map +1 -0
- package/dist/{html-dom-DvJmuHt2.js → html-dom-LZCgntnJ.js} +42 -43
- package/dist/html-dom-LZCgntnJ.js.map +1 -0
- package/dist/html.d.ts +53 -9
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +12 -13
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +21 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +14 -16
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +18 -19
- package/dist/inspect.js.map +1 -1
- package/dist/{text-anchor-BgLPbwbL.js → lock-attrs-CSQnFDHP.js} +62 -12
- package/dist/lock-attrs-CSQnFDHP.js.map +1 -0
- package/dist/math.d.ts +2 -4
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +12 -13
- package/dist/math.js.map +1 -1
- package/dist/measure.d.ts +23 -12
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +3 -3
- package/dist/node.d.ts +21 -13
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +12 -12
- package/dist/node.js.map +1 -1
- package/dist/{options-internal-WqgMf720.js → options-internal-BWgmLPdx.js} +4 -5
- package/dist/options-internal-BWgmLPdx.js.map +1 -0
- package/dist/{package-KoEgVwII.d.ts → package-CANBWuSm.d.ts} +4 -12
- package/dist/package-CANBWuSm.d.ts.map +1 -0
- package/dist/{playbtn-CUqQdoDf.js → playbtn-BQZFJir9.js} +4 -5
- package/dist/playbtn-BQZFJir9.js.map +1 -0
- package/dist/{pres-BA9_lJbY.d.ts → pres-BkEkUAEM.d.ts} +383 -230
- package/dist/pres-BkEkUAEM.d.ts.map +1 -0
- package/dist/{presentation-Cyl74rq2.js → presentation-4Ggq0_Xa.js} +408 -288
- package/dist/presentation-4Ggq0_Xa.js.map +1 -0
- package/dist/{presentation-types-B3VQH4Bz.d.ts → presentation-types-BgnZR-0a.d.ts} +1104 -457
- package/dist/presentation-types-BgnZR-0a.d.ts.map +1 -0
- package/dist/read.d.ts +18 -13
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +4 -4
- package/dist/script.d.ts +116 -65
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +2697 -777
- package/dist/script.js.map +1 -1
- package/dist/{shapes-BcyFdZpp.js → shapes-CAPOjU0Q.js} +1556 -487
- package/dist/shapes-CAPOjU0Q.js.map +1 -0
- package/dist/{slide-BqPtyKmb.d.ts → slide-BmT4kMoO.d.ts} +94 -86
- package/dist/slide-BmT4kMoO.d.ts.map +1 -0
- package/dist/{slide-size-BalTjFuv.js → slide-size-SkScz1ig.js} +2 -3
- package/dist/{slide-size-BalTjFuv.js.map → slide-size-SkScz1ig.js.map} +1 -1
- package/dist/{table-dom-CVbvUfgh.js → table-dom-BYga4FYY.js} +3 -4
- package/dist/{table-dom-CVbvUfgh.js.map → table-dom-BYga4FYY.js.map} +1 -1
- package/dist/{text-BvFFMMFQ.js → text-Dz0ArGIp.js} +365 -318
- package/dist/text-Dz0ArGIp.js.map +1 -0
- package/dist/{transition-speed-kUEWDWTx.js → transition-speed-CNJ0fSpQ.js} +2 -3
- package/dist/{transition-speed-kUEWDWTx.js.map → transition-speed-CNJ0fSpQ.js.map} +1 -1
- package/dist/{units-internal-DFcUYjh3.js → units-internal-BR3a4cIi.js} +26 -29
- package/dist/units-internal-BR3a4cIi.js.map +1 -0
- package/dist/{zip-CYZ0F6BV.js → zip-7JTh61LX.js} +8 -10
- package/dist/zip-7JTh61LX.js.map +1 -0
- package/dist/{zip-CTll_dr0.d.ts → zip-uUjs9Cqx.d.ts} +4 -6
- package/dist/zip-uUjs9Cqx.d.ts.map +1 -0
- package/dist/zip.d.ts +3 -3
- package/dist/zip.js +3 -3
- package/dist/{zoom-BoNyOlPm.js → zoom-CSSeOwM8.js} +1153 -583
- package/dist/zoom-CSSeOwM8.js.map +1 -0
- package/package.json +20 -21
- package/skills/{ts-pptx-upstream → pptx-ts-upstream}/SKILL.md +27 -74
- package/dist/autopage-D4kyVp11.js.map +0 -1
- package/dist/binary-string-CKVAYI3M.js.map +0 -1
- package/dist/body-insets-kVHmjGc6.js.map +0 -1
- package/dist/clip-DHDlnHUq.d.ts.map +0 -1
- package/dist/diagnostics-DiMmBU8P.d.ts.map +0 -1
- package/dist/embedded-fonts-CI_YGW2d.d.ts.map +0 -1
- package/dist/entry-compose-6hF9aTmT.d.ts.map +0 -1
- package/dist/errors-Da2nXCJm.js.map +0 -1
- package/dist/fit-CcXbg__l.js.map +0 -1
- package/dist/font-metrics-CBGmhLo0.d.ts.map +0 -1
- package/dist/grid-9B2w5EaY.js.map +0 -1
- package/dist/html-dom-DvJmuHt2.js.map +0 -1
- package/dist/image-size-DwDbakcl.js.map +0 -1
- package/dist/notes-BcT571R4.js.map +0 -1
- package/dist/options-internal-WqgMf720.js.map +0 -1
- package/dist/package-KoEgVwII.d.ts.map +0 -1
- package/dist/playbtn-CUqQdoDf.js.map +0 -1
- package/dist/pres-BA9_lJbY.d.ts.map +0 -1
- package/dist/presentation-Cyl74rq2.js.map +0 -1
- package/dist/presentation-types-B3VQH4Bz.d.ts.map +0 -1
- package/dist/shapes-BcyFdZpp.js.map +0 -1
- package/dist/slide-BqPtyKmb.d.ts.map +0 -1
- package/dist/table-cell-margins-PDshga8T.js.map +0 -1
- package/dist/text-BvFFMMFQ.js.map +0 -1
- package/dist/text-anchor-BgLPbwbL.js.map +0 -1
- package/dist/units-internal-DFcUYjh3.js.map +0 -1
- package/dist/zip-CTll_dr0.d.ts.map +0 -1
- package/dist/zip-CYZ0F6BV.js.map +0 -1
- package/dist/zoom-BoNyOlPm.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The runtime-agnostic authoring entry, which the bare `pptx-ts` specifier resolves to when
|
|
3
|
+
* neither the `node` nor the `browser` export condition applies.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { C as isChartType, S as isChartExType, _ as VALID_SHAPE_PRESETS, a as CONNECTOR_PRESET_NAME, b as asChartType, c as PLACEHOLDER_TYPE, d as SHAPE_NAME, f as SchemeColor, g as TextAnchor, h as TableStyle, i as CHART_NAME, l as PlaceholderType, m as SlideObjectType, n as AlignV, o as ChartType, p as ShapeType, r as BulletType, s as OutputType, t as AlignH, u as SCHEME_COLORS, v as WRITE_OUTPUT_TYPE, x as connectorPresetFor, y as ZIP_OUTPUT_TYPE } from "./enums-PcXr3o3J.js";
|
|
8
|
+
import { $ as ChartExBinning, $t as ImageBaseProps, A as PositionProps, At as ObjectLockProps, B as HyperlinkActionJump, Bt as ResolvedCommentAuthor, C as HexColor, Ct as ChartPropsLegend, D as PatternFillProps, Dt as OptsChartData, E as Margin, En as RadarStyleAlias, Et as LineCap, F as ActionHyperlinkProps, Ft as CommentProps, G as ShapeLineProps, Gt as TextBulletProps, H as HyperlinkProps, Ht as TableCellLayout, I as BorderProps, It as MeasureTextOptions, J as UrlHyperlinkProps, Jt as TextMeasurement, K as SlideHyperlinkProps, Kt as TextFitShrinkProps, L as ConnectorProps, Lt as NotesProps, M as TextVertType, Mn as TimeUnit, Mt as PlaceholderBinding, N as ThemeColor, Nt as PlaceholderOption, O as PatternPreset, Ot as OptsChartGridLine, P as VAlign, Pt as PlaceholderProps, Q as ChartErrorBarOptions, Qt as textRuns, R as ConnectorType, Rt as NotesTextOptions, S as HAlign, Sn as LineDataSymbol, St as ChartPropsFillLine, T as LinearGradientFillProps, Tn as RadarStyle, Tt as ChartSeriesOpts, U as ShadowProps, Ut as TableLayoutResult, V as HyperlinkBaseProps, Vt as SlideComment, W as ShapeFillProps, Wt as TextBaseProps, X as ChartAxisTickMark, Xt as TextPropsOptions, Y as ChartAreaProps, Yt as TextProps, Z as ChartDataPointStyle, Zt as textRun, _ as DataOrPathProps, _n as DisplayBlanksAs, _t as ChartPropsChartStock, a as PresentationProps, an as ShapeAdjustHandlePolar, at as ChartPropsAxisCat, b as GradientFillProps, bn as LightRigDirection, bt as ChartPropsDataLabel, c as WriteFileProps, cn as ShapeConnectionSite, ct as ChartPropsBase, d as ThemeColorScheme, dn as Bar3DShape, dt as ChartPropsChartDoughnut, en as ImageProps, et as ChartExGeography, f as ThemeProps, fn as BarDirection, ft as ChartPropsChartHistogram, g as Coord, gn as DataLabelPosition, gt as ChartPropsChartRegionMap, h as Color, ht as ChartPropsChartRadar, i as PresLayout, in as ShapeAdjustHandle, it as ChartOpts, j as RadialGradientFillProps, jt as ObjectNameProps, k as PlaceholderPositionProps, kt as CommonObjectDescriptor, l as WriteOutputMap, ln as ShapeGuide, lt as ChartPropsChartBar, m as BackgroundProps, mn as BevelPresetType, mt as ChartPropsChartPie, n as PackagePart, nn as MediaType, nt as ChartLineDash, o as SectionProps, on as ShapeAdjustHandleXY, ot as ChartPropsAxisSer, p as BackgroundOption, pn as BarGrouping, pt as ChartPropsChartLine, q as StrokeProps, qt as TextGlowProps, r as PartsProps, rn as OleObjectProps, rt as ChartMulti, s as WriteBaseProps, sn as ShapeAdjustValue, st as ChartPropsAxisVal, t as CustomPropertyValue, tn as MediaProps, tt as ChartExStatistics, u as WriteProps, un as ShapeProps, ut as ChartPropsChartBoxWhisker, v as DataOrPathRequiredProps, vt as ChartPropsChartSurface, w as ImageFillProps, wn as PresetMaterialType, wt as ChartPropsTitle, x as GradientStopProps, xn as LightRigType, xt as ChartPropsDataTable, y as GeometryPoint, yn as LegendPosition, yt as ChartPropsChartWaterfall, z as FillOption, zt as OverflowBoxOptions } from "./pres-BkEkUAEM.js";
|
|
9
|
+
import { A as TableCellDiagonals, C as AnimationTrigger, D as TransitionType, E as TransitionSoundProps, F as TableToSlidesDocument, I as TableToSlidesElement, L as TableToSlidesProps, M as TableProps, N as TableRow, O as TableCell, P as TableRowSlide, S as AnimationProps, T as TransitionProps, _ as MasterTextStyleProps, a as Slide, b as SlideMasterProps, c as SectionZoomProps, d as ZoomBaseProps, f as Model3dCameraProps, g as MasterTextStyleLevel, h as MasterBulletProps, i as ObjectOptions, j as TableCellProps, k as TableCell3DProps, l as SlideZoomProps, m as Model3dProps, n as GroupChildProps, o as SlideLayout, p as Model3dPoint, r as GroupProps, s as SlideObjectInfo, t as AddSlideProps, u as SummaryZoomProps, v as SlideMasterChartProps, w as PresetEffect, x as SlideNumberProps, y as SlideMasterObject } from "./slide-BmT4kMoO.js";
|
|
10
|
+
import { S as UnsupportedFeatureErrorCode, _ as InternalErrorCode, a as TsPptxCode, b as PackageReadErrorCode, c as InternalError, d as PackageReadError, f as PptxTsError, g as ErrorCode, h as DiagnosticCode, i as setDiagnosticHandler, l as InvalidOptionError, m as UnsupportedFeatureError, n as DiagnosticHandler, o as TsPptxError, p as PptxTsErrorOptions, r as resetDiagnosticState, s as TsPptxErrorOptions, t as Diagnostic, u as MediaError, v as InvalidOptionErrorCode, x as PptxTsCode, y as MediaErrorCode } from "./diagnostics-MoA4MBq5.js";
|
|
11
|
+
import { A as pixelsToEmu, C as StandardLayoutName, D as emuToPoints, E as emuToPixels, M as ptToHundredths, O as inchesToEmu, S as StandardLayout, T as emuToInches, _ as HUNDREDTHS_PER_POINT, b as PERCENT_SCALE, c as ConstructFamily, g as FIXED_PCT_PER_PERCENT, h as Emu, i as ComposedSlide, j as pointsToEmu, k as percentToEmu, m as DEFAULT_PX_PER_INCH, n as Composed, p as ANGLE_UNITS_PER_DEGREE, r as ComposedPresentation, s as PresentationCore, t as ComposeOptions, v as MAX_COORDINATE_EMU, w as coordToEmu, x as STANDARD_LAYOUTS, y as MIN_COORDINATE_EMU } from "./entry-compose-CiakSt-f.js";
|
|
12
|
+
import { a as EMU_PER_INCH, i as clipPath, n as FlatSide, o as EMU_PER_POINT, r as HalfDiscPreset, s as POINTS_PER_INCH, t as ClipShape } from "./clip-ISfCMtWA.js";
|
|
8
13
|
/**
|
|
9
14
|
* The runtime-agnostic entry: what a consumer gets from the bare `pptx-ts` specifier
|
|
10
|
-
* when neither the `node` nor the `browser` export condition resolves
|
|
15
|
+
* when neither the `node` nor the `browser` export condition resolves: Deno, Bun, edge workers.
|
|
11
16
|
* Node and browser consumers reach `pptx-ts/node` and `pptx-ts/browser` through those conditions
|
|
12
17
|
* without naming them, and get the same class backed by an adapter that can reach their host.
|
|
13
18
|
*
|
|
14
19
|
* Authoring is identical on all three. The difference is only where the finished deck can go:
|
|
15
20
|
* `write`, `stream` and `toParts` hand the bytes back here as everywhere, while `writeFile`
|
|
16
21
|
* throws `runtime/file-output-unavailable` because there is no filesystem and no DOM to write
|
|
17
|
-
* to. Live-DOM `tableToSlides` is likewise absent
|
|
22
|
+
* to. Live-DOM `tableToSlides` is likewise absent. It is defined on the browser entry, and the
|
|
18
23
|
* DOM-agnostic form is the free `tableToSlides` on `pptx-ts/html`.
|
|
19
24
|
*/
|
|
20
|
-
export declare class
|
|
25
|
+
export declare class PptxTs extends PresentationCore {
|
|
21
26
|
constructor();
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* Compose a presentation from the construct families it needs, on the runtime-agnostic adapter.
|
|
25
30
|
*
|
|
26
|
-
* The counterpart to {@link
|
|
31
|
+
* The counterpart to {@link PptxTs}, which is composed with every family there is. This one costs
|
|
27
32
|
* what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever
|
|
28
33
|
* `use` names, and nothing else reaches the bundle.
|
|
29
34
|
* @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`
|
|
@@ -33,6 +38,9 @@ export declare class TsPptx extends PresentationCore {
|
|
|
33
38
|
* const pres = createPresentation({ use: [charts] })
|
|
34
39
|
*/
|
|
35
40
|
export declare function createPresentation<const Fs extends readonly ConstructFamily[] = []>(opts?: ComposeOptions<Fs>): Composed<Fs>;
|
|
36
|
-
|
|
37
|
-
export
|
|
41
|
+
/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */
|
|
42
|
+
export declare const TsPptx: typeof PptxTs;
|
|
43
|
+
/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */
|
|
44
|
+
export type TsPptx = PptxTs;
|
|
45
|
+
export { ANGLE_UNITS_PER_DEGREE, ActionHyperlinkProps, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundOption, BackgroundProps, type Bar3DShape, type BarDirection, type BarGrouping, type BevelPresetType, BorderProps, BulletType, CHART_NAME, CONNECTOR_PRESET_NAME, ChartAreaProps, ChartAxisTickMark, ChartDataPointStyle, ChartErrorBarOptions, ChartExBinning, ChartExGeography, ChartExStatistics, ChartLineDash, ChartMulti, ChartOpts, ChartPropsAxisCat, ChartPropsAxisSer, ChartPropsAxisVal, ChartPropsBase, ChartPropsChartBar, ChartPropsChartBoxWhisker, ChartPropsChartDoughnut, ChartPropsChartHistogram, ChartPropsChartLine, ChartPropsChartPie, ChartPropsChartRadar, ChartPropsChartRegionMap, ChartPropsChartStock, ChartPropsChartSurface, ChartPropsChartWaterfall, ChartPropsDataLabel, ChartPropsDataTable, ChartPropsFillLine, ChartPropsLegend, ChartPropsTitle, ChartSeriesOpts, ChartType, ClipShape, Color, CommentProps, CommonObjectDescriptor, type ComposeOptions, type Composed, type ComposedPresentation, type ComposedSlide, ConnectorProps, ConnectorType, type ConstructFamily, Coord, CustomPropertyValue, DEFAULT_PX_PER_INCH, type DataLabelPosition, DataOrPathProps, DataOrPathRequiredProps, type Diagnostic, type DiagnosticCode, type DiagnosticHandler, type DisplayBlanksAs, EMU_PER_INCH, EMU_PER_POINT, Emu, type ErrorCode, FIXED_PCT_PER_PERCENT, FillOption, FlatSide, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HalfDiscPreset, HexColor, HyperlinkActionJump, HyperlinkBaseProps, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LegendPosition, type LightRigDirection, type LightRigType, LineCap, type LineDataSymbol, LinearGradientFillProps, MAX_COORDINATE_EMU, MIN_COORDINATE_EMU, Margin, MasterBulletProps, MasterTextStyleLevel, MasterTextStyleProps, MeasureTextOptions, MediaError, type MediaErrorCode, MediaProps, MediaType, Model3dCameraProps, Model3dPoint, Model3dProps, NotesProps, NotesTextOptions, ObjectLockProps, ObjectNameProps, ObjectOptions, OleObjectProps, OptsChartData, OptsChartGridLine, OutputType, OverflowBoxOptions, PERCENT_SCALE, PLACEHOLDER_TYPE, POINTS_PER_INCH, PackagePart, PackageReadError, type PackageReadErrorCode, PartsProps, PatternFillProps, PatternPreset, PlaceholderBinding, PlaceholderOption, PlaceholderPositionProps, PlaceholderProps, PlaceholderType, PositionProps, PptxTs as default, type PptxTsCode, PptxTsError, type PptxTsErrorOptions, PresLayout, PresentationProps, PresetEffect, type PresetMaterialType, type RadarStyle, type RadarStyleAlias, RadialGradientFillProps, ResolvedCommentAuthor, SCHEME_COLORS, SHAPE_NAME, STANDARD_LAYOUTS, SchemeColor, SectionProps, SectionZoomProps, ShadowProps, ShapeAdjustHandle, ShapeAdjustHandlePolar, ShapeAdjustHandleXY, ShapeAdjustValue, ShapeConnectionSite, ShapeFillProps, ShapeGuide, ShapeLineProps, ShapeProps, ShapeType, Slide, SlideComment, SlideHyperlinkProps, SlideLayout, SlideMasterChartProps, SlideMasterObject, SlideMasterProps, SlideNumberProps, SlideObjectInfo, SlideObjectType, SlideZoomProps, StandardLayout, StandardLayoutName, StrokeProps, SummaryZoomProps, TableCell, TableCell3DProps, TableCellDiagonals, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps, TextAnchor, TextBaseProps, TextBulletProps, TextFitShrinkProps, TextGlowProps, TextMeasurement, TextProps, TextPropsOptions, TextVertType, ThemeColor, ThemeColorScheme, ThemeProps, type TimeUnit, TransitionProps, TransitionSoundProps, TransitionType, TsPptxCode, TsPptxError, TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, UrlHyperlinkProps, VALID_SHAPE_PRESETS, VAlign, WRITE_OUTPUT_TYPE, WriteBaseProps, WriteFileProps, WriteOutputMap, WriteProps, ZIP_OUTPUT_TYPE, ZoomBaseProps, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
|
|
38
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAwBa,eAAe;EAC3B;;;;;;;;;;;;;;wBAiBe,yBAAyB,oBAAoB,wBAC5D,OAAO,eAAe,MACpB,SAAS;;qBAOC,eAAM;;YAEP,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { A as inchesToEmu, C as MIN_COORDINATE_EMU, D as emuToInches, E as coordToEmu, F as EMU_PER_INCH, I as EMU_PER_POINT, L as POINTS_PER_INCH, M as pixelsToEmu, N as pointsToEmu, O as emuToPixels, P as ptToHundredths, S as MAX_COORDINATE_EMU, T as STANDARD_LAYOUTS,
|
|
3
|
-
import { a as
|
|
4
|
-
|
|
1
|
+
import { a as fetchMediaBase64, c as ALL_CONSTRUCT_FAMILIES, i as fetchFontBytes, l as composePresentation, n as textRuns, r as clipPath, s as placeholderSvgPreview, t as textRun, u as PresentationCore } from "./text-Dz0ArGIp.js";
|
|
2
|
+
import { A as inchesToEmu, C as MIN_COORDINATE_EMU, D as emuToInches, E as coordToEmu, F as EMU_PER_INCH, I as EMU_PER_POINT, L as POINTS_PER_INCH, M as pixelsToEmu, N as pointsToEmu, O as emuToPixels, P as ptToHundredths, S as MAX_COORDINATE_EMU, T as STANDARD_LAYOUTS, a as OutputType, b as FIXED_PCT_PER_PERCENT, c as ShapeType, d as TextAnchor, f as VALID_SHAPE_PRESETS, g as isChartType, h as isChartExType, i as ChartType, j as percentToEmu, k as emuToPoints, l as SlideObjectType, m as connectorPresetFor, n as AlignV, o as PlaceholderType, p as asChartType, r as BulletType, s as SchemeColor, t as AlignH, u as TableStyle, v as ANGLE_UNITS_PER_DEGREE, w as PERCENT_SCALE, x as HUNDREDTHS_PER_POINT, y as DEFAULT_PX_PER_INCH } from "./enums-BP9wsb9Q.js";
|
|
3
|
+
import { a as PackageReadError, c as resetDiagnosticState, i as MediaError, l as setDiagnosticHandler, n as InternalError, o as PptxTsError, r as InvalidOptionError, s as UnsupportedFeatureError, t as TsPptxError } from "./entry-errors-JMthgJ2g.js";
|
|
4
|
+
// src/runtime/neutral.ts
|
|
5
5
|
/**
|
|
6
|
-
* The adapter for a runtime that is neither Node nor a browser
|
|
6
|
+
* The adapter for a runtime that is neither Node nor a browser: Deno, Bun, an edge worker,
|
|
7
7
|
* anything that imports the bare `pptx-ts` specifier without resolving the `node` or
|
|
8
8
|
* `browser` export condition.
|
|
9
9
|
*
|
|
10
10
|
* It implements everything that is genuinely host-neutral and refuses only what is not.
|
|
11
11
|
* `fetch`, `btoa` and `TextEncoder` exist in all of these runtimes, so remote media and fonts
|
|
12
|
-
* load here exactly as they do in a browser
|
|
12
|
+
* load here exactly as they do in a browser, which is why every method but `writeFile` is now
|
|
13
13
|
* the shared implementation in {@link ./fetch-media} rather than a copy of it. What is missing
|
|
14
14
|
* is a *destination*: there is no `node:fs` to write to and no `document` to hand a download to,
|
|
15
15
|
* so {@link RuntimeAdapter.writeFile} throws a named error rather than guessing. Everything that
|
|
16
|
-
* returns bytes to the caller
|
|
16
|
+
* returns bytes to the caller (`write`, `stream`, `toParts`) works normally, which is the
|
|
17
17
|
* shape that suits a worker anyway.
|
|
18
18
|
*
|
|
19
19
|
* Media loading is fetch-only here: a bare filesystem path has no meaning without a filesystem,
|
|
@@ -31,8 +31,7 @@ function createNeutralRuntime() {
|
|
|
31
31
|
async function writeFile(fileName) {
|
|
32
32
|
throw new UnsupportedFeatureError("runtime/file-output-unavailable", `Cannot write "${fileName}": this runtime has neither a filesystem nor a DOM. Import "pptx-ts/node" to write to disk or "pptx-ts/browser" to trigger a download; anywhere else, use write() and persist the bytes yourself.`);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
//#region src/index.ts
|
|
34
|
+
// src/index.ts
|
|
36
35
|
/**
|
|
37
36
|
* The runtime-agnostic authoring entry, which the bare `pptx-ts` specifier resolves to when
|
|
38
37
|
* neither the `node` nor the `browser` export condition applies.
|
|
@@ -41,17 +40,17 @@ async function writeFile(fileName) {
|
|
|
41
40
|
*/
|
|
42
41
|
/**
|
|
43
42
|
* The runtime-agnostic entry: what a consumer gets from the bare `pptx-ts` specifier
|
|
44
|
-
* when neither the `node` nor the `browser` export condition resolves
|
|
43
|
+
* when neither the `node` nor the `browser` export condition resolves: Deno, Bun, edge workers.
|
|
45
44
|
* Node and browser consumers reach `pptx-ts/node` and `pptx-ts/browser` through those conditions
|
|
46
45
|
* without naming them, and get the same class backed by an adapter that can reach their host.
|
|
47
46
|
*
|
|
48
47
|
* Authoring is identical on all three. The difference is only where the finished deck can go:
|
|
49
48
|
* `write`, `stream` and `toParts` hand the bytes back here as everywhere, while `writeFile`
|
|
50
49
|
* throws `runtime/file-output-unavailable` because there is no filesystem and no DOM to write
|
|
51
|
-
* to. Live-DOM `tableToSlides` is likewise absent
|
|
50
|
+
* to. Live-DOM `tableToSlides` is likewise absent. It is defined on the browser entry, and the
|
|
52
51
|
* DOM-agnostic form is the free `tableToSlides` on `pptx-ts/html`.
|
|
53
52
|
*/
|
|
54
|
-
var
|
|
53
|
+
var PptxTs = class extends PresentationCore {
|
|
55
54
|
constructor() {
|
|
56
55
|
super(createNeutralRuntime(), ALL_CONSTRUCT_FAMILIES);
|
|
57
56
|
}
|
|
@@ -59,7 +58,7 @@ var TsPptx = class extends PresentationCore {
|
|
|
59
58
|
/**
|
|
60
59
|
* Compose a presentation from the construct families it needs, on the runtime-agnostic adapter.
|
|
61
60
|
*
|
|
62
|
-
* The counterpart to {@link
|
|
61
|
+
* The counterpart to {@link PptxTs}, which is composed with every family there is. This one costs
|
|
63
62
|
* what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever
|
|
64
63
|
* `use` names, and nothing else reaches the bundle.
|
|
65
64
|
* @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`
|
|
@@ -71,7 +70,8 @@ var TsPptx = class extends PresentationCore {
|
|
|
71
70
|
function createPresentation(opts) {
|
|
72
71
|
return composePresentation(createNeutralRuntime(), opts);
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */
|
|
74
|
+
const TsPptx = PptxTs;
|
|
75
|
+
export { ANGLE_UNITS_PER_DEGREE, AlignH, AlignV, BulletType, ChartType, DEFAULT_PX_PER_INCH, EMU_PER_INCH, EMU_PER_POINT, FIXED_PCT_PER_PERCENT, HUNDREDTHS_PER_POINT, InternalError, InvalidOptionError, MAX_COORDINATE_EMU, MIN_COORDINATE_EMU, MediaError, OutputType, PERCENT_SCALE, POINTS_PER_INCH, PackageReadError, PlaceholderType, PptxTs, PptxTs as default, PptxTsError, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, createPresentation, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
|
|
76
76
|
|
|
77
77
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/runtime/neutral.ts","../src/index.ts"],"sourcesContent":["import { UnsupportedFeatureError } from '../errors.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes, fetchMediaBase64, placeholderSvgPreview } from './fetch-media.js'\n\n/**\n * The adapter for a runtime that is neither Node nor a browser
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/runtime/neutral.ts","../src/index.ts"],"sourcesContent":["import { UnsupportedFeatureError } from '../errors.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes, fetchMediaBase64, placeholderSvgPreview } from './fetch-media.js'\n\n/**\n * The adapter for a runtime that is neither Node nor a browser: Deno, Bun, an edge worker,\n * anything that imports the bare `pptx-ts` specifier without resolving the `node` or\n * `browser` export condition.\n *\n * It implements everything that is genuinely host-neutral and refuses only what is not.\n * `fetch`, `btoa` and `TextEncoder` exist in all of these runtimes, so remote media and fonts\n * load here exactly as they do in a browser, which is why every method but `writeFile` is now\n * the shared implementation in {@link ./fetch-media} rather than a copy of it. What is missing\n * is a *destination*: there is no `node:fs` to write to and no `document` to hand a download to,\n * so {@link RuntimeAdapter.writeFile} throws a named error rather than guessing. Everything that\n * returns bytes to the caller (`write`, `stream`, `toParts`) works normally, which is the\n * shape that suits a worker anyway.\n *\n * Media loading is fetch-only here: a bare filesystem path has no meaning without a filesystem,\n * and `fetch` rejecting it is reported by the caller as a load failure naming the path.\n */\nexport function createNeutralRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: null,\n\t\tloadMedia: (rel) => fetchMediaBase64(rel.path),\n\t\tcreateSvgPngPreview: placeholderSvgPreview,\n\t\twriteFile,\n\t\tloadFontData: fetchFontBytes,\n\t}\n}\n\nasync function writeFile(fileName: string): Promise<string> {\n\tthrow new UnsupportedFeatureError(\n\t\t'runtime/file-output-unavailable',\n\t\t`Cannot write \"${fileName}\": this runtime has neither a filesystem nor a DOM. ` +\n\t\t\t'Import \"pptx-ts/node\" to write to disk or \"pptx-ts/browser\" to trigger a ' +\n\t\t\t'download; anywhere else, use write() and persist the bytes yourself.'\n\t)\n}\n","/**\n * The runtime-agnostic authoring entry, which the bare `pptx-ts` specifier resolves to when\n * neither the `node` nor the `browser` export condition applies.\n *\n * @module\n */\nimport PresentationCore from './presentation.js'\nimport { composePresentation, type ComposeOptions, type Composed } from './entry-compose.js'\nimport type { ConstructFamily } from './families/shared.js'\nimport { ALL_CONSTRUCT_FAMILIES } from './entry-families.js'\nimport { createNeutralRuntime } from './runtime/neutral.js'\n\n/**\n * The runtime-agnostic entry: what a consumer gets from the bare `pptx-ts` specifier\n * when neither the `node` nor the `browser` export condition resolves: Deno, Bun, edge workers.\n * Node and browser consumers reach `pptx-ts/node` and `pptx-ts/browser` through those conditions\n * without naming them, and get the same class backed by an adapter that can reach their host.\n *\n * Authoring is identical on all three. The difference is only where the finished deck can go:\n * `write`, `stream` and `toParts` hand the bytes back here as everywhere, while `writeFile`\n * throws `runtime/file-output-unavailable` because there is no filesystem and no DOM to write\n * to. Live-DOM `tableToSlides` is likewise absent. It is defined on the browser entry, and the\n * DOM-agnostic form is the free `tableToSlides` on `pptx-ts/html`.\n */\nexport class PptxTs extends PresentationCore {\n\tconstructor() {\n\t\tsuper(createNeutralRuntime(), ALL_CONSTRUCT_FAMILIES)\n\t}\n}\n\n/**\n * Compose a presentation from the construct families it needs, on the runtime-agnostic adapter.\n *\n * The counterpart to {@link PptxTs}, which is composed with every family there is. This one costs\n * what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever\n * `use` names, and nothing else reaches the bundle.\n * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`\n * @example\n * import { createPresentation } from 'pptx-ts'\n * import { charts } from 'pptx-ts/families'\n * const pres = createPresentation({ use: [charts] })\n */\nexport function createPresentation<const Fs extends readonly ConstructFamily[] = []>(\n\topts?: ComposeOptions<Fs>\n): Composed<Fs> {\n\treturn composePresentation(createNeutralRuntime(), opts)\n}\n\nexport { PptxTs as default }\n\n/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */\nexport const TsPptx = PptxTs\n/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */\nexport type TsPptx = PptxTs\n\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,uBAAuC;CACtD,OAAO;EACN,qBAAqB;EACrB,YAAY,QAAQ,iBAAiB,IAAI,IAAI;EAC7C,qBAAqB;EACrB;EACA,cAAc;CACf;AACD;AAEA,eAAe,UAAU,UAAmC;CAC3D,MAAM,IAAI,wBACT,mCACA,iBAAiB,SAAS,kMAG3B;AACD;;;;;;;;;;;;;;;;;;;;ACdA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EACb,MAAM,qBAAqB,GAAG,sBAAsB;CACrD;AACD;;;;;;;;;;;;;AAcA,SAAgB,mBACf,MACe;CACf,OAAO,oBAAoB,qBAAqB,GAAG,IAAI;AACxD;;AAKA,MAAa,SAAS"}
|
package/dist/inspect.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
//#region src/inspect.d.ts
|
|
1
|
+
import { n as OpcPackage } from "./package-CANBWuSm.js";
|
|
2
|
+
import { S as UnsupportedFeatureErrorCode, _ as InternalErrorCode, a as TsPptxCode, b as PackageReadErrorCode, c as InternalError, d as PackageReadError, f as PptxTsError, g as ErrorCode, h as DiagnosticCode, i as setDiagnosticHandler, l as InvalidOptionError, m as UnsupportedFeatureError, n as DiagnosticHandler, o as TsPptxError, p as PptxTsErrorOptions, r as resetDiagnosticState, s as TsPptxErrorOptions, t as Diagnostic, u as MediaError, v as InvalidOptionErrorCode, x as PptxTsCode, y as MediaErrorCode } from "./diagnostics-MoA4MBq5.js";
|
|
4
3
|
/**
|
|
5
4
|
* Input to the inspect surface. A `string` is a **filesystem path** (Node) read
|
|
6
5
|
* from disk; pass `Uint8Array`/`ArrayBuffer`/`Blob`/`number[]` for an in-memory
|
|
7
|
-
* archive. (A string is a path, not JSZip's latin1 binary content
|
|
6
|
+
* archive. (A string is a path, not JSZip's latin1 binary content; see
|
|
8
7
|
* `ZipInput`.)
|
|
9
8
|
*/
|
|
10
9
|
export type PptxInspectInputValue = string | number[] | Uint8Array | ArrayBuffer | Blob;
|
|
@@ -38,7 +37,7 @@ export interface PptxTextRun {
|
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
39
|
* One paragraph (`a:p`): its runs in document order. Preserves the paragraph/line
|
|
41
|
-
* boundaries that the flat {@link PptxSlideElement.textRuns} list discards
|
|
40
|
+
* boundaries that the flat {@link PptxSlideElement.textRuns} list discards, needed
|
|
42
41
|
* to measure a `wrap="none"` frame line-by-line (each paragraph is one unwrapped line).
|
|
43
42
|
*/
|
|
44
43
|
export interface PptxParagraph {
|
|
@@ -46,7 +45,7 @@ export interface PptxParagraph {
|
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* What an element is. `'group'` is a `p:grpSp` container: it has its own identity,
|
|
49
|
-
* box, and fill, but no text of its own
|
|
48
|
+
* box, and fill, but no text of its own. Its content is the elements that name it
|
|
50
49
|
* in {@link PptxSlideElement.parentZIndex}. `'graphicFrame'` is a `p:graphicFrame`
|
|
51
50
|
* hosting a table, a chart or a SmartArt graphic; {@link PptxSlideElement.graphicKind}
|
|
52
51
|
* says which, and it keeps that kind even when it carries text (a `'text'` element is
|
|
@@ -57,14 +56,14 @@ export type PptxSlideElementKind = 'text' | 'image' | 'shape' | 'group' | 'graph
|
|
|
57
56
|
* What a `'graphicFrame'` element hosts, read from its `a:graphicData/@uri`:
|
|
58
57
|
* a table (`a:tbl`), a classic chart (`c:chart`), a 2016-family chart
|
|
59
58
|
* (`cx:chartSpace`: waterfall/funnel/treemap/…), or a SmartArt diagram. `'other'`
|
|
60
|
-
* is a frame whose URI matches none of those
|
|
61
|
-
* model
|
|
59
|
+
* is a frame whose URI matches none of those (an OLE object, an ink part, a 3D
|
|
60
|
+
* model), reported as a box so it is not silently missing from the slide.
|
|
62
61
|
*/
|
|
63
62
|
export type PptxGraphicKind = 'table' | 'chart' | 'chartEx' | 'diagram' | 'other';
|
|
64
63
|
/**
|
|
65
64
|
* Vertical-autofit mode of a text frame, read from the `a:bodyPr` child element:
|
|
66
65
|
* - `'none'`: no autofit (`a:noAutofit`, or no autofit child at all). The box has a
|
|
67
|
-
* fixed height the text must fit inside
|
|
66
|
+
* fixed height the text must fit inside: a genuine overflow candidate.
|
|
68
67
|
* - `'normAutofit'`: shrink text to fit (`a:normAutofit`, pptx-ts `fit: 'shrink'`).
|
|
69
68
|
* Text is downscaled rather than overflowing.
|
|
70
69
|
* - `'spAutoFit'`: resize shape to fit text (`a:spAutoFit`, pptx-ts `fit: 'resize'`).
|
|
@@ -102,7 +101,7 @@ export interface PptxSlideElement {
|
|
|
102
101
|
zIndex: number;
|
|
103
102
|
/**
|
|
104
103
|
* Position and size in **slide-absolute** inches, composing every enclosing
|
|
105
|
-
* group transform
|
|
104
|
+
* group transform, so it is directly comparable across elements whether or not they are
|
|
106
105
|
* grouped. For a rotated element this is the unrotated placement box (the box
|
|
107
106
|
* PowerPoint writes after Ungroup); see {@link rotation}.
|
|
108
107
|
*/
|
|
@@ -125,7 +124,7 @@ export interface PptxSlideElement {
|
|
|
125
124
|
* this is the text the structure puts on the slide (table cells in row order,
|
|
126
125
|
* SmartArt node text), which is what {@link PptxSlideInspection.text} and
|
|
127
126
|
* `wordCount` then count; a chart contributes nothing, matching `Slide.text` on
|
|
128
|
-
* the read model. That text has no {@link textRuns} or {@link paragraphs} here
|
|
127
|
+
* the read model. That text has no {@link textRuns} or {@link paragraphs} here;
|
|
129
128
|
* per-run formatting inside a structure is what this surface does not flatten.
|
|
130
129
|
*/
|
|
131
130
|
text: string;
|
|
@@ -169,7 +168,7 @@ export type PptxBoxAnchor = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bo
|
|
|
169
168
|
*/
|
|
170
169
|
export declare const DEFAULT_INSPECT_SLIDE_SIZE: PptxSlideSize;
|
|
171
170
|
/**
|
|
172
|
-
* Load a `.pptx` as an {@link OpcPackage}
|
|
171
|
+
* Load a `.pptx` as an {@link OpcPackage}, the same package model `pptx-ts/read`
|
|
173
172
|
* uses, so a caller that starts here can hand the result straight to
|
|
174
173
|
* `Presentation.fromPackage()` without re-reading the bytes.
|
|
175
174
|
*
|
|
@@ -182,7 +181,7 @@ export declare function listPptxParts(pptxPackage: OpcPackage): string[];
|
|
|
182
181
|
/** Read a package part as UTF-8 text, or `null` when the part is absent. */
|
|
183
182
|
export declare function readPptxTextPart(pptxPackage: OpcPackage, path: string): Promise<string | null>;
|
|
184
183
|
/**
|
|
185
|
-
* Read a package part as raw bytes
|
|
184
|
+
* Read a package part as raw bytes: the binary sibling of {@link readPptxTextPart}
|
|
186
185
|
* for embedded media (SVG/PNG/EMF blobs, fonts, …) that must not be UTF-8 decoded.
|
|
187
186
|
* Returns `null` when the part is absent. The `Uint8Array` is browser-isomorphic;
|
|
188
187
|
* Node consumers can wrap it with `Buffer.from(...)` if they need Buffer methods.
|
|
@@ -194,13 +193,12 @@ export declare function readPptxBinaryPart(pptxPackage: OpcPackage, path: string
|
|
|
194
193
|
export declare function inspectPptx(input: PptxInspectInput): Promise<PptxInspection>;
|
|
195
194
|
export declare function readPresentationSize(pptxPackage: OpcPackage, fallback?: PptxSlideSize): Promise<PptxSlideSize>;
|
|
196
195
|
/**
|
|
197
|
-
* Every slide in the deck, in **presentation order** (`p:sldIdLst`)
|
|
196
|
+
* Every slide in the deck, in **presentation order** (`p:sldIdLst`): the order
|
|
198
197
|
* PowerPoint shows them in, which is not the order their parts are named once a
|
|
199
198
|
* deck has been reordered.
|
|
200
199
|
*/
|
|
201
200
|
export declare function extractSlides(pptxPackage: OpcPackage, size?: PptxSlideSize): Promise<PptxSlideInspection[]>;
|
|
202
201
|
export declare function overlapArea(a: PptxBox, b: PptxBox): number;
|
|
203
202
|
export declare function boxAnchor(box: PptxBox, anchor: PptxBoxAnchor, axis: PptxBoxAxis): number;
|
|
204
|
-
|
|
205
|
-
export { type Diagnostic, type DiagnosticCode, type DiagnosticHandler, type ErrorCode, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, MediaError, type MediaErrorCode, PackageReadError, type PackageReadErrorCode, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, resetDiagnosticState, setDiagnosticHandler };
|
|
203
|
+
export { type Diagnostic, type DiagnosticCode, type DiagnosticHandler, type ErrorCode, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, MediaError, type MediaErrorCode, PackageReadError, type PackageReadErrorCode, type PptxTsCode, PptxTsError, type PptxTsErrorOptions, TsPptxCode, TsPptxError, TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, resetDiagnosticState, setDiagnosticHandler };
|
|
206
204
|
//# sourceMappingURL=inspect.d.ts.map
|
package/dist/inspect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","names":[],"sources":["../src/inspect.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","names":[],"sources":["../src/inspect.ts"],"mappings":";;;;;;;;YA0CY,4CAA4C,aAAa,cAAc;YAEvE,mBAAmB,wBAAwB,QAAQ;iBAE9C;EAChB;EACA;;iBAGgB;EAChB;EACA;EACA;EACA;;iBAGgB;EAChB;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;iBAQgB;EAChB,MAAM;;;;;;;;;;YAWK;;;;;;;;YASA;;;;;;;;;;YAWA;;;;;;iBAOK;EAChB;EACA;EACA;EACA;;iBAGgB;;EAEhB;EACA;EACA,MAAM;;;;;EAKN,aAAa;;;;;;;;EAQb;;;;;;;EAOA,KAAK;;;;;EAKL;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;EASA;EACA;EACA,SAAS;;;;;;EAMT;EACA,YAAY;EACZ,UAAU;;EAEV,YAAY;EACZ;EACA;EACA;EACA;EACA;;iBAGgB;EAChB;EACA;EACA;EACA,MAAM;EACN,UAAU;EACV;EACA;;iBAGgB;EAChB,WAAW;EACX,QAAQ;;YAGG;YACA;;;;;;qBAOC,4BAA4B;;;;;;;;;wBAsBnB,gBAAgB,OAAO,mBAAmB,QAAQ;;wBAKxD,cAAc,aAAa;;wBAKrB,iBAAiB,aAAa,YAAY,eAAe;;;;;;;;;;wBAczD,mBAAmB,aAAa,YAAY,eAAe,QAAQ;wBAmBnE,YAAY,OAAO,mBAAmB,QAAQ;wBAO9C,qBACrB,aAAa,YACb,WAAU,gBACR,QAAQ;;;;;;wBAWW,cAAc,aAAa,YAAY,OAAO,gBAAgB,QAAQ;wBA2C5E,YAAY,GAAG,SAAS,GAAG;wBAM3B,UAAU,KAAK,SAAS,QAAQ,eAAe,MAAM"}
|
package/dist/inspect.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { a as PackageReadError, c as resetDiagnosticState, i as MediaError, l as setDiagnosticHandler, n as InternalError, o as PptxTsError, r as InvalidOptionError, s as UnsupportedFeatureError, t as TsPptxError, u as warn } from "./entry-errors-JMthgJ2g.js";
|
|
2
|
+
import { p as OpcPackage, t as Presentation } from "./presentation-4Ggq0_Xa.js";
|
|
3
|
+
import { D as emuToInches } from "./enums-BP9wsb9Q.js";
|
|
4
|
+
import { r as BODY_INSET_DEFAULTS_PT } from "./body-insets-BDHymJvz.js";
|
|
5
|
+
import { t as ABSENT_SLIDE_SIZE_EMU } from "./slide-size-SkScz1ig.js";
|
|
6
|
+
// src/inspect.ts
|
|
7
7
|
/**
|
|
8
8
|
* A cheap, flat snapshot of what a `.pptx` contains: every element on every
|
|
9
9
|
* slide, with its slide-absolute box and the handful of text/fill properties a
|
|
@@ -11,8 +11,8 @@ import { p as OpcPackage, t as Presentation } from "./presentation-Cyl74rq2.js";
|
|
|
11
11
|
*
|
|
12
12
|
* It is a **projection over `pptx-ts/read`**, not a second reader. `read` gives a
|
|
13
13
|
* navigable, mutable model of a package and answers questions in the shape of the
|
|
14
|
-
* OOXML tree; this answers one flat question
|
|
15
|
-
*
|
|
14
|
+
* OOXML tree; this answers one flat question ("what is on the slides, and where")
|
|
15
|
+
* in the shape a linter, an overlap check, or a diffing tool wants. The two used
|
|
16
16
|
* to be independent implementations over two different XML parsers, which meant
|
|
17
17
|
* every read-side fix had to be made twice and a divergence between them was
|
|
18
18
|
* invisible to every test. Now the model below is the only reader, and this file
|
|
@@ -22,7 +22,7 @@ import { p as OpcPackage, t as Presentation } from "./presentation-Cyl74rq2.js";
|
|
|
22
22
|
* `Presentation` re-exported:
|
|
23
23
|
* - **Only geometry a shape carries itself.** A placeholder that inherits its box
|
|
24
24
|
* from the layout is omitted rather than resolved (`absoluteFrame`, not
|
|
25
|
-
* `resolvedFrame`)
|
|
25
|
+
* `resolvedFrame`): the snapshot reports what the slide states.
|
|
26
26
|
* - **A `p:graphicFrame` is a box, not its contents.** A table, chart or SmartArt
|
|
27
27
|
* graphic is reported as one element with its box, its kind, and the text a
|
|
28
28
|
* reader sees on the slide, but its structure is not flattened: no per-run
|
|
@@ -40,7 +40,7 @@ const DEFAULT_INSPECT_SLIDE_SIZE = Object.freeze({
|
|
|
40
40
|
heightIn: round(emuToInches(ABSENT_SLIDE_SIZE_EMU.heightEmu), 3)
|
|
41
41
|
});
|
|
42
42
|
/**
|
|
43
|
-
* Load a `.pptx` as an {@link OpcPackage}
|
|
43
|
+
* Load a `.pptx` as an {@link OpcPackage}, the same package model `pptx-ts/read`
|
|
44
44
|
* uses, so a caller that starts here can hand the result straight to
|
|
45
45
|
* `Presentation.fromPackage()` without re-reading the bytes.
|
|
46
46
|
*
|
|
@@ -60,7 +60,7 @@ async function readPptxTextPart(pptxPackage, path) {
|
|
|
60
60
|
return bytes ? textDecoder.decode(bytes) : null;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* Read a package part as raw bytes
|
|
63
|
+
* Read a package part as raw bytes: the binary sibling of {@link readPptxTextPart}
|
|
64
64
|
* for embedded media (SVG/PNG/EMF blobs, fonts, …) that must not be UTF-8 decoded.
|
|
65
65
|
* Returns `null` when the part is absent. The `Uint8Array` is browser-isomorphic;
|
|
66
66
|
* Node consumers can wrap it with `Buffer.from(...)` if they need Buffer methods.
|
|
@@ -96,7 +96,7 @@ async function readPresentationSize(pptxPackage, fallback = DEFAULT_INSPECT_SLID
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Every slide in the deck, in **presentation order** (`p:sldIdLst`)
|
|
99
|
+
* Every slide in the deck, in **presentation order** (`p:sldIdLst`): the order
|
|
100
100
|
* PowerPoint shows them in, which is not the order their parts are named once a
|
|
101
101
|
* deck has been reordered.
|
|
102
102
|
*/
|
|
@@ -126,7 +126,7 @@ async function extractSlides(pptxPackage, size) {
|
|
|
126
126
|
* `presentation.xml`. Callers here are auditing files they did not author, so a
|
|
127
127
|
* package that is a valid OPC container but not a presentation reports an empty
|
|
128
128
|
* deck rather than throwing. `presentationPart` is the throw site: it rejects a
|
|
129
|
-
* package with no
|
|
129
|
+
* package with no office-document relationship, or with more than one.
|
|
130
130
|
*/
|
|
131
131
|
function presentationOf(pptxPackage) {
|
|
132
132
|
const presentation = Presentation.fromPackage(pptxPackage);
|
|
@@ -172,7 +172,7 @@ function harvest(shapes, parentZIndex, out) {
|
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Turn harvested shapes into elements, dropping the ones with no resolvable slide
|
|
175
|
-
* position. A dropped shape keeps its zIndex
|
|
175
|
+
* position. A dropped shape keeps its zIndex: the numbers are positions in the
|
|
176
176
|
* shape tree, and renumbering them would silently repoint every `parentZIndex`.
|
|
177
177
|
*/
|
|
178
178
|
function flatten(harvested, slidePath) {
|
|
@@ -238,7 +238,7 @@ function graphicKindOf(frame) {
|
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* The text a graphic frame puts on the slide: table cells in row order, or SmartArt
|
|
241
|
-
* node text. Charts contribute nothing, matching `Slide.text` on the read model
|
|
241
|
+
* node text. Charts contribute nothing, matching `Slide.text` on the read model: a
|
|
242
242
|
* chart's strings are data labels and axis titles that PowerPoint itself does not
|
|
243
243
|
* treat as slide body text.
|
|
244
244
|
*
|
|
@@ -291,10 +291,10 @@ function reportUnresolvable(shape, zIndex, slidePath) {
|
|
|
291
291
|
if (failure === null || failure === "no-own-transform") return;
|
|
292
292
|
const who = shape.name ? `"${shape.name}"` : `the element at zIndex ${zIndex}`;
|
|
293
293
|
if (failure === "group-transform-missing") {
|
|
294
|
-
warn("inspect/group-transform-missing", `inspect: skipped ${who} on ${slidePath}
|
|
294
|
+
warn("inspect/group-transform-missing", `inspect: skipped ${who} on ${slidePath}: an enclosing group has no usable a:xfrm, so its slide position cannot be resolved.`);
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
warn("inspect/group-transform-degenerate", `inspect: skipped ${who} on ${slidePath}
|
|
297
|
+
warn("inspect/group-transform-degenerate", `inspect: skipped ${who} on ${slidePath}: an enclosing group has a degenerate transform (zero a:chExt), so its slide position cannot be resolved.`);
|
|
298
298
|
}
|
|
299
299
|
function countWords(text) {
|
|
300
300
|
return text.split(/\s+/).filter(Boolean).length;
|
|
@@ -303,7 +303,6 @@ function round(value, digits) {
|
|
|
303
303
|
const factor = 10 ** digits;
|
|
304
304
|
return Math.round(value * factor) / factor;
|
|
305
305
|
}
|
|
306
|
-
|
|
307
|
-
export { DEFAULT_INSPECT_SLIDE_SIZE, InternalError, InvalidOptionError, MediaError, PackageReadError, TsPptxError, UnsupportedFeatureError, boxAnchor, extractSlides, inspectPptx, listPptxParts, loadPptxPackage, overlapArea, readPptxBinaryPart, readPptxTextPart, readPresentationSize, resetDiagnosticState, setDiagnosticHandler };
|
|
306
|
+
export { DEFAULT_INSPECT_SLIDE_SIZE, InternalError, InvalidOptionError, MediaError, PackageReadError, PptxTsError, TsPptxError, UnsupportedFeatureError, boxAnchor, extractSlides, inspectPptx, listPptxParts, loadPptxPackage, overlapArea, readPptxBinaryPart, readPptxTextPart, readPresentationSize, resetDiagnosticState, setDiagnosticHandler };
|
|
308
307
|
|
|
309
308
|
//# sourceMappingURL=inspect.js.map
|
package/dist/inspect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.js","names":[],"sources":["../src/inspect.ts"],"sourcesContent":["/**\n * A cheap, flat snapshot of what a `.pptx` contains: every element on every\n * slide, with its slide-absolute box and the handful of text/fill properties a\n * layout audit asks about.\n *\n * It is a **projection over `pptx-ts/read`**, not a second reader. `read` gives a\n * navigable, mutable model of a package and answers questions in the shape of the\n * OOXML tree; this answers one flat question — \"what is on the slides, and where\"\n * — in the shape a linter, an overlap check, or a diffing tool wants. The two used\n * to be independent implementations over two different XML parsers, which meant\n * every read-side fix had to be made twice and a divergence between them was\n * invisible to every test. Now the model below is the only reader, and this file\n * is the flattening.\n *\n * What it deliberately does NOT do, and why the projection is not just\n * `Presentation` re-exported:\n * - **Only geometry a shape carries itself.** A placeholder that inherits its box\n * from the layout is omitted rather than resolved (`absoluteFrame`, not\n * `resolvedFrame`) — the snapshot reports what the slide states.\n * - **A `p:graphicFrame` is a box, not its contents.** A table, chart or SmartArt\n * graphic is reported as one element with its box, its kind, and the text a\n * reader sees on the slide, but its structure is not flattened: no per-run\n * formatting, no cells, no series. Walk `pptx-ts/read` for what is inside one.\n *\n * @module\n */\nimport { warn } from './diagnostics.js'\nimport { OpcPackage } from './read/opc/package.js'\nimport { Presentation } from './read/api/presentation.js'\nimport type { AnyShape } from './read/api/shapes.js'\nimport type { GraphicFrame } from './read/api/shapes/graphic-frame.js'\nimport type { Run, TextFrame } from './read/api/text.js'\nimport { POINTS_PER_INCH, emuToInches } from './units.js'\nimport { BODY_INSET_DEFAULTS_PT } from './ooxml/body-insets.js'\nimport { ABSENT_SLIDE_SIZE_EMU } from './ooxml/slide-size.js'\n\n/**\n * Input to the inspect surface. A `string` is a **filesystem path** (Node) read\n * from disk; pass `Uint8Array`/`ArrayBuffer`/`Blob`/`number[]` for an in-memory\n * archive. (A string is a path, not JSZip's latin1 binary content — see\n * `ZipInput`.)\n */\nexport type PptxInspectInputValue = string | number[] | Uint8Array | ArrayBuffer | Blob\n\nexport type PptxInspectInput = PptxInspectInputValue | Promise<PptxInspectInputValue>\n\nexport interface PptxSlideSize {\n\twidthIn: number\n\theightIn: number\n}\n\nexport interface PptxBox {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n}\n\nexport interface PptxTextRun {\n\ttext: string\n\tfontSizePt: number | null\n\tcolor: string | null\n\t/** Run font face (`a:rPr > a:latin@typeface`), or null when it inherits from the theme/placeholder. */\n\tfontFace: string | null\n\t/** Bold (`a:rPr@b`). */\n\tbold: boolean\n\t/** Italic (`a:rPr@i`). */\n\titalic: boolean\n\t/** Strikethrough token (`a:rPr@strike`: `noStrike`/`sngStrike`/`dblStrike`), or null when unset. */\n\tstrike: string | null\n\t/** Highlight colour hex (`a:rPr > a:highlight`), or null when unset. A theme token is resolved against the slide's theme. */\n\thighlight: string | null\n\t/** Character spacing in points (`a:rPr@spc`, authored in hundredths of a point), or null when unset. */\n\tcharSpacingPt: number | null\n}\n\n/**\n * One paragraph (`a:p`): its runs in document order. Preserves the paragraph/line\n * boundaries that the flat {@link PptxSlideElement.textRuns} list discards — needed\n * to measure a `wrap=\"none\"` frame line-by-line (each paragraph is one unwrapped line).\n */\nexport interface PptxParagraph {\n\truns: PptxTextRun[]\n}\n\n/**\n * What an element is. `'group'` is a `p:grpSp` container: it has its own identity,\n * box, and fill, but no text of its own — its content is the elements that name it\n * in {@link PptxSlideElement.parentZIndex}. `'graphicFrame'` is a `p:graphicFrame`\n * hosting a table, a chart or a SmartArt graphic; {@link PptxSlideElement.graphicKind}\n * says which, and it keeps that kind even when it carries text (a `'text'` element is\n * always a `p:sp`).\n */\nexport type PptxSlideElementKind = 'text' | 'image' | 'shape' | 'group' | 'graphicFrame'\n\n/**\n * What a `'graphicFrame'` element hosts, read from its `a:graphicData/@uri`:\n * a table (`a:tbl`), a classic chart (`c:chart`), a 2016-family chart\n * (`cx:chartSpace`: waterfall/funnel/treemap/…), or a SmartArt diagram. `'other'`\n * is a frame whose URI matches none of those — an OLE object, an ink part, a 3D\n * model — reported as a box so it is not silently missing from the slide.\n */\nexport type PptxGraphicKind = 'table' | 'chart' | 'chartEx' | 'diagram' | 'other'\n\n/**\n * Vertical-autofit mode of a text frame, read from the `a:bodyPr` child element:\n * - `'none'`: no autofit (`a:noAutofit`, or no autofit child at all). The box has a\n * fixed height the text must fit inside — a genuine overflow candidate.\n * - `'normAutofit'`: shrink text to fit (`a:normAutofit`, pptx-ts `fit: 'shrink'`).\n * Text is downscaled rather than overflowing.\n * - `'spAutoFit'`: resize shape to fit text (`a:spAutoFit`, pptx-ts `fit: 'resize'`).\n * The authored height is an output, not a constraint, so the box cannot overflow.\n */\nexport type PptxAutofitMode = 'none' | 'normAutofit' | 'spAutoFit'\n\n/**\n * Text-frame body insets in inches (`a:bodyPr` `lIns`/`tIns`/`rIns`/`bIns`), with\n * PowerPoint defaults applied when an attribute is absent (0.1in left/right,\n * 0.05in top/bottom). Subtract these from {@link PptxBox} to get the inner text box.\n */\nexport interface PptxBodyInsets {\n\tleft: number\n\ttop: number\n\tright: number\n\tbottom: number\n}\n\nexport interface PptxSlideElement {\n\t/** `p:cNvPr/@id`, or `zIndex + 1` when the attribute is missing. */\n\tid: number\n\tname: string\n\tkind: PptxSlideElementKind\n\t/**\n\t * What a `'graphicFrame'` element hosts, or `null` for every other kind. See\n\t * {@link PptxGraphicKind}.\n\t */\n\tgraphicKind: PptxGraphicKind | null\n\t/**\n\t * Paint order on the slide, `0`-based: the element's position in a depth-first\n\t * walk of `p:spTree` in document order. A group is immediately followed by its\n\t * own children, which is also the order PowerPoint paints them, so a higher\n\t * `zIndex` draws on top. Unique within a slide, which is what\n\t * {@link parentZIndex} / {@link childZIndices} key on.\n\t */\n\tzIndex: number\n\t/**\n\t * Position and size in **slide-absolute** inches, composing every enclosing\n\t * group transform — directly comparable across elements whether or not they are\n\t * grouped. For a rotated element this is the unrotated placement box (the box\n\t * PowerPoint writes after Ungroup); see {@link rotation}.\n\t */\n\tbox: PptxBox\n\t/**\n\t * Effective clockwise rotation in degrees, normalised to `[0, 360)`, after\n\t * composing the element's own `a:xfrm@rot` with every enclosing group rotation.\n\t */\n\trotation: number\n\t/** Effective horizontal flip, XOR-composing the element's own `@flipH` with enclosing group flips. */\n\tflipH: boolean\n\t/** Effective vertical flip, XOR-composing the element's own `@flipV` with enclosing group flips. */\n\tflipV: boolean\n\t/** {@link zIndex} of the enclosing `'group'` element, or `null` when the element sits at slide level. */\n\tparentZIndex: number | null\n\t/** {@link zIndex} of each direct child, in document order. Empty unless {@link kind} is `'group'`. */\n\tchildZIndices: number[]\n\t/**\n\t * The element's text, whitespace-collapsed to one line. For a `'graphicFrame'`\n\t * this is the text the structure puts on the slide (table cells in row order,\n\t * SmartArt node text), which is what {@link PptxSlideInspection.text} and\n\t * `wordCount` then count; a chart contributes nothing, matching `Slide.text` on\n\t * the read model. That text has no {@link textRuns} or {@link paragraphs} here —\n\t * per-run formatting inside a structure is what this surface does not flatten.\n\t */\n\ttext: string\n\ttextWrap: string | null\n\tautofit: PptxAutofitMode | null\n\t/**\n\t * Baked shrink scale from `<a:normAutofit@fontScale>` as a percent (62.5 = 62.5%),\n\t * or null when the frame has no `normAutofit` or bakes no scale (a bare\n\t * `<a:normAutofit/>`, which PowerPoint draws at 100% until edited).\n\t */\n\tautofitFontScale: number | null\n\tbodyInsets: PptxBodyInsets | null\n\ttextRuns: PptxTextRun[]\n\t/** Runs grouped by their source paragraph (`a:p`), in document order. */\n\tparagraphs: PptxParagraph[]\n\tfontSizes: number[]\n\tcolors: string[]\n\tfill: string | null\n\tline: string | null\n\tshapeType: string | null\n}\n\nexport interface PptxSlideInspection {\n\tindex: number\n\tname: string\n\tpath: string\n\tsize: PptxSlideSize\n\telements: PptxSlideElement[]\n\ttext: string\n\twordCount: number\n}\n\nexport interface PptxInspection {\n\tslideSize: PptxSlideSize\n\tslides: PptxSlideInspection[]\n}\n\nexport type PptxBoxAxis = 'x' | 'y'\nexport type PptxBoxAnchor = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom'\n\n/**\n * The size reported for a deck that declares no `p:sldSz`: the 10in × 7.5in PowerPoint opens such\n * a deck at, which is also what the script converter assumes. It was the widescreen size, so the\n * two readers disagreed about the same deck. See `ABSENT_SLIDE_SIZE_EMU`.\n */\nexport const DEFAULT_INSPECT_SLIDE_SIZE: PptxSlideSize = Object.freeze({\n\twidthIn: round(emuToInches(ABSENT_SLIDE_SIZE_EMU.widthEmu), 3),\n\theightIn: round(emuToInches(ABSENT_SLIDE_SIZE_EMU.heightEmu), 3),\n})\n\n/* ────────────────────────────────────────────────────────────────────────────\n * Package layer\n *\n * Thin conveniences over `OpcPackage`, kept because this surface speaks zip\n * paths (`ppt/slides/slide1.xml`) while OPC speaks partnames (`/ppt/...`), and\n * because reaching a part's bytes is the one thing a caller of a *flat* surface\n * still routinely needs.\n * ──────────────────────────────────────────────────────────────────────────── */\n\n/**\n * Load a `.pptx` as an {@link OpcPackage} — the same package model `pptx-ts/read`\n * uses, so a caller that starts here can hand the result straight to\n * `Presentation.fromPackage()` without re-reading the bytes.\n *\n * The input must be a real OPC package: a zip that merely contains some slide XML\n * but no `[Content_Types].xml` is rejected with a `PackageReadError`.\n */\nexport async function loadPptxPackage(input: PptxInspectInput): Promise<OpcPackage> {\n\treturn OpcPackage.load(await input)\n}\n\n/** Every part in the package, as zip paths (`ppt/slides/slide1.xml`), sorted. */\nexport function listPptxParts(pptxPackage: OpcPackage): string[] {\n\treturn [...pptxPackage.parts.keys()].map(zipPathOf).sort()\n}\n\n/** Read a package part as UTF-8 text, or `null` when the part is absent. */\nexport async function readPptxTextPart(pptxPackage: OpcPackage, path: string): Promise<string | null> {\n\tconst bytes = await readPptxBinaryPart(pptxPackage, path)\n\treturn bytes ? textDecoder.decode(bytes) : null\n}\n\n/**\n * Read a package part as raw bytes — the binary sibling of {@link readPptxTextPart}\n * for embedded media (SVG/PNG/EMF blobs, fonts, …) that must not be UTF-8 decoded.\n * Returns `null` when the part is absent. The `Uint8Array` is browser-isomorphic;\n * Node consumers can wrap it with `Buffer.from(...)` if they need Buffer methods.\n *\n * The part's current body, so a package also opened as a `Presentation` and edited\n * reads back with its edits.\n */\nexport async function readPptxBinaryPart(pptxPackage: OpcPackage, path: string): Promise<Uint8Array | null> {\n\treturn pptxPackage.part(partNameOf(path))?.serialize() ?? null\n}\n\nconst textDecoder = new TextDecoder('utf-8')\n\n/** OPC partnames are absolute (`/ppt/…`); this surface speaks zip paths (`ppt/…`). */\nfunction zipPathOf(partName: string): string {\n\treturn partName.startsWith('/') ? partName.slice(1) : partName\n}\n\nfunction partNameOf(zipPath: string): string {\n\treturn zipPath.startsWith('/') ? zipPath : `/${zipPath}`\n}\n\n/* ────────────────────────────────────────────────────────────────────────────\n * The surface\n * ──────────────────────────────────────────────────────────────────────────── */\n\nexport async function inspectPptx(input: PptxInspectInput): Promise<PptxInspection> {\n\tconst pptxPackage = await loadPptxPackage(input)\n\tconst slideSize = await readPresentationSize(pptxPackage)\n\tconst slides = await extractSlides(pptxPackage, slideSize)\n\treturn { slideSize, slides }\n}\n\nexport async function readPresentationSize(\n\tpptxPackage: OpcPackage,\n\tfallback: PptxSlideSize = DEFAULT_INSPECT_SLIDE_SIZE\n): Promise<PptxSlideSize> {\n\tconst size = presentationOf(pptxPackage)?.slideSize\n\tif (!size) return fallback\n\treturn { widthIn: round(size.widthIn, 3), heightIn: round(size.heightIn, 3) }\n}\n\n/**\n * Every slide in the deck, in **presentation order** (`p:sldIdLst`) — the order\n * PowerPoint shows them in, which is not the order their parts are named once a\n * deck has been reordered.\n */\nexport async function extractSlides(pptxPackage: OpcPackage, size?: PptxSlideSize): Promise<PptxSlideInspection[]> {\n\tconst slideSize = size || (await readPresentationSize(pptxPackage))\n\tconst presentation = presentationOf(pptxPackage)\n\tif (!presentation) return []\n\n\treturn presentation.slides.map((slide, index) => {\n\t\tconst path = zipPathOf(slide.partName)\n\t\tconst harvested: HarvestedShape[] = []\n\t\tharvest(slide.shapes, null, harvested) // slide level: no enclosing group\n\t\tconst elements = flatten(harvested, path)\n\t\tconst text = elements\n\t\t\t.map((el) => el.text)\n\t\t\t.filter(Boolean)\n\t\t\t.join(' ')\n\n\t\treturn {\n\t\t\tindex,\n\t\t\tname: slide.name || `Slide ${index + 1}`,\n\t\t\tpath,\n\t\t\tsize: slideSize,\n\t\t\telements,\n\t\t\ttext,\n\t\t\twordCount: countWords(text),\n\t\t}\n\t})\n}\n\n/**\n * The deck's `Presentation`, or `null` when the package holds no readable\n * `presentation.xml`. Callers here are auditing files they did not author, so a\n * package that is a valid OPC container but not a presentation reports an empty\n * deck rather than throwing. `presentationPart` is the throw site: it rejects a\n * package with no — or more than one — office-document relationship.\n */\nfunction presentationOf(pptxPackage: OpcPackage): Presentation | null {\n\tconst presentation = Presentation.fromPackage(pptxPackage)\n\ttry {\n\t\treturn presentation.presentationPart.isXmlPart ? presentation : null\n\t} catch {\n\t\treturn null\n\t}\n}\n\nexport function overlapArea(a: PptxBox, b: PptxBox): number {\n\tconst x = Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x))\n\tconst y = Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y))\n\treturn x * y\n}\n\nexport function boxAnchor(box: PptxBox, anchor: PptxBoxAnchor, axis: PptxBoxAxis): number {\n\tif (axis === 'x') {\n\t\tif (anchor === 'left') return box.x\n\t\tif (anchor === 'right') return box.x + box.w\n\t\treturn box.x + box.w / 2\n\t}\n\tif (anchor === 'top') return box.y\n\tif (anchor === 'bottom') return box.y + box.h\n\treturn box.y + box.h / 2\n}\n\n/* ────────────────────────────────────────────────────────────────────────────\n * Shape-tree harvest\n * ──────────────────────────────────────────────────────────────────────────── */\n\n/** One harvested shape, before it is flattened into a {@link PptxSlideElement}. */\ninterface HarvestedShape {\n\tshape: AnyShape\n\tparentZIndex: number | null\n\tchildZIndices: number[]\n}\n\n/**\n * Flatten a shape list depth-first in document order: each shape is followed by\n * its descendants, which is both paint order and the order the\n * {@link PptxSlideElement.zIndex} contract promises. Every entry's index in `out`\n * is its zIndex. Returns the zIndices assigned at this level, which is what the\n * enclosing group records as its {@link PptxSlideElement.childZIndices}.\n */\nfunction harvest(shapes: AnyShape[], parentZIndex: number | null, out: HarvestedShape[]): number[] {\n\tconst zIndices: number[] = []\n\tfor (const shape of shapes) {\n\t\tconst entry: HarvestedShape = { shape, parentZIndex, childZIndices: [] }\n\t\tconst zIndex = out.push(entry) - 1\n\t\tzIndices.push(zIndex)\n\t\tif (shape.shapeType === 'group') entry.childZIndices = harvest(shape.shapes, zIndex, out)\n\t}\n\treturn zIndices\n}\n\n/**\n * Turn harvested shapes into elements, dropping the ones with no resolvable slide\n * position. A dropped shape keeps its zIndex — the numbers are positions in the\n * shape tree, and renumbering them would silently repoint every `parentZIndex`.\n */\nfunction flatten(harvested: HarvestedShape[], slidePath: string): PptxSlideElement[] {\n\treturn harvested\n\t\t.map((entry, zIndex) => toElement(entry, zIndex, slidePath))\n\t\t.filter((element): element is PptxSlideElement => Boolean(element))\n}\n\nfunction toElement(entry: HarvestedShape, zIndex: number, slidePath: string): PptxSlideElement | null {\n\tconst { shape } = entry\n\tconst frame = shape.absoluteFrame\n\tif (!frame) {\n\t\treportUnresolvable(shape, zIndex, slidePath)\n\t\treturn null\n\t}\n\n\t// Only `p:sp` holds a text body, so every other kind projects as an empty frame.\n\tconst textFrame = shape.textFrame\n\tconst paragraphs = textFrame ? textFrame.paragraphs.map((p) => ({ runs: p.runs.map(toRun) })) : []\n\tconst textRuns = paragraphs.flatMap((paragraph) => paragraph.runs)\n\t// A graphic frame has no text body of its own; its text comes from the structure\n\t// it hosts, and arrives as a plain string with no runs behind it.\n\t// Paragraphs are joined by a line break, so the last word of one and the first of the next stay\n\t// two words once the whitespace collapses below.\n\tconst runText = paragraphs.map((paragraph) => paragraph.runs.map((run) => run.text).join('')).join('\\n')\n\tconst raw = shape.shapeType === 'graphicFrame' ? graphicFrameText(shape) : runText\n\t// Deliberately not `TextFrame.text`: this is one whitespace-collapsed line for\n\t// matching and word-counting, not the frame's text with its line structure.\n\tconst text = raw.replace(/\\s+/g, ' ').trim()\n\tconst kind: PptxSlideElementKind =\n\t\tshape.shapeType === 'group'\n\t\t\t? 'group'\n\t\t\t: shape.shapeType === 'graphicFrame'\n\t\t\t\t? 'graphicFrame'\n\t\t\t\t: text\n\t\t\t\t\t? 'text'\n\t\t\t\t\t: shape.shapeType === 'picture'\n\t\t\t\t\t\t? 'image'\n\t\t\t\t\t\t: 'shape'\n\n\treturn {\n\t\tid: shape.id ?? zIndex + 1,\n\t\tname: shape.name || `${kind} ${zIndex + 1}`,\n\t\tkind,\n\t\tgraphicKind: shape.shapeType === 'graphicFrame' ? graphicKindOf(shape) : null,\n\t\tzIndex,\n\t\tbox: {\n\t\t\tx: emuToInches(frame.left),\n\t\t\ty: emuToInches(frame.top),\n\t\t\tw: emuToInches(frame.width),\n\t\t\th: emuToInches(frame.height),\n\t\t},\n\t\trotation: frame.rotation,\n\t\tflipH: frame.flipH,\n\t\tflipV: frame.flipV,\n\t\tparentZIndex: entry.parentZIndex,\n\t\tchildZIndices: entry.childZIndices,\n\t\ttext,\n\t\ttextWrap: textFrame?.bodyProperties?.wrap ?? null,\n\t\tautofit: textFrame?.autofit ?? null,\n\t\tautofitFontScale: textFrame?.autofitFontScale ?? null,\n\t\tbodyInsets: readBodyInsets(textFrame),\n\t\ttextRuns,\n\t\tparagraphs,\n\t\tfontSizes: [...new Set(textRuns.map((run) => run.fontSizePt).filter((size): size is number => size !== null))],\n\t\tcolors: [...new Set(textRuns.map((run) => run.color).filter((color): color is string => Boolean(color)))],\n\t\tfill: shape.fillColor,\n\t\tline: shape.lineColor,\n\t\tshapeType: shape.presetGeometry,\n\t}\n}\n\n/**\n * What a graphic frame hosts, from the same `a:graphicData/@uri` the read model's\n * `has*` predicates compare against. A frame that answers none of them is `'other'`\n * rather than dropped: a box the deck's author placed is on the slide whether or not\n * this library models its payload, and an overlap or coverage check that skipped it\n * would report a gap where a 3D model or an OLE object sits.\n */\nfunction graphicKindOf(frame: GraphicFrame): PptxGraphicKind {\n\tif (frame.hasTable) return 'table'\n\tif (frame.hasChart) return 'chart'\n\tif (frame.hasChartEx) return 'chartEx'\n\tif (frame.hasDiagram) return 'diagram'\n\treturn 'other'\n}\n\n/**\n * The text a graphic frame puts on the slide: table cells in row order, or SmartArt\n * node text. Charts contribute nothing, matching `Slide.text` on the read model — a\n * chart's strings are data labels and axis titles that PowerPoint itself does not\n * treat as slide body text.\n *\n * Separators are single spaces rather than the read model's `\t`/`\n`, because the\n * caller collapses whitespace anyway; the point here is only that cells do not run\n * together into one word.\n */\nfunction graphicFrameText(frame: GraphicFrame): string {\n\tconst table = frame.table\n\tif (table) return table.rows.map((row) => row.cells.map((cell) => cell.text).join(' ')).join(' ')\n\treturn frame.diagram?.text ?? ''\n}\n\n/** Project one read-model {@link Run} onto the flat run shape. */\nfunction toRun(run: Run): PptxTextRun {\n\treturn {\n\t\ttext: run.text,\n\t\tfontSizePt: run.fontSizePt,\n\t\tcolor: run.color,\n\t\tfontFace: run.fontName,\n\t\t// The read model distinguishes \"explicitly not bold\" from \"unset, inherits\";\n\t\t// this surface reports what renders, so an unset flag is `false`.\n\t\tbold: run.bold ?? false,\n\t\titalic: run.italic ?? false,\n\t\tstrike: run.strike,\n\t\thighlight: run.highlight?.hex ?? null,\n\t\tcharSpacingPt: run.charSpacingPt,\n\t}\n}\n\nfunction readBodyInsets(textFrame: TextFrame | null): PptxBodyInsets | null {\n\tconst insets = textFrame?.bodyProperties?.insetsPt\n\tif (!insets) return null\n\t// The read model reports only the explicitly-set sides; an omitted one takes PowerPoint's\n\t// own default rather than zero.\n\tconst inches = (pt: number | undefined, fallbackPt: number): number =>\n\t\t(pt === undefined ? fallbackPt : pt) / POINTS_PER_INCH\n\treturn {\n\t\tleft: inches(insets.left, BODY_INSET_DEFAULTS_PT.left),\n\t\ttop: inches(insets.top, BODY_INSET_DEFAULTS_PT.top),\n\t\tright: inches(insets.right, BODY_INSET_DEFAULTS_PT.right),\n\t\tbottom: inches(insets.bottom, BODY_INSET_DEFAULTS_PT.bottom),\n\t}\n}\n\n/**\n * Warn about a shape whose slide position cannot be resolved, unless it never\n * claimed one.\n *\n * `absoluteFrame` is `null` for three different situations and only two of them\n * are worth telling the caller about; `absoluteFrameFailure` is the read model\n * naming which, so this surface does not walk the ancestry a second time to\n * re-derive it.\n */\nfunction reportUnresolvable(shape: AnyShape, zIndex: number, slidePath: string): void {\n\tconst failure = shape.absoluteFrameFailure\n\t// No own `a:xfrm` at all: the shape inherits its geometry from a layout\n\t// placeholder, which this surface deliberately does not resolve. Nothing is\n\t// wrong with the deck, so nothing is reported. (`null` cannot reach here — the\n\t// caller only calls this for a shape whose frame did not resolve.)\n\tif (failure === null || failure === 'no-own-transform') return\n\n\tconst who = shape.name ? `\"${shape.name}\"` : `the element at zIndex ${zIndex}`\n\tif (failure === 'group-transform-missing') {\n\t\twarn(\n\t\t\t'inspect/group-transform-missing',\n\t\t\t`inspect: skipped ${who} on ${slidePath} — an enclosing group has no usable a:xfrm, so its slide position cannot be resolved.`\n\t\t)\n\t\treturn\n\t}\n\twarn(\n\t\t'inspect/group-transform-degenerate',\n\t\t`inspect: skipped ${who} on ${slidePath} — an enclosing group has a degenerate transform (zero a:chExt), so its slide position cannot be resolved.`\n\t)\n}\n\nfunction countWords(text: string): number {\n\treturn text.split(/\\s+/).filter(Boolean).length\n}\n\nfunction round(value: number, digits: number): number {\n\tconst factor = 10 ** digits\n\treturn Math.round(value * factor) / factor\n}\n\n// Error taxonomy — see `entry-errors.ts`. Re-exported from every entry so `instanceof`\n// works whichever subpath a consumer imports.\nexport * from './entry-errors.js'\n\n// Diagnostics — see `entry-diagnostics.ts`. Re-exported from every entry so a consumer of any\n// subpath can install a handler for the warnings that subpath emits.\nexport * from './entry-diagnostics.js'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwNA,MAAa,6BAA4C,OAAO,OAAO;CACtE,SAAS,MAAM,YAAY,sBAAsB,QAAQ,GAAG,CAAC;CAC7D,UAAU,MAAM,YAAY,sBAAsB,SAAS,GAAG,CAAC;AAChE,CAAC;;;;;;;;;AAmBD,eAAsB,gBAAgB,OAA8C;CACnF,OAAO,WAAW,KAAK,MAAM,KAAK;AACnC;;AAGA,SAAgB,cAAc,aAAmC;CAChE,OAAO,CAAC,GAAG,YAAY,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,KAAK;AAC1D;;AAGA,eAAsB,iBAAiB,aAAyB,MAAsC;CACrG,MAAM,QAAQ,MAAM,mB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AO;EACN,MAAM,OAAO,OAAO,MAAM,uBAAuB,IAAI;EACrD,KAAK,OAAO,OAAO,KAAK,uBAAuB,GAAG;EAClD,OAAO,OAAO,OAAO,OAAO,uBAAuB,KAAK;EACxD,QAAQ,OAAO,OAAO,QAAQ,uBAAuB,MAAM;CAC5D;AACD;;;;;;;;;;AAWA,SAAS,mBAAmB,OAAiB,QAAgB,WAAyB;CACrF,MAAM,UAAU,MAAM;CAKtB,IAAI,YAAY,QAAQ,YAAY,oBAAoB;CAExD,MAAM,MAAM,MAAM,OAAO,IAAI,MAAM,KAAK,KAAK,yBAAyB;CACtE,IAAI,YAAY,2BAA2B;EAC1C,KACC,mCACA,oBAAoB,IAAI,MAAM,UAAU,sFACzC;EACA;CACD;CACA,KACC,sCACA,oBAAoB,IAAI,MAAM,UAAU,2GACzC;AACD;AAEA,SAAS,WAAW,MAAsB;CACzC,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C;AAEA,SAAS,MAAM,OAAe,QAAwB;CACrD,MAAM,SAAS,MAAM;CACrB,OAAO,KAAK,MAAM,QAAQ,MAAM,IAAI;AACrC"}
|
|
1
|
+
{"version":3,"file":"inspect.js","names":[],"sources":["../src/inspect.ts"],"sourcesContent":["/**\n * A cheap, flat snapshot of what a `.pptx` contains: every element on every\n * slide, with its slide-absolute box and the handful of text/fill properties a\n * layout audit asks about.\n *\n * It is a **projection over `pptx-ts/read`**, not a second reader. `read` gives a\n * navigable, mutable model of a package and answers questions in the shape of the\n * OOXML tree; this answers one flat question (\"what is on the slides, and where\")\n * in the shape a linter, an overlap check, or a diffing tool wants. The two used\n * to be independent implementations over two different XML parsers, which meant\n * every read-side fix had to be made twice and a divergence between them was\n * invisible to every test. Now the model below is the only reader, and this file\n * is the flattening.\n *\n * What it deliberately does NOT do, and why the projection is not just\n * `Presentation` re-exported:\n * - **Only geometry a shape carries itself.** A placeholder that inherits its box\n * from the layout is omitted rather than resolved (`absoluteFrame`, not\n * `resolvedFrame`): the snapshot reports what the slide states.\n * - **A `p:graphicFrame` is a box, not its contents.** A table, chart or SmartArt\n * graphic is reported as one element with its box, its kind, and the text a\n * reader sees on the slide, but its structure is not flattened: no per-run\n * formatting, no cells, no series. Walk `pptx-ts/read` for what is inside one.\n *\n * @module\n */\nimport { warn } from './diagnostics.js'\nimport { OpcPackage } from './read/opc/package.js'\nimport { Presentation } from './read/api/presentation.js'\nimport type { AnyShape } from './read/api/shapes.js'\nimport type { GraphicFrame } from './read/api/shapes/graphic-frame.js'\nimport type { Run, TextFrame } from './read/api/text.js'\nimport { POINTS_PER_INCH, emuToInches } from './units.js'\nimport { BODY_INSET_DEFAULTS_PT } from './ooxml/body-insets.js'\nimport { ABSENT_SLIDE_SIZE_EMU } from './ooxml/slide-size.js'\n\n/**\n * Input to the inspect surface. A `string` is a **filesystem path** (Node) read\n * from disk; pass `Uint8Array`/`ArrayBuffer`/`Blob`/`number[]` for an in-memory\n * archive. (A string is a path, not JSZip's latin1 binary content; see\n * `ZipInput`.)\n */\nexport type PptxInspectInputValue = string | number[] | Uint8Array | ArrayBuffer | Blob\n\nexport type PptxInspectInput = PptxInspectInputValue | Promise<PptxInspectInputValue>\n\nexport interface PptxSlideSize {\n\twidthIn: number\n\theightIn: number\n}\n\nexport interface PptxBox {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n}\n\nexport interface PptxTextRun {\n\ttext: string\n\tfontSizePt: number | null\n\tcolor: string | null\n\t/** Run font face (`a:rPr > a:latin@typeface`), or null when it inherits from the theme/placeholder. */\n\tfontFace: string | null\n\t/** Bold (`a:rPr@b`). */\n\tbold: boolean\n\t/** Italic (`a:rPr@i`). */\n\titalic: boolean\n\t/** Strikethrough token (`a:rPr@strike`: `noStrike`/`sngStrike`/`dblStrike`), or null when unset. */\n\tstrike: string | null\n\t/** Highlight colour hex (`a:rPr > a:highlight`), or null when unset. A theme token is resolved against the slide's theme. */\n\thighlight: string | null\n\t/** Character spacing in points (`a:rPr@spc`, authored in hundredths of a point), or null when unset. */\n\tcharSpacingPt: number | null\n}\n\n/**\n * One paragraph (`a:p`): its runs in document order. Preserves the paragraph/line\n * boundaries that the flat {@link PptxSlideElement.textRuns} list discards, needed\n * to measure a `wrap=\"none\"` frame line-by-line (each paragraph is one unwrapped line).\n */\nexport interface PptxParagraph {\n\truns: PptxTextRun[]\n}\n\n/**\n * What an element is. `'group'` is a `p:grpSp` container: it has its own identity,\n * box, and fill, but no text of its own. Its content is the elements that name it\n * in {@link PptxSlideElement.parentZIndex}. `'graphicFrame'` is a `p:graphicFrame`\n * hosting a table, a chart or a SmartArt graphic; {@link PptxSlideElement.graphicKind}\n * says which, and it keeps that kind even when it carries text (a `'text'` element is\n * always a `p:sp`).\n */\nexport type PptxSlideElementKind = 'text' | 'image' | 'shape' | 'group' | 'graphicFrame'\n\n/**\n * What a `'graphicFrame'` element hosts, read from its `a:graphicData/@uri`:\n * a table (`a:tbl`), a classic chart (`c:chart`), a 2016-family chart\n * (`cx:chartSpace`: waterfall/funnel/treemap/…), or a SmartArt diagram. `'other'`\n * is a frame whose URI matches none of those (an OLE object, an ink part, a 3D\n * model), reported as a box so it is not silently missing from the slide.\n */\nexport type PptxGraphicKind = 'table' | 'chart' | 'chartEx' | 'diagram' | 'other'\n\n/**\n * Vertical-autofit mode of a text frame, read from the `a:bodyPr` child element:\n * - `'none'`: no autofit (`a:noAutofit`, or no autofit child at all). The box has a\n * fixed height the text must fit inside: a genuine overflow candidate.\n * - `'normAutofit'`: shrink text to fit (`a:normAutofit`, pptx-ts `fit: 'shrink'`).\n * Text is downscaled rather than overflowing.\n * - `'spAutoFit'`: resize shape to fit text (`a:spAutoFit`, pptx-ts `fit: 'resize'`).\n * The authored height is an output, not a constraint, so the box cannot overflow.\n */\nexport type PptxAutofitMode = 'none' | 'normAutofit' | 'spAutoFit'\n\n/**\n * Text-frame body insets in inches (`a:bodyPr` `lIns`/`tIns`/`rIns`/`bIns`), with\n * PowerPoint defaults applied when an attribute is absent (0.1in left/right,\n * 0.05in top/bottom). Subtract these from {@link PptxBox} to get the inner text box.\n */\nexport interface PptxBodyInsets {\n\tleft: number\n\ttop: number\n\tright: number\n\tbottom: number\n}\n\nexport interface PptxSlideElement {\n\t/** `p:cNvPr/@id`, or `zIndex + 1` when the attribute is missing. */\n\tid: number\n\tname: string\n\tkind: PptxSlideElementKind\n\t/**\n\t * What a `'graphicFrame'` element hosts, or `null` for every other kind. See\n\t * {@link PptxGraphicKind}.\n\t */\n\tgraphicKind: PptxGraphicKind | null\n\t/**\n\t * Paint order on the slide, `0`-based: the element's position in a depth-first\n\t * walk of `p:spTree` in document order. A group is immediately followed by its\n\t * own children, which is also the order PowerPoint paints them, so a higher\n\t * `zIndex` draws on top. Unique within a slide, which is what\n\t * {@link parentZIndex} / {@link childZIndices} key on.\n\t */\n\tzIndex: number\n\t/**\n\t * Position and size in **slide-absolute** inches, composing every enclosing\n\t * group transform, so it is directly comparable across elements whether or not they are\n\t * grouped. For a rotated element this is the unrotated placement box (the box\n\t * PowerPoint writes after Ungroup); see {@link rotation}.\n\t */\n\tbox: PptxBox\n\t/**\n\t * Effective clockwise rotation in degrees, normalised to `[0, 360)`, after\n\t * composing the element's own `a:xfrm@rot` with every enclosing group rotation.\n\t */\n\trotation: number\n\t/** Effective horizontal flip, XOR-composing the element's own `@flipH` with enclosing group flips. */\n\tflipH: boolean\n\t/** Effective vertical flip, XOR-composing the element's own `@flipV` with enclosing group flips. */\n\tflipV: boolean\n\t/** {@link zIndex} of the enclosing `'group'` element, or `null` when the element sits at slide level. */\n\tparentZIndex: number | null\n\t/** {@link zIndex} of each direct child, in document order. Empty unless {@link kind} is `'group'`. */\n\tchildZIndices: number[]\n\t/**\n\t * The element's text, whitespace-collapsed to one line. For a `'graphicFrame'`\n\t * this is the text the structure puts on the slide (table cells in row order,\n\t * SmartArt node text), which is what {@link PptxSlideInspection.text} and\n\t * `wordCount` then count; a chart contributes nothing, matching `Slide.text` on\n\t * the read model. That text has no {@link textRuns} or {@link paragraphs} here;\n\t * per-run formatting inside a structure is what this surface does not flatten.\n\t */\n\ttext: string\n\ttextWrap: string | null\n\tautofit: PptxAutofitMode | null\n\t/**\n\t * Baked shrink scale from `<a:normAutofit@fontScale>` as a percent (62.5 = 62.5%),\n\t * or null when the frame has no `normAutofit` or bakes no scale (a bare\n\t * `<a:normAutofit/>`, which PowerPoint draws at 100% until edited).\n\t */\n\tautofitFontScale: number | null\n\tbodyInsets: PptxBodyInsets | null\n\ttextRuns: PptxTextRun[]\n\t/** Runs grouped by their source paragraph (`a:p`), in document order. */\n\tparagraphs: PptxParagraph[]\n\tfontSizes: number[]\n\tcolors: string[]\n\tfill: string | null\n\tline: string | null\n\tshapeType: string | null\n}\n\nexport interface PptxSlideInspection {\n\tindex: number\n\tname: string\n\tpath: string\n\tsize: PptxSlideSize\n\telements: PptxSlideElement[]\n\ttext: string\n\twordCount: number\n}\n\nexport interface PptxInspection {\n\tslideSize: PptxSlideSize\n\tslides: PptxSlideInspection[]\n}\n\nexport type PptxBoxAxis = 'x' | 'y'\nexport type PptxBoxAnchor = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom'\n\n/**\n * The size reported for a deck that declares no `p:sldSz`: the 10in × 7.5in PowerPoint opens such\n * a deck at, which is also what the script converter assumes. It was the widescreen size, so the\n * two readers disagreed about the same deck. See `ABSENT_SLIDE_SIZE_EMU`.\n */\nexport const DEFAULT_INSPECT_SLIDE_SIZE: PptxSlideSize = Object.freeze({\n\twidthIn: round(emuToInches(ABSENT_SLIDE_SIZE_EMU.widthEmu), 3),\n\theightIn: round(emuToInches(ABSENT_SLIDE_SIZE_EMU.heightEmu), 3),\n})\n\n/* ────────────────────────────────────────────────────────────────────────────\n * Package layer\n *\n * Thin conveniences over `OpcPackage`, kept because this surface speaks zip\n * paths (`ppt/slides/slide1.xml`) while OPC speaks partnames (`/ppt/...`), and\n * because reaching a part's bytes is the one thing a caller of a *flat* surface\n * still routinely needs.\n * ──────────────────────────────────────────────────────────────────────────── */\n\n/**\n * Load a `.pptx` as an {@link OpcPackage}, the same package model `pptx-ts/read`\n * uses, so a caller that starts here can hand the result straight to\n * `Presentation.fromPackage()` without re-reading the bytes.\n *\n * The input must be a real OPC package: a zip that merely contains some slide XML\n * but no `[Content_Types].xml` is rejected with a `PackageReadError`.\n */\nexport async function loadPptxPackage(input: PptxInspectInput): Promise<OpcPackage> {\n\treturn OpcPackage.load(await input)\n}\n\n/** Every part in the package, as zip paths (`ppt/slides/slide1.xml`), sorted. */\nexport function listPptxParts(pptxPackage: OpcPackage): string[] {\n\treturn [...pptxPackage.parts.keys()].map(zipPathOf).sort()\n}\n\n/** Read a package part as UTF-8 text, or `null` when the part is absent. */\nexport async function readPptxTextPart(pptxPackage: OpcPackage, path: string): Promise<string | null> {\n\tconst bytes = await readPptxBinaryPart(pptxPackage, path)\n\treturn bytes ? textDecoder.decode(bytes) : null\n}\n\n/**\n * Read a package part as raw bytes: the binary sibling of {@link readPptxTextPart}\n * for embedded media (SVG/PNG/EMF blobs, fonts, …) that must not be UTF-8 decoded.\n * Returns `null` when the part is absent. The `Uint8Array` is browser-isomorphic;\n * Node consumers can wrap it with `Buffer.from(...)` if they need Buffer methods.\n *\n * The part's current body, so a package also opened as a `Presentation` and edited\n * reads back with its edits.\n */\nexport async function readPptxBinaryPart(pptxPackage: OpcPackage, path: string): Promise<Uint8Array | null> {\n\treturn pptxPackage.part(partNameOf(path))?.serialize() ?? null\n}\n\nconst textDecoder = new TextDecoder('utf-8')\n\n/** OPC partnames are absolute (`/ppt/…`); this surface speaks zip paths (`ppt/…`). */\nfunction zipPathOf(partName: string): string {\n\treturn partName.startsWith('/') ? partName.slice(1) : partName\n}\n\nfunction partNameOf(zipPath: string): string {\n\treturn zipPath.startsWith('/') ? zipPath : `/${zipPath}`\n}\n\n/* ────────────────────────────────────────────────────────────────────────────\n * The surface\n * ──────────────────────────────────────────────────────────────────────────── */\n\nexport async function inspectPptx(input: PptxInspectInput): Promise<PptxInspection> {\n\tconst pptxPackage = await loadPptxPackage(input)\n\tconst slideSize = await readPresentationSize(pptxPackage)\n\tconst slides = await extractSlides(pptxPackage, slideSize)\n\treturn { slideSize, slides }\n}\n\nexport async function readPresentationSize(\n\tpptxPackage: OpcPackage,\n\tfallback: PptxSlideSize = DEFAULT_INSPECT_SLIDE_SIZE\n): Promise<PptxSlideSize> {\n\tconst size = presentationOf(pptxPackage)?.slideSize\n\tif (!size) return fallback\n\treturn { widthIn: round(size.widthIn, 3), heightIn: round(size.heightIn, 3) }\n}\n\n/**\n * Every slide in the deck, in **presentation order** (`p:sldIdLst`): the order\n * PowerPoint shows them in, which is not the order their parts are named once a\n * deck has been reordered.\n */\nexport async function extractSlides(pptxPackage: OpcPackage, size?: PptxSlideSize): Promise<PptxSlideInspection[]> {\n\tconst slideSize = size || (await readPresentationSize(pptxPackage))\n\tconst presentation = presentationOf(pptxPackage)\n\tif (!presentation) return []\n\n\treturn presentation.slides.map((slide, index) => {\n\t\tconst path = zipPathOf(slide.partName)\n\t\tconst harvested: HarvestedShape[] = []\n\t\tharvest(slide.shapes, null, harvested) // slide level: no enclosing group\n\t\tconst elements = flatten(harvested, path)\n\t\tconst text = elements\n\t\t\t.map((el) => el.text)\n\t\t\t.filter(Boolean)\n\t\t\t.join(' ')\n\n\t\treturn {\n\t\t\tindex,\n\t\t\tname: slide.name || `Slide ${index + 1}`,\n\t\t\tpath,\n\t\t\tsize: slideSize,\n\t\t\telements,\n\t\t\ttext,\n\t\t\twordCount: countWords(text),\n\t\t}\n\t})\n}\n\n/**\n * The deck's `Presentation`, or `null` when the package holds no readable\n * `presentation.xml`. Callers here are auditing files they did not author, so a\n * package that is a valid OPC container but not a presentation reports an empty\n * deck rather than throwing. `presentationPart` is the throw site: it rejects a\n * package with no office-document relationship, or with more than one.\n */\nfunction presentationOf(pptxPackage: OpcPackage): Presentation | null {\n\tconst presentation = Presentation.fromPackage(pptxPackage)\n\ttry {\n\t\treturn presentation.presentationPart.isXmlPart ? presentation : null\n\t} catch {\n\t\treturn null\n\t}\n}\n\nexport function overlapArea(a: PptxBox, b: PptxBox): number {\n\tconst x = Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x))\n\tconst y = Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y))\n\treturn x * y\n}\n\nexport function boxAnchor(box: PptxBox, anchor: PptxBoxAnchor, axis: PptxBoxAxis): number {\n\tif (axis === 'x') {\n\t\tif (anchor === 'left') return box.x\n\t\tif (anchor === 'right') return box.x + box.w\n\t\treturn box.x + box.w / 2\n\t}\n\tif (anchor === 'top') return box.y\n\tif (anchor === 'bottom') return box.y + box.h\n\treturn box.y + box.h / 2\n}\n\n/* ────────────────────────────────────────────────────────────────────────────\n * Shape-tree harvest\n * ──────────────────────────────────────────────────────────────────────────── */\n\n/** One harvested shape, before it is flattened into a {@link PptxSlideElement}. */\ninterface HarvestedShape {\n\tshape: AnyShape\n\tparentZIndex: number | null\n\tchildZIndices: number[]\n}\n\n/**\n * Flatten a shape list depth-first in document order: each shape is followed by\n * its descendants, which is both paint order and the order the\n * {@link PptxSlideElement.zIndex} contract promises. Every entry's index in `out`\n * is its zIndex. Returns the zIndices assigned at this level, which is what the\n * enclosing group records as its {@link PptxSlideElement.childZIndices}.\n */\nfunction harvest(shapes: AnyShape[], parentZIndex: number | null, out: HarvestedShape[]): number[] {\n\tconst zIndices: number[] = []\n\tfor (const shape of shapes) {\n\t\tconst entry: HarvestedShape = { shape, parentZIndex, childZIndices: [] }\n\t\tconst zIndex = out.push(entry) - 1\n\t\tzIndices.push(zIndex)\n\t\tif (shape.shapeType === 'group') entry.childZIndices = harvest(shape.shapes, zIndex, out)\n\t}\n\treturn zIndices\n}\n\n/**\n * Turn harvested shapes into elements, dropping the ones with no resolvable slide\n * position. A dropped shape keeps its zIndex: the numbers are positions in the\n * shape tree, and renumbering them would silently repoint every `parentZIndex`.\n */\nfunction flatten(harvested: HarvestedShape[], slidePath: string): PptxSlideElement[] {\n\treturn harvested\n\t\t.map((entry, zIndex) => toElement(entry, zIndex, slidePath))\n\t\t.filter((element): element is PptxSlideElement => Boolean(element))\n}\n\nfunction toElement(entry: HarvestedShape, zIndex: number, slidePath: string): PptxSlideElement | null {\n\tconst { shape } = entry\n\tconst frame = shape.absoluteFrame\n\tif (!frame) {\n\t\treportUnresolvable(shape, zIndex, slidePath)\n\t\treturn null\n\t}\n\n\t// Only `p:sp` holds a text body, so every other kind projects as an empty frame.\n\tconst textFrame = shape.textFrame\n\tconst paragraphs = textFrame ? textFrame.paragraphs.map((p) => ({ runs: p.runs.map(toRun) })) : []\n\tconst textRuns = paragraphs.flatMap((paragraph) => paragraph.runs)\n\t// A graphic frame has no text body of its own; its text comes from the structure\n\t// it hosts, and arrives as a plain string with no runs behind it.\n\t// Paragraphs are joined by a line break, so the last word of one and the first of the next stay\n\t// two words once the whitespace collapses below.\n\tconst runText = paragraphs.map((paragraph) => paragraph.runs.map((run) => run.text).join('')).join('\\n')\n\tconst raw = shape.shapeType === 'graphicFrame' ? graphicFrameText(shape) : runText\n\t// Deliberately not `TextFrame.text`: this is one whitespace-collapsed line for\n\t// matching and word-counting, not the frame's text with its line structure.\n\tconst text = raw.replace(/\\s+/g, ' ').trim()\n\tconst kind: PptxSlideElementKind =\n\t\tshape.shapeType === 'group'\n\t\t\t? 'group'\n\t\t\t: shape.shapeType === 'graphicFrame'\n\t\t\t\t? 'graphicFrame'\n\t\t\t\t: text\n\t\t\t\t\t? 'text'\n\t\t\t\t\t: shape.shapeType === 'picture'\n\t\t\t\t\t\t? 'image'\n\t\t\t\t\t\t: 'shape'\n\n\treturn {\n\t\tid: shape.id ?? zIndex + 1,\n\t\tname: shape.name || `${kind} ${zIndex + 1}`,\n\t\tkind,\n\t\tgraphicKind: shape.shapeType === 'graphicFrame' ? graphicKindOf(shape) : null,\n\t\tzIndex,\n\t\tbox: {\n\t\t\tx: emuToInches(frame.left),\n\t\t\ty: emuToInches(frame.top),\n\t\t\tw: emuToInches(frame.width),\n\t\t\th: emuToInches(frame.height),\n\t\t},\n\t\trotation: frame.rotation,\n\t\tflipH: frame.flipH,\n\t\tflipV: frame.flipV,\n\t\tparentZIndex: entry.parentZIndex,\n\t\tchildZIndices: entry.childZIndices,\n\t\ttext,\n\t\ttextWrap: textFrame?.bodyProperties?.wrap ?? null,\n\t\tautofit: textFrame?.autofit ?? null,\n\t\tautofitFontScale: textFrame?.autofitFontScale ?? null,\n\t\tbodyInsets: readBodyInsets(textFrame),\n\t\ttextRuns,\n\t\tparagraphs,\n\t\tfontSizes: [...new Set(textRuns.map((run) => run.fontSizePt).filter((size): size is number => size !== null))],\n\t\tcolors: [...new Set(textRuns.map((run) => run.color).filter((color): color is string => Boolean(color)))],\n\t\tfill: shape.fillColor,\n\t\tline: shape.lineColor,\n\t\tshapeType: shape.presetGeometry,\n\t}\n}\n\n/**\n * What a graphic frame hosts, from the same `a:graphicData/@uri` the read model's\n * `has*` predicates compare against. A frame that answers none of them is `'other'`\n * rather than dropped: a box the deck's author placed is on the slide whether or not\n * this library models its payload, and an overlap or coverage check that skipped it\n * would report a gap where a 3D model or an OLE object sits.\n */\nfunction graphicKindOf(frame: GraphicFrame): PptxGraphicKind {\n\tif (frame.hasTable) return 'table'\n\tif (frame.hasChart) return 'chart'\n\tif (frame.hasChartEx) return 'chartEx'\n\tif (frame.hasDiagram) return 'diagram'\n\treturn 'other'\n}\n\n/**\n * The text a graphic frame puts on the slide: table cells in row order, or SmartArt\n * node text. Charts contribute nothing, matching `Slide.text` on the read model: a\n * chart's strings are data labels and axis titles that PowerPoint itself does not\n * treat as slide body text.\n *\n * Separators are single spaces rather than the read model's `\t`/`\n`, because the\n * caller collapses whitespace anyway; the point here is only that cells do not run\n * together into one word.\n */\nfunction graphicFrameText(frame: GraphicFrame): string {\n\tconst table = frame.table\n\tif (table) return table.rows.map((row) => row.cells.map((cell) => cell.text).join(' ')).join(' ')\n\treturn frame.diagram?.text ?? ''\n}\n\n/** Project one read-model {@link Run} onto the flat run shape. */\nfunction toRun(run: Run): PptxTextRun {\n\treturn {\n\t\ttext: run.text,\n\t\tfontSizePt: run.fontSizePt,\n\t\tcolor: run.color,\n\t\tfontFace: run.fontName,\n\t\t// The read model distinguishes \"explicitly not bold\" from \"unset, inherits\";\n\t\t// this surface reports what renders, so an unset flag is `false`.\n\t\tbold: run.bold ?? false,\n\t\titalic: run.italic ?? false,\n\t\tstrike: run.strike,\n\t\thighlight: run.highlight?.hex ?? null,\n\t\tcharSpacingPt: run.charSpacingPt,\n\t}\n}\n\nfunction readBodyInsets(textFrame: TextFrame | null): PptxBodyInsets | null {\n\tconst insets = textFrame?.bodyProperties?.insetsPt\n\tif (!insets) return null\n\t// The read model reports only the explicitly-set sides; an omitted one takes PowerPoint's\n\t// own default rather than zero.\n\tconst inches = (pt: number | undefined, fallbackPt: number): number =>\n\t\t(pt === undefined ? fallbackPt : pt) / POINTS_PER_INCH\n\treturn {\n\t\tleft: inches(insets.left, BODY_INSET_DEFAULTS_PT.left),\n\t\ttop: inches(insets.top, BODY_INSET_DEFAULTS_PT.top),\n\t\tright: inches(insets.right, BODY_INSET_DEFAULTS_PT.right),\n\t\tbottom: inches(insets.bottom, BODY_INSET_DEFAULTS_PT.bottom),\n\t}\n}\n\n/**\n * Warn about a shape whose slide position cannot be resolved, unless it never\n * claimed one.\n *\n * `absoluteFrame` is `null` for three different situations and only two of them\n * are worth telling the caller about; `absoluteFrameFailure` is the read model\n * naming which, so this surface does not walk the ancestry a second time to\n * re-derive it.\n */\nfunction reportUnresolvable(shape: AnyShape, zIndex: number, slidePath: string): void {\n\tconst failure = shape.absoluteFrameFailure\n\t// No own `a:xfrm` at all: the shape inherits its geometry from a layout\n\t// placeholder, which this surface deliberately does not resolve. Nothing is\n\t// wrong with the deck, so nothing is reported. (`null` cannot reach here; the\n\t// caller only calls this for a shape whose frame did not resolve.)\n\tif (failure === null || failure === 'no-own-transform') return\n\n\tconst who = shape.name ? `\"${shape.name}\"` : `the element at zIndex ${zIndex}`\n\tif (failure === 'group-transform-missing') {\n\t\twarn(\n\t\t\t'inspect/group-transform-missing',\n\t\t\t`inspect: skipped ${who} on ${slidePath}: an enclosing group has no usable a:xfrm, so its slide position cannot be resolved.`\n\t\t)\n\t\treturn\n\t}\n\twarn(\n\t\t'inspect/group-transform-degenerate',\n\t\t`inspect: skipped ${who} on ${slidePath}: an enclosing group has a degenerate transform (zero a:chExt), so its slide position cannot be resolved.`\n\t)\n}\n\nfunction countWords(text: string): number {\n\treturn text.split(/\\s+/).filter(Boolean).length\n}\n\nfunction round(value: number, digits: number): number {\n\tconst factor = 10 ** digits\n\treturn Math.round(value * factor) / factor\n}\n\n// Error taxonomy: see `entry-errors.ts`. Re-exported from every entry so `instanceof`\n// works whichever subpath a consumer imports.\nexport * from './entry-errors.js'\n\n// Diagnostics: see `entry-diagnostics.ts`. Re-exported from every entry so a consumer of any\n// subpath can install a handler for the warnings that subpath emits.\nexport * from './entry-diagnostics.js'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwNA,MAAa,6BAA4C,OAAO,OAAO;CACtE,SAAS,MAAM,YAAY,sBAAsB,QAAQ,GAAG,CAAC;CAC7D,UAAU,MAAM,YAAY,sBAAsB,SAAS,GAAG,CAAC;AAChE,CAAC;;;;;;;;;AAmBD,eAAsB,gBAAgB,OAA8C;CACnF,OAAO,WAAW,KAAK,MAAM,KAAK;AACnC;;AAGA,SAAgB,cAAc,aAAmC;CAChE,OAAO,CAAC,GAAG,YAAY,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,KAAK;AAC1D;;AAGA,eAAsB,iBAAiB,aAAyB,MAAsC;CACrG,MAAM,QAAQ,MAAM,mBAAmB,aAAa,IAAI;CACxD,OAAO,QAAQ,YAAY,OAAO,KAAK,IAAI;AAC5C;;;;;;;;;;AAWA,eAAsB,mBAAmB,aAAyB,MAA0C;CAC3G,OAAO,YAAY,KAAK,WAAW,IAAI,CAAC,CAA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