@officedk/pptxdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { layoutPlaceholderSpecSchema, placeholderRoleSchema } from "../../../core/dist/placeholders.js";
|
|
2
|
+
import { slideFooterValueSchema, slideNumberValueSchema } from "../../../core/dist/author-schemas.js";
|
|
3
|
+
import { footerPlaceholdersSchema, headerFooterSchema } from "../../../core/dist/masters.js";
|
|
4
|
+
import "../../../codegen/dist/index.js";
|
|
5
|
+
import { defineSlideCodegen, expr } from "../../../codegen/dist/types.js";
|
|
6
|
+
import "../../../core/dist/capability.js";
|
|
7
|
+
import { serializeImageDescriptorValue } from "../image/image-codegen.js";
|
|
8
|
+
// ../capabilities/dist/masters/masters-codegen.js
|
|
9
|
+
const masterOrLayoutPathPattern = /^deck\/slide-master\[[^\]]+\](?:\/slide-layout\[[^\]]+\])?$/u;
|
|
10
|
+
function isPlainRecord(value) {
|
|
11
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
12
|
+
const proto = Object.getPrototypeOf(value);
|
|
13
|
+
return proto === Object.prototype || proto === null;
|
|
14
|
+
}
|
|
15
|
+
function serializePlaceholderStyleValue(style, ctx) {
|
|
16
|
+
const entries = [];
|
|
17
|
+
for (const [key, value] of Object.entries(style)) {
|
|
18
|
+
if (value === void 0) continue;
|
|
19
|
+
if (key === "background") {
|
|
20
|
+
const serializedImage = serializeImageDescriptorValue(value, ctx);
|
|
21
|
+
entries.push([key, serializedImage ?? value]);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
entries.push([key, value]);
|
|
25
|
+
}
|
|
26
|
+
return expr(ctx.formatProps(entries));
|
|
27
|
+
}
|
|
28
|
+
function serializeMasterOrLayoutPlaceholderSpec(value, ctx) {
|
|
29
|
+
if (!masterOrLayoutPathPattern.test(ctx.path) || !isPlainRecord(value) || !placeholderRoleSchema.safeParse(value["type"]).success) return;
|
|
30
|
+
const parsed = layoutPlaceholderSpecSchema.safeParse(value);
|
|
31
|
+
if (!parsed.success) {
|
|
32
|
+
const issue = parsed.error.issues[0];
|
|
33
|
+
ctx.fail("unexpressible-value", `Invalid placeholder declaration: ${issue?.message ?? "invalid value"}`, "@placeholders");
|
|
34
|
+
}
|
|
35
|
+
const specEntries = [];
|
|
36
|
+
for (const [key, entryValue] of Object.entries(value)) {
|
|
37
|
+
if (entryValue === void 0) continue;
|
|
38
|
+
if (key === "style") {
|
|
39
|
+
if (!isPlainRecord(entryValue)) ctx.fail("unexpressible-value", "Placeholder.style must be a plain object", "@placeholders.style");
|
|
40
|
+
specEntries.push(["style", serializePlaceholderStyleValue(entryValue, ctx)]);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
specEntries.push([key, entryValue]);
|
|
44
|
+
}
|
|
45
|
+
return expr(ctx.formatProps(specEntries));
|
|
46
|
+
}
|
|
47
|
+
function serializeFooterPlaceholdersValue(value, ctx) {
|
|
48
|
+
const parsed = footerPlaceholdersSchema.safeParse(value);
|
|
49
|
+
if (!parsed.success) return ctx.fail("unexpressible-value", `Invalid footerPlaceholders declaration: ${parsed.error.issues[0]?.message ?? "invalid value"}`);
|
|
50
|
+
return expr(ctx.emitValueExpr(value));
|
|
51
|
+
}
|
|
52
|
+
function serializeValidatedValue(label, validate, value, ctx) {
|
|
53
|
+
const parsed = validate(value);
|
|
54
|
+
if (!parsed.success) return ctx.fail("unexpressible-value", `Invalid ${label} declaration: ${parsed.error?.issues[0]?.message ?? "invalid value"}`);
|
|
55
|
+
return expr(ctx.emitValueExpr(value));
|
|
56
|
+
}
|
|
57
|
+
/** Source codegen contribution for `SlideMaster` and `SlideLayout` `headerFooter` and placeholder specs. */
|
|
58
|
+
const mastersCodegen = defineSlideCodegen({
|
|
59
|
+
slideProps: { headerFooter: (value, ctx) => serializeValidatedValue("headerFooter", (candidate) => headerFooterSchema.safeParse(candidate), value, ctx) },
|
|
60
|
+
valueSerializers: [serializeMasterOrLayoutPlaceholderSpec]
|
|
61
|
+
});
|
|
62
|
+
/** Source codegen contribution for `footerPlaceholders` and slide `footer` / `dateTime` / `slideNumber`. */
|
|
63
|
+
const footerPlaceholderCodegen = defineSlideCodegen({ slideProps: {
|
|
64
|
+
footerPlaceholders: serializeFooterPlaceholdersValue,
|
|
65
|
+
footer: (value, ctx) => serializeValidatedValue("footer", (candidate) => slideFooterValueSchema.safeParse(candidate), value, ctx),
|
|
66
|
+
dateTime: (value, ctx) => serializeValidatedValue("dateTime", (candidate) => slideFooterValueSchema.safeParse(candidate), value, ctx),
|
|
67
|
+
slideNumber: (value, ctx) => serializeValidatedValue("slideNumber", (candidate) => slideNumberValueSchema.safeParse(candidate), value, ctx)
|
|
68
|
+
} });
|
|
69
|
+
export { footerPlaceholderCodegen, mastersCodegen };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { defaultColorMap, defaultTheme, visualStyleShape } from "../../../core/dist/theme.js";
|
|
2
|
+
import { resolvePlaceholderBoxFromLayers } from "../../../core/dist/placeholders.js";
|
|
3
|
+
import "../../../core/dist/capability.js";
|
|
4
|
+
import { colorMapAttributesXml, colorMapOverrideXml, layoutXml, masterXml, themeOverrideXml, themeXml } from "../../../emit/dist/ooxml.js";
|
|
5
|
+
import "../../../emit/dist/index.js";
|
|
6
|
+
import { readPlaceholderSpPrVisuals } from "../../../import/dist/visual.js";
|
|
7
|
+
import { importMastersAndLayouts } from "../../../import/dist/masters.js";
|
|
8
|
+
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
9
|
+
import "../../../import/dist/index.js";
|
|
10
|
+
import { hasLocalDeclaration } from "../shared/style-inheritance.js";
|
|
11
|
+
import { emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
|
|
12
|
+
import { mastersCodegen } from "./masters-codegen.js";
|
|
13
|
+
import { footerPlaceholderCapability } from "./footer-placeholder.js";
|
|
14
|
+
// ../capabilities/dist/masters/masters.js
|
|
15
|
+
const supportedPlaceholderVisualStyleKeys = new Set(Object.keys(visualStyleShape));
|
|
16
|
+
const readMasterPlaceholderVisuals = (args) => readPlaceholderSpPrVisuals(args, {
|
|
17
|
+
readAppearance: (spPr, pkg, fallbackUnits, location, diagnostics) => readSpPrAppearance(spPr, pkg, fallbackUnits, location, diagnostics, { preservePlaceholderClears: true }),
|
|
18
|
+
allowedStyleKeys: supportedPlaceholderVisualStyleKeys
|
|
19
|
+
});
|
|
20
|
+
function importDeckMasters(context) {
|
|
21
|
+
if (context.deckNode.masters.length > 0) return {};
|
|
22
|
+
const diagnostics = [];
|
|
23
|
+
const presRelById = context.relById ?? new Map(context.package.presentationRels.map((entry) => [entry.Id, entry]));
|
|
24
|
+
const usedDeckIds = context.usedDeckIds ?? /* @__PURE__ */ new Set();
|
|
25
|
+
const clrMapByLayoutPartPath = context.clrMapByLayoutPartPath ?? /* @__PURE__ */ new Map();
|
|
26
|
+
const layoutNodes = importMastersAndLayouts(context.presentationCursor, context.package, presRelById, context.deckNode, usedDeckIds, diagnostics, context.slideHandlers ?? [], context.shapeTreeHandlers ?? [], context.registerDeferredSlideLink ?? (() => {}), clrMapByLayoutPartPath, readMasterPlaceholderVisuals);
|
|
27
|
+
if (context.layoutNodeByPartPath !== void 0) for (const [partPath, layoutNode] of layoutNodes) context.layoutNodeByPartPath.set(partPath, layoutNode);
|
|
28
|
+
return diagnostics.length === 0 ? {} : { diagnostics };
|
|
29
|
+
}
|
|
30
|
+
function resolvePlaceholderVisualEntries(placeholders, theme, dimensions) {
|
|
31
|
+
if (placeholders === void 0) return [];
|
|
32
|
+
const entries = [];
|
|
33
|
+
for (const [key, spec] of Object.entries(placeholders)) {
|
|
34
|
+
const resolvedBox = resolvePlaceholderBoxFromLayers([spec], dimensions);
|
|
35
|
+
const hasBox = typeof resolvedBox.x === "number" && typeof resolvedBox.y === "number" && typeof resolvedBox.width === "number" && typeof resolvedBox.height === "number";
|
|
36
|
+
const styleRecord = spec.style;
|
|
37
|
+
const hasRotate = hasLocalDeclaration(styleRecord, "rotate");
|
|
38
|
+
const hasFlipH = hasLocalDeclaration(styleRecord, "flipH");
|
|
39
|
+
const hasFlipV = hasLocalDeclaration(styleRecord, "flipV");
|
|
40
|
+
const hasGeometryOrRadius = spec.geometry !== void 0 || hasLocalDeclaration(styleRecord, "borderRadius");
|
|
41
|
+
const hasFill = hasLocalDeclaration(styleRecord, "background");
|
|
42
|
+
const hasBorder = hasLocalDeclaration(styleRecord, "border");
|
|
43
|
+
const hasEffects = hasLocalDeclaration(styleRecord, "boxShadow") || hasLocalDeclaration(styleRecord, "softEdge");
|
|
44
|
+
if (!hasBox && !hasRotate && !hasFlipH && !hasFlipV && !hasGeometryOrRadius && !hasFill && !hasBorder && !hasEffects) continue;
|
|
45
|
+
const box = hasBox ? {
|
|
46
|
+
x: resolvedBox.x,
|
|
47
|
+
y: resolvedBox.y,
|
|
48
|
+
width: resolvedBox.width,
|
|
49
|
+
height: resolvedBox.height
|
|
50
|
+
} : {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
width: 100,
|
|
54
|
+
height: 100
|
|
55
|
+
};
|
|
56
|
+
const visual = resolveVisualModel({
|
|
57
|
+
theme,
|
|
58
|
+
style: styleRecord ?? {},
|
|
59
|
+
box,
|
|
60
|
+
...spec.geometry === void 0 ? {} : { geometry: spec.geometry },
|
|
61
|
+
layoutOnlyWhenInvisible: !hasBox
|
|
62
|
+
});
|
|
63
|
+
entries.push({
|
|
64
|
+
key,
|
|
65
|
+
visual,
|
|
66
|
+
flags: {
|
|
67
|
+
hasBox,
|
|
68
|
+
hasRotate,
|
|
69
|
+
hasFlipH,
|
|
70
|
+
hasFlipV,
|
|
71
|
+
hasGeometryOrRadius,
|
|
72
|
+
hasFill,
|
|
73
|
+
hasBorder,
|
|
74
|
+
hasEffects,
|
|
75
|
+
includeDefaultRectWhenHasBox: true
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return entries;
|
|
80
|
+
}
|
|
81
|
+
function paintThemeCanvasBackdrop(themeContext) {
|
|
82
|
+
const bg = themeContext.resolveColor("bg1");
|
|
83
|
+
if (bg.hex.toUpperCase() === "FFFFFF" && (bg.alpha === void 0 || bg.alpha === 1)) return { svg: "<rect width=\"100%\" height=\"100%\" fill=\"white\"/>" };
|
|
84
|
+
const opacityAttr = bg.alpha === void 0 || bg.alpha === 1 ? "" : ` fill-opacity="${bg.alpha}"`;
|
|
85
|
+
return { svg: `<rect width="100%" height="100%" fill="#${bg.hex}"${opacityAttr}/>` };
|
|
86
|
+
}
|
|
87
|
+
function paintSharedCanvasFragments(fragments) {
|
|
88
|
+
return { svg: fragments.join("") };
|
|
89
|
+
}
|
|
90
|
+
/** Native canvas mechanism for `<p:sldMaster>` ownership, `preserve`, and master-layout relationships. */
|
|
91
|
+
const slideMasterMechanism = defineCanvasMechanism({
|
|
92
|
+
key: "slide-master",
|
|
93
|
+
role: "canvas",
|
|
94
|
+
emit: (_model, context) => ({ xml: masterXml(context.spec, context.layoutIds, context.themeContext, context.colorMapXml) }),
|
|
95
|
+
paint: (_model, fragments) => paintSharedCanvasFragments(fragments),
|
|
96
|
+
import: {
|
|
97
|
+
target: "deck",
|
|
98
|
+
stage: "pre-slides",
|
|
99
|
+
read: importDeckMasters
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
/** Native canvas mechanism for `<p:sldLayout>` ownership, `type`, `preserve`, and idle layout retention. */
|
|
103
|
+
const slideLayoutMechanism = defineCanvasMechanism({
|
|
104
|
+
key: "slide-layout",
|
|
105
|
+
role: "canvas",
|
|
106
|
+
emit: (_model, context) => ({ xml: layoutXml(context.spec, context.themeContext, context.colorMapOvrXml) }),
|
|
107
|
+
paint: (_model, fragments) => paintSharedCanvasFragments(fragments),
|
|
108
|
+
import: {
|
|
109
|
+
target: "deck",
|
|
110
|
+
stage: "pre-slides",
|
|
111
|
+
read: importDeckMasters
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
function serializeColorMapModel(model) {
|
|
115
|
+
if (model.colorMap !== void 0) return `<p:clrMap ${colorMapAttributesXml(model.colorMap)}/>`;
|
|
116
|
+
return colorMapOverrideXml(model.colorMapOverride);
|
|
117
|
+
}
|
|
118
|
+
/** Native canvas mechanism for `<a:theme>` (`clrScheme`, `fontScheme`, `fmtScheme`) part identity and mutation. */
|
|
119
|
+
const nativeThemeMechanism = defineCanvasMechanism({
|
|
120
|
+
key: "native-theme",
|
|
121
|
+
role: "canvas",
|
|
122
|
+
emit: (model) => ({ xml: themeXml(model.theme) }),
|
|
123
|
+
paint: (_model, themeContext) => paintThemeCanvasBackdrop(themeContext),
|
|
124
|
+
import: {
|
|
125
|
+
target: "deck",
|
|
126
|
+
stage: "pre-slides",
|
|
127
|
+
read: importDeckMasters
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
/** Native canvas mechanism for master `<p:clrMap>` and layout/slide `<p:clrMapOvr>` color-slot mapping. */
|
|
131
|
+
const colorMapMechanism = defineCanvasMechanism({
|
|
132
|
+
key: "color-map",
|
|
133
|
+
role: "canvas",
|
|
134
|
+
emit: (model) => ({ xml: serializeColorMapModel(model) }),
|
|
135
|
+
paint: (_model, themeContext) => paintThemeCanvasBackdrop(themeContext),
|
|
136
|
+
import: {
|
|
137
|
+
target: "deck",
|
|
138
|
+
stage: "pre-slides",
|
|
139
|
+
read: importDeckMasters
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
/** Native canvas mechanism for `<a:themeOverride>` layout and slide palette/font/format overrides. */
|
|
143
|
+
const themeOverrideMechanism = defineCanvasMechanism({
|
|
144
|
+
key: "theme-override",
|
|
145
|
+
role: "canvas",
|
|
146
|
+
emit: (model) => ({ xml: themeOverrideXml(model.override, model.baseTheme ?? defaultTheme) }),
|
|
147
|
+
paint: (_model, themeContext) => paintThemeCanvasBackdrop(themeContext),
|
|
148
|
+
import: {
|
|
149
|
+
target: "deck",
|
|
150
|
+
stage: "pre-slides",
|
|
151
|
+
read: importDeckMasters
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
/** Native canvas mechanism for non-placeholder shared canvas objects (`sp`/`pic`/`grpSp`) on SlideMaster and SlideLayout. */
|
|
155
|
+
const masterSharedCanvasMechanism = defineCanvasMechanism({
|
|
156
|
+
key: "master-shared-canvas",
|
|
157
|
+
role: "canvas",
|
|
158
|
+
emit: (model) => ({ xml: model.fragments.join("") }),
|
|
159
|
+
paint: (model) => paintSharedCanvasFragments(model.fragments),
|
|
160
|
+
import: {
|
|
161
|
+
target: "deck",
|
|
162
|
+
stage: "pre-slides",
|
|
163
|
+
read: importDeckMasters
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
/** Capability declaration wiring native slide master, layout, theme, color-map, theme-override, and shared-canvas mechanisms into builds. */
|
|
167
|
+
const mastersCapability = {
|
|
168
|
+
declaration: "slide-masters",
|
|
169
|
+
slideProps: [],
|
|
170
|
+
slot: "background",
|
|
171
|
+
codegen: mastersCodegen,
|
|
172
|
+
always: false,
|
|
173
|
+
mechanisms: [
|
|
174
|
+
slideMasterMechanism,
|
|
175
|
+
slideLayoutMechanism,
|
|
176
|
+
nativeThemeMechanism,
|
|
177
|
+
colorMapMechanism,
|
|
178
|
+
themeOverrideMechanism,
|
|
179
|
+
masterSharedCanvasMechanism
|
|
180
|
+
],
|
|
181
|
+
mastersCanvas: {
|
|
182
|
+
paintBackdrop(input) {
|
|
183
|
+
if (input.themeOverride !== void 0) return themeOverrideMechanism.paint({ override: input.themeOverride }, input.theme);
|
|
184
|
+
if (input.colorMapOverride !== void 0 || input.hasCustomColorMap === true) return colorMapMechanism.paint(input.colorMapOverride === void 0 ? {} : { colorMapOverride: input.colorMapOverride }, input.theme);
|
|
185
|
+
return nativeThemeMechanism.paint({ theme: input.theme.theme }, input.theme);
|
|
186
|
+
},
|
|
187
|
+
paintMasterLayers(fragments) {
|
|
188
|
+
return slideMasterMechanism.paint(void 0, fragments);
|
|
189
|
+
},
|
|
190
|
+
paintLayoutLayers(fragments) {
|
|
191
|
+
return slideLayoutMechanism.paint(void 0, fragments);
|
|
192
|
+
},
|
|
193
|
+
paintSharedObject(svg) {
|
|
194
|
+
return masterSharedCanvasMechanism.paint({ fragments: [svg] });
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
mastersEmitDriver: {
|
|
198
|
+
emitMaster(spec, layoutIds, themeContext) {
|
|
199
|
+
const colorMapXml = colorMapMechanism.emit({ colorMap: spec.colorMap ?? defaultColorMap }).xml;
|
|
200
|
+
return slideMasterMechanism.emit(void 0, {
|
|
201
|
+
spec,
|
|
202
|
+
layoutIds,
|
|
203
|
+
themeContext,
|
|
204
|
+
colorMapXml
|
|
205
|
+
}).xml;
|
|
206
|
+
},
|
|
207
|
+
emitLayout(spec, themeContext) {
|
|
208
|
+
const colorMapOvrXml = colorMapMechanism.emit(spec.colorMapOverride === void 0 ? {} : { colorMapOverride: spec.colorMapOverride }).xml;
|
|
209
|
+
return slideLayoutMechanism.emit(void 0, {
|
|
210
|
+
spec,
|
|
211
|
+
themeContext,
|
|
212
|
+
colorMapOvrXml
|
|
213
|
+
}).xml;
|
|
214
|
+
},
|
|
215
|
+
emitTheme(theme) {
|
|
216
|
+
return nativeThemeMechanism.emit({ theme }).xml;
|
|
217
|
+
},
|
|
218
|
+
emitColorMap(model) {
|
|
219
|
+
return colorMapMechanism.emit(model).xml;
|
|
220
|
+
},
|
|
221
|
+
emitThemeOverride(override, baseTheme) {
|
|
222
|
+
return themeOverrideMechanism.emit({
|
|
223
|
+
override,
|
|
224
|
+
...baseTheme === void 0 ? {} : { baseTheme }
|
|
225
|
+
}).xml;
|
|
226
|
+
},
|
|
227
|
+
emitSharedCanvas(fragments) {
|
|
228
|
+
return masterSharedCanvasMechanism.emit({ fragments }).xml;
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
bindSlide(input, context) {
|
|
232
|
+
const placeholders = input.props["placeholders"];
|
|
233
|
+
const entries = resolvePlaceholderVisualEntries(placeholders, context.theme, context.dimensions);
|
|
234
|
+
return { resolveSlide() {
|
|
235
|
+
return {
|
|
236
|
+
extensions: [],
|
|
237
|
+
emit(emitContext) {
|
|
238
|
+
if (entries.length === 0) return { xml: "" };
|
|
239
|
+
const placeholderSpPrByKey = {};
|
|
240
|
+
for (const entry of entries) placeholderSpPrByKey[entry.key] = emitPlaceholderVisualSpPr(entry.visual, entry.flags, (resource) => emitContext.registerResource(resource));
|
|
241
|
+
return {
|
|
242
|
+
xml: "",
|
|
243
|
+
placeholderSpPrByKey
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
} };
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
export { colorMapMechanism, footerPlaceholderCapability, masterSharedCanvasMechanism, mastersCapability, nativeThemeMechanism, slideLayoutMechanism, slideMasterMechanism, themeOverrideMechanism };
|