@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,320 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import "../../../core/dist/geometry-schemas.js";
|
|
3
|
+
import { assertValidLang, textStyleKeys } from "../../../core/dist/theme.js";
|
|
4
|
+
import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
|
|
5
|
+
import { paddingStyleKeys } from "../../../core/dist/block-flex-layout.js";
|
|
6
|
+
import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
|
|
7
|
+
import "../../../core/dist/capability.js";
|
|
8
|
+
import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
9
|
+
import "../../../emit/dist/index.js";
|
|
10
|
+
import "../../../import/dist/index.js";
|
|
11
|
+
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
12
|
+
import { applyTransformToPoints, blockArc, evaluateGeometry, path, preset } from "../shared/geometry.js";
|
|
13
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
14
|
+
import { customGeometryShapeImportHandler, presetShapeImportHandler } from "./shape-import.js";
|
|
15
|
+
import { shapeXml } from "./shape-xml.js";
|
|
16
|
+
import { emitVisualModel, gradientFillMechanism, imageFillMechanism, linearGradient, paintVisualModel, radialGradient, resolveVisualModel, solidFillMechanism } from "../shared/visual.js";
|
|
17
|
+
import { motionAnnotations, motionParagraphAnnotations, pickMotionProps } from "../motion/motion-api.js";
|
|
18
|
+
import { computeTextMetrics, emitTextBody, measureTextLayoutFromParagraphs, parseTextContent, renderTextOutlinesSvg, resolveTextBody, textInsets } from "../shared/text-service.js";
|
|
19
|
+
import { shapeCodegen } from "./shape-codegen.js";
|
|
20
|
+
import { shapeCoordinateSchema, shapeDeclarationPropsKeys, shapeSizeSchema, shapeStyleKeyList } from "./shape-declaration.js";
|
|
21
|
+
// ../capabilities/dist/shape/shape.js
|
|
22
|
+
const allowedParameters = shapeDeclarationPropsKeys;
|
|
23
|
+
const shapeStyleKeys = shapeStyleKeyList;
|
|
24
|
+
function record(input) {
|
|
25
|
+
return typeof input === "object" && input !== null && !Array.isArray(input) ? input : {};
|
|
26
|
+
}
|
|
27
|
+
function shapeTextStyle(props) {
|
|
28
|
+
const layoutStyle = record(props["style"]);
|
|
29
|
+
if (layoutStyle["lang"] !== void 0) assertValidLang(layoutStyle["lang"]);
|
|
30
|
+
return Object.fromEntries(Object.entries(layoutStyle).filter(([key]) => textStyleKeys.has(key)));
|
|
31
|
+
}
|
|
32
|
+
function validateCoordinate(value, name, path) {
|
|
33
|
+
const parsed = shapeCoordinateSchema.safeParse(value);
|
|
34
|
+
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number, width and height must be greater than 0, and coordinates must be between -1000000 and 1000000`, path);
|
|
35
|
+
return parsed.data;
|
|
36
|
+
}
|
|
37
|
+
function validateSize(value, name, path) {
|
|
38
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
39
|
+
if (value === 0 || pxToEmu(value) === 0) throw new CapabilityError("invalid-coordinate", `Computed ${name} is 0px; ${name} must be greater than 0px`, path);
|
|
40
|
+
if (value < 0 || pxToEmu(value) < 1) throw new CapabilityError("invalid-coordinate", `Computed ${name} is ${value}px; ${name} must be greater than 0px`, path);
|
|
41
|
+
} else throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number greater than 0px`, path);
|
|
42
|
+
const parsed = shapeSizeSchema.safeParse(value);
|
|
43
|
+
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must convert to an EMU value between 1 and 2147483647 inclusive`, path);
|
|
44
|
+
return parsed.data;
|
|
45
|
+
}
|
|
46
|
+
function roundSvgNumber(value) {
|
|
47
|
+
const rounded = Math.round(value * 1e6) / 1e6;
|
|
48
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
49
|
+
}
|
|
50
|
+
function emitShapeModel(model, emitContext) {
|
|
51
|
+
const properties = emitVisualModel(model.visual, (resource) => emitContext.registerResource(resource));
|
|
52
|
+
const embedFonts = emitContext.options.embedFonts;
|
|
53
|
+
switch (model.text.kind) {
|
|
54
|
+
case "none": return { xml: shapeXml(emitContext.id, model.escapedName, properties.xml, "", nativeLinkXml(emitContext.nativeLink)) };
|
|
55
|
+
case "body": {
|
|
56
|
+
const emittedBody = emitTextBody(model.text.body, emitContext.theme, {
|
|
57
|
+
createFieldId: emitContext.createTextFieldId,
|
|
58
|
+
...embedFonts === void 0 ? {} : { embedFonts }
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
xml: shapeXml(emitContext.id, model.escapedName, properties.xml, emittedBody.xml, nativeLinkXml(emitContext.nativeLink)),
|
|
62
|
+
presentationContributions: emittedBody.presentationContributions
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
default: return model.text;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function paintShapeModel(model, paintContext) {
|
|
69
|
+
const visualPaint = paintVisualModel({
|
|
70
|
+
model: model.visual,
|
|
71
|
+
slideNumber: paintContext.slideNumber,
|
|
72
|
+
objectId: paintContext.objectId,
|
|
73
|
+
...paintContext.registerRasterResource === void 0 ? {} : { registerRasterResource: paintContext.registerRasterResource }
|
|
74
|
+
});
|
|
75
|
+
switch (model.text.kind) {
|
|
76
|
+
case "none": return visualPaint;
|
|
77
|
+
case "body": {
|
|
78
|
+
const { box, flipH, flipV, rotate, geometry } = model.visual;
|
|
79
|
+
const paintBox = paintContext.box ?? box;
|
|
80
|
+
const { textRect } = evaluateGeometry(geometry, paintBox);
|
|
81
|
+
const cx = paintBox.x + paintBox.width / 2;
|
|
82
|
+
const cy = paintBox.y + paintBox.height / 2;
|
|
83
|
+
const effectiveTextRect = {
|
|
84
|
+
x: flipH ? 2 * cx - (textRect.x + textRect.width) : textRect.x,
|
|
85
|
+
y: flipV ? 2 * cy - (textRect.y + textRect.height) : textRect.y,
|
|
86
|
+
width: textRect.width,
|
|
87
|
+
height: textRect.height
|
|
88
|
+
};
|
|
89
|
+
const glyphsSvg = renderTextOutlinesSvg({
|
|
90
|
+
paragraphs: model.text.body.paragraphs,
|
|
91
|
+
box: effectiveTextRect,
|
|
92
|
+
insets: model.text.insets,
|
|
93
|
+
verticalAlign: model.text.verticalAlign,
|
|
94
|
+
theme: paintContext.theme,
|
|
95
|
+
measuredLayout: paintBox.width === box.width && paintBox.height === box.height ? model.text.body.measuredLayout : void 0,
|
|
96
|
+
idPrefix: `obj-s${paintContext.slideNumber}-o${paintContext.objectId}`,
|
|
97
|
+
rotate
|
|
98
|
+
});
|
|
99
|
+
const textLayer = glyphsSvg === "" ? "" : rotate === 0 ? glyphsSvg : `<g transform="rotate(${roundSvgNumber(rotate)} ${roundSvgNumber(cx)} ${roundSvgNumber(cy)})">${glyphsSvg}</g>`;
|
|
100
|
+
return {
|
|
101
|
+
svg: `${visualPaint.svg}${textLayer}`,
|
|
102
|
+
...visualPaint.placeholders === void 0 ? {} : { placeholders: visualPaint.placeholders }
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
default: return model.text;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Native canvas mechanism for DrawingML `<a:prstGeom>` shapes. */
|
|
109
|
+
const presetShapeMechanism = defineCanvasMechanism({
|
|
110
|
+
key: "preset-shape",
|
|
111
|
+
role: "canvas",
|
|
112
|
+
emit: emitShapeModel,
|
|
113
|
+
paint: paintShapeModel,
|
|
114
|
+
import: presetShapeImportHandler
|
|
115
|
+
});
|
|
116
|
+
/** Native canvas mechanism for DrawingML `<a:custGeom>` shapes. */
|
|
117
|
+
const customGeometryShapeMechanism = defineCanvasMechanism({
|
|
118
|
+
key: "custom-geometry-shape",
|
|
119
|
+
role: "canvas",
|
|
120
|
+
emit: emitShapeModel,
|
|
121
|
+
paint: paintShapeModel,
|
|
122
|
+
import: customGeometryShapeImportHandler
|
|
123
|
+
});
|
|
124
|
+
/** Shape module independently validates input, encapsulates bound state, and emits native PresentationML objects. */
|
|
125
|
+
const shapeCapability = {
|
|
126
|
+
declaration: "shape",
|
|
127
|
+
codegen: shapeCodegen,
|
|
128
|
+
mechanisms: [
|
|
129
|
+
presetShapeMechanism,
|
|
130
|
+
customGeometryShapeMechanism,
|
|
131
|
+
solidFillMechanism,
|
|
132
|
+
gradientFillMechanism,
|
|
133
|
+
imageFillMechanism
|
|
134
|
+
],
|
|
135
|
+
bind(input, context) {
|
|
136
|
+
const unknown = Object.keys(input.props).find((key) => key !== "children" && !allowedParameters.includes(key));
|
|
137
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Shape contains unsupported parameter ${unknown}`, void 0, {
|
|
138
|
+
prop: unknown,
|
|
139
|
+
scope: "props"
|
|
140
|
+
});
|
|
141
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
142
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
143
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
144
|
+
const layoutStyleRecord = record(input.props["style"]);
|
|
145
|
+
const hasDeclaredTextOrPaddingStyle = Object.keys(layoutStyleRecord).some((key) => textStyleKeys.has(key) || paddingStyleKeys.includes(key));
|
|
146
|
+
const hasNonEmptyText = input.children.some((child) => !("text" in child && typeof child.text === "string") || child.text !== "");
|
|
147
|
+
const hasExplicitEmptyText = input.children.length > 0 && !hasNonEmptyText;
|
|
148
|
+
const hasTextBody = hasNonEmptyText || hasDeclaredTextOrPaddingStyle;
|
|
149
|
+
const allowedStyleKeys = new Set(shapeStyleKeys);
|
|
150
|
+
const contract = parseCapabilityLayoutContract({
|
|
151
|
+
nativeKind: "sp",
|
|
152
|
+
props: input.props,
|
|
153
|
+
allowedStyleKeys,
|
|
154
|
+
allowPadding: true,
|
|
155
|
+
path: context.path
|
|
156
|
+
});
|
|
157
|
+
const insets = hasTextBody ? textInsets(input.props["style"]) : {
|
|
158
|
+
top: 0,
|
|
159
|
+
right: 0,
|
|
160
|
+
bottom: 0,
|
|
161
|
+
left: 0
|
|
162
|
+
};
|
|
163
|
+
const rawTextStyle = shapeTextStyle(input.props);
|
|
164
|
+
const effectiveTextStyle = {
|
|
165
|
+
...rawTextStyle,
|
|
166
|
+
verticalAlign: rawTextStyle["verticalAlign"] ?? "middle"
|
|
167
|
+
};
|
|
168
|
+
const { paragraphs, paragraphMotions, style: parsedTextStyle } = hasTextBody ? parseTextContent(input.children, effectiveTextStyle, context.theme, { slideNumber: context.slideNumber }, "Shape.style", void 0, void 0, { allowParagraphMotion: true }) : {
|
|
169
|
+
paragraphs: [],
|
|
170
|
+
paragraphMotions: [],
|
|
171
|
+
style: parseTextContent([], {}, context.theme, { slideNumber: context.slideNumber }, "Shape.style").style
|
|
172
|
+
};
|
|
173
|
+
const visualStyle = { ...record(input.props["style"]) };
|
|
174
|
+
const geometry = input.props["geometry"];
|
|
175
|
+
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
176
|
+
const motionProps = pickMotionProps(input.props);
|
|
177
|
+
resolveVisualModel({
|
|
178
|
+
theme: context.theme,
|
|
179
|
+
style: visualStyle,
|
|
180
|
+
box: {
|
|
181
|
+
x: 0,
|
|
182
|
+
y: 0,
|
|
183
|
+
width: 100,
|
|
184
|
+
height: 100
|
|
185
|
+
},
|
|
186
|
+
...geometry !== void 0 ? { geometry } : {}
|
|
187
|
+
});
|
|
188
|
+
const declaredWidth = contract.explicitPixelSize?.width;
|
|
189
|
+
const declaredHeight = contract.explicitPixelSize?.height;
|
|
190
|
+
const hasFixedHeight = contract.fixedAxes?.height ?? false;
|
|
191
|
+
const native = {
|
|
192
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
193
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
194
|
+
...link === void 0 ? {} : { link }
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
contract,
|
|
198
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
199
|
+
measureLayout(request) {
|
|
200
|
+
if (!hasTextBody || paragraphs.length === 0) return {
|
|
201
|
+
minContentWidth: 0,
|
|
202
|
+
minContentHeight: 0
|
|
203
|
+
};
|
|
204
|
+
const width = request.availableWidth ?? declaredWidth;
|
|
205
|
+
const innerWidth = request.availableWidth !== void 0 ? request.availableWidth : typeof width === "number" ? Math.max(0, width - insets.left - insets.right) : void 0;
|
|
206
|
+
try {
|
|
207
|
+
const measured = measureTextLayoutFromParagraphs(paragraphs, parsedTextStyle, innerWidth);
|
|
208
|
+
const baseline = parsedTextStyle.verticalAlign === "top" ? measured.baseline ?? "unavailable" : "unavailable";
|
|
209
|
+
return {
|
|
210
|
+
...measured,
|
|
211
|
+
baseline
|
|
212
|
+
};
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (hasFixedHeight && request.purpose !== "baseline" && error instanceof CapabilityError && (error.code === "font-measurement-unavailable" || error.code === "font-missing-glyph")) return { baseline: "unavailable" };
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
resolve(resolveContext) {
|
|
219
|
+
const box = resolveContext.layoutBox === void 0 ? {
|
|
220
|
+
x: validateCoordinate(void 0, "x"),
|
|
221
|
+
y: validateCoordinate(void 0, "y"),
|
|
222
|
+
width: validateSize(declaredWidth, "width"),
|
|
223
|
+
height: validateSize(declaredHeight, "height")
|
|
224
|
+
} : {
|
|
225
|
+
x: validateCoordinate(resolveContext.layoutBox.x, "x"),
|
|
226
|
+
y: validateCoordinate(resolveContext.layoutBox.y, "y"),
|
|
227
|
+
width: validateSize(resolveContext.layoutBox.width, "width"),
|
|
228
|
+
height: validateSize(resolveContext.layoutBox.height, "height")
|
|
229
|
+
};
|
|
230
|
+
const visual = resolveVisualModel({
|
|
231
|
+
theme: resolveContext.theme,
|
|
232
|
+
style: visualStyle,
|
|
233
|
+
box,
|
|
234
|
+
...geometry === void 0 ? {} : { geometry }
|
|
235
|
+
});
|
|
236
|
+
const geometryName = visual.geometry.kind === "custom" ? "custom" : visual.geometry.name;
|
|
237
|
+
const evaluated = evaluateGeometry(visual.geometry, box);
|
|
238
|
+
const connectionSites = applyTransformToPoints(evaluated.connectionSites, box, {
|
|
239
|
+
flipH: visual.flipH,
|
|
240
|
+
flipV: visual.flipV,
|
|
241
|
+
rotate: visual.rotate
|
|
242
|
+
});
|
|
243
|
+
let resolvedText;
|
|
244
|
+
if (hasTextBody && paragraphs.length > 0) {
|
|
245
|
+
const { textRect } = evaluated;
|
|
246
|
+
resolvedText = resolveTextBody(paragraphs, parsedTextStyle, resolveContext.theme, parsedTextStyle.verticalAlign ?? "middle", {
|
|
247
|
+
width: Math.max(0, textRect.width - insets.left - insets.right),
|
|
248
|
+
height: Math.max(0, textRect.height - insets.top - insets.bottom),
|
|
249
|
+
contentSized: !hasFixedHeight,
|
|
250
|
+
insets
|
|
251
|
+
}, "text-box");
|
|
252
|
+
}
|
|
253
|
+
const name = resolveContext.morphName ?? requestedName ?? `Shape ${resolveContext.id - 1}`;
|
|
254
|
+
const target = {
|
|
255
|
+
kind: "shape",
|
|
256
|
+
name,
|
|
257
|
+
...authorId === void 0 ? {} : { authorId },
|
|
258
|
+
textBody: resolvedText !== void 0,
|
|
259
|
+
filled: visual.fill.kind !== "none",
|
|
260
|
+
solidFilled: visual.fill.kind === "solid",
|
|
261
|
+
box,
|
|
262
|
+
rotationDegrees: visual.rotate,
|
|
263
|
+
hasBackground: visual.fill.kind !== "none" || visual.border !== void 0,
|
|
264
|
+
...resolvedText === void 0 ? {} : { paragraphCount: resolvedText.paragraphCount }
|
|
265
|
+
};
|
|
266
|
+
const annotations = [...motionAnnotations(motionProps, target), ...motionParagraphAnnotations(paragraphMotions, target, motionProps)];
|
|
267
|
+
let escapedName;
|
|
268
|
+
try {
|
|
269
|
+
escapedName = xmlEscape(name);
|
|
270
|
+
} catch {
|
|
271
|
+
throw new CapabilityError("invalid-xml-character", "Shape.name contains characters not allowed in XML 1.0");
|
|
272
|
+
}
|
|
273
|
+
const resolvedModel = {
|
|
274
|
+
escapedName,
|
|
275
|
+
visual,
|
|
276
|
+
text: resolvedText === void 0 ? { kind: "none" } : {
|
|
277
|
+
kind: "body",
|
|
278
|
+
body: resolvedText,
|
|
279
|
+
insets,
|
|
280
|
+
verticalAlign: parsedTextStyle.verticalAlign ?? "middle"
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const transform = {
|
|
284
|
+
box,
|
|
285
|
+
angle: visual.rotate,
|
|
286
|
+
flipH: visual.flipH,
|
|
287
|
+
flipV: visual.flipV
|
|
288
|
+
};
|
|
289
|
+
return {
|
|
290
|
+
observation: {
|
|
291
|
+
id: resolveContext.id,
|
|
292
|
+
kind: "shape",
|
|
293
|
+
name,
|
|
294
|
+
geometry: geometryName,
|
|
295
|
+
box,
|
|
296
|
+
...resolvedText === void 0 ? hasExplicitEmptyText ? { text: "" } : {} : {
|
|
297
|
+
text: resolvedText.text,
|
|
298
|
+
textMetrics: resolvedText.textMetrics ?? computeTextMetrics(resolvedText, 0, 0)
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
transform,
|
|
302
|
+
connectionSites,
|
|
303
|
+
extensions: [],
|
|
304
|
+
...annotations.length === 0 ? {} : { annotations },
|
|
305
|
+
...resolvedText === void 0 ? {} : {
|
|
306
|
+
resourceClaims: resolvedText.resourceClaims,
|
|
307
|
+
fontUsages: resolvedText.fontUsages
|
|
308
|
+
},
|
|
309
|
+
emit(emitContext) {
|
|
310
|
+
return resolvedModel.visual.geometry.kind === "custom" ? customGeometryShapeMechanism.emit(resolvedModel, emitContext) : presetShapeMechanism.emit(resolvedModel, emitContext);
|
|
311
|
+
},
|
|
312
|
+
paint(paintContext) {
|
|
313
|
+
return resolvedModel.visual.geometry.kind === "custom" ? customGeometryShapeMechanism.paint(resolvedModel, paintContext) : presetShapeMechanism.paint(resolvedModel, paintContext);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
export { blockArc, customGeometryShapeMechanism, linearGradient, path, preset, presetShapeMechanism, radialGradient, shapeCapability, shapeStyleKeys };
|