@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,1033 @@
|
|
|
1
|
+
import { CommonContainer, CommonNode } from "../../../core/dist/document.js";
|
|
2
|
+
import "../../../import/dist/index.js";
|
|
3
|
+
import { A_NS, P_NS } from "../../../import/dist/namespaces.js";
|
|
4
|
+
import { ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema } from "../../../import/dist/xml-fragments.js";
|
|
5
|
+
import { after, breathe, createMotionScopeHandle, createMotionScopeNode, createMotionStepIdentity, createMotionStepNode, fade, fillColor, floatDown, floatUp, fly, repeat, spin, spinIn, stretch, wipe, zoom } from "./motion-api.js";
|
|
6
|
+
// ../capabilities/dist/motion/motion-import.js
|
|
7
|
+
const supportedBehaviorNames = /* @__PURE__ */ new Set([
|
|
8
|
+
"set",
|
|
9
|
+
"anim",
|
|
10
|
+
"animEffect",
|
|
11
|
+
"animRot",
|
|
12
|
+
"animClr"
|
|
13
|
+
]);
|
|
14
|
+
const presetById = {
|
|
15
|
+
2: "fly",
|
|
16
|
+
8: "spin",
|
|
17
|
+
9: "fillColor",
|
|
18
|
+
10: "fade",
|
|
19
|
+
17: "stretch",
|
|
20
|
+
22: "wipe",
|
|
21
|
+
42: "floatUp",
|
|
22
|
+
47: "floatDown",
|
|
23
|
+
49: "spinIn",
|
|
24
|
+
53: "zoom"
|
|
25
|
+
};
|
|
26
|
+
const directionBySubtype = {
|
|
27
|
+
1: "top",
|
|
28
|
+
2: "right",
|
|
29
|
+
4: "bottom",
|
|
30
|
+
8: "left"
|
|
31
|
+
};
|
|
32
|
+
function locationFor(context, xpath, objectId, objectName) {
|
|
33
|
+
return {
|
|
34
|
+
part: context.part,
|
|
35
|
+
xpath,
|
|
36
|
+
...context.slideIndex === void 0 ? {} : { slideIndex: context.slideIndex },
|
|
37
|
+
...objectId === void 0 ? {} : { objectId },
|
|
38
|
+
...objectName === void 0 ? {} : { objectName }
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function parsePositiveInt(raw) {
|
|
42
|
+
if (raw === void 0) return void 0;
|
|
43
|
+
const parsed = ooxmlPositiveIntSchema.safeParse(raw);
|
|
44
|
+
return parsed.success ? parsed.data : void 0;
|
|
45
|
+
}
|
|
46
|
+
function parseNonNegativeInt(raw) {
|
|
47
|
+
if (raw === void 0) return void 0;
|
|
48
|
+
const parsed = ooxmlNonNegativeIntSchema.safeParse(raw);
|
|
49
|
+
return parsed.success ? parsed.data : void 0;
|
|
50
|
+
}
|
|
51
|
+
function parseSignedInt(raw) {
|
|
52
|
+
if (raw === void 0 || !/^-?\d+$/u.test(raw)) return void 0;
|
|
53
|
+
const n = Number(raw);
|
|
54
|
+
return Number.isSafeInteger(n) ? n : void 0;
|
|
55
|
+
}
|
|
56
|
+
function consumeTargetElement(tgtEl) {
|
|
57
|
+
const refs = [];
|
|
58
|
+
tgtEl.children(P_NS, "sldTgt");
|
|
59
|
+
for (const spTgt of tgtEl.children(P_NS, "spTgt")) {
|
|
60
|
+
const spid = parsePositiveInt(spTgt.attr("spid"));
|
|
61
|
+
let isBackground = false;
|
|
62
|
+
for (const _bg of spTgt.children(P_NS, "bg")) isBackground = true;
|
|
63
|
+
let range;
|
|
64
|
+
for (const txEl of spTgt.children(P_NS, "txEl")) {
|
|
65
|
+
const pRg = txEl.child(P_NS, "pRg");
|
|
66
|
+
if (pRg !== void 0) {
|
|
67
|
+
const st = parseNonNegativeInt(pRg.attr("st"));
|
|
68
|
+
const end = parseNonNegativeInt(pRg.attr("end"));
|
|
69
|
+
if (st !== void 0 && end !== void 0 && st <= end) range = {
|
|
70
|
+
type: "paragraph",
|
|
71
|
+
start: st,
|
|
72
|
+
end
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const charRg = txEl.child(P_NS, "charRg");
|
|
76
|
+
if (charRg !== void 0) {
|
|
77
|
+
charRg.consumeAttr("st");
|
|
78
|
+
charRg.consumeAttr("end");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const graphicEl of spTgt.children(P_NS, "graphicEl")) {
|
|
82
|
+
const chart = graphicEl.child(A_NS, "chart");
|
|
83
|
+
if (chart !== void 0) {
|
|
84
|
+
const seriesIdx = parseSignedInt(chart.attr("seriesIdx"));
|
|
85
|
+
const categoryIdx = parseSignedInt(chart.attr("categoryIdx"));
|
|
86
|
+
const bldStep = chart.attr("bldStep");
|
|
87
|
+
if (seriesIdx !== void 0 && categoryIdx !== void 0 && (bldStep === "gridLegend" || bldStep === "series" || bldStep === "category" || bldStep === "ptInSeries" || bldStep === "ptInCategory")) range = {
|
|
88
|
+
type: "chart",
|
|
89
|
+
step: bldStep,
|
|
90
|
+
seriesIndex: seriesIdx,
|
|
91
|
+
categoryIndex: categoryIdx
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (spid !== void 0) refs.push({
|
|
96
|
+
spid,
|
|
97
|
+
isBackground,
|
|
98
|
+
...range === void 0 ? {} : { range }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return refs;
|
|
102
|
+
}
|
|
103
|
+
function consumeConditionList(condList) {
|
|
104
|
+
if (condList === void 0) return [];
|
|
105
|
+
const result = [];
|
|
106
|
+
for (const cond of condList.children(P_NS, "cond")) {
|
|
107
|
+
const evt = cond.attr("evt");
|
|
108
|
+
const rawDelay = cond.attr("delay");
|
|
109
|
+
const delayMs = rawDelay === void 0 || rawDelay === "indefinite" ? 0 : parseNonNegativeInt(rawDelay) ?? 0;
|
|
110
|
+
const sourceId = parsePositiveInt(cond.child(P_NS, "tn")?.attr("val"));
|
|
111
|
+
const tgtEl = cond.child(P_NS, "tgtEl");
|
|
112
|
+
if (tgtEl !== void 0) consumeTargetElement(tgtEl);
|
|
113
|
+
if (evt === "onBegin") result.push({
|
|
114
|
+
kind: "onBegin",
|
|
115
|
+
delayMs
|
|
116
|
+
});
|
|
117
|
+
else if (evt === "end" && sourceId !== void 0) result.push({
|
|
118
|
+
kind: "end",
|
|
119
|
+
sourceTimingId: sourceId,
|
|
120
|
+
offsetMs: delayMs
|
|
121
|
+
});
|
|
122
|
+
else result.push({
|
|
123
|
+
kind: "delay",
|
|
124
|
+
delayMs
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
function consumeCommonTimeNodeAttrs(cTn) {
|
|
130
|
+
const id = parsePositiveInt(cTn.attr("id"));
|
|
131
|
+
const dur = cTn.attr("dur");
|
|
132
|
+
cTn.consumeAttr("fill");
|
|
133
|
+
cTn.consumeAttr("restart");
|
|
134
|
+
const nodeType = cTn.attr("nodeType");
|
|
135
|
+
const presetId = parseNonNegativeInt(cTn.attr("presetID"));
|
|
136
|
+
const presetClass = cTn.attr("presetClass");
|
|
137
|
+
const presetSubtype = parseNonNegativeInt(cTn.attr("presetSubtype"));
|
|
138
|
+
const grpId = parseNonNegativeInt(cTn.attr("grpId"));
|
|
139
|
+
const rawRepeat = cTn.attr("repeatCount");
|
|
140
|
+
let repeatCount;
|
|
141
|
+
if (rawRepeat === "indefinite") repeatCount = "forever";
|
|
142
|
+
else if (rawRepeat !== void 0) {
|
|
143
|
+
const milliCount = parsePositiveInt(rawRepeat);
|
|
144
|
+
if (milliCount !== void 0 && milliCount >= 1e3 && milliCount % 1e3 === 0) repeatCount = milliCount / 1e3;
|
|
145
|
+
}
|
|
146
|
+
const rawAutoRev = cTn.attr("autoRev");
|
|
147
|
+
const autoRev = rawAutoRev === "1" || rawAutoRev === "true";
|
|
148
|
+
const accel = parseNonNegativeInt(cTn.attr("accel"));
|
|
149
|
+
const decel = parseNonNegativeInt(cTn.attr("decel"));
|
|
150
|
+
return {
|
|
151
|
+
...id === void 0 ? {} : { id },
|
|
152
|
+
...dur === void 0 ? {} : { dur },
|
|
153
|
+
...nodeType === void 0 ? {} : { nodeType },
|
|
154
|
+
...presetId === void 0 ? {} : { presetId },
|
|
155
|
+
...presetClass === void 0 ? {} : { presetClass },
|
|
156
|
+
...presetSubtype === void 0 ? {} : { presetSubtype },
|
|
157
|
+
...grpId === void 0 ? {} : { grpId },
|
|
158
|
+
...repeatCount === void 0 ? {} : { repeatCount },
|
|
159
|
+
autoRev,
|
|
160
|
+
...accel === void 0 ? {} : { accel },
|
|
161
|
+
...decel === void 0 ? {} : { decel }
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function consumeBehaviorValueWrapper(wrapper) {
|
|
165
|
+
if (wrapper === void 0) return;
|
|
166
|
+
for (const fltVal of wrapper.children(P_NS, "fltVal")) fltVal.consumeAttr("val");
|
|
167
|
+
for (const strVal of wrapper.children(P_NS, "strVal")) strVal.consumeAttr("val");
|
|
168
|
+
for (const srgb of wrapper.children(A_NS, "srgbClr")) srgb.consumeAttr("val");
|
|
169
|
+
}
|
|
170
|
+
function readColorFromWrapper(wrapper) {
|
|
171
|
+
if (wrapper === void 0) return void 0;
|
|
172
|
+
const hex = wrapper.child(A_NS, "srgbClr")?.attr("val");
|
|
173
|
+
if (hex === void 0 || !/^[0-9a-f]{6}$/iu.test(hex)) return void 0;
|
|
174
|
+
return `#${hex.toUpperCase()}`;
|
|
175
|
+
}
|
|
176
|
+
function readBehaviorElement(behavior) {
|
|
177
|
+
const localName = behavior.localName;
|
|
178
|
+
if (localName === "animEffect") {
|
|
179
|
+
behavior.consumeAttr("transition");
|
|
180
|
+
behavior.consumeAttr("filter");
|
|
181
|
+
} else if (localName === "anim") {
|
|
182
|
+
behavior.consumeAttr("calcmode");
|
|
183
|
+
behavior.consumeAttr("valueType");
|
|
184
|
+
behavior.consumeAttr("from");
|
|
185
|
+
behavior.consumeAttr("to");
|
|
186
|
+
behavior.consumeAttr("by");
|
|
187
|
+
} else if (localName === "animClr") behavior.consumeAttr("clrSpc");
|
|
188
|
+
else if (localName === "animRot") {}
|
|
189
|
+
const rawRotFrom = localName === "animRot" ? behavior.attr("from") : void 0;
|
|
190
|
+
const rawRotBy = localName === "animRot" ? behavior.attr("by") : void 0;
|
|
191
|
+
if (localName === "animRot") behavior.consumeAttr("to");
|
|
192
|
+
const rotationFrom = parseSignedInt(rawRotFrom);
|
|
193
|
+
const rotationBy = parseSignedInt(rawRotBy);
|
|
194
|
+
const cBhvr = behavior.child(P_NS, "cBhvr");
|
|
195
|
+
const additive = cBhvr?.attr("additive");
|
|
196
|
+
cBhvr?.consumeAttr("accumulate");
|
|
197
|
+
cBhvr?.consumeAttr("override");
|
|
198
|
+
const innerCTn = cBhvr?.child(P_NS, "cTn");
|
|
199
|
+
const innerAttrs = innerCTn === void 0 ? void 0 : consumeCommonTimeNodeAttrs(innerCTn);
|
|
200
|
+
if (innerCTn !== void 0) consumeConditionList(innerCTn.child(P_NS, "stCondLst"));
|
|
201
|
+
const durationMs = parsePositiveInt(innerAttrs?.dur);
|
|
202
|
+
const tgtEl = cBhvr?.child(P_NS, "tgtEl");
|
|
203
|
+
const targets = tgtEl === void 0 ? [] : consumeTargetElement(tgtEl);
|
|
204
|
+
const attrNameLst = cBhvr?.child(P_NS, "attrNameLst");
|
|
205
|
+
const attrNames = [];
|
|
206
|
+
if (attrNameLst !== void 0) for (const attrName of attrNameLst.children(P_NS, "attrName")) attrNames.push(attrName.textContent.trim());
|
|
207
|
+
const tavLst = behavior.child(P_NS, "tavLst");
|
|
208
|
+
if (tavLst !== void 0) for (const tav of tavLst.children(P_NS, "tav")) {
|
|
209
|
+
tav.consumeAttr("tm");
|
|
210
|
+
tav.consumeAttr("fmla");
|
|
211
|
+
consumeBehaviorValueWrapper(tav.child(P_NS, "val"));
|
|
212
|
+
}
|
|
213
|
+
const fromEl = behavior.child(P_NS, "from");
|
|
214
|
+
const toEl = behavior.child(P_NS, "to");
|
|
215
|
+
let fromColor;
|
|
216
|
+
let toColor;
|
|
217
|
+
if (localName === "animClr") {
|
|
218
|
+
fromColor = readColorFromWrapper(fromEl);
|
|
219
|
+
toColor = readColorFromWrapper(toEl);
|
|
220
|
+
} else {
|
|
221
|
+
consumeBehaviorValueWrapper(fromEl);
|
|
222
|
+
consumeBehaviorValueWrapper(toEl);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
localName,
|
|
226
|
+
xpath: behavior.xpath,
|
|
227
|
+
targets,
|
|
228
|
+
...durationMs === void 0 ? {} : { durationMs },
|
|
229
|
+
attrNames,
|
|
230
|
+
...additive === void 0 ? {} : { additive },
|
|
231
|
+
...fromColor === void 0 ? {} : { fromColor },
|
|
232
|
+
...toColor === void 0 ? {} : { toColor },
|
|
233
|
+
...rotationFrom === void 0 ? {} : { rotationFrom },
|
|
234
|
+
...rotationBy === void 0 ? {} : { rotationBy }
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function buildEffectDeclaration(args) {
|
|
238
|
+
const baseOptions = {
|
|
239
|
+
duration: args.durationMs,
|
|
240
|
+
delay: args.delayMs,
|
|
241
|
+
...args.easing === void 0 ? {} : { easing: args.easing }
|
|
242
|
+
};
|
|
243
|
+
const granularityOptions = {
|
|
244
|
+
...baseOptions,
|
|
245
|
+
...typeof args.by === "string" ? { by: args.by } : {},
|
|
246
|
+
...args.intervalMs === void 0 ? {} : { intervalMs: args.intervalMs }
|
|
247
|
+
};
|
|
248
|
+
let effect;
|
|
249
|
+
switch (args.preset) {
|
|
250
|
+
case "fade":
|
|
251
|
+
effect = fade(granularityOptions);
|
|
252
|
+
break;
|
|
253
|
+
case "wipe":
|
|
254
|
+
effect = wipe({
|
|
255
|
+
...granularityOptions,
|
|
256
|
+
...typeof args.from === "string" ? { from: args.from } : {}
|
|
257
|
+
});
|
|
258
|
+
break;
|
|
259
|
+
case "zoom":
|
|
260
|
+
effect = zoom(granularityOptions);
|
|
261
|
+
break;
|
|
262
|
+
case "fly":
|
|
263
|
+
effect = fly({
|
|
264
|
+
...granularityOptions,
|
|
265
|
+
...typeof args.from === "string" ? { from: args.from } : {}
|
|
266
|
+
});
|
|
267
|
+
break;
|
|
268
|
+
case "floatUp":
|
|
269
|
+
effect = floatUp(granularityOptions);
|
|
270
|
+
break;
|
|
271
|
+
case "floatDown":
|
|
272
|
+
effect = floatDown(granularityOptions);
|
|
273
|
+
break;
|
|
274
|
+
case "spinIn":
|
|
275
|
+
effect = spinIn(granularityOptions);
|
|
276
|
+
break;
|
|
277
|
+
case "stretch":
|
|
278
|
+
effect = stretch(granularityOptions);
|
|
279
|
+
break;
|
|
280
|
+
case "spin":
|
|
281
|
+
effect = spin({
|
|
282
|
+
...baseOptions,
|
|
283
|
+
...typeof args.by === "number" ? { by: args.by } : {},
|
|
284
|
+
...typeof args.from === "number" ? { from: args.from } : {}
|
|
285
|
+
});
|
|
286
|
+
break;
|
|
287
|
+
case "breathe":
|
|
288
|
+
effect = breathe({
|
|
289
|
+
period: args.durationMs,
|
|
290
|
+
from: args.fromColor ?? "#000000",
|
|
291
|
+
to: args.toColor ?? "#FFFFFF",
|
|
292
|
+
delay: args.delayMs,
|
|
293
|
+
...args.easing === void 0 ? {} : { easing: args.easing }
|
|
294
|
+
});
|
|
295
|
+
break;
|
|
296
|
+
case "fillColor": effect = fillColor({
|
|
297
|
+
...baseOptions,
|
|
298
|
+
from: args.fromColor ?? "#000000",
|
|
299
|
+
to: args.toColor ?? "#FFFFFF"
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const declaration = args.repeatCount === void 0 ? effect : repeat(effect, args.repeatCount);
|
|
303
|
+
return {
|
|
304
|
+
effect,
|
|
305
|
+
declaration
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function commonEffectPropsMatch(left, right) {
|
|
309
|
+
return left.targetId === right.targetId && left.effect.preset === right.effect.preset && left.effect.kind === right.effect.kind && left.effect.duration === right.effect.duration && left.from === right.from && left.repeatCount === right.repeatCount && JSON.stringify(left.easing ?? null) === JSON.stringify(right.easing ?? null);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Reads slide, layout, or master `<p:timing>` back into live `enter`/`emphasis`,
|
|
313
|
+
* `Step`/`MotionScope`, or `OwnerMotion` declarations, emitting localized diagnostics
|
|
314
|
+
* with cascaded dependency tracking when targets or animation behaviors cannot be imported.
|
|
315
|
+
*/
|
|
316
|
+
function readSlideMotionImport(context) {
|
|
317
|
+
const timingCursors = context.slideCursor.children(P_NS, "timing");
|
|
318
|
+
if (timingCursors.length === 0) return {};
|
|
319
|
+
const diagnostics = [];
|
|
320
|
+
for (const extraTiming of timingCursors.slice(1)) {
|
|
321
|
+
diagnostics.push({
|
|
322
|
+
code: "invalid-xml-value",
|
|
323
|
+
category: "corrupt-input",
|
|
324
|
+
disposition: "recovered",
|
|
325
|
+
location: locationFor(context, extraTiming.xpath),
|
|
326
|
+
attributeOrElement: "p:timing"
|
|
327
|
+
});
|
|
328
|
+
extraTiming.suppressUnconsumed();
|
|
329
|
+
}
|
|
330
|
+
const timingCursor = timingCursors[0];
|
|
331
|
+
const paragraphBuilds = /* @__PURE__ */ new Map();
|
|
332
|
+
const chartBuilds = /* @__PURE__ */ new Map();
|
|
333
|
+
const bldLst = timingCursor.child(P_NS, "bldLst");
|
|
334
|
+
if (bldLst !== void 0) {
|
|
335
|
+
for (const bldP of bldLst.children(P_NS, "bldP")) {
|
|
336
|
+
const spid = parsePositiveInt(bldP.attr("spid"));
|
|
337
|
+
const grpId = parseNonNegativeInt(bldP.attr("grpId")) ?? 0;
|
|
338
|
+
const build = bldP.attr("build");
|
|
339
|
+
const rawAnimBg = bldP.attr("animBg");
|
|
340
|
+
bldP.consumeAttr("rev");
|
|
341
|
+
bldP.consumeAttr("advAuto");
|
|
342
|
+
bldP.consumeAttr("uiExpand");
|
|
343
|
+
bldP.consumeAttr("bld");
|
|
344
|
+
const animBg = rawAnimBg === "1" || rawAnimBg === "true" ? true : rawAnimBg === "0" || rawAnimBg === "false" ? false : void 0;
|
|
345
|
+
if (spid !== void 0) paragraphBuilds.set(`${spid}:${grpId}`, {
|
|
346
|
+
...build === void 0 ? {} : { build },
|
|
347
|
+
...animBg === void 0 ? {} : { animBg }
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
for (const bldGraphic of bldLst.children(P_NS, "bldGraphic")) {
|
|
351
|
+
const spid = parsePositiveInt(bldGraphic.attr("spid"));
|
|
352
|
+
const grpId = parseNonNegativeInt(bldGraphic.attr("grpId")) ?? 0;
|
|
353
|
+
bldGraphic.consumeAttr("uiExpand");
|
|
354
|
+
let mode;
|
|
355
|
+
if (bldGraphic.child("http://schemas.openxmlformats.org/presentationml/2006/main", "bldAsOne") !== void 0) mode = "all";
|
|
356
|
+
const bldSub = bldGraphic.child(P_NS, "bldSub");
|
|
357
|
+
if (bldSub !== void 0) {
|
|
358
|
+
const bldChart = bldSub.child(A_NS, "bldChart");
|
|
359
|
+
const rawBld = bldChart?.attr("bld");
|
|
360
|
+
bldChart?.consumeAttr("animBg");
|
|
361
|
+
if (rawBld === "all" || rawBld === "series" || rawBld === "category" || rawBld === "seriesEl" || rawBld === "categoryEl") mode = rawBld;
|
|
362
|
+
}
|
|
363
|
+
if (spid !== void 0 && mode !== void 0) chartBuilds.set(`${spid}:${grpId}`, { mode });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const rootCTn = (timingCursor.child(P_NS, "tnLst")?.child(P_NS, "par"))?.child(P_NS, "cTn");
|
|
367
|
+
if (rootCTn === void 0) {
|
|
368
|
+
diagnostics.push({
|
|
369
|
+
code: "corrupt-part",
|
|
370
|
+
category: "corrupt-input",
|
|
371
|
+
disposition: "omitted",
|
|
372
|
+
location: locationFor(context, timingCursor.xpath)
|
|
373
|
+
});
|
|
374
|
+
timingCursor.suppressUnconsumed();
|
|
375
|
+
return { diagnostics };
|
|
376
|
+
}
|
|
377
|
+
consumeCommonTimeNodeAttrs(rootCTn);
|
|
378
|
+
consumeConditionList(rootCTn.child(P_NS, "stCondLst"));
|
|
379
|
+
const rootChildTnLst = rootCTn.child(P_NS, "childTnLst");
|
|
380
|
+
let mainSeq;
|
|
381
|
+
if (rootChildTnLst !== void 0) for (const childSeq of rootChildTnLst.children(P_NS, "seq")) {
|
|
382
|
+
childSeq.consumeAttr("concurrent");
|
|
383
|
+
childSeq.consumeAttr("nextAc");
|
|
384
|
+
const seqCTn = childSeq.child(P_NS, "cTn");
|
|
385
|
+
const attrs = seqCTn === void 0 ? void 0 : consumeCommonTimeNodeAttrs(seqCTn);
|
|
386
|
+
consumeConditionList(childSeq.child(P_NS, "prevCondLst"));
|
|
387
|
+
consumeConditionList(childSeq.child(P_NS, "nextCondLst"));
|
|
388
|
+
if (attrs?.nodeType === "mainSeq" && mainSeq === void 0) mainSeq = childSeq;
|
|
389
|
+
else {
|
|
390
|
+
diagnostics.push({
|
|
391
|
+
code: "unsupported-mechanism",
|
|
392
|
+
category: "unsupported",
|
|
393
|
+
disposition: "omitted",
|
|
394
|
+
location: locationFor(context, childSeq.xpath),
|
|
395
|
+
namespaceUri: childSeq.namespaceUri,
|
|
396
|
+
localName: childSeq.localName,
|
|
397
|
+
mechanismHint: `timing-sequence:${attrs?.nodeType ?? "unknown"}`
|
|
398
|
+
});
|
|
399
|
+
childSeq.suppressUnconsumed();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const mainSeqChildren = (mainSeq?.child(P_NS, "cTn"))?.child(P_NS, "childTnLst");
|
|
403
|
+
if (mainSeqChildren === void 0) return diagnostics.length === 0 ? {} : { diagnostics };
|
|
404
|
+
const rawNodesById = /* @__PURE__ */ new Map();
|
|
405
|
+
const stepInfos = [];
|
|
406
|
+
const visitTimingNode = (cursor, parentTimingId, stepIndex) => {
|
|
407
|
+
const cTn = cursor.child(P_NS, "cTn");
|
|
408
|
+
if (cTn === void 0) return void 0;
|
|
409
|
+
const attrs = consumeCommonTimeNodeAttrs(cTn);
|
|
410
|
+
if (attrs.id === void 0) {
|
|
411
|
+
diagnostics.push({
|
|
412
|
+
code: "invalid-xml-value",
|
|
413
|
+
category: "corrupt-input",
|
|
414
|
+
disposition: "omitted",
|
|
415
|
+
location: locationFor(context, cTn.xpath),
|
|
416
|
+
attributeOrElement: "@id"
|
|
417
|
+
});
|
|
418
|
+
cursor.suppressUnconsumed();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const timingId = attrs.id;
|
|
422
|
+
const conds = consumeConditionList(cTn.child(P_NS, "stCondLst"));
|
|
423
|
+
let delayMs = 0;
|
|
424
|
+
const dependsOn = [];
|
|
425
|
+
for (const cond of conds) if (cond.kind === "delay") delayMs += cond.delayMs;
|
|
426
|
+
else if (cond.kind === "end") dependsOn.push({
|
|
427
|
+
timingId: cond.sourceTimingId,
|
|
428
|
+
offsetMs: cond.offsetMs
|
|
429
|
+
});
|
|
430
|
+
const endSyncEl = cTn.child(P_NS, "endSync");
|
|
431
|
+
let endSyncAll = false;
|
|
432
|
+
if (endSyncEl !== void 0) {
|
|
433
|
+
const evt = endSyncEl.attr("evt");
|
|
434
|
+
endSyncEl.consumeAttr("delay");
|
|
435
|
+
const val = endSyncEl.child(P_NS, "rtn")?.attr("val");
|
|
436
|
+
endSyncAll = evt === "end" && (val === "all" || val === void 0);
|
|
437
|
+
}
|
|
438
|
+
const iterateEl = cTn.child(P_NS, "iterate");
|
|
439
|
+
let iterateBy;
|
|
440
|
+
let iterateIntervalMs;
|
|
441
|
+
if (iterateEl !== void 0) {
|
|
442
|
+
const rawType = iterateEl.attr("type");
|
|
443
|
+
if (rawType === "wd") iterateBy = "word";
|
|
444
|
+
else if (rawType === "lt") iterateBy = "letter";
|
|
445
|
+
iterateIntervalMs = parsePositiveInt(iterateEl.child(P_NS, "tmAbs")?.attr("val"));
|
|
446
|
+
iterateEl.consumeAttr("backwards");
|
|
447
|
+
}
|
|
448
|
+
const childTnLst = cTn.child(P_NS, "childTnLst");
|
|
449
|
+
const subContainers = [];
|
|
450
|
+
const behaviorCursors = [];
|
|
451
|
+
const otherChildren = [];
|
|
452
|
+
if (childTnLst !== void 0) for (const child of childTnLst.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && (child.localName === "par" || child.localName === "seq")) {
|
|
453
|
+
if (child.localName === "seq") {
|
|
454
|
+
child.consumeAttr("concurrent");
|
|
455
|
+
child.consumeAttr("nextAc");
|
|
456
|
+
}
|
|
457
|
+
subContainers.push(child);
|
|
458
|
+
} else if (child.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && supportedBehaviorNames.has(child.localName)) behaviorCursors.push(child);
|
|
459
|
+
else otherChildren.push(child);
|
|
460
|
+
if ((attrs.presetId !== void 0 || behaviorCursors.length > 0 || otherChildren.length > 0) && subContainers.length === 0) {
|
|
461
|
+
const behaviors = behaviorCursors.map(readBehaviorElement);
|
|
462
|
+
const targetIds = [...new Set(behaviors.flatMap((b) => b.targets.map((t) => t.spid)))];
|
|
463
|
+
let unsupportedBehavior;
|
|
464
|
+
if (otherChildren.length > 0) {
|
|
465
|
+
const firstUnsupported = otherChildren[0];
|
|
466
|
+
let unsupportedTargetId;
|
|
467
|
+
const innerTgt = firstUnsupported.child(P_NS, "cBhvr")?.child(P_NS, "tgtEl");
|
|
468
|
+
if (innerTgt !== void 0) unsupportedTargetId = consumeTargetElement(innerTgt)[0]?.spid;
|
|
469
|
+
unsupportedBehavior = {
|
|
470
|
+
namespaceUri: firstUnsupported.namespaceUri,
|
|
471
|
+
localName: firstUnsupported.localName,
|
|
472
|
+
xpath: firstUnsupported.xpath,
|
|
473
|
+
...unsupportedTargetId === void 0 ? {} : { targetId: unsupportedTargetId }
|
|
474
|
+
};
|
|
475
|
+
cursor.suppressUnconsumed();
|
|
476
|
+
}
|
|
477
|
+
const hasSetBehavior = behaviors.some((b) => b.localName === "set");
|
|
478
|
+
const firstRange = behaviors.flatMap((b) => b.targets).find((t) => !t.isBackground && t.range !== void 0)?.range;
|
|
479
|
+
rawNodesById.set(timingId, {
|
|
480
|
+
kind: "effect",
|
|
481
|
+
timingId,
|
|
482
|
+
xpath: cursor.xpath,
|
|
483
|
+
...parentTimingId === void 0 ? {} : { parentTimingId },
|
|
484
|
+
stepIndex,
|
|
485
|
+
...attrs.presetId === void 0 ? {} : { presetId: attrs.presetId },
|
|
486
|
+
...attrs.presetClass === void 0 ? {} : { presetClass: attrs.presetClass },
|
|
487
|
+
...attrs.presetSubtype === void 0 ? {} : { presetSubtype: attrs.presetSubtype },
|
|
488
|
+
...attrs.grpId === void 0 ? {} : { buildGroupId: attrs.grpId },
|
|
489
|
+
...attrs.repeatCount === void 0 ? {} : { repeatCount: attrs.repeatCount },
|
|
490
|
+
autoRev: attrs.autoRev,
|
|
491
|
+
...attrs.accel === void 0 ? {} : { accel: attrs.accel },
|
|
492
|
+
...attrs.decel === void 0 ? {} : { decel: attrs.decel },
|
|
493
|
+
delayMs,
|
|
494
|
+
dependsOn,
|
|
495
|
+
...iterateBy === void 0 ? {} : { iterateBy },
|
|
496
|
+
...iterateIntervalMs === void 0 ? {} : { iterateIntervalMs },
|
|
497
|
+
hasSetBehavior,
|
|
498
|
+
behaviors,
|
|
499
|
+
targetIds,
|
|
500
|
+
...firstRange === void 0 ? {} : { targetRange: firstRange },
|
|
501
|
+
...unsupportedBehavior === void 0 ? {} : { unsupportedBehavior },
|
|
502
|
+
cursor
|
|
503
|
+
});
|
|
504
|
+
return timingId;
|
|
505
|
+
}
|
|
506
|
+
const childIds = [];
|
|
507
|
+
for (const sub of subContainers) {
|
|
508
|
+
const childId = visitTimingNode(sub, timingId, stepIndex);
|
|
509
|
+
if (childId !== void 0) childIds.push(childId);
|
|
510
|
+
}
|
|
511
|
+
rawNodesById.set(timingId, {
|
|
512
|
+
kind: "container",
|
|
513
|
+
timingId,
|
|
514
|
+
containerKind: cursor.localName === "seq" ? "sequence" : "parallel",
|
|
515
|
+
xpath: cursor.xpath,
|
|
516
|
+
...parentTimingId === void 0 ? {} : { parentTimingId },
|
|
517
|
+
stepIndex,
|
|
518
|
+
endSyncAll,
|
|
519
|
+
delayMs,
|
|
520
|
+
dependsOn,
|
|
521
|
+
childIds,
|
|
522
|
+
cursor
|
|
523
|
+
});
|
|
524
|
+
return timingId;
|
|
525
|
+
};
|
|
526
|
+
const stepPars = mainSeqChildren.children(P_NS, "par");
|
|
527
|
+
for (let stepIndex = 0; stepIndex < stepPars.length; stepIndex += 1) {
|
|
528
|
+
const stepPar = stepPars[stepIndex];
|
|
529
|
+
const stepCTn = stepPar.child(P_NS, "cTn");
|
|
530
|
+
if (stepCTn === void 0) continue;
|
|
531
|
+
const stepAttrs = consumeCommonTimeNodeAttrs(stepCTn);
|
|
532
|
+
const trigger = consumeConditionList(stepCTn.child("http://schemas.openxmlformats.org/presentationml/2006/main", "stCondLst")).some((c) => c.kind === "onBegin") ? "auto" : "click";
|
|
533
|
+
const stepChildTnLst = stepCTn.child(P_NS, "childTnLst");
|
|
534
|
+
const rootChildIds = [];
|
|
535
|
+
if (stepChildTnLst !== void 0) {
|
|
536
|
+
for (const childCursor of stepChildTnLst.children(P_NS, "par")) {
|
|
537
|
+
const id = visitTimingNode(childCursor, stepAttrs.id, stepIndex);
|
|
538
|
+
if (id !== void 0) rootChildIds.push(id);
|
|
539
|
+
}
|
|
540
|
+
for (const childCursor of stepChildTnLst.children(P_NS, "seq")) {
|
|
541
|
+
childCursor.consumeAttr("concurrent");
|
|
542
|
+
childCursor.consumeAttr("nextAc");
|
|
543
|
+
const id = visitTimingNode(childCursor, stepAttrs.id, stepIndex);
|
|
544
|
+
if (id !== void 0) rootChildIds.push(id);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
stepInfos.push({
|
|
548
|
+
stepIndex,
|
|
549
|
+
trigger,
|
|
550
|
+
rootChildIds,
|
|
551
|
+
xpath: stepPar.xpath
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
const rootDiagnosticByNodeId = /* @__PURE__ */ new Map();
|
|
555
|
+
const omittedNodeIds = /* @__PURE__ */ new Set();
|
|
556
|
+
const isKnownSlideTarget = (spid) => context.placeholderKeyBySpid !== void 0 ? true : context.objectBySpid?.has(spid) === true;
|
|
557
|
+
for (const [timingId, rawNode] of rawNodesById) {
|
|
558
|
+
if (rawNode.kind !== "effect") continue;
|
|
559
|
+
if (rawNode.unsupportedBehavior !== void 0) {
|
|
560
|
+
const targetId = rawNode.unsupportedBehavior.targetId ?? rawNode.targetIds[0];
|
|
561
|
+
const diag = {
|
|
562
|
+
code: "unsupported-mechanism",
|
|
563
|
+
category: "unsupported",
|
|
564
|
+
disposition: "omitted",
|
|
565
|
+
location: locationFor(context, rawNode.unsupportedBehavior.xpath, targetId),
|
|
566
|
+
namespaceUri: rawNode.unsupportedBehavior.namespaceUri,
|
|
567
|
+
localName: rawNode.unsupportedBehavior.localName,
|
|
568
|
+
mechanismHint: `motion-behavior:${rawNode.unsupportedBehavior.localName}`
|
|
569
|
+
};
|
|
570
|
+
rootDiagnosticByNodeId.set(timingId, diag);
|
|
571
|
+
omittedNodeIds.add(timingId);
|
|
572
|
+
rawNode.cursor.suppressUnconsumed();
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if ((rawNode.presetId === void 0 ? void 0 : presetById[rawNode.presetId] ?? (rawNode.presetId === 0 && rawNode.behaviors.some((b) => b.localName === "animClr") && rawNode.autoRev ? "breathe" : void 0)) === void 0) {
|
|
576
|
+
const targetId = rawNode.targetIds[0];
|
|
577
|
+
const diag = {
|
|
578
|
+
code: "unsupported-mechanism",
|
|
579
|
+
category: "unsupported",
|
|
580
|
+
disposition: "omitted",
|
|
581
|
+
location: locationFor(context, rawNode.xpath, targetId),
|
|
582
|
+
namespaceUri: P_NS,
|
|
583
|
+
localName: "cTn",
|
|
584
|
+
mechanismHint: `motion-preset:${rawNode.presetClass ?? ""}#${String(rawNode.presetId ?? "")}`
|
|
585
|
+
};
|
|
586
|
+
rootDiagnosticByNodeId.set(timingId, diag);
|
|
587
|
+
omittedNodeIds.add(timingId);
|
|
588
|
+
rawNode.cursor.suppressUnconsumed();
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
const missingTargetId = rawNode.targetIds.find((id) => !isKnownSlideTarget(id));
|
|
592
|
+
if (rawNode.targetIds.length !== 1 || missingTargetId !== void 0) {
|
|
593
|
+
const omittedInfo = missingTargetId === void 0 ? void 0 : context.omittedSpids?.get(missingTargetId);
|
|
594
|
+
const diag = {
|
|
595
|
+
code: "unsupported-mechanism",
|
|
596
|
+
category: "unsupported",
|
|
597
|
+
disposition: "omitted",
|
|
598
|
+
location: locationFor(context, rawNode.xpath, missingTargetId, omittedInfo?.objectName),
|
|
599
|
+
namespaceUri: P_NS,
|
|
600
|
+
localName: "spTgt",
|
|
601
|
+
mechanismHint: omittedInfo === void 0 ? "missing-animation-target" : `omitted-target:${omittedInfo.reason}`
|
|
602
|
+
};
|
|
603
|
+
rootDiagnosticByNodeId.set(timingId, diag);
|
|
604
|
+
omittedNodeIds.add(timingId);
|
|
605
|
+
rawNode.cursor.suppressUnconsumed();
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const directDependentsOf = /* @__PURE__ */ new Map();
|
|
610
|
+
for (const [timingId, rawNode] of rawNodesById) for (const dep of rawNode.dependsOn) {
|
|
611
|
+
const list = directDependentsOf.get(dep.timingId) ?? [];
|
|
612
|
+
list.push(timingId);
|
|
613
|
+
directDependentsOf.set(dep.timingId, list);
|
|
614
|
+
}
|
|
615
|
+
const hasAnySurvivingEffect = (containerId) => {
|
|
616
|
+
const node = rawNodesById.get(containerId);
|
|
617
|
+
if (node === void 0) return false;
|
|
618
|
+
if (node.kind === "effect") return !omittedNodeIds.has(node.timingId);
|
|
619
|
+
return node.childIds.some((cid) => hasAnySurvivingEffect(cid));
|
|
620
|
+
};
|
|
621
|
+
const cascadedByRootDiag = /* @__PURE__ */ new Map();
|
|
622
|
+
const addCascadedToRoot = (rootId, dependentNode) => {
|
|
623
|
+
const list = cascadedByRootDiag.get(rootId) ?? [];
|
|
624
|
+
const targetId = dependentNode.kind === "effect" ? dependentNode.targetIds[0] : void 0;
|
|
625
|
+
list.push({
|
|
626
|
+
location: locationFor(context, dependentNode.xpath, targetId),
|
|
627
|
+
role: "animation-dependency"
|
|
628
|
+
});
|
|
629
|
+
cascadedByRootDiag.set(rootId, list);
|
|
630
|
+
};
|
|
631
|
+
for (const [rootId] of rootDiagnosticByNodeId) {
|
|
632
|
+
const queue = [rootId];
|
|
633
|
+
const visited = /* @__PURE__ */ new Set([rootId]);
|
|
634
|
+
while (queue.length > 0) {
|
|
635
|
+
const currentId = queue.shift();
|
|
636
|
+
const currentNode = rawNodesById.get(currentId);
|
|
637
|
+
if (currentNode?.parentTimingId !== void 0) {
|
|
638
|
+
const parentNode = rawNodesById.get(currentNode.parentTimingId);
|
|
639
|
+
if (parentNode?.kind === "container" && !omittedNodeIds.has(parentNode.timingId) && !hasAnySurvivingEffect(parentNode.timingId)) {
|
|
640
|
+
omittedNodeIds.add(parentNode.timingId);
|
|
641
|
+
if (!visited.has(parentNode.timingId)) {
|
|
642
|
+
visited.add(parentNode.timingId);
|
|
643
|
+
queue.push(parentNode.timingId);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
for (const dependentId of directDependentsOf.get(currentId) ?? []) {
|
|
648
|
+
if (visited.has(dependentId)) continue;
|
|
649
|
+
visited.add(dependentId);
|
|
650
|
+
const dependentNode = rawNodesById.get(dependentId);
|
|
651
|
+
if (dependentNode === void 0) continue;
|
|
652
|
+
omittedNodeIds.add(dependentId);
|
|
653
|
+
dependentNode.cursor.suppressUnconsumed();
|
|
654
|
+
if (dependentNode.kind === "effect") addCascadedToRoot(rootId, dependentNode);
|
|
655
|
+
queue.push(dependentId);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
for (const [rootId, diag] of rootDiagnosticByNodeId) {
|
|
660
|
+
const cascaded = cascadedByRootDiag.get(rootId);
|
|
661
|
+
if (cascaded !== void 0 && cascaded.length > 0) diagnostics.push({
|
|
662
|
+
...diag,
|
|
663
|
+
cascaded
|
|
664
|
+
});
|
|
665
|
+
else diagnostics.push(diag);
|
|
666
|
+
}
|
|
667
|
+
const survivingEffects = [];
|
|
668
|
+
const collectStepEffects = (nodeId, accumulatedDelayMs, inheritedStartAfter) => {
|
|
669
|
+
if (omittedNodeIds.has(nodeId)) return;
|
|
670
|
+
const node = rawNodesById.get(nodeId);
|
|
671
|
+
if (node === void 0) return;
|
|
672
|
+
const dep = node.dependsOn[0];
|
|
673
|
+
const effectiveDelayMs = dep !== void 0 ? dep.offsetMs : inheritedStartAfter !== void 0 ? inheritedStartAfter.offsetMs + node.delayMs : accumulatedDelayMs + node.delayMs;
|
|
674
|
+
const effectiveStartAfter = dep !== void 0 && !omittedNodeIds.has(dep.timingId) ? dep : inheritedStartAfter;
|
|
675
|
+
if (node.kind === "container") {
|
|
676
|
+
for (const childId of node.childIds) collectStepEffects(childId, effectiveStartAfter === void 0 ? effectiveDelayMs : 0, effectiveStartAfter);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const preset = node.presetId === void 0 ? void 0 : presetById[node.presetId] ?? (node.presetId === 0 && node.behaviors.some((b) => b.localName === "animClr") && node.autoRev ? "breathe" : void 0);
|
|
680
|
+
if (preset === void 0 || node.targetIds.length !== 1) return;
|
|
681
|
+
const targetId = node.targetIds[0];
|
|
682
|
+
const kind = node.presetClass === "emph" ? "emphasis" : "entrance";
|
|
683
|
+
const nonSetDurations = node.behaviors.filter((b) => b.localName !== "set").map((b) => b.durationMs).filter((d) => d !== void 0);
|
|
684
|
+
const traversalDurationMs = nonSetDurations.length > 0 ? Math.max(...nonSetDurations) : 500;
|
|
685
|
+
const durationMs = preset === "breathe" ? traversalDurationMs * 2 : traversalDurationMs;
|
|
686
|
+
const easing = node.accel !== void 0 && node.accel !== 0 || node.decel !== void 0 && node.decel !== 0 ? {
|
|
687
|
+
...node.accel !== void 0 && node.accel !== 0 ? { accelerate: node.accel / 1e5 } : {},
|
|
688
|
+
...node.decel !== void 0 && node.decel !== 0 ? { decelerate: node.decel / 1e5 } : {}
|
|
689
|
+
} : void 0;
|
|
690
|
+
let from;
|
|
691
|
+
if (preset === "wipe" || preset === "fly") from = node.presetSubtype === void 0 ? void 0 : directionBySubtype[node.presetSubtype];
|
|
692
|
+
let by = node.iterateBy;
|
|
693
|
+
if (preset === "spin") {
|
|
694
|
+
const rotBehavior = node.behaviors.find((b) => b.localName === "animRot");
|
|
695
|
+
if (rotBehavior?.rotationBy !== void 0) by = rotBehavior.rotationBy / 6e4;
|
|
696
|
+
else if (rotBehavior?.rotationFrom !== void 0) from = rotBehavior.rotationFrom / 6e4;
|
|
697
|
+
}
|
|
698
|
+
const clrBehavior = node.behaviors.find((b) => b.localName === "animClr");
|
|
699
|
+
const fromColor = clrBehavior?.fromColor;
|
|
700
|
+
const toColor = clrBehavior?.toColor;
|
|
701
|
+
if (!node.hasSetBehavior && kind === "entrance" && node.targetRange?.type === "paragraph" && (node.buildGroupId ?? 0) === 0) return;
|
|
702
|
+
const built = buildEffectDeclaration({
|
|
703
|
+
preset,
|
|
704
|
+
kind,
|
|
705
|
+
durationMs,
|
|
706
|
+
delayMs: effectiveDelayMs,
|
|
707
|
+
...from === void 0 ? {} : { from },
|
|
708
|
+
...fromColor === void 0 ? {} : { fromColor },
|
|
709
|
+
...toColor === void 0 ? {} : { toColor },
|
|
710
|
+
...easing === void 0 ? {} : { easing },
|
|
711
|
+
...by === void 0 ? {} : { by },
|
|
712
|
+
...node.iterateIntervalMs === void 0 ? {} : { intervalMs: node.iterateIntervalMs },
|
|
713
|
+
...node.repeatCount === void 0 ? {} : { repeatCount: node.repeatCount }
|
|
714
|
+
});
|
|
715
|
+
survivingEffects.push({
|
|
716
|
+
effect: built.effect,
|
|
717
|
+
declaration: built.declaration,
|
|
718
|
+
targetId,
|
|
719
|
+
...node.targetRange === void 0 ? {} : { targetRange: node.targetRange },
|
|
720
|
+
...node.buildGroupId === void 0 ? {} : { buildGroupId: node.buildGroupId },
|
|
721
|
+
stepIndex: node.stepIndex,
|
|
722
|
+
...node.parentTimingId === void 0 ? {} : { parentTimingId: node.parentTimingId },
|
|
723
|
+
timingId: node.timingId,
|
|
724
|
+
effectiveDelayMs,
|
|
725
|
+
...effectiveStartAfter === void 0 ? {} : {
|
|
726
|
+
startAfterTimingId: effectiveStartAfter.timingId,
|
|
727
|
+
startAfterOffsetMs: effectiveStartAfter.offsetMs
|
|
728
|
+
},
|
|
729
|
+
...easing === void 0 ? {} : { easing },
|
|
730
|
+
...node.repeatCount === void 0 ? {} : { repeatCount: node.repeatCount },
|
|
731
|
+
...from === void 0 ? {} : { from },
|
|
732
|
+
...by === void 0 ? {} : { by },
|
|
733
|
+
...node.iterateIntervalMs === void 0 ? {} : { intervalMs: node.iterateIntervalMs },
|
|
734
|
+
...fromColor === void 0 ? {} : { fromColor },
|
|
735
|
+
...toColor === void 0 ? {} : { toColor }
|
|
736
|
+
});
|
|
737
|
+
};
|
|
738
|
+
for (const step of stepInfos) for (const rootId of step.rootChildIds) collectStepEffects(rootId, 0, void 0);
|
|
739
|
+
if (context.placeholderKeyBySpid !== void 0) {
|
|
740
|
+
const ownerSteps = [];
|
|
741
|
+
for (const stepInfo of stepInfos) {
|
|
742
|
+
const stepEffects = survivingEffects.filter((eff) => eff.stepIndex === stepInfo.stepIndex);
|
|
743
|
+
if (stepEffects.length === 0) continue;
|
|
744
|
+
const mappedEffects = stepEffects.map((eff) => {
|
|
745
|
+
const placeholderKey = context.placeholderKeyBySpid?.get(eff.targetId);
|
|
746
|
+
return {
|
|
747
|
+
target: placeholderKey !== void 0 ? { placeholder: placeholderKey } : { spid: eff.targetId },
|
|
748
|
+
effect: eff.declaration,
|
|
749
|
+
...eff.targetRange === void 0 ? {} : { range: eff.targetRange }
|
|
750
|
+
};
|
|
751
|
+
});
|
|
752
|
+
ownerSteps.push({
|
|
753
|
+
trigger: stepInfo.trigger,
|
|
754
|
+
effects: mappedEffects
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
if (ownerSteps.length > 0) {
|
|
758
|
+
const motion = { steps: ownerSteps };
|
|
759
|
+
context.slideNode.set({ motion });
|
|
760
|
+
}
|
|
761
|
+
return diagnostics.length === 0 ? {} : { diagnostics };
|
|
762
|
+
}
|
|
763
|
+
const collapsedEffects = [];
|
|
764
|
+
const consumedIndices = /* @__PURE__ */ new Set();
|
|
765
|
+
for (let i = 0; i < survivingEffects.length; i += 1) {
|
|
766
|
+
if (consumedIndices.has(i)) continue;
|
|
767
|
+
const head = survivingEffects[i];
|
|
768
|
+
if (head.targetRange?.type === "paragraph" && head.buildGroupId === 1) {
|
|
769
|
+
consumedIndices.add(i);
|
|
770
|
+
const { targetRange: _omittedRange, ...rest } = head;
|
|
771
|
+
collapsedEffects.push(rest);
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
if (head.targetRange?.type === "chart") {
|
|
775
|
+
const chartBuild = chartBuilds.get(`${head.targetId}:${head.buildGroupId ?? 0}`);
|
|
776
|
+
const groupIndices = [i];
|
|
777
|
+
for (let j = i + 1; j < survivingEffects.length; j += 1) {
|
|
778
|
+
if (consumedIndices.has(j)) continue;
|
|
779
|
+
const cand = survivingEffects[j];
|
|
780
|
+
if (cand.targetRange?.type === "chart" && cand.stepIndex === head.stepIndex && commonEffectPropsMatch(head, cand) && cand.startAfterTimingId === head.startAfterTimingId && cand.startAfterOffsetMs === head.startAfterOffsetMs) groupIndices.push(j);
|
|
781
|
+
}
|
|
782
|
+
const mappedBy = chartBuild?.mode === "series" ? "series" : chartBuild?.mode === "category" ? "category" : chartBuild?.mode === "seriesEl" ? "seriesElements" : chartBuild?.mode === "categoryEl" ? "categoryElements" : head.targetRange.step === "series" ? "series" : head.targetRange.step === "category" ? "category" : head.targetRange.step === "ptInSeries" ? "seriesElements" : head.targetRange.step === "ptInCategory" ? "categoryElements" : void 0;
|
|
783
|
+
for (const idx of groupIndices) consumedIndices.add(idx);
|
|
784
|
+
const baseDelay = Math.min(...groupIndices.map((idx) => survivingEffects[idx].effectiveDelayMs));
|
|
785
|
+
const rebuilt = buildEffectDeclaration({
|
|
786
|
+
preset: head.effect.preset,
|
|
787
|
+
kind: head.effect.kind,
|
|
788
|
+
durationMs: head.effect.duration,
|
|
789
|
+
delayMs: baseDelay,
|
|
790
|
+
...head.from === void 0 ? {} : { from: head.from },
|
|
791
|
+
...head.fromColor === void 0 ? {} : { fromColor: head.fromColor },
|
|
792
|
+
...head.toColor === void 0 ? {} : { toColor: head.toColor },
|
|
793
|
+
...head.easing === void 0 ? {} : { easing: head.easing },
|
|
794
|
+
...mappedBy === void 0 ? {} : { by: mappedBy },
|
|
795
|
+
...head.repeatCount === void 0 ? {} : { repeatCount: head.repeatCount }
|
|
796
|
+
});
|
|
797
|
+
const { targetRange: _omittedRange, ...headRest } = head;
|
|
798
|
+
collapsedEffects.push({
|
|
799
|
+
...headRest,
|
|
800
|
+
effectiveDelayMs: baseDelay,
|
|
801
|
+
...mappedBy === void 0 ? {} : { by: mappedBy },
|
|
802
|
+
effect: rebuilt.effect,
|
|
803
|
+
declaration: rebuilt.declaration
|
|
804
|
+
});
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
if (head.targetRange?.type === "paragraph" && (head.buildGroupId ?? 0) === 0) {
|
|
808
|
+
if (paragraphBuilds.get(`${head.targetId}:0`)?.build === "p") {
|
|
809
|
+
const groupIndices = [i];
|
|
810
|
+
let expectedNextStart = head.targetRange.end + 1;
|
|
811
|
+
for (let j = i + 1; j < survivingEffects.length; j += 1) {
|
|
812
|
+
if (consumedIndices.has(j)) continue;
|
|
813
|
+
const cand = survivingEffects[j];
|
|
814
|
+
if (cand.targetRange?.type === "paragraph" && cand.targetRange.start === expectedNextStart && cand.stepIndex === head.stepIndex && commonEffectPropsMatch(head, cand) && cand.startAfterTimingId === head.startAfterTimingId && cand.startAfterOffsetMs === head.startAfterOffsetMs) {
|
|
815
|
+
groupIndices.push(j);
|
|
816
|
+
expectedNextStart = cand.targetRange.end + 1;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
for (const idx of groupIndices) consumedIndices.add(idx);
|
|
820
|
+
const baseDelay = Math.min(...groupIndices.map((idx) => survivingEffects[idx].effectiveDelayMs));
|
|
821
|
+
const rebuilt = buildEffectDeclaration({
|
|
822
|
+
preset: head.effect.preset,
|
|
823
|
+
kind: head.effect.kind,
|
|
824
|
+
durationMs: head.effect.duration,
|
|
825
|
+
delayMs: baseDelay,
|
|
826
|
+
...head.from === void 0 ? {} : { from: head.from },
|
|
827
|
+
...head.fromColor === void 0 ? {} : { fromColor: head.fromColor },
|
|
828
|
+
...head.toColor === void 0 ? {} : { toColor: head.toColor },
|
|
829
|
+
...head.easing === void 0 ? {} : { easing: head.easing },
|
|
830
|
+
by: "paragraph",
|
|
831
|
+
...head.repeatCount === void 0 ? {} : { repeatCount: head.repeatCount }
|
|
832
|
+
});
|
|
833
|
+
const { targetRange: _omittedRange, ...headRest } = head;
|
|
834
|
+
collapsedEffects.push({
|
|
835
|
+
...headRest,
|
|
836
|
+
effectiveDelayMs: baseDelay,
|
|
837
|
+
by: "paragraph",
|
|
838
|
+
effect: rebuilt.effect,
|
|
839
|
+
declaration: rebuilt.declaration
|
|
840
|
+
});
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
consumedIndices.add(i);
|
|
845
|
+
collapsedEffects.push(head);
|
|
846
|
+
}
|
|
847
|
+
const objectBySpid = context.objectBySpid;
|
|
848
|
+
const slideContainer = context.slideNode;
|
|
849
|
+
if (objectBySpid === void 0 || !(slideContainer instanceof CommonContainer)) return diagnostics.length === 0 ? {} : { diagnostics };
|
|
850
|
+
const topLevelOwnerByNode = /* @__PURE__ */ new Map();
|
|
851
|
+
const registerTopLevelOwner = (node, topLevel) => {
|
|
852
|
+
topLevelOwnerByNode.set(node, topLevel);
|
|
853
|
+
for (const child of node.children) if (child instanceof CommonNode) registerTopLevelOwner(child, topLevel);
|
|
854
|
+
};
|
|
855
|
+
for (const child of context.slideNode.children) if (child instanceof CommonNode) registerTopLevelOwner(child, child);
|
|
856
|
+
const spidsByNode = /* @__PURE__ */ new Map();
|
|
857
|
+
for (const [spid, node] of objectBySpid) spidsByNode.set(node, spid);
|
|
858
|
+
const collectGroupLeaves = (groupNode) => {
|
|
859
|
+
const leaves = [];
|
|
860
|
+
for (const member of groupNode.children) {
|
|
861
|
+
if (!(member instanceof CommonNode)) continue;
|
|
862
|
+
if (member.kind === "group") leaves.push(...collectGroupLeaves(member));
|
|
863
|
+
else leaves.push(member);
|
|
864
|
+
}
|
|
865
|
+
return leaves;
|
|
866
|
+
};
|
|
867
|
+
const liftedCollapsed = [];
|
|
868
|
+
const spinConsumed = /* @__PURE__ */ new Set();
|
|
869
|
+
const findAllGroups = (nodes) => {
|
|
870
|
+
const groups = [];
|
|
871
|
+
for (const n of nodes) if (n instanceof CommonNode && n.kind === "group") {
|
|
872
|
+
groups.push(n);
|
|
873
|
+
groups.push(...findAllGroups(n.children));
|
|
874
|
+
}
|
|
875
|
+
return groups;
|
|
876
|
+
};
|
|
877
|
+
for (const groupNode of findAllGroups(context.slideNode.children)) {
|
|
878
|
+
const groupSpid = spidsByNode.get(groupNode);
|
|
879
|
+
if (groupSpid === void 0) continue;
|
|
880
|
+
const leaves = collectGroupLeaves(groupNode);
|
|
881
|
+
if (leaves.length === 0) continue;
|
|
882
|
+
const leafSpids = leaves.map((leaf) => spidsByNode.get(leaf)).filter((id) => id !== void 0);
|
|
883
|
+
if (leafSpids.length !== leaves.length) continue;
|
|
884
|
+
for (let idx = 0; idx < collapsedEffects.length; idx += 1) {
|
|
885
|
+
if (spinConsumed.has(idx)) continue;
|
|
886
|
+
const candidate = collapsedEffects[idx];
|
|
887
|
+
if (candidate.effect.preset !== "spin" || candidate.targetId !== leafSpids[0]) continue;
|
|
888
|
+
const matchedLeafIndices = [idx];
|
|
889
|
+
for (const leafSpid of leafSpids.slice(1)) {
|
|
890
|
+
const matchIdx = collapsedEffects.findIndex((other, otherIdx) => !spinConsumed.has(otherIdx) && other.effect.preset === "spin" && other.targetId === leafSpid && other.stepIndex === candidate.stepIndex && other.effectiveDelayMs === candidate.effectiveDelayMs && other.effect.duration === candidate.effect.duration && other.by === candidate.by && other.from === candidate.from && other.startAfterTimingId === candidate.startAfterTimingId && other.startAfterOffsetMs === candidate.startAfterOffsetMs);
|
|
891
|
+
if (matchIdx >= 0) matchedLeafIndices.push(matchIdx);
|
|
892
|
+
}
|
|
893
|
+
if (matchedLeafIndices.length === leafSpids.length) {
|
|
894
|
+
for (const m of matchedLeafIndices) spinConsumed.add(m);
|
|
895
|
+
liftedCollapsed.push({
|
|
896
|
+
...candidate,
|
|
897
|
+
targetId: groupSpid
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
for (let i = 0; i < collapsedEffects.length; i += 1) if (!spinConsumed.has(i)) liftedCollapsed.push(collapsedEffects[i]);
|
|
903
|
+
const effectsByNode = /* @__PURE__ */ new Map();
|
|
904
|
+
for (const eff of liftedCollapsed) {
|
|
905
|
+
const targetNode = objectBySpid.get(eff.targetId);
|
|
906
|
+
if (targetNode === void 0) continue;
|
|
907
|
+
const list = effectsByNode.get(targetNode) ?? [];
|
|
908
|
+
list.push(eff);
|
|
909
|
+
effectsByNode.set(targetNode, list);
|
|
910
|
+
}
|
|
911
|
+
for (const [targetNode, list] of effectsByNode) {
|
|
912
|
+
const enters = list.filter((e) => e.effect.kind === "entrance").map((e) => e.declaration);
|
|
913
|
+
const emphases = list.filter((e) => e.effect.kind === "emphasis").map((e) => e.declaration);
|
|
914
|
+
const patch = {};
|
|
915
|
+
if (enters.length === 1) patch.enter = enters[0];
|
|
916
|
+
else if (enters.length > 1) patch.enter = enters;
|
|
917
|
+
if (emphases.length >= 1) patch.emphasis = emphases[0];
|
|
918
|
+
if (patch.enter !== void 0 || patch.emphasis !== void 0) targetNode.set(patch);
|
|
919
|
+
}
|
|
920
|
+
const clickNumberByStepIndex = /* @__PURE__ */ new Map();
|
|
921
|
+
let nextClickNumber = 1;
|
|
922
|
+
for (const info of stepInfos) if (info.trigger === "click") {
|
|
923
|
+
if (liftedCollapsed.some((e) => e.stepIndex === info.stepIndex)) clickNumberByStepIndex.set(info.stepIndex, nextClickNumber++);
|
|
924
|
+
}
|
|
925
|
+
const referencedTimingIds = /* @__PURE__ */ new Set();
|
|
926
|
+
for (const eff of liftedCollapsed) if (eff.startAfterTimingId !== void 0 && !omittedNodeIds.has(eff.startAfterTimingId)) referencedTimingIds.add(eff.startAfterTimingId);
|
|
927
|
+
const handleByTimingId = /* @__PURE__ */ new Map();
|
|
928
|
+
for (const tid of referencedTimingIds) handleByTimingId.set(tid, createMotionScopeHandle());
|
|
929
|
+
const ancestorsOfTimingId = (timingId) => {
|
|
930
|
+
const chain = [];
|
|
931
|
+
let current = timingId;
|
|
932
|
+
while (current !== void 0) {
|
|
933
|
+
if (handleByTimingId.has(current)) chain.unshift(current);
|
|
934
|
+
current = rawNodesById.get(current)?.parentTimingId;
|
|
935
|
+
}
|
|
936
|
+
return chain;
|
|
937
|
+
};
|
|
938
|
+
const assignmentByTopLevel = /* @__PURE__ */ new Map();
|
|
939
|
+
for (const eff of liftedCollapsed) {
|
|
940
|
+
const targetNode = objectBySpid.get(eff.targetId);
|
|
941
|
+
if (targetNode === void 0) continue;
|
|
942
|
+
const topLevelNode = topLevelOwnerByNode.get(targetNode) ?? targetNode;
|
|
943
|
+
if (assignmentByTopLevel.has(topLevelNode)) continue;
|
|
944
|
+
const clickStep = clickNumberByStepIndex.get(eff.stepIndex);
|
|
945
|
+
const sourceScopeIds = ancestorsOfTimingId(eff.timingId);
|
|
946
|
+
let startAfter;
|
|
947
|
+
if (eff.startAfterTimingId !== void 0) {
|
|
948
|
+
const sourceHandle = handleByTimingId.get(eff.startAfterTimingId);
|
|
949
|
+
if (sourceHandle !== void 0) {
|
|
950
|
+
const offset = eff.startAfterOffsetMs ?? 0;
|
|
951
|
+
startAfter = offset > 0 ? after(sourceHandle.end, offset) : sourceHandle.end;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
assignmentByTopLevel.set(topLevelNode, {
|
|
955
|
+
...clickStep === void 0 ? {} : { clickStep },
|
|
956
|
+
sourceScopeIds,
|
|
957
|
+
...startAfter === void 0 ? {} : { startAfter }
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
const originalChildren = [...context.slideNode.children];
|
|
961
|
+
const anyMotionScopesNeeded = referencedTimingIds.size > 0;
|
|
962
|
+
const indexByChild = /* @__PURE__ */ new Map();
|
|
963
|
+
let childOrd = 0;
|
|
964
|
+
for (const child of originalChildren) if (child instanceof CommonNode) indexByChild.set(child, childOrd++);
|
|
965
|
+
let needsScopeReordering = false;
|
|
966
|
+
if (anyMotionScopesNeeded) for (const scopeTimingId of referencedTimingIds) {
|
|
967
|
+
const indices = originalChildren.filter((c) => c instanceof CommonNode).filter((c) => assignmentByTopLevel.get(c)?.sourceScopeIds.includes(scopeTimingId)).map((c) => indexByChild.get(c)).sort((a, b) => a - b);
|
|
968
|
+
if (indices.length > 1 && indices[indices.length - 1] - indices[0] + 1 !== indices.length) needsScopeReordering = true;
|
|
969
|
+
}
|
|
970
|
+
if (needsScopeReordering) for (const [node, ord] of indexByChild) node.style({ zIndex: ord });
|
|
971
|
+
if (assignmentByTopLevel.size === 0) return diagnostics.length === 0 ? {} : { diagnostics };
|
|
972
|
+
for (const child of originalChildren) if (child instanceof CommonNode || child instanceof CommonContainer) child.remove();
|
|
973
|
+
const orderedNodes = [...originalChildren].filter((c) => c instanceof CommonNode);
|
|
974
|
+
if (needsScopeReordering) {
|
|
975
|
+
const earliestForScope = /* @__PURE__ */ new Map();
|
|
976
|
+
for (const tid of referencedTimingIds) {
|
|
977
|
+
const minOrd = Math.min(...orderedNodes.filter((n) => assignmentByTopLevel.get(n)?.sourceScopeIds.includes(tid)).map((n) => indexByChild.get(n)));
|
|
978
|
+
earliestForScope.set(tid, minOrd);
|
|
979
|
+
}
|
|
980
|
+
orderedNodes.sort((left, right) => {
|
|
981
|
+
const leftAssign = assignmentByTopLevel.get(left);
|
|
982
|
+
const rightAssign = assignmentByTopLevel.get(right);
|
|
983
|
+
return (leftAssign?.sourceScopeIds[0] !== void 0 ? earliestForScope.get(leftAssign.sourceScopeIds[0]) ?? indexByChild.get(left) : indexByChild.get(left)) - (rightAssign?.sourceScopeIds[0] !== void 0 ? earliestForScope.get(rightAssign.sourceScopeIds[0]) ?? indexByChild.get(right) : indexByChild.get(right)) || indexByChild.get(left) - indexByChild.get(right);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
const createdScopeHosts = /* @__PURE__ */ new Map();
|
|
987
|
+
for (const node of orderedNodes) {
|
|
988
|
+
const assign = assignmentByTopLevel.get(node);
|
|
989
|
+
if (assign === void 0) {
|
|
990
|
+
slideContainer.append(node);
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
let wrapped = node;
|
|
994
|
+
if (assign.startAfter !== void 0) {
|
|
995
|
+
const consumerHandle = createMotionScopeHandle();
|
|
996
|
+
const consumerScope = createMotionScopeNode({
|
|
997
|
+
scope: consumerHandle,
|
|
998
|
+
startAt: assign.startAfter
|
|
999
|
+
});
|
|
1000
|
+
consumerScope.append(wrapped);
|
|
1001
|
+
wrapped = consumerScope;
|
|
1002
|
+
}
|
|
1003
|
+
let appendedToExistingHost = false;
|
|
1004
|
+
for (const scopeId of [...assign.sourceScopeIds].reverse()) {
|
|
1005
|
+
const existingHost = createdScopeHosts.get(scopeId);
|
|
1006
|
+
if (existingHost !== void 0) {
|
|
1007
|
+
existingHost.append(wrapped);
|
|
1008
|
+
appendedToExistingHost = true;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
const handle = handleByTimingId.get(scopeId);
|
|
1012
|
+
const scopeHost = createMotionScopeNode({ scope: handle });
|
|
1013
|
+
scopeHost.append(wrapped);
|
|
1014
|
+
createdScopeHosts.set(scopeId, scopeHost);
|
|
1015
|
+
wrapped = scopeHost;
|
|
1016
|
+
}
|
|
1017
|
+
if (appendedToExistingHost) continue;
|
|
1018
|
+
if (assign.clickStep !== void 0) {
|
|
1019
|
+
const lastChild = slideContainer.children.at(-1);
|
|
1020
|
+
if (lastChild instanceof CommonContainer && lastChild.kind === "motion-step" && lastChild.props["n"] === assign.clickStep) lastChild.append(wrapped);
|
|
1021
|
+
else {
|
|
1022
|
+
const stepHost = createMotionStepNode({
|
|
1023
|
+
n: assign.clickStep,
|
|
1024
|
+
stepIdentity: createMotionStepIdentity()
|
|
1025
|
+
});
|
|
1026
|
+
stepHost.append(wrapped);
|
|
1027
|
+
slideContainer.append(stepHost);
|
|
1028
|
+
}
|
|
1029
|
+
} else slideContainer.append(wrapped);
|
|
1030
|
+
}
|
|
1031
|
+
return diagnostics.length === 0 ? {} : { diagnostics };
|
|
1032
|
+
}
|
|
1033
|
+
export { readSlideMotionImport };
|