@officedk/pptxdk 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/dist/build.d.ts +14 -76
  2. package/dist/build.js +69 -97
  3. package/dist/cli.js +1 -1
  4. package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
  5. package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
  6. package/dist/core/dist/capabilities/audio/entry.js +122 -0
  7. package/dist/core/dist/capabilities/box/box-codegen.js +83 -0
  8. package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
  9. package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
  10. package/dist/core/dist/capabilities/box/entry.js +2 -0
  11. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
  12. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
  13. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
  14. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
  15. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
  16. package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
  17. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +216 -212
  18. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
  19. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
  20. package/dist/core/dist/capabilities/chart/entry.js +2 -0
  21. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
  22. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
  23. package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
  24. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
  25. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +30 -9
  26. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
  27. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
  28. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
  29. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
  30. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
  31. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
  32. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +3 -3
  33. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
  34. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
  35. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +5 -5
  36. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
  37. package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
  38. package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
  39. package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
  40. package/dist/core/dist/capabilities/comment/comment.js +141 -0
  41. package/dist/core/dist/capabilities/comment/entry.js +1 -0
  42. package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
  43. package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
  44. package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +194 -133
  45. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
  46. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
  47. package/dist/core/dist/capabilities/group/entry.js +2 -0
  48. package/dist/core/dist/capabilities/group/group-codegen.js +73 -0
  49. package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
  50. package/dist/core/dist/capabilities/group/group-import.js +608 -0
  51. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
  52. package/dist/core/dist/capabilities/group/group.js +260 -0
  53. package/dist/core/dist/capabilities/image/entry.js +4 -0
  54. package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
  55. package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
  56. package/dist/core/dist/capabilities/image/image-import.js +26 -0
  57. package/dist/core/dist/capabilities/image/image.js +57 -0
  58. package/dist/core/dist/capabilities/line/entry.js +3 -0
  59. package/dist/core/dist/capabilities/line/line-codegen.js +88 -0
  60. package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
  61. package/dist/core/dist/capabilities/line/line-import.js +424 -0
  62. package/dist/core/dist/capabilities/line/line-xml.js +9 -0
  63. package/dist/core/dist/capabilities/line/line.js +329 -0
  64. package/dist/core/dist/capabilities/masters/entry.js +1 -0
  65. package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
  66. package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
  67. package/dist/core/dist/capabilities/motion/entry.js +5 -0
  68. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
  69. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
  70. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
  71. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
  72. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
  73. package/dist/core/dist/capabilities/notes/entry.js +2 -0
  74. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
  75. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
  76. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
  77. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +12 -9
  78. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
  79. package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
  80. package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
  81. package/dist/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
  82. package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
  83. package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
  84. package/dist/core/dist/capabilities/shape/entry.js +6 -0
  85. package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
  86. package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
  87. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
  88. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +100 -103
  89. package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
  90. package/dist/core/dist/capabilities/shared/date-time.js +98 -0
  91. package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
  92. package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
  93. package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
  94. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
  95. package/dist/core/dist/capabilities/shared/font/font.js +72 -0
  96. package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
  97. package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
  98. package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
  99. package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
  100. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -56
  101. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
  102. package/dist/core/dist/capabilities/shared/line-match.js +78 -0
  103. package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
  104. package/dist/core/dist/capabilities/shared/media-import.js +156 -0
  105. package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
  106. package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
  107. package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
  108. package/dist/core/dist/capabilities/shared/media-source.js +107 -0
  109. package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
  110. package/dist/core/dist/capabilities/shared/media.js +134 -0
  111. package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
  112. package/dist/core/dist/capabilities/shared/motion-api.js +770 -0
  113. package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
  114. package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
  115. package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
  116. package/dist/core/dist/capabilities/shared/picture.js +510 -0
  117. package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
  118. package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
  119. package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
  120. package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
  121. package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
  122. package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
  123. package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
  124. package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
  125. package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
  126. package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
  127. package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
  128. package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
  129. package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
  130. package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
  131. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +12 -7
  132. package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
  133. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
  134. package/dist/core/dist/capabilities/table/entry.js +2 -0
  135. package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
  136. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
  137. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
  138. package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
  139. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
  140. package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
  141. package/dist/core/dist/capabilities/text/entry.js +3 -0
  142. package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
  143. package/dist/core/dist/capabilities/text/text-import.js +468 -0
  144. package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
  145. package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +103 -111
  146. package/dist/core/dist/capabilities/transition/entry.js +3 -0
  147. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
  148. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
  149. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
  150. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
  151. package/dist/core/dist/capabilities/video/entry.js +77 -0
  152. package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
  153. package/dist/core/dist/capabilities/video/video-source.js +42 -0
  154. package/dist/{codegen/dist → core/dist/codegen}/assets.js +16 -10
  155. package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
  156. package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -1
  157. package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
  158. package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
  159. package/dist/core/dist/document/all.js +41 -0
  160. package/dist/core/dist/document/default.js +10 -0
  161. package/dist/core/dist/document/document.js +218 -0
  162. package/dist/core/dist/document/index.js +62 -0
  163. package/dist/core/dist/document/stages.js +54 -0
  164. package/dist/{emit/dist → core/dist/emit}/emit.js +173 -90
  165. package/dist/core/dist/emit/index.js +6 -0
  166. package/dist/core/dist/emit/ooxml.js +241 -0
  167. package/dist/core/dist/import/import.js +547 -0
  168. package/dist/core/dist/import/index.js +19 -0
  169. package/dist/{import/dist → core/dist/import}/masters.js +404 -328
  170. package/dist/core/dist/import/media-timing.js +233 -0
  171. package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
  172. package/dist/core/dist/index.js +47 -15
  173. package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +9 -6
  174. package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
  175. package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
  176. package/dist/core/dist/kernel/build.js +4 -0
  177. package/dist/core/dist/kernel/capability.js +17 -0
  178. package/dist/core/dist/kernel/codegen.js +97 -0
  179. package/dist/core/dist/kernel/container-slots.js +104 -0
  180. package/dist/core/dist/kernel/date-time-format.js +18 -0
  181. package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
  182. package/dist/core/dist/{declaration.js → kernel/declaration.js} +3 -2
  183. package/dist/core/dist/kernel/diagnostics.js +370 -0
  184. package/dist/core/dist/kernel/document-internals.js +26 -0
  185. package/dist/core/dist/{document.js → kernel/document.js} +23 -13
  186. package/dist/core/dist/kernel/drawing-units.js +14 -0
  187. package/dist/core/dist/kernel/font-seal.js +204 -0
  188. package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
  189. package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
  190. package/dist/core/dist/{host.js → kernel/host.js} +1 -1
  191. package/dist/core/dist/kernel/index.js +24 -0
  192. package/dist/core/dist/kernel/input-values.js +62 -0
  193. package/dist/core/dist/kernel/layout-definition.js +7 -0
  194. package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
  195. package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
  196. package/dist/core/dist/kernel/layout.js +339 -0
  197. package/dist/core/dist/kernel/masters.js +171 -0
  198. package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
  199. package/dist/core/dist/kernel/placeholders.js +289 -0
  200. package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
  201. package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +33 -29
  202. package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
  203. package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
  204. package/dist/core/dist/kernel/pptx-read/index.js +15 -0
  205. package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
  206. package/dist/core/dist/kernel/pptx-read/media.js +26 -0
  207. package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +6 -7
  208. package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
  209. package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
  210. package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
  211. package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +182 -41
  212. package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
  213. package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
  214. package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
  215. package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
  216. package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
  217. package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +133 -290
  218. package/dist/core/dist/{query.js → kernel/query.js} +76 -37
  219. package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
  220. package/dist/core/dist/kernel/resolve-work.js +58 -0
  221. package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
  222. package/dist/core/dist/kernel/resource-source.js +11 -0
  223. package/dist/core/dist/kernel/stage-options.js +312 -0
  224. package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
  225. package/dist/core/dist/kernel/transform-geometry.js +72 -0
  226. package/dist/core/dist/kernel/xml-values.js +13 -0
  227. package/dist/document-C0lPlH-L.d.ts +1442 -0
  228. package/dist/index-B9_OUeA-.d.ts +2238 -0
  229. package/dist/index-BJEzQxWV.d.ts +75 -0
  230. package/dist/index-DA9flrlR.d.ts +146 -0
  231. package/dist/index-GSt0t9VO.d.ts +54 -0
  232. package/dist/index.d.ts +7 -7
  233. package/dist/index.js +75 -61
  234. package/dist/node.d.ts +37 -35
  235. package/dist/node.js +125 -51
  236. package/dist/pptxdk/src/cli-commands.js +79 -81
  237. package/dist/pptxdk/src/compose.js +32 -24
  238. package/dist/pptxdk/src/preview-result.js +24 -0
  239. package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
  240. package/dist/preview/dist/index.js +229 -77
  241. package/dist/preview/dist/options.js +17 -26
  242. package/dist/preview/dist/raster.js +66 -0
  243. package/dist/preview/dist/svg-guard.js +1090 -0
  244. package/dist/preview.d.ts +6 -3
  245. package/dist/preview.js +8 -24
  246. package/dist/react/dist/append.js +3 -3
  247. package/dist/react/dist/author/audio-elements.js +14 -0
  248. package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
  249. package/dist/react/dist/author/chart-elements.js +14 -0
  250. package/dist/react/dist/author/comment-elements.js +15 -0
  251. package/dist/react/dist/author/group-elements.js +14 -0
  252. package/dist/react/dist/author/image-elements.js +14 -0
  253. package/dist/react/dist/author/line-elements.js +14 -0
  254. package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
  255. package/dist/react/dist/author/notes-elements.js +14 -0
  256. package/dist/react/dist/author/placeholder-elements.js +14 -0
  257. package/dist/react/dist/author/shape-elements.js +14 -0
  258. package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
  259. package/dist/react/dist/author/text-elements.js +64 -0
  260. package/dist/react/dist/author/video-elements.js +14 -0
  261. package/dist/react/dist/document-adapter.js +376 -37
  262. package/dist/react/dist/elements.js +30 -4
  263. package/dist/react/dist/from-vanilla.js +57 -0
  264. package/dist/react/dist/index.js +47 -12
  265. package/dist/react/dist/mount.js +34 -0
  266. package/dist/react/dist/reconciler.js +26 -26
  267. package/dist/react.d.ts +174 -50
  268. package/dist/react.js +31 -27
  269. package/dist/stages-DYHSHKt4.d.ts +80 -0
  270. package/dist/vanilla.d.ts +4 -4
  271. package/dist/vanilla.js +14 -14
  272. package/package.json +6 -8
  273. package/README.md +0 -49
  274. package/dist/capabilities/dist/all.js +0 -32
  275. package/dist/capabilities/dist/box/box-codegen.js +0 -51
  276. package/dist/capabilities/dist/box/box-declaration.js +0 -31
  277. package/dist/capabilities/dist/chart/chart-elements.js +0 -12
  278. package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
  279. package/dist/capabilities/dist/document.js +0 -148
  280. package/dist/capabilities/dist/font/font-embedding.js +0 -289
  281. package/dist/capabilities/dist/font/font-family.js +0 -10
  282. package/dist/capabilities/dist/font/font-import.js +0 -302
  283. package/dist/capabilities/dist/font/font.js +0 -25
  284. package/dist/capabilities/dist/group/group-codegen.js +0 -51
  285. package/dist/capabilities/dist/group/group-declaration.js +0 -42
  286. package/dist/capabilities/dist/group/group-elements.js +0 -12
  287. package/dist/capabilities/dist/group/group-import.js +0 -319
  288. package/dist/capabilities/dist/group/group.js +0 -211
  289. package/dist/capabilities/dist/image/image-codegen.js +0 -94
  290. package/dist/capabilities/dist/image/image-declaration.js +0 -8
  291. package/dist/capabilities/dist/image/image-elements.js +0 -12
  292. package/dist/capabilities/dist/image/image-xml.js +0 -12
  293. package/dist/capabilities/dist/image/image.js +0 -472
  294. package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
  295. package/dist/capabilities/dist/motion/motion-api.js +0 -527
  296. package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
  297. package/dist/capabilities/dist/notes/notes-elements.js +0 -12
  298. package/dist/capabilities/dist/notes/notes-xml.js +0 -38
  299. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +0 -23
  300. package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
  301. package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
  302. package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
  303. package/dist/capabilities/dist/shape/shape-elements.js +0 -12
  304. package/dist/capabilities/dist/shape/shape-import.js +0 -579
  305. package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
  306. package/dist/capabilities/dist/shared/style-parse.js +0 -11
  307. package/dist/capabilities/dist/shared/text-schemas.js +0 -216
  308. package/dist/capabilities/dist/shared/text-service.js +0 -1883
  309. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
  310. package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
  311. package/dist/capabilities/dist/table/table-codegen.js +0 -81
  312. package/dist/capabilities/dist/table/table-schemas.js +0 -279
  313. package/dist/capabilities/dist/text/text-codegen.js +0 -129
  314. package/dist/capabilities/dist/text/text-declaration.js +0 -19
  315. package/dist/capabilities/dist/text/text-elements.js +0 -38
  316. package/dist/capabilities/dist/text/text-import.js +0 -1077
  317. package/dist/capability-D_xeNVIw.d.ts +0 -29496
  318. package/dist/codegen/dist/types.js +0 -49
  319. package/dist/core/dist/build.js +0 -4
  320. package/dist/core/dist/capability.js +0 -13
  321. package/dist/core/dist/diagnostics.js +0 -21
  322. package/dist/core/dist/document-internals.js +0 -13
  323. package/dist/core/dist/input-values.js +0 -45
  324. package/dist/core/dist/layout.js +0 -299
  325. package/dist/core/dist/masters.js +0 -169
  326. package/dist/core/dist/placeholders.js +0 -213
  327. package/dist/core/dist/stage-options.js +0 -67
  328. package/dist/document-BHPUODPP.d.ts +0 -27759
  329. package/dist/emit/dist/index.js +0 -5
  330. package/dist/import/dist/import.js +0 -504
  331. package/dist/import/dist/index.js +0 -16
  332. package/dist/import/dist/xml-fragments.js +0 -36
  333. package/dist/index-B5m3hqjC.d.ts +0 -7
  334. package/dist/index-CCy-Yo8G.d.ts +0 -1208
  335. package/dist/index-DpxcZ4Gs.d.ts +0 -725
  336. package/dist/pptxdk/src/slide.js +0 -9
  337. package/dist/preview-Cfw0QdMM.d.ts +0 -86
  338. package/dist/transition-Cips9wma.d.ts +0 -82
@@ -0,0 +1,394 @@
1
+ import { CapabilityError } from "../../kernel/diagnostics.js";
2
+ import { EMU_PER_PX } from "../../kernel/drawing-units.js";
3
+ import { parseLinkTarget } from "../../kernel/author-schemas.js";
4
+ import { parseCapabilityLayoutContract } from "../../kernel/layout.js";
5
+ import { nativeLinkXml, parseMorphKey, parseOptionalName, readClickLink } from "../shared/identity.js";
6
+ import { directElementChild, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
7
+ import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
8
+ import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../kernel/pptx-read/xml-fragments.js";
9
+ import { readPlaceholderTransform } from "../../kernel/pptx-read/visual.js";
10
+ import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
11
+ import { createShapeNode, shapeStyleSchema } from "../shared/shape-declaration.js";
12
+ import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
13
+ import { assertVisualBoxExtent, bindVisualModel, emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
14
+ import "../../kernel/capability.js";
15
+ import "../../kernel/pptx-read/index.js";
16
+ import { assertXml10Characters, placeholderRefXml, xmlEscape } from "../../kernel/pptx-write/xml.js";
17
+ import { placeholderCodegen } from "./placeholder-codegen.js";
18
+ import { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys } from "./placeholder-schemas.js";
19
+ import { z } from "zod";
20
+ // ../core/dist/capabilities/placeholder/placeholder.js
21
+ const NonVisualSpIdSchema = z.object({
22
+ id: ooxmlNonNegativeIntSchema,
23
+ name: z.string().optional()
24
+ });
25
+ const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
26
+ const placeholderAllowedStyleKeys = new Set(placeholderStyleKeys);
27
+ function emitPlaceholderModel(model, emitContext) {
28
+ const escapedName = xmlEscape(model.name);
29
+ const spPrXml = emitPlaceholderVisualSpPr(model.visual, model.spPrFlags, (resource) => emitContext.registerResource(resource));
30
+ return { xml: `<p:sp><p:nvSpPr><p:cNvPr id="${emitContext.id}" name="${escapedName}">${nativeLinkXml(emitContext.nativeLink)}</p:cNvPr><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(model.nativeRef)}</p:nvPr></p:nvSpPr>${spPrXml}</p:sp>` };
31
+ }
32
+ function paintPlaceholderModel() {
33
+ return { svg: "" };
34
+ }
35
+ /**
36
+ * Reads an unpopulated `<p:sp>` content/object placeholder (no `<p:txBody>`)
37
+ * into a layout-bound `PlaceholderNode` while preserving `<p:ph>` binding.
38
+ */
39
+ function readContentPlaceholderSp(context) {
40
+ const { cursor, part, slideIndex } = context;
41
+ const diagnostics = [];
42
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
43
+ if (nvSpPr === void 0) {
44
+ diagnostics.push({
45
+ code: "corrupt-part",
46
+ category: "corrupt-input",
47
+ disposition: "omitted",
48
+ location: {
49
+ part,
50
+ xpath: cursor.xpath,
51
+ slideIndex
52
+ }
53
+ });
54
+ return { diagnostics };
55
+ }
56
+ let objectId;
57
+ let objectName;
58
+ let clickResult;
59
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
60
+ if (cNvPr !== void 0) {
61
+ const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
62
+ const parsedCNvPr = NonVisualSpIdSchema.safeParse(rawCNvPr);
63
+ if (!parsedCNvPr.success) diagnostics.push({
64
+ code: "invalid-xml-value",
65
+ category: "corrupt-input",
66
+ disposition: "recovered",
67
+ location: {
68
+ part,
69
+ xpath: cNvPr.xpath,
70
+ slideIndex
71
+ },
72
+ attributeOrElement: "p:cNvPr",
73
+ rawValue: JSON.stringify(rawCNvPr)
74
+ });
75
+ else {
76
+ objectId = parsedCNvPr.data.id;
77
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
78
+ }
79
+ const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
80
+ if (hlinkClick !== void 0) {
81
+ clickResult = readClickLink(hlinkClick, context, {
82
+ ...objectId === void 0 ? {} : { objectId },
83
+ ...objectName === void 0 ? {} : { objectName }
84
+ });
85
+ diagnostics.push(...clickResult.diagnostics);
86
+ }
87
+ cNvPr.ignoreEmptyChild(A_NS, "extLst");
88
+ }
89
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
90
+ if (cNvSpPr !== void 0) {
91
+ NonVisualSpPrFlagsSchema.safeParse(cNvSpPr.attrsObject(["txBox"]));
92
+ cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
93
+ "noGrp",
94
+ "noRot",
95
+ "noChangeAspect",
96
+ "noMove",
97
+ "noResize",
98
+ "noSelect"
99
+ ]);
100
+ }
101
+ const phLocation = {
102
+ part,
103
+ xpath: cursor.xpath,
104
+ slideIndex,
105
+ ...objectId === void 0 ? {} : { objectId },
106
+ ...objectName === void 0 ? {} : { objectName }
107
+ };
108
+ const nvPr = nvSpPr.child(P_NS, "nvPr");
109
+ const phResult = readNvPrPlaceholder(nvPr, phLocation, diagnostics);
110
+ if (phResult.kind === "none") {
111
+ diagnostics.push({
112
+ code: "corrupt-part",
113
+ category: "corrupt-input",
114
+ disposition: "omitted",
115
+ location: phLocation
116
+ });
117
+ return { diagnostics };
118
+ }
119
+ if (phResult.kind === "error") return { diagnostics };
120
+ const nativeRef = phResult.nativeRef;
121
+ const spPr = cursor.child(P_NS, "spPr");
122
+ if (spPr === void 0) {
123
+ diagnostics.push({
124
+ code: "corrupt-part",
125
+ category: "corrupt-input",
126
+ disposition: "omitted",
127
+ location: phLocation
128
+ });
129
+ return { diagnostics };
130
+ }
131
+ const { offset, extent, rotate, flipH, flipV } = readPlaceholderTransform(spPr.child(A_NS, "xfrm"), phLocation, diagnostics);
132
+ const claim = resolvePlaceholderImportClaim({
133
+ context,
134
+ nativeRef
135
+ });
136
+ const layoutPlaceholder = claim.layoutPlaceholder;
137
+ const masterPlaceholder = claim.masterPlaceholder;
138
+ const inheritedWidth = (typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0) ?? (typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0);
139
+ const inheritedHeight = (typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0) ?? (typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0);
140
+ const boxSize = extent ?? (inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
141
+ width: inheritedWidth,
142
+ height: inheritedHeight
143
+ } : void 0);
144
+ const effectiveFallbackUnits = boxSize === void 0 ? {
145
+ w: 0,
146
+ h: 0
147
+ } : {
148
+ w: Math.round(boxSize.width * EMU_PER_PX),
149
+ h: Math.round(boxSize.height * EMU_PER_PX)
150
+ };
151
+ const appearance = readSpPrAppearance(spPr, context.package, effectiveFallbackUnits, phLocation, diagnostics, { preservePlaceholderClears: true });
152
+ const { border: rawBorder, ...restVisualStyle } = appearance.style;
153
+ const border = rawBorder;
154
+ let borderRadius;
155
+ if (appearance.geometry === "roundRect") {
156
+ if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
157
+ } else if (typeof appearance.geometry === "object" && appearance.geometry.type === "preset" && appearance.geometry.name === "roundRect" && boxSize !== void 0) {
158
+ const adj = appearance.geometry.adjust?.["adj"] ?? 16667;
159
+ if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
160
+ }
161
+ const combinedStyle = {
162
+ ...offset === void 0 ? {} : {
163
+ position: "absolute",
164
+ left: offset.x,
165
+ top: offset.y
166
+ },
167
+ ...extent,
168
+ ...restVisualStyle,
169
+ ...border === void 0 ? {} : { border },
170
+ ...borderRadius === void 0 ? {} : { borderRadius },
171
+ ...rotate === void 0 ? {} : { rotate },
172
+ ...flipH === void 0 ? {} : { flipH },
173
+ ...flipV === void 0 ? {} : { flipV }
174
+ };
175
+ if (!claim.bound) {
176
+ const resolvedBox = resolveUnboundPlaceholderBox({
177
+ inheritanceContext: claim.inheritanceContext,
178
+ localBox: {
179
+ ...offset,
180
+ ...extent
181
+ },
182
+ requireHeight: true
183
+ });
184
+ if (resolvedBox === void 0 || resolvedBox.height === void 0) {
185
+ emitPlaceholderUnbindDiagnostic({
186
+ diagnostics,
187
+ location: phLocation,
188
+ retainedAs: "omitted"
189
+ });
190
+ return { diagnostics };
191
+ }
192
+ const freeVisual = materializeUnboundVisualStyle({
193
+ inheritanceContext: claim.inheritanceContext,
194
+ localVisualStyle: {
195
+ ...restVisualStyle,
196
+ ...border === void 0 ? {} : { border },
197
+ ...borderRadius === void 0 ? {} : { borderRadius },
198
+ ...rotate === void 0 ? {} : { rotate },
199
+ ...flipH === void 0 ? {} : { flipH },
200
+ ...flipV === void 0 ? {} : { flipV }
201
+ },
202
+ ...appearance.geometry === void 0 ? {} : { localGeometry: appearance.geometry },
203
+ boxSize: {
204
+ width: resolvedBox.width,
205
+ height: resolvedBox.height
206
+ }
207
+ });
208
+ const rawFreeStyle = stripPlaceholderClearSentinels({
209
+ ...freeVisual,
210
+ position: "absolute",
211
+ left: resolvedBox.x,
212
+ top: resolvedBox.y,
213
+ width: resolvedBox.width,
214
+ height: resolvedBox.height
215
+ });
216
+ const parsedFreeStyle = shapeStyleSchema.safeParse(rawFreeStyle);
217
+ const effectiveGeom = appearance.geometry ?? layoutPlaceholder?.geometry ?? masterPlaceholder?.geometry;
218
+ const freeShape = createShapeNode({
219
+ ...objectName === void 0 ? {} : { name: objectName },
220
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
221
+ ...effectiveGeom === void 0 ? {} : { geometry: effectiveGeom },
222
+ style: parsedFreeStyle.success ? parsedFreeStyle.data : {
223
+ position: "absolute",
224
+ left: resolvedBox.x,
225
+ top: resolvedBox.y,
226
+ width: resolvedBox.width,
227
+ height: resolvedBox.height
228
+ }
229
+ });
230
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
231
+ const deferred = clickResult.deferredSlideLink;
232
+ context.registerDeferredSlideLink({
233
+ ...deferred,
234
+ apply(targetSlideId) {
235
+ freeShape.set({ link: { id: targetSlideId } });
236
+ }
237
+ });
238
+ }
239
+ emitPlaceholderUnbindDiagnostic({
240
+ diagnostics,
241
+ location: phLocation,
242
+ retainedAs: "shape"
243
+ });
244
+ return {
245
+ node: freeShape,
246
+ diagnostics
247
+ };
248
+ }
249
+ let validatedStyle;
250
+ if (Object.keys(combinedStyle).length > 0) {
251
+ const parsedStyle = placeholderObjectStyleSchema.safeParse(combinedStyle);
252
+ if (parsedStyle.success) validatedStyle = parsedStyle.data;
253
+ }
254
+ const node = createPlaceholderNode({
255
+ ...objectName === void 0 ? {} : { name: objectName },
256
+ placeholder: claim.key,
257
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
258
+ ...validatedStyle === void 0 ? {} : { style: validatedStyle }
259
+ });
260
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
261
+ const deferred = clickResult.deferredSlideLink;
262
+ context.registerDeferredSlideLink({
263
+ ...deferred,
264
+ apply(targetSlideId) {
265
+ node.set({ link: { id: targetSlideId } });
266
+ }
267
+ });
268
+ }
269
+ return {
270
+ node,
271
+ diagnostics
272
+ };
273
+ }
274
+ /** Shape-tree import handler wired into `contentPlaceholderMechanism` for unpopulated `<p:sp><p:ph .../></p:sp>` placeholders without `<p:txBody>`. */
275
+ const contentPlaceholderImportHandler = {
276
+ target: "shape-tree",
277
+ localName: "sp",
278
+ matches: (cursor) => isPlaceholderSpElement(cursor) && directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0,
279
+ read: readContentPlaceholderSp
280
+ };
281
+ /** Typed native canvas mechanism connecting emit, paint, and import for unpopulated `content-placeholder`. */
282
+ const contentPlaceholderMechanism = defineCanvasMechanism({
283
+ key: "content-placeholder",
284
+ role: "canvas",
285
+ emit: emitPlaceholderModel,
286
+ paint: paintPlaceholderModel,
287
+ import: contentPlaceholderImportHandler
288
+ });
289
+ /** Capability preserving unpopulated non-text content placeholder slots across import/emit without synthesizing empty text bodies. */
290
+ const placeholderCapability = {
291
+ declaration: "placeholder",
292
+ mechanisms: [contentPlaceholderMechanism],
293
+ codegen: placeholderCodegen,
294
+ *bind(input, context) {
295
+ const unknown = Object.keys(input.props).find((key) => !placeholderAllowedPropKeys.has(key));
296
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Placeholder contains unsupported parameter ${unknown}`);
297
+ if (input.children.length > 0) throw new CapabilityError("unsupported-children", "Unpopulated content placeholder does not accept children");
298
+ const placeholder = context.placeholder;
299
+ if (placeholder === void 0) throw new CapabilityError("missing-placeholder-binding", "Content placeholder requires a bound layout placeholder");
300
+ const requestedName = parseOptionalName(input.props["name"]);
301
+ const morphKey = parseMorphKey(input.props["morphKey"]);
302
+ const link = parseLinkTarget(input.props["link"]);
303
+ const contract = parseCapabilityLayoutContract({
304
+ nativeKind: "sp",
305
+ props: input.props,
306
+ allowedStyleKeys: placeholderAllowedStyleKeys,
307
+ allowPadding: false,
308
+ path: context.path
309
+ });
310
+ const rawSlideStyle = typeof input.props["style"] === "object" && input.props["style"] !== null && !Array.isArray(input.props["style"]) ? input.props["style"] : void 0;
311
+ const inheritedPlaceholderGeometry = placeholder.layoutPlaceholder?.geometry ?? placeholder.masterPlaceholder?.geometry;
312
+ const visualStyle = resolvePlaceholderVisualStyle(placeholder, rawSlideStyle);
313
+ const initialVisual = yield* bindVisualModel({
314
+ theme: placeholder.masterTheme,
315
+ style: visualStyle,
316
+ box: {
317
+ x: 0,
318
+ y: 0,
319
+ width: 100,
320
+ height: 100
321
+ },
322
+ ...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
323
+ layoutOnlyWhenInvisible: true
324
+ });
325
+ const placeholderGeometry = resolvePlaceholderGeometry(placeholder, input.props);
326
+ const { x: rawX, y: rawY, width: rawWidth, height: rawHeight } = placeholderGeometry;
327
+ const native = {
328
+ ...morphKey === void 0 ? {} : { morphKey },
329
+ ...requestedName === void 0 ? {} : { hasExplicitName: true },
330
+ ...link === void 0 ? {} : { link }
331
+ };
332
+ return {
333
+ contract,
334
+ ...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
335
+ resolve(resolveContext) {
336
+ const box = {
337
+ x: resolveContext.layoutBox?.x ?? (typeof rawX === "number" ? rawX : 0),
338
+ y: resolveContext.layoutBox?.y ?? (typeof rawY === "number" ? rawY : 0),
339
+ width: resolveContext.layoutBox?.width ?? (typeof rawWidth === "number" ? rawWidth : 100),
340
+ height: resolveContext.layoutBox?.height ?? (typeof rawHeight === "number" ? rawHeight : 100)
341
+ };
342
+ const name = resolveContext.morphName ?? requestedName ?? placeholder.layoutPlaceholder?.name ?? `Placeholder ${resolveContext.id - 1}`;
343
+ try {
344
+ assertXml10Characters(name);
345
+ } catch {
346
+ throw new CapabilityError("invalid-xml-character", "Placeholder.name contains characters not allowed in XML 1.0", void 0, { field: "name" });
347
+ }
348
+ const hasBox = placeholderGeometry.hasLocalBoxOverride;
349
+ if (hasBox) assertVisualBoxExtent(box);
350
+ const visual = resolveVisualModel({
351
+ theme: placeholder.masterTheme,
352
+ style: visualStyle,
353
+ box,
354
+ ...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
355
+ layoutOnlyWhenInvisible: !hasBox
356
+ }, initialVisual.fill);
357
+ const spPrFlags = {
358
+ hasBox,
359
+ hasRotate: hasLocalDeclaration(rawSlideStyle, "rotate"),
360
+ hasFlipH: hasLocalDeclaration(rawSlideStyle, "flipH"),
361
+ hasFlipV: hasLocalDeclaration(rawSlideStyle, "flipV"),
362
+ hasGeometryOrRadius: hasLocalDeclaration(rawSlideStyle, "borderRadius"),
363
+ hasFill: hasLocalDeclaration(rawSlideStyle, "background"),
364
+ hasBorder: hasLocalDeclaration(rawSlideStyle, "border"),
365
+ hasEffects: hasLocalDeclaration(rawSlideStyle, "boxShadow") || hasLocalDeclaration(rawSlideStyle, "softEdge"),
366
+ includeDefaultRectWhenHasBox: true
367
+ };
368
+ const model = {
369
+ box,
370
+ name,
371
+ nativeRef: placeholder.nativeRef,
372
+ visual,
373
+ spPrFlags
374
+ };
375
+ return {
376
+ observation: {
377
+ id: resolveContext.id,
378
+ kind: "placeholder",
379
+ name,
380
+ box
381
+ },
382
+ extensions: [],
383
+ emit(emitContext) {
384
+ return contentPlaceholderMechanism.emit(model, emitContext);
385
+ },
386
+ paint() {
387
+ return contentPlaceholderMechanism.paint(model, void 0);
388
+ }
389
+ };
390
+ }
391
+ };
392
+ }
393
+ };
394
+ export { contentPlaceholderImportHandler, contentPlaceholderMechanism, createPlaceholderNode, placeholderCapability, placeholderObjectStyleSchema, readContentPlaceholderSp };
@@ -0,0 +1,6 @@
1
+ import "../../kernel/geometry-schemas.js";
2
+ import { blockArc, path, preset } from "../shared/geometry.js";
3
+ import { linearGradient, radialGradient } from "../shared/visual.js";
4
+ import "../shared/shape-declaration.js";
5
+ import { customGeometryShapeMechanism, presetShapeMechanism, shapeCapability, shapeStyleKeys } from "./shape.js";
6
+ export { blockArc, customGeometryShapeMechanism, linearGradient, path, preset, presetShapeMechanism, radialGradient, shapeCapability, shapeStyleKeys };
@@ -0,0 +1,112 @@
1
+ import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
2
+ import { serializeGeometryProp } from "../shared/geometry-codegen.js";
3
+ import { serializeImageDescriptorValue } from "../shared/image-codegen.js";
4
+ import { motionPropKeySet } from "../shared/motion-schemas.js";
5
+ import { steppableRichTextChildKinds } from "../shared/rich-text-codegen.js";
6
+ import { shapeAllowedPropKeyList, shapeStyleSchema } from "../shared/shape-declaration.js";
7
+ import "../../kernel/capability.js";
8
+ import { defineObjectCodegen, expr } from "../../kernel/codegen.js";
9
+ import { CommonNode } from "../../kernel/document.js";
10
+ // ../core/dist/capabilities/shape/shape-codegen.js
11
+ const objectMotionPropKeys = motionPropKeySet;
12
+ const shapeAllowedPropKeys = new Set(shapeAllowedPropKeyList);
13
+ const shapeAllowedChildKinds = /* @__PURE__ */ new Set([...steppableRichTextChildKinds, "br"]);
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ function isPlainRecord(value) {
18
+ if (!isRecord(value)) return false;
19
+ const proto = Object.getPrototypeOf(value);
20
+ return proto === Object.prototype || proto === null;
21
+ }
22
+ function singleTextLeaf(node) {
23
+ if (node.children.length !== 1) return void 0;
24
+ const only = node.children[0];
25
+ if (only === void 0 || only instanceof CommonNode) return void 0;
26
+ const leaf = only;
27
+ return leaf.type === "#text" ? leaf.text : void 0;
28
+ }
29
+ function assertAllowedShapeChildren(node, ctx) {
30
+ let childIndex = 0;
31
+ for (const child of node.children) {
32
+ if (!(child instanceof CommonNode)) continue;
33
+ const label = child.id === void 0 ? `${child.type}[${childIndex + 1}]` : `${child.type}[${child.id}]`;
34
+ if (!shapeAllowedChildKinds.has(child.type)) ctx.fail("invalid-document", `shape declaration cannot contain ${JSON.stringify(child.type)} child`, `${ctx.path}/${label}`);
35
+ childIndex += 1;
36
+ }
37
+ }
38
+ function serializeShapeStyleProp(style, ctx) {
39
+ if (!isPlainRecord(style)) ctx.fail("unexpressible-value", "Shape.style must be a plain object", "@style");
40
+ const parsed = shapeStyleSchema.safeParse(style);
41
+ if (!parsed.success) {
42
+ const issue = parsed.error.issues[0];
43
+ const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
44
+ ctx.fail("unexpressible-value", issue?.message ?? "Shape.style cannot be expressed", issuePath);
45
+ }
46
+ const entries = [];
47
+ for (const [key, entryValue] of Object.entries(style)) {
48
+ if (entryValue === void 0) continue;
49
+ if (key === "background") {
50
+ const serializedImage = serializeImageDescriptorValue(entryValue, ctx);
51
+ entries.push([key, serializedImage ?? entryValue]);
52
+ continue;
53
+ }
54
+ entries.push([key, entryValue]);
55
+ }
56
+ return expr(ctx.formatProps(entries));
57
+ }
58
+ function collectShapeProps(node, ctx) {
59
+ const props = readInternalDeclarationProps(node);
60
+ const extra = ctx.emitObjectExtraProps(props);
61
+ const entries = [];
62
+ for (const [key, value] of Object.entries(props)) {
63
+ if (value === void 0) continue;
64
+ if (!shapeAllowedPropKeys.has(key)) ctx.fail("invalid-document", `shape declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
65
+ if (objectMotionPropKeys.has(key)) {
66
+ if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
67
+ else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
68
+ continue;
69
+ }
70
+ if (key === "geometry") {
71
+ entries.push([key, serializeGeometryProp(value, ctx)]);
72
+ continue;
73
+ }
74
+ if (key === "style") {
75
+ entries.push([key, serializeShapeStyleProp(value, ctx)]);
76
+ continue;
77
+ }
78
+ entries.push([key, value]);
79
+ }
80
+ return entries;
81
+ }
82
+ function emitShapeVanilla(node, ctx) {
83
+ assertAllowedShapeChildren(node, ctx);
84
+ const callee = ctx.useImport("shape");
85
+ const propsEntries = collectShapeProps(node, ctx);
86
+ const leafText = singleTextLeaf(node);
87
+ if (leafText !== void 0) {
88
+ const args = propsEntries.length === 0 ? [JSON.stringify(leafText)] : [JSON.stringify(leafText), ctx.formatProps(propsEntries)];
89
+ return ctx.formatVanillaCall(callee, args);
90
+ }
91
+ if (node.children.length === 0) {
92
+ const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
93
+ return ctx.formatVanillaCall(callee, args);
94
+ }
95
+ const children = ctx.emitRichTextChildren(node.children);
96
+ const contentArg = ctx.emitValueExpr(children.map((code) => expr(code)));
97
+ const args = propsEntries.length === 0 ? [contentArg] : [contentArg, ctx.formatProps(propsEntries)];
98
+ return ctx.formatVanillaCall(callee, args);
99
+ }
100
+ function emitShapeReact(node, ctx) {
101
+ assertAllowedShapeChildren(node, ctx);
102
+ const tag = ctx.useImport("Shape");
103
+ const propsEntries = collectShapeProps(node, ctx);
104
+ const children = node.children.length === 0 ? [] : ctx.emitRichTextChildren(node.children);
105
+ return ctx.formatJsxElement(tag, propsEntries, children);
106
+ }
107
+ /** Source codegen contribution for `shape` declarations and DrawingML gradient values. */
108
+ const shapeCodegen = defineObjectCodegen({ declarations: { shape: {
109
+ emitVanilla: emitShapeVanilla,
110
+ emitReact: emitShapeReact
111
+ } } });
112
+ export { shapeCodegen };
@@ -0,0 +1,152 @@
1
+ import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
2
+ import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readNonVisualCommonProperties } from "../shared/identity.js";
3
+ import { isLineNormalizedSpElement } from "../shared/line-match.js";
4
+ import { isPlaceholderSpElement } from "../shared/placeholder-import.js";
5
+ import { populateRichTextNode, promoteSingleParagraph, readRichTextBody } from "../shared/rich-text-import.js";
6
+ import { createShapeNode } from "../shared/shape-declaration.js";
7
+ import { readSpPrVisuals } from "../shared/visual.js";
8
+ import "../../kernel/pptx-read/index.js";
9
+ // ../core/dist/capabilities/shape/shape-import.js
10
+ function directElementChild(parent, namespaceUri, localName) {
11
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
12
+ if (child.nodeType !== 1) continue;
13
+ const el = child;
14
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
15
+ }
16
+ }
17
+ function isTextBoxSpElement(cursor) {
18
+ const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
19
+ if (nvSpPr === void 0) return false;
20
+ const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
21
+ if (cNvSpPr === void 0) return false;
22
+ const txBox = cNvSpPr.getAttribute("txBox");
23
+ return txBox === "1" || txBox === "true";
24
+ }
25
+ function isCustomGeomSpElement(cursor) {
26
+ const spPr = directElementChild(cursor.element, P_NS, "spPr");
27
+ if (spPr === void 0) return false;
28
+ return directElementChild(spPr, A_NS, "custGeom") !== void 0;
29
+ }
30
+ /** Side-effect-free predicate matching non-textbox preset shapes (`<p:sp>` without `txBox="1"`, `<p:ph>`, `<a:custGeom>`, or normalized 1D lines). */
31
+ function isPresetShapeSpElement(cursor) {
32
+ return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && !isCustomGeomSpElement(cursor) && !isLineNormalizedSpElement(cursor);
33
+ }
34
+ /** Side-effect-free predicate matching non-textbox custom-geometry shapes (`<p:sp>` without `<p:ph>` and with `<a:custGeom>`). */
35
+ function isCustomGeometryShapeSpElement(cursor) {
36
+ return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && isCustomGeomSpElement(cursor);
37
+ }
38
+ /**
39
+ * Reads a Transitional `<p:sp>` native shape (preset or custom geometry, fills, borders, effects,
40
+ * transforms, hyperlink, and optional rich text body) into an editable `ShapeNode`.
41
+ */
42
+ function readShapeSp(context, mapBox) {
43
+ const { cursor, part, slideIndex, package: pkg } = context;
44
+ const diagnostics = [];
45
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
46
+ if (nvSpPr === void 0) {
47
+ diagnostics.push({
48
+ code: "corrupt-part",
49
+ category: "corrupt-input",
50
+ disposition: "omitted",
51
+ location: {
52
+ part,
53
+ xpath: cursor.xpath,
54
+ slideIndex
55
+ }
56
+ });
57
+ return { diagnostics };
58
+ }
59
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
60
+ const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
61
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
62
+ if (cNvSpPr !== void 0) cNvSpPr.consumeAttr("txBox");
63
+ consumeNonPlaceholderNvPr(nvSpPr);
64
+ const location = {
65
+ part,
66
+ slideIndex,
67
+ ...objectId === void 0 ? {} : { objectId },
68
+ ...objectName === void 0 ? {} : { objectName }
69
+ };
70
+ const spPr = cursor.child(P_NS, "spPr");
71
+ if (spPr === void 0) {
72
+ diagnostics.push({
73
+ code: "corrupt-part",
74
+ category: "corrupt-input",
75
+ disposition: "omitted",
76
+ location: {
77
+ ...location,
78
+ xpath: cursor.xpath
79
+ }
80
+ });
81
+ return { diagnostics };
82
+ }
83
+ const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
84
+ if (visuals === void 0) return { diagnostics };
85
+ const mappedBox = mapBox ? mapBox({
86
+ x: visuals.transform.x,
87
+ y: visuals.transform.y,
88
+ width: visuals.transform.width,
89
+ height: visuals.transform.height
90
+ }) : {
91
+ x: visuals.transform.x,
92
+ y: visuals.transform.y,
93
+ width: visuals.transform.width,
94
+ height: visuals.transform.height
95
+ };
96
+ const txBody = cursor.child(P_NS, "txBody");
97
+ const importedText = txBody === void 0 ? void 0 : readRichTextBody(txBody, location, diagnostics, "shape");
98
+ const paragraphs = importedText?.importedParagraphs ?? [];
99
+ const promoted = promoteSingleParagraph(paragraphs);
100
+ const hasTextBody = promoted === void 0 ? paragraphs.length > 0 : promoted.text === void 0 ? paragraphs[0]?.hasTextDefaults === true : promoted.text !== "";
101
+ const { border: rawBorder, ...restVisualStyle } = visuals.style;
102
+ if (visuals.borderArrows !== void 0) diagnostics.push({
103
+ code: "unsupported-mechanism",
104
+ category: "unsupported",
105
+ disposition: "omitted",
106
+ location,
107
+ namespaceUri: A_NS,
108
+ localName: visuals.borderArrows.startArrow !== void 0 ? "headEnd" : "tailEnd",
109
+ mechanismHint: "shape-line-arrow"
110
+ });
111
+ const effectiveVisualStyle = rawBorder === "none" ? restVisualStyle : visuals.style;
112
+ const shapeStyle = {
113
+ position: "absolute",
114
+ left: mappedBox.x,
115
+ top: mappedBox.y,
116
+ width: mappedBox.width,
117
+ height: mappedBox.height,
118
+ ...effectiveVisualStyle,
119
+ ...hasTextBody ? importedText?.boxStyle : {},
120
+ ...hasTextBody ? promoted?.style : {}
121
+ };
122
+ const props = {
123
+ ...objectName === void 0 ? {} : { name: objectName },
124
+ ...link === void 0 ? {} : { link },
125
+ ...visuals.geometry === void 0 ? {} : { geometry: visuals.geometry },
126
+ style: shapeStyle
127
+ };
128
+ const node = createShapeNode(props);
129
+ if (hasTextBody) {
130
+ if (promoted === void 0) populateRichTextNode(node, paragraphs);
131
+ else node.content(promoted.text ?? "");
132
+ }
133
+ attachDeferredSlideLink(node, deferredSlideLink, context);
134
+ return {
135
+ node,
136
+ diagnostics
137
+ };
138
+ }
139
+ const presetShapeImportHandler = {
140
+ target: "shape-tree",
141
+ localName: "sp",
142
+ matches: isPresetShapeSpElement,
143
+ read: (context) => readShapeSp(context, context.mapBox),
144
+ groupMember: (cursor) => !(isTextBoxSpElement(cursor) && !isPlaceholderSpElement(cursor)) && !isLineNormalizedSpElement(cursor)
145
+ };
146
+ const customGeometryShapeImportHandler = {
147
+ target: "shape-tree",
148
+ localName: "sp",
149
+ matches: isCustomGeometryShapeSpElement,
150
+ read: (context) => readShapeSp(context, context.mapBox)
151
+ };
152
+ export { customGeometryShapeImportHandler, isCustomGeometryShapeSpElement, isPresetShapeSpElement, presetShapeImportHandler, readShapeSp };
@@ -1,4 +1,4 @@
1
- // ../capabilities/dist/shape/shape-xml.js
1
+ // ../core/dist/capabilities/shape/shape-xml.js
2
2
  /** Internal PresentationML wrapper for native shape objects. */
3
3
  function shapeXml(id, escapedName, properties, textBody, linkXml) {
4
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>`;