@officedk/pptxdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/build.d.ts +94 -0
- package/dist/build.js +148 -0
- package/dist/capabilities/dist/all.js +32 -0
- package/dist/capabilities/dist/box/box-codegen.js +51 -0
- package/dist/capabilities/dist/box/box-declaration.js +31 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +138 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2272 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1124 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +190 -0
- package/dist/capabilities/dist/chart/preview/layout.js +519 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +48 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +148 -0
- package/dist/capabilities/dist/font/font-embedding.js +289 -0
- package/dist/capabilities/dist/font/font-family.js +10 -0
- package/dist/capabilities/dist/font/font-import.js +302 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +25 -0
- package/dist/capabilities/dist/group/group-codegen.js +51 -0
- package/dist/capabilities/dist/group/group-declaration.js +42 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +319 -0
- package/dist/capabilities/dist/group/group-xml.js +7 -0
- package/dist/capabilities/dist/group/group.js +211 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +94 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +221 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +778 -0
- package/dist/capabilities/dist/image/image-schemas.js +149 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +472 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +527 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1033 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
- package/dist/capabilities/dist/motion/motion-query.js +420 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
- package/dist/capabilities/dist/motion/motion.js +1372 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +191 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +579 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +337 -0
- package/dist/capabilities/dist/shared/geometry.js +1423 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
- package/dist/capabilities/dist/shared/style-parse.js +11 -0
- package/dist/capabilities/dist/shared/text-schemas.js +216 -0
- package/dist/capabilities/dist/shared/text-service.js +1883 -0
- package/dist/capabilities/dist/shared/visual.js +918 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
- package/dist/capabilities/dist/table/table-codegen.js +81 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +539 -0
- package/dist/capabilities/dist/table/table-schemas.js +279 -0
- package/dist/capabilities/dist/table/table-xml.js +37 -0
- package/dist/capabilities/dist/table/table.js +662 -0
- package/dist/capabilities/dist/text/text-codegen.js +129 -0
- package/dist/capabilities/dist/text/text-declaration.js +19 -0
- package/dist/capabilities/dist/text/text-elements.js +38 -0
- package/dist/capabilities/dist/text/text-import.js +1077 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +335 -0
- package/dist/capabilities/dist/transition/transition-api.js +139 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-D_xeNVIw.d.ts +29496 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +78 -0
- package/dist/codegen/dist/codegen.js +611 -0
- package/dist/codegen/dist/identifiers.js +193 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +49 -0
- package/dist/core/dist/author-ids.js +48 -0
- package/dist/core/dist/author-schemas.js +313 -0
- package/dist/core/dist/block-flex-layout.js +749 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +13 -0
- package/dist/core/dist/declaration.js +15 -0
- package/dist/core/dist/diagnostics.js +21 -0
- package/dist/core/dist/document-internals.js +13 -0
- package/dist/core/dist/document.js +408 -0
- package/dist/core/dist/geometry-schemas.js +249 -0
- package/dist/core/dist/grid-layout.js +445 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +45 -0
- package/dist/core/dist/layout-protocol.js +66 -0
- package/dist/core/dist/layout-schemas.js +208 -0
- package/dist/core/dist/layout.js +299 -0
- package/dist/core/dist/masters.js +169 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +213 -0
- package/dist/core/dist/query.js +155 -0
- package/dist/core/dist/resolution.js +11 -0
- package/dist/core/dist/resolve.js +1827 -0
- package/dist/core/dist/stage-options.js +67 -0
- package/dist/core/dist/theme.js +931 -0
- package/dist/document-BHPUODPP.d.ts +27759 -0
- package/dist/emit/dist/emit.js +936 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +606 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +153 -0
- package/dist/import/dist/fonts.js +250 -0
- package/dist/import/dist/import.js +504 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1153 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +60 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +671 -0
- package/dist/import/dist/visual.js +761 -0
- package/dist/import/dist/xml-fragments.js +36 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-B5m3hqjC.d.ts +7 -0
- package/dist/index-CCy-Yo8G.d.ts +1208 -0
- package/dist/index-DpxcZ4Gs.d.ts +725 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +70 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +194 -0
- package/dist/pptxdk/src/cli-commands.js +913 -0
- package/dist/pptxdk/src/compose.js +44 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +240 -0
- package/dist/preview/dist/options.js +53 -0
- package/dist/preview-Cfw0QdMM.d.ts +86 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +27 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +65 -0
- package/dist/react/dist/elements.js +59 -0
- package/dist/react/dist/index.js +68 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +145 -0
- package/dist/react.js +27 -0
- package/dist/transition-Cips9wma.d.ts +82 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +14 -0
- package/package.json +78 -3
|
@@ -0,0 +1,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 { BuildError, CapabilityError } from "./diagnostics.js";
|
|
2
|
+
import { authorIdSchema } from "./author-ids.js";
|
|
3
|
+
import { backgroundRefSchema, deckPropsSchema, linkTargetSchema, placeholderSizeSchema, sectionPropsSchema, slideBackgroundSchema, slideFooterValueSchema, slideNumberValueSchema, slidePropsSchema } from "./author-schemas.js";
|
|
4
|
+
import { createMorphScope } from "./morph.js";
|
|
5
|
+
import "./geometry-schemas.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, slideLayoutDataPropsSchema, slideLayoutObservationSchema, slideLayoutTypeSchema, slideLayoutTypeValues, slideMasterDataPropsSchema, slideMasterObservationSchema } from "./masters.js";
|
|
9
|
+
import { allocatePlaceholderAuthorKeys, layoutPlaceholderSpecSchema, masterPlaceholderSpecSchema, masterTextStylesSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSzSchema } from "./placeholders.js";
|
|
10
|
+
import { assertValidLang, colorMapOverrideSchema, colorMapSchema, darker, defaultColorMap, defaultTheme, defineTheme, formatSchemeSchema, isNativeColorSlot, isSchemeColorName, isSchemeColorSlot, isTheme, lighter, nativeColorSlots, schemeColorNameSchema, schemeColorNames, schemeColorSlots, textStyleSchema, themeDataSchema, themeInputSchema, themeOverrideSchema, themeSchema, themeScopeSchema } from "./theme.js";
|
|
11
|
+
import "./block-flex-layout.js";
|
|
12
|
+
import "./layout.js";
|
|
13
|
+
import { BuildQueryError } from "./query.js";
|
|
14
|
+
import { buildOptionsSchema, diagnosticSchema, diagnosticSeveritySchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets } from "./stage-options.js";
|
|
15
|
+
export { AuthorQuery, AuthorQueryError, BuildError, BuildQueryError, CapabilityError, CommonContainer, CommonNode, DeckContainer, RichTextContainer, SlideContainer, SlideLayoutContainer, SlideMasterContainer, allocatePlaceholderAuthorKeys, assertValidLang, authorIdSchema, backgroundRefSchema, buildOptionsSchema, colorMapOverrideSchema, colorMapSchema, createMorphScope, darker, deckPropsSchema, defaultColorMap, defaultTheme, defineSlideLayout, defineTheme, diagnosticSchema, diagnosticSeveritySchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, footerPlaceholderSpecSchema, footerPlaceholdersSchema, formatBaseline, formatBaselineSchema, formatSchemeSchema, headerFooterSchema, isNativeColorSlot, isSchemeColorName, isSchemeColorSlot, isSlideLayoutDefinition, isTheme, layoutLengthSchema, layoutPlaceholderSpecSchema, layoutSpacingSchema, layoutStyleSchema, lighter, linkTargetSchema, masterPlaceholderSpecSchema, masterTextStylesSchema, nativeColorSlots, paddingStyleSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSizeSchema, placeholderSzSchema, resolveOptionsSchema, schemeColorNameSchema, schemeColorNames, schemeColorSlots, sectionPropsSchema, slideBackgroundSchema, slideFooterValueSchema, slideLayoutDataPropsSchema, slideLayoutObservationSchema, slideLayoutTypeSchema, slideLayoutTypeValues, slideMasterDataPropsSchema, slideMasterObservationSchema, slideNumberValueSchema, slidePropsSchema, targetNameSchema, targetSchema, targets, textStyleSchema, themeDataSchema, themeInputSchema, themeOverrideSchema, themeSchema, themeScopeSchema };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { replaceDeclarationProps } from "./document-internals.js";
|
|
2
|
+
import { isMorphKey } from "./morph.js";
|
|
3
|
+
// ../core/dist/input-values.js
|
|
4
|
+
const slideLayoutDefinitionSymbol = Symbol.for("@pptxdk/core/slide-layout-definition");
|
|
5
|
+
const themeBrandSymbol = Symbol.for("@pptxdk/core/theme");
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function preservesIdentity(value) {
|
|
10
|
+
if (isMorphKey(value) || slideLayoutDefinitionSymbol in value || themeBrandSymbol in value) return true;
|
|
11
|
+
if (replaceDeclarationProps in value) return true;
|
|
12
|
+
return isRecord(value) && Object.getOwnPropertyDescriptor(value, "type")?.value === "motion-scope-handle";
|
|
13
|
+
}
|
|
14
|
+
function isRecordValue(value) {
|
|
15
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Copies author-owned values received by a declaration entry.
|
|
19
|
+
*
|
|
20
|
+
* Record values, arrays, URLs, and byte views are isolated recursively. Enumerable getters are read
|
|
21
|
+
* at receipt, while behavior handles and opaque objects keep their identity. This is a field-level
|
|
22
|
+
* authoring rule, not a general document clone.
|
|
23
|
+
*/
|
|
24
|
+
function snapshotValue(value) {
|
|
25
|
+
if (value === null || typeof value !== "object") return value;
|
|
26
|
+
if (value instanceof Uint8Array) return new Uint8Array(value);
|
|
27
|
+
if (value instanceof ArrayBuffer) return value.slice(0);
|
|
28
|
+
if (value instanceof URL) return new URL(value.href);
|
|
29
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshotValue(item)));
|
|
30
|
+
if (preservesIdentity(value)) return value;
|
|
31
|
+
if (!isRecordValue(value)) return value;
|
|
32
|
+
const copy = Object.create(null);
|
|
33
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
34
|
+
if (Object.getOwnPropertyDescriptor(value, key)?.enumerable !== true) continue;
|
|
35
|
+
const observedValue = Reflect.get(value, key);
|
|
36
|
+
Object.defineProperty(copy, key, {
|
|
37
|
+
configurable: false,
|
|
38
|
+
enumerable: true,
|
|
39
|
+
value: snapshotValue(observedValue),
|
|
40
|
+
writable: false
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return Object.freeze(copy);
|
|
44
|
+
}
|
|
45
|
+
export { snapshotValue };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BuildError } from "./diagnostics.js";
|
|
2
|
+
// ../core/dist/layout-protocol.js
|
|
3
|
+
function failLayoutProtocol(path, code, message) {
|
|
4
|
+
throw new BuildError([{
|
|
5
|
+
severity: "error",
|
|
6
|
+
path,
|
|
7
|
+
code,
|
|
8
|
+
message
|
|
9
|
+
}]);
|
|
10
|
+
}
|
|
11
|
+
function parseLayoutNumber(value, name, path) {
|
|
12
|
+
if (typeof value !== "number" || !Number.isFinite(value)) failLayoutProtocol(path, "invalid-layout-style", `${name} must be a finite pixel number`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function parseLayoutSpacing(value, name, path) {
|
|
16
|
+
if (value === void 0) return {
|
|
17
|
+
top: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
bottom: 0,
|
|
20
|
+
left: 0
|
|
21
|
+
};
|
|
22
|
+
if (typeof value === "number") {
|
|
23
|
+
const amount = parseLayoutNumber(value, name, path);
|
|
24
|
+
return {
|
|
25
|
+
top: amount,
|
|
26
|
+
right: amount,
|
|
27
|
+
bottom: amount,
|
|
28
|
+
left: amount
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
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`);
|
|
32
|
+
const values = value.map((item) => parseLayoutNumber(item, name, path));
|
|
33
|
+
if (values.length === 2) return {
|
|
34
|
+
top: values[0],
|
|
35
|
+
right: values[1],
|
|
36
|
+
bottom: values[0],
|
|
37
|
+
left: values[1]
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
top: values[0],
|
|
41
|
+
right: values[1],
|
|
42
|
+
bottom: values[2],
|
|
43
|
+
left: values[3]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function expandedSpacing(style, kind) {
|
|
47
|
+
const base = parseLayoutSpacing(style[kind], kind, "layout");
|
|
48
|
+
if (kind === "margin") return {
|
|
49
|
+
top: style.marginTop ?? base.top,
|
|
50
|
+
right: style.marginRight ?? base.right,
|
|
51
|
+
bottom: style.marginBottom ?? base.bottom,
|
|
52
|
+
left: style.marginLeft ?? base.left
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
top: style.paddingTop ?? base.top,
|
|
56
|
+
right: style.paddingRight ?? base.right,
|
|
57
|
+
bottom: style.paddingBottom ?? base.bottom,
|
|
58
|
+
left: style.paddingLeft ?? base.left
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function resolvePercent(value, basis) {
|
|
62
|
+
if (typeof value !== "string") return void 0;
|
|
63
|
+
const match = /^(-?(?:\d+(?:\.\d*)?|\.\d+))%$/u.exec(value);
|
|
64
|
+
return match === null ? void 0 : Number(match[1]) * basis / 100;
|
|
65
|
+
}
|
|
66
|
+
export { expandedSpacing, parseLayoutNumber, parseLayoutSpacing, resolvePercent };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { BuildError } from "./diagnostics.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// ../core/dist/layout-schemas.js
|
|
4
|
+
const percentPattern = /^(-?(?:\d+(?:\.\d*)?|\.\d+))%$/u;
|
|
5
|
+
const nonNegativePercentPattern = /^(\d+(?:\.\d*)?|\.\d+)%$/u;
|
|
6
|
+
const percentLengthSchema = z.string().regex(percentPattern, "must be a pixel number, percentage, or auto");
|
|
7
|
+
const nonNegativePercentLengthSchema = z.string().regex(nonNegativePercentPattern, "must be a non-negative pixel number, percentage, or auto");
|
|
8
|
+
/** Fixed canvas length; numeric values are interpreted in pixels, percentages are evaluated against the parent layout region. */
|
|
9
|
+
const layoutLengthSchema = z.union([
|
|
10
|
+
z.number().finite(),
|
|
11
|
+
percentLengthSchema,
|
|
12
|
+
z.literal("auto")
|
|
13
|
+
]);
|
|
14
|
+
const nonNegativeLayoutLengthSchema = z.union([
|
|
15
|
+
z.number().finite().nonnegative(),
|
|
16
|
+
nonNegativePercentLengthSchema,
|
|
17
|
+
z.literal("auto")
|
|
18
|
+
]);
|
|
19
|
+
const layoutSpacingSchema = z.union([
|
|
20
|
+
z.number().finite(),
|
|
21
|
+
z.tuple([z.number().finite(), z.number().finite()]).readonly(),
|
|
22
|
+
z.tuple([
|
|
23
|
+
z.number().finite(),
|
|
24
|
+
z.number().finite(),
|
|
25
|
+
z.number().finite(),
|
|
26
|
+
z.number().finite()
|
|
27
|
+
]).readonly()
|
|
28
|
+
]);
|
|
29
|
+
const nonNegativeLayoutSpacingSchema = z.union([
|
|
30
|
+
z.number().finite().nonnegative(),
|
|
31
|
+
z.tuple([z.number().finite().nonnegative(), z.number().finite().nonnegative()]).readonly(),
|
|
32
|
+
z.tuple([
|
|
33
|
+
z.number().finite().nonnegative(),
|
|
34
|
+
z.number().finite().nonnegative(),
|
|
35
|
+
z.number().finite().nonnegative(),
|
|
36
|
+
z.number().finite().nonnegative()
|
|
37
|
+
]).readonly()
|
|
38
|
+
]);
|
|
39
|
+
const paddingStyleSchema = z.strictObject({
|
|
40
|
+
padding: nonNegativeLayoutSpacingSchema.optional(),
|
|
41
|
+
paddingTop: z.number().finite().nonnegative().optional(),
|
|
42
|
+
paddingRight: z.number().finite().nonnegative().optional(),
|
|
43
|
+
paddingBottom: z.number().finite().nonnegative().optional(),
|
|
44
|
+
paddingLeft: z.number().finite().nonnegative().optional()
|
|
45
|
+
}).readonly();
|
|
46
|
+
const layoutDisplaySchema = z.enum([
|
|
47
|
+
"block",
|
|
48
|
+
"flex",
|
|
49
|
+
"grid",
|
|
50
|
+
"none"
|
|
51
|
+
]);
|
|
52
|
+
const layoutPositionSchema = z.enum([
|
|
53
|
+
"static",
|
|
54
|
+
"relative",
|
|
55
|
+
"absolute"
|
|
56
|
+
]);
|
|
57
|
+
const flexDirectionSchema = z.enum([
|
|
58
|
+
"row",
|
|
59
|
+
"column",
|
|
60
|
+
"row-reverse",
|
|
61
|
+
"column-reverse"
|
|
62
|
+
]);
|
|
63
|
+
const flexWrapSchema = z.enum(["nowrap", "wrap"]);
|
|
64
|
+
const justifyContentSchema = z.enum([
|
|
65
|
+
"start",
|
|
66
|
+
"end",
|
|
67
|
+
"center",
|
|
68
|
+
"flex-start",
|
|
69
|
+
"flex-end",
|
|
70
|
+
"space-between",
|
|
71
|
+
"space-around",
|
|
72
|
+
"space-evenly"
|
|
73
|
+
]);
|
|
74
|
+
const alignItemsSchema = z.enum([
|
|
75
|
+
"start",
|
|
76
|
+
"end",
|
|
77
|
+
"center",
|
|
78
|
+
"stretch",
|
|
79
|
+
"flex-start",
|
|
80
|
+
"flex-end",
|
|
81
|
+
"baseline"
|
|
82
|
+
]);
|
|
83
|
+
const alignSelfSchema = z.enum([
|
|
84
|
+
"auto",
|
|
85
|
+
"start",
|
|
86
|
+
"end",
|
|
87
|
+
"center",
|
|
88
|
+
"stretch",
|
|
89
|
+
"flex-start",
|
|
90
|
+
"flex-end",
|
|
91
|
+
"baseline"
|
|
92
|
+
]);
|
|
93
|
+
const alignContentSchema = z.enum([
|
|
94
|
+
"start",
|
|
95
|
+
"end",
|
|
96
|
+
"center",
|
|
97
|
+
"flex-start",
|
|
98
|
+
"flex-end",
|
|
99
|
+
"space-between",
|
|
100
|
+
"space-around",
|
|
101
|
+
"space-evenly",
|
|
102
|
+
"stretch"
|
|
103
|
+
]);
|
|
104
|
+
const justifyItemsSchema = z.enum([
|
|
105
|
+
"start",
|
|
106
|
+
"end",
|
|
107
|
+
"center",
|
|
108
|
+
"stretch",
|
|
109
|
+
"flex-start",
|
|
110
|
+
"flex-end"
|
|
111
|
+
]);
|
|
112
|
+
const justifySelfSchema = z.enum([
|
|
113
|
+
"auto",
|
|
114
|
+
"start",
|
|
115
|
+
"end",
|
|
116
|
+
"center",
|
|
117
|
+
"stretch",
|
|
118
|
+
"flex-start",
|
|
119
|
+
"flex-end"
|
|
120
|
+
]);
|
|
121
|
+
/** Fixed canvas CSS layout subset; numeric lengths are interpreted in pixels. */
|
|
122
|
+
const layoutStyleObjectSchema = z.strictObject({
|
|
123
|
+
display: layoutDisplaySchema.optional(),
|
|
124
|
+
position: layoutPositionSchema.optional(),
|
|
125
|
+
inset: layoutLengthSchema.optional(),
|
|
126
|
+
left: layoutLengthSchema.optional(),
|
|
127
|
+
top: layoutLengthSchema.optional(),
|
|
128
|
+
right: layoutLengthSchema.optional(),
|
|
129
|
+
bottom: layoutLengthSchema.optional(),
|
|
130
|
+
width: nonNegativeLayoutLengthSchema.optional(),
|
|
131
|
+
height: nonNegativeLayoutLengthSchema.optional(),
|
|
132
|
+
minWidth: nonNegativeLayoutLengthSchema.optional(),
|
|
133
|
+
minHeight: nonNegativeLayoutLengthSchema.optional(),
|
|
134
|
+
maxWidth: nonNegativeLayoutLengthSchema.optional(),
|
|
135
|
+
maxHeight: nonNegativeLayoutLengthSchema.optional(),
|
|
136
|
+
margin: layoutSpacingSchema.optional(),
|
|
137
|
+
marginTop: z.number().finite().optional(),
|
|
138
|
+
marginRight: z.number().finite().optional(),
|
|
139
|
+
marginBottom: z.number().finite().optional(),
|
|
140
|
+
marginLeft: z.number().finite().optional(),
|
|
141
|
+
padding: nonNegativeLayoutSpacingSchema.optional(),
|
|
142
|
+
paddingTop: z.number().finite().nonnegative().optional(),
|
|
143
|
+
paddingRight: z.number().finite().nonnegative().optional(),
|
|
144
|
+
paddingBottom: z.number().finite().nonnegative().optional(),
|
|
145
|
+
paddingLeft: z.number().finite().nonnegative().optional(),
|
|
146
|
+
gap: z.number().finite().nonnegative().optional(),
|
|
147
|
+
rowGap: z.number().finite().nonnegative().optional(),
|
|
148
|
+
columnGap: z.number().finite().nonnegative().optional(),
|
|
149
|
+
flexDirection: flexDirectionSchema.optional(),
|
|
150
|
+
flexWrap: flexWrapSchema.optional(),
|
|
151
|
+
justifyContent: justifyContentSchema.optional(),
|
|
152
|
+
alignItems: alignItemsSchema.optional(),
|
|
153
|
+
alignSelf: alignSelfSchema.optional(),
|
|
154
|
+
alignContent: alignContentSchema.optional(),
|
|
155
|
+
flex: z.number().finite().nonnegative().optional(),
|
|
156
|
+
flexGrow: z.number().finite().nonnegative().optional(),
|
|
157
|
+
flexShrink: z.number().finite().nonnegative().optional(),
|
|
158
|
+
flexBasis: nonNegativeLayoutLengthSchema.optional(),
|
|
159
|
+
aspectRatio: z.number().finite().positive().optional(),
|
|
160
|
+
gridTemplateColumns: z.string().optional(),
|
|
161
|
+
gridTemplateRows: z.string().optional(),
|
|
162
|
+
/** Track sizes for implicit Grid rows, cycling in order like CSS `grid-auto-rows`; defaults to `auto`. */
|
|
163
|
+
gridAutoRows: z.string().optional(),
|
|
164
|
+
gridColumn: z.union([z.number(), z.string()]).optional(),
|
|
165
|
+
gridRow: z.union([z.number(), z.string()]).optional(),
|
|
166
|
+
justifyItems: justifyItemsSchema.optional(),
|
|
167
|
+
justifySelf: justifySelfSchema.optional(),
|
|
168
|
+
zIndex: z.number().finite().optional()
|
|
169
|
+
});
|
|
170
|
+
const layoutStyleSchema = layoutStyleObjectSchema.readonly();
|
|
171
|
+
const slideLayoutStyleObjectSchema = layoutStyleObjectSchema.omit({ zIndex: true });
|
|
172
|
+
const slideLayoutStyleShape = slideLayoutStyleObjectSchema.shape;
|
|
173
|
+
slideLayoutStyleObjectSchema.readonly();
|
|
174
|
+
const enumLayoutStyleKeys = /* @__PURE__ */ new Set([
|
|
175
|
+
"display",
|
|
176
|
+
"position",
|
|
177
|
+
"flexDirection",
|
|
178
|
+
"flexWrap",
|
|
179
|
+
"justifyContent",
|
|
180
|
+
"alignItems",
|
|
181
|
+
"alignSelf",
|
|
182
|
+
"alignContent",
|
|
183
|
+
"justifyItems",
|
|
184
|
+
"justifySelf"
|
|
185
|
+
]);
|
|
186
|
+
const layoutSchemaKeys = new Set(Object.keys(layoutStyleObjectSchema.shape));
|
|
187
|
+
/**
|
|
188
|
+
* Validates pure value shapes of layout properties present in `style`, preserving existing
|
|
189
|
+
* BuildError diagnostic codes (`unsupported-layout-value` for enum mismatches, `invalid-layout-style`
|
|
190
|
+
* for invalid lengths, spacing, numbers, or grid track/placement types).
|
|
191
|
+
*/
|
|
192
|
+
function validateLayoutStyleValues(style, path) {
|
|
193
|
+
const layoutEntries = {};
|
|
194
|
+
for (const [key, value] of Object.entries(style)) if (layoutSchemaKeys.has(key) && value !== void 0) layoutEntries[key] = value;
|
|
195
|
+
const parsed = layoutStyleSchema.safeParse(layoutEntries);
|
|
196
|
+
if (parsed.success) return;
|
|
197
|
+
const issue = parsed.error.issues[0];
|
|
198
|
+
const key = typeof issue?.path[0] === "string" ? issue.path[0] : void 0;
|
|
199
|
+
const code = key !== void 0 && enumLayoutStyleKeys.has(key) ? "unsupported-layout-value" : "invalid-layout-style";
|
|
200
|
+
const message = key === void 0 ? issue?.message ?? "Invalid layout style" : `${key}: ${issue?.message ?? "invalid value"}`;
|
|
201
|
+
throw new BuildError([{
|
|
202
|
+
severity: "error",
|
|
203
|
+
path,
|
|
204
|
+
code,
|
|
205
|
+
message
|
|
206
|
+
}]);
|
|
207
|
+
}
|
|
208
|
+
export { alignContentSchema, alignItemsSchema, alignSelfSchema, flexDirectionSchema, flexWrapSchema, justifyContentSchema, justifyItemsSchema, justifySelfSchema, layoutDisplaySchema, layoutLengthSchema, layoutPositionSchema, layoutSpacingSchema, layoutStyleSchema, nonNegativeLayoutLengthSchema, nonNegativeLayoutSpacingSchema, paddingStyleSchema, slideLayoutStyleShape, validateLayoutStyleValues };
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { blockFlexLayoutProperties, createBlockFlexLayoutSolver, isStyleRecord, paddingStyleKeys, validateBlockFlexContainerContext, validateBlockFlexContainerProperties, validateBlockFlexLayoutContextBounds } from "./block-flex-layout.js";
|
|
2
|
+
import { BuildError, CapabilityError } from "./diagnostics.js";
|
|
3
|
+
import { gridLayoutMode } from "./grid-layout.js";
|
|
4
|
+
import { expandedSpacing } from "./layout-protocol.js";
|
|
5
|
+
import { validateLayoutStyleValues } from "./layout-schemas.js";
|
|
6
|
+
import { textStyleKeys } from "./theme.js";
|
|
7
|
+
// ../core/dist/layout.js
|
|
8
|
+
const customContainerModes = [gridLayoutMode];
|
|
9
|
+
const layoutProperties = [...blockFlexLayoutProperties, ...customContainerModes.flatMap((mode) => [...mode.containerStyleKeys, ...mode.itemStyleKeys])];
|
|
10
|
+
const layoutPropertySet = new Set(layoutProperties);
|
|
11
|
+
const layoutStyleKeys = layoutProperties.filter((key) => !paddingStyleKeys.includes(key));
|
|
12
|
+
function diagnostic(path, code, message) {
|
|
13
|
+
return {
|
|
14
|
+
severity: "error",
|
|
15
|
+
path,
|
|
16
|
+
code,
|
|
17
|
+
message
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function fail(path, code, message) {
|
|
21
|
+
throw new BuildError([diagnostic(path, code, message)]);
|
|
22
|
+
}
|
|
23
|
+
function element(child) {
|
|
24
|
+
return "props" in child;
|
|
25
|
+
}
|
|
26
|
+
function identity(element) {
|
|
27
|
+
const id = element.props["id"];
|
|
28
|
+
return typeof id === "string" && id.trim() !== "" ? id : void 0;
|
|
29
|
+
}
|
|
30
|
+
function label(element, index) {
|
|
31
|
+
return `${element.type}[${identity(element) ?? String(index + 1)}]`;
|
|
32
|
+
}
|
|
33
|
+
function readStyle(value, path, isContainer, allowsPadding = isContainer, allowedPresentation = /* @__PURE__ */ new Set()) {
|
|
34
|
+
if (value === void 0) return {};
|
|
35
|
+
if (!isStyleRecord(value)) fail(path, "invalid-layout-style", "style must be an object");
|
|
36
|
+
const unknown = Object.keys(value).find((key) => !layoutPropertySet.has(key) && !allowedPresentation.has(key));
|
|
37
|
+
if (unknown !== void 0) fail(path, "unsupported-layout-style", `style contains unsupported property ${unknown}`);
|
|
38
|
+
const resolvedDisplay = validateBlockFlexContainerContext(value, path, isContainer, customContainerModes);
|
|
39
|
+
validateBlockFlexContainerProperties(value, resolvedDisplay, path, customContainerModes);
|
|
40
|
+
for (const mode of customContainerModes) mode.validateContainerStyle(value, resolvedDisplay, path);
|
|
41
|
+
validateLayoutStyleValues(value, path);
|
|
42
|
+
for (const mode of customContainerModes) mode.validateStyleValues(value, path);
|
|
43
|
+
validateBlockFlexLayoutContextBounds(value, allowsPadding, path);
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parses and validates host props into a CapabilityLayoutContract for object capabilities.
|
|
48
|
+
*/
|
|
49
|
+
function parseCapabilityLayoutContract(options) {
|
|
50
|
+
const { nativeKind, props, allowedStyleKeys, allowPadding = false, isContainer = false } = options;
|
|
51
|
+
const path = options.path ?? "style";
|
|
52
|
+
const rawStyle = props["style"];
|
|
53
|
+
if (rawStyle !== void 0) {
|
|
54
|
+
if (!isStyleRecord(rawStyle)) throw new CapabilityError("invalid-style", "style must be an object", options.path);
|
|
55
|
+
if (!allowPadding) {
|
|
56
|
+
if (paddingStyleKeys.find((key) => rawStyle[key] !== void 0) !== void 0) throw new CapabilityError("invalid-layout-context", "padding is only applicable to layout containers", options.path);
|
|
57
|
+
}
|
|
58
|
+
const unknown = Object.keys(rawStyle).find((key) => rawStyle[key] !== void 0 && !allowedStyleKeys.has(key));
|
|
59
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-style", `style contains unsupported property ${unknown}`, options.path);
|
|
60
|
+
}
|
|
61
|
+
const layoutStyle = readStyle(rawStyle, path, isContainer, allowPadding, allowedStyleKeys);
|
|
62
|
+
let padding;
|
|
63
|
+
if (allowPadding && rawStyle !== void 0) {
|
|
64
|
+
if (paddingStyleKeys.some((key) => rawStyle[key] !== void 0)) {
|
|
65
|
+
const edges = expandedSpacing(layoutStyle, "padding");
|
|
66
|
+
padding = {
|
|
67
|
+
top: edges.top,
|
|
68
|
+
right: edges.right,
|
|
69
|
+
bottom: edges.bottom,
|
|
70
|
+
left: edges.left
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const x = typeof props["x"] === "number" ? props["x"] : void 0;
|
|
75
|
+
const y = typeof props["y"] === "number" ? props["y"] : void 0;
|
|
76
|
+
const styleWidth = rawStyle !== void 0 ? rawStyle["width"] : void 0;
|
|
77
|
+
const styleHeight = rawStyle !== void 0 ? rawStyle["height"] : void 0;
|
|
78
|
+
const width = styleWidth ?? props["width"];
|
|
79
|
+
const height = styleHeight ?? props["height"];
|
|
80
|
+
return {
|
|
81
|
+
nativeKind,
|
|
82
|
+
...x === void 0 ? {} : { x },
|
|
83
|
+
...y === void 0 ? {} : { y },
|
|
84
|
+
...width === void 0 ? {} : { width },
|
|
85
|
+
...height === void 0 ? {} : { height },
|
|
86
|
+
layoutStyle,
|
|
87
|
+
...padding === void 0 ? {} : { padding }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const nativeElementKinds = /* @__PURE__ */ new Set([
|
|
91
|
+
"sp",
|
|
92
|
+
"pic",
|
|
93
|
+
"grpSp",
|
|
94
|
+
"graphicFrame",
|
|
95
|
+
"cxnSp"
|
|
96
|
+
]);
|
|
97
|
+
function validateBoundObjectCapability(bound) {
|
|
98
|
+
if (typeof bound !== "object" || bound === null) throw new CapabilityError("invalid-capability-binding", "Object capability bind() must return a bound capability object");
|
|
99
|
+
const candidate = bound;
|
|
100
|
+
if (typeof candidate.contract !== "object" || candidate.contract === null || candidate.contract.nativeKind === void 0 || !nativeElementKinds.has(candidate.contract.nativeKind) || typeof candidate.contract.layoutStyle !== "object" || candidate.contract.layoutStyle === null || Array.isArray(candidate.contract.layoutStyle) || typeof candidate.resolve !== "function") throw new CapabilityError("invalid-capability-binding", "Object capability bind() must return a valid contract and resolve handler");
|
|
101
|
+
return bound;
|
|
102
|
+
}
|
|
103
|
+
function objectModule(module) {
|
|
104
|
+
return module !== void 0 && "bind" in module;
|
|
105
|
+
}
|
|
106
|
+
/** Coordinates layout tree construction, capability binding, solver collaboration, and box commitment. */
|
|
107
|
+
var LayoutPass = class {
|
|
108
|
+
#modules;
|
|
109
|
+
#dimensions;
|
|
110
|
+
#slideNumber;
|
|
111
|
+
#options;
|
|
112
|
+
#boxes = /* @__PURE__ */ new WeakMap();
|
|
113
|
+
#themes = /* @__PURE__ */ new WeakMap();
|
|
114
|
+
#hidden = /* @__PURE__ */ new WeakSet();
|
|
115
|
+
#boundObjects = /* @__PURE__ */ new WeakMap();
|
|
116
|
+
#nodeMeta = /* @__PURE__ */ new WeakMap();
|
|
117
|
+
#warnings = [];
|
|
118
|
+
#warningKeys = /* @__PURE__ */ new Set();
|
|
119
|
+
#solver;
|
|
120
|
+
#placeholderFor = () => void 0;
|
|
121
|
+
constructor(modules, dimensions, slideNumber = 1, options = {}) {
|
|
122
|
+
this.#modules = modules;
|
|
123
|
+
this.#dimensions = dimensions;
|
|
124
|
+
this.#slideNumber = slideNumber;
|
|
125
|
+
this.#options = options;
|
|
126
|
+
this.#solver = createBlockFlexLayoutSolver({
|
|
127
|
+
dimensions,
|
|
128
|
+
customContainers: customContainerModes.map((mode) => mode.createSolver((path, code, message) => {
|
|
129
|
+
this.#warnOnce(path, code, message);
|
|
130
|
+
}))
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
run(children, parentPath, theme, slideStyle, placeholderFor) {
|
|
134
|
+
this.#placeholderFor = placeholderFor ?? (() => void 0);
|
|
135
|
+
const rootStyle = readStyle(slideStyle, parentPath, true, true, textStyleKeys);
|
|
136
|
+
const root = this.#solver.createRoot({
|
|
137
|
+
path: parentPath,
|
|
138
|
+
style: rootStyle
|
|
139
|
+
});
|
|
140
|
+
this.#appendChildren(children, parentPath, root, slideStyle !== void 0, theme);
|
|
141
|
+
this.#solver.solve((node, box) => {
|
|
142
|
+
const meta = this.#nodeMeta.get(node);
|
|
143
|
+
if (meta === void 0) return;
|
|
144
|
+
this.#boxes.set(meta.element, box);
|
|
145
|
+
if (meta.checksCanvasOverflow && (box.x < 0 || box.y < 0 || box.x + box.width > this.#dimensions.width || box.y + box.height > this.#dimensions.height)) this.#warnings.push({
|
|
146
|
+
severity: "warning",
|
|
147
|
+
path: node.path,
|
|
148
|
+
code: "overflow",
|
|
149
|
+
message: "Layout container overflows slide canvas; build retains original declaration"
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
boxes: this.#boxes,
|
|
154
|
+
themes: this.#themes,
|
|
155
|
+
hidden: this.#hidden,
|
|
156
|
+
warnings: this.#warnings,
|
|
157
|
+
bound: this.#boundObjects
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
#bindCapability(child, childPath, themeContext, module, placeholder) {
|
|
161
|
+
let bound = this.#boundObjects.get(child);
|
|
162
|
+
if (bound === void 0) try {
|
|
163
|
+
bound = validateBoundObjectCapability(module.bind(child, {
|
|
164
|
+
path: childPath,
|
|
165
|
+
theme: themeContext,
|
|
166
|
+
options: this.#options,
|
|
167
|
+
slideNumber: this.#slideNumber,
|
|
168
|
+
...placeholder === void 0 ? {} : { placeholder }
|
|
169
|
+
}));
|
|
170
|
+
this.#boundObjects.set(child, bound);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error instanceof BuildError) throw error;
|
|
173
|
+
const code = error instanceof CapabilityError ? error.code : "invalid-capability-input";
|
|
174
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
175
|
+
return fail(error instanceof CapabilityError && error.path !== void 0 ? error.path.startsWith(childPath) ? error.path : `${childPath}/${error.path}` : childPath, code, message);
|
|
176
|
+
}
|
|
177
|
+
return bound;
|
|
178
|
+
}
|
|
179
|
+
#appendChildren(children, parentPath, parent, includeObjects, themeContext) {
|
|
180
|
+
children.forEach((child, index) => {
|
|
181
|
+
if (!element(child)) return;
|
|
182
|
+
const childPath = `${parentPath}/${label(child, index)}`;
|
|
183
|
+
if (parent.style.display === "none") {
|
|
184
|
+
this.#markHidden(child);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const module = this.#modules.get(child.type);
|
|
188
|
+
if (module !== void 0 && "compileDeclaration" in module) {
|
|
189
|
+
this.#themes.set(child, themeContext);
|
|
190
|
+
if (module.children === "owned") return;
|
|
191
|
+
this.#appendChildren(child.children, childPath, parent, includeObjects, themeContext);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (objectModule(module)) {
|
|
195
|
+
const placeholder = this.#placeholderFor(child);
|
|
196
|
+
const elementTheme = placeholder === void 0 ? themeContext : placeholder.masterTheme;
|
|
197
|
+
const bound = this.#bindCapability(child, childPath, elementTheme, module, placeholder);
|
|
198
|
+
const contract = bound.contract;
|
|
199
|
+
if (contract.layoutStyle.display === "none") {
|
|
200
|
+
this.#markHidden(child);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (placeholder !== void 0) {
|
|
204
|
+
this.#themes.set(child, elementTheme);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
for (const mode of customContainerModes) mode.validateItemStyle(contract.layoutStyle, parent.style, childPath);
|
|
208
|
+
if (bound.container !== void 0) {
|
|
209
|
+
if (!includeObjects && bound.container.layoutMode === "when-styled" && !Object.keys(contract.layoutStyle).some((key) => key !== "zIndex" && layoutPropertySet.has(key) && contract.layoutStyle[key] !== void 0)) {
|
|
210
|
+
const theme = bound.container.theme ?? themeContext;
|
|
211
|
+
this.#themes.set(child, theme);
|
|
212
|
+
this.#appendChildren(bound.container.children, childPath, parent, false, theme);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const built = this.#buildContainer(child, childPath, parent, themeContext, contract, bound.container);
|
|
216
|
+
this.#solver.appendChild(parent, built);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.#themes.set(child, themeContext);
|
|
220
|
+
if (!includeObjects && !this.#solver.requiresLooseLayout(contract.layoutStyle)) return;
|
|
221
|
+
const built = this.#buildLeafObject(child, childPath, parent, themeContext, bound, contract);
|
|
222
|
+
if (!includeObjects) this.#solver.positionLooseGeometry(built);
|
|
223
|
+
this.#solver.appendChild(parent, built);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
#buildContainer(input, path, parent, themeContext, contract, container) {
|
|
228
|
+
const style = contract.layoutStyle;
|
|
229
|
+
const theme = container.theme ?? themeContext;
|
|
230
|
+
this.#themes.set(input, theme);
|
|
231
|
+
const node = this.#solver.createNode({
|
|
232
|
+
path,
|
|
233
|
+
style,
|
|
234
|
+
isContainer: true,
|
|
235
|
+
propagatesBaseline: container.propagatesBaseline !== false,
|
|
236
|
+
...contract.width === void 0 ? {} : { contractWidth: contract.width },
|
|
237
|
+
...contract.height === void 0 ? {} : { contractHeight: contract.height },
|
|
238
|
+
...contract.x === void 0 ? {} : { contractX: contract.x },
|
|
239
|
+
...contract.y === void 0 ? {} : { contractY: contract.y },
|
|
240
|
+
...contract.padding === void 0 ? {} : { padding: contract.padding }
|
|
241
|
+
}, parent);
|
|
242
|
+
this.#nodeMeta.set(node, {
|
|
243
|
+
element: input,
|
|
244
|
+
checksCanvasOverflow: container.checksCanvasOverflow !== false
|
|
245
|
+
});
|
|
246
|
+
this.#appendChildren(container.children, path, node, true, theme);
|
|
247
|
+
return node;
|
|
248
|
+
}
|
|
249
|
+
#buildLeafObject(input, path, parent, themeContext, bound, contract) {
|
|
250
|
+
const node = this.#solver.createNode({
|
|
251
|
+
path,
|
|
252
|
+
style: contract.layoutStyle,
|
|
253
|
+
isContainer: false,
|
|
254
|
+
propagatesBaseline: false,
|
|
255
|
+
...contract.width === void 0 ? {} : { contractWidth: contract.width },
|
|
256
|
+
...contract.height === void 0 ? {} : { contractHeight: contract.height },
|
|
257
|
+
...contract.x === void 0 ? {} : { contractX: contract.x },
|
|
258
|
+
...contract.y === void 0 ? {} : { contractY: contract.y },
|
|
259
|
+
...contract.padding === void 0 ? {} : { padding: contract.padding },
|
|
260
|
+
...bound.measureLayout === void 0 ? {} : { measure: (request) => this.#measure(path, themeContext, bound, request) }
|
|
261
|
+
}, parent);
|
|
262
|
+
this.#nodeMeta.set(node, {
|
|
263
|
+
element: input,
|
|
264
|
+
checksCanvasOverflow: false
|
|
265
|
+
});
|
|
266
|
+
return node;
|
|
267
|
+
}
|
|
268
|
+
#markHidden(child) {
|
|
269
|
+
this.#hidden.add(child);
|
|
270
|
+
for (const descendant of child.children) if (element(descendant)) this.#markHidden(descendant);
|
|
271
|
+
}
|
|
272
|
+
#warnOnce(path, code, message) {
|
|
273
|
+
const key = `${path}\u0000${code}\u0000${message}`;
|
|
274
|
+
if (this.#warningKeys.has(key)) return;
|
|
275
|
+
this.#warningKeys.add(key);
|
|
276
|
+
this.#warnings.push({
|
|
277
|
+
severity: "warning",
|
|
278
|
+
path,
|
|
279
|
+
code,
|
|
280
|
+
message
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
#measure(path, theme, bound, request) {
|
|
284
|
+
if (bound.measureLayout === void 0) return;
|
|
285
|
+
try {
|
|
286
|
+
return bound.measureLayout({
|
|
287
|
+
...request,
|
|
288
|
+
theme,
|
|
289
|
+
slideNumber: this.#slideNumber
|
|
290
|
+
});
|
|
291
|
+
} catch (error) {
|
|
292
|
+
if (error instanceof BuildError) throw error;
|
|
293
|
+
const code = error instanceof CapabilityError ? error.code : "layout-measurement-failed";
|
|
294
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
295
|
+
return fail(error instanceof CapabilityError && error.path !== void 0 ? error.path.startsWith(path) ? error.path : `${path}/${error.path}` : path, code, message);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
export { LayoutPass, layoutStyleKeys, paddingStyleKeys, parseCapabilityLayoutContract, validateBoundObjectCapability };
|