@web-ppt/edit-core 0.5.0-beta.2 → 0.5.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 (337) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +164 -21
  3. package/dist/alt-text.d.ts +5 -0
  4. package/dist/appearance/index.d.ts +12 -0
  5. package/dist/appearance/materialize.d.ts +4 -0
  6. package/dist/appearance/types.d.ts +26 -0
  7. package/dist/appearance/values.d.ts +9 -0
  8. package/dist/appearance.js +301 -0
  9. package/dist/cfb/index.d.ts +5 -0
  10. package/dist/cfb/read.d.ts +16 -0
  11. package/dist/cfb/write.d.ts +3 -0
  12. package/dist/cfb.js +208 -0
  13. package/dist/change-classification.d.ts +3 -3
  14. package/dist/chart/category-binding.d.ts +4 -0
  15. package/dist/chart/category-commands.d.ts +23 -0
  16. package/dist/chart/category-levels.d.ts +14 -0
  17. package/dist/chart/category-matrix.d.ts +2 -0
  18. package/dist/chart/category-value.d.ts +2 -0
  19. package/dist/chart/category-workbook.d.ts +13 -0
  20. package/dist/chart/commands.d.ts +28 -0
  21. package/dist/chart/context.d.ts +12 -0
  22. package/dist/chart/dataset-merge.d.ts +5 -0
  23. package/dist/chart/formula.d.ts +13 -0
  24. package/dist/chart/identity-frames.d.ts +4 -0
  25. package/dist/chart/identity-scopes.d.ts +6 -0
  26. package/dist/chart/identity.d.ts +24 -0
  27. package/dist/chart/index.d.ts +8 -0
  28. package/dist/chart/limits.d.ts +6 -0
  29. package/dist/chart/locator.d.ts +4 -0
  30. package/dist/chart/materialize.d.ts +7 -0
  31. package/dist/chart/ordering.d.ts +9 -0
  32. package/dist/chart/part-graph.d.ts +5 -0
  33. package/dist/chart/patch-validation.d.ts +3 -0
  34. package/dist/chart/plot-kinds.d.ts +2 -0
  35. package/dist/chart/projection.d.ts +8 -0
  36. package/dist/chart/save.d.ts +4 -0
  37. package/dist/chart/shared-added-plan.d.ts +19 -0
  38. package/dist/chart/shared-added-records.d.ts +8 -0
  39. package/dist/chart/shared-address.d.ts +5 -0
  40. package/dist/chart/shared-allocate.d.ts +7 -0
  41. package/dist/chart/shared-cache-codec.d.ts +5 -0
  42. package/dist/chart/shared-cache-identities.d.ts +3 -0
  43. package/dist/chart/shared-cache-migration.d.ts +7 -0
  44. package/dist/chart/shared-cache-save.d.ts +3 -0
  45. package/dist/chart/shared-cache-scopes.d.ts +13 -0
  46. package/dist/chart/shared-cache.d.ts +11 -0
  47. package/dist/chart/shared-category.d.ts +4 -0
  48. package/dist/chart/shared-cell.d.ts +9 -0
  49. package/dist/chart/shared-family.d.ts +26 -0
  50. package/dist/chart/shared-fields.d.ts +18 -0
  51. package/dist/chart/shared-graph.d.ts +19 -0
  52. package/dist/chart/shared-growth-space.d.ts +5 -0
  53. package/dist/chart/shared-inserted-cells.d.ts +14 -0
  54. package/dist/chart/shared-inserted-command.d.ts +7 -0
  55. package/dist/chart/shared-inserted-layout.d.ts +16 -0
  56. package/dist/chart/shared-inserted-project.d.ts +14 -0
  57. package/dist/chart/shared-inserted-records.d.ts +16 -0
  58. package/dist/chart/shared-inserted-save.d.ts +6 -0
  59. package/dist/chart/shared-joint-command.d.ts +9 -0
  60. package/dist/chart/shared-joint-records.d.ts +9 -0
  61. package/dist/chart/shared-record-axis.d.ts +25 -0
  62. package/dist/chart/shared-record-remove.d.ts +13 -0
  63. package/dist/chart/shared-record-stage.d.ts +2 -0
  64. package/dist/chart/shared-records.d.ts +2 -0
  65. package/dist/chart/shared-rows.d.ts +17 -0
  66. package/dist/chart/shared-runtime.d.ts +19 -0
  67. package/dist/chart/shared-save-plan.d.ts +4 -0
  68. package/dist/chart/shared-save.d.ts +3 -0
  69. package/dist/chart/shared-series.d.ts +6 -0
  70. package/dist/chart/shared-source-cache.d.ts +4 -0
  71. package/dist/chart/shared-topology.d.ts +9 -0
  72. package/dist/chart/shared-unresolved.d.ts +3 -0
  73. package/dist/chart/shared-validation.d.ts +6 -0
  74. package/dist/chart/shared-workbook-source.d.ts +6 -0
  75. package/dist/chart/shared-xy-command.d.ts +7 -0
  76. package/dist/chart/shared-xy-family.d.ts +16 -0
  77. package/dist/chart/shared-xy-project.d.ts +6 -0
  78. package/dist/chart/shared-xy-records.d.ts +23 -0
  79. package/dist/chart/shared-xy-save.d.ts +5 -0
  80. package/dist/chart/shared-xy-source.d.ts +39 -0
  81. package/dist/chart/shared.d.ts +13 -0
  82. package/dist/chart/source.d.ts +11 -0
  83. package/dist/chart/types.d.ts +86 -0
  84. package/dist/chart/validation.d.ts +24 -0
  85. package/dist/chart/workbook-range.d.ts +16 -0
  86. package/dist/chart/workbook-read.d.ts +7 -0
  87. package/dist/chart/workbook-write.d.ts +9 -0
  88. package/dist/chart/workbook.d.ts +25 -0
  89. package/dist/chart/xml-data.d.ts +14 -0
  90. package/dist/chart/xml-namespaces.d.ts +16 -0
  91. package/dist/chart-design/index.d.ts +10 -0
  92. package/dist/chart-design/types.d.ts +11 -0
  93. package/dist/chart-design/xml.d.ts +2 -0
  94. package/dist/chart-design.js +361 -0
  95. package/dist/chart-ex/index.d.ts +15 -0
  96. package/dist/chart-ex/workbook.d.ts +6 -0
  97. package/dist/chart-ex/xml.d.ts +14 -0
  98. package/dist/chart-ex.js +457 -0
  99. package/dist/chart-shared/index.d.ts +12 -0
  100. package/dist/chart-shared.js +1 -0
  101. package/dist/chart.js +1 -0
  102. package/dist/clipboard-links-GuPtqr1z.js +778 -0
  103. package/dist/clipboard-package.d.ts +4 -0
  104. package/dist/clipboard-source.d.ts +6 -2
  105. package/dist/clipboard-trees.d.ts +9 -0
  106. package/dist/commands/add-slide-identity.d.ts +2 -0
  107. package/dist/commands/bullet-image-resource.d.ts +11 -0
  108. package/dist/commands/clear-format.d.ts +4 -0
  109. package/dist/commands/common-object-slide-patch.d.ts +4 -0
  110. package/dist/commands/common-object-slide-types.d.ts +68 -0
  111. package/dist/commands/direct-format-patches.d.ts +11 -5
  112. package/dist/commands/distribute-elements.d.ts +4 -0
  113. package/dist/commands/edit-table-grid.d.ts +10 -0
  114. package/dist/commands/element-alt-text.d.ts +8 -0
  115. package/dist/commands/element-arrangement.d.ts +17 -0
  116. package/dist/commands/element-effects.d.ts +1 -1
  117. package/dist/commands/element-fill.d.ts +1 -1
  118. package/dist/commands/element-geometry.d.ts +5 -2
  119. package/dist/commands/element-image-content.d.ts +2 -2
  120. package/dist/commands/element-link.d.ts +1 -1
  121. package/dist/commands/element-name.d.ts +1 -1
  122. package/dist/commands/element-stroke.d.ts +1 -1
  123. package/dist/commands/element-text.d.ts +1 -1
  124. package/dist/commands/element-transform.d.ts +2 -2
  125. package/dist/commands/geometry-types.d.ts +23 -1
  126. package/dist/commands/hierarchy-record.d.ts +5 -0
  127. package/dist/commands/image-resource.d.ts +8 -1
  128. package/dist/commands/insertion-host.d.ts +14 -1
  129. package/dist/commands/layout-property.d.ts +7 -0
  130. package/dist/commands/master-property.d.ts +5 -0
  131. package/dist/commands/master-text-style-types.d.ts +27 -0
  132. package/dist/commands/master-text-style.d.ts +7 -0
  133. package/dist/commands/paste-resources.d.ts +9 -5
  134. package/dist/commands/patch-apply.d.ts +3 -0
  135. package/dist/commands/patch-count.d.ts +1 -0
  136. package/dist/commands/patch-invalidation.d.ts +1 -1
  137. package/dist/commands/patch-stage.d.ts +4 -0
  138. package/dist/commands/record-override.d.ts +5 -0
  139. package/dist/commands/replace-image.d.ts +6 -1
  140. package/dist/commands/sections.d.ts +10 -0
  141. package/dist/commands/set-preset.d.ts +5 -0
  142. package/dist/commands/slide-property-types.d.ts +55 -5
  143. package/dist/commands/slide-size.d.ts +7 -0
  144. package/dist/commands/spid.d.ts +1 -1
  145. package/dist/commands/table-grid-patch.d.ts +12 -0
  146. package/dist/commands/text-target.d.ts +2 -2
  147. package/dist/commands/theme-types.d.ts +47 -0
  148. package/dist/commands/theme.d.ts +9 -0
  149. package/dist/commands/types.d.ts +194 -17
  150. package/dist/commands/ungroup-source.d.ts +3 -0
  151. package/dist/comments/index.d.ts +35 -0
  152. package/dist/comments/save.d.ts +3 -0
  153. package/dist/comments/state.d.ts +10 -0
  154. package/dist/comments/xml.d.ts +12 -0
  155. package/dist/comments.js +782 -0
  156. package/dist/common-object-slide-types.d.ts +34 -0
  157. package/dist/data-validation.d.ts +1 -1
  158. package/dist/describe/budget.d.ts +3 -0
  159. package/dist/describe/index.d.ts +5 -0
  160. package/dist/describe/read.d.ts +4 -0
  161. package/dist/describe/types.d.ts +103 -0
  162. package/dist/describe.js +192 -0
  163. package/dist/design-dependencies.d.ts +8 -0
  164. package/dist/design-projection-package.d.ts +10 -0
  165. package/dist/design-target.d.ts +10 -0
  166. package/dist/design.d.ts +3 -0
  167. package/dist/document-extensions.d.ts +9 -0
  168. package/dist/document.d.ts +1 -1
  169. package/dist/dynamic-projection.d.ts +6 -0
  170. package/dist/edit-core.js +5420 -4111
  171. package/dist/editor.d.ts +15 -3
  172. package/dist/element-source.d.ts +11 -0
  173. package/dist/element-spids.d.ts +4 -0
  174. package/dist/extension-address-journal.d.ts +9 -0
  175. package/dist/extension-address-remap.d.ts +14 -0
  176. package/dist/extension-addresses.d.ts +20 -0
  177. package/dist/extension-copy-history.d.ts +7 -0
  178. package/dist/extension-copy.d.ts +16 -0
  179. package/dist/extension-migration-receipt.d.ts +34 -0
  180. package/dist/extension-recovery-context.d.ts +5 -0
  181. package/dist/extension-runtime.d.ts +64 -0
  182. package/dist/generate/comments.d.ts +3 -0
  183. package/dist/generate/compatibility-parts.d.ts +14 -0
  184. package/dist/generate/compatibility-references.d.ts +3 -0
  185. package/dist/generate/compatibility.d.ts +4 -0
  186. package/dist/generate/index.d.ts +1 -0
  187. package/dist/generate/master-defaults.d.ts +4 -0
  188. package/dist/generate/materialize.d.ts +2 -2
  189. package/dist/generate/math.d.ts +3 -0
  190. package/dist/generate/portable-clipboard.d.ts +4 -0
  191. package/dist/generate/projection-tree.d.ts +8 -0
  192. package/dist/generate/template.d.ts +68 -1
  193. package/dist/generate/text-body.d.ts +2 -0
  194. package/dist/generate/text-effects.d.ts +5 -0
  195. package/dist/generate/text-override.d.ts +8 -0
  196. package/dist/generate/validation.d.ts +3 -0
  197. package/dist/generate/warp.d.ts +2 -0
  198. package/dist/generate.js +1232 -512
  199. package/dist/history.d.ts +11 -1
  200. package/dist/identities.d.ts +4 -0
  201. package/dist/image-content.d.ts +5 -2
  202. package/dist/image-resource-history.d.ts +2 -0
  203. package/dist/index-C2r7c6G6.js +714 -0
  204. package/dist/index-CYDvbiwF.js +1 -0
  205. package/dist/index.d.ts +35 -7
  206. package/dist/ink/index.d.ts +27 -0
  207. package/dist/ink/model.d.ts +4 -0
  208. package/dist/ink/save.d.ts +3 -0
  209. package/dist/ink/source.d.ts +7 -0
  210. package/dist/ink.js +324 -0
  211. package/dist/layout-assets.d.ts +3 -1
  212. package/dist/layout-projection.d.ts +17 -5
  213. package/dist/layout-state.d.ts +2 -0
  214. package/dist/layout-types.d.ts +42 -0
  215. package/dist/layout.d.ts +5 -0
  216. package/dist/lint/color.d.ts +5 -0
  217. package/dist/lint/index.d.ts +7 -0
  218. package/dist/lint/prompts.d.ts +3 -0
  219. package/dist/lint/report.d.ts +21 -0
  220. package/dist/lint/sampler-batch.d.ts +4 -0
  221. package/dist/lint/sampler-images.d.ts +2 -0
  222. package/dist/lint/sampler.d.ts +9 -0
  223. package/dist/lint/snapshot.d.ts +34 -0
  224. package/dist/lint/types.d.ts +67 -0
  225. package/dist/lint-sampler.js +187 -0
  226. package/dist/lint.js +659 -0
  227. package/dist/master-state.d.ts +3 -0
  228. package/dist/master-text-style-state.d.ts +3 -0
  229. package/dist/master-types.d.ts +55 -0
  230. package/dist/master.d.ts +5 -0
  231. package/dist/media/audio-icon.d.ts +2 -0
  232. package/dist/media/commands.d.ts +3 -0
  233. package/dist/media/index.d.ts +10 -0
  234. package/dist/media/markup.d.ts +10 -0
  235. package/dist/media/mp4-boxes.d.ts +12 -0
  236. package/dist/media/mp4-fragments.d.ts +8 -0
  237. package/dist/media/mp4-samples.d.ts +4 -0
  238. package/dist/media/mp4.d.ts +2 -0
  239. package/dist/media/poster.d.ts +2 -0
  240. package/dist/media/replace-poster.d.ts +3 -0
  241. package/dist/media/resource.d.ts +4 -0
  242. package/dist/media/source.d.ts +14 -0
  243. package/dist/media/types.d.ts +33 -0
  244. package/dist/media-properties.d.ts +4 -0
  245. package/dist/media.js +1630 -0
  246. package/dist/model-invariants-BM19JVxy.js +8980 -0
  247. package/dist/object-source.d.ts +11 -0
  248. package/dist/ole/container.d.ts +14 -0
  249. package/dist/ole/content.d.ts +94 -0
  250. package/dist/ole/index.d.ts +20 -0
  251. package/dist/ole/preview.d.ts +3 -0
  252. package/dist/ole/save.d.ts +2 -0
  253. package/dist/ole/state.d.ts +16 -0
  254. package/dist/ole.js +870 -0
  255. package/dist/opc.js +1 -1
  256. package/dist/paragraph-level.d.ts +2 -2
  257. package/dist/paragraph-property-schema.d.ts +4 -1
  258. package/dist/{patch-D7lZelRa.js → patch-BwhfBbYE.js} +10 -10
  259. package/dist/patch-events.d.ts +5 -1
  260. package/dist/ppt/appearance.d.ts +11 -0
  261. package/dist/ppt/binary.d.ts +20 -0
  262. package/dist/ppt/drawing.d.ts +18 -0
  263. package/dist/ppt/geometry.d.ts +4 -0
  264. package/dist/ppt/index.d.ts +12 -0
  265. package/dist/ppt/pictures.d.ts +11 -0
  266. package/dist/ppt/text.d.ts +9 -0
  267. package/dist/ppt.js +774 -0
  268. package/dist/preset-geometry.d.ts +6 -0
  269. package/dist/projection.d.ts +2 -0
  270. package/dist/query-BHLjWjnu.js +903 -0
  271. package/dist/recovery-identity.d.ts +1 -0
  272. package/dist/recovery-migrations.d.ts +3 -0
  273. package/dist/recovery.d.ts +3 -0
  274. package/dist/resize/index.d.ts +6 -0
  275. package/dist/resize/text.d.ts +4 -0
  276. package/dist/resize.js +5090 -0
  277. package/dist/retained-element-origins.d.ts +6 -0
  278. package/dist/run-property-fields.d.ts +12 -0
  279. package/dist/run-property-schema.d.ts +3 -1
  280. package/dist/run-style.d.ts +15 -0
  281. package/dist/save/alt-text.d.ts +4 -0
  282. package/dist/save/comments.d.ts +3 -0
  283. package/dist/save/effects.d.ts +2 -1
  284. package/dist/save/extension-availability.d.ts +3 -0
  285. package/dist/save/extension-elements.d.ts +26 -0
  286. package/dist/save/index.d.ts +6 -1
  287. package/dist/save/insertion.d.ts +6 -5
  288. package/dist/save/layout-properties.d.ts +4 -0
  289. package/dist/save/master-properties.d.ts +5 -0
  290. package/dist/save/paragraph-overrides.d.ts +3 -0
  291. package/dist/save/slide-parts.d.ts +1 -0
  292. package/dist/save/table.d.ts +2 -0
  293. package/dist/save/xfrm.d.ts +8 -2
  294. package/dist/save.js +493 -498
  295. package/dist/sections.d.ts +8 -0
  296. package/dist/session-assets.d.ts +4 -0
  297. package/dist/slide-parts-D0o_DDhi.js +1331 -0
  298. package/dist/slide-size.d.ts +6 -0
  299. package/dist/smartart/drawing.d.ts +3 -0
  300. package/dist/smartart/index.d.ts +16 -0
  301. package/dist/smartart/model.d.ts +18 -0
  302. package/dist/smartart/save.d.ts +3 -0
  303. package/dist/smartart.js +604 -0
  304. package/dist/source-retention.d.ts +7 -0
  305. package/dist/space.d.ts +37 -0
  306. package/dist/table-cell.d.ts +7 -1
  307. package/dist/table-grid-projection.d.ts +6 -0
  308. package/dist/table-grid.d.ts +45 -0
  309. package/dist/table-invariants.d.ts +4 -0
  310. package/dist/table-rows.d.ts +2 -1
  311. package/dist/table-scale.d.ts +4 -0
  312. package/dist/table-style.d.ts +5 -4
  313. package/dist/templates/index.d.ts +4 -0
  314. package/dist/templates/recipes.d.ts +5 -0
  315. package/dist/templates/types.d.ts +17 -0
  316. package/dist/templates.js +543 -0
  317. package/dist/text-flatten.d.ts +6 -0
  318. package/dist/text-fragment.d.ts +5 -0
  319. package/dist/text-model.d.ts +8 -8
  320. package/dist/text-override-validation.d.ts +6 -2
  321. package/dist/text-selection.d.ts +4 -0
  322. package/dist/theme-projection.d.ts +8 -0
  323. package/dist/theme-xml.d.ts +3 -0
  324. package/dist/theme.d.ts +14 -0
  325. package/dist/types.d.ts +174 -8
  326. package/dist/xml/index.d.ts +1 -1
  327. package/dist/xml/nodes.d.ts +2 -2
  328. package/dist/xml/shape-ids.d.ts +3 -0
  329. package/dist/xml.js +19 -16
  330. package/package.json +79 -5
  331. package/schemas/describe.schema.json +479 -0
  332. package/schemas/lint.schema.json +145 -0
  333. package/dist/document-B1jjN-QB.js +0 -274
  334. package/dist/image-resource-DbgJS9n-.js +0 -24
  335. package/dist/index-D2JizcOQ.js +0 -706
  336. package/dist/insertion-CGpb504L.js +0 -6152
  337. package/dist/table-style-part-DBtpxmuo.js +0 -1042
@@ -0,0 +1,301 @@
1
+ import { effectiveElement as Z } from "@web-ppt/edit-core";
2
+ function C(t, o, e) {
3
+ if (!t || typeof t != "object" || Object.getPrototypeOf(t) !== Object.prototype && Object.getPrototypeOf(t) !== null)
4
+ throw new Error(`${e} 必须是纯数据对象`);
5
+ const r = Array.isArray(o) ? new Set(o) : o;
6
+ for (const n of Reflect.ownKeys(t)) {
7
+ const a = Object.getOwnPropertyDescriptor(t, n);
8
+ if (typeof n != "string" || !r.has(n) || !(a != null && a.enumerable) || !("value" in a))
9
+ throw new Error(`${e} 包含不可序列化或未知字段:${String(n)}`);
10
+ }
11
+ }
12
+ const K = [
13
+ "pct5",
14
+ "pct10",
15
+ "pct20",
16
+ "pct25",
17
+ "pct30",
18
+ "pct40",
19
+ "pct50",
20
+ "pct60",
21
+ "pct70",
22
+ "pct75",
23
+ "pct80",
24
+ "pct90",
25
+ "ltHorz",
26
+ "horz",
27
+ "dkHorz",
28
+ "ltVert",
29
+ "vert",
30
+ "dkVert",
31
+ "ltUpDiag",
32
+ "upDiag",
33
+ "ltDnDiag",
34
+ "dnDiag",
35
+ "smGrid",
36
+ "lgGrid",
37
+ "cross",
38
+ "diagCross",
39
+ "trellis",
40
+ "wave"
41
+ ];
42
+ new Set(K);
43
+ function I(t, o) {
44
+ if (typeof t != "string") throw new Error(`${o} 必须是颜色字符串`);
45
+ if (/^#[0-9a-f]{6}$/i.test(t)) return;
46
+ const e = /^(rgb|rgba)\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?\)$/i.exec(t);
47
+ if (!e) throw new Error(`${o} 必须是 #RRGGBB、rgb() 或 rgba()`);
48
+ const r = e[5];
49
+ if (e[1].toLowerCase() === "rgb" != (r === void 0))
50
+ throw new Error(`${o} 的 rgb/rgba 参数数量不匹配`);
51
+ const n = e.slice(2, 5).map(Number), a = r === void 0 ? 1 : Number(r);
52
+ if (n.some((s) => !Number.isFinite(s) || s < 0 || s > 255) || !Number.isFinite(a) || a < 0 || a > 1)
53
+ throw new Error(`${o} 的通道超出范围`);
54
+ }
55
+ function J(t) {
56
+ var a;
57
+ const o = (a = /^#([0-9a-f]{6})$/i.exec(t)) == null ? void 0 : a[1];
58
+ if (o)
59
+ return `rgb(${[0, 2, 4].map((m) => Number.parseInt(o.slice(m, m + 2), 16)).join(",")})`;
60
+ const e = /^(rgb|rgba)\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?\)$/i.exec(t), r = e.slice(2, 5).map(Number), n = e[1].toLowerCase() === "rgba" ? Math.round(Number(e[5]) * 1e3) / 1e3 : 1;
61
+ return n >= 1 ? `rgb(${r.join(",")})` : `rgba(${r.join(",")},${n})`;
62
+ }
63
+ const y = "http://schemas.openxmlformats.org/drawingml/2006/main", j = "http://schemas.openxmlformats.org/presentationml/2006/main", k = Symbol.for("@web-ppt/edit-core/extensions/v1"), F = Symbol.for("@web-ppt/edit-core/extensions-generation/v1"), T = Symbol.for("@web-ppt/edit-core/extensions-listeners/v1"), Q = /^[a-z][a-z0-9-]{0,63}$/;
64
+ function z() {
65
+ const t = globalThis;
66
+ return t[T] ?? (t[T] = { documents: /* @__PURE__ */ new WeakMap(), pending: /* @__PURE__ */ new Map(), active: /* @__PURE__ */ new Set(), resolvers: /* @__PURE__ */ new WeakMap() });
67
+ }
68
+ function tt(t) {
69
+ if (!Q.test(t))
70
+ throw new Error(`编辑扩展命名空间无效:${t}`);
71
+ }
72
+ function ot() {
73
+ const t = globalThis;
74
+ return t[k] ?? (t[k] = /* @__PURE__ */ new Map());
75
+ }
76
+ function rt(t, o) {
77
+ var n;
78
+ tt(t), ot().set(t, o);
79
+ const e = globalThis;
80
+ e[F] = (e[F] ?? 0) + 1;
81
+ const r = new Set(z().pending.get(t));
82
+ if (o.migrate) for (const a of z().active) r.add(a);
83
+ z().pending.delete(t);
84
+ for (const a of r ?? [])
85
+ try {
86
+ a(t);
87
+ } catch (s) {
88
+ (n = globalThis.reportError) == null || n.call(globalThis, s);
89
+ }
90
+ }
91
+ const et = [
92
+ "legacyMatte",
93
+ "legacyPlastic",
94
+ "legacyMetal",
95
+ "legacyWireframe",
96
+ "matte",
97
+ "plastic",
98
+ "metal",
99
+ "warmMatte",
100
+ "translucentPowder",
101
+ "powder",
102
+ "dkEdge",
103
+ "softEdge",
104
+ "clear",
105
+ "flat",
106
+ "softmetal"
107
+ ], R = ["extrusion", "bevelTop", "bevelBottom", "bevelTopWidth", "bevelBottomWidth", "contourWidth"], X = ["extrusionColor", "contourColor"], O = ["rotX", "rotY", "rotZ"], S = (t, o, e) => typeof t == "number" && Number.isFinite(t) && t >= o && t <= e;
108
+ function x(t) {
109
+ C(t, ["alpha", "grayscale", "duotone"], "图片效果");
110
+ const o = t, e = {};
111
+ if ("alpha" in o) {
112
+ if (!S(o.alpha, 0, 1)) throw new Error("图片不透明度必须在 0–1 之间");
113
+ e.alpha = Math.round(o.alpha * 1e5) / 1e5;
114
+ }
115
+ if ("grayscale" in o) {
116
+ if (typeof o.grayscale != "boolean") throw new Error("图片灰度开关必须是布尔值");
117
+ e.grayscale = o.grayscale;
118
+ }
119
+ if ("duotone" in o) {
120
+ if (!Array.isArray(o.duotone) || o.duotone.length !== 2) throw new Error("双色调需要暗部和亮部两种颜色");
121
+ e.duotone = o.duotone.map((r) => {
122
+ I(r, "双色调颜色");
123
+ const n = J(r);
124
+ if (n.startsWith("rgba")) throw new Error("双色调颜色必须不透明");
125
+ return n;
126
+ });
127
+ }
128
+ return e;
129
+ }
130
+ function M(t) {
131
+ C(t, [...R, ...X, ...O, "material", "camera", "fieldOfView", "zoom", "z", "lightRig", "lightDirection"], "立体效果");
132
+ const o = t, e = {};
133
+ for (const r of R) if (r in o) {
134
+ if (!S(o[r], 0, 2147483647 / 9525)) throw new Error("立体尺寸超出 DrawingML 范围");
135
+ e[r] = Math.round(o[r] * 9525) / 9525;
136
+ }
137
+ for (const r of O) if (r in o) {
138
+ if (!S(o[r], -360, 360)) throw new Error("立体旋转必须在 ±360° 之间");
139
+ e[r] = (Math.round(o[r] * 6e4) % 216e5 + 216e5) % 216e5 / 6e4;
140
+ }
141
+ for (const r of X) r in o && (I(o[r], "立体颜色"), e[r] = J(o[r]));
142
+ if ("material" in o) {
143
+ if (!et.includes(o.material)) throw new Error("未知立体材质");
144
+ e.material = o.material;
145
+ }
146
+ for (const r of ["camera", "lightRig", "lightDirection"]) if (r in o) {
147
+ if (typeof o[r] != "string" || !/^[a-zA-Z][a-zA-Z0-9]{0,63}$/.test(o[r])) throw new Error("三维场景预设名称无效");
148
+ e[r] = o[r];
149
+ }
150
+ for (const [r, n, a, s] of [["fieldOfView", 0, 180, 6e4], ["zoom", 1e-5, 1e3, 1e5], ["z", -2147483647 / 9525, 2147483647 / 9525, 9525]]) if (r in o) {
151
+ if (!S(o[r], n, a)) throw new Error("三维相机参数超出范围");
152
+ e[r] = Math.round(o[r] * s) / s;
153
+ }
154
+ return e;
155
+ }
156
+ function it(t) {
157
+ if (Object.keys(t).length)
158
+ return {
159
+ camera: "orthographicFront",
160
+ lightRig: "threePt",
161
+ lightDirection: "t",
162
+ ...t,
163
+ ...t.bevelTop !== void 0 ? { bevelTopWidth: t.bevelTopWidth ?? t.bevelTop } : {},
164
+ ...t.bevelBottom !== void 0 ? { bevelBottomWidth: t.bevelBottomWidth ?? t.bevelBottom } : {},
165
+ ...t.bevelTopWidth !== void 0 && t.bevelTop === void 0 ? { bevelTop: 4 } : {},
166
+ ...t.bevelBottomWidth !== void 0 && t.bevelBottom === void 0 ? { bevelBottom: 4 } : {},
167
+ ...O.some((o) => o in t) ? { rotX: t.rotX ?? 0, rotY: t.rotY ?? 0, rotZ: t.rotZ ?? 0 } : {}
168
+ };
169
+ }
170
+ function L(t) {
171
+ return { ...t };
172
+ }
173
+ function nt(t, o) {
174
+ var r;
175
+ const e = (r = t.filter) == null ? void 0 : r.replace(/grayscale\(1\)(?: contrast\(1\.1\))?\s*/g, "").trim();
176
+ return {
177
+ ...t,
178
+ alpha: o.alpha ?? 1,
179
+ duotone: o.duotone ? [...o.duotone] : void 0,
180
+ filter: [o.grayscale ? "grayscale(1)" : "", e].filter(Boolean).join(" ") || void 0
181
+ };
182
+ }
183
+ function V(t) {
184
+ var o;
185
+ return {
186
+ ...t.alpha !== void 0 ? { alpha: t.alpha } : {},
187
+ ...(o = t.filter) != null && o.includes("grayscale(1)") ? { grayscale: !0 } : {},
188
+ ...t.duotone ? { duotone: t.duotone } : {}
189
+ };
190
+ }
191
+ function at(t, o, e, r) {
192
+ var D;
193
+ const {
194
+ findXmlChild: n,
195
+ xmlElementChildren: a,
196
+ removeXmlChild: s,
197
+ insertXmlChildUnchecked: m,
198
+ setXmlAttribute: u,
199
+ insertXmlInOrder: b,
200
+ locateElementHost: E,
201
+ namespacedElement: N,
202
+ appendDrawingColor: P
203
+ } = r, v = (f, i, c = y) => n(f, { localName: i, namespaceUri: c }), w = (f) => String(Math.round(f * 9525));
204
+ function g(f, i, c = {}) {
205
+ const d = N(f, y, i);
206
+ for (const [h, p] of Object.entries(c)) u(d, h, p);
207
+ return m(f, d, v(f, "extLst")), d;
208
+ }
209
+ function U(f, i) {
210
+ const c = v(f, "blipFill", j), d = c && v(c, "blip");
211
+ if (!d) throw new Error("图片缺少可写回的 blip");
212
+ for (const h of a(d))
213
+ h.namespaceUri === y && ["alphaModFix", "grayscl", "duotone"].includes(h.localName) && s(d, h);
214
+ if (i.alpha !== void 0 && i.alpha < 1 && g(d, "alphaModFix", { amt: String(Math.round(i.alpha * 1e5)) }), i.grayscale && g(d, "grayscl"), i.duotone) {
215
+ const h = g(d, "duotone");
216
+ i.duotone.forEach((p) => P(h, p));
217
+ }
218
+ }
219
+ function Y(f, i) {
220
+ const c = v(f, "spPr", j);
221
+ if (!c) throw new Error("立体形状缺少 spPr");
222
+ for (const q of ["scene3d", "sp3d"]) {
223
+ const $ = v(c, q);
224
+ $ && s(c, $);
225
+ }
226
+ if (!Object.keys(i).length) return;
227
+ const d = N(c, y, "scene3d");
228
+ b(c, d);
229
+ const h = g(d, "camera", { prst: i.camera ?? "orthographicFront" });
230
+ i.fieldOfView !== void 0 && u(h, "fov", String(Math.round(i.fieldOfView * 6e4))), i.zoom !== void 0 && u(h, "zoom", String(Math.round(i.zoom * 1e5))), (i.rotX !== void 0 || i.rotY !== void 0 || i.rotZ !== void 0) && g(h, "rot", {
231
+ lat: String(Math.round((i.rotX ?? 0) * 6e4)),
232
+ lon: String(Math.round((i.rotY ?? 0) * 6e4)),
233
+ rev: String(Math.round((i.rotZ ?? 0) * 6e4))
234
+ }), g(d, "lightRig", { rig: i.lightRig ?? "threePt", dir: i.lightDirection ?? "t" });
235
+ const p = N(c, y, "sp3d");
236
+ b(c, p), i.extrusion !== void 0 && u(p, "extrusionH", w(i.extrusion)), i.z !== void 0 && u(p, "z", w(i.z)), i.contourWidth !== void 0 && u(p, "contourW", w(i.contourWidth)), i.material && u(p, "prstMaterial", i.material), (i.bevelTop !== void 0 || i.bevelTopWidth !== void 0) && g(p, "bevelT", { w: w(i.bevelTopWidth ?? i.bevelTop ?? 0), h: w(i.bevelTop ?? 4), prst: "circle" }), (i.bevelBottom !== void 0 || i.bevelBottomWidth !== void 0) && g(p, "bevelB", { w: w(i.bevelBottomWidth ?? i.bevelBottom ?? 0), h: w(i.bevelBottom ?? 4), prst: "circle" }), i.extrusionColor && P(g(p, "extrusionClr"), i.extrusionColor), i.contourColor && P(g(p, "contourClr"), i.contourColor);
237
+ }
238
+ const l = (D = o.ovr.extensions) == null ? void 0 : D.appearance, W = o.src.kind === "image" && ((l == null ? void 0 : l.picture) !== void 0 || e), A = o.src.kind === "shape" && ((l == null ? void 0 : l.scene) !== void 0 || e && o.src.scene3d);
239
+ if (!W && !A) return;
240
+ const { host: B } = E(t, o);
241
+ W && o.src.kind === "image" && U(B, (l == null ? void 0 : l.picture) !== void 0 ? x(JSON.parse(l.picture)) : V(o.src)), A && Y(B, (l == null ? void 0 : l.scene) !== void 0 ? M(JSON.parse(l.scene)) : L(o.src.scene3d));
242
+ }
243
+ const H = (t, o) => {
244
+ var e, r;
245
+ return ((r = (e = t.elements[o]) == null ? void 0 : e.ovr.extensions) == null ? void 0 : r.appearance) ?? {};
246
+ };
247
+ function _(t, o) {
248
+ var n;
249
+ const e = o.path[5], r = t.elements[o.path[1]];
250
+ if (o.path.length !== 6 || !["picture", "scene"].includes(e) || r.src.kind !== (e === "picture" ? "image" : "shape") || (n = r.src.editInfo) != null && n.requiresOriginal)
251
+ throw new Error("外观补丁目标或字段无效");
252
+ if (o.op === "set") {
253
+ if (typeof o.value != "string" || o.value.length > 4096) throw new Error("外观补丁值无效");
254
+ (e === "picture" ? x : M)(JSON.parse(o.value));
255
+ }
256
+ }
257
+ function st(t, o, e) {
258
+ const r = o.payload;
259
+ if (C(r, ["type", "id", (r == null ? void 0 : r.type) === "SetPictureFx" ? "effects" : "scene"], "外观命令"), !["SetPictureFx", "SetScene3D"].includes(r.type) || r.id !== o.id) throw new Error("外观命令身份无效");
260
+ const n = t.elements[r.id];
261
+ if (!n || t.meta.readonly || n.meta.locked || n.meta.editable !== "full") throw new Error("目标不允许修改外观");
262
+ const a = r.type === "SetPictureFx" ? "picture" : "scene", s = r.type === "SetPictureFx" ? r.effects : r.scene, m = ["elements", r.id, "ovr", "extensions", "appearance", a], u = H(t, r.id)[a], b = s === null ? void 0 : JSON.stringify(
263
+ r.type === "SetPictureFx" ? x(s) : M(s)
264
+ ), E = b === void 0 ? { op: "del", path: m, origin: e } : { op: "set", path: m, value: b, origin: e };
265
+ return _(t, E), b === u ? { forward: [], inverse: [] } : { forward: [E], inverse: [u === void 0 ? { op: "del", path: m, origin: e } : { op: "set", path: m, value: u, origin: e }] };
266
+ }
267
+ let G = !1;
268
+ function lt() {
269
+ G || (rt("appearance", {
270
+ command: st,
271
+ validatePatch: _,
272
+ materialize: at,
273
+ supportsGenerated: (t) => t.kind === "shape" || t.kind === "image" && (!t.filter || t.filter === "grayscale(1)"),
274
+ project(t, o, e) {
275
+ const r = H(t, o);
276
+ return r.picture !== void 0 && e.kind === "image" ? nt(e, x(JSON.parse(r.picture))) : r.scene !== void 0 && e.kind === "shape" ? { ...e, scene3d: it(M(JSON.parse(r.scene))) } : e;
277
+ }
278
+ }), G = !0);
279
+ }
280
+ function dt(t) {
281
+ return lt(), { exec(o) {
282
+ return t.exec({ type: "Extension", namespace: "appearance", id: o.id, payload: o });
283
+ } };
284
+ }
285
+ function pt(t, o) {
286
+ const e = Z(t, o);
287
+ if (e.kind !== "image") throw new Error("图片效果查询需要图片");
288
+ return structuredClone(V(e));
289
+ }
290
+ function ut(t, o) {
291
+ const e = Z(t, o);
292
+ if (e.kind !== "shape") throw new Error("立体效果查询需要形状");
293
+ return structuredClone(L(e.scene3d));
294
+ }
295
+ export {
296
+ et as SCENE_MATERIALS,
297
+ dt as createAppearanceEditor,
298
+ pt as queryPictureFx,
299
+ ut as queryScene3D,
300
+ lt as registerAppearanceEditing
301
+ };
@@ -0,0 +1,5 @@
1
+ export { isCompoundFile, readCompoundFile } from './read';
2
+ export type { CompoundFile, CompoundEntry } from './read';
3
+ export { writeCompoundFile } from './write';
4
+ export declare function patchCompoundFile(bytes: Uint8Array, streams: Readonly<Record<string, Uint8Array>>): Uint8Array;
5
+ export declare function createCompoundFile(streams: Readonly<Record<string, Uint8Array>>): Uint8Array;
@@ -0,0 +1,16 @@
1
+ export declare const END = 4294967294, FREE = 4294967295, LIMIT: number;
2
+ export declare const view: (bytes: Uint8Array) => DataView<ArrayBufferLike>;
3
+ export declare const isCompoundFile: (bytes: Uint8Array) => boolean;
4
+ export interface CompoundEntry {
5
+ path: string;
6
+ name: string;
7
+ type: number;
8
+ raw: Uint8Array;
9
+ bytes?: Uint8Array;
10
+ }
11
+ export interface CompoundFile {
12
+ entries: CompoundEntry[];
13
+ header: Uint8Array;
14
+ }
15
+ /** 写回需要保留目录索引、存储层级及 CLSID,不能复用只按流名读取的 PPT 解析器。 */
16
+ export declare function readCompoundFile(bytes: Uint8Array): CompoundFile;
@@ -0,0 +1,3 @@
1
+ import type { CompoundFile } from './read';
2
+ /** 统一输出 v3;重排扇区但保留目录身份、树指针、CLSID 和未知元数据。 */
3
+ export declare function writeCompoundFile(file: CompoundFile): Uint8Array;
package/dist/cfb.js ADDED
@@ -0,0 +1,208 @@
1
+ const F = (l) => new DataView(l.buffer, l.byteOffset, l.byteLength), j = (l) => [208, 207, 17, 224, 161, 177, 26, 225].every((o, i) => l[i] === o);
2
+ function x(l) {
3
+ var R;
4
+ if (!j(l) || l.length < 512 || l.length > 268435456) throw new Error("CFB 文件无效或超限");
5
+ const o = l.slice(0, 512), i = F(o), A = i.getUint16(26, !0), f = i.getUint16(30, !0);
6
+ if (i.getUint16(28, !0) !== 65534 || !(A === 3 && f === 9 || A === 4 && f === 12) || i.getUint16(32, !0) !== 6 || i.getUint32(56, !0) !== 4096) throw new Error("CFB 扇区格式无效");
7
+ const n = 2 ** f, U = Math.floor(l.length / n) - 1;
8
+ if (l.length % n) throw new Error("CFB 扇区被截断");
9
+ const w = (e) => {
10
+ if (e >= U) throw new Error("CFB 扇区越界");
11
+ return l.subarray((e + 1) * n, (e + 2) * n);
12
+ }, c = [], u = /* @__PURE__ */ new Set();
13
+ for (let e = 0; e < 109; e++) {
14
+ const r = i.getUint32(76 + e * 4, !0);
15
+ r !== 4294967295 && c.push(r);
16
+ }
17
+ let g = i.getUint32(68, !0);
18
+ const I = i.getUint32(72, !0);
19
+ if (I > U) throw new Error("CFB DIFAT 数量无效");
20
+ for (let e = 0; e < I; e++) {
21
+ if (u.has(g)) throw new Error("CFB DIFAT 循环");
22
+ u.add(g);
23
+ const r = F(w(g));
24
+ for (let a = 0; a < n / 4 - 1; a++) {
25
+ const h = r.getUint32(a * 4, !0);
26
+ h !== 4294967295 && c.push(h);
27
+ }
28
+ g = r.getUint32(n - 4, !0);
29
+ }
30
+ if (I && g !== 4294967294 || c.length !== i.getUint32(44, !0)) throw new Error("CFB FAT 数量无效");
31
+ const b = [];
32
+ for (const e of c) {
33
+ if (u.has(e)) throw new Error("CFB FAT 扇区重叠");
34
+ u.add(e);
35
+ const r = F(w(e));
36
+ for (let a = 0; a < n; a += 4) b.push(r.getUint32(a, !0));
37
+ }
38
+ const T = (e, r, a) => {
39
+ const h = [], p = /* @__PURE__ */ new Set();
40
+ for (let B = e; B !== 4294967294; ) {
41
+ if (B >= a || B >= r.length || p.has(B)) throw new Error("CFB 链循环或越界");
42
+ p.add(B), h.push(B), B = r[B];
43
+ }
44
+ return h;
45
+ }, d = (e, r) => {
46
+ if (r === 0) return new Uint8Array();
47
+ const a = T(e, b, U), h = a.length * n;
48
+ if (r !== void 0 && (r > h || h - r >= n)) throw new Error("CFB 流长度与链不符");
49
+ const p = new Uint8Array(r ?? h);
50
+ return a.forEach((B, v) => p.set(w(B).subarray(0, Math.min(n, p.length - v * n)), v * n)), p;
51
+ }, m = d(i.getUint32(48, !0));
52
+ if (m.length > 16 * 1024 * 1024) throw new Error("CFB 目录超限");
53
+ const E = [];
54
+ for (let e = 0; e < m.length; e += 128) {
55
+ const r = m.slice(e, e + 128), a = F(r), h = r[66], p = a.getUint16(64, !0);
56
+ if (h && (![1, 2, 5].includes(h) || p < 2 || p > 64 || p % 2 || a.getUint16(p - 2, !0))) throw new Error("CFB 目录项无效");
57
+ let B = "";
58
+ for (let v = 0; h && v < p - 2; v += 2) B += String.fromCharCode(a.getUint16(v, !0));
59
+ E.push({ path: "", name: B, type: h, raw: r });
60
+ }
61
+ if (((R = E[0]) == null ? void 0 : R.type) !== 5) throw new Error("CFB 缺少根存储");
62
+ const M = /* @__PURE__ */ new Set([0]), C = [{ id: F(E[0].raw).getUint32(76, !0), parent: "", depth: 0 }];
63
+ for (; C.length; ) {
64
+ const { id: e, parent: r, depth: a } = C.pop();
65
+ if (e === 4294967295) continue;
66
+ const h = E[e];
67
+ if (!h || ![1, 2].includes(h.type) || M.has(e) || a > 64 || /[\/\0]/.test(h.name)) throw new Error("CFB 目录层级无效");
68
+ M.add(e), h.path = r + h.name;
69
+ const p = F(h.raw);
70
+ C.push({ id: p.getUint32(68, !0), parent: r, depth: a }, { id: p.getUint32(72, !0), parent: r, depth: a }), h.type === 1 && C.push({ id: p.getUint32(76, !0), parent: h.path + "/", depth: a + 1 });
71
+ }
72
+ if (E.some((e, r) => e.type && !M.has(r))) throw new Error("CFB 目录包含孤立节点");
73
+ const N = (e) => {
74
+ const r = F(e.raw), a = r.getUint32(120, !0) + (A === 4 ? r.getUint32(124, !0) * 2 ** 32 : 0);
75
+ if (a > 268435456) throw new Error("CFB 流超限");
76
+ return a;
77
+ }, t = d(F(E[0].raw).getUint32(116, !0), N(E[0])), s = d(i.getUint32(60, !0), i.getUint32(64, !0) * n), y = [];
78
+ for (let e = 0; e < s.length; e += 4) y.push(F(s).getUint32(e, !0));
79
+ let D = 0;
80
+ for (const e of E) if (e.type === 2) {
81
+ const r = N(e), a = F(e.raw).getUint32(116, !0);
82
+ if ((D += r) > 268435456) throw new Error("CFB 流总量超限");
83
+ if (r >= 4096 || r === 0) e.bytes = d(a, r);
84
+ else {
85
+ const h = T(a, y, Math.ceil(t.length / 64));
86
+ if (h.length !== Math.ceil(r / 64)) throw new Error("CFB 小流长度无效");
87
+ e.bytes = new Uint8Array(r), h.forEach((p, B) => e.bytes.set(t.subarray(p * 64, p * 64 + Math.min(64, r - B * 64)), B * 64));
88
+ }
89
+ }
90
+ return { entries: E, header: o };
91
+ }
92
+ function S(l) {
93
+ var N;
94
+ const o = l.entries.map((t) => ({ ...t, raw: t.raw.slice() }));
95
+ if (((N = o[0]) == null ? void 0 : N.type) !== 5) throw new Error("CFB 缺少根存储");
96
+ const i = [], A = [], f = [], n = [];
97
+ let U = 0;
98
+ const w = (t) => {
99
+ const s = t.length ? n.length : 4294967294;
100
+ for (let y = 0; y < t.length; y += 512) {
101
+ if ((U += 512) > 268435456) throw new Error("CFB 写入超限");
102
+ const D = new Uint8Array(512);
103
+ D.set(t.subarray(y, y + 512)), n.push(D), f.push(y + 512 < t.length ? n.length : 4294967294);
104
+ }
105
+ return s;
106
+ };
107
+ for (const t of o) if (t.type === 2) {
108
+ const s = t.bytes ?? new Uint8Array(), y = F(t.raw);
109
+ if (y.setUint32(120, s.length, !0), y.setUint32(124, 0, !0), s.length >= 4096 || !s.length) y.setUint32(116, w(s), !0);
110
+ else {
111
+ y.setUint32(116, i.length, !0);
112
+ for (let D = 0; D < s.length; D += 64) {
113
+ const R = new Uint8Array(64);
114
+ R.set(s.subarray(D, D + 64)), i.push(R), A.push(D + 64 < s.length ? i.length : 4294967294);
115
+ }
116
+ }
117
+ }
118
+ const c = new Uint8Array(i.length * 64);
119
+ i.forEach((t, s) => c.set(t, s * 64));
120
+ const u = F(o[0].raw);
121
+ u.setUint32(116, w(c), !0), u.setUint32(120, c.length, !0), u.setUint32(124, 0, !0);
122
+ const g = new Uint8Array(Math.ceil(A.length / 128) * 512).fill(255);
123
+ A.forEach((t, s) => F(g).setUint32(s * 4, t, !0));
124
+ const I = w(g), b = new Uint8Array(Math.ceil(o.length / 4) * 512);
125
+ o.forEach((t, s) => b.set(t.raw, s * 128));
126
+ const T = w(b), d = n.length;
127
+ let m = 0, E = 0;
128
+ for (; ; ) {
129
+ const t = Math.ceil((d + m + E) / 128), s = Math.max(0, Math.ceil((t - 109) / 127));
130
+ if (t === m && s === E) break;
131
+ m = t, E = s;
132
+ }
133
+ const M = new Uint8Array((1 + d + m + E) * 512);
134
+ if (M.length > 268435456) throw new Error("CFB 写入超限");
135
+ M.set(l.header.subarray(0, 512));
136
+ const C = F(M.subarray(0, 512));
137
+ M.set([208, 207, 17, 224, 161, 177, 26, 225]), C.setUint16(24, 62, !0), C.setUint16(26, 3, !0), C.setUint16(28, 65534, !0), C.setUint16(30, 9, !0), C.setUint16(32, 6, !0), M.fill(0, 34, 44), C.setUint32(44, m, !0), C.setUint32(48, T, !0), C.setUint32(56, 4096, !0), C.setUint32(60, I, !0), C.setUint32(64, g.length / 512, !0), C.setUint32(68, E ? d + m : 4294967294, !0), C.setUint32(72, E, !0);
138
+ for (let t = 0; t < 109; t++) C.setUint32(76 + t * 4, t < m ? d + t : 4294967295, !0);
139
+ n.forEach((t, s) => M.set(t, (s + 1) * 512));
140
+ for (let t = 0; t < m; t++) f.push(4294967293);
141
+ for (let t = 0; t < E; t++) f.push(4294967292);
142
+ M.fill(255, (d + 1) * 512), f.forEach((t, s) => F(M).setUint32((d + 1) * 512 + s * 4, t, !0));
143
+ for (let t = 0; t < E; t++) {
144
+ const s = F(M.subarray((d + m + t + 1) * 512));
145
+ for (let y = 0; y < 127; y++) {
146
+ const D = 109 + t * 127 + y;
147
+ s.setUint32(y * 4, D < m ? d + D : 4294967295, !0);
148
+ }
149
+ s.setUint32(508, t + 1 < E ? d + m + t + 1 : 4294967294, !0);
150
+ }
151
+ return M;
152
+ }
153
+ function k(l, o) {
154
+ const i = x(l);
155
+ for (const [A, f] of Object.entries(o)) {
156
+ const n = i.entries.find((U) => U.path === A && U.type === 2);
157
+ if (!n) throw new Error(`CFB 流不存在:${A}`);
158
+ n.bytes = f;
159
+ }
160
+ return S(i);
161
+ }
162
+ const L = (l) => l.split("").map((o) => {
163
+ const i = o.toUpperCase();
164
+ return i.length === 1 ? i : o;
165
+ }).join("");
166
+ function O(l) {
167
+ const o = [], i = /* @__PURE__ */ new Map(), A = (f, n, U, w) => {
168
+ if (!f || f.length > 31 || /[\\/:!\0]/.test(f)) throw new Error("CFB 流名称无效");
169
+ const c = new Uint8Array(128), u = F(c);
170
+ for (let g = 0; g < f.length; g++) u.setUint16(g * 2, f.charCodeAt(g), !0);
171
+ u.setUint16(64, (f.length + 1) * 2, !0), c[66] = U, c[67] = 1;
172
+ for (const g of [68, 72, 76]) u.setUint32(g, 4294967295, !0);
173
+ return u.setUint32(116, U === 1 ? 0 : 4294967294, !0), o.push({ name: f, path: n, type: U, raw: c, bytes: w }), o.length - 1;
174
+ };
175
+ A("Root Entry", "", 5);
176
+ for (const [f, n] of Object.entries(l).sort(([U], [w]) => U < w ? -1 : U > w ? 1 : 0)) {
177
+ const U = f.split("/");
178
+ let w = 0, c = "";
179
+ U.forEach((u, g) => {
180
+ const I = i.get(w) ?? [], b = g === U.length - 1, T = I.find((d) => L(o[d].name) === L(u));
181
+ if (T !== void 0) {
182
+ if (b || o[T].type !== 1) throw new Error("CFB 路径冲突");
183
+ w = T;
184
+ } else {
185
+ const d = A(u, c + u, b ? 2 : 1, b ? n : void 0);
186
+ I.push(d), i.set(w, I), w = d;
187
+ }
188
+ c += u + "/";
189
+ });
190
+ }
191
+ for (const [f, n] of i) {
192
+ n.sort((c, u) => o[c].name.length - o[u].name.length || (L(o[c].name) < L(o[u].name) ? -1 : 1));
193
+ const U = Math.floor(Math.log2(n.length + 1)), w = (c, u, g = 0) => {
194
+ if (c >= u) return 4294967295;
195
+ const I = c + u >>> 1, b = n[I], T = F(o[b].raw);
196
+ return o[b].raw[67] = g === U ? 0 : 1, T.setUint32(68, w(c, I, g + 1), !0), T.setUint32(72, w(I + 1, u, g + 1), !0), b;
197
+ };
198
+ F(o[f].raw).setUint32(76, w(0, n.length), !0);
199
+ }
200
+ return S({ entries: o, header: new Uint8Array(512) });
201
+ }
202
+ export {
203
+ O as createCompoundFile,
204
+ j as isCompoundFile,
205
+ k as patchCompoundFile,
206
+ x as readCompoundFile,
207
+ S as writeCompoundFile
208
+ };
@@ -1,8 +1,8 @@
1
1
  import type { Patch } from './commands/types';
2
- import type { ElementId, SlideId } from './types';
3
- export declare function patchElements(patches: readonly Patch[]): Set<ElementId>;
2
+ import type { EditDoc, ElementId, SlideId } from './types';
3
+ export declare function patchElements(patches: readonly Patch[], dirtyElements?: ReadonlySet<ElementId>): Set<ElementId>;
4
4
  export declare function affectsSlideSequence(patches: readonly Patch[]): boolean;
5
- export declare function renderPatchSlides(patches: readonly Patch[]): Set<SlideId>;
5
+ export declare function renderPatchSlides(doc: EditDoc, patches: readonly Patch[], dirtySlides?: ReadonlySet<SlideId>): Set<SlideId>;
6
6
  export declare function renderPatchElements(patches: readonly Patch[], dirtyElements?: ReadonlySet<ElementId>): Set<ElementId>;
7
7
  export declare function reorderedPatchElements(patches: readonly Patch[]): Set<ElementId>;
8
8
  export declare function panePatchElements(patches: readonly Patch[]): Set<ElementId>;
@@ -0,0 +1,4 @@
1
+ import type { ChartSeries, ChartFormulaBinding } from './types';
2
+ export type CategoryOrientation = NonNullable<ChartFormulaBinding['hierarchy']>['orientation'];
3
+ /** 墓碑系列仍保存类别矩阵的定义,删空系列后才能继续编辑和重建。 */
4
+ export declare const categoryHierarchyBinding: (series: Readonly<Record<string, Pick<ChartSeries, "bindings">>>) => ChartFormulaBinding | undefined;
@@ -0,0 +1,23 @@
1
+ import type { ExtensionPatch } from '../commands/types';
2
+ import type { ChartCategory, ChartDatasetState, ChartPointId } from './types';
3
+ import type { EditDoc } from '../types';
4
+ export type CategoryPayload = {
5
+ op: 'set-category-label';
6
+ pointId: ChartPointId;
7
+ label: string;
8
+ } | {
9
+ op: 'set-category-path';
10
+ pointId: ChartPointId;
11
+ levels: readonly (string | null)[];
12
+ };
13
+ export declare function categoryCommandPatches(doc: EditDoc, id: string, state: ChartDatasetState, payload: CategoryPayload, origin: string): {
14
+ forward: ExtensionPatch[];
15
+ inverse: ExtensionPatch[];
16
+ };
17
+ export declare function previousCategoryId(state: ChartDatasetState, id: ChartPointId): ChartPointId | null;
18
+ export declare function assertCategoryCapacity(state: ChartDatasetState): void;
19
+ export declare function categoryLevelOverride(doc: EditDoc, id: string, categoryId: string, level: number): string | null | undefined;
20
+ export declare function categoryLevelPatches(doc: EditDoc, id: string, category: ChartCategory, levels: readonly (string | null)[], origin: string, previousId?: ChartPointId | null): {
21
+ forward: ExtensionPatch[];
22
+ inverse: ExtensionPatch[];
23
+ };
@@ -0,0 +1,14 @@
1
+ import type { XmlElement } from '@web-ppt/edit-core/xml';
2
+ import type { ChartCategory, ChartDatasetState, ChartFormulaBinding, ChartPointId } from './types';
3
+ import type { CategoryOrientation } from './category-binding';
4
+ export declare function readCategoryLevels(holder: XmlElement | null, valueFormula: string | null, storedOrientation?: CategoryOrientation): {
5
+ readonly slots: Array<Array<string | null>>;
6
+ readonly count: number;
7
+ readonly hierarchy: NonNullable<ChartFormulaBinding['hierarchy']>;
8
+ } | undefined;
9
+ export declare function resizedCategoryFormula(binding: ChartFormulaBinding, count: number): string | null;
10
+ /** 更高级别开始新组时,下级空槽不继承旧父组中的标签。 */
11
+ export declare function resolvedCategoryLevels(categories: readonly ChartCategory[], depth: number): Array<Array<string | null>>;
12
+ /** 以墓碑中的原生组首恢复跨度;并发删除相邻类别也不能把仍被使用的父组删掉。 */
13
+ export declare function preserveCategorySpans(categories: readonly ChartDatasetState['categories'][ChartPointId][], depth: number): void;
14
+ export declare function writeCategoryLevels(holder: XmlElement, categories: readonly ChartCategory[], binding: ChartFormulaBinding): void;
@@ -0,0 +1,2 @@
1
+ import type { ChartDatasetState } from './types';
2
+ export declare function reconcileCategoryMatrix(state: ChartDatasetState): void;
@@ -0,0 +1,2 @@
1
+ /** 只有 JS/Excel/OOXML 往返词法完全不变时,类别标签才继续按数值写入。 */
2
+ export declare function canonicalNumericCategories(values: readonly string[]): number[] | null;
@@ -0,0 +1,13 @@
1
+ import type { ChartDatasetState } from './types';
2
+ import type { WorkbookMap } from './workbook';
3
+ export type CategoryWorkbookCell = {
4
+ readonly kind: 'string' | 'number';
5
+ readonly value: string | number | null;
6
+ };
7
+ type Values = Pick<ChartDatasetState, 'categories' | 'series'>;
8
+ export declare function categoryWorkbookWrites(source: Values, planned: Values, parts: Readonly<Record<string, Uint8Array>>, map: WorkbookMap): {
9
+ sheet: string;
10
+ cells: Map<string, CategoryWorkbookCell>;
11
+ } | undefined;
12
+ export declare function assertCategoryWorkbookSource(state: Values, parts: Readonly<Record<string, Uint8Array>>, map: WorkbookMap): void;
13
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { Editor } from '../editor';
2
+ import type { ElementId } from '../types';
3
+ import type { ChartPlotKind, ChartPointId, ChartSeriesId } from './types';
4
+ type Editable = Pick<Editor, 'doc' | 'exec'>;
5
+ export interface ChartDataEditor {
6
+ setSeriesName(chartId: ElementId, seriesId: ChartSeriesId, name: string): void;
7
+ setCategoryLabel(chartId: ElementId, pointId: ChartPointId, label: string): void;
8
+ setCategoryPath(chartId: ElementId, pointId: ChartPointId, levels: readonly (string | null)[]): void;
9
+ setCategoryLevel(chartId: ElementId, pointId: ChartPointId, level: number, value: string | null): void;
10
+ setValue(chartId: ElementId, seriesId: ChartSeriesId, pointId: ChartPointId, value: number | null): void;
11
+ setPoint(chartId: ElementId, seriesId: ChartSeriesId, pointId: ChartPointId, value: {
12
+ value?: number | null;
13
+ x?: number | null;
14
+ size?: number | null;
15
+ }): void;
16
+ addSeries(chartId: ElementId, name: string, plotKind?: ChartPlotKind): ChartSeriesId;
17
+ removeSeries(chartId: ElementId, seriesId: ChartSeriesId): void;
18
+ addCategory(chartId: ElementId, labelOrPath: string | readonly (string | null)[]): ChartPointId;
19
+ removeCategory(chartId: ElementId, pointId: ChartPointId): void;
20
+ addPoint(chartId: ElementId, seriesId: ChartSeriesId, value: {
21
+ value: number | null;
22
+ x?: number | null;
23
+ size?: number | null;
24
+ }): ChartPointId;
25
+ removePoint(chartId: ElementId, seriesId: ChartSeriesId, pointId: ChartPointId): void;
26
+ }
27
+ export declare function chartDataEditor(editor: Editable): ChartDataEditor;
28
+ export {};
@@ -0,0 +1,12 @@
1
+ import { sourcePartBytes } from '@web-ppt/edit-core';
2
+ import type { ChartEnv } from '@web-ppt/core';
3
+ import type { EditDoc, ElementId } from '../types';
4
+ export declare const chartSourceBytes: typeof sourcePartBytes;
5
+ export type ChartRelationships = Record<string, {
6
+ type: string;
7
+ target: string;
8
+ external?: true;
9
+ }>;
10
+ export declare function chartRelationshipPart(part: string): string;
11
+ export declare function chartRelationships(doc: EditDoc, part: string): ChartRelationships;
12
+ export declare function chartRenderContext(doc: EditDoc, id: ElementId, part: string): ChartEnv;