@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,777 @@
|
|
|
1
|
+
import { colorMapSchema, defaultColorMap, defineTheme, nativeColorSlots, schemeColorNames, schemeColorSlots } from "../../core/dist/theme.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { A_NS } from "./namespaces.js";
|
|
4
|
+
import { hexRgb6Schema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlLineWidthEmuSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveFixedAngleSchema, ooxmlWritableExtentEmuSchema } from "./xml-fragments.js";
|
|
5
|
+
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ../import/dist/themes.js
|
|
8
|
+
const percentValAttrSchema = z.object({ val: ooxmlNonNegativeIntSchema });
|
|
9
|
+
const percentPosAttrSchema = z.object({ pos: ooxmlNonNegativeIntSchema });
|
|
10
|
+
const sysClrAttrSchema = z.object({
|
|
11
|
+
val: z.string().min(1),
|
|
12
|
+
lastClr: hexRgb6Schema.optional()
|
|
13
|
+
});
|
|
14
|
+
const colorMapXmlAttrSchema = colorMapSchema;
|
|
15
|
+
const lineAttrSchema = z.object({
|
|
16
|
+
w: ooxmlLineWidthEmuSchema.optional(),
|
|
17
|
+
cap: z.enum([
|
|
18
|
+
"rnd",
|
|
19
|
+
"sq",
|
|
20
|
+
"flat"
|
|
21
|
+
]).optional(),
|
|
22
|
+
cmpd: z.enum([
|
|
23
|
+
"sng",
|
|
24
|
+
"dbl",
|
|
25
|
+
"thickThin",
|
|
26
|
+
"thinThick",
|
|
27
|
+
"tri"
|
|
28
|
+
]).optional(),
|
|
29
|
+
algn: z.enum(["ctr", "in"]).optional()
|
|
30
|
+
});
|
|
31
|
+
const linearGradAttrSchema = z.object({
|
|
32
|
+
ang: ooxmlIntSchema.optional(),
|
|
33
|
+
scaled: ooxmlBoolSchema.optional()
|
|
34
|
+
});
|
|
35
|
+
const pathGradAttrSchema = z.object({ path: z.enum([
|
|
36
|
+
"circle",
|
|
37
|
+
"rect",
|
|
38
|
+
"shape"
|
|
39
|
+
]).optional() });
|
|
40
|
+
const fillToRectAttrSchema = z.object({
|
|
41
|
+
l: ooxmlIntSchema.optional(),
|
|
42
|
+
t: ooxmlIntSchema.optional(),
|
|
43
|
+
r: ooxmlIntSchema.optional(),
|
|
44
|
+
b: ooxmlIntSchema.optional()
|
|
45
|
+
});
|
|
46
|
+
const outerShdwAttrSchema = z.object({
|
|
47
|
+
blurRad: ooxmlWritableExtentEmuSchema.optional(),
|
|
48
|
+
dist: ooxmlWritableExtentEmuSchema.optional(),
|
|
49
|
+
algn: z.string().optional(),
|
|
50
|
+
rotWithShape: ooxmlBoolSchema.optional()
|
|
51
|
+
});
|
|
52
|
+
const officeFallbackColors = {
|
|
53
|
+
dk1: "#000000",
|
|
54
|
+
lt1: "#FFFFFF",
|
|
55
|
+
dk2: "#1F497D",
|
|
56
|
+
lt2: "#EEECE1",
|
|
57
|
+
accent1: "#4F81BD",
|
|
58
|
+
accent2: "#C0504D",
|
|
59
|
+
accent3: "#9BBB59",
|
|
60
|
+
accent4: "#8064A2",
|
|
61
|
+
accent5: "#4BACC6",
|
|
62
|
+
accent6: "#F79646",
|
|
63
|
+
hlink: "#0000FF",
|
|
64
|
+
folHlink: "#800080"
|
|
65
|
+
};
|
|
66
|
+
function colorMapsEqual(left, right) {
|
|
67
|
+
return schemeColorSlots.every((slot) => left[slot] === right[slot]);
|
|
68
|
+
}
|
|
69
|
+
/** Reads `<p:clrMap>` or `<a:overrideClrMapping>` attributes into a validated 12-slot `ColorMap`. */
|
|
70
|
+
function readColorMapElement(cursor, partPath, slideIndex, diagnostics) {
|
|
71
|
+
const raw = cursor.attrsObject(schemeColorSlots);
|
|
72
|
+
const parsed = colorMapXmlAttrSchema.safeParse(raw);
|
|
73
|
+
if (parsed.success) return { ...parsed.data };
|
|
74
|
+
for (const issue of parsed.error.issues) {
|
|
75
|
+
const slot = String(issue.path[0] ?? "clrMap");
|
|
76
|
+
diagnostics.push({
|
|
77
|
+
code: "invalid-xml-value",
|
|
78
|
+
category: "corrupt-input",
|
|
79
|
+
disposition: "recovered",
|
|
80
|
+
location: {
|
|
81
|
+
part: partPath,
|
|
82
|
+
xpath: `${cursor.xpath}/@${slot}`,
|
|
83
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
84
|
+
},
|
|
85
|
+
attributeOrElement: `@${slot}`,
|
|
86
|
+
rawValue: raw[slot] ?? ""
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const recovered = { ...defaultColorMap };
|
|
90
|
+
for (const slot of schemeColorSlots) {
|
|
91
|
+
const candidate = raw[slot];
|
|
92
|
+
if (candidate !== void 0 && nativeColorSlots.includes(candidate)) recovered[slot] = candidate;
|
|
93
|
+
}
|
|
94
|
+
return colorMapSchema.parse(recovered);
|
|
95
|
+
}
|
|
96
|
+
/** Reads `<p:clrMapOvr>` into `"master"` or an explicit 12-slot `ColorMap`. */
|
|
97
|
+
function readColorMapOverride(clrMapOvrCursor, partPath, slideIndex, diagnostics) {
|
|
98
|
+
if (clrMapOvrCursor.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "masterClrMapping")) return "master";
|
|
99
|
+
const overrideCursor = clrMapOvrCursor.child(A_NS, "overrideClrMapping");
|
|
100
|
+
if (overrideCursor !== void 0) return readColorMapElement(overrideCursor, partPath, slideIndex, diagnostics);
|
|
101
|
+
}
|
|
102
|
+
function resolveSimpleThemeHex(slotCursor, partPath, slideIndex, diagnostics) {
|
|
103
|
+
let result;
|
|
104
|
+
for (const child of slotCursor.remainingElementChildren()) {
|
|
105
|
+
if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") {
|
|
106
|
+
diagnostics.push({
|
|
107
|
+
code: "unconsumed-xml",
|
|
108
|
+
category: "unsupported",
|
|
109
|
+
disposition: "omitted",
|
|
110
|
+
kind: "element",
|
|
111
|
+
location: {
|
|
112
|
+
part: partPath,
|
|
113
|
+
xpath: child.xpath,
|
|
114
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
115
|
+
},
|
|
116
|
+
namespaceUri: child.namespaceUri,
|
|
117
|
+
localName: child.localName
|
|
118
|
+
});
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (child.localName === "srgbClr" && result === void 0) {
|
|
122
|
+
const raw = child.attrsObject(["val"]);
|
|
123
|
+
const parsed = hexRgb6Schema.safeParse(raw["val"]);
|
|
124
|
+
if (!parsed.success) diagnostics.push({
|
|
125
|
+
code: "invalid-xml-value",
|
|
126
|
+
category: "corrupt-input",
|
|
127
|
+
disposition: "recovered",
|
|
128
|
+
location: {
|
|
129
|
+
part: partPath,
|
|
130
|
+
xpath: `${child.xpath}/@val`,
|
|
131
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
132
|
+
},
|
|
133
|
+
attributeOrElement: "a:srgbClr/@val",
|
|
134
|
+
rawValue: raw["val"] ?? ""
|
|
135
|
+
});
|
|
136
|
+
else result = `#${parsed.data.toUpperCase()}`;
|
|
137
|
+
child.suppressUnconsumed();
|
|
138
|
+
} else if (child.localName === "sysClr" && result === void 0) {
|
|
139
|
+
const raw = child.attrsObject(["val", "lastClr"]);
|
|
140
|
+
const parsed = sysClrAttrSchema.safeParse(raw);
|
|
141
|
+
if (!parsed.success) diagnostics.push({
|
|
142
|
+
code: "invalid-xml-value",
|
|
143
|
+
category: "corrupt-input",
|
|
144
|
+
disposition: "recovered",
|
|
145
|
+
location: {
|
|
146
|
+
part: partPath,
|
|
147
|
+
xpath: child.xpath,
|
|
148
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
149
|
+
},
|
|
150
|
+
attributeOrElement: "a:sysClr",
|
|
151
|
+
rawValue: JSON.stringify(raw)
|
|
152
|
+
});
|
|
153
|
+
else {
|
|
154
|
+
const fallback = parsed.data.val === "windowText" ? "000000" : parsed.data.val === "window" ? "FFFFFF" : void 0;
|
|
155
|
+
const hex = parsed.data.lastClr ?? fallback;
|
|
156
|
+
if (hex !== void 0) result = `#${hex.toUpperCase()}`;
|
|
157
|
+
}
|
|
158
|
+
child.suppressUnconsumed();
|
|
159
|
+
} else {
|
|
160
|
+
diagnostics.push({
|
|
161
|
+
code: "unsupported-mechanism",
|
|
162
|
+
category: "unsupported",
|
|
163
|
+
disposition: "omitted",
|
|
164
|
+
location: {
|
|
165
|
+
part: partPath,
|
|
166
|
+
xpath: child.xpath,
|
|
167
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
168
|
+
},
|
|
169
|
+
namespaceUri: child.namespaceUri,
|
|
170
|
+
localName: child.localName,
|
|
171
|
+
mechanismHint: `theme-color:${child.localName}`
|
|
172
|
+
});
|
|
173
|
+
child.suppressUnconsumed();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
function readClrScheme(clrSchemeCursor, partPath, slideIndex, diagnostics) {
|
|
179
|
+
clrSchemeCursor.consumeAttr("name");
|
|
180
|
+
const colors = { ...officeFallbackColors };
|
|
181
|
+
for (const child of clrSchemeCursor.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && nativeColorSlots.includes(child.localName)) {
|
|
182
|
+
const slot = child.localName;
|
|
183
|
+
const hex = resolveSimpleThemeHex(child, partPath, slideIndex, diagnostics);
|
|
184
|
+
if (hex !== void 0) colors[slot] = hex;
|
|
185
|
+
} else diagnostics.push({
|
|
186
|
+
code: "unconsumed-xml",
|
|
187
|
+
category: "unsupported",
|
|
188
|
+
disposition: "omitted",
|
|
189
|
+
kind: "element",
|
|
190
|
+
location: {
|
|
191
|
+
part: partPath,
|
|
192
|
+
xpath: child.xpath,
|
|
193
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
194
|
+
},
|
|
195
|
+
namespaceUri: child.namespaceUri,
|
|
196
|
+
localName: child.localName
|
|
197
|
+
});
|
|
198
|
+
return colors;
|
|
199
|
+
}
|
|
200
|
+
const reservedThemeFontPattern = /^(?:major|minor|\+(?:mj|mn)-)/iu;
|
|
201
|
+
function readThemeFontSlotTypeface(child, elementTag, partPath, slideIndex, diagnostics) {
|
|
202
|
+
let result;
|
|
203
|
+
const typeface = child.attr("typeface");
|
|
204
|
+
if (typeface !== void 0 && typeface.trim() !== "") {
|
|
205
|
+
if (reservedThemeFontPattern.test(typeface.trim())) diagnostics.push({
|
|
206
|
+
code: "invalid-xml-value",
|
|
207
|
+
category: "corrupt-input",
|
|
208
|
+
disposition: "omitted",
|
|
209
|
+
location: {
|
|
210
|
+
part: partPath,
|
|
211
|
+
xpath: `${child.xpath}/@typeface`,
|
|
212
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
213
|
+
},
|
|
214
|
+
attributeOrElement: `${elementTag}/@typeface`,
|
|
215
|
+
rawValue: typeface
|
|
216
|
+
});
|
|
217
|
+
else result = typeface;
|
|
218
|
+
}
|
|
219
|
+
child.consumeAttr("panose");
|
|
220
|
+
child.consumeAttr("pitchFamily");
|
|
221
|
+
child.consumeAttr("charset");
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
function readFontCollection(fontCollectionCursor, partPath, slideIndex, diagnostics) {
|
|
225
|
+
let latinTypeface;
|
|
226
|
+
let eaTypeface;
|
|
227
|
+
for (const child of fontCollectionCursor.remainingElementChildren()) {
|
|
228
|
+
if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
|
|
229
|
+
if (child.localName === "latin") latinTypeface = readThemeFontSlotTypeface(child, "a:latin", partPath, slideIndex, diagnostics);
|
|
230
|
+
else if (child.localName === "ea") eaTypeface = readThemeFontSlotTypeface(child, "a:ea", partPath, slideIndex, diagnostics);
|
|
231
|
+
else if (child.localName === "cs") {
|
|
232
|
+
child.consumeAttr("typeface");
|
|
233
|
+
child.consumeAttr("panose");
|
|
234
|
+
child.consumeAttr("pitchFamily");
|
|
235
|
+
child.consumeAttr("charset");
|
|
236
|
+
} else if (child.localName === "font") {
|
|
237
|
+
child.consumeAttr("script");
|
|
238
|
+
child.consumeAttr("typeface");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
...latinTypeface === void 0 ? {} : { latin: latinTypeface },
|
|
243
|
+
...eaTypeface === void 0 ? {} : { ea: eaTypeface }
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function readFontScheme(fontSchemeCursor, partPath, slideIndex, diagnostics) {
|
|
247
|
+
fontSchemeCursor.consumeAttr("name");
|
|
248
|
+
const majorCursor = fontSchemeCursor.child(A_NS, "majorFont");
|
|
249
|
+
const minorCursor = fontSchemeCursor.child(A_NS, "minorFont");
|
|
250
|
+
const majorInfo = majorCursor === void 0 ? void 0 : readFontCollection(majorCursor, partPath, slideIndex, diagnostics);
|
|
251
|
+
const minorInfo = minorCursor === void 0 ? void 0 : readFontCollection(minorCursor, partPath, slideIndex, diagnostics);
|
|
252
|
+
const major = majorInfo?.latin;
|
|
253
|
+
const minor = minorInfo?.latin;
|
|
254
|
+
const majorEastAsian = majorInfo?.ea !== void 0 && majorInfo.ea !== major ? majorInfo.ea : void 0;
|
|
255
|
+
const minorEastAsian = minorInfo?.ea !== void 0 && minorInfo.ea !== minor ? minorInfo.ea : void 0;
|
|
256
|
+
if (major === void 0 && minor === void 0 && majorEastAsian === void 0 && minorEastAsian === void 0) return;
|
|
257
|
+
return {
|
|
258
|
+
...major === void 0 ? {} : { major },
|
|
259
|
+
...minor === void 0 ? {} : { minor },
|
|
260
|
+
...majorEastAsian === void 0 ? {} : { majorEastAsian },
|
|
261
|
+
...minorEastAsian === void 0 ? {} : { minorEastAsian }
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function readFormatColorTransform(parentCursor, partPath, slideIndex, diagnostics) {
|
|
265
|
+
let colorCursor;
|
|
266
|
+
let colorValue;
|
|
267
|
+
for (const child of parentCursor.remainingElementChildren()) {
|
|
268
|
+
if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
|
|
269
|
+
if (child.localName === "schemeClr" && colorCursor === void 0) {
|
|
270
|
+
colorCursor = child;
|
|
271
|
+
const val = child.attr("val");
|
|
272
|
+
if (val === "phClr" || val !== void 0 && schemeColorNames.includes(val)) colorValue = val;
|
|
273
|
+
} else if (child.localName === "srgbClr" && colorCursor === void 0) {
|
|
274
|
+
colorCursor = child;
|
|
275
|
+
const val = child.attr("val");
|
|
276
|
+
const parsed = hexRgb6Schema.safeParse(val);
|
|
277
|
+
if (parsed.success) colorValue = `#${parsed.data.toUpperCase()}`;
|
|
278
|
+
} else {
|
|
279
|
+
diagnostics.push({
|
|
280
|
+
code: "unsupported-mechanism",
|
|
281
|
+
category: "unsupported",
|
|
282
|
+
disposition: "omitted",
|
|
283
|
+
location: {
|
|
284
|
+
part: partPath,
|
|
285
|
+
xpath: child.xpath,
|
|
286
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
287
|
+
},
|
|
288
|
+
namespaceUri: child.namespaceUri,
|
|
289
|
+
localName: child.localName,
|
|
290
|
+
mechanismHint: `format-color:${child.localName}`
|
|
291
|
+
});
|
|
292
|
+
child.suppressUnconsumed();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (colorCursor === void 0 || colorValue === void 0) return void 0;
|
|
296
|
+
let alpha;
|
|
297
|
+
let lumMod;
|
|
298
|
+
let lumOff;
|
|
299
|
+
let tint;
|
|
300
|
+
let shade;
|
|
301
|
+
let satMod;
|
|
302
|
+
for (const mod of colorCursor.remainingElementChildren()) {
|
|
303
|
+
if (mod.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
|
|
304
|
+
const parsed = percentValAttrSchema.safeParse(mod.attrsObject(["val"]));
|
|
305
|
+
if (!parsed.success) continue;
|
|
306
|
+
const fraction = parsed.data.val / 1e5;
|
|
307
|
+
switch (mod.localName) {
|
|
308
|
+
case "alpha":
|
|
309
|
+
alpha = Math.min(1, Math.max(0, fraction));
|
|
310
|
+
break;
|
|
311
|
+
case "lumMod":
|
|
312
|
+
lumMod = Math.min(1, Math.max(0, fraction));
|
|
313
|
+
break;
|
|
314
|
+
case "lumOff":
|
|
315
|
+
lumOff = Math.min(1, Math.max(0, fraction));
|
|
316
|
+
break;
|
|
317
|
+
case "tint":
|
|
318
|
+
tint = Math.min(1, Math.max(0, fraction));
|
|
319
|
+
break;
|
|
320
|
+
case "shade":
|
|
321
|
+
shade = Math.min(1, Math.max(0, fraction));
|
|
322
|
+
break;
|
|
323
|
+
case "satMod":
|
|
324
|
+
satMod = Math.max(0, fraction);
|
|
325
|
+
break;
|
|
326
|
+
default: diagnostics.push({
|
|
327
|
+
code: "unsupported-mechanism",
|
|
328
|
+
category: "unsupported",
|
|
329
|
+
disposition: "omitted",
|
|
330
|
+
location: {
|
|
331
|
+
part: partPath,
|
|
332
|
+
xpath: mod.xpath,
|
|
333
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
334
|
+
},
|
|
335
|
+
namespaceUri: mod.namespaceUri,
|
|
336
|
+
localName: mod.localName,
|
|
337
|
+
mechanismHint: `format-color-transform:${mod.localName}`
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
color: colorValue,
|
|
343
|
+
...alpha === void 0 ? {} : { alpha },
|
|
344
|
+
...lumMod === void 0 ? {} : { lumMod },
|
|
345
|
+
...lumOff === void 0 ? {} : { lumOff },
|
|
346
|
+
...tint === void 0 ? {} : { tint },
|
|
347
|
+
...shade === void 0 ? {} : { shade },
|
|
348
|
+
...satMod === void 0 ? {} : { satMod }
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function readFormatFillStyle(cursor, partPath, slideIndex, diagnostics) {
|
|
352
|
+
if (cursor.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") return void 0;
|
|
353
|
+
if (cursor.localName === "noFill") return { kind: "none" };
|
|
354
|
+
if (cursor.localName === "solidFill") {
|
|
355
|
+
const color = readFormatColorTransform(cursor, partPath, slideIndex, diagnostics);
|
|
356
|
+
return color === void 0 ? void 0 : {
|
|
357
|
+
kind: "solid",
|
|
358
|
+
color
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
if (cursor.localName === "gradFill") {
|
|
362
|
+
const gradAttrs = linearGradAttrSchema.extend({ rotWithShape: ooxmlBoolSchema.optional() }).safeParse(cursor.attrsObject(["rotWithShape"]));
|
|
363
|
+
const rotWithShape = gradAttrs.success ? gradAttrs.data.rotWithShape : void 0;
|
|
364
|
+
cursor.consumeAttr("flip");
|
|
365
|
+
const stops = [];
|
|
366
|
+
const gsLst = cursor.child(A_NS, "gsLst");
|
|
367
|
+
if (gsLst !== void 0) for (const gs of gsLst.children(A_NS, "gs")) {
|
|
368
|
+
const posParsed = percentPosAttrSchema.safeParse(gs.attrsObject(["pos"]));
|
|
369
|
+
const color = readFormatColorTransform(gs, partPath, slideIndex, diagnostics);
|
|
370
|
+
if (posParsed.success && color !== void 0) stops.push({
|
|
371
|
+
position: Math.min(1, Math.max(0, posParsed.data.pos / 1e5)),
|
|
372
|
+
color
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (stops.length === 0) return;
|
|
376
|
+
let linear;
|
|
377
|
+
const lin = cursor.child(A_NS, "lin");
|
|
378
|
+
if (lin !== void 0) {
|
|
379
|
+
const parsed = linearGradAttrSchema.safeParse(lin.attrsObject(["ang", "scaled"]));
|
|
380
|
+
if (parsed.success) linear = {
|
|
381
|
+
angle: (parsed.data.ang ?? 0) / 6e4,
|
|
382
|
+
...parsed.data.scaled === void 0 ? {} : { scaled: parsed.data.scaled }
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
let pathSpec;
|
|
386
|
+
const pathCursor = cursor.child(A_NS, "path");
|
|
387
|
+
if (pathCursor !== void 0) {
|
|
388
|
+
const parsedPath = pathGradAttrSchema.safeParse(pathCursor.attrsObject(["path"]));
|
|
389
|
+
const rectCursor = pathCursor.child(A_NS, "fillToRect");
|
|
390
|
+
let fillToRect;
|
|
391
|
+
if (rectCursor !== void 0) {
|
|
392
|
+
const parsedRect = fillToRectAttrSchema.safeParse(rectCursor.attrsObject([
|
|
393
|
+
"l",
|
|
394
|
+
"t",
|
|
395
|
+
"r",
|
|
396
|
+
"b"
|
|
397
|
+
]));
|
|
398
|
+
if (parsedRect.success) fillToRect = {
|
|
399
|
+
l: (parsedRect.data.l ?? 0) / 1e5,
|
|
400
|
+
t: (parsedRect.data.t ?? 0) / 1e5,
|
|
401
|
+
r: (parsedRect.data.r ?? 0) / 1e5,
|
|
402
|
+
b: (parsedRect.data.b ?? 0) / 1e5
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
pathSpec = {
|
|
406
|
+
shape: parsedPath.success ? parsedPath.data.path ?? "rect" : "rect",
|
|
407
|
+
...fillToRect === void 0 ? {} : { fillToRect }
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
cursor.ignoreEmptyChild(A_NS, "tileRect");
|
|
411
|
+
return {
|
|
412
|
+
kind: "gradient",
|
|
413
|
+
...rotWithShape === void 0 ? {} : { rotWithShape },
|
|
414
|
+
stops,
|
|
415
|
+
...linear === void 0 ? {} : { linear },
|
|
416
|
+
...pathSpec === void 0 ? {} : { path: pathSpec }
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
diagnostics.push({
|
|
420
|
+
code: "unsupported-mechanism",
|
|
421
|
+
category: "unsupported",
|
|
422
|
+
disposition: "omitted",
|
|
423
|
+
location: {
|
|
424
|
+
part: partPath,
|
|
425
|
+
xpath: cursor.xpath,
|
|
426
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
427
|
+
},
|
|
428
|
+
namespaceUri: cursor.namespaceUri,
|
|
429
|
+
localName: cursor.localName,
|
|
430
|
+
mechanismHint: `format-fill:${cursor.localName}`
|
|
431
|
+
});
|
|
432
|
+
cursor.suppressUnconsumed();
|
|
433
|
+
}
|
|
434
|
+
function readFormatLineStyle(lnCursor, partPath, slideIndex, diagnostics) {
|
|
435
|
+
const rawAttrs = lnCursor.attrsObject([
|
|
436
|
+
"w",
|
|
437
|
+
"cap",
|
|
438
|
+
"cmpd",
|
|
439
|
+
"algn"
|
|
440
|
+
]);
|
|
441
|
+
let widthEmu;
|
|
442
|
+
if (rawAttrs["w"] !== void 0) {
|
|
443
|
+
const parsedW = ooxmlLineWidthEmuSchema.safeParse(rawAttrs["w"]);
|
|
444
|
+
if (parsedW.success) widthEmu = parsedW.data;
|
|
445
|
+
else diagnostics.push({
|
|
446
|
+
code: "invalid-xml-value",
|
|
447
|
+
category: "corrupt-input",
|
|
448
|
+
disposition: "recovered",
|
|
449
|
+
location: {
|
|
450
|
+
part: partPath,
|
|
451
|
+
xpath: `${lnCursor.xpath}/@w`,
|
|
452
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
453
|
+
},
|
|
454
|
+
attributeOrElement: "a:ln/@w",
|
|
455
|
+
rawValue: rawAttrs["w"]
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const parsed = lineAttrSchema.omit({ w: true }).safeParse(rawAttrs);
|
|
459
|
+
let fill;
|
|
460
|
+
let dash;
|
|
461
|
+
for (const child of lnCursor.remainingElementChildren()) {
|
|
462
|
+
if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
|
|
463
|
+
if ((child.localName === "solidFill" || child.localName === "gradFill" || child.localName === "noFill") && fill === void 0) fill = readFormatFillStyle(child, partPath, slideIndex, diagnostics);
|
|
464
|
+
else if (child.localName === "prstDash") {
|
|
465
|
+
const val = child.attr("val");
|
|
466
|
+
if (val !== void 0) dash = val;
|
|
467
|
+
} else if (child.localName === "miter" || child.localName === "round" || child.localName === "bevel") child.consumeAttr("lim");
|
|
468
|
+
else {
|
|
469
|
+
diagnostics.push({
|
|
470
|
+
code: "unsupported-mechanism",
|
|
471
|
+
category: "unsupported",
|
|
472
|
+
disposition: "omitted",
|
|
473
|
+
location: {
|
|
474
|
+
part: partPath,
|
|
475
|
+
xpath: child.xpath,
|
|
476
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
477
|
+
},
|
|
478
|
+
namespaceUri: child.namespaceUri,
|
|
479
|
+
localName: child.localName,
|
|
480
|
+
mechanismHint: `format-line:${child.localName}`
|
|
481
|
+
});
|
|
482
|
+
child.suppressUnconsumed();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
...widthEmu === void 0 ? {} : { widthEmu },
|
|
487
|
+
...parsed.success && parsed.data.cap !== void 0 ? { cap: parsed.data.cap } : {},
|
|
488
|
+
...parsed.success && parsed.data.cmpd !== void 0 ? { compound: parsed.data.cmpd } : {},
|
|
489
|
+
...parsed.success && parsed.data.algn !== void 0 ? { align: parsed.data.algn } : {},
|
|
490
|
+
...dash === void 0 ? {} : { dash },
|
|
491
|
+
...fill === void 0 ? {} : { fill }
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function readFormatEffectStyle(effectCursor, partPath, slideIndex, diagnostics) {
|
|
495
|
+
let shadow;
|
|
496
|
+
for (const child of effectCursor.remainingElementChildren()) {
|
|
497
|
+
if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
|
|
498
|
+
if (child.localName === "effectLst") {
|
|
499
|
+
const outerShdw = child.child(A_NS, "outerShdw");
|
|
500
|
+
if (outerShdw !== void 0) {
|
|
501
|
+
const rawShdw = outerShdw.attrsObject([
|
|
502
|
+
"blurRad",
|
|
503
|
+
"dist",
|
|
504
|
+
"dir",
|
|
505
|
+
"algn",
|
|
506
|
+
"rotWithShape"
|
|
507
|
+
]);
|
|
508
|
+
const parsed = outerShdwAttrSchema.safeParse(rawShdw);
|
|
509
|
+
if (!parsed.success) {
|
|
510
|
+
diagnostics.push({
|
|
511
|
+
code: "invalid-xml-value",
|
|
512
|
+
category: "corrupt-input",
|
|
513
|
+
disposition: "omitted",
|
|
514
|
+
location: {
|
|
515
|
+
part: partPath,
|
|
516
|
+
xpath: outerShdw.xpath,
|
|
517
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
518
|
+
},
|
|
519
|
+
attributeOrElement: "a:outerShdw",
|
|
520
|
+
rawValue: JSON.stringify(rawShdw)
|
|
521
|
+
});
|
|
522
|
+
outerShdw.suppressUnconsumed();
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
let dir;
|
|
526
|
+
if (rawShdw["dir"] !== void 0) {
|
|
527
|
+
const parsedDir = ooxmlPositiveFixedAngleSchema.safeParse(rawShdw["dir"]);
|
|
528
|
+
if (parsedDir.success) dir = parsedDir.data;
|
|
529
|
+
else diagnostics.push({
|
|
530
|
+
code: "invalid-xml-value",
|
|
531
|
+
category: "corrupt-input",
|
|
532
|
+
disposition: "recovered",
|
|
533
|
+
location: {
|
|
534
|
+
part: partPath,
|
|
535
|
+
xpath: `${outerShdw.xpath}/@dir`,
|
|
536
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
537
|
+
},
|
|
538
|
+
attributeOrElement: "a:outerShdw/@dir",
|
|
539
|
+
rawValue: rawShdw["dir"]
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
const colorHex = resolveSimpleThemeHex(outerShdw, partPath, slideIndex, diagnostics);
|
|
543
|
+
shadow = {
|
|
544
|
+
...colorHex === void 0 ? {} : { color: colorHex },
|
|
545
|
+
...parsed.data.blurRad !== void 0 ? { blur: parsed.data.blurRad / 12700 } : {},
|
|
546
|
+
...parsed.data.dist !== void 0 ? { distance: parsed.data.dist / 12700 } : {},
|
|
547
|
+
...dir !== void 0 ? { angle: dir / 6e4 } : {}
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
} else {
|
|
551
|
+
diagnostics.push({
|
|
552
|
+
code: "unsupported-mechanism",
|
|
553
|
+
category: "unsupported",
|
|
554
|
+
disposition: "omitted",
|
|
555
|
+
location: {
|
|
556
|
+
part: partPath,
|
|
557
|
+
xpath: child.xpath,
|
|
558
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
559
|
+
},
|
|
560
|
+
namespaceUri: child.namespaceUri,
|
|
561
|
+
localName: child.localName,
|
|
562
|
+
mechanismHint: `format-effect:${child.localName}`
|
|
563
|
+
});
|
|
564
|
+
child.suppressUnconsumed();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return shadow === void 0 ? {} : { shadow };
|
|
568
|
+
}
|
|
569
|
+
const defaultFormatFill = {
|
|
570
|
+
kind: "solid",
|
|
571
|
+
color: { color: "phClr" }
|
|
572
|
+
};
|
|
573
|
+
const defaultFormatLine = {
|
|
574
|
+
widthEmu: 6350,
|
|
575
|
+
fill: defaultFormatFill
|
|
576
|
+
};
|
|
577
|
+
const defaultFormatEffect = {};
|
|
578
|
+
function padFormatList(list, fallback, minimum = 3) {
|
|
579
|
+
while (list.length < minimum) list.push(fallback);
|
|
580
|
+
}
|
|
581
|
+
function readFmtScheme(fmtSchemeCursor, partPath, slideIndex, diagnostics) {
|
|
582
|
+
const name = fmtSchemeCursor.attr("name");
|
|
583
|
+
const fillStyles = [];
|
|
584
|
+
const lineStyles = [];
|
|
585
|
+
const effectStyles = [];
|
|
586
|
+
const bgFillStyles = [];
|
|
587
|
+
const fillStyleLst = fmtSchemeCursor.child(A_NS, "fillStyleLst");
|
|
588
|
+
if (fillStyleLst !== void 0) {
|
|
589
|
+
for (const child of fillStyleLst.remainingElementChildren()) {
|
|
590
|
+
const parsed = readFormatFillStyle(child, partPath, slideIndex, diagnostics);
|
|
591
|
+
if (parsed !== void 0) fillStyles.push(parsed);
|
|
592
|
+
}
|
|
593
|
+
padFormatList(fillStyles, defaultFormatFill);
|
|
594
|
+
}
|
|
595
|
+
const lnStyleLst = fmtSchemeCursor.child(A_NS, "lnStyleLst");
|
|
596
|
+
if (lnStyleLst !== void 0) {
|
|
597
|
+
for (const child of lnStyleLst.children(A_NS, "ln")) lineStyles.push(readFormatLineStyle(child, partPath, slideIndex, diagnostics));
|
|
598
|
+
padFormatList(lineStyles, defaultFormatLine);
|
|
599
|
+
}
|
|
600
|
+
const effectStyleLst = fmtSchemeCursor.child(A_NS, "effectStyleLst");
|
|
601
|
+
if (effectStyleLst !== void 0) {
|
|
602
|
+
for (const child of effectStyleLst.children(A_NS, "effectStyle")) effectStyles.push(readFormatEffectStyle(child, partPath, slideIndex, diagnostics));
|
|
603
|
+
padFormatList(effectStyles, defaultFormatEffect);
|
|
604
|
+
}
|
|
605
|
+
const bgFillStyleLst = fmtSchemeCursor.child(A_NS, "bgFillStyleLst");
|
|
606
|
+
if (bgFillStyleLst !== void 0) {
|
|
607
|
+
for (const child of bgFillStyleLst.remainingElementChildren()) {
|
|
608
|
+
const parsed = readFormatFillStyle(child, partPath, slideIndex, diagnostics);
|
|
609
|
+
if (parsed !== void 0) bgFillStyles.push(parsed);
|
|
610
|
+
}
|
|
611
|
+
padFormatList(bgFillStyles, defaultFormatFill);
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
...name === void 0 ? {} : { name },
|
|
615
|
+
...fillStyles.length === 0 ? {} : { fillStyles },
|
|
616
|
+
...lineStyles.length === 0 ? {} : { lineStyles },
|
|
617
|
+
...effectStyles.length === 0 ? {} : { effectStyles },
|
|
618
|
+
...bgFillStyles.length === 0 ? {} : { bgFillStyles }
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Reads a native `ppt/theme/theme{n}.xml` part into a branded `Theme` instance,
|
|
623
|
+
* deduplicating shared OPC theme parts by normalized target path so masters sharing
|
|
624
|
+
* `ppt/theme/theme1.xml` share the exact same `Theme` object identity.
|
|
625
|
+
*/
|
|
626
|
+
function readThemePart(pkg, themePartPath, themesByPartPath, diagnostics) {
|
|
627
|
+
const cached = themesByPartPath.get(themePartPath);
|
|
628
|
+
if (cached !== void 0) return cached;
|
|
629
|
+
const xmlText = pkg.readTextPart(themePartPath);
|
|
630
|
+
if (xmlText === void 0) return void 0;
|
|
631
|
+
let rootEl;
|
|
632
|
+
try {
|
|
633
|
+
rootEl = parseXmlPart(themePartPath, xmlText);
|
|
634
|
+
} catch {
|
|
635
|
+
diagnostics.push({
|
|
636
|
+
code: "corrupt-part",
|
|
637
|
+
category: "corrupt-input",
|
|
638
|
+
disposition: "omitted",
|
|
639
|
+
location: { part: themePartPath }
|
|
640
|
+
});
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if ((rootEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/drawingml/2006/main" || (rootEl.localName ?? rootEl.tagName) !== "theme") {
|
|
644
|
+
diagnostics.push({
|
|
645
|
+
code: "corrupt-part",
|
|
646
|
+
category: "corrupt-input",
|
|
647
|
+
disposition: "omitted",
|
|
648
|
+
location: { part: themePartPath }
|
|
649
|
+
});
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const themeCursor = XmlElementCursor.createRoot(rootEl, themePartPath, "/a:theme");
|
|
653
|
+
const rawName = themeCursor.attr("name");
|
|
654
|
+
const themeName = rawName !== void 0 && rawName.trim() !== "" ? rawName : "Office Theme";
|
|
655
|
+
const themeElements = themeCursor.child(A_NS, "themeElements");
|
|
656
|
+
let colors = { ...officeFallbackColors };
|
|
657
|
+
let fonts = {};
|
|
658
|
+
let formatScheme;
|
|
659
|
+
if (themeElements !== void 0) {
|
|
660
|
+
const clrScheme = themeElements.child(A_NS, "clrScheme");
|
|
661
|
+
if (clrScheme !== void 0) colors = readClrScheme(clrScheme, themePartPath, void 0, diagnostics);
|
|
662
|
+
const fontScheme = themeElements.child(A_NS, "fontScheme");
|
|
663
|
+
if (fontScheme !== void 0) fonts = readFontScheme(fontScheme, themePartPath, void 0, diagnostics) ?? {};
|
|
664
|
+
const fmtScheme = themeElements.child(A_NS, "fmtScheme");
|
|
665
|
+
if (fmtScheme !== void 0) formatScheme = readFmtScheme(fmtScheme, themePartPath, void 0, diagnostics);
|
|
666
|
+
}
|
|
667
|
+
const objectDefaults = themeCursor.child(A_NS, "objectDefaults");
|
|
668
|
+
if (objectDefaults !== void 0) for (const child of objectDefaults.remainingElementChildren()) {
|
|
669
|
+
diagnostics.push({
|
|
670
|
+
code: "unsupported-mechanism",
|
|
671
|
+
category: "unsupported",
|
|
672
|
+
disposition: "omitted",
|
|
673
|
+
location: {
|
|
674
|
+
part: themePartPath,
|
|
675
|
+
xpath: child.xpath
|
|
676
|
+
},
|
|
677
|
+
namespaceUri: child.namespaceUri,
|
|
678
|
+
localName: child.localName,
|
|
679
|
+
mechanismHint: `theme-object-defaults:${child.localName}`
|
|
680
|
+
});
|
|
681
|
+
child.suppressUnconsumed();
|
|
682
|
+
}
|
|
683
|
+
const extraClrSchemeLst = themeCursor.child(A_NS, "extraClrSchemeLst");
|
|
684
|
+
if (extraClrSchemeLst !== void 0) for (const child of extraClrSchemeLst.remainingElementChildren()) {
|
|
685
|
+
diagnostics.push({
|
|
686
|
+
code: "unsupported-mechanism",
|
|
687
|
+
category: "unsupported",
|
|
688
|
+
disposition: "omitted",
|
|
689
|
+
location: {
|
|
690
|
+
part: themePartPath,
|
|
691
|
+
xpath: child.xpath
|
|
692
|
+
},
|
|
693
|
+
namespaceUri: child.namespaceUri,
|
|
694
|
+
localName: child.localName,
|
|
695
|
+
mechanismHint: `theme-extra-color-scheme:${child.localName}`
|
|
696
|
+
});
|
|
697
|
+
child.suppressUnconsumed();
|
|
698
|
+
}
|
|
699
|
+
for (const item of themeCursor.collectUnconsumed()) diagnostics.push({
|
|
700
|
+
code: "unconsumed-xml",
|
|
701
|
+
category: "unsupported",
|
|
702
|
+
disposition: "omitted",
|
|
703
|
+
kind: item.kind,
|
|
704
|
+
location: item.location,
|
|
705
|
+
namespaceUri: item.namespaceUri,
|
|
706
|
+
localName: item.localName
|
|
707
|
+
});
|
|
708
|
+
const theme = defineTheme({
|
|
709
|
+
name: themeName,
|
|
710
|
+
colors,
|
|
711
|
+
fonts,
|
|
712
|
+
...formatScheme === void 0 ? {} : { formatScheme }
|
|
713
|
+
});
|
|
714
|
+
themesByPartPath.set(themePartPath, theme);
|
|
715
|
+
return theme;
|
|
716
|
+
}
|
|
717
|
+
/** Reads an optional `<a:themeOverride>` part referenced by a SlideLayout or Slide. */
|
|
718
|
+
function readThemeOverridePart(pkg, overridePartPath, slideIndex, diagnostics) {
|
|
719
|
+
const xmlText = pkg.readTextPart(overridePartPath);
|
|
720
|
+
if (xmlText === void 0) return void 0;
|
|
721
|
+
let rootEl;
|
|
722
|
+
try {
|
|
723
|
+
rootEl = parseXmlPart(overridePartPath, xmlText);
|
|
724
|
+
} catch {
|
|
725
|
+
diagnostics.push({
|
|
726
|
+
code: "corrupt-part",
|
|
727
|
+
category: "corrupt-input",
|
|
728
|
+
disposition: "omitted",
|
|
729
|
+
location: {
|
|
730
|
+
part: overridePartPath,
|
|
731
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if ((rootEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/drawingml/2006/main" || (rootEl.localName ?? rootEl.tagName) !== "themeOverride") {
|
|
737
|
+
diagnostics.push({
|
|
738
|
+
code: "corrupt-part",
|
|
739
|
+
category: "corrupt-input",
|
|
740
|
+
disposition: "omitted",
|
|
741
|
+
location: {
|
|
742
|
+
part: overridePartPath,
|
|
743
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
const cursor = XmlElementCursor.createRoot(rootEl, overridePartPath, "/a:themeOverride");
|
|
749
|
+
const clrScheme = cursor.child(A_NS, "clrScheme");
|
|
750
|
+
const colors = clrScheme === void 0 ? void 0 : readClrScheme(clrScheme, overridePartPath, slideIndex, diagnostics);
|
|
751
|
+
const fontScheme = cursor.child(A_NS, "fontScheme");
|
|
752
|
+
const fonts = fontScheme === void 0 ? void 0 : readFontScheme(fontScheme, overridePartPath, slideIndex, diagnostics);
|
|
753
|
+
const fmtScheme = cursor.child(A_NS, "fmtScheme");
|
|
754
|
+
const formatScheme = fmtScheme === void 0 ? void 0 : readFmtScheme(fmtScheme, overridePartPath, slideIndex, diagnostics);
|
|
755
|
+
for (const item of cursor.collectUnconsumed()) diagnostics.push({
|
|
756
|
+
code: "unconsumed-xml",
|
|
757
|
+
category: "unsupported",
|
|
758
|
+
disposition: "omitted",
|
|
759
|
+
kind: item.kind,
|
|
760
|
+
location: {
|
|
761
|
+
...item.location,
|
|
762
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
763
|
+
},
|
|
764
|
+
namespaceUri: item.namespaceUri,
|
|
765
|
+
localName: item.localName
|
|
766
|
+
});
|
|
767
|
+
if (colors === void 0 && fonts === void 0 && formatScheme === void 0) return;
|
|
768
|
+
return {
|
|
769
|
+
...colors === void 0 ? {} : { colors },
|
|
770
|
+
...fonts === void 0 ? {} : { fonts },
|
|
771
|
+
...formatScheme === void 0 ? {} : { formatScheme }
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function isNonDefaultColorMap(map) {
|
|
775
|
+
return !colorMapsEqual(map, defaultColorMap);
|
|
776
|
+
}
|
|
777
|
+
export { isNonDefaultColorMap, readColorMapElement, readColorMapOverride, readThemeOverridePart, readThemePart };
|