@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
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{z as t}from"zod";import{LOCALE as m}from"./messages.js";import{OUTPUT_KINDS as u}from"./piece.js";import{musicTimeProblem as b}from"./music.js";import{FPS_HELP as d,VIDEO_FORMAT_HELP as g,formatSpecProblem as f,isVideoFormat as h,parseFps as x}from"./formats.js";import{RESERVED_DIMS as l}from"./matrix.js";export const VideoFormatSchema=t.string().refine(h,{message:`unknown format (${g})`}),ComboSchema=t.record(t.string(),t.string()),ProblemSchema=t.strictObject({code:t.string().regex(/^AK-[A-Z]\d{3}$/),level:t.enum(["error","warn"]),message:t.string(),piece:t.string().optional(),output:t.string().optional(),combo:ComboSchema.optional(),format:t.string().optional(),part:t.string().optional(),t:t.number().optional(),page:t.number().int().nonnegative().optional(),where:t.strictObject({file:t.string().optional(),line:t.number().int().optional(),selector:t.string().optional(),bbox:t.tuple([t.number(),t.number(),t.number(),t.number()]).optional()}).optional()}),Locale=t.string().regex(m,"must be a lower-case locale such as en or zh-cn"),PieceId=t.string().regex(/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/,"id: lowercase letters, digits, . _ -, with / between levels"),DimName=t.string().regex(/^[a-z][a-zA-Z0-9_-]*$/,"dimension name: starts with a letter; letters, digits, _ and -"),DimValue=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,"dimension value: letters, digits, . _ -"),OutputName=t.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,"output name: starts with a letter; letters, digits, _ and -"),DimsSchema=t.record(DimName,t.array(DimValue).min(1)).superRefine((o,e)=>{for(const[n,a]of Object.entries(o)){if(l.includes(n)){e.addIssue({code:"custom",path:[n],message:n==="size"||n==="format"?`${n} is not a dimension: a piece has one format, format: "9x16", and another format is a piece of its own`:`${n} cannot name a dimension: the preview's address uses it. Choose another name`});continue}if(new Set(a).size!==a.length&&e.addIssue({code:"custom",path:[n],message:"the same value is listed twice"}),n==="lang")for(const s of a)m.test(s)||e.addIssue({code:"custom",path:[n],message:`lang value ${s} must be a lowercase language tag, such as en or zh-cn`})}});const O=o=>l.includes(o)?`${o} cannot name a slot: the framework uses it. Choose another name`:void 0;export const CandidateSchema=t.union([DimValue,t.strictObject({name:DimValue,tags:t.array(t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/)).optional()})]),SlotSchema=t.union([t.array(CandidateSchema).min(1),t.strictObject({pool:t.string().min(1),tags:t.array(t.string().min(1)).optional()})]);const j=t.union([t.string().min(1),t.array(t.string().min(1)).min(1)]),r=t.record(t.string(),j);export const MatrixSchema=t.strictObject({dims:DimsSchema.optional(),slots:t.record(DimName,SlotSchema).optional(),structures:t.record(DimValue,t.array(DimName).min(1)).optional(),combos:t.array(t.record(DimName,DimValue)).min(1).max(1e4).optional(),pick:t.number().int().min(1).max(1e4).optional(),seed:t.union([t.number(),t.string()]).optional(),differ:t.strictObject({slots:t.number().int().min(1).optional(),first:t.union([t.number().int().min(1),t.array(DimName).min(1)]).optional()}).optional(),rules:t.array(t.strictObject({if:r.optional(),require:r.optional(),exclude:r.optional()})).optional()}).superRefine((o,e)=>{for(const n of Object.keys(o.slots??{})){const a=O(n);a&&e.addIssue({code:"custom",path:["slots",n],message:a})}if(o.structures&&!o.slots&&e.addIssue({code:"custom",path:["structures"],message:"structures order slots: declare matrix.slots too"}),o.combos&&!o.slots&&e.addIssue({code:"custom",path:["combos"],message:"combos choose candidates of slots: declare matrix.slots too"}),o.combos)for(const n of["pick","seed"])o[n]!==void 0&&e.addIssue({code:"custom",path:[n],message:`combos names the combos to make, so nothing is sampled: remove ${n}, which only steers sampling`})}),FormatSpecSchema=t.strictObject({format:t.string().min(1),safe:t.strictObject({top:t.number().optional(),bottom:t.number().optional(),left:t.number().optional(),right:t.number().optional()}).optional(),maxDuration:t.number().positive().optional(),loudness:t.number().min(-70).max(0).optional()}).superRefine((o,e)=>{const n=f(o);n&&e.addIssue({code:"custom",message:n})}),FormatEntrySchema=t.union([t.string().min(1),FormatSpecSchema]);const i=t.number().min(-70).max(0),c=t.unknown().superRefine((o,e)=>{const n=b(o);n&&e.addIssue({code:"custom",message:n})}),p=t.strictObject({from:c,to:c.optional()}),S=t.union([t.number().min(0),t.string().min(1),t.strictObject({part:t.string().min(1),at:t.union([t.number(),t.string().min(1)])})]);export const PartDefaultsSchema=t.strictObject({dur:t.number().positive().max(3600).optional(),lead:t.number().min(0).max(60).optional(),tail:t.number().min(0).max(60).optional()}),VideoOptionsMeta=t.strictObject({music:t.strictObject({file:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),from:t.number().min(0).optional(),loop:t.union([t.boolean(),p]).optional(),play:t.array(p).min(1).optional(),seam:t.number().min(0).max(5).optional(),meter:t.number().int().min(1).max(32).optional(),downbeat:t.number().min(0).optional(),end:t.enum(["film","bar","beat"]).optional(),snap:t.boolean().optional(),bpm:t.number().min(20).max(400).optional(),gain:t.array(t.strictObject({at:S,db:t.number().min(-60).max(24)})).min(1).optional(),filter:t.string().min(1).optional(),eq:t.array(t.unknown()).optional(),compress:t.unknown().optional()}).optional(),mix:t.strictObject({speech:i.optional(),music:i.optional(),musicAlone:i.optional(),sfx:i.optional(),footage:i.optional(),footageUnderSpeech:i.optional(),duck:t.strictObject({db:t.number().min(-60).max(0).optional(),attack:t.number().min(0).max(10).optional(),release:t.number().min(0).max(10).optional(),hold:t.number().min(0).max(60).optional()}).optional(),musicFade:t.strictObject({in:t.number().min(0).max(60).optional(),out:t.number().min(0).max(60).optional()}).optional()}).optional(),mic:t.union([t.string().min(1),t.record(t.string(),t.unknown()),t.literal(!1)]).optional(),look:t.string().min(1).optional(),defaults:t.strictObject({part:PartDefaultsSchema.optional()}).optional(),covers:t.literal(!0).optional(),fps:t.union([t.number(),t.string()]).refine(o=>x(o)!==void 0,{error:`A frame rate is ${d}`}).optional(),transparent:t.boolean().optional(),maxDuration:t.number().positive().optional(),loadLimit:t.number().positive().optional(),seekLimit:t.number().positive().optional(),deliverable:t.boolean().optional(),master:t.union([i,t.literal(!1),t.strictObject({lufs:t.union([i,t.literal(!1)]).optional(),truePeak:t.number().min(-9).max(0).optional()})]).optional(),motionBlur:t.strictObject({samples:t.number().int().min(2).max(16),shutter:t.number().gt(0).max(1).optional()}).optional(),capture:t.strictObject({bloom:t.strictObject({threshold:t.number().optional(),radius:t.number().optional(),strength:t.number().optional()}).optional(),aberration:t.number().optional(),soften:t.number().optional(),vignette:t.number().optional(),exposure:t.strictObject({drift:t.number().optional(),period:t.number().optional()}).optional(),grain:t.strictObject({amount:t.number().optional(),size:t.number().optional(),shadows:t.number().optional(),highlights:t.number().optional(),chroma:t.number().optional(),chromaSize:t.number().optional(),static:t.boolean().optional()}).optional(),sharpen:t.number().optional()}).optional(),post:t.strictObject({filter:t.string().min(1).optional(),lut:t.string().regex(/\.cube$/i,"A LUT is a .cube file").optional()}).optional()}),OutputMeta=t.strictObject({kind:t.enum(u),options:t.record(t.string(),t.unknown())}),PieceMeta=t.strictObject({id:PieceId.optional(),title:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),format:FormatEntrySchema.optional(),matrix:MatrixSchema.optional(),meta:t.record(t.string(),t.unknown()).optional(),outputs:t.record(OutputName,OutputMeta).refine(o=>Object.keys(o).length>0,"outputs needs at least one output")}),LookConfigSchema=t.strictObject({color:t.strictObject({bg:t.string().min(1).optional(),fg:t.string().min(1).optional(),accent:t.string().min(1).optional(),muted:t.string().min(1).optional(),surface:t.string().min(1).optional()}).optional(),font:t.strictObject({display:t.string().min(1).optional(),body:t.string().min(1).optional(),mono:t.string().min(1).optional(),emoji:t.string().min(1).optional()}).optional(),motion:t.strictObject({beat:t.number().positive().optional()}).optional(),sfx:t.record(t.string().regex(/^[a-z][a-z0-9-]*$/,"a sound's name: lowercase letters, digits and -"),t.string().min(1).refine(o=>!o.startsWith("/")&&!o.split(/[\\/]/).includes(".."),"a sound is an audio file relative to the workspace's root")).optional()}),PropSchemaEntry=t.looseObject({type:t.enum(["text","time","asset","color","number","boolean","list","object"])}),ComponentEntry=t.strictObject({name:t.string(),label:t.union([t.string(),t.record(t.string(),t.string())]),file:t.string(),props:t.record(t.string(),PropSchemaEntry),examples:t.array(t.string()),hidden:t.boolean()}),VideoConfigSchema=t.object({look:LookConfigSchema.optional(),defaults:t.strictObject({format:VideoFormatSchema.optional(),part:PartDefaultsSchema.optional()}).optional()});
2
+ import{z as t}from"zod";import{LOCALE as m,FPS_HELP as u,VIDEO_FORMAT_HELP as b,formatSpecProblem as d,isVideoFormat as g,parseFps as f,RESERVED_DIMS as l}from"@allyhub/piece";import{OUTPUT_KINDS as h}from"./piece.js";import{musicTimeProblem as x}from"./music.js";export const VideoFormatSchema=t.string().refine(g,{message:`unknown format (${b})`}),ComboSchema=t.record(t.string(),t.string()),ProblemSchema=t.strictObject({code:t.string().regex(/^AK-[A-Z]\d{3}$/),level:t.enum(["error","warn"]),message:t.string(),piece:t.string().optional(),output:t.string().optional(),combo:ComboSchema.optional(),format:t.string().optional(),part:t.string().optional(),t:t.number().optional(),page:t.number().int().nonnegative().optional(),where:t.strictObject({file:t.string().optional(),line:t.number().int().optional(),selector:t.string().optional(),bbox:t.tuple([t.number(),t.number(),t.number(),t.number()]).optional()}).optional()}),Locale=t.string().regex(m,"must be a lower-case locale such as en or zh-cn"),PieceId=t.string().regex(/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/,"id: lowercase letters, digits, . _ -, with / between levels"),DimName=t.string().regex(/^[a-z][a-zA-Z0-9_-]*$/,"dimension name: starts with a letter; letters, digits, _ and -"),DimValue=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/,"dimension value: letters, digits, . _ -"),OutputName=t.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,"output name: starts with a letter; letters, digits, _ and -"),DimsSchema=t.record(DimName,t.array(DimValue).min(1)).superRefine((o,e)=>{for(const[n,a]of Object.entries(o)){if(l.includes(n)){e.addIssue({code:"custom",path:[n],message:n==="size"||n==="format"?`${n} is not a dimension: a piece has one format, format: "9x16", and another format is a piece of its own`:`${n} cannot name a dimension: the preview's address uses it. Choose another name`});continue}if(new Set(a).size!==a.length&&e.addIssue({code:"custom",path:[n],message:"the same value is listed twice"}),n==="lang")for(const s of a)m.test(s)||e.addIssue({code:"custom",path:[n],message:`lang value ${s} must be a lowercase language tag, such as en or zh-cn`})}});const O=o=>l.includes(o)?`${o} cannot name a slot: the framework uses it. Choose another name`:void 0;export const CandidateSchema=t.union([DimValue,t.strictObject({name:DimValue,tags:t.array(t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/)).optional()})]),SlotSchema=t.union([t.array(CandidateSchema).min(1),t.strictObject({pool:t.string().min(1),tags:t.array(t.string().min(1)).optional()})]);const j=t.union([t.string().min(1),t.array(t.string().min(1)).min(1)]),r=t.record(t.string(),j);export const MatrixSchema=t.strictObject({dims:DimsSchema.optional(),slots:t.record(DimName,SlotSchema).optional(),structures:t.record(DimValue,t.array(DimName).min(1)).optional(),combos:t.array(t.record(DimName,DimValue)).min(1).max(1e4).optional(),pick:t.number().int().min(1).max(1e4).optional(),seed:t.union([t.number(),t.string()]).optional(),differ:t.strictObject({slots:t.number().int().min(1).optional(),first:t.union([t.number().int().min(1),t.array(DimName).min(1)]).optional()}).optional(),rules:t.array(t.strictObject({if:r.optional(),require:r.optional(),exclude:r.optional()})).optional()}).superRefine((o,e)=>{for(const n of Object.keys(o.slots??{})){const a=O(n);a&&e.addIssue({code:"custom",path:["slots",n],message:a})}if(o.structures&&!o.slots&&e.addIssue({code:"custom",path:["structures"],message:"structures order slots: declare matrix.slots too"}),o.combos&&!o.slots&&e.addIssue({code:"custom",path:["combos"],message:"combos choose candidates of slots: declare matrix.slots too"}),o.combos)for(const n of["pick","seed"])o[n]!==void 0&&e.addIssue({code:"custom",path:[n],message:`combos names the combos to make, so nothing is sampled: remove ${n}, which only steers sampling`})}),FormatSpecSchema=t.strictObject({format:t.string().min(1),safe:t.strictObject({top:t.number().optional(),bottom:t.number().optional(),left:t.number().optional(),right:t.number().optional()}).optional()}).superRefine((o,e)=>{const n=d(o);n&&e.addIssue({code:"custom",message:n})}),FormatEntrySchema=t.union([t.string().min(1),FormatSpecSchema]);const i=t.number().min(-70).max(0),c=t.unknown().superRefine((o,e)=>{const n=x(o);n&&e.addIssue({code:"custom",message:n})}),p=t.strictObject({from:c,to:c.optional()}),S=t.union([t.number().min(0),t.string().min(1),t.strictObject({part:t.string().min(1),at:t.union([t.number(),t.string().min(1)])})]);export const PartDefaultsSchema=t.strictObject({dur:t.number().positive().max(3600).optional(),lead:t.number().min(0).max(60).optional(),tail:t.number().min(0).max(60).optional()}),VideoOptionsMeta=t.strictObject({music:t.strictObject({file:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),from:t.number().min(0).optional(),loop:t.union([t.boolean(),p]).optional(),play:t.array(p).min(1).optional(),seam:t.number().min(0).max(5).optional(),meter:t.number().int().min(1).max(32).optional(),downbeat:t.number().min(0).optional(),end:t.enum(["film","bar","beat"]).optional(),snap:t.boolean().optional(),bpm:t.number().min(20).max(400).optional(),gain:t.array(t.strictObject({at:S,db:t.number().min(-60).max(24)})).min(1).optional(),filter:t.string().min(1).optional(),eq:t.array(t.unknown()).optional(),compress:t.unknown().optional()}).optional(),mix:t.strictObject({speech:i.optional(),music:i.optional(),musicAlone:i.optional(),sfx:i.optional(),footage:i.optional(),footageUnderSpeech:i.optional(),duck:t.strictObject({db:t.number().min(-60).max(0).optional(),attack:t.number().min(0).max(10).optional(),release:t.number().min(0).max(10).optional(),hold:t.number().min(0).max(60).optional()}).optional(),musicFade:t.strictObject({in:t.number().min(0).max(60).optional(),out:t.number().min(0).max(60).optional()}).optional()}).optional(),mic:t.union([t.string().min(1),t.record(t.string(),t.unknown()),t.literal(!1)]).optional(),look:t.string().min(1).optional(),defaults:t.strictObject({part:PartDefaultsSchema.optional()}).optional(),covers:t.literal(!0).optional(),fps:t.union([t.number(),t.string()]).refine(o=>f(o)!==void 0,{error:`A frame rate is ${u}`}).optional(),transparent:t.boolean().optional(),maxDuration:t.number().positive().optional(),loadLimit:t.number().positive().optional(),seekLimit:t.number().positive().optional(),deliverable:t.boolean().optional(),master:t.union([i,t.literal(!1),t.strictObject({lufs:t.union([i,t.literal(!1)]).optional(),truePeak:t.number().min(-9).max(0).optional()})]).optional(),motionBlur:t.strictObject({samples:t.number().int().min(2).max(16),shutter:t.number().gt(0).max(1).optional()}).optional(),capture:t.strictObject({bloom:t.strictObject({threshold:t.number().optional(),radius:t.number().optional(),strength:t.number().optional()}).optional(),aberration:t.number().optional(),soften:t.number().optional(),vignette:t.number().optional(),exposure:t.strictObject({drift:t.number().optional(),period:t.number().optional()}).optional(),grain:t.strictObject({amount:t.number().optional(),size:t.number().optional(),shadows:t.number().optional(),highlights:t.number().optional(),chroma:t.number().optional(),chromaSize:t.number().optional(),static:t.boolean().optional()}).optional(),sharpen:t.number().optional()}).optional(),post:t.strictObject({filter:t.string().min(1).optional(),lut:t.string().regex(/\.cube$/i,"A LUT is a .cube file").optional()}).optional()}),OutputMeta=t.strictObject({kind:t.enum(h),options:t.record(t.string(),t.unknown())}),PieceMeta=t.strictObject({id:PieceId.optional(),script:t.string().min(1).optional(),title:t.union([t.string().min(1),t.record(Locale,t.string().min(1))]).optional(),format:FormatEntrySchema.optional(),matrix:MatrixSchema.optional(),meta:t.record(t.string(),t.unknown()).optional(),outputs:t.record(OutputName,OutputMeta).refine(o=>Object.keys(o).length>0,"outputs needs at least one output")}),LookConfigSchema=t.strictObject({color:t.strictObject({bg:t.string().min(1).optional(),fg:t.string().min(1).optional(),accent:t.string().min(1).optional(),muted:t.string().min(1).optional(),surface:t.string().min(1).optional()}).optional(),font:t.strictObject({display:t.string().min(1).optional(),body:t.string().min(1).optional(),mono:t.string().min(1).optional(),emoji:t.string().min(1).optional()}).optional(),motion:t.strictObject({beat:t.number().positive().optional()}).optional(),sfx:t.record(t.string().regex(/^[a-z][a-z0-9-]*$/,"a sound's name: lowercase letters, digits and -"),t.string().min(1).refine(o=>!o.startsWith("/")&&!o.split(/[\\/]/).includes(".."),"a sound is an audio file relative to the workspace's root")).optional()}),PropSchemaEntry=t.looseObject({type:t.enum(["text","time","asset","color","number","boolean","list","object"])}),ComponentEntry=t.strictObject({name:t.string(),label:t.union([t.string(),t.record(t.string(),t.string())]),file:t.string(),props:t.record(t.string(),PropSchemaEntry),examples:t.array(t.string()),hidden:t.boolean()}),VideoConfigSchema=t.object({look:LookConfigSchema.optional(),defaults:t.strictObject({format:VideoFormatSchema.optional(),part:PartDefaultsSchema.optional()}).optional()});
@@ -1,5 +1,6 @@
1
- import { type SpokenSpan, type TextAnchor } from "./anchors.js";
2
- import type { ScriptFile, ScriptPart, ScriptText } from "./script.js";
1
+ import { type TextAnchor } from "@allyhub/piece";
2
+ import { type SpokenSpan } from "@allyhub/piece";
3
+ import type { ScriptFile, ScriptPart, ScriptText } from "@allyhub/piece";
3
4
  /** A text of a row, by where it is: "say", "screen.items.0", "screen.price.display". */
4
5
  export interface FieldText {
5
6
  field: string;
@@ -62,7 +63,8 @@ export declare const draftEdit: {
62
63
  parts: ScriptPart[];
63
64
  title?: string;
64
65
  text?: Record<string, ScriptText>;
65
- slides?: import("./script.js").ScriptSlide[];
66
+ slides?: import("@allyhub/piece").ScriptSlide[];
67
+ boards?: import("@allyhub/piece").ScriptBoard[];
66
68
  };
67
69
  id: string;
68
70
  };
@@ -85,7 +87,8 @@ export declare const draftEdit: {
85
87
  parts: ScriptPart[];
86
88
  title?: string;
87
89
  text?: Record<string, ScriptText>;
88
- slides?: import("./script.js").ScriptSlide[];
90
+ slides?: import("@allyhub/piece").ScriptSlide[];
91
+ boards?: import("@allyhub/piece").ScriptBoard[];
89
92
  };
90
93
  caret: undefined;
91
94
  };
@@ -101,7 +104,8 @@ export declare const draftEdit: {
101
104
  parts: ScriptPart[];
102
105
  title?: string;
103
106
  text?: Record<string, ScriptText>;
104
- slides?: import("./script.js").ScriptSlide[];
107
+ slides?: import("@allyhub/piece").ScriptSlide[];
108
+ boards?: import("@allyhub/piece").ScriptBoard[];
105
109
  };
106
110
  caret: {
107
111
  id: string;
@@ -122,7 +126,8 @@ export declare const draftEdit: {
122
126
  parts: ScriptPart[];
123
127
  title?: string;
124
128
  text?: Record<string, ScriptText>;
125
- slides?: import("./script.js").ScriptSlide[];
129
+ slides?: import("@allyhub/piece").ScriptSlide[];
130
+ boards?: import("@allyhub/piece").ScriptBoard[];
126
131
  };
127
132
  id: string;
128
133
  };
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{editLine as y,joinLines as N,readLine as R,rewordLine as V,sliceLine as k,spokenLine as q,withoutAnchors as L,writeLine as T}from"./anchors.js";import{isSpoken as F}from"./messages.js";const J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&"match"in e;function $(e,t,n){if(e!==void 0){if(typeof e=="string")n.push({field:t,value:e});else if(Array.isArray(e))e.forEach((s,i)=>{$(s,`${t}.${String(i)}`,n)});else if(F(e))n.push({field:`${t}.display`,value:e.display}),n.push({field:`${t}.speak`,value:e.speak});else if(!J(e))for(const[s,i]of Object.entries(e))$(i,`${t}.${s}`,n)}}export function partTexts(e){const t=[];$(e.say,"say",t);for(const[n,s]of Object.entries(e.screen??{}))$(s,`screen.${n}`,t);return t}export function itemTexts(e){const t=[];for(const[n,s]of Object.entries(e.text??{}))$(s,`text.${n}`,t);return t}function w(e,t,n){const[s,...i]=t;if(s===void 0)return n;if(Array.isArray(e))return e.map((o,d)=>String(d)===s?w(o,i,n):o);if(typeof e=="object"){const o=e,d=o[s];return d===void 0?e:{...o,[s]:w(d,i,n)}}return e}export function setPartText(e,t,n){const[s,...i]=t.split(".");if(s==="say"){const o=e.say===void 0?n:w(e.say,i,n);return{...e,say:o}}return s==="screen"&&e.screen?{...e,screen:w(e.screen,i,n)}:e}export function setItemText(e,t,n){const[s,...i]=t.split(".");return s!=="text"||!e.text?e:{...e,text:w(e.text,i,n)}}const I=(e,t,n)=>({...e,parts:e.parts.map(s=>s.id===t?n(s):s)});export function newPartId(...e){const t=new Set(e.flatMap(n=>n.parts.map(s=>s.id)));for(let n=1;;n++){const s=`new-${String(n)}`;if(!t.has(s))return s}}export const SAY="say";const M=e=>typeof e.say=="string"?e.say:void 0;export const saidText=e=>{const t=M(e);return t===void 0?void 0:L(t)};const p=e=>R(M(e)??"");export const saidAnchors=e=>p(e).anchors,saidSpans=e=>p(e).spans,spokenText=e=>M(e)===void 0?void 0:q(p(e)).text;const l=(e,t)=>setPartText(e,SAY,T(t));export function placeOfRemoved(e,t,n){const s=t.parts.findIndex(i=>i.id===n);for(let i=s+1;i<t.parts.length;i++){const o=e.findIndex(d=>d.id===t.parts[i]?.id);if(o>=0)return o}return e.length}export const draftEdit={text:(e,t,n,s)=>I(e,t,i=>{const o=saidText(i);return n===SAY&&o!==void 0?l(i,V(p(i),s)):setPartText(i,n,s)}),title:(e,t)=>({...e,title:t}),remove:(e,t)=>({...e,parts:e.parts.filter(n=>n.id!==t)}),restore(e,t,n){const s=t.parts.find(o=>o.id===n);if(!s||e.parts.some(o=>o.id===n))return e;const i=[...e.parts];return i.splice(placeOfRemoved(i,t,n),0,s),{...e,parts:i}},add(e,t,n){const s=newPartId(e,t),i=n===void 0?0:e.parts.findIndex(d=>d.id===n)+1,o=[...e.parts];return o.splice(i,0,{id:s,say:""}),{script:{...e,parts:o},id:s}},insert(e,t,n){const s=e.parts.find(d=>d.id===t.id);if(!s)return{script:e,caret:t};const i=saidText(s)??"",o=Math.max(0,Math.min(t.offset,i.length));return{script:I(e,t.id,d=>l(d,y(p(d),o,0,n))),caret:{id:t.id,offset:o+n.length}}},replace(e,t,n,s){const i=e.parts.find(f=>f.id===t.id),o=i?saidText(i):void 0;if(t.id!==n.id||!i||o===void 0){const f=draftEdit.cut(e,t,n);return f.caret?draftEdit.insert(f.script,f.caret,s):{script:f.script,caret:void 0}}const d=f=>Math.max(0,Math.min(f.offset,o.length)),r=Math.min(d(t),d(n)),c=Math.max(d(t),d(n));return{script:I(e,t.id,f=>l(f,y(p(f),r,c-r,s))),caret:{id:t.id,offset:r+s.length}}},cut(e,t,n){const s=e.parts.findIndex(a=>a.id===t.id),i=e.parts.findIndex(a=>a.id===n.id);if(s<0||i<0)return{script:e,caret:t};const[o,d,r,c]=s<i||s===i&&t.offset<=n.offset?[t,n,s,i]:[n,t,i,s],f=e.parts[r],u=e.parts[c];if(!f||!u)return{script:e,caret:t};if(r===c){const a=saidText(f)??"";return{script:a.slice(0,o.offset)+a.slice(d.offset)===a?e:I(e,f.id,S=>l(S,y(p(S),o.offset,d.offset-o.offset,""))),caret:o}}const m=saidText(f)??"",g=m.slice(0,o.offset),j=o.offset>0,A=d.offset<(saidText(u)??"").length||d.offset<=0,E=e.parts.flatMap((a,h)=>h<r||h>c?[a]:h===r?j?[saidText(a)===void 0?a:l(a,y(p(a),g.length,m.length-g.length,""))]:[]:h>r&&h<c&&saidText(a)===void 0?[a]:h===c?A?[saidText(a)===void 0||d.offset<=0?a:l(a,y(p(a),0,d.offset,""))]:[]:[]),C=j?{id:f.id,offset:g.length}:A?{id:u.id,offset:0}:void 0;return{script:{...e,parts:E},caret:C}},move(e,t,n){const s=e.parts.findIndex(r=>r.id===t),i=s+n,o=e.parts[s];if(!o||i<0||i>=e.parts.length)return e;const d=[...e.parts];return d.splice(s,1),d.splice(i,0,o),{...e,parts:d}},split(e,t,n,s){const i=e.parts.find(u=>u.id===n),o=i?saidText(i):void 0;if(!i||o===void 0)return{script:e,id:void 0};const d=newPartId(e,t),r=p(i),c=e.parts.indexOf(i),f=[...e.parts];return f.splice(c,1,l(i,k(r,0,s)),{id:d,say:T(k(r,s,o.length))}),{script:{...e,parts:f},id:d}},merge(e,t,n){const s=e.parts.findIndex(c=>c.id===t),i=e.parts[s],o=n===void 0?s-1:e.parts.findIndex(c=>c.id===n),d=e.parts[o];if(!i||!d||o===s)return e;const r=l(d,N(p(d),p(i)));return{...e,parts:e.parts.flatMap((c,f)=>f===s?[]:f===o?[r]:[c])}}};export function withVideoParts(e,t){const n=[...e.parts];return t.forEach((s,i)=>{if(n.some(d=>d.id===s))return;let o=0;for(let d=i-1;d>=0;d--){const r=n.findIndex(c=>c.id===t[d]);if(r>=0){o=r+1;break}}n.splice(o,0,{id:s})}),n.length===e.parts.length?e:{...e,parts:n}}function W(e,t){const n=e.length,s=t.length,i=Array.from({length:n+1},()=>new Array(s+1).fill(0));for(let c=n-1;c>=0;c--)for(let f=s-1;f>=0;f--){const u=i[c];u&&(u[f]=e[c]===t[f]?(i[c+1]?.[f+1]??0)+1:Math.max(i[c+1]?.[f]??0,u[f+1]??0))}const o=new Set;let d=0,r=0;for(;d<n&&r<s;){const c=e[d];c!==void 0&&c===t[r]?(o.add(c),d++,r++):(i[d+1]?.[r]??0)>=(i[d]?.[r+1]??0)?d++:r++}return o}function P(e,t,n){const s=[],i=new Map(e.map(r=>[r.field,r.value])),o=new Map(t.map(r=>[r.field,r.value])),d=(r,c)=>r==="say"||r.startsWith("say.")?L(c):c;for(const[r,c]of o){const f=i.get(r);(f===void 0||d(r,f)!==d(r,c))&&s.push({kind:"text",...n===void 0?{}:{part:n},field:r,...f===void 0?{}:{before:f},after:c})}for(const[r,c]of i)o.has(r)||s.push({kind:"text",...n===void 0?{}:{part:n},field:r,before:c});return s}export function scriptChanges(e,t){const n=[];e.title!==t.title&&n.push({kind:"title",...e.title===void 0?{}:{before:e.title},...t.title===void 0?{}:{after:t.title}}),n.push(...P(itemTexts(e),itemTexts(t),void 0));const s=e.parts.map(r=>r.id),i=t.parts.map(r=>r.id),o=new Set(s.filter(r=>i.includes(r))),d=W(s.filter(r=>o.has(r)),i.filter(r=>o.has(r)));t.parts.forEach((r,c)=>{const f=t.parts[c-1]?.id,u=f===void 0?{}:{after:f},m=e.parts.find(g=>g.id===r.id);if(!m){n.push({kind:"add",part:r.id,...u,texts:partTexts(r)});return}d.has(r.id)||n.push({kind:"move",part:r.id,...u}),n.push(...P(partTexts(m),partTexts(r),r.id))});for(const r of e.parts){if(o.has(r.id))continue;const c=saidText(r);n.push({kind:"remove",part:r.id,...c===void 0?{}:{said:c}})}return n}const x=e=>e===void 0||e===""?"(nothing)":JSON.stringify(e),O=e=>e===void 0?"first":`after ${e}`;export function changeLine(e){switch(e.kind){case"title":return`Title: ${x(e.before)} → ${x(e.after)}`;case"text":return`${e.part===void 0?"The item's text":`Part ${e.part}`}, ${e.field}: ${x(e.before)} → ${x(e.after)}`;case"remove":return`Part ${e.part}: removed${e.said?` (it said ${x(e.said)})`:""}`;case"add":return`New part ${e.part}, ${O(e.after)}: ${e.texts.length===0?"empty":e.texts.map(t=>`${t.field} ${x(t.value)}`).join("; ")}`;case"move":return`Part ${e.part}: moved, now ${O(e.after)}`}}
2
+ import{isSpoken as N}from"@allyhub/piece";import{editLine as y,joinLines as R,readLine as V,rewordLine as q,sliceLine as k,spokenLine as F,withoutAnchors as L,writeLine as T}from"@allyhub/piece";const J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&"match"in e;function $(e,t,n){if(e!==void 0){if(typeof e=="string")n.push({field:t,value:e});else if(Array.isArray(e))e.forEach((s,i)=>{$(s,`${t}.${String(i)}`,n)});else if(N(e))n.push({field:`${t}.display`,value:e.display}),n.push({field:`${t}.speak`,value:e.speak});else if(!J(e))for(const[s,i]of Object.entries(e))$(i,`${t}.${s}`,n)}}export function partTexts(e){const t=[];$(e.say,"say",t);for(const[n,s]of Object.entries(e.screen??{}))$(s,`screen.${n}`,t);return t}export function itemTexts(e){const t=[];for(const[n,s]of Object.entries(e.text??{}))$(s,`text.${n}`,t);return t}function w(e,t,n){const[s,...i]=t;if(s===void 0)return n;if(Array.isArray(e))return e.map((o,d)=>String(d)===s?w(o,i,n):o);if(typeof e=="object"){const o=e,d=o[s];return d===void 0?e:{...o,[s]:w(d,i,n)}}return e}export function setPartText(e,t,n){const[s,...i]=t.split(".");if(s==="say"){const o=e.say===void 0?n:w(e.say,i,n);return{...e,say:o}}return s==="screen"&&e.screen?{...e,screen:w(e.screen,i,n)}:e}export function setItemText(e,t,n){const[s,...i]=t.split(".");return s!=="text"||!e.text?e:{...e,text:w(e.text,i,n)}}const I=(e,t,n)=>({...e,parts:e.parts.map(s=>s.id===t?n(s):s)});export function newPartId(...e){const t=new Set(e.flatMap(n=>n.parts.map(s=>s.id)));for(let n=1;;n++){const s=`new-${String(n)}`;if(!t.has(s))return s}}export const SAY="say";const M=e=>typeof e.say=="string"?e.say:void 0;export const saidText=e=>{const t=M(e);return t===void 0?void 0:L(t)};const p=e=>V(M(e)??"");export const saidAnchors=e=>p(e).anchors,saidSpans=e=>p(e).spans,spokenText=e=>M(e)===void 0?void 0:F(p(e)).text;const l=(e,t)=>setPartText(e,SAY,T(t));export function placeOfRemoved(e,t,n){const s=t.parts.findIndex(i=>i.id===n);for(let i=s+1;i<t.parts.length;i++){const o=e.findIndex(d=>d.id===t.parts[i]?.id);if(o>=0)return o}return e.length}export const draftEdit={text:(e,t,n,s)=>I(e,t,i=>{const o=saidText(i);return n===SAY&&o!==void 0?l(i,q(p(i),s)):setPartText(i,n,s)}),title:(e,t)=>({...e,title:t}),remove:(e,t)=>({...e,parts:e.parts.filter(n=>n.id!==t)}),restore(e,t,n){const s=t.parts.find(o=>o.id===n);if(!s||e.parts.some(o=>o.id===n))return e;const i=[...e.parts];return i.splice(placeOfRemoved(i,t,n),0,s),{...e,parts:i}},add(e,t,n){const s=newPartId(e,t),i=n===void 0?0:e.parts.findIndex(d=>d.id===n)+1,o=[...e.parts];return o.splice(i,0,{id:s,say:""}),{script:{...e,parts:o},id:s}},insert(e,t,n){const s=e.parts.find(d=>d.id===t.id);if(!s)return{script:e,caret:t};const i=saidText(s)??"",o=Math.max(0,Math.min(t.offset,i.length));return{script:I(e,t.id,d=>l(d,y(p(d),o,0,n))),caret:{id:t.id,offset:o+n.length}}},replace(e,t,n,s){const i=e.parts.find(f=>f.id===t.id),o=i?saidText(i):void 0;if(t.id!==n.id||!i||o===void 0){const f=draftEdit.cut(e,t,n);return f.caret?draftEdit.insert(f.script,f.caret,s):{script:f.script,caret:void 0}}const d=f=>Math.max(0,Math.min(f.offset,o.length)),r=Math.min(d(t),d(n)),c=Math.max(d(t),d(n));return{script:I(e,t.id,f=>l(f,y(p(f),r,c-r,s))),caret:{id:t.id,offset:r+s.length}}},cut(e,t,n){const s=e.parts.findIndex(a=>a.id===t.id),i=e.parts.findIndex(a=>a.id===n.id);if(s<0||i<0)return{script:e,caret:t};const[o,d,r,c]=s<i||s===i&&t.offset<=n.offset?[t,n,s,i]:[n,t,i,s],f=e.parts[r],u=e.parts[c];if(!f||!u)return{script:e,caret:t};if(r===c){const a=saidText(f)??"";return{script:a.slice(0,o.offset)+a.slice(d.offset)===a?e:I(e,f.id,S=>l(S,y(p(S),o.offset,d.offset-o.offset,""))),caret:o}}const m=saidText(f)??"",g=m.slice(0,o.offset),j=o.offset>0,A=d.offset<(saidText(u)??"").length||d.offset<=0,E=e.parts.flatMap((a,h)=>h<r||h>c?[a]:h===r?j?[saidText(a)===void 0?a:l(a,y(p(a),g.length,m.length-g.length,""))]:[]:h>r&&h<c&&saidText(a)===void 0?[a]:h===c?A?[saidText(a)===void 0||d.offset<=0?a:l(a,y(p(a),0,d.offset,""))]:[]:[]),C=j?{id:f.id,offset:g.length}:A?{id:u.id,offset:0}:void 0;return{script:{...e,parts:E},caret:C}},move(e,t,n){const s=e.parts.findIndex(r=>r.id===t),i=s+n,o=e.parts[s];if(!o||i<0||i>=e.parts.length)return e;const d=[...e.parts];return d.splice(s,1),d.splice(i,0,o),{...e,parts:d}},split(e,t,n,s){const i=e.parts.find(u=>u.id===n),o=i?saidText(i):void 0;if(!i||o===void 0)return{script:e,id:void 0};const d=newPartId(e,t),r=p(i),c=e.parts.indexOf(i),f=[...e.parts];return f.splice(c,1,l(i,k(r,0,s)),{id:d,say:T(k(r,s,o.length))}),{script:{...e,parts:f},id:d}},merge(e,t,n){const s=e.parts.findIndex(c=>c.id===t),i=e.parts[s],o=n===void 0?s-1:e.parts.findIndex(c=>c.id===n),d=e.parts[o];if(!i||!d||o===s)return e;const r=l(d,R(p(d),p(i)));return{...e,parts:e.parts.flatMap((c,f)=>f===s?[]:f===o?[r]:[c])}}};export function withVideoParts(e,t){const n=[...e.parts];return t.forEach((s,i)=>{if(n.some(d=>d.id===s))return;let o=0;for(let d=i-1;d>=0;d--){const r=n.findIndex(c=>c.id===t[d]);if(r>=0){o=r+1;break}}n.splice(o,0,{id:s})}),n.length===e.parts.length?e:{...e,parts:n}}function W(e,t){const n=e.length,s=t.length,i=Array.from({length:n+1},()=>new Array(s+1).fill(0));for(let c=n-1;c>=0;c--)for(let f=s-1;f>=0;f--){const u=i[c];u&&(u[f]=e[c]===t[f]?(i[c+1]?.[f+1]??0)+1:Math.max(i[c+1]?.[f]??0,u[f+1]??0))}const o=new Set;let d=0,r=0;for(;d<n&&r<s;){const c=e[d];c!==void 0&&c===t[r]?(o.add(c),d++,r++):(i[d+1]?.[r]??0)>=(i[d]?.[r+1]??0)?d++:r++}return o}function P(e,t,n){const s=[],i=new Map(e.map(r=>[r.field,r.value])),o=new Map(t.map(r=>[r.field,r.value])),d=(r,c)=>r==="say"||r.startsWith("say.")?L(c):c;for(const[r,c]of o){const f=i.get(r);(f===void 0||d(r,f)!==d(r,c))&&s.push({kind:"text",...n===void 0?{}:{part:n},field:r,...f===void 0?{}:{before:f},after:c})}for(const[r,c]of i)o.has(r)||s.push({kind:"text",...n===void 0?{}:{part:n},field:r,before:c});return s}export function scriptChanges(e,t){const n=[];e.title!==t.title&&n.push({kind:"title",...e.title===void 0?{}:{before:e.title},...t.title===void 0?{}:{after:t.title}}),n.push(...P(itemTexts(e),itemTexts(t),void 0));const s=e.parts.map(r=>r.id),i=t.parts.map(r=>r.id),o=new Set(s.filter(r=>i.includes(r))),d=W(s.filter(r=>o.has(r)),i.filter(r=>o.has(r)));t.parts.forEach((r,c)=>{const f=t.parts[c-1]?.id,u=f===void 0?{}:{after:f},m=e.parts.find(g=>g.id===r.id);if(!m){n.push({kind:"add",part:r.id,...u,texts:partTexts(r)});return}d.has(r.id)||n.push({kind:"move",part:r.id,...u}),n.push(...P(partTexts(m),partTexts(r),r.id))});for(const r of e.parts){if(o.has(r.id))continue;const c=saidText(r);n.push({kind:"remove",part:r.id,...c===void 0?{}:{said:c}})}return n}const x=e=>e===void 0||e===""?"(nothing)":JSON.stringify(e),O=e=>e===void 0?"first":`after ${e}`;export function changeLine(e){switch(e.kind){case"title":return`Title: ${x(e.before)} → ${x(e.after)}`;case"text":return`${e.part===void 0?"The item's text":`Part ${e.part}`}, ${e.field}: ${x(e.before)} → ${x(e.after)}`;case"remove":return`Part ${e.part}: removed${e.said?` (it said ${x(e.said)})`:""}`;case"add":return`New part ${e.part}, ${O(e.after)}: ${e.texts.length===0?"empty":e.texts.map(t=>`${t.field} ${x(t.value)}`).join("; ")}`;case"move":return`Part ${e.part}: moved, now ${O(e.after)}`}}
@@ -1,6 +1,5 @@
1
- import type { Pixels } from "./contrast.js";
2
- import type { Track } from "./measure.js";
3
- import type { Box } from "./problem.js";
1
+ import type { Pixels, Track } from "@allyhub/piece";
2
+ import type { Box } from "@allyhub/diagnostics";
4
3
  /** How cut-seam measures. */
5
4
  export interface SeamOptions {
6
5
  /** Frames looked at on each side of a join (2 or more): velocities are over them. */
@@ -1,5 +1,5 @@
1
- import type { Word } from "./media.js";
2
- import { type VoiceFrames } from "./voice.js";
1
+ import type { Word } from "@allyhub/piece";
2
+ import { type VoiceFrames } from "@allyhub/piece";
3
3
  /** What the sound summary counts by. */
4
4
  export interface SoundParams {
5
5
  /** A stretch with no word counts from this long, seconds. */
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{frameDb as k}from"./voice.js";export const SOUND_DEFAULTS={gap:.2,edge:.05,voiced:50};const d=n=>Math.round(n*10)/10,b=n=>Math.round(n*1e3)/1e3;function m(n,h){const s=[...n].sort((e,i)=>e-i),o=e=>s[Math.min(s.length-1,Math.floor(e*s.length))]??-120;return{seconds:b(s.length*h),p10:d(o(.1)),median:d(o(.5)),p90:d(o(.9))}}export function soundUnder(n,h,s,o={}){const e={...SOUND_DEFAULTS,...o},i=n.db.length,p=[];for(let t=0;t<i;t++)p.push(k(n,t));const f=[...p].sort((t,c)=>t-c),u=f.slice(0,Math.max(1,Math.floor(f.length/10))),M=u.length?d(u.reduce((t,c)=>t+c,0)/u.length):-120,U={gap:e.gap,edge:e.edge,voiced:e.voiced,whole:m(p,n.hop),floor:M};if(!h)return U;const w=t=>t*n.hop,a=new Uint8Array(i),x=t=>Math.ceil(t/n.hop-1e-6);for(const t of h){const c=Math.max(0,x(t.start-e.edge)),r=Math.min(i-1,x(t.end+e.edge)-1);for(let l=c;l<=r;l++)l>=x(t.start)&&l<x(t.end)?a[l]=1:a[l]===0&&(a[l]=2)}const v=[],g=[];let D=0;const P=[];for(let t=0;t<i;){if(a[t]===1&&v.push(k(n,t)),a[t]!==0){t++;continue}let c=t;for(;c<i&&a[c]===0;)c++;if((c-t)*n.hop>=e.gap){P.push([w(t),w(c)]);for(let r=t;r<c;r++)g.push(k(n,r)),(n.voicing[r]??0)>=e.voiced&&D++}t=c}const F=s.filter(t=>P.some(([c,r])=>t>=c&&t<r)).length,A=g.length*n.hop/60;return{...U,...v.length>0?{words:m(v,n.hop)}:{},...g.length>0?{between:{...m(g,n.hop),voicedShare:b(D/g.length),onsetsPerMinute:A>0?d(F/A):0}}:{}}}const S=(n,h)=>h>0?d(n*60/h):0;export function paceOf(n,h,s,o){const e=o[0],i=o.at(-1),p=e&&i?i.end-e.start:0,f=o.reduce((u,M)=>u+Math.max(0,M.end-M.start),0);return{tempo:s?{bpm:s.bpm,confidence:s.confidence}:null,onsetsPerMinute:S(h,n),wordsPerMinute:S(o.length,n),speakingRate:S(o.length,p),speechShare:n>0?Math.min(1,b(f/n)):0,timeToFirstWord:e?b(e.start):null}}export function joinedWords(n,h){const s=[];for(const o of[...n].sort((e,i)=>e.start-i.start)){const e=s.at(-1);if(e?.text===o.text&&o.start-e.end<=h&&o.start>=e.start){s[s.length-1]={...e,end:Math.max(e.end,o.end)};continue}s.push({...o})}return s}
2
+ import{frameDb as k}from"@allyhub/piece";export const SOUND_DEFAULTS={gap:.2,edge:.05,voiced:50};const d=n=>Math.round(n*10)/10,b=n=>Math.round(n*1e3)/1e3;function m(n,h){const s=[...n].sort((e,i)=>e-i),o=e=>s[Math.min(s.length-1,Math.floor(e*s.length))]??-120;return{seconds:b(s.length*h),p10:d(o(.1)),median:d(o(.5)),p90:d(o(.9))}}export function soundUnder(n,h,s,o={}){const e={...SOUND_DEFAULTS,...o},i=n.db.length,p=[];for(let t=0;t<i;t++)p.push(k(n,t));const f=[...p].sort((t,c)=>t-c),u=f.slice(0,Math.max(1,Math.floor(f.length/10))),M=u.length?d(u.reduce((t,c)=>t+c,0)/u.length):-120,U={gap:e.gap,edge:e.edge,voiced:e.voiced,whole:m(p,n.hop),floor:M};if(!h)return U;const w=t=>t*n.hop,a=new Uint8Array(i),x=t=>Math.ceil(t/n.hop-1e-6);for(const t of h){const c=Math.max(0,x(t.start-e.edge)),r=Math.min(i-1,x(t.end+e.edge)-1);for(let l=c;l<=r;l++)l>=x(t.start)&&l<x(t.end)?a[l]=1:a[l]===0&&(a[l]=2)}const v=[],g=[];let D=0;const P=[];for(let t=0;t<i;){if(a[t]===1&&v.push(k(n,t)),a[t]!==0){t++;continue}let c=t;for(;c<i&&a[c]===0;)c++;if((c-t)*n.hop>=e.gap){P.push([w(t),w(c)]);for(let r=t;r<c;r++)g.push(k(n,r)),(n.voicing[r]??0)>=e.voiced&&D++}t=c}const F=s.filter(t=>P.some(([c,r])=>t>=c&&t<r)).length,A=g.length*n.hop/60;return{...U,...v.length>0?{words:m(v,n.hop)}:{},...g.length>0?{between:{...m(g,n.hop),voicedShare:b(D/g.length),onsetsPerMinute:A>0?d(F/A):0}}:{}}}const S=(n,h)=>h>0?d(n*60/h):0;export function paceOf(n,h,s,o){const e=o[0],i=o.at(-1),p=e&&i?i.end-e.start:0,f=o.reduce((u,M)=>u+Math.max(0,M.end-M.start),0);return{tempo:s?{bpm:s.bpm,confidence:s.confidence}:null,onsetsPerMinute:S(h,n),wordsPerMinute:S(o.length,n),speakingRate:S(o.length,p),speechShare:n>0?Math.min(1,b(f/n)):0,timeToFirstWord:e?b(e.start):null}}export function joinedWords(n,h){const s=[];for(const o of[...n].sort((e,i)=>e.start-i.start)){const e=s.at(-1);if(e?.text===o.text&&o.start-e.end<=h&&o.start>=e.start){s[s.length-1]={...e,end:Math.max(e.end,o.end)};continue}s.push({...o})}return s}
@@ -1,8 +1,8 @@
1
- import type { MediaInfo, Word } from "./media.js";
1
+ import type { Word } from "@allyhub/piece";
2
2
  /** Where `allyhub voice` puts the files of `say`, from the project root. */
3
3
  export declare const SAY_DIR = "assets/media/gen/say";
4
4
  /** The voice tool `say` uses when it names none. */
5
- export declare const DEFAULT_VOICE_TOOL = "speech-elevenlabs-multilingual-v2";
5
+ export declare const DEFAULT_VOICE_TOOL = "speak";
6
6
  /**
7
7
  * FNV-1a, 64 bits, over the UTF-8 bytes: the same 16 hex digits in Node and
8
8
  * the browser, synchronously.
@@ -28,8 +28,6 @@ export declare function sayStem(say: {
28
28
  tool?: string | undefined;
29
29
  params?: Readonly<Record<string, unknown>> | undefined;
30
30
  }): string;
31
- /** The audio file of a stem among the project's media (any audio extension). */
32
- export declare function mediaByStem(media: Readonly<Record<string, MediaInfo>>, stem: string): MediaInfo | undefined;
33
31
  /**
34
32
  * The words a part's speech plays, on the film's clock: the stretch of
35
33
  * its take from `from`, or, for a cut take, the words inside each kept
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MEDIA_DIR as p}from"@allyhub/formats";export const SAY_DIR=`${p}/gen/say`,DEFAULT_VOICE_TOOL="speech-elevenlabs-multilingual-v2";export function hash64(n){let t=0xcbf29ce484222325n;const e=0x100000001b3n;for(const r of new TextEncoder().encode(n))t^=BigInt(r),t=t*e&0xffffffffffffffffn;return t.toString(16).padStart(16,"0")}export function notJson(n,t="value"){if(n===null||typeof n=="string"||typeof n=="boolean")return;if(typeof n=="number")return Number.isFinite(n)?void 0:t;if(typeof n!="object")return t;if(Array.isArray(n)){for(const[r,o]of n.entries()){const i=notJson(o,`${t}[${String(r)}]`);if(i!==void 0)return i}return}const e=Object.getPrototypeOf(n);if(e!==Object.prototype&&e!==null)return t;for(const[r,o]of Object.entries(n)){const i=notJson(o,`${t}.${r}`);if(i!==void 0)return i}}export function canonicalJson(n){if(Array.isArray(n))return`[${n.map(canonicalJson).join(",")}]`;if(typeof n=="object"&&n!==null){const t=n;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${canonicalJson(t[e])}`).join(",")}}`}return JSON.stringify(n)}export function sayStem(n){const t=n.tool??DEFAULT_VOICE_TOOL,e=n.params&&Object.keys(n.params).length>0?`
2
+ import{MEDIA_DIR as p}from"@allyhub/formats";export const SAY_DIR=`${p}/gen/say`,DEFAULT_VOICE_TOOL="speak";export function hash64(n){let t=0xcbf29ce484222325n;const e=0x100000001b3n;for(const r of new TextEncoder().encode(n))t^=BigInt(r),t=t*e&0xffffffffffffffffn;return t.toString(16).padStart(16,"0")}export function notJson(n,t="value"){if(n===null||typeof n=="string"||typeof n=="boolean")return;if(typeof n=="number")return Number.isFinite(n)?void 0:t;if(typeof n!="object")return t;if(Array.isArray(n)){for(const[r,o]of n.entries()){const s=notJson(o,`${t}[${String(r)}]`);if(s!==void 0)return s}return}const e=Object.getPrototypeOf(n);if(e!==Object.prototype&&e!==null)return t;for(const[r,o]of Object.entries(n)){const s=notJson(o,`${t}.${r}`);if(s!==void 0)return s}}export function canonicalJson(n){if(Array.isArray(n))return`[${n.map(canonicalJson).join(",")}]`;if(typeof n=="object"&&n!==null){const t=n;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${canonicalJson(t[e])}`).join(",")}}`}return JSON.stringify(n)}export function sayStem(n){const t=n.tool??DEFAULT_VOICE_TOOL,e=n.params&&Object.keys(n.params).length>0?`
3
3
  ${canonicalJson(n.params)}`:"";return`${SAY_DIR}/${hash64(`${t}
4
4
  ${n.voice??""}
5
- ${n.text}${e}`)}`}export function mediaByStem(n,t){for(const[e,r]of Object.entries(n))if(r.kind==="audio"&&e.startsWith(`${t}.`)){const o=e.slice(t.length+1);if(!o.includes("/")&&!o.includes("."))return r}}export function speechWords(n,t){const e=t.speed??1,r=t.cuts;return!r||r.length===0?wordsIn(n,t.from,t.end-t.start,t.start,e):r.flatMap((o,i)=>{const c=r[i+1]?.at??t.end;return wordsIn(n,o.from,c-o.at,o.at,e)})}export function wordsIn(n,t,e,r,o=1){const i=s=>Math.round(s*1e3)/1e3,c=t+e*o,d=r-t,u=s=>i(o===1?s+d:r+(s-t)/o);return n.filter(s=>s.start>=t-1e-6&&s.start<c-1e-6).map(s=>({text:s.text,start:u(s.start),end:u(Math.min(s.end,c))}))}const a=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu;export const SPEECH_RATE_DEFAULTS={word:.38,cjk:.22};export function speechUnits(n){const t=n.match(a)?.length??0;return{words:n.replace(a," ").split(/\s+/u).filter(r=>/[\p{L}\p{N}]/u.test(r)).length,cjk:t}}const f=(n,t)=>{const{words:e,cjk:r}=speechUnits(n);return e*(t.word??SPEECH_RATE_DEFAULTS.word)+r*(t.cjk??SPEECH_RATE_DEFAULTS.cjk)};export function estimateSpeech(n,t={}){return Math.max(1,Math.round(f(n,t)*10)/10)}export function speechLength(n,t,e={}){const r=f(n,e),o=t===void 0?0:f(t.text,e),i=t!==void 0&&o>0&&t.seconds>0?t.seconds*r/o:r;return Math.round(i*10)/10}
5
+ ${n.text}${e}`)}`}export function speechWords(n,t){const e=t.speed??1,r=t.cuts;return!r||r.length===0?wordsIn(n,t.from,t.end-t.start,t.start,e):r.flatMap((o,s)=>{const i=r[s+1]?.at??t.end;return wordsIn(n,o.from,i-o.at,o.at,e)})}export function wordsIn(n,t,e,r,o=1){const s=c=>Math.round(c*1e3)/1e3,i=t+e*o,d=r-t,u=c=>s(o===1?c+d:r+(c-t)/o);return n.filter(c=>c.start>=t-1e-6&&c.start<i-1e-6).map(c=>({text:c.text,start:u(c.start),end:u(Math.min(c.end,i))}))}const a=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu;export const SPEECH_RATE_DEFAULTS={word:.38,cjk:.22};export function speechUnits(n){const t=n.match(a)?.length??0;return{words:n.replace(a," ").split(/\s+/u).filter(r=>/[\p{L}\p{N}]/u.test(r)).length,cjk:t}}const f=(n,t)=>{const{words:e,cjk:r}=speechUnits(n);return e*(t.word??SPEECH_RATE_DEFAULTS.word)+r*(t.cjk??SPEECH_RATE_DEFAULTS.cjk)};export function estimateSpeech(n,t={}){return Math.max(1,Math.round(f(n,t)*10)/10)}export function speechLength(n,t,e={}){const r=f(n,e),o=t===void 0?0:f(t.text,e),s=t!==void 0&&o>0&&t.seconds>0?t.seconds*r/o:r;return Math.round(s*10)/10}
@@ -0,0 +1,52 @@
1
+ import type { MixPlan } from "@allyhub/audio";
2
+ import type { CaptionLine, CaptionOptions, StageOutput, StageSummary, Word } from "@allyhub/piece";
3
+ import type { CoverInfo, PageObjects, PartText, Timeline } from "./timeline.js";
4
+ import type { Reads } from "@allyhub/piece";
5
+ /** A `say` the project needs a file for (allyhub voice). */
6
+ export interface SayNeed {
7
+ part: string;
8
+ /** The text read aloud. */
9
+ text: string;
10
+ voice?: string;
11
+ tool: string;
12
+ /** More input for the voice tool (say's params), part of the hash. */
13
+ params?: Record<string, unknown>;
14
+ /** `assets/media/gen/say/<hash>`: the file is this plus an audio extension. */
15
+ stem: string;
16
+ /** The file, when it is there. */
17
+ file?: string;
18
+ }
19
+ /** What a host reads once of a piece on the film's clock, after its load and ready(). */
20
+ export interface FilmSummary extends StageSummary {
21
+ timeline: Timeline;
22
+ reads: Reads;
23
+ text: PartText[];
24
+ says: SayNeed[];
25
+ covers: CoverInfo[];
26
+ }
27
+ /** One output of a piece on the film's clock, loaded on the stage. */
28
+ export interface FilmOutput extends StageOutput<FilmSummary> {
29
+ /** The film's plan; after ready() it has the parts' titles. */
30
+ readonly timeline: Timeline;
31
+ /** The words said in it, on its film clock, as its captions have them. */
32
+ words(): Word[];
33
+ /** Its caption lines on its film clock: each part's line as shown and as said, with its words. */
34
+ lines(): CaptionLine[];
35
+ /** The options its first layer that read its captions asked (ctx.captions), which its subtitles follow; null when none did. */
36
+ captionOptions(): CaptionOptions | null;
37
+ /** The player plays or pauses: footage plays along. */
38
+ setPlaying(on: boolean): void;
39
+ text(): PartText[];
40
+ reads(): Reads;
41
+ /** The parts that say text through `say`, and the file each needs. */
42
+ says(): SayNeed[];
43
+ /** Its sound as a plan, which @allyhub/audio renders (the player's and the export's). */
44
+ mixPlan(): MixPlan;
45
+ covers(): CoverInfo[];
46
+ drawCover(n: number): Promise<void>;
47
+ /** What moment t shows that an editor lets a person point at: placed elements and text blocks with their message keys. */
48
+ objects(t: number): Promise<PageObjects>;
49
+ }
50
+ /** What a film's output says once it is ready (StageOutput.summary). */
51
+ export declare const filmSummary: (output: FilmOutput) => FilmSummary;
52
+ //# sourceMappingURL=stage.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ export const filmSummary=s=>({kind:s.kind,timeline:s.timeline,problems:s.problems(),facts:s.facts(),reads:s.reads(),text:s.text(),says:s.says(),signs:s.signs(),covers:s.covers(),seekLimit:s.seekLimit});
@@ -1,107 +1,9 @@
1
- import type { SlidesFile } from "@allyhub/formats";
2
- import { type TextAnchor } from "./anchors.js";
3
- import type { PlatformProfile } from "./formats.js";
4
- import type { Look } from "./look.js";
5
- import type { MediaInfo, MediaKind } from "./media.js";
1
+ import type { IndexNeed, PixelRect } from "@allyhub/piece";
6
2
  import type { FixedShape, MasterTargets, MixLevels, ResolvedShape, ResolvedVoice } from "./audio-types.js";
7
- import type { MessagesFile } from "./messages.js";
8
- import type { MessageHint, PartDefaults } from "./piece.js";
9
- import type { Combo, Dims, MatrixRule, MatrixSpace } from "./matrix.js";
10
3
  import type { Ease } from "./motion.js";
11
4
  import type { PlacedStretch } from "./music.js";
12
5
  import type { TimelineTransition } from "./transition.js";
13
- import type { RoomLevel } from "./voice.js";
14
- export interface LoadOptions {
15
- /** The combo: one value per dimension, e.g. { lang: "zh-cn" }. */
16
- combo: Combo;
17
- purpose: "play" | "render" | "check";
18
- /**
19
- * The most different console messages kept from piece code (see
20
- * console.ts); default CONSOLE_LIMIT.
21
- */
22
- consoleLimit?: number;
23
- }
24
- /** A data file ctx.data(path) can read: parsed, or why it could not be. */
25
- export interface DataFile {
26
- sha256: string;
27
- value?: unknown;
28
- error?: string;
29
- }
30
- /** What the host hands load(): one piece, as the build made it. */
31
- export interface BuildSource {
32
- /**
33
- * What it is: a video (the default), a deck, which the stage loads with
34
- * the deck's runtime, or a doc that shows components, whose module
35
- * exports their table (`components`: reference → component) and which
36
- * the stage draws one component at a time.
37
- */
38
- kind?: "video" | "slides" | "doc";
39
- /** The piece's id: seeds and problems use it. */
40
- piece: string;
41
- /**
42
- * The piece's file, relative to the project root: a path its own options
43
- * name (music, a LUT) and ctx.asset() are relative to it, unless the
44
- * piece says where it was written (`base`).
45
- */
46
- file: string;
47
- /**
48
- * The bundled piece module's address. A build writes it, and every
49
- * address below, relative to the root of the tree the stage is served
50
- * in (`build/pieces/…`, `media/…`); the stage resolves them
51
- * (resolveSource), so one build is served anywhere.
52
- */
53
- module: string;
54
- /** The stylesheets the bundle imports. */
55
- styles?: string[];
56
- /** The piece's dimensions, as the build resolved them (lang filled in). */
57
- dims: Dims;
58
- /** Its slots, structures and rules, when it has slots (pools resolved). */
59
- matrix?: {
60
- space: MatrixSpace;
61
- rules: MatrixRule[];
62
- };
63
- /**
64
- * The piece's one format, as the build resolved it (the project's
65
- * default filled in), e.g. "9x16". A piece has one output, its kind's.
66
- */
67
- format: string;
68
- /** Locales, the default first. */
69
- locales: string[];
70
- /** Every message by locale: the messages files' and the items' scripts'. */
71
- messages: Record<string, MessagesFile>;
72
- /**
73
- * locale → key → the anchors a script wrote in that line (@{name}), by
74
- * their place in the line as spoken.
75
- */
76
- anchors?: Record<string, Record<string, TextAnchor[]>>;
77
- /** The folder of the shared words (allyhub.config.ts's text); default assets/text. */
78
- text?: string;
79
- /** Repo path → media, with its address. */
80
- media: Record<string, MediaInfo>;
81
- /** Repo path → data files (CSV, YAML, JSON) that ctx.data(path) reads. */
82
- data?: Record<string, DataFile>;
83
- /** Looks by name; the built-in clean is always there. */
84
- looks?: Record<string, Look>;
85
- /** The project's part defaults (allyhub.config.ts `defaults.part`). */
86
- partDefaults?: PartDefaults;
87
- /** A deck's pages: its slides.yaml as the build read it (none when it has none, or it does not match the format). */
88
- slides?: SlidesFile;
89
- /** A deck's code as data, as the build ran it (slides-core's DeckCode): its generators' slides made in Node; without it the stage runs them. */
90
- code?: unknown;
91
- /**
92
- * Every piece of the build by id, for a piece that shows another inside
93
- * it (a scenery's screen): its file, dimensions, format and matrix.
94
- */
95
- pieces?: Record<string, {
96
- file: string;
97
- dims: Dims;
98
- format: string;
99
- matrix?: {
100
- space: MatrixSpace;
101
- rules: MatrixRule[];
102
- };
103
- }>;
104
- }
6
+ import type { RoomLevel } from "@allyhub/piece";
105
7
  /** Where a part's speech plays: film seconds, and the take's file and offset. */
106
8
  export interface PartSpeech {
107
9
  /** Film time the speech starts and ends. */
@@ -216,8 +118,13 @@ export interface Part {
216
118
  still: number;
217
119
  /** A deck's page: each of its steps' still moments, absolute, step 0 first (the last is `still`). */
218
120
  steps?: number[];
219
- /** A deck's page left out when the deck is presented or exported (slides.yaml's `hidden`). */
121
+ /** A deck's page left out when the deck is presented or exported (its slides file's `hidden`). */
220
122
  hidden?: boolean;
123
+ /** A part drawn at a frame of its own (an image's board), in pixels, not the timeline's. */
124
+ frame?: {
125
+ width: number;
126
+ height: number;
127
+ };
221
128
  /** A name for people: part({ title }), else its largest text at its still that not every part shows. */
222
129
  title?: string;
223
130
  /** Voiced parts: where the speech plays. */
@@ -263,8 +170,6 @@ export interface Cue {
263
170
  /** How it is shaped before it is levelled (its sound's `shape`). */
264
171
  shape?: FixedShape;
265
172
  }
266
- /** A rectangle in pixels: x, y, width, height. */
267
- export type PixelRect = [x: number, y: number, w: number, h: number];
268
173
  /**
269
174
  * A footage layer's background as its `background` option resolved: what
270
175
  * is drawn behind the person, and the person's edge, in the frame's pixels.
@@ -518,12 +423,6 @@ export interface Timeline {
518
423
  /** The pixels the frame is drawn in. */
519
424
  width: number;
520
425
  height: number;
521
- /**
522
- * A video in a platform profile's format: the profile, with the
523
- * numbers the piece's formats entry changes (covered edges, length,
524
- * loudness).
525
- */
526
- profile?: PlatformProfile;
527
426
  /** A deck's paper (CSS `@page size`): its slide size, as PowerPoint prints it. */
528
427
  paper?: string;
529
428
  duration: number;
@@ -551,12 +450,6 @@ export interface Timeline {
551
450
  */
552
451
  index?: IndexNeed[];
553
452
  }
554
- /** A video the media index should learn about: its face track, its person matte. */
555
- export interface IndexNeed {
556
- file: string;
557
- faces?: true;
558
- matte?: true;
559
- }
560
453
  export interface PartText {
561
454
  key: string;
562
455
  onScreen: string[];
@@ -569,27 +462,6 @@ export interface PartText {
569
462
  /** A deck's speaker notes for this slide (the script's `notes`). */
570
463
  notes?: string;
571
464
  }
572
- export interface MessageRead {
573
- key: string;
574
- part?: string;
575
- kind: "text" | "list";
576
- hint?: MessageHint;
577
- fallback: boolean;
578
- }
579
- export interface Reads {
580
- messages: MessageRead[];
581
- media: {
582
- path: string;
583
- sha256: string;
584
- part?: string;
585
- kind: MediaKind;
586
- }[];
587
- /** Data files read with ctx.data (imported data is in the bundle). */
588
- data: {
589
- path: string;
590
- sha256: string;
591
- }[];
592
- }
593
465
  export interface CoverInfo {
594
466
  key: string;
595
467
  /** What its layers are: component names, and "footage". */
@@ -627,5 +499,15 @@ export interface PageObjects {
627
499
  size: number;
628
500
  keys: string[];
629
501
  }[];
502
+ /**
503
+ * A video's graphic layers shown, front last: each by its part and its
504
+ * place in the part's `layers` (as its code lists them), with the box its
505
+ * drawing takes in the frame's pixels.
506
+ */
507
+ layers?: {
508
+ part: string;
509
+ index: number;
510
+ box: [number, number, number, number];
511
+ }[];
630
512
  }
631
513
  //# sourceMappingURL=timeline.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{parseAnchorRef as f}from"./anchors.js";export function planeAt(t,s,r){return(t?.planes[s]?.layers??[]).some(n=>n.end>n.start&&r>=n.start-1e-6&&r<n.end+1e-6)}export function stackOf(t,s){const r=s.filter(a=>a.part===t.key),n=[];for(let a=0;a<=t.planes.length;a++){for(const o of r)Math.min(o.over??0,t.planes.length)===a&&n.push({kind:"footage",footage:o});const e=t.planes[a];if(e&&(n.push({kind:"graphics",plane:a,layers:e.layers}),!!e.behindPerson))for(const o of r)o.cutout===!0&&(o.over??0)===a&&n.push({kind:"person",footage:o})}return n}export function momentOf(t,s){const r=new Set(t.parts.flatMap(e=>(e.anchors??[]).map(o=>o.name))),n=f(s,r);if(n){for(const e of t.parts){const o=e.anchors?.find(i=>i.name===n.name);if(o){if(n.end&&o.end===void 0)throw new Error(`The anchor "${n.name}" of part ${e.key} is a place, not a stretch: "@/${n.name}" has no end. Use "@${n.name}".`);return(n.end?o.end??o.at:o.at)+n.shift}}throw new Error(`No part of the video has the anchor "${n.name}"; it has ${r.size>0?[...r].map(e=>`@${e}`).join(", "):"no anchors"}.`)}const a=t.parts.find(e=>e.key===s);if(a)return a.start;throw new Error(`"${s}" is not an anchor ("@name") or a part of the video; its parts are ${t.parts.map(e=>e.key).join(", ")}.`)}
2
+ import{parseAnchorRef as f}from"@allyhub/piece";export function planeAt(t,s,r){return(t?.planes[s]?.layers??[]).some(n=>n.end>n.start&&r>=n.start-1e-6&&r<n.end+1e-6)}export function stackOf(t,s){const r=s.filter(a=>a.part===t.key),n=[];for(let a=0;a<=t.planes.length;a++){for(const o of r)Math.min(o.over??0,t.planes.length)===a&&n.push({kind:"footage",footage:o});const e=t.planes[a];if(e&&(n.push({kind:"graphics",plane:a,layers:e.layers}),!!e.behindPerson))for(const o of r)o.cutout===!0&&(o.over??0)===a&&n.push({kind:"person",footage:o})}return n}export function momentOf(t,s){const r=new Set(t.parts.flatMap(e=>(e.anchors??[]).map(o=>o.name))),n=f(s,r);if(n){for(const e of t.parts){const o=e.anchors?.find(i=>i.name===n.name);if(o){if(n.end&&o.end===void 0)throw new Error(`The anchor "${n.name}" of part ${e.key} is a place, not a stretch: "@/${n.name}" has no end. Use "@${n.name}".`);return(n.end?o.end??o.at:o.at)+n.shift}}throw new Error(`No part of the video has the anchor "${n.name}"; it has ${r.size>0?[...r].map(e=>`@${e}`).join(", "):"no anchors"}.`)}const a=t.parts.find(e=>e.key===s);if(a)return a.start;throw new Error(`"${s}" is not an anchor ("@name") or a part of the video; its parts are ${t.parts.map(e=>e.key).join(", ")}.`)}
@@ -1,6 +1,6 @@
1
- import { type LineAnchor } from "./anchors.js";
2
- import { type Problem } from "./problem.js";
3
- import type { Word } from "./media.js";
1
+ import { type LineAnchor } from "@allyhub/piece";
2
+ import { type Problem } from "@allyhub/diagnostics";
3
+ import type { Word } from "@allyhub/piece";
4
4
  export interface PartInput {
5
5
  key: string;
6
6
  /** The part's words on its speech's clock (seconds from the start of its speech). */
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{parseAnchorRef as z}from"./anchors.js";import{FPS as B}from"./formats.js";import{problem as R}from"./problem.js";import{joinWords as E,normText as W,numericRef as H,parseWordRef as I,ScriptAlignment as J,WordStream as j}from"./words.js";const g=i=>Math.round(i*1e3)/1e3;function L(i,l,a){const x=w=>Math.round(w*a)/a,p=i.map(x);for(let w=1;w<p.length;w++){const d=p[w-1]??0;(p[w]??0)<=d&&(p[w]=d+1/a)}const b=p.at(-1)??0;return{starts:p,end:Math.max(x(l),b+1/a)}}const F=i=>i.speechDur!==void 0&&i.speechDur>0;export function overlapOf(i,l){const a=i[l]??0;if(!F(i)||!Number.isFinite(a)||a<=0)return 0;const x=(i.speechDur??0)/2+(l==="before"?i.lead:i.tail);return Math.min(a,x)}export function timeParts(i,l={}){const a=i.map((t,e)=>({...t,before:e===0?0:t.before??0,after:e===i.length-1?0:t.after??0})),x=l.fps??B,p=l.beat??0,b=[];for(const t of a){const e=new Set((t.placed??[]).map(n=>n.name));for(const n of t.anchors??[])e.has(n.name)&&b.push(R("AK-T004",`The anchor ${n.name} of part ${t.key} is both in the line it says (@{${n.name}}) and in the part's own anchors; "@${n.name}" is the part's own. Rename one of them.`,{part:t.key}))}const w=[];let d=0;for(const t of a){w.push(d);let e;if(F(t))e=t.lead+(t.speechDur??0)+t.tail-overlapOf(t,"before")-overlapOf(t,"after");else{e=t.dur;const n=l.snap?.(d+e,d);if(n!==void 0)e=n-d;else if(p>0&&!l.snap){const r=l.beatPhase??0;let s=r+Math.round((d+e-r)/p)*p;s<=d+1e-9&&(s+=p),e=s-d}}d+=Math.max(e,1/x)}const{starts:G,end:K}=L(w,d,x),T=a.map((t,e)=>{const n=G[e]??0;return{key:t.key,start:n,end:G[e+1]??K,...F(t)?{speechAt:g(n+t.lead-overlapOf(t,"before"))}:{}}}),D=new Map,P=t=>{if(D.has(t))return D.get(t);const e=a[t],n=e?.script&&e.words?.length?new J(new j(e.words),[e.script]):void 0;return D.set(t,n),n};function C(t,e){const n=T[t],r=a[t];if(!n||!r)return;const s=r.anchors??[],f=r.placed??[],o=z(e,new Set([...s,...f].map(u=>u.name)));if(!o)return;const $=n.end-n.start,y=u=>(b.push(R("AK-T004",u,{part:r.key})),g($/2)),k=u=>g(Math.min($,Math.max(0,u))),m=f.find(u=>u.name===o.name);if(m)return o.end&&m.end===void 0?y(`"${e}" asks for the end of the anchor ${m.name} of part ${r.key}, which is a point. Give it as a stretch (anchors: { ${m.name}: [from, to] }), or use "@${m.name}".`):k((o.end?m.end??m.at:m.at)+o.shift);const c=s.find(u=>u.name===o.name);if(!c){const u=[...s,...f].map(q=>`@${q.name}`);return y(`The anchor "${e}" is not in the line part ${r.key} says, nor in the part's own anchors${u.length>0?` (its anchors: ${u.join(", ")})`:""}. Write @{${o.name}} before the word it is for, in the part's say in the item's script, in every language (the part must say that line, s("….say")); or give its seconds in the part: anchors: { ${o.name}: 1.2 }.`)}if(o.end&&c.end===void 0)return y(`"${e}" asks for the end of the anchor ${c.name} of part ${r.key}, which is a point. Write @{${c.name}}…@{/${c.name}} around the words in the script, or use "@${c.name}".`);const M=o.end?c.end??c.at:c.at,S=W(r.script??"");if(r.pending===!0&&n.speechAt===void 0)return S.length===0?g($/2):k(M/S.length*$+o.shift);const h=r.words??[],A=P(t);if(n.speechAt===void 0||!A||h.length===0)return y(`The anchor "${e}" is in part ${r.key}, which has no speech. Give its seconds in the part instead: anchors: { ${o.name}: 1.2 }.`);const v=h.at(-1),U=o.end?h[A.wordAtChar(0,Math.max(0,M-1))]?.end:M>=S.length?v?.end:h[A.wordAtChar(0,M)]?.start;return k(n.speechAt+(U??0)+o.shift-n.start)}function O(t,e){const n=H(e);if(n!==void 0)return n;const r=typeof e=="string"?C(t,e):void 0;if(r!==void 0)return r;const s=T[t],f=a[t];if(!s||!f)return 0;const o=s.end-s.start,$=f.words??[],{text:y,nth:k,shift:m}=I(String(e));let c=-1;$.length>0&&(c=P(t)?.wordFor(0,y,k)??-1,c<0&&(c=new j($).find(W(y),0,$.length-1,k)));const M=$[c];if(f.pending===!0&&s.speechAt===void 0){const h=W(f.script??"");let A=-1;for(let v=0;v<k;v++)A=h.indexOf(W(y),A+1);return A<0||h.length===0?g(o/2):g(Math.min(o,Math.max(0,A/h.length*o+m)))}if(c<0||!M||s.speechAt===void 0){const h=f.script??E($);return b.push(R("AK-T004",s.speechAt===void 0?`The word reference "${String(e)}" is in part ${f.key}, which has no speech. Give it in seconds from the part's start instead.`:`The word reference "${String(e)}" is not in the words of part ${f.key}${h?` (it says: "${h.length>160?`${h.slice(0,160)}…`:h}")`:""}. Use a word the part says, as "word", "word@2" or "word+0.2".`,{part:f.key})),g(o/2)}const S=s.speechAt+M.start+m;return g(Math.min(o,Math.max(0,S-s.start)))}function N(t){const e=T[t],n=a[t];if(!e||!n||e.speechAt===void 0)return[];const r=e.speechAt-e.start;return(n.words??[]).map(s=>({text:s.text,start:g(s.start+r),end:g(s.end+r)}))}return{parts:T,duration:K,problems:b,at:O,words:N}}
2
+ import{parseAnchorRef as z}from"@allyhub/piece";import{FPS as B}from"@allyhub/piece";import{problem as R}from"@allyhub/diagnostics";import{joinWords as E,normText as W,numericRef as H,parseWordRef as I,ScriptAlignment as J,WordStream as j}from"@allyhub/piece";const g=i=>Math.round(i*1e3)/1e3;function L(i,l,a){const x=w=>Math.round(w*a)/a,p=i.map(x);for(let w=1;w<p.length;w++){const d=p[w-1]??0;(p[w]??0)<=d&&(p[w]=d+1/a)}const b=p.at(-1)??0;return{starts:p,end:Math.max(x(l),b+1/a)}}const F=i=>i.speechDur!==void 0&&i.speechDur>0;export function overlapOf(i,l){const a=i[l]??0;if(!F(i)||!Number.isFinite(a)||a<=0)return 0;const x=(i.speechDur??0)/2+(l==="before"?i.lead:i.tail);return Math.min(a,x)}export function timeParts(i,l={}){const a=i.map((t,e)=>({...t,before:e===0?0:t.before??0,after:e===i.length-1?0:t.after??0})),x=l.fps??B,p=l.beat??0,b=[];for(const t of a){const e=new Set((t.placed??[]).map(n=>n.name));for(const n of t.anchors??[])e.has(n.name)&&b.push(R("AK-T004",`The anchor ${n.name} of part ${t.key} is both in the line it says (@{${n.name}}) and in the part's own anchors; "@${n.name}" is the part's own. Rename one of them.`,{part:t.key}))}const w=[];let d=0;for(const t of a){w.push(d);let e;if(F(t))e=t.lead+(t.speechDur??0)+t.tail-overlapOf(t,"before")-overlapOf(t,"after");else{e=t.dur;const n=l.snap?.(d+e,d);if(n!==void 0)e=n-d;else if(p>0&&!l.snap){const r=l.beatPhase??0;let s=r+Math.round((d+e-r)/p)*p;s<=d+1e-9&&(s+=p),e=s-d}}d+=Math.max(e,1/x)}const{starts:G,end:K}=L(w,d,x),T=a.map((t,e)=>{const n=G[e]??0;return{key:t.key,start:n,end:G[e+1]??K,...F(t)?{speechAt:g(n+t.lead-overlapOf(t,"before"))}:{}}}),D=new Map,P=t=>{if(D.has(t))return D.get(t);const e=a[t],n=e?.script&&e.words?.length?new J(new j(e.words),[e.script]):void 0;return D.set(t,n),n};function C(t,e){const n=T[t],r=a[t];if(!n||!r)return;const s=r.anchors??[],f=r.placed??[],o=z(e,new Set([...s,...f].map(u=>u.name)));if(!o)return;const $=n.end-n.start,y=u=>(b.push(R("AK-T004",u,{part:r.key})),g($/2)),k=u=>g(Math.min($,Math.max(0,u))),m=f.find(u=>u.name===o.name);if(m)return o.end&&m.end===void 0?y(`"${e}" asks for the end of the anchor ${m.name} of part ${r.key}, which is a point. Give it as a stretch (anchors: { ${m.name}: [from, to] }), or use "@${m.name}".`):k((o.end?m.end??m.at:m.at)+o.shift);const c=s.find(u=>u.name===o.name);if(!c){const u=[...s,...f].map(q=>`@${q.name}`);return y(`The anchor "${e}" is not in the line part ${r.key} says, nor in the part's own anchors${u.length>0?` (its anchors: ${u.join(", ")})`:""}. Write @{${o.name}} before the word it is for, in the part's say in the item's script, in every language (the part must say that line, s("….say")); or give its seconds in the part: anchors: { ${o.name}: 1.2 }.`)}if(o.end&&c.end===void 0)return y(`"${e}" asks for the end of the anchor ${c.name} of part ${r.key}, which is a point. Write @{${c.name}}…@{/${c.name}} around the words in the script, or use "@${c.name}".`);const M=o.end?c.end??c.at:c.at,S=W(r.script??"");if(r.pending===!0&&n.speechAt===void 0)return S.length===0?g($/2):k(M/S.length*$+o.shift);const h=r.words??[],A=P(t);if(n.speechAt===void 0||!A||h.length===0)return y(`The anchor "${e}" is in part ${r.key}, which has no speech. Give its seconds in the part instead: anchors: { ${o.name}: 1.2 }.`);const v=h.at(-1),U=o.end?h[A.wordAtChar(0,Math.max(0,M-1))]?.end:M>=S.length?v?.end:h[A.wordAtChar(0,M)]?.start;return k(n.speechAt+(U??0)+o.shift-n.start)}function O(t,e){const n=H(e);if(n!==void 0)return n;const r=typeof e=="string"?C(t,e):void 0;if(r!==void 0)return r;const s=T[t],f=a[t];if(!s||!f)return 0;const o=s.end-s.start,$=f.words??[],{text:y,nth:k,shift:m}=I(String(e));let c=-1;$.length>0&&(c=P(t)?.wordFor(0,y,k)??-1,c<0&&(c=new j($).find(W(y),0,$.length-1,k)));const M=$[c];if(f.pending===!0&&s.speechAt===void 0){const h=W(f.script??"");let A=-1;for(let v=0;v<k;v++)A=h.indexOf(W(y),A+1);return A<0||h.length===0?g(o/2):g(Math.min(o,Math.max(0,A/h.length*o+m)))}if(c<0||!M||s.speechAt===void 0){const h=f.script??E($);return b.push(R("AK-T004",s.speechAt===void 0?`The word reference "${String(e)}" is in part ${f.key}, which has no speech. Give it in seconds from the part's start instead.`:`The word reference "${String(e)}" is not in the words of part ${f.key}${h?` (it says: "${h.length>160?`${h.slice(0,160)}…`:h}")`:""}. Use a word the part says, as "word", "word@2" or "word+0.2".`,{part:f.key})),g(o/2)}const S=s.speechAt+M.start+m;return g(Math.min(o,Math.max(0,S-s.start)))}function N(t){const e=T[t],n=a[t];if(!e||!n||e.speechAt===void 0)return[];const r=e.speechAt-e.start;return(n.words??[]).map(s=>({text:s.text,start:g(s.start+r),end:g(s.end+r)}))}return{parts:T,duration:K,problems:b,at:O,words:N}}
@@ -1,6 +1,6 @@
1
1
  import type { EditedSpeech } from "./edits.js";
2
- import type { Word } from "./media.js";
3
- import { type UnheardSound, type VoiceFrames } from "./voice.js";
2
+ import type { Word, UnheardSound } from "@allyhub/piece";
3
+ import { type VoiceFrames } from "@allyhub/piece";
4
4
  /** A take's noise floor and speech level, dBFS (FilmCraft's percentiles). */
5
5
  export interface TakeLevels {
6
6
  /** The 10th percentile of frame levels above −100 dBFS. */
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{frameDb as E}from"./voice.js";import{findLine as z,joinWords as G,LINE_FOUND as K,normText as N,ScriptAlignment as Q,WordStream as q}from"./words.js";const b=t=>Math.round(t*1e3)/1e3,_=t=>Math.round(t*10)/10;export function takeLevels(t){const e=Array.from(t.db,n=>-n).filter(n=>n>-100).sort((n,a)=>n-a);if(e.length===0)return{floor:-100,speech:-100,threshold:-60};const r=n=>e[Math.floor((e.length-1)*n)]??-100,u=r(.1),i=r(.95);return{floor:_(u),speech:_(i),threshold:_(Math.max(u+.3*(i-u),u+6))}}function V(t,e,r){return[Math.round(e/t),Math.max(Math.round(e/t)+1,Math.round(r/t))]}export function wordLevels(t,e){return t.map(r=>{const[u,i]=V(e.hop,r.start,r.end);let n=-120,a=0,f=0;for(let l=u;l<i&&l<e.db.length;l++){const s=E(e,l);n=Math.max(n,s),a+=s,f++}return{peak:_(n),mean:_(f?a/f:-120)}})}const X=.06;export function tightenWords(t,e){const{threshold:r}=takeLevels(e),u=e.hop,i=Math.round(X/u);let n=0;return{words:t.map(f=>{const l=Math.max(0,Math.round(f.start/u)),s=Math.min(e.db.length,Math.round(f.end/u));if(s<=l+i)return{...f};const d=g=>E(e,g)>=r;let x=!1;for(let g=l;g<s;g++)d(g)&&(x=!0);if(!x)return{...f};let o=l;for(;o+i<s&&!d(o);)o++;let c=s;for(;c>o+i&&!d(c-1);)c--;const h=o>l?b(Math.max(f.start,o*u-u/2)):f.start,M=c<s?b(Math.min(f.end,Math.max(h,c*u-u/2))):f.end;return(h!==f.start||M!==f.end)&&n++,{...f,start:h,end:M}}),moved:n}}export const WORD_SHAPE_DEFAULTS={voiced:.6,dip:10};const U=8,C=2,Y=/\p{L}/gu,Z=/\p{N}/u;function H(t){const e=N(t);return Z.test(e)?0:e.match(Y)?.length??0}const w=t=>{const e=[...t].sort((u,i)=>u-i),r=e.length>>1;return e.length%2?e[r]??0:((e[r-1]??0)+(e[r]??0))/2};export function speakingRate(t){const e=new Map;let r=0;for(const x of t){const o=H(x.text),c=x.end-x.start;o===0||!(c>0)||(e.set(o,[...e.get(o)??[],c]),r++)}if(r<U)return;let u=0,i=0,n=0,a=0,f=0;for(const[x,o]of e){const c=o.length,h=w(o);u+=c,i+=c*x,n+=c*h,a+=c*x*x,f+=c*x*h}const l=u*a-i*i;let s=l>1e-9?(u*f-i*n)/l:0,d=(n-s*i)/u;if((d<0||l<=1e-9)&&(d=0,s=a>0?f/a:0),s>0)return{base:b(d),perLetter:b(s),words:r}}export function wordShapes(t,e,r={}){const u={voiced:r.voiced??WORD_SHAPE_DEFAULTS.voiced,dip:r.dip??WORD_SHAPE_DEFAULTS.dip},i=speakingRate(t),n=e.hop,a=Math.round(u.voiced*100),f=t.map((l,s)=>{const d=Math.max(0,l.end-l.start),x=H(l.text),o=i&&x>0?b(i.base+i.perLetter*x):null,c=Math.max(0,Math.round(l.start/n)),h=Math.min(e.db.length,Math.round(l.end/n)),M=[];let g=-1;for(let p=c;p<=h;p++){const $=p<h&&(e.voicing[p]??0)>=a;$&&g<0&&(g=p),!$&&g>=0&&(p-g>=C&&M.push({start:b(g*n),end:b(p*n)}),g=-1)}const m=[],L=new Float64Array(Math.max(0,h-c));let A=-120;for(let p=h-1;p>=c;p--)A=Math.max(A,E(e,p)),L[p-c]=A;let W=-120,S=-1,k=0;for(let p=c;p<=h;p++){let $=0;p<h&&(W=Math.max(W,E(e,p)),$=Math.min(W,L[p-c]??-120)-E(e,p)),$>=u.dip?(S<0&&(S=p),k=Math.max(k,$)):S>=0&&(p-S>=C&&m.push({start:b(S*n),end:b(p*n),depth:_(k)}),S=-1,k=0)}return{i:s,dur:b(d),letters:x,expected:o,ratio:o===null?null:Math.round(d/o*100)/100,excess:o===null?null:b(d-o),voicedRuns:M,dips:m}});return{rate:i??null,...i?{}:{rateWhy:t.length<U?`the take has under ${String(U)} words with letters`:"the take's longer words do not last longer than its short ones"},options:u,words:f}}export const LONG_WORD_DEFAULTS={ratio:2,excess:.15};export function longWords(t,e={}){const r=e.ratio??LONG_WORD_DEFAULTS.ratio,u=e.excess??LONG_WORD_DEFAULTS.excess;return t.filter(i=>i.ratio!==null&&i.excess!==null&&i.ratio>=r&&i.excess>=u)}export function longLabel(t){return`(long ${t.dur.toFixed(2)}s ×${(t.ratio??0).toFixed(1)})`}export const PARAGRAPH_GAP=.5;export function paragraphs(t,e=PARAGRAPH_GAP,r=0,u=t.length-1){const i=[];let n=r;for(let a=r;a<=u;a++){const f=t[a],l=t[a+1];if(!f)break;if(a===u||!l||l.start-f.end>=e){const s=t[n];s&&i.push({from:n,to:a,start:s.start,end:f.end,text:G(t.slice(n,a+1))}),n=a+1}}return i}export function searchWords(t,e){const r=e.split(/\s+/u).map(N).filter(n=>n!=="");if(r.length===0)return[];const u=t.map(n=>N(n.text)),i=[];for(let n=0;n+r.length<=t.length;n++){let a=!0;for(let f=0;f<r.length&&a;f++){const l=u[n+f]??"",s=r[f]??"";a=f===r.length-1?l.startsWith(s):l===s}a&&i.push(y(t,n,n+r.length-1))}return i}function y(t,e,r){return{from:e,to:r,start:t[e]?.start??0,end:t[r]?.end??0,text:G(t.slice(e,r+1))}}export function phraseMatches(t,e){const r=e.map(n=>({phrase:n,norm:n.split(/\s+/u).map(N).filter(a=>a!=="")})).filter(n=>n.norm.length>0).sort((n,a)=>a.norm.length-n.norm.length),u=t.map(n=>N(n.text)),i=[];for(let n=0;n<t.length;n++)for(const a of r)if(!(n+a.norm.length>t.length)&&a.norm.every((f,l)=>u[n+l]===f)){i.push({...y(t,n,n+a.norm.length-1),phrase:a.phrase}),n+=a.norm.length-1;break}return i}export function pauseCandidates(t,e,r,u=0,i=t.length-1){const n=[];for(let a=u;a<i;a++){const f=t[a],l=t[a+1];if(!f||!l)continue;const s=l.start-f.end;if(s<e)continue;const d=Math.min(r,s)/2;n.push({after:a,start:f.end,end:l.start,gap:b(s),remove:{from:b(f.end+d),to:b(l.start-d),seconds:b(Math.max(0,s-2*d))}})}return n}export const JOIN_NEAR=.2;export function joinsOf(t,e,r,u,i=JOIN_NEAR){const{ranges:n,kept:a}=e,f=r?wordLevels(t,r):void 0,l=r?.hop??.01,s=[];let d=0;for(let x=0;x+1<n.length;x++){const o=n[x],c=n[x+1];if(!o||!c)continue;d+=o.to-o.from;let h=-1,M=-1;for(const v of a){const F=t[v];F&&(F.start<o.to&&(h=v),M<0&&F.end>c.from&&(M=v))}const g=t[h],m=t[M];if(!g||!m)continue;const L=(v,F,O)=>{if(!r)return null;const I=Math.ceil(v/l-1e-9),R=Math.ceil(F/l-1e-9)-1;let D=0;for(let T=0;T<=R-I;T++){const J=O?R-T:I+T;if(E(r,J)>=u)break;D++}return b(D*l)},A=(v,F)=>{const O=Math.ceil(v/l-1e-9),I=Math.ceil(F/l-1e-9)-1,R=[];if(!r)return R;for(let D=Math.max(0,O);D<=I&&D<r.db.length;D++)R.push(E(r,D));return R},W=(v,F)=>{const O=A(v,F);return O.length?_(Math.max(...O)):null},S=(v,F)=>{const O=A(v,Math.max(F,v+l));return O.length?_(O.reduce((I,R)=>I+R,0)/O.length):null},k=(v,F,O,I,R,D,T)=>({i:v,text:F.text,edge:O,gap:b(I),quiet:R,peakBetween:D,peak:f?.[v]?.peak??null,mean:f?.[v]?.mean??null,near:T}),p=Math.min(g.end,o.to),$=Math.max(m.start,c.from),j=k(h,g,p,o.to-p,L(o.from,o.to,!0),W(p,o.to),S(Math.max(g.start,p-i),p)),P=k(M,m,$,$-c.from,L(c.from,c.to,!1),W(c.from,$),S($,Math.min(m.end,$+i)));s.push({at:b(d),out:o.to,in:c.from,removed:M>h+1?{from:h+1,to:M-1}:null,inWord:g.end>o.to+1e-9||m.start<c.from-1e-9,before:j,after:P,step:j.near===null||P.near===null?null:_(P.near-j.near)})}return s}export const SCRIPT_DIFF_DEFAULTS={match:.5,lineMatch:K};export function scriptDiff(t,e,r={}){const u={match:r.match??SCRIPT_DIFF_DEFAULTS.match,lineMatch:r.lineMatch??SCRIPT_DIFF_DEFAULTS.lineMatch},i=new q(t),n=e.filter(o=>N(o)!==""),a=new Q(i,n),f=[];let l;for(let o=0;o<=t.length;o++){let c=!1;if(o<t.length){const h=i.charOf(o),M=i.charOf(o+1);let g=0;for(let m=h;m<M;m++)g+=a.takeHits[m]??0;c=M>h&&g/(M-h)<u.match}c&&l===void 0&&(l=o),!c&&l!==void 0&&(f.push(y(t,l,o-1)),l=void 0)}const s=(o,c,h)=>{if(h<c)return[];const M=new q(t.slice(c,h+1)),g=z(M,o,0);return!g||g.score<u.lineMatch?[]:[...s(o,c,c+g.first-1),y(t,c+g.first,c+g.last),...s(o,c+g.last+1,h)]},d=n.map((o,c)=>{const h=a.lines[c]?.length??0;return{line:c,text:o,share:h?Math.round((a.matched[c]??0)/h*1e3)/1e3:0,matches:s(o,0,t.length-1)}}),x=d.filter(o=>o.matches.length>1).map(({line:o,text:c,matches:h})=>({line:o,text:c,matches:h}));return{options:u,unscripted:f,repeated:x,lines:d}}const B=t=>t.toFixed(2).padStart(6,"0");export const LINE_WORDS=12;export function soundLabel(t,e=!1){const r=t.peak>=0?`+${String(t.peak)}`:`−${String(-t.peak)}`;return`(${e?"cut ":""}sound ${t.start.toFixed(2)}–${t.end.toFixed(2)} ${(t.end-t.start).toFixed(2)}s ${r}dB v${t.voiced.toFixed(2)})`}export function packTranscript(t,e={}){const r=Math.max(0,e.from??0),u=Math.min(t.length-1,e.to??t.length-1),i=e.sounds??[],n=e.lineWords??LINE_WORDS,a=s=>(e.removedSounds??[]).some(d=>d.from<s.end&&d.to>s.start)||e.removed?.has(s.after)===!0&&e.removed.has(s.after+1),f=[],l=[];for(const s of paragraphs(t,e.gap??PARAGRAPH_GAP,r,u)){let d=s.from;for(let x=s.from;x<=s.to;x++){const o=/[.?!。?!]["')\]]*$/u.test(t[x]?.text??"");(x===s.to||o&&x-d+1>=n)&&(l.push({from:d,to:x}),d=x+1)}}for(const s of l){const d=[],x=i.filter(m=>m.after===s.from-1&&s.from===r);for(const m of x)d.push(soundLabel(m,a(m)));let o,c;const h=()=>{o&&d.push(`[-${o.join(" ")}-]`),c&&d.push(`{${c.join(" ")}}`),o=void 0,c=void 0};for(let m=s.from;m<=s.to;m++){const L=t[m]?.text??"",A=e.unscripted?.has(m)===!0;e.removed?.has(m)===!0?(c&&h(),(o??=[]).push(A?`{${L}}`:L)):A?(o&&h(),(c??=[]).push(L)):(h(),d.push(L));const W=t[m],S=e.long?.get(m);S&&e.removed?.has(m)!==!0&&(h(),d.push(longLabel(S)));for(const k of e.inWord??[]){if(!W||e.removed?.has(m)===!0)continue;const p=t[m-1];k.from<W.end&&k.to>W.start&&!(p&&m>s.from&&k.from<p.end&&k.to>p.start)&&(h(),d.push(`(cut ${k.from.toFixed(2)}–${k.to.toFixed(2)} in word)`))}(m-s.from)%8===7&&m<s.to&&(h(),d.push(`#${String(m+1)}`));for(const k of i.filter(p=>p.after===m))h(),d.push(soundLabel(k,a(k)))}h();const M=t[s.from],g=t[s.to];f.push(`[${B(M?.start??0)}-${B(g?.end??0)}] #${String(s.from)}-#${String(s.to)} ${d.join(" ")}`)}return f}
2
+ import{frameDb as E}from"@allyhub/piece";import{findLine as z,joinWords as G,LINE_FOUND as K,normText as N,ScriptAlignment as Q,WordStream as q}from"@allyhub/piece";const b=t=>Math.round(t*1e3)/1e3,_=t=>Math.round(t*10)/10;export function takeLevels(t){const e=Array.from(t.db,n=>-n).filter(n=>n>-100).sort((n,a)=>n-a);if(e.length===0)return{floor:-100,speech:-100,threshold:-60};const r=n=>e[Math.floor((e.length-1)*n)]??-100,u=r(.1),i=r(.95);return{floor:_(u),speech:_(i),threshold:_(Math.max(u+.3*(i-u),u+6))}}function V(t,e,r){return[Math.round(e/t),Math.max(Math.round(e/t)+1,Math.round(r/t))]}export function wordLevels(t,e){return t.map(r=>{const[u,i]=V(e.hop,r.start,r.end);let n=-120,a=0,f=0;for(let l=u;l<i&&l<e.db.length;l++){const s=E(e,l);n=Math.max(n,s),a+=s,f++}return{peak:_(n),mean:_(f?a/f:-120)}})}const X=.06;export function tightenWords(t,e){const{threshold:r}=takeLevels(e),u=e.hop,i=Math.round(X/u);let n=0;return{words:t.map(f=>{const l=Math.max(0,Math.round(f.start/u)),s=Math.min(e.db.length,Math.round(f.end/u));if(s<=l+i)return{...f};const d=g=>E(e,g)>=r;let x=!1;for(let g=l;g<s;g++)d(g)&&(x=!0);if(!x)return{...f};let o=l;for(;o+i<s&&!d(o);)o++;let c=s;for(;c>o+i&&!d(c-1);)c--;const h=o>l?b(Math.max(f.start,o*u-u/2)):f.start,M=c<s?b(Math.min(f.end,Math.max(h,c*u-u/2))):f.end;return(h!==f.start||M!==f.end)&&n++,{...f,start:h,end:M}}),moved:n}}export const WORD_SHAPE_DEFAULTS={voiced:.6,dip:10};const U=8,C=2,Y=/\p{L}/gu,Z=/\p{N}/u;function H(t){const e=N(t);return Z.test(e)?0:e.match(Y)?.length??0}const w=t=>{const e=[...t].sort((u,i)=>u-i),r=e.length>>1;return e.length%2?e[r]??0:((e[r-1]??0)+(e[r]??0))/2};export function speakingRate(t){const e=new Map;let r=0;for(const x of t){const o=H(x.text),c=x.end-x.start;o===0||!(c>0)||(e.set(o,[...e.get(o)??[],c]),r++)}if(r<U)return;let u=0,i=0,n=0,a=0,f=0;for(const[x,o]of e){const c=o.length,h=w(o);u+=c,i+=c*x,n+=c*h,a+=c*x*x,f+=c*x*h}const l=u*a-i*i;let s=l>1e-9?(u*f-i*n)/l:0,d=(n-s*i)/u;if((d<0||l<=1e-9)&&(d=0,s=a>0?f/a:0),s>0)return{base:b(d),perLetter:b(s),words:r}}export function wordShapes(t,e,r={}){const u={voiced:r.voiced??WORD_SHAPE_DEFAULTS.voiced,dip:r.dip??WORD_SHAPE_DEFAULTS.dip},i=speakingRate(t),n=e.hop,a=Math.round(u.voiced*100),f=t.map((l,s)=>{const d=Math.max(0,l.end-l.start),x=H(l.text),o=i&&x>0?b(i.base+i.perLetter*x):null,c=Math.max(0,Math.round(l.start/n)),h=Math.min(e.db.length,Math.round(l.end/n)),M=[];let g=-1;for(let p=c;p<=h;p++){const $=p<h&&(e.voicing[p]??0)>=a;$&&g<0&&(g=p),!$&&g>=0&&(p-g>=C&&M.push({start:b(g*n),end:b(p*n)}),g=-1)}const m=[],L=new Float64Array(Math.max(0,h-c));let A=-120;for(let p=h-1;p>=c;p--)A=Math.max(A,E(e,p)),L[p-c]=A;let W=-120,S=-1,k=0;for(let p=c;p<=h;p++){let $=0;p<h&&(W=Math.max(W,E(e,p)),$=Math.min(W,L[p-c]??-120)-E(e,p)),$>=u.dip?(S<0&&(S=p),k=Math.max(k,$)):S>=0&&(p-S>=C&&m.push({start:b(S*n),end:b(p*n),depth:_(k)}),S=-1,k=0)}return{i:s,dur:b(d),letters:x,expected:o,ratio:o===null?null:Math.round(d/o*100)/100,excess:o===null?null:b(d-o),voicedRuns:M,dips:m}});return{rate:i??null,...i?{}:{rateWhy:t.length<U?`the take has under ${String(U)} words with letters`:"the take's longer words do not last longer than its short ones"},options:u,words:f}}export const LONG_WORD_DEFAULTS={ratio:2,excess:.15};export function longWords(t,e={}){const r=e.ratio??LONG_WORD_DEFAULTS.ratio,u=e.excess??LONG_WORD_DEFAULTS.excess;return t.filter(i=>i.ratio!==null&&i.excess!==null&&i.ratio>=r&&i.excess>=u)}export function longLabel(t){return`(long ${t.dur.toFixed(2)}s ×${(t.ratio??0).toFixed(1)})`}export const PARAGRAPH_GAP=.5;export function paragraphs(t,e=PARAGRAPH_GAP,r=0,u=t.length-1){const i=[];let n=r;for(let a=r;a<=u;a++){const f=t[a],l=t[a+1];if(!f)break;if(a===u||!l||l.start-f.end>=e){const s=t[n];s&&i.push({from:n,to:a,start:s.start,end:f.end,text:G(t.slice(n,a+1))}),n=a+1}}return i}export function searchWords(t,e){const r=e.split(/\s+/u).map(N).filter(n=>n!=="");if(r.length===0)return[];const u=t.map(n=>N(n.text)),i=[];for(let n=0;n+r.length<=t.length;n++){let a=!0;for(let f=0;f<r.length&&a;f++){const l=u[n+f]??"",s=r[f]??"";a=f===r.length-1?l.startsWith(s):l===s}a&&i.push(y(t,n,n+r.length-1))}return i}function y(t,e,r){return{from:e,to:r,start:t[e]?.start??0,end:t[r]?.end??0,text:G(t.slice(e,r+1))}}export function phraseMatches(t,e){const r=e.map(n=>({phrase:n,norm:n.split(/\s+/u).map(N).filter(a=>a!=="")})).filter(n=>n.norm.length>0).sort((n,a)=>a.norm.length-n.norm.length),u=t.map(n=>N(n.text)),i=[];for(let n=0;n<t.length;n++)for(const a of r)if(!(n+a.norm.length>t.length)&&a.norm.every((f,l)=>u[n+l]===f)){i.push({...y(t,n,n+a.norm.length-1),phrase:a.phrase}),n+=a.norm.length-1;break}return i}export function pauseCandidates(t,e,r,u=0,i=t.length-1){const n=[];for(let a=u;a<i;a++){const f=t[a],l=t[a+1];if(!f||!l)continue;const s=l.start-f.end;if(s<e)continue;const d=Math.min(r,s)/2;n.push({after:a,start:f.end,end:l.start,gap:b(s),remove:{from:b(f.end+d),to:b(l.start-d),seconds:b(Math.max(0,s-2*d))}})}return n}export const JOIN_NEAR=.2;export function joinsOf(t,e,r,u,i=JOIN_NEAR){const{ranges:n,kept:a}=e,f=r?wordLevels(t,r):void 0,l=r?.hop??.01,s=[];let d=0;for(let x=0;x+1<n.length;x++){const o=n[x],c=n[x+1];if(!o||!c)continue;d+=o.to-o.from;let h=-1,M=-1;for(const v of a){const F=t[v];F&&(F.start<o.to&&(h=v),M<0&&F.end>c.from&&(M=v))}const g=t[h],m=t[M];if(!g||!m)continue;const L=(v,F,O)=>{if(!r)return null;const I=Math.ceil(v/l-1e-9),R=Math.ceil(F/l-1e-9)-1;let D=0;for(let T=0;T<=R-I;T++){const J=O?R-T:I+T;if(E(r,J)>=u)break;D++}return b(D*l)},A=(v,F)=>{const O=Math.ceil(v/l-1e-9),I=Math.ceil(F/l-1e-9)-1,R=[];if(!r)return R;for(let D=Math.max(0,O);D<=I&&D<r.db.length;D++)R.push(E(r,D));return R},W=(v,F)=>{const O=A(v,F);return O.length?_(Math.max(...O)):null},S=(v,F)=>{const O=A(v,Math.max(F,v+l));return O.length?_(O.reduce((I,R)=>I+R,0)/O.length):null},k=(v,F,O,I,R,D,T)=>({i:v,text:F.text,edge:O,gap:b(I),quiet:R,peakBetween:D,peak:f?.[v]?.peak??null,mean:f?.[v]?.mean??null,near:T}),p=Math.min(g.end,o.to),$=Math.max(m.start,c.from),j=k(h,g,p,o.to-p,L(o.from,o.to,!0),W(p,o.to),S(Math.max(g.start,p-i),p)),P=k(M,m,$,$-c.from,L(c.from,c.to,!1),W(c.from,$),S($,Math.min(m.end,$+i)));s.push({at:b(d),out:o.to,in:c.from,removed:M>h+1?{from:h+1,to:M-1}:null,inWord:g.end>o.to+1e-9||m.start<c.from-1e-9,before:j,after:P,step:j.near===null||P.near===null?null:_(P.near-j.near)})}return s}export const SCRIPT_DIFF_DEFAULTS={match:.5,lineMatch:K};export function scriptDiff(t,e,r={}){const u={match:r.match??SCRIPT_DIFF_DEFAULTS.match,lineMatch:r.lineMatch??SCRIPT_DIFF_DEFAULTS.lineMatch},i=new q(t),n=e.filter(o=>N(o)!==""),a=new Q(i,n),f=[];let l;for(let o=0;o<=t.length;o++){let c=!1;if(o<t.length){const h=i.charOf(o),M=i.charOf(o+1);let g=0;for(let m=h;m<M;m++)g+=a.takeHits[m]??0;c=M>h&&g/(M-h)<u.match}c&&l===void 0&&(l=o),!c&&l!==void 0&&(f.push(y(t,l,o-1)),l=void 0)}const s=(o,c,h)=>{if(h<c)return[];const M=new q(t.slice(c,h+1)),g=z(M,o,0);return!g||g.score<u.lineMatch?[]:[...s(o,c,c+g.first-1),y(t,c+g.first,c+g.last),...s(o,c+g.last+1,h)]},d=n.map((o,c)=>{const h=a.lines[c]?.length??0;return{line:c,text:o,share:h?Math.round((a.matched[c]??0)/h*1e3)/1e3:0,matches:s(o,0,t.length-1)}}),x=d.filter(o=>o.matches.length>1).map(({line:o,text:c,matches:h})=>({line:o,text:c,matches:h}));return{options:u,unscripted:f,repeated:x,lines:d}}const B=t=>t.toFixed(2).padStart(6,"0");export const LINE_WORDS=12;export function soundLabel(t,e=!1){const r=t.peak>=0?`+${String(t.peak)}`:`−${String(-t.peak)}`;return`(${e?"cut ":""}sound ${t.start.toFixed(2)}–${t.end.toFixed(2)} ${(t.end-t.start).toFixed(2)}s ${r}dB v${t.voiced.toFixed(2)})`}export function packTranscript(t,e={}){const r=Math.max(0,e.from??0),u=Math.min(t.length-1,e.to??t.length-1),i=e.sounds??[],n=e.lineWords??LINE_WORDS,a=s=>(e.removedSounds??[]).some(d=>d.from<s.end&&d.to>s.start)||e.removed?.has(s.after)===!0&&e.removed.has(s.after+1),f=[],l=[];for(const s of paragraphs(t,e.gap??PARAGRAPH_GAP,r,u)){let d=s.from;for(let x=s.from;x<=s.to;x++){const o=/[.?!。?!]["')\]]*$/u.test(t[x]?.text??"");(x===s.to||o&&x-d+1>=n)&&(l.push({from:d,to:x}),d=x+1)}}for(const s of l){const d=[],x=i.filter(m=>m.after===s.from-1&&s.from===r);for(const m of x)d.push(soundLabel(m,a(m)));let o,c;const h=()=>{o&&d.push(`[-${o.join(" ")}-]`),c&&d.push(`{${c.join(" ")}}`),o=void 0,c=void 0};for(let m=s.from;m<=s.to;m++){const L=t[m]?.text??"",A=e.unscripted?.has(m)===!0;e.removed?.has(m)===!0?(c&&h(),(o??=[]).push(A?`{${L}}`:L)):A?(o&&h(),(c??=[]).push(L)):(h(),d.push(L));const W=t[m],S=e.long?.get(m);S&&e.removed?.has(m)!==!0&&(h(),d.push(longLabel(S)));for(const k of e.inWord??[]){if(!W||e.removed?.has(m)===!0)continue;const p=t[m-1];k.from<W.end&&k.to>W.start&&!(p&&m>s.from&&k.from<p.end&&k.to>p.start)&&(h(),d.push(`(cut ${k.from.toFixed(2)}–${k.to.toFixed(2)} in word)`))}(m-s.from)%8===7&&m<s.to&&(h(),d.push(`#${String(m+1)}`));for(const k of i.filter(p=>p.after===m))h(),d.push(soundLabel(k,a(k)))}h();const M=t[s.from],g=t[s.to];f.push(`[${B(M?.start??0)}-${B(g?.end??0)}] #${String(s.from)}-#${String(s.to)} ${d.join(" ")}`)}return f}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/video-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {