@officedk/pptxdk 0.0.0-stage → 0.1.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/README.md +48 -2
- package/dist/build.d.ts +94 -0
- package/dist/build.js +148 -0
- package/dist/capabilities/dist/all.js +32 -0
- package/dist/capabilities/dist/box/box-codegen.js +51 -0
- package/dist/capabilities/dist/box/box-declaration.js +31 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +138 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +77 -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 +2272 -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 +1078 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1124 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -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 +190 -0
- package/dist/capabilities/dist/chart/preview/layout.js +519 -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 +48 -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 +148 -0
- package/dist/capabilities/dist/font/font-embedding.js +289 -0
- package/dist/capabilities/dist/font/font-family.js +10 -0
- package/dist/capabilities/dist/font/font-import.js +302 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +25 -0
- package/dist/capabilities/dist/group/group-codegen.js +51 -0
- package/dist/capabilities/dist/group/group-declaration.js +42 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +319 -0
- package/dist/capabilities/dist/group/group-xml.js +7 -0
- package/dist/capabilities/dist/group/group.js +211 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +94 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +221 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +778 -0
- package/dist/capabilities/dist/image/image-schemas.js +149 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +472 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +527 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1033 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
- package/dist/capabilities/dist/motion/motion-query.js +420 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
- package/dist/capabilities/dist/motion/motion.js +1372 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +20 -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 +35 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +191 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +579 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +337 -0
- package/dist/capabilities/dist/shared/geometry.js +1423 -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 +113 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
- package/dist/capabilities/dist/shared/style-parse.js +11 -0
- package/dist/capabilities/dist/shared/text-schemas.js +216 -0
- package/dist/capabilities/dist/shared/text-service.js +1883 -0
- package/dist/capabilities/dist/shared/visual.js +918 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
- package/dist/capabilities/dist/table/table-codegen.js +81 -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 +539 -0
- package/dist/capabilities/dist/table/table-schemas.js +279 -0
- package/dist/capabilities/dist/table/table-xml.js +37 -0
- package/dist/capabilities/dist/table/table.js +662 -0
- package/dist/capabilities/dist/text/text-codegen.js +129 -0
- package/dist/capabilities/dist/text/text-declaration.js +19 -0
- package/dist/capabilities/dist/text/text-elements.js +38 -0
- package/dist/capabilities/dist/text/text-import.js +1077 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +335 -0
- package/dist/capabilities/dist/transition/transition-api.js +139 -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-D_xeNVIw.d.ts +29496 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +78 -0
- package/dist/codegen/dist/codegen.js +611 -0
- package/dist/codegen/dist/identifiers.js +193 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +49 -0
- package/dist/core/dist/author-ids.js +48 -0
- package/dist/core/dist/author-schemas.js +313 -0
- package/dist/core/dist/block-flex-layout.js +749 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +13 -0
- package/dist/core/dist/declaration.js +15 -0
- package/dist/core/dist/diagnostics.js +21 -0
- package/dist/core/dist/document-internals.js +13 -0
- package/dist/core/dist/document.js +408 -0
- package/dist/core/dist/geometry-schemas.js +249 -0
- package/dist/core/dist/grid-layout.js +445 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +45 -0
- package/dist/core/dist/layout-protocol.js +66 -0
- package/dist/core/dist/layout-schemas.js +208 -0
- package/dist/core/dist/layout.js +299 -0
- package/dist/core/dist/masters.js +169 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +213 -0
- package/dist/core/dist/query.js +155 -0
- package/dist/core/dist/resolution.js +11 -0
- package/dist/core/dist/resolve.js +1827 -0
- package/dist/core/dist/stage-options.js +67 -0
- package/dist/core/dist/theme.js +931 -0
- package/dist/document-BHPUODPP.d.ts +27759 -0
- package/dist/emit/dist/emit.js +936 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +606 -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 +153 -0
- package/dist/import/dist/fonts.js +250 -0
- package/dist/import/dist/import.js +504 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1153 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +60 -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 +671 -0
- package/dist/import/dist/visual.js +761 -0
- package/dist/import/dist/xml-fragments.js +36 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-B5m3hqjC.d.ts +7 -0
- package/dist/index-CCy-Yo8G.d.ts +1208 -0
- package/dist/index-DpxcZ4Gs.d.ts +725 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +70 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +194 -0
- package/dist/pptxdk/src/cli-commands.js +913 -0
- package/dist/pptxdk/src/compose.js +44 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +240 -0
- package/dist/preview/dist/options.js +53 -0
- package/dist/preview-Cfw0QdMM.d.ts +86 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +27 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +65 -0
- package/dist/react/dist/elements.js +59 -0
- package/dist/react/dist/index.js +68 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +145 -0
- package/dist/react.js +27 -0
- package/dist/transition-Cips9wma.d.ts +82 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +14 -0
- package/package.json +78 -3
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import { createMorphScope } from "../../core/dist/morph.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { createDeckNode, createSlideNode } from "../../core/dist/document.js";
|
|
4
|
+
import { importOptionsSchema } from "./diagnostics.js";
|
|
5
|
+
import { allocateScopedAuthorId, appendUnconsumedDiagnostics, consumeCommonSlideCreationId, readShapeTreeItems } from "./masters.js";
|
|
6
|
+
import { P_NS, R_NS, emuToPx } from "./namespaces.js";
|
|
7
|
+
import { inspectNotesAndHandoutMasters } from "./notes-masters.js";
|
|
8
|
+
import { openPptxPackage, resolvePartPath } from "./opc.js";
|
|
9
|
+
import { buildRelationshipIndex } from "./resources.js";
|
|
10
|
+
import { readColorMapOverride, readThemeOverridePart } from "./themes.js";
|
|
11
|
+
import { extentEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema } from "./xml-fragments.js";
|
|
12
|
+
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
// ../import/dist/import.js
|
|
15
|
+
const defaultSlideWidthPx = 960;
|
|
16
|
+
const defaultSlideHeightPx = 540;
|
|
17
|
+
const slideSizeFragmentSchema = extentEmuFragmentSchema.extend({ type: z.string().optional() });
|
|
18
|
+
const slideShowAttrSchema = z.object({
|
|
19
|
+
show: ooxmlBoolSchema.optional(),
|
|
20
|
+
showMasterPhAnim: ooxmlBoolSchema.optional(),
|
|
21
|
+
showMasterSp: ooxmlBoolSchema.optional()
|
|
22
|
+
});
|
|
23
|
+
function isImportMechanismHandler(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null || !("target" in value)) return false;
|
|
25
|
+
const target = value.target;
|
|
26
|
+
return target === "shape-tree" || target === "slide" || target === "deck";
|
|
27
|
+
}
|
|
28
|
+
function collectHandlers(capabilities) {
|
|
29
|
+
const shapeTree = [];
|
|
30
|
+
const slide = [];
|
|
31
|
+
const deck = [];
|
|
32
|
+
for (const mod of capabilities) {
|
|
33
|
+
if (!("mechanisms" in mod) || mod.mechanisms === void 0) continue;
|
|
34
|
+
for (const mechanism of mod.mechanisms) {
|
|
35
|
+
if (!isImportMechanismHandler(mechanism.import)) continue;
|
|
36
|
+
const handler = mechanism.import;
|
|
37
|
+
switch (handler.target) {
|
|
38
|
+
case "shape-tree":
|
|
39
|
+
shapeTree.push(handler);
|
|
40
|
+
break;
|
|
41
|
+
case "slide":
|
|
42
|
+
slide.push(handler);
|
|
43
|
+
break;
|
|
44
|
+
case "deck": deck.push(handler);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
shapeTree,
|
|
50
|
+
slide,
|
|
51
|
+
deck
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function consumePresentationHeaderBoilerplate(presCursor) {
|
|
55
|
+
const notesSz = presCursor.child(P_NS, "notesSz");
|
|
56
|
+
if (notesSz !== void 0) {
|
|
57
|
+
notesSz.consumeAttr("cx");
|
|
58
|
+
notesSz.consumeAttr("cy");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function readSlideSize(presCursor, diagnostics) {
|
|
62
|
+
const sldSz = presCursor.child(P_NS, "sldSz");
|
|
63
|
+
if (sldSz === void 0) return {
|
|
64
|
+
width: defaultSlideWidthPx,
|
|
65
|
+
height: defaultSlideHeightPx
|
|
66
|
+
};
|
|
67
|
+
const raw = sldSz.attrsObject([
|
|
68
|
+
"cx",
|
|
69
|
+
"cy",
|
|
70
|
+
"type"
|
|
71
|
+
]);
|
|
72
|
+
const parsed = slideSizeFragmentSchema.safeParse(raw);
|
|
73
|
+
if (!parsed.success) {
|
|
74
|
+
diagnostics.push({
|
|
75
|
+
code: "invalid-xml-value",
|
|
76
|
+
category: "corrupt-input",
|
|
77
|
+
disposition: "recovered",
|
|
78
|
+
location: {
|
|
79
|
+
part: presCursor.part,
|
|
80
|
+
xpath: sldSz.xpath
|
|
81
|
+
},
|
|
82
|
+
attributeOrElement: "p:sldSz",
|
|
83
|
+
rawValue: JSON.stringify(raw)
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
width: defaultSlideWidthPx,
|
|
87
|
+
height: defaultSlideHeightPx
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
width: emuToPx(parsed.data.cx),
|
|
92
|
+
height: emuToPx(parsed.data.cy)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function applyNativeMorphToken(node, slidePartPath, slideIndex, morphScope, morphHandleByToken, usedSlideMorphTokens, diagnostics) {
|
|
96
|
+
const rawName = node.props["name"];
|
|
97
|
+
if (typeof rawName !== "string" || !rawName.startsWith("!!")) return;
|
|
98
|
+
const token = rawName.slice(2);
|
|
99
|
+
if (token.trim() === "") return;
|
|
100
|
+
if (usedSlideMorphTokens.has(token)) {
|
|
101
|
+
diagnostics.push({
|
|
102
|
+
code: "invalid-xml-value",
|
|
103
|
+
category: "corrupt-input",
|
|
104
|
+
disposition: "recovered",
|
|
105
|
+
location: {
|
|
106
|
+
part: slidePartPath,
|
|
107
|
+
slideIndex
|
|
108
|
+
},
|
|
109
|
+
attributeOrElement: "p:cNvPr/@name",
|
|
110
|
+
rawValue: rawName
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
usedSlideMorphTokens.add(token);
|
|
115
|
+
let handle = morphHandleByToken.get(token);
|
|
116
|
+
if (handle === void 0) {
|
|
117
|
+
handle = morphScope.handle(token);
|
|
118
|
+
morphHandleByToken.set(token, handle);
|
|
119
|
+
}
|
|
120
|
+
node.set({
|
|
121
|
+
name: void 0,
|
|
122
|
+
morphKey: handle
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function readSlidePart(pkg, slidePartPath, slideIndex, usedSlideIds, layoutNodeByPartPath, clrMapByLayoutPartPath, handlers, registerDeferredSlideLink, morphScope, morphHandleByToken, diagnostics) {
|
|
126
|
+
const xmlText = pkg.readTextPart(slidePartPath);
|
|
127
|
+
if (xmlText === void 0) return void 0;
|
|
128
|
+
let slideEl;
|
|
129
|
+
try {
|
|
130
|
+
slideEl = parseXmlPart(slidePartPath, xmlText);
|
|
131
|
+
} catch {
|
|
132
|
+
diagnostics.push({
|
|
133
|
+
code: "corrupt-part",
|
|
134
|
+
category: "corrupt-input",
|
|
135
|
+
disposition: "omitted",
|
|
136
|
+
location: {
|
|
137
|
+
part: slidePartPath,
|
|
138
|
+
slideIndex
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if ((slideEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (slideEl.localName ?? slideEl.tagName) !== "sld") {
|
|
144
|
+
diagnostics.push({
|
|
145
|
+
code: "corrupt-part",
|
|
146
|
+
category: "corrupt-input",
|
|
147
|
+
disposition: "omitted",
|
|
148
|
+
location: {
|
|
149
|
+
part: slidePartPath,
|
|
150
|
+
slideIndex
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const relIndex = buildRelationshipIndex(pkg, slidePartPath);
|
|
156
|
+
diagnostics.push(...relIndex.diagnostics);
|
|
157
|
+
const slideCursor = XmlElementCursor.createRoot(slideEl, slidePartPath, "/p:sld");
|
|
158
|
+
const rawShow = slideCursor.attrsObject([
|
|
159
|
+
"show",
|
|
160
|
+
"showMasterPhAnim",
|
|
161
|
+
"showMasterSp"
|
|
162
|
+
]);
|
|
163
|
+
const parsedShow = slideShowAttrSchema.safeParse(rawShow);
|
|
164
|
+
let hidden = false;
|
|
165
|
+
let showMasterPlaceholderAnimations;
|
|
166
|
+
let showMasterShapes;
|
|
167
|
+
if (!parsedShow.success) {
|
|
168
|
+
const singleShow = ooxmlBoolSchema.safeParse(rawShow["show"]);
|
|
169
|
+
if (rawShow["show"] !== void 0) {
|
|
170
|
+
if (!singleShow.success) diagnostics.push({
|
|
171
|
+
code: "invalid-xml-value",
|
|
172
|
+
category: "corrupt-input",
|
|
173
|
+
disposition: "recovered",
|
|
174
|
+
location: {
|
|
175
|
+
part: slidePartPath,
|
|
176
|
+
xpath: `${slideCursor.xpath}/@show`,
|
|
177
|
+
slideIndex
|
|
178
|
+
},
|
|
179
|
+
attributeOrElement: "@show",
|
|
180
|
+
rawValue: rawShow["show"]
|
|
181
|
+
});
|
|
182
|
+
else if (!singleShow.data) hidden = true;
|
|
183
|
+
}
|
|
184
|
+
const singlePhAnim = ooxmlBoolSchema.safeParse(rawShow["showMasterPhAnim"]);
|
|
185
|
+
if (rawShow["showMasterPhAnim"] !== void 0) {
|
|
186
|
+
if (!singlePhAnim.success) diagnostics.push({
|
|
187
|
+
code: "invalid-xml-value",
|
|
188
|
+
category: "corrupt-input",
|
|
189
|
+
disposition: "recovered",
|
|
190
|
+
location: {
|
|
191
|
+
part: slidePartPath,
|
|
192
|
+
xpath: `${slideCursor.xpath}/@showMasterPhAnim`,
|
|
193
|
+
slideIndex
|
|
194
|
+
},
|
|
195
|
+
attributeOrElement: "@showMasterPhAnim",
|
|
196
|
+
rawValue: rawShow["showMasterPhAnim"]
|
|
197
|
+
});
|
|
198
|
+
else showMasterPlaceholderAnimations = singlePhAnim.data;
|
|
199
|
+
}
|
|
200
|
+
const singleShowMasterSp = ooxmlBoolSchema.safeParse(rawShow["showMasterSp"]);
|
|
201
|
+
if (rawShow["showMasterSp"] !== void 0) {
|
|
202
|
+
if (!singleShowMasterSp.success) diagnostics.push({
|
|
203
|
+
code: "invalid-xml-value",
|
|
204
|
+
category: "corrupt-input",
|
|
205
|
+
disposition: "recovered",
|
|
206
|
+
location: {
|
|
207
|
+
part: slidePartPath,
|
|
208
|
+
xpath: `${slideCursor.xpath}/@showMasterSp`,
|
|
209
|
+
slideIndex
|
|
210
|
+
},
|
|
211
|
+
attributeOrElement: "@showMasterSp",
|
|
212
|
+
rawValue: rawShow["showMasterSp"]
|
|
213
|
+
});
|
|
214
|
+
else showMasterShapes = singleShowMasterSp.data;
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (parsedShow.data.show === false) hidden = true;
|
|
218
|
+
showMasterPlaceholderAnimations = parsedShow.data.showMasterPhAnim;
|
|
219
|
+
showMasterShapes = parsedShow.data.showMasterSp;
|
|
220
|
+
}
|
|
221
|
+
const cSld = slideCursor.child(P_NS, "cSld");
|
|
222
|
+
if (cSld === void 0) {
|
|
223
|
+
diagnostics.push({
|
|
224
|
+
code: "corrupt-part",
|
|
225
|
+
category: "corrupt-input",
|
|
226
|
+
disposition: "omitted",
|
|
227
|
+
location: {
|
|
228
|
+
part: slidePartPath,
|
|
229
|
+
xpath: slideCursor.xpath,
|
|
230
|
+
slideIndex
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
consumeCommonSlideCreationId(cSld);
|
|
236
|
+
const slideRels = pkg.readRelationships(slidePartPath);
|
|
237
|
+
diagnostics.push(...slideRels.diagnostics);
|
|
238
|
+
const layoutRel = slideRels.entries.find((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" && entry.TargetMode !== "External");
|
|
239
|
+
const resolvedLayoutPath = layoutRel === void 0 ? void 0 : resolvePartPath(slidePartPath, layoutRel.Target);
|
|
240
|
+
const layoutNode = resolvedLayoutPath === void 0 ? void 0 : layoutNodeByPartPath.get(resolvedLayoutPath);
|
|
241
|
+
const layoutPlaceholders = layoutNode?.props["placeholders"];
|
|
242
|
+
const masterPlaceholders = layoutNode?.parent?.props["placeholders"];
|
|
243
|
+
const layoutClrMap = resolvedLayoutPath === void 0 ? void 0 : clrMapByLayoutPartPath.get(resolvedLayoutPath);
|
|
244
|
+
const clrMapOvr = slideCursor.child(P_NS, "clrMapOvr");
|
|
245
|
+
let colorMapOverride;
|
|
246
|
+
if (clrMapOvr !== void 0) {
|
|
247
|
+
const parsedOvr = readColorMapOverride(clrMapOvr, slidePartPath, slideIndex, diagnostics);
|
|
248
|
+
if (parsedOvr !== void 0 && parsedOvr !== "master") colorMapOverride = parsedOvr;
|
|
249
|
+
}
|
|
250
|
+
let themeOverride;
|
|
251
|
+
const themeOverrideRel = slideRels.entries.find((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride" && entry.TargetMode !== "External");
|
|
252
|
+
if (themeOverrideRel !== void 0) {
|
|
253
|
+
const overridePart = resolvePartPath(slidePartPath, themeOverrideRel.Target);
|
|
254
|
+
if (overridePart === void 0 || !pkg.hasPart(overridePart)) diagnostics.push({
|
|
255
|
+
code: "missing-target-part",
|
|
256
|
+
category: "corrupt-input",
|
|
257
|
+
disposition: "omitted",
|
|
258
|
+
location: {
|
|
259
|
+
part: slidePartPath,
|
|
260
|
+
xpath: themeOverrideRel.xpath,
|
|
261
|
+
slideIndex
|
|
262
|
+
},
|
|
263
|
+
relationshipId: themeOverrideRel.Id,
|
|
264
|
+
targetPart: overridePart ?? themeOverrideRel.Target
|
|
265
|
+
});
|
|
266
|
+
else themeOverride = readThemeOverridePart(pkg, overridePart, slideIndex, diagnostics);
|
|
267
|
+
}
|
|
268
|
+
const rawSlideName = cSld.attr("name");
|
|
269
|
+
const slideId = allocateScopedAuthorId(rawSlideName, usedSlideIds, `slide-${slideIndex + 1}`);
|
|
270
|
+
const displayName = rawSlideName !== void 0 && rawSlideName.trim().length > 0 && rawSlideName !== slideId ? rawSlideName : void 0;
|
|
271
|
+
const slideNode = createSlideNode({
|
|
272
|
+
id: slideId,
|
|
273
|
+
...displayName === void 0 ? {} : { name: displayName },
|
|
274
|
+
...layoutNode === void 0 ? {} : { layout: layoutNode },
|
|
275
|
+
...colorMapOverride === void 0 ? {} : { colorMapOverride },
|
|
276
|
+
...themeOverride === void 0 ? {} : { themeOverride },
|
|
277
|
+
...hidden ? { hidden: true } : {},
|
|
278
|
+
...showMasterPlaceholderAnimations === void 0 ? {} : { showMasterPlaceholderAnimations },
|
|
279
|
+
...showMasterShapes === void 0 ? {} : { showMasterShapes }
|
|
280
|
+
});
|
|
281
|
+
const objectBySpid = /* @__PURE__ */ new Map();
|
|
282
|
+
const omittedSpids = /* @__PURE__ */ new Map();
|
|
283
|
+
const registerImportedObject = (spid, node) => {
|
|
284
|
+
objectBySpid.set(spid, node);
|
|
285
|
+
};
|
|
286
|
+
const usedSlideMorphTokens = /* @__PURE__ */ new Set();
|
|
287
|
+
const spTree = cSld.child(P_NS, "spTree");
|
|
288
|
+
if (spTree !== void 0) readShapeTreeItems({
|
|
289
|
+
spTree,
|
|
290
|
+
pkg,
|
|
291
|
+
partPath: slidePartPath,
|
|
292
|
+
slideIndex,
|
|
293
|
+
relIndex,
|
|
294
|
+
shapeTreeHandlers: handlers.shapeTree,
|
|
295
|
+
registerDeferredSlideLink,
|
|
296
|
+
registerImportedObject,
|
|
297
|
+
omittedSpids,
|
|
298
|
+
appendNode: (node) => {
|
|
299
|
+
applyNativeMorphToken(node, slidePartPath, slideIndex, morphScope, morphHandleByToken, usedSlideMorphTokens, diagnostics);
|
|
300
|
+
slideNode.append(node);
|
|
301
|
+
},
|
|
302
|
+
diagnostics,
|
|
303
|
+
containerNode: slideNode,
|
|
304
|
+
...layoutPlaceholders === void 0 ? {} : { layoutPlaceholders },
|
|
305
|
+
...masterPlaceholders === void 0 ? {} : { masterPlaceholders },
|
|
306
|
+
...layoutClrMap === void 0 ? {} : { clrMap: layoutClrMap }
|
|
307
|
+
});
|
|
308
|
+
for (const slideHandler of handlers.slide) {
|
|
309
|
+
if (slideHandler.matches !== void 0 && !slideHandler.matches(slideCursor)) continue;
|
|
310
|
+
const outcome = slideHandler.read({
|
|
311
|
+
slideCursor,
|
|
312
|
+
slideNode,
|
|
313
|
+
part: slidePartPath,
|
|
314
|
+
slideIndex,
|
|
315
|
+
package: pkg,
|
|
316
|
+
objectBySpid,
|
|
317
|
+
omittedSpids
|
|
318
|
+
});
|
|
319
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
320
|
+
}
|
|
321
|
+
appendUnconsumedDiagnostics(slideCursor, slideIndex, diagnostics);
|
|
322
|
+
return {
|
|
323
|
+
node: slideNode,
|
|
324
|
+
slideId
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Creates a Transitional PPTX importer bound to the caller's registered capability modules.
|
|
329
|
+
*
|
|
330
|
+
* The returned function owns OPC package traversal, XML cursor tracking, and structured diagnostics,
|
|
331
|
+
* while delegating native object/slide parsing to mechanisms declared by `capabilities`.
|
|
332
|
+
*/
|
|
333
|
+
function createImporter(capabilities) {
|
|
334
|
+
const handlers = collectHandlers(capabilities);
|
|
335
|
+
return function importPptx(input, options = {}) {
|
|
336
|
+
importOptionsSchema.parse(options);
|
|
337
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
338
|
+
const pkg = openPptxPackage(input);
|
|
339
|
+
const diagnostics = [...pkg.relDiagnostics];
|
|
340
|
+
const presCursor = pkg.presentationRoot;
|
|
341
|
+
consumePresentationHeaderBoilerplate(presCursor);
|
|
342
|
+
const size = readSlideSize(presCursor, diagnostics);
|
|
343
|
+
const deckNode = createDeckNode({
|
|
344
|
+
width: size.width,
|
|
345
|
+
height: size.height
|
|
346
|
+
});
|
|
347
|
+
const relById = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const rel of pkg.presentationRels) relById.set(rel.Id, rel);
|
|
349
|
+
const usedDeckIds = /* @__PURE__ */ new Set();
|
|
350
|
+
const clrMapByLayoutPartPath = /* @__PURE__ */ new Map();
|
|
351
|
+
const layoutNodeByPartPath = /* @__PURE__ */ new Map();
|
|
352
|
+
const slideIdByPartPath = /* @__PURE__ */ new Map();
|
|
353
|
+
const slideNodeByPresentationSldId = /* @__PURE__ */ new Map();
|
|
354
|
+
const deferredSlideLinks = [];
|
|
355
|
+
const registerDeferredSlideLink = (link) => {
|
|
356
|
+
deferredSlideLinks.push(link);
|
|
357
|
+
};
|
|
358
|
+
const seenDeckReaders = /* @__PURE__ */ new Set();
|
|
359
|
+
const uniqueDeckHandlers = handlers.deck.filter((handler) => {
|
|
360
|
+
if (seenDeckReaders.has(handler.read)) return false;
|
|
361
|
+
seenDeckReaders.add(handler.read);
|
|
362
|
+
return true;
|
|
363
|
+
});
|
|
364
|
+
const preSlideDeckHandlers = uniqueDeckHandlers.filter((handler) => handler.stage === "pre-slides");
|
|
365
|
+
const postSlideDeckHandlers = uniqueDeckHandlers.filter((handler) => handler.stage !== "pre-slides");
|
|
366
|
+
if (preSlideDeckHandlers.length > 0) for (const deckHandler of preSlideDeckHandlers) {
|
|
367
|
+
const outcome = deckHandler.read({
|
|
368
|
+
presentationCursor: presCursor,
|
|
369
|
+
deckNode,
|
|
370
|
+
package: pkg,
|
|
371
|
+
relById,
|
|
372
|
+
usedDeckIds,
|
|
373
|
+
slideHandlers: handlers.slide,
|
|
374
|
+
shapeTreeHandlers: handlers.shapeTree,
|
|
375
|
+
registerDeferredSlideLink,
|
|
376
|
+
layoutNodeByPartPath,
|
|
377
|
+
clrMapByLayoutPartPath
|
|
378
|
+
});
|
|
379
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
380
|
+
}
|
|
381
|
+
else presCursor.child(P_NS, "sldMasterIdLst")?.suppressUnconsumed();
|
|
382
|
+
const morphScope = createMorphScope();
|
|
383
|
+
const morphHandleByToken = /* @__PURE__ */ new Map();
|
|
384
|
+
let slideCount = 0;
|
|
385
|
+
const sldIdLst = presCursor.child(P_NS, "sldIdLst");
|
|
386
|
+
if (sldIdLst !== void 0) {
|
|
387
|
+
const sldIds = sldIdLst.children(P_NS, "sldId");
|
|
388
|
+
for (let index = 0; index < sldIds.length; index += 1) {
|
|
389
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
390
|
+
const sldIdCursor = sldIds[index];
|
|
391
|
+
const rawId = sldIdCursor.attr("id");
|
|
392
|
+
const parsedSlideNumId = rawId === void 0 ? void 0 : ooxmlIntSchema.safeParse(rawId);
|
|
393
|
+
if (parsedSlideNumId !== void 0 && !parsedSlideNumId.success) diagnostics.push({
|
|
394
|
+
code: "invalid-xml-value",
|
|
395
|
+
category: "corrupt-input",
|
|
396
|
+
disposition: "recovered",
|
|
397
|
+
location: {
|
|
398
|
+
part: pkg.presentationPath,
|
|
399
|
+
xpath: `${sldIdCursor.xpath}/@id`,
|
|
400
|
+
slideIndex: index
|
|
401
|
+
},
|
|
402
|
+
attributeOrElement: "@id",
|
|
403
|
+
rawValue: rawId
|
|
404
|
+
});
|
|
405
|
+
const rId = sldIdCursor.attr("id", R_NS);
|
|
406
|
+
if (rId === void 0) {
|
|
407
|
+
diagnostics.push({
|
|
408
|
+
code: "broken-relationship",
|
|
409
|
+
category: "corrupt-input",
|
|
410
|
+
disposition: "omitted",
|
|
411
|
+
location: {
|
|
412
|
+
part: pkg.presentationPath,
|
|
413
|
+
xpath: sldIdCursor.xpath,
|
|
414
|
+
slideIndex: index
|
|
415
|
+
},
|
|
416
|
+
relationshipId: ""
|
|
417
|
+
});
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const rel = relById.get(rId);
|
|
421
|
+
if (rel === void 0 || rel.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" || rel.TargetMode === "External") {
|
|
422
|
+
diagnostics.push({
|
|
423
|
+
code: "broken-relationship",
|
|
424
|
+
category: "corrupt-input",
|
|
425
|
+
disposition: "omitted",
|
|
426
|
+
location: {
|
|
427
|
+
part: pkg.presentationPath,
|
|
428
|
+
xpath: sldIdCursor.xpath,
|
|
429
|
+
slideIndex: index
|
|
430
|
+
},
|
|
431
|
+
relationshipId: rId
|
|
432
|
+
});
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
const targetPart = resolvePartPath(pkg.presentationPath, rel.Target);
|
|
436
|
+
if (targetPart === void 0 || !pkg.hasPart(targetPart)) {
|
|
437
|
+
diagnostics.push({
|
|
438
|
+
code: "missing-target-part",
|
|
439
|
+
category: "corrupt-input",
|
|
440
|
+
disposition: "omitted",
|
|
441
|
+
location: {
|
|
442
|
+
part: pkg.presentationPath,
|
|
443
|
+
xpath: sldIdCursor.xpath,
|
|
444
|
+
slideIndex: index
|
|
445
|
+
},
|
|
446
|
+
relationshipId: rId,
|
|
447
|
+
targetPart: targetPart ?? rel.Target
|
|
448
|
+
});
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const slideResult = readSlidePart(pkg, targetPart, index, usedDeckIds, layoutNodeByPartPath, clrMapByLayoutPartPath, handlers, registerDeferredSlideLink, morphScope, morphHandleByToken, diagnostics);
|
|
452
|
+
if (slideResult !== void 0) {
|
|
453
|
+
slideIdByPartPath.set(targetPart, slideResult.slideId);
|
|
454
|
+
if (parsedSlideNumId?.success) slideNodeByPresentationSldId.set(parsedSlideNumId.data, slideResult.node);
|
|
455
|
+
deckNode.append(slideResult.node);
|
|
456
|
+
slideCount += 1;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
for (const pending of deferredSlideLinks) {
|
|
461
|
+
const targetSlideId = slideIdByPartPath.get(pending.targetPart);
|
|
462
|
+
if (targetSlideId === void 0) {
|
|
463
|
+
diagnostics.push({
|
|
464
|
+
code: "missing-target-part",
|
|
465
|
+
category: "corrupt-input",
|
|
466
|
+
disposition: "omitted",
|
|
467
|
+
location: pending.location,
|
|
468
|
+
relationshipId: pending.relationshipId,
|
|
469
|
+
targetPart: pending.targetPart
|
|
470
|
+
});
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
pending.apply(targetSlideId);
|
|
474
|
+
}
|
|
475
|
+
inspectNotesAndHandoutMasters(presCursor, pkg, relById, diagnostics);
|
|
476
|
+
for (const deckHandler of postSlideDeckHandlers) {
|
|
477
|
+
const outcome = deckHandler.read({
|
|
478
|
+
presentationCursor: presCursor,
|
|
479
|
+
deckNode,
|
|
480
|
+
package: pkg,
|
|
481
|
+
relById,
|
|
482
|
+
usedDeckIds,
|
|
483
|
+
slideHandlers: handlers.slide,
|
|
484
|
+
shapeTreeHandlers: handlers.shapeTree,
|
|
485
|
+
registerDeferredSlideLink,
|
|
486
|
+
layoutNodeByPartPath,
|
|
487
|
+
clrMapByLayoutPartPath,
|
|
488
|
+
slideNodeByPresentationSldId
|
|
489
|
+
});
|
|
490
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
491
|
+
}
|
|
492
|
+
appendUnconsumedDiagnostics(presCursor, void 0, diagnostics);
|
|
493
|
+
return {
|
|
494
|
+
document: deckNode,
|
|
495
|
+
report: Object.freeze({
|
|
496
|
+
evidence: "import",
|
|
497
|
+
sourceFormat: "ECMA-376 5th edition Transitional",
|
|
498
|
+
slideCount,
|
|
499
|
+
diagnostics: Object.freeze(diagnostics)
|
|
500
|
+
})
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
export { createImporter };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { A_NS, C_NS, EMU_PER_PX, MC_NS, P14_CREATION_ID_EXT_URI, P14_NS, P159_NS, P_NS, REL_CHART, REL_HYPERLINK, REL_IMAGE, REL_NOTES_SLIDE, REL_SLIDE, R_NS, TABLE_NS_URI, XML_NS, canonicalQName, emuToPx } from "./namespaces.js";
|
|
2
|
+
import "./alternate-content.js";
|
|
3
|
+
import { arrowTypeSchema, readBlipFill, readDrawingColor, readEffectList, readGradientFill, readLineBorder, readPlaceholderSpPrVisuals, readTransformXml } from "./visual.js";
|
|
4
|
+
import { ImportError, cascadedOmissionSchema, editabilityLossSchema, fatalImportIssueSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema } from "./diagnostics.js";
|
|
5
|
+
import { createImporter } from "./import.js";
|
|
6
|
+
import { appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate, importMastersAndLayouts } from "./masters.js";
|
|
7
|
+
import "./notes-masters.js";
|
|
8
|
+
import { importPresentationSections } from "./sections.js";
|
|
9
|
+
import "./themes.js";
|
|
10
|
+
import { readEmbeddedFontList, readPresentationThemeFontScheme, unpackEotFontData } from "./fonts.js";
|
|
11
|
+
import { resolvePartPath } from "./opc.js";
|
|
12
|
+
import { peekShapeTreeObjectIdentity, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "./resources.js";
|
|
13
|
+
import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, transformAttributesFragmentSchema } from "./xml-fragments.js";
|
|
14
|
+
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
15
|
+
import { defineCanvasMechanism, defineShowMechanism } from "./mechanism.js";
|
|
16
|
+
export { A_NS, C_NS, EMU_PER_PX, ImportError, MC_NS, P14_CREATION_ID_EXT_URI, P14_NS, P159_NS, P_NS, REL_CHART, REL_HYPERLINK, REL_IMAGE, REL_NOTES_SLIDE, REL_SLIDE, R_NS, TABLE_NS_URI, XML_NS, XmlElementCursor, appendUnconsumedDiagnostics, arrowTypeSchema, canonicalQName, cascadedOmissionSchema, consumeIdentityShapeTreeBoilerplate, createImporter, defineCanvasMechanism, defineShowMechanism, editabilityLossSchema, emuToPx, extentEmuFragmentSchema, fatalImportIssueSchema, hexRgb6Schema, importDiagnosticSchema, importLocationSchema, importMastersAndLayouts, importOptionsSchema, importPresentationSections, importReportSchema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, parseXmlPart, peekShapeTreeObjectIdentity, readBlipFill, readDrawingColor, readEffectList, readEmbeddedFontList, readGradientFill, readLineBorder, readPlaceholderSpPrVisuals, readPresentationThemeFontScheme, readTransformXml, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget, resolvePartPath, transformAttributesFragmentSchema, unpackEotFontData };
|