@officedk/pptxdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { footerPlaceholderStyleSchema, slideBackgroundSchema, slideStyleSchema, xml10StringSchema } from "./author-schemas.js";
|
|
2
|
+
import { BuildError, zodIssueToBuildDiagnostic } from "./diagnostics.js";
|
|
3
|
+
import { snapshotValue } from "./input-values.js";
|
|
4
|
+
import { masterPlaceholderMapSchema, masterTextStylesSchema, placeholderMapSchema, placeholderRoleSchema, placeholderSizeSchema } from "./placeholders.js";
|
|
5
|
+
import { colorMapOverrideSchema, colorMapSchema, themeOverrideSchema } from "./theme.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ../core/dist/masters.js
|
|
8
|
+
const rawHeaderFooterSchema = z.strictObject({
|
|
9
|
+
dateTime: z.boolean().optional(),
|
|
10
|
+
footer: z.boolean().optional(),
|
|
11
|
+
header: z.boolean().optional(),
|
|
12
|
+
slideNumber: z.boolean().optional()
|
|
13
|
+
}).readonly();
|
|
14
|
+
/** OOXML `<p:hf>` header/footer visibility flags on SlideMaster and SlideLayout (ECMA-376 §19.3.1.24). */
|
|
15
|
+
const headerFooterSchema = rawHeaderFooterSchema;
|
|
16
|
+
const rawFooterPlaceholderSpecSchema = z.strictObject({
|
|
17
|
+
idx: z.number().int().nonnegative().optional(),
|
|
18
|
+
size: placeholderSizeSchema.optional(),
|
|
19
|
+
text: xml10StringSchema.optional(),
|
|
20
|
+
style: footerPlaceholderStyleSchema.optional(),
|
|
21
|
+
visible: z.boolean().optional()
|
|
22
|
+
}).readonly();
|
|
23
|
+
/** Geometry, placeholder metadata, and default text/style for a `dt`, `ftr`, or `sldNum` slot. */
|
|
24
|
+
const footerPlaceholderSpecSchema = rawFooterPlaceholderSpecSchema;
|
|
25
|
+
const rawFooterPlaceholdersSchema = z.strictObject({
|
|
26
|
+
dateTime: rawFooterPlaceholderSpecSchema.optional(),
|
|
27
|
+
footer: rawFooterPlaceholderSpecSchema.optional(),
|
|
28
|
+
slideNumber: rawFooterPlaceholderSpecSchema.optional()
|
|
29
|
+
}).readonly();
|
|
30
|
+
/** Collection of date, footer, and slide-number metadata placeholder definitions on a master or layout. */
|
|
31
|
+
const footerPlaceholdersSchema = rawFooterPlaceholdersSchema;
|
|
32
|
+
/** Official OOXML ST_SlideLayoutType enumeration values (ECMA-376 §19.7.15). */
|
|
33
|
+
const slideLayoutTypeValues = [
|
|
34
|
+
"title",
|
|
35
|
+
"tx",
|
|
36
|
+
"twoColTx",
|
|
37
|
+
"tbl",
|
|
38
|
+
"txAndChart",
|
|
39
|
+
"chartAndTx",
|
|
40
|
+
"dgm",
|
|
41
|
+
"chart",
|
|
42
|
+
"txAndClipArt",
|
|
43
|
+
"clipArtAndTx",
|
|
44
|
+
"titleOnly",
|
|
45
|
+
"blank",
|
|
46
|
+
"txAndObj",
|
|
47
|
+
"objAndTx",
|
|
48
|
+
"objOnly",
|
|
49
|
+
"obj",
|
|
50
|
+
"txAndMedia",
|
|
51
|
+
"mediaAndTx",
|
|
52
|
+
"objOverTx",
|
|
53
|
+
"txOverObj",
|
|
54
|
+
"txAndTwoObj",
|
|
55
|
+
"twoObjAndTx",
|
|
56
|
+
"twoObjOverTx",
|
|
57
|
+
"fourObj",
|
|
58
|
+
"vertTx",
|
|
59
|
+
"clipArtAndVertTx",
|
|
60
|
+
"vertTitleAndTx",
|
|
61
|
+
"vertTitleAndTxOverChart",
|
|
62
|
+
"twoObj",
|
|
63
|
+
"objAndTwoObj",
|
|
64
|
+
"twoObjAndObj",
|
|
65
|
+
"cust",
|
|
66
|
+
"secHead",
|
|
67
|
+
"twoTxTwoObj",
|
|
68
|
+
"objTx",
|
|
69
|
+
"picTx"
|
|
70
|
+
];
|
|
71
|
+
const rawSlideLayoutTypeSchema = z.enum(slideLayoutTypeValues);
|
|
72
|
+
const slideLayoutTypeSchema = rawSlideLayoutTypeSchema;
|
|
73
|
+
const slideMasterDataPropsSchema = z.strictObject({
|
|
74
|
+
id: z.string().trim().min(1).optional(),
|
|
75
|
+
name: z.string().optional(),
|
|
76
|
+
preserve: z.boolean().optional(),
|
|
77
|
+
placeholders: masterPlaceholderMapSchema.optional(),
|
|
78
|
+
textStyles: masterTextStylesSchema.optional(),
|
|
79
|
+
colorMap: colorMapSchema.optional(),
|
|
80
|
+
style: slideStyleSchema.optional(),
|
|
81
|
+
background: slideBackgroundSchema.optional(),
|
|
82
|
+
headerFooter: rawHeaderFooterSchema.optional(),
|
|
83
|
+
footerPlaceholders: rawFooterPlaceholdersSchema.optional(),
|
|
84
|
+
transition: z.unknown().optional(),
|
|
85
|
+
advanceAfter: z.number().optional(),
|
|
86
|
+
motion: z.unknown().optional()
|
|
87
|
+
}).readonly();
|
|
88
|
+
const slideLayoutDataPropsSchema = z.strictObject({
|
|
89
|
+
id: z.string().trim().min(1).optional(),
|
|
90
|
+
name: z.string().optional(),
|
|
91
|
+
type: rawSlideLayoutTypeSchema.optional(),
|
|
92
|
+
preserve: z.boolean().optional(),
|
|
93
|
+
matchingName: z.string().optional(),
|
|
94
|
+
userDrawn: z.boolean().optional(),
|
|
95
|
+
showMasterShapes: z.boolean().optional(),
|
|
96
|
+
showMasterPlaceholderAnimations: z.boolean().optional(),
|
|
97
|
+
placeholders: placeholderMapSchema.optional(),
|
|
98
|
+
colorMapOverride: colorMapOverrideSchema.optional(),
|
|
99
|
+
themeOverride: themeOverrideSchema.optional(),
|
|
100
|
+
style: slideStyleSchema.optional(),
|
|
101
|
+
background: slideBackgroundSchema.optional(),
|
|
102
|
+
headerFooter: rawHeaderFooterSchema.optional(),
|
|
103
|
+
footerPlaceholders: rawFooterPlaceholdersSchema.optional(),
|
|
104
|
+
transition: z.unknown().optional(),
|
|
105
|
+
advanceAfter: z.number().optional(),
|
|
106
|
+
motion: z.unknown().optional()
|
|
107
|
+
}).readonly();
|
|
108
|
+
const rectObservationSchema = z.object({
|
|
109
|
+
x: z.number(),
|
|
110
|
+
y: z.number(),
|
|
111
|
+
width: z.number(),
|
|
112
|
+
height: z.number()
|
|
113
|
+
}).readonly();
|
|
114
|
+
const rawResolvedPlaceholderSchema = z.object({
|
|
115
|
+
key: z.string().min(1),
|
|
116
|
+
type: placeholderRoleSchema,
|
|
117
|
+
idx: z.number().int().nonnegative().optional(),
|
|
118
|
+
size: placeholderSizeSchema.optional(),
|
|
119
|
+
box: rectObservationSchema.optional(),
|
|
120
|
+
style: z.record(z.string(), z.unknown()).readonly().optional()
|
|
121
|
+
}).readonly();
|
|
122
|
+
const resolvedPlaceholderSchema = rawResolvedPlaceholderSchema;
|
|
123
|
+
const rawResolvedSlideLayoutSchema = z.object({
|
|
124
|
+
id: z.string().min(1),
|
|
125
|
+
name: z.string().optional(),
|
|
126
|
+
type: rawSlideLayoutTypeSchema.optional(),
|
|
127
|
+
preserve: z.boolean().optional(),
|
|
128
|
+
matchingName: z.string().optional(),
|
|
129
|
+
userDrawn: z.boolean().optional(),
|
|
130
|
+
showMasterShapes: z.boolean().optional(),
|
|
131
|
+
showMasterPlaceholderAnimations: z.boolean().optional(),
|
|
132
|
+
colorMapOverride: colorMapOverrideSchema.optional(),
|
|
133
|
+
themeOverride: themeOverrideSchema.optional(),
|
|
134
|
+
style: slideStyleSchema.optional(),
|
|
135
|
+
background: slideBackgroundSchema.optional(),
|
|
136
|
+
headerFooter: rawHeaderFooterSchema.optional(),
|
|
137
|
+
objects: z.array(z.custom()).readonly(),
|
|
138
|
+
placeholders: z.array(rawResolvedPlaceholderSchema).readonly(),
|
|
139
|
+
capabilities: z.record(z.string(), z.unknown()).readonly().optional()
|
|
140
|
+
}).readonly();
|
|
141
|
+
const resolvedSlideLayoutSchema = rawResolvedSlideLayoutSchema;
|
|
142
|
+
const resolvedMasterSchema = z.object({
|
|
143
|
+
id: z.string().min(1),
|
|
144
|
+
name: z.string().optional(),
|
|
145
|
+
preserve: z.boolean().optional(),
|
|
146
|
+
colorMap: colorMapSchema.optional(),
|
|
147
|
+
headerFooter: rawHeaderFooterSchema.optional(),
|
|
148
|
+
objects: z.array(z.custom()).readonly(),
|
|
149
|
+
placeholders: z.array(rawResolvedPlaceholderSchema).readonly(),
|
|
150
|
+
capabilities: z.record(z.string(), z.unknown()).readonly().optional(),
|
|
151
|
+
layouts: z.array(rawResolvedSlideLayoutSchema).readonly()
|
|
152
|
+
}).readonly();
|
|
153
|
+
const slideLayoutDefinitionSymbol = Symbol.for("@pptxdk/core/slide-layout-definition");
|
|
154
|
+
/** Checks whether a runtime value was produced by `defineSlideLayout`. */
|
|
155
|
+
function isSlideLayoutDefinition(value) {
|
|
156
|
+
return typeof value === "object" && value !== null && slideLayoutDefinitionSymbol in value;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Defines a reusable native slide layout specification that can be mounted into a `SlideMaster`
|
|
160
|
+
* across both JSX (`<SlideLayout layout={def} />`) and imperative (`slideLayout(def)`) entries.
|
|
161
|
+
*/
|
|
162
|
+
function defineSlideLayout(spec) {
|
|
163
|
+
const parsed = slideLayoutDataPropsSchema.safeParse(spec);
|
|
164
|
+
if (!parsed.success) {
|
|
165
|
+
const first = parsed.error.issues[0];
|
|
166
|
+
throw new BuildError([zodIssueToBuildDiagnostic("slide-layout", "invalid-slide-layout", first?.message ?? "Invalid slide layout specification", first)]);
|
|
167
|
+
}
|
|
168
|
+
const normalized = {};
|
|
169
|
+
for (const [key, value] of Object.entries(parsed.data)) if (value !== void 0) normalized[key] = snapshotValue(value);
|
|
170
|
+
const frozenProps = Object.freeze(normalized);
|
|
171
|
+
return Object.freeze({
|
|
172
|
+
[slideLayoutDefinitionSymbol]: true,
|
|
173
|
+
props: frozenProps,
|
|
174
|
+
...frozenProps.id === void 0 ? {} : { id: frozenProps.id },
|
|
175
|
+
...frozenProps.name === void 0 ? {} : { name: frozenProps.name },
|
|
176
|
+
...frozenProps.type === void 0 ? {} : { type: frozenProps.type },
|
|
177
|
+
...frozenProps.preserve === void 0 ? {} : { preserve: frozenProps.preserve },
|
|
178
|
+
...frozenProps.matchingName === void 0 ? {} : { matchingName: frozenProps.matchingName },
|
|
179
|
+
...frozenProps.userDrawn === void 0 ? {} : { userDrawn: frozenProps.userDrawn },
|
|
180
|
+
...frozenProps.showMasterShapes === void 0 ? {} : { showMasterShapes: frozenProps.showMasterShapes },
|
|
181
|
+
...frozenProps.showMasterPlaceholderAnimations === void 0 ? {} : { showMasterPlaceholderAnimations: frozenProps.showMasterPlaceholderAnimations },
|
|
182
|
+
...frozenProps.placeholders === void 0 ? {} : { placeholders: frozenProps.placeholders },
|
|
183
|
+
...frozenProps.colorMapOverride === void 0 ? {} : { colorMapOverride: frozenProps.colorMapOverride },
|
|
184
|
+
...frozenProps.themeOverride === void 0 ? {} : { themeOverride: frozenProps.themeOverride },
|
|
185
|
+
...frozenProps.style === void 0 ? {} : { style: frozenProps.style },
|
|
186
|
+
...frozenProps.background === void 0 ? {} : { background: frozenProps.background },
|
|
187
|
+
...frozenProps.headerFooter === void 0 ? {} : { headerFooter: frozenProps.headerFooter },
|
|
188
|
+
...frozenProps.footerPlaceholders === void 0 ? {} : { footerPlaceholders: frozenProps.footerPlaceholders },
|
|
189
|
+
...frozenProps.transition === void 0 ? {} : { transition: frozenProps.transition },
|
|
190
|
+
...frozenProps.advanceAfter === void 0 ? {} : { advanceAfter: frozenProps.advanceAfter },
|
|
191
|
+
...frozenProps.motion === void 0 ? {} : { motion: frozenProps.motion }
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
export { defineSlideLayout, footerPlaceholderSpecSchema, footerPlaceholdersSchema, headerFooterSchema, isSlideLayoutDefinition, resolvedMasterSchema, resolvedPlaceholderSchema, resolvedSlideLayoutSchema, slideLayoutDataPropsSchema, slideLayoutTypeSchema, slideLayoutTypeValues, slideMasterDataPropsSchema };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// ../core/dist/morph.js
|
|
2
|
+
const morphKeyBrand = Symbol("MorphKey");
|
|
3
|
+
const morphKeyLabel = Symbol("MorphKeyLabel");
|
|
4
|
+
/**
|
|
5
|
+
* Create an independent continuity scope; handles correspond across slides only when explicitly reused.
|
|
6
|
+
*
|
|
7
|
+
* When created in a React component, use useMemo or useState to keep the return value stable; cross-slide correspondence requires reusing the same scope.
|
|
8
|
+
*/
|
|
9
|
+
function createMorphScope() {
|
|
10
|
+
const handles = /* @__PURE__ */ new Map();
|
|
11
|
+
return Object.freeze({ handle(name) {
|
|
12
|
+
if (typeof name !== "string" || name.trim() === "") throw new TypeError("MorphScope.handle(name) requires a non-empty name");
|
|
13
|
+
let handle = handles.get(name);
|
|
14
|
+
if (handle === void 0) {
|
|
15
|
+
handle = Object.freeze({
|
|
16
|
+
[morphKeyBrand]: true,
|
|
17
|
+
[morphKeyLabel]: name
|
|
18
|
+
});
|
|
19
|
+
handles.set(name, handle);
|
|
20
|
+
}
|
|
21
|
+
return handle;
|
|
22
|
+
} });
|
|
23
|
+
}
|
|
24
|
+
function isMorphKey(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && morphKeyBrand in value && morphKeyLabel in value;
|
|
26
|
+
}
|
|
27
|
+
function getMorphKeyLabel(value) {
|
|
28
|
+
return value[morphKeyLabel];
|
|
29
|
+
}
|
|
30
|
+
export { createMorphScope, getMorphKeyLabel, isMorphKey };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { geometrySchema } from "./geometry-schemas.js";
|
|
2
|
+
import { resolvePercent } from "./layout-protocol.js";
|
|
3
|
+
import { layoutStyleShape, paddingStyleShape } from "./layout-schemas.js";
|
|
4
|
+
import { textStyleShape, visualStyleShape } from "./theme.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
// ../core/dist/placeholders.js
|
|
7
|
+
const singleUnicodeCharacterSchema = z.string().refine((character) => {
|
|
8
|
+
const codePoint = character.codePointAt(0);
|
|
9
|
+
return codePoint !== void 0 && String.fromCodePoint(codePoint) === character;
|
|
10
|
+
}, "Bullet must be a single Unicode character");
|
|
11
|
+
const textListBulletSchema = z.strictObject({
|
|
12
|
+
type: z.literal("bullet"),
|
|
13
|
+
character: singleUnicodeCharacterSchema.optional(),
|
|
14
|
+
level: z.number().int().min(0).max(8).optional()
|
|
15
|
+
}).readonly();
|
|
16
|
+
const textListNumberSchema = z.strictObject({
|
|
17
|
+
type: z.literal("number"),
|
|
18
|
+
style: z.literal("arabicPeriod").optional(),
|
|
19
|
+
startAt: z.number().int().min(1).max(32767).optional(),
|
|
20
|
+
level: z.number().int().min(0).max(8).optional()
|
|
21
|
+
}).readonly();
|
|
22
|
+
const rawTextListSchema = z.discriminatedUnion("type", [textListBulletSchema, textListNumberSchema]);
|
|
23
|
+
/** Native paragraph list schema (bullets and Arabic period numbering). */
|
|
24
|
+
const textListSchema = rawTextListSchema;
|
|
25
|
+
const textPlaceholderRoles = [
|
|
26
|
+
"title",
|
|
27
|
+
"ctrTitle",
|
|
28
|
+
"subTitle",
|
|
29
|
+
"body",
|
|
30
|
+
"dt",
|
|
31
|
+
"ftr",
|
|
32
|
+
"hdr"
|
|
33
|
+
];
|
|
34
|
+
z.enum(textPlaceholderRoles);
|
|
35
|
+
const contentPlaceholderRoles = [
|
|
36
|
+
...textPlaceholderRoles,
|
|
37
|
+
"pic",
|
|
38
|
+
"clipArt",
|
|
39
|
+
"tbl",
|
|
40
|
+
"chart",
|
|
41
|
+
"obj",
|
|
42
|
+
"sldNum",
|
|
43
|
+
"dgm",
|
|
44
|
+
"media"
|
|
45
|
+
];
|
|
46
|
+
const rawPlaceholderRoleSchema = z.enum(contentPlaceholderRoles);
|
|
47
|
+
const placeholderRoleSchema = rawPlaceholderRoleSchema;
|
|
48
|
+
const rawPlaceholderSizeSchema = z.enum([
|
|
49
|
+
"full",
|
|
50
|
+
"half",
|
|
51
|
+
"quarter"
|
|
52
|
+
]);
|
|
53
|
+
/** Official OOXML ST_PlaceholderSize values for placeholder slots. */
|
|
54
|
+
const placeholderSizeSchema = rawPlaceholderSizeSchema;
|
|
55
|
+
const rawPlaceholderOrientSchema = z.enum(["horz", "vert"]);
|
|
56
|
+
const placeholderOrientSchema = rawPlaceholderOrientSchema;
|
|
57
|
+
const rawPlaceholderLevelStyleSchema = z.strictObject({
|
|
58
|
+
...textStyleShape,
|
|
59
|
+
list: rawTextListSchema.optional(),
|
|
60
|
+
marginLeft: z.number().finite().nonnegative().optional(),
|
|
61
|
+
indent: z.number().finite().optional(),
|
|
62
|
+
spacingBefore: z.number().finite().nonnegative().optional()
|
|
63
|
+
}).readonly();
|
|
64
|
+
const placeholderLevelStyleSchema = rawPlaceholderLevelStyleSchema;
|
|
65
|
+
const rawPlaceholderListStylesSchema = z.strictObject({
|
|
66
|
+
1: rawPlaceholderLevelStyleSchema.optional(),
|
|
67
|
+
2: rawPlaceholderLevelStyleSchema.optional(),
|
|
68
|
+
3: rawPlaceholderLevelStyleSchema.optional(),
|
|
69
|
+
4: rawPlaceholderLevelStyleSchema.optional(),
|
|
70
|
+
5: rawPlaceholderLevelStyleSchema.optional(),
|
|
71
|
+
6: rawPlaceholderLevelStyleSchema.optional(),
|
|
72
|
+
7: rawPlaceholderLevelStyleSchema.optional(),
|
|
73
|
+
8: rawPlaceholderLevelStyleSchema.optional(),
|
|
74
|
+
9: rawPlaceholderLevelStyleSchema.optional()
|
|
75
|
+
}).readonly();
|
|
76
|
+
const rawPlaceholderStyleSchema = z.strictObject({
|
|
77
|
+
...layoutStyleShape,
|
|
78
|
+
...paddingStyleShape,
|
|
79
|
+
...textStyleShape,
|
|
80
|
+
...visualStyleShape
|
|
81
|
+
}).readonly();
|
|
82
|
+
const placeholderStyleSchema = rawPlaceholderStyleSchema;
|
|
83
|
+
const rawLayoutPlaceholderSpecSchema = z.strictObject({
|
|
84
|
+
type: rawPlaceholderRoleSchema,
|
|
85
|
+
explicitType: z.boolean().optional(),
|
|
86
|
+
idx: z.number().int().nonnegative().optional(),
|
|
87
|
+
size: rawPlaceholderSizeSchema.optional(),
|
|
88
|
+
orient: rawPlaceholderOrientSchema.optional(),
|
|
89
|
+
hasCustomPrompt: z.boolean().optional(),
|
|
90
|
+
name: z.string().optional(),
|
|
91
|
+
geometry: geometrySchema.optional(),
|
|
92
|
+
style: rawPlaceholderStyleSchema.optional(),
|
|
93
|
+
listStyles: rawPlaceholderListStylesSchema.optional(),
|
|
94
|
+
promptText: z.string().optional()
|
|
95
|
+
}).readonly();
|
|
96
|
+
const layoutPlaceholderSpecSchema = rawLayoutPlaceholderSpecSchema;
|
|
97
|
+
const masterPlaceholderSpecSchema = layoutPlaceholderSpecSchema;
|
|
98
|
+
const placeholderMapSchema = z.record(z.string().min(1), rawLayoutPlaceholderSpecSchema).readonly();
|
|
99
|
+
const masterPlaceholderMapSchema = placeholderMapSchema;
|
|
100
|
+
const masterTextStylesSchema = z.strictObject({
|
|
101
|
+
titleStyle: rawPlaceholderListStylesSchema.optional(),
|
|
102
|
+
bodyStyle: rawPlaceholderListStylesSchema.optional(),
|
|
103
|
+
otherStyle: rawPlaceholderListStylesSchema.optional()
|
|
104
|
+
}).readonly();
|
|
105
|
+
const nativePlaceholderRefSchema = z.strictObject({
|
|
106
|
+
type: rawPlaceholderRoleSchema,
|
|
107
|
+
explicitType: z.boolean().optional(),
|
|
108
|
+
idx: z.number().int().nonnegative().optional(),
|
|
109
|
+
size: rawPlaceholderSizeSchema.optional(),
|
|
110
|
+
orient: rawPlaceholderOrientSchema.optional(),
|
|
111
|
+
hasCustomPrompt: z.boolean().optional()
|
|
112
|
+
}).readonly();
|
|
113
|
+
function resolvePlaceholderScalar(value, basis) {
|
|
114
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
115
|
+
if (basis !== void 0 && typeof value === "string") return resolvePercent(value, basis);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Cascades box coordinates (`left`/`right`/`inset`/`width` and `top`/`bottom`/`inset`/`height`)
|
|
119
|
+
* across Master -> Layout -> Slide placeholder style layers, resolving percentages against `slideDimensions`.
|
|
120
|
+
*/
|
|
121
|
+
function resolvePlaceholderBoxFromLayers(layers, slideDimensions) {
|
|
122
|
+
let accLeft;
|
|
123
|
+
let accRight;
|
|
124
|
+
let accWidth;
|
|
125
|
+
let accTop;
|
|
126
|
+
let accBottom;
|
|
127
|
+
let accHeight;
|
|
128
|
+
for (const layer of layers) {
|
|
129
|
+
if (layer === void 0) continue;
|
|
130
|
+
const style = typeof layer.style === "object" && layer.style !== null && !Array.isArray(layer.style) ? layer.style : void 0;
|
|
131
|
+
if (style === void 0) continue;
|
|
132
|
+
const hasOwn = (obj, key) => Object.hasOwn(obj, key) && obj[key] !== void 0;
|
|
133
|
+
const hasLeft = hasOwn(style, "left") || hasOwn(style, "inset");
|
|
134
|
+
const hasRight = hasOwn(style, "right") || hasOwn(style, "inset");
|
|
135
|
+
const hasWidth = hasOwn(style, "width");
|
|
136
|
+
const hasTop = hasOwn(style, "top") || hasOwn(style, "inset");
|
|
137
|
+
const hasBottom = hasOwn(style, "bottom") || hasOwn(style, "inset");
|
|
138
|
+
const hasHeight = hasOwn(style, "height");
|
|
139
|
+
if (hasRight && !hasLeft) accLeft = void 0;
|
|
140
|
+
if (hasLeft && !hasRight && hasWidth) accRight = void 0;
|
|
141
|
+
if (hasLeft) accLeft = hasOwn(style, "left") ? style["left"] : style["inset"];
|
|
142
|
+
if (hasRight) accRight = hasOwn(style, "right") ? style["right"] : style["inset"];
|
|
143
|
+
if (hasWidth) accWidth = style["width"];
|
|
144
|
+
if (hasBottom && !hasTop) accTop = void 0;
|
|
145
|
+
if (hasTop && !hasBottom && hasHeight) accBottom = void 0;
|
|
146
|
+
if (hasTop) accTop = hasOwn(style, "top") ? style["top"] : style["inset"];
|
|
147
|
+
if (hasBottom) accBottom = hasOwn(style, "bottom") ? style["bottom"] : style["inset"];
|
|
148
|
+
if (hasHeight) accHeight = style["height"];
|
|
149
|
+
}
|
|
150
|
+
const leftNum = resolvePlaceholderScalar(accLeft, slideDimensions?.width);
|
|
151
|
+
const rightNum = resolvePlaceholderScalar(accRight, slideDimensions?.width);
|
|
152
|
+
const widthNum = resolvePlaceholderScalar(accWidth, slideDimensions?.width);
|
|
153
|
+
let resolvedX = leftNum ?? accLeft;
|
|
154
|
+
let resolvedWidth = widthNum ?? accWidth;
|
|
155
|
+
if (slideDimensions !== void 0 && leftNum !== void 0 && rightNum !== void 0 && widthNum === void 0) resolvedWidth = slideDimensions.width - leftNum - rightNum;
|
|
156
|
+
else if (slideDimensions !== void 0 && leftNum === void 0 && rightNum !== void 0 && widthNum !== void 0) resolvedX = slideDimensions.width - rightNum - widthNum;
|
|
157
|
+
const topNum = resolvePlaceholderScalar(accTop, slideDimensions?.height);
|
|
158
|
+
const bottomNum = resolvePlaceholderScalar(accBottom, slideDimensions?.height);
|
|
159
|
+
const heightNum = resolvePlaceholderScalar(accHeight, slideDimensions?.height);
|
|
160
|
+
let resolvedY = topNum ?? accTop;
|
|
161
|
+
let resolvedHeight = heightNum ?? accHeight;
|
|
162
|
+
if (slideDimensions !== void 0 && topNum !== void 0 && bottomNum !== void 0 && heightNum === void 0) resolvedHeight = slideDimensions.height - topNum - bottomNum;
|
|
163
|
+
else if (slideDimensions !== void 0 && topNum === void 0 && bottomNum !== void 0 && heightNum !== void 0) resolvedY = slideDimensions.height - bottomNum - heightNum;
|
|
164
|
+
return {
|
|
165
|
+
x: resolvedX,
|
|
166
|
+
y: resolvedY,
|
|
167
|
+
width: resolvedWidth,
|
|
168
|
+
height: resolvedHeight
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const baseAuthorKeyByRole = {
|
|
172
|
+
title: "title",
|
|
173
|
+
ctrTitle: "ctrTitle",
|
|
174
|
+
subTitle: "subTitle",
|
|
175
|
+
body: "body",
|
|
176
|
+
obj: "content",
|
|
177
|
+
pic: "pic",
|
|
178
|
+
clipArt: "clipArt",
|
|
179
|
+
tbl: "tbl",
|
|
180
|
+
chart: "chart",
|
|
181
|
+
dt: "dt",
|
|
182
|
+
ftr: "ftr",
|
|
183
|
+
sldNum: "sldNum",
|
|
184
|
+
hdr: "hdr",
|
|
185
|
+
dgm: "dgm",
|
|
186
|
+
media: "media"
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Allocates deterministic unique author keys for placeholders on a SlideLayout or SlideMaster.
|
|
190
|
+
*
|
|
191
|
+
* Never infers semantic column/side names from coordinates. When multiple placeholders share the
|
|
192
|
+
* same base role (e.g. two `body` slots with `idx=1` and `idx=3`), disambiguates deterministically
|
|
193
|
+
* via `${base}-${idx}` (falling back to `-2`, `-3` in XML order if needed).
|
|
194
|
+
*/
|
|
195
|
+
function allocatePlaceholderAuthorKeys(specs) {
|
|
196
|
+
const counts = /* @__PURE__ */ new Map();
|
|
197
|
+
const bases = specs.map((spec) => spec.explicitType === false ? "content" : baseAuthorKeyByRole[spec.type]);
|
|
198
|
+
for (const base of bases) counts.set(base, (counts.get(base) ?? 0) + 1);
|
|
199
|
+
const used = /* @__PURE__ */ new Set();
|
|
200
|
+
return specs.map((spec, index) => {
|
|
201
|
+
const base = bases[index];
|
|
202
|
+
const preferred = (counts.get(base) ?? 1) === 1 ? base : spec.idx !== void 0 ? `${base}-${spec.idx}` : base;
|
|
203
|
+
if (!used.has(preferred)) {
|
|
204
|
+
used.add(preferred);
|
|
205
|
+
return preferred;
|
|
206
|
+
}
|
|
207
|
+
let suffix = 2;
|
|
208
|
+
while (used.has(`${preferred}-${suffix}`)) suffix += 1;
|
|
209
|
+
const unique = `${preferred}-${suffix}`;
|
|
210
|
+
used.add(unique);
|
|
211
|
+
return unique;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Matches a slide `<p:ph>` reference onto a layout placeholder slot per ECMA-376 §19.3.1.36:
|
|
216
|
+
* `@idx` matches first; when `@idx` is absent, matches `@type` (preferring an unindexed slot).
|
|
217
|
+
*/
|
|
218
|
+
function matchLayoutPlaceholderKey(placeholders, ref) {
|
|
219
|
+
if (placeholders === void 0) return void 0;
|
|
220
|
+
const entries = Object.entries(placeholders);
|
|
221
|
+
if (ref.idx !== void 0) {
|
|
222
|
+
const byIdx = entries.find(([, spec]) => spec.idx === ref.idx);
|
|
223
|
+
if (byIdx !== void 0) return byIdx[0];
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (ref.type !== void 0) {
|
|
227
|
+
const unindexedByType = entries.find(([, spec]) => spec.idx === void 0 && spec.type === ref.type);
|
|
228
|
+
if (unindexedByType !== void 0) return unindexedByType[0];
|
|
229
|
+
const anyByType = entries.find(([, spec]) => spec.type === ref.type);
|
|
230
|
+
if (anyByType !== void 0) return anyByType[0];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Matches a layout or slide placeholder onto its parent master placeholder by role (not `@idx`).
|
|
235
|
+
*/
|
|
236
|
+
function matchMasterPlaceholderSpec(masterPlaceholders, role) {
|
|
237
|
+
if (masterPlaceholders === void 0) return void 0;
|
|
238
|
+
const specs = Object.values(masterPlaceholders);
|
|
239
|
+
const exact = specs.find((spec) => spec.type === role);
|
|
240
|
+
if (exact !== void 0) return exact;
|
|
241
|
+
switch (role) {
|
|
242
|
+
case "ctrTitle": return specs.find((spec) => spec.type === "title");
|
|
243
|
+
case "subTitle":
|
|
244
|
+
case "obj":
|
|
245
|
+
case "pic":
|
|
246
|
+
case "clipArt":
|
|
247
|
+
case "tbl":
|
|
248
|
+
case "chart":
|
|
249
|
+
case "dgm":
|
|
250
|
+
case "media": return specs.find((spec) => spec.type === "body");
|
|
251
|
+
default: return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** Selects the master `<p:txStyles>` bucket (`titleStyle`, `bodyStyle`, `otherStyle`) for a role. */
|
|
255
|
+
function masterTextStyleCategoryForRole(role) {
|
|
256
|
+
switch (role) {
|
|
257
|
+
case "title":
|
|
258
|
+
case "ctrTitle": return "titleStyle";
|
|
259
|
+
case "body":
|
|
260
|
+
case "subTitle":
|
|
261
|
+
case "obj":
|
|
262
|
+
case "pic":
|
|
263
|
+
case "clipArt":
|
|
264
|
+
case "tbl":
|
|
265
|
+
case "chart":
|
|
266
|
+
case "dgm":
|
|
267
|
+
case "media": return "bodyStyle";
|
|
268
|
+
case "dt":
|
|
269
|
+
case "ftr":
|
|
270
|
+
case "sldNum":
|
|
271
|
+
case "hdr": return "otherStyle";
|
|
272
|
+
default: return role;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export { allocatePlaceholderAuthorKeys, contentPlaceholderRoles, layoutPlaceholderSpecSchema, masterPlaceholderMapSchema, masterPlaceholderSpecSchema, masterTextStyleCategoryForRole, masterTextStylesSchema, matchLayoutPlaceholderKey, matchMasterPlaceholderSpec, nativePlaceholderRefSchema, placeholderLevelStyleSchema, placeholderMapSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSizeSchema, placeholderStyleSchema, resolvePlaceholderBoxFromLayers, textListBulletSchema, textListNumberSchema, textListSchema, textPlaceholderRoles };
|