@allyhub/sdk 0.8.0 → 0.9.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 (438) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/NOTICE +46 -49
  3. package/dist/dom.d.ts +1 -209
  4. package/dist/dom.js +1 -1
  5. package/dist/image.d.ts +2 -0
  6. package/dist/image.js +2 -0
  7. package/dist/index.d.ts +1 -21
  8. package/dist/index.js +1 -1
  9. package/dist/media.d.ts +1 -5
  10. package/dist/media.js +1 -1
  11. package/dist/node_modules/@allyhub/audio/dist/levels.d.ts +4 -5
  12. package/dist/node_modules/@allyhub/audio/dist/levels.js +1 -1
  13. package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.d.ts +1 -6
  14. package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.js +1 -1
  15. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  16. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
  17. package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +1 -1
  18. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
  19. package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
  20. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  21. package/dist/node_modules/@allyhub/diagnostics/LICENSE +241 -0
  22. package/dist/node_modules/@allyhub/diagnostics/dist/fact.d.ts +37 -0
  23. package/dist/node_modules/@allyhub/diagnostics/dist/fact.js +2 -0
  24. package/dist/node_modules/@allyhub/diagnostics/dist/index.d.ts +4 -0
  25. package/dist/node_modules/@allyhub/diagnostics/dist/index.js +2 -0
  26. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +43 -0
  27. package/dist/node_modules/@allyhub/diagnostics/dist/problem.js +2 -0
  28. package/dist/node_modules/@allyhub/diagnostics/dist/rules.d.ts +30 -0
  29. package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +2 -0
  30. package/dist/node_modules/@allyhub/diagnostics/package.json +14 -0
  31. package/dist/node_modules/@allyhub/formats/dist/contributed.d.ts +126 -0
  32. package/dist/node_modules/@allyhub/formats/dist/contributed.js +2 -0
  33. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
  34. package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +7 -12
  35. package/dist/node_modules/@allyhub/formats/dist/data/reference.js +1 -1
  36. package/dist/node_modules/@allyhub/formats/dist/data/script.d.ts +9 -4
  37. package/dist/node_modules/@allyhub/formats/dist/data/script.js +1 -1
  38. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +20 -82
  39. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  40. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +96 -8
  41. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  42. package/dist/node_modules/@allyhub/formats/dist/data/website.d.ts +2 -1
  43. package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
  44. package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
  45. package/dist/node_modules/@allyhub/formats/dist/data/work.js +2 -0
  46. package/dist/node_modules/@allyhub/formats/dist/extension.d.ts +91 -0
  47. package/dist/node_modules/@allyhub/formats/dist/extension.js +2 -0
  48. package/dist/node_modules/@allyhub/formats/dist/files.d.ts +51 -0
  49. package/dist/node_modules/@allyhub/formats/dist/files.js +2 -0
  50. package/dist/node_modules/@allyhub/formats/dist/index.d.ts +5 -1
  51. package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
  52. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +226 -90
  53. package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
  54. package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +7 -1
  55. package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
  56. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +46 -42
  57. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  58. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  59. package/dist/node_modules/@allyhub/image-draw/LICENSE +241 -0
  60. package/dist/node_modules/@allyhub/image-draw/dist/context.d.ts +5 -0
  61. package/dist/node_modules/@allyhub/image-draw/dist/context.js +2 -0
  62. package/dist/node_modules/@allyhub/image-draw/dist/contrast.d.ts +13 -0
  63. package/dist/node_modules/@allyhub/image-draw/dist/contrast.js +2 -0
  64. package/dist/node_modules/@allyhub/image-draw/dist/env.d.ts +112 -0
  65. package/dist/node_modules/@allyhub/image-draw/dist/env.js +2 -0
  66. package/dist/node_modules/@allyhub/image-draw/dist/errors.d.ts +20 -0
  67. package/dist/node_modules/@allyhub/image-draw/dist/errors.js +2 -0
  68. package/dist/node_modules/@allyhub/image-draw/dist/fonts.d.ts +110 -0
  69. package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +2 -0
  70. package/dist/node_modules/@allyhub/image-draw/dist/guards.d.ts +32 -0
  71. package/dist/node_modules/@allyhub/image-draw/dist/guards.js +2 -0
  72. package/dist/node_modules/@allyhub/image-draw/dist/hash.d.ts +3 -0
  73. package/dist/node_modules/@allyhub/image-draw/dist/hash.js +2 -0
  74. package/dist/node_modules/@allyhub/image-draw/dist/inspect.d.ts +113 -0
  75. package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +3 -0
  76. package/dist/node_modules/@allyhub/image-draw/dist/layer-style.d.ts +151 -0
  77. package/dist/node_modules/@allyhub/image-draw/dist/layer-style.js +2 -0
  78. package/dist/node_modules/@allyhub/image-draw/dist/paint.d.ts +29 -0
  79. package/dist/node_modules/@allyhub/image-draw/dist/paint.js +2 -0
  80. package/dist/node_modules/@allyhub/image-draw/dist/pictures.d.ts +39 -0
  81. package/dist/node_modules/@allyhub/image-draw/dist/pictures.js +2 -0
  82. package/dist/node_modules/@allyhub/image-draw/dist/plan.d.ts +52 -0
  83. package/dist/node_modules/@allyhub/image-draw/dist/plan.js +2 -0
  84. package/dist/node_modules/@allyhub/image-draw/dist/reads.d.ts +145 -0
  85. package/dist/node_modules/@allyhub/image-draw/dist/reads.js +2 -0
  86. package/dist/node_modules/@allyhub/image-draw/dist/shape-path.d.ts +26 -0
  87. package/dist/node_modules/@allyhub/image-draw/dist/shape-path.js +2 -0
  88. package/dist/node_modules/@allyhub/image-draw/dist/stage.d.ts +56 -0
  89. package/dist/node_modules/@allyhub/image-draw/dist/stage.js +2 -0
  90. package/dist/node_modules/@allyhub/image-draw/dist/styles.d.ts +35 -0
  91. package/dist/node_modules/@allyhub/image-draw/dist/styles.js +2 -0
  92. package/dist/node_modules/@allyhub/image-draw/dist/tone.d.ts +53 -0
  93. package/dist/node_modules/@allyhub/image-draw/dist/tone.js +2 -0
  94. package/dist/node_modules/@allyhub/image-draw/package.json +14 -0
  95. package/dist/node_modules/@allyhub/image-measure/LICENSE +241 -0
  96. package/dist/node_modules/@allyhub/image-measure/dist/contrast.d.ts +43 -0
  97. package/dist/node_modules/@allyhub/image-measure/dist/contrast.js +2 -0
  98. package/dist/node_modules/@allyhub/image-measure/dist/layout.d.ts +186 -0
  99. package/dist/node_modules/@allyhub/image-measure/dist/layout.js +5 -0
  100. package/dist/node_modules/@allyhub/image-measure/package.json +14 -0
  101. package/dist/node_modules/@allyhub/image-sdk/LICENSE +241 -0
  102. package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.d.ts +13 -0
  103. package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.js +2 -0
  104. package/dist/{define.d.ts → node_modules/@allyhub/image-sdk/dist/define.d.ts} +21 -4
  105. package/dist/node_modules/@allyhub/image-sdk/dist/define.js +2 -0
  106. package/dist/node_modules/@allyhub/image-sdk/dist/dom.d.ts +210 -0
  107. package/dist/node_modules/@allyhub/image-sdk/dist/dom.js +2 -0
  108. package/dist/node_modules/@allyhub/image-sdk/dist/fill.d.ts +21 -0
  109. package/dist/node_modules/@allyhub/image-sdk/dist/fill.js +2 -0
  110. package/dist/node_modules/@allyhub/image-sdk/dist/group.d.ts +17 -0
  111. package/dist/node_modules/@allyhub/image-sdk/dist/group.js +2 -0
  112. package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +166 -0
  113. package/dist/node_modules/@allyhub/image-sdk/dist/index.js +2 -0
  114. package/dist/node_modules/@allyhub/image-sdk/dist/media.d.ts +6 -0
  115. package/dist/node_modules/@allyhub/image-sdk/dist/media.js +2 -0
  116. package/dist/{messages.d.ts → node_modules/@allyhub/image-sdk/dist/messages.d.ts} +1 -1
  117. package/dist/node_modules/@allyhub/image-sdk/dist/picture.d.ts +59 -0
  118. package/dist/node_modules/@allyhub/image-sdk/dist/picture.js +2 -0
  119. package/dist/{props.d.ts → node_modules/@allyhub/image-sdk/dist/props.d.ts} +4 -4
  120. package/dist/node_modules/@allyhub/image-sdk/dist/shape.d.ts +34 -0
  121. package/dist/node_modules/@allyhub/image-sdk/dist/shape.js +2 -0
  122. package/dist/node_modules/@allyhub/image-sdk/dist/stack.d.ts +16 -0
  123. package/dist/node_modules/@allyhub/image-sdk/dist/stack.js +2 -0
  124. package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.d.ts +38 -0
  125. package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.js +2 -0
  126. package/dist/{written.js → node_modules/@allyhub/image-sdk/dist/written.js} +1 -1
  127. package/dist/node_modules/@allyhub/image-sdk/package.json +19 -0
  128. package/dist/node_modules/@allyhub/measure/LICENSE +241 -0
  129. package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +195 -0
  130. package/dist/node_modules/@allyhub/measure/dist/compare.js +2 -0
  131. package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +8 -0
  132. package/dist/node_modules/@allyhub/measure/dist/grain.js +2 -0
  133. package/dist/node_modules/@allyhub/measure/dist/image.d.ts +16 -0
  134. package/dist/node_modules/@allyhub/measure/dist/image.js +2 -0
  135. package/dist/node_modules/@allyhub/measure/dist/index.d.ts +4 -0
  136. package/dist/node_modules/@allyhub/measure/dist/index.js +2 -0
  137. package/dist/node_modules/@allyhub/measure/package.json +13 -0
  138. package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.d.ts +4 -1
  139. package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.js +1 -1
  140. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.d.ts +15 -1
  141. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
  142. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  143. package/dist/node_modules/@allyhub/piece/LICENSE +241 -0
  144. package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.d.ts +1 -9
  145. package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.js +1 -1
  146. package/dist/node_modules/@allyhub/piece/dist/context.d.ts +39 -0
  147. package/dist/node_modules/@allyhub/piece/dist/context.js +2 -0
  148. package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.d.ts +2 -2
  149. package/dist/node_modules/@allyhub/{video-core → piece}/dist/export.d.ts +27 -10
  150. package/dist/node_modules/@allyhub/piece/dist/export.js +2 -0
  151. package/dist/node_modules/@allyhub/{video-core → piece}/dist/formats.d.ts +12 -68
  152. package/dist/node_modules/@allyhub/piece/dist/formats.js +2 -0
  153. package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +104 -0
  154. package/dist/node_modules/@allyhub/piece/dist/index.d.ts +26 -0
  155. package/dist/node_modules/@allyhub/piece/dist/index.js +2 -0
  156. package/dist/node_modules/@allyhub/piece/dist/layer-style.d.ts +1558 -0
  157. package/dist/node_modules/@allyhub/piece/dist/layer-style.js +2 -0
  158. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +389 -0
  159. package/dist/node_modules/@allyhub/piece/dist/layer.js +2 -0
  160. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +421 -0
  161. package/dist/node_modules/@allyhub/piece/dist/layout.js +2 -0
  162. package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.d.ts +1 -1
  163. package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.d.ts +39 -9
  164. package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.js +1 -1
  165. package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.d.ts +6 -0
  166. package/dist/node_modules/@allyhub/piece/dist/names.d.ts +26 -0
  167. package/dist/node_modules/@allyhub/piece/dist/names.js +2 -0
  168. package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +21 -0
  169. package/dist/node_modules/@allyhub/piece/dist/page/console.js +2 -0
  170. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +3 -0
  171. package/dist/node_modules/@allyhub/piece/dist/page/index.js +2 -0
  172. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +4 -0
  173. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +2 -0
  174. package/dist/node_modules/@allyhub/piece/dist/picture.d.ts +62 -0
  175. package/dist/node_modules/@allyhub/piece/dist/picture.js +2 -0
  176. package/dist/node_modules/@allyhub/piece/dist/piece.d.ts +15 -0
  177. package/dist/node_modules/@allyhub/piece/dist/piece.js +2 -0
  178. package/dist/node_modules/@allyhub/{video-core → piece}/dist/script.d.ts +9 -4
  179. package/dist/node_modules/@allyhub/piece/dist/script.js +2 -0
  180. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +131 -0
  181. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +285 -0
  182. package/dist/node_modules/@allyhub/piece/dist/stage.js +2 -0
  183. package/dist/node_modules/@allyhub/piece/dist/version.d.ts +15 -0
  184. package/dist/node_modules/@allyhub/piece/dist/version.js +2 -0
  185. package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.d.ts +1 -20
  186. package/dist/node_modules/@allyhub/piece/package.json +18 -0
  187. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +139 -0
  188. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  189. package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +3 -10
  190. package/dist/node_modules/@allyhub/protocol/dist/app.js +1 -1
  191. package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +12 -1
  192. package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
  193. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +2 -0
  194. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  195. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +232 -132
  196. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  197. package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -0
  198. package/dist/node_modules/@allyhub/protocol/dist/files.js +1 -1
  199. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +22 -9
  200. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  201. package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +8 -0
  202. package/dist/node_modules/@allyhub/protocol/dist/image.js +2 -0
  203. package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +5 -0
  204. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  205. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
  206. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +98 -0
  207. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +2 -0
  208. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +273 -0
  209. package/dist/node_modules/@allyhub/protocol/dist/mail.js +2 -0
  210. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +26 -0
  211. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  212. package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +59 -0
  213. package/dist/node_modules/@allyhub/protocol/dist/peer.js +2 -0
  214. package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +21 -0
  215. package/dist/node_modules/@allyhub/protocol/dist/place.js +2 -0
  216. package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +125 -0
  217. package/dist/node_modules/@allyhub/protocol/dist/presence.js +2 -0
  218. package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +1 -1
  219. package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
  220. package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +35 -0
  221. package/dist/node_modules/@allyhub/protocol/dist/shape.js +2 -0
  222. package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +2 -8
  223. package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
  224. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +70 -40
  225. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  226. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +224 -177
  227. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  228. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  229. package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
  230. package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +14 -0
  231. package/dist/node_modules/@allyhub/runtimes/dist/declared.js +2 -0
  232. package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +15 -0
  233. package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.js +2 -0
  234. package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +2 -0
  235. package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
  236. package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
  237. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +1 -0
  238. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
  239. package/dist/node_modules/@allyhub/runtimes/manifest.json +0 -82
  240. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  241. package/dist/node_modules/@allyhub/scenery/dist/define.d.ts +2 -0
  242. package/dist/node_modules/@allyhub/scenery/dist/define.js +1 -1
  243. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  244. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  245. package/dist/node_modules/@allyhub/sheet/dist/api/code.d.ts +4 -4
  246. package/dist/node_modules/@allyhub/sheet/dist/api/code.js +1 -1
  247. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +15 -11
  248. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  249. package/dist/node_modules/@allyhub/sheet/dist/calc/server.d.ts +1 -1
  250. package/dist/node_modules/@allyhub/sheet/dist/export.js +1 -1
  251. package/dist/node_modules/@allyhub/sheet/dist/file.d.ts +5 -0
  252. package/dist/node_modules/@allyhub/sheet/dist/file.js +1 -1
  253. package/dist/node_modules/@allyhub/sheet/dist/generated.d.ts +5 -19
  254. package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
  255. package/dist/node_modules/@allyhub/sheet/dist/import.d.ts +3 -1
  256. package/dist/node_modules/@allyhub/sheet/dist/import.js +1 -1
  257. package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +3 -4
  258. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  259. package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +76 -1
  260. package/dist/node_modules/@allyhub/sheet/dist/patch.d.ts +1 -1
  261. package/dist/node_modules/@allyhub/sheet/dist/patch.js +1 -1
  262. package/dist/node_modules/@allyhub/sheet/dist/sdk.d.ts +2 -0
  263. package/dist/node_modules/@allyhub/sheet/dist/sdk.js +2 -0
  264. package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +6 -6
  265. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  266. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +2 -0
  267. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  268. package/dist/node_modules/@allyhub/sheet/package.json +5 -1
  269. package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +23 -7
  270. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  271. package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +44 -4
  272. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  273. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  274. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +18 -1
  275. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  276. package/dist/node_modules/@allyhub/slides-core/dist/code.d.ts +1 -1
  277. package/dist/node_modules/@allyhub/slides-core/dist/connect.d.ts +62 -0
  278. package/dist/node_modules/@allyhub/slides-core/dist/connect.js +2 -0
  279. package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +208 -0
  280. package/dist/node_modules/@allyhub/slides-core/dist/fact.js +2 -0
  281. package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +4 -4
  282. package/dist/node_modules/@allyhub/slides-core/dist/file.js +2 -2
  283. package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +2 -0
  284. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  285. package/dist/node_modules/@allyhub/slides-core/dist/measure.d.ts +4 -2
  286. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  287. package/dist/node_modules/@allyhub/slides-core/dist/merge.d.ts +5 -5
  288. package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
  289. package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +19 -2
  290. package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +1 -1
  291. package/dist/node_modules/@allyhub/slides-core/dist/path.d.ts +1 -1
  292. package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +17 -10
  293. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  294. package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +18 -0
  295. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +2 -0
  296. package/dist/node_modules/@allyhub/slides-core/dist/stage.d.ts +28 -11
  297. package/dist/node_modules/@allyhub/slides-core/dist/units.d.ts +3 -6
  298. package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
  299. package/dist/node_modules/@allyhub/slides-core/package.json +5 -1
  300. package/dist/node_modules/@allyhub/video-core/dist/audio-types.d.ts +1 -2
  301. package/dist/node_modules/@allyhub/video-core/dist/captions.d.ts +1 -10
  302. package/dist/node_modules/@allyhub/video-core/dist/captions.js +1 -1
  303. package/dist/node_modules/@allyhub/video-core/dist/check.d.ts +62 -0
  304. package/dist/node_modules/@allyhub/video-core/dist/check.js +2 -0
  305. package/dist/node_modules/@allyhub/video-core/dist/cut-report.d.ts +2 -2
  306. package/dist/node_modules/@allyhub/video-core/dist/cut-report.js +1 -1
  307. package/dist/node_modules/@allyhub/video-core/dist/edits.d.ts +3 -3
  308. package/dist/node_modules/@allyhub/video-core/dist/edits.js +1 -1
  309. package/dist/node_modules/@allyhub/video-core/dist/fact.d.ts +21 -762
  310. package/dist/node_modules/@allyhub/video-core/dist/fact.js +1 -1
  311. package/dist/node_modules/@allyhub/video-core/dist/footage-motion.d.ts +3 -2
  312. package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
  313. package/dist/node_modules/@allyhub/video-core/dist/index.d.ts +3 -17
  314. package/dist/node_modules/@allyhub/video-core/dist/index.js +1 -1
  315. package/dist/node_modules/@allyhub/video-core/dist/measure.d.ts +72 -423
  316. package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -4
  317. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.d.ts +44 -0
  318. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +2 -0
  319. package/dist/node_modules/@allyhub/video-core/dist/motion.d.ts +1 -1
  320. package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +22 -430
  321. package/dist/node_modules/@allyhub/video-core/dist/piece.js +1 -1
  322. package/dist/node_modules/@allyhub/video-core/dist/placement.d.ts +1 -1
  323. package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +6 -12
  324. package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
  325. package/dist/node_modules/@allyhub/video-core/dist/script-edit.d.ts +11 -6
  326. package/dist/node_modules/@allyhub/video-core/dist/script-edit.js +1 -1
  327. package/dist/node_modules/@allyhub/video-core/dist/seams.d.ts +2 -3
  328. package/dist/node_modules/@allyhub/video-core/dist/sound-under.d.ts +2 -2
  329. package/dist/node_modules/@allyhub/video-core/dist/sound-under.js +1 -1
  330. package/dist/node_modules/@allyhub/video-core/dist/speech.d.ts +2 -4
  331. package/dist/node_modules/@allyhub/video-core/dist/speech.js +2 -2
  332. package/dist/node_modules/@allyhub/video-core/dist/stage.d.ts +52 -0
  333. package/dist/node_modules/@allyhub/video-core/dist/stage.js +2 -0
  334. package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +18 -136
  335. package/dist/node_modules/@allyhub/video-core/dist/timeline.js +1 -1
  336. package/dist/node_modules/@allyhub/video-core/dist/timing.d.ts +3 -3
  337. package/dist/node_modules/@allyhub/video-core/dist/timing.js +1 -1
  338. package/dist/node_modules/@allyhub/video-core/dist/transcript.d.ts +2 -2
  339. package/dist/node_modules/@allyhub/video-core/dist/transcript.js +1 -1
  340. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  341. package/dist/node_modules/@allyhub/video-sdk/LICENSE +241 -0
  342. package/dist/node_modules/@allyhub/video-sdk/NOTICE +118 -0
  343. package/dist/{free.d.ts → node_modules/@allyhub/video-sdk/dist/free.d.ts} +14 -10
  344. package/dist/node_modules/@allyhub/video-sdk/dist/free.js +2 -0
  345. package/dist/node_modules/@allyhub/video-sdk/dist/index.d.ts +28 -0
  346. package/dist/node_modules/@allyhub/video-sdk/dist/index.js +2 -0
  347. package/dist/{input.d.ts → node_modules/@allyhub/video-sdk/dist/input.d.ts} +76 -22
  348. package/dist/node_modules/@allyhub/video-sdk/dist/input.js +2 -0
  349. package/dist/{module.d.ts → node_modules/@allyhub/video-sdk/dist/module.d.ts} +6 -4
  350. package/dist/node_modules/@allyhub/video-sdk/dist/module.js +2 -0
  351. package/dist/{parts.d.ts → node_modules/@allyhub/video-sdk/dist/parts.d.ts} +15 -6
  352. package/dist/node_modules/@allyhub/video-sdk/dist/parts.js +2 -0
  353. package/dist/{piece.d.ts → node_modules/@allyhub/video-sdk/dist/piece.d.ts} +26 -16
  354. package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +2 -0
  355. package/dist/node_modules/@allyhub/video-sdk/dist/route.d.ts +46 -0
  356. package/dist/node_modules/@allyhub/video-sdk/dist/route.js +2 -0
  357. package/dist/node_modules/@allyhub/video-sdk/dist/scenery.d.ts +2 -0
  358. package/dist/node_modules/@allyhub/video-sdk/dist/scenery.js +2 -0
  359. package/dist/node_modules/@allyhub/video-sdk/package.json +19 -0
  360. package/dist/scenery.d.ts +1 -1
  361. package/dist/scenery.js +1 -1
  362. package/dist/sheets.d.ts +1 -1
  363. package/dist/sheets.js +1 -1
  364. package/dist/slides.d.ts +1 -9
  365. package/dist/slides.js +1 -1
  366. package/docs/README.md +8 -6
  367. package/docs/batches.md +5 -5
  368. package/docs/contract.md +2 -2
  369. package/docs/defaults.md +278 -20
  370. package/docs/docs.md +77 -63
  371. package/docs/footage.md +7 -7
  372. package/docs/image.md +165 -0
  373. package/docs/layers.md +22 -13
  374. package/docs/modeling.md +4 -4
  375. package/docs/pictures.md +65 -0
  376. package/docs/project.md +51 -31
  377. package/docs/scenery.md +11 -11
  378. package/docs/sheets.md +26 -25
  379. package/docs/slides.md +73 -65
  380. package/docs/sound.md +3 -3
  381. package/docs/speech.md +8 -8
  382. package/docs/video.md +16 -13
  383. package/docs/websites.md +4 -4
  384. package/package.json +7 -2
  385. package/dist/define.js +0 -2
  386. package/dist/free.js +0 -2
  387. package/dist/input.js +0 -2
  388. package/dist/module.js +0 -2
  389. package/dist/node_modules/@allyhub/formats/dist/data/comments.d.ts +0 -94
  390. package/dist/node_modules/@allyhub/formats/dist/data/comments.js +0 -2
  391. package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package-lock.json +0 -227
  392. package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package.json +0 -8
  393. package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package-lock.json +0 -105
  394. package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package.json +0 -8
  395. package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package-lock.json +0 -128
  396. package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package.json +0 -9
  397. package/dist/node_modules/@allyhub/video-core/dist/export.js +0 -2
  398. package/dist/node_modules/@allyhub/video-core/dist/formats.js +0 -2
  399. package/dist/node_modules/@allyhub/video-core/dist/gen.d.ts +0 -37
  400. package/dist/node_modules/@allyhub/video-core/dist/problem.d.ts +0 -278
  401. package/dist/node_modules/@allyhub/video-core/dist/problem.js +0 -2
  402. package/dist/node_modules/@allyhub/video-core/dist/script.js +0 -2
  403. package/dist/node_modules/@allyhub/video-core/dist/source.d.ts +0 -7
  404. package/dist/parts.js +0 -2
  405. package/dist/piece.js +0 -2
  406. /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.d.ts +0 -0
  407. /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.js +0 -0
  408. /package/dist/{fit.d.ts → node_modules/@allyhub/image-sdk/dist/fit.d.ts} +0 -0
  409. /package/dist/{fit.js → node_modules/@allyhub/image-sdk/dist/fit.js} +0 -0
  410. /package/dist/{messages.js → node_modules/@allyhub/image-sdk/dist/messages.js} +0 -0
  411. /package/dist/{props.js → node_modules/@allyhub/image-sdk/dist/props.js} +0 -0
  412. /package/dist/{text.d.ts → node_modules/@allyhub/image-sdk/dist/text.d.ts} +0 -0
  413. /package/dist/{text.js → node_modules/@allyhub/image-sdk/dist/text.js} +0 -0
  414. /package/dist/{written.d.ts → node_modules/@allyhub/image-sdk/dist/written.d.ts} +0 -0
  415. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.js +0 -0
  416. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.d.ts +0 -0
  417. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.d.ts +0 -0
  418. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.js +0 -0
  419. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.js +0 -0
  420. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/gen.js +0 -0
  421. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.js +0 -0
  422. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.d.ts +0 -0
  423. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.js +0 -0
  424. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.d.ts +0 -0
  425. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.js +0 -0
  426. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.js +0 -0
  427. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/source.js +0 -0
  428. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.js +0 -0
  429. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.d.ts +0 -0
  430. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.js +0 -0
  431. /package/dist/{anim.d.ts → node_modules/@allyhub/video-sdk/dist/anim.d.ts} +0 -0
  432. /package/dist/{anim.js → node_modules/@allyhub/video-sdk/dist/anim.js} +0 -0
  433. /package/dist/{noise.d.ts → node_modules/@allyhub/video-sdk/dist/noise.d.ts} +0 -0
  434. /package/dist/{noise.js → node_modules/@allyhub/video-sdk/dist/noise.js} +0 -0
  435. /package/dist/{paths.d.ts → node_modules/@allyhub/video-sdk/dist/paths.d.ts} +0 -0
  436. /package/dist/{paths.js → node_modules/@allyhub/video-sdk/dist/paths.js} +0 -0
  437. /package/dist/{phone.d.ts → node_modules/@allyhub/video-sdk/dist/phone.d.ts} +0 -0
  438. /package/dist/{phone.js → node_modules/@allyhub/video-sdk/dist/phone.js} +0 -0
@@ -4,7 +4,9 @@ export { bundledEnv, type BundledOptions } from "./bundled.js";
4
4
  export { RuntimeError, type RuntimeErrorCode } from "./errors.js";
5
5
  export { cacheHome } from "./home.js";
6
6
  export { shippedManifest } from "./manifest.js";
7
+ export { declareRuntimes, declaredRuntimes, knownManifest, runtimeExtension, } from "./declared.js";
7
8
  export { download, sha256Of, DOWNLOAD_RETRIES, DOWNLOAD_RETRY_DELAY_MS, DOWNLOAD_STALL_MS, type DownloadOptions, type DownloadTimings, } from "./download.js";
8
9
  export { withLock } from "./lock.js";
9
10
  export { unzip, untgz } from "./unpack.js";
11
+ export { ffmpegOf, runFfmpegWith, type FfmpegOptions } from "./ffmpeg.js";
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{binVariable,createRuntimes}from"./runtimes.js";export{createPackages,npmCi,NPM_FETCH_TIMEOUT_MS,NPM_STALL_MS}from"./packages.js";export{bundledEnv}from"./bundled.js";export{RuntimeError}from"./errors.js";export{cacheHome}from"./home.js";export{shippedManifest}from"./manifest.js";export{download,sha256Of,DOWNLOAD_RETRIES,DOWNLOAD_RETRY_DELAY_MS,DOWNLOAD_STALL_MS}from"./download.js";export{withLock}from"./lock.js";export{unzip,untgz}from"./unpack.js";
2
+ export{binVariable,createRuntimes}from"./runtimes.js";export{createPackages,npmCi,NPM_FETCH_TIMEOUT_MS,NPM_STALL_MS}from"./packages.js";export{bundledEnv}from"./bundled.js";export{RuntimeError}from"./errors.js";export{cacheHome}from"./home.js";export{shippedManifest}from"./manifest.js";export{declareRuntimes,declaredRuntimes,knownManifest,runtimeExtension}from"./declared.js";export{download,sha256Of,DOWNLOAD_RETRIES,DOWNLOAD_RETRY_DELAY_MS,DOWNLOAD_STALL_MS}from"./download.js";export{withLock}from"./lock.js";export{unzip,untgz}from"./unpack.js";export{ffmpegOf,runFfmpegWith}from"./ffmpeg.js";
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{spawn as R}from"node:child_process";import{createHash as I}from"node:crypto";import{existsSync as M,readFileSync as T}from"node:fs";import{copyFile as P,mkdir as j,readdir as b,readFile as A,rename as D,rm as $,stat as H,writeFile as C}from"node:fs/promises";import{createRequire as F}from"node:module";import{delimiter as z,join as o}from"node:path";import{fileURLToPath as U,pathToFileURL as J}from"node:url";import{DOWNLOAD_STALL_MS as W}from"./download.js";import{RuntimeError as x}from"./errors.js";import{cacheHome as G}from"./home.js";import{partialOf as q,sweepPartials as B,withLock as K}from"./lock.js";import{nodeCommand as V}from"./node-program.js";import{createRuntimes as X}from"./runtimes.js";const E=".allyhub-package.json",Y=U(new URL("../pins/",import.meta.url));export const NPM_FETCH_TIMEOUT_MS=W,NPM_STALL_MS=12e4;async function Q(n){const s=o(n,"node_modules","onnxruntime-node","bin","napi-v6");for(const i of await b(s)){if(i!==process.platform){await $(o(s,i),{recursive:!0,force:!0});continue}for(const l of await b(o(s,i)))l!==process.arch&&await $(o(s,i,l),{recursive:!0,force:!0})}if(process.platform!=="darwin")return;const a=o(s,"darwin",process.arch);for(const i of await b(a))/^libonnxruntime\.\d+\.\d+\.\d+\.dylib$/u.test(i)&&await $(o(a,i),{force:!0})}const Z={"onnxruntime-node":Q};export const NPX_SETTING=/^npm_config_(global|prefix|location|cache|.*_prefix)/iu;export function npmProblem(n,s){return n.split(`
3
- `).map(i=>i.replace(/^npm (error|ERR!)\s*/u,"").trim()).find(i=>i!==""&&!/^(code|errno|syscall|path|type|A complete log|Exit handler|This is an error with npm|<https)/u.test(i))??`npm ended with code ${String(s)}`}const tt=(n,s)=>(s.PATH??"").split(z).some(a=>a!==""&&M(o(a,n)));export async function findNpm(n,s){const a=n.ALLYHUB_NPM??n.npm_execpath;if(a?.endsWith(".js"))return{command:V(n),script:[a]};if(tt("npm",n))return{command:"npm",script:[]};const i=await s(),{node:l,npm:d}=i;if(!l||!d)throw new Error("AllyHub's Node has no npm");return{command:l,script:[d]}}async function et(n,s){const a=await b(n,{recursive:!0}).catch(()=>[]);let i=0;for(const l of await b(s).catch(()=>[]))i+=await H(o(s,l)).then(d=>d.size,()=>0);return`${String(a.length)}:${String(i)}`}export const npmCi=async(n,{home:s,signal:a,fetchTimeoutMs:i=NPM_FETCH_TIMEOUT_MS,stallMs:l=NPM_STALL_MS,omit:d})=>{const O=await findNpm(process.env,async()=>(await X({home:s}).ensure("node",{signal:a})).bins),m=Object.fromEntries(Object.entries(process.env).filter(([p])=>!NPX_SETTING.test(p))),w=o(s,"packages",".npm"),h=["ci","--ignore-scripts","--omit=dev","--no-audit","--no-fund","--omit=peer",...(d??[]).map(p=>`--omit=${p}`),"--loglevel=error","--fetch-retries=1",`--fetch-timeout=${String(i)}`];await new Promise((p,g)=>{const v=R(O.command,[...O.script,...h],{cwd:n,env:{...m,npm_config_cache:w},stdio:["ignore","ignore","pipe"],...a?{signal:a}:{}});let k="",y=Date.now(),S="",_=!1,t=!1;const e=setInterval(()=>{_||t||(_=!0,et(n,o(w,"_cacache","tmp")).then(r=>{r!==S?(S=r,y=Date.now()):Date.now()-y>=l&&(t=!0,v.kill(),setTimeout(()=>v.kill("SIGKILL"),5e3).unref())}).finally(()=>{_=!1}))},Math.max(20,Math.min(5e3,l/4)));v.stderr.on("data",r=>{y=Date.now(),k=`${k}${r.toString()}`.slice(-1e3)}),v.on("error",r=>{clearInterval(e),g(r)}),v.on("close",r=>{clearInterval(e),t?g(new x("install",`npm made no progress for ${String(l/1e3)} s and was stopped${k.trim()?`; it said: ${npmProblem(k,r)}`:""}`)):r===0?p():g(new Error(npmProblem(k,r)))})})};export function createPackages(n={}){const s=n.env??process.env,a=n.home??G(s),i=n.pins??Y,l=n.install??npmCi,{fetchTimeoutMs:d,stallMs:O}=n,m=o(a,"packages"),w=t=>{const e=o(i,t);let r,c;try{r=JSON.parse(T(o(e,"package.json"),"utf8")),c=T(o(e,"package-lock.json"),"utf8")}catch{throw new x("unknown-package",`AllyHub has no package "${t}".`)}const u=r.dependencies??{},f=u[t]??r.version;if(!f)throw new x("unknown-package",`The pin of "${t}" does not name it.`);return{version:f,holds:u,lock:I("sha256").update(c).digest("hex"),dir:e,size:r.allyhubSize??0,omit:r.allyhubOmit??[]}},h=(t,e)=>o(m,`${t}@${e.version}`),p=(t,e)=>{try{const r=JSON.parse(T(o(h(t,e),E),"utf8"));return r.version===e.version&&r.lock===e.lock}catch{return!1}},g=(t,e)=>({name:t,version:e.version,dir:h(t,e)}),v=async(t,e,r)=>{const c=h(t,e),u=q(c);await j(u,{recursive:!0});try{await P(o(e.dir,"package.json"),o(u,"package.json")),await P(o(e.dir,"package-lock.json"),o(u,"package-lock.json")),await l(u,{home:a,signal:r,fetchTimeoutMs:d,stallMs:O,omit:e.omit});for(const[f,L]of Object.entries(e.holds)){const N=JSON.parse(await A(o(u,"node_modules",f,"package.json"),"utf8"));if(N.version!==L)throw new Error(`it holds ${f} ${String(N.version)}, not ${L}`)}await Z[t]?.(u),await C(o(u,E),`${JSON.stringify({version:e.version,lock:e.lock,at:new Date().toISOString()})}
4
- `),await $(c,{recursive:!0,force:!0}),await D(u,c),await k(t,e)}catch(f){throw await $(u,{recursive:!0,force:!0}),r?.aborted?new x("cancelled",`Stopped getting ${t}.`,{cause:f}):new x("install",`Could not get ${t} ${e.version} (${f instanceof Error?f.message:String(f)}). Check the connection and run it again.`,{cause:f})}},k=async(t,e)=>{const r=`${t}@${e.version}`;for(const c of await b(m))c.startsWith(`${t}@`)&&c!==r&&!c.startsWith(`${r}.`)&&await $(o(m,c),{recursive:!0,force:!0})},y=t=>{const e=w(t);return p(t,e)?g(t,e):void 0},S=(t,e)=>F(o(t,"package.json")).resolve(e),_=async(t,e={})=>{const r=w(t);return p(t,r)||(await j(m,{recursive:!0}).catch(c=>{throw new x("install",`Could not get ${t} ${r.version}: AllyHub cannot write to ${m}.`,{cause:c})}),await K(`${h(t,r)}.lock`,async()=>{p(t,r)||(await B(m,t),e.onFetch?.(t),await v(t,r,e.signal))},{signal:e.signal})),g(t,r)};return{home:a,locate:y,ensure:_,size:t=>w(t).size,entry(t){const e=y(t);return e?S(e.dir,t):void 0},resolve(t,e){const r=y(t);return r?S(r.dir,e):void 0},async load(t,e){const{dir:r}=await _(t,e),c=S(r,e?.module??t);return await import(J(c).href)},async remove(t){await $(h(t,w(t)),{recursive:!0,force:!0})}}}
2
+ import{spawn as I}from"node:child_process";import{createHash as R}from"node:crypto";import{existsSync as A,readFileSync as x}from"node:fs";import{copyFile as P,mkdir as j,readdir as T,readFile as M,rename as D,rm as b,stat as H,writeFile as C}from"node:fs/promises";import{createRequire as F}from"node:module";import{delimiter as z,join as n}from"node:path";import{fileURLToPath as U,pathToFileURL as J}from"node:url";import{DOWNLOAD_STALL_MS as W}from"./download.js";import{RuntimeError as _}from"./errors.js";import{cacheHome as G}from"./home.js";import{partialOf as q,sweepPartials as B,withLock as K}from"./lock.js";import{nodeCommand as V}from"./node-program.js";import{createRuntimes as X}from"./runtimes.js";const E=".allyhub-package.json",Y=U(new URL("../pins/",import.meta.url));export const NPM_FETCH_TIMEOUT_MS=W,NPM_STALL_MS=12e4,NPX_SETTING=/^npm_config_(global|prefix|location|cache|.*_prefix)/iu;export function npmProblem(o,a){return o.split(`
3
+ `).map(c=>c.replace(/^npm (error|ERR!)\s*/u,"").trim()).find(c=>c!==""&&!/^(code|errno|syscall|path|type|A complete log|Exit handler|This is an error with npm|<https)/u.test(c))??`npm ended with code ${String(a)}`}const Q=(o,a)=>(a.PATH??"").split(z).some(s=>s!==""&&A(n(s,o)));export async function findNpm(o,a){const s=o.ALLYHUB_NPM??o.npm_execpath;if(s?.endsWith(".js"))return{command:V(o),script:[s]};if(Q("npm",o))return{command:"npm",script:[]};const c=await a(),{node:p,npm:d}=c;if(!p||!d)throw new Error("AllyHub's Node has no npm");return{command:p,script:[d]}}async function Z(o,a){const s=await T(o,{recursive:!0}).catch(()=>[]);let c=0;for(const p of await T(a).catch(()=>[]))c+=await H(n(a,p)).then(d=>d.size,()=>0);return`${String(s.length)}:${String(c)}`}export const npmCi=async(o,{home:a,signal:s,fetchTimeoutMs:c=NPM_FETCH_TIMEOUT_MS,stallMs:p=NPM_STALL_MS,omit:d})=>{const O=await findNpm(process.env,async()=>(await X({home:a}).ensure("node",{signal:s})).bins),m=Object.fromEntries(Object.entries(process.env).filter(([f])=>!NPX_SETTING.test(f))),h=n(a,"packages",".npm"),w=["ci","--ignore-scripts","--omit=dev","--no-audit","--no-fund","--omit=peer",...(d??[]).map(f=>`--omit=${f}`),"--loglevel=error","--fetch-retries=1",`--fetch-timeout=${String(c)}`];await new Promise((f,g)=>{const v=I(O.command,[...O.script,...w],{cwd:o,env:{...m,npm_config_cache:h},stdio:["ignore","ignore","pipe"],...s?{signal:s}:{}});let k="",y=Date.now(),$="",S=!1,t=!1;const e=setInterval(()=>{S||t||(S=!0,Z(o,n(h,"_cacache","tmp")).then(r=>{r!==$?($=r,y=Date.now()):Date.now()-y>=p&&(t=!0,v.kill(),setTimeout(()=>v.kill("SIGKILL"),5e3).unref())}).finally(()=>{S=!1}))},Math.max(20,Math.min(5e3,p/4)));v.stderr.on("data",r=>{y=Date.now(),k=`${k}${r.toString()}`.slice(-1e3)}),v.on("error",r=>{clearInterval(e),g(r)}),v.on("close",r=>{clearInterval(e),t?g(new _("install",`npm made no progress for ${String(p/1e3)} s and was stopped${k.trim()?`; it said: ${npmProblem(k,r)}`:""}`)):r===0?f():g(new Error(npmProblem(k,r)))})})};export function createPackages(o={}){const a=o.env??process.env,s=o.home??G(a),c=o.pins??Y,p=o.install??npmCi,{fetchTimeoutMs:d,stallMs:O}=o,m=n(s,"packages"),h=t=>{const e=n(c,t);let r,i;try{r=JSON.parse(x(n(e,"package.json"),"utf8")),i=x(n(e,"package-lock.json"),"utf8")}catch{throw new _("unknown-package",`AllyHub has no package "${t}".`)}const l=r.dependencies??{},u=l[t]??r.version;if(!u)throw new _("unknown-package",`The pin of "${t}" does not name it.`);return{version:u,holds:l,lock:R("sha256").update(i).digest("hex"),dir:e,size:r.allyhubSize??0,omit:r.allyhubOmit??[]}},w=(t,e)=>n(m,`${t}@${e.version}`),f=(t,e)=>{try{const r=JSON.parse(x(n(w(t,e),E),"utf8"));return r.version===e.version&&r.lock===e.lock}catch{return!1}},g=(t,e)=>({name:t,version:e.version,dir:w(t,e)}),v=async(t,e,r)=>{const i=w(t,e),l=q(i);await j(l,{recursive:!0});try{await P(n(e.dir,"package.json"),n(l,"package.json")),await P(n(e.dir,"package-lock.json"),n(l,"package-lock.json")),await p(l,{home:s,signal:r,fetchTimeoutMs:d,stallMs:O,omit:e.omit});for(const[u,L]of Object.entries(e.holds)){const N=JSON.parse(await M(n(l,"node_modules",u,"package.json"),"utf8"));if(N.version!==L)throw new Error(`it holds ${u} ${String(N.version)}, not ${L}`)}await C(n(l,E),`${JSON.stringify({version:e.version,lock:e.lock,at:new Date().toISOString()})}
4
+ `),await b(i,{recursive:!0,force:!0}),await D(l,i),await k(t,e)}catch(u){throw await b(l,{recursive:!0,force:!0}),r?.aborted?new _("cancelled",`Stopped getting ${t}.`,{cause:u}):new _("install",`Could not get ${t} ${e.version} (${u instanceof Error?u.message:String(u)}). Check the connection and run it again.`,{cause:u})}},k=async(t,e)=>{const r=`${t}@${e.version}`;for(const i of await T(m))i.startsWith(`${t}@`)&&i!==r&&!i.startsWith(`${r}.`)&&await b(n(m,i),{recursive:!0,force:!0})},y=t=>{const e=h(t);return f(t,e)?g(t,e):void 0},$=(t,e)=>F(n(t,"package.json")).resolve(e),S=async(t,e={})=>{const r=h(t);return f(t,r)||(await j(m,{recursive:!0}).catch(i=>{throw new _("install",`Could not get ${t} ${r.version}: AllyHub cannot write to ${m}.`,{cause:i})}),await K(`${w(t,r)}.lock`,async()=>{f(t,r)||(await B(m,t),e.onFetch?.(t),await v(t,r,e.signal))},{signal:e.signal})),g(t,r)};return{home:s,locate:y,ensure:S,size:t=>h(t).size,entry(t){const e=y(t);return e?$(e.dir,t):void 0},resolve(t,e){const r=y(t);return r?$(r.dir,e):void 0},async load(t,e){const{dir:r}=await S(t,e),i=$(r,e?.module??t);return await import(J(i).href)},async remove(t){await b(w(t,h(t)),{recursive:!0,force:!0})}}}
@@ -3,6 +3,7 @@ import { type DownloadTimings } from "./download.js";
3
3
  export interface RuntimesOptions {
4
4
  /** The cache folder (default: the system's, `cacheHome`). */
5
5
  home?: string;
6
+ /** The pins it knows (default: the core's, then those the extensions in this process declared). */
6
7
  manifest?: RuntimeManifest;
7
8
  /** The platform (default: this process's). */
8
9
  platform?: Platform | undefined;
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chmod as T,mkdir as E,readFile as W,rename as J,rm as z,writeFile as _}from"node:fs/promises";import{dirname as U,join as d}from"node:path";import{binsOf as A,filesFor as C,platformOf as V}from"@allyhub/protocol";import{download as Y,sha256Of as q}from"./download.js";import{RuntimeError as g}from"./errors.js";import{cacheHome as G}from"./home.js";import{partialOf as K,sweepPartials as Q,withLock as X}from"./lock.js";import{shippedManifest as Z}from"./manifest.js";import{inside as D,native as tt,undmg as et,untgz as rt,unzip as nt}from"./unpack.js";const F=".allyhub-runtime.json";export const binVariable=o=>`ALLYHUB_${o.toUpperCase().replaceAll("-","_")}`;const L=o=>`${String(Math.max(1,Math.round(o/1e6)))} MB`;function st(o,$,w,v){v(`Downloading ${o} ${$} (${L(w)}), once…`);let h=0;return u=>{const b=Math.floor(u/w*10)*10;b!==h&&(h=b,v(` ${String(b)}% (${L(u)} of ${L(w)})`))}}export function createRuntimes(o={}){const $=o.log??(t=>{process.stderr.write(`${t}
2
+ import{chmod as T,mkdir as E,readFile as W,rename as J,rm as z,writeFile as _}from"node:fs/promises";import{dirname as U,join as d}from"node:path";import{binsOf as A,filesFor as C,platformOf as V}from"@allyhub/protocol";import{download as Y,sha256Of as q}from"./download.js";import{RuntimeError as g}from"./errors.js";import{cacheHome as G}from"./home.js";import{partialOf as K,sweepPartials as Q,withLock as X}from"./lock.js";import{knownManifest as Z}from"./declared.js";import{inside as D,native as tt,undmg as et,untgz as rt,unzip as nt}from"./unpack.js";const F=".allyhub-runtime.json";export const binVariable=o=>`ALLYHUB_${o.toUpperCase().replaceAll("-","_")}`;const L=o=>`${String(Math.max(1,Math.round(o/1e6)))} MB`;function st(o,$,w,v){v(`Downloading ${o} ${$} (${L(w)}), once…`);let h=0;return u=>{const b=Math.floor(u/w*10)*10;b!==h&&(h=b,v(` ${String(b)}% (${L(u)} of ${L(w)})`))}}export function createRuntimes(o={}){const $=o.log??(t=>{process.stderr.write(`${t}
3
3
  `)}),w=o.env??process.env,v=o.home??G(w),h=o.manifest??Z(),u="platform"in o?o.platform:V(process.platform,process.arch),b=o.fetch??globalThis.fetch,y=d(v,"runtimes"),j=t=>{const e=Object.hasOwn(h.runtimes,t)?h.runtimes[t]:void 0;if(!e)throw new g("unknown-runtime",`AllyHub has no runtime "${t}".`);return e},p=(t,e)=>d(y,`${t}@${e.version}`),k=(t,e)=>{const r=u?C(e,u):void 0;if(!r)throw new g("unsupported",`${t} ${e.version} has no build for ${u??`${process.platform}-${process.arch}`}.`);return r},H=(t,e,r)=>Object.fromEntries(Object.entries(A(k(t,e))).map(([n,s])=>[n,d(r,tt(s))])),N=(t,e)=>{const r=[...new Set(Object.values(e.platforms).flatMap(f=>Object.keys(A(f))))];if(r.length===0)return;const n=r.map(f=>[f,w[binVariable(f)]]);if(n.some(([,f])=>!f))return;const s=Object.fromEntries(n),c=n[0]?.[1]??"";return{name:t,version:void 0,dir:U(c),bins:s,from:"env"}},R=async(t,e)=>{try{const r=JSON.parse(await W(d(p(t,e),F),"utf8")),n=k(t,e).map(s=>s.sha256);return r.version===e.version&&JSON.stringify(r.files)===JSON.stringify(n)}catch{return!1}},M=async t=>{const e=j(t),r=N(t,e);if(r)return r;if(!await R(t,e))return;const n=p(t,e);return{name:t,version:e.version,dir:n,bins:H(t,e,n),from:"cache"}},I=async(t,e,r)=>{const n=k(t,e),s=p(t,e),c=K(s),f=d(c,".downloads");await E(f,{recursive:!0});const B=r.onProgress?void 0:st(t,e.version,n.reduce((l,i)=>l+i.size,0),$);let x=0;try{for(const[l,i]of n.entries()){const O=d(f,String(l));if(await Y(i.url,O,{size:i.size,sha256:i.sha256,fetch:b,signal:r.signal,...o.downloads,onRetry:(a,m,S)=>{$(` ${a.message} Trying again (${String(m+1)} of ${String(S)})…`)},onProgress:(a,m)=>{B?.(x+a),r.onProgress?.({runtime:t,url:i.url,received:a,total:m})}}),x+=i.size,i.unpack==="zip")await nt(O,c);else if(i.unpack==="tgz")await rt(O,c);else if(i.unpack==="dmg")await et(O,c);else{const a=D(c,i.name??ot(i.url));if(!a)throw new g("unpack",`${i.url} would be kept outside its folder.`);await E(U(a),{recursive:!0}),await J(O,a),i.executable&&await T(a,493)}for(const a of i.check){const m=D(c,a.path),S=m?await q(m).catch(()=>"missing"):"missing";if(S!==a.sha256)throw new g("checksum",`${a.path} from ${i.url} has sha256 ${S}; its pin is ${a.sha256}.`)}}await z(f,{recursive:!0,force:!0}),await _(d(c,F),`${JSON.stringify({version:e.version,files:n.map(l=>l.sha256),at:new Date().toISOString()})}
4
4
  `),await z(s,{recursive:!0,force:!0}),await J(c,s)}catch(l){throw await z(c,{recursive:!0,force:!0}),l}},P=async(t,e={})=>{const r=j(t),n=await M(t);if(n)return n;k(t,r),await E(y,{recursive:!0}),await X(`${p(t,r)}.lock`,async()=>{await R(t,r)||(await Q(y,t),await I(t,r,e))},{signal:e.signal,onWait:()=>{$(`Waiting for ${t}, which another command is getting…`)}});const s=await M(t);if(!s)throw new g("download",`${t} was installed but cannot be found in ${y}.`);return s};return{home:v,platform:u,locate:M,ensure:P,async bin(t,e,r){const s=(await P(t,r)).bins[e];if(!s)throw new g("unknown-runtime",`${t} holds no program "${e}".`);return s},async remove(t){const e=j(t);await z(p(t,e),{recursive:!0,force:!0})},async status(){return Promise.all(Object.entries(h.runtimes).map(async([t,e])=>{const r=u?C(e,u):void 0,n=p(t,e),s=N(t,e)!==void 0?"env":r!==void 0&&await R(t,e)?"cache":void 0;return{name:t,about:e.about,version:e.version,license:e.license,available:r!==void 0,installed:s!==void 0,...s?{from:s}:{},size:(r??[]).reduce((c,f)=>c+f.size,0),dir:n}}))}}}const ot=o=>decodeURIComponent(new URL(o).pathname.split("/").pop()??"file");
@@ -267,88 +267,6 @@
267
267
  ]
268
268
  }
269
269
  },
270
- "parakeet": {
271
- "about": "Parakeet TDT 0.6B v3, int8 ONNX: speech recognition in 25 languages",
272
- "version": "tdt-0.6b-v3-int8@2bda32ec",
273
- "license": "CC-BY-4.0",
274
- "homepage": "https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3",
275
- "platforms": {
276
- "any": [
277
- {
278
- "url": "https://huggingface.co/csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/resolve/2bda32ec70b097a55adaa07d9a7173915b43cc78/encoder.int8.onnx",
279
- "sha256": "acfc2b4456377e15d04f0243af540b7fe7c992f8d898d751cf134c3a55fd2247",
280
- "size": 652184281,
281
- "name": "encoder.int8.onnx"
282
- },
283
- {
284
- "url": "https://huggingface.co/csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/resolve/2bda32ec70b097a55adaa07d9a7173915b43cc78/decoder.int8.onnx",
285
- "sha256": "179e50c43d1a9de79c8a24149a2f9bac6eb5981823f2a2ed88d655b24248db4e",
286
- "size": 11845275,
287
- "name": "decoder.int8.onnx"
288
- },
289
- {
290
- "url": "https://huggingface.co/csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/resolve/2bda32ec70b097a55adaa07d9a7173915b43cc78/joiner.int8.onnx",
291
- "sha256": "3164c13fc2821009440d20fcb5fdc78bff28b4db2f8d0f0b329101719c0948b3",
292
- "size": 6355277,
293
- "name": "joiner.int8.onnx"
294
- },
295
- {
296
- "url": "https://huggingface.co/csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/resolve/2bda32ec70b097a55adaa07d9a7173915b43cc78/tokens.txt",
297
- "sha256": "d58544679ea4bc6ac563d1f545eb7d474bd6cfa467f0a6e2c1dc1c7d37e3c35d",
298
- "size": 93939,
299
- "name": "tokens.txt"
300
- }
301
- ]
302
- }
303
- },
304
- "yunet": {
305
- "about": "YuNet face detector, 2023mar",
306
- "version": "2023mar@3cc26e7f",
307
- "license": "MIT",
308
- "homepage": "https://github.com/opencv/opencv_zoo",
309
- "platforms": {
310
- "any": [
311
- {
312
- "url": "https://huggingface.co/opencv/face_detection_yunet/resolve/3cc26e7f1014a5ee5d74a42acee58bafc9d0a310/face_detection_yunet_2023mar.onnx",
313
- "sha256": "8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4",
314
- "size": 232589,
315
- "name": "face_detection_yunet_2023mar.onnx"
316
- }
317
- ]
318
- }
319
- },
320
- "u2net-human-seg": {
321
- "about": "U²-Net human segmentation, for person mattes",
322
- "version": "rembg-v0.0.0",
323
- "license": "Apache-2.0",
324
- "homepage": "https://github.com/xuebinqin/U-2-Net",
325
- "platforms": {
326
- "any": [
327
- {
328
- "url": "https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net_human_seg.onnx",
329
- "sha256": "01eb6a29a5c4d8edb30b56adad9bb3a2a0535338e480724a213e0acfd2d1c73c",
330
- "size": 175997641,
331
- "name": "u2net_human_seg.onnx"
332
- }
333
- ]
334
- }
335
- },
336
- "tesseract-eng": {
337
- "about": "Tesseract's English model, best int",
338
- "version": "4.0.0-best-int",
339
- "license": "Apache-2.0",
340
- "homepage": "https://github.com/tesseract-ocr/tessdata_best",
341
- "platforms": {
342
- "any": [
343
- {
344
- "url": "https://cdn.jsdelivr.net/npm/@tesseract.js-data/eng@1.0.0/4.0.0_best_int/eng.traineddata.gz",
345
- "sha256": "45b4cb346724ac1774f1c36f42f182b887bcdb28ebe63e6fff90ac41f3fcff91",
346
- "size": 2952873,
347
- "name": "eng.traineddata.gz"
348
- }
349
- ]
350
- }
351
- },
352
270
  "node": {
353
271
  "about": "Node.js and its npm, the official builds: what a Studio Host package runs on, and Studio's agents on the desktop",
354
272
  "version": "24.22.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/runtimes",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -134,6 +134,8 @@ export interface SceneryProp<O extends Object3D = Object3D> {
134
134
  }
135
135
  /** A scenery as an agent writes it. M is what build returns and update receives. */
136
136
  export interface SceneryDefinition<M = unknown> {
137
+ /** Its title, for people: what Studio and `allyhub dev` list it by (none: its name). */
138
+ title?: string;
137
139
  renderer?: SceneryRendererOptions;
138
140
  /** Once, before anything is drawn. Awaited, with every load it starts. */
139
141
  build(w: SceneryHost): M | Promise<M>;
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{bakeProblems as c}from"./bake.js";import{cameraProblems as f}from"./camera.js";export const SCENERY_RENDERER_DEFAULTS={antialias:!1,transmissionScale:.25,focus:{samples:64,maxRadius:64}};export function isScenery(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.kind==="scenery"&&typeof n.build=="function"}export function defineScenery(e){if(typeof e.build!="function")throw new Error("defineScenery needs build(w), the function that builds the scenery.");const n=e.renderer?.kind;if(n!==void 0&&n!=="webgl"&&n!=="webgpu")throw new Error(`defineScenery's renderer.kind is "webgl" or "webgpu", not ${JSON.stringify(n)}.`);const r=e.renderer?.transmissionScale;if(r!==void 0&&!(Number.isFinite(r)&&r>0&&r<=2))throw new Error(`defineScenery's renderer.transmissionScale is a share of the frame's size in (0, 2], not ${String(r)}.`);const i=[];for(const[o,t]of Object.entries(e.cameras??{}))for(const s of f(t))i.push(`camera "${o}": ${s}`);for(const[o,t]of Object.entries(e.moves??{}))typeof t!="function"&&i.push(`move "${o}" is not a function of time`);if(e.bake!==void 0&&i.push(...c(e.bake)),i.length>0)throw new Error(`defineScenery: ${i.join("; ")}.`);return Object.freeze({...e,kind:"scenery"})}
2
+ import{bakeProblems as c}from"./bake.js";import{cameraProblems as a}from"./camera.js";export const SCENERY_RENDERER_DEFAULTS={antialias:!1,transmissionScale:.25,focus:{samples:64,maxRadius:64}};export function isScenery(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.kind==="scenery"&&typeof n.build=="function"}export function defineScenery(e){if(typeof e.build!="function")throw new Error("defineScenery needs build(w), the function that builds the scenery.");const n=e.renderer?.kind;if(n!==void 0&&n!=="webgl"&&n!=="webgpu")throw new Error(`defineScenery's renderer.kind is "webgl" or "webgpu", not ${JSON.stringify(n)}.`);const i=e.renderer?.transmissionScale;if(i!==void 0&&!(Number.isFinite(i)&&i>0&&i<=2))throw new Error(`defineScenery's renderer.transmissionScale is a share of the frame's size in (0, 2], not ${String(i)}.`);const r=[],t=e.title;t!==void 0&&typeof t!="string"&&r.push(`title is a string, not ${JSON.stringify(t)}`);for(const[o,s]of Object.entries(e.cameras??{}))for(const f of a(s))r.push(`camera "${o}": ${f}`);for(const[o,s]of Object.entries(e.moves??{}))typeof s!="function"&&r.push(`move "${o}" is not a function of time`);if(e.bake!==void 0&&r.push(...c(e.bake)),r.length>0)throw new Error(`defineScenery: ${r.join("; ")}.`);return Object.freeze({...e,kind:"scenery"})}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/scenery",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{publicNames as n}from"@allyhub/formats";import{FUNCTIONS as h}from"../calc/functions/index.js";import{AreaChart as d,BarChart as p,DataLabelList as m,DoughnutChart as c,GraphicalProperties as w,Legend as f,LineChart as u,LineProperties as y,Marker as g,NumericAxis as b,PieChart as k,Reference as _,ScatterChart as x,Scaling as C,Series as A,TextAxis as S}from"./charts.js";import{AutoFilter as v,ConditionalFormattingList as D,DataValidation as P,DataValidationList as F,DifferentialStyle as L,Rule as T}from"./rules.js";import{Alignment as R,Border as I,Color as N,Font as E,PatternFill as V,Side as B}from"./styles.js";import{Cell as W,ColumnDimension as j,DefinedName as G,DefinedNameDict as H,RowDimension as M,Table as O,TableList as U,Workbook as z,Worksheet as q}from"./workbook.js";import{Comment as X,HeaderFooter as J,HeaderFooterPart as K,Image as Q,PageMargins as Y,PageSetup as Z,SheetProtection as $}from"./page.js";const a={Series:{title:"A series' name in words, openpyxl's SeriesFactory argument, kept here as a field."},Workbook:{open:"Workbook.open(dir): a workbook's folder read (load_workbook(dir) is the same).",block_cells:"How many typed cells together go in a CSV file of their own: 100 unless set.",title:"The workbook's title, sheet.yaml's.",check:"wb.check(): what allyhub check would say of the workbook as it stands: a list of { file, line, message }."},Cell:{computed:"What the cell computes to, the workbook as it stands, saved or not."},Table:{key:"The column that lines rows up when two hands' changes merge."},DataValidation:{multiple:"A list's cell may hold several of its values, joined by separator: an .xlsx keeps them as text.",separator:"What joins a cell's choices: a comma and a space unless set."},PageSetup:{fitToWidth:"Pages wide; setting it or fitToHeight fits the sheet, with no pageSetUpPr to set."},ColumnDimension:{files:"Its cells name files, from the sheet's folder: true, or { separator, height }."}},ee=["add_data","set_categories","append","title","legend","width","height","style","anchor","series","dataLabels","x_axis","y_axis"],te={BarChart:["type","grouping","overlap","gapWidth","varyColors"],LineChart:["grouping"],AreaChart:["grouping"],PieChart:["varyColors"],DoughnutChart:["holeSize"],ScatterChart:[]},oe={Workbook:z.prototype,Worksheet:q.prototype,Cell:W.prototype,Font:E.prototype,PatternFill:V.prototype,Border:I.prototype,Side:B.prototype,Alignment:R.prototype,Color:N.prototype,Table:O.prototype,TableList:U.prototype,DefinedName:G.prototype,DefinedNameDict:H.prototype,ColumnDimension:j.prototype,RowDimension:M.prototype,ConditionalFormattingList:D.prototype,Rule:T.prototype,DifferentialStyle:L.prototype,DataValidation:P.prototype,DataValidationList:F.prototype,AutoFilter:v.prototype,BarChart:p.prototype,LineChart:u.prototype,AreaChart:d.prototype,PieChart:k.prototype,DoughnutChart:c.prototype,ScatterChart:x.prototype,Reference:_.prototype,Series:A.prototype,Legend:f.prototype,Scaling:C.prototype,TextAxis:S.prototype,NumericAxis:b.prototype,DataLabelList:m.prototype,Marker:g.prototype,GraphicalProperties:w.prototype,LineProperties:y.prototype,PageSetup:Z.prototype,PageMargins:Y.prototype,_HeaderFooterItem:J.prototype,_HeaderFooterPart:K.prototype,SheetProtection:$.prototype,Comment:X.prototype,Image:Q.prototype},r=["title","scaling","majorUnit","number_format","delete","majorGridlines"],ae={_HeaderFooterItem:["left","center","right"],Comment:["text","author"],Image:["path","width","height","anchor"],Workbook:["worksheets","defined_names","data_only","path","title","block_cells"],Cell:["row","column"],Worksheet:["min_row","min_column"],Font:["name","size","bold","italic","underline","strike","color"],PatternFill:["fill_type","fgColor","bgColor"],Border:["left","right","top","bottom"],Side:["style","color"],Alignment:["horizontal","vertical","wrap_text","shrink_to_fit","indent","text_rotation"],Color:["rgb"],Table:["displayName","ref","key","autoFilter"],DefinedName:["name","attr_text"],ColumnDimension:["index"],RowDimension:["index"],Rule:["type","operator","formula","stopIfTrue","rank","percent","bottom","aboveAverage","equalAverage","text","dxf"],DifferentialStyle:["font","fill","border"],DataValidation:["type","formula1","formula2","operator","allow_blank","showDropDown","showErrorMessage","showInputMessage","errorStyle","errorTitle","error","promptTitle","prompt","sqref"],DataValidationList:["dataValidation"],AutoFilter:["ref"],...Object.fromEntries(Object.entries(te).map(([e,t])=>[e,[...ee.filter(o=>!(/^(?:Pie|Doughnut)/u.test(e)&&o.endsWith("_axis"))),...t]])),Reference:["worksheet","min_col","min_row","max_col","max_row"],Series:["val","xVal","title","smooth","marker","graphicalProperties"],Legend:["position"],Scaling:["min","max","orientation"],TextAxis:r.filter(e=>e!=="majorUnit"),NumericAxis:r,DataLabelList:["showVal","showPercent","showCatName","showSerName","dLblPos"],Marker:["symbol","size"],GraphicalProperties:["solidFill","noFill","line"],LineProperties:["width","solidFill","noFill"]};export const HELPERS=["CellIsRule","ColorScaleRule","DataBarRule","FormulaRule","IconSetRule","column_index_from_string","coordinate_to_tuple","get_column_letter","range_boundaries"];const re=()=>{const e={};for(const[t,o]of Object.entries(oe)){const i=a[t]??{};e[t]=[...n(o),...ae[t]??[]].filter(l=>!Object.hasOwn(i,l)).sort()}return e},s=e=>[...h.values()].filter(t=>t.from===e).map(t=>t.name).sort();export const CAPABILITIES={reference:{library:"openpyxl",version:"3.1.5",docs:"https://openpyxl.readthedocs.io/"},holds:re(),functions:HELPERS,differs:["A workbook is a folder, not a file: load_workbook(dir) reads sheet.yaml and its CSV files, wb.save(dir) writes them, and only what changed is written. This API does not read or write .xlsx: allyhub sheet import and allyhub render --type xlsx do.","A keyword argument of openpyxl's is a field of an object: new Font({ bold: true }), new Table({ displayName, ref }), new DefinedName(name, { attr_text }). Classes are made with new.","A name openpyxl has that is not held throws where it is used, naming what the class holds. ws['A1'], ws['A1:B2'], ws['A'], ws[1], wb['Sheet'], ws.tables['t'], wb.defined_names['n'], ws.column_dimensions['A'] and ws.row_dimensions[1] are held; in TypeScript ws['A1'] is typed as a Cell, so write ws['A1'].value = v (ws['A1'] = v works at run time), and wb.get_sheet_by_name(name) is typed where wb[name] is not.","Rows and columns count from 1, as openpyxl's. iter_rows, rows, columns and values give arrays, not generators.","A colour is #RRGGBB; RRGGBB and AARRGGBB are taken, the alpha left out. Theme colours are not held.","cell.value of a date is a Date (read in UTC), a formula's its text, and with load_workbook(dir, { data_only: true }) what it computes to, which openpyxl reads from a file's cache and this computes.","column_dimensions' width is Excel's unit and row_dimensions' height points, as openpyxl's; the file holds pixels.","ws.merged_cells is an array of each merged range's text.","A table's rows are its CSV file, so ws.add_table(new Table({ displayName, ref })) moves the cells of ref there; its header row names its columns. A column whose every row has one formula, moved, is written as a calculated column.","A run of cells with one formula, moved, is written as one range key, and at least wb.block_cells typed cells together in a CSV file of their own (a block).","ws.title = 'New' renames the sheet in every formula, which openpyxl leaves to you.","ws.insert_rows, delete_rows, insert_cols and delete_cols rewrite every formula of the workbook as Excel does (a reference moves, a range grows or shrinks, one to what went is #REF!), move tables, blocks, merges and looks, and take rows and columns in or out of a table's CSV file. openpyxl moves cells and leaves formulas as they were. A table's header row is not deleted unless all of the table is.","A string that reads as another value (=, 12%, 2026-01-01) stays text, as openpyxl's does: its cell is written with a leading ' unless it starts with =, which makes it a formula.","A DataValidation refuses what breaks it and shows its prompt unless showErrorMessage or showInputMessage is false, as Excel's dialog starts: openpyxl's leave both off. A list's cell keeps its blank unless allow_blank is false.","ws.auto_filter.ref and add_filter_column say what a filter keeps, and the rows it leaves out are worked out from that, never written: a file made by openpyxl hides nothing until Excel reapplies it. A table has its own, table.autoFilter. add_sort_condition is not held: sorting is the rows of the files in order.","A chart reads its cells live, whatever else is in the file: there is no cache to refresh. chart.add_data and set_categories, and Series, take a Reference or a formula's text for a table's column or a spill, as add_data('orders[total]', { title: 'Total' }) or set_categories('orders[month]'), since a Reference cannot name one.","Series is made with new Series(values, { xvalues, title, title_from_data }); openpyxl's is the SeriesFactory function.","A chart's width and height are centimetres, as openpyxl's; the file holds pixels, and anchor a cell: ws.add_chart(chart, 'E2').","A LineChart's grouping is standard; a stacked area is an AreaChart. Chart styles are kept but draw nothing, as sheet.yaml has no place for them: chart.style is only read.","ws._charts lists a sheet's charts, those read from sheet.yaml among them, as the classes above.","In a rule, a fill's bgColor paints, or its fgColor where it has none. A rule's font holds bold, italic, underline, strike and a colour; alignment and number formats in a rule are not held.","workbook((wb, { data }) => { … }), the default export of an item's sheet.ts, makes sheets with these classes, on a workbook of its own that starts with none. They are made again from the code wherever the workbook is read, never saved: wb.save throws there."],adds:a,formulas:{own:s("allyhub"),formulajs:s("formulajs")}};
2
+ import{publicNames as n}from"@allyhub/formats";import{FUNCTIONS as h}from"../calc/functions/index.js";import{AreaChart as p,BarChart as d,DataLabelList as m,DoughnutChart as c,GraphicalProperties as w,Legend as f,LineChart as u,LineProperties as y,Marker as g,NumericAxis as b,PieChart as k,Reference as _,ScatterChart as x,Scaling as C,Series as A,TextAxis as S}from"./charts.js";import{AutoFilter as v,ConditionalFormattingList as D,DataValidation as L,DataValidationList as P,DifferentialStyle as F,Rule as T}from"./rules.js";import{Alignment as R,Border as I,Color as N,Font as E,PatternFill as V,Side as B}from"./styles.js";import{Cell as W,ColumnDimension as j,DefinedName as M,DefinedNameDict as G,RowDimension as H,Table as O,TableList as U,Workbook as z,Worksheet as q}from"./workbook.js";import{Comment as X,HeaderFooter as Y,HeaderFooterPart as J,Image as K,PageMargins as Q,PageSetup as Z,SheetProtection as $}from"./page.js";const a={Series:{title:"A series' name in words, openpyxl's SeriesFactory argument, kept here as a field."},Workbook:{open:"Workbook.open(path): a workbook read, by its file or a folder's sheet.yaml (load_workbook(path) is the same).",block_cells:"How many typed cells together go in a CSV file of their own: 100 unless set.",title:"The workbook's title, sheet.yaml's.",check:"wb.check(): what allyhub check would say of the workbook as it stands: a list of { file, line, message }."},Cell:{computed:"What the cell computes to, the workbook as it stands, saved or not."},Table:{key:"The column that lines rows up when two hands' changes merge."},DataValidation:{multiple:"A list's cell may hold several of its values, joined by separator: an .xlsx keeps them as text.",separator:"What joins a cell's choices: a comma and a space unless set."},PageSetup:{fitToWidth:"Pages wide; setting it or fitToHeight fits the sheet, with no pageSetUpPr to set."},ColumnDimension:{files:"Its cells name files, from the sheet's folder: true, or { separator, height }."}},ee=["add_data","set_categories","append","title","legend","width","height","style","anchor","series","dataLabels","x_axis","y_axis"],te={BarChart:["type","grouping","overlap","gapWidth","varyColors"],LineChart:["grouping"],AreaChart:["grouping"],PieChart:["varyColors"],DoughnutChart:["holeSize"],ScatterChart:[]},oe={Workbook:z.prototype,Worksheet:q.prototype,Cell:W.prototype,Font:E.prototype,PatternFill:V.prototype,Border:I.prototype,Side:B.prototype,Alignment:R.prototype,Color:N.prototype,Table:O.prototype,TableList:U.prototype,DefinedName:M.prototype,DefinedNameDict:G.prototype,ColumnDimension:j.prototype,RowDimension:H.prototype,ConditionalFormattingList:D.prototype,Rule:T.prototype,DifferentialStyle:F.prototype,DataValidation:L.prototype,DataValidationList:P.prototype,AutoFilter:v.prototype,BarChart:d.prototype,LineChart:u.prototype,AreaChart:p.prototype,PieChart:k.prototype,DoughnutChart:c.prototype,ScatterChart:x.prototype,Reference:_.prototype,Series:A.prototype,Legend:f.prototype,Scaling:C.prototype,TextAxis:S.prototype,NumericAxis:b.prototype,DataLabelList:m.prototype,Marker:g.prototype,GraphicalProperties:w.prototype,LineProperties:y.prototype,PageSetup:Z.prototype,PageMargins:Q.prototype,_HeaderFooterItem:Y.prototype,_HeaderFooterPart:J.prototype,SheetProtection:$.prototype,Comment:X.prototype,Image:K.prototype},r=["title","scaling","majorUnit","number_format","delete","majorGridlines"],ae={_HeaderFooterItem:["left","center","right"],Comment:["text","author"],Image:["path","width","height","anchor"],Workbook:["worksheets","defined_names","data_only","path","title","block_cells"],Cell:["row","column"],Worksheet:["min_row","min_column"],Font:["name","size","bold","italic","underline","strike","color"],PatternFill:["fill_type","fgColor","bgColor"],Border:["left","right","top","bottom"],Side:["style","color"],Alignment:["horizontal","vertical","wrap_text","shrink_to_fit","indent","text_rotation"],Color:["rgb"],Table:["displayName","ref","key","autoFilter"],DefinedName:["name","attr_text"],ColumnDimension:["index"],RowDimension:["index"],Rule:["type","operator","formula","stopIfTrue","rank","percent","bottom","aboveAverage","equalAverage","text","dxf"],DifferentialStyle:["font","fill","border"],DataValidation:["type","formula1","formula2","operator","allow_blank","showDropDown","showErrorMessage","showInputMessage","errorStyle","errorTitle","error","promptTitle","prompt","sqref"],DataValidationList:["dataValidation"],AutoFilter:["ref"],...Object.fromEntries(Object.entries(te).map(([e,t])=>[e,[...ee.filter(o=>!(/^(?:Pie|Doughnut)/u.test(e)&&o.endsWith("_axis"))),...t]])),Reference:["worksheet","min_col","min_row","max_col","max_row"],Series:["val","xVal","title","smooth","marker","graphicalProperties"],Legend:["position"],Scaling:["min","max","orientation"],TextAxis:r.filter(e=>e!=="majorUnit"),NumericAxis:r,DataLabelList:["showVal","showPercent","showCatName","showSerName","dLblPos"],Marker:["symbol","size"],GraphicalProperties:["solidFill","noFill","line"],LineProperties:["width","solidFill","noFill"]};export const HELPERS=["CellIsRule","ColorScaleRule","DataBarRule","FormulaRule","IconSetRule","column_index_from_string","coordinate_to_tuple","get_column_letter","range_boundaries"];const re=()=>{const e={};for(const[t,o]of Object.entries(oe)){const i=a[t]??{};e[t]=[...n(o),...ae[t]??[]].filter(l=>!Object.hasOwn(i,l)).sort()}return e},s=e=>[...h.values()].filter(t=>t.from===e).map(t=>t.name).sort();export const CAPABILITIES={reference:{library:"openpyxl",version:"3.1.5",docs:"https://openpyxl.readthedocs.io/"},holds:re(),functions:HELPERS,differs:["A workbook is a YAML file and the CSV files beside it: load_workbook(path) reads them, by the file or a folder's sheet.yaml, wb.save(path) writes them, and only what changed is written. This API does not read or write .xlsx: allyhub sheet import and allyhub render --type xlsx do.","A keyword argument of openpyxl's is a field of an object: new Font({ bold: true }), new Table({ displayName, ref }), new DefinedName(name, { attr_text }). Classes are made with new.","A name openpyxl has that is not held throws where it is used, naming what the class holds. ws['A1'], ws['A1:B2'], ws['A'], ws[1], wb['Sheet'], ws.tables['t'], wb.defined_names['n'], ws.column_dimensions['A'] and ws.row_dimensions[1] are held; in TypeScript ws['A1'] is typed as a Cell, so write ws['A1'].value = v (ws['A1'] = v works at run time), and wb.get_sheet_by_name(name) is typed where wb[name] is not.","Rows and columns count from 1, as openpyxl's. iter_rows, rows, columns and values give arrays, not generators.","A colour is #RRGGBB; RRGGBB and AARRGGBB are taken, the alpha left out. Theme colours are not held.","cell.value of a date is a Date (read in UTC), a formula's its text, and with load_workbook(path, { data_only: true }) what it computes to, which openpyxl reads from a file's cache and this computes.","column_dimensions' width is Excel's unit and row_dimensions' height points, as openpyxl's; the file holds pixels.","ws.merged_cells is an array of each merged range's text.","A table's rows are its CSV file, so ws.add_table(new Table({ displayName, ref })) moves the cells of ref there; its header row names its columns. A column whose every row has one formula, moved, is written as a calculated column.","A run of cells with one formula, moved, is written as one range key, and at least wb.block_cells typed cells together in a CSV file of their own (a block).","ws.title = 'New' renames the sheet in every formula, which openpyxl leaves to you.","ws.insert_rows, delete_rows, insert_cols and delete_cols rewrite every formula of the workbook as Excel does (a reference moves, a range grows or shrinks, one to what went is #REF!), move tables, blocks, merges and looks, and take rows and columns in or out of a table's CSV file. openpyxl moves cells and leaves formulas as they were. A table's header row is not deleted unless all of the table is.","A string that reads as another value (=, 12%, 2026-01-01) stays text, as openpyxl's does: its cell is written with a leading ' unless it starts with =, which makes it a formula.","A DataValidation refuses what breaks it and shows its prompt unless showErrorMessage or showInputMessage is false, as Excel's dialog starts: openpyxl's leave both off. A list's cell keeps its blank unless allow_blank is false.","ws.auto_filter.ref and add_filter_column say what a filter keeps, and the rows it leaves out are worked out from that, never written: a file made by openpyxl hides nothing until Excel reapplies it. A table has its own, table.autoFilter. add_sort_condition is not held: sorting is the rows of the files in order.","A chart reads its cells live, whatever else is in the file: there is no cache to refresh. chart.add_data and set_categories, and Series, take a Reference or a formula's text for a table's column or a spill, as add_data('orders[total]', { title: 'Total' }) or set_categories('orders[month]'), since a Reference cannot name one.","Series is made with new Series(values, { xvalues, title, title_from_data }); openpyxl's is the SeriesFactory function.","A chart's width and height are centimetres, as openpyxl's; the file holds pixels, and anchor a cell: ws.add_chart(chart, 'E2').","A LineChart's grouping is standard; a stacked area is an AreaChart. Chart styles are kept but draw nothing, as sheet.yaml has no place for them: chart.style is only read.","ws._charts lists a sheet's charts, those read from sheet.yaml among them, as the classes above.","In a rule, a fill's bgColor paints, or its fgColor where it has none. A rule's font holds bold, italic, underline, strike and a colour; alignment and number formats in a rule are not held.","workbook((wb, { data }) => { … }), the default export of the code a sheet's file names (code: ./forecast.ts), makes sheets with these classes, on a workbook of its own that starts with none. They are made again from the code wherever the workbook is read, never saved: wb.save throws there."],adds:a,formulas:{own:s("allyhub"),formulajs:s("formulajs")}};
@@ -1,19 +1,19 @@
1
1
  import { Workbook } from "./workbook.js";
2
- import type { GeneratedSheets } from "../generated.js";
2
+ import type { GeneratedSheets } from "@allyhub/formats";
3
3
  /** Marks what workbook() makes. */
4
4
  export declare const WORKBOOK_BRAND = "__allyhubWorkbook";
5
5
  export interface SheetCodeContext {
6
- /** A project file, from the sheet's folder: CSV as a row object each, YAML and JSON as they are. */
6
+ /** A project file, from the code's folder: CSV as a row object each, YAML and JSON as they are. */
7
7
  data: (path: string) => unknown;
8
8
  }
9
9
  export type SheetCodeBuild = (wb: Workbook, ctx: SheetCodeContext) => unknown;
10
- /** The default export of an item's sheet.ts. */
10
+ /** The default export of a sheet's code. */
11
11
  export interface SheetCode {
12
12
  readonly [WORKBOOK_BRAND]: true;
13
13
  /** Runs it. Here, in the module its classes are from, whoever calls. */
14
14
  readonly generate: (ctx: SheetCodeContext) => GeneratedSheets;
15
15
  }
16
16
  export declare function isSheetCode(v: unknown): v is SheetCode;
17
- /** What an item's sheet.ts exports: export default workbook((wb, { data }) => { … }). */
17
+ /** What a sheet's code exports: export default workbook((wb, { data }) => { … }). */
18
18
  export declare function workbook(build: SheetCodeBuild): SheetCode;
19
19
  //# sourceMappingURL=code.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{Workbook as n}from"./workbook.js";export const WORKBOOK_BRAND="__allyhubWorkbook";export function isSheetCode(o){return typeof o=="object"&&o!==null&&WORKBOOK_BRAND in o}export function workbook(o){if(typeof o!="function")throw new TypeError("An item's sheet.ts exports one function: export default workbook((wb, { data }) => { … }).");return{[WORKBOOK_BRAND]:!0,generate:e=>{const t=new n;if(t.worksheets=[],t._making=!0,o(t,e)instanceof Promise)throw new TypeError("sheet.ts's function waits for nothing: it is not async, as it has no network and reads with data().");return t._generated()}}}
2
+ import{Workbook as r}from"./workbook.js";export const WORKBOOK_BRAND="__allyhubWorkbook";export function isSheetCode(o){return typeof o=="object"&&o!==null&&WORKBOOK_BRAND in o}export function workbook(o){if(typeof o!="function")throw new TypeError("A sheet's code exports one function: export default workbook((wb, { data }) => { … }).");return{[WORKBOOK_BRAND]:!0,generate:e=>{const t=new r;if(t.worksheets=[],t._making=!0,o(t,e)instanceof Promise)throw new TypeError("A sheet's code waits for nothing: it is not async, as it has no network and reads with data().");return t._generated()}}}
@@ -1,9 +1,9 @@
1
1
  import { type SheetNote, type SheetPicture, type SheetPrint, type SheetConditional, type SheetFile, type SheetFilesColumn, type SheetTable, type SheetWorksheet } from "@allyhub/formats";
2
2
  import { Comment, HeaderFooter, PageMargins, PageSetup, SheetProtection, type Image } from "./page.js";
3
3
  import { Calc } from "../calc/engine.js";
4
- import { type ParsedCsv } from "../csv.js";
4
+ import { type ParsedCsv } from "@allyhub/formats";
5
5
  import type { SheetProblem } from "../file.js";
6
- import { type GeneratedSheets } from "../generated.js";
6
+ import { type GeneratedSheets } from "@allyhub/formats";
7
7
  import { type StructureEdit } from "../formula/rewrite.js";
8
8
  import { type Scalar } from "../values.js";
9
9
  import { type CellLook, type Workbook as Model, type Worksheet as ModelSheet } from "../workbook.js";
@@ -263,7 +263,7 @@ export declare class Workbook {
263
263
  readonly data_only: boolean;
264
264
  /** The workbook's title, sheet.yaml's. */
265
265
  title: string | undefined;
266
- /** Where it was opened or last saved. */
266
+ /** Its file, where it was opened or last saved. */
267
267
  path: string | undefined;
268
268
  /** How many typed cells together go in a CSV file of their own. */
269
269
  block_cells: number;
@@ -280,12 +280,12 @@ export declare class Workbook {
280
280
  _active: number;
281
281
  /** Something changed since the files were last made. */
282
282
  _pending: boolean;
283
- /** It is sheet.ts's: what it makes is never saved. */
283
+ /** It is a sheet's code's: what it makes is never saved. */
284
284
  _making: boolean;
285
285
  private _calc;
286
286
  constructor(o?: LoadOptions);
287
- /** A workbook's folder, read. */
288
- static open(dir: string, o?: LoadOptions): Workbook;
287
+ /** A workbook read from its file. */
288
+ static open(path: string, o?: LoadOptions): Workbook;
289
289
  private _read;
290
290
  private _keepCsv;
291
291
  private _load;
@@ -306,6 +306,7 @@ export declare class Workbook {
306
306
  private _rewrite;
307
307
  private _rewriteCsv;
308
308
  private _sheetEntry;
309
+ /** A new table's CSV file, beside the workbook's file, under a name no file there has. */
309
310
  private _dataPath;
310
311
  /** A table added since the files were read: its cells become its CSV file. */
311
312
  private _writeNewTable;
@@ -345,13 +346,16 @@ export declare class Workbook {
345
346
  };
346
347
  /** What allyhub check would say of it as it stands, added to openpyxl's. */
347
348
  check(): SheetProblem[];
348
- /** What sheet.ts made on it: each CSV file named where it stands for no file on disk. */
349
+ /** What the sheet's code made on it: each CSV file named where it stands for no file on disk. */
349
350
  _generated(): GeneratedSheets;
350
- /** Writes sheet.yaml and its CSV files: to the folder it came from, or one named. */
351
- save(dir?: string): void;
351
+ /**
352
+ * Writes its file and its CSV files beside it: where it came from, or to
353
+ * the file named (`finance/budget.yaml`).
354
+ */
355
+ save(path?: string): void;
352
356
  }
353
- /** A workbook's folder, read: openpyxl's load_workbook. */
354
- export declare function load_workbook(dir: string, o?: LoadOptions): Workbook;
357
+ /** A workbook read, by its file or a folder's sheet.yaml: openpyxl's load_workbook. */
358
+ export declare function load_workbook(path: string, o?: LoadOptions): Workbook;
355
359
  /** openpyxl's helpers for addresses. */
356
360
  export declare const get_column_letter: (column: number) => string;
357
361
  export declare function column_index_from_string(letters: string): number;
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{SHEET_DATA as G,SHEET_FILE as P,strict as g}from"@allyhub/formats";import{Comment as z,HeaderFooter as A,PageMargins as V,PageSetup as Y,SheetProtection as q}from"./page.js";import{columnIndex as E,columnLetter as L,cellName as C,contains as N,rangeName as x,readAddress as y,readArea as k}from"../address.js";import{Calc as Q}from"../calc/engine.js";import{checkWorkbook as X}from"../check.js";import{readCsv as Z,writeCsv as ee}from"../csv.js";import{GENERATED as te}from"../generated.js";import{moveFormula as se,relativeKey as ne}from"../formula/move.js";import{parseFormula as F}from"../formula/parse.js";import{printFormula as B}from"../formula/print.js";import{rewriteFormula as oe}from"../formula/rewrite.js";import{isDateCode as S}from"../format.js";import{patchCsv as re}from"../patch.js";import{CellError as W,dateOfSerial as ie,isoOfSerial as le,readTyped as M,serialOfDate as ae,writeTyped as he}from"../values.js";import{FormulaCell as fe,readWorkbook as I,validName as H}from"../workbook.js";import{restructure as _e,tableShape as ce}from"../structure.js";import{patchYaml as ue}from"../write.js";import{anchorOf as de,chartOfSpec as me}from"./charts.js";import{HINT as w}from"./hint.js";import{rectangles as T}from"./rectangles.js";import{AutoFilter as K,ConditionalFormattingList as pe,DataValidationList as we,validationOf as ge,validationSpec as ke}from"./rules.js";import{alignmentLook as ye,alignmentOf as be,borderLook as ve,borderOf as xe,fillLook as Ee,fillOf as Se,fontLook as $e,fontOf as Ce}from"./styles.js";const J=()=>process.getBuiltinModule("node:fs"),$=(...l)=>process.getBuiltinModule("node:path").join(...l);export const BLOCK_CELLS=100;const Te=l=>Math.round(l*7+5),Oe=l=>(l-5)/7,Le=l=>l*4/3,Ne=l=>l*3/4;function Fe(l,e){const t={},s=l,n=e;for(const o of new Set([...Object.keys(s),...Object.keys(n)])){const r=n[o];JSON.stringify(r??!1)!==JSON.stringify(s[o]??!1)&&(t[o]=r??!1)}return t}const m=l=>Object.keys(l).length===0,b=(l,e)=>{if(!Number.isInteger(l)||l<1)throw new RangeError(`A ${e} is a whole number from 1: ${String(l)}.`);return l},j=(l,e)=>Object.fromEntries(Object.entries(l).filter(([t])=>t!==e));export class Cell{row;column;_ws;_value;_formula=void 0;_look;_changed=!1;_styled=!1;_fresh=!1;constructor(e,t,s){this._ws=e,this.row=t,this.column=s;const n=t-1,o=s-1,r=e._model?.at(n,o);return this._value=null,r instanceof fe?this._formula=r.text:r!==void 0&&(this._value=r),this._look=e._model?.lookAt(n,o)??{},this._fresh=r===void 0,g(this,"Cell",w)}get parent(){return this._ws}get coordinate(){return C({row:this.row-1,col:this.column-1})}get column_letter(){return L(this.column-1)}get col_idx(){return this.column}get value(){return this._ws.parent.data_only?this.computed:this._formula!==void 0?this._formula:this._shown(this._value)}set value(e){if(e===void 0)throw new TypeError(`${this.coordinate}: a value is not undefined.`);if(this._formula=void 0,this._changed=!0,this._ws.parent._pending=!0,e instanceof Date){if(Number.isNaN(e.getTime()))throw new TypeError(`${this.coordinate}: the date is not valid.`);this._value=ae(e),S(this._look.format)||(this._look={...this._look,format:Number.isInteger(this._value)?"yyyy-mm-dd":"yyyy-mm-dd hh:mm"});return}if(typeof e=="string"&&e.length>1&&e.startsWith("=")){this._formula=e,this._value=null;return}this._value=e}_shown(e){return typeof e=="number"&&S(this._look.format)?ie(e)??e:e instanceof W?e.code:e}get computed(){const{calc:e,model:t}=this._ws.parent._computed(),s=t.sheet(this._ws.title);return s?this._shown(e.value(s,this.row-1,this.column-1)):null}get data_type(){if(this._formula!==void 0)return"f";const e=this._value;return e===null?"n":typeof e=="number"?S(this._look.format)?"d":"n":typeof e=="boolean"?"b":e instanceof W?"e":"s"}get is_date(){return this.data_type==="d"}get hyperlink(){return this._ws._links[this.coordinate]}set hyperlink(e){e===void 0?Reflect.deleteProperty(this._ws._links,this.coordinate):this._ws._links[this.coordinate]=e,this._ws._changed()}get comment(){const e=this._ws._notes[this.coordinate];if(e!==void 0)return typeof e=="string"?new z(e):new z(e.text,e.author)}set comment(e){e===void 0?Reflect.deleteProperty(this._ws._notes,this.coordinate):this._ws._notes[this.coordinate]=e._file(),this._ws._changed()}get number_format(){return this._look.format??"General"}set number_format(e){this._setLook({format:e})}_setLook(e){this._look={...this._look,...e},this._styled=!0,this._ws.parent._pending=!0}get font(){return Ce(this._look)}set font(e){this._setLook($e(e))}get fill(){return Se(this._look)}set fill(e){this._setLook(Ee(e))}get border(){return xe(this._look)}set border(e){this._setLook(ve(e))}get alignment(){return be(this._look)}set alignment(e){this._setLook(ye(e))}get has_style(){return!m(this._look)}offset(e=0,t=0){return this._ws.cell(this.row+e,this.column+t)}}export class ColumnDimension{index;_width;_hidden;_files;_level;_ws;constructor(e,t){this._ws=e,this.index=t;const s=e._spec()?.columns?.[t];return this._level=s?.level,this._width=s?.width,this._hidden=s?.hidden,this._files=s?.files,g(this,"ColumnDimension",w)}get outlineLevel(){return this._level}set outlineLevel(e){this._level=e,this._ws._dimensions=!0}get files(){return this._files}set files(e){this._files=e,this._ws._dimensions=!0}get width(){return this._width===void 0?void 0:Oe(this._width)}set width(e){this._width=e===void 0?void 0:Te(e),this._ws._dimensions=!0}get hidden(){return this._hidden??!1}set hidden(e){this._hidden=e,this._ws._dimensions=!0}}export class RowDimension{index;_height;_hidden;_level;_ws;constructor(e,t){this._ws=e,this.index=t;const s=e._spec()?.rows?.[String(t)];return this._level=s?.level,this._height=s?.height,this._hidden=s?.hidden,g(this,"RowDimension",w)}get outlineLevel(){return this._level}set outlineLevel(e){this._level=e,this._ws._dimensions=!0}get height(){return this._height===void 0?void 0:Ne(this._height)}set height(e){this._height=e===void 0?void 0:Le(e),this._ws._dimensions=!0}get hidden(){return this._hidden??!1}set hidden(e){this._hidden=e,this._ws._dimensions=!0}}export class Table{displayName;ref;key;_spec;autoFilter;constructor(e){for(const t of Object.keys(e))if(!["displayName","ref","key"].includes(t))throw new TypeError(`Table takes displayName, ref and key; it has no ${t}. ${w}`);if(!H(e.displayName))throw new TypeError(`${e.displayName} cannot be a table's name.`);if(!k(e.ref))throw new TypeError(`${e.ref} is not a range.`);return this.displayName=e.displayName,this.ref=e.ref,this.key=e.key,this.autoFilter=new K(e.ref,()=>{}),g(this,"Table",w)}get name(){return this.displayName}}export class TableList{_items=new Map;constructor(){return g(this,"TableList",w,{key:e=>this._items.get(e)})}add(e){this._items.set(e.name,e)}get(e){return this._items.get(e)}keys(){return[...this._items.keys()]}values(){return[...this._items.values()]}items(){return[...this._items.entries()]}pop(e){const t=this._items.get(e);return this._items.delete(e),t}}export class DefinedName{name;attr_text;constructor(e,t){if(!H(e))throw new TypeError(`${e} cannot be a name.`);return this.name=e,this.attr_text=t.attr_text.replace(/^=/u,""),g(this,"DefinedName",w)}get value(){return this.attr_text}set value(e){this.attr_text=e.replace(/^=/u,"")}}export class DefinedNameDict{_items=new Map;constructor(){return g(this,"DefinedNameDict",w,{key:e=>this._items.get(e),setKey:(e,t)=>t instanceof DefinedName?(this._items.set(e,t),!0):!1})}add(e){this._items.set(e.name,e)}get(e){return this._items.get(e)}keys(){return[...this._items.keys()]}values(){return[...this._items.values()]}items(){return[...this._items.entries()]}pop(e){const t=this._items.get(e);return this._items.delete(e),t}}const v=l=>{if(l._formula!==void 0)return l._formula;const e=l._value;return typeof e=="number"&&S(l._look.format)?le(e):he(e)};function U(l){if(l._formula!==void 0)return l._formula;const e=l._value;return e===null?null:typeof e=="number"&&!S(l._look.format)||typeof e=="boolean"?e:v(l)}const Me=l=>l.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"")||"rows";export class Worksheet{_parent;_title;_was;_model;_cells=new Map;_columns=new Map;_rows=new Map;_tables=new TableList;_freeze;_merges=[];_state="visible";_dimensions=!1;_lastRow=0;_rules=[];_validations=[];_filter;_charts=[];_print={};_links={};_notes={};_pictures=[];_protect=!1;constructor(e,t,s){if(this._parent=e,this._title=t,this._filter=new K(void 0,()=>{this._parent._pending=!0}),s){this._model=s,this._was=t,this._freeze=s.spec.freeze,this._heldPage(s.spec),this._merges=[...s.spec.merges??[]],this._state=s.spec.hidden===!0?"hidden":"visible",this._lastRow=(s.used?.bottom??-1)+1,this._heldRules(s.spec);for(const n of s.tables){const o=new Table({displayName:n.name,ref:x(n.area),...n.spec.key===void 0?{}:{key:n.spec.key}});o._spec=n.spec;const{filter:r}=n.spec;if(r)for(const[a,f]of Object.entries(r.columns)){const c=n.column(a);c&&o.autoFilter._columns.set(c.index,f)}this._tables.add(o)}}return g(this,"Worksheet",w,{index:n=>this._rowCells(n),key:n=>this._at(n),setKey:(n,o)=>{const r=y(n);return r?(this.cell(r.row+1,r.col+1).value=o,!0):!1}})}_spec(){return this._parent._file.sheets.find(e=>e.name===(this._was??this._title))}_heldRules(e){this._rules=[...e?.conditional??[]],this._validations=(e?.validations??[]).map(ge),this._charts=(e?.charts??[]).map(me),this._filter.ref=e?.filter?.range,this._filter._columns.clear();const t=e?.filter?k(e.filter.range):void 0;for(const[s,n]of Object.entries(e?.filter?.columns??{})){const o=E(s);t&&o!==void 0&&this._filter._columns.set(o-t.left,n)}}_at(e){const t=y(e);if(t)return this.cell(t.row+1,t.col+1);const s=k(e);if(s)return this._area(s);const n=E(e);if(n!==void 0){const o=[];for(let r=1;r<=this.max_row;r++)o.push(this.cell(r,n+1));return o}}_rowCells(e){const t=[];for(let s=1;s<=this.max_column;s++)t.push(this.cell(e,s));return t}_area(e){const t=[];for(let s=e.top;s<=e.bottom;s++){const n=[];for(let o=e.left;o<=e.right;o++)n.push(this.cell(s+1,o+1));t.push(n)}return t}get parent(){return this._parent}get title(){return this._title}set title(e){const t=this._title;e!==t&&this._parent._renameSheet(this,t,e)}get sheet_state(){return this._state}set sheet_state(e){this._state=e}cell(e,t,s){if(e<1||t<1)throw new RangeError(`Row and column values must be at least 1: ${String(e)}, ${String(t)}.`);const n=(e-1)*16384+t-1;let o=this._cells.get(n);return o||(o=new Cell(this,e,t),this._cells.set(n,o)),s!==void 0&&(o.value=s),e>this._lastRow&&(this._lastRow=e),o}append(e){const t=this._lastRow+1,s=(n,o)=>{o!=null&&this.cell(t,n,o)};if(Array.isArray(e))e.forEach((n,o)=>{s(o+1,n)});else for(const[n,o]of Object.entries(e)){const r=/^\d+$/u.test(n)?Number(n)-1:E(n);if(r===void 0)throw new TypeError(`${n} is not a column.`);s(r+1,o)}this._lastRow=t}get max_row(){return Math.max(1,this._lastRow)}get max_column(){let e=this._model?.columnsUsed??0;for(const t of this._cells.values())(t._value!==null||t._formula!==void 0)&&t.column>e&&(e=t.column);return Math.max(1,e)}min_row=1;min_column=1;get dimensions(){return x({top:0,left:0,bottom:this.max_row-1,right:this.max_column-1})}iter_rows(e={}){const t=this._area({top:(e.min_row??1)-1,left:(e.min_col??1)-1,bottom:(e.max_row??this.max_row)-1,right:(e.max_col??this.max_column)-1});return e.values_only===!0?t.map(s=>s.map(n=>n.value)):t}iter_cols(e={}){const t=this.iter_rows(e);return(t[0]??[]).map((n,o)=>t.map(r=>r[o]))}get rows(){return this.iter_rows()}get columns(){return this.iter_cols()}get values(){return this.iter_rows({values_only:!0})}insert_rows(e,t=1){this._parent._restructure({op:"insert-rows",sheet:this._title,at:b(e,"row")-1,count:b(t,"amount")})}delete_rows(e,t=1){this._parent._restructure({op:"delete-rows",sheet:this._title,at:b(e,"row")-1,count:b(t,"amount")})}insert_cols(e,t=1){this._parent._restructure({op:"insert-columns",sheet:this._title,at:b(e,"column")-1,count:b(t,"amount")})}delete_cols(e,t=1){this._parent._restructure({op:"delete-columns",sheet:this._title,at:b(e,"column")-1,count:b(t,"amount")})}merge_cells(e){if(!k(e))throw new TypeError(`${e} is not a range.`);this._merges.includes(e)||this._merges.push(e),this._parent._pending=!0}unmerge_cells(e){this._merges=this._merges.filter(t=>t!==e),this._parent._pending=!0}get merged_cells(){return[...this._merges]}get freeze_panes(){return this._freeze}set freeze_panes(e){const t=e instanceof Cell?e.coordinate:e;if(t!==void 0&&!y(t))throw new TypeError(`${t} is not a cell.`);this._freeze=t,this._parent._pending=!0}get column_dimensions(){return new Proxy({},{get:(e,t)=>{if(typeof t!="string")return;const s=t.toUpperCase();if(E(s)===void 0)throw new TypeError(`${t} is not a column.`);let n=this._columns.get(s);return n||(n=new ColumnDimension(this,s),this._columns.set(s,n)),n}})}get row_dimensions(){return new Proxy({},{get:(e,t)=>{if(typeof t!="string"||!/^[1-9]\d*$/u.test(t))throw new TypeError(`${String(t)} is not a row.`);const s=Number(t);let n=this._rows.get(s);return n||(n=new RowDimension(this,s),this._rows.set(s,n)),n}})}get tables(){return this._tables}get conditional_formatting(){return new pe(this._rules,()=>{this._parent._pending=!0})}get data_validations(){return new we(this._validations,()=>{this._parent._pending=!0})}add_data_validation(e){this._validations.push(e),this._parent._pending=!0}get auto_filter(){return this._filter}_changed(){this._parent._pending=!0}_heldPage(e){this._print=structuredClone(e?.print??{}),this._links={...e?.links},this._notes={...e?.notes},this._pictures=[...e?.pictures??[]],this._protect=e?.protect===!0}get page_setup(){return new Y(this)}get page_margins(){return new V(this)}get oddHeader(){return new A(this,"header")}get oddFooter(){return new A(this,"footer")}get protection(){return new q(()=>this._protect,e=>{this._protect=e,this._changed()})}get print_area(){return this._print.area}set print_area(e){if(e===void 0)delete this._print.area;else if(k(e))this._print.area=e;else throw new TypeError(`${e} is not a range.`);this._changed()}get print_title_rows(){return this._print.title_rows}set print_title_rows(e){e===void 0?delete this._print.title_rows:this._print.title_rows=e,this._changed()}get print_title_cols(){return this._print.title_cols}set print_title_cols(e){e===void 0?delete this._print.title_cols:this._print.title_cols=e,this._changed()}add_image(e,t){const s=t??e.anchor??"A1";if(!y(s))throw new TypeError(`${s} is not a cell.`);this._pictures.push({file:e.path,at:s,...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}),this._changed()}add_chart(e,t){e.anchor=de(t)??e.anchor,this._charts.push(e),this._parent._pending=!0}add_table(e){if(this._parent._tableNamed(e.name))throw new Error(`There is already a table named ${e.name}.`);this._tables.add(e),this._parent._pending=!0}}export class Workbook{worksheets=[];defined_names=new DefinedNameDict;data_only;title;path;block_cells=BLOCK_CELLS;_file={sheets:[]};_text="";_disk={text:"",csv:new Map};_csv=new Map;_model;_names=new Map;_active=0;_pending=!1;_making=!1;_calc=void 0;constructor(e={}){this.data_only=e.data_only??!1;const t=g(this,"Workbook",w,{key:s=>this.worksheets.find(n=>n.title===s),index:s=>this.worksheets[s]});return t.worksheets=[new Worksheet(t,"Sheet")],t}static open(e,t={}){const s=new Workbook(t);return s.path=e,s._read(e),s}_read(e){const{readFileSync:t}=J(),s=t($(e,P),"utf8"),n=new Map,o=r=>{try{const a=t($(e,r),"utf8");return n.set(r,a),a}catch{return}};this._load(s,o);for(const[r,a]of n)this._keepCsv(r,a);this._disk={text:s,csv:n}}_keepCsv(e,t){const s=Z(t);this._csv.set(e,{parsed:s,rows:s.records.map(n=>n.end===n.start?[]:[...n.fields])})}_load(e,t){const{workbook:s,problems:n}=I({text:e,read:t});if(!s)throw new Error(`sheet.yaml cannot be opened: ${n.map(o=>o.message).join("; ")}`);this._text=e,this._file=structuredClone(s.file),this._model=s,this.title=s.title,this.worksheets=s.sheets.map(o=>new Worksheet(this,o.name,o));for(const o of s.names.values()){if(o.source.path?.[0]!=="names")continue;const r=o.formula?o.formula.text:o.value??null;this._names.set(o.name,r),this.defined_names.add(new DefinedName(o.name,{attr_text:String(r)}))}}get active(){const e=this.worksheets[this._active]??this.worksheets[0];if(!e)throw new Error("The workbook has no sheets.");return e}set active(e){this._active=this.worksheets.indexOf(e)}get sheetnames(){return this.worksheets.map(e=>e.title)}get_sheet_by_name(e){return this.worksheets.find(t=>t.title===e)}index(e){return this.worksheets.indexOf(e)}create_sheet(e,t){let s=e??"Sheet";for(let o=1;this.worksheets.some(r=>r.title===s);o++)s=`${e??"Sheet"}${String(o)}`;const n=new Worksheet(this,s);return this.worksheets.splice(t??this.worksheets.length,0,n),this._pending=!0,n}remove(e){this.worksheets=this.worksheets.filter(t=>t!==e),this._pending=!0}move_sheet(e,t=0){const s=this.worksheets.indexOf(e);this.worksheets.splice(s,1),this.worksheets.splice(s+t,0,e),this._pending=!0}_tableNamed(e){for(const t of this.worksheets){const s=t._tables.get(e);if(s)return s}}_renameSheet(e,t,s){if(this.worksheets.some(o=>o!==e&&o.title===s))throw new Error(`There is already a sheet named ${s}.`);this._apply(),this._rewrite({op:"rename-sheet",from:t,to:s}),e._title=s,e._was=s;const n=this._file.sheets.find(o=>o.name===t);n&&(n.name=s),this._apply()}_restructure(e){this._apply();const t=_e({file:this._file,rows:new Map([...this._csv].map(([n,o])=>[n,o.rows]))},e);if(t.refused!==void 0)throw new Error(t.refused==="table-header"?"A table's header row is not deleted: delete the table's rows, or all of it.":"That sheet is not there.");this._file=t.file;for(const[n,o]of t.rows){const r=this._csv.get(n);r&&(r.rows=o.map(a=>[...a]))}for(const n of this.worksheets){const o=this._file.sheets.find(r=>r.name===n._title);n._cells.clear(),n._columns.clear(),n._rows.clear(),n._merges=[...o?.merges??[]],n._freeze=o?.freeze,n._heldPage(o),n._heldRules(o)}const s=this._build();this._rebase(s.text,s.files);for(const n of this.worksheets){const o=this._model?.sheet(n._title);if(o){n._lastRow=(o.used?.bottom??-1)+1;for(const r of o.tables){const a=n._tables.get(r.name);a&&(a.ref=x(r.area))}}}}_rewrite(e){const t=(n,o)=>{const r=F(n);if(!r.ok)return n;const a=oe(r.node,e,o);return a===r.node?n:B(a)},{_file:s}=this;if(s.names){for(const[n,o]of Object.entries(s.names))if(typeof o=="string"&&o.startsWith("=")){const r=t(o,s.sheets[0]?.name??"");s.names[n]=r,this._names.set(n,r);const a=this.defined_names.get(n);a&&(a.attr_text=r.slice(1))}}for(const n of s.checks??[])n.formula=t(n.formula,s.sheets[0]?.name??"");for(const n of s.sheets){for(const[o,r]of Object.entries(n.cells??{}))typeof r=="string"&&r.startsWith("=")?n.cells[o]=t(r,n.name):r!==null&&typeof r=="object"&&r.formula!==void 0&&(r.formula=t(r.formula,n.name));for(const o of n.tables??[]){for(const r of Object.values(o.columns??{}))r.formula!==void 0&&(r.formula=t(r.formula,n.name));this._rewriteCsv(o.rows,n.name,t)}for(const o of n.blocks??[])this._rewriteCsv(o.rows,n.name,t)}}_rewriteCsv(e,t,s){const n=this._csv.get(e);n&&(n.rows=n.rows.map(o=>o.map(r=>M(r).formula!==void 0?s(r,t):r)))}_sheetEntry(e){const t=e._was??e._title;let s=this._file.sheets.find(n=>n.name===t);return s||(s={name:e._title},this._file.sheets.push(s)),s.name=e._title,s}_dataPath(e){const t=`${G}/${Me(e)}`;let s=`${t}.csv`;const n=o=>this._csv.has(o)||this._file.sheets.some(r=>r.tables?.some(a=>a.rows===o)??r.blocks?.some(a=>a.rows===o));for(let o=2;n(s);o++)s=`${t}-${String(o)}.csv`;return s}_writeNewTable(e,t,s){const n=k(s.ref);if(!n)throw new Error(`${s.ref} is not a range.`);const o=[];for(let i=n.left;i<=n.right;i++){const h=e.cell(n.top+1,i+1).value;if(h===null||h==="")throw new Error(`Table ${s.name}'s header has no name at ${C({row:n.top,col:i})}.`);o.push(String(h))}const r={},a=[];o.forEach((i,h)=>{const _=n.left+h,d=this._columnFormula(e,n,_);d===void 0?a.push(h):r[i]={formula:d};const p=this._columnFormat(e,n,_);p!==void 0&&(r[i]={...r[i],format:p})}),this._columnsStyled(e,n);const f=[a.map(i=>o[i]??"")];for(let i=n.top+1;i<=n.bottom;i++)f.push(a.map(h=>v(e.cell(i+1,n.left+h+1))));t.cells&&(t.cells=Object.fromEntries(Object.entries(t.cells).filter(([i])=>{const h=y(i);return!h||!N(n,h.row,h.col)})));const c=this._dataPath(s.name);this._csv.set(c,{parsed:void 0,rows:f});const u={name:s.name,at:C({row:n.top,col:n.left}),rows:c,...s.key===void 0?{}:{key:s.key},...m(r)?{}:{columns:r}};(t.tables??=[]).push(u),s._spec=u}_columnsStyled(e,t){for(let s=t.left;s<=t.right;s++)for(let n=t.top+1;n<=t.bottom;n++){const o=e.cell(n+1,s+1),{format:r,...a}=this._ownLook(o);r!==void 0&&m(a)&&(o._styled=!1)}}_columnFormula(e,t,s){if(t.bottom<=t.top)return;const n=e.cell(t.top+2,s+1),o=R(n);if(o!==void 0){for(let r=t.top+2;r<=t.bottom;r++)if(R(e.cell(r+1,s+1))!==o)return;return n._formula}}_columnFormat(e,t,s){if(t.bottom<=t.top)return;const n=r=>this._ownLook(e.cell(r+1,s+1)).format,o=n(t.top+1);for(let r=t.top+2;r<=t.bottom;r++)if(n(r)!==o)return;return o}_held(e){const t=this._csv.get(e);if(!t)throw new Error(`${e} was not read.`);return t}_setCsvCell(e,t,s,n){const{rows:o}=this._held(e);for(;o.length<=t;)o.push([]);const r=o[t];if(r){for(;r.length<=s;)r.push("");r[s]=n}}_recordOf(e,t){let s=0;for(let n=0;n<t;){if(s+=1,s>=e.length)return s+t-n-1;e[s]?.length!==0&&(n+=1)}return s}_writeTableCell(e,t,s){const n=this._held(e.rows),o=n.rows[0]??[],r=s.column-1-t.left,a=this._recordOf(n.rows,s.row-1-t.top),f=Object.keys(e.columns??{}).filter(_=>!o.some(d=>d.trim().toLowerCase()===_.toLowerCase())),u=[...o.map(_=>_.trim()),...f][r];if(u===void 0)return;if(a===0){r<o.length&&(o[r]=v(s));return}const i=e.columns?.[u]?.formula;if(i!==void 0){const _=this._movedColumn(i,t,s);if(s._formula===_){const d=o.findIndex(p=>p.trim()===u);d>=0&&this._setCsvCell(e.rows,a,d,"");return}}let h=o.findIndex(_=>_.trim()===u);h<0&&(h=o.length,this._setCsvCell(e.rows,0,h,u)),this._setCsvCell(e.rows,a,h,v(s))}_movedColumn(e,t,s){const n=F(e);if(!n.ok)return e;const o=s.row-1-(t.top+1);return o===0?e:B(se(n.node,o,0))}_apply(){this.title===void 0?delete this._file.title:this._file.title=this.title;const e=new Set(this.worksheets.map(s=>s._was??s._title));this._file.sheets=this._file.sheets.filter(s=>e.has(s.name));for(const s of this.worksheets)this._applySheet(s);this._file.sheets=this.worksheets.map(s=>this._sheetEntry(s)),this._applyNames();const t=this._build();this._rebase(t.text,t.files)}_applyNames(){const e={};for(const t of this.defined_names.values()){const s=M(t.attr_text),n=this._names.get(t.name);e[t.name]=n!==void 0&&String(n).replace(/^=/u,"")===t.attr_text?n:typeof s.value=="number"||typeof s.value=="boolean"?s.value:/^"[^"]*"$/u.test(t.attr_text)?t.attr_text.slice(1,-1):`=${t.attr_text}`}m(e)?delete this._file.names:this._file.names=e}_applySheet(e){const t=this._sheetEntry(e);e._freeze===void 0?delete t.freeze:t.freeze=e._freeze,m(e._print)?delete t.print:t.print=e._print,m(e._links)?delete t.links:t.links=e._links,m(e._notes)?delete t.notes:t.notes=e._notes,e._pictures.length===0?delete t.pictures:t.pictures=e._pictures,e._protect?t.protect=!0:delete t.protect,e._merges.length===0?delete t.merges:t.merges=[...e._merges],e._state==="hidden"?t.hidden=!0:delete t.hidden,e._rules.length===0?delete t.conditional:t.conditional=[...e._rules],e._validations.length===0?delete t.validations:t.validations=e._validations.map(ke),e._charts.length===0?delete t.charts:t.charts=e._charts.map(n=>n._spec(e._title)),this._applyFilter(e,t);const s=new Set(t.tables?.map(n=>n.name.toLowerCase()));for(const n of e._tables.values())s.has(n.name.toLowerCase())||this._writeNewTable(e,t,n);this._applyTableFilters(e,t),this._applyCells(e,t),this._applyDimensions(e,t),t.cells&&m(t.cells)&&delete t.cells,t.columns&&m(t.columns)&&delete t.columns,t.rows&&m(t.rows)&&delete t.rows,t.format?.length===0&&delete t.format,t.tables?.length===0&&delete t.tables,t.blocks?.length===0&&delete t.blocks}_applyFilter(e,t){const{ref:s,_columns:n}=e._filter;if(s===void 0){delete t.filter;return}const o=k(s);if(!o)throw new TypeError(`${s} is not a range.`);const r={};for(const[a,f]of n)r[L(o.left+a)]=f;t.filter={range:s,...m(r)?{}:{columns:r}}}_applyTableFilters(e,t){for(const s of t.tables??[]){const n=e._tables.get(s.name);if(!n||n.autoFilter._columns.size===0)continue;const o=this._csv.get(s.rows)?.rows??[],r=ce(s,o)?.names??[],a={};for(const[f,c]of n.autoFilter._columns){const u=r[f];if(u===void 0)throw new RangeError(`Table ${s.name} has no column at ${String(f)}.`);a[u]=c}s.filter={columns:a}}}_applyDimensions(e,t){if(e._dimensions){for(const[s,n]of e._columns){const o={...t.columns?.[s]};n._width===void 0?delete o.width:o.width=n._width,n._hidden===void 0?delete o.hidden:o.hidden=n._hidden,n._files===void 0?delete o.files:o.files=n._files,n._level===void 0?delete o.level:o.level=n._level;const r=j(t.columns??{},s);t.columns=m(o)?r:{...r,[s]:o}}for(const[s,n]of e._rows){const o={...t.rows?.[String(s)]};n._height===void 0?delete o.height:o.height=n._height,n._hidden===void 0?delete o.hidden:o.hidden=n._hidden,n._level===void 0?delete o.level:o.level=n._level;const r=j(t.rows??{},String(s));t.rows=m(o)?r:{...r,[String(s)]:o}}e._dimensions=!1}}_applyCells(e,t){const s=(t.tables??[]).flatMap(r=>{const a=y(r.at),f=e._tables.get(r.name),c=f?k(f.ref):void 0;return a&&c?[{entry:r,area:c}]:[]}),n=(t.blocks??[]).flatMap(r=>{const a=e._model?.blocks.find(f=>f.file===r.rows);return a?[{entry:r,area:a.area}]:[]}),o=[];for(const r of e._cells.values()){if(!r._changed&&!r._styled)continue;const a=r.row-1,f=r.column-1,c=s.find(i=>N(i.area,a,f)),u=n.find(i=>N(i.area,a,f));c?(r._changed&&this._writeTableCell(c.entry,c.area,r),r._styled&&this._styleByFormat(t,r)):u?(r._changed&&this._setCsvCell(u.entry.rows,a-u.area.top,f-u.area.left,v(r)),r._styled&&this._styleByFormat(t,r)):r._fresh&&!e._model?.keys.has(a*16384+f)?o.push(r):this._writeLoose(e,t,r),r._changed=!1,r._styled=!1}this._consolidate(e,t,o),je(t)}_styleByFormat(e,t){(e.format??=[]).push({range:t.coordinate,...this._ownLook(t)})}_ownLook(e){const t=e._ws._model?.lookAt(e.row-1,e.column-1)??{},s=Fe(t,e._look);return s.format!==void 0&&e._formula===void 0&&M(v(e)).format===s.format&&delete s.format,s}_writeLoose(e,t,s){const n=s.coordinate,o=t.cells??={},r=U(s),a=this._ownLook(s),f=o[n],u={...f!==null&&typeof f=="object"?Object.fromEntries(Object.entries(f).filter(([_])=>_!=="value"&&_!=="formula"&&_!=="name")):{},...a},i=f!==null&&typeof f=="object"&&f.name!==void 0?{name:f.name}:{},h=e._model?.at(s.row-1,s.column-1)!==void 0;if(r===null&&m(u)&&!h){t.cells=j(o,n);return}o[n]=m(u)&&m(i)?r:{...typeof r=="string"&&r.startsWith("=")?{formula:r}:r===null?{}:{value:r},...i,...u}}_consolidate(e,t,s){const n=s.filter(i=>i._value!==null||i._formula!==void 0),o=new Map;for(const i of s){const h=this._ownLook(i);if(m(h))continue;const _=JSON.stringify(h),d=o.get(_);d?d.push(i):o.set(_,[i])}const r=new Map(n.map(i=>[`${String(i.row)}:${String(i.column)}`,i])),a=i=>r.get(`${String(i.row+1)}:${String(i.col+1)}`)??e.cell(i.row+1,i.col+1),f=new Map,c=[];for(const i of n){const h={row:i.row-1,col:i.column-1},_=i._formula===void 0?void 0:R(i);if(_===void 0){c.push(h);continue}const d=f.get(_);d?d.push(h):f.set(_,[h])}const u=t.cells??={};for(const i of f.values())for(const h of T(i))u[x(h)]=a({row:h.top,col:h.left})._formula??null;for(const i of T(c))if((i.bottom-i.top+1)*(i.right-i.left+1)>=this.block_cells){const _=[];for(let p=i.top;p<=i.bottom;p++){const D=[];for(let O=i.left;O<=i.right;O++)D.push(v(a({row:p,col:O})));_.push(D)}const d=this._dataPath(e._title);this._csv.set(d,{parsed:void 0,rows:_}),(t.blocks??=[]).push({at:C({row:i.top,col:i.left}),rows:d})}else for(let _=i.top;_<=i.bottom;_++)for(let d=i.left;d<=i.right;d++){const p=a({row:_,col:d});u[p.coordinate]=U(p)}for(const i of o.values()){const[h]=i;if(!h)continue;const _=this._ownLook(h),d=i.map(p=>({row:p.row-1,col:p.column-1}));for(const p of T(d))(t.format??=[]).push({range:x(p),..._})}}_build(){const e=new Map;for(const[t,s]of this._csv)e.set(t,s.parsed?re(s.parsed,s.rows):ee(s.rows));return{text:ue(this._text,this._file),files:e}}_rebase(e,t){const{workbook:s,problems:n}=I({text:e,read:o=>t.get(o)});if(!s)throw new Error(`The workbook is not one: ${n.map(o=>o.message).join("; ")}`);this._text=e,this._file=structuredClone(s.file),this._model=s;for(const[o,r]of t)this._keepCsv(o,r);this._calc=void 0,this._pending=!1;for(const o of this.worksheets){o._was=o._title;const r=s.sheet(o._title);r&&(o._model=r);for(const a of o._cells.values())a._fresh=r?.at(a.row-1,a.column-1)===void 0}this._names=new Map;for(const o of s.names.values())o.source.path?.[0]==="names"&&this._names.set(o.name,o.formula?o.formula.text:o.value??null)}_computed(){const e=[...this.defined_names.values()];if((this._pending||e.length!==this._names.size||e.some(t=>String(this._names.get(t.name)).replace(/^=/u,"")!==t.attr_text))&&this._apply(),!this._calc){const t=this._model;if(!t)throw new Error("The workbook has no sheets.");this._calc={calc:new Q(t).calculate(),model:t}}return this._calc}check(){this._apply();const{text:e,files:t}=this._build();return X({text:e,read:s=>t.get(s)}).problems}_generated(){if(this.worksheets.length===0)return this._applyNames(),{sheets:[],csv:{},...this._file.names?{names:this._file.names}:{}};this._apply();const e=structuredClone(this._file.sheets),t=n=>`${te}${n}`;for(const n of e){for(const o of n.tables??[])o.rows=t(o.rows);for(const o of n.blocks??[])o.rows=t(o.rows)}const s={};for(const[n,o]of this._build().files)s[t(n)]=o;return{sheets:e,csv:s,...this._file.names?{names:this._file.names}:{}}}save(e){if(this._making)throw new Error("sheet.ts makes sheets and saves nothing: what it adds to wb is what it makes.");const t=e??this.path;if(t===void 0)throw new TypeError("A new workbook is saved to a folder: wb.save('finance/budget').");if(this.worksheets.length===0)throw new Error("A workbook has at least one sheet.");const{text:s,csv:n}=this._disk;this._apply();const o=new Set(this._file.sheets.flatMap(i=>[...(i.tables??[]).map(h=>h.rows),...(i.blocks??[]).map(h=>h.rows)])),r=[...this._csv.keys()].filter(i=>!o.has(i));for(const i of r)this._csv.delete(i);const{mkdirSync:a,rmSync:f,writeFileSync:c}=J(),u=process.getBuiltinModule("node:path");a(t,{recursive:!0}),(this._text!==s||e!==void 0)&&c($(t,P),this._text);for(const[i,h]of this._csv){const _=h.parsed?.source??"";if(e===void 0&&n.get(i)===_)continue;const d=$(t,i);a(u.dirname(d),{recursive:!0}),c(d,_)}if(e===void 0||t===this.path)for(const i of r)f($(t,i),{force:!0});this._disk={text:this._text,csv:new Map([...this._csv].map(([i,h])=>[i,h.parsed?.source??""]))},this.path=t}}function R(l){if(l._formula===void 0)return;const e=F(l._formula);if(e.ok)return ne(e.node,l.row-1,l.column-1)}function je(l){const e=l.format;if(!e||e.length<2)return;const t=[],s=new Map;for(const n of e){const{range:o,...r}=n,a=y(o);if(!a){t.push(n);continue}const f=JSON.stringify(r),c=s.get(f);c?c.places.push(a):s.set(f,{look:r,places:[a]})}for(const{look:n,places:o}of s.values())for(const r of T(o))t.push({range:x(r),...n});l.format=t}export function load_workbook(l,e={}){return Workbook.open(l,e)}export const get_column_letter=l=>L(l-1);export function column_index_from_string(l){const e=E(l);if(e===void 0)throw new TypeError(`${l} is not a column.`);return e+1}export function coordinate_to_tuple(l){const e=y(l);if(!e)throw new TypeError(`${l} is not a cell.`);return[e.row+1,e.col+1]}export function range_boundaries(l){const e=k(l);if(!e)throw new TypeError(`${l} is not a range.`);return[e.left+1,e.top+1,e.right+1,e.bottom+1]}
2
+ import{strict as g}from"@allyhub/formats";import{Comment as z,HeaderFooter as A,PageMargins as G,PageSetup as V,SheetProtection as Y}from"./page.js";import{columnIndex as C,columnLetter as N,cellName as E,contains as F,rangeName as x,readAddress as y,readArea as k}from"../address.js";import{Calc as q}from"../calc/engine.js";import{checkWorkbook as Q}from"../check.js";import{readCsv as X,writeCsv as Z}from"@allyhub/formats";import{GENERATED as ee}from"../generated.js";import"@allyhub/formats";import{moveFormula as te,relativeKey as se}from"../formula/move.js";import{parseFormula as M}from"../formula/parse.js";import{printFormula as B}from"../formula/print.js";import{rewriteFormula as ne}from"../formula/rewrite.js";import{isDateCode as S}from"../format.js";import{patchCsv as oe}from"../patch.js";import{CellError as W,dateOfSerial as ie,isoOfSerial as re,readTyped as j,serialOfDate as le,writeTyped as ae}from"../values.js";import{FormulaCell as he,readWorkbook as I,validName as K}from"../workbook.js";import{restructure as fe,tableShape as ce}from"../structure.js";import{patchYaml as _e}from"../write.js";import{anchorOf as ue,chartOfSpec as de}from"./charts.js";import{HINT as w}from"./hint.js";import{rectangles as T}from"./rectangles.js";import{AutoFilter as J,ConditionalFormattingList as me,DataValidationList as pe,validationOf as we,validationSpec as ge}from"./rules.js";import{alignmentLook as ke,alignmentOf as ye,borderLook as be,borderOf as ve,fillLook as xe,fillOf as $e,fontLook as Ce,fontOf as Se}from"./styles.js";const R=()=>process.getBuiltinModule("node:fs"),O=(...l)=>process.getBuiltinModule("node:path").join(...l);function H(l){if(!/\.ya?ml$/iu.test(l))throw new TypeError(`${l} is not a sheet's file: a workbook is its YAML file, wb.save('finance/budget.yaml'), load_workbook('finance/budget.yaml').`);return l}export const BLOCK_CELLS=100;const Ee=l=>Math.round(l*7+5),Te=l=>(l-5)/7,Oe=l=>l*4/3,Le=l=>l*3/4;function Ne(l,e){const t={},s=l,n=e;for(const o of new Set([...Object.keys(s),...Object.keys(n)])){const i=n[o];JSON.stringify(i??!1)!==JSON.stringify(s[o]??!1)&&(t[o]=i??!1)}return t}const p=l=>Object.keys(l).length===0,b=(l,e)=>{if(!Number.isInteger(l)||l<1)throw new RangeError(`A ${e} is a whole number from 1: ${String(l)}.`);return l},D=(l,e)=>Object.fromEntries(Object.entries(l).filter(([t])=>t!==e));export class Cell{row;column;_ws;_value;_formula=void 0;_look;_changed=!1;_styled=!1;_fresh=!1;constructor(e,t,s){this._ws=e,this.row=t,this.column=s;const n=t-1,o=s-1,i=e._model?.at(n,o);return this._value=null,i instanceof he?this._formula=i.text:i!==void 0&&(this._value=i),this._look=e._model?.lookAt(n,o)??{},this._fresh=i===void 0,g(this,"Cell",w)}get parent(){return this._ws}get coordinate(){return E({row:this.row-1,col:this.column-1})}get column_letter(){return N(this.column-1)}get col_idx(){return this.column}get value(){return this._ws.parent.data_only?this.computed:this._formula!==void 0?this._formula:this._shown(this._value)}set value(e){if(e===void 0)throw new TypeError(`${this.coordinate}: a value is not undefined.`);if(this._formula=void 0,this._changed=!0,this._ws.parent._pending=!0,e instanceof Date){if(Number.isNaN(e.getTime()))throw new TypeError(`${this.coordinate}: the date is not valid.`);this._value=le(e),S(this._look.format)||(this._look={...this._look,format:Number.isInteger(this._value)?"yyyy-mm-dd":"yyyy-mm-dd hh:mm"});return}if(typeof e=="string"&&e.length>1&&e.startsWith("=")){this._formula=e,this._value=null;return}this._value=e}_shown(e){return typeof e=="number"&&S(this._look.format)?ie(e)??e:e instanceof W?e.code:e}get computed(){const{calc:e,model:t}=this._ws.parent._computed(),s=t.sheet(this._ws.title);return s?this._shown(e.value(s,this.row-1,this.column-1)):null}get data_type(){if(this._formula!==void 0)return"f";const e=this._value;return e===null?"n":typeof e=="number"?S(this._look.format)?"d":"n":typeof e=="boolean"?"b":e instanceof W?"e":"s"}get is_date(){return this.data_type==="d"}get hyperlink(){return this._ws._links[this.coordinate]}set hyperlink(e){e===void 0?Reflect.deleteProperty(this._ws._links,this.coordinate):this._ws._links[this.coordinate]=e,this._ws._changed()}get comment(){const e=this._ws._notes[this.coordinate];if(e!==void 0)return typeof e=="string"?new z(e):new z(e.text,e.author)}set comment(e){e===void 0?Reflect.deleteProperty(this._ws._notes,this.coordinate):this._ws._notes[this.coordinate]=e._file(),this._ws._changed()}get number_format(){return this._look.format??"General"}set number_format(e){this._setLook({format:e})}_setLook(e){this._look={...this._look,...e},this._styled=!0,this._ws.parent._pending=!0}get font(){return Se(this._look)}set font(e){this._setLook(Ce(e))}get fill(){return $e(this._look)}set fill(e){this._setLook(xe(e))}get border(){return ve(this._look)}set border(e){this._setLook(be(e))}get alignment(){return ye(this._look)}set alignment(e){this._setLook(ke(e))}get has_style(){return!p(this._look)}offset(e=0,t=0){return this._ws.cell(this.row+e,this.column+t)}}export class ColumnDimension{index;_width;_hidden;_files;_level;_ws;constructor(e,t){this._ws=e,this.index=t;const s=e._spec()?.columns?.[t];return this._level=s?.level,this._width=s?.width,this._hidden=s?.hidden,this._files=s?.files,g(this,"ColumnDimension",w)}get outlineLevel(){return this._level}set outlineLevel(e){this._level=e,this._ws._dimensions=!0}get files(){return this._files}set files(e){this._files=e,this._ws._dimensions=!0}get width(){return this._width===void 0?void 0:Te(this._width)}set width(e){this._width=e===void 0?void 0:Ee(e),this._ws._dimensions=!0}get hidden(){return this._hidden??!1}set hidden(e){this._hidden=e,this._ws._dimensions=!0}}export class RowDimension{index;_height;_hidden;_level;_ws;constructor(e,t){this._ws=e,this.index=t;const s=e._spec()?.rows?.[String(t)];return this._level=s?.level,this._height=s?.height,this._hidden=s?.hidden,g(this,"RowDimension",w)}get outlineLevel(){return this._level}set outlineLevel(e){this._level=e,this._ws._dimensions=!0}get height(){return this._height===void 0?void 0:Le(this._height)}set height(e){this._height=e===void 0?void 0:Oe(e),this._ws._dimensions=!0}get hidden(){return this._hidden??!1}set hidden(e){this._hidden=e,this._ws._dimensions=!0}}export class Table{displayName;ref;key;_spec;autoFilter;constructor(e){for(const t of Object.keys(e))if(!["displayName","ref","key"].includes(t))throw new TypeError(`Table takes displayName, ref and key; it has no ${t}. ${w}`);if(!K(e.displayName))throw new TypeError(`${e.displayName} cannot be a table's name.`);if(!k(e.ref))throw new TypeError(`${e.ref} is not a range.`);return this.displayName=e.displayName,this.ref=e.ref,this.key=e.key,this.autoFilter=new J(e.ref,()=>{}),g(this,"Table",w)}get name(){return this.displayName}}export class TableList{_items=new Map;constructor(){return g(this,"TableList",w,{key:e=>this._items.get(e)})}add(e){this._items.set(e.name,e)}get(e){return this._items.get(e)}keys(){return[...this._items.keys()]}values(){return[...this._items.values()]}items(){return[...this._items.entries()]}pop(e){const t=this._items.get(e);return this._items.delete(e),t}}export class DefinedName{name;attr_text;constructor(e,t){if(!K(e))throw new TypeError(`${e} cannot be a name.`);return this.name=e,this.attr_text=t.attr_text.replace(/^=/u,""),g(this,"DefinedName",w)}get value(){return this.attr_text}set value(e){this.attr_text=e.replace(/^=/u,"")}}export class DefinedNameDict{_items=new Map;constructor(){return g(this,"DefinedNameDict",w,{key:e=>this._items.get(e),setKey:(e,t)=>t instanceof DefinedName?(this._items.set(e,t),!0):!1})}add(e){this._items.set(e.name,e)}get(e){return this._items.get(e)}keys(){return[...this._items.keys()]}values(){return[...this._items.values()]}items(){return[...this._items.entries()]}pop(e){const t=this._items.get(e);return this._items.delete(e),t}}const v=l=>{if(l._formula!==void 0)return l._formula;const e=l._value;return typeof e=="number"&&S(l._look.format)?re(e):ae(e)};function U(l){if(l._formula!==void 0)return l._formula;const e=l._value;return e===null?null:typeof e=="number"&&!S(l._look.format)||typeof e=="boolean"?e:v(l)}const Fe=l=>l.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"")||"rows";export class Worksheet{_parent;_title;_was;_model;_cells=new Map;_columns=new Map;_rows=new Map;_tables=new TableList;_freeze;_merges=[];_state="visible";_dimensions=!1;_lastRow=0;_rules=[];_validations=[];_filter;_charts=[];_print={};_links={};_notes={};_pictures=[];_protect=!1;constructor(e,t,s){if(this._parent=e,this._title=t,this._filter=new J(void 0,()=>{this._parent._pending=!0}),s){this._model=s,this._was=t,this._freeze=s.spec.freeze,this._heldPage(s.spec),this._merges=[...s.spec.merges??[]],this._state=s.spec.hidden===!0?"hidden":"visible",this._lastRow=(s.used?.bottom??-1)+1,this._heldRules(s.spec);for(const n of s.tables){const o=new Table({displayName:n.name,ref:x(n.area),...n.spec.key===void 0?{}:{key:n.spec.key}});o._spec=n.spec;const{filter:i}=n.spec;if(i)for(const[a,h]of Object.entries(i.columns)){const d=n.column(a);d&&o.autoFilter._columns.set(d.index,h)}this._tables.add(o)}}return g(this,"Worksheet",w,{index:n=>this._rowCells(n),key:n=>this._at(n),setKey:(n,o)=>{const i=y(n);return i?(this.cell(i.row+1,i.col+1).value=o,!0):!1}})}_spec(){return this._parent._file.sheets.find(e=>e.name===(this._was??this._title))}_heldRules(e){this._rules=[...e?.conditional??[]],this._validations=(e?.validations??[]).map(we),this._charts=(e?.charts??[]).map(de),this._filter.ref=e?.filter?.range,this._filter._columns.clear();const t=e?.filter?k(e.filter.range):void 0;for(const[s,n]of Object.entries(e?.filter?.columns??{})){const o=C(s);t&&o!==void 0&&this._filter._columns.set(o-t.left,n)}}_at(e){const t=y(e);if(t)return this.cell(t.row+1,t.col+1);const s=k(e);if(s)return this._area(s);const n=C(e);if(n!==void 0){const o=[];for(let i=1;i<=this.max_row;i++)o.push(this.cell(i,n+1));return o}}_rowCells(e){const t=[];for(let s=1;s<=this.max_column;s++)t.push(this.cell(e,s));return t}_area(e){const t=[];for(let s=e.top;s<=e.bottom;s++){const n=[];for(let o=e.left;o<=e.right;o++)n.push(this.cell(s+1,o+1));t.push(n)}return t}get parent(){return this._parent}get title(){return this._title}set title(e){const t=this._title;e!==t&&this._parent._renameSheet(this,t,e)}get sheet_state(){return this._state}set sheet_state(e){this._state=e}cell(e,t,s){if(e<1||t<1)throw new RangeError(`Row and column values must be at least 1: ${String(e)}, ${String(t)}.`);const n=(e-1)*16384+t-1;let o=this._cells.get(n);return o||(o=new Cell(this,e,t),this._cells.set(n,o)),s!==void 0&&(o.value=s),e>this._lastRow&&(this._lastRow=e),o}append(e){const t=this._lastRow+1,s=(n,o)=>{o!=null&&this.cell(t,n,o)};if(Array.isArray(e))e.forEach((n,o)=>{s(o+1,n)});else for(const[n,o]of Object.entries(e)){const i=/^\d+$/u.test(n)?Number(n)-1:C(n);if(i===void 0)throw new TypeError(`${n} is not a column.`);s(i+1,o)}this._lastRow=t}get max_row(){return Math.max(1,this._lastRow)}get max_column(){let e=this._model?.columnsUsed??0;for(const t of this._cells.values())(t._value!==null||t._formula!==void 0)&&t.column>e&&(e=t.column);return Math.max(1,e)}min_row=1;min_column=1;get dimensions(){return x({top:0,left:0,bottom:this.max_row-1,right:this.max_column-1})}iter_rows(e={}){const t=this._area({top:(e.min_row??1)-1,left:(e.min_col??1)-1,bottom:(e.max_row??this.max_row)-1,right:(e.max_col??this.max_column)-1});return e.values_only===!0?t.map(s=>s.map(n=>n.value)):t}iter_cols(e={}){const t=this.iter_rows(e);return(t[0]??[]).map((n,o)=>t.map(i=>i[o]))}get rows(){return this.iter_rows()}get columns(){return this.iter_cols()}get values(){return this.iter_rows({values_only:!0})}insert_rows(e,t=1){this._parent._restructure({op:"insert-rows",sheet:this._title,at:b(e,"row")-1,count:b(t,"amount")})}delete_rows(e,t=1){this._parent._restructure({op:"delete-rows",sheet:this._title,at:b(e,"row")-1,count:b(t,"amount")})}insert_cols(e,t=1){this._parent._restructure({op:"insert-columns",sheet:this._title,at:b(e,"column")-1,count:b(t,"amount")})}delete_cols(e,t=1){this._parent._restructure({op:"delete-columns",sheet:this._title,at:b(e,"column")-1,count:b(t,"amount")})}merge_cells(e){if(!k(e))throw new TypeError(`${e} is not a range.`);this._merges.includes(e)||this._merges.push(e),this._parent._pending=!0}unmerge_cells(e){this._merges=this._merges.filter(t=>t!==e),this._parent._pending=!0}get merged_cells(){return[...this._merges]}get freeze_panes(){return this._freeze}set freeze_panes(e){const t=e instanceof Cell?e.coordinate:e;if(t!==void 0&&!y(t))throw new TypeError(`${t} is not a cell.`);this._freeze=t,this._parent._pending=!0}get column_dimensions(){return new Proxy({},{get:(e,t)=>{if(typeof t!="string")return;const s=t.toUpperCase();if(C(s)===void 0)throw new TypeError(`${t} is not a column.`);let n=this._columns.get(s);return n||(n=new ColumnDimension(this,s),this._columns.set(s,n)),n}})}get row_dimensions(){return new Proxy({},{get:(e,t)=>{if(typeof t!="string"||!/^[1-9]\d*$/u.test(t))throw new TypeError(`${String(t)} is not a row.`);const s=Number(t);let n=this._rows.get(s);return n||(n=new RowDimension(this,s),this._rows.set(s,n)),n}})}get tables(){return this._tables}get conditional_formatting(){return new me(this._rules,()=>{this._parent._pending=!0})}get data_validations(){return new pe(this._validations,()=>{this._parent._pending=!0})}add_data_validation(e){this._validations.push(e),this._parent._pending=!0}get auto_filter(){return this._filter}_changed(){this._parent._pending=!0}_heldPage(e){this._print=structuredClone(e?.print??{}),this._links={...e?.links},this._notes={...e?.notes},this._pictures=[...e?.pictures??[]],this._protect=e?.protect===!0}get page_setup(){return new V(this)}get page_margins(){return new G(this)}get oddHeader(){return new A(this,"header")}get oddFooter(){return new A(this,"footer")}get protection(){return new Y(()=>this._protect,e=>{this._protect=e,this._changed()})}get print_area(){return this._print.area}set print_area(e){if(e===void 0)delete this._print.area;else if(k(e))this._print.area=e;else throw new TypeError(`${e} is not a range.`);this._changed()}get print_title_rows(){return this._print.title_rows}set print_title_rows(e){e===void 0?delete this._print.title_rows:this._print.title_rows=e,this._changed()}get print_title_cols(){return this._print.title_cols}set print_title_cols(e){e===void 0?delete this._print.title_cols:this._print.title_cols=e,this._changed()}add_image(e,t){const s=t??e.anchor??"A1";if(!y(s))throw new TypeError(`${s} is not a cell.`);this._pictures.push({file:e.path,at:s,...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}),this._changed()}add_chart(e,t){e.anchor=ue(t)??e.anchor,this._charts.push(e),this._parent._pending=!0}add_table(e){if(this._parent._tableNamed(e.name))throw new Error(`There is already a table named ${e.name}.`);this._tables.add(e),this._parent._pending=!0}}export class Workbook{worksheets=[];defined_names=new DefinedNameDict;data_only;title;path;block_cells=BLOCK_CELLS;_file={sheets:[]};_text="";_disk={text:"",csv:new Map};_csv=new Map;_model;_names=new Map;_active=0;_pending=!1;_making=!1;_calc=void 0;constructor(e={}){this.data_only=e.data_only??!1;const t=g(this,"Workbook",w,{key:s=>this.worksheets.find(n=>n.title===s),index:s=>this.worksheets[s]});return t.worksheets=[new Worksheet(t,"Sheet")],t}static open(e,t={}){const s=new Workbook(t);return s.path=H(e),s._read(s.path),s}_read(e){const{readFileSync:t}=R(),s=t(e,"utf8"),n=process.getBuiltinModule("node:path").dirname(e),o=new Map,i=a=>{try{const h=t(O(n,a),"utf8");return o.set(a,h),h}catch{return}};this._load(s,i);for(const[a,h]of o)this._keepCsv(a,h);this._disk={text:s,csv:o}}_keepCsv(e,t){const s=X(t);this._csv.set(e,{parsed:s,rows:s.records.map(n=>n.end===n.start?[]:[...n.fields])})}_load(e,t){const{workbook:s,problems:n}=I({text:e,read:t});if(!s)throw new Error(`The workbook cannot be opened: ${n.map(o=>o.message).join("; ")}`);this._text=e,this._file=structuredClone(s.file),this._model=s,this.title=s.title,this.worksheets=s.sheets.map(o=>new Worksheet(this,o.name,o));for(const o of s.names.values()){if(o.source.path?.[0]!=="names")continue;const i=o.formula?o.formula.text:o.value??null;this._names.set(o.name,i),this.defined_names.add(new DefinedName(o.name,{attr_text:String(i)}))}}get active(){const e=this.worksheets[this._active]??this.worksheets[0];if(!e)throw new Error("The workbook has no sheets.");return e}set active(e){this._active=this.worksheets.indexOf(e)}get sheetnames(){return this.worksheets.map(e=>e.title)}get_sheet_by_name(e){return this.worksheets.find(t=>t.title===e)}index(e){return this.worksheets.indexOf(e)}create_sheet(e,t){let s=e??"Sheet";for(let o=1;this.worksheets.some(i=>i.title===s);o++)s=`${e??"Sheet"}${String(o)}`;const n=new Worksheet(this,s);return this.worksheets.splice(t??this.worksheets.length,0,n),this._pending=!0,n}remove(e){this.worksheets=this.worksheets.filter(t=>t!==e),this._pending=!0}move_sheet(e,t=0){const s=this.worksheets.indexOf(e);this.worksheets.splice(s,1),this.worksheets.splice(s+t,0,e),this._pending=!0}_tableNamed(e){for(const t of this.worksheets){const s=t._tables.get(e);if(s)return s}}_renameSheet(e,t,s){if(this.worksheets.some(o=>o!==e&&o.title===s))throw new Error(`There is already a sheet named ${s}.`);this._apply(),this._rewrite({op:"rename-sheet",from:t,to:s}),e._title=s,e._was=s;const n=this._file.sheets.find(o=>o.name===t);n&&(n.name=s),this._apply()}_restructure(e){this._apply();const t=fe({file:this._file,rows:new Map([...this._csv].map(([n,o])=>[n,o.rows]))},e);if(t.refused!==void 0)throw new Error(t.refused==="table-header"?"A table's header row is not deleted: delete the table's rows, or all of it.":"That sheet is not there.");this._file=t.file;for(const[n,o]of t.rows){const i=this._csv.get(n);i&&(i.rows=o.map(a=>[...a]))}for(const n of this.worksheets){const o=this._file.sheets.find(i=>i.name===n._title);n._cells.clear(),n._columns.clear(),n._rows.clear(),n._merges=[...o?.merges??[]],n._freeze=o?.freeze,n._heldPage(o),n._heldRules(o)}const s=this._build();this._rebase(s.text,s.files);for(const n of this.worksheets){const o=this._model?.sheet(n._title);if(o){n._lastRow=(o.used?.bottom??-1)+1;for(const i of o.tables){const a=n._tables.get(i.name);a&&(a.ref=x(i.area))}}}}_rewrite(e){const t=(n,o)=>{const i=M(n);if(!i.ok)return n;const a=ne(i.node,e,o);return a===i.node?n:B(a)},{_file:s}=this;if(s.names){for(const[n,o]of Object.entries(s.names))if(typeof o=="string"&&o.startsWith("=")){const i=t(o,s.sheets[0]?.name??"");s.names[n]=i,this._names.set(n,i);const a=this.defined_names.get(n);a&&(a.attr_text=i.slice(1))}}for(const n of s.checks??[])n.formula=t(n.formula,s.sheets[0]?.name??"");for(const n of s.sheets){for(const[o,i]of Object.entries(n.cells??{}))typeof i=="string"&&i.startsWith("=")?n.cells[o]=t(i,n.name):i!==null&&typeof i=="object"&&i.formula!==void 0&&(i.formula=t(i.formula,n.name));for(const o of n.tables??[]){for(const i of Object.values(o.columns??{}))i.formula!==void 0&&(i.formula=t(i.formula,n.name));this._rewriteCsv(o.rows,n.name,t)}for(const o of n.blocks??[])this._rewriteCsv(o.rows,n.name,t)}}_rewriteCsv(e,t,s){const n=this._csv.get(e);n&&(n.rows=n.rows.map(o=>o.map(i=>j(i).formula!==void 0?s(i,t):i)))}_sheetEntry(e){const t=e._was??e._title;let s=this._file.sheets.find(n=>n.name===t);return s||(s={name:e._title},this._file.sheets.push(s)),s.name=e._title,s}_dataPath(e){const t=Fe(e);let s=`${t}.csv`;const n=this.path===void 0?void 0:process.getBuiltinModule("node:path").dirname(this.path),o=i=>this._csv.has(i)||this._file.sheets.some(a=>a.tables?.some(h=>h.rows===i)??a.blocks?.some(h=>h.rows===i))||n!==void 0&&R().existsSync(O(n,i));for(let i=2;o(s);i++)s=`${t}-${String(i)}.csv`;return s}_writeNewTable(e,t,s){const n=k(s.ref);if(!n)throw new Error(`${s.ref} is not a range.`);const o=[];for(let r=n.left;r<=n.right;r++){const c=e.cell(n.top+1,r+1).value;if(c===null||c==="")throw new Error(`Table ${s.name}'s header has no name at ${E({row:n.top,col:r})}.`);o.push(String(c))}const i={},a=[];o.forEach((r,c)=>{const f=n.left+c,_=this._columnFormula(e,n,f);_===void 0?a.push(c):i[r]={formula:_};const m=this._columnFormat(e,n,f);m!==void 0&&(i[r]={...i[r],format:m})}),this._columnsStyled(e,n);const h=[a.map(r=>o[r]??"")];for(let r=n.top+1;r<=n.bottom;r++)h.push(a.map(c=>v(e.cell(r+1,n.left+c+1))));t.cells&&(t.cells=Object.fromEntries(Object.entries(t.cells).filter(([r])=>{const c=y(r);return!c||!F(n,c.row,c.col)})));const d=this._dataPath(s.name);this._csv.set(d,{parsed:void 0,rows:h});const u={name:s.name,at:E({row:n.top,col:n.left}),rows:d,...s.key===void 0?{}:{key:s.key},...p(i)?{}:{columns:i}};(t.tables??=[]).push(u),s._spec=u}_columnsStyled(e,t){for(let s=t.left;s<=t.right;s++)for(let n=t.top+1;n<=t.bottom;n++){const o=e.cell(n+1,s+1),{format:i,...a}=this._ownLook(o);i!==void 0&&p(a)&&(o._styled=!1)}}_columnFormula(e,t,s){if(t.bottom<=t.top)return;const n=e.cell(t.top+2,s+1),o=P(n);if(o!==void 0){for(let i=t.top+2;i<=t.bottom;i++)if(P(e.cell(i+1,s+1))!==o)return;return n._formula}}_columnFormat(e,t,s){if(t.bottom<=t.top)return;const n=i=>this._ownLook(e.cell(i+1,s+1)).format,o=n(t.top+1);for(let i=t.top+2;i<=t.bottom;i++)if(n(i)!==o)return;return o}_held(e){const t=this._csv.get(e);if(!t)throw new Error(`${e} was not read.`);return t}_setCsvCell(e,t,s,n){const{rows:o}=this._held(e);for(;o.length<=t;)o.push([]);const i=o[t];if(i){for(;i.length<=s;)i.push("");i[s]=n}}_recordOf(e,t){let s=0;for(let n=0;n<t;){if(s+=1,s>=e.length)return s+t-n-1;e[s]?.length!==0&&(n+=1)}return s}_writeTableCell(e,t,s){const n=this._held(e.rows),o=n.rows[0]??[],i=s.column-1-t.left,a=this._recordOf(n.rows,s.row-1-t.top),h=Object.keys(e.columns??{}).filter(f=>!o.some(_=>_.trim().toLowerCase()===f.toLowerCase())),u=[...o.map(f=>f.trim()),...h][i];if(u===void 0)return;if(a===0){i<o.length&&(o[i]=v(s));return}const r=e.columns?.[u]?.formula;if(r!==void 0){const f=this._movedColumn(r,t,s);if(s._formula===f){const _=o.findIndex(m=>m.trim()===u);_>=0&&this._setCsvCell(e.rows,a,_,"");return}}let c=o.findIndex(f=>f.trim()===u);c<0&&(c=o.length,this._setCsvCell(e.rows,0,c,u)),this._setCsvCell(e.rows,a,c,v(s))}_movedColumn(e,t,s){const n=M(e);if(!n.ok)return e;const o=s.row-1-(t.top+1);return o===0?e:B(te(n.node,o,0))}_apply(){this.title===void 0?delete this._file.title:this._file.title=this.title;const e=new Set(this.worksheets.map(s=>s._was??s._title));this._file.sheets=this._file.sheets.filter(s=>e.has(s.name));for(const s of this.worksheets)this._applySheet(s);this._file.sheets=this.worksheets.map(s=>this._sheetEntry(s)),this._applyNames();const t=this._build();this._rebase(t.text,t.files)}_applyNames(){const e={};for(const t of this.defined_names.values()){const s=j(t.attr_text),n=this._names.get(t.name);e[t.name]=n!==void 0&&String(n).replace(/^=/u,"")===t.attr_text?n:typeof s.value=="number"||typeof s.value=="boolean"?s.value:/^"[^"]*"$/u.test(t.attr_text)?t.attr_text.slice(1,-1):`=${t.attr_text}`}p(e)?delete this._file.names:this._file.names=e}_applySheet(e){const t=this._sheetEntry(e);e._freeze===void 0?delete t.freeze:t.freeze=e._freeze,p(e._print)?delete t.print:t.print=e._print,p(e._links)?delete t.links:t.links=e._links,p(e._notes)?delete t.notes:t.notes=e._notes,e._pictures.length===0?delete t.pictures:t.pictures=e._pictures,e._protect?t.protect=!0:delete t.protect,e._merges.length===0?delete t.merges:t.merges=[...e._merges],e._state==="hidden"?t.hidden=!0:delete t.hidden,e._rules.length===0?delete t.conditional:t.conditional=[...e._rules],e._validations.length===0?delete t.validations:t.validations=e._validations.map(ge),e._charts.length===0?delete t.charts:t.charts=e._charts.map(n=>n._spec(e._title)),this._applyFilter(e,t);const s=new Set(t.tables?.map(n=>n.name.toLowerCase()));for(const n of e._tables.values())s.has(n.name.toLowerCase())||this._writeNewTable(e,t,n);this._applyTableFilters(e,t),this._applyCells(e,t),this._applyDimensions(e,t),t.cells&&p(t.cells)&&delete t.cells,t.columns&&p(t.columns)&&delete t.columns,t.rows&&p(t.rows)&&delete t.rows,t.format?.length===0&&delete t.format,t.tables?.length===0&&delete t.tables,t.blocks?.length===0&&delete t.blocks}_applyFilter(e,t){const{ref:s,_columns:n}=e._filter;if(s===void 0){delete t.filter;return}const o=k(s);if(!o)throw new TypeError(`${s} is not a range.`);const i={};for(const[a,h]of n)i[N(o.left+a)]=h;t.filter={range:s,...p(i)?{}:{columns:i}}}_applyTableFilters(e,t){for(const s of t.tables??[]){const n=e._tables.get(s.name);if(!n||n.autoFilter._columns.size===0)continue;const o=this._csv.get(s.rows)?.rows??[],i=ce(s,o)?.names??[],a={};for(const[h,d]of n.autoFilter._columns){const u=i[h];if(u===void 0)throw new RangeError(`Table ${s.name} has no column at ${String(h)}.`);a[u]=d}s.filter={columns:a}}}_applyDimensions(e,t){if(e._dimensions){for(const[s,n]of e._columns){const o={...t.columns?.[s]};n._width===void 0?delete o.width:o.width=n._width,n._hidden===void 0?delete o.hidden:o.hidden=n._hidden,n._files===void 0?delete o.files:o.files=n._files,n._level===void 0?delete o.level:o.level=n._level;const i=D(t.columns??{},s);t.columns=p(o)?i:{...i,[s]:o}}for(const[s,n]of e._rows){const o={...t.rows?.[String(s)]};n._height===void 0?delete o.height:o.height=n._height,n._hidden===void 0?delete o.hidden:o.hidden=n._hidden,n._level===void 0?delete o.level:o.level=n._level;const i=D(t.rows??{},String(s));t.rows=p(o)?i:{...i,[String(s)]:o}}e._dimensions=!1}}_applyCells(e,t){const s=(t.tables??[]).flatMap(i=>{const a=y(i.at),h=e._tables.get(i.name),d=h?k(h.ref):void 0;return a&&d?[{entry:i,area:d}]:[]}),n=(t.blocks??[]).flatMap(i=>{const a=e._model?.blocks.find(h=>h.file===i.rows);return a?[{entry:i,area:a.area}]:[]}),o=[];for(const i of e._cells.values()){if(!i._changed&&!i._styled)continue;const a=i.row-1,h=i.column-1,d=s.find(r=>F(r.area,a,h)),u=n.find(r=>F(r.area,a,h));d?(i._changed&&this._writeTableCell(d.entry,d.area,i),i._styled&&this._styleByFormat(t,i)):u?(i._changed&&this._setCsvCell(u.entry.rows,a-u.area.top,h-u.area.left,v(i)),i._styled&&this._styleByFormat(t,i)):i._fresh&&!e._model?.keys.has(a*16384+h)?o.push(i):this._writeLoose(e,t,i),i._changed=!1,i._styled=!1}this._consolidate(e,t,o),Me(t)}_styleByFormat(e,t){(e.format??=[]).push({range:t.coordinate,...this._ownLook(t)})}_ownLook(e){const t=e._ws._model?.lookAt(e.row-1,e.column-1)??{},s=Ne(t,e._look);return s.format!==void 0&&e._formula===void 0&&j(v(e)).format===s.format&&delete s.format,s}_writeLoose(e,t,s){const n=s.coordinate,o=t.cells??={},i=U(s),a=this._ownLook(s),h=o[n],u={...h!==null&&typeof h=="object"?Object.fromEntries(Object.entries(h).filter(([f])=>f!=="value"&&f!=="formula"&&f!=="name")):{},...a},r=h!==null&&typeof h=="object"&&h.name!==void 0?{name:h.name}:{},c=e._model?.at(s.row-1,s.column-1)!==void 0;if(i===null&&p(u)&&!c){t.cells=D(o,n);return}o[n]=p(u)&&p(r)?i:{...typeof i=="string"&&i.startsWith("=")?{formula:i}:i===null?{}:{value:i},...r,...u}}_consolidate(e,t,s){const n=s.filter(r=>r._value!==null||r._formula!==void 0),o=new Map;for(const r of s){const c=this._ownLook(r);if(p(c))continue;const f=JSON.stringify(c),_=o.get(f);_?_.push(r):o.set(f,[r])}const i=new Map(n.map(r=>[`${String(r.row)}:${String(r.column)}`,r])),a=r=>i.get(`${String(r.row+1)}:${String(r.col+1)}`)??e.cell(r.row+1,r.col+1),h=new Map,d=[];for(const r of n){const c={row:r.row-1,col:r.column-1},f=r._formula===void 0?void 0:P(r);if(f===void 0){d.push(c);continue}const _=h.get(f);_?_.push(c):h.set(f,[c])}const u=t.cells??={};for(const r of h.values())for(const c of T(r))u[x(c)]=a({row:c.top,col:c.left})._formula??null;for(const r of T(d))if((r.bottom-r.top+1)*(r.right-r.left+1)>=this.block_cells){const f=[];for(let m=r.top;m<=r.bottom;m++){const $=[];for(let L=r.left;L<=r.right;L++)$.push(v(a({row:m,col:L})));f.push($)}const _=this._dataPath(e._title);this._csv.set(_,{parsed:void 0,rows:f}),(t.blocks??=[]).push({at:E({row:r.top,col:r.left}),rows:_})}else for(let f=r.top;f<=r.bottom;f++)for(let _=r.left;_<=r.right;_++){const m=a({row:f,col:_});u[m.coordinate]=U(m)}for(const r of o.values()){const[c]=r;if(!c)continue;const f=this._ownLook(c),_=r.map(m=>({row:m.row-1,col:m.column-1}));for(const m of T(_))(t.format??=[]).push({range:x(m),...f})}}_build(){const e=new Map;for(const[t,s]of this._csv)e.set(t,s.parsed?oe(s.parsed,s.rows):Z(s.rows));return{text:_e(this._text,this._file),files:e}}_rebase(e,t){const{workbook:s,problems:n}=I({text:e,read:o=>t.get(o)});if(!s)throw new Error(`The workbook is not one: ${n.map(o=>o.message).join("; ")}`);this._text=e,this._file=structuredClone(s.file),this._model=s;for(const[o,i]of t)this._keepCsv(o,i);this._calc=void 0,this._pending=!1;for(const o of this.worksheets){o._was=o._title;const i=s.sheet(o._title);i&&(o._model=i);for(const a of o._cells.values())a._fresh=i?.at(a.row-1,a.column-1)===void 0}this._names=new Map;for(const o of s.names.values())o.source.path?.[0]==="names"&&this._names.set(o.name,o.formula?o.formula.text:o.value??null)}_computed(){const e=[...this.defined_names.values()];if((this._pending||e.length!==this._names.size||e.some(t=>String(this._names.get(t.name)).replace(/^=/u,"")!==t.attr_text))&&this._apply(),!this._calc){const t=this._model;if(!t)throw new Error("The workbook has no sheets.");this._calc={calc:new q(t).calculate(),model:t}}return this._calc}check(){this._apply();const{text:e,files:t}=this._build();return Q({text:e,read:s=>t.get(s)}).problems}_generated(){if(this.worksheets.length===0)return this._applyNames(),{sheets:[],csv:{},...this._file.names?{names:this._file.names}:{}};this._apply();const e=structuredClone(this._file.sheets),t=n=>`${ee}${n}`;for(const n of e){for(const o of n.tables??[])o.rows=t(o.rows);for(const o of n.blocks??[])o.rows=t(o.rows)}const s={};for(const[n,o]of this._build().files)s[t(n)]=o;return{sheets:e,csv:s,...this._file.names?{names:this._file.names}:{}}}save(e){if(this._making)throw new Error("A sheet's code makes sheets and saves nothing: what it adds to wb is what it makes.");const t=e===void 0?this.path:H(e);if(t===void 0)throw new TypeError("A new workbook is saved to a file: wb.save('finance/budget.yaml').");if(this.worksheets.length===0)throw new Error("A workbook has at least one sheet.");const{text:s,csv:n}=this._disk;this._apply();const o=new Set(this._file.sheets.flatMap(f=>[...(f.tables??[]).map(_=>_.rows),...(f.blocks??[]).map(_=>_.rows)])),i=[...this._csv.keys()].filter(f=>!o.has(f));for(const f of i)this._csv.delete(f);const{mkdirSync:a,rmSync:h,writeFileSync:d}=R(),u=process.getBuiltinModule("node:path"),r=u.dirname(t),c=e===void 0||t===this.path;a(r,{recursive:!0}),(this._text!==s||!c)&&d(t,this._text);for(const[f,_]of this._csv){const m=_.parsed?.source??"";if(c&&n.get(f)===m)continue;const $=O(r,f);a(u.dirname($),{recursive:!0}),d($,m)}if(c)for(const f of i)h(O(r,f),{force:!0});this._disk={text:this._text,csv:new Map([...this._csv].map(([f,_])=>[f,_.parsed?.source??""]))},this.path=t}}function P(l){if(l._formula===void 0)return;const e=M(l._formula);if(e.ok)return se(e.node,l.row-1,l.column-1)}function Me(l){const e=l.format;if(!e||e.length<2)return;const t=[],s=new Map;for(const n of e){const{range:o,...i}=n,a=y(o);if(!a){t.push(n);continue}const h=JSON.stringify(i),d=s.get(h);d?d.places.push(a):s.set(h,{look:i,places:[a]})}for(const{look:n,places:o}of s.values())for(const i of T(o))t.push({range:x(i),...n});l.format=t}export function load_workbook(l,e={}){return Workbook.open(l,e)}export const get_column_letter=l=>N(l-1);export function column_index_from_string(l){const e=C(l);if(e===void 0)throw new TypeError(`${l} is not a column.`);return e+1}export function coordinate_to_tuple(l){const e=y(l);if(!e)throw new TypeError(`${l} is not a cell.`);return[e.row+1,e.col+1]}export function range_boundaries(l){const e=k(l);if(!e)throw new TypeError(`${l} is not a range.`);return[e.left+1,e.top+1,e.right+1,e.bottom+1]}
@@ -1,6 +1,6 @@
1
1
  import type { SheetFile } from "@allyhub/formats";
2
2
  import type { BookEdit } from "../edit.js";
3
- import type { GeneratedSheets } from "../generated.js";
3
+ import type { GeneratedSheets } from "@allyhub/formats";
4
4
  import { type CsvRows, type Workbook } from "../workbook.js";
5
5
  import { Calc } from "./engine.js";
6
6
  import type { Computed } from "./remote.js";
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{writeCsv as S}from"./csv.js";import{isDateCode as k,shownValue as b}from"./format.js";import{CellError as w,dateOf as j}from"./values.js";const y=t=>(t.split(";")[0]??"").replace(/"[^"]*"|\\.|_.|\*./gu,"").replace(/\[(?![hms]+\])[^\]]*\]/giu,""),h=new Map;function _(t){if(t===void 0)return;if(h.has(t))return h.get(t);let n;if(k(t)){const r=y(t).toLowerCase(),o=/\[(h+|m+|s+)\]/u.test(r),e=[...r.matchAll(/\[?([ydhms])\1*\]?|am\/pm|a\/p/gu)].map(c=>c[0]);let s=!1,i=!1,u=!1;for(const[c,a]of e.entries()){const f=a.replace(/[[\]]/gu,"")[0];if(f==="y"||f==="d")s=!0;else if(f==="h"||a.includes("/"))i=!0;else if(f==="s")i=!0,u=!0;else if(f==="m"){const l=e[c-1]?.replace(/[[\]]/gu,"")[0],m=e[c+1]?.replace(/[[\]]/gu,"")[0];a.startsWith("[")||l==="h"||m==="s"?i=!0:s=!0}}o?n={kind:"duration",seconds:u}:s&&i?n={kind:"datetime",seconds:u}:i?n={kind:"time",seconds:u}:s&&(n={kind:"date",seconds:!1})}return h.set(t,n),n}const $=864e5,A=2958465,d=(t,n=2)=>String(t).padStart(n,"0");export const excelNumber=t=>t===0?0:Number(t.toPrecision(15));function x(t,n,r=2){const o=Math.floor(t/1e3),e=t%1e3;let s=`${d(Math.floor(o/3600),r)}:${d(Math.floor(o/60)%60)}`;return(n||o%60!==0||e!==0)&&(s+=`:${d(o%60)}`),e!==0&&(s+=`.${d(e,3).replace(/0+$/u,"")}`),s}function T(t){const n=t<0?"-":"";let r=Math.abs(t);const o=Math.floor(r/36e5);r-=o*36e5;const e=Math.floor(r/6e4);r-=e*6e4;const s=[o>0?`${String(o)}H`:"",e>0?`${String(e)}M`:"",r>0?`${String(r/1e3)}S`:""].join("");return`${n}PT${s||"0S"}`}function M(t,n,r){const o=Math.round(t*$);if(n.kind==="duration")return r==="json"?T(o):`${o<0?"-":""}${x(Math.abs(o),n.seconds,1)}`;if(t<0||t>=A+1)return;const e=Math.floor(o/$),s=x(o-e*$,n.seconds||r==="json");if(e===0||n.kind==="time")return s;if(e===60)return;const{year:i,month:u,day:c}=j(e),a=`${d(i,4)}-${d(u)}-${d(c)}`;return n.kind==="date"?a:`${a}${r==="json"?"T":" "}${s}`}export function csvText(t,n,r="data"){if(t===null)return"";if(r==="shown")return b(t,n);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof w)return t.code;if(typeof t=="string")return t;const o=_(n);return(o&&M(t,o,"csv"))??String(excelNumber(t))}export function dataValue(t,n,r="data"){if(t===null)return null;if(r==="shown")return b(t,n);if(t instanceof w)return t.code;if(typeof t!="number")return t;const o=_(n);return(o&&M(t,o,"json"))??excelNumber(t)}const p=(t,n,r)=>t.lookAt(n,r).format;function g(t,n){const r=t.used;if(!r)return[];const o=[];for(let e=0;e<=r.bottom;e++){const s=[];for(let i=0;i<=r.right;i++)s.push(n(e,i));o.push(s)}return o}export function csvOf(t,n,r={}){const o=g(n,(e,s)=>csvText(t.value(n,e,s),p(n,e,s),r.values));return S(o,{delimiter:",",newline:`\r
2
+ import{writeCsv as S}from"@allyhub/formats";import{isDateCode as k,shownValue as b}from"./format.js";import{CellError as w,dateOf as j}from"./values.js";const y=t=>(t.split(";")[0]??"").replace(/"[^"]*"|\\.|_.|\*./gu,"").replace(/\[(?![hms]+\])[^\]]*\]/giu,""),h=new Map;function _(t){if(t===void 0)return;if(h.has(t))return h.get(t);let n;if(k(t)){const r=y(t).toLowerCase(),o=/\[(h+|m+|s+)\]/u.test(r),e=[...r.matchAll(/\[?([ydhms])\1*\]?|am\/pm|a\/p/gu)].map(c=>c[0]);let s=!1,i=!1,u=!1;for(const[c,a]of e.entries()){const f=a.replace(/[[\]]/gu,"")[0];if(f==="y"||f==="d")s=!0;else if(f==="h"||a.includes("/"))i=!0;else if(f==="s")i=!0,u=!0;else if(f==="m"){const l=e[c-1]?.replace(/[[\]]/gu,"")[0],m=e[c+1]?.replace(/[[\]]/gu,"")[0];a.startsWith("[")||l==="h"||m==="s"?i=!0:s=!0}}o?n={kind:"duration",seconds:u}:s&&i?n={kind:"datetime",seconds:u}:i?n={kind:"time",seconds:u}:s&&(n={kind:"date",seconds:!1})}return h.set(t,n),n}const $=864e5,A=2958465,d=(t,n=2)=>String(t).padStart(n,"0");export const excelNumber=t=>t===0?0:Number(t.toPrecision(15));function x(t,n,r=2){const o=Math.floor(t/1e3),e=t%1e3;let s=`${d(Math.floor(o/3600),r)}:${d(Math.floor(o/60)%60)}`;return(n||o%60!==0||e!==0)&&(s+=`:${d(o%60)}`),e!==0&&(s+=`.${d(e,3).replace(/0+$/u,"")}`),s}function T(t){const n=t<0?"-":"";let r=Math.abs(t);const o=Math.floor(r/36e5);r-=o*36e5;const e=Math.floor(r/6e4);r-=e*6e4;const s=[o>0?`${String(o)}H`:"",e>0?`${String(e)}M`:"",r>0?`${String(r/1e3)}S`:""].join("");return`${n}PT${s||"0S"}`}function M(t,n,r){const o=Math.round(t*$);if(n.kind==="duration")return r==="json"?T(o):`${o<0?"-":""}${x(Math.abs(o),n.seconds,1)}`;if(t<0||t>=A+1)return;const e=Math.floor(o/$),s=x(o-e*$,n.seconds||r==="json");if(e===0||n.kind==="time")return s;if(e===60)return;const{year:i,month:u,day:c}=j(e),a=`${d(i,4)}-${d(u)}-${d(c)}`;return n.kind==="date"?a:`${a}${r==="json"?"T":" "}${s}`}export function csvText(t,n,r="data"){if(t===null)return"";if(r==="shown")return b(t,n);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof w)return t.code;if(typeof t=="string")return t;const o=_(n);return(o&&M(t,o,"csv"))??String(excelNumber(t))}export function dataValue(t,n,r="data"){if(t===null)return null;if(r==="shown")return b(t,n);if(t instanceof w)return t.code;if(typeof t!="number")return t;const o=_(n);return(o&&M(t,o,"json"))??excelNumber(t)}const p=(t,n,r)=>t.lookAt(n,r).format;function g(t,n){const r=t.used;if(!r)return[];const o=[];for(let e=0;e<=r.bottom;e++){const s=[];for(let i=0;i<=r.right;i++)s.push(n(e,i));o.push(s)}return o}export function csvOf(t,n,r={}){const o=g(n,(e,s)=>csvText(t.value(n,e,s),p(n,e,s),r.values));return S(o,{delimiter:",",newline:`\r
3
3
  `,bom:r.bom??!0,finalNewline:!0})}const E=t=>t.replaceAll("|","\\|").replace(/\r?\n/gu,"<br>");export function markdownOf(t,n,r={}){const o=r.values??"shown",e=[],s=g(n,(f,l)=>{const m=t.value(n,f,l);return f>0&&m!==null&&(e[l]=(e[l]??!0)&&typeof m=="number"),csvText(m,p(n,f,l),o)}),[i,...u]=s;if(!i)return"";const c=f=>`| ${f.map(E).join(" | ")} |`,a=i.map((f,l)=>e[l]===!0?"---:":"---");return`${[c(i),`| ${a.join(" | ")} |`,...u.map(c)].join(`
4
4
  `)}
5
5
  `}export function tableRows(t,n,r={}){const{sheet:o,at:e}=n,s=[];for(let i=0;i<n.rows;i++){const u={};for(const c of n.columns){const a=e.row+1+i,f=e.col+c.index;u[c.name]=dataValue(t.value(o,a,f),p(o,a,f),r.values)}s.push(u)}return s}export function jsonOf(t,n={}){const{wb:r}=t,o={};for(const e of r.sheets){const s={};for(const i of e.tables)s[i.name]=tableRows(t,i,n);o[e.name]={rows:g(e,(i,u)=>dataValue(t.value(e,i,u),p(e,i,u),n.values)),...e.tables.length>0?{tables:s}:{}}}return{...r.title===void 0?{}:{title:r.title},sheets:o}}
@@ -6,13 +6,18 @@ export interface SheetProblem {
6
6
  line?: number;
7
7
  message: string;
8
8
  }
9
+ /** What the model calls a sheet's own file, whatever it is named: the build says which file it is. */
9
10
  export declare const ENTRY = "sheet.yaml";
11
+ /** What the model calls a sheet's code (its file's `code`), whatever it is named. */
12
+ export declare const CODE = "sheet.ts";
10
13
  export type YamlPath = readonly (string | number)[];
11
14
  export interface ReadFile {
12
15
  file?: SheetFile;
13
16
  problems: SheetProblem[];
14
17
  lineOf: (path: YamlPath) => number | undefined;
15
18
  }
19
+ /** The module a sheet's file names as its code (`code`), from its folder. */
20
+ export declare const codeOf: (text: string) => string | undefined;
16
21
  /** The CSV files a sheet.yaml names, from its folder. */
17
22
  export declare function dataFilesOf(text: string): string[];
18
23
  export declare function readSheetFile(text: string): ReadFile;