@shbernal/ts-pptx 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{autopage-D1sqK6j7.js → autopage-BYlTzX-l.js} +8 -5
- package/dist/autopage-BYlTzX-l.js.map +1 -0
- package/dist/browser.d.ts +5 -5
- package/dist/browser.js +11 -11
- package/dist/browser.js.map +1 -1
- package/dist/{diagnostics-B2yWpcjB.d.ts → diagnostics-BDuR8UkG.d.ts} +39 -7
- package/dist/diagnostics-BDuR8UkG.d.ts.map +1 -0
- package/dist/{diagnostics-H1QzgRSw.js → diagnostics-CPVADSL1.js} +29 -3
- package/dist/{diagnostics-H1QzgRSw.js.map → diagnostics-CPVADSL1.js.map} +1 -1
- package/dist/{errors-fB1KDJKQ.d.ts → errors-CgnueTYL.d.ts} +3 -3
- package/dist/{errors-fB1KDJKQ.d.ts.map → errors-CgnueTYL.d.ts.map} +1 -1
- package/dist/{fit-CYJ1jkQI.js → fit-TjpNbMru.js} +3 -3
- package/dist/{fit-CYJ1jkQI.js.map → fit-TjpNbMru.js.map} +1 -1
- package/dist/{html-dom-CzewEdE1.js → html-dom-yUSdCExA.js} +5 -5
- package/dist/html-dom-yUSdCExA.js.map +1 -0
- package/dist/html.d.ts +3 -3
- package/dist/html.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +16 -33
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +28 -4
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +43 -10
- package/dist/inspect.js.map +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/measure.d.ts +2 -2
- package/dist/measure.js +1 -1
- package/dist/{st-enums-bVnezkMJ.js → namespaces-CcKuzeuE.js} +291 -200
- package/dist/namespaces-CcKuzeuE.js.map +1 -0
- package/dist/node.d.ts +5 -5
- package/dist/node.js +7 -19
- package/dist/node.js.map +1 -1
- package/dist/{notes-SCvpJz0l.js → notes-DNqAggXx.js} +221 -140
- package/dist/notes-DNqAggXx.js.map +1 -0
- package/dist/{pres-Cb-1xDne.d.ts → pres-Dybf7ZUl.d.ts} +2 -2
- package/dist/{pres-Cb-1xDne.d.ts.map → pres-Dybf7ZUl.d.ts.map} +1 -1
- package/dist/{presentation-DeKTJGHf.js → presentation-VfJ_FT7E.js} +306 -234
- package/dist/presentation-VfJ_FT7E.js.map +1 -0
- package/dist/{presentation-types-B50aOUFI.d.ts → presentation-types-CpkTx9Xa.d.ts} +352 -16
- package/dist/presentation-types-CpkTx9Xa.d.ts.map +1 -0
- package/dist/read.d.ts +4 -4
- package/dist/read.js +3 -3
- package/dist/script.d.ts +2 -2
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +128 -63
- package/dist/script.js.map +1 -1
- package/dist/{shapes-BXVgsk0F.js → shapes-Kt51vry6.js} +717 -54
- package/dist/shapes-Kt51vry6.js.map +1 -0
- package/dist/{slide-DWw9UoI6.d.ts → slide-B_aInw3N.d.ts} +208 -180
- package/dist/slide-B_aInw3N.d.ts.map +1 -0
- package/dist/{text-uM-zGton.js → text-D04NUMvA.js} +3563 -3437
- package/dist/text-D04NUMvA.js.map +1 -0
- package/dist/{units-internal-CGf4VrXy.js → units-internal-DNvK2I6o.js} +54 -34
- package/dist/{units-internal-CGf4VrXy.js.map → units-internal-DNvK2I6o.js.map} +1 -1
- package/dist/zip.d.ts +1 -1
- package/package.json +4 -4
- package/dist/autopage-D1sqK6j7.js.map +0 -1
- package/dist/diagnostics-B2yWpcjB.d.ts.map +0 -1
- package/dist/html-dom-CzewEdE1.js.map +0 -1
- package/dist/notes-SCvpJz0l.js.map +0 -1
- package/dist/presentation-DeKTJGHf.js.map +0 -1
- package/dist/presentation-types-B50aOUFI.d.ts.map +0 -1
- package/dist/shapes-BXVgsk0F.js.map +0 -1
- package/dist/slide-DWw9UoI6.d.ts.map +0 -1
- package/dist/st-enums-bVnezkMJ.js.map +0 -1
- package/dist/text-uM-zGton.js.map +0 -1
package/dist/node.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { C as isChartExType, S as connectorPresetFor, _ as TextAnchor, a as CONNECTOR_PRESETS, b as ZIP_OUTPUT_TYPE, c as OutputType, d as SCHEME_COLORS, f as SHAPE_NAME, g as TableStyle, h as SlideObjectType, i as CHART_NAME, l as PLACEHOLDER_TYPE, m as ShapeType, n as AlignV, o as CONNECTOR_PRESET_NAME, p as SchemeColor, r as BulletType, s as ChartType, t as AlignH, u as PlaceholderType, v as VALID_SHAPE_PRESETS, w as isChartType, x as asChartType, y as WRITE_OUTPUT_TYPE } from "./enums-CvRYniUA.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { a as PresentationProps, c as WriteFileProps, d as ThemeProps, i as PresLayout, l as WriteProps, n as PackagePart, o as SectionProps, r as PartsProps, s as WriteBaseProps, t as CustomPropertyValue, u as ThemeColorScheme } from "./pres-
|
|
4
|
-
import { A as
|
|
5
|
-
import { a as TsPptxError, c as DiagnosticCode, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-
|
|
2
|
+
import { $ as PositionProps, $t as CommentProps, A as TableToSlidesDocument, At as ChartPropsChartBar, B as Coord, Bt as ChartPropsChartWaterfall, C as TableCell, Ct as ChartLineDash, D as TableProps, Dt as ChartPropsAxisSer, E as TableCellProps, Et as ChartPropsAxisCat, F as MediaProps, Ft as ChartPropsChartPie, G as GradientStopProps, Gt as ChartPropsTitle, H as DataOrPathRequiredProps, Ht as ChartPropsDataTable, I as MediaType, It as ChartPropsChartRadar, J as ImageFillProps, Jt as OptsChartData, K as HAlign, Kt as ChartSeriesOpts, L as OleObjectProps, Lt as ChartPropsChartRegionMap, M as TableToSlidesProps, Mt as ChartPropsChartDoughnut, N as ImageBaseProps, Nt as ChartPropsChartHistogram, O as TableRow, Ot as ChartPropsAxisVal, P as ImageProps, Pt as ChartPropsChartLine, Q as PatternPreset, Qt as PlaceholderProps, R as BackgroundProps, Rt as ChartPropsChartStock, S as TransitionType, Sn as ShapeProps, St as ChartExStatistics, T as TableCellDiagonals, Tt as ChartOpts, U as GeometryPoint, Ut as ChartPropsFillLine, V as DataOrPathProps, Vt as ChartPropsDataLabel, W as GradientFillProps, Wt as ChartPropsLegend, X as Margin, Xt as ObjectLockProps, Y as LinearGradientFillProps, Yt as OptsChartGridLine, Z as PatternFillProps, Zt as ObjectNameProps, _ as AnimationProps, _n as ShapeAdjustHandlePolar, _t as ChartAxisTickMark, a as Slide, an as SlideComment, at as ConnectorProps, b as TransitionProps, bn as ShapeConnectionSite, bt as ChartExBinning, c as Model3dPoint, cn as TextBaseProps, ct as HyperlinkProps, d as MasterTextStyleLevel, dn as TextMeasurement, dt as ShapeLineProps, en as MeasureTextOptions, et as RadialGradientFillProps, f as MasterTextStyleProps, fn as TextProps, ft as BevelPresetType, g as SlideNumberProps, gn as ShapeAdjustHandle, gt as ChartAreaProps, h as SlideMasterProps, hn as textRuns, ht as PresetMaterialType, i as ObjectOptions, in as ResolvedCommentAuthor, it as BorderProps, j as TableToSlidesElement, jt as ChartPropsChartBoxWhisker, k as TableRowSlide, kt as ChartPropsBase, l as Model3dProps, ln as TextFitShrinkProps, lt as ShadowProps, m as SlideMasterObject, mn as textRun, mt as LightRigType, n as GroupChildProps, nn as NotesTextOptions, nt as ThemeColor, o as SlideLayout, on as TableCellLayout, ot as ConnectorType, p as SlideMasterChartProps, pn as TextPropsOptions, pt as LightRigDirection, q as HexColor, qt as LineCap, r as GroupProps, rn as OverflowBoxOptions, rt as VAlign, s as Model3dCameraProps, sn as TableLayoutResult, st as HyperlinkActionJump, t as AddSlideProps, tn as NotesProps, tt as TextVertType, u as MasterBulletProps, un as TextGlowProps, ut as ShapeFillProps, v as AnimationTrigger, vn as ShapeAdjustHandleXY, vt as ChartDataPointStyle, w as TableCell3DProps, wt as ChartMulti, x as TransitionSoundProps, xn as ShapeGuide, xt as ChartExGeography, y as PresetEffect, yn as ShapeAdjustValue, yt as ChartErrorBarOptions, z as Color, zt as ChartPropsChartSurface } from "./slide-B_aInw3N.js";
|
|
3
|
+
import { a as PresentationProps, c as WriteFileProps, d as ThemeProps, i as PresLayout, l as WriteProps, n as PackagePart, o as SectionProps, r as PartsProps, s as WriteBaseProps, t as CustomPropertyValue, u as ThemeColorScheme } from "./pres-Dybf7ZUl.js";
|
|
4
|
+
import { A as ptToHundredths, C as emuToInches, D as percentToEmu, E as inchesToEmu, M as SlideZoomProps, N as SummaryZoomProps, O as pixelsToEmu, P as ZoomBaseProps, S as coordToEmu, T as emuToPoints, _ as PERCENT_SCALE, a as ClipShape, b as StandardLayout, c as clipPath, d as DEFAULT_PX_PER_INCH, f as EMU_PER_INCH, g as HUNDREDTHS_PER_POINT, h as FIXED_PCT_PER_PERCENT, i as setDiagnosticHandler, j as SectionZoomProps, k as pointsToEmu, l as PresentationCore, m as Emu, n as DiagnosticHandler, o as FlatSide, p as EMU_PER_POINT, r as resetDiagnosticState, s as HalfDiscPreset, t as Diagnostic, u as ANGLE_UNITS_PER_DEGREE, v as POINTS_PER_INCH, w as emuToPixels, x as StandardLayoutName, y as STANDARD_LAYOUTS } from "./diagnostics-BDuR8UkG.js";
|
|
5
|
+
import { a as TsPptxError, c as DiagnosticCode, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-CgnueTYL.js";
|
|
6
6
|
//#region src/node.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The Node entry, reached through the `node` export condition — a consumer importing the bare
|
|
@@ -16,5 +16,5 @@ declare class TsPptx extends PresentationCore {
|
|
|
16
16
|
constructor();
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
-
export { ANGLE_UNITS_PER_DEGREE, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundProps, type BevelPresetType, BorderProps, BulletType, CHART_NAME, CONNECTOR_PRESETS, 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, ConnectorProps, ConnectorType, Coord, CustomPropertyValue, DEFAULT_PX_PER_INCH, DataOrPathProps, DataOrPathRequiredProps, type Diagnostic, type DiagnosticCode, type DiagnosticHandler, EMU_PER_INCH, EMU_PER_POINT, Emu, type ErrorCode, FIXED_PCT_PER_PERCENT, FlatSide, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HalfDiscPreset, HexColor, HyperlinkActionJump, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LightRigDirection, type LightRigType, LineCap, LinearGradientFillProps, 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, PlaceholderProps, PlaceholderType, PositionProps, PresLayout, PresentationProps, PresetEffect, type PresetMaterialType, RadialGradientFillProps, ResolvedCommentAuthor, SCHEME_COLORS, SHAPE_NAME, STANDARD_LAYOUTS, SchemeColor, SectionProps, SectionZoomProps, ShadowProps, ShapeAdjustHandle, ShapeAdjustHandlePolar, ShapeAdjustHandleXY, ShapeAdjustValue, ShapeConnectionSite, ShapeFillProps, ShapeGuide, ShapeLineProps, ShapeProps, ShapeType, Slide, SlideComment, SlideLayout, SlideMasterChartProps, SlideMasterObject, SlideMasterProps, SlideNumberProps, SlideObjectType, SlideZoomProps, StandardLayout, StandardLayoutName, SummaryZoomProps, TableCell, TableCell3DProps, TableCellDiagonals, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps, TextAnchor, TextBaseProps, TextFitShrinkProps, TextGlowProps, TextMeasurement, TextProps, TextPropsOptions, TextVertType, ThemeColor, ThemeColorScheme, ThemeProps, TransitionProps, TransitionSoundProps, TransitionType, TsPptx, TsPptx as default, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, VALID_SHAPE_PRESETS, VAlign, WRITE_OUTPUT_TYPE, WriteBaseProps, WriteFileProps, WriteProps, ZIP_OUTPUT_TYPE, ZoomBaseProps, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, setDiagnosticHandler, textRun, textRuns };
|
|
19
|
+
export { ANGLE_UNITS_PER_DEGREE, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundProps, type BevelPresetType, BorderProps, BulletType, CHART_NAME, CONNECTOR_PRESETS, 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, ConnectorProps, ConnectorType, Coord, CustomPropertyValue, DEFAULT_PX_PER_INCH, DataOrPathProps, DataOrPathRequiredProps, type Diagnostic, type DiagnosticCode, type DiagnosticHandler, EMU_PER_INCH, EMU_PER_POINT, Emu, type ErrorCode, FIXED_PCT_PER_PERCENT, FlatSide, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HalfDiscPreset, HexColor, HyperlinkActionJump, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LightRigDirection, type LightRigType, LineCap, LinearGradientFillProps, 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, PlaceholderProps, PlaceholderType, PositionProps, PresLayout, PresentationProps, PresetEffect, type PresetMaterialType, RadialGradientFillProps, ResolvedCommentAuthor, SCHEME_COLORS, SHAPE_NAME, STANDARD_LAYOUTS, SchemeColor, SectionProps, SectionZoomProps, ShadowProps, ShapeAdjustHandle, ShapeAdjustHandlePolar, ShapeAdjustHandleXY, ShapeAdjustValue, ShapeConnectionSite, ShapeFillProps, ShapeGuide, ShapeLineProps, ShapeProps, ShapeType, Slide, SlideComment, SlideLayout, SlideMasterChartProps, SlideMasterObject, SlideMasterProps, SlideNumberProps, SlideObjectType, SlideZoomProps, StandardLayout, StandardLayoutName, SummaryZoomProps, TableCell, TableCell3DProps, TableCellDiagonals, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps, TextAnchor, TextBaseProps, TextFitShrinkProps, TextGlowProps, TextMeasurement, TextProps, TextPropsOptions, TextVertType, ThemeColor, ThemeColorScheme, ThemeProps, TransitionProps, TransitionSoundProps, TransitionType, TsPptx, TsPptx as default, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, VALID_SHAPE_PRESETS, VAlign, WRITE_OUTPUT_TYPE, WriteBaseProps, WriteFileProps, WriteProps, ZIP_OUTPUT_TYPE, ZoomBaseProps, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
|
|
20
20
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as setDiagnosticHandler, t as resetDiagnosticState } from "./diagnostics-CPVADSL1.js";
|
|
2
2
|
import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-Bvln0H-7.js";
|
|
3
|
-
import { $ as
|
|
4
|
-
import {
|
|
3
|
+
import { $ as VALID_SHAPE_PRESETS, G as ChartType, H as AlignV, J as SchemeColor, K as OutputType, Q as TextAnchor, U as BulletType, V as AlignH, W as CONNECTOR_PRESETS, X as SlideObjectType, Y as ShapeType, Z as TableStyle, _t as inchesToEmu, at as DEFAULT_PX_PER_INCH, bt as pointsToEmu, ct as FIXED_PCT_PER_PERCENT, dt as POINTS_PER_INCH, et as asChartType, ft as STANDARD_LAYOUTS, gt as emuToPoints, ht as emuToPixels, it as ANGLE_UNITS_PER_DEGREE, lt as HUNDREDTHS_PER_POINT, mt as emuToInches, nt as isChartExType, ot as EMU_PER_INCH, pt as coordToEmu, q as PlaceholderType, rt as isChartType, st as EMU_PER_POINT, tt as connectorPresetFor, ut as PERCENT_SCALE, vt as percentToEmu, xt as ptToHundredths, yt as pixelsToEmu } from "./units-internal-DNvK2I6o.js";
|
|
4
|
+
import { a as fetchMediaBase64, c as PresentationCore, i as fetchFontBytes, n as textRuns, o as isRemote, r as clipPath, s as placeholderSvgPreview, t as textRun } from "./text-D04NUMvA.js";
|
|
5
5
|
import { Buffer } from "node:buffer";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
//#region src/runtime/node.ts
|
|
@@ -9,17 +9,13 @@ function createNodeRuntime() {
|
|
|
9
9
|
return {
|
|
10
10
|
writeFileOutputType: "nodebuffer",
|
|
11
11
|
loadMedia,
|
|
12
|
-
createSvgPngPreview,
|
|
12
|
+
createSvgPngPreview: placeholderSvgPreview,
|
|
13
13
|
writeFile,
|
|
14
14
|
loadFontData
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
async function loadFontData(source) {
|
|
18
|
-
if (source
|
|
19
|
-
const response = await fetch(source);
|
|
20
|
-
if (!response.ok) throw new MediaError("font/fetch-failed", `Unable to load font (fetch): ${source}`);
|
|
21
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
22
|
-
}
|
|
18
|
+
if (isRemote(source)) return await fetchFontBytes(source);
|
|
23
19
|
try {
|
|
24
20
|
return new Uint8Array(await fs.readFile(source));
|
|
25
21
|
} catch (ex) {
|
|
@@ -27,21 +23,13 @@ async function loadFontData(source) {
|
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
async function loadMedia(rel) {
|
|
30
|
-
if (rel.path
|
|
31
|
-
const response = await fetch(rel.path);
|
|
32
|
-
if (!response.ok) throw new MediaError("media/fetch-failed", `Unable to load image (fetch): ${rel.path}`);
|
|
33
|
-
return Buffer.from(await response.arrayBuffer()).toString("base64");
|
|
34
|
-
}
|
|
26
|
+
if (isRemote(rel.path)) return await fetchMediaBase64(rel.path);
|
|
35
27
|
try {
|
|
36
28
|
return Buffer.from(await fs.readFile(rel.path)).toString("base64");
|
|
37
29
|
} catch (ex) {
|
|
38
30
|
throw new MediaError("media/read-failed", `Unable to read media: "${rel.path}"\n${String(ex)}`, { cause: ex });
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
|
-
async function createSvgPngPreview(rel) {
|
|
42
|
-
rel.data = IMG_SVG_PLACEHOLDER;
|
|
43
|
-
return "done";
|
|
44
|
-
}
|
|
45
33
|
async function writeFile(fileName, data) {
|
|
46
34
|
await fs.writeFile(fileName, data);
|
|
47
35
|
return fileName;
|
|
@@ -62,6 +50,6 @@ var TsPptx = class extends PresentationCore {
|
|
|
62
50
|
}
|
|
63
51
|
};
|
|
64
52
|
//#endregion
|
|
65
|
-
export { ANGLE_UNITS_PER_DEGREE, AlignH, AlignV, BulletType, CONNECTOR_PRESETS, ChartType, DEFAULT_PX_PER_INCH, EMU_PER_INCH, EMU_PER_POINT, FIXED_PCT_PER_PERCENT, HUNDREDTHS_PER_POINT, InternalError, InvalidOptionError, MediaError, OutputType, PERCENT_SCALE, POINTS_PER_INCH, PackageReadError, PlaceholderType, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptx as default, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, setDiagnosticHandler, textRun, textRuns };
|
|
53
|
+
export { ANGLE_UNITS_PER_DEGREE, AlignH, AlignV, BulletType, CONNECTOR_PRESETS, ChartType, DEFAULT_PX_PER_INCH, EMU_PER_INCH, EMU_PER_POINT, FIXED_PCT_PER_PERCENT, HUNDREDTHS_PER_POINT, InternalError, InvalidOptionError, MediaError, OutputType, PERCENT_SCALE, POINTS_PER_INCH, PackageReadError, PlaceholderType, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptx as default, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
|
|
66
54
|
|
|
67
55
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":[],"sources":["../src/runtime/node.ts","../src/node.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport fs from 'node:fs/promises'\nimport {
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../src/runtime/node.ts","../src/node.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport fs from 'node:fs/promises'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes, fetchMediaBase64, isRemote, placeholderSvgPreview } from './fetch-media.js'\n\nexport function createNodeRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: 'nodebuffer',\n\t\tloadMedia,\n\t\tcreateSvgPngPreview: placeholderSvgPreview,\n\t\twriteFile,\n\t\tloadFontData,\n\t}\n}\n\nasync function loadFontData(source: string): Promise<Uint8Array> {\n\tif (isRemote(source)) return await fetchFontBytes(source)\n\ttry {\n\t\treturn new Uint8Array(await fs.readFile(source))\n\t} catch (ex) {\n\t\tthrow new MediaError('font/read-failed', `Unable to read font file: \"${source}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function loadMedia(rel: SlideRelMedia & { path: string }): Promise<string> {\n\tif (isRemote(rel.path)) return await fetchMediaBase64(rel.path)\n\n\ttry {\n\t\treturn Buffer.from(await fs.readFile(rel.path)).toString('base64')\n\t} catch (ex) {\n\t\tthrow new MediaError('media/read-failed', `Unable to read media: \"${rel.path}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function writeFile(fileName: string, data: string | ArrayBuffer | Blob | Uint8Array): Promise<string> {\n\tawait fs.writeFile(fileName, data as string | Uint8Array)\n\treturn fileName\n}\n","import PresentationCore from './presentation.js'\nimport { createNodeRuntime } from './runtime/node.js'\n\n/**\n * The Node entry, reached through the `node` export condition — a consumer importing the bare\n * `@shbernal/ts-pptx` specifier under Node lands here without naming this subpath.\n *\n * Same authoring API as every other entry (see `entry-surface.ts`); the runtime adapter is what\n * differs. This one can reach the filesystem, so `writeFile` writes a real file and media may be\n * loaded from a path — both of which throw on the runtime-agnostic entry.\n */\nexport class TsPptx extends PresentationCore {\n\tconstructor() {\n\t\tsuper(createNodeRuntime())\n\t}\n}\n\nexport { TsPptx as default }\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;;AAOA,SAAgB,oBAAoC;CACnD,OAAO;EACN,qBAAqB;EACrB;EACA,qBAAqB;EACrB;EACA;CACD;AACD;AAEA,eAAe,aAAa,QAAqC;CAChE,IAAI,SAAS,MAAM,GAAG,OAAO,MAAM,eAAe,MAAM;CACxD,IAAI;EACH,OAAO,IAAI,WAAW,MAAM,GAAG,SAAS,MAAM,CAAC;CAChD,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,oBAAoB,8BAA8B,OAAO,KAAK,OAAO,EAAE,KAAK,EAChG,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,KAAwD;CAChF,IAAI,SAAS,IAAI,IAAI,GAAG,OAAO,MAAM,iBAAiB,IAAI,IAAI;CAE9D,IAAI;EACH,OAAO,OAAO,KAAK,MAAM,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,QAAQ;CAClE,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,qBAAqB,0BAA0B,IAAI,KAAK,KAAK,OAAO,EAAE,KAAK,EAC/F,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,GAAG,UAAU,UAAU,IAA2B;CACxD,OAAO;AACR;;;;;;;;;;;AChCA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EACb,MAAM,kBAAkB,CAAC;CAC1B;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as warnOnce, r as warn } from "./diagnostics-CPVADSL1.js";
|
|
2
2
|
import { n as InvalidOptionError, o as UnsupportedFeatureError } from "./errors-Bvln0H-7.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { B as XML_DECL, J as SchemeColor, L as REGEX_HEX_COLOR, O as DEF_TEXT_GLOW, R as SLDNUMFLDID, S as DEF_FONT_COLOR, a as inch2Emu, c as opacityToAlpha, ct as FIXED_PCT_PER_PERCENT, d as transparencyToAlpha, it as ANGLE_UNITS_PER_DEGREE, k as DEF_TEXT_SHADOW, l as ptsToEmuLenient, o as lineWidthToEmu, r as convertRotationDegrees, st as EMU_PER_POINT, ut as PERCENT_SCALE, xt as ptToHundredths } from "./units-internal-DNvK2I6o.js";
|
|
4
|
+
import { l as OFFICE_REL, n as PML_ROOT_NS, u as PACKAGE_REL_NS } from "./namespaces-CcKuzeuE.js";
|
|
5
5
|
//#region src/gen/utils.ts
|
|
6
6
|
/**
|
|
7
7
|
* ts-pptx: shared generator helpers.
|
|
@@ -10,17 +10,26 @@ import { g as PACKAGE_REL_NS, h as OFFICE_REL } from "./st-enums-bVnezkMJ.js";
|
|
|
10
10
|
* no single part:
|
|
11
11
|
* - XML text encodeXmlEntities
|
|
12
12
|
* - Identifiers & naming getUuid, validateObjectName, getDuplicateObjectNames
|
|
13
|
-
* - Slide relationships getNewRelId, isHyperlinkRel
|
|
13
|
+
* - Slide relationships getNewRelId, isHyperlinkRel, mediaSlideKey
|
|
14
14
|
*
|
|
15
15
|
* DrawingML fragment builders moved to `gen/drawingml/{color,effect,fill,line}.ts`;
|
|
16
16
|
* unit conversion to `units-internal.ts` (over the public primitives in `units.ts`);
|
|
17
17
|
* base64/image-header decoding and media content types to `media/`.
|
|
18
18
|
*/
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Fill the `x`/`y` placeholders of a hex pattern with random nibbles.
|
|
21
|
+
*
|
|
22
|
+
* **Not replaceable by `crypto.randomUUID()`**, which exists on Node 24 and in every
|
|
23
|
+
* browser. This takes a *format string*, and half its callers pass a partial one:
|
|
24
|
+
* `gen/chart/plot-scatter.ts` asks for a bare tail (`-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)
|
|
25
|
+
* to splice onto a padded point index, and its other two calls want a GUID shape with
|
|
26
|
+
* no version nibble. Only `gen/define/zoom.ts` and `presentation.ts`, which pass a
|
|
27
|
+
* v4-shaped pattern, could switch, and switching only those would leave two generators
|
|
28
|
+
* where there is now one. The analysis is recorded here so it does not get re-derived:
|
|
29
|
+
* the swap is low value and non-zero risk, and it is not on the roadmap.
|
|
21
30
|
* @link https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript#answer-2117523
|
|
22
|
-
* @param {string} uuidFormat -
|
|
23
|
-
* @returns {string}
|
|
31
|
+
* @param {string} uuidFormat - the pattern; `x` becomes a random nibble, `y` one of 8/9/a/b
|
|
32
|
+
* @returns {string} the filled pattern
|
|
24
33
|
*/
|
|
25
34
|
function getUuid(uuidFormat) {
|
|
26
35
|
return uuidFormat.replace(/[xy]/g, function(c) {
|
|
@@ -146,6 +155,20 @@ function getNewRelId(target) {
|
|
|
146
155
|
function isHyperlinkRel(rel) {
|
|
147
156
|
return rel.type.toLowerCase().includes("hyperlink");
|
|
148
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* The slide-scoped segment of a media part's name.
|
|
160
|
+
*
|
|
161
|
+
* Media targets are namespaced by the slide that registered them so that slide
|
|
162
|
+
* master (`sm`) and slide layout (`sl-N`) media never collide with regular slide
|
|
163
|
+
* media names in large decks. A layout is identified by the `_slideNum >= 1000`
|
|
164
|
+
* convention the layout builder stamps on it; a master has no `_slideNum` at all.
|
|
165
|
+
* @param {PresSlideInternal} target - the slide, layout or master registering the media
|
|
166
|
+
* @returns {string} the key to splice into the media part name
|
|
167
|
+
*/
|
|
168
|
+
function mediaSlideKey(target) {
|
|
169
|
+
if (target._slideNum == null) return "sm";
|
|
170
|
+
return target._slideNum >= 1e3 ? `sl-${target._slideNum}` : `${target._slideNum}`;
|
|
171
|
+
}
|
|
149
172
|
//#endregion
|
|
150
173
|
//#region src/gen/oxml/el.ts
|
|
151
174
|
/**
|
|
@@ -324,8 +347,8 @@ function createShadowElement(options, defaults) {
|
|
|
324
347
|
};
|
|
325
348
|
if (opts.type === "none") return "";
|
|
326
349
|
const type = opts.type || "outer";
|
|
327
|
-
const blur =
|
|
328
|
-
const offset =
|
|
350
|
+
const blur = ptsToEmuLenient(opts.blur ?? 0);
|
|
351
|
+
const offset = ptsToEmuLenient(opts.offset ?? 0);
|
|
329
352
|
const angle = Math.round((opts.angle ?? 0) * ANGLE_UNITS_PER_DEGREE);
|
|
330
353
|
const opacity = Math.round((opts._alpha ?? .75) * PERCENT_SCALE);
|
|
331
354
|
const color = opts.color || "000000";
|
|
@@ -396,97 +419,6 @@ function correctShadowOptions(ShadowProps) {
|
|
|
396
419
|
return corrected;
|
|
397
420
|
}
|
|
398
421
|
//#endregion
|
|
399
|
-
//#region src/embedded-fonts.ts
|
|
400
|
-
/**
|
|
401
|
-
* Shared model + serializer for PresentationML embedded fonts, used by both the
|
|
402
|
-
* write side (author-side `pptx.embedFont`, `gen/pres/presentation.ts`) and the read side
|
|
403
|
-
* (`importSlide({ embedFonts: true })`, `src/read/api/ops/embedded-fonts.ts`).
|
|
404
|
-
*
|
|
405
|
-
* Embedded fonts are three coordinated pieces (ECMA-376 transitional):
|
|
406
|
-
* 1. binary font parts `/ppt/fonts/fontN.fntdata` — the **raw** TTF/OTF bytes
|
|
407
|
-
* (PresentationML does not obfuscate embedded fonts), content type
|
|
408
|
-
* `application/x-fontdata` via a single `fntdata` Default extension;
|
|
409
|
-
* 2. one `font` relationship per face from `presentation.xml`;
|
|
410
|
-
* 3. a `p:embeddedFontLst` in `presentation.xml`, at index 7 of the
|
|
411
|
-
* `CT_Presentation` child sequence (after `smartTags`, before `custShowLst`
|
|
412
|
-
* … `defaultTextStyle`).
|
|
413
|
-
*
|
|
414
|
-
* This module owns only the OOXML-shape knowledge; rId allocation and part
|
|
415
|
-
* placement stay with each caller (their packaging models differ).
|
|
416
|
-
*/
|
|
417
|
-
/** Extension for the binary font parts (`/ppt/fonts/fontN.fntdata`). */
|
|
418
|
-
const FONT_DATA_EXTENSION = "fntdata";
|
|
419
|
-
/** Content type for a `.fntdata` part — one `Default` covers every font part. */
|
|
420
|
-
const FONT_DATA_CONTENT_TYPE = "application/x-fontdata";
|
|
421
|
-
/** Relationship type from `presentation.xml` to a font part (one per face). */
|
|
422
|
-
const FONT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
|
|
423
|
-
/**
|
|
424
|
-
* The four face slots of `CT_EmbeddedFontListEntry`, in schema child order
|
|
425
|
-
* (`font` first, then these). Iterate in this order everywhere so the read- and
|
|
426
|
-
* write-side emitters agree on element order.
|
|
427
|
-
*/
|
|
428
|
-
const EMBEDDED_FONT_SLOTS = [
|
|
429
|
-
"regular",
|
|
430
|
-
"bold",
|
|
431
|
-
"italic",
|
|
432
|
-
"boldItalic"
|
|
433
|
-
];
|
|
434
|
-
/**
|
|
435
|
-
* Flatten `fonts` into one ordered face list, assigning sequential part indices
|
|
436
|
-
* (1-based) and relationship ids (starting at `firstRId`). Faces are emitted in
|
|
437
|
-
* `fonts` order, each font's faces in {@link EMBEDDED_FONT_SLOTS} order. Faces
|
|
438
|
-
* without `bytes` are skipped (nothing to write).
|
|
439
|
-
*/
|
|
440
|
-
function flattenEmbeddedFaces(fonts, firstRId) {
|
|
441
|
-
const flat = [];
|
|
442
|
-
let partIndex = 0;
|
|
443
|
-
let rId = firstRId;
|
|
444
|
-
fonts.forEach((font, fontIndex) => {
|
|
445
|
-
for (const slot of EMBEDDED_FONT_SLOTS) {
|
|
446
|
-
const face = font.faces.find((f) => f.slot === slot);
|
|
447
|
-
if (!face || !face.bytes) continue;
|
|
448
|
-
flat.push({
|
|
449
|
-
fontIndex,
|
|
450
|
-
slot,
|
|
451
|
-
bytes: face.bytes,
|
|
452
|
-
partIndex: ++partIndex,
|
|
453
|
-
rId: rId++
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
return flat;
|
|
458
|
-
}
|
|
459
|
-
/** Minimal XML attribute escaper (kept local so this module stays dependency-free). */
|
|
460
|
-
function escapeAttr(value) {
|
|
461
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Serialize a `<p:embeddedFontLst>` from `fonts` and a `(fontIndex, slot) → rId`
|
|
465
|
-
* lookup (typically backed by {@link flattenEmbeddedFaces}). Returns `''` when no
|
|
466
|
-
* font has any face with an allocated rId, so callers can emit nothing. Assumes
|
|
467
|
-
* the enclosing document declares the `p:` and `r:` prefixes (presentation.xml
|
|
468
|
-
* does), so no namespace declarations are emitted here.
|
|
469
|
-
*/
|
|
470
|
-
function serializeEmbeddedFontLst(fonts, rIdForFace) {
|
|
471
|
-
const entries = [];
|
|
472
|
-
fonts.forEach((font, fontIndex) => {
|
|
473
|
-
const faceXml = [];
|
|
474
|
-
for (const slot of EMBEDDED_FONT_SLOTS) {
|
|
475
|
-
const rId = rIdForFace(fontIndex, slot);
|
|
476
|
-
if (rId === void 0) continue;
|
|
477
|
-
faceXml.push(`<p:${slot} r:id="rId${rId}"/>`);
|
|
478
|
-
}
|
|
479
|
-
if (faceXml.length === 0) return;
|
|
480
|
-
let fontAttrs = `typeface="${escapeAttr(font.typeface)}"`;
|
|
481
|
-
if (font.panose !== void 0) fontAttrs += ` panose="${escapeAttr(font.panose)}"`;
|
|
482
|
-
if (font.pitchFamily !== void 0) fontAttrs += ` pitchFamily="${font.pitchFamily}"`;
|
|
483
|
-
if (font.charset !== void 0) fontAttrs += ` charset="${font.charset}"`;
|
|
484
|
-
entries.push(`<p:embeddedFont><p:font ${fontAttrs}/>${faceXml.join("")}</p:embeddedFont>`);
|
|
485
|
-
});
|
|
486
|
-
if (entries.length === 0) return "";
|
|
487
|
-
return `<p:embeddedFontLst>${entries.join("")}</p:embeddedFontLst>`;
|
|
488
|
-
}
|
|
489
|
-
//#endregion
|
|
490
422
|
//#region src/gen/drawingml/fill.ts
|
|
491
423
|
/**
|
|
492
424
|
* ts-pptx: DrawingML fills
|
|
@@ -621,6 +553,97 @@ function genXmlColorSelection(props) {
|
|
|
621
553
|
return outText;
|
|
622
554
|
}
|
|
623
555
|
//#endregion
|
|
556
|
+
//#region src/embedded-fonts.ts
|
|
557
|
+
/**
|
|
558
|
+
* Shared model + serializer for PresentationML embedded fonts, used by both the
|
|
559
|
+
* write side (author-side `pptx.embedFont`, `gen/pres/presentation.ts`) and the read side
|
|
560
|
+
* (`importSlide({ embedFonts: true })`, `src/read/api/ops/embedded-fonts.ts`).
|
|
561
|
+
*
|
|
562
|
+
* Embedded fonts are three coordinated pieces (ECMA-376 transitional):
|
|
563
|
+
* 1. binary font parts `/ppt/fonts/fontN.fntdata` — the **raw** TTF/OTF bytes
|
|
564
|
+
* (PresentationML does not obfuscate embedded fonts), content type
|
|
565
|
+
* `application/x-fontdata` via a single `fntdata` Default extension;
|
|
566
|
+
* 2. one `font` relationship per face from `presentation.xml`;
|
|
567
|
+
* 3. a `p:embeddedFontLst` in `presentation.xml`, at index 7 of the
|
|
568
|
+
* `CT_Presentation` child sequence (after `smartTags`, before `custShowLst`
|
|
569
|
+
* … `defaultTextStyle`).
|
|
570
|
+
*
|
|
571
|
+
* This module owns only the OOXML-shape knowledge; rId allocation and part
|
|
572
|
+
* placement stay with each caller (their packaging models differ).
|
|
573
|
+
*/
|
|
574
|
+
/** Extension for the binary font parts (`/ppt/fonts/fontN.fntdata`). */
|
|
575
|
+
const FONT_DATA_EXTENSION = "fntdata";
|
|
576
|
+
/** Content type for a `.fntdata` part — one `Default` covers every font part. */
|
|
577
|
+
const FONT_DATA_CONTENT_TYPE = "application/x-fontdata";
|
|
578
|
+
/** Relationship type from `presentation.xml` to a font part (one per face). */
|
|
579
|
+
const FONT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
|
|
580
|
+
/**
|
|
581
|
+
* The four face slots of `CT_EmbeddedFontListEntry`, in schema child order
|
|
582
|
+
* (`font` first, then these). Iterate in this order everywhere so the read- and
|
|
583
|
+
* write-side emitters agree on element order.
|
|
584
|
+
*/
|
|
585
|
+
const EMBEDDED_FONT_SLOTS = [
|
|
586
|
+
"regular",
|
|
587
|
+
"bold",
|
|
588
|
+
"italic",
|
|
589
|
+
"boldItalic"
|
|
590
|
+
];
|
|
591
|
+
/**
|
|
592
|
+
* Flatten `fonts` into one ordered face list, assigning sequential part indices
|
|
593
|
+
* (1-based) and relationship ids (starting at `firstRId`). Faces are emitted in
|
|
594
|
+
* `fonts` order, each font's faces in {@link EMBEDDED_FONT_SLOTS} order. Faces
|
|
595
|
+
* without `bytes` are skipped (nothing to write).
|
|
596
|
+
*/
|
|
597
|
+
function flattenEmbeddedFaces(fonts, firstRId) {
|
|
598
|
+
const flat = [];
|
|
599
|
+
let partIndex = 0;
|
|
600
|
+
let rId = firstRId;
|
|
601
|
+
fonts.forEach((font, fontIndex) => {
|
|
602
|
+
for (const slot of EMBEDDED_FONT_SLOTS) {
|
|
603
|
+
const face = font.faces.find((f) => f.slot === slot);
|
|
604
|
+
if (!face || !face.bytes) continue;
|
|
605
|
+
flat.push({
|
|
606
|
+
fontIndex,
|
|
607
|
+
slot,
|
|
608
|
+
bytes: face.bytes,
|
|
609
|
+
partIndex: ++partIndex,
|
|
610
|
+
rId: rId++
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
return flat;
|
|
615
|
+
}
|
|
616
|
+
/** Minimal XML attribute escaper (kept local so this module stays dependency-free). */
|
|
617
|
+
function escapeAttr(value) {
|
|
618
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Serialize a `<p:embeddedFontLst>` from `fonts` and a `(fontIndex, slot) → rId`
|
|
622
|
+
* lookup (typically backed by {@link flattenEmbeddedFaces}). Returns `''` when no
|
|
623
|
+
* font has any face with an allocated rId, so callers can emit nothing. Assumes
|
|
624
|
+
* the enclosing document declares the `p:` and `r:` prefixes (presentation.xml
|
|
625
|
+
* does), so no namespace declarations are emitted here.
|
|
626
|
+
*/
|
|
627
|
+
function serializeEmbeddedFontLst(fonts, rIdForFace) {
|
|
628
|
+
const entries = [];
|
|
629
|
+
fonts.forEach((font, fontIndex) => {
|
|
630
|
+
const faceXml = [];
|
|
631
|
+
for (const slot of EMBEDDED_FONT_SLOTS) {
|
|
632
|
+
const rId = rIdForFace(fontIndex, slot);
|
|
633
|
+
if (rId === void 0) continue;
|
|
634
|
+
faceXml.push(`<p:${slot} r:id="rId${rId}"/>`);
|
|
635
|
+
}
|
|
636
|
+
if (faceXml.length === 0) return;
|
|
637
|
+
let fontAttrs = `typeface="${escapeAttr(font.typeface)}"`;
|
|
638
|
+
if (font.panose !== void 0) fontAttrs += ` panose="${escapeAttr(font.panose)}"`;
|
|
639
|
+
if (font.pitchFamily !== void 0) fontAttrs += ` pitchFamily="${font.pitchFamily}"`;
|
|
640
|
+
if (font.charset !== void 0) fontAttrs += ` charset="${font.charset}"`;
|
|
641
|
+
entries.push(`<p:embeddedFont><p:font ${fontAttrs}/>${faceXml.join("")}</p:embeddedFont>`);
|
|
642
|
+
});
|
|
643
|
+
if (entries.length === 0) return "";
|
|
644
|
+
return `<p:embeddedFontLst>${entries.join("")}</p:embeddedFontLst>`;
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
624
647
|
//#region src/gen/drawingml/clamp.ts
|
|
625
648
|
/**
|
|
626
649
|
* ts-pptx: DrawingML value clamps
|
|
@@ -630,22 +653,74 @@ function genXmlColorSelection(props) {
|
|
|
630
653
|
* Out-of-range values make PowerPoint report the package as needing repair.
|
|
631
654
|
*/
|
|
632
655
|
/**
|
|
656
|
+
* Clamp a points value into its schema range and warn once if it did not already fit.
|
|
657
|
+
*
|
|
658
|
+
* The five measures below differ only in the fields of {@link ClampSpec}; the arithmetic and
|
|
659
|
+
* the shape of the warning are the same for all of them. `warnOnce` keys its dedupe set on the
|
|
660
|
+
* code plus the message, so the wording is part of the contract, not decoration.
|
|
661
|
+
*/
|
|
662
|
+
function clampWithWarn(points, spec) {
|
|
663
|
+
const raw = spec.convert(points);
|
|
664
|
+
const clamped = Math.min(spec.max, Math.max(spec.min, raw));
|
|
665
|
+
if (clamped !== raw) warnOnce(spec.code, `${spec.label} ${points} is outside the valid range ${spec.range}; using ${clamped / spec.perPoint}.`);
|
|
666
|
+
return clamped;
|
|
667
|
+
}
|
|
668
|
+
const FONT_SIZE = {
|
|
669
|
+
code: "font/size-out-of-range",
|
|
670
|
+
label: "fontSize",
|
|
671
|
+
range: "1-4000pt",
|
|
672
|
+
convert: ptToHundredths,
|
|
673
|
+
perPoint: 100,
|
|
674
|
+
min: 100,
|
|
675
|
+
max: 4e5
|
|
676
|
+
};
|
|
677
|
+
const CHAR_SPACING = {
|
|
678
|
+
code: "text/char-spacing-out-of-range",
|
|
679
|
+
label: "charSpacing",
|
|
680
|
+
range: "-4000..4000pt",
|
|
681
|
+
convert: ptToHundredths,
|
|
682
|
+
perPoint: 100,
|
|
683
|
+
min: -4e5,
|
|
684
|
+
max: 4e5
|
|
685
|
+
};
|
|
686
|
+
const PARA_MARGIN = {
|
|
687
|
+
code: "text/paragraph-margin-out-of-range",
|
|
688
|
+
label: "paraMarginLeft",
|
|
689
|
+
range: "0-4032pt",
|
|
690
|
+
convert: ptsToEmuLenient,
|
|
691
|
+
perPoint: EMU_PER_POINT,
|
|
692
|
+
min: 0,
|
|
693
|
+
max: 51206400
|
|
694
|
+
};
|
|
695
|
+
const PARA_INDENT = {
|
|
696
|
+
code: "text/paragraph-indent-out-of-range",
|
|
697
|
+
label: "paraIndent",
|
|
698
|
+
range: "-4032..4032pt",
|
|
699
|
+
convert: ptsToEmuLenient,
|
|
700
|
+
perPoint: EMU_PER_POINT,
|
|
701
|
+
min: -51206400,
|
|
702
|
+
max: 51206400
|
|
703
|
+
};
|
|
704
|
+
const LINE_SPACING = {
|
|
705
|
+
code: "text/line-spacing-out-of-range",
|
|
706
|
+
label: "lineSpacing",
|
|
707
|
+
range: "0-1584pt",
|
|
708
|
+
convert: ptToHundredths,
|
|
709
|
+
perPoint: 100,
|
|
710
|
+
min: 0,
|
|
711
|
+
max: 158400
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
633
714
|
* Clamp a font size (points) into ST_TextFontSize (1-4000pt) and return it in
|
|
634
715
|
* hundredths of a point for the `sz` attribute. Out-of-range sizes make
|
|
635
716
|
* PowerPoint report the package as needing repair (e.g. `sz` > 400000 or < 100).
|
|
636
717
|
*/
|
|
637
718
|
function clampFontSizeSz(fontSizePts) {
|
|
638
|
-
|
|
639
|
-
const clamped = Math.min(4e5, Math.max(100, raw));
|
|
640
|
-
if (clamped !== raw) warnOnce("font/size-out-of-range", `fontSize ${fontSizePts} is outside the valid range 1-4000pt; using ${clamped / 100}.`);
|
|
641
|
-
return clamped;
|
|
719
|
+
return clampWithWarn(fontSizePts, FONT_SIZE);
|
|
642
720
|
}
|
|
643
721
|
/** Clamp character spacing (points) into ST_TextPoint (-4000..4000pt); returns hundredths for the `spc` attribute. */
|
|
644
722
|
function clampCharSpacingSpc(charSpacingPts) {
|
|
645
|
-
|
|
646
|
-
const clamped = Math.min(4e5, Math.max(-4e5, raw));
|
|
647
|
-
if (clamped !== raw) warnOnce("text/char-spacing-out-of-range", `charSpacing ${charSpacingPts} is outside the valid range -4000..4000pt; using ${clamped / 100}.`);
|
|
648
|
-
return clamped;
|
|
723
|
+
return clampWithWarn(charSpacingPts, CHAR_SPACING);
|
|
649
724
|
}
|
|
650
725
|
/**
|
|
651
726
|
* Clamp a paragraph's left margin (points) into ST_TextMargin (0..4032pt, i.e. 0..51206400 EMU);
|
|
@@ -653,10 +728,7 @@ function clampCharSpacingSpc(charSpacingPts) {
|
|
|
653
728
|
* it is a value PowerPoint reports as needing repair.
|
|
654
729
|
*/
|
|
655
730
|
function clampParaMarginEmu(marginPts) {
|
|
656
|
-
|
|
657
|
-
const clamped = Math.min(51206400, Math.max(0, raw));
|
|
658
|
-
if (clamped !== raw) warnOnce("text/paragraph-margin-out-of-range", `paraMarginLeft ${marginPts} is outside the valid range 0-4032pt; using ${clamped / EMU_PER_POINT}.`);
|
|
659
|
-
return clamped;
|
|
731
|
+
return clampWithWarn(marginPts, PARA_MARGIN);
|
|
660
732
|
}
|
|
661
733
|
/**
|
|
662
734
|
* Clamp a first-line indent (points) into ST_TextIndent (-4032..4032pt); returns EMU for
|
|
@@ -664,17 +736,11 @@ function clampParaMarginEmu(marginPts) {
|
|
|
664
736
|
* indent every bulleted paragraph uses.
|
|
665
737
|
*/
|
|
666
738
|
function clampParaIndentEmu(indentPts) {
|
|
667
|
-
|
|
668
|
-
const clamped = Math.min(51206400, Math.max(-51206400, raw));
|
|
669
|
-
if (clamped !== raw) warnOnce("text/paragraph-indent-out-of-range", `paraIndent ${indentPts} is outside the valid range -4032..4032pt; using ${clamped / EMU_PER_POINT}.`);
|
|
670
|
-
return clamped;
|
|
739
|
+
return clampWithWarn(indentPts, PARA_INDENT);
|
|
671
740
|
}
|
|
672
741
|
/** Clamp line spacing (points) into ST_TextSpacingPoint (0..1584pt); returns hundredths for `<a:spcPts val>`. */
|
|
673
742
|
function clampLineSpacingPts(lineSpacingPts) {
|
|
674
|
-
|
|
675
|
-
const clamped = Math.min(158400, Math.max(0, raw));
|
|
676
|
-
if (clamped !== raw) warnOnce("text/line-spacing-out-of-range", `lineSpacing ${lineSpacingPts} is outside the valid range 0-1584pt; using ${clamped / 100}.`);
|
|
677
|
-
return clamped;
|
|
743
|
+
return clampWithWarn(lineSpacingPts, LINE_SPACING);
|
|
678
744
|
}
|
|
679
745
|
//#endregion
|
|
680
746
|
//#region src/gen/drawingml/math.ts
|
|
@@ -805,7 +871,7 @@ function genXmlParagraphProperties(textObj, isDefault) {
|
|
|
805
871
|
let strXmlParaSpc = "";
|
|
806
872
|
let strXmlTabStops = "";
|
|
807
873
|
const tag = isDefault ? "a:lvl1pPr" : "a:pPr";
|
|
808
|
-
let bulletMarL =
|
|
874
|
+
let bulletMarL = ptsToEmuLenient(27);
|
|
809
875
|
let defaultMarL = null;
|
|
810
876
|
let defaultIndent = null;
|
|
811
877
|
let indentBeforeMarL = false;
|
|
@@ -834,7 +900,7 @@ function genXmlParagraphProperties(textObj, isDefault) {
|
|
|
834
900
|
if (typeof opts.bullet === "object") {
|
|
835
901
|
const bulletImage = opts.bullet.image;
|
|
836
902
|
const isPictureBullet = !!(bulletImage && (bulletImage.path || bulletImage.data));
|
|
837
|
-
if (opts.bullet?.indent) bulletMarL =
|
|
903
|
+
if (opts.bullet?.indent) bulletMarL = ptsToEmuLenient(opts.bullet.indent);
|
|
838
904
|
defaultMarL = opts.indentLevel && opts.indentLevel > 0 ? bulletMarL + bulletMarL * opts.indentLevel : bulletMarL;
|
|
839
905
|
defaultIndent = -bulletMarL;
|
|
840
906
|
if (opts.bullet.color && !isPictureBullet) strXmlBulletColor = el("a:buClr", null, raw(createColorElement(opts.bullet.color)));
|
|
@@ -1103,6 +1169,34 @@ function renderTextParagraphsXml(arrLines, slideObj, opts) {
|
|
|
1103
1169
|
return strSlideXml;
|
|
1104
1170
|
}
|
|
1105
1171
|
//#endregion
|
|
1172
|
+
//#region src/gen/opc/rels.ts
|
|
1173
|
+
/**
|
|
1174
|
+
* ts-pptx: shared `Relationship` writers.
|
|
1175
|
+
*
|
|
1176
|
+
* A `.rels` part is mostly one-off entries, written where the part that needs
|
|
1177
|
+
* them is built. This module holds the ones **more than one part** writes, so
|
|
1178
|
+
* that the attribute set stays a single fact — a `Relationship` whose `Type` and
|
|
1179
|
+
* `TargetMode` disagree between two writers does not throw, it produces a link
|
|
1180
|
+
* PowerPoint silently drops.
|
|
1181
|
+
*/
|
|
1182
|
+
/**
|
|
1183
|
+
* A `Relationship` to a URL outside the package: the shape of every external
|
|
1184
|
+
* hyperlink, whether it hangs off a slide (`gen/slide/object.ts`) or off a notes
|
|
1185
|
+
* slide (`gen/slide/notes.ts`). `TargetMode="External"` is what makes the target
|
|
1186
|
+
* a URI rather than a partname, so it is not optional.
|
|
1187
|
+
* @param {number} rId - the relationship id, without its `rId` prefix
|
|
1188
|
+
* @param {string} target - the URL, already escaped for an attribute value
|
|
1189
|
+
* @returns {string} the `Relationship` element
|
|
1190
|
+
*/
|
|
1191
|
+
function externalHyperlinkRel(rId, target) {
|
|
1192
|
+
return voidEl("Relationship", {
|
|
1193
|
+
Id: `rId${rId}`,
|
|
1194
|
+
Type: OFFICE_REL + "hyperlink",
|
|
1195
|
+
Target: target,
|
|
1196
|
+
TargetMode: "External"
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
//#endregion
|
|
1106
1200
|
//#region src/gen/slide/notes.ts
|
|
1107
1201
|
/**
|
|
1108
1202
|
* Collect the speaker-notes runs for a slide (flattened across any number of `addNotes()` calls).
|
|
@@ -1464,11 +1558,7 @@ function makeXmlNotesMaster() {
|
|
|
1464
1558
|
3200400,
|
|
1465
1559
|
3657600
|
|
1466
1560
|
].map((marL, i) => notesStyleLevel(i + 1, marL)).join("")));
|
|
1467
|
-
return XML_DECL + "\r\n" + el("p:notesMaster", {
|
|
1468
|
-
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
1469
|
-
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
1470
|
-
"xmlns:p": "http://schemas.openxmlformats.org/presentationml/2006/main"
|
|
1471
|
-
}, [
|
|
1561
|
+
return XML_DECL + "\r\n" + el("p:notesMaster", { ...PML_ROOT_NS }, [
|
|
1472
1562
|
raw(cSld),
|
|
1473
1563
|
raw(clrMap),
|
|
1474
1564
|
raw(notesStyle)
|
|
@@ -1588,11 +1678,7 @@ function makeXmlNotesSlideSkeleton(bodyParagraphsXml, slideNum) {
|
|
|
1588
1678
|
val: 1024086991
|
|
1589
1679
|
})))));
|
|
1590
1680
|
const cSld = el("p:cSld", null, [raw(spTree), raw(extLst)]);
|
|
1591
|
-
return XML_DECL + "\r\n" + el("p:notes", {
|
|
1592
|
-
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
1593
|
-
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
1594
|
-
"xmlns:p": "http://schemas.openxmlformats.org/presentationml/2006/main"
|
|
1595
|
-
}, [raw(cSld), raw(el("p:clrMapOvr", null, raw(voidEl("a:masterClrMapping"))))]);
|
|
1681
|
+
return XML_DECL + "\r\n" + el("p:notes", { ...PML_ROOT_NS }, [raw(cSld), raw(el("p:clrMapOvr", null, raw(voidEl("a:masterClrMapping"))))]);
|
|
1596
1682
|
}
|
|
1597
1683
|
/**
|
|
1598
1684
|
* Generates XML string for a notes-slide relation file (`ppt/notesSlides/_rels/notesSlideN.xml.rels`).
|
|
@@ -1602,12 +1688,7 @@ function makeXmlNotesSlideSkeleton(bodyParagraphsXml, slideNum) {
|
|
|
1602
1688
|
* @return {string} XML
|
|
1603
1689
|
*/
|
|
1604
1690
|
function makeXmlNotesSlideRel(slide, slideNumber) {
|
|
1605
|
-
const hlinkRels = buildNotesSlideRels(slide).map((rel) =>
|
|
1606
|
-
Id: `rId${rel.rId}`,
|
|
1607
|
-
Type: OFFICE_REL + "hyperlink",
|
|
1608
|
-
Target: rel.Target,
|
|
1609
|
-
TargetMode: "External"
|
|
1610
|
-
})).join("");
|
|
1691
|
+
const hlinkRels = buildNotesSlideRels(slide).map((rel) => externalHyperlinkRel(rel.rId, rel.Target)).join("");
|
|
1611
1692
|
return XML_DECL + el("Relationships", { xmlns: PACKAGE_REL_NS }, [
|
|
1612
1693
|
raw(voidEl("Relationship", {
|
|
1613
1694
|
Id: "rId1",
|
|
@@ -1641,6 +1722,6 @@ function makeXmlNotesMasterRel() {
|
|
|
1641
1722
|
});
|
|
1642
1723
|
}
|
|
1643
1724
|
//#endregion
|
|
1644
|
-
export {
|
|
1725
|
+
export { getDuplicateObjectNames as A, createShadowEffectLst as C, voidEl as D, raw as E, validateObjectName as F, getUuid as M, isHyperlinkRel as N, encodeXmlAttrValue as O, mediaSlideKey as P, correctShadowOptions as S, el as T, flattenEmbeddedFaces as _, makeXmlNotesSlideRel as a, genXmlGradientFill as b, genXmlNormAutofit as c, renderTextParagraphsXml as d, clampFontSizeSz as f, FONT_REL_TYPE as g, FONT_DATA_EXTENSION as h, makeXmlNotesSlide as i, getNewRelId as j, encodeXmlEntities as k, genXmlParagraphProperties as l, FONT_DATA_CONTENT_TYPE as m, makeXmlNotesMaster as n, makeXmlNotesSlideSkeleton as o, EMBEDDED_FONT_SLOTS as p, makeXmlNotesMasterRel as r, externalHyperlinkRel as s, buildNotesSlideRels as t, groupRunsIntoLines as u, serializeEmbeddedFontLst as v, createColorElement as w, genXmlPatternFill as x, genXmlColorSelection as y };
|
|
1645
1726
|
|
|
1646
|
-
//# sourceMappingURL=notes-
|
|
1727
|
+
//# sourceMappingURL=notes-DNqAggXx.js.map
|