@open-take/compositor 0.5.3 → 0.6.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 (439) hide show
  1. package/dist/cdp-CzT5BKNY.js +3 -0
  2. package/dist/cdp-QXbQfXna.js +373 -0
  3. package/dist/cdp-QXbQfXna.js.map +1 -0
  4. package/dist/index.d.ts +4327 -195
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +26282 -160
  7. package/dist/index.js.map +1 -1
  8. package/dist/server-841PMF2H.js +163 -0
  9. package/dist/server-841PMF2H.js.map +1 -0
  10. package/dist/server-C2aVv4-t.js +3 -0
  11. package/kit/audio.mjs +2366 -0
  12. package/kit/camera.js +587 -0
  13. package/kit/cursor.js +264 -0
  14. package/kit/cut.js +427 -0
  15. package/kit/draw.js +346 -0
  16. package/kit/look.js +589 -0
  17. package/kit/map.js +170 -0
  18. package/kit/media.js +3568 -0
  19. package/kit/motion.js +1115 -0
  20. package/kit/seams.js +1006 -0
  21. package/kit/stage.js +923 -0
  22. package/kit/time.js +812 -0
  23. package/kit/world.js +1072 -0
  24. package/package.json +7 -3
  25. package/src/ffmpeg.ts +63 -0
  26. package/src/film/beats.ts +1285 -0
  27. package/src/film/carry.ts +221 -0
  28. package/src/film/changes.ts +330 -0
  29. package/src/film/check.ts +996 -0
  30. package/src/film/clock.ts +2530 -0
  31. package/src/film/components-probe.ts +809 -0
  32. package/src/film/components.ts +1566 -0
  33. package/src/film/frames.ts +389 -0
  34. package/src/film/gallery.ts +3276 -0
  35. package/src/film/kit.ts +515 -0
  36. package/src/film/layout.ts +701 -0
  37. package/src/film/listen.ts +1979 -0
  38. package/src/film/look.ts +3829 -0
  39. package/src/film/materials.ts +976 -0
  40. package/src/film/moving.ts +248 -0
  41. package/src/film/part-files.ts +729 -0
  42. package/src/film/picture.ts +74 -0
  43. package/src/film/probe-text.ts +843 -0
  44. package/src/film/probe.ts +3456 -0
  45. package/src/film/provenance.ts +596 -0
  46. package/src/film/render.ts +2447 -0
  47. package/src/film/report.ts +1631 -0
  48. package/src/film/sheet.ts +156 -0
  49. package/src/film/study-declared.ts +123 -0
  50. package/src/film/study-picture.ts +791 -0
  51. package/src/film/study-sound.ts +416 -0
  52. package/src/film/study.ts +864 -0
  53. package/src/film/tuning.ts +155 -0
  54. package/src/film/viewer.ts +174 -0
  55. package/src/html/cdp.ts +575 -0
  56. package/src/html/server.ts +208 -0
  57. package/src/index.ts +202 -0
  58. package/src/launch-render.ts +3 -2
  59. package/src/math.ts +3 -3
  60. package/src/mjpeg-matroska.ts +228 -0
  61. package/src/render.ts +6 -4
  62. package/src/state-diff.ts +215 -0
  63. package/src/state-index.ts +99 -0
  64. package/src/types.ts +59 -1
  65. package/starter/PLAN.md +84 -0
  66. package/starter/START.md +460 -0
  67. package/starter/lib/anim.js +760 -0
  68. package/starter/lib/devices.js +1402 -0
  69. package/starter/lib/handoff.js +421 -0
  70. package/starter/lib/hud.js +1879 -0
  71. package/starter/lib/measure.mjs +154 -0
  72. package/starter/lib/moves.js +1095 -0
  73. package/starter/lib/palette.mjs +803 -0
  74. package/starter/lib/physics-seeds.mjs +198 -0
  75. package/starter/lib/physics.js +738 -0
  76. package/starter/lib/sampler.mjs +242 -0
  77. package/starter/lib/solid.js +727 -0
  78. package/starter/lib/space.js +1227 -0
  79. package/starter/lib/swarm.js +1398 -0
  80. package/starter/reference/motion.md +276 -0
  81. package/starter/reference/structure.md +466 -0
  82. package/starter/reference/travel/motion.md +433 -0
  83. package/starter/reference/travel/sound.md +241 -0
  84. package/starter/reference/travel/structure.md +518 -0
  85. package/starter/samples/NOTICE.txt +55 -0
  86. package/starter/samples/celli/celli_24_1.opus +0 -0
  87. package/starter/samples/celli/celli_24_3.opus +0 -0
  88. package/starter/samples/celli/celli_28_1.opus +0 -0
  89. package/starter/samples/celli/celli_28_3.opus +0 -0
  90. package/starter/samples/celli/celli_31_1.opus +0 -0
  91. package/starter/samples/celli/celli_31_3.opus +0 -0
  92. package/starter/samples/celli/celli_35_1.opus +0 -0
  93. package/starter/samples/celli/celli_35_3.opus +0 -0
  94. package/starter/samples/celli/celli_38_1.opus +0 -0
  95. package/starter/samples/celli/celli_38_3.opus +0 -0
  96. package/starter/samples/celli/celli_41_1.opus +0 -0
  97. package/starter/samples/celli/celli_41_3.opus +0 -0
  98. package/starter/samples/celli/celli_45_1.opus +0 -0
  99. package/starter/samples/celli/celli_45_3.opus +0 -0
  100. package/starter/samples/celli/celli_48_1.opus +0 -0
  101. package/starter/samples/celli/celli_48_3.opus +0 -0
  102. package/starter/samples/celli/celli_52_1.opus +0 -0
  103. package/starter/samples/celli/celli_52_3.opus +0 -0
  104. package/starter/samples/celli/celli_55_1.opus +0 -0
  105. package/starter/samples/celli/celli_55_3.opus +0 -0
  106. package/starter/samples/celli/celli_59_1.opus +0 -0
  107. package/starter/samples/celli/celli_59_3.opus +0 -0
  108. package/starter/samples/celli/celli_62_1.opus +0 -0
  109. package/starter/samples/celli/celli_62_3.opus +0 -0
  110. package/starter/samples/celli/celli_65_1.opus +0 -0
  111. package/starter/samples/celli/celli_65_3.opus +0 -0
  112. package/starter/samples/crash/crash_f_1.flac +0 -0
  113. package/starter/samples/crash/crash_fff_1.flac +0 -0
  114. package/starter/samples/ebass/ebass_0_x.flac +0 -0
  115. package/starter/samples/ebass/ebass_10_x.flac +0 -0
  116. package/starter/samples/ebass/ebass_11_x.flac +0 -0
  117. package/starter/samples/ebass/ebass_1_x.flac +0 -0
  118. package/starter/samples/ebass/ebass_2_x.flac +0 -0
  119. package/starter/samples/ebass/ebass_3_x.flac +0 -0
  120. package/starter/samples/ebass/ebass_4_x.flac +0 -0
  121. package/starter/samples/ebass/ebass_5_x.flac +0 -0
  122. package/starter/samples/ebass/ebass_6_x.flac +0 -0
  123. package/starter/samples/ebass/ebass_7_x.flac +0 -0
  124. package/starter/samples/ebass/ebass_8_x.flac +0 -0
  125. package/starter/samples/ebass/ebass_9_x.flac +0 -0
  126. package/starter/samples/ek_clap/ek_clap_1_1.flac +0 -0
  127. package/starter/samples/ek_hat/ek_hat_1_1.flac +0 -0
  128. package/starter/samples/ek_hat/ek_hat_1_2.flac +0 -0
  129. package/starter/samples/ek_kick/ek_kick_1_1.flac +0 -0
  130. package/starter/samples/ek_kick/ek_kick_1_2.flac +0 -0
  131. package/starter/samples/glock/glock_67_x.flac +0 -0
  132. package/starter/samples/glock/glock_72_x.flac +0 -0
  133. package/starter/samples/glock/glock_79_x.flac +0 -0
  134. package/starter/samples/glock/glock_84_x.flac +0 -0
  135. package/starter/samples/glock/glock_91_x.flac +0 -0
  136. package/starter/samples/glock/glock_96_x.flac +0 -0
  137. package/starter/samples/harp/harp_101_f.opus +0 -0
  138. package/starter/samples/harp/harp_28_f.opus +0 -0
  139. package/starter/samples/harp/harp_31_mp.opus +0 -0
  140. package/starter/samples/harp/harp_35_mf.opus +0 -0
  141. package/starter/samples/harp/harp_38_mf.opus +0 -0
  142. package/starter/samples/harp/harp_41_mf.opus +0 -0
  143. package/starter/samples/harp/harp_45_mf.opus +0 -0
  144. package/starter/samples/harp/harp_48_mf.opus +0 -0
  145. package/starter/samples/harp/harp_52_mf.opus +0 -0
  146. package/starter/samples/harp/harp_55_mf.opus +0 -0
  147. package/starter/samples/harp/harp_59_mf.opus +0 -0
  148. package/starter/samples/harp/harp_62_mf.opus +0 -0
  149. package/starter/samples/harp/harp_65_mf.opus +0 -0
  150. package/starter/samples/harp/harp_69_mf.opus +0 -0
  151. package/starter/samples/harp/harp_72_mf.opus +0 -0
  152. package/starter/samples/harp/harp_76_mf.opus +0 -0
  153. package/starter/samples/harp/harp_79_mf.opus +0 -0
  154. package/starter/samples/harp/harp_83_mf.opus +0 -0
  155. package/starter/samples/harp/harp_86_mf.opus +0 -0
  156. package/starter/samples/harp/harp_89_mf.opus +0 -0
  157. package/starter/samples/harp/harp_93_mf.opus +0 -0
  158. package/starter/samples/harp/harp_95_mf.opus +0 -0
  159. package/starter/samples/harp/harp_98_f.opus +0 -0
  160. package/starter/samples/manifest.json +2951 -0
  161. package/starter/samples/marimba/marimba_29_x.flac +0 -0
  162. package/starter/samples/marimba/marimba_36_x.flac +0 -0
  163. package/starter/samples/marimba/marimba_43_x.flac +0 -0
  164. package/starter/samples/marimba/marimba_47_x.flac +0 -0
  165. package/starter/samples/marimba/marimba_53_x.flac +0 -0
  166. package/starter/samples/marimba/marimba_60_x.flac +0 -0
  167. package/starter/samples/marimba/marimba_67_x.flac +0 -0
  168. package/starter/samples/marimba/marimba_71_x.flac +0 -0
  169. package/starter/samples/marimba/marimba_77_x.flac +0 -0
  170. package/starter/samples/marimba/marimba_84_x.flac +0 -0
  171. package/starter/samples/piano/piano_102_12.opus +0 -0
  172. package/starter/samples/piano/piano_102_16.opus +0 -0
  173. package/starter/samples/piano/piano_102_4.opus +0 -0
  174. package/starter/samples/piano/piano_102_8.opus +0 -0
  175. package/starter/samples/piano/piano_105_12.opus +0 -0
  176. package/starter/samples/piano/piano_105_16.opus +0 -0
  177. package/starter/samples/piano/piano_105_4.opus +0 -0
  178. package/starter/samples/piano/piano_105_8.opus +0 -0
  179. package/starter/samples/piano/piano_108_12.opus +0 -0
  180. package/starter/samples/piano/piano_108_16.opus +0 -0
  181. package/starter/samples/piano/piano_108_4.opus +0 -0
  182. package/starter/samples/piano/piano_108_8.opus +0 -0
  183. package/starter/samples/piano/piano_21_12.opus +0 -0
  184. package/starter/samples/piano/piano_21_16.opus +0 -0
  185. package/starter/samples/piano/piano_21_4.opus +0 -0
  186. package/starter/samples/piano/piano_21_8.opus +0 -0
  187. package/starter/samples/piano/piano_24_12.opus +0 -0
  188. package/starter/samples/piano/piano_24_16.opus +0 -0
  189. package/starter/samples/piano/piano_24_4.opus +0 -0
  190. package/starter/samples/piano/piano_24_8.opus +0 -0
  191. package/starter/samples/piano/piano_27_12.opus +0 -0
  192. package/starter/samples/piano/piano_27_16.opus +0 -0
  193. package/starter/samples/piano/piano_27_4.opus +0 -0
  194. package/starter/samples/piano/piano_27_8.opus +0 -0
  195. package/starter/samples/piano/piano_30_12.opus +0 -0
  196. package/starter/samples/piano/piano_30_16.opus +0 -0
  197. package/starter/samples/piano/piano_30_4.opus +0 -0
  198. package/starter/samples/piano/piano_30_8.opus +0 -0
  199. package/starter/samples/piano/piano_33_12.opus +0 -0
  200. package/starter/samples/piano/piano_33_16.opus +0 -0
  201. package/starter/samples/piano/piano_33_4.opus +0 -0
  202. package/starter/samples/piano/piano_33_8.opus +0 -0
  203. package/starter/samples/piano/piano_36_12.opus +0 -0
  204. package/starter/samples/piano/piano_36_16.opus +0 -0
  205. package/starter/samples/piano/piano_36_4.opus +0 -0
  206. package/starter/samples/piano/piano_36_8.opus +0 -0
  207. package/starter/samples/piano/piano_39_12.opus +0 -0
  208. package/starter/samples/piano/piano_39_16.opus +0 -0
  209. package/starter/samples/piano/piano_39_4.opus +0 -0
  210. package/starter/samples/piano/piano_39_8.opus +0 -0
  211. package/starter/samples/piano/piano_42_12.opus +0 -0
  212. package/starter/samples/piano/piano_42_16.opus +0 -0
  213. package/starter/samples/piano/piano_42_4.opus +0 -0
  214. package/starter/samples/piano/piano_42_8.opus +0 -0
  215. package/starter/samples/piano/piano_45_12.opus +0 -0
  216. package/starter/samples/piano/piano_45_16.opus +0 -0
  217. package/starter/samples/piano/piano_45_4.opus +0 -0
  218. package/starter/samples/piano/piano_45_8.opus +0 -0
  219. package/starter/samples/piano/piano_48_12.opus +0 -0
  220. package/starter/samples/piano/piano_48_16.opus +0 -0
  221. package/starter/samples/piano/piano_48_4.opus +0 -0
  222. package/starter/samples/piano/piano_48_8.opus +0 -0
  223. package/starter/samples/piano/piano_51_12.opus +0 -0
  224. package/starter/samples/piano/piano_51_16.opus +0 -0
  225. package/starter/samples/piano/piano_51_4.opus +0 -0
  226. package/starter/samples/piano/piano_51_8.opus +0 -0
  227. package/starter/samples/piano/piano_54_12.opus +0 -0
  228. package/starter/samples/piano/piano_54_16.opus +0 -0
  229. package/starter/samples/piano/piano_54_4.opus +0 -0
  230. package/starter/samples/piano/piano_54_8.opus +0 -0
  231. package/starter/samples/piano/piano_57_12.opus +0 -0
  232. package/starter/samples/piano/piano_57_16.opus +0 -0
  233. package/starter/samples/piano/piano_57_4.opus +0 -0
  234. package/starter/samples/piano/piano_57_8.opus +0 -0
  235. package/starter/samples/piano/piano_60_12.opus +0 -0
  236. package/starter/samples/piano/piano_60_16.opus +0 -0
  237. package/starter/samples/piano/piano_60_4.opus +0 -0
  238. package/starter/samples/piano/piano_60_8.opus +0 -0
  239. package/starter/samples/piano/piano_63_12.opus +0 -0
  240. package/starter/samples/piano/piano_63_16.opus +0 -0
  241. package/starter/samples/piano/piano_63_4.opus +0 -0
  242. package/starter/samples/piano/piano_63_8.opus +0 -0
  243. package/starter/samples/piano/piano_66_12.opus +0 -0
  244. package/starter/samples/piano/piano_66_16.opus +0 -0
  245. package/starter/samples/piano/piano_66_4.opus +0 -0
  246. package/starter/samples/piano/piano_66_8.opus +0 -0
  247. package/starter/samples/piano/piano_69_12.opus +0 -0
  248. package/starter/samples/piano/piano_69_16.opus +0 -0
  249. package/starter/samples/piano/piano_69_4.opus +0 -0
  250. package/starter/samples/piano/piano_69_8.opus +0 -0
  251. package/starter/samples/piano/piano_72_12.opus +0 -0
  252. package/starter/samples/piano/piano_72_16.opus +0 -0
  253. package/starter/samples/piano/piano_72_4.opus +0 -0
  254. package/starter/samples/piano/piano_72_8.opus +0 -0
  255. package/starter/samples/piano/piano_75_12.opus +0 -0
  256. package/starter/samples/piano/piano_75_16.opus +0 -0
  257. package/starter/samples/piano/piano_75_4.opus +0 -0
  258. package/starter/samples/piano/piano_75_8.opus +0 -0
  259. package/starter/samples/piano/piano_78_12.opus +0 -0
  260. package/starter/samples/piano/piano_78_16.opus +0 -0
  261. package/starter/samples/piano/piano_78_4.opus +0 -0
  262. package/starter/samples/piano/piano_78_8.opus +0 -0
  263. package/starter/samples/piano/piano_81_12.opus +0 -0
  264. package/starter/samples/piano/piano_81_16.opus +0 -0
  265. package/starter/samples/piano/piano_81_4.opus +0 -0
  266. package/starter/samples/piano/piano_81_8.opus +0 -0
  267. package/starter/samples/piano/piano_84_12.opus +0 -0
  268. package/starter/samples/piano/piano_84_16.opus +0 -0
  269. package/starter/samples/piano/piano_84_4.opus +0 -0
  270. package/starter/samples/piano/piano_84_8.opus +0 -0
  271. package/starter/samples/piano/piano_87_12.opus +0 -0
  272. package/starter/samples/piano/piano_87_16.opus +0 -0
  273. package/starter/samples/piano/piano_87_4.opus +0 -0
  274. package/starter/samples/piano/piano_87_8.opus +0 -0
  275. package/starter/samples/piano/piano_90_12.opus +0 -0
  276. package/starter/samples/piano/piano_90_16.opus +0 -0
  277. package/starter/samples/piano/piano_90_4.opus +0 -0
  278. package/starter/samples/piano/piano_90_8.opus +0 -0
  279. package/starter/samples/piano/piano_93_12.opus +0 -0
  280. package/starter/samples/piano/piano_93_16.opus +0 -0
  281. package/starter/samples/piano/piano_93_4.opus +0 -0
  282. package/starter/samples/piano/piano_93_8.opus +0 -0
  283. package/starter/samples/piano/piano_96_12.opus +0 -0
  284. package/starter/samples/piano/piano_96_16.opus +0 -0
  285. package/starter/samples/piano/piano_96_4.opus +0 -0
  286. package/starter/samples/piano/piano_96_8.opus +0 -0
  287. package/starter/samples/piano/piano_99_12.opus +0 -0
  288. package/starter/samples/piano/piano_99_16.opus +0 -0
  289. package/starter/samples/piano/piano_99_4.opus +0 -0
  290. package/starter/samples/piano/piano_99_8.opus +0 -0
  291. package/starter/samples/piano/piano_rel_102_x.opus +0 -0
  292. package/starter/samples/piano/piano_rel_105_x.opus +0 -0
  293. package/starter/samples/piano/piano_rel_108_x.opus +0 -0
  294. package/starter/samples/piano/piano_rel_21_x.opus +0 -0
  295. package/starter/samples/piano/piano_rel_24_x.opus +0 -0
  296. package/starter/samples/piano/piano_rel_27_x.opus +0 -0
  297. package/starter/samples/piano/piano_rel_30_x.opus +0 -0
  298. package/starter/samples/piano/piano_rel_33_x.opus +0 -0
  299. package/starter/samples/piano/piano_rel_36_x.opus +0 -0
  300. package/starter/samples/piano/piano_rel_39_x.opus +0 -0
  301. package/starter/samples/piano/piano_rel_42_x.opus +0 -0
  302. package/starter/samples/piano/piano_rel_45_x.opus +0 -0
  303. package/starter/samples/piano/piano_rel_48_x.opus +0 -0
  304. package/starter/samples/piano/piano_rel_51_x.opus +0 -0
  305. package/starter/samples/piano/piano_rel_54_x.opus +0 -0
  306. package/starter/samples/piano/piano_rel_57_x.opus +0 -0
  307. package/starter/samples/piano/piano_rel_60_x.opus +0 -0
  308. package/starter/samples/piano/piano_rel_63_x.opus +0 -0
  309. package/starter/samples/piano/piano_rel_66_x.opus +0 -0
  310. package/starter/samples/piano/piano_rel_69_x.opus +0 -0
  311. package/starter/samples/piano/piano_rel_72_x.opus +0 -0
  312. package/starter/samples/piano/piano_rel_75_x.opus +0 -0
  313. package/starter/samples/piano/piano_rel_78_x.opus +0 -0
  314. package/starter/samples/piano/piano_rel_81_x.opus +0 -0
  315. package/starter/samples/piano/piano_rel_84_x.opus +0 -0
  316. package/starter/samples/piano/piano_rel_87_x.opus +0 -0
  317. package/starter/samples/piano/piano_rel_90_x.opus +0 -0
  318. package/starter/samples/piano/piano_rel_93_x.opus +0 -0
  319. package/starter/samples/piano/piano_rel_96_x.opus +0 -0
  320. package/starter/samples/piano/piano_rel_99_x.opus +0 -0
  321. package/starter/samples/pizz/pizz_24_2.flac +0 -0
  322. package/starter/samples/pizz/pizz_28_2.flac +0 -0
  323. package/starter/samples/pizz/pizz_31_2.flac +0 -0
  324. package/starter/samples/pizz/pizz_35_2.flac +0 -0
  325. package/starter/samples/pizz/pizz_38_2.flac +0 -0
  326. package/starter/samples/pizz/pizz_41_2.flac +0 -0
  327. package/starter/samples/pizz/pizz_45_2.flac +0 -0
  328. package/starter/samples/pizz/pizz_48_2.flac +0 -0
  329. package/starter/samples/pizz/pizz_52_2.flac +0 -0
  330. package/starter/samples/pizz/pizz_57_2.flac +0 -0
  331. package/starter/samples/pizz/pizz_60_2.flac +0 -0
  332. package/starter/samples/pizz/pizz_64_2.flac +0 -0
  333. package/starter/samples/pizz/pizz_67_2.flac +0 -0
  334. package/starter/samples/pizz/pizz_71_2.flac +0 -0
  335. package/starter/samples/pizz/pizz_74_2.flac +0 -0
  336. package/starter/samples/pk_hat/pk_hat_2_1.flac +0 -0
  337. package/starter/samples/pk_hat/pk_hat_2_2.flac +0 -0
  338. package/starter/samples/pk_hat/pk_hat_6_1.flac +0 -0
  339. package/starter/samples/pk_hat/pk_hat_6_2.flac +0 -0
  340. package/starter/samples/pk_kick/pk_kick_3_1.flac +0 -0
  341. package/starter/samples/pk_kick/pk_kick_3_2.flac +0 -0
  342. package/starter/samples/pk_kick/pk_kick_7_1.flac +0 -0
  343. package/starter/samples/pk_kick/pk_kick_7_2.flac +0 -0
  344. package/starter/samples/pk_ohat/pk_ohat_3_1.flac +0 -0
  345. package/starter/samples/pk_ohat/pk_ohat_3_2.flac +0 -0
  346. package/starter/samples/pk_ohat/pk_ohat_6_1.flac +0 -0
  347. package/starter/samples/pk_ohat/pk_ohat_6_2.flac +0 -0
  348. package/starter/samples/pk_rim/pk_rim_2_1.flac +0 -0
  349. package/starter/samples/pk_rim/pk_rim_2_2.flac +0 -0
  350. package/starter/samples/pk_rim/pk_rim_5_1.flac +0 -0
  351. package/starter/samples/pk_rim/pk_rim_5_2.flac +0 -0
  352. package/starter/samples/pk_snare/pk_snare_3_1.flac +0 -0
  353. package/starter/samples/pk_snare/pk_snare_3_2.flac +0 -0
  354. package/starter/samples/pk_snare/pk_snare_7_1.flac +0 -0
  355. package/starter/samples/pk_snare/pk_snare_7_2.flac +0 -0
  356. package/starter/samples/shaker/shaker_1_1.flac +0 -0
  357. package/starter/samples/shaker/shaker_2_1.flac +0 -0
  358. package/starter/samples/snap/snap_r_1.flac +0 -0
  359. package/starter/samples/snap/snap_r_2.flac +0 -0
  360. package/starter/samples/snap/snap_r_3.flac +0 -0
  361. package/starter/samples/snap/snap_r_4.flac +0 -0
  362. package/starter/samples/snap/snap_r_5.flac +0 -0
  363. package/starter/samples/snap/snap_r_6.flac +0 -0
  364. package/starter/samples/tom/tom_3_1.flac +0 -0
  365. package/starter/samples/tom/tom_3_2.flac +0 -0
  366. package/starter/samples/tom/tom_4_1.flac +0 -0
  367. package/starter/samples/tom/tom_4_2.flac +0 -0
  368. package/starter/samples/vibes/vibes_41_1.opus +0 -0
  369. package/starter/samples/vibes/vibes_41_2.opus +0 -0
  370. package/starter/samples/vibes/vibes_45_1.opus +0 -0
  371. package/starter/samples/vibes/vibes_45_2.opus +0 -0
  372. package/starter/samples/vibes/vibes_48_1.opus +0 -0
  373. package/starter/samples/vibes/vibes_48_2.opus +0 -0
  374. package/starter/samples/vibes/vibes_52_1.opus +0 -0
  375. package/starter/samples/vibes/vibes_52_2.opus +0 -0
  376. package/starter/samples/vibes/vibes_55_1.opus +0 -0
  377. package/starter/samples/vibes/vibes_55_2.opus +0 -0
  378. package/starter/samples/vibes/vibes_59_1.opus +0 -0
  379. package/starter/samples/vibes/vibes_59_2.opus +0 -0
  380. package/starter/samples/vibes/vibes_62_1.opus +0 -0
  381. package/starter/samples/vibes/vibes_62_2.opus +0 -0
  382. package/starter/samples/vibes/vibes_65_1.opus +0 -0
  383. package/starter/samples/vibes/vibes_65_2.opus +0 -0
  384. package/starter/samples/vibes/vibes_69_1.opus +0 -0
  385. package/starter/samples/vibes/vibes_69_2.opus +0 -0
  386. package/starter/samples/vibes/vibes_72_1.opus +0 -0
  387. package/starter/samples/vibes/vibes_72_2.opus +0 -0
  388. package/starter/samples/vibes/vibes_76_1.opus +0 -0
  389. package/starter/samples/vibes/vibes_76_2.opus +0 -0
  390. package/starter/samples/violas/violas_36_1.opus +0 -0
  391. package/starter/samples/violas/violas_36_2.opus +0 -0
  392. package/starter/samples/violas/violas_38_1.opus +0 -0
  393. package/starter/samples/violas/violas_38_2.opus +0 -0
  394. package/starter/samples/violas/violas_40_1.opus +0 -0
  395. package/starter/samples/violas/violas_40_2.opus +0 -0
  396. package/starter/samples/violas/violas_43_1.opus +0 -0
  397. package/starter/samples/violas/violas_43_2.opus +0 -0
  398. package/starter/samples/violas/violas_47_1.opus +0 -0
  399. package/starter/samples/violas/violas_47_2.opus +0 -0
  400. package/starter/samples/violas/violas_50_1.opus +0 -0
  401. package/starter/samples/violas/violas_50_2.opus +0 -0
  402. package/starter/samples/violas/violas_53_1.opus +0 -0
  403. package/starter/samples/violas/violas_53_2.opus +0 -0
  404. package/starter/samples/violas/violas_57_1.opus +0 -0
  405. package/starter/samples/violas/violas_57_2.opus +0 -0
  406. package/starter/samples/violas/violas_60_1.opus +0 -0
  407. package/starter/samples/violas/violas_60_2.opus +0 -0
  408. package/starter/samples/violas/violas_64_1.opus +0 -0
  409. package/starter/samples/violas/violas_64_2.opus +0 -0
  410. package/starter/samples/violas/violas_67_1.opus +0 -0
  411. package/starter/samples/violas/violas_67_2.opus +0 -0
  412. package/starter/samples/violas/violas_71_1.opus +0 -0
  413. package/starter/samples/violas/violas_71_2.opus +0 -0
  414. package/starter/samples/violas/violas_74_1.opus +0 -0
  415. package/starter/samples/violas/violas_74_2.opus +0 -0
  416. package/starter/samples/violins/violins_43_1.opus +0 -0
  417. package/starter/samples/violins/violins_43_2.opus +0 -0
  418. package/starter/samples/violins/violins_45_1.opus +0 -0
  419. package/starter/samples/violins/violins_45_2.opus +0 -0
  420. package/starter/samples/violins/violins_47_1.opus +0 -0
  421. package/starter/samples/violins/violins_47_2.opus +0 -0
  422. package/starter/samples/violins/violins_50_1.opus +0 -0
  423. package/starter/samples/violins/violins_50_2.opus +0 -0
  424. package/starter/samples/violins/violins_54_1.opus +0 -0
  425. package/starter/samples/violins/violins_54_2.opus +0 -0
  426. package/starter/samples/violins/violins_57_1.opus +0 -0
  427. package/starter/samples/violins/violins_57_2.opus +0 -0
  428. package/starter/samples/violins/violins_60_1.opus +0 -0
  429. package/starter/samples/violins/violins_60_2.opus +0 -0
  430. package/starter/samples/violins/violins_64_1.opus +0 -0
  431. package/starter/samples/violins/violins_64_2.opus +0 -0
  432. package/starter/samples/violins/violins_67_1.opus +0 -0
  433. package/starter/samples/violins/violins_67_2.opus +0 -0
  434. package/starter/samples/violins/violins_71_1.opus +0 -0
  435. package/starter/samples/violins/violins_71_2.opus +0 -0
  436. package/starter/samples/violins/violins_74_1.opus +0 -0
  437. package/starter/samples/violins/violins_74_2.opus +0 -0
  438. package/starter/samples/woodblock/woodblock_f_1.flac +0 -0
  439. package/starter/samples/woodblock/woodblock_f_2.flac +0 -0
@@ -0,0 +1,515 @@
1
+ // `open-take film init`: the film kit (kit/*.js beside this package's dist/)
2
+ // copied into a film's folder, where the film's author reads, changes or
3
+ // drops it — it is the film's own code from then on, not a dependency. Beside
4
+ // it the starter (starter/ beside kit/): START.md, the page to read first;
5
+ // PLAN.md, the plan to fill; reference/, measurements of one launch film
6
+ // (reference/travel/, of six more); lib/, motion helpers, 2.5D camera and
7
+ // cut moves, the words kept on screen, devices, changes of scene, a 3D stage
8
+ // with solids, baked physics, the score's gestures and a sampler; samples/,
9
+ // the sampler's recorded instruments. A page to start from is written only
10
+ // where there is none; a file the author has changed is kept unless asked to
11
+ // replace it, and PLAN.md, once written in, is never replaced. With `--url` the CLI first keeps the
12
+ // product's landing page as a saved screen in states/home/ (its parts as
13
+ // files in parts/, its look in look/); the page to start from then names
14
+ // them in a comment — listed, like the kit, not used.
15
+
16
+ import { constants, existsSync } from "node:fs";
17
+ import { copyFile, mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
18
+ import { createRequire } from "node:module";
19
+ import { dirname, join, posix, relative, resolve } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+
22
+ const PKG_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
23
+
24
+ /** where the kit this package ships is */
25
+ export function filmKitDir(): string {
26
+ // from dist/ or from src/film/ (tests run the sources)
27
+ for (const dir of [join(PKG_ROOT, "kit"), join(PKG_ROOT, "..", "kit")])
28
+ if (existsSync(join(dir, "camera.js"))) return dir;
29
+ throw new Error("film init: the film kit is missing from @open-take/compositor — reinstall it");
30
+ }
31
+
32
+ /** where the starter this package ships is */
33
+ export function filmStarterDir(): string {
34
+ // from dist/ or from src/film/ (tests run the sources)
35
+ for (const dir of [join(PKG_ROOT, "starter"), join(PKG_ROOT, "..", "starter")])
36
+ if (existsSync(join(dir, "START.md"))) return dir;
37
+ throw new Error("film init: the starter is missing from @open-take/compositor — reinstall it");
38
+ }
39
+
40
+ /** what the starter puts in a film's folder, at the same paths there:
41
+ * lib/sampler.mjs imports ../kit/audio.mjs and reads ../samples */
42
+ export const STARTER_PARTS = ["START.md", "PLAN.md", "reference", "lib", "samples"] as const;
43
+
44
+ /** the film's plan: once it differs from the starter's, its author has written in it */
45
+ const PLAN = "PLAN.md";
46
+
47
+ /** three.js's two files a film page imports for kit/world.js (three is a
48
+ * dependency of this package; its build/ holds them) */
49
+ export const THREE_FILES = ["three.module.min.js", "three.core.min.js"] as const;
50
+ const THREE_WEBGPU_FILES = ["three.webgpu.min.js", "three.tsl.min.js"] as const;
51
+
52
+ /** where this package's three.js build is */
53
+ export function threeBuildDir(): string {
54
+ // "three" resolves to build/three.cjs (its exports do not list the .min files)
55
+ const dir = dirname(createRequire(import.meta.url).resolve("three"));
56
+ for (const f of THREE_FILES)
57
+ if (!existsSync(join(dir, f)))
58
+ throw new Error(`film init: three.js's ${f} is missing from ${dir} — reinstall open-take`);
59
+ return dir;
60
+ }
61
+
62
+ /** what copying a set of files into the film's folder did, file by file (absolute) */
63
+ export type FilmFiles = {
64
+ /** written: there was none, or it was replaced (force) */
65
+ written: string[];
66
+ /** left alone because the film's copy is already the same */
67
+ same: string[];
68
+ /** left alone because the film's copy differs (changed by its author) */
69
+ kept: string[];
70
+ };
71
+
72
+ /** the kit's files and the page at the top level, the starter's apart */
73
+ export type FilmInitResult = FilmFiles & {
74
+ /** the film's folder (absolute) */
75
+ dir: string;
76
+ /** the starter's files: START.md, PLAN.md, reference/, lib/, samples/ —
77
+ * none when it was left out */
78
+ starter: FilmFiles;
79
+ /** START.md in the film's folder, the page to read first, when the starter
80
+ * wrote it or found it there */
81
+ start: string | null;
82
+ };
83
+
84
+ /** One file into the film's folder: written where there is none, left where
85
+ * the film's copy is the same, kept where it differs unless `replace`. A
86
+ * clone where the filesystem can make one, else a copy. */
87
+ async function place(from: string, to: string, replace: boolean, into: FilmFiles): Promise<void> {
88
+ const there = await stat(to).catch(() => null);
89
+ if (there) {
90
+ // a folder where the file goes is the author's: never replaced
91
+ if (!there.isFile()) {
92
+ into.kept.push(to);
93
+ return;
94
+ }
95
+ if (
96
+ there.size === (await stat(from)).size &&
97
+ (await readFile(from)).equals(await readFile(to))
98
+ ) {
99
+ into.same.push(to);
100
+ return;
101
+ }
102
+ if (!replace) {
103
+ into.kept.push(to);
104
+ return;
105
+ }
106
+ }
107
+ await copyFile(from, to, constants.COPYFILE_FICLONE);
108
+ into.written.push(to);
109
+ }
110
+
111
+ /** the files of one starter part, relative to the starter, sorted; .DS_Store left out */
112
+ async function starterFiles(root: string, part: string): Promise<string[]> {
113
+ const at = join(root, part);
114
+ const s = await stat(at).catch(() => null);
115
+ if (!s)
116
+ throw new Error(
117
+ `film init: the starter's ${part} is missing from ${root} — reinstall open-take`,
118
+ );
119
+ if (!s.isDirectory()) return [part];
120
+ const out: string[] = [];
121
+ for (const name of (await readdir(at)).sort()) {
122
+ if (name === ".DS_Store") continue;
123
+ out.push(...(await starterFiles(root, join(part, name))));
124
+ }
125
+ return out;
126
+ }
127
+
128
+ /** Starter scripts in lib/ import addons as "three/addons/<path>.js" through the
129
+ * page's import map, or as "../kit/three/addons/<path>.js". Keep the layout
130
+ * of three's examples/jsm so the addons' own imports work. */
131
+ async function threeAddons(root: string, three: string) {
132
+ const bare = "three/addons/";
133
+ const starterPrefixes = [bare, `../kit/${bare}`];
134
+ const source = join(three, "..", "examples", "jsm");
135
+ // file (under examples/jsm) → the file that first asked for it
136
+ const found = new Map<string, string>();
137
+ const want = async (file: string, by: string): Promise<void> => {
138
+ file = file.replace(/[?#].*$/, "");
139
+ if (found.has(file) || file.startsWith("../") || file.startsWith("/") || !file.endsWith(".js")) return;
140
+ found.set(file, by);
141
+ const js = await readFile(join(source, file), "utf8").catch(() => {
142
+ throw new Error(
143
+ `film init: ${by} imports three/addons/${file}, which the three.js open-take ships does not have (no examples/jsm/${file}) — fix the import`,
144
+ );
145
+ });
146
+ for (const spec of moduleSpecifiers(js)) {
147
+ if (spec.startsWith("./") || spec.startsWith("../"))
148
+ await want(posix.join(posix.dirname(file), spec), `three/addons/${file}`);
149
+ else if (spec.startsWith(bare))
150
+ await want(posix.normalize(spec.slice(bare.length)), `three/addons/${file}`);
151
+ }
152
+ };
153
+ for (const file of (await readdir(join(root, "lib"), { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
154
+ if (!file.isFile() || !/\.m?js$/.test(file.name)) continue;
155
+ for (const spec of moduleSpecifiers(await readFile(join(root, "lib", file.name), "utf8"))) {
156
+ const prefix = starterPrefixes.find((p) => spec.startsWith(p));
157
+ if (prefix) await want(posix.normalize(spec.slice(prefix.length)), `lib/${file.name}`);
158
+ }
159
+ }
160
+ return { source, files: [...found.keys()] };
161
+ }
162
+
163
+ // a keyword after which a `/` opens a regular expression, not a division
164
+ const BEFORE_REGEX = new Set([
165
+ "return", "typeof", "instanceof", "in", "of", "new", "delete", "void", "throw", "case", "do",
166
+ "else", "yield", "await",
167
+ ]);
168
+
169
+ /** The tokens of a script, comments left out: strings, template literals and
170
+ * regular expression literals each as one token (so a quote inside a regex
171
+ * opens no string), names, and single characters. A `/` is a regex where an
172
+ * expression starts: at the start, after an operator or opening bracket, or
173
+ * after a keyword such as `return`; after a name, a number or a closing
174
+ * bracket it divides. */
175
+ function jsTokens(js: string): string[] {
176
+ const lexeme =
177
+ /\/\*[\s\S]*?\*\/|\/\/[^\r\n]*|"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]*(?:\\[\s\S][^'\\]*)*'|`[^`\\]*(?:\\[\s\S][^`\\]*)*`|[$\p{ID_Continue}]+|\S/uy;
178
+ const out: string[] = [];
179
+ let i = 0;
180
+ while (i < js.length) {
181
+ while (i < js.length && /\s/.test(js[i]!)) i++;
182
+ if (i >= js.length) break;
183
+ const prev = out[out.length - 1];
184
+ const divides =
185
+ prev !== undefined &&
186
+ (/^[)\]}]$/.test(prev) ||
187
+ prev.startsWith('"') ||
188
+ prev.startsWith("'") ||
189
+ prev.startsWith("`") ||
190
+ (/^[$\p{ID_Continue}]/u.test(prev) && !BEFORE_REGEX.has(prev)));
191
+ if (js[i] === "/" && js[i + 1] !== "/" && js[i + 1] !== "*" && !divides) {
192
+ // a regular expression literal: to the closing `/` outside a class, then its flags
193
+ let j = i + 1;
194
+ let inClass = false;
195
+ for (; j < js.length && js[j] !== "\n"; j++) {
196
+ const c = js[j];
197
+ if (c === "\\") j++;
198
+ else if (c === "[") inClass = true;
199
+ else if (c === "]") inClass = false;
200
+ else if (c === "/" && !inClass) break;
201
+ }
202
+ j++;
203
+ while (j < js.length && /[a-z]/i.test(js[j]!)) j++;
204
+ out.push(js.slice(i, j));
205
+ i = j;
206
+ continue;
207
+ }
208
+ lexeme.lastIndex = i;
209
+ const m = lexeme.exec(js);
210
+ const t = m ? m[0] : js[i]!;
211
+ i += t.length;
212
+ if (!t.startsWith("//") && !t.startsWith("/*")) out.push(t);
213
+ }
214
+ return out;
215
+ }
216
+
217
+ /** Literal module specifiers in imports and re-exports. */
218
+ export function moduleSpecifiers(js: string): string[] {
219
+ const tokens = jsTokens(js);
220
+ const string = (t: string | undefined) => t?.startsWith('"') || t?.startsWith("'");
221
+ const out: string[] = [];
222
+ for (let i = 0; i < tokens.length; i++) {
223
+ const kind = tokens[i];
224
+ const next = tokens[i + 1];
225
+ if (tokens[i - 1] === ".") continue;
226
+ let spec: string | undefined;
227
+ if (kind === "import" && string(next)) spec = next;
228
+ else if (kind === "import" && next === "(" && string(tokens[i + 2]) &&
229
+ (tokens[i + 3] === ")" || tokens[i + 3] === ",")) spec = tokens[i + 2];
230
+ else if ((kind === "import" && next !== "." && next !== "(" && next !== ":") ||
231
+ (kind === "export" && (next === "*" || next === "{"))) {
232
+ // A name in braces can itself be "from".
233
+ for (let j = i + 1; j < tokens.length; j++) {
234
+ const t = tokens[j];
235
+ if (t === "{") {
236
+ while (j + 1 < tokens.length && tokens[++j] !== "}") { /* binding list */ }
237
+ } else if (t === "from" && string(tokens[j + 1])) {
238
+ spec = tokens[j + 1];
239
+ break;
240
+ } else if (t === ";" || t === "=" || t === "(" || string(t)) break;
241
+ }
242
+ }
243
+ if (spec) out.push(spec.slice(1, -1));
244
+ }
245
+ return out;
246
+ }
247
+
248
+ /** what one kit file is, from its header's first line: "// Motion for a film
249
+ * page — open-take's film kit. …" → "motion for a film page" */
250
+ function kitRole(source: string): string {
251
+ const line = source.split("\n").find((l) => /^\/\/ (?!@ts-)/.test(l)) ?? "";
252
+ const role = line
253
+ .replace(/^\/\/\s*/, "")
254
+ .split(" — ")[0]!
255
+ .trim();
256
+ return role ? role[0]!.toLowerCase() + role.slice(1) : "";
257
+ }
258
+
259
+ /** The page `film init` starts a film from: wiring only. No story, no look,
260
+ * no length — the duration is a placeholder — and of the kit it imports only
261
+ * the timeline, whose hooks carry the page's events to the score; the rest
262
+ * of the kit is listed, not imported. The product's material is named in a
263
+ * comment, a live part that acts first and the whole screen kept for the
264
+ * moment it is the proof — where to start, said, not drawn. Where the
265
+ * starter is in the folder, the comment opens on START.md, the page to read
266
+ * first, and names lib/ and samples/ beside the kit. */
267
+ export function starterPage(
268
+ kit: { name: string; role: string }[],
269
+ /** what the folder already holds of the product: a saved screen
270
+ * (states/home/state.html), its look (look/look.json) and its parts as
271
+ * files (parts/index.json); and whether the starter is there (START.md,
272
+ * lib/, samples/) */
273
+ has: { home?: string; look?: string; parts?: string; starter?: boolean } = {},
274
+ ): string {
275
+ const w = Math.max(...kit.map((k) => k.name.length)) + 6;
276
+ const list = kit.map((k) => ` // ${`kit/${k.name}`.padEnd(w)}${k.role}`.trimEnd()).join("\n");
277
+ const dir = has.home ? has.home.replace(/[^/]*$/, "") : null;
278
+ const product = [
279
+ " // the product, as material — start from one of its parts, live, acting: the cursor does one real",
280
+ " // thing to it and the result shows in the part (npx open-take skill film material). Screens shown",
281
+ " // as pictures under a caption read as flat. A film needs not all of these:",
282
+ ...(has.parts
283
+ ? [
284
+ ` // its parts as files: ${has.parts} — each part's own HTML, its styles inlined, in its fonts, alone at`,
285
+ ` // any size: an iframe's src, or (await partFiles("${has.parts.replace(/[^/]*$/, "")}")).node("<ref>") // kit/media.js`,
286
+ ]
287
+ : []),
288
+ ...(has.home
289
+ ? [
290
+ ` // its interface, live DOM: const home = screen(iframe, "${has.home}"); // kit/media.js`,
291
+ ` // lifted out: lift(home, "<selector>") — a live layer, moved at any size, its own elements acting in it`,
292
+ ` // its parts as references: const P = await product("${dir}"); P.part("<ref>") → cam.frame(part, …) · lift(home, part) · cur.click(part, t)`,
293
+ ]
294
+ : []),
295
+ ` // rebuilt: the film's own HTML at film size, in the product's fonts and colours${has.look ? ` (${has.look}, npx open-take film look)` : " (npx open-take film look)"}, with its real values (readValues)`,
296
+ ...(has.home
297
+ ? [
298
+ " // in place: cam.frame(box) · isolate(home, [...]) the rest faded — when the screen round the part matters;",
299
+ " // the whole screen, as a screenshot or a recording, for the moment it is the proof",
300
+ ]
301
+ : [" // the whole screen, as a screenshot or a recording, for the moment it is the proof"]),
302
+ ...(dir
303
+ ? [
304
+ ` // what it says: ${dir}materials.json — its headings and copy, its images (saved), the pages it`,
305
+ ` // links to (its About, docs, repository); npx open-take materials ${dir.replace(/\/$/, "")}`,
306
+ ]
307
+ : []),
308
+ " // what it makes: a shoot's s.save(name, target) keeps a drawn shape, a picture, a result, a",
309
+ " // download as a file of its own — (await stills(url, img)).output(name) in kit/media.js",
310
+ ];
311
+ const starter = has.starter
312
+ ? " // START.md in this folder is what to read first, then PLAN.md to fill and one reference.\n" +
313
+ ' // Beside the kit, lib/ (START.md, "What is in the folder"): anim.js, moves.js (camera and\n' +
314
+ " // cut moves on flat layers), hud.js (words pinned to the screen), handoff.js, devices.js,\n" +
315
+ " // space.js and solid.js (a 3D stage), physics.js, palette.mjs (the score's low bed and\n" +
316
+ " // hits), sampler.mjs with samples/ (recorded instruments) and measure.mjs (this film\n" +
317
+ " // beside one you admire, picture and sound on one ruler).\n"
318
+ : "";
319
+ return `<!doctype html>
320
+ <html>
321
+ <head>
322
+ <meta charset="utf-8">
323
+ <script type="importmap">
324
+ {"imports":{
325
+ "three": "./kit/three.module.min.js",
326
+ "three/webgpu": "./kit/three.webgpu.min.js",
327
+ "three/tsl": "./kit/three.tsl.min.js",
328
+ "three/addons/": "./kit/three/addons/"
329
+ }}
330
+ </script>
331
+ <style>
332
+ html, body { margin: 0; width: 1920px; height: 1080px; overflow: hidden; }
333
+ </style>
334
+ </head>
335
+ <body>
336
+ <script type="module">
337
+ ${starter} // open-take renders this page frame by frame: npx open-take film render .
338
+ // It asks only for window.__film and window.__render(t), the film at t
339
+ // seconds — drawn with the kit, without it, or on a canvas or in WebGL of
340
+ // the page's own, any part of it. The import map above resolves "three",
341
+ // "three/webgpu", "three/tsl" and "three/addons/…" to kit/.
342
+ // kit/ is yours to read, change or drop (npx open-take film gallery draws
343
+ // what each of its blocks does):
344
+ ${list}
345
+ ${product.length ? `${product.join("\n")}\n` : ""} import { timeline } from "./kit/time.js";
346
+
347
+ // the film's moments and what happens when — <film>.events.json, for the score
348
+ const tl = timeline();
349
+
350
+ window.__film = {
351
+ duration: 1, // s — a placeholder: the film is as long as it needs to be
352
+ width: 1920,
353
+ height: 1080,
354
+ ...tl.hooks(),
355
+ };
356
+ window.__render = (t) => {
357
+ // the film at t seconds
358
+ };
359
+ </script>
360
+ </body>
361
+ </html>
362
+ `;
363
+ }
364
+
365
+ export async function initFilm(opts: {
366
+ dir: string;
367
+ /** replace the kit's and the starter's files the author has changed — PLAN.md excepted */
368
+ force?: boolean;
369
+ /** the starter beside the kit (default true); false writes the kit and the page only */
370
+ starter?: boolean;
371
+ /** where the starter is copied from, when supplied */
372
+ starterDir?: string;
373
+ }): Promise<FilmInitResult> {
374
+ const dir = resolve(opts.dir);
375
+ const kit = filmKitDir();
376
+ const three = threeBuildDir();
377
+ const starter = opts.starter !== false ? opts.starterDir ?? filmStarterDir() : null;
378
+ const addons = starter ? await threeAddons(starter, three) : null;
379
+ const force = opts.force === true;
380
+ const res: FilmInitResult = {
381
+ dir,
382
+ written: [],
383
+ same: [],
384
+ kept: [],
385
+ starter: { written: [], same: [], kept: [] },
386
+ start: null,
387
+ };
388
+ await mkdir(join(dir, "kit"), { recursive: true });
389
+ const roles: { name: string; role: string }[] = [];
390
+ for (const name of (await readdir(kit)).filter((f) => /\.m?js$/.test(f)).sort()) {
391
+ const role = kitRole(await readFile(join(kit, name), "utf8"));
392
+ roles.push({ name, role: name.endsWith(".mjs") ? `${role}, for a Node script` : role });
393
+ await place(join(kit, name), join(dir, "kit", name), force, res);
394
+ }
395
+ // three.js (MIT), for kit/world.js and the starter: the page imports it
396
+ // from kit/ itself, and its import map resolves the addons' bare imports
397
+ const threeRoles = {
398
+ "three.module.min.js": 'three.js, for kit/world.js — import * as THREE from "./kit/three.module.min.js"',
399
+ "three.core.min.js": "three.js's core, shared by its WebGL and WebGPU builds",
400
+ "three.webgpu.min.js": 'three.js with its WebGPU renderer — import * as THREE from "three/webgpu" (the page\'s import map)',
401
+ "three.tsl.min.js": 'three.js shader nodes — import from "three/tsl"',
402
+ };
403
+ for (const name of [...THREE_FILES, ...THREE_WEBGPU_FILES]) {
404
+ roles.push({ name, role: threeRoles[name] });
405
+ await place(join(three, name), join(dir, "kit", name), force, res);
406
+ }
407
+ // the starter, at the same paths in the film's folder as in starter/
408
+ if (starter && addons) {
409
+ const root = starter;
410
+ const made = new Set<string>();
411
+ for (const part of STARTER_PARTS)
412
+ for (const rel of await starterFiles(root, part)) {
413
+ const to = join(dir, rel);
414
+ if (!made.has(dirname(to))) {
415
+ await mkdir(dirname(to), { recursive: true });
416
+ made.add(dirname(to));
417
+ }
418
+ // PLAN.md is the film's own working page: force does not replace it
419
+ await place(join(root, rel), to, force && rel !== PLAN, res.starter);
420
+ }
421
+ for (const file of addons.files) {
422
+ const to = join(dir, "kit", "three", "addons", file);
423
+ await mkdir(dirname(to), { recursive: true });
424
+ await place(join(addons.source, file), to, force, res);
425
+ }
426
+ const start = join(dir, "START.md");
427
+ if ((await stat(start).catch(() => null))?.isFile()) res.start = start;
428
+ }
429
+ const page = join(dir, "index.html");
430
+ if (!existsSync(page)) {
431
+ const home = "states/home/state.html";
432
+ const look = "look/look.json";
433
+ const parts = "parts/index.json";
434
+ await writeFile(
435
+ page,
436
+ starterPage(roles, {
437
+ ...(existsSync(join(dir, home)) ? { home } : {}),
438
+ ...(existsSync(join(dir, look)) ? { look } : {}),
439
+ ...(existsSync(join(dir, parts)) ? { parts } : {}),
440
+ ...(starter ? { starter: true } : {}),
441
+ }),
442
+ );
443
+ res.written.push(page);
444
+ }
445
+ return res;
446
+ }
447
+
448
+ /** a folder of the starter with more files than this is told as one line */
449
+ const MANY = 5;
450
+
451
+ /** what a folder of the starter is, for its one line */
452
+ const FOLDER_ABOUT: Record<string, string> = {
453
+ samples: "recorded instruments; NOTICE.txt has their licences",
454
+ lib: "camera and cut moves, words on screen, devices, a 3D stage, physics, the score's bed, the sampler — START.md names each",
455
+ };
456
+
457
+ /**
458
+ * The lines `film init` prints: a line a file written or kept, a folder of
459
+ * the starter with many (samples/) as one line with its count, the files
460
+ * already the same as one line, and last, where START.md is, the pointer to
461
+ * it. `show` gives a path as typed from where the command runs.
462
+ */
463
+ export function filmInitLines(r: FilmInitResult, show: (p: string) => string): string[] {
464
+ const top = (f: string) => relative(r.dir, f).split(/[\\/]/);
465
+ /** the starter's files by their top folder ("" for a file at the top), in order */
466
+ const byFolder = (files: string[]) => {
467
+ const by = new Map<string, string[]>();
468
+ for (const f of files) {
469
+ const parts = top(f);
470
+ const k = parts.length > 1 ? parts[0]! : "";
471
+ by.set(k, [...(by.get(k) ?? []), f]);
472
+ }
473
+ return by;
474
+ };
475
+ const lines: string[] = [];
476
+ for (const f of r.written) lines.push(`wrote ${show(f)}`);
477
+ for (const [folder, files] of byFolder(r.starter.written)) {
478
+ if (folder && files.length > MANY) {
479
+ const about = FOLDER_ABOUT[folder];
480
+ lines.push(
481
+ `wrote ${show(join(r.dir, folder))}/ (${files.length} files${about ? ` — ${about}` : ""})`,
482
+ );
483
+ } else for (const f of files) lines.push(`wrote ${show(f)}`);
484
+ }
485
+ for (const f of r.kept)
486
+ lines.push(`kept ${show(f)} — yours differs from the kit's (--force replaces it)`);
487
+ for (const [folder, files] of byFolder(r.starter.kept)) {
488
+ if (folder && files.length > MANY) {
489
+ const names = files.slice(0, 3).map((f) => top(f).slice(1).join("/"));
490
+ lines.push(
491
+ `kept ${files.length} files in ${show(join(r.dir, folder))}/ — yours differ from the starter's (--force replaces them): ${names.join(", ")}, …`,
492
+ );
493
+ continue;
494
+ }
495
+ for (const f of files)
496
+ lines.push(
497
+ relative(r.dir, f) === PLAN
498
+ ? `kept ${show(f)} — the film's plan, written in: never replaced, with or without --force`
499
+ : `kept ${show(f)} — yours differs from the starter's (--force replaces it)`,
500
+ );
501
+ }
502
+ // the files already as the kit and the starter have them, by folder, in
503
+ // the film's folder
504
+ const same = byFolder([...r.same, ...r.starter.same]);
505
+ if (same.size) {
506
+ const what = [...same].flatMap(([folder, files]) =>
507
+ folder
508
+ ? [`${folder}/ (${files.length} file${files.length === 1 ? "" : "s"})`]
509
+ : files.map((f) => relative(r.dir, f)),
510
+ );
511
+ lines.push(`already the same in ${show(r.dir)}/: ${what.join(", ")}`);
512
+ }
513
+ if (r.start) lines.push(`Read ${show(r.start)} first.`);
514
+ return lines;
515
+ }