@officedk/pptxdk 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
import { resolveFontClassification } from "../../core/dist/font-seal.js";
|
|
2
|
+
import "../../core/dist/capability.js";
|
|
3
|
+
import { resolvePlaceholderBoxFromLayers } from "../../core/dist/placeholders.js";
|
|
4
|
+
import { createThemeContext, defaultColorMap, defaultTheme, isFont, nativeColorSlots, schemeColorSlots } from "../../core/dist/theme.js";
|
|
5
|
+
import { shapeTreeXml } from "./shape-tree.js";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
// ../emit/dist/ooxml.js
|
|
8
|
+
function pxToEmu(value) {
|
|
9
|
+
return Math.round(value * 9525);
|
|
10
|
+
}
|
|
11
|
+
function assertXml10Characters(value) {
|
|
12
|
+
for (const character of value) {
|
|
13
|
+
const codePoint = character.codePointAt(0);
|
|
14
|
+
if (codePoint !== void 0 && codePoint !== 9 && codePoint !== 10 && codePoint !== 13 && (codePoint < 32 || codePoint >= 55296 && codePoint <= 57343 || codePoint === 65534 || codePoint === 65535)) throw new Error("String contains characters not allowed in XML 1.0");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function xmlEscape(value) {
|
|
18
|
+
assertXml10Characters(value);
|
|
19
|
+
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """).replace(/'/gu, "'").replace(/\r/gu, "
").replace(/\n/gu, "
").replace(/\t/gu, "	");
|
|
20
|
+
}
|
|
21
|
+
function xmlDocument(body) {
|
|
22
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n${body}`;
|
|
23
|
+
}
|
|
24
|
+
const nativeSchemeReference = {
|
|
25
|
+
dk1: "tx1",
|
|
26
|
+
lt1: "bg1",
|
|
27
|
+
dk2: "tx2",
|
|
28
|
+
lt2: "bg2",
|
|
29
|
+
accent1: "accent1",
|
|
30
|
+
accent2: "accent2",
|
|
31
|
+
accent3: "accent3",
|
|
32
|
+
accent4: "accent4",
|
|
33
|
+
accent5: "accent5",
|
|
34
|
+
accent6: "accent6",
|
|
35
|
+
hlink: "hlink",
|
|
36
|
+
folHlink: "folHlink"
|
|
37
|
+
};
|
|
38
|
+
/** Write native theme colors as schemeClr and literal colors as srgbClr. */
|
|
39
|
+
function resolvedColorXml(value) {
|
|
40
|
+
const children = [
|
|
41
|
+
value.lumMod === void 0 ? "" : `<a:lumMod val="${Math.round(value.lumMod * 1e5)}"/>`,
|
|
42
|
+
value.lumOff === void 0 ? "" : `<a:lumOff val="${Math.round(value.lumOff * 1e5)}"/>`,
|
|
43
|
+
value.alpha === void 0 ? "" : `<a:alpha val="${Math.round(value.alpha * 1e5)}"/>`
|
|
44
|
+
].join("");
|
|
45
|
+
const schemeVal = value.scheme ?? (value.slot === void 0 ? void 0 : nativeSchemeReference[value.slot]);
|
|
46
|
+
const element = schemeVal === void 0 ? "srgbClr" : "schemeClr";
|
|
47
|
+
const color = schemeVal ?? value.hex;
|
|
48
|
+
return children === "" ? `<a:${element} val="${color}"/>` : `<a:${element} val="${color}">${children}</a:${element}>`;
|
|
49
|
+
}
|
|
50
|
+
const namespaces = {
|
|
51
|
+
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
52
|
+
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
53
|
+
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
54
|
+
relationships: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
55
|
+
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
56
|
+
};
|
|
57
|
+
const minimumSlideLayoutId = 2147483648;
|
|
58
|
+
function relationships(entries) {
|
|
59
|
+
return xmlDocument(`<Relationships xmlns="${namespaces.relationships}">${entries.map(({ id, type, target, targetMode }) => `<Relationship Id="${xmlEscape(id)}" Type="${xmlEscape(type)}" Target="${xmlEscape(target)}"${targetMode === void 0 ? "" : ` TargetMode="${xmlEscape(targetMode)}"`}/>`).join("")}</Relationships>`);
|
|
60
|
+
}
|
|
61
|
+
const defaultEmittedMasters = [{
|
|
62
|
+
key: "master-1",
|
|
63
|
+
name: "Office Theme",
|
|
64
|
+
layouts: [{
|
|
65
|
+
key: "layout-1",
|
|
66
|
+
name: "Blank",
|
|
67
|
+
type: "blank",
|
|
68
|
+
preserve: true
|
|
69
|
+
}]
|
|
70
|
+
}];
|
|
71
|
+
function contentTypes(masterCount, layoutCount, themeCount, themeOverrideCount, slideCount, resources, packageParts, hasCoreProperties) {
|
|
72
|
+
const overrides = [
|
|
73
|
+
["/ppt/presentation.xml", "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"],
|
|
74
|
+
...Array.from({ length: masterCount }, (_, index) => [`/ppt/slideMasters/slideMaster${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"]),
|
|
75
|
+
...Array.from({ length: layoutCount }, (_, index) => [`/ppt/slideLayouts/slideLayout${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"]),
|
|
76
|
+
...Array.from({ length: themeCount }, (_, index) => [`/ppt/theme/theme${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.theme+xml"]),
|
|
77
|
+
...Array.from({ length: themeOverrideCount }, (_, index) => [`/ppt/theme/themeOverride${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.themeOverride+xml"]),
|
|
78
|
+
...Array.from({ length: slideCount }, (_, index) => [`/ppt/slides/slide${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slide+xml"]),
|
|
79
|
+
...hasCoreProperties ? [["/docProps/core.xml", "application/vnd.openxmlformats-package.core-properties+xml"]] : [],
|
|
80
|
+
...packageParts.map((part) => [`/${part.path}`, part.contentType])
|
|
81
|
+
];
|
|
82
|
+
const defaults = /* @__PURE__ */ new Map([["rels", "application/vnd.openxmlformats-package.relationships+xml"], ["xml", "application/xml"]]);
|
|
83
|
+
for (const resource of resources) defaults.set(resource.extension, resource.contentType);
|
|
84
|
+
return xmlDocument(`<Types xmlns="${namespaces.contentTypes}">${[...defaults].map(([extension, contentType]) => `<Default Extension="${xmlEscape(extension)}" ContentType="${xmlEscape(contentType)}"/>`).join("")}${overrides.map(([partName, contentType]) => `<Override PartName="${xmlEscape(partName)}" ContentType="${xmlEscape(contentType)}"/>`).join("")}</Types>`);
|
|
85
|
+
}
|
|
86
|
+
function normalizedHex6(color, label) {
|
|
87
|
+
const trimmed = color.trim();
|
|
88
|
+
const six = /^#[0-9a-f]{3}$/iu.test(trimmed) ? trimmed.slice(1).split("").map((c) => c + c).join("") : /^#[0-9a-f]{6}$/iu.test(trimmed) ? trimmed.slice(1) : void 0;
|
|
89
|
+
if (six === void 0) throw new Error(`${label} must be a #RRGGBB color`);
|
|
90
|
+
return six.toUpperCase();
|
|
91
|
+
}
|
|
92
|
+
function colorSchemeXml(name, colors) {
|
|
93
|
+
return `<a:clrScheme name="${xmlEscape(name)}">${nativeColorSlots.map((slot) => {
|
|
94
|
+
return `<a:${slot}><a:srgbClr val="${normalizedHex6(colors[slot], `Theme.colors.${slot}`)}"/></a:${slot}>`;
|
|
95
|
+
}).join("")}</a:clrScheme>`;
|
|
96
|
+
}
|
|
97
|
+
function fontClassificationAttrs(fontValue, weight, faceStyle) {
|
|
98
|
+
if (fontValue === void 0) return "";
|
|
99
|
+
const cls = resolveFontClassification(fontValue, weight, faceStyle);
|
|
100
|
+
if (cls === void 0) return "";
|
|
101
|
+
return `${cls.panose === void 0 ? "" : ` panose="${cls.panose}"`} pitchFamily="${cls.pitchFamily}"`;
|
|
102
|
+
}
|
|
103
|
+
function fontSchemeXml(name, majorValue, minorValue, majorEastAsianValue, minorEastAsianValue) {
|
|
104
|
+
const effectiveMajorEa = majorEastAsianValue ?? majorValue;
|
|
105
|
+
const effectiveMinorEa = minorEastAsianValue ?? minorValue;
|
|
106
|
+
const major = isFont(majorValue) ? majorValue.family : majorValue;
|
|
107
|
+
const minor = isFont(minorValue) ? minorValue.family : minorValue;
|
|
108
|
+
const majorEa = isFont(effectiveMajorEa) ? effectiveMajorEa.family : effectiveMajorEa;
|
|
109
|
+
const minorEa = isFont(effectiveMinorEa) ? effectiveMinorEa.family : effectiveMinorEa;
|
|
110
|
+
const majorEscaped = xmlEscape(major);
|
|
111
|
+
const minorEscaped = xmlEscape(minor);
|
|
112
|
+
const majorEaEscaped = xmlEscape(majorEa);
|
|
113
|
+
const minorEaEscaped = xmlEscape(minorEa);
|
|
114
|
+
const majorAttrs = fontClassificationAttrs(isFont(majorValue) ? majorValue : void 0);
|
|
115
|
+
const minorAttrs = fontClassificationAttrs(isFont(minorValue) ? minorValue : void 0);
|
|
116
|
+
const majorEaAttrs = fontClassificationAttrs(isFont(effectiveMajorEa) ? effectiveMajorEa : void 0);
|
|
117
|
+
const minorEaAttrs = fontClassificationAttrs(isFont(effectiveMinorEa) ? effectiveMinorEa : void 0);
|
|
118
|
+
return `<a:fontScheme name="${xmlEscape(name)}"><a:majorFont><a:latin typeface="${majorEscaped}"${majorAttrs}/><a:ea typeface="${majorEaEscaped}"${majorEaAttrs}/><a:cs typeface="${majorEscaped}"/></a:majorFont><a:minorFont><a:latin typeface="${minorEscaped}"${minorAttrs}/><a:ea typeface="${minorEaEscaped}"${minorEaAttrs}/><a:cs typeface="${minorEscaped}"/></a:minorFont></a:fontScheme>`;
|
|
119
|
+
}
|
|
120
|
+
function formatColorTransformXml(transform) {
|
|
121
|
+
const mods = [
|
|
122
|
+
transform.tint === void 0 ? "" : `<a:tint val="${Math.round(transform.tint * 1e5)}"/>`,
|
|
123
|
+
transform.shade === void 0 ? "" : `<a:shade val="${Math.round(transform.shade * 1e5)}"/>`,
|
|
124
|
+
transform.satMod === void 0 ? "" : `<a:satMod val="${Math.round(transform.satMod * 1e5)}"/>`,
|
|
125
|
+
transform.lumMod === void 0 ? "" : `<a:lumMod val="${Math.round(transform.lumMod * 1e5)}"/>`,
|
|
126
|
+
transform.lumOff === void 0 ? "" : `<a:lumOff val="${Math.round(transform.lumOff * 1e5)}"/>`,
|
|
127
|
+
transform.alpha === void 0 ? "" : `<a:alpha val="${Math.round(transform.alpha * 1e5)}"/>`
|
|
128
|
+
].join("");
|
|
129
|
+
if (transform.color.startsWith("#")) {
|
|
130
|
+
const hex = normalizedHex6(transform.color, "FormatScheme color");
|
|
131
|
+
return mods === "" ? `<a:srgbClr val="${hex}"/>` : `<a:srgbClr val="${hex}">${mods}</a:srgbClr>`;
|
|
132
|
+
}
|
|
133
|
+
return mods === "" ? `<a:schemeClr val="${xmlEscape(transform.color)}"/>` : `<a:schemeClr val="${xmlEscape(transform.color)}">${mods}</a:schemeClr>`;
|
|
134
|
+
}
|
|
135
|
+
function formatFillStyleXml(fill) {
|
|
136
|
+
if (fill.kind === "none") return "<a:noFill/>";
|
|
137
|
+
if (fill.kind === "solid") return `<a:solidFill>${formatColorTransformXml(fill.color)}</a:solidFill>`;
|
|
138
|
+
return `<a:gradFill${fill.rotWithShape === void 0 ? "" : ` rotWithShape="${fill.rotWithShape ? "1" : "0"}"`}><a:gsLst>${fill.stops.map((stop) => `<a:gs pos="${Math.round(stop.position * 1e5)}">${formatColorTransformXml(stop.color)}</a:gs>`).join("")}</a:gsLst>${fill.linear === void 0 ? "" : `<a:lin ang="${Math.round(fill.linear.angle * 6e4)}"${fill.linear.scaled === void 0 ? "" : ` scaled="${fill.linear.scaled ? "1" : "0"}"`}/>`}${fill.path === void 0 ? "" : `<a:path path="${fill.path.shape}">${fill.path.fillToRect === void 0 ? "" : `<a:fillToRect l="${Math.round(fill.path.fillToRect.l * 1e5)}" t="${Math.round(fill.path.fillToRect.t * 1e5)}" r="${Math.round(fill.path.fillToRect.r * 1e5)}" b="${Math.round(fill.path.fillToRect.b * 1e5)}"/>`}</a:path>`}</a:gradFill>`;
|
|
139
|
+
}
|
|
140
|
+
function formatLineStyleXml(line) {
|
|
141
|
+
return `<a:ln${[
|
|
142
|
+
line.widthEmu === void 0 ? "" : ` w="${line.widthEmu}"`,
|
|
143
|
+
line.cap === void 0 ? "" : ` cap="${line.cap}"`,
|
|
144
|
+
line.compound === void 0 ? "" : ` cmpd="${line.compound}"`,
|
|
145
|
+
line.align === void 0 ? "" : ` algn="${line.align}"`
|
|
146
|
+
].join("")}>${line.fill === void 0 ? `<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>` : formatFillStyleXml(line.fill)}${line.dash === void 0 ? "" : `<a:prstDash val="${xmlEscape(line.dash)}"/>`}</a:ln>`;
|
|
147
|
+
}
|
|
148
|
+
function positiveFixedAngleUnits(angleDegrees) {
|
|
149
|
+
return Math.round((angleDegrees % 360 + 360) % 360 * 6e4) % 216e5;
|
|
150
|
+
}
|
|
151
|
+
function formatEffectStyleXml(effect) {
|
|
152
|
+
if (effect.shadow === void 0) return "<a:effectStyle><a:effectLst/></a:effectStyle>";
|
|
153
|
+
return `<a:effectStyle><a:effectLst><a:outerShdw blurRad="${Math.round((effect.shadow.blur ?? 0) * 12700)}" dist="${Math.round((effect.shadow.distance ?? 0) * 12700)}" dir="${positiveFixedAngleUnits(effect.shadow.angle ?? 0)}" rotWithShape="0">${typeof effect.shadow.color === "string" && effect.shadow.color.startsWith("#") ? `<a:srgbClr val="${normalizedHex6(effect.shadow.color, "shadow.color")}"/>` : "<a:srgbClr val=\"000000\"><a:alpha val=\"38000\"/></a:srgbClr>"}</a:outerShdw></a:effectLst></a:effectStyle>`;
|
|
154
|
+
}
|
|
155
|
+
function padFormatStyleXmlList(entries, fallbackXml) {
|
|
156
|
+
const padded = [...entries];
|
|
157
|
+
while (padded.length < 3) padded.push(fallbackXml);
|
|
158
|
+
return padded.join("");
|
|
159
|
+
}
|
|
160
|
+
function formatSchemeXml(scheme) {
|
|
161
|
+
const fill = `<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>`;
|
|
162
|
+
const line = `<a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln>`;
|
|
163
|
+
const effect = `<a:effectStyle><a:effectLst/></a:effectStyle>`;
|
|
164
|
+
if (scheme === void 0) return `<a:fmtScheme name="Office"><a:fillStyleLst>${fill}${fill}${fill}</a:fillStyleLst><a:lnStyleLst>${line}${line}${line}</a:lnStyleLst><a:effectStyleLst>${effect}${effect}${effect}</a:effectStyleLst><a:bgFillStyleLst>${fill}${fill}${fill}</a:bgFillStyleLst></a:fmtScheme>`;
|
|
165
|
+
const fillList = padFormatStyleXmlList((scheme.fillStyles ?? []).map(formatFillStyleXml), fill);
|
|
166
|
+
const lnList = padFormatStyleXmlList((scheme.lineStyles ?? []).map(formatLineStyleXml), line);
|
|
167
|
+
const effList = padFormatStyleXmlList((scheme.effectStyles ?? []).map(formatEffectStyleXml), effect);
|
|
168
|
+
const bgList = padFormatStyleXmlList((scheme.bgFillStyles ?? []).map(formatFillStyleXml), fill);
|
|
169
|
+
return `<a:fmtScheme name="${xmlEscape(scheme.name ?? "Office")}"><a:fillStyleLst>${fillList}</a:fillStyleLst><a:lnStyleLst>${lnList}</a:lnStyleLst><a:effectStyleLst>${effList}</a:effectStyleLst><a:bgFillStyleLst>${bgList}</a:bgFillStyleLst></a:fmtScheme>`;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Serializes a resolved deck or master theme as a native theme part.
|
|
173
|
+
*/
|
|
174
|
+
function themeXml(value) {
|
|
175
|
+
const name = xmlEscape(value.name);
|
|
176
|
+
const colors = colorSchemeXml(value.name, value.colors);
|
|
177
|
+
const fonts = fontSchemeXml(value.name, value.fonts.major, value.fonts.minor, value.fonts.majorEastAsian, value.fonts.minorEastAsian);
|
|
178
|
+
const format = formatSchemeXml(value.formatScheme);
|
|
179
|
+
return xmlDocument(`<a:theme xmlns:a="${namespaces.a}" name="${name}"><a:themeElements>${colors}${fonts}${format}</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>`);
|
|
180
|
+
}
|
|
181
|
+
function fontSizeCentipoints(value) {
|
|
182
|
+
if (typeof value === "string" && value.endsWith("pt")) return Math.round(Number(value.slice(0, -2)) * 100);
|
|
183
|
+
if (typeof value === "string" && value.endsWith("px")) return Math.round(Number(value.slice(0, -2)) * 75);
|
|
184
|
+
return Math.round(Number(value) * 75);
|
|
185
|
+
}
|
|
186
|
+
function lengthCentipoints(value) {
|
|
187
|
+
if (typeof value === "string" && value.endsWith("pt")) return Math.round(Number(value.slice(0, -2)) * 100);
|
|
188
|
+
if (typeof value === "string" && value.endsWith("px")) return Math.round(Number(value.slice(0, -2)) * 75);
|
|
189
|
+
return Math.round(Number(value) * 75);
|
|
190
|
+
}
|
|
191
|
+
function ooxmlAlign(value) {
|
|
192
|
+
switch (value) {
|
|
193
|
+
case "left": return "l";
|
|
194
|
+
case "center": return "ctr";
|
|
195
|
+
case "right": return "r";
|
|
196
|
+
case "justify": return "just";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function ooxmlAnchor(value) {
|
|
200
|
+
return value === "middle" ? "ctr" : value === "bottom" ? "b" : "t";
|
|
201
|
+
}
|
|
202
|
+
function placeholderRefXml(ref) {
|
|
203
|
+
const attrs = [];
|
|
204
|
+
if (ref.explicitType !== false) attrs.push(`type="${xmlEscape(ref.type)}"`);
|
|
205
|
+
const size = ref.size;
|
|
206
|
+
if (size !== void 0) attrs.push(`sz="${xmlEscape(size)}"`);
|
|
207
|
+
if (ref.orient !== void 0) attrs.push(`orient="${xmlEscape(ref.orient)}"`);
|
|
208
|
+
if (ref.idx !== void 0) attrs.push(`idx="${ref.idx}"`);
|
|
209
|
+
if (ref.hasCustomPrompt === true) attrs.push("hasCustomPrompt=\"1\"");
|
|
210
|
+
return `<p:ph${attrs.length === 0 ? "" : ` ${attrs.join(" ")}`}/>`;
|
|
211
|
+
}
|
|
212
|
+
function levelDefRPrXml(style, themeContext) {
|
|
213
|
+
const attrs = [];
|
|
214
|
+
if (style.lang !== void 0) attrs.push(`lang="${xmlEscape(style.lang)}"`);
|
|
215
|
+
if (style.fontSize !== void 0) attrs.push(`sz="${fontSizeCentipoints(style.fontSize)}"`);
|
|
216
|
+
if (style.fontWeight !== void 0) {
|
|
217
|
+
const bold = style.fontWeight === "bold" || typeof style.fontWeight === "number" && style.fontWeight >= 600;
|
|
218
|
+
attrs.push(`b="${bold ? 1 : 0}"`);
|
|
219
|
+
}
|
|
220
|
+
if (style.fontStyle !== void 0) attrs.push(`i="${style.fontStyle === "italic" ? 1 : 0}"`);
|
|
221
|
+
if (style.textDecoration === "underline") attrs.push("u=\"sng\"");
|
|
222
|
+
else if (style.textDecoration === "line-through") attrs.push("strike=\"sngStrike\"");
|
|
223
|
+
if (style.textTransform === "uppercase") attrs.push("cap=\"all\"");
|
|
224
|
+
if (style.letterSpacing !== void 0) attrs.push(`spc="${Math.round(style.letterSpacing * 75)}"`);
|
|
225
|
+
let fillXml = "";
|
|
226
|
+
if (style.color !== void 0) fillXml = `<a:solidFill>${resolvedColorXml(themeContext.resolveColor(style.color))}</a:solidFill>`;
|
|
227
|
+
let effectXml = "";
|
|
228
|
+
if (style.textShadow === "none") effectXml = "<a:effectLst/>";
|
|
229
|
+
else if (style.textShadow !== void 0) effectXml = `<a:effectLst><a:outerShdw blurRad="${pxToEmu(style.textShadow.blur ?? 4)}" dist="${pxToEmu(style.textShadow.distance ?? 0)}" dir="${positiveFixedAngleUnits(style.textShadow.angle ?? 90)}" algn="ctr" rotWithShape="0">${resolvedColorXml(themeContext.resolveColor(style.textShadow.color ?? {
|
|
230
|
+
color: "#000000",
|
|
231
|
+
alpha: .35
|
|
232
|
+
}))}</a:outerShdw></a:effectLst>`;
|
|
233
|
+
let fontXml = "";
|
|
234
|
+
if (style.fontFamily !== void 0 || style.eastAsianFontFamily !== void 0) {
|
|
235
|
+
const weight = style.fontWeight === "bold" ? 700 : style.fontWeight === "normal" ? 400 : typeof style.fontWeight === "number" ? style.fontWeight : 400;
|
|
236
|
+
fontXml = `${(() => {
|
|
237
|
+
if (style.fontFamily === void 0) return "";
|
|
238
|
+
const resolved = themeContext.resolveFont(style.fontFamily);
|
|
239
|
+
const clsAttrs = resolved.themeFont === void 0 ? fontClassificationAttrs(resolved.font, weight, style.fontStyle) : "";
|
|
240
|
+
return `<a:latin typeface="${xmlEscape(resolved.themeFont === "major" ? "+mj-lt" : resolved.themeFont === "minor" ? "+mn-lt" : resolved.family)}"${clsAttrs}/>`;
|
|
241
|
+
})()}${(() => {
|
|
242
|
+
if (style.eastAsianFontFamily === void 0) return "";
|
|
243
|
+
const resolvedEa = themeContext.resolveEastAsianFont(style.eastAsianFontFamily);
|
|
244
|
+
const clsAttrs = resolvedEa.themeFont === void 0 ? fontClassificationAttrs(resolvedEa.font, weight, style.fontStyle) : "";
|
|
245
|
+
return `<a:ea typeface="${xmlEscape(resolvedEa.themeFont === "major" ? "+mj-ea" : resolvedEa.themeFont === "minor" ? "+mn-ea" : resolvedEa.family)}"${clsAttrs}/>`;
|
|
246
|
+
})()}${(() => {
|
|
247
|
+
if (style.fontFamily === void 0) return "";
|
|
248
|
+
const resolved = themeContext.resolveFont(style.fontFamily);
|
|
249
|
+
return `<a:cs typeface="${xmlEscape(resolved.themeFont === "major" ? "+mj-cs" : resolved.themeFont === "minor" ? "+mn-cs" : resolved.family)}"/>`;
|
|
250
|
+
})()}`;
|
|
251
|
+
}
|
|
252
|
+
if (attrs.length === 0 && fillXml === "" && effectXml === "" && fontXml === "") return "";
|
|
253
|
+
const attrText = attrs.length === 0 ? "" : ` ${attrs.join(" ")}`;
|
|
254
|
+
const inner = `${fillXml}${effectXml}${fontXml}`;
|
|
255
|
+
return inner === "" ? `<a:defRPr${attrText}/>` : `<a:defRPr${attrText}>${inner}</a:defRPr>`;
|
|
256
|
+
}
|
|
257
|
+
function levelLineSpacingXml(value) {
|
|
258
|
+
if (value === void 0) return "";
|
|
259
|
+
if (typeof value === "string" && value.endsWith("%")) return `<a:lnSpc><a:spcPct val="${Math.round(Number(value.slice(0, -1)) * 1e3)}"/></a:lnSpc>`;
|
|
260
|
+
return `<a:lnSpc><a:spcPts val="${lengthCentipoints(value)}"/></a:lnSpc>`;
|
|
261
|
+
}
|
|
262
|
+
function levelParagraphPropertiesXml(tagName, level, themeContext) {
|
|
263
|
+
const attrs = [];
|
|
264
|
+
if (level.marginLeft !== void 0) attrs.push(`marL="${pxToEmu(level.marginLeft)}"`);
|
|
265
|
+
if (level.indent !== void 0) attrs.push(`indent="${pxToEmu(level.indent)}"`);
|
|
266
|
+
if (level.align !== void 0) attrs.push(`algn="${ooxmlAlign(level.align)}"`);
|
|
267
|
+
const spcBef = level.spacingBefore === void 0 ? "" : `<a:spcBef><a:spcPts val="${Math.round(level.spacingBefore * 75)}"/></a:spcBef>`;
|
|
268
|
+
const lnSpc = levelLineSpacingXml(level.lineHeight);
|
|
269
|
+
const spcAft = level.spacingAfter === void 0 ? "" : `<a:spcAft><a:spcPts val="${Math.round(level.spacingAfter * 75)}"/></a:spcAft>`;
|
|
270
|
+
let listXml = "";
|
|
271
|
+
if (level.list !== void 0) {
|
|
272
|
+
if (level.list.type === "bullet") listXml = `<a:buChar char="${xmlEscape(level.list.character ?? "•")}"/>`;
|
|
273
|
+
else listXml = `<a:buAutoNum type="${level.list.style ?? "arabicPeriod"}"${level.list.startAt === void 0 ? "" : ` startAt="${level.list.startAt}"`}/>`;
|
|
274
|
+
}
|
|
275
|
+
const defRPr = levelDefRPrXml(level, themeContext);
|
|
276
|
+
const children = `${lnSpc}${spcBef}${spcAft}${listXml}${defRPr}`;
|
|
277
|
+
if (attrs.length === 0 && children === "") return "";
|
|
278
|
+
const attrText = attrs.length === 0 ? "" : ` ${attrs.join(" ")}`;
|
|
279
|
+
return children === "" ? `<${tagName}${attrText}/>` : `<${tagName}${attrText}>${children}</${tagName}>`;
|
|
280
|
+
}
|
|
281
|
+
function listStylesInnerXml(styles, themeContext) {
|
|
282
|
+
if (styles === void 0) return "";
|
|
283
|
+
const parts = [];
|
|
284
|
+
for (const levelNumber of [
|
|
285
|
+
1,
|
|
286
|
+
2,
|
|
287
|
+
3,
|
|
288
|
+
4,
|
|
289
|
+
5,
|
|
290
|
+
6,
|
|
291
|
+
7,
|
|
292
|
+
8,
|
|
293
|
+
9
|
|
294
|
+
]) {
|
|
295
|
+
const entry = styles[levelNumber];
|
|
296
|
+
if (entry === void 0) continue;
|
|
297
|
+
const xml = levelParagraphPropertiesXml(`a:lvl${levelNumber}pPr`, entry, themeContext);
|
|
298
|
+
if (xml !== "") parts.push(xml);
|
|
299
|
+
}
|
|
300
|
+
return parts.join("");
|
|
301
|
+
}
|
|
302
|
+
function styleAsLevel1(style) {
|
|
303
|
+
if (style === void 0) return void 0;
|
|
304
|
+
const lvl = {};
|
|
305
|
+
for (const key of [
|
|
306
|
+
"fontFamily",
|
|
307
|
+
"eastAsianFontFamily",
|
|
308
|
+
"fontSize",
|
|
309
|
+
"fontWeight",
|
|
310
|
+
"fontStyle",
|
|
311
|
+
"color",
|
|
312
|
+
"letterSpacing",
|
|
313
|
+
"textTransform",
|
|
314
|
+
"textDecoration",
|
|
315
|
+
"textShadow",
|
|
316
|
+
"lang",
|
|
317
|
+
"lineHeight",
|
|
318
|
+
"align",
|
|
319
|
+
"spacingAfter"
|
|
320
|
+
]) if (style[key] !== void 0) lvl[key] = style[key];
|
|
321
|
+
return Object.keys(lvl).length === 0 ? void 0 : lvl;
|
|
322
|
+
}
|
|
323
|
+
function placeholderBodyPrXml(style) {
|
|
324
|
+
if (style === void 0) return "<a:bodyPr/>";
|
|
325
|
+
const attrs = [];
|
|
326
|
+
if (style.textWrap !== void 0) attrs.push(`wrap="${style.textWrap === "nowrap" ? "none" : "square"}"`);
|
|
327
|
+
const rawPad = style.padding;
|
|
328
|
+
const padTop = style.paddingTop ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad[0] : void 0);
|
|
329
|
+
const padRight = style.paddingRight ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad[1] : void 0);
|
|
330
|
+
const padBottom = style.paddingBottom ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad.length === 2 ? rawPad[0] : rawPad[2] : void 0);
|
|
331
|
+
const padLeft = style.paddingLeft ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad.length === 2 ? rawPad[1] : rawPad[3] : void 0);
|
|
332
|
+
if (padLeft !== void 0) attrs.push(`lIns="${pxToEmu(padLeft)}"`);
|
|
333
|
+
if (padTop !== void 0) attrs.push(`tIns="${pxToEmu(padTop)}"`);
|
|
334
|
+
if (padRight !== void 0) attrs.push(`rIns="${pxToEmu(padRight)}"`);
|
|
335
|
+
if (padBottom !== void 0) attrs.push(`bIns="${pxToEmu(padBottom)}"`);
|
|
336
|
+
if (style.verticalAlign !== void 0) attrs.push(`anchor="${ooxmlAnchor(style.verticalAlign)}"`);
|
|
337
|
+
return attrs.length === 0 ? "<a:bodyPr/>" : `<a:bodyPr ${attrs.join(" ")}/>`;
|
|
338
|
+
}
|
|
339
|
+
function placeholderShapesXml(placeholders, themeContext, placeholderSpPrByKey) {
|
|
340
|
+
if (placeholders === void 0) return "";
|
|
341
|
+
return Object.entries(placeholders).map(([key, spec], index) => {
|
|
342
|
+
const id = 2 + index;
|
|
343
|
+
const name = xmlEscape(spec.name ?? key);
|
|
344
|
+
const size = spec.size;
|
|
345
|
+
const phXml = placeholderRefXml({
|
|
346
|
+
type: spec.type,
|
|
347
|
+
...spec.explicitType === void 0 ? {} : { explicitType: spec.explicitType },
|
|
348
|
+
...spec.idx === void 0 ? {} : { idx: spec.idx },
|
|
349
|
+
...size === void 0 ? {} : { size },
|
|
350
|
+
...spec.orient === void 0 ? {} : { orient: spec.orient },
|
|
351
|
+
...spec.hasCustomPrompt === void 0 ? {} : { hasCustomPrompt: spec.hasCustomPrompt }
|
|
352
|
+
});
|
|
353
|
+
const resolvedBox = resolvePlaceholderBoxFromLayers([spec]);
|
|
354
|
+
const hasBox = typeof resolvedBox.x === "number" && typeof resolvedBox.y === "number" && typeof resolvedBox.width === "number" && typeof resolvedBox.height === "number";
|
|
355
|
+
const spPr = placeholderSpPrByKey?.[key] ?? (hasBox ? `<p:spPr><a:xfrm><a:off x="${pxToEmu(resolvedBox.x)}" y="${pxToEmu(resolvedBox.y)}"/><a:ext cx="${pxToEmu(resolvedBox.width)}" cy="${pxToEmu(resolvedBox.height)}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr>` : "<p:spPr/>");
|
|
356
|
+
const mergedLvl1 = styleAsLevel1(spec.style) === void 0 && spec.listStyles?.[1] === void 0 ? void 0 : {
|
|
357
|
+
...styleAsLevel1(spec.style),
|
|
358
|
+
...spec.listStyles?.[1]
|
|
359
|
+
};
|
|
360
|
+
const lstStyleInner = listStylesInnerXml(mergedLvl1 === void 0 && spec.listStyles === void 0 ? void 0 : {
|
|
361
|
+
...spec.listStyles,
|
|
362
|
+
...mergedLvl1 === void 0 ? {} : { 1: mergedLvl1 }
|
|
363
|
+
}, themeContext);
|
|
364
|
+
const lstStyle = lstStyleInner === "" ? "<a:lstStyle/>" : `<a:lstStyle>${lstStyleInner}</a:lstStyle>`;
|
|
365
|
+
return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${name}"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${phXml}</p:nvPr></p:nvSpPr>${spPr}<p:txBody>${placeholderBodyPrXml(spec.style)}${lstStyle}${spec.promptText === void 0 ? "<a:p><a:endParaRPr/></a:p>" : `<a:p><a:r><a:t xml:space="preserve">${xmlEscape(spec.promptText)}</a:t></a:r></a:p>`}</p:txBody></p:sp>`;
|
|
366
|
+
}).join("");
|
|
367
|
+
}
|
|
368
|
+
function masterTextStylesXml(textStyles, themeContext) {
|
|
369
|
+
if (textStyles === void 0) return "<p:txStyles><p:titleStyle/><p:bodyStyle/><p:otherStyle/></p:txStyles>";
|
|
370
|
+
const titleInner = listStylesInnerXml(textStyles.titleStyle, themeContext);
|
|
371
|
+
const bodyInner = listStylesInnerXml(textStyles.bodyStyle, themeContext);
|
|
372
|
+
const otherInner = listStylesInnerXml(textStyles.otherStyle, themeContext);
|
|
373
|
+
return `<p:txStyles>${titleInner === "" ? "<p:titleStyle/>" : `<p:titleStyle>${titleInner}</p:titleStyle>`}${bodyInner === "" ? "<p:bodyStyle/>" : `<p:bodyStyle>${bodyInner}</p:bodyStyle>`}${otherInner === "" ? "<p:otherStyle/>" : `<p:otherStyle>${otherInner}</p:otherStyle>`}</p:txStyles>`;
|
|
374
|
+
}
|
|
375
|
+
function effectiveThemeWithOverride(baseTheme, override) {
|
|
376
|
+
if (override === void 0) return baseTheme;
|
|
377
|
+
const mergedColors = { ...baseTheme.colors };
|
|
378
|
+
if (override.colors !== void 0) for (const slot of nativeColorSlots) {
|
|
379
|
+
const value = override.colors[slot];
|
|
380
|
+
if (value !== void 0) mergedColors[slot] = value;
|
|
381
|
+
}
|
|
382
|
+
const mergedFonts = {
|
|
383
|
+
...baseTheme.fonts,
|
|
384
|
+
...override.fonts?.major === void 0 ? {} : { major: override.fonts.major },
|
|
385
|
+
...override.fonts?.minor === void 0 ? {} : { minor: override.fonts.minor },
|
|
386
|
+
...override.fonts?.majorEastAsian === void 0 ? {} : { majorEastAsian: override.fonts.majorEastAsian },
|
|
387
|
+
...override.fonts?.minorEastAsian === void 0 ? {} : { minorEastAsian: override.fonts.minorEastAsian }
|
|
388
|
+
};
|
|
389
|
+
return {
|
|
390
|
+
...baseTheme,
|
|
391
|
+
colors: mergedColors,
|
|
392
|
+
fonts: mergedFonts,
|
|
393
|
+
...override.formatScheme === void 0 ? baseTheme.formatScheme === void 0 ? {} : { formatScheme: baseTheme.formatScheme } : { formatScheme: override.formatScheme }
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function hasThemeOverrideContent(override) {
|
|
397
|
+
if (override === void 0) return false;
|
|
398
|
+
return override.colors !== void 0 && Object.keys(override.colors).length > 0 || override.fonts !== void 0 && (override.fonts.major !== void 0 || override.fonts.minor !== void 0 || override.fonts.majorEastAsian !== void 0 || override.fonts.minorEastAsian !== void 0) || override.formatScheme !== void 0;
|
|
399
|
+
}
|
|
400
|
+
function themeOverrideXml(override, baseTheme) {
|
|
401
|
+
let colorsXml = "";
|
|
402
|
+
if (override.colors !== void 0) {
|
|
403
|
+
const merged = {};
|
|
404
|
+
for (const slot of nativeColorSlots) merged[slot] = override.colors[slot] ?? baseTheme.colors[slot];
|
|
405
|
+
colorsXml = colorSchemeXml(baseTheme.name, merged);
|
|
406
|
+
}
|
|
407
|
+
const fontsXml = override.fonts === void 0 ? "" : fontSchemeXml(baseTheme.name, override.fonts.major ?? baseTheme.fonts.major, override.fonts.minor ?? baseTheme.fonts.minor, override.fonts.majorEastAsian ?? baseTheme.fonts.majorEastAsian, override.fonts.minorEastAsian ?? baseTheme.fonts.minorEastAsian);
|
|
408
|
+
const formatXml = override.formatScheme === void 0 ? "" : formatSchemeXml(override.formatScheme);
|
|
409
|
+
return xmlDocument(`<a:themeOverride xmlns:a="${namespaces.a}">${colorsXml}${fontsXml}${formatXml}</a:themeOverride>`);
|
|
410
|
+
}
|
|
411
|
+
function colorMapAttributesXml(map) {
|
|
412
|
+
return schemeColorSlots.map((slot) => `${slot}="${map[slot]}"`).join(" ");
|
|
413
|
+
}
|
|
414
|
+
function colorMapOverrideXml(override) {
|
|
415
|
+
if (override === void 0 || override === "master") return "<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>";
|
|
416
|
+
return `<p:clrMapOvr><a:overrideClrMapping ${colorMapAttributesXml(override)}/></p:clrMapOvr>`;
|
|
417
|
+
}
|
|
418
|
+
function headerFooterXml(hf) {
|
|
419
|
+
if (hf === void 0) return "";
|
|
420
|
+
return `<p:hf${[
|
|
421
|
+
hf.slideNumber === void 0 ? "" : ` sldNum="${hf.slideNumber ? "1" : "0"}"`,
|
|
422
|
+
hf.header === void 0 ? "" : ` hdr="${hf.header ? "1" : "0"}"`,
|
|
423
|
+
hf.footer === void 0 ? "" : ` ftr="${hf.footer ? "1" : "0"}"`,
|
|
424
|
+
hf.dateTime === void 0 ? "" : ` dt="${hf.dateTime ? "1" : "0"}"`
|
|
425
|
+
].join("")}/>`;
|
|
426
|
+
}
|
|
427
|
+
function masterXml(spec, layoutIds, themeContext, colorMapXml = `<p:clrMap ${colorMapAttributesXml(spec.colorMap ?? defaultColorMap)}/>`) {
|
|
428
|
+
const preserveAttr = spec.preserve === void 0 ? "" : ` preserve="${spec.preserve ? "1" : "0"}"`;
|
|
429
|
+
const nameAttr = spec.name === void 0 ? "" : ` name="${xmlEscape(spec.name)}"`;
|
|
430
|
+
const layoutIdList = layoutIds.map(({ id, rId }) => `<p:sldLayoutId id="${id}" r:id="${xmlEscape(rId)}"/>`).join("");
|
|
431
|
+
const shapes = `${placeholderShapesXml(spec.placeholders, themeContext, spec.placeholderSpPrByKey)}${spec.shapeXml ?? ""}`;
|
|
432
|
+
const txStyles = masterTextStylesXml(spec.textStyles, themeContext);
|
|
433
|
+
return xmlDocument(`<p:sldMaster xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${preserveAttr}><p:cSld${nameAttr}>${spec.backgroundXml ?? ""}${shapeTreeXml(shapes)}</p:cSld>${colorMapXml}<p:sldLayoutIdLst>${layoutIdList}</p:sldLayoutIdLst>${spec.transitionXml ?? ""}${spec.timingXml ?? ""}${headerFooterXml(spec.headerFooter)}${txStyles}</p:sldMaster>`);
|
|
434
|
+
}
|
|
435
|
+
function layoutXml(spec, themeContext, colorMapOvrXml = colorMapOverrideXml(spec.colorMapOverride)) {
|
|
436
|
+
const typeAttr = spec.type === void 0 ? "" : ` type="${xmlEscape(spec.type)}"`;
|
|
437
|
+
const preserveAttr = spec.preserve === void 0 ? "" : ` preserve="${spec.preserve ? "1" : "0"}"`;
|
|
438
|
+
const matchingNameAttr = spec.matchingName === void 0 ? "" : ` matchingName="${xmlEscape(spec.matchingName)}"`;
|
|
439
|
+
const userDrawnAttr = spec.userDrawn === void 0 ? "" : ` userDrawn="${spec.userDrawn ? "1" : "0"}"`;
|
|
440
|
+
const showMasterSpAttr = spec.showMasterShapes === false ? " showMasterSp=\"0\"" : "";
|
|
441
|
+
const showMasterPhAnimAttr = spec.showMasterPlaceholderAnimations === void 0 ? "" : ` showMasterPhAnim="${spec.showMasterPlaceholderAnimations ? "1" : "0"}"`;
|
|
442
|
+
const nameAttr = spec.name === void 0 ? "" : ` name="${xmlEscape(spec.name)}"`;
|
|
443
|
+
const shapes = `${placeholderShapesXml(spec.placeholders, themeContext, spec.placeholderSpPrByKey)}${spec.shapeXml ?? ""}`;
|
|
444
|
+
return xmlDocument(`<p:sldLayout xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${typeAttr}${preserveAttr}${matchingNameAttr}${userDrawnAttr}${showMasterSpAttr}${showMasterPhAnimAttr}><p:cSld${nameAttr}>${spec.backgroundXml ?? ""}${shapeTreeXml(shapes)}</p:cSld>${colorMapOvrXml}${spec.transitionXml ?? ""}${spec.timingXml ?? ""}${headerFooterXml(spec.headerFooter)}</p:sldLayout>`);
|
|
445
|
+
}
|
|
446
|
+
function slide(slideId, shapeXml, slideXml, backgroundXml, hidden, showMasterPlaceholderAnimations, colorMapOverride, showMasterShapes, name, colorMapOvrXml = colorMapOverrideXml(colorMapOverride)) {
|
|
447
|
+
const showMasterSpAttr = showMasterShapes === false ? " showMasterSp=\"0\"" : "";
|
|
448
|
+
const showMasterPhAnimAttr = showMasterPlaceholderAnimations === void 0 ? "" : ` showMasterPhAnim="${showMasterPlaceholderAnimations ? "1" : "0"}"`;
|
|
449
|
+
return xmlDocument(`<p:sld xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${showMasterSpAttr}${showMasterPhAnimAttr}${hidden ? " show=\"false\"" : ""}><p:cSld name="${xmlEscape(name ?? slideId)}">${backgroundXml}${shapeTreeXml(shapeXml)}</p:cSld>${colorMapOvrXml}${slideXml}</p:sld>`);
|
|
450
|
+
}
|
|
451
|
+
function sectionId(index, name) {
|
|
452
|
+
const hex = createHash("sha1").update(`section:${index}:${name}`).digest("hex").toUpperCase();
|
|
453
|
+
return `{${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}}`;
|
|
454
|
+
}
|
|
455
|
+
function sectionListXml(sections) {
|
|
456
|
+
if (sections.length === 0) return "";
|
|
457
|
+
return `<p:extLst><p:ext uri="{521415D9-36F7-43E2-AB2F-B90AF26B5E84}"><p14:sectionLst xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main">${sections.map(({ name, slideIndexes }, index) => `<p14:section name="${xmlEscape(name)}" id="${sectionId(index, name)}"><p14:sldIdLst>${slideIndexes.map((slideIndex) => `<p14:sldId id="${255 + slideIndex}"/>`).join("")}</p14:sldIdLst></p14:section>`).join("")}</p14:sectionLst></p:ext></p:extLst>`;
|
|
458
|
+
}
|
|
459
|
+
function coreProperties(title) {
|
|
460
|
+
return xmlDocument(`<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${xmlEscape(title)}</dc:title></cp:coreProperties>`);
|
|
461
|
+
}
|
|
462
|
+
function countAllocatedMasterThemeParts(mastersInput, fallbackTheme = defaultTheme) {
|
|
463
|
+
const masters = mastersInput !== void 0 && mastersInput.length > 0 ? mastersInput : defaultEmittedMasters;
|
|
464
|
+
const seen = /* @__PURE__ */ new Set();
|
|
465
|
+
let count = 0;
|
|
466
|
+
for (const spec of masters) {
|
|
467
|
+
const masterTheme = spec.theme ?? fallbackTheme;
|
|
468
|
+
if (masterTheme !== defaultTheme && seen.has(masterTheme)) continue;
|
|
469
|
+
if (masterTheme !== defaultTheme) seen.add(masterTheme);
|
|
470
|
+
count += 1;
|
|
471
|
+
}
|
|
472
|
+
return count;
|
|
473
|
+
}
|
|
474
|
+
function pptxParts(size, slides, resources = [], packageParts = [], packageRelationships = [], presentationContent = {}, presentationAttributes = [], themeValue = defaultTheme, title, sectionXml = "", mastersInput, mastersEmitDriver) {
|
|
475
|
+
const masters = mastersInput !== void 0 && mastersInput.length > 0 ? mastersInput : defaultEmittedMasters;
|
|
476
|
+
let nextMasterLayoutId = minimumSlideLayoutId;
|
|
477
|
+
let globalLayoutNumber = 0;
|
|
478
|
+
const allocatedThemePartByTheme = /* @__PURE__ */ new Map();
|
|
479
|
+
const emittedThemeParts = [];
|
|
480
|
+
const emittedThemeOverrideParts = [];
|
|
481
|
+
const allocateThemePart = (masterTheme) => {
|
|
482
|
+
if (masterTheme !== defaultTheme) {
|
|
483
|
+
const existing = allocatedThemePartByTheme.get(masterTheme);
|
|
484
|
+
if (existing !== void 0) return existing;
|
|
485
|
+
}
|
|
486
|
+
const themeNumber = emittedThemeParts.length + 1;
|
|
487
|
+
const partPath = `ppt/theme/theme${themeNumber}.xml`;
|
|
488
|
+
const allocation = {
|
|
489
|
+
partPath,
|
|
490
|
+
relTarget: `../theme/theme${themeNumber}.xml`
|
|
491
|
+
};
|
|
492
|
+
emittedThemeParts.push({
|
|
493
|
+
partPath,
|
|
494
|
+
xml: mastersEmitDriver !== void 0 ? mastersEmitDriver.emitTheme(masterTheme) : themeXml(masterTheme)
|
|
495
|
+
});
|
|
496
|
+
if (masterTheme !== defaultTheme) allocatedThemePartByTheme.set(masterTheme, allocation);
|
|
497
|
+
return allocation;
|
|
498
|
+
};
|
|
499
|
+
const allocateThemeOverridePart = (override, baseTheme) => {
|
|
500
|
+
const overrideNumber = emittedThemeOverrideParts.length + 1;
|
|
501
|
+
const partPath = `ppt/theme/themeOverride${overrideNumber}.xml`;
|
|
502
|
+
emittedThemeOverrideParts.push({
|
|
503
|
+
partPath,
|
|
504
|
+
xml: mastersEmitDriver !== void 0 ? mastersEmitDriver.emitThemeOverride(override, baseTheme) : themeOverrideXml(override, baseTheme)
|
|
505
|
+
});
|
|
506
|
+
return `../theme/themeOverride${overrideNumber}.xml`;
|
|
507
|
+
};
|
|
508
|
+
const allocatedMasters = masters.map((spec, masterIndex) => {
|
|
509
|
+
const masterNumber = masterIndex + 1;
|
|
510
|
+
const masterId = nextMasterLayoutId++;
|
|
511
|
+
const masterPart = `ppt/slideMasters/slideMaster${masterNumber}.xml`;
|
|
512
|
+
const masterTheme = spec.theme ?? themeValue;
|
|
513
|
+
const themeAllocation = allocateThemePart(masterTheme);
|
|
514
|
+
const layouts = spec.layouts.map((layoutSpec, layoutIndex) => {
|
|
515
|
+
const layoutNumber = ++globalLayoutNumber;
|
|
516
|
+
const layoutId = nextMasterLayoutId++;
|
|
517
|
+
const layoutPart = `ppt/slideLayouts/slideLayout${layoutNumber}.xml`;
|
|
518
|
+
const themeOverrideTarget = hasThemeOverrideContent(layoutSpec.themeOverride) ? allocateThemeOverridePart(layoutSpec.themeOverride, masterTheme) : void 0;
|
|
519
|
+
return {
|
|
520
|
+
spec: layoutSpec,
|
|
521
|
+
layoutNumber,
|
|
522
|
+
layoutId,
|
|
523
|
+
layoutPart,
|
|
524
|
+
masterRelId: `rId${layoutIndex + 1}`,
|
|
525
|
+
themeOverrideTarget
|
|
526
|
+
};
|
|
527
|
+
});
|
|
528
|
+
return {
|
|
529
|
+
spec,
|
|
530
|
+
masterNumber,
|
|
531
|
+
masterId,
|
|
532
|
+
masterPart,
|
|
533
|
+
masterTheme,
|
|
534
|
+
themeRelTarget: themeAllocation.relTarget,
|
|
535
|
+
presentationRelId: `rId${masterNumber}`,
|
|
536
|
+
layouts
|
|
537
|
+
};
|
|
538
|
+
});
|
|
539
|
+
const layoutPartByKey = /* @__PURE__ */ new Map();
|
|
540
|
+
const masterThemeByLayoutKey = /* @__PURE__ */ new Map();
|
|
541
|
+
for (const allocatedMaster of allocatedMasters) for (const allocatedLayout of allocatedMaster.layouts) {
|
|
542
|
+
layoutPartByKey.set(allocatedLayout.spec.key, allocatedLayout.layoutPart);
|
|
543
|
+
masterThemeByLayoutKey.set(allocatedLayout.spec.key, effectiveThemeWithOverride(allocatedMaster.masterTheme, allocatedLayout.spec.themeOverride));
|
|
544
|
+
}
|
|
545
|
+
const fallbackLayoutPart = allocatedMasters[0]?.layouts[0]?.layoutPart ?? "ppt/slideLayouts/slideLayout1.xml";
|
|
546
|
+
const fallbackMasterTheme = allocatedMasters[0]?.masterTheme ?? themeValue;
|
|
547
|
+
const slideThemeOverrideTargets = slides.map((slideSpec) => {
|
|
548
|
+
if (!hasThemeOverrideContent(slideSpec.themeOverride)) return void 0;
|
|
549
|
+
const baseTheme = (slideSpec.layoutKey === void 0 ? void 0 : masterThemeByLayoutKey.get(slideSpec.layoutKey)) ?? fallbackMasterTheme;
|
|
550
|
+
return allocateThemeOverridePart(slideSpec.themeOverride, baseTheme);
|
|
551
|
+
});
|
|
552
|
+
const masterRelationships = allocatedMasters.map(({ masterNumber, presentationRelId }) => ({
|
|
553
|
+
id: presentationRelId,
|
|
554
|
+
type: `${namespaces.r}/slideMaster`,
|
|
555
|
+
target: `slideMasters/slideMaster${masterNumber}.xml`
|
|
556
|
+
}));
|
|
557
|
+
const masterIdsXml = allocatedMasters.map(({ masterId, presentationRelId }) => `<p:sldMasterId id="${masterId}" r:id="${presentationRelId}"/>`).join("");
|
|
558
|
+
const slideRelStart = allocatedMasters.length + 1;
|
|
559
|
+
const slideRelationships = slides.map((_, index) => ({
|
|
560
|
+
id: `rId${slideRelStart + index}`,
|
|
561
|
+
type: `${namespaces.r}/slide`,
|
|
562
|
+
target: `slides/slide${index + 1}.xml`
|
|
563
|
+
}));
|
|
564
|
+
const slideIds = slides.map((_, index) => `<p:sldId id="${256 + index}" r:id="rId${slideRelStart + index}"/>`).join("");
|
|
565
|
+
const slideIdListXml = slides.length === 0 ? "" : `<p:sldIdLst>${slideIds}</p:sldIdLst>`;
|
|
566
|
+
const presentationAttributeXml = presentationAttributes.map(({ name, value }) => ` ${name}="${xmlEscape(value)}"`).join("");
|
|
567
|
+
const extraPresentationRelationships = packageRelationships.find(({ sourcePath }) => sourcePath === "ppt/presentation.xml")?.relationships ?? [];
|
|
568
|
+
const presentation = xmlDocument(`<p:presentation xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${presentationAttributeXml}><p:sldMasterIdLst>${masterIdsXml}</p:sldMasterIdLst>${presentationContent.beforeSlides ?? ""}${slideIdListXml}<p:sldSz cx="${pxToEmu(size.width)}" cy="${pxToEmu(size.height)}"/><p:notesSz cx="6858000" cy="9144000"/>${presentationContent.afterNotesSize ?? ""}${sectionXml}</p:presentation>`);
|
|
569
|
+
const parts = {
|
|
570
|
+
"[Content_Types].xml": contentTypes(allocatedMasters.length, globalLayoutNumber, emittedThemeParts.length, emittedThemeOverrideParts.length, slides.length, resources, packageParts, title !== void 0),
|
|
571
|
+
"_rels/.rels": relationships([{
|
|
572
|
+
id: "rId1",
|
|
573
|
+
type: `${namespaces.r}/officeDocument`,
|
|
574
|
+
target: "ppt/presentation.xml"
|
|
575
|
+
}, ...title === void 0 ? [] : [{
|
|
576
|
+
id: "rId2",
|
|
577
|
+
type: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
|
|
578
|
+
target: "docProps/core.xml"
|
|
579
|
+
}]]),
|
|
580
|
+
"ppt/presentation.xml": presentation,
|
|
581
|
+
"ppt/_rels/presentation.xml.rels": relationships([
|
|
582
|
+
...masterRelationships,
|
|
583
|
+
...slideRelationships,
|
|
584
|
+
...extraPresentationRelationships
|
|
585
|
+
])
|
|
586
|
+
};
|
|
587
|
+
const defaultThemeCtx = createThemeContext(themeValue);
|
|
588
|
+
for (const themePart of emittedThemeParts) parts[themePart.partPath] = themePart.xml;
|
|
589
|
+
for (const overridePart of emittedThemeOverrideParts) parts[overridePart.partPath] = overridePart.xml;
|
|
590
|
+
for (const allocatedMaster of allocatedMasters) {
|
|
591
|
+
const masterThemeCtx = allocatedMaster.spec.themeContext ?? (allocatedMaster.spec.theme === void 0 ? defaultThemeCtx : createThemeContext(allocatedMaster.spec.theme, void 0, allocatedMaster.spec.colorMap === void 0 ? {} : { colorMap: allocatedMaster.spec.colorMap }));
|
|
592
|
+
const masterLayoutIds = allocatedMaster.layouts.map((item) => ({
|
|
593
|
+
id: item.layoutId,
|
|
594
|
+
rId: item.masterRelId
|
|
595
|
+
}));
|
|
596
|
+
parts[allocatedMaster.masterPart] = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitMaster(allocatedMaster.spec, masterLayoutIds, masterThemeCtx) : masterXml(allocatedMaster.spec, masterLayoutIds, masterThemeCtx);
|
|
597
|
+
parts[`ppt/slideMasters/_rels/slideMaster${allocatedMaster.masterNumber}.xml.rels`] = relationships([
|
|
598
|
+
...allocatedMaster.layouts.map((item) => ({
|
|
599
|
+
id: item.masterRelId,
|
|
600
|
+
type: `${namespaces.r}/slideLayout`,
|
|
601
|
+
target: `../slideLayouts/slideLayout${item.layoutNumber}.xml`
|
|
602
|
+
})),
|
|
603
|
+
{
|
|
604
|
+
id: `rId${allocatedMaster.layouts.length + 1}`,
|
|
605
|
+
type: `${namespaces.r}/theme`,
|
|
606
|
+
target: allocatedMaster.themeRelTarget
|
|
607
|
+
},
|
|
608
|
+
...allocatedMaster.spec.extraRelationships ?? []
|
|
609
|
+
]);
|
|
610
|
+
for (const allocatedLayout of allocatedMaster.layouts) {
|
|
611
|
+
const layoutThemeCtx = allocatedLayout.spec.themeOverride !== void 0 || allocatedLayout.spec.colorMapOverride !== void 0 ? masterThemeCtx.withNativeOverrides(allocatedLayout.spec.themeOverride, allocatedLayout.spec.colorMapOverride) : masterThemeCtx;
|
|
612
|
+
parts[allocatedLayout.layoutPart] = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitLayout(allocatedLayout.spec, layoutThemeCtx) : layoutXml(allocatedLayout.spec, layoutThemeCtx);
|
|
613
|
+
const layoutRels = [
|
|
614
|
+
{
|
|
615
|
+
id: "rId1",
|
|
616
|
+
type: `${namespaces.r}/slideMaster`,
|
|
617
|
+
target: `../slideMasters/slideMaster${allocatedMaster.masterNumber}.xml`
|
|
618
|
+
},
|
|
619
|
+
...allocatedLayout.themeOverrideTarget === void 0 ? [] : [{
|
|
620
|
+
id: "rId2",
|
|
621
|
+
type: `${namespaces.r}/themeOverride`,
|
|
622
|
+
target: allocatedLayout.themeOverrideTarget
|
|
623
|
+
}],
|
|
624
|
+
...allocatedLayout.spec.extraRelationships ?? []
|
|
625
|
+
];
|
|
626
|
+
parts[`ppt/slideLayouts/_rels/slideLayout${allocatedLayout.layoutNumber}.xml.rels`] = relationships(layoutRels);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
slides.forEach(({ shapeXml, slideXml, backgroundXml, hidden, showMasterPlaceholderAnimations, showMasterShapes, layoutKey, colorMapOverride }, index) => {
|
|
630
|
+
const targetLayoutRel = `../${((layoutKey === void 0 ? void 0 : layoutPartByKey.get(layoutKey)) ?? fallbackLayoutPart).slice(4)}`;
|
|
631
|
+
const colorMapOvrXml = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitColorMap(colorMapOverride === void 0 ? {} : { colorMapOverride }) : colorMapOverrideXml(colorMapOverride);
|
|
632
|
+
parts[`ppt/slides/slide${index + 1}.xml`] = slide(slides[index].id, shapeXml, slideXml ?? "", backgroundXml ?? "", hidden ?? false, showMasterPlaceholderAnimations, colorMapOverride, showMasterShapes, slides[index].name, colorMapOvrXml);
|
|
633
|
+
const slideOverrideTarget = slideThemeOverrideTargets[index];
|
|
634
|
+
const slideRels = [
|
|
635
|
+
{
|
|
636
|
+
id: "rId1",
|
|
637
|
+
type: `${namespaces.r}/slideLayout`,
|
|
638
|
+
target: targetLayoutRel
|
|
639
|
+
},
|
|
640
|
+
...slides[index].relationships,
|
|
641
|
+
...slideOverrideTarget === void 0 ? [] : [{
|
|
642
|
+
id: `rId${slides[index].relationships.length + 2}`,
|
|
643
|
+
type: `${namespaces.r}/themeOverride`,
|
|
644
|
+
target: slideOverrideTarget
|
|
645
|
+
}]
|
|
646
|
+
];
|
|
647
|
+
parts[`ppt/slides/_rels/slide${index + 1}.xml.rels`] = relationships(slideRels);
|
|
648
|
+
});
|
|
649
|
+
if (title !== void 0) parts["docProps/core.xml"] = coreProperties(title);
|
|
650
|
+
for (const resource of resources) parts[`ppt/media/${resource.name}`] = resource.bytes;
|
|
651
|
+
for (const part of packageParts) parts[part.path] = part.content;
|
|
652
|
+
for (const relationshipSet of packageRelationships) {
|
|
653
|
+
if (relationshipSet.sourcePath === "ppt/presentation.xml") continue;
|
|
654
|
+
const marker = relationshipSet.sourcePath.lastIndexOf("/");
|
|
655
|
+
const directory = marker === -1 ? "" : relationshipSet.sourcePath.slice(0, marker + 1);
|
|
656
|
+
const name = relationshipSet.sourcePath.slice(marker + 1);
|
|
657
|
+
parts[`${directory}_rels/${name}.rels`] = relationships(relationshipSet.relationships);
|
|
658
|
+
}
|
|
659
|
+
return parts;
|
|
660
|
+
}
|
|
661
|
+
export { assertXml10Characters, colorMapAttributesXml, colorMapOverrideXml, countAllocatedMasterThemeParts, hasThemeOverrideContent, layoutXml, masterXml, placeholderRefXml, pptxParts, pxToEmu, resolvedColorXml, sectionListXml, themeOverrideXml, themeXml, xmlDocument, xmlEscape };
|