@deckflow/deckuse 1.2.1 → 1.3.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 (282) hide show
  1. package/README.es.md +342 -0
  2. package/README.fr.md +342 -0
  3. package/README.ja.md +342 -0
  4. package/README.ko.md +342 -0
  5. package/README.md +60 -8
  6. package/README.pt-BR.md +342 -0
  7. package/README.ru.md +342 -0
  8. package/README.zh-CN.md +367 -0
  9. package/assets/default.docx +0 -0
  10. package/assets/default.pptx +0 -0
  11. package/dist/bin.js +188 -21
  12. package/dist/bin.js.map +1 -1
  13. package/dist/core/adapter.d.ts +24 -0
  14. package/dist/core/adapter.d.ts.map +1 -0
  15. package/dist/core/adapter.js +20 -0
  16. package/dist/core/adapter.js.map +1 -0
  17. package/dist/core/executor.d.ts +24 -0
  18. package/dist/core/executor.d.ts.map +1 -0
  19. package/dist/core/executor.js +65 -0
  20. package/dist/core/executor.js.map +1 -0
  21. package/dist/core/index.d.ts +7 -0
  22. package/dist/core/index.d.ts.map +1 -0
  23. package/dist/core/index.js +7 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/core/length.d.ts +27 -0
  26. package/dist/core/length.d.ts.map +1 -0
  27. package/dist/core/length.js +63 -0
  28. package/dist/core/length.js.map +1 -0
  29. package/dist/core/measure.d.ts +24 -0
  30. package/dist/core/measure.d.ts.map +1 -0
  31. package/dist/core/measure.js +79 -0
  32. package/dist/core/measure.js.map +1 -0
  33. package/dist/core/not-implemented.d.ts +3 -0
  34. package/dist/core/not-implemented.d.ts.map +1 -0
  35. package/dist/core/not-implemented.js +12 -0
  36. package/dist/core/not-implemented.js.map +1 -0
  37. package/dist/core/schema.d.ts +3065 -0
  38. package/dist/core/schema.d.ts.map +1 -0
  39. package/dist/core/schema.js +799 -0
  40. package/dist/core/schema.js.map +1 -0
  41. package/dist/default-template.d.ts +8 -0
  42. package/dist/default-template.d.ts.map +1 -0
  43. package/dist/default-template.js +29 -0
  44. package/dist/default-template.js.map +1 -0
  45. package/dist/docx/adapter.d.ts +29 -0
  46. package/dist/docx/adapter.d.ts.map +1 -0
  47. package/dist/docx/adapter.js +442 -0
  48. package/dist/docx/adapter.js.map +1 -0
  49. package/dist/docx/addressing.d.ts +18 -0
  50. package/dist/docx/addressing.d.ts.map +1 -0
  51. package/dist/docx/addressing.js +111 -0
  52. package/dist/docx/addressing.js.map +1 -0
  53. package/dist/docx/blank.d.ts +4 -0
  54. package/dist/docx/blank.d.ts.map +1 -0
  55. package/dist/docx/blank.js +75 -0
  56. package/dist/docx/blank.js.map +1 -0
  57. package/dist/docx/index-sync.d.ts +7 -0
  58. package/dist/docx/index-sync.d.ts.map +1 -0
  59. package/dist/docx/index-sync.js +24 -0
  60. package/dist/docx/index-sync.js.map +1 -0
  61. package/dist/docx/index.d.ts +5 -0
  62. package/dist/docx/index.d.ts.map +1 -0
  63. package/dist/docx/index.js +4 -0
  64. package/dist/docx/index.js.map +1 -0
  65. package/dist/docx/indexer.d.ts +41 -0
  66. package/dist/docx/indexer.d.ts.map +1 -0
  67. package/dist/docx/indexer.js +353 -0
  68. package/dist/docx/indexer.js.map +1 -0
  69. package/dist/docx/mutations.d.ts +5 -0
  70. package/dist/docx/mutations.d.ts.map +1 -0
  71. package/dist/docx/mutations.js +311 -0
  72. package/dist/docx/mutations.js.map +1 -0
  73. package/dist/docx/paragraphs.d.ts +26 -0
  74. package/dist/docx/paragraphs.d.ts.map +1 -0
  75. package/dist/docx/paragraphs.js +314 -0
  76. package/dist/docx/paragraphs.js.map +1 -0
  77. package/dist/docx/properties.d.ts +23 -0
  78. package/dist/docx/properties.d.ts.map +1 -0
  79. package/dist/docx/properties.js +414 -0
  80. package/dist/docx/properties.js.map +1 -0
  81. package/dist/docx/tables.d.ts +4 -0
  82. package/dist/docx/tables.d.ts.map +1 -0
  83. package/dist/docx/tables.js +64 -0
  84. package/dist/docx/tables.js.map +1 -0
  85. package/dist/docx/text-spans.d.ts +25 -0
  86. package/dist/docx/text-spans.d.ts.map +1 -0
  87. package/dist/docx/text-spans.js +142 -0
  88. package/dist/docx/text-spans.js.map +1 -0
  89. package/dist/docx/types.d.ts +27 -0
  90. package/dist/docx/types.d.ts.map +1 -0
  91. package/dist/docx/types.js +2 -0
  92. package/dist/docx/types.js.map +1 -0
  93. package/dist/docx/workspace.d.ts +20 -0
  94. package/dist/docx/workspace.d.ts.map +1 -0
  95. package/dist/docx/workspace.js +145 -0
  96. package/dist/docx/workspace.js.map +1 -0
  97. package/dist/docx/xml.d.ts +18 -0
  98. package/dist/docx/xml.d.ts.map +1 -0
  99. package/dist/docx/xml.js +87 -0
  100. package/dist/docx/xml.js.map +1 -0
  101. package/dist/edition-config/index.d.ts +25 -0
  102. package/dist/edition-config/index.d.ts.map +1 -0
  103. package/dist/edition-config/index.js +22 -0
  104. package/dist/edition-config/index.js.map +1 -0
  105. package/dist/edition.d.ts +2 -2
  106. package/dist/edition.d.ts.map +1 -1
  107. package/dist/edition.js +1 -1
  108. package/dist/edition.js.map +1 -1
  109. package/dist/help.d.ts.map +1 -1
  110. package/dist/help.js +124 -32
  111. package/dist/help.js.map +1 -1
  112. package/dist/index.d.ts +1 -1
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +6 -6
  115. package/dist/index.js.map +1 -1
  116. package/dist/key/index.d.ts +2 -0
  117. package/dist/key/index.d.ts.map +1 -0
  118. package/dist/key/index.js +3 -0
  119. package/dist/key/index.js.map +1 -0
  120. package/dist/monitor-daemon.d.ts +21 -8
  121. package/dist/monitor-daemon.d.ts.map +1 -1
  122. package/dist/monitor-daemon.js +189 -51
  123. package/dist/monitor-daemon.js.map +1 -1
  124. package/dist/monitor-registry.d.ts +34 -0
  125. package/dist/monitor-registry.d.ts.map +1 -0
  126. package/dist/monitor-registry.js +191 -0
  127. package/dist/monitor-registry.js.map +1 -0
  128. package/dist/monitor.d.ts.map +1 -1
  129. package/dist/monitor.js +2 -12
  130. package/dist/monitor.js.map +1 -1
  131. package/dist/numbers/index.d.ts +2 -0
  132. package/dist/numbers/index.d.ts.map +1 -0
  133. package/dist/numbers/index.js +3 -0
  134. package/dist/numbers/index.js.map +1 -0
  135. package/dist/opc/index.d.ts +96 -0
  136. package/dist/opc/index.d.ts.map +1 -0
  137. package/dist/opc/index.js +596 -0
  138. package/dist/opc/index.js.map +1 -0
  139. package/dist/pptx/adapter.d.ts +167 -0
  140. package/dist/pptx/adapter.d.ts.map +1 -0
  141. package/dist/pptx/adapter.js +841 -0
  142. package/dist/pptx/adapter.js.map +1 -0
  143. package/dist/pptx/addressing.d.ts +47 -0
  144. package/dist/pptx/addressing.d.ts.map +1 -0
  145. package/dist/pptx/addressing.js +481 -0
  146. package/dist/pptx/addressing.js.map +1 -0
  147. package/dist/pptx/align.d.ts +24 -0
  148. package/dist/pptx/align.d.ts.map +1 -0
  149. package/dist/pptx/align.js +112 -0
  150. package/dist/pptx/align.js.map +1 -0
  151. package/dist/pptx/chart-classify.d.ts +10 -0
  152. package/dist/pptx/chart-classify.d.ts.map +1 -0
  153. package/dist/pptx/chart-classify.js +58 -0
  154. package/dist/pptx/chart-classify.js.map +1 -0
  155. package/dist/pptx/chart.d.ts +42 -0
  156. package/dist/pptx/chart.d.ts.map +1 -0
  157. package/dist/pptx/chart.js +614 -0
  158. package/dist/pptx/chart.js.map +1 -0
  159. package/dist/pptx/edition-extension.d.ts +25 -0
  160. package/dist/pptx/edition-extension.d.ts.map +1 -0
  161. package/dist/pptx/edition-extension.js +10 -0
  162. package/dist/pptx/edition-extension.js.map +1 -0
  163. package/dist/pptx/edition.d.ts +20 -0
  164. package/dist/pptx/edition.d.ts.map +1 -0
  165. package/dist/pptx/edition.js +69 -0
  166. package/dist/pptx/edition.js.map +1 -0
  167. package/dist/pptx/elements.d.ts +12 -0
  168. package/dist/pptx/elements.d.ts.map +1 -0
  169. package/dist/pptx/elements.js +224 -0
  170. package/dist/pptx/elements.js.map +1 -0
  171. package/dist/pptx/hyperlink.d.ts +7 -0
  172. package/dist/pptx/hyperlink.d.ts.map +1 -0
  173. package/dist/pptx/hyperlink.js +81 -0
  174. package/dist/pptx/hyperlink.js.map +1 -0
  175. package/dist/pptx/index-sync.d.ts +7 -0
  176. package/dist/pptx/index-sync.d.ts.map +1 -0
  177. package/dist/pptx/index-sync.js +24 -0
  178. package/dist/pptx/index-sync.js.map +1 -0
  179. package/dist/pptx/index.d.ts +10 -0
  180. package/dist/pptx/index.d.ts.map +1 -0
  181. package/dist/pptx/index.js +7 -0
  182. package/dist/pptx/index.js.map +1 -0
  183. package/dist/pptx/indexer.d.ts +19 -0
  184. package/dist/pptx/indexer.d.ts.map +1 -0
  185. package/dist/pptx/indexer.js +320 -0
  186. package/dist/pptx/indexer.js.map +1 -0
  187. package/dist/pptx/layout-ref.d.ts +41 -0
  188. package/dist/pptx/layout-ref.d.ts.map +1 -0
  189. package/dist/pptx/layout-ref.js +145 -0
  190. package/dist/pptx/layout-ref.js.map +1 -0
  191. package/dist/pptx/media.d.ts +15 -0
  192. package/dist/pptx/media.d.ts.map +1 -0
  193. package/dist/pptx/media.js +145 -0
  194. package/dist/pptx/media.js.map +1 -0
  195. package/dist/pptx/mutations.d.ts +11 -0
  196. package/dist/pptx/mutations.d.ts.map +1 -0
  197. package/dist/pptx/mutations.js +1114 -0
  198. package/dist/pptx/mutations.js.map +1 -0
  199. package/dist/pptx/picture.d.ts +25 -0
  200. package/dist/pptx/picture.d.ts.map +1 -0
  201. package/dist/pptx/picture.js +118 -0
  202. package/dist/pptx/picture.js.map +1 -0
  203. package/dist/pptx/placeholder-role.d.ts +19 -0
  204. package/dist/pptx/placeholder-role.d.ts.map +1 -0
  205. package/dist/pptx/placeholder-role.js +71 -0
  206. package/dist/pptx/placeholder-role.js.map +1 -0
  207. package/dist/pptx/properties.d.ts +13 -0
  208. package/dist/pptx/properties.d.ts.map +1 -0
  209. package/dist/pptx/properties.js +587 -0
  210. package/dist/pptx/properties.js.map +1 -0
  211. package/dist/pptx/resolve-properties.d.ts +17 -0
  212. package/dist/pptx/resolve-properties.d.ts.map +1 -0
  213. package/dist/pptx/resolve-properties.js +623 -0
  214. package/dist/pptx/resolve-properties.js.map +1 -0
  215. package/dist/pptx/slide-size.d.ts +9 -0
  216. package/dist/pptx/slide-size.d.ts.map +1 -0
  217. package/dist/pptx/slide-size.js +29 -0
  218. package/dist/pptx/slide-size.js.map +1 -0
  219. package/dist/pptx/slides.d.ts +15 -0
  220. package/dist/pptx/slides.d.ts.map +1 -0
  221. package/dist/pptx/slides.js +247 -0
  222. package/dist/pptx/slides.js.map +1 -0
  223. package/dist/pptx/table-measure.d.ts +43 -0
  224. package/dist/pptx/table-measure.d.ts.map +1 -0
  225. package/dist/pptx/table-measure.js +70 -0
  226. package/dist/pptx/table-measure.js.map +1 -0
  227. package/dist/pptx/table.d.ts +26 -0
  228. package/dist/pptx/table.d.ts.map +1 -0
  229. package/dist/pptx/table.js +638 -0
  230. package/dist/pptx/table.js.map +1 -0
  231. package/dist/pptx/types.d.ts +27 -0
  232. package/dist/pptx/types.d.ts.map +1 -0
  233. package/dist/pptx/types.js +2 -0
  234. package/dist/pptx/types.js.map +1 -0
  235. package/dist/pptx/workspace.d.ts +23 -0
  236. package/dist/pptx/workspace.d.ts.map +1 -0
  237. package/dist/pptx/workspace.js +148 -0
  238. package/dist/pptx/workspace.js.map +1 -0
  239. package/dist/pptx/xml.d.ts +75 -0
  240. package/dist/pptx/xml.d.ts.map +1 -0
  241. package/dist/pptx/xml.js +390 -0
  242. package/dist/pptx/xml.js.map +1 -0
  243. package/dist/render.d.ts.map +1 -1
  244. package/dist/render.js +14 -2
  245. package/dist/render.js.map +1 -1
  246. package/dist/version.d.ts +1 -1
  247. package/dist/version.js +1 -1
  248. package/dist/workspace/git.d.ts +7 -0
  249. package/dist/workspace/git.d.ts.map +1 -0
  250. package/dist/workspace/git.js +119 -0
  251. package/dist/workspace/git.js.map +1 -0
  252. package/dist/workspace/index.d.ts +7 -0
  253. package/dist/workspace/index.d.ts.map +1 -0
  254. package/dist/workspace/index.js +7 -0
  255. package/dist/workspace/index.js.map +1 -0
  256. package/dist/workspace/lock.d.ts +5 -0
  257. package/dist/workspace/lock.d.ts.map +1 -0
  258. package/dist/workspace/lock.js +104 -0
  259. package/dist/workspace/lock.js.map +1 -0
  260. package/dist/workspace/metadata.d.ts +4 -0
  261. package/dist/workspace/metadata.d.ts.map +1 -0
  262. package/dist/workspace/metadata.js +21 -0
  263. package/dist/workspace/metadata.js.map +1 -0
  264. package/dist/workspace/operations.d.ts +14 -0
  265. package/dist/workspace/operations.d.ts.map +1 -0
  266. package/dist/workspace/operations.js +35 -0
  267. package/dist/workspace/operations.js.map +1 -0
  268. package/dist/workspace/paths.d.ts +11 -0
  269. package/dist/workspace/paths.d.ts.map +1 -0
  270. package/dist/workspace/paths.js +12 -0
  271. package/dist/workspace/paths.js.map +1 -0
  272. package/dist/workspace/revision.d.ts +6 -0
  273. package/dist/workspace/revision.d.ts.map +1 -0
  274. package/dist/workspace/revision.js +15 -0
  275. package/dist/workspace/revision.js.map +1 -0
  276. package/dist/xlsx/index.d.ts +2 -0
  277. package/dist/xlsx/index.d.ts.map +1 -0
  278. package/dist/xlsx/index.js +3 -0
  279. package/dist/xlsx/index.js.map +1 -0
  280. package/package.json +51 -27
  281. package/schema/command.schema.json +2405 -0
  282. package/dist/.tsbuildinfo +0 -1
@@ -0,0 +1,623 @@
1
+ import { cNvPrIdOf } from './addressing.js';
2
+ import { NS, REL, attr, children, cNvPr, descendants, first, notesBodyShape, notesBodyText, root, textOf, } from './xml.js';
3
+ const EMU_PER_PT = 12700;
4
+ const SHAPE_LOCAL_NAMES = new Set(['sp', 'pic', 'graphicFrame', 'cxnSp', 'grpSp']);
5
+ const directChild = (node, localName) => children(node).find((child) => child.localName === localName);
6
+ const shapeByCNvPrId = (doc, id) => descendants(doc).find((node) => node.localName != null &&
7
+ SHAPE_LOCAL_NAMES.has(node.localName) &&
8
+ attr(cNvPr(node), 'id') === id);
9
+ const nodeForItem = (doc, item) => {
10
+ if (item.kind === 'notes')
11
+ return notesBodyShape(doc) ?? undefined;
12
+ if (['slide', 'master', 'layout', 'theme'].includes(item.kind))
13
+ return root(doc);
14
+ const id = cNvPrIdOf(item);
15
+ return id ? shapeByCNvPrId(doc, id) : undefined;
16
+ };
17
+ const prop = (effective, direct, source, unit) => {
18
+ const inherited = direct === null || direct === undefined;
19
+ return {
20
+ effective: effective ?? null,
21
+ direct: direct ?? null,
22
+ inherited,
23
+ ...(source ? { source } : inherited ? { source: { scope: 'default' } } : {}),
24
+ ...(unit ? { unit } : {}),
25
+ };
26
+ };
27
+ const readSrgb = (node) => {
28
+ if (!node)
29
+ return undefined;
30
+ const srgb = first(node, 'srgbClr');
31
+ const val = attr(srgb, 'val');
32
+ if (val)
33
+ return `#${val.toUpperCase()}`;
34
+ return undefined;
35
+ };
36
+ const readSchemeColor = (node, themeColors) => {
37
+ if (!node)
38
+ return undefined;
39
+ const scheme = first(node, 'schemeClr');
40
+ const name = attr(scheme, 'val');
41
+ if (!name)
42
+ return undefined;
43
+ const mapped = themeColors.get(name) ?? themeColors.get(name.toLowerCase());
44
+ return mapped ? `#${mapped.replace(/^#/, '').toUpperCase()}` : undefined;
45
+ };
46
+ const readFillColor = (container, themeColors) => {
47
+ if (!container)
48
+ return undefined;
49
+ if (directChild(container, 'noFill'))
50
+ return { kind: 'none', color: null, transparency: null };
51
+ const solid = directChild(container, 'solidFill');
52
+ if (solid) {
53
+ const color = readSrgb(solid) ?? readSchemeColor(solid, themeColors) ?? null;
54
+ const alpha = attr(first(solid, 'alpha') ?? first(solid, 'srgbClr'), 'val');
55
+ // alpha on srgbClr child
56
+ const alphaNode = descendants(solid, 'alpha')[0];
57
+ const alphaVal = attr(alphaNode, 'val');
58
+ let transparency = null;
59
+ if (alphaVal !== undefined) {
60
+ const n = Number(alphaVal);
61
+ if (Number.isFinite(n))
62
+ transparency = Math.round((1 - n / 100000) * 100);
63
+ }
64
+ void alpha;
65
+ return { kind: 'solid', color, transparency };
66
+ }
67
+ return undefined;
68
+ };
69
+ const loadThemeColors = (archive, themePart) => {
70
+ const map = new Map();
71
+ if (!themePart || !archive.getPart(themePart))
72
+ return map;
73
+ const doc = archive.readXml(themePart);
74
+ const scheme = first(doc, 'clrScheme');
75
+ if (!scheme)
76
+ return map;
77
+ for (const child of children(scheme)) {
78
+ const name = child.localName;
79
+ if (!name)
80
+ continue;
81
+ const srgb = attr(first(child, 'srgbClr'), 'val');
82
+ const sys = attr(first(child, 'sysClr'), 'lastClr');
83
+ const val = srgb ?? sys;
84
+ if (val) {
85
+ map.set(name, val.toUpperCase());
86
+ map.set(name.toLowerCase(), val.toUpperCase());
87
+ }
88
+ }
89
+ return map;
90
+ };
91
+ const loadThemeFonts = (archive, themePart) => {
92
+ if (!themePart || !archive.getPart(themePart))
93
+ return {};
94
+ const doc = archive.readXml(themePart);
95
+ const major = attr(first(first(doc, 'majorFont') ?? doc, 'latin'), 'typeface');
96
+ const minor = attr(first(first(doc, 'minorFont') ?? doc, 'latin'), 'typeface');
97
+ return { ...(major ? { major } : {}), ...(minor ? { minor } : {}) };
98
+ };
99
+ const resolveStyleChain = (archive, slidePart) => {
100
+ const slideRels = archive.getRelationships(slidePart);
101
+ const layoutRel = slideRels.find((r) => r.type === REL.layout);
102
+ const layoutPart = layoutRel?.resolvedTarget;
103
+ let masterPart;
104
+ let themePart;
105
+ if (layoutPart) {
106
+ const layoutRels = archive.getRelationships(layoutPart);
107
+ const masterRel = layoutRels.find((r) => r.type === REL.slideMaster);
108
+ masterPart = masterRel?.resolvedTarget;
109
+ }
110
+ if (masterPart) {
111
+ const masterRels = archive.getRelationships(masterPart);
112
+ const themeRel = masterRels.find((r) => r.type === REL.theme);
113
+ themePart = themeRel?.resolvedTarget;
114
+ }
115
+ if (!themePart) {
116
+ const theme = [...archive.parts.keys()].find((name) => name.startsWith('/ppt/theme/') && name.endsWith('.xml'));
117
+ themePart = theme;
118
+ }
119
+ return {
120
+ ...(layoutPart
121
+ ? {
122
+ layoutPart,
123
+ layoutTarget: `layout:${layoutPart
124
+ .split('/')
125
+ .pop()
126
+ ?.replace(/\.xml$/, '') ?? layoutPart}`,
127
+ }
128
+ : {}),
129
+ ...(masterPart
130
+ ? {
131
+ masterPart,
132
+ masterTarget: `master:${masterPart
133
+ .split('/')
134
+ .pop()
135
+ ?.replace(/\.xml$/, '') ?? masterPart}`,
136
+ }
137
+ : {}),
138
+ ...(themePart ? { themePart } : {}),
139
+ };
140
+ };
141
+ const placeholderOf = (node) => {
142
+ const ph = first(node, 'ph');
143
+ if (!ph)
144
+ return undefined;
145
+ const type = attr(ph, 'type') ?? 'body';
146
+ const idx = attr(ph, 'idx');
147
+ return { type, ...(idx !== undefined ? { idx } : {}) };
148
+ };
149
+ const findPlaceholderShape = (doc, type, idx) => {
150
+ for (const node of descendants(doc)) {
151
+ if (!node.localName || !SHAPE_LOCAL_NAMES.has(node.localName))
152
+ continue;
153
+ const ph = placeholderOf(node);
154
+ if (!ph)
155
+ continue;
156
+ if (idx !== undefined && ph.idx === idx)
157
+ return node;
158
+ if (type && ph.type === type && (idx === undefined || ph.idx === undefined))
159
+ return node;
160
+ }
161
+ return undefined;
162
+ };
163
+ const txStyleLevel = (masterDoc, styleKind, level) => {
164
+ const styles = first(masterDoc, 'txStyles');
165
+ if (!styles)
166
+ return undefined;
167
+ const blockName = styleKind === 'title' ? 'titleStyle' : styleKind === 'body' ? 'bodyStyle' : 'otherStyle';
168
+ const block = directChild(styles, blockName) ?? first(styles, blockName);
169
+ if (!block)
170
+ return undefined;
171
+ if (level === 0)
172
+ return (directChild(block, 'defPPr') ??
173
+ first(block, 'defPPr') ??
174
+ directChild(block, 'lvl1pPr') ??
175
+ first(block, 'lvl1pPr'));
176
+ const name = `lvl${level + 1}pPr`;
177
+ return directChild(block, name) ?? first(block, name);
178
+ };
179
+ const styleKindForPlaceholder = (type) => {
180
+ if (!type)
181
+ return 'body';
182
+ if (type === 'title' || type === 'ctrTitle')
183
+ return 'title';
184
+ if (type === 'body' || type === 'obj' || type === 'subTitle')
185
+ return 'body';
186
+ return 'other';
187
+ };
188
+ const readFontFromRPr = (rPr, themeFonts, themeColors) => {
189
+ if (!rPr)
190
+ return {};
191
+ const sz = attr(rPr, 'sz');
192
+ const size = sz !== undefined ? Number(sz) / 100 : undefined;
193
+ const latin = attr(directChild(rPr, 'latin'), 'typeface');
194
+ let family = latin;
195
+ if (family?.startsWith('+mj-'))
196
+ family = themeFonts.major;
197
+ if (family?.startsWith('+mn-'))
198
+ family = themeFonts.minor;
199
+ const bold = attr(rPr, 'b');
200
+ const italic = attr(rPr, 'i');
201
+ const underline = attr(rPr, 'u');
202
+ const solid = directChild(rPr, 'solidFill');
203
+ const color = solid ? (readSrgb(solid) ?? readSchemeColor(solid, themeColors)) : undefined;
204
+ return {
205
+ ...(family ? { family } : {}),
206
+ ...(size !== undefined && Number.isFinite(size) ? { size } : {}),
207
+ ...(bold === '1' || bold === 'true'
208
+ ? { weight: 'bold' }
209
+ : bold === '0'
210
+ ? { weight: 'regular' }
211
+ : {}),
212
+ ...(italic === '1' || italic === 'true'
213
+ ? { italic: true }
214
+ : italic === '0'
215
+ ? { italic: false }
216
+ : {}),
217
+ ...(underline && underline !== 'none' ? { underline: true } : {}),
218
+ ...(color ? { color } : {}),
219
+ };
220
+ };
221
+ const firstRunRPr = (node) => {
222
+ const run = descendants(node, 'r')[0];
223
+ return run ? directChild(run, 'rPr') : undefined;
224
+ };
225
+ const defRPrFromLevel = (level) => {
226
+ if (!level)
227
+ return undefined;
228
+ return directChild(level, 'defRPr') ?? first(level, 'defRPr');
229
+ };
230
+ const readTransform = (node) => {
231
+ const xfrm = first(node, 'xfrm');
232
+ const off = xfrm ? first(xfrm, 'off') : undefined;
233
+ const ext = xfrm ? first(xfrm, 'ext') : undefined;
234
+ const rot = attr(xfrm, 'rot');
235
+ return {
236
+ x: attr(off, 'x') !== undefined ? Number(attr(off, 'x')) : null,
237
+ y: attr(off, 'y') !== undefined ? Number(attr(off, 'y')) : null,
238
+ width: attr(ext, 'cx') !== undefined ? Number(attr(ext, 'cx')) : null,
239
+ height: attr(ext, 'cy') !== undefined ? Number(attr(ext, 'cy')) : null,
240
+ rotation: rot !== undefined ? Number(rot) / 60000 : null,
241
+ 'flip.x': attr(xfrm, 'flipH') === '1',
242
+ 'flip.y': attr(xfrm, 'flipV') === '1',
243
+ };
244
+ };
245
+ const filterProps = (all, props, mode, includeProvenance) => {
246
+ const keys = props?.length ? props : Object.keys(all);
247
+ const out = {};
248
+ for (const key of keys) {
249
+ const value = all[key];
250
+ if (!value)
251
+ continue;
252
+ if (mode === 'effective') {
253
+ out[key] = includeProvenance
254
+ ? {
255
+ effective: value.effective,
256
+ inherited: value.inherited,
257
+ ...(value.source ? { source: value.source } : {}),
258
+ ...(value.unit ? { unit: value.unit } : {}),
259
+ }
260
+ : value.effective;
261
+ }
262
+ else if (mode === 'direct') {
263
+ out[key] = includeProvenance
264
+ ? {
265
+ direct: value.direct,
266
+ inherited: value.inherited,
267
+ ...(value.unit ? { unit: value.unit } : {}),
268
+ }
269
+ : value.direct;
270
+ }
271
+ else {
272
+ out[key] = includeProvenance
273
+ ? value
274
+ : { effective: value.effective, direct: value.direct, inherited: value.inherited };
275
+ }
276
+ }
277
+ return out;
278
+ };
279
+ export function resolveProperties(archive, resolved, options = {}) {
280
+ const mode = options.resolve ?? 'both';
281
+ const includeProvenance = options.provenance !== false;
282
+ const warnings = [];
283
+ const item = resolved.item;
284
+ // Synthetic notes (no part yet): return empty text without reading an empty path.
285
+ if (item.kind === 'notes' && (!item.partUri || !archive.getPart(item.partUri))) {
286
+ const properties = {
287
+ 'text.value': prop(null, null, {
288
+ scope: 'default',
289
+ target: resolved.target,
290
+ path: 'text.value',
291
+ }),
292
+ };
293
+ return {
294
+ target: resolved.target,
295
+ uid: resolved.uid,
296
+ ...(item.name ? { name: item.name } : {}),
297
+ properties: filterProps(properties, options.props, mode, includeProvenance),
298
+ warnings,
299
+ };
300
+ }
301
+ const doc = archive.readXml(item.partUri);
302
+ const node = nodeForItem(doc, item);
303
+ if (!node) {
304
+ if (item.kind === 'notes') {
305
+ const properties = {
306
+ 'text.value': prop(null, null, {
307
+ scope: 'default',
308
+ target: resolved.target,
309
+ path: 'text.value',
310
+ }),
311
+ };
312
+ return {
313
+ target: resolved.target,
314
+ uid: resolved.uid,
315
+ ...(item.name ? { name: item.name } : {}),
316
+ properties: filterProps(properties, options.props, mode, includeProvenance),
317
+ warnings,
318
+ };
319
+ }
320
+ warnings.push('Element XML node was not found; returning empty properties');
321
+ return {
322
+ target: resolved.target,
323
+ uid: resolved.uid,
324
+ ...(item.name ? { name: item.name } : {}),
325
+ properties: {},
326
+ warnings,
327
+ };
328
+ }
329
+ if (item.kind === 'slide' ||
330
+ item.kind === 'master' ||
331
+ item.kind === 'layout' ||
332
+ item.kind === 'theme') {
333
+ const properties = {
334
+ name: prop(item.name ?? null, item.name ?? null, { scope: 'local', target: resolved.target }),
335
+ };
336
+ return {
337
+ target: resolved.target,
338
+ uid: resolved.uid,
339
+ ...(item.name ? { name: item.name } : {}),
340
+ properties: filterProps(properties, options.props, mode, includeProvenance),
341
+ warnings,
342
+ };
343
+ }
344
+ if (item.kind === 'notes') {
345
+ const text = notesBodyText(doc).replace(/\s+/g, ' ').trim();
346
+ const properties = {
347
+ 'text.value': prop(text || null, text || null, {
348
+ scope: 'local',
349
+ target: resolved.target,
350
+ path: 'text.value',
351
+ }),
352
+ };
353
+ return {
354
+ target: resolved.target,
355
+ uid: resolved.uid,
356
+ ...(item.name ? { name: item.name } : {}),
357
+ properties: filterProps(properties, options.props, mode, includeProvenance),
358
+ warnings,
359
+ };
360
+ }
361
+ const chain = resolveStyleChain(archive, item.partUri);
362
+ const themeColors = loadThemeColors(archive, chain.themePart);
363
+ const themeFonts = loadThemeFonts(archive, chain.themePart);
364
+ const all = {};
365
+ const name = attr(cNvPr(node), 'name') ?? null;
366
+ all['name'] = prop(name, name, { scope: 'local', target: resolved.target, path: 'name' });
367
+ const nvPr = first(node, 'nvPr');
368
+ const hidden = attr(nvPr, 'hidden') === '1';
369
+ all['visible'] = prop(!hidden, !hidden, {
370
+ scope: 'local',
371
+ target: resolved.target,
372
+ path: 'visible',
373
+ });
374
+ const xfrm = readTransform(node);
375
+ for (const [key, value] of Object.entries(xfrm)) {
376
+ const unit = ['x', 'y', 'width', 'height'].includes(key)
377
+ ? 'emu'
378
+ : key === 'rotation'
379
+ ? 'deg'
380
+ : undefined;
381
+ all[key] = prop(value, value, { scope: 'local', target: resolved.target, path: key }, unit);
382
+ }
383
+ const spPr = directChild(node, 'spPr') ?? first(node, 'spPr');
384
+ const directFill = readFillColor(spPr, themeColors);
385
+ all['fill.kind'] = prop(directFill?.kind ?? null, directFill?.kind ?? null, directFill
386
+ ? { scope: 'local', target: resolved.target, path: 'fill.kind' }
387
+ : { scope: 'default' });
388
+ all['fill.color'] = prop(directFill?.color ?? null, directFill?.color ?? null, directFill?.color
389
+ ? { scope: 'local', target: resolved.target, path: 'fill.color' }
390
+ : { scope: 'default' });
391
+ all['fill.transparency'] = prop(directFill?.transparency ?? null, directFill?.transparency ?? null, directFill?.transparency !== null && directFill?.transparency !== undefined
392
+ ? { scope: 'local', target: resolved.target, path: 'fill.transparency' }
393
+ : { scope: 'default' });
394
+ const ln = spPr ? directChild(spPr, 'ln') : undefined;
395
+ if (ln && directChild(ln, 'noFill')) {
396
+ all['line.kind'] = prop('none', 'none', {
397
+ scope: 'local',
398
+ target: resolved.target,
399
+ path: 'line.kind',
400
+ });
401
+ all['line.color'] = prop(null, null, {
402
+ scope: 'local',
403
+ target: resolved.target,
404
+ path: 'line.color',
405
+ });
406
+ all['line.width'] = prop(null, null, { scope: 'local', target: resolved.target, path: 'line.width' }, 'pt');
407
+ }
408
+ else if (ln) {
409
+ const lineFill = readFillColor(ln, themeColors);
410
+ const w = attr(ln, 'w');
411
+ all['line.kind'] = prop('solid', 'solid', {
412
+ scope: 'local',
413
+ target: resolved.target,
414
+ path: 'line.kind',
415
+ });
416
+ all['line.color'] = prop(lineFill?.color ?? null, lineFill?.color ?? null, {
417
+ scope: 'local',
418
+ target: resolved.target,
419
+ path: 'line.color',
420
+ });
421
+ all['line.width'] = prop(w !== undefined ? Number(w) / EMU_PER_PT : null, w !== undefined ? Number(w) / EMU_PER_PT : null, { scope: 'local', target: resolved.target, path: 'line.width' }, 'pt');
422
+ }
423
+ else {
424
+ all['line.kind'] = prop(null, null, { scope: 'default' });
425
+ all['line.color'] = prop(null, null, { scope: 'default' });
426
+ all['line.width'] = prop(null, null, { scope: 'default' }, 'pt');
427
+ }
428
+ const text = textOf(node).replace(/\s+/g, ' ').trim();
429
+ all['text.value'] = prop(text || null, text || null, {
430
+ scope: 'local',
431
+ target: resolved.target,
432
+ path: 'text.value',
433
+ });
434
+ const directRPr = firstRunRPr(node);
435
+ const directFont = readFontFromRPr(directRPr, themeFonts, themeColors);
436
+ const ph = placeholderOf(node);
437
+ let inheritedFont = {};
438
+ let inheritedSource;
439
+ if (!directFont.size || !directFont.family || !directFont.color) {
440
+ // Try layout placeholder shape defRPr / list style, then master txStyles.
441
+ if (ph && chain.layoutPart && archive.getPart(chain.layoutPart)) {
442
+ const layoutDoc = archive.readXml(chain.layoutPart);
443
+ const layoutShape = findPlaceholderShape(layoutDoc, ph.type, ph.idx);
444
+ if (layoutShape) {
445
+ const layoutRPr = firstRunRPr(layoutShape) ??
446
+ defRPrFromLevel(first(layoutShape, 'lstStyle')
447
+ ? first(first(layoutShape, 'lstStyle'), 'defPPr')
448
+ : undefined);
449
+ const fromLayout = readFontFromRPr(layoutRPr, themeFonts, themeColors);
450
+ inheritedFont = { ...fromLayout, ...inheritedFont };
451
+ if (fromLayout.size || fromLayout.family || fromLayout.color) {
452
+ inheritedSource = {
453
+ scope: 'layout',
454
+ target: chain.layoutTarget,
455
+ path: 'placeholder.font',
456
+ };
457
+ }
458
+ }
459
+ }
460
+ if (chain.masterPart && archive.getPart(chain.masterPart)) {
461
+ const masterDoc = archive.readXml(chain.masterPart);
462
+ const styleKind = styleKindForPlaceholder(ph?.type);
463
+ const level = txStyleLevel(masterDoc, styleKind, 0);
464
+ const fromMaster = readFontFromRPr(defRPrFromLevel(level), themeFonts, themeColors);
465
+ inheritedFont = { ...fromMaster, ...inheritedFont };
466
+ if (!inheritedSource && (fromMaster.size || fromMaster.family || fromMaster.color)) {
467
+ inheritedSource = {
468
+ scope: 'master',
469
+ target: chain.masterTarget,
470
+ path: `textStyles.${styleKind}.level.0.font`,
471
+ };
472
+ }
473
+ // Also match placeholder shape on master.
474
+ if (ph) {
475
+ const masterShape = findPlaceholderShape(masterDoc, ph.type, ph.idx);
476
+ if (masterShape) {
477
+ const masterRPr = firstRunRPr(masterShape);
478
+ const fromMasterShape = readFontFromRPr(masterRPr, themeFonts, themeColors);
479
+ inheritedFont = { ...fromMasterShape, ...inheritedFont };
480
+ }
481
+ }
482
+ }
483
+ if (!inheritedFont.family && themeFonts.minor) {
484
+ inheritedFont = { ...inheritedFont, family: themeFonts.minor };
485
+ if (!inheritedSource)
486
+ inheritedSource = { scope: 'theme', target: 'theme', path: 'fontScheme.minorFont' };
487
+ }
488
+ }
489
+ const mergeFont = (key, propName, unit) => {
490
+ const direct = directFont[key] ?? null;
491
+ const effective = (directFont[key] ?? inheritedFont[key] ?? null);
492
+ const source = direct !== null && direct !== undefined
493
+ ? { scope: 'local', target: resolved.target, path: propName }
494
+ : inheritedFont[key] !== undefined
495
+ ? (inheritedSource ?? { scope: 'default' })
496
+ : { scope: 'default' };
497
+ // Refine path for master font.size
498
+ const refined = source?.scope === 'master' && propName.startsWith('font.')
499
+ ? {
500
+ ...source,
501
+ path: `${source.path?.replace(/\.font$/, '') ?? 'textStyles.body.level.0'}.${propName}`,
502
+ }
503
+ : source;
504
+ all[propName] = prop(effective, direct, refined, unit);
505
+ };
506
+ mergeFont('family', 'font.family');
507
+ mergeFont('size', 'font.size', 'pt');
508
+ mergeFont('weight', 'font.weight');
509
+ mergeFont('italic', 'font.italic');
510
+ mergeFont('underline', 'font.underline');
511
+ mergeFont('color', 'font.color');
512
+ const pPr = first(descendants(node, 'p')[0] ?? node, 'pPr');
513
+ const align = attr(pPr, 'algn');
514
+ const lvl = attr(pPr, 'lvl');
515
+ all['paragraph.align'] = prop(align ?? null, align ?? null, align
516
+ ? { scope: 'local', target: resolved.target, path: 'paragraph.align' }
517
+ : { scope: 'default' });
518
+ all['paragraph.level'] = prop(lvl !== undefined ? Number(lvl) : 0, lvl !== undefined ? Number(lvl) : null, lvl !== undefined
519
+ ? { scope: 'local', target: resolved.target, path: 'paragraph.level' }
520
+ : { scope: 'default' });
521
+ const hlink = typeof item.payload?.['hyperlink'] === 'string' ? item.payload['hyperlink'] : null;
522
+ all['hyperlink'] = prop(hlink, hlink, hlink ? { scope: 'local', target: resolved.target, path: 'hyperlink' } : { scope: 'default' });
523
+ const phType = typeof item.payload?.['placeholder'] === 'string' ? item.payload['placeholder'] : null;
524
+ all['placeholder'] = prop(phType, phType, phType
525
+ ? { scope: 'local', target: resolved.target, path: 'placeholder' }
526
+ : { scope: 'default' });
527
+ return {
528
+ target: resolved.target,
529
+ uid: resolved.uid,
530
+ ...(name ? { name } : {}),
531
+ properties: filterProps(all, options.props, mode, includeProvenance),
532
+ warnings,
533
+ };
534
+ }
535
+ /** Map Phase-1 dotted property names to legacy setProperties keys. */
536
+ export const mapDottedProperties = (properties) => {
537
+ const out = {};
538
+ for (const [key, value] of Object.entries(properties)) {
539
+ switch (key) {
540
+ case 'font.family':
541
+ out['fontFamily'] = value;
542
+ break;
543
+ case 'font.size':
544
+ out['fontSize'] = value;
545
+ break;
546
+ case 'font.weight':
547
+ out['bold'] = value === 'bold' || value === true;
548
+ break;
549
+ case 'font.italic':
550
+ out['italic'] = value;
551
+ break;
552
+ case 'font.underline':
553
+ out['underline'] = value;
554
+ break;
555
+ case 'font.color':
556
+ out['textColor'] = typeof value === 'string' ? value.replace(/^#/, '') : value;
557
+ break;
558
+ case 'fill.color':
559
+ out['fill'] = typeof value === 'string' ? value.replace(/^#/, '') : value;
560
+ break;
561
+ case 'fill.kind':
562
+ if (value === 'none')
563
+ out['fill'] = 'none';
564
+ break;
565
+ case 'fill.transparency':
566
+ // Stored via fill object when combined; ignore alone for now.
567
+ break;
568
+ case 'line.color':
569
+ case 'line.kind':
570
+ case 'line.width':
571
+ case 'line.dash': {
572
+ const line = out['line'] ?? {};
573
+ if (key === 'line.color' && typeof value === 'string')
574
+ line['color'] = value.replace(/^#/, '');
575
+ else if (key === 'line.kind' && value === 'none')
576
+ out['line'] = 'none';
577
+ else if (key === 'line.width')
578
+ line['width'] = value;
579
+ else if (key === 'line.dash')
580
+ line['dash'] = value;
581
+ if (out['line'] !== 'none')
582
+ out['line'] = { ...line };
583
+ break;
584
+ }
585
+ case 'text.value':
586
+ out['text'] = value;
587
+ break;
588
+ case 'name':
589
+ out['name'] = value;
590
+ break;
591
+ case 'visible':
592
+ out['hidden'] = value === false;
593
+ break;
594
+ case 'paragraph.align':
595
+ out['paragraph.align'] = value;
596
+ break;
597
+ case 'paragraph.level':
598
+ out['paragraph.level'] = typeof value === 'string' ? Number(value) : value;
599
+ break;
600
+ case 'bullet':
601
+ out['bullet'] = value;
602
+ break;
603
+ case 'hyperlink':
604
+ out['hyperlink'] = value === '' ? null : value;
605
+ break;
606
+ default:
607
+ out[key] = value;
608
+ }
609
+ }
610
+ // Combine fill.color + transparency
611
+ if ('fill.color' in properties || 'fill.transparency' in properties) {
612
+ const color = properties['fill.color'];
613
+ const transparency = properties['fill.transparency'];
614
+ if (typeof color === 'string') {
615
+ out['fill'] =
616
+ transparency !== undefined
617
+ ? { type: 'solid', color: color.replace(/^#/, ''), transparency }
618
+ : color.replace(/^#/, '');
619
+ }
620
+ }
621
+ return out;
622
+ };
623
+ //# sourceMappingURL=resolve-properties.js.map