@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,330 @@
|
|
|
1
|
+
import { authorIdSchema, readAuthorId } from "./author-ids.js";
|
|
2
|
+
import { BuildError, CapabilityError } from "./diagnostics.js";
|
|
3
|
+
import { layoutStyleShape, slideLayoutStyleShape } from "./layout-schemas.js";
|
|
4
|
+
import { placeholderSizeSchema } from "./placeholders.js";
|
|
5
|
+
import { backgroundValueSchema, colorMapOverrideSchema, colorValueSchema, isTheme, textStyleSchema, textStyleShape, themeInputSchema, themeOverrideSchema } from "./theme.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ../core/dist/author-schemas.js
|
|
8
|
+
const minimumSlideSizeEmu = 914400;
|
|
9
|
+
const maximumSlideSizeEmu = 51206400;
|
|
10
|
+
const emuPerPx = 9525;
|
|
11
|
+
const xml10StringSchema = z.string().refine((value) => {
|
|
12
|
+
for (const character of value) {
|
|
13
|
+
const codePoint = character.codePointAt(0);
|
|
14
|
+
if (codePoint !== void 0 && codePoint !== 9 && codePoint !== 10 && codePoint !== 13 && (codePoint < 32 || codePoint >= 55296 && codePoint <= 57343 || codePoint === 65534 || codePoint === 65535)) return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}, "String contains characters not allowed in XML 1.0");
|
|
18
|
+
const slideDimensionSchema = z.number().finite().positive().refine((value) => {
|
|
19
|
+
const sizeEmu = Math.round(value * emuPerPx);
|
|
20
|
+
return sizeEmu >= minimumSlideSizeEmu && sizeEmu <= maximumSlideSizeEmu;
|
|
21
|
+
}, { message: `Converted slide size must be within the closed interval of ${minimumSlideSizeEmu} to ${maximumSlideSizeEmu} EMU` });
|
|
22
|
+
const rawBackgroundRefSchema = z.strictObject({
|
|
23
|
+
ref: z.union([
|
|
24
|
+
z.literal(1001),
|
|
25
|
+
z.literal(1002),
|
|
26
|
+
z.literal(1003)
|
|
27
|
+
]),
|
|
28
|
+
color: colorValueSchema.optional()
|
|
29
|
+
}).readonly();
|
|
30
|
+
/** DrawingML `<p:bgRef idx="1001..1003">` reference resolved against `Theme.formatScheme.bgFillStyles`. */
|
|
31
|
+
const backgroundRefSchema = rawBackgroundRefSchema;
|
|
32
|
+
const rawSlideBackgroundSchema = z.union([backgroundValueSchema, rawBackgroundRefSchema]);
|
|
33
|
+
/** Slide background can use theme colors, gradients supported by the shared visual writer, formal image resource inputs, `"none"`, or theme background fill references (`p:bgRef`). */
|
|
34
|
+
const slideBackgroundSchema = rawSlideBackgroundSchema;
|
|
35
|
+
const deckPropsObjectSchema = z.strictObject({
|
|
36
|
+
width: slideDimensionSchema.optional(),
|
|
37
|
+
height: slideDimensionSchema.optional(),
|
|
38
|
+
theme: z.union([z.custom(isTheme), themeInputSchema]).optional(),
|
|
39
|
+
style: textStyleSchema.optional(),
|
|
40
|
+
title: xml10StringSchema.optional()
|
|
41
|
+
});
|
|
42
|
+
const deckPropsSchema = deckPropsObjectSchema.readonly();
|
|
43
|
+
const rawSlideStyleSchema = z.strictObject({
|
|
44
|
+
...textStyleShape,
|
|
45
|
+
...slideLayoutStyleShape,
|
|
46
|
+
background: rawSlideBackgroundSchema.optional()
|
|
47
|
+
}).readonly();
|
|
48
|
+
const slideStyleSchema = rawSlideStyleSchema;
|
|
49
|
+
const slideCorePropsObjectSchema = z.strictObject({
|
|
50
|
+
/** Page author id; unique within the deck and written as the stable slide identifier. */
|
|
51
|
+
id: authorIdSchema,
|
|
52
|
+
/** Optional PowerPoint display name written to `<p:cSld name="...">` without altering the stable `id`. */
|
|
53
|
+
name: xml10StringSchema.optional(),
|
|
54
|
+
layout: z.unknown().optional(),
|
|
55
|
+
colorMapOverride: colorMapOverrideSchema.optional(),
|
|
56
|
+
themeOverride: themeOverrideSchema.optional(),
|
|
57
|
+
style: rawSlideStyleSchema.optional(),
|
|
58
|
+
hidden: z.boolean().optional(),
|
|
59
|
+
showMasterPlaceholderAnimations: z.boolean().optional(),
|
|
60
|
+
showMasterShapes: z.boolean().optional()
|
|
61
|
+
});
|
|
62
|
+
slideCorePropsObjectSchema.readonly();
|
|
63
|
+
const rawFooterPlaceholderStyleSchema = z.strictObject({
|
|
64
|
+
...textStyleShape,
|
|
65
|
+
...layoutStyleShape
|
|
66
|
+
}).readonly();
|
|
67
|
+
/** Footer placeholder slot style combining inherited text styles and LayoutStyle placement. */
|
|
68
|
+
const footerPlaceholderStyleSchema = rawFooterPlaceholderStyleSchema;
|
|
69
|
+
const rawSlideFooterValueSchema = z.union([
|
|
70
|
+
z.boolean(),
|
|
71
|
+
xml10StringSchema,
|
|
72
|
+
z.strictObject({
|
|
73
|
+
text: xml10StringSchema.optional(),
|
|
74
|
+
style: rawFooterPlaceholderStyleSchema.optional(),
|
|
75
|
+
idx: z.number().int().nonnegative().optional(),
|
|
76
|
+
size: placeholderSizeSchema.optional(),
|
|
77
|
+
visible: z.boolean().optional()
|
|
78
|
+
}).readonly()
|
|
79
|
+
]);
|
|
80
|
+
/** Per-slide dateTime/footer override declaration (`false` hides; string sets text; object overrides text/style/slot). */
|
|
81
|
+
const slideFooterValueSchema = rawSlideFooterValueSchema;
|
|
82
|
+
const rawSlideNumberValueSchema = z.union([z.boolean(), z.strictObject({
|
|
83
|
+
style: rawFooterPlaceholderStyleSchema.optional(),
|
|
84
|
+
idx: z.number().int().nonnegative().optional(),
|
|
85
|
+
size: placeholderSizeSchema.optional(),
|
|
86
|
+
visible: z.boolean().optional()
|
|
87
|
+
}).readonly()]);
|
|
88
|
+
/** Per-slide slide-number override declaration (`false` hides; `true` enables; object overrides style/slot). */
|
|
89
|
+
const slideNumberValueSchema = rawSlideNumberValueSchema;
|
|
90
|
+
const slidePropsSchema = slideCorePropsObjectSchema.extend({
|
|
91
|
+
transition: z.unknown().optional(),
|
|
92
|
+
advanceAfter: z.number().optional(),
|
|
93
|
+
background: rawSlideBackgroundSchema.optional(),
|
|
94
|
+
dateTime: rawSlideFooterValueSchema.optional(),
|
|
95
|
+
footer: rawSlideFooterValueSchema.optional(),
|
|
96
|
+
slideNumber: rawSlideNumberValueSchema.optional()
|
|
97
|
+
}).readonly();
|
|
98
|
+
/** Organizes slides into collapsible flat sections in PowerPoint. */
|
|
99
|
+
const sectionPropsSchema = z.strictObject({ name: z.string().refine((value) => value.trim() !== "", "Section.name must be a non-empty string").pipe(xml10StringSchema) }).readonly();
|
|
100
|
+
/** Target declaration interpreted by PowerPoint upon clicking an object; internal targets are resolved by page author id. */
|
|
101
|
+
const linkTargetSchema = z.union([
|
|
102
|
+
z.strictObject({ id: z.string() }).readonly(),
|
|
103
|
+
z.strictObject({ url: z.string() }).readonly(),
|
|
104
|
+
z.strictObject({ action: z.literal("home") }).readonly()
|
|
105
|
+
]);
|
|
106
|
+
/** Validates link target declarations once during capability bind or resolve. */
|
|
107
|
+
function parseLinkTarget(value, path) {
|
|
108
|
+
if (value === void 0) return void 0;
|
|
109
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new CapabilityError("invalid-link", "link must specify id, url, or home action", path);
|
|
110
|
+
const definedEntries = Object.entries(value).filter(([, target]) => target !== void 0);
|
|
111
|
+
if (definedEntries.length !== 1) throw new CapabilityError("invalid-link", "link must specify exactly one target", path);
|
|
112
|
+
const parsed = linkTargetSchema.safeParse(Object.fromEntries(definedEntries));
|
|
113
|
+
if (!parsed.success) throw new CapabilityError("invalid-link", "link supports { id }, { url }, or { action: 'home' }", path);
|
|
114
|
+
return parsed.data;
|
|
115
|
+
}
|
|
116
|
+
const deckAllowedKeys = new Set(Object.keys(deckPropsObjectSchema.shape));
|
|
117
|
+
/**
|
|
118
|
+
* Validates Deck declaration props against `deckPropsSchema` and normalizes default dimensions
|
|
119
|
+
* while preserving original omitted vs explicit declarations on the editable node.
|
|
120
|
+
*/
|
|
121
|
+
function parseDeckProps(props) {
|
|
122
|
+
const unknown = Object.keys(props).find((key) => !deckAllowedKeys.has(key));
|
|
123
|
+
if (unknown !== void 0) throw new BuildError([{
|
|
124
|
+
code: "unknown-prop",
|
|
125
|
+
path: "deck",
|
|
126
|
+
prop: unknown,
|
|
127
|
+
field: unknown,
|
|
128
|
+
scope: "props",
|
|
129
|
+
message: `Deck contains unknown parameter ${unknown}`
|
|
130
|
+
}]);
|
|
131
|
+
const widthResult = props["width"] === void 0 ? {
|
|
132
|
+
success: true,
|
|
133
|
+
data: 1280
|
|
134
|
+
} : slideDimensionSchema.safeParse(props["width"]);
|
|
135
|
+
if (!widthResult.success) throw new BuildError([{
|
|
136
|
+
code: "invalid-prop",
|
|
137
|
+
path: "deck",
|
|
138
|
+
field: "width",
|
|
139
|
+
message: `Deck.width ${widthResult.error.issues[0]?.message ?? "must be a finite positive pixel value"}`
|
|
140
|
+
}]);
|
|
141
|
+
const heightResult = props["height"] === void 0 ? {
|
|
142
|
+
success: true,
|
|
143
|
+
data: 720
|
|
144
|
+
} : slideDimensionSchema.safeParse(props["height"]);
|
|
145
|
+
if (!heightResult.success) throw new BuildError([{
|
|
146
|
+
code: "invalid-prop",
|
|
147
|
+
path: "deck",
|
|
148
|
+
field: "height",
|
|
149
|
+
message: `Deck.height ${heightResult.error.issues[0]?.message ?? "must be a finite positive pixel value"}`
|
|
150
|
+
}]);
|
|
151
|
+
const rawTitle = props["title"];
|
|
152
|
+
if (rawTitle !== void 0) {
|
|
153
|
+
if (typeof rawTitle !== "string") throw new BuildError([{
|
|
154
|
+
code: "invalid-prop",
|
|
155
|
+
path: "deck",
|
|
156
|
+
field: "title",
|
|
157
|
+
message: "Deck.title must be a string"
|
|
158
|
+
}]);
|
|
159
|
+
if (!xml10StringSchema.safeParse(rawTitle).success) throw new BuildError([{
|
|
160
|
+
code: "invalid-prop",
|
|
161
|
+
path: "deck",
|
|
162
|
+
field: "title",
|
|
163
|
+
message: "Deck.title contains characters not allowed in XML 1.0"
|
|
164
|
+
}]);
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
width: widthResult.data,
|
|
168
|
+
height: heightResult.data,
|
|
169
|
+
...typeof rawTitle === "string" ? { title: rawTitle } : {}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Validates Section declaration props against `sectionPropsSchema` with localized BuildError diagnostics. */
|
|
173
|
+
function parseSectionProps(props, index) {
|
|
174
|
+
const unknown = Object.keys(props).find((key) => key !== "name");
|
|
175
|
+
if (unknown !== void 0) throw new BuildError([{
|
|
176
|
+
code: "unknown-prop",
|
|
177
|
+
path: `deck/section[${index + 1}]`,
|
|
178
|
+
prop: unknown,
|
|
179
|
+
field: unknown,
|
|
180
|
+
scope: "props",
|
|
181
|
+
message: `Section does not support property ${unknown}`
|
|
182
|
+
}]);
|
|
183
|
+
const rawName = props["name"];
|
|
184
|
+
if (typeof rawName !== "string" || rawName.trim() === "") throw new BuildError([{
|
|
185
|
+
code: "invalid-prop",
|
|
186
|
+
path: `deck/section[${index + 1}]`,
|
|
187
|
+
field: "name",
|
|
188
|
+
message: "Section.name must be a non-empty string"
|
|
189
|
+
}]);
|
|
190
|
+
const parsed = sectionPropsSchema.safeParse(props);
|
|
191
|
+
if (!parsed.success) throw new BuildError([{
|
|
192
|
+
code: "invalid-prop",
|
|
193
|
+
path: `deck/section[${rawName}]`,
|
|
194
|
+
field: "name",
|
|
195
|
+
message: "Section.name contains characters not allowed in XML 1.0"
|
|
196
|
+
}]);
|
|
197
|
+
return parsed.data;
|
|
198
|
+
}
|
|
199
|
+
const knownTrimmedSlideProps = /* @__PURE__ */ new Set([
|
|
200
|
+
"background",
|
|
201
|
+
"transition",
|
|
202
|
+
"advanceAfter",
|
|
203
|
+
"motion",
|
|
204
|
+
"footer",
|
|
205
|
+
"dateTime",
|
|
206
|
+
"slideNumber"
|
|
207
|
+
]);
|
|
208
|
+
/** Validates core Slide props against `slideCorePropsSchema` while respecting registered slide capability extensions. */
|
|
209
|
+
function parseSlideCoreProps(props, index, registeredSlideProps) {
|
|
210
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
211
|
+
"id",
|
|
212
|
+
"name",
|
|
213
|
+
"layout",
|
|
214
|
+
"placeholders",
|
|
215
|
+
"colorMapOverride",
|
|
216
|
+
"themeOverride",
|
|
217
|
+
"style",
|
|
218
|
+
"hidden",
|
|
219
|
+
"showMasterPlaceholderAnimations",
|
|
220
|
+
"showMasterShapes",
|
|
221
|
+
...registeredSlideProps
|
|
222
|
+
]);
|
|
223
|
+
const unknown = Object.keys(props).find((key) => !allowed.has(key));
|
|
224
|
+
const authorId = readAuthorId(props["id"], `deck/slide[${index + 1}]`);
|
|
225
|
+
if (unknown !== void 0) {
|
|
226
|
+
const label = authorId ?? index + 1;
|
|
227
|
+
if (knownTrimmedSlideProps.has(unknown)) throw new BuildError([{
|
|
228
|
+
code: "missing-capability",
|
|
229
|
+
path: `deck/slide[${label}]`,
|
|
230
|
+
field: unknown,
|
|
231
|
+
capability: unknown,
|
|
232
|
+
message: `No capability module registered for Slide.${unknown}`
|
|
233
|
+
}]);
|
|
234
|
+
throw new BuildError([{
|
|
235
|
+
code: "unknown-prop",
|
|
236
|
+
path: `deck/slide[${label}]`,
|
|
237
|
+
prop: unknown,
|
|
238
|
+
field: unknown,
|
|
239
|
+
scope: "props",
|
|
240
|
+
message: `Slide contains unknown parameter ${unknown}`
|
|
241
|
+
}]);
|
|
242
|
+
}
|
|
243
|
+
if (authorId === void 0) throw new BuildError([{
|
|
244
|
+
code: "invalid-prop",
|
|
245
|
+
path: `deck/slide[${index + 1}]`,
|
|
246
|
+
field: "id",
|
|
247
|
+
message: "Slide must declare id as a non-empty string"
|
|
248
|
+
}]);
|
|
249
|
+
if (!xml10StringSchema.safeParse(authorId).success) throw new BuildError([{
|
|
250
|
+
code: "invalid-prop",
|
|
251
|
+
path: `deck/slide[${index + 1}]`,
|
|
252
|
+
field: "id",
|
|
253
|
+
message: "Slide.id contains characters not allowed in XML 1.0"
|
|
254
|
+
}]);
|
|
255
|
+
const rawName = props["name"];
|
|
256
|
+
if (rawName !== void 0 && typeof rawName !== "string") throw new BuildError([{
|
|
257
|
+
code: "invalid-prop",
|
|
258
|
+
path: `deck/slide[${authorId}]`,
|
|
259
|
+
field: "name",
|
|
260
|
+
message: "Slide.name must be a string"
|
|
261
|
+
}]);
|
|
262
|
+
if (rawName !== void 0 && !xml10StringSchema.safeParse(rawName).success) throw new BuildError([{
|
|
263
|
+
code: "invalid-prop",
|
|
264
|
+
path: `deck/slide[${authorId}]`,
|
|
265
|
+
field: "name",
|
|
266
|
+
message: "Slide.name contains characters not allowed in XML 1.0"
|
|
267
|
+
}]);
|
|
268
|
+
const hidden = props["hidden"];
|
|
269
|
+
if (hidden !== void 0 && !slideCorePropsObjectSchema.shape.hidden.safeParse(hidden).success) throw new BuildError([{
|
|
270
|
+
code: "invalid-prop",
|
|
271
|
+
path: `deck/slide[${authorId}]`,
|
|
272
|
+
field: "hidden",
|
|
273
|
+
message: "Slide.hidden must be a boolean"
|
|
274
|
+
}]);
|
|
275
|
+
const showMasterShapes = props["showMasterShapes"];
|
|
276
|
+
if (showMasterShapes !== void 0 && !slideCorePropsObjectSchema.shape.showMasterShapes.safeParse(showMasterShapes).success) throw new BuildError([{
|
|
277
|
+
code: "invalid-prop",
|
|
278
|
+
path: `deck/slide[${authorId}]`,
|
|
279
|
+
field: "showMasterShapes",
|
|
280
|
+
message: "Slide.showMasterShapes must be a boolean"
|
|
281
|
+
}]);
|
|
282
|
+
const rawStyle = props["style"];
|
|
283
|
+
if (typeof rawStyle === "object" && rawStyle !== null && !Array.isArray(rawStyle) && Object.hasOwn(rawStyle, "zIndex") && rawStyle["zIndex"] !== void 0) throw new BuildError([{
|
|
284
|
+
code: "invalid-style",
|
|
285
|
+
path: `deck/slide[${authorId}]`,
|
|
286
|
+
field: "style.zIndex",
|
|
287
|
+
message: "Slide.style does not support zIndex"
|
|
288
|
+
}]);
|
|
289
|
+
const rawColorMapOverride = props["colorMapOverride"];
|
|
290
|
+
let colorMapOverride;
|
|
291
|
+
if (rawColorMapOverride !== void 0) {
|
|
292
|
+
const parsedMap = colorMapOverrideSchema.safeParse(rawColorMapOverride);
|
|
293
|
+
if (!parsedMap.success) throw new BuildError([{
|
|
294
|
+
code: "invalid-prop",
|
|
295
|
+
path: `deck/slide[${authorId}]`,
|
|
296
|
+
field: "colorMapOverride",
|
|
297
|
+
message: parsedMap.error.issues[0]?.message ?? "Slide.colorMapOverride must be 'master' or a 12-slot color map"
|
|
298
|
+
}]);
|
|
299
|
+
colorMapOverride = parsedMap.data;
|
|
300
|
+
}
|
|
301
|
+
const rawThemeOverride = props["themeOverride"];
|
|
302
|
+
let themeOverride;
|
|
303
|
+
if (rawThemeOverride !== void 0) {
|
|
304
|
+
const parsedOverride = themeOverrideSchema.safeParse(rawThemeOverride);
|
|
305
|
+
if (!parsedOverride.success) throw new BuildError([{
|
|
306
|
+
code: "invalid-prop",
|
|
307
|
+
path: `deck/slide[${authorId}]`,
|
|
308
|
+
field: "themeOverride",
|
|
309
|
+
message: parsedOverride.error.issues[0]?.message ?? "Slide.themeOverride is invalid"
|
|
310
|
+
}]);
|
|
311
|
+
themeOverride = parsedOverride.data;
|
|
312
|
+
}
|
|
313
|
+
const showMasterPlaceholderAnimations = props["showMasterPlaceholderAnimations"];
|
|
314
|
+
if (showMasterPlaceholderAnimations !== void 0 && !slideCorePropsObjectSchema.shape.showMasterPlaceholderAnimations.safeParse(showMasterPlaceholderAnimations).success) throw new BuildError([{
|
|
315
|
+
code: "invalid-prop",
|
|
316
|
+
path: `deck/slide[${authorId}]`,
|
|
317
|
+
field: "showMasterPlaceholderAnimations",
|
|
318
|
+
message: "Slide.showMasterPlaceholderAnimations must be a boolean"
|
|
319
|
+
}]);
|
|
320
|
+
return {
|
|
321
|
+
id: authorId,
|
|
322
|
+
...rawName === void 0 ? {} : { name: rawName },
|
|
323
|
+
...hidden === void 0 ? {} : { hidden },
|
|
324
|
+
...showMasterPlaceholderAnimations === void 0 ? {} : { showMasterPlaceholderAnimations },
|
|
325
|
+
...showMasterShapes === void 0 ? {} : { showMasterShapes },
|
|
326
|
+
...colorMapOverride === void 0 ? {} : { colorMapOverride },
|
|
327
|
+
...themeOverride === void 0 ? {} : { themeOverride }
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
export { backgroundRefSchema, deckPropsSchema, footerPlaceholderStyleSchema, linkTargetSchema, parseDeckProps, parseLinkTarget, parseSectionProps, parseSlideCoreProps, placeholderSizeSchema, sectionPropsSchema, slideBackgroundSchema, slideDimensionSchema, slideFooterValueSchema, slideNumberValueSchema, slidePropsSchema, slideStyleSchema, xml10StringSchema };
|