deckjsx 0.8.0 → 0.8.1
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/README.md +149 -58
- package/dist/{adapter-C2AHiDGa.d.mts → adapter-B-bVXjv-.d.mts} +3 -7
- package/dist/{adapter-BamaV2yi.mjs → adapter-CNSvvD4i.mjs} +12 -37
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +1 -1
- package/dist/{index-dx2ZSBgF.d.mts → index-BlOsGMTm.d.mts} +7 -7
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +335 -266
- package/dist/inspect.d.mts +3 -3
- package/dist/jsx-dev-runtime.d.mts +2 -2
- package/dist/jsx-dev-runtime.mjs +1 -2
- package/dist/{jsx-runtime-_eIs-wi1.d.mts → jsx-runtime-Dd6G09P7.d.mts} +1 -1
- package/dist/jsx-runtime-DzJLgS1w.mjs +120 -0
- package/dist/jsx-runtime.d.mts +2 -2
- package/dist/jsx-runtime.mjs +1 -7
- package/dist/{model-BVkO8qGK.d.mts → model-oqG9gKTq.d.mts} +1 -2
- package/dist/{resolve-BD1dHxZd.d.mts → resolve-CfjiMtv5.d.mts} +1 -1
- package/dist/tree-DNsco0U3.mjs +156 -0
- package/package.json +3 -4
- package/dist/jsx-DGGM5erN.mjs +0 -403
- /package/dist/{node-output-ChRpOCV8.mjs → node-output-BXQOTLKj.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as CompositionDiagnosticError, C as parsePointValue, D as POINTS_PER_INCH, E as EMU_PER_INCH, F as formatDiagnostics, M as SemanticGraphDiagnosticError, N as StyleDiagnosticError, O as createDiagnostics, P as formatDiagnostic, S as parsePointToken, T as pointsToEmu, _ as isDeckLengthString, a as isInspectableThemePayload, b as parseLengthToken, c as fingerprintString, d as createWriterRenderContext, f as createTemplateHandle, g as DEFAULT_FONT_SIZE_PT, h as validateSlideTemplates, i as isContentTypesPayload, j as DeckDiagnosticError, k as diagnostic, l as stableJson, m as templateRefValue, n as pptxMediaAssetLoadRequirements, o as isRecord$2, p as isTemplateAreaRef, r as validatePptxPackageModel, s as projectedRelationshipTarget, t as pptx, u as withPackagePartFingerprints, v as isDeckPointLengthString, w as parseStrokeWidth, x as parsePercentage$1, y as parseLength } from "./adapter-
|
|
1
|
+
import { c as isAuthoredTag, i as createAuthorElement, o as isAuthorTreeChild, s as isAuthorTreeNode, t as authorElementPropsFromEntries } from "./tree-DNsco0U3.mjs";
|
|
2
|
+
import { A as CompositionDiagnosticError, C as parsePointValue, D as POINTS_PER_INCH, E as EMU_PER_INCH, F as formatDiagnostics, M as SemanticGraphDiagnosticError, N as StyleDiagnosticError, O as createDiagnostics, P as formatDiagnostic, S as parsePointToken, T as pointsToEmu, _ as isDeckLengthString, a as isInspectableThemePayload, b as parseLengthToken, c as fingerprintString, d as createWriterRenderContext, f as createTemplateHandle, g as DEFAULT_FONT_SIZE_PT, h as validateSlideTemplates, i as isContentTypesPayload, j as DeckDiagnosticError, k as diagnostic, l as stableJson, m as templateRefValue, n as pptxMediaAssetLoadRequirements, o as isRecord$2, p as isTemplateAreaRef, r as validatePptxPackageModel, s as projectedRelationshipTarget, t as pptx, u as withPackagePartFingerprints, v as isDeckPointLengthString, w as parseStrokeWidth, x as parsePercentage$1, y as parseLength } from "./adapter-CNSvvD4i.mjs";
|
|
3
3
|
import { n as isPptxMediaPart, o as isPptxSlidePart, r as isPptxPackageModel } from "./model-DIuh51qh.mjs";
|
|
4
4
|
//#region src/composition/types.ts
|
|
5
5
|
const COMPOSITION_SOURCE = Symbol("deckjsx.compositionSource");
|
|
@@ -61,7 +61,6 @@ function validateSourceKey(sourceKey) {
|
|
|
61
61
|
if (sourceKey.includes("/")) return "Source Key must not contain /.";
|
|
62
62
|
}
|
|
63
63
|
function describeInvalidRoot(value) {
|
|
64
|
-
if (isAuthorNodeValue(value)) return "Slide factory returned an AuthorNode value instead of an Author Tree node.";
|
|
65
64
|
if (isAuthorTreeNode(value)) return "Slide factory returned an Author Tree node that cannot be used as slide content.";
|
|
66
65
|
if (value === null) return "Slide factory returned null.";
|
|
67
66
|
return `Slide factory returned ${typeof value}.`;
|
|
@@ -1960,6 +1959,9 @@ function semanticRoleForTag(tag) {
|
|
|
1960
1959
|
function isRecord(value) {
|
|
1961
1960
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1962
1961
|
}
|
|
1962
|
+
function hasOwnProp(props, key) {
|
|
1963
|
+
return Object.prototype.hasOwnProperty.call(props, key);
|
|
1964
|
+
}
|
|
1963
1965
|
function keySegment(key, index) {
|
|
1964
1966
|
return key === void 0 ? `index:${index}` : `key:${String(key)}`;
|
|
1965
1967
|
}
|
|
@@ -1984,6 +1986,35 @@ function isShapeElement(node) {
|
|
|
1984
1986
|
function templateAreaValueFor(node) {
|
|
1985
1987
|
return "area" in node.props ? node.props.area : void 0;
|
|
1986
1988
|
}
|
|
1989
|
+
function supportedPropNamesFor(node) {
|
|
1990
|
+
if (node.source.kind === "slide") return new Set([
|
|
1991
|
+
"name",
|
|
1992
|
+
"template",
|
|
1993
|
+
"className",
|
|
1994
|
+
"style"
|
|
1995
|
+
]);
|
|
1996
|
+
switch (node.source.tag) {
|
|
1997
|
+
case "span": return new Set(["className", "style"]);
|
|
1998
|
+
case "img": return new Set([
|
|
1999
|
+
"className",
|
|
2000
|
+
"style",
|
|
2001
|
+
"area",
|
|
2002
|
+
"src",
|
|
2003
|
+
"data"
|
|
2004
|
+
]);
|
|
2005
|
+
case "shape": return new Set([
|
|
2006
|
+
"className",
|
|
2007
|
+
"style",
|
|
2008
|
+
"area",
|
|
2009
|
+
"shape"
|
|
2010
|
+
]);
|
|
2011
|
+
default: return new Set([
|
|
2012
|
+
"className",
|
|
2013
|
+
"style",
|
|
2014
|
+
"area"
|
|
2015
|
+
]);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
1987
2018
|
function sourceFor(context) {
|
|
1988
2019
|
return context.activeSlot?.source ?? context.source;
|
|
1989
2020
|
}
|
|
@@ -2035,22 +2066,12 @@ function classRefsFor(value) {
|
|
|
2035
2066
|
index
|
|
2036
2067
|
}));
|
|
2037
2068
|
}
|
|
2038
|
-
function directStyleProps(props) {
|
|
2039
|
-
const directStyle = Object.fromEntries(Object.entries(props).filter(([key]) => key !== "children" && key !== "className" && key !== "data" && key !== "area" && key !== "name" && key !== "shape" && key !== "src" && key !== "style" && key !== "template"));
|
|
2040
|
-
return Object.keys(directStyle).length === 0 ? void 0 : directStyle;
|
|
2041
|
-
}
|
|
2042
2069
|
function sourceKeyFor(source) {
|
|
2043
2070
|
return !source || source.kind === "root" ? "root" : source.sourceIdentity;
|
|
2044
2071
|
}
|
|
2045
2072
|
function mergedAuthoredStyle(props) {
|
|
2046
|
-
const directStyle = directStyleProps(props);
|
|
2047
2073
|
const inlineStyle = props.style;
|
|
2048
|
-
|
|
2049
|
-
if (inlineStyle !== void 0 && (typeof inlineStyle !== "object" || inlineStyle === null || Array.isArray(inlineStyle))) return;
|
|
2050
|
-
return {
|
|
2051
|
-
...directStyle,
|
|
2052
|
-
...isRecord(inlineStyle) ? inlineStyle : void 0
|
|
2053
|
-
};
|
|
2074
|
+
return isRecord(inlineStyle) ? Object.fromEntries(Object.entries(inlineStyle)) : void 0;
|
|
2054
2075
|
}
|
|
2055
2076
|
function styleRefFor(state, idMaterial, target, props) {
|
|
2056
2077
|
const style = mergedAuthoredStyle(props);
|
|
@@ -2083,7 +2104,90 @@ function invalidStructure(path, title, message, help) {
|
|
|
2083
2104
|
...help ? { help } : {}
|
|
2084
2105
|
});
|
|
2085
2106
|
}
|
|
2107
|
+
function authoringPropDiagnostic(input) {
|
|
2108
|
+
return diagnostic({
|
|
2109
|
+
severity: "error",
|
|
2110
|
+
code: input.code,
|
|
2111
|
+
title: input.title,
|
|
2112
|
+
message: input.message,
|
|
2113
|
+
labels: [{
|
|
2114
|
+
path: input.path,
|
|
2115
|
+
message: input.message
|
|
2116
|
+
}],
|
|
2117
|
+
...input.help ? { help: input.help } : {}
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
function validateAuthoringProps(state, node, path) {
|
|
2121
|
+
const supported = supportedPropNamesFor(node);
|
|
2122
|
+
const propPath = node.source.kind === "slide" ? `${path}.options` : `${path}.props`;
|
|
2123
|
+
for (const key of Object.keys(node.props)) if (!supported.has(key)) addDiagnostic(state, authoringPropDiagnostic({
|
|
2124
|
+
code: "E_COMPILE_UNSUPPORTED_AUTHORING_PROP",
|
|
2125
|
+
title: `unsupported ${node.source.kind === "slide" ? "slide declaration option" : "authoring prop"}`,
|
|
2126
|
+
path: `${propPath}.${key}`,
|
|
2127
|
+
message: `${key} is not supported in the current deckjsx authoring interface.`
|
|
2128
|
+
}));
|
|
2129
|
+
if (hasOwnProp(node.props, "style")) {
|
|
2130
|
+
const style = node.props.style;
|
|
2131
|
+
if (style !== void 0 && !isRecord(style)) addDiagnostic(state, authoringPropDiagnostic({
|
|
2132
|
+
code: "E_COMPILE_INVALID_STYLE_PROP",
|
|
2133
|
+
title: "style prop is invalid",
|
|
2134
|
+
path: `${propPath}.style`,
|
|
2135
|
+
message: "The style prop must be an object when it is provided."
|
|
2136
|
+
}));
|
|
2137
|
+
}
|
|
2138
|
+
if (isShapeElement(node) && node.props.shape !== void 0) {
|
|
2139
|
+
if (node.props.shape !== "rect" && node.props.shape !== "ellipse" && node.props.shape !== "line") addDiagnostic(state, authoringPropDiagnostic({
|
|
2140
|
+
code: "E_COMPILE_INVALID_SHAPE_PROP",
|
|
2141
|
+
title: "shape prop is invalid",
|
|
2142
|
+
path: `${propPath}.shape`,
|
|
2143
|
+
message: "The shape prop must be rect, ellipse, or line."
|
|
2144
|
+
}));
|
|
2145
|
+
}
|
|
2146
|
+
if (isSlideElement(node)) {
|
|
2147
|
+
if (node.props.name !== void 0 && typeof node.props.name !== "string") addDiagnostic(state, authoringPropDiagnostic({
|
|
2148
|
+
code: "E_COMPILE_INVALID_SLIDE_NAME_OPTION",
|
|
2149
|
+
title: "slide name option is invalid",
|
|
2150
|
+
path: `${propPath}.name`,
|
|
2151
|
+
message: "The slide declaration name option must be a string when it is provided."
|
|
2152
|
+
}));
|
|
2153
|
+
if (node.props.template !== void 0 && typeof node.props.template !== "string") addDiagnostic(state, authoringPropDiagnostic({
|
|
2154
|
+
code: "E_COMPILE_INVALID_SLIDE_TEMPLATE_OPTION",
|
|
2155
|
+
title: "slide template option is invalid",
|
|
2156
|
+
path: `${propPath}.template`,
|
|
2157
|
+
message: "The slide declaration template option must be a template name string."
|
|
2158
|
+
}));
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2086
2161
|
function assetForImage(state, idMaterial, props, path) {
|
|
2162
|
+
const hasSrc = props.src !== void 0;
|
|
2163
|
+
const hasData = props.data !== void 0;
|
|
2164
|
+
if (hasSrc && typeof props.src !== "string") {
|
|
2165
|
+
addDiagnostic(state, authoringPropDiagnostic({
|
|
2166
|
+
code: "E_COMPILE_INVALID_IMAGE_SOURCE_PROP",
|
|
2167
|
+
title: "image src prop is invalid",
|
|
2168
|
+
path: `${path}.props.src`,
|
|
2169
|
+
message: "The img src prop must be a string when it is provided."
|
|
2170
|
+
}));
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
if (hasData && typeof props.data !== "string") {
|
|
2174
|
+
addDiagnostic(state, authoringPropDiagnostic({
|
|
2175
|
+
code: "E_COMPILE_INVALID_IMAGE_SOURCE_PROP",
|
|
2176
|
+
title: "image data prop is invalid",
|
|
2177
|
+
path: `${path}.props.data`,
|
|
2178
|
+
message: "The img data prop must be a string when it is provided."
|
|
2179
|
+
}));
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
if (typeof props.src === "string" && typeof props.data === "string") {
|
|
2183
|
+
addDiagnostic(state, authoringPropDiagnostic({
|
|
2184
|
+
code: "E_COMPILE_AMBIGUOUS_IMAGE_SOURCE_PROP",
|
|
2185
|
+
title: "image source props are ambiguous",
|
|
2186
|
+
path: `${path}.props`,
|
|
2187
|
+
message: "Use either img src or img data, not both."
|
|
2188
|
+
}));
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2087
2191
|
if (typeof props.src !== "string" && typeof props.data !== "string") {
|
|
2088
2192
|
addDiagnostic(state, invalidStructure(path, "image source is missing", "Image nodes require either src or data.", ["Add a src path or data URL to the image."]));
|
|
2089
2193
|
return;
|
|
@@ -2350,6 +2454,7 @@ function buildNode(state, node, context, index) {
|
|
|
2350
2454
|
const material = [...nodeContext.parentMaterial, segment];
|
|
2351
2455
|
const id = graphNodeId(material);
|
|
2352
2456
|
const path = `${nodeContext.path} > ${sourceName(node)}[${keySegment(node.key, index)}]`;
|
|
2457
|
+
validateAuthoringProps(state, node, path);
|
|
2353
2458
|
if (kind === "textRun") {
|
|
2354
2459
|
if (!context.inline) {
|
|
2355
2460
|
addDiagnostic(state, invalidStructure(path, "span cannot appear here", "span must be inside a text-like element.", ["Wrap the span in <p>...</p> or move it inside an existing text element."]));
|
|
@@ -3076,6 +3181,169 @@ function summarizePptxPackage(projection, options = {}) {
|
|
|
3076
3181
|
};
|
|
3077
3182
|
}
|
|
3078
3183
|
//#endregion
|
|
3184
|
+
//#region src/layout/input.ts
|
|
3185
|
+
function pushDefined(values, value) {
|
|
3186
|
+
if (value !== void 0) values.push(value);
|
|
3187
|
+
}
|
|
3188
|
+
function resolvedPropsFor(node, resolvedStyles) {
|
|
3189
|
+
const resolved = resolvedStyles.get(node.id);
|
|
3190
|
+
if (!resolved) return {};
|
|
3191
|
+
return Object.fromEntries(Object.entries(resolved.properties).filter(([, property]) => property.source.layer !== "default").map(([key, property]) => [key, property.value]));
|
|
3192
|
+
}
|
|
3193
|
+
function sourceKeyForOrigin$2(source) {
|
|
3194
|
+
return !source || source.kind === "root" ? "root" : source.sourceIdentity;
|
|
3195
|
+
}
|
|
3196
|
+
function propsWithTemplateAreaFrame(resolvedStyles, node, templates) {
|
|
3197
|
+
const props = resolvedPropsFor(node, resolvedStyles);
|
|
3198
|
+
const ref = node.templateAreaRef;
|
|
3199
|
+
if (!ref) return props;
|
|
3200
|
+
const frame = templates?.[ref.template]?.areas?.[ref.area]?.frame;
|
|
3201
|
+
if (!frame) return props;
|
|
3202
|
+
const resolved = resolvedStyles.get(node.id);
|
|
3203
|
+
const frameProps = {};
|
|
3204
|
+
if (resolved?.properties.x?.source.layer !== "style") frameProps.x = frame.x;
|
|
3205
|
+
if (resolved?.properties.y?.source.layer !== "style") frameProps.y = frame.y;
|
|
3206
|
+
if (resolved?.properties.width?.source.layer !== "style") frameProps.width = frame.width;
|
|
3207
|
+
if (resolved?.properties.height?.source.layer !== "style") frameProps.height = frame.height;
|
|
3208
|
+
return {
|
|
3209
|
+
...props,
|
|
3210
|
+
...frameProps
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3213
|
+
function templateAreaKindFor$1(node, templates) {
|
|
3214
|
+
const ref = node.templateAreaRef;
|
|
3215
|
+
if (!ref) return;
|
|
3216
|
+
return templates?.[ref.template]?.areas?.[ref.area]?.kind ?? "generic";
|
|
3217
|
+
}
|
|
3218
|
+
function collectTextOrigin(graph, node) {
|
|
3219
|
+
const graphNodeIds = [node.id];
|
|
3220
|
+
const styleEntityIds = [];
|
|
3221
|
+
pushDefined(styleEntityIds, node.styleRef);
|
|
3222
|
+
node.inlineChildren.forEach((childId) => {
|
|
3223
|
+
const child = graph.nodes.get(childId);
|
|
3224
|
+
if (!child) return;
|
|
3225
|
+
graphNodeIds.push(child.id);
|
|
3226
|
+
pushDefined(styleEntityIds, child.styleRef);
|
|
3227
|
+
if (child.kind === "text") {
|
|
3228
|
+
const nested = collectTextOrigin(graph, child);
|
|
3229
|
+
graphNodeIds.push(...nested.graphNodeIds ?? []);
|
|
3230
|
+
styleEntityIds.push(...nested.styleEntityIds ?? []);
|
|
3231
|
+
}
|
|
3232
|
+
});
|
|
3233
|
+
return {
|
|
3234
|
+
graphNodeIds: [...new Set(graphNodeIds)],
|
|
3235
|
+
...styleEntityIds.length > 0 ? { styleEntityIds: [...new Set(styleEntityIds)] } : {}
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
function layoutOriginFor(graph, node, templates) {
|
|
3239
|
+
const templateAreaKind = templateAreaKindFor$1(node, templates);
|
|
3240
|
+
if (node.kind === "text") return {
|
|
3241
|
+
...collectTextOrigin(graph, node),
|
|
3242
|
+
...node.origin.source ? { source: node.origin.source } : {},
|
|
3243
|
+
...node.templateAreaRef ? { templateAreaRef: node.templateAreaRef } : {},
|
|
3244
|
+
...templateAreaKind ? { templateAreaKind } : {}
|
|
3245
|
+
};
|
|
3246
|
+
return {
|
|
3247
|
+
graphNodeIds: [node.id],
|
|
3248
|
+
...node.styleRef ? { styleEntityIds: [node.styleRef] } : {},
|
|
3249
|
+
...node.kind === "image" && node.assetRef ? { assetEntityIds: [node.assetRef] } : {},
|
|
3250
|
+
...node.origin.source ? { source: node.origin.source } : {},
|
|
3251
|
+
...node.templateAreaRef ? { templateAreaRef: node.templateAreaRef } : {},
|
|
3252
|
+
...templateAreaKind ? { templateAreaKind } : {}
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
function textChildrenFromGraph(graph, resolvedStyles, childIds, templates) {
|
|
3256
|
+
return childIds.flatMap((childId) => {
|
|
3257
|
+
const child = graph.nodes.get(childId);
|
|
3258
|
+
if (!child) return [];
|
|
3259
|
+
if (child.kind === "textRun") return [{
|
|
3260
|
+
kind: "text",
|
|
3261
|
+
props: resolvedPropsFor(child, resolvedStyles),
|
|
3262
|
+
children: [child.text],
|
|
3263
|
+
origin: layoutOriginFor(graph, child, templates)
|
|
3264
|
+
}];
|
|
3265
|
+
if (child.kind === "text") return textChildrenFromGraph(graph, resolvedStyles, child.inlineChildren, templates);
|
|
3266
|
+
return [];
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3269
|
+
function contentChildrenFromGraph(graph, resolvedStyles, childIds, assetProbeArtifacts, templates) {
|
|
3270
|
+
return childIds.flatMap((childId) => {
|
|
3271
|
+
const child = graph.nodes.get(childId);
|
|
3272
|
+
if (!child) return [];
|
|
3273
|
+
const node = layoutInputNodeFromGraph(graph, resolvedStyles, child, assetProbeArtifacts, templates);
|
|
3274
|
+
return node && node.kind !== "slide" ? [node] : [];
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
function layoutInputNodeFromGraph(graph, resolvedStyles, node, assetProbeArtifacts, templates) {
|
|
3278
|
+
switch (node.kind) {
|
|
3279
|
+
case "slide": {
|
|
3280
|
+
const props = propsWithTemplateAreaFrame(resolvedStyles, node, templates);
|
|
3281
|
+
const slideTemplates = graph.templates.get(sourceKeyForOrigin$2(node.origin.source));
|
|
3282
|
+
return {
|
|
3283
|
+
kind: "slide",
|
|
3284
|
+
props: {
|
|
3285
|
+
...props,
|
|
3286
|
+
name: node.name
|
|
3287
|
+
},
|
|
3288
|
+
children: contentChildrenFromGraph(graph, resolvedStyles, node.children, assetProbeArtifacts, slideTemplates),
|
|
3289
|
+
origin: layoutOriginFor(graph, node, slideTemplates)
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
case "container": return {
|
|
3293
|
+
kind: "view",
|
|
3294
|
+
props: propsWithTemplateAreaFrame(resolvedStyles, node, templates),
|
|
3295
|
+
children: contentChildrenFromGraph(graph, resolvedStyles, node.children, assetProbeArtifacts, templates),
|
|
3296
|
+
origin: layoutOriginFor(graph, node, templates)
|
|
3297
|
+
};
|
|
3298
|
+
case "text": return {
|
|
3299
|
+
kind: "text",
|
|
3300
|
+
props: propsWithTemplateAreaFrame(resolvedStyles, node, templates),
|
|
3301
|
+
children: textChildrenFromGraph(graph, resolvedStyles, node.inlineChildren, templates),
|
|
3302
|
+
origin: layoutOriginFor(graph, node, templates)
|
|
3303
|
+
};
|
|
3304
|
+
case "image": {
|
|
3305
|
+
const props = propsWithTemplateAreaFrame(resolvedStyles, node, templates);
|
|
3306
|
+
const asset = node.assetRef ? graph.assets.get(node.assetRef) : void 0;
|
|
3307
|
+
if (!asset) return;
|
|
3308
|
+
return {
|
|
3309
|
+
kind: "image",
|
|
3310
|
+
props: {
|
|
3311
|
+
...props,
|
|
3312
|
+
...imageSourceProps(asset)
|
|
3313
|
+
},
|
|
3314
|
+
...node.assetRef ? { assetProbe: assetProbeArtifacts?.get(node.assetRef)?.probe } : {},
|
|
3315
|
+
origin: layoutOriginFor(graph, node, templates)
|
|
3316
|
+
};
|
|
3317
|
+
}
|
|
3318
|
+
case "shape": return {
|
|
3319
|
+
kind: "shape",
|
|
3320
|
+
props: {
|
|
3321
|
+
...propsWithTemplateAreaFrame(resolvedStyles, node, templates),
|
|
3322
|
+
shape: node.shape
|
|
3323
|
+
},
|
|
3324
|
+
origin: layoutOriginFor(graph, node, templates)
|
|
3325
|
+
};
|
|
3326
|
+
case "document":
|
|
3327
|
+
case "textRun": return;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
function imageSourceProps(asset) {
|
|
3331
|
+
if (asset.source.kind === "data") return { data: asset.source.data };
|
|
3332
|
+
return { src: asset.source.kind === "path" ? asset.source.path : asset.source.url };
|
|
3333
|
+
}
|
|
3334
|
+
function buildLayoutInputSnapshot(input) {
|
|
3335
|
+
const document = input.graph.nodes.get(input.graph.documentId);
|
|
3336
|
+
const slideNodes = document?.kind === "document" ? document.children.map((id) => input.graph.nodes.get(id)).filter((node) => node?.kind === "slide") : [];
|
|
3337
|
+
return {
|
|
3338
|
+
snapshot: {
|
|
3339
|
+
...input.meta ? { meta: input.meta } : {},
|
|
3340
|
+
...input.deckSize ? { size: input.deckSize } : {},
|
|
3341
|
+
slides: slideNodes.map((node) => layoutInputNodeFromGraph(input.graph, input.resolvedStyles, node, input.assetProbeArtifacts)).filter((node) => node?.kind === "slide")
|
|
3342
|
+
},
|
|
3343
|
+
diagnostics: input.diagnostics ?? createDiagnostics()
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
//#endregion
|
|
3079
3347
|
//#region src/layout/frame.ts
|
|
3080
3348
|
function intersectClipRect(frame, clipRect) {
|
|
3081
3349
|
if (!clipRect) return frame;
|
|
@@ -5361,12 +5629,12 @@ function extractText(children, textTransform) {
|
|
|
5361
5629
|
parts.push(String(child));
|
|
5362
5630
|
continue;
|
|
5363
5631
|
}
|
|
5364
|
-
if (
|
|
5632
|
+
if (typeof child === "object") throw new Error("Text nodes can only contain string or number children.");
|
|
5365
5633
|
}
|
|
5366
5634
|
return applyTextTransform$1(parts.join(""), textTransform);
|
|
5367
5635
|
}
|
|
5368
5636
|
//#endregion
|
|
5369
|
-
//#region src/
|
|
5637
|
+
//#region src/layout/normalization.ts
|
|
5370
5638
|
function resolveFlexDirection(direction, flexDirection) {
|
|
5371
5639
|
if (direction) return direction;
|
|
5372
5640
|
if (flexDirection === "row") return "horizontal";
|
|
@@ -5574,7 +5842,8 @@ function normalizeShapeProps(props) {
|
|
|
5574
5842
|
const { style, ...rest } = props;
|
|
5575
5843
|
const resolved = {
|
|
5576
5844
|
...rest,
|
|
5577
|
-
...style
|
|
5845
|
+
...style,
|
|
5846
|
+
shape: rest.shape ?? "rect"
|
|
5578
5847
|
};
|
|
5579
5848
|
const background = parseBackgroundShorthand(resolved.background);
|
|
5580
5849
|
const border = parseBorderShorthand(resolved.border);
|
|
@@ -6813,11 +7082,14 @@ function imageSourceFromProps(props) {
|
|
|
6813
7082
|
};
|
|
6814
7083
|
throw new Error("Image requires either src or data.");
|
|
6815
7084
|
}
|
|
6816
|
-
function
|
|
6817
|
-
return
|
|
7085
|
+
function isLayoutInputContentNode(value) {
|
|
7086
|
+
return typeof value === "object" && value !== null && "kind" in value && (value.kind === "view" || value.kind === "text" || value.kind === "image" || value.kind === "shape");
|
|
6818
7087
|
}
|
|
6819
|
-
function
|
|
6820
|
-
|
|
7088
|
+
function isLayoutInputTextNode(value) {
|
|
7089
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "text";
|
|
7090
|
+
}
|
|
7091
|
+
function layoutChildFromNode(child, siblingOrder, context) {
|
|
7092
|
+
const origin = child.origin;
|
|
6821
7093
|
switch (child.kind) {
|
|
6822
7094
|
case "view": return {
|
|
6823
7095
|
kind: "view",
|
|
@@ -7131,12 +7403,9 @@ function compileGridChildren(authorChildren, parentFrame, idGenerator, options,
|
|
|
7131
7403
|
}).filter((node) => node !== null));
|
|
7132
7404
|
}
|
|
7133
7405
|
function compileChildren$1(children, parentFrame, idGenerator, layout, options, clipRect, context, resolutionOptions) {
|
|
7134
|
-
const authorChildren = children.
|
|
7135
|
-
if (!
|
|
7136
|
-
|
|
7137
|
-
throw new Error("Only deckjsx components can be children of View in structured layout.");
|
|
7138
|
-
}
|
|
7139
|
-
return layoutChildFromNode(child, siblingOrder, context, resolutionOptions);
|
|
7406
|
+
const authorChildren = children.map((child, siblingOrder) => {
|
|
7407
|
+
if (!isLayoutInputContentNode(child)) throw new Error("Only deckjsx components can be children of View in structured layout.");
|
|
7408
|
+
return layoutChildFromNode(child, siblingOrder, context);
|
|
7140
7409
|
}).filter((child) => child.props.display !== "none");
|
|
7141
7410
|
if (layout === "grid") return compileGridChildren(authorChildren, parentFrame, idGenerator, {
|
|
7142
7411
|
padding: options.padding,
|
|
@@ -7356,24 +7625,21 @@ function textStyleFromProps$1(props, textLengthContext) {
|
|
|
7356
7625
|
function isEmptyRunStyle(style) {
|
|
7357
7626
|
return Object.values(style).every((value) => value === void 0);
|
|
7358
7627
|
}
|
|
7359
|
-
function
|
|
7360
|
-
return children.flatMap((child) => Array.isArray(child) ?
|
|
7628
|
+
function flattenTextChildren(children) {
|
|
7629
|
+
return children.flatMap((child) => Array.isArray(child) ? flattenTextChildren(child) : [child]);
|
|
7361
7630
|
}
|
|
7362
7631
|
function extractRichTextRuns(children, textTransform, textLengthContext) {
|
|
7363
7632
|
const runs = [];
|
|
7364
|
-
for (const child of
|
|
7365
|
-
if (child === null || child === void 0 || child === false || child === true) continue;
|
|
7633
|
+
for (const child of flattenTextChildren(children)) {
|
|
7366
7634
|
if (typeof child === "string" || typeof child === "number") {
|
|
7367
7635
|
runs.push({ text: extractText([child], textTransform) });
|
|
7368
7636
|
continue;
|
|
7369
7637
|
}
|
|
7370
|
-
if (
|
|
7371
|
-
const
|
|
7372
|
-
if (authorNode.kind !== "text") throw new Error("Text nodes can only contain primitive text or inline text runs.");
|
|
7373
|
-
const props = normalizeTextProps(authorNode.props);
|
|
7638
|
+
if (isLayoutInputTextNode(child)) {
|
|
7639
|
+
const props = normalizeTextProps(child.props);
|
|
7374
7640
|
const childLengthContext = getTextLengthContext(props, textLengthContext);
|
|
7375
7641
|
const style = textStyleFromProps$1(props, childLengthContext);
|
|
7376
|
-
const text = extractRichTextRuns(
|
|
7642
|
+
const text = extractRichTextRuns(child.children, props.textTransform ?? textTransform, childLengthContext).map((run) => run.text).join("");
|
|
7377
7643
|
runs.push({
|
|
7378
7644
|
text,
|
|
7379
7645
|
...!isEmptyRunStyle(style) ? { style } : {}
|
|
@@ -7616,32 +7882,33 @@ function compileNode(child, parentFrame, idGenerator, placement, clipRect, conte
|
|
|
7616
7882
|
case "shape": return compileShapeNode(child, parentFrame, idGenerator, placement, clipRect, context);
|
|
7617
7883
|
}
|
|
7618
7884
|
}
|
|
7619
|
-
function compileSlide(root, context, slideFrame, idGenerator, lengthContext
|
|
7620
|
-
if (!isSlideNode(root)) throw new Error(`Slide factory at index ${context.slideIndex} must resolve to a slide node.`);
|
|
7885
|
+
function compileSlide(root, context, slideFrame, idGenerator, lengthContext) {
|
|
7621
7886
|
const slideProps = normalizeSlideProps(root.props);
|
|
7622
7887
|
const backgroundBoxFrames = resolveBackgroundBoxFrames(slideFrame);
|
|
7623
7888
|
const backgroundFill = resolveBackgroundLayersOrEmpty(backgroundInput(slideProps), slideProps.backgroundTransparency, {
|
|
7624
7889
|
widthEmu: slideFrame.widthEmu,
|
|
7625
7890
|
heightEmu: slideFrame.heightEmu
|
|
7626
7891
|
}, slideFrame, backgroundBoxFrames, slideProps.backgroundPosition, slideProps.backgroundSize, slideProps.backgroundRepeat, slideProps.backgroundOrigin, slideProps.backgroundClip);
|
|
7627
|
-
const nodes = root.children.
|
|
7892
|
+
const nodes = root.children.map((child, siblingOrder) => layoutChildFromNode(child, siblingOrder, lengthContext)).filter((child) => child.props.display !== "none").map((child) => compileNode(child, slideFrame, idGenerator, void 0, void 0, lengthContext)).filter((node) => node !== null);
|
|
7628
7893
|
return {
|
|
7629
7894
|
id: idGenerator.nextSlide(),
|
|
7630
7895
|
name: slideProps.name,
|
|
7896
|
+
...root.origin ? { origin: root.origin } : {},
|
|
7631
7897
|
background: backgroundFill.fill,
|
|
7632
7898
|
...backgroundFill.backgroundLayers ? { backgroundLayers: backgroundFill.backgroundLayers } : {},
|
|
7633
7899
|
nodes: sortNodesForPaint(nodes)
|
|
7634
7900
|
};
|
|
7635
7901
|
}
|
|
7636
|
-
function resolveProjectedLayout(options,
|
|
7902
|
+
function resolveProjectedLayout(options, input) {
|
|
7637
7903
|
const idGenerator = createIdGenerator();
|
|
7638
|
-
const slideSize = options.layout.unit === "in" ? {
|
|
7904
|
+
const slideSize = input.size ? input.size : options.layout.unit === "in" ? {
|
|
7639
7905
|
widthEmu: options.layout.width * EMU_PER_INCH,
|
|
7640
7906
|
heightEmu: options.layout.height * EMU_PER_INCH
|
|
7641
7907
|
} : {
|
|
7642
7908
|
widthEmu: options.layout.width / 72 * EMU_PER_INCH,
|
|
7643
7909
|
heightEmu: options.layout.height / 72 * EMU_PER_INCH
|
|
7644
7910
|
};
|
|
7911
|
+
const slideMeta = input.meta ?? options.meta;
|
|
7645
7912
|
const slideFrame = {
|
|
7646
7913
|
xEmu: 0,
|
|
7647
7914
|
yEmu: 0,
|
|
@@ -7653,194 +7920,14 @@ function resolveProjectedLayout(options, slides, resolutionOptions = {}) {
|
|
|
7653
7920
|
viewportHeightEmu: slideFrame.heightEmu
|
|
7654
7921
|
};
|
|
7655
7922
|
return {
|
|
7656
|
-
|
|
7657
|
-
meta: options.meta,
|
|
7923
|
+
...slideMeta ? { meta: slideMeta } : {},
|
|
7658
7924
|
size: slideSize,
|
|
7659
|
-
slides: slides.map((
|
|
7660
|
-
return compileSlide(
|
|
7661
|
-
slideIndex,
|
|
7662
|
-
totalSlides: slides.length,
|
|
7663
|
-
deckSlideIndex: slideIndex,
|
|
7664
|
-
deckTotalSlides: slides.length
|
|
7665
|
-
} })), { slideIndex }, slideFrame, idGenerator, lengthContext, resolutionOptions);
|
|
7925
|
+
slides: input.slides.map((slide, slideIndex) => {
|
|
7926
|
+
return compileSlide(slide, { slideIndex }, slideFrame, idGenerator, lengthContext);
|
|
7666
7927
|
})
|
|
7667
7928
|
};
|
|
7668
7929
|
}
|
|
7669
7930
|
//#endregion
|
|
7670
|
-
//#region src/layout/graph.ts
|
|
7671
|
-
function layoutSlideNode(props, children) {
|
|
7672
|
-
return {
|
|
7673
|
-
$$typeof: "deckjsx.author-node",
|
|
7674
|
-
kind: "slide",
|
|
7675
|
-
props,
|
|
7676
|
-
children
|
|
7677
|
-
};
|
|
7678
|
-
}
|
|
7679
|
-
function layoutViewNode(props, children) {
|
|
7680
|
-
return {
|
|
7681
|
-
$$typeof: "deckjsx.author-node",
|
|
7682
|
-
kind: "view",
|
|
7683
|
-
props,
|
|
7684
|
-
children
|
|
7685
|
-
};
|
|
7686
|
-
}
|
|
7687
|
-
function layoutTextNode(props, children) {
|
|
7688
|
-
return {
|
|
7689
|
-
$$typeof: "deckjsx.author-node",
|
|
7690
|
-
kind: "text",
|
|
7691
|
-
props,
|
|
7692
|
-
children
|
|
7693
|
-
};
|
|
7694
|
-
}
|
|
7695
|
-
function layoutImageNode(props) {
|
|
7696
|
-
return {
|
|
7697
|
-
$$typeof: "deckjsx.author-node",
|
|
7698
|
-
kind: "image",
|
|
7699
|
-
props,
|
|
7700
|
-
children: []
|
|
7701
|
-
};
|
|
7702
|
-
}
|
|
7703
|
-
function layoutShapeNode(props) {
|
|
7704
|
-
return {
|
|
7705
|
-
$$typeof: "deckjsx.author-node",
|
|
7706
|
-
kind: "shape",
|
|
7707
|
-
props,
|
|
7708
|
-
children: []
|
|
7709
|
-
};
|
|
7710
|
-
}
|
|
7711
|
-
function resolvedPropsFor(node, resolvedStyles) {
|
|
7712
|
-
const resolved = resolvedStyles.get(node.id);
|
|
7713
|
-
if (!resolved) return {};
|
|
7714
|
-
return Object.fromEntries(Object.entries(resolved.properties).filter(([, property]) => property.source.layer !== "default").map(([key, property]) => [key, property.value]));
|
|
7715
|
-
}
|
|
7716
|
-
function sourceKeyForOrigin$2(source) {
|
|
7717
|
-
return !source || source.kind === "root" ? "root" : source.sourceIdentity;
|
|
7718
|
-
}
|
|
7719
|
-
function propsWithTemplateAreaFrame(resolvedStyles, node, templates) {
|
|
7720
|
-
const props = resolvedPropsFor(node, resolvedStyles);
|
|
7721
|
-
const ref = node.templateAreaRef;
|
|
7722
|
-
if (!ref) return props;
|
|
7723
|
-
const frame = templates?.[ref.template]?.areas?.[ref.area]?.frame;
|
|
7724
|
-
if (!frame) return props;
|
|
7725
|
-
const resolved = resolvedStyles.get(node.id);
|
|
7726
|
-
const frameProps = {};
|
|
7727
|
-
if (resolved?.properties.x?.source.layer !== "style") frameProps.x = frame.x;
|
|
7728
|
-
if (resolved?.properties.y?.source.layer !== "style") frameProps.y = frame.y;
|
|
7729
|
-
if (resolved?.properties.width?.source.layer !== "style") frameProps.width = frame.width;
|
|
7730
|
-
if (resolved?.properties.height?.source.layer !== "style") frameProps.height = frame.height;
|
|
7731
|
-
return {
|
|
7732
|
-
...props,
|
|
7733
|
-
...frameProps
|
|
7734
|
-
};
|
|
7735
|
-
}
|
|
7736
|
-
function templateAreaKindFor$1(node, templates) {
|
|
7737
|
-
const ref = node.templateAreaRef;
|
|
7738
|
-
if (!ref) return;
|
|
7739
|
-
return templates?.[ref.template]?.areas?.[ref.area]?.kind ?? "generic";
|
|
7740
|
-
}
|
|
7741
|
-
function pushDefined(values, value) {
|
|
7742
|
-
if (value !== void 0) values.push(value);
|
|
7743
|
-
}
|
|
7744
|
-
function collectTextOrigin(graph, node) {
|
|
7745
|
-
const graphNodeIds = [node.id];
|
|
7746
|
-
const styleEntityIds = [];
|
|
7747
|
-
pushDefined(styleEntityIds, node.styleRef);
|
|
7748
|
-
node.inlineChildren.forEach((childId) => {
|
|
7749
|
-
const child = graph.nodes.get(childId);
|
|
7750
|
-
if (!child) return;
|
|
7751
|
-
graphNodeIds.push(child.id);
|
|
7752
|
-
pushDefined(styleEntityIds, child.styleRef);
|
|
7753
|
-
if (child.kind === "text") {
|
|
7754
|
-
const nested = collectTextOrigin(graph, child);
|
|
7755
|
-
graphNodeIds.push(...nested.graphNodeIds ?? []);
|
|
7756
|
-
styleEntityIds.push(...nested.styleEntityIds ?? []);
|
|
7757
|
-
}
|
|
7758
|
-
});
|
|
7759
|
-
return {
|
|
7760
|
-
graphNodeIds: [...new Set(graphNodeIds)],
|
|
7761
|
-
...styleEntityIds.length > 0 ? { styleEntityIds: [...new Set(styleEntityIds)] } : {}
|
|
7762
|
-
};
|
|
7763
|
-
}
|
|
7764
|
-
function layoutOriginFor(graph, node, templates) {
|
|
7765
|
-
const templateAreaKind = templateAreaKindFor$1(node, templates);
|
|
7766
|
-
if (node.kind === "text") return {
|
|
7767
|
-
...collectTextOrigin(graph, node),
|
|
7768
|
-
...node.origin.source ? { source: node.origin.source } : {},
|
|
7769
|
-
...node.templateAreaRef ? { templateAreaRef: node.templateAreaRef } : {},
|
|
7770
|
-
...templateAreaKind ? { templateAreaKind } : {}
|
|
7771
|
-
};
|
|
7772
|
-
return {
|
|
7773
|
-
graphNodeIds: [node.id],
|
|
7774
|
-
...node.styleRef ? { styleEntityIds: [node.styleRef] } : {},
|
|
7775
|
-
...node.kind === "image" && node.assetRef ? { assetEntityIds: [node.assetRef] } : {},
|
|
7776
|
-
...node.origin.source ? { source: node.origin.source } : {},
|
|
7777
|
-
...node.templateAreaRef ? { templateAreaRef: node.templateAreaRef } : {},
|
|
7778
|
-
...templateAreaKind ? { templateAreaKind } : {}
|
|
7779
|
-
};
|
|
7780
|
-
}
|
|
7781
|
-
function rememberOrigin(node, origin, origins) {
|
|
7782
|
-
origins.set(node, origin);
|
|
7783
|
-
return node;
|
|
7784
|
-
}
|
|
7785
|
-
function slideFactoryFor(slide) {
|
|
7786
|
-
return () => slide;
|
|
7787
|
-
}
|
|
7788
|
-
function textChildrenFromGraph(graph, resolvedStyles, childIds, origins, templates) {
|
|
7789
|
-
return childIds.flatMap((childId) => {
|
|
7790
|
-
const child = graph.nodes.get(childId);
|
|
7791
|
-
if (!child) return [];
|
|
7792
|
-
if (child.kind === "textRun") return [rememberOrigin(layoutTextNode(resolvedPropsFor(child, resolvedStyles), [child.text]), layoutOriginFor(graph, child, templates), origins)];
|
|
7793
|
-
if (child.kind === "text") return textChildrenFromGraph(graph, resolvedStyles, child.inlineChildren, origins, templates);
|
|
7794
|
-
return [];
|
|
7795
|
-
});
|
|
7796
|
-
}
|
|
7797
|
-
function contentChildrenFromGraph(graph, resolvedStyles, childIds, origins, templates) {
|
|
7798
|
-
return childIds.flatMap((childId) => {
|
|
7799
|
-
const child = graph.nodes.get(childId);
|
|
7800
|
-
if (!child) return [];
|
|
7801
|
-
const node = layoutAuthorNodeFromGraph(graph, resolvedStyles, child, origins, templates);
|
|
7802
|
-
return node ? [node] : [];
|
|
7803
|
-
});
|
|
7804
|
-
}
|
|
7805
|
-
function layoutAuthorNodeFromGraph(graph, resolvedStyles, node, origins, templates) {
|
|
7806
|
-
switch (node.kind) {
|
|
7807
|
-
case "slide": {
|
|
7808
|
-
const props = propsWithTemplateAreaFrame(resolvedStyles, node, templates);
|
|
7809
|
-
const slideTemplates = graph.templates.get(sourceKeyForOrigin$2(node.origin.source));
|
|
7810
|
-
return rememberOrigin(layoutSlideNode({
|
|
7811
|
-
...props,
|
|
7812
|
-
name: node.name
|
|
7813
|
-
}, contentChildrenFromGraph(graph, resolvedStyles, node.children, origins, slideTemplates)), layoutOriginFor(graph, node, slideTemplates), origins);
|
|
7814
|
-
}
|
|
7815
|
-
case "container": return rememberOrigin(layoutViewNode(propsWithTemplateAreaFrame(resolvedStyles, node, templates), contentChildrenFromGraph(graph, resolvedStyles, node.children, origins, templates)), layoutOriginFor(graph, node, templates), origins);
|
|
7816
|
-
case "text": return rememberOrigin(layoutTextNode(propsWithTemplateAreaFrame(resolvedStyles, node, templates), textChildrenFromGraph(graph, resolvedStyles, node.inlineChildren, origins, templates)), layoutOriginFor(graph, node, templates), origins);
|
|
7817
|
-
case "image": {
|
|
7818
|
-
const props = propsWithTemplateAreaFrame(resolvedStyles, node, templates);
|
|
7819
|
-
const asset = node.assetRef ? graph.assets.get(node.assetRef) : void 0;
|
|
7820
|
-
if (!asset) return;
|
|
7821
|
-
if (asset.source.kind === "data") return rememberOrigin(layoutImageNode({
|
|
7822
|
-
...props,
|
|
7823
|
-
data: asset.source.data
|
|
7824
|
-
}), layoutOriginFor(graph, node, templates), origins);
|
|
7825
|
-
return rememberOrigin(layoutImageNode({
|
|
7826
|
-
...props,
|
|
7827
|
-
src: asset.source.kind === "path" ? asset.source.path : asset.source.url
|
|
7828
|
-
}), layoutOriginFor(graph, node, templates), origins);
|
|
7829
|
-
}
|
|
7830
|
-
case "shape": return rememberOrigin(layoutShapeNode({
|
|
7831
|
-
...propsWithTemplateAreaFrame(resolvedStyles, node, templates),
|
|
7832
|
-
shape: node.shape
|
|
7833
|
-
}), layoutOriginFor(graph, node, templates), origins);
|
|
7834
|
-
case "document":
|
|
7835
|
-
case "textRun": return;
|
|
7836
|
-
}
|
|
7837
|
-
}
|
|
7838
|
-
function resolveProjectedLayoutFromGraph(options, graph, resolvedStyles) {
|
|
7839
|
-
const origins = /* @__PURE__ */ new WeakMap();
|
|
7840
|
-
const document = graph.nodes.get(graph.documentId);
|
|
7841
|
-
return resolveProjectedLayout(options, (document?.kind === "document" ? document.children.map((id) => graph.nodes.get(id)).filter((node) => node?.kind === "slide") : []).map((node) => layoutAuthorNodeFromGraph(graph, resolvedStyles, node, origins)).filter((node) => node?.kind === "slide").map(slideFactoryFor), { origins });
|
|
7842
|
-
}
|
|
7843
|
-
//#endregion
|
|
7844
7931
|
//#region src/projection/pptx/identity.ts
|
|
7845
7932
|
const MAX_WRITER_SHAPE_OBJECT_ID = Number.MAX_SAFE_INTEGER - 1;
|
|
7846
7933
|
function packagePartId(value) {
|
|
@@ -9688,9 +9775,6 @@ function compileChildrenPartial(graph, resolvedStyles, children, templates, pack
|
|
|
9688
9775
|
});
|
|
9689
9776
|
return elements.sort(comparePptxElementsByPaintOrder);
|
|
9690
9777
|
}
|
|
9691
|
-
function graphNodeForElement(graph, nodeId) {
|
|
9692
|
-
return nodeId ? graph.nodes.get(nodeId) : void 0;
|
|
9693
|
-
}
|
|
9694
9778
|
function elementOriginFromLayoutOrigin(origin) {
|
|
9695
9779
|
return {
|
|
9696
9780
|
...origin?.graphNodeIds ? { graphNodeIds: origin.graphNodeIds } : {},
|
|
@@ -9701,7 +9785,6 @@ function elementOriginFromLayoutOrigin(origin) {
|
|
|
9701
9785
|
}
|
|
9702
9786
|
function mapProjectedLayoutNodeToElement(input) {
|
|
9703
9787
|
const graphNodeId = input.node.origin?.graphNodeIds?.[0];
|
|
9704
|
-
const graphNode = graphNodeForElement(input.graph, graphNodeId);
|
|
9705
9788
|
const layoutAnchor = layoutAnchorFor({
|
|
9706
9789
|
templateAreaRef: input.node.origin?.templateAreaRef,
|
|
9707
9790
|
templateAreaKind: input.node.origin?.templateAreaKind,
|
|
@@ -9715,7 +9798,7 @@ function mapProjectedLayoutNodeToElement(input) {
|
|
|
9715
9798
|
}),
|
|
9716
9799
|
packagePartId: input.packagePartId,
|
|
9717
9800
|
serialized: { shapeObjectId: shapeObjectId(input.indexPath) },
|
|
9718
|
-
origin:
|
|
9801
|
+
origin: elementOriginFromLayoutOrigin(input.node.origin),
|
|
9719
9802
|
frame: input.node.frame,
|
|
9720
9803
|
measurement: { frame: input.node.frame },
|
|
9721
9804
|
...layoutAnchor ? { layoutAnchor } : {},
|
|
@@ -9762,7 +9845,6 @@ function mapProjectedLayoutNodeToElement(input) {
|
|
|
9762
9845
|
radiusEmu: input.node.radiusEmu,
|
|
9763
9846
|
children: input.node.children.map((child, index) => mapProjectedLayoutNodeToElement({
|
|
9764
9847
|
node: child,
|
|
9765
|
-
graph: input.graph,
|
|
9766
9848
|
packagePartId: input.packagePartId,
|
|
9767
9849
|
indexPath: [...input.indexPath, index]
|
|
9768
9850
|
}))
|
|
@@ -9850,34 +9932,17 @@ function mapProjectedLayoutNodeToElement(input) {
|
|
|
9850
9932
|
function pptxSlidePartFor(input) {
|
|
9851
9933
|
const slideNumber = input.slideIndex + 1;
|
|
9852
9934
|
const partId = input.slidePartId;
|
|
9853
|
-
const resolved = resolvedStyleFor(input.slide, input.resolvedStyles);
|
|
9854
|
-
const props = normalizeSlideProps(slideStyleFor(input.slide, input.resolvedStyles));
|
|
9855
|
-
const slideTemplates = input.graph.templates.get(sourceKeyForOrigin$1(input.slide.origin.source));
|
|
9856
|
-
const backgroundInput = backgroundInputFor(resolved, props);
|
|
9857
|
-
const slideFill = resolveBackgroundLayersSafely({
|
|
9858
|
-
property: backgroundInput?.property ?? "background",
|
|
9859
|
-
value: backgroundInput?.value
|
|
9860
|
-
}, props.backgroundTransparency, {
|
|
9861
|
-
widthEmu: input.slideFrame.widthEmu,
|
|
9862
|
-
heightEmu: input.slideFrame.heightEmu
|
|
9863
|
-
}, input.slideFrame, {
|
|
9864
|
-
borderBox: input.slideFrame,
|
|
9865
|
-
paddingBox: input.slideFrame,
|
|
9866
|
-
contentBox: input.slideFrame
|
|
9867
|
-
}, props.backgroundPosition, props.backgroundSize, props.backgroundRepeat, props.backgroundOrigin, props.backgroundClip);
|
|
9868
9935
|
const backgroundLayers = projectBackgroundLayers({
|
|
9869
|
-
layers: input.layoutSlide
|
|
9936
|
+
layers: input.layoutSlide.backgroundLayers,
|
|
9870
9937
|
indexPath: [5e3 + input.slideIndex]
|
|
9871
9938
|
});
|
|
9939
|
+
const origin = elementOriginFromLayoutOrigin(input.layoutSlide.origin);
|
|
9872
9940
|
return {
|
|
9873
9941
|
id: partId,
|
|
9874
9942
|
category: "authored-content",
|
|
9875
9943
|
kind: "slide",
|
|
9876
9944
|
path: `ppt/slides/slide${slideNumber}.xml`,
|
|
9877
|
-
origin
|
|
9878
|
-
graphNodeIds: [input.slide.id],
|
|
9879
|
-
...input.slide.origin.source ? { source: input.slide.origin.source } : {}
|
|
9880
|
-
},
|
|
9945
|
+
origin,
|
|
9881
9946
|
relationships: [{
|
|
9882
9947
|
id: serializedId("rId1"),
|
|
9883
9948
|
target: projectedRelationshipTarget({
|
|
@@ -9890,18 +9955,14 @@ function pptxSlidePartFor(input) {
|
|
|
9890
9955
|
}],
|
|
9891
9956
|
payload: {
|
|
9892
9957
|
slideId: String(256 + input.slideIndex),
|
|
9893
|
-
name: input.
|
|
9894
|
-
background: input.layoutSlide
|
|
9958
|
+
name: input.layoutSlide.name,
|
|
9959
|
+
background: input.layoutSlide.background,
|
|
9895
9960
|
...backgroundLayers ? { backgroundLayers } : {},
|
|
9896
|
-
drawing: drawingFromElements(input.layoutSlide
|
|
9961
|
+
drawing: drawingFromElements(input.layoutSlide.nodes.map((node, index) => mapProjectedLayoutNodeToElement({
|
|
9897
9962
|
node,
|
|
9898
|
-
graph: input.graph,
|
|
9899
9963
|
packagePartId: partId,
|
|
9900
9964
|
indexPath: [index]
|
|
9901
|
-
}))
|
|
9902
|
-
viewportWidthEmu: input.slideFrame.widthEmu,
|
|
9903
|
-
viewportHeightEmu: input.slideFrame.heightEmu
|
|
9904
|
-
}))
|
|
9965
|
+
})))
|
|
9905
9966
|
}
|
|
9906
9967
|
};
|
|
9907
9968
|
}
|
|
@@ -10748,7 +10809,15 @@ function projectGraphToPptxPackageInternal(input) {
|
|
|
10748
10809
|
size,
|
|
10749
10810
|
slideIds
|
|
10750
10811
|
});
|
|
10751
|
-
const
|
|
10812
|
+
const layoutInput = input.partial ? void 0 : buildLayoutInputSnapshot({
|
|
10813
|
+
graph: input.graph,
|
|
10814
|
+
resolvedStyles: input.resolvedStyles,
|
|
10815
|
+
assetProbeArtifacts: input.assets,
|
|
10816
|
+
deckSize: size,
|
|
10817
|
+
diagnostics: input.diagnostics,
|
|
10818
|
+
meta: input.options.meta
|
|
10819
|
+
});
|
|
10820
|
+
const projectedLayout = layoutInput ? resolveProjectedLayout(input.options, layoutInput.snapshot) : void 0;
|
|
10752
10821
|
const slideFrame = {
|
|
10753
10822
|
xEmu: 0,
|
|
10754
10823
|
yEmu: 0,
|
|
@@ -10758,6 +10827,7 @@ function projectGraphToPptxPackageInternal(input) {
|
|
|
10758
10827
|
const projectedSlidesWithMedia = withCanonicalImageMediaPartIds(slideIds.flatMap((slideId, slideIndex) => {
|
|
10759
10828
|
const slide = input.graph.nodes.get(slideId);
|
|
10760
10829
|
if (slide?.kind !== "slide") return [];
|
|
10830
|
+
const layoutSlide = projectedLayout?.slides[slideIndex];
|
|
10761
10831
|
const partId = slidePartIdFor(slide);
|
|
10762
10832
|
const slideLayoutPart = slideLayoutPartForSlide({
|
|
10763
10833
|
graph: input.graph,
|
|
@@ -10765,7 +10835,7 @@ function projectGraphToPptxPackageInternal(input) {
|
|
|
10765
10835
|
slideLayoutParts: supportParts.slideLayoutParts,
|
|
10766
10836
|
defaultSlideLayoutPart: supportParts.slideLayoutPart
|
|
10767
10837
|
});
|
|
10768
|
-
|
|
10838
|
+
if (input.partial) return [partialPptxSlidePartFor({
|
|
10769
10839
|
graph: input.graph,
|
|
10770
10840
|
resolvedStyles: input.resolvedStyles,
|
|
10771
10841
|
slide,
|
|
@@ -10773,11 +10843,10 @@ function projectGraphToPptxPackageInternal(input) {
|
|
|
10773
10843
|
slideFrame,
|
|
10774
10844
|
slideLayoutPart,
|
|
10775
10845
|
slidePartId: partId
|
|
10776
|
-
})
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
layoutSlide: projectedLayout?.slides[slideIndex],
|
|
10846
|
+
})];
|
|
10847
|
+
if (!layoutSlide) return [];
|
|
10848
|
+
return [pptxSlidePartFor({
|
|
10849
|
+
layoutSlide,
|
|
10781
10850
|
slideIndex,
|
|
10782
10851
|
slideFrame,
|
|
10783
10852
|
slideLayoutPart,
|
|
@@ -10907,7 +10976,7 @@ async function loadNodeOutputRuntime() {
|
|
|
10907
10976
|
const status = nodeOutputRuntimeStatus();
|
|
10908
10977
|
if (!status.ok) return status;
|
|
10909
10978
|
try {
|
|
10910
|
-
const { createNodeOutputByteSink, writeNodeOutput } = await import("./node-output-
|
|
10979
|
+
const { createNodeOutputByteSink, writeNodeOutput } = await import("./node-output-BXQOTLKj.mjs");
|
|
10911
10980
|
return {
|
|
10912
10981
|
ok: true,
|
|
10913
10982
|
createByteSink: createNodeOutputByteSink,
|