@canonical/motion-control 0.0.0-stage → 0.47.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 (310) hide show
  1. package/README.md +300 -2
  2. package/cast.schema.json +101 -0
  3. package/dist/esm/cli.js +30 -0
  4. package/dist/esm/cli.js.map +1 -0
  5. package/dist/esm/global.js +7 -0
  6. package/dist/esm/global.js.map +1 -0
  7. package/dist/esm/index.js +2 -0
  8. package/dist/esm/index.js.map +1 -0
  9. package/dist/esm/lib/cast/checkCasts.js +34 -0
  10. package/dist/esm/lib/cast/checkCasts.js.map +1 -0
  11. package/dist/esm/lib/cast/checkScene.js +58 -0
  12. package/dist/esm/lib/cast/checkScene.js.map +1 -0
  13. package/dist/esm/lib/cast/checkStep.js +73 -0
  14. package/dist/esm/lib/cast/checkStep.js.map +1 -0
  15. package/dist/esm/lib/cast/constants.js +53 -0
  16. package/dist/esm/lib/cast/constants.js.map +1 -0
  17. package/dist/esm/lib/cast/formatReport.js +22 -0
  18. package/dist/esm/lib/cast/formatReport.js.map +1 -0
  19. package/dist/esm/lib/cast/index.js +10 -0
  20. package/dist/esm/lib/cast/index.js.map +1 -0
  21. package/dist/esm/lib/cast/listFrameNames.js +19 -0
  22. package/dist/esm/lib/cast/listFrameNames.js.map +1 -0
  23. package/dist/esm/lib/cast/measureScene.js +11 -0
  24. package/dist/esm/lib/cast/measureScene.js.map +1 -0
  25. package/dist/esm/lib/cast/measureStep.js +21 -0
  26. package/dist/esm/lib/cast/measureStep.js.map +1 -0
  27. package/dist/esm/lib/cast/measureTyping.js +13 -0
  28. package/dist/esm/lib/cast/measureTyping.js.map +1 -0
  29. package/dist/esm/lib/cast/types.js +2 -0
  30. package/dist/esm/lib/cast/types.js.map +1 -0
  31. package/dist/esm/lib/gif/compressLzw.js +61 -0
  32. package/dist/esm/lib/gif/compressLzw.js.map +1 -0
  33. package/dist/esm/lib/gif/constants.js +9 -0
  34. package/dist/esm/lib/gif/constants.js.map +1 -0
  35. package/dist/esm/lib/gif/encodeGif.js +45 -0
  36. package/dist/esm/lib/gif/encodeGif.js.map +1 -0
  37. package/dist/esm/lib/gif/index.js +6 -0
  38. package/dist/esm/lib/gif/index.js.map +1 -0
  39. package/dist/esm/lib/gif/mergeStills.js +32 -0
  40. package/dist/esm/lib/gif/mergeStills.js.map +1 -0
  41. package/dist/esm/lib/gif/quantizePictures.js +75 -0
  42. package/dist/esm/lib/gif/quantizePictures.js.map +1 -0
  43. package/dist/esm/lib/gif/types.js +2 -0
  44. package/dist/esm/lib/gif/types.js.map +1 -0
  45. package/dist/esm/lib/index.js +3 -0
  46. package/dist/esm/lib/index.js.map +1 -0
  47. package/dist/esm/lib/moment/constants.js +33 -0
  48. package/dist/esm/lib/moment/constants.js.map +1 -0
  49. package/dist/esm/lib/moment/describeAction.js +20 -0
  50. package/dist/esm/lib/moment/describeAction.js.map +1 -0
  51. package/dist/esm/lib/moment/describeKeyRun.js +53 -0
  52. package/dist/esm/lib/moment/describeKeyRun.js.map +1 -0
  53. package/dist/esm/lib/moment/describeMoment.js +323 -0
  54. package/dist/esm/lib/moment/describeMoment.js.map +1 -0
  55. package/dist/esm/lib/moment/easeInOut.js +12 -0
  56. package/dist/esm/lib/moment/easeInOut.js.map +1 -0
  57. package/dist/esm/lib/moment/index.js +8 -0
  58. package/dist/esm/lib/moment/index.js.map +1 -0
  59. package/dist/esm/lib/moment/resolveStates.js +82 -0
  60. package/dist/esm/lib/moment/resolveStates.js.map +1 -0
  61. package/dist/esm/lib/moment/takeSpan.js +12 -0
  62. package/dist/esm/lib/moment/takeSpan.js.map +1 -0
  63. package/dist/esm/lib/moment/types.js +2 -0
  64. package/dist/esm/lib/moment/types.js.map +1 -0
  65. package/dist/esm/lib/player/Player.js +498 -0
  66. package/dist/esm/lib/player/Player.js.map +1 -0
  67. package/dist/esm/lib/player/announceHeight.js +30 -0
  68. package/dist/esm/lib/player/announceHeight.js.map +1 -0
  69. package/dist/esm/lib/player/applyMoment.js +155 -0
  70. package/dist/esm/lib/player/applyMoment.js.map +1 -0
  71. package/dist/esm/lib/player/assertPresent.js +14 -0
  72. package/dist/esm/lib/player/assertPresent.js.map +1 -0
  73. package/dist/esm/lib/player/collectFrames.js +30 -0
  74. package/dist/esm/lib/player/collectFrames.js.map +1 -0
  75. package/dist/esm/lib/player/collectStyles.js +24 -0
  76. package/dist/esm/lib/player/collectStyles.js.map +1 -0
  77. package/dist/esm/lib/player/constants.js +101 -0
  78. package/dist/esm/lib/player/constants.js.map +1 -0
  79. package/dist/esm/lib/player/defaultProfile.js +50 -0
  80. package/dist/esm/lib/player/defaultProfile.js.map +1 -0
  81. package/dist/esm/lib/player/drawMarkup.js +36 -0
  82. package/dist/esm/lib/player/drawMarkup.js.map +1 -0
  83. package/dist/esm/lib/player/drawScene.js +32 -0
  84. package/dist/esm/lib/player/drawScene.js.map +1 -0
  85. package/dist/esm/lib/player/drawSprites.js +122 -0
  86. package/dist/esm/lib/player/drawSprites.js.map +1 -0
  87. package/dist/esm/lib/player/fitEmbeds.js +42 -0
  88. package/dist/esm/lib/player/fitEmbeds.js.map +1 -0
  89. package/dist/esm/lib/player/fitSlide.js +27 -0
  90. package/dist/esm/lib/player/fitSlide.js.map +1 -0
  91. package/dist/esm/lib/player/formatKey.js +13 -0
  92. package/dist/esm/lib/player/formatKey.js.map +1 -0
  93. package/dist/esm/lib/player/formatKeySign.js +12 -0
  94. package/dist/esm/lib/player/formatKeySign.js.map +1 -0
  95. package/dist/esm/lib/player/formatSpeed.js +11 -0
  96. package/dist/esm/lib/player/formatSpeed.js.map +1 -0
  97. package/dist/esm/lib/player/formatTime.js +18 -0
  98. package/dist/esm/lib/player/formatTime.js.map +1 -0
  99. package/dist/esm/lib/player/index.js +30 -0
  100. package/dist/esm/lib/player/index.js.map +1 -0
  101. package/dist/esm/lib/player/installStateRules.js +25 -0
  102. package/dist/esm/lib/player/installStateRules.js.map +1 -0
  103. package/dist/esm/lib/player/listHidden.js +24 -0
  104. package/dist/esm/lib/player/listHidden.js.map +1 -0
  105. package/dist/esm/lib/player/makeElement.js +15 -0
  106. package/dist/esm/lib/player/makeElement.js.map +1 -0
  107. package/dist/esm/lib/player/mergeProfile.js +17 -0
  108. package/dist/esm/lib/player/mergeProfile.js.map +1 -0
  109. package/dist/esm/lib/player/mirrorStates.js +23 -0
  110. package/dist/esm/lib/player/mirrorStates.js.map +1 -0
  111. package/dist/esm/lib/player/mountScenes.js +100 -0
  112. package/dist/esm/lib/player/mountScenes.js.map +1 -0
  113. package/dist/esm/lib/player/readLayerBox.js +20 -0
  114. package/dist/esm/lib/player/readLayerBox.js.map +1 -0
  115. package/dist/esm/lib/player/recordGif.js +63 -0
  116. package/dist/esm/lib/player/recordGif.js.map +1 -0
  117. package/dist/esm/lib/player/recordVideo.js +114 -0
  118. package/dist/esm/lib/player/recordVideo.js.map +1 -0
  119. package/dist/esm/lib/player/renderLegend.js +27 -0
  120. package/dist/esm/lib/player/renderLegend.js.map +1 -0
  121. package/dist/esm/lib/player/saveFile.js +22 -0
  122. package/dist/esm/lib/player/saveFile.js.map +1 -0
  123. package/dist/esm/lib/player/serializeElement.js +36 -0
  124. package/dist/esm/lib/player/serializeElement.js.map +1 -0
  125. package/dist/esm/lib/player/types.js +2 -0
  126. package/dist/esm/lib/player/types.js.map +1 -0
  127. package/dist/esm/lib/player/wrapSlide.js +28 -0
  128. package/dist/esm/lib/player/wrapSlide.js.map +1 -0
  129. package/dist/esm/lib/timeline/advanceClock.js +24 -0
  130. package/dist/esm/lib/timeline/advanceClock.js.map +1 -0
  131. package/dist/esm/lib/timeline/buildTimeline.js +47 -0
  132. package/dist/esm/lib/timeline/buildTimeline.js.map +1 -0
  133. package/dist/esm/lib/timeline/constants.js +3 -0
  134. package/dist/esm/lib/timeline/constants.js.map +1 -0
  135. package/dist/esm/lib/timeline/findKeyframe.js +11 -0
  136. package/dist/esm/lib/timeline/findKeyframe.js.map +1 -0
  137. package/dist/esm/lib/timeline/index.js +7 -0
  138. package/dist/esm/lib/timeline/index.js.map +1 -0
  139. package/dist/esm/lib/timeline/locateTime.js +21 -0
  140. package/dist/esm/lib/timeline/locateTime.js.map +1 -0
  141. package/dist/esm/lib/timeline/stepKeyframe.js +20 -0
  142. package/dist/esm/lib/timeline/stepKeyframe.js.map +1 -0
  143. package/dist/esm/lib/timeline/types.js +2 -0
  144. package/dist/esm/lib/timeline/types.js.map +1 -0
  145. package/dist/esm/lib/video/constants.js +7 -0
  146. package/dist/esm/lib/video/constants.js.map +1 -0
  147. package/dist/esm/lib/video/index.js +4 -0
  148. package/dist/esm/lib/video/index.js.map +1 -0
  149. package/dist/esm/lib/video/types.js +2 -0
  150. package/dist/esm/lib/video/types.js.map +1 -0
  151. package/dist/esm/lib/video/writeBox.js +21 -0
  152. package/dist/esm/lib/video/writeBox.js.map +1 -0
  153. package/dist/esm/lib/video/writeMp4.js +45 -0
  154. package/dist/esm/lib/video/writeMp4.js.map +1 -0
  155. package/dist/motion.css +581 -0
  156. package/dist/motion.global.js +1534 -0
  157. package/dist/types/cli.d.ts +3 -0
  158. package/dist/types/cli.d.ts.map +1 -0
  159. package/dist/types/global.d.ts +2 -0
  160. package/dist/types/global.d.ts.map +1 -0
  161. package/dist/types/index.d.ts +17 -0
  162. package/dist/types/index.d.ts.map +1 -0
  163. package/dist/types/lib/cast/checkCasts.d.ts +15 -0
  164. package/dist/types/lib/cast/checkCasts.d.ts.map +1 -0
  165. package/dist/types/lib/cast/checkScene.d.ts +11 -0
  166. package/dist/types/lib/cast/checkScene.d.ts.map +1 -0
  167. package/dist/types/lib/cast/checkStep.d.ts +12 -0
  168. package/dist/types/lib/cast/checkStep.d.ts.map +1 -0
  169. package/dist/types/lib/cast/constants.d.ts +20 -0
  170. package/dist/types/lib/cast/constants.d.ts.map +1 -0
  171. package/dist/types/lib/cast/formatReport.d.ts +11 -0
  172. package/dist/types/lib/cast/formatReport.d.ts.map +1 -0
  173. package/dist/types/lib/cast/index.d.ts +11 -0
  174. package/dist/types/lib/cast/index.d.ts.map +1 -0
  175. package/dist/types/lib/cast/listFrameNames.d.ts +8 -0
  176. package/dist/types/lib/cast/listFrameNames.d.ts.map +1 -0
  177. package/dist/types/lib/cast/measureScene.d.ts +9 -0
  178. package/dist/types/lib/cast/measureScene.d.ts.map +1 -0
  179. package/dist/types/lib/cast/measureStep.d.ts +13 -0
  180. package/dist/types/lib/cast/measureStep.d.ts.map +1 -0
  181. package/dist/types/lib/cast/measureTyping.d.ts +12 -0
  182. package/dist/types/lib/cast/measureTyping.d.ts.map +1 -0
  183. package/dist/types/lib/cast/types.d.ts +87 -0
  184. package/dist/types/lib/cast/types.d.ts.map +1 -0
  185. package/dist/types/lib/gif/compressLzw.d.ts +9 -0
  186. package/dist/types/lib/gif/compressLzw.d.ts.map +1 -0
  187. package/dist/types/lib/gif/constants.d.ts +9 -0
  188. package/dist/types/lib/gif/constants.d.ts.map +1 -0
  189. package/dist/types/lib/gif/encodeGif.d.ts +13 -0
  190. package/dist/types/lib/gif/encodeGif.d.ts.map +1 -0
  191. package/dist/types/lib/gif/index.d.ts +7 -0
  192. package/dist/types/lib/gif/index.d.ts.map +1 -0
  193. package/dist/types/lib/gif/mergeStills.d.ts +12 -0
  194. package/dist/types/lib/gif/mergeStills.d.ts.map +1 -0
  195. package/dist/types/lib/gif/quantizePictures.d.ts +13 -0
  196. package/dist/types/lib/gif/quantizePictures.d.ts.map +1 -0
  197. package/dist/types/lib/gif/types.d.ts +22 -0
  198. package/dist/types/lib/gif/types.d.ts.map +1 -0
  199. package/dist/types/lib/index.d.ts +3 -0
  200. package/dist/types/lib/index.d.ts.map +1 -0
  201. package/dist/types/lib/moment/constants.d.ts +33 -0
  202. package/dist/types/lib/moment/constants.d.ts.map +1 -0
  203. package/dist/types/lib/moment/describeAction.d.ts +9 -0
  204. package/dist/types/lib/moment/describeAction.d.ts.map +1 -0
  205. package/dist/types/lib/moment/describeKeyRun.d.ts +18 -0
  206. package/dist/types/lib/moment/describeKeyRun.d.ts.map +1 -0
  207. package/dist/types/lib/moment/describeMoment.d.ts +16 -0
  208. package/dist/types/lib/moment/describeMoment.d.ts.map +1 -0
  209. package/dist/types/lib/moment/easeInOut.d.ts +8 -0
  210. package/dist/types/lib/moment/easeInOut.d.ts.map +1 -0
  211. package/dist/types/lib/moment/index.d.ts +9 -0
  212. package/dist/types/lib/moment/index.d.ts.map +1 -0
  213. package/dist/types/lib/moment/resolveStates.d.ts +18 -0
  214. package/dist/types/lib/moment/resolveStates.d.ts.map +1 -0
  215. package/dist/types/lib/moment/takeSpan.d.ts +10 -0
  216. package/dist/types/lib/moment/takeSpan.d.ts.map +1 -0
  217. package/dist/types/lib/moment/types.d.ts +187 -0
  218. package/dist/types/lib/moment/types.d.ts.map +1 -0
  219. package/dist/types/lib/player/Player.d.ts +134 -0
  220. package/dist/types/lib/player/Player.d.ts.map +1 -0
  221. package/dist/types/lib/player/announceHeight.d.ts +12 -0
  222. package/dist/types/lib/player/announceHeight.d.ts.map +1 -0
  223. package/dist/types/lib/player/applyMoment.d.ts +21 -0
  224. package/dist/types/lib/player/applyMoment.d.ts.map +1 -0
  225. package/dist/types/lib/player/assertPresent.d.ts +10 -0
  226. package/dist/types/lib/player/assertPresent.d.ts.map +1 -0
  227. package/dist/types/lib/player/collectFrames.d.ts +11 -0
  228. package/dist/types/lib/player/collectFrames.d.ts.map +1 -0
  229. package/dist/types/lib/player/collectStyles.d.ts +12 -0
  230. package/dist/types/lib/player/collectStyles.d.ts.map +1 -0
  231. package/dist/types/lib/player/constants.d.ts +80 -0
  232. package/dist/types/lib/player/constants.d.ts.map +1 -0
  233. package/dist/types/lib/player/defaultProfile.d.ts +8 -0
  234. package/dist/types/lib/player/defaultProfile.d.ts.map +1 -0
  235. package/dist/types/lib/player/drawMarkup.d.ts +15 -0
  236. package/dist/types/lib/player/drawMarkup.d.ts.map +1 -0
  237. package/dist/types/lib/player/drawScene.d.ts +23 -0
  238. package/dist/types/lib/player/drawScene.d.ts.map +1 -0
  239. package/dist/types/lib/player/drawSprites.d.ts +35 -0
  240. package/dist/types/lib/player/drawSprites.d.ts.map +1 -0
  241. package/dist/types/lib/player/fitEmbeds.d.ts +13 -0
  242. package/dist/types/lib/player/fitEmbeds.d.ts.map +1 -0
  243. package/dist/types/lib/player/fitSlide.d.ts +24 -0
  244. package/dist/types/lib/player/fitSlide.d.ts.map +1 -0
  245. package/dist/types/lib/player/formatKey.d.ts +9 -0
  246. package/dist/types/lib/player/formatKey.d.ts.map +1 -0
  247. package/dist/types/lib/player/formatKeySign.d.ts +9 -0
  248. package/dist/types/lib/player/formatKeySign.d.ts.map +1 -0
  249. package/dist/types/lib/player/formatSpeed.d.ts +9 -0
  250. package/dist/types/lib/player/formatSpeed.d.ts.map +1 -0
  251. package/dist/types/lib/player/formatTime.d.ts +12 -0
  252. package/dist/types/lib/player/formatTime.d.ts.map +1 -0
  253. package/dist/types/lib/player/index.d.ts +31 -0
  254. package/dist/types/lib/player/index.d.ts.map +1 -0
  255. package/dist/types/lib/player/installStateRules.d.ts +12 -0
  256. package/dist/types/lib/player/installStateRules.d.ts.map +1 -0
  257. package/dist/types/lib/player/listHidden.d.ts +12 -0
  258. package/dist/types/lib/player/listHidden.d.ts.map +1 -0
  259. package/dist/types/lib/player/makeElement.d.ts +10 -0
  260. package/dist/types/lib/player/makeElement.d.ts.map +1 -0
  261. package/dist/types/lib/player/mergeProfile.d.ts +9 -0
  262. package/dist/types/lib/player/mergeProfile.d.ts.map +1 -0
  263. package/dist/types/lib/player/mirrorStates.d.ts +12 -0
  264. package/dist/types/lib/player/mirrorStates.d.ts.map +1 -0
  265. package/dist/types/lib/player/mountScenes.d.ts +25 -0
  266. package/dist/types/lib/player/mountScenes.d.ts.map +1 -0
  267. package/dist/types/lib/player/readLayerBox.d.ts +23 -0
  268. package/dist/types/lib/player/readLayerBox.d.ts.map +1 -0
  269. package/dist/types/lib/player/recordGif.d.ts +16 -0
  270. package/dist/types/lib/player/recordGif.d.ts.map +1 -0
  271. package/dist/types/lib/player/recordVideo.d.ts +19 -0
  272. package/dist/types/lib/player/recordVideo.d.ts.map +1 -0
  273. package/dist/types/lib/player/renderLegend.d.ts +8 -0
  274. package/dist/types/lib/player/renderLegend.d.ts.map +1 -0
  275. package/dist/types/lib/player/saveFile.d.ts +13 -0
  276. package/dist/types/lib/player/saveFile.d.ts.map +1 -0
  277. package/dist/types/lib/player/serializeElement.d.ts +14 -0
  278. package/dist/types/lib/player/serializeElement.d.ts.map +1 -0
  279. package/dist/types/lib/player/types.d.ts +321 -0
  280. package/dist/types/lib/player/types.d.ts.map +1 -0
  281. package/dist/types/lib/player/wrapSlide.d.ts +17 -0
  282. package/dist/types/lib/player/wrapSlide.d.ts.map +1 -0
  283. package/dist/types/lib/timeline/advanceClock.d.ts +16 -0
  284. package/dist/types/lib/timeline/advanceClock.d.ts.map +1 -0
  285. package/dist/types/lib/timeline/buildTimeline.d.ts +15 -0
  286. package/dist/types/lib/timeline/buildTimeline.d.ts.map +1 -0
  287. package/dist/types/lib/timeline/constants.d.ts +3 -0
  288. package/dist/types/lib/timeline/constants.d.ts.map +1 -0
  289. package/dist/types/lib/timeline/findKeyframe.d.ts +10 -0
  290. package/dist/types/lib/timeline/findKeyframe.d.ts.map +1 -0
  291. package/dist/types/lib/timeline/index.d.ts +8 -0
  292. package/dist/types/lib/timeline/index.d.ts.map +1 -0
  293. package/dist/types/lib/timeline/locateTime.d.ts +10 -0
  294. package/dist/types/lib/timeline/locateTime.d.ts.map +1 -0
  295. package/dist/types/lib/timeline/stepKeyframe.d.ts +12 -0
  296. package/dist/types/lib/timeline/stepKeyframe.d.ts.map +1 -0
  297. package/dist/types/lib/timeline/types.d.ts +40 -0
  298. package/dist/types/lib/timeline/types.d.ts.map +1 -0
  299. package/dist/types/lib/video/constants.d.ts +5 -0
  300. package/dist/types/lib/video/constants.d.ts.map +1 -0
  301. package/dist/types/lib/video/index.d.ts +5 -0
  302. package/dist/types/lib/video/index.d.ts.map +1 -0
  303. package/dist/types/lib/video/types.d.ts +21 -0
  304. package/dist/types/lib/video/types.d.ts.map +1 -0
  305. package/dist/types/lib/video/writeBox.d.ts +9 -0
  306. package/dist/types/lib/video/writeBox.d.ts.map +1 -0
  307. package/dist/types/lib/video/writeMp4.d.ts +10 -0
  308. package/dist/types/lib/video/writeMp4.d.ts.map +1 -0
  309. package/package.json +105 -4
  310. package/skills/design-motion-frames/SKILL.md +183 -0
@@ -0,0 +1,53 @@
1
+ /** The interactions that draw a symbol, each with its name and a description of what is drawn. */
2
+ export const SYMBOLS = {
3
+ tap: ["Tap", "a finger, down and up"],
4
+ hold: ["Hold", "a finger that stays; the ring fills"],
5
+ slide: ["Slide", "a finger moving sideways, with its trail"],
6
+ drag: ["Scroll by touch", "a finger moving up or down, with its trail"],
7
+ move: ["Pointer", "the mouse"],
8
+ click: ["Click", "the pointer, and a ring at its tip"],
9
+ wheel: ["Wheel", "the pointer, and a wheel that turns"],
10
+ key: ["Key", "a keycap with the key's name"],
11
+ type: ["Typing", "letters arriving in the line"],
12
+ };
13
+ /** Every value a step's `do` may take. */
14
+ export const ACTIONS = [
15
+ "tap",
16
+ "hold",
17
+ "slide",
18
+ "drag",
19
+ "move",
20
+ "click",
21
+ "wheel",
22
+ "key",
23
+ "type",
24
+ "wait",
25
+ ];
26
+ /** How long each interaction lasts when its step gives no `ms`, in milliseconds. */
27
+ export const DURATIONS = {
28
+ tap: 650,
29
+ hold: 1000,
30
+ slide: 950,
31
+ drag: 1050,
32
+ move: 600,
33
+ click: 850,
34
+ wheel: 1050,
35
+ key: 750,
36
+ wait: 500,
37
+ };
38
+ /** How long a frame stays when its step gives no `hold`, in milliseconds. */
39
+ export const DEFAULT_HOLD = 900;
40
+ /** How many characters a typed line is taken to have when its length is not known. */
41
+ export const DEFAULT_CHARS = 12;
42
+ /** Typing speed when a step gives no `cps`, in characters per second. */
43
+ export const DEFAULT_CPS = 14;
44
+ /** The shortest time typing takes, in milliseconds, so that a short word is still seen arriving. */
45
+ export const MIN_TYPING = 400;
46
+ /** The longest caption that still reads at a glance, in characters. */
47
+ export const MAX_CAPTION = 90;
48
+ /** How long a scene and a clip are meant to last, as lower and upper bounds in milliseconds. */
49
+ export const LIMITS = {
50
+ scene: [2000, 10000],
51
+ clip: [20000, 30000],
52
+ };
53
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/cast/constants.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,MAAM,CAAC,MAAM,OAAO,GAAsD;IACxE,GAAG,EAAE,CAAC,KAAK,EAAE,uBAAuB,CAAC;IACrC,IAAI,EAAE,CAAC,MAAM,EAAE,qCAAqC,CAAC;IACrD,KAAK,EAAE,CAAC,OAAO,EAAE,0CAA0C,CAAC;IAC5D,IAAI,EAAE,CAAC,iBAAiB,EAAE,4CAA4C,CAAC;IACvE,IAAI,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;IAC9B,KAAK,EAAE,CAAC,OAAO,EAAE,oCAAoC,CAAC;IACtD,KAAK,EAAE,CAAC,OAAO,EAAE,qCAAqC,CAAC;IACvD,GAAG,EAAE,CAAC,KAAK,EAAE,8BAA8B,CAAC;IAC5C,IAAI,EAAE,CAAC,QAAQ,EAAE,8BAA8B,CAAC;CACjD,CAAC;AAEF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAa;IAC/B,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;CACP,CAAC;AAEF,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAA4C;IAChE,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,yEAAyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,oGAAoG;AACpG,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAE9B,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,gGAAgG;AAChG,MAAM,CAAC,MAAM,MAAM,GAA+C;IAChE,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;IACpB,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;CACrB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import measureScene from "./measureScene.js";
2
+ /**
3
+ * Writes the outcome of a check as lines to print: each warning, each error, then one line that counts.
4
+ *
5
+ * @param casts - The scenes that were checked.
6
+ * @param result - What the check found.
7
+ * @param namesChecked - Whether frame names were checked; the last line says so when they were not.
8
+ * @returns The lines, in the order to print them.
9
+ */
10
+ export default function formatReport(casts, result, namesChecked) {
11
+ const scenes = Array.isArray(casts) ? casts : [];
12
+ const seconds = scenes.reduce((sum, scene) => sum +
13
+ (Array.isArray(scene?.steps) && result.errors.length === 0
14
+ ? measureScene(scene)
15
+ : 0), 0) / 1000;
16
+ return [
17
+ ...result.warnings.map((line) => `warning ${line}`),
18
+ ...result.errors.map((line) => `error ${line}`),
19
+ `${scenes.length} scenes${result.errors.length === 0 ? `, ${seconds.toFixed(1)} s in all` : ""}: ${result.errors.length} errors, ${result.warnings.length} warnings${namesChecked ? "" : " (frame names not checked: pass --frames)"}`,
20
+ ];
21
+ }
22
+ //# sourceMappingURL=formatReport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatReport.js","sourceRoot":"","sources":["../../../../src/lib/cast/formatReport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAG7C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,KAAc,EACd,MAAmB,EACnB,YAAqB;IAErB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,MAAM,OAAO,GACX,MAAM,CAAC,MAAM,CACX,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CACb,GAAG;QACH,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YACxD,CAAC,CAAC,YAAY,CAAC,KAAc,CAAC;YAC9B,CAAC,CAAC,CAAC,CAAC,EACR,CAAC,CACF,GAAG,IAAI,CAAC;IACX,OAAO;QACL,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC;QACpD,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC;QAClD,GAAG,MAAM,CAAC,MAAM,UAAU,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,2CAA2C,EAAE;KACvO,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { default as checkCasts } from "./checkCasts.js";
2
+ export { default as checkScene } from "./checkScene.js";
3
+ export { default as checkStep } from "./checkStep.js";
4
+ export { ACTIONS, DEFAULT_CHARS, DEFAULT_CPS, DEFAULT_HOLD, DURATIONS, LIMITS, MAX_CAPTION, MIN_TYPING, SYMBOLS, } from "./constants.js";
5
+ export { default as formatReport } from "./formatReport.js";
6
+ export { default as listFrameNames } from "./listFrameNames.js";
7
+ export { default as measureScene } from "./measureScene.js";
8
+ export { default as measureStep } from "./measureStep.js";
9
+ export { default as measureTyping } from "./measureTyping.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/cast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,EACV,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Lists the names frames answer to, from a catalogue read from a file.
3
+ *
4
+ * @param catalogue - A list of names, or of objects with an `id` and perhaps a `code`.
5
+ * @returns Every name: each string, and each object's id and code.
6
+ */
7
+ export default function listFrameNames(catalogue) {
8
+ if (!Array.isArray(catalogue))
9
+ return [];
10
+ return catalogue.flatMap((entry) => {
11
+ if (typeof entry === "string")
12
+ return [entry];
13
+ if (typeof entry !== "object" || entry === null)
14
+ return [];
15
+ const { id, code } = entry;
16
+ return [id, code].filter((name) => typeof name === "string" && name !== "");
17
+ });
18
+ }
19
+ //# sourceMappingURL=listFrameNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listFrameNames.js","sourceRoot":"","sources":["../../../../src/lib/cast/listFrameNames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,SAAkB;IACvD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAC3D,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,KAAyC,CAAC;QAC/D,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,MAAM,CACtB,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,CAClE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import measureStep from "./measureStep.js";
2
+ /**
3
+ * Says how long a scene lasts, in milliseconds, as the sum of its steps.
4
+ *
5
+ * @param scene - The scene.
6
+ * @returns The duration. Typing whose words come from a frame is counted at the usual length of a line.
7
+ */
8
+ export default function measureScene(scene) {
9
+ return scene.steps.reduce((sum, step) => sum + measureStep(step), 0);
10
+ }
11
+ //# sourceMappingURL=measureScene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measureScene.js","sourceRoot":"","sources":["../../../../src/lib/cast/measureScene.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAG3C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAA2B;IAC9D,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { DEFAULT_HOLD, DURATIONS } from "./constants.js";
2
+ import measureTyping from "./measureTyping.js";
3
+ /**
4
+ * Says how long one step lasts, in milliseconds.
5
+ *
6
+ * A frame lasts its hold, after any typing. Typing lasts as long as its words. Any other interaction lasts
7
+ * its `ms`, or the usual time of its kind.
8
+ *
9
+ * @param step - The step.
10
+ * @param chars - The number of characters typed, when the words come from the frame.
11
+ * @returns The duration.
12
+ */
13
+ export default function measureStep(step, chars) {
14
+ if ("frame" in step) {
15
+ return ((step.hold ?? DEFAULT_HOLD) + (step.type ? measureTyping(step, chars) : 0));
16
+ }
17
+ if (step.do === "type")
18
+ return measureTyping(step, chars);
19
+ return step.ms ?? DURATIONS[step.do];
20
+ }
21
+ //# sourceMappingURL=measureStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measureStep.js","sourceRoot":"","sources":["../../../../src/lib/cast/measureStep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAG/C;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAU,EAAE,KAAc;IAC5D,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM;QAAE,OAAO,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { DEFAULT_CHARS, DEFAULT_CPS, MIN_TYPING } from "./constants.js";
2
+ /**
3
+ * Says how long typing takes, in milliseconds.
4
+ *
5
+ * @param step - What is typed: its words, when the step gives them, and its speed.
6
+ * @param chars - The number of characters, when the words come from the frame and not from the step.
7
+ * @returns The duration, never shorter than the time a short word needs to be seen arriving.
8
+ */
9
+ export default function measureTyping(step, chars) {
10
+ const count = chars ?? step.text?.length ?? DEFAULT_CHARS;
11
+ return Math.max(MIN_TYPING, count * (1000 / (step.cps ?? DEFAULT_CPS)));
12
+ }
13
+ //# sourceMappingURL=measureTyping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measureTyping.js","sourceRoot":"","sources":["../../../../src/lib/cast/measureTyping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,IAAqC,EACrC,KAAc;IAEd,MAAM,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,aAAa,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/cast/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ import { MAX_CODE_BITS, MIN_CODE_SIZE } from "./constants.js";
2
+ /**
3
+ * Compresses a picture's palette indices the way the GIF format asks: sequences already seen are written as one
4
+ * code, and codes grow from nine bits to twelve as the table of sequences fills, then the table starts again.
5
+ *
6
+ * @param indices - One palette index per pixel.
7
+ * @returns The stream of codes packed into bytes, lowest bit first, not yet cut into blocks.
8
+ */
9
+ export default function compressLzw(indices) {
10
+ const clear = 1 << MIN_CODE_SIZE;
11
+ const end = clear + 1;
12
+ const out = [];
13
+ let bits = 0;
14
+ let held = 0;
15
+ let size = MIN_CODE_SIZE + 1;
16
+ let next = end + 1;
17
+ let table = new Map();
18
+ const write = (code) => {
19
+ held |= code << bits;
20
+ bits += size;
21
+ while (bits >= 8) {
22
+ out.push(held & 0xff);
23
+ held >>>= 8;
24
+ bits -= 8;
25
+ }
26
+ };
27
+ write(clear);
28
+ let prefix = indices.at(0);
29
+ if (prefix !== undefined) {
30
+ for (let at = 1; at < indices.length; at += 1) {
31
+ const byte = indices[at];
32
+ const key = (prefix << 8) | byte;
33
+ const known = table.get(key);
34
+ if (known !== undefined) {
35
+ prefix = known;
36
+ continue;
37
+ }
38
+ write(prefix);
39
+ if (next < 1 << MAX_CODE_BITS) {
40
+ table.set(key, next);
41
+ if (next === 1 << size)
42
+ size += 1;
43
+ next += 1;
44
+ }
45
+ else {
46
+ // The table is full: say so, and start it again at nine bits.
47
+ write(clear);
48
+ table = new Map();
49
+ size = MIN_CODE_SIZE + 1;
50
+ next = end + 1;
51
+ }
52
+ prefix = byte;
53
+ }
54
+ write(prefix);
55
+ }
56
+ write(end);
57
+ if (bits > 0)
58
+ out.push(held & 0xff);
59
+ return Uint8Array.from(out);
60
+ }
61
+ //# sourceMappingURL=compressLzw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressLzw.js","sourceRoot":"","sources":["../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KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,GAAG,KAAK,CAAC;gBACf,SAAS;YACX,CAAC;YACD,KAAK,CAAC,MAAM,CAAC,CAAC;YACd,IAAI,IAAI,GAAG,CAAC,IAAI,aAAa,EAAE,CAAC;gBAC9B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBACrB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI;oBAAE,IAAI,IAAI,CAAC,CAAC;gBAClC,IAAI,IAAI,CAAC,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,8DAA8D;gBAC9D,KAAK,CAAC,KAAK,CAAC,CAAC;gBACb,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;gBAClB,IAAI,GAAG,aAAa,GAAG,CAAC,CAAC;gBACzB,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;YACjB,CAAC;YACD,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,CAAC;IACX,IAAI,IAAI,GAAG,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACpC,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** How many colours a GIF's palette holds. */
2
+ export const PALETTE_SIZE = 256;
3
+ /** The number of bits a pixel's index takes before compression: eight, for a palette of 256. */
4
+ export const MIN_CODE_SIZE = 8;
5
+ /** The longest code the format allows, in bits. The table of sequences starts again when it is full. */
6
+ export const MAX_CODE_BITS = 12;
7
+ /** The most bytes one block of image data may carry. */
8
+ export const BLOCK_SIZE = 255;
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/gif/constants.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,wGAAwG;AACxG,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC"}
@@ -0,0 +1,45 @@
1
+ import compressLzw from "./compressLzw.js";
2
+ import { BLOCK_SIZE, MIN_CODE_SIZE } from "./constants.js";
3
+ const word = (value) => [
4
+ value & 0xff,
5
+ (value >> 8) & 0xff,
6
+ ];
7
+ /**
8
+ * Writes pictures that share one palette as an animated GIF that plays again when it ends.
9
+ *
10
+ * @param quantized - The palette of 256 colours and the pictures as indices into it.
11
+ * @param width - The width of every picture, in pixels.
12
+ * @param height - The height of every picture, in pixels.
13
+ * @param loop - Whether the file plays again when it ends; a viewer shows it once and stops on its last picture
14
+ * when not.
15
+ * @returns The bytes of the file.
16
+ */
17
+ export default function encodeGif(quantized, width, height, loop = true) {
18
+ const bytes = [];
19
+ // The header and the screen: its size, and a palette of 256 colours for every picture.
20
+ bytes.push(...Array.from("GIF89a", (letter) => letter.charCodeAt(0)));
21
+ bytes.push(...word(width), ...word(height), 0xf7, 0, 0);
22
+ bytes.push(...quantized.palette);
23
+ // Play again, without end. A file without this block plays once.
24
+ if (loop) {
25
+ bytes.push(0x21, 0xff, 0x0b);
26
+ bytes.push(...Array.from("NETSCAPE2.0", (letter) => letter.charCodeAt(0)));
27
+ bytes.push(0x03, 0x01, 0, 0, 0);
28
+ }
29
+ for (const picture of quantized.pictures) {
30
+ // How long the picture stays, in hundredths of a second; each picture replaces the one before it.
31
+ const hundredths = Math.max(2, Math.round(picture.delay / 10));
32
+ bytes.push(0x21, 0xf9, 0x04, 0x04, ...word(hundredths), 0, 0);
33
+ bytes.push(0x2c, 0, 0, 0, 0, ...word(width), ...word(height), 0);
34
+ bytes.push(MIN_CODE_SIZE);
35
+ const data = compressLzw(picture.indices);
36
+ for (let at = 0; at < data.length; at += BLOCK_SIZE) {
37
+ const block = data.subarray(at, at + BLOCK_SIZE);
38
+ bytes.push(block.length, ...block);
39
+ }
40
+ bytes.push(0);
41
+ }
42
+ bytes.push(0x3b);
43
+ return Uint8Array.from(bytes);
44
+ }
45
+ //# sourceMappingURL=encodeGif.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeGif.js","sourceRoot":"","sources":["../../../../src/lib/gif/encodeGif.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG3D,MAAM,IAAI,GAAG,CAAC,KAAa,EAAoB,EAAE,CAAC;IAChD,KAAK,GAAG,IAAI;IACZ,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI;CACpB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAAoB,EACpB,KAAa,EACb,MAAc,EACd,IAAI,GAAG,IAAI;IAEX,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,uFAAuF;IACvF,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,iEAAiE;IACjE,IAAI,IAAI,EAAE,CAAC;QACT,KAAK,CAAC,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KAAK,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { default as compressLzw } from "./compressLzw.js";
2
+ export { BLOCK_SIZE, MAX_CODE_BITS, MIN_CODE_SIZE, PALETTE_SIZE, } from "./constants.js";
3
+ export { default as encodeGif } from "./encodeGif.js";
4
+ export { default as mergeStills } from "./mergeStills.js";
5
+ export { default as quantizePictures } from "./quantizePictures.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/gif/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,32 @@
1
+ const isSame = (one, other) => {
2
+ if (one.length !== other.length)
3
+ return false;
4
+ for (let at = 0; at < one.length; at += 1) {
5
+ if (one[at] !== other[at])
6
+ return false;
7
+ }
8
+ return true;
9
+ };
10
+ /**
11
+ * Merges pictures that follow each other and show the same thing into one that stays longer.
12
+ *
13
+ * A clip holds each frame for a second or more, so most of a recording is the same picture again and again;
14
+ * merged, the file carries each still once.
15
+ *
16
+ * @param pictures - The pictures, in order.
17
+ * @returns The pictures with each run of identical ones made one, its delay the sum of theirs.
18
+ */
19
+ export default function mergeStills(pictures) {
20
+ const merged = [];
21
+ for (const picture of pictures) {
22
+ const last = merged.at(-1);
23
+ if (last !== undefined && isSame(last.rgba, picture.rgba)) {
24
+ last.delay += picture.delay;
25
+ }
26
+ else {
27
+ merged.push({ rgba: picture.rgba, delay: picture.delay });
28
+ }
29
+ }
30
+ return merged;
31
+ }
32
+ //# sourceMappingURL=mergeStills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeStills.js","sourceRoot":"","sources":["../../../../src/lib/gif/mergeStills.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,CAAC,GAAoB,EAAE,KAAsB,EAAW,EAAE;IACvE,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9C,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAC1C,IAAI,GAAG,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,QAAmB;IACrD,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { PALETTE_SIZE } from "./constants.js";
2
+ /** A colour reduced to five bits per channel: near colours share a key, so they are counted together. */
3
+ const keyOf = (red, green, blue) => ((red >> 3) << 10) | ((green >> 3) << 5) | (blue >> 3);
4
+ /**
5
+ * Reduces pictures to one shared palette of 256 colours: the colours used most across all of them. A colour
6
+ * that did not make the palette takes the nearest one that did.
7
+ *
8
+ * An interface is drawn in few colours, so its commonest ones cover it; what is lost is the rarest shades of
9
+ * its smoothed edges. Transparent pixels are read as their colour, since a GIF frame here is always opaque.
10
+ *
11
+ * @param pictures - The pictures, all of one size.
12
+ * @returns The palette, and each picture as indices into it.
13
+ */
14
+ export default function quantizePictures(pictures) {
15
+ const counts = new Map();
16
+ const first = new Map();
17
+ for (const picture of pictures) {
18
+ const { rgba } = picture;
19
+ for (let at = 0; at < rgba.length; at += 4) {
20
+ const red = rgba[at];
21
+ const green = rgba[at + 1];
22
+ const blue = rgba[at + 2];
23
+ const key = keyOf(red, green, blue);
24
+ const count = counts.get(key);
25
+ if (count === undefined)
26
+ first.set(key, [red, green, blue]);
27
+ counts.set(key, (count ?? 0) + 1);
28
+ }
29
+ }
30
+ const kept = Array.from(counts.entries())
31
+ .sort((one, other) => other[1] - one[1])
32
+ .slice(0, PALETTE_SIZE)
33
+ .map(([key]) => key);
34
+ const palette = new Uint8Array(PALETTE_SIZE * 3);
35
+ const indexOf = new Map();
36
+ kept.forEach((key, index) => {
37
+ palette.set(first.get(key), index * 3);
38
+ indexOf.set(key, index);
39
+ });
40
+ // The nearest kept colour, for a colour that was too rare to keep. Found once per colour, then remembered.
41
+ const nearest = (red, green, blue) => {
42
+ let best = 0;
43
+ let least = Number.POSITIVE_INFINITY;
44
+ for (let index = 0; index < kept.length; index += 1) {
45
+ const far = (palette[index * 3] - red) ** 2 +
46
+ (palette[index * 3 + 1] - green) ** 2 +
47
+ (palette[index * 3 + 2] - blue) ** 2;
48
+ if (far < least) {
49
+ least = far;
50
+ best = index;
51
+ }
52
+ }
53
+ return best;
54
+ };
55
+ return {
56
+ palette,
57
+ pictures: pictures.map(({ rgba, delay }) => {
58
+ const indices = new Uint8Array(rgba.length / 4);
59
+ for (let at = 0; at < indices.length; at += 1) {
60
+ const red = rgba[at * 4];
61
+ const green = rgba[at * 4 + 1];
62
+ const blue = rgba[at * 4 + 2];
63
+ const key = keyOf(red, green, blue);
64
+ let index = indexOf.get(key);
65
+ if (index === undefined) {
66
+ index = nearest(red, green, blue);
67
+ indexOf.set(key, index);
68
+ }
69
+ indices[at] = index;
70
+ }
71
+ return { indices, delay };
72
+ }),
73
+ };
74
+ }
75
+ //# sourceMappingURL=quantizePictures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quantizePictures.js","sourceRoot":"","sources":["../../../../src/lib/gif/quantizePictures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,yGAAyG;AACzG,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,IAAY,EAAU,EAAE,CACjE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,QAAmB;IAC1D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoC,CAAC;IAC1D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACzB,KAAK,IAAI,EAAE,GAAG,CAAC,E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AAM,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAW,CAAC;gBACzC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAW,CAAC;gBACxC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;gBACpC,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC1B,CAAC;gBACD,OAAO,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/gif/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from "./cast/index.js";
2
+ export * from "./player/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /** How far into a click the pointer has reached its target and presses it. */
2
+ export const CLICK_PRESS = 0.6;
3
+ /** How far into a tap the finger is down. */
4
+ export const TAP_PRESS = 0.35;
5
+ /** How far into a click or a tap the press is let go. */
6
+ export const PRESS_RELEASE = 0.8;
7
+ /** How far along its way the pointer still counts as over what it is leaving. */
8
+ export const HOVER_LEAVES = 0.2;
9
+ /** How far along its way the pointer counts as over what it is going to. */
10
+ export const HOVER_ARRIVES = 0.8;
11
+ /** How far into a key's press a key that takes a letter back has taken it. */
12
+ export const KEY_ERASES = 0.45;
13
+ /** How far into a key's step the key goes down, and how far it comes back up. */
14
+ export const KEY_DOWN = 0.3;
15
+ export const KEY_UP = 0.6;
16
+ /** How long the keys of a run stay after the last one was pressed, in milliseconds, before they fade. */
17
+ export const KEY_LINGER = 1500;
18
+ /** How long a run of keys takes to fade, in milliseconds: after its linger, or once a step that is not a key starts. */
19
+ export const KEY_RUN_FADE = 400;
20
+ /** How much fainter each earlier key of a run is than the one after it, and the faintest any is shown. */
21
+ export const KEY_AGE_FADE = 0.35;
22
+ export const KEY_FAINTEST = 0.2;
23
+ /** How many keys of a run are shown at most, the newest among them. */
24
+ export const KEYS_IN_RUN = 4;
25
+ /** The keys that take back the letter before the end of the line, by their name in lower case. */
26
+ export const ERASING_KEYS = ["backspace"];
27
+ /** How long a frame takes to come to full strength after a cut, in milliseconds. */
28
+ export const CUT_FADE = 160;
29
+ /** How long the name of an interaction takes to fade once its frame has come, in milliseconds. */
30
+ export const PATTERN_FADE = 350;
31
+ /** How far a scroll moves its content when a step does not say, in pixels; negative moves it up. */
32
+ export const DEFAULT_SCROLL = -140;
33
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/moment/constants.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAE9B,yDAAyD;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,iFAAiF;AACjF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;AAE1B,yGAAyG;AACzG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,wHAAwH;AACxH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,0GAA0G;AAC1G,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAE7B,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,WAAW,CAAC,CAAC;AAE7D,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE5B,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,oGAAoG;AACpG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { SYMBOLS } from "../cast/index.js";
2
+ /**
3
+ * Names an interaction for the strip under a clip: its kind, and what tells it from others of its kind.
4
+ *
5
+ * @param step - The interaction.
6
+ * @returns The name, such as `Tap`, `Key · Enter` or `Slide · all the way to the end`; empty for a wait.
7
+ */
8
+ export default function describeAction(step) {
9
+ if (step.do === "wait")
10
+ return "";
11
+ const name = SYMBOLS[step.do][0];
12
+ if (step.do === "slide") {
13
+ const depth = step.depth === "deep" ? "all the way" : "a little";
14
+ return `${name} · ${depth} to the ${step.to === "end" ? "end" : "start"}`;
15
+ }
16
+ if (step.do === "key")
17
+ return `${name} · ${step.k ?? ""}`;
18
+ return name;
19
+ }
20
+ //# sourceMappingURL=describeAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeAction.js","sourceRoot":"","sources":["../../../../src/lib/moment/describeAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAgB;IACrD,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM;QAAE,OAAO,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC;QACjE,OAAO,GAAG,IAAI,MAAM,KAAK,WAAW,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK;QAAE,OAAO,GAAG,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { KEY_AGE_FADE, KEY_DOWN, KEY_FAINTEST, KEY_LINGER, KEY_RUN_FADE, KEY_UP, KEYS_IN_RUN, } from "./constants.js";
2
+ import takeSpan from "./takeSpan.js";
3
+ const isKey = (step) => step !== undefined && !("frame" in step) && step.do === "key";
4
+ /**
5
+ * Describes the run of named keys a sign shows at one moment: the keys pressed one after another up to now,
6
+ * so that one pressed a moment ago can still be read while the next one comes.
7
+ *
8
+ * The newest key comes in as its step starts and stays; each earlier one is fainter by its age. The run fades
9
+ * once a step that is not a key starts, or once no key has been pressed for a while, whichever comes first.
10
+ *
11
+ * @param timeline - The scene laid out in time.
12
+ * @param index - The step in view.
13
+ * @param elapsed - How far into it, in milliseconds.
14
+ * @returns The run, or nothing when no key is shown.
15
+ */
16
+ export default function describeKeyRun(timeline, index, elapsed) {
17
+ const { steps, starts, durations } = timeline;
18
+ const during = isKey(steps[index]);
19
+ const newest = during ? index : index - 1;
20
+ if (!isKey(steps[newest]))
21
+ return undefined;
22
+ let start = newest;
23
+ while (start > 0 && isKey(steps[start - 1]))
24
+ start -= 1;
25
+ const now = starts[index] + elapsed;
26
+ const pressedAt = (step) => starts[step] + durations[step] * KEY_DOWN;
27
+ const progress = during ? elapsed / durations[index] : 1;
28
+ // The last key of the run that has been pressed by now: the newest, or while it is still coming, the one before.
29
+ const last = during && progress < KEY_DOWN ? newest - 1 : newest;
30
+ const lingered = last < start
31
+ ? 0
32
+ : takeSpan(now - pressedAt(last), KEY_LINGER, KEY_LINGER + KEY_RUN_FADE);
33
+ const ended = during ? 0 : takeSpan(elapsed, 0, KEY_RUN_FADE);
34
+ const strength = 1 - Math.max(lingered, ended);
35
+ if (strength <= 0)
36
+ return undefined;
37
+ const caps = [];
38
+ for (let step = Math.max(start, newest - KEYS_IN_RUN + 1); step <= newest; step += 1) {
39
+ const age = newest - step;
40
+ const coming = during && age === 0;
41
+ const own = coming
42
+ ? takeSpan(progress, 0, 0.15)
43
+ : Math.max(KEY_FAINTEST, 1 - KEY_AGE_FADE * age);
44
+ const key = steps[step];
45
+ caps.push({
46
+ label: key.k ?? "",
47
+ down: coming && progress > KEY_DOWN && progress < KEY_UP,
48
+ opacity: own * strength,
49
+ });
50
+ }
51
+ return { kind: "keys", caps };
52
+ }
53
+ //# sourceMappingURL=describeKeyRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeKeyRun.js","sourceRoot":"","sources":["../../../../src/lib/moment/describeKeyRun.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,YAAY,EACZ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