@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,449 @@
|
|
|
1
|
+
import { BuildError, toBuildDiagnostic } from "./diagnostics.js";
|
|
2
|
+
import { expandedSpacing, resolvePercent } from "./layout-protocol.js";
|
|
3
|
+
// ../core/dist/grid-layout.js
|
|
4
|
+
const gridContainerProperties = [
|
|
5
|
+
"gridTemplateColumns",
|
|
6
|
+
"gridTemplateRows",
|
|
7
|
+
"gridAutoRows",
|
|
8
|
+
"justifyItems"
|
|
9
|
+
];
|
|
10
|
+
const gridItemProperties = [
|
|
11
|
+
"gridColumn",
|
|
12
|
+
"gridRow",
|
|
13
|
+
"justifySelf"
|
|
14
|
+
];
|
|
15
|
+
function fail(path, code, message, details) {
|
|
16
|
+
throw new BuildError([toBuildDiagnostic(path, code, message, details)]);
|
|
17
|
+
}
|
|
18
|
+
function gridTokens(input, path) {
|
|
19
|
+
const tokens = [];
|
|
20
|
+
let depth = 0;
|
|
21
|
+
let current = "";
|
|
22
|
+
for (const character of input.trim()) {
|
|
23
|
+
if (character === "(") depth += 1;
|
|
24
|
+
if (character === ")") depth -= 1;
|
|
25
|
+
if (depth < 0) fail(path, "invalid-grid-tracks", "Mismatched parentheses in grid tracks");
|
|
26
|
+
if (/\s/u.test(character) && depth === 0) {
|
|
27
|
+
if (current !== "") tokens.push(current);
|
|
28
|
+
current = "";
|
|
29
|
+
} else current += character;
|
|
30
|
+
}
|
|
31
|
+
if (depth !== 0) fail(path, "invalid-grid-tracks", "Mismatched parentheses in grid tracks");
|
|
32
|
+
if (current !== "") tokens.push(current);
|
|
33
|
+
return tokens;
|
|
34
|
+
}
|
|
35
|
+
function parseGridPixels(token, path) {
|
|
36
|
+
const match = /^(\d+(?:\.\d+)?)(?:px)?$/u.exec(token);
|
|
37
|
+
if (match === null) fail(path, "invalid-grid-tracks", `Unsupported grid track ${token}`);
|
|
38
|
+
return Number(match[1]);
|
|
39
|
+
}
|
|
40
|
+
function parseGridBasicTrack(token, path) {
|
|
41
|
+
if (token === "auto") return {
|
|
42
|
+
kind: "auto",
|
|
43
|
+
min: 0
|
|
44
|
+
};
|
|
45
|
+
const fraction = /^(\d+(?:\.\d+)?)fr$/u.exec(token);
|
|
46
|
+
if (fraction !== null) {
|
|
47
|
+
const value = Number(fraction[1]);
|
|
48
|
+
if (value <= 0) fail(path, "invalid-grid-tracks", "fr track fraction must be greater than 0");
|
|
49
|
+
return {
|
|
50
|
+
kind: "fr",
|
|
51
|
+
value,
|
|
52
|
+
min: 0
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
kind: "px",
|
|
57
|
+
value: parseGridPixels(token, path)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function gridTracks(input, path, defaultFr) {
|
|
61
|
+
if (input === void 0 || input.trim() === "") return defaultFr ? [{
|
|
62
|
+
kind: "fr",
|
|
63
|
+
value: 1,
|
|
64
|
+
min: 0
|
|
65
|
+
}] : [];
|
|
66
|
+
const parseOne = (token) => {
|
|
67
|
+
const repeat = /^repeat\(\s*(\d+)\s*,\s*(.+)\)$/u.exec(token);
|
|
68
|
+
if (repeat !== null) {
|
|
69
|
+
const count = Number(repeat[1]);
|
|
70
|
+
if (!Number.isInteger(count) || count < 1 || count > 128) fail(path, "invalid-grid-tracks", "repeat count must be an integer between 1 and 128");
|
|
71
|
+
const repeated = gridTokens(repeat[2], path).flatMap(parseOne);
|
|
72
|
+
if (repeated.length * count > 128) fail(path, "invalid-grid-tracks", "Expanded grid tracks cannot exceed 128 tracks");
|
|
73
|
+
return Array.from({ length: count }, () => repeated).flat();
|
|
74
|
+
}
|
|
75
|
+
const minmax = /^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/u.exec(token);
|
|
76
|
+
if (minmax !== null) {
|
|
77
|
+
const lower = minmax[1].trim();
|
|
78
|
+
const minValue = lower === "auto" ? 0 : parseGridPixels(lower, path);
|
|
79
|
+
const maximum = parseGridBasicTrack(minmax[2].trim(), path);
|
|
80
|
+
if (maximum.kind === "fr") return [{
|
|
81
|
+
...maximum,
|
|
82
|
+
min: Math.max(minValue, maximum.min),
|
|
83
|
+
contentMinimum: lower === "auto"
|
|
84
|
+
}];
|
|
85
|
+
if (maximum.kind === "auto") return [{
|
|
86
|
+
kind: "auto",
|
|
87
|
+
min: minValue
|
|
88
|
+
}];
|
|
89
|
+
return [{
|
|
90
|
+
kind: "px",
|
|
91
|
+
value: Math.max(minValue, maximum.value)
|
|
92
|
+
}];
|
|
93
|
+
}
|
|
94
|
+
return [parseGridBasicTrack(token, path)];
|
|
95
|
+
};
|
|
96
|
+
const tracks = gridTokens(input, path).flatMap(parseOne);
|
|
97
|
+
if (tracks.length === 0 || tracks.length > 128) fail(path, "invalid-grid-tracks", "Grid tracks must contain between 1 and 128 tracks");
|
|
98
|
+
return tracks;
|
|
99
|
+
}
|
|
100
|
+
function gridAutoRowTracks(input, path) {
|
|
101
|
+
if (input === void 0) return [{
|
|
102
|
+
kind: "auto",
|
|
103
|
+
min: 0
|
|
104
|
+
}];
|
|
105
|
+
const tracks = gridTracks(input, path, false);
|
|
106
|
+
if (tracks.length === 0) fail(path, "invalid-grid-tracks", "gridAutoRows must contain at least 1 track");
|
|
107
|
+
return tracks;
|
|
108
|
+
}
|
|
109
|
+
function rowTrackGrowsWithContent(track) {
|
|
110
|
+
return track.kind === "auto" || track.kind === "fr" && track.contentMinimum === true;
|
|
111
|
+
}
|
|
112
|
+
function distributeFrTracks(sizes, tracks, availableSize, gap) {
|
|
113
|
+
const trackAt = (index) => tracks[index] ?? {
|
|
114
|
+
kind: "auto",
|
|
115
|
+
min: 0
|
|
116
|
+
};
|
|
117
|
+
const flexible = new Set(sizes.flatMap((_, index) => trackAt(index).kind === "fr" ? [index] : []));
|
|
118
|
+
if (flexible.size === 0) return;
|
|
119
|
+
const gapSize = gap * Math.max(0, sizes.length - 1);
|
|
120
|
+
const fixedSize = sizes.reduce((sum, size, index) => sum + (trackAt(index).kind === "fr" ? 0 : size), 0);
|
|
121
|
+
while (flexible.size > 0) {
|
|
122
|
+
const factorTotal = [...flexible].reduce((sum, index) => {
|
|
123
|
+
const track = trackAt(index);
|
|
124
|
+
return sum + (track.kind === "fr" ? track.value : 0);
|
|
125
|
+
}, 0);
|
|
126
|
+
const frozenSize = sizes.reduce((sum, size, index) => sum + (flexible.has(index) ? 0 : trackAt(index).kind === "fr" ? size : 0), 0);
|
|
127
|
+
const freeSize = Math.max(0, availableSize - fixedSize - gapSize - frozenSize);
|
|
128
|
+
const undersized = [...flexible].filter((index) => {
|
|
129
|
+
const track = trackAt(index);
|
|
130
|
+
return track.kind === "fr" && freeSize * (track.value / factorTotal) < (sizes[index] ?? track.min);
|
|
131
|
+
});
|
|
132
|
+
if (undersized.length > 0) {
|
|
133
|
+
for (const index of undersized) flexible.delete(index);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
for (const index of flexible) {
|
|
137
|
+
const track = trackAt(index);
|
|
138
|
+
if (track.kind === "fr") sizes[index] = freeSize * (track.value / factorTotal);
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function gridPlacement(value, path) {
|
|
144
|
+
if (value === void 0) return { span: 1 };
|
|
145
|
+
const positiveIndex = (raw) => {
|
|
146
|
+
const result = Number(raw);
|
|
147
|
+
if (!Number.isInteger(result) || result < 1) fail(path, "invalid-grid-placement", "Grid line numbers must be positive integers");
|
|
148
|
+
return result - 1;
|
|
149
|
+
};
|
|
150
|
+
if (typeof value === "number") {
|
|
151
|
+
if (!Number.isInteger(value) || value < 1) fail(path, "invalid-grid-placement", "Grid line numbers must be positive integers");
|
|
152
|
+
return {
|
|
153
|
+
start: value - 1,
|
|
154
|
+
span: 1
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const text = value.trim();
|
|
158
|
+
let match = /^span\s+(\d+)$/u.exec(text);
|
|
159
|
+
if (match !== null) {
|
|
160
|
+
const span = Number(match[1]);
|
|
161
|
+
if (span < 1) fail(path, "invalid-grid-placement", "Grid span must be a positive integer");
|
|
162
|
+
return { span };
|
|
163
|
+
}
|
|
164
|
+
match = /^(\d+)\s*\/\s*span\s+(\d+)$/u.exec(text);
|
|
165
|
+
if (match !== null) {
|
|
166
|
+
const span = Number(match[2]);
|
|
167
|
+
if (span < 1) fail(path, "invalid-grid-placement", "Grid span must be a positive integer");
|
|
168
|
+
return {
|
|
169
|
+
start: positiveIndex(match[1]),
|
|
170
|
+
span
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
match = /^(\d+)\s*\/\s*(\d+)$/u.exec(text);
|
|
174
|
+
if (match !== null) {
|
|
175
|
+
const start = positiveIndex(match[1]);
|
|
176
|
+
const end = positiveIndex(match[2]);
|
|
177
|
+
if (end <= start) fail(path, "invalid-grid-placement", "Grid end line number must be greater than start line number");
|
|
178
|
+
return {
|
|
179
|
+
start,
|
|
180
|
+
span: end - start
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (/^\d+$/u.test(text)) return {
|
|
184
|
+
start: positiveIndex(text),
|
|
185
|
+
span: 1
|
|
186
|
+
};
|
|
187
|
+
return fail(path, "invalid-grid-placement", `Unsupported grid placement ${value}`);
|
|
188
|
+
}
|
|
189
|
+
function gridAlignment(value) {
|
|
190
|
+
if (value === "center") return "center";
|
|
191
|
+
if (value === "end" || value === "flex-end") return "end";
|
|
192
|
+
if (value === "stretch") return "stretch";
|
|
193
|
+
return "start";
|
|
194
|
+
}
|
|
195
|
+
function validateGridContainerStyle(value, resolvedDisplay, path) {
|
|
196
|
+
if (resolvedDisplay === "grid" && value["alignItems"] === "baseline") fail(path, "unsupported-grid-alignment", "Grid containers do not support baseline alignment");
|
|
197
|
+
for (const key of gridContainerProperties) if (value[key] !== void 0 && resolvedDisplay !== "grid") fail(path, "invalid-layout-context", `${key} is only applicable to display: "grid" containers`);
|
|
198
|
+
}
|
|
199
|
+
function validateGridStyleValues() {}
|
|
200
|
+
function validateGridItemStyle(style, parentStyle, path) {
|
|
201
|
+
if (parentStyle.display === "grid" && style.position === "absolute" && (style.alignSelf !== void 0 || style.justifySelf !== void 0 || style.gridColumn !== void 0 || style.gridRow !== void 0)) fail(path, "unsupported-grid-positioning", "Absolutely positioned grid items currently do not support grid placement or self alignment");
|
|
202
|
+
if (parentStyle.display === "grid" && style.position !== "absolute" && style.alignSelf === "baseline") fail(path, "unsupported-grid-alignment", "Grid items do not support baseline alignment");
|
|
203
|
+
}
|
|
204
|
+
function computeGridPlacements(node, explicitColumns) {
|
|
205
|
+
const columns = [...explicitColumns];
|
|
206
|
+
const children = node.children.filter((child) => child.style.position !== "absolute");
|
|
207
|
+
const occupied = /* @__PURE__ */ new Set();
|
|
208
|
+
const placements = [];
|
|
209
|
+
let cursorRow = 0;
|
|
210
|
+
let cursorColumn = 0;
|
|
211
|
+
const ensureColumns = (count) => {
|
|
212
|
+
if (count > 128) fail(node.path, "invalid-grid-placement", "Implicit grid columns cannot exceed 128 columns");
|
|
213
|
+
while (columns.length < count) columns.push({
|
|
214
|
+
kind: "auto",
|
|
215
|
+
min: 0
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
for (const child of children) {
|
|
219
|
+
const column = gridPlacement(child.style.gridColumn, child.path);
|
|
220
|
+
const row = gridPlacement(child.style.gridRow, child.path);
|
|
221
|
+
const columnSpan = column.span;
|
|
222
|
+
if (column.start !== void 0) ensureColumns(column.start + columnSpan);
|
|
223
|
+
else if (columnSpan > columns.length) ensureColumns(columnSpan);
|
|
224
|
+
let currentRow = row.start ?? cursorRow;
|
|
225
|
+
let currentColumn = column.start ?? cursorColumn;
|
|
226
|
+
if (row.start === void 0 && column.start !== void 0 && column.start < cursorColumn) currentRow += 1;
|
|
227
|
+
const fits = (rowIndex, columnIndex) => {
|
|
228
|
+
if (row.start === void 0 && column.start === void 0) {
|
|
229
|
+
if (columnIndex + columnSpan > columns.length) return false;
|
|
230
|
+
} else ensureColumns(columnIndex + columnSpan);
|
|
231
|
+
for (let rowOffset = 0; rowOffset < row.span; rowOffset += 1) for (let columnOffset = 0; columnOffset < columnSpan; columnOffset += 1) if (occupied.has(`${rowIndex + rowOffset}:${columnIndex + columnOffset}`)) return false;
|
|
232
|
+
return true;
|
|
233
|
+
};
|
|
234
|
+
if (!(row.start !== void 0 && column.start !== void 0)) while (!fits(currentRow, currentColumn)) if (column.start !== void 0) currentRow += 1;
|
|
235
|
+
else {
|
|
236
|
+
currentColumn += 1;
|
|
237
|
+
if (currentColumn + columnSpan > columns.length) {
|
|
238
|
+
currentColumn = 0;
|
|
239
|
+
currentRow += 1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (currentRow + row.span > 128) fail(child.path, "invalid-grid-placement", "Implicit grid rows cannot exceed 128 rows");
|
|
243
|
+
for (let rowOffset = 0; rowOffset < row.span; rowOffset += 1) for (let columnOffset = 0; columnOffset < columnSpan; columnOffset += 1) occupied.add(`${currentRow + rowOffset}:${currentColumn + columnOffset}`);
|
|
244
|
+
placements.push({
|
|
245
|
+
node: child,
|
|
246
|
+
row: currentRow,
|
|
247
|
+
column: currentColumn,
|
|
248
|
+
rowSpan: row.span,
|
|
249
|
+
columnSpan
|
|
250
|
+
});
|
|
251
|
+
if (row.start === void 0) {
|
|
252
|
+
cursorRow = currentRow;
|
|
253
|
+
cursorColumn = currentColumn + columnSpan;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
placements,
|
|
258
|
+
columns
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function buildGridModel(node, innerWidth, innerHeight, port) {
|
|
262
|
+
const columnTracks = gridTracks(node.style.gridTemplateColumns, node.path, true);
|
|
263
|
+
const rowTracks = gridTracks(node.style.gridTemplateRows, node.path, false);
|
|
264
|
+
const autoRowTracks = gridAutoRowTracks(node.style.gridAutoRows, node.path);
|
|
265
|
+
const { placements, columns } = computeGridPlacements(node, columnTracks);
|
|
266
|
+
const columnGap = node.style.columnGap ?? node.style.gap ?? 0;
|
|
267
|
+
const rowGap = node.style.rowGap ?? node.style.gap ?? 0;
|
|
268
|
+
const rowCount = Math.max(rowTracks.length, ...placements.map((placement) => placement.row + placement.rowSpan), 0);
|
|
269
|
+
const rowTrackAt = (index) => rowTracks[index] ?? autoRowTracks[(index - rowTracks.length) % autoRowTracks.length];
|
|
270
|
+
const minContentWidth = (item) => port.measureMinContentContribution(item, "width");
|
|
271
|
+
const columnWidths = columns.map((track) => track.kind === "px" ? track.value : track.min);
|
|
272
|
+
for (const placement of placements) {
|
|
273
|
+
if (placement.columnSpan !== 1) continue;
|
|
274
|
+
const track = columns[placement.column];
|
|
275
|
+
if (track === void 0 || track.kind === "px" || track.kind === "fr" && track.contentMinimum !== true) continue;
|
|
276
|
+
columnWidths[placement.column] = Math.max(columnWidths[placement.column] ?? 0, Math.max(track.min, minContentWidth(placement.node)));
|
|
277
|
+
}
|
|
278
|
+
const columnSpanWidth = (start, span) => columnWidths.slice(start, start + span).reduce((sum, width) => sum + width, 0) + columnGap * Math.max(0, span - 1);
|
|
279
|
+
for (const placement of placements) {
|
|
280
|
+
if (placement.columnSpan === 1) continue;
|
|
281
|
+
const missing = minContentWidth(placement.node) - columnSpanWidth(placement.column, placement.columnSpan);
|
|
282
|
+
if (missing <= 0) continue;
|
|
283
|
+
const growable = Array.from({ length: placement.columnSpan }, (_, index) => placement.column + index).filter((index) => columns[index]?.kind === "auto" || columns[index]?.kind === "fr" && columns[index]?.contentMinimum === true);
|
|
284
|
+
if (growable.length === 0) continue;
|
|
285
|
+
for (const index of growable) columnWidths[index] = (columnWidths[index] ?? 0) + missing / growable.length;
|
|
286
|
+
}
|
|
287
|
+
if (innerWidth !== void 0) distributeFrTracks(columnWidths, columns, innerWidth, columnGap);
|
|
288
|
+
const spanWidth = (start, span) => columnWidths.slice(start, start + span).reduce((sum, width) => sum + width, 0) + columnGap * Math.max(0, span - 1);
|
|
289
|
+
const rowHeights = Array.from({ length: rowCount }, (_, index) => {
|
|
290
|
+
const track = rowTrackAt(index);
|
|
291
|
+
return track.kind === "px" ? track.value : track.min;
|
|
292
|
+
});
|
|
293
|
+
for (const placement of placements) {
|
|
294
|
+
if (placement.rowSpan !== 1) continue;
|
|
295
|
+
const track = rowTrackAt(placement.row);
|
|
296
|
+
if (!rowTrackGrowsWithContent(track)) continue;
|
|
297
|
+
const margin = expandedSpacing(placement.node.style, "margin");
|
|
298
|
+
const size = port.measureNaturalSize(placement.node, spanWidth(placement.column, placement.columnSpan));
|
|
299
|
+
rowHeights[placement.row] = Math.max(rowHeights[placement.row] ?? 0, track.min, size.height + margin.top + margin.bottom);
|
|
300
|
+
}
|
|
301
|
+
const spanHeight = (start, span) => rowHeights.slice(start, start + span).reduce((sum, height) => sum + height, 0) + rowGap * Math.max(0, span - 1);
|
|
302
|
+
for (const placement of placements) {
|
|
303
|
+
if (placement.rowSpan === 1) continue;
|
|
304
|
+
const natural = port.measureNaturalSize(placement.node, spanWidth(placement.column, placement.columnSpan));
|
|
305
|
+
const margin = expandedSpacing(placement.node.style, "margin");
|
|
306
|
+
const missing = natural.height + margin.top + margin.bottom - spanHeight(placement.row, placement.rowSpan);
|
|
307
|
+
if (missing <= 0) continue;
|
|
308
|
+
const growable = Array.from({ length: placement.rowSpan }, (_, index) => placement.row + index).filter((index) => rowTrackGrowsWithContent(rowTrackAt(index)));
|
|
309
|
+
if (growable.length === 0) continue;
|
|
310
|
+
for (const index of growable) rowHeights[index] = (rowHeights[index] ?? 0) + missing / growable.length;
|
|
311
|
+
}
|
|
312
|
+
if (innerHeight !== void 0) distributeFrTracks(rowHeights, Array.from({ length: rowCount }, (_, index) => rowTrackAt(index)), innerHeight, rowGap);
|
|
313
|
+
const spanHeightFinal = (start, span) => rowHeights.slice(start, start + span).reduce((sum, height) => sum + height, 0) + rowGap * Math.max(0, span - 1);
|
|
314
|
+
return {
|
|
315
|
+
placements,
|
|
316
|
+
widths: columnWidths,
|
|
317
|
+
heights: rowHeights,
|
|
318
|
+
columnGap,
|
|
319
|
+
rowGap,
|
|
320
|
+
spanWidth,
|
|
321
|
+
spanHeight: spanHeightFinal,
|
|
322
|
+
width: spanWidth(0, columnWidths.length),
|
|
323
|
+
height: rowCount === 0 ? 0 : spanHeightFinal(0, rowCount)
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Creates the Grid container solver collaborating strictly through `LayoutSolverPort`.
|
|
328
|
+
*/
|
|
329
|
+
function createGridContainerSolver() {
|
|
330
|
+
return {
|
|
331
|
+
handlesDisplay(display) {
|
|
332
|
+
return display === "grid";
|
|
333
|
+
},
|
|
334
|
+
measureMinContent(node, axis, port) {
|
|
335
|
+
const model = buildGridModel(node, void 0, void 0, port);
|
|
336
|
+
const padding = expandedSpacing(node.style, "padding");
|
|
337
|
+
return (axis === "width" ? model.width : model.height) + (axis === "width" ? padding.left + padding.right : padding.top + padding.bottom);
|
|
338
|
+
},
|
|
339
|
+
placeContainer(node, port) {
|
|
340
|
+
if (node.style.display !== "grid") return;
|
|
341
|
+
const padding = expandedSpacing(node.style, "padding");
|
|
342
|
+
const computed = port.getComputedSize(node);
|
|
343
|
+
const outerWidth = computed.width;
|
|
344
|
+
const outerHeight = computed.height || port.getAllocatedHeight(node) || 0;
|
|
345
|
+
const hasWidth = node.isRoot || node.style.width !== void 0 && node.style.width !== "auto";
|
|
346
|
+
const hasResolvedHeight = node.isRoot || node.style.height !== void 0 && node.style.height !== "auto" || outerHeight > 0;
|
|
347
|
+
const model = buildGridModel(node, outerWidth > 0 ? Math.max(0, outerWidth - padding.left - padding.right) : void 0, hasResolvedHeight ? Math.max(0, outerHeight - padding.top - padding.bottom) : void 0, port);
|
|
348
|
+
port.setContainerSize(node, {
|
|
349
|
+
...!hasWidth && outerWidth <= 0 ? { width: model.width + padding.left + padding.right } : {},
|
|
350
|
+
...!hasResolvedHeight ? { height: model.height + padding.top + padding.bottom } : {}
|
|
351
|
+
});
|
|
352
|
+
port.setGridTracks?.(node, {
|
|
353
|
+
columnWidths: [...model.widths],
|
|
354
|
+
rowHeights: [...model.heights]
|
|
355
|
+
});
|
|
356
|
+
for (const placement of model.placements) {
|
|
357
|
+
const child = placement.node;
|
|
358
|
+
const childStyle = child.style;
|
|
359
|
+
const cellWidth = model.spanWidth(placement.column, placement.columnSpan);
|
|
360
|
+
const cellHeight = model.spanHeight(placement.row, placement.rowSpan);
|
|
361
|
+
const cellX = padding.left + model.spanWidth(0, placement.column) + (placement.column > 0 ? model.columnGap : 0);
|
|
362
|
+
const cellY = padding.top + model.spanHeight(0, placement.row) + (placement.row > 0 ? model.rowGap : 0);
|
|
363
|
+
port.setGridCellArea?.(child, {
|
|
364
|
+
x: cellX,
|
|
365
|
+
y: cellY,
|
|
366
|
+
width: cellWidth,
|
|
367
|
+
height: cellHeight
|
|
368
|
+
});
|
|
369
|
+
const margin = expandedSpacing(childStyle, "margin");
|
|
370
|
+
const availableWidth = Math.max(0, cellWidth - margin.left - margin.right);
|
|
371
|
+
const availableHeight = Math.max(0, cellHeight - margin.top - margin.bottom);
|
|
372
|
+
const justify = gridAlignment(childStyle.justifySelf === void 0 || childStyle.justifySelf === "auto" ? node.style.justifyItems ?? "stretch" : childStyle.justifySelf);
|
|
373
|
+
const alignValue = childStyle.alignSelf === void 0 || childStyle.alignSelf === "auto" ? node.style.alignItems ?? "stretch" : childStyle.alignSelf;
|
|
374
|
+
if (alignValue === "baseline") fail(child.path, "unsupported-grid-alignment", "Text baseline alignment in grid does not yet have a reliable row baseline");
|
|
375
|
+
const align = gridAlignment(alignValue);
|
|
376
|
+
const declaredWidth = childStyle.width;
|
|
377
|
+
const declaredHeight = childStyle.height;
|
|
378
|
+
const widthPercent = resolvePercent(declaredWidth, cellWidth);
|
|
379
|
+
const heightPercent = resolvePercent(declaredHeight, cellHeight);
|
|
380
|
+
const widthSpecified = declaredWidth !== void 0 && declaredWidth !== "auto";
|
|
381
|
+
let heightSpecified = declaredHeight !== void 0 && declaredHeight !== "auto";
|
|
382
|
+
const minWidth = resolvePercent(childStyle.minWidth, cellWidth);
|
|
383
|
+
const maxWidth = resolvePercent(childStyle.maxWidth, cellWidth);
|
|
384
|
+
const minHeight = resolvePercent(childStyle.minHeight, cellHeight);
|
|
385
|
+
const maxHeight = resolvePercent(childStyle.maxHeight, cellHeight);
|
|
386
|
+
let initialHeightConstraint;
|
|
387
|
+
if (heightPercent !== void 0 && availableHeight > 0) initialHeightConstraint = heightPercent;
|
|
388
|
+
else if (heightPercent !== void 0) {
|
|
389
|
+
initialHeightConstraint = "auto";
|
|
390
|
+
heightSpecified = false;
|
|
391
|
+
}
|
|
392
|
+
port.setChildConstraints(child, {
|
|
393
|
+
...widthPercent === void 0 ? {} : { width: widthPercent },
|
|
394
|
+
...initialHeightConstraint === void 0 ? {} : { height: initialHeightConstraint },
|
|
395
|
+
...minWidth === void 0 ? {} : { minWidth },
|
|
396
|
+
...maxWidth === void 0 ? {} : { maxWidth },
|
|
397
|
+
...minHeight === void 0 ? {} : { minHeight },
|
|
398
|
+
...maxHeight === void 0 ? {} : { maxHeight }
|
|
399
|
+
});
|
|
400
|
+
const intrinsic = port.measureNaturalSize(child, typeof declaredWidth === "string" && declaredWidth.endsWith("%") ? cellWidth : void 0);
|
|
401
|
+
let width = widthSpecified ? intrinsic.width : justify === "stretch" ? availableWidth : intrinsic.width;
|
|
402
|
+
if (childStyle.aspectRatio !== void 0 && heightSpecified && !widthSpecified) width = intrinsic.height * childStyle.aspectRatio;
|
|
403
|
+
if (!widthSpecified || widthPercent !== void 0 || child.contentMinimumsEnforced) port.setChildConstraints(child, { width: Math.max(0, width) });
|
|
404
|
+
const naturalAtWidth = port.measureNaturalSize(child, width);
|
|
405
|
+
let height = heightSpecified ? naturalAtWidth.height : align === "stretch" && childStyle.aspectRatio === void 0 ? availableHeight : naturalAtWidth.height;
|
|
406
|
+
if (!heightSpecified && childStyle.aspectRatio === void 0 || child.contentMinimumsEnforced) port.setChildConstraints(child, { height: Math.max(0, height) });
|
|
407
|
+
const finalSize = port.measureNaturalSize(child, width);
|
|
408
|
+
const usedWidth = finalSize.width || width;
|
|
409
|
+
const usedHeight = finalSize.height || height;
|
|
410
|
+
if (child.contentMinimumsEnforced) port.setChildConstraints(child, {
|
|
411
|
+
width: Math.max(0, usedWidth),
|
|
412
|
+
height: Math.max(0, usedHeight)
|
|
413
|
+
});
|
|
414
|
+
if (child.isContainer && !heightSpecified) port.setAllocatedHeight(child, height);
|
|
415
|
+
const xAlign = justify === "center" ? Math.max(0, (availableWidth - usedWidth) / 2) : justify === "end" ? Math.max(0, availableWidth - usedWidth) : 0;
|
|
416
|
+
const yAlign = align === "center" ? Math.max(0, (availableHeight - usedHeight) / 2) : align === "end" ? Math.max(0, availableHeight - usedHeight) : 0;
|
|
417
|
+
const relative = (start, end, basis) => {
|
|
418
|
+
const resolve = (value) => typeof value === "number" ? value : resolvePercent(value, basis);
|
|
419
|
+
return resolve(start) ?? -(resolve(end) ?? 0);
|
|
420
|
+
};
|
|
421
|
+
const dx = childStyle.position === "relative" ? relative(childStyle.left ?? childStyle.inset, childStyle.right ?? childStyle.inset, cellWidth) : 0;
|
|
422
|
+
const dy = childStyle.position === "relative" ? relative(childStyle.top ?? childStyle.inset, childStyle.bottom ?? childStyle.inset, cellHeight) : 0;
|
|
423
|
+
port.placeChild(child, {
|
|
424
|
+
x: cellX + xAlign + dx,
|
|
425
|
+
y: cellY + yAlign + dy
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Ownership descriptor for Grid layout mode, registered with the core layout coordinator.
|
|
433
|
+
*/
|
|
434
|
+
const gridLayoutMode = {
|
|
435
|
+
display: "grid",
|
|
436
|
+
containerStyleKeys: gridContainerProperties,
|
|
437
|
+
itemStyleKeys: gridItemProperties,
|
|
438
|
+
sharedContainerProperties: [
|
|
439
|
+
"alignItems",
|
|
440
|
+
"gap",
|
|
441
|
+
"rowGap",
|
|
442
|
+
"columnGap"
|
|
443
|
+
],
|
|
444
|
+
validateContainerStyle: validateGridContainerStyle,
|
|
445
|
+
validateStyleValues: validateGridStyleValues,
|
|
446
|
+
validateItemStyle: validateGridItemStyle,
|
|
447
|
+
createSolver: createGridContainerSolver
|
|
448
|
+
};
|
|
449
|
+
export { createGridContainerSolver, gridLayoutMode };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { validateAuthorIdScopes } from "./author-ids.js";
|
|
2
|
+
import { insertDeclarationChild as insertDeclarationChild$1, removeDeclarationChild as removeDeclarationChild$1, replaceDeclarationProps as replaceDeclarationProps$1, setDeclarationText as setDeclarationText$1 } from "./document-internals.js";
|
|
3
|
+
// ../core/dist/host.js
|
|
4
|
+
/**
|
|
5
|
+
* Internal React host prop carrying the editable-node creator for one declaration type.
|
|
6
|
+
*
|
|
7
|
+
* A JSX host element knows which common node class its capability declares. The adapter removes
|
|
8
|
+
* this value before the declaration reaches the formal build, so it is not author content and the
|
|
9
|
+
* adapter does not need a separate tag-to-node-class table.
|
|
10
|
+
*/
|
|
11
|
+
const hostNodeCreator = "__pptxdkNodeCreator";
|
|
12
|
+
/** A literal text instance reconciled inside a rich-text common node. */
|
|
13
|
+
var HostTextNode = class {
|
|
14
|
+
#text;
|
|
15
|
+
constructor(text) {
|
|
16
|
+
this.#text = text;
|
|
17
|
+
}
|
|
18
|
+
get type() {
|
|
19
|
+
return "#text";
|
|
20
|
+
}
|
|
21
|
+
get text() {
|
|
22
|
+
return this.#text;
|
|
23
|
+
}
|
|
24
|
+
[setDeclarationText$1](text) {
|
|
25
|
+
this.#text = text;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function replaceDeclarationProps(node, props) {
|
|
29
|
+
node[replaceDeclarationProps$1](props);
|
|
30
|
+
}
|
|
31
|
+
function insertDeclarationChild(parent, child, before) {
|
|
32
|
+
parent[insertDeclarationChild$1](child, before);
|
|
33
|
+
}
|
|
34
|
+
function removeDeclarationChild(parent, child) {
|
|
35
|
+
parent[removeDeclarationChild$1](child);
|
|
36
|
+
}
|
|
37
|
+
function setDeclarationText(node, text) {
|
|
38
|
+
node[setDeclarationText$1](text);
|
|
39
|
+
}
|
|
40
|
+
export { HostTextNode, hostNodeCreator, insertDeclarationChild, removeDeclarationChild, replaceDeclarationProps, setDeclarationText, validateAuthorIdScopes };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { authorIdSchema } from "./author-ids.js";
|
|
2
|
+
import { backgroundRefSchema, deckPropsSchema, linkTargetSchema, sectionPropsSchema, slideBackgroundSchema, slideFooterValueSchema, slideNumberValueSchema, slidePropsSchema } from "./author-schemas.js";
|
|
3
|
+
import { BuildError, CapabilityError, toBuildDiagnostic } from "./diagnostics.js";
|
|
4
|
+
import { geometrySchema } from "./geometry-schemas.js";
|
|
5
|
+
import { createMorphScope } from "./morph.js";
|
|
6
|
+
import { layoutLengthSchema, layoutSpacingSchema, layoutStyleSchema, paddingStyleSchema } from "./layout-schemas.js";
|
|
7
|
+
import { AuthorQuery, AuthorQueryError, CommonContainer, CommonNode, DeckContainer, RichTextContainer, SlideContainer, SlideLayoutContainer, SlideMasterContainer } from "./document.js";
|
|
8
|
+
import { defineSlideLayout, footerPlaceholderSpecSchema, footerPlaceholdersSchema, headerFooterSchema, isSlideLayoutDefinition, resolvedMasterSchema, resolvedPlaceholderSchema, resolvedSlideLayoutSchema, slideLayoutDataPropsSchema, slideLayoutTypeSchema, slideLayoutTypeValues, slideMasterDataPropsSchema } from "./masters.js";
|
|
9
|
+
import { allocatePlaceholderAuthorKeys, layoutPlaceholderSpecSchema, masterPlaceholderSpecSchema, masterTextStylesSchema, placeholderLevelStyleSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSizeSchema, placeholderStyleSchema } from "./placeholders.js";
|
|
10
|
+
import { assertValidLang, backgroundValueSchema, borderObjectSchema, borderStyleSchema, borderValueSchema, boxShadowValueSchema, colorMapOverrideSchema, colorMapSchema, darker, defaultColorMap, defaultTheme, defineTheme, externalImageFillSourceSchema, formatSchemeSchema, imageBackgroundFitSchema, imageBackgroundPositionKeywordSchema, imageBackgroundPositionSchema, imageBackgroundSchema, imageFillSourceSchema, isNativeColorSlot, isSchemeColorName, isSchemeColorSlot, isTheme, isThemeFontSlot, lighter, nativeColorSlots, schemeColorNameSchema, schemeColorNames, schemeColorSlots, textStyleSchema, themeDataSchema, themeFontSlotSchema, themeFontSlots, themeInputSchema, themeOverrideSchema, themeSchema } from "./theme.js";
|
|
11
|
+
import "./block-flex-layout.js";
|
|
12
|
+
import "./layout.js";
|
|
13
|
+
import { BuildQueryError } from "./query.js";
|
|
14
|
+
import { PreviewPageRangeError, buildDiagnosticFontUnavailableReasonSchema, buildDiagnosticSchema, buildOptionsSchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets } from "./stage-options.js";
|
|
15
|
+
export { AuthorQuery, AuthorQueryError, BuildError, BuildQueryError, CapabilityError, CommonContainer, CommonNode, DeckContainer, PreviewPageRangeError, RichTextContainer, SlideContainer, SlideLayoutContainer, SlideMasterContainer, allocatePlaceholderAuthorKeys, assertValidLang, authorIdSchema, backgroundRefSchema, backgroundValueSchema, borderObjectSchema, borderStyleSchema, borderValueSchema, boxShadowValueSchema, buildDiagnosticFontUnavailableReasonSchema, buildDiagnosticSchema, buildOptionsSchema, colorMapOverrideSchema, colorMapSchema, createMorphScope, darker, deckPropsSchema, defaultColorMap, defaultTheme, defineSlideLayout, defineTheme, emitOptionsSchema, extensionSchema, externalImageFillSourceSchema, fontEmbeddingModeSchema, footerPlaceholderSpecSchema, footerPlaceholdersSchema, formatBaseline, formatBaselineSchema, formatSchemeSchema, geometrySchema, headerFooterSchema, imageBackgroundFitSchema, imageBackgroundPositionKeywordSchema, imageBackgroundPositionSchema, imageBackgroundSchema, imageFillSourceSchema, isNativeColorSlot, isSchemeColorName, isSchemeColorSlot, isSlideLayoutDefinition, isTheme, isThemeFontSlot, layoutLengthSchema, layoutPlaceholderSpecSchema, layoutSpacingSchema, layoutStyleSchema, lighter, linkTargetSchema, masterPlaceholderSpecSchema, masterTextStylesSchema, nativeColorSlots, paddingStyleSchema, placeholderLevelStyleSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSizeSchema, placeholderStyleSchema, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, resolvedMasterSchema, resolvedPlaceholderSchema, resolvedSlideLayoutSchema, schemeColorNameSchema, schemeColorNames, schemeColorSlots, sectionPropsSchema, slideBackgroundSchema, slideFooterValueSchema, slideLayoutDataPropsSchema, slideLayoutTypeSchema, slideLayoutTypeValues, slideMasterDataPropsSchema, slideNumberValueSchema, slidePropsSchema, targetNameSchema, targetSchema, targets, textStyleSchema, themeDataSchema, themeFontSlotSchema, themeFontSlots, themeInputSchema, themeOverrideSchema, themeSchema, toBuildDiagnostic };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { replaceDeclarationProps } from "./document-internals.js";
|
|
2
|
+
import { isImmutableBytes, isSealedFont, markImmutableBytes } from "./font-seal.js";
|
|
3
|
+
import { isMorphKey } from "./morph.js";
|
|
4
|
+
// ../core/dist/input-values.js
|
|
5
|
+
const slideLayoutDefinitionSymbol = Symbol.for("@pptxdk/core/slide-layout-definition");
|
|
6
|
+
const themeBrandSymbol = Symbol.for("@pptxdk/core/theme");
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function preservesIdentity(value) {
|
|
11
|
+
if (isSealedFont(value) || isMorphKey(value) || slideLayoutDefinitionSymbol in value || themeBrandSymbol in value) return true;
|
|
12
|
+
if (replaceDeclarationProps in value) return true;
|
|
13
|
+
return isRecord(value) && Object.getOwnPropertyDescriptor(value, "type")?.value === "motion-scope-handle";
|
|
14
|
+
}
|
|
15
|
+
function isRecordValue(value) {
|
|
16
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
17
|
+
}
|
|
18
|
+
function copyValue(value, cloneImmutableBytes) {
|
|
19
|
+
if (value === null || typeof value !== "object") return value;
|
|
20
|
+
if (value instanceof Uint8Array) {
|
|
21
|
+
if (!cloneImmutableBytes && isImmutableBytes(value)) return value;
|
|
22
|
+
const copy = new Uint8Array(value);
|
|
23
|
+
return cloneImmutableBytes ? copy : markImmutableBytes(copy);
|
|
24
|
+
}
|
|
25
|
+
if (value instanceof ArrayBuffer) return value.slice(0);
|
|
26
|
+
if (value instanceof URL) return new URL(value.href);
|
|
27
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => copyValue(item, cloneImmutableBytes)));
|
|
28
|
+
if (preservesIdentity(value)) return value;
|
|
29
|
+
if (!isRecordValue(value)) return value;
|
|
30
|
+
const copy = Object.create(null);
|
|
31
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
32
|
+
if (Object.getOwnPropertyDescriptor(value, key)?.enumerable !== true) continue;
|
|
33
|
+
const observedValue = Reflect.get(value, key);
|
|
34
|
+
Object.defineProperty(copy, key, {
|
|
35
|
+
configurable: false,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
value: copyValue(observedValue, cloneImmutableBytes),
|
|
38
|
+
writable: false
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return Object.freeze(copy);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Copies author-owned values received by a declaration entry.
|
|
45
|
+
*
|
|
46
|
+
* Record values, arrays, URLs, and byte views are isolated recursively. Enumerable getters are read
|
|
47
|
+
* at receipt, while behavior handles, sealed fonts, already-immutable bytes, and opaque objects
|
|
48
|
+
* keep their identity. This is a field-level authoring rule, not a general document clone.
|
|
49
|
+
*/
|
|
50
|
+
function snapshotValue(value) {
|
|
51
|
+
return copyValue(value, false);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clones internal declaration values for public inspection (`CommonNode.prototype.props`),
|
|
55
|
+
* always returning fresh unmarked `Uint8Array` copies so external reads cannot mutate internal
|
|
56
|
+
* `immutableBytes` buffers.
|
|
57
|
+
*/
|
|
58
|
+
function cloneExternalValue(value) {
|
|
59
|
+
return copyValue(value, true);
|
|
60
|
+
}
|
|
61
|
+
export { cloneExternalValue, snapshotValue };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BuildError, toBuildDiagnostic } from "./diagnostics.js";
|
|
2
|
+
// ../core/dist/layout-protocol.js
|
|
3
|
+
function failLayoutProtocol(path, code, message, field) {
|
|
4
|
+
throw new BuildError([toBuildDiagnostic(path, code, message, field === void 0 ? void 0 : { field })]);
|
|
5
|
+
}
|
|
6
|
+
function parseLayoutNumber(value, name, path) {
|
|
7
|
+
if (typeof value !== "number" || !Number.isFinite(value)) failLayoutProtocol(path, "invalid-layout-style", `${name} must be a finite pixel number`, `style.${name}`);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function parseLayoutSpacing(value, name, path) {
|
|
11
|
+
if (value === void 0) return {
|
|
12
|
+
top: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0
|
|
16
|
+
};
|
|
17
|
+
if (typeof value === "number") {
|
|
18
|
+
const amount = parseLayoutNumber(value, name, path);
|
|
19
|
+
return {
|
|
20
|
+
top: amount,
|
|
21
|
+
right: amount,
|
|
22
|
+
bottom: amount,
|
|
23
|
+
left: amount
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (!Array.isArray(value) || value.length !== 2 && value.length !== 4) failLayoutProtocol(path, "invalid-layout-style", `${name} must be a number, 2-tuple, or 4-tuple`);
|
|
27
|
+
const values = value.map((item) => parseLayoutNumber(item, name, path));
|
|
28
|
+
if (values.length === 2) return {
|
|
29
|
+
top: values[0],
|
|
30
|
+
right: values[1],
|
|
31
|
+
bottom: values[0],
|
|
32
|
+
left: values[1]
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
top: values[0],
|
|
36
|
+
right: values[1],
|
|
37
|
+
bottom: values[2],
|
|
38
|
+
left: values[3]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function expandedSpacing(style, kind) {
|
|
42
|
+
const base = parseLayoutSpacing(style[kind], kind, "layout");
|
|
43
|
+
if (kind === "margin") return {
|
|
44
|
+
top: style.marginTop ?? base.top,
|
|
45
|
+
right: style.marginRight ?? base.right,
|
|
46
|
+
bottom: style.marginBottom ?? base.bottom,
|
|
47
|
+
left: style.marginLeft ?? base.left
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
top: style.paddingTop ?? base.top,
|
|
51
|
+
right: style.paddingRight ?? base.right,
|
|
52
|
+
bottom: style.paddingBottom ?? base.bottom,
|
|
53
|
+
left: style.paddingLeft ?? base.left
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function resolvePercent(value, basis) {
|
|
57
|
+
if (typeof value !== "string") return void 0;
|
|
58
|
+
const match = /^(-?(?:\d+(?:\.\d*)?|\.\d+))%$/u.exec(value);
|
|
59
|
+
return match === null ? void 0 : Number(match[1]) * basis / 100;
|
|
60
|
+
}
|
|
61
|
+
export { expandedSpacing, parseLayoutNumber, parseLayoutSpacing, resolvePercent };
|