@nodetool-ai/timeline 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (505) hide show
  1. package/README.md +55 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/animation/bakedAnimation.d.ts +84 -0
  4. package/dist/animation/bakedAnimation.d.ts.map +1 -0
  5. package/dist/animation/bakedAnimation.js +95 -0
  6. package/dist/animation/bakedAnimation.js.map +1 -0
  7. package/dist/animation/beat.d.ts +7 -0
  8. package/dist/animation/beat.d.ts.map +1 -0
  9. package/dist/animation/beat.js +36 -0
  10. package/dist/animation/beat.js.map +1 -0
  11. package/dist/animation/compile.d.ts +184 -0
  12. package/dist/animation/compile.d.ts.map +1 -0
  13. package/dist/animation/compile.js +312 -0
  14. package/dist/animation/compile.js.map +1 -0
  15. package/dist/animation/custom.d.ts +183 -0
  16. package/dist/animation/custom.d.ts.map +1 -0
  17. package/dist/animation/custom.js +583 -0
  18. package/dist/animation/custom.js.map +1 -0
  19. package/dist/animation/easing.d.ts +34 -0
  20. package/dist/animation/easing.d.ts.map +1 -0
  21. package/dist/animation/easing.js +332 -0
  22. package/dist/animation/easing.js.map +1 -0
  23. package/dist/animation/index.d.ts +20 -0
  24. package/dist/animation/index.d.ts.map +1 -0
  25. package/dist/animation/index.js +20 -0
  26. package/dist/animation/index.js.map +1 -0
  27. package/dist/animation/links.d.ts +33 -0
  28. package/dist/animation/links.d.ts.map +1 -0
  29. package/dist/animation/links.js +126 -0
  30. package/dist/animation/links.js.map +1 -0
  31. package/dist/animation/presets.d.ts +86 -0
  32. package/dist/animation/presets.d.ts.map +1 -0
  33. package/dist/animation/presets.js +642 -0
  34. package/dist/animation/presets.js.map +1 -0
  35. package/dist/animation/sample.d.ts +145 -0
  36. package/dist/animation/sample.d.ts.map +1 -0
  37. package/dist/animation/sample.js +390 -0
  38. package/dist/animation/sample.js.map +1 -0
  39. package/dist/animation/simplify.d.ts +70 -0
  40. package/dist/animation/simplify.d.ts.map +1 -0
  41. package/dist/animation/simplify.js +278 -0
  42. package/dist/animation/simplify.js.map +1 -0
  43. package/dist/animation/sourceCurves.d.ts +45 -0
  44. package/dist/animation/sourceCurves.d.ts.map +1 -0
  45. package/dist/animation/sourceCurves.js +168 -0
  46. package/dist/animation/sourceCurves.js.map +1 -0
  47. package/dist/animation/styleTracks.d.ts +23 -0
  48. package/dist/animation/styleTracks.d.ts.map +1 -0
  49. package/dist/animation/styleTracks.js +341 -0
  50. package/dist/animation/styleTracks.js.map +1 -0
  51. package/dist/animation/types.d.ts +269 -0
  52. package/dist/animation/types.d.ts.map +1 -0
  53. package/dist/animation/types.js +173 -0
  54. package/dist/animation/types.js.map +1 -0
  55. package/dist/animation/typewriter.d.ts +8 -0
  56. package/dist/animation/typewriter.d.ts.map +1 -0
  57. package/dist/animation/typewriter.js +32 -0
  58. package/dist/animation/typewriter.js.map +1 -0
  59. package/dist/audioFade.d.ts +73 -0
  60. package/dist/audioFade.d.ts.map +1 -0
  61. package/dist/audioFade.js +134 -0
  62. package/dist/audioFade.js.map +1 -0
  63. package/dist/authoredStyles.d.ts +61 -0
  64. package/dist/authoredStyles.d.ts.map +1 -0
  65. package/dist/authoredStyles.js +90 -0
  66. package/dist/authoredStyles.js.map +1 -0
  67. package/dist/authoring.d.ts +50 -0
  68. package/dist/authoring.d.ts.map +1 -0
  69. package/dist/authoring.js +207 -0
  70. package/dist/authoring.js.map +1 -0
  71. package/dist/beats.d.ts +103 -0
  72. package/dist/beats.d.ts.map +1 -0
  73. package/dist/beats.js +228 -0
  74. package/dist/beats.js.map +1 -0
  75. package/dist/clone.d.ts +32 -0
  76. package/dist/clone.d.ts.map +1 -0
  77. package/dist/clone.js +53 -0
  78. package/dist/clone.js.map +1 -0
  79. package/dist/composition.d.ts +87 -0
  80. package/dist/composition.d.ts.map +1 -0
  81. package/dist/composition.js +253 -0
  82. package/dist/composition.js.map +1 -0
  83. package/dist/crop.d.ts +48 -0
  84. package/dist/crop.d.ts.map +1 -0
  85. package/dist/crop.js +75 -0
  86. package/dist/crop.js.map +1 -0
  87. package/dist/defaults.d.ts +142 -0
  88. package/dist/defaults.d.ts.map +1 -0
  89. package/dist/defaults.js +335 -0
  90. package/dist/defaults.js.map +1 -0
  91. package/dist/dependencyHash.d.ts +14 -0
  92. package/dist/dependencyHash.d.ts.map +1 -0
  93. package/dist/dependencyHash.js +19 -0
  94. package/dist/dependencyHash.js.map +1 -0
  95. package/dist/dropResolve.d.ts +40 -0
  96. package/dist/dropResolve.d.ts.map +1 -0
  97. package/dist/dropResolve.js +137 -0
  98. package/dist/dropResolve.js.map +1 -0
  99. package/dist/examples/node.d.ts +11 -0
  100. package/dist/examples/node.d.ts.map +1 -0
  101. package/dist/examples/node.js +87 -0
  102. package/dist/examples/node.js.map +1 -0
  103. package/dist/extension.d.ts +52 -0
  104. package/dist/extension.d.ts.map +1 -0
  105. package/dist/extension.js +269 -0
  106. package/dist/extension.js.map +1 -0
  107. package/dist/extensionRequest.d.ts +40 -0
  108. package/dist/extensionRequest.d.ts.map +1 -0
  109. package/dist/extensionRequest.js +135 -0
  110. package/dist/extensionRequest.js.map +1 -0
  111. package/dist/fill-text.d.ts +30 -0
  112. package/dist/fill-text.d.ts.map +1 -0
  113. package/dist/fill-text.js +73 -0
  114. package/dist/fill-text.js.map +1 -0
  115. package/dist/fonts/catalog.d.ts +97 -0
  116. package/dist/fonts/catalog.d.ts.map +1 -0
  117. package/dist/fonts/catalog.js +276 -0
  118. package/dist/fonts/catalog.js.map +1 -0
  119. package/dist/fonts/css.d.ts +24 -0
  120. package/dist/fonts/css.d.ts.map +1 -0
  121. package/dist/fonts/css.js +50 -0
  122. package/dist/fonts/css.js.map +1 -0
  123. package/dist/fonts/index.d.ts +10 -0
  124. package/dist/fonts/index.d.ts.map +1 -0
  125. package/dist/fonts/index.js +10 -0
  126. package/dist/fonts/index.js.map +1 -0
  127. package/dist/fonts/register-node.d.ts +45 -0
  128. package/dist/fonts/register-node.d.ts.map +1 -0
  129. package/dist/fonts/register-node.js +71 -0
  130. package/dist/fonts/register-node.js.map +1 -0
  131. package/dist/generatedMatte.d.ts +86 -0
  132. package/dist/generatedMatte.d.ts.map +1 -0
  133. package/dist/generatedMatte.js +152 -0
  134. package/dist/generatedMatte.js.map +1 -0
  135. package/dist/generative.d.ts +145 -0
  136. package/dist/generative.d.ts.map +1 -0
  137. package/dist/generative.js +396 -0
  138. package/dist/generative.js.map +1 -0
  139. package/dist/group.d.ts +47 -0
  140. package/dist/group.d.ts.map +1 -0
  141. package/dist/group.js +131 -0
  142. package/dist/group.js.map +1 -0
  143. package/dist/index.d.ts +55 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +58 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/interchange.d.ts +47 -0
  148. package/dist/interchange.d.ts.map +1 -0
  149. package/dist/interchange.js +158 -0
  150. package/dist/interchange.js.map +1 -0
  151. package/dist/keyframes.d.ts +44 -0
  152. package/dist/keyframes.d.ts.map +1 -0
  153. package/dist/keyframes.js +148 -0
  154. package/dist/keyframes.js.map +1 -0
  155. package/dist/lineDelivery.d.ts +108 -0
  156. package/dist/lineDelivery.d.ts.map +1 -0
  157. package/dist/lineDelivery.js +154 -0
  158. package/dist/lineDelivery.js.map +1 -0
  159. package/dist/linked.d.ts +41 -0
  160. package/dist/linked.d.ts.map +1 -0
  161. package/dist/linked.js +166 -0
  162. package/dist/linked.js.map +1 -0
  163. package/dist/lipSyncRequest.d.ts +65 -0
  164. package/dist/lipSyncRequest.d.ts.map +1 -0
  165. package/dist/lipSyncRequest.js +73 -0
  166. package/dist/lipSyncRequest.js.map +1 -0
  167. package/dist/measureClipDurations.d.ts +7 -0
  168. package/dist/measureClipDurations.d.ts.map +1 -0
  169. package/dist/measureClipDurations.js +17 -0
  170. package/dist/measureClipDurations.js.map +1 -0
  171. package/dist/mediaTrack.d.ts +120 -0
  172. package/dist/mediaTrack.d.ts.map +1 -0
  173. package/dist/mediaTrack.js +269 -0
  174. package/dist/mediaTrack.js.map +1 -0
  175. package/dist/midi/cacheKey.d.ts +25 -0
  176. package/dist/midi/cacheKey.d.ts.map +1 -0
  177. package/dist/midi/cacheKey.js +54 -0
  178. package/dist/midi/cacheKey.js.map +1 -0
  179. package/dist/midi/edit.d.ts +48 -0
  180. package/dist/midi/edit.d.ts.map +1 -0
  181. package/dist/midi/edit.js +93 -0
  182. package/dist/midi/edit.js.map +1 -0
  183. package/dist/midi/engines/bl1.d.ts +29 -0
  184. package/dist/midi/engines/bl1.d.ts.map +1 -0
  185. package/dist/midi/engines/bl1.js +128 -0
  186. package/dist/midi/engines/bl1.js.map +1 -0
  187. package/dist/midi/engines/dr1.d.ts +28 -0
  188. package/dist/midi/engines/dr1.d.ts.map +1 -0
  189. package/dist/midi/engines/dr1.js +101 -0
  190. package/dist/midi/engines/dr1.js.map +1 -0
  191. package/dist/midi/engines/dsp.d.ts +126 -0
  192. package/dist/midi/engines/dsp.d.ts.map +1 -0
  193. package/dist/midi/engines/dsp.js +371 -0
  194. package/dist/midi/engines/dsp.js.map +1 -0
  195. package/dist/midi/engines/index.d.ts +13 -0
  196. package/dist/midi/engines/index.d.ts.map +1 -0
  197. package/dist/midi/engines/index.js +13 -0
  198. package/dist/midi/engines/index.js.map +1 -0
  199. package/dist/midi/engines/kits.d.ts +12 -0
  200. package/dist/midi/engines/kits.d.ts.map +1 -0
  201. package/dist/midi/engines/kits.js +121 -0
  202. package/dist/midi/engines/kits.js.map +1 -0
  203. package/dist/midi/engines/wavetables.d.ts +45 -0
  204. package/dist/midi/engines/wavetables.d.ts.map +1 -0
  205. package/dist/midi/engines/wavetables.js +334 -0
  206. package/dist/midi/engines/wavetables.js.map +1 -0
  207. package/dist/midi/engines/wt1.d.ts +30 -0
  208. package/dist/midi/engines/wt1.d.ts.map +1 -0
  209. package/dist/midi/engines/wt1.js +91 -0
  210. package/dist/midi/engines/wt1.js.map +1 -0
  211. package/dist/midi/grid.d.ts +51 -0
  212. package/dist/midi/grid.d.ts.map +1 -0
  213. package/dist/midi/grid.js +104 -0
  214. package/dist/midi/grid.js.map +1 -0
  215. package/dist/midi/index.d.ts +20 -0
  216. package/dist/midi/index.d.ts.map +1 -0
  217. package/dist/midi/index.js +20 -0
  218. package/dist/midi/index.js.map +1 -0
  219. package/dist/midi/instrument.d.ts +32 -0
  220. package/dist/midi/instrument.d.ts.map +1 -0
  221. package/dist/midi/instrument.js +73 -0
  222. package/dist/midi/instrument.js.map +1 -0
  223. package/dist/midi/notes.d.ts +46 -0
  224. package/dist/midi/notes.d.ts.map +1 -0
  225. package/dist/midi/notes.js +121 -0
  226. package/dist/midi/notes.js.map +1 -0
  227. package/dist/midi/notesEdit.d.ts +94 -0
  228. package/dist/midi/notesEdit.d.ts.map +1 -0
  229. package/dist/midi/notesEdit.js +159 -0
  230. package/dist/midi/notesEdit.js.map +1 -0
  231. package/dist/midi/presets.d.ts +29 -0
  232. package/dist/midi/presets.d.ts.map +1 -0
  233. package/dist/midi/presets.js +281 -0
  234. package/dist/midi/presets.js.map +1 -0
  235. package/dist/midi/tempo.d.ts +27 -0
  236. package/dist/midi/tempo.d.ts.map +1 -0
  237. package/dist/midi/tempo.js +57 -0
  238. package/dist/midi/tempo.js.map +1 -0
  239. package/dist/midi/ticks.d.ts +25 -0
  240. package/dist/midi/ticks.d.ts.map +1 -0
  241. package/dist/midi/ticks.js +35 -0
  242. package/dist/midi/ticks.js.map +1 -0
  243. package/dist/midi/voice.d.ts +148 -0
  244. package/dist/midi/voice.d.ts.map +1 -0
  245. package/dist/midi/voice.js +348 -0
  246. package/dist/midi/voice.js.map +1 -0
  247. package/dist/midi/wav.d.ts +14 -0
  248. package/dist/midi/wav.d.ts.map +1 -0
  249. package/dist/midi/wav.js +51 -0
  250. package/dist/midi/wav.js.map +1 -0
  251. package/dist/model3d.d.ts +41 -0
  252. package/dist/model3d.d.ts.map +1 -0
  253. package/dist/model3d.js +39 -0
  254. package/dist/model3d.js.map +1 -0
  255. package/dist/model3dBake.d.ts +80 -0
  256. package/dist/model3dBake.d.ts.map +1 -0
  257. package/dist/model3dBake.js +127 -0
  258. package/dist/model3dBake.js.map +1 -0
  259. package/dist/ops/apply.d.ts +32 -0
  260. package/dist/ops/apply.d.ts.map +1 -0
  261. package/dist/ops/apply.js +1595 -0
  262. package/dist/ops/apply.js.map +1 -0
  263. package/dist/ops/index.d.ts +13 -0
  264. package/dist/ops/index.d.ts.map +1 -0
  265. package/dist/ops/index.js +13 -0
  266. package/dist/ops/index.js.map +1 -0
  267. package/dist/ops/op.d.ts +407 -0
  268. package/dist/ops/op.d.ts.map +1 -0
  269. package/dist/ops/op.js +61 -0
  270. package/dist/ops/op.js.map +1 -0
  271. package/dist/ops/serialize.d.ts +77 -0
  272. package/dist/ops/serialize.d.ts.map +1 -0
  273. package/dist/ops/serialize.js +81 -0
  274. package/dist/ops/serialize.js.map +1 -0
  275. package/dist/ops/types.d.ts +150 -0
  276. package/dist/ops/types.d.ts.map +1 -0
  277. package/dist/ops/types.js +12 -0
  278. package/dist/ops/types.js.map +1 -0
  279. package/dist/pathSampling.d.ts +51 -0
  280. package/dist/pathSampling.d.ts.map +1 -0
  281. package/dist/pathSampling.js +111 -0
  282. package/dist/pathSampling.js.map +1 -0
  283. package/dist/placement/index.d.ts +2 -0
  284. package/dist/placement/index.d.ts.map +1 -0
  285. package/dist/placement/index.js +2 -0
  286. package/dist/placement/index.js.map +1 -0
  287. package/dist/placement/resolveTrackPlacement.d.ts +40 -0
  288. package/dist/placement/resolveTrackPlacement.d.ts.map +1 -0
  289. package/dist/placement/resolveTrackPlacement.js +71 -0
  290. package/dist/placement/resolveTrackPlacement.js.map +1 -0
  291. package/dist/production.d.ts +99 -0
  292. package/dist/production.d.ts.map +1 -0
  293. package/dist/production.js +328 -0
  294. package/dist/production.js.map +1 -0
  295. package/dist/reassemble.d.ts +68 -0
  296. package/dist/reassemble.d.ts.map +1 -0
  297. package/dist/reassemble.js +187 -0
  298. package/dist/reassemble.js.map +1 -0
  299. package/dist/recipe.d.ts +24 -0
  300. package/dist/recipe.d.ts.map +1 -0
  301. package/dist/recipe.js +89 -0
  302. package/dist/recipe.js.map +1 -0
  303. package/dist/recordedVoiceReplacement.d.ts +70 -0
  304. package/dist/recordedVoiceReplacement.d.ts.map +1 -0
  305. package/dist/recordedVoiceReplacement.js +82 -0
  306. package/dist/recordedVoiceReplacement.js.map +1 -0
  307. package/dist/reframe.d.ts +31 -0
  308. package/dist/reframe.d.ts.map +1 -0
  309. package/dist/reframe.js +227 -0
  310. package/dist/reframe.js.map +1 -0
  311. package/dist/render/canvas2d.d.ts +419 -0
  312. package/dist/render/canvas2d.d.ts.map +1 -0
  313. package/dist/render/canvas2d.js +1392 -0
  314. package/dist/render/canvas2d.js.map +1 -0
  315. package/dist/render/color.d.ts +26 -0
  316. package/dist/render/color.d.ts.map +1 -0
  317. package/dist/render/color.js +305 -0
  318. package/dist/render/color.js.map +1 -0
  319. package/dist/render/cpuLegacyEffects.d.ts +17 -0
  320. package/dist/render/cpuLegacyEffects.d.ts.map +1 -0
  321. package/dist/render/cpuLegacyEffects.js +347 -0
  322. package/dist/render/cpuLegacyEffects.js.map +1 -0
  323. package/dist/render/cpuVisualEffects.d.ts +13 -0
  324. package/dist/render/cpuVisualEffects.d.ts.map +1 -0
  325. package/dist/render/cpuVisualEffects.js +388 -0
  326. package/dist/render/cpuVisualEffects.js.map +1 -0
  327. package/dist/render/cubeLut.d.ts +12 -0
  328. package/dist/render/cubeLut.d.ts.map +1 -0
  329. package/dist/render/cubeLut.js +81 -0
  330. package/dist/render/cubeLut.js.map +1 -0
  331. package/dist/render/curveFitting.d.ts +28 -0
  332. package/dist/render/curveFitting.d.ts.map +1 -0
  333. package/dist/render/curveFitting.js +94 -0
  334. package/dist/render/curveFitting.js.map +1 -0
  335. package/dist/render/draw.d.ts +265 -0
  336. package/dist/render/draw.d.ts.map +1 -0
  337. package/dist/render/draw.js +929 -0
  338. package/dist/render/draw.js.map +1 -0
  339. package/dist/render/effects.d.ts +120 -0
  340. package/dist/render/effects.d.ts.map +1 -0
  341. package/dist/render/effects.js +804 -0
  342. package/dist/render/effects.js.map +1 -0
  343. package/dist/render/frameCompositor.d.ts +502 -0
  344. package/dist/render/frameCompositor.d.ts.map +1 -0
  345. package/dist/render/frameCompositor.js +1331 -0
  346. package/dist/render/frameCompositor.js.map +1 -0
  347. package/dist/render/index.d.ts +27 -0
  348. package/dist/render/index.d.ts.map +1 -0
  349. package/dist/render/index.js +27 -0
  350. package/dist/render/index.js.map +1 -0
  351. package/dist/render/layout.d.ts +17 -0
  352. package/dist/render/layout.d.ts.map +1 -0
  353. package/dist/render/layout.js +197 -0
  354. package/dist/render/layout.js.map +1 -0
  355. package/dist/render/model3dBakeSamples.d.ts +45 -0
  356. package/dist/render/model3dBakeSamples.d.ts.map +1 -0
  357. package/dist/render/model3dBakeSamples.js +68 -0
  358. package/dist/render/model3dBakeSamples.js.map +1 -0
  359. package/dist/render/motionBlur.d.ts +170 -0
  360. package/dist/render/motionBlur.d.ts.map +1 -0
  361. package/dist/render/motionBlur.js +193 -0
  362. package/dist/render/motionBlur.js.map +1 -0
  363. package/dist/render/sceneModel.d.ts +577 -0
  364. package/dist/render/sceneModel.d.ts.map +1 -0
  365. package/dist/render/sceneModel.js +1460 -0
  366. package/dist/render/sceneModel.js.map +1 -0
  367. package/dist/render/shapeGeometry.d.ts +81 -0
  368. package/dist/render/shapeGeometry.d.ts.map +1 -0
  369. package/dist/render/shapeGeometry.js +460 -0
  370. package/dist/render/shapeGeometry.js.map +1 -0
  371. package/dist/render/spatial.d.ts +9 -0
  372. package/dist/render/spatial.d.ts.map +1 -0
  373. package/dist/render/spatial.js +58 -0
  374. package/dist/render/spatial.js.map +1 -0
  375. package/dist/render/svgPath.d.ts +80 -0
  376. package/dist/render/svgPath.d.ts.map +1 -0
  377. package/dist/render/svgPath.js +199 -0
  378. package/dist/render/svgPath.js.map +1 -0
  379. package/dist/render/temporal.d.ts +6 -0
  380. package/dist/render/temporal.d.ts.map +1 -0
  381. package/dist/render/temporal.js +74 -0
  382. package/dist/render/temporal.js.map +1 -0
  383. package/dist/render/textLayout.d.ts +159 -0
  384. package/dist/render/textLayout.d.ts.map +1 -0
  385. package/dist/render/textLayout.js +301 -0
  386. package/dist/render/textLayout.js.map +1 -0
  387. package/dist/render/trackEffects.d.ts +23 -0
  388. package/dist/render/trackEffects.d.ts.map +1 -0
  389. package/dist/render/trackEffects.js +93 -0
  390. package/dist/render/trackEffects.js.map +1 -0
  391. package/dist/render/transform.d.ts +54 -0
  392. package/dist/render/transform.d.ts.map +1 -0
  393. package/dist/render/transform.js +222 -0
  394. package/dist/render/transform.js.map +1 -0
  395. package/dist/render/transition.d.ts +109 -0
  396. package/dist/render/transition.d.ts.map +1 -0
  397. package/dist/render/transition.js +351 -0
  398. package/dist/render/transition.js.map +1 -0
  399. package/dist/retarget.d.ts +73 -0
  400. package/dist/retarget.d.ts.map +1 -0
  401. package/dist/retarget.js +305 -0
  402. package/dist/retarget.js.map +1 -0
  403. package/dist/rippleEdit.d.ts +83 -0
  404. package/dist/rippleEdit.d.ts.map +1 -0
  405. package/dist/rippleEdit.js +184 -0
  406. package/dist/rippleEdit.js.map +1 -0
  407. package/dist/scene.d.ts +28 -0
  408. package/dist/scene.d.ts.map +1 -0
  409. package/dist/scene.js +28 -0
  410. package/dist/scene.js.map +1 -0
  411. package/dist/script-link.d.ts +52 -0
  412. package/dist/script-link.d.ts.map +1 -0
  413. package/dist/script-link.js +78 -0
  414. package/dist/script-link.js.map +1 -0
  415. package/dist/script.d.ts +52 -0
  416. package/dist/script.d.ts.map +1 -0
  417. package/dist/script.js +93 -0
  418. package/dist/script.js.map +1 -0
  419. package/dist/snap.d.ts +2 -0
  420. package/dist/snap.d.ts.map +1 -0
  421. package/dist/snap.js +21 -0
  422. package/dist/snap.js.map +1 -0
  423. package/dist/snapping/buildSnapPoints.d.ts +16 -0
  424. package/dist/snapping/buildSnapPoints.d.ts.map +1 -0
  425. package/dist/snapping/buildSnapPoints.js +39 -0
  426. package/dist/snapping/buildSnapPoints.js.map +1 -0
  427. package/dist/snapping/index.d.ts +3 -0
  428. package/dist/snapping/index.d.ts.map +1 -0
  429. package/dist/snapping/index.js +3 -0
  430. package/dist/snapping/index.js.map +1 -0
  431. package/dist/snapping/resolveSnap.d.ts +19 -0
  432. package/dist/snapping/resolveSnap.d.ts.map +1 -0
  433. package/dist/snapping/resolveSnap.js +39 -0
  434. package/dist/snapping/resolveSnap.js.map +1 -0
  435. package/dist/sourceRate.d.ts +12 -0
  436. package/dist/sourceRate.d.ts.map +1 -0
  437. package/dist/sourceRate.js +13 -0
  438. package/dist/sourceRate.js.map +1 -0
  439. package/dist/spatialVideoRequest.d.ts +91 -0
  440. package/dist/spatialVideoRequest.d.ts.map +1 -0
  441. package/dist/spatialVideoRequest.js +175 -0
  442. package/dist/spatialVideoRequest.js.map +1 -0
  443. package/dist/splitClip.d.ts +3 -0
  444. package/dist/splitClip.d.ts.map +1 -0
  445. package/dist/splitClip.js +190 -0
  446. package/dist/splitClip.js.map +1 -0
  447. package/dist/stableSerialize.d.ts +11 -0
  448. package/dist/stableSerialize.d.ts.map +1 -0
  449. package/dist/stableSerialize.js +31 -0
  450. package/dist/stableSerialize.js.map +1 -0
  451. package/dist/staleSet.d.ts +41 -0
  452. package/dist/staleSet.d.ts.map +1 -0
  453. package/dist/staleSet.js +106 -0
  454. package/dist/staleSet.js.map +1 -0
  455. package/dist/storyboard.d.ts +221 -0
  456. package/dist/storyboard.d.ts.map +1 -0
  457. package/dist/storyboard.js +417 -0
  458. package/dist/storyboard.js.map +1 -0
  459. package/dist/subtitles.d.ts +61 -0
  460. package/dist/subtitles.d.ts.map +1 -0
  461. package/dist/subtitles.js +92 -0
  462. package/dist/subtitles.js.map +1 -0
  463. package/dist/takes.d.ts +76 -0
  464. package/dist/takes.d.ts.map +1 -0
  465. package/dist/takes.js +238 -0
  466. package/dist/takes.js.map +1 -0
  467. package/dist/timeRemap.d.ts +101 -0
  468. package/dist/timeRemap.d.ts.map +1 -0
  469. package/dist/timeRemap.js +183 -0
  470. package/dist/timeRemap.js.map +1 -0
  471. package/dist/trackOrder.d.ts +38 -0
  472. package/dist/trackOrder.d.ts.map +1 -0
  473. package/dist/trackOrder.js +54 -0
  474. package/dist/trackOrder.js.map +1 -0
  475. package/dist/transitionAtCut.d.ts +89 -0
  476. package/dist/transitionAtCut.d.ts.map +1 -0
  477. package/dist/transitionAtCut.js +217 -0
  478. package/dist/transitionAtCut.js.map +1 -0
  479. package/dist/trimClip.d.ts +13 -0
  480. package/dist/trimClip.d.ts.map +1 -0
  481. package/dist/trimClip.js +60 -0
  482. package/dist/trimClip.js.map +1 -0
  483. package/dist/types.d.ts +1772 -0
  484. package/dist/types.d.ts.map +1 -0
  485. package/dist/types.js +84 -0
  486. package/dist/types.js.map +1 -0
  487. package/fonts/BebasNeue-Regular.ttf +0 -0
  488. package/fonts/Inter-ExtraBold.ttf +0 -0
  489. package/fonts/Inter-Italic-Variable.ttf +0 -0
  490. package/fonts/Inter-SemiBold.ttf +0 -0
  491. package/fonts/Inter-Variable.ttf +0 -0
  492. package/fonts/JetBrainsMono-Italic-Variable.ttf +0 -0
  493. package/fonts/JetBrainsMono-Variable.ttf +0 -0
  494. package/fonts/Lora-Italic-Variable.ttf +0 -0
  495. package/fonts/Lora-Variable.ttf +0 -0
  496. package/fonts/OFL-BebasNeue.txt +93 -0
  497. package/fonts/OFL-Inter.txt +93 -0
  498. package/fonts/OFL-JetBrainsMono.txt +93 -0
  499. package/fonts/OFL-Lora.txt +93 -0
  500. package/fonts/OFL-PlayfairDisplay.txt +93 -0
  501. package/fonts/OFL-SpaceGrotesk.txt +93 -0
  502. package/fonts/PlayfairDisplay-Italic-Variable.ttf +0 -0
  503. package/fonts/PlayfairDisplay-Variable.ttf +0 -0
  504. package/fonts/SpaceGrotesk-Variable.ttf +0 -0
  505. package/package.json +108 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * textLayout — the wrap, the grapheme split and the stagger-unit enumeration
3
+ * shared by the text rasterizer and the stagger compiler.
4
+ *
5
+ * The compiler times a stagger against a unit COUNT and the rasterizer walks a
6
+ * unit LIST. If the two disagree, the last units of a title animate at the
7
+ * wrong moment or never at all, so both come from this module.
8
+ *
9
+ * Word and character counts are independent of where the lines break — a wrap
10
+ * regroups words but never adds or removes one, and a break consumes exactly
11
+ * the separator a space would have occupied — so those two are counted with no
12
+ * measurement at all. Line counts are not: they need the same measured wrap the
13
+ * draw uses, which is what {@link MeasureTextWidth} carries into the count.
14
+ *
15
+ * Pure: written against a width function, never a canvas context.
16
+ */
17
+ import type { ClipTextStyle } from "../types.js";
18
+ import type { StaggerUnit } from "../animation/types.js";
19
+ /**
20
+ * Advance width of `text` set in `font` (a CSS `font` shorthand). The host
21
+ * supplies one backed by the same 2D context kind its rasterizer draws
22
+ * through, so the count wraps exactly where the draw does.
23
+ */
24
+ export type MeasureTextWidth = (text: string, font: string) => number;
25
+ /**
26
+ * The canvas the scene model resolves a frame against: the sequence's pixel
27
+ * size, plus an optional measurer. Without one, `"line"` staggers fall back to
28
+ * counting explicit line breaks — a soft-wrapped title then reports fewer
29
+ * units than the rasterizer draws, and the extra lines animate with the last
30
+ * counted one (see {@link layoutStaggerUnits}).
31
+ */
32
+ export interface RenderCanvas {
33
+ width: number;
34
+ height: number;
35
+ measureText?: MeasureTextWidth;
36
+ }
37
+ /**
38
+ * What the `font` shorthand is built from. Narrower than `ClipTextStyle` so a
39
+ * caption, which carries no text of its own, resolves its font through the
40
+ * same builder — which is also the one place family resolution happens (D8).
41
+ */
42
+ export interface FontSpecStyle {
43
+ fontFamily?: string;
44
+ fontSizePx: number;
45
+ fontWeight?: number;
46
+ fontStyle?: string;
47
+ }
48
+ /**
49
+ * The `ctx.font` shorthand a text style renders with.
50
+ *
51
+ * The family list comes from {@link resolveFontFamily}, so every host — the
52
+ * editor preview, the browser export, the server render and the agent's frame
53
+ * preview — sets the same string on its context and a bundled family resolves
54
+ * to the face NodeTool ships rather than to whatever the machine has.
55
+ */
56
+ export declare function textFontSpec(style: FontSpecStyle): string;
57
+ /** Line advance in px: the `lineHeight` multiple of the font size, default 1.2. */
58
+ export declare function textLineHeightPx(style: ClipTextStyle): number;
59
+ /** Extra advance after each grapheme, in canvas px. */
60
+ export declare function textLetterSpacingPx(style: ClipTextStyle): number;
61
+ /** The px the text wraps within, from `maxWidthFrac` of the canvas. */
62
+ export declare function textMaxWidthPx(style: ClipTextStyle, canvasWidth: number): number;
63
+ export interface WrappedLine {
64
+ text: string;
65
+ words: string[];
66
+ }
67
+ /**
68
+ * Greedy word-wrap by measured candidate width — the one wrap rule for every
69
+ * draw and count path, so a staggered title breaks lines exactly like its
70
+ * un-staggered self.
71
+ */
72
+ export declare function wrapTextLines(text: string, maxWidth: number, measure: (text: string) => number): WrappedLine[];
73
+ /**
74
+ * Split `text` into grapheme clusters. On a runtime with no `Intl.Segmenter`
75
+ * this falls back to code points, which splits a ZWJ sequence into its parts —
76
+ * the count is then higher than the glyphs drawn, which is a timing artifact
77
+ * rather than a broken frame, because the count and the draw both fall back.
78
+ */
79
+ export declare function segmentGraphemes(text: string): string[];
80
+ /**
81
+ * How many units `unit` splits a text style into — the number the compiler
82
+ * times the stagger span against.
83
+ *
84
+ * `"character"` counts one unit per grapheme of every word plus one per gap
85
+ * between words, whether that gap is drawn as a space or eaten by a line
86
+ * break. That is what makes the count wrap-independent while still matching
87
+ * the draw: whitespace is timed and draws nothing.
88
+ */
89
+ export declare function countTextStaggerUnits(style: ClipTextStyle, canvas: RenderCanvas, unit: StaggerUnit): number;
90
+ /** One wrapped line placed on the raster, in canvas px. */
91
+ export interface LaidOutTextLine {
92
+ text: string;
93
+ words: string[];
94
+ /** Advance width of each word, letter spacing included. */
95
+ wordWidths: number[];
96
+ /** Left edge. */
97
+ x: number;
98
+ width: number;
99
+ /** Vertical center of the line box (textBaseline "middle"). */
100
+ y: number;
101
+ }
102
+ /** A box on the raster, in canvas px. */
103
+ export interface TextBlockBox {
104
+ x: number;
105
+ y: number;
106
+ width: number;
107
+ height: number;
108
+ }
109
+ /** Everything a draw needs about a wrapped text block. */
110
+ export interface TextBlockLayout {
111
+ lines: LaidOutTextLine[];
112
+ lineHeight: number;
113
+ /** Advance of one space, letter spacing included. */
114
+ spaceWidth: number;
115
+ letterSpacingPx: number;
116
+ /**
117
+ * The union of the line boxes: what a background scrim sits behind and what
118
+ * a gradient fill is measured against — the text, not the raster.
119
+ */
120
+ box: TextBlockBox;
121
+ }
122
+ /**
123
+ * Wrap `style.text` and place every line on the raster. The one layout the
124
+ * plain draw, the staggered draw and the background scrim all read, so a
125
+ * staggered title breaks and sits exactly where its un-staggered self does.
126
+ *
127
+ * `measure` reports unspaced advances; `letterSpacingPx` is charged here, so a
128
+ * host measuring through a context that applies spacing of its own must ask it
129
+ * with spacing off.
130
+ */
131
+ export declare function layoutTextBlock(measure: (text: string) => number, style: ClipTextStyle, width: number, height: number): TextBlockLayout;
132
+ /**
133
+ * One unit of a staggered text draw, in the raster's own pixel space.
134
+ * `text` is empty for a whitespace unit: it takes an index (so the units after
135
+ * it are timed correctly) and draws nothing.
136
+ */
137
+ export interface TextStaggerUnit {
138
+ text: string;
139
+ /** Left edge in canvas px. */
140
+ x: number;
141
+ /** Advance width in canvas px. */
142
+ width: number;
143
+ /** Vertical center of the unit's line (textBaseline "middle"). */
144
+ y: number;
145
+ /** Line box height in canvas px — the unit's vertical extent. */
146
+ height: number;
147
+ }
148
+ /**
149
+ * Lay `style.text` out into the units `unit` names, in the order the stagger
150
+ * times them. The list length equals {@link countTextStaggerUnits} for the
151
+ * same style, canvas and unit whenever both see the same measurer.
152
+ *
153
+ * Character units are positioned from cumulative `measureText` prefixes rather
154
+ * than per-glyph widths, so a glyph sits where the shaped word would have put
155
+ * it. Drawing them one at a time still drops kerning between the pair, the
156
+ * same trade the per-word draw already makes.
157
+ */
158
+ export declare function layoutStaggerUnits(measure: (text: string) => number, style: ClipTextStyle, width: number, height: number, unit: StaggerUnit): TextStaggerUnit[];
159
+ //# sourceMappingURL=textLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textLayout.d.ts","sourceRoot":"","sources":["../../src/render/textLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAUD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAOzD;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAI7D;AAED,uDAAuD;AACvD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAGhE;AAeD,uEAAuE;AACvE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,QA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AM,CAAC;IACb,8BAA8B;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,CAAC,EAAE,MAAM,CAAC;IACV,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACjC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,GAChB,eAAe,EAAE,CA+DnB"}
@@ -0,0 +1,301 @@
1
+ /**
2
+ * textLayout — the wrap, the grapheme split and the stagger-unit enumeration
3
+ * shared by the text rasterizer and the stagger compiler.
4
+ *
5
+ * The compiler times a stagger against a unit COUNT and the rasterizer walks a
6
+ * unit LIST. If the two disagree, the last units of a title animate at the
7
+ * wrong moment or never at all, so both come from this module.
8
+ *
9
+ * Word and character counts are independent of where the lines break — a wrap
10
+ * regroups words but never adds or removes one, and a break consumes exactly
11
+ * the separator a space would have occupied — so those two are counted with no
12
+ * measurement at all. Line counts are not: they need the same measured wrap the
13
+ * draw uses, which is what {@link MeasureTextWidth} carries into the count.
14
+ *
15
+ * Pure: written against a width function, never a canvas context.
16
+ */
17
+ import { resolveFontFamily } from "../fonts/catalog.js";
18
+ import { countStaggerUnits } from "../animation/compile.js";
19
+ import { countTypewriterUnits } from "../animation/typewriter.js";
20
+ /**
21
+ * The slants the `font` shorthand accepts. An unknown `fontStyle` is dropped
22
+ * rather than emitted: the shorthand is parsed as a whole, so one unreadable
23
+ * token would make a context ignore the assignment and keep whatever font it
24
+ * last had — a wrong picture instead of an unstyled one (I2).
25
+ */
26
+ const FONT_SLANTS = new Set(["italic", "oblique"]);
27
+ /**
28
+ * The `ctx.font` shorthand a text style renders with.
29
+ *
30
+ * The family list comes from {@link resolveFontFamily}, so every host — the
31
+ * editor preview, the browser export, the server render and the agent's frame
32
+ * preview — sets the same string on its context and a bundled family resolves
33
+ * to the face NodeTool ships rather than to whatever the machine has.
34
+ */
35
+ export function textFontSpec(style) {
36
+ const fontSize = Math.max(1, style.fontSizePx);
37
+ const { family } = resolveFontFamily(style.fontFamily);
38
+ const slant = FONT_SLANTS.has(style.fontStyle ?? "")
39
+ ? `${style.fontStyle} `
40
+ : "";
41
+ return `${slant}${style.fontWeight ?? 400} ${fontSize}px ${family}`;
42
+ }
43
+ /** Line advance in px: the `lineHeight` multiple of the font size, default 1.2. */
44
+ export function textLineHeightPx(style) {
45
+ const fontSize = Math.max(1, style.fontSizePx);
46
+ const multiple = style.lineHeight;
47
+ return fontSize * (multiple !== undefined && multiple > 0 ? multiple : 1.2);
48
+ }
49
+ /** Extra advance after each grapheme, in canvas px. */
50
+ export function textLetterSpacingPx(style) {
51
+ const spacing = style.letterSpacingPx ?? 0;
52
+ return Number.isFinite(spacing) ? spacing : 0;
53
+ }
54
+ /**
55
+ * A width function that charges `spacingPx` for every grapheme, the way a
56
+ * canvas with `letterSpacing` set reports its own advances — trailing space
57
+ * included, so a spaced line is as wide as it draws.
58
+ */
59
+ function spacedMeasure(measure, spacingPx) {
60
+ if (spacingPx === 0)
61
+ return measure;
62
+ return (text) => measure(text) + spacingPx * segmentGraphemes(text).length;
63
+ }
64
+ /** The px the text wraps within, from `maxWidthFrac` of the canvas. */
65
+ export function textMaxWidthPx(style, canvasWidth) {
66
+ return canvasWidth * Math.min(1, Math.max(0.05, style.maxWidthFrac ?? 0.8));
67
+ }
68
+ /**
69
+ * Greedy word-wrap by measured candidate width — the one wrap rule for every
70
+ * draw and count path, so a staggered title breaks lines exactly like its
71
+ * un-staggered self.
72
+ */
73
+ export function wrapTextLines(text, maxWidth, measure) {
74
+ const lines = [];
75
+ for (const paragraph of text.split(/\r?\n/)) {
76
+ const words = paragraph.split(/\s+/).filter(Boolean);
77
+ let line = "";
78
+ let lineWords = [];
79
+ for (const word of words) {
80
+ const candidate = line ? `${line} ${word}` : word;
81
+ if (line && measure(candidate) > maxWidth) {
82
+ lines.push({ text: line, words: lineWords });
83
+ line = word;
84
+ lineWords = [word];
85
+ }
86
+ else {
87
+ line = candidate;
88
+ lineWords.push(word);
89
+ }
90
+ }
91
+ lines.push({ text: line, words: lineWords });
92
+ }
93
+ return lines;
94
+ }
95
+ /**
96
+ * `Intl.Segmenter` is the only correct grapheme splitter — an emoji built from
97
+ * several code points (a ZWJ family, a flag) is one cluster, as is a letter
98
+ * followed by combining marks. Resolved once: constructing a segmenter is not
99
+ * cheap and the rasterizer runs per frame.
100
+ */
101
+ const graphemeSegmenter = typeof Intl !== "undefined" && typeof Intl.Segmenter === "function"
102
+ ? new Intl.Segmenter(undefined, { granularity: "grapheme" })
103
+ : null;
104
+ /**
105
+ * Split `text` into grapheme clusters. On a runtime with no `Intl.Segmenter`
106
+ * this falls back to code points, which splits a ZWJ sequence into its parts —
107
+ * the count is then higher than the glyphs drawn, which is a timing artifact
108
+ * rather than a broken frame, because the count and the draw both fall back.
109
+ */
110
+ export function segmentGraphemes(text) {
111
+ if (graphemeSegmenter) {
112
+ const out = [];
113
+ for (const { segment } of graphemeSegmenter.segment(text))
114
+ out.push(segment);
115
+ return out;
116
+ }
117
+ return Array.from(text);
118
+ }
119
+ /**
120
+ * How many units `unit` splits a text style into — the number the compiler
121
+ * times the stagger span against.
122
+ *
123
+ * `"character"` counts one unit per grapheme of every word plus one per gap
124
+ * between words, whether that gap is drawn as a space or eaten by a line
125
+ * break. That is what makes the count wrap-independent while still matching
126
+ * the draw: whitespace is timed and draws nothing.
127
+ */
128
+ export function countTextStaggerUnits(style, canvas, unit) {
129
+ const text = style.text;
130
+ if (unit === "word")
131
+ return countStaggerUnits(text);
132
+ if (unit === "character")
133
+ return countTypewriterUnits(text);
134
+ return wrapTextLines(text, textMaxWidthPx(style, canvas.width), measurerFor(style, canvas)).length;
135
+ }
136
+ /**
137
+ * A width function for `style`, or one that reports zero when the canvas
138
+ * carries no measurer — under which nothing ever exceeds the wrap width, so
139
+ * `wrapTextLines` returns one line per authored paragraph. Letter spacing is
140
+ * charged only on the measuring branch: adding it to the zero fallback would
141
+ * wrap a title the rasterizer could not measure.
142
+ */
143
+ function measurerFor(style, canvas) {
144
+ const measure = canvas.measureText;
145
+ if (!measure)
146
+ return () => 0;
147
+ const font = textFontSpec(style);
148
+ return spacedMeasure((text) => measure(text, font), textLetterSpacingPx(style));
149
+ }
150
+ /**
151
+ * Vertical center of the first line. `verticalAlign` moves the whole block
152
+ * within the raster, which covers the frame, so `"top"` sits the first line
153
+ * against the top edge and `"bottom"` the last against the bottom. An unknown
154
+ * value reads as `"middle"` (I2).
155
+ */
156
+ function firstLineCenterY(style, lineCount, height, lineHeight) {
157
+ const align = style.verticalAlign ?? "middle";
158
+ const block = lineCount * lineHeight;
159
+ if (align === "top")
160
+ return lineHeight / 2;
161
+ if (align === "bottom")
162
+ return height - block + lineHeight / 2;
163
+ return height / 2 - block / 2 + lineHeight / 2;
164
+ }
165
+ /**
166
+ * Wrap `style.text` and place every line on the raster. The one layout the
167
+ * plain draw, the staggered draw and the background scrim all read, so a
168
+ * staggered title breaks and sits exactly where its un-staggered self does.
169
+ *
170
+ * `measure` reports unspaced advances; `letterSpacingPx` is charged here, so a
171
+ * host measuring through a context that applies spacing of its own must ask it
172
+ * with spacing off.
173
+ */
174
+ export function layoutTextBlock(measure, style, width, height) {
175
+ const letterSpacingPx = textLetterSpacingPx(style);
176
+ const advance = spacedMeasure(measure, letterSpacingPx);
177
+ const align = style.align ?? "center";
178
+ const maxWidth = textMaxWidthPx(style, width);
179
+ const wrapped = wrapTextLines(style.text, maxWidth, advance);
180
+ const spaceWidth = advance(" ");
181
+ const lineHeight = textLineHeightPx(style);
182
+ const firstY = firstLineCenterY(style, wrapped.length, height, lineHeight);
183
+ const lines = wrapped.map((line, index) => {
184
+ const wordWidths = line.words.map((word) => advance(word));
185
+ const lineWidth = wordWidths.reduce((sum, w) => sum + w, 0) +
186
+ spaceWidth * Math.max(0, line.words.length - 1);
187
+ const x = align === "left"
188
+ ? (width - maxWidth) / 2
189
+ : align === "right"
190
+ ? (width + maxWidth) / 2 - lineWidth
191
+ : (width - lineWidth) / 2;
192
+ return {
193
+ text: line.text,
194
+ words: line.words,
195
+ wordWidths,
196
+ x,
197
+ width: lineWidth,
198
+ y: firstY + index * lineHeight
199
+ };
200
+ });
201
+ let left = Number.POSITIVE_INFINITY;
202
+ let right = Number.NEGATIVE_INFINITY;
203
+ for (const line of lines) {
204
+ if (line.width <= 0)
205
+ continue;
206
+ left = Math.min(left, line.x);
207
+ right = Math.max(right, line.x + line.width);
208
+ }
209
+ // An empty title has no ink, so its block collapses to a point rather than
210
+ // spanning the raster — a scrim behind nothing would otherwise be full-frame.
211
+ if (right <= left) {
212
+ left = width / 2;
213
+ right = width / 2;
214
+ }
215
+ return {
216
+ lines,
217
+ lineHeight,
218
+ spaceWidth,
219
+ letterSpacingPx,
220
+ box: {
221
+ x: left,
222
+ y: firstY - lineHeight / 2,
223
+ width: right - left,
224
+ height: lines.length * lineHeight
225
+ }
226
+ };
227
+ }
228
+ /**
229
+ * Lay `style.text` out into the units `unit` names, in the order the stagger
230
+ * times them. The list length equals {@link countTextStaggerUnits} for the
231
+ * same style, canvas and unit whenever both see the same measurer.
232
+ *
233
+ * Character units are positioned from cumulative `measureText` prefixes rather
234
+ * than per-glyph widths, so a glyph sits where the shaped word would have put
235
+ * it. Drawing them one at a time still drops kerning between the pair, the
236
+ * same trade the per-word draw already makes.
237
+ */
238
+ export function layoutStaggerUnits(measure, style, width, height, unit) {
239
+ const layout = layoutTextBlock(measure, style, width, height);
240
+ const { lineHeight, spaceWidth, letterSpacingPx } = layout;
241
+ const out = [];
242
+ for (const line of layout.lines) {
243
+ const y = line.y;
244
+ if (unit === "line") {
245
+ out.push({
246
+ text: line.text,
247
+ x: line.x,
248
+ width: line.width,
249
+ y,
250
+ height: lineHeight
251
+ });
252
+ continue;
253
+ }
254
+ // The break that starts this line ate the space that would have separated
255
+ // it from the previous one, so it takes that separator's index. Counting
256
+ // it here rather than at the end of the previous line is what keeps a
257
+ // blank line (an empty paragraph) from inventing a unit.
258
+ if (unit === "character" && line.words.length > 0 && out.length > 0) {
259
+ out.push({ text: "", x: line.x, width: 0, y, height: lineHeight });
260
+ }
261
+ let x = line.x;
262
+ line.words.forEach((word, wordIndex) => {
263
+ const wordWidth = line.wordWidths[wordIndex];
264
+ if (unit === "word") {
265
+ out.push({ text: word, x, width: wordWidth, y, height: lineHeight });
266
+ }
267
+ else {
268
+ let prefixWidth = 0;
269
+ let prefix = "";
270
+ let glyphs = 0;
271
+ for (const grapheme of segmentGraphemes(word)) {
272
+ prefix += grapheme;
273
+ glyphs += 1;
274
+ const nextWidth = measure(prefix) + letterSpacingPx * glyphs;
275
+ out.push({
276
+ text: grapheme,
277
+ x: x + prefixWidth,
278
+ width: nextWidth - prefixWidth,
279
+ y,
280
+ height: lineHeight
281
+ });
282
+ prefixWidth = nextWidth;
283
+ }
284
+ // The space between two words on one line is a unit too: timed, and
285
+ // drawn as nothing.
286
+ if (wordIndex < line.words.length - 1) {
287
+ out.push({
288
+ text: "",
289
+ x: x + wordWidth,
290
+ width: spaceWidth,
291
+ y,
292
+ height: lineHeight
293
+ });
294
+ }
295
+ }
296
+ x += wordWidth + spaceWidth;
297
+ });
298
+ }
299
+ return out;
300
+ }
301
+ //# sourceMappingURL=textLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textLayout.js","sourceRoot":"","sources":["../../src/render/textLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAuBlE;;;;;GAKG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,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MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC;oBAC7D,GAAG,CAAC,IAAI,CAAC;wBACP,IAAI,EAAE,QAAQ;wBACd,CAAC,EAAE,CAAC,GAAG,WAAW;wBAClB,KAAK,EAAE,SAAS,GAAG,WAAW;wBAC9B,CAAC;wBACD,MAAM,EAAE,UAAU;qBACnB,CAAC,CAAC;oBACH,WAAW,GAAG,SAAS,CAAC;gBAC1B,CAAC;gBACD,oEAAoE;gBACpE,oBAAoB;gBACpB,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtC,GAAG,CAAC,IAAI,CAAC;wBACP,IAAI,EAAE,EAAE;wBACR,CAAC,EAAE,CAAC,GAAG,SAAS;wBAChB,KAAK,EAAE,UAAU;wBACjB,CAAC;wBACD,MAAM,EAAE,UAAU;qBACnB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,CAAC,IAAI,SAAS,GAAG,UAAU,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ClipEffect, TrackEffect } from "../types.js";
2
+ /**
3
+ * A track's video effects in the clip vocabulary, so a renderer reads one
4
+ * effect chain rather than two.
5
+ *
6
+ * `TrackEffect`'s five video kinds and `ClipEffect` describe the same shader
7
+ * steps under different field names (`keyColor`/`color`,
8
+ * `intensity`/`amount`). Both spellings are on the wire — a saved document
9
+ * carries whichever scope it was authored in, and `packages/protocol`'s
10
+ * `trackEffect` union still pins the track one — so the conversion happens
11
+ * here, at the door of the renderer, and everything past it addresses effects
12
+ * one way.
13
+ *
14
+ * The audio kinds have no picture and drop out. `enabled` rides along
15
+ * untouched: callers that report an effect (`unsupportedEffectTypes`) and
16
+ * callers that apply one filter on it themselves.
17
+ *
18
+ * Results are memoized on the array identity a track holds until its effects
19
+ * are edited, which is the premise the Canvas 2D filter cache already runs on:
20
+ * a track sitting still converts once, not once per layer per frame.
21
+ */
22
+ export declare function trackEffectsAsClipEffects(effects: readonly TrackEffect[] | undefined): readonly ClipEffect[];
23
+ //# sourceMappingURL=trackEffects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackEffects.d.ts","sourceRoot":"","sources":["../../src/render/trackEffects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,UAAU,EAGV,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,GAC1C,SAAS,UAAU,EAAE,CAYvB"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A track's video effects in the clip vocabulary, so a renderer reads one
3
+ * effect chain rather than two.
4
+ *
5
+ * `TrackEffect`'s five video kinds and `ClipEffect` describe the same shader
6
+ * steps under different field names (`keyColor`/`color`,
7
+ * `intensity`/`amount`). Both spellings are on the wire — a saved document
8
+ * carries whichever scope it was authored in, and `packages/protocol`'s
9
+ * `trackEffect` union still pins the track one — so the conversion happens
10
+ * here, at the door of the renderer, and everything past it addresses effects
11
+ * one way.
12
+ *
13
+ * The audio kinds have no picture and drop out. `enabled` rides along
14
+ * untouched: callers that report an effect (`unsupportedEffectTypes`) and
15
+ * callers that apply one filter on it themselves.
16
+ *
17
+ * Results are memoized on the array identity a track holds until its effects
18
+ * are edited, which is the premise the Canvas 2D filter cache already runs on:
19
+ * a track sitting still converts once, not once per layer per frame.
20
+ */
21
+ export function trackEffectsAsClipEffects(effects) {
22
+ if (!effects || effects.length === 0)
23
+ return NONE;
24
+ const hit = cache.get(effects);
25
+ if (hit)
26
+ return hit;
27
+ const converted = [];
28
+ for (const effect of effects) {
29
+ const clip = asClipEffect(effect);
30
+ if (clip)
31
+ converted.push(clip);
32
+ }
33
+ const result = converted.length > 0 ? converted : NONE;
34
+ cache.set(effects, result);
35
+ return result;
36
+ }
37
+ const NONE = Object.freeze([]);
38
+ const cache = new WeakMap();
39
+ function asClipEffect(effect) {
40
+ switch (effect.type) {
41
+ case "colorCorrection":
42
+ return {
43
+ id: effect.id,
44
+ type: "color",
45
+ enabled: effect.enabled,
46
+ brightness: effect.brightness,
47
+ contrast: effect.contrast,
48
+ saturation: effect.saturation,
49
+ hue: effect.hue,
50
+ temperature: effect.temperature,
51
+ tint: effect.tint,
52
+ shadows: effect.shadows,
53
+ highlights: effect.highlights
54
+ };
55
+ case "videoBlur":
56
+ return {
57
+ id: effect.id,
58
+ type: "blur",
59
+ enabled: effect.enabled,
60
+ radius: effect.radius
61
+ };
62
+ case "sharpen":
63
+ return {
64
+ id: effect.id,
65
+ type: "sharpen",
66
+ enabled: effect.enabled,
67
+ amount: effect.amount,
68
+ threshold: effect.threshold
69
+ };
70
+ case "vignette":
71
+ return {
72
+ id: effect.id,
73
+ type: "vignette",
74
+ enabled: effect.enabled,
75
+ amount: effect.intensity,
76
+ radius: effect.radius,
77
+ softness: effect.softness
78
+ };
79
+ case "chromaKey":
80
+ return {
81
+ id: effect.id,
82
+ type: "chromaKey",
83
+ enabled: effect.enabled,
84
+ color: effect.keyColor,
85
+ tolerance: effect.tolerance,
86
+ softness: effect.softness,
87
+ spill: effect.spill
88
+ };
89
+ default:
90
+ return null;
91
+ }
92
+ }
93
+ //# sourceMappingURL=trackEffects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackEffects.js","sourceRoot":"","sources":["../../src/render/trackEffects.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAA2C;IAE3C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,GAAG;QAAE,OAAO,GAAG,C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,CAAC;QAC7B,KAAK,SAAS;YACZ,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;aACA,CAAC;QAChC,KAAK,UAAU;YACb,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,SAAS;gBACxB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aACG,CAAC;QACjC,KAAK,WAAW;YACd,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,KAAK,EAAE,MAAM,CAAC,QAAQ;gBACtB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,KAAK,EAAE,MAAM,CAAC,KAAK;aACU,CAAC;QAClC;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * transform — placement math shared by every timeline render surface.
3
+ *
4
+ * The live preview, the browser exporter and the server-side renderer all
5
+ * build a layer's placement matrix here, so a clip sits in the same spot in
6
+ * the preview, the gizmo, and the exported file.
7
+ */
8
+ import type { ClipTransform } from "../types.js";
9
+ export declare const IDENTITY_TRANSFORM: ClipTransform;
10
+ /**
11
+ * Compute the contain-fit base scale (clip space) for a layer of given
12
+ * source size against a canvas. Mirrors `object-fit: contain` — the longer
13
+ * source axis fills the canvas, the other shrinks proportionally.
14
+ */
15
+ export declare function containBaseScale(layerWidth: number, layerHeight: number, canvasWidth: number, canvasHeight: number): {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ /**
20
+ * `parentMatrix` is the resolved matrix of the group this layer is parented to
21
+ * (see `sceneModel`'s `resolveGroups`), already carrying its own ancestors. A
22
+ * group's matrix is built against the identity base, so it is a pure clip-space
23
+ * transform and composes with any child regardless of the child's source size.
24
+ */
25
+ export declare function buildTransformMatrix(transform: ClipTransform, base: {
26
+ x: number;
27
+ y: number;
28
+ }, width: number, height: number, parentMatrix?: Float32Array): Float32Array;
29
+ /** A 2D affine in `CanvasRenderingContext2D.setTransform` order. */
30
+ export interface CanvasAffine {
31
+ a: number;
32
+ b: number;
33
+ c: number;
34
+ d: number;
35
+ e: number;
36
+ f: number;
37
+ }
38
+ /**
39
+ * Convert a clip-space transform matrix (from {@link buildTransformMatrix}) into
40
+ * the 2D affine that draws a `srcWidth × srcHeight` source image onto a
41
+ * `canvasWidth × canvasHeight` Canvas2D context with the same placement the
42
+ * WebGPU compositor produces. Use as:
43
+ *
44
+ * const t = clipMatrixToCanvasAffine(m, src.w, src.h, cw, ch);
45
+ * ctx.setTransform(t.a, t.b, t.c, t.d, t.e, t.f);
46
+ * ctx.drawImage(source, 0, 0, src.w, src.h);
47
+ *
48
+ * The matrix maps an NDC quad in [-1,1]² to clip space; an image pixel
49
+ * `(ix, iy)` maps to `ndc = (2·ix/srcW − 1, 1 − 2·iy/srcH)`, then to clip space,
50
+ * then to canvas pixels via `px = (clip.x + 1)·W/2`, `py = (1 − clip.y)·H/2`.
51
+ * Composing those linear maps yields the affine below.
52
+ */
53
+ export declare function clipMatrixToCanvasAffine(m: Float32Array, srcWidth: number, srcHeight: number, canvasWidth: number, canvasHeight: number): CanvasAffine;
54
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/render/transform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,eAAO,MAAM,kBAAkB,EAAE,aAKhC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM;;;EAgBrB;AAuFD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,YAAY,GAC1B,YAAY,CAqFd;AAED,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,YAAY,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,YAAY,CAcd"}