@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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2272 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +48 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,579 @@
1
+ import { assertValidLang } from "../../../core/dist/theme.js";
2
+ import "../../../core/dist/capability.js";
3
+ import { A_NS, P_NS, XML_NS, emuToPx } from "../../../import/dist/namespaces.js";
4
+ import { ooxmlBoolSchema, ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema } from "../../../import/dist/xml-fragments.js";
5
+ import { readDrawingColor, readEffectList } from "../../../import/dist/visual.js";
6
+ import "../../../import/dist/index.js";
7
+ import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readClickLink } from "../shared/identity.js";
8
+ import { isPlaceholderSpElement } from "../shared/placeholder-import.js";
9
+ import { readSpPrVisuals } from "../shared/visual.js";
10
+ import { createParagraphNode, createSlideNumberNode, createSpanNode } from "../text/text-declaration.js";
11
+ import { createShapeNode } from "./shape-declaration.js";
12
+ import { z } from "zod";
13
+ // ../capabilities/dist/shape/shape-import.js
14
+ const NonVisualIdAttrSchema = z.object({
15
+ id: ooxmlNonNegativeIntSchema,
16
+ name: z.string().optional()
17
+ });
18
+ const BodyPrAttrSchema = z.object({
19
+ wrap: z.enum(["square", "none"]).optional(),
20
+ rtlCol: ooxmlBoolSchema.optional(),
21
+ lIns: ooxmlNonNegativeIntSchema.optional(),
22
+ tIns: ooxmlNonNegativeIntSchema.optional(),
23
+ rIns: ooxmlNonNegativeIntSchema.optional(),
24
+ bIns: ooxmlNonNegativeIntSchema.optional(),
25
+ anchor: z.enum([
26
+ "t",
27
+ "ctr",
28
+ "b"
29
+ ]).optional()
30
+ });
31
+ const ParagraphPrAttrSchema = z.object({
32
+ algn: z.enum([
33
+ "l",
34
+ "ctr",
35
+ "r",
36
+ "just"
37
+ ]).optional(),
38
+ rtl: ooxmlBoolSchema.optional(),
39
+ lvl: ooxmlNonNegativeIntSchema.optional()
40
+ });
41
+ const RunPrAttrSchema = z.object({
42
+ lang: z.string().min(1).optional(),
43
+ sz: ooxmlPositiveIntSchema.optional(),
44
+ b: ooxmlBoolSchema.optional(),
45
+ i: ooxmlBoolSchema.optional(),
46
+ u: z.enum(["none", "sng"]).optional(),
47
+ strike: z.enum(["noStrike", "sngStrike"]).optional(),
48
+ cap: z.enum(["none", "all"]).optional(),
49
+ spc: ooxmlIntSchema.optional(),
50
+ dirty: ooxmlBoolSchema.optional(),
51
+ smtClean: ooxmlBoolSchema.optional()
52
+ });
53
+ const TypefaceAttrSchema = z.object({ typeface: z.string().min(1) });
54
+ const BulletCharAttrSchema = z.object({ char: z.string().min(1) });
55
+ const BulletAutoNumAttrSchema = z.object({
56
+ type: z.string().min(1),
57
+ startAt: ooxmlIntSchema.optional()
58
+ });
59
+ const SpacingValAttrSchema = z.object({ val: ooxmlNonNegativeIntSchema });
60
+ const anchorToVerticalAlign = {
61
+ t: "top",
62
+ ctr: "middle",
63
+ b: "bottom"
64
+ };
65
+ const algnToTextAlign = {
66
+ l: "left",
67
+ ctr: "center",
68
+ r: "right",
69
+ just: "justify"
70
+ };
71
+ function directElementChild(parent, namespaceUri, localName) {
72
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
73
+ if (child.nodeType !== 1) continue;
74
+ const el = child;
75
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
76
+ }
77
+ }
78
+ function isTextBoxSpElement(cursor) {
79
+ const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
80
+ if (nvSpPr === void 0) return false;
81
+ const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
82
+ if (cNvSpPr === void 0) return false;
83
+ const txBox = cNvSpPr.getAttribute("txBox");
84
+ return txBox === "1" || txBox === "true";
85
+ }
86
+ function isCustomGeomSpElement(cursor) {
87
+ const spPr = directElementChild(cursor.element, P_NS, "spPr");
88
+ if (spPr === void 0) return false;
89
+ return directElementChild(spPr, A_NS, "custGeom") !== void 0;
90
+ }
91
+ /** Side-effect-free predicate matching non-textbox preset shapes (`<p:sp>` without `txBox="1"`, `<p:ph>`, or `<a:custGeom>`). */
92
+ function isPresetShapeSpElement(cursor) {
93
+ return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && !isCustomGeomSpElement(cursor);
94
+ }
95
+ /** Side-effect-free predicate matching non-textbox custom-geometry shapes (`<p:sp>` without `<p:ph>` and with `<a:custGeom>`). */
96
+ function isCustomGeometryShapeSpElement(cursor) {
97
+ return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && isCustomGeomSpElement(cursor);
98
+ }
99
+ /** Reads `<p:cNvPr>` id, name, and hyperlink without assuming shape vs group wrapper tag. */
100
+ function readNonVisualCommonProperties(cNvPrCursor, context, diagnostics) {
101
+ if (cNvPrCursor === void 0) return {};
102
+ const raw = cNvPrCursor.attrsObject(["id", "name"]);
103
+ const parsed = NonVisualIdAttrSchema.safeParse(raw);
104
+ let objectId;
105
+ let objectName;
106
+ if (!parsed.success) diagnostics.push({
107
+ code: "invalid-xml-value",
108
+ category: "corrupt-input",
109
+ disposition: "recovered",
110
+ location: {
111
+ part: context.part,
112
+ xpath: cNvPrCursor.xpath,
113
+ slideIndex: context.slideIndex
114
+ },
115
+ attributeOrElement: "p:cNvPr",
116
+ rawValue: JSON.stringify(raw)
117
+ });
118
+ else {
119
+ objectId = parsed.data.id;
120
+ if (parsed.data.name !== void 0 && parsed.data.name.trim() !== "") objectName = parsed.data.name;
121
+ }
122
+ const hlinkClick = cNvPrCursor.child(A_NS, "hlinkClick");
123
+ let clickResult;
124
+ if (hlinkClick !== void 0) {
125
+ clickResult = readClickLink(hlinkClick, context, {
126
+ ...objectId === void 0 ? {} : { objectId },
127
+ ...objectName === void 0 ? {} : { objectName }
128
+ });
129
+ diagnostics.push(...clickResult.diagnostics);
130
+ }
131
+ return {
132
+ ...objectId === void 0 ? {} : { objectId },
133
+ ...objectName === void 0 ? {} : { objectName },
134
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
135
+ ...clickResult?.deferredSlideLink === void 0 ? {} : { deferredSlideLink: clickResult.deferredSlideLink }
136
+ };
137
+ }
138
+ function readShapeRunProperties(rPrCursor, location, diagnostics) {
139
+ const raw = rPrCursor.attrsObject([
140
+ "lang",
141
+ "sz",
142
+ "b",
143
+ "i",
144
+ "u",
145
+ "strike",
146
+ "cap",
147
+ "spc",
148
+ "dirty",
149
+ "smtClean"
150
+ ]);
151
+ const parsed = RunPrAttrSchema.safeParse(raw);
152
+ let lang;
153
+ let fontSize;
154
+ let fontWeight;
155
+ let fontStyle;
156
+ let textDecoration;
157
+ let textTransform;
158
+ let letterSpacing;
159
+ if (!parsed.success) diagnostics.push({
160
+ code: "invalid-xml-value",
161
+ category: "corrupt-input",
162
+ disposition: "recovered",
163
+ location: {
164
+ ...location,
165
+ xpath: rPrCursor.xpath
166
+ },
167
+ attributeOrElement: "a:rPr",
168
+ rawValue: JSON.stringify(raw)
169
+ });
170
+ else {
171
+ const data = parsed.data;
172
+ if (data.lang !== void 0) try {
173
+ lang = assertValidLang(data.lang);
174
+ } catch {
175
+ diagnostics.push({
176
+ code: "invalid-xml-value",
177
+ category: "corrupt-input",
178
+ disposition: "omitted",
179
+ location: {
180
+ ...location,
181
+ xpath: `${rPrCursor.xpath}/@lang`
182
+ },
183
+ attributeOrElement: "@lang",
184
+ rawValue: data.lang
185
+ });
186
+ }
187
+ if (data.sz !== void 0) fontSize = `${data.sz / 100}pt`;
188
+ if (data.b !== void 0) fontWeight = data.b ? "bold" : "normal";
189
+ if (data.i !== void 0) fontStyle = data.i ? "italic" : "normal";
190
+ if (data.u === "sng") textDecoration = "underline";
191
+ else if (data.strike === "sngStrike") textDecoration = "line-through";
192
+ if (data.cap === "all") textTransform = "uppercase";
193
+ else if (data.cap === "none") textTransform = "none";
194
+ if (data.spc !== void 0) letterSpacing = data.spc / 75;
195
+ }
196
+ const solidFill = rPrCursor.child(A_NS, "solidFill");
197
+ const color = solidFill === void 0 ? void 0 : readDrawingColor(solidFill, location, diagnostics);
198
+ const effectLst = rPrCursor.child(A_NS, "effectLst");
199
+ const effects = effectLst === void 0 ? {} : readEffectList(effectLst, location, diagnostics);
200
+ let fontFamily;
201
+ const latin = rPrCursor.child(A_NS, "latin");
202
+ const ea = rPrCursor.child(A_NS, "ea");
203
+ const cs = rPrCursor.child(A_NS, "cs");
204
+ const fontCursor = latin ?? ea ?? cs;
205
+ if (fontCursor !== void 0) {
206
+ const parsedFont = TypefaceAttrSchema.safeParse(fontCursor.attrsObject(["typeface"]));
207
+ if (parsedFont.success) {
208
+ const tf = parsedFont.data.typeface;
209
+ if (tf.startsWith("+mj-")) fontFamily = "major";
210
+ else if (tf.startsWith("+mn-")) fontFamily = "minor";
211
+ else fontFamily = tf;
212
+ }
213
+ }
214
+ if (ea !== void 0 && ea !== fontCursor) ea.consumeAttr("typeface");
215
+ if (cs !== void 0 && cs !== fontCursor) cs.consumeAttr("typeface");
216
+ return {
217
+ ...fontFamily === void 0 ? {} : { fontFamily },
218
+ ...fontSize === void 0 ? {} : { fontSize },
219
+ ...fontWeight === void 0 ? {} : { fontWeight },
220
+ ...fontStyle === void 0 ? {} : { fontStyle },
221
+ ...color === void 0 ? {} : { color },
222
+ ...letterSpacing === void 0 ? {} : { letterSpacing },
223
+ ...textTransform === void 0 ? {} : { textTransform },
224
+ ...textDecoration === void 0 ? {} : { textDecoration },
225
+ ...effects.boxShadow === void 0 ? {} : { textShadow: effects.boxShadow },
226
+ ...lang === void 0 ? {} : { lang }
227
+ };
228
+ }
229
+ function readLineSpacing(lnSpcCursor, location, diagnostics) {
230
+ const spcPts = lnSpcCursor.child(A_NS, "spcPts");
231
+ if (spcPts !== void 0) {
232
+ const parsed = SpacingValAttrSchema.safeParse(spcPts.attrsObject(["val"]));
233
+ if (parsed.success && parsed.data.val > 0) return parsed.data.val / 75;
234
+ }
235
+ const spcPct = lnSpcCursor.child(A_NS, "spcPct");
236
+ if (spcPct !== void 0) {
237
+ spcPct.consumeAttr("val");
238
+ diagnostics.push({
239
+ code: "unsupported-mechanism",
240
+ category: "unsupported",
241
+ disposition: "omitted",
242
+ location: {
243
+ ...location,
244
+ xpath: spcPct.xpath
245
+ },
246
+ namespaceUri: A_NS,
247
+ localName: "spcPct"
248
+ });
249
+ }
250
+ }
251
+ function readShapeParagraph(pCursor, location, diagnostics) {
252
+ let align;
253
+ let lineHeight;
254
+ let spacingAfter;
255
+ let list;
256
+ let level = 0;
257
+ const pPr = pCursor.child(A_NS, "pPr");
258
+ if (pPr !== void 0) {
259
+ const rawPPr = pPr.attrsObject([
260
+ "algn",
261
+ "rtl",
262
+ "lvl"
263
+ ]);
264
+ const parsedPPr = ParagraphPrAttrSchema.safeParse(rawPPr);
265
+ if (!parsedPPr.success) diagnostics.push({
266
+ code: "invalid-xml-value",
267
+ category: "corrupt-input",
268
+ disposition: "recovered",
269
+ location: {
270
+ ...location,
271
+ xpath: pPr.xpath
272
+ },
273
+ attributeOrElement: "a:pPr",
274
+ rawValue: JSON.stringify(rawPPr)
275
+ });
276
+ else {
277
+ if (parsedPPr.data.algn !== void 0) align = algnToTextAlign[parsedPPr.data.algn];
278
+ if (parsedPPr.data.lvl !== void 0) level = parsedPPr.data.lvl;
279
+ }
280
+ const lnSpc = pPr.child(A_NS, "lnSpc");
281
+ if (lnSpc !== void 0) lineHeight = readLineSpacing(lnSpc, location, diagnostics);
282
+ const spcAft = pPr.child(A_NS, "spcAft");
283
+ if (spcAft !== void 0) {
284
+ const spcPts = spcAft.child(A_NS, "spcPts");
285
+ if (spcPts !== void 0) {
286
+ const parsed = SpacingValAttrSchema.safeParse(spcPts.attrsObject(["val"]));
287
+ if (parsed.success) spacingAfter = parsed.data.val / 75;
288
+ }
289
+ }
290
+ pPr.ignoreEmptyChild(A_NS, "buNone");
291
+ const buChar = pPr.child(A_NS, "buChar");
292
+ if (buChar !== void 0) {
293
+ const parsedBu = BulletCharAttrSchema.safeParse(buChar.attrsObject(["char"]));
294
+ if (parsedBu.success) list = {
295
+ type: "bullet",
296
+ character: parsedBu.data.char,
297
+ ...level > 0 ? { level } : {}
298
+ };
299
+ } else {
300
+ const buAutoNum = pPr.child(A_NS, "buAutoNum");
301
+ if (buAutoNum !== void 0) {
302
+ const parsedAuto = BulletAutoNumAttrSchema.safeParse(buAutoNum.attrsObject(["type", "startAt"]));
303
+ if (parsedAuto.success) list = {
304
+ type: "number",
305
+ style: "arabicPeriod",
306
+ ...parsedAuto.data.startAt === void 0 ? {} : { startAt: parsedAuto.data.startAt },
307
+ ...level > 0 ? { level } : {}
308
+ };
309
+ }
310
+ }
311
+ }
312
+ const runs = [];
313
+ for (const child of pCursor.remainingElementChildren()) {
314
+ if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
315
+ const rPr = child.child(A_NS, "rPr");
316
+ const runStyle = rPr === void 0 ? {} : readShapeRunProperties(rPr, location, diagnostics);
317
+ const t = child.child(A_NS, "t");
318
+ if (t !== void 0) {
319
+ t.consumeAttr("space", XML_NS);
320
+ runs.push({
321
+ kind: "text",
322
+ text: t.textContent,
323
+ style: runStyle
324
+ });
325
+ }
326
+ continue;
327
+ }
328
+ if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
329
+ child.consumeAttr("id");
330
+ const fieldType = child.attr("type");
331
+ const rPr = child.child(A_NS, "rPr");
332
+ const runStyle = rPr === void 0 ? {} : readShapeRunProperties(rPr, location, diagnostics);
333
+ const t = child.child(A_NS, "t");
334
+ if (t !== void 0) t.consumeAttr("space", XML_NS);
335
+ if (fieldType === "slidenum") runs.push({
336
+ kind: "slidenum",
337
+ style: runStyle
338
+ });
339
+ else {
340
+ diagnostics.push({
341
+ code: "unsupported-mechanism",
342
+ category: "unsupported",
343
+ disposition: "omitted",
344
+ location: {
345
+ ...location,
346
+ xpath: child.xpath
347
+ },
348
+ namespaceUri: A_NS,
349
+ localName: "fld",
350
+ mechanismHint: `field:${fieldType ?? "unknown"}`
351
+ });
352
+ if (t !== void 0) runs.push({
353
+ kind: "text",
354
+ text: t.textContent,
355
+ style: runStyle
356
+ });
357
+ }
358
+ continue;
359
+ }
360
+ if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
361
+ const rPr = child.child(A_NS, "rPr");
362
+ const runStyle = rPr === void 0 ? {} : readShapeRunProperties(rPr, location, diagnostics);
363
+ runs.push({
364
+ kind: "text",
365
+ text: "\n",
366
+ style: runStyle
367
+ });
368
+ continue;
369
+ }
370
+ if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
371
+ child.consumeAttr("lang");
372
+ child.consumeAttr("sz");
373
+ child.consumeAttr("b");
374
+ child.consumeAttr("i");
375
+ child.consumeAttr("dirty");
376
+ child.consumeAttr("smtClean");
377
+ continue;
378
+ }
379
+ diagnostics.push({
380
+ code: "unconsumed-xml",
381
+ category: "unsupported",
382
+ disposition: "omitted",
383
+ kind: "element",
384
+ location: {
385
+ ...location,
386
+ xpath: child.xpath
387
+ },
388
+ namespaceUri: child.namespaceUri,
389
+ localName: child.localName
390
+ });
391
+ }
392
+ return {
393
+ runs,
394
+ style: {
395
+ ...align === void 0 ? {} : { align },
396
+ ...lineHeight === void 0 ? {} : { lineHeight },
397
+ ...spacingAfter === void 0 ? {} : { spacingAfter },
398
+ ...list === void 0 ? {} : { list }
399
+ }
400
+ };
401
+ }
402
+ function readShapeTxBody(txBodyCursor, location, diagnostics) {
403
+ let paddingTop;
404
+ let paddingRight;
405
+ let paddingBottom;
406
+ let paddingLeft;
407
+ let verticalAlign;
408
+ let textWrap;
409
+ const bodyPr = txBodyCursor.child(A_NS, "bodyPr");
410
+ if (bodyPr !== void 0) {
411
+ const rawBodyPr = bodyPr.attrsObject([
412
+ "wrap",
413
+ "rtlCol",
414
+ "lIns",
415
+ "tIns",
416
+ "rIns",
417
+ "bIns",
418
+ "anchor"
419
+ ]);
420
+ const parsedBodyPr = BodyPrAttrSchema.safeParse(rawBodyPr);
421
+ if (!parsedBodyPr.success) diagnostics.push({
422
+ code: "invalid-xml-value",
423
+ category: "corrupt-input",
424
+ disposition: "recovered",
425
+ location: {
426
+ ...location,
427
+ xpath: bodyPr.xpath
428
+ },
429
+ attributeOrElement: "a:bodyPr",
430
+ rawValue: JSON.stringify(rawBodyPr)
431
+ });
432
+ else {
433
+ const b = parsedBodyPr.data;
434
+ if (b.wrap === "none") textWrap = "nowrap";
435
+ else if (b.wrap === "square") textWrap = "normal";
436
+ if (b.anchor !== void 0) verticalAlign = anchorToVerticalAlign[b.anchor];
437
+ if (b.lIns !== void 0 && b.lIns !== 0) paddingLeft = emuToPx(b.lIns);
438
+ if (b.tIns !== void 0 && b.tIns !== 0) paddingTop = emuToPx(b.tIns);
439
+ if (b.rIns !== void 0 && b.rIns !== 0) paddingRight = emuToPx(b.rIns);
440
+ if (b.bIns !== void 0 && b.bIns !== 0) paddingBottom = emuToPx(b.bIns);
441
+ }
442
+ bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
443
+ bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
444
+ }
445
+ txBodyCursor.ignoreEmptyChild(A_NS, "lstStyle");
446
+ const paragraphs = txBodyCursor.children(A_NS, "p").map((pCursor) => readShapeParagraph(pCursor, location, diagnostics));
447
+ return {
448
+ ...paddingTop === void 0 ? {} : { paddingTop },
449
+ ...paddingRight === void 0 ? {} : { paddingRight },
450
+ ...paddingBottom === void 0 ? {} : { paddingBottom },
451
+ ...paddingLeft === void 0 ? {} : { paddingLeft },
452
+ ...verticalAlign === void 0 ? {} : { verticalAlign },
453
+ ...textWrap === void 0 ? {} : { textWrap },
454
+ paragraphs
455
+ };
456
+ }
457
+ /**
458
+ * Reads a Transitional `<p:sp>` native shape (preset or custom geometry, fills, borders, effects,
459
+ * transforms, hyperlink, and optional rich text body) into an editable `ShapeNode`.
460
+ */
461
+ function readShapeSp(context, mapBox) {
462
+ const { cursor, part, slideIndex, package: pkg } = context;
463
+ const diagnostics = [];
464
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
465
+ if (nvSpPr === void 0) {
466
+ diagnostics.push({
467
+ code: "corrupt-part",
468
+ category: "corrupt-input",
469
+ disposition: "omitted",
470
+ location: {
471
+ part,
472
+ xpath: cursor.xpath,
473
+ slideIndex
474
+ }
475
+ });
476
+ return { diagnostics };
477
+ }
478
+ const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(nvSpPr.child(P_NS, "cNvPr"), context, diagnostics);
479
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
480
+ if (cNvSpPr !== void 0) cNvSpPr.consumeAttr("txBox");
481
+ consumeNonPlaceholderNvPr(nvSpPr);
482
+ const location = {
483
+ part,
484
+ slideIndex,
485
+ ...objectId === void 0 ? {} : { objectId },
486
+ ...objectName === void 0 ? {} : { objectName }
487
+ };
488
+ const spPr = cursor.child(P_NS, "spPr");
489
+ if (spPr === void 0) {
490
+ diagnostics.push({
491
+ code: "corrupt-part",
492
+ category: "corrupt-input",
493
+ disposition: "omitted",
494
+ location: {
495
+ ...location,
496
+ xpath: cursor.xpath
497
+ }
498
+ });
499
+ return { diagnostics };
500
+ }
501
+ const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
502
+ if (visuals === void 0) return { diagnostics };
503
+ const mappedBox = mapBox ? mapBox({
504
+ x: visuals.transform.x,
505
+ y: visuals.transform.y,
506
+ width: visuals.transform.width,
507
+ height: visuals.transform.height
508
+ }) : {
509
+ x: visuals.transform.x,
510
+ y: visuals.transform.y,
511
+ width: visuals.transform.width,
512
+ height: visuals.transform.height
513
+ };
514
+ const txBody = cursor.child(P_NS, "txBody");
515
+ const importedText = txBody === void 0 ? void 0 : readShapeTxBody(txBody, location, diagnostics);
516
+ const singleParagraph = importedText !== void 0 && importedText.paragraphs.length === 1 ? importedText.paragraphs[0] : void 0;
517
+ const isSingleEmptyParagraph = singleParagraph !== void 0 && singleParagraph.runs.length === 0 && singleParagraph.style.list === void 0;
518
+ const singlePlainRun = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" ? singleParagraph.runs[0] : void 0;
519
+ const hasEffectiveText = singlePlainRun !== void 0 && singlePlainRun.text !== "" || importedText !== void 0 && singlePlainRun === void 0 && !isSingleEmptyParagraph && importedText.paragraphs.length > 0;
520
+ const shapeStyle = {
521
+ ...visuals.style,
522
+ ...hasEffectiveText && importedText?.paddingTop !== void 0 ? { paddingTop: importedText.paddingTop } : {},
523
+ ...hasEffectiveText && importedText?.paddingRight !== void 0 ? { paddingRight: importedText.paddingRight } : {},
524
+ ...hasEffectiveText && importedText?.paddingBottom !== void 0 ? { paddingBottom: importedText.paddingBottom } : {},
525
+ ...hasEffectiveText && importedText?.paddingLeft !== void 0 ? { paddingLeft: importedText.paddingLeft } : {},
526
+ ...hasEffectiveText && importedText?.verticalAlign !== void 0 ? { verticalAlign: importedText.verticalAlign } : {},
527
+ ...hasEffectiveText && importedText?.textWrap !== void 0 ? { textWrap: importedText.textWrap } : {}
528
+ };
529
+ const singleTextStyle = hasEffectiveText && singlePlainRun !== void 0 && singleParagraph !== void 0 ? {
530
+ ...singleParagraph.style,
531
+ ...singlePlainRun.style
532
+ } : void 0;
533
+ const props = {
534
+ ...objectName === void 0 ? {} : { name: objectName },
535
+ ...link === void 0 ? {} : { link },
536
+ ...visuals.geometry === void 0 ? {} : { geometry: visuals.geometry },
537
+ ...visuals.transform.flipH ? { flipH: true } : {},
538
+ ...visuals.transform.flipV ? { flipV: true } : {},
539
+ x: mappedBox.x,
540
+ y: mappedBox.y,
541
+ width: mappedBox.width,
542
+ height: mappedBox.height,
543
+ ...Object.keys(shapeStyle).length === 0 ? {} : { style: shapeStyle },
544
+ ...hasEffectiveText && singlePlainRun !== void 0 ? { text: singlePlainRun.text } : {},
545
+ ...singleTextStyle !== void 0 && Object.keys(singleTextStyle).length > 0 ? { textStyle: singleTextStyle } : {}
546
+ };
547
+ const node = createShapeNode(props);
548
+ if (hasEffectiveText && importedText !== void 0 && singlePlainRun === void 0 && importedText.paragraphs.length > 0) {
549
+ const paragraphNodes = importedText.paragraphs.map((para) => {
550
+ const pProps = Object.keys(para.style).length === 0 ? {} : { style: para.style };
551
+ const pNode = createParagraphNode(pProps);
552
+ if (para.runs.length === 1 && para.runs[0].kind === "text" && Object.keys(para.runs[0].style).length === 0) pNode.content(para.runs[0].text);
553
+ else pNode.content(...para.runs.map((run) => {
554
+ if (run.kind === "slidenum") return createSlideNumberNode(Object.keys(run.style).length === 0 ? {} : { style: run.style });
555
+ return Object.keys(run.style).length === 0 ? run.text : createSpanNode({ style: run.style }).content(run.text);
556
+ }));
557
+ return pNode;
558
+ });
559
+ node.content(...paragraphNodes);
560
+ }
561
+ attachDeferredSlideLink(node, deferredSlideLink, context);
562
+ return {
563
+ node,
564
+ diagnostics
565
+ };
566
+ }
567
+ const presetShapeImportHandler = {
568
+ target: "shape-tree",
569
+ localName: "sp",
570
+ matches: isPresetShapeSpElement,
571
+ read: (context) => readShapeSp(context)
572
+ };
573
+ const customGeometryShapeImportHandler = {
574
+ target: "shape-tree",
575
+ localName: "sp",
576
+ matches: isCustomGeometryShapeSpElement,
577
+ read: (context) => readShapeSp(context)
578
+ };
579
+ export { customGeometryShapeImportHandler, isCustomGeometryShapeSpElement, isPresetShapeSpElement, presetShapeImportHandler, readNonVisualCommonProperties, readShapeSp };
@@ -0,0 +1,6 @@
1
+ // ../capabilities/dist/shape/shape-xml.js
2
+ /** Internal PresentationML wrapper for native shape objects. */
3
+ function shapeXml(id, escapedName, properties, textBody, linkXml) {
4
+ return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr/><p:nvPr/></p:nvSpPr>${properties}${textBody}</p:sp>`;
5
+ }
6
+ export { shapeXml };