canvas-recorder-lib 0.5.0 → 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 (317) hide show
  1. package/BREAKING-CHANGES.md +18 -0
  2. package/README.md +112 -20
  3. package/dev/audio-builder.ts +4 -2
  4. package/dev/canvas-recorder.css +59 -0
  5. package/dev/canvas-recorder.ts +679 -51
  6. package/dev/delay-files.ts +1 -1
  7. package/dev/font-utils.ts +8 -1
  8. package/dev/format-editor.ts +734 -0
  9. package/dev/format-string.ts +110 -0
  10. package/dev/local-file-row.ts +107 -0
  11. package/dev/multi-text-dialog.ts +360 -0
  12. package/dev/multi-text-panel.ts +11 -0
  13. package/dev/player-body.ts +86 -6
  14. package/dev/rect-snap.ts +9 -9
  15. package/dev/slide-panel.ts +1 -1
  16. package/dev/split-dialog.ts +13 -2
  17. package/dev/static-image-panel.ts +35 -5
  18. package/dev/timeline-display.ts +50 -5
  19. package/dev/transcripts.ts +5 -3
  20. package/dev/video-clip-panel.ts +201 -15
  21. package/dist/dev/audio-builder.d.ts +1 -1
  22. package/dist/dev/audio-builder.d.ts.map +1 -1
  23. package/dist/dev/audio-builder.js +3 -2
  24. package/dist/dev/audio-builder.js.map +1 -1
  25. package/dist/dev/canvas-recorder.css +59 -0
  26. package/dist/dev/canvas-recorder.js +612 -50
  27. package/dist/dev/canvas-recorder.js.map +1 -1
  28. package/dist/dev/delay-files.js +1 -1
  29. package/dist/dev/delay-files.js.map +1 -1
  30. package/dist/dev/font-utils.d.ts.map +1 -1
  31. package/dist/dev/font-utils.js +9 -1
  32. package/dist/dev/font-utils.js.map +1 -1
  33. package/dist/dev/format-editor.d.ts +75 -0
  34. package/dist/dev/format-editor.d.ts.map +1 -0
  35. package/dist/dev/format-editor.js +642 -0
  36. package/dist/dev/format-editor.js.map +1 -0
  37. package/dist/dev/format-string.d.ts +62 -0
  38. package/dist/dev/format-string.d.ts.map +1 -0
  39. package/dist/dev/format-string.js +86 -0
  40. package/dist/dev/format-string.js.map +1 -0
  41. package/dist/dev/local-file-row.d.ts +22 -0
  42. package/dist/dev/local-file-row.d.ts.map +1 -0
  43. package/dist/dev/local-file-row.js +84 -0
  44. package/dist/dev/local-file-row.js.map +1 -0
  45. package/dist/dev/multi-text-dialog.d.ts +30 -0
  46. package/dist/dev/multi-text-dialog.d.ts.map +1 -0
  47. package/dist/dev/multi-text-dialog.js +297 -0
  48. package/dist/dev/multi-text-dialog.js.map +1 -0
  49. package/dist/dev/multi-text-panel.d.ts +2 -0
  50. package/dist/dev/multi-text-panel.d.ts.map +1 -1
  51. package/dist/dev/multi-text-panel.js +4 -0
  52. package/dist/dev/multi-text-panel.js.map +1 -1
  53. package/dist/dev/player-body.d.ts +1 -1
  54. package/dist/dev/player-body.d.ts.map +1 -1
  55. package/dist/dev/player-body.js +86 -6
  56. package/dist/dev/player-body.js.map +1 -1
  57. package/dist/dev/rect-snap.d.ts +1 -1
  58. package/dist/dev/rect-snap.js +7 -7
  59. package/dist/dev/rect-snap.js.map +1 -1
  60. package/dist/dev/slide-panel.d.ts +1 -1
  61. package/dist/dev/slide-panel.d.ts.map +1 -1
  62. package/dist/dev/slide-panel.js +1 -1
  63. package/dist/dev/slide-panel.js.map +1 -1
  64. package/dist/dev/split-dialog.d.ts.map +1 -1
  65. package/dist/dev/split-dialog.js +14 -2
  66. package/dist/dev/split-dialog.js.map +1 -1
  67. package/dist/dev/static-image-panel.d.ts +2 -0
  68. package/dist/dev/static-image-panel.d.ts.map +1 -1
  69. package/dist/dev/static-image-panel.js +29 -5
  70. package/dist/dev/static-image-panel.js.map +1 -1
  71. package/dist/dev/timeline-display.d.ts +23 -2
  72. package/dist/dev/timeline-display.d.ts.map +1 -1
  73. package/dist/dev/timeline-display.js +47 -5
  74. package/dist/dev/timeline-display.js.map +1 -1
  75. package/dist/dev/transcripts.d.ts.map +1 -1
  76. package/dist/dev/transcripts.js +5 -3
  77. package/dist/dev/transcripts.js.map +1 -1
  78. package/dist/dev/video-clip-panel.d.ts +8 -0
  79. package/dist/dev/video-clip-panel.d.ts.map +1 -1
  80. package/dist/dev/video-clip-panel.js +175 -9
  81. package/dist/dev/video-clip-panel.js.map +1 -1
  82. package/dist/lib/index.d.ts +3 -0
  83. package/dist/lib/index.d.ts.map +1 -1
  84. package/dist/lib/index.js +3 -0
  85. package/dist/lib/index.js.map +1 -1
  86. package/dist/lib/main-control.d.ts +50 -4
  87. package/dist/lib/main-control.d.ts.map +1 -1
  88. package/dist/lib/main-control.js +94 -12
  89. package/dist/lib/main-control.js.map +1 -1
  90. package/dist/src/binary-search.js +1 -1
  91. package/dist/src/binary-search.js.map +1 -1
  92. package/dist/src/corner-rounder.d.ts +17 -0
  93. package/dist/src/corner-rounder.d.ts.map +1 -0
  94. package/dist/src/corner-rounder.js +89 -0
  95. package/dist/src/corner-rounder.js.map +1 -0
  96. package/dist/src/cross-fade.d.ts +1 -1
  97. package/dist/src/cross-fade.d.ts.map +1 -1
  98. package/dist/src/cross-fade.js +3 -3
  99. package/dist/src/cross-fade.js.map +1 -1
  100. package/dist/src/fancy-text.d.ts +116 -0
  101. package/dist/src/fancy-text.d.ts.map +1 -0
  102. package/dist/src/fancy-text.js +211 -0
  103. package/dist/src/fancy-text.js.map +1 -0
  104. package/dist/src/glib/letters-base.d.ts +1 -1
  105. package/dist/src/glib/letters-base.d.ts.map +1 -1
  106. package/dist/src/glib/letters-base.js +4 -3
  107. package/dist/src/glib/letters-base.js.map +1 -1
  108. package/dist/src/glib/line-font.d.ts +2 -2
  109. package/dist/src/glib/line-font.d.ts.map +1 -1
  110. package/dist/src/glib/line-font.js +2 -2
  111. package/dist/src/glib/line-font.js.map +1 -1
  112. package/dist/src/glib/paragraph-layout.d.ts +2 -2
  113. package/dist/src/glib/paragraph-layout.d.ts.map +1 -1
  114. package/dist/src/glib/paragraph-layout.js +1 -1
  115. package/dist/src/glib/paragraph-layout.js.map +1 -1
  116. package/dist/src/glib/path-shape-splitter.d.ts +1 -1
  117. package/dist/src/glib/path-shape-splitter.d.ts.map +1 -1
  118. package/dist/src/glib/path-shape-splitter.js +1 -1
  119. package/dist/src/glib/path-shape-splitter.js.map +1 -1
  120. package/dist/src/glib/path-shape.js +2 -2
  121. package/dist/src/glib/path-shape.js.map +1 -1
  122. package/dist/src/interpolate.d.ts +2 -2
  123. package/dist/src/interpolate.d.ts.map +1 -1
  124. package/dist/src/interpolate.js +1 -1
  125. package/dist/src/interpolate.js.map +1 -1
  126. package/dist/src/lattice.d.ts +1 -1
  127. package/dist/src/lattice.d.ts.map +1 -1
  128. package/dist/src/local-files.d.ts +129 -0
  129. package/dist/src/local-files.d.ts.map +1 -0
  130. package/dist/src/local-files.js +327 -0
  131. package/dist/src/local-files.js.map +1 -0
  132. package/dist/src/morph-animation.d.ts +1 -1
  133. package/dist/src/morph-animation.d.ts.map +1 -1
  134. package/dist/src/morph-animation.js +2 -2
  135. package/dist/src/morph-animation.js.map +1 -1
  136. package/dist/src/peano-fourier/fourier-shared.d.ts +1 -1
  137. package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
  138. package/dist/src/peano-fourier/fourier-shared.js +17 -4
  139. package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
  140. package/dist/src/schedule-helper.d.ts +4 -4
  141. package/dist/src/schedule-helper.d.ts.map +1 -1
  142. package/dist/src/schedule-helper.js +2 -2
  143. package/dist/src/schedule-helper.js.map +1 -1
  144. package/dist/src/showable.d.ts +36 -4
  145. package/dist/src/showable.d.ts.map +1 -1
  146. package/dist/src/showable.js +37 -1
  147. package/dist/src/showable.js.map +1 -1
  148. package/dist/src/slide-components/arrow.d.ts +4 -4
  149. package/dist/src/slide-components/arrow.d.ts.map +1 -1
  150. package/dist/src/slide-components/arrow.js +2 -2
  151. package/dist/src/slide-components/arrow.js.map +1 -1
  152. package/dist/src/slide-components/cross-fade-transition.d.ts +3 -3
  153. package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
  154. package/dist/src/slide-components/cross-fade-transition.js +3 -3
  155. package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
  156. package/dist/src/slide-components/duration-agnostic.d.ts +3 -3
  157. package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
  158. package/dist/src/slide-components/duration-agnostic.js +1 -1
  159. package/dist/src/slide-components/duration-agnostic.js.map +1 -1
  160. package/dist/src/slide-components/fixed-duration.d.ts +1 -1
  161. package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
  162. package/dist/src/slide-components/fixed-duration.js +1 -1
  163. package/dist/src/slide-components/fixed-duration.js.map +1 -1
  164. package/dist/src/slide-components/fourier.d.ts +6 -6
  165. package/dist/src/slide-components/fourier.d.ts.map +1 -1
  166. package/dist/src/slide-components/fourier.js +6 -6
  167. package/dist/src/slide-components/fourier.js.map +1 -1
  168. package/dist/src/slide-components/frame-counter.d.ts +2 -2
  169. package/dist/src/slide-components/frame-counter.d.ts.map +1 -1
  170. package/dist/src/slide-components/frame-counter.js +1 -1
  171. package/dist/src/slide-components/frame-counter.js.map +1 -1
  172. package/dist/src/slide-components/function-graph.d.ts +2 -2
  173. package/dist/src/slide-components/function-graph.d.ts.map +1 -1
  174. package/dist/src/slide-components/function-graph.js +3 -3
  175. package/dist/src/slide-components/function-graph.js.map +1 -1
  176. package/dist/src/slide-components/halftone-shadow.d.ts +4 -4
  177. package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
  178. package/dist/src/slide-components/halftone-shadow.js +2 -2
  179. package/dist/src/slide-components/halftone-shadow.js.map +1 -1
  180. package/dist/src/slide-components/handwriting-effect.d.ts +5 -5
  181. package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
  182. package/dist/src/slide-components/handwriting-effect.js +5 -5
  183. package/dist/src/slide-components/handwriting-effect.js.map +1 -1
  184. package/dist/src/slide-components/hold.d.ts +3 -3
  185. package/dist/src/slide-components/hold.d.ts.map +1 -1
  186. package/dist/src/slide-components/hold.js +3 -3
  187. package/dist/src/slide-components/hold.js.map +1 -1
  188. package/dist/src/slide-components/image.d.ts +3 -3
  189. package/dist/src/slide-components/image.d.ts.map +1 -1
  190. package/dist/src/slide-components/image.js +3 -3
  191. package/dist/src/slide-components/image.js.map +1 -1
  192. package/dist/src/slide-components/in-parallel.d.ts +3 -3
  193. package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
  194. package/dist/src/slide-components/in-parallel.js +2 -2
  195. package/dist/src/slide-components/in-parallel.js.map +1 -1
  196. package/dist/src/slide-components/in-series.d.ts +4 -4
  197. package/dist/src/slide-components/in-series.d.ts.map +1 -1
  198. package/dist/src/slide-components/in-series.js +5 -1
  199. package/dist/src/slide-components/in-series.js.map +1 -1
  200. package/dist/src/slide-components/live-duration.d.ts +1 -1
  201. package/dist/src/slide-components/live-duration.d.ts.map +1 -1
  202. package/dist/src/slide-components/live-duration.js +1 -1
  203. package/dist/src/slide-components/live-duration.js.map +1 -1
  204. package/dist/src/slide-components/multi-text.d.ts +76 -15
  205. package/dist/src/slide-components/multi-text.d.ts.map +1 -1
  206. package/dist/src/slide-components/multi-text.js +170 -25
  207. package/dist/src/slide-components/multi-text.js.map +1 -1
  208. package/dist/src/slide-components/rectangle.d.ts +3 -3
  209. package/dist/src/slide-components/rectangle.d.ts.map +1 -1
  210. package/dist/src/slide-components/rectangle.js +1 -1
  211. package/dist/src/slide-components/rectangle.js.map +1 -1
  212. package/dist/src/slide-components/registry.d.ts +1 -1
  213. package/dist/src/slide-components/registry.d.ts.map +1 -1
  214. package/dist/src/slide-components/registry.js +18 -18
  215. package/dist/src/slide-components/registry.js.map +1 -1
  216. package/dist/src/slide-components/serialize.d.ts +1 -1
  217. package/dist/src/slide-components/serialize.d.ts.map +1 -1
  218. package/dist/src/slide-components/serialize.js +2 -2
  219. package/dist/src/slide-components/serialize.js.map +1 -1
  220. package/dist/src/slide-components/show-error.js +2 -2
  221. package/dist/src/slide-components/show-error.js.map +1 -1
  222. package/dist/src/slide-components/simple-text.d.ts +4 -4
  223. package/dist/src/slide-components/simple-text.d.ts.map +1 -1
  224. package/dist/src/slide-components/simple-text.js +4 -4
  225. package/dist/src/slide-components/simple-text.js.map +1 -1
  226. package/dist/src/slide-components/slide-component.d.ts +5 -5
  227. package/dist/src/slide-components/slide-component.d.ts.map +1 -1
  228. package/dist/src/slide-components/slide-component.js +4 -4
  229. package/dist/src/slide-components/slide-component.js.map +1 -1
  230. package/dist/src/slide-components/slide-left.d.ts +3 -3
  231. package/dist/src/slide-components/slide-left.d.ts.map +1 -1
  232. package/dist/src/slide-components/slide-left.js +3 -3
  233. package/dist/src/slide-components/slide-left.js.map +1 -1
  234. package/dist/src/slide-components/split-video-clip.d.ts +2 -2
  235. package/dist/src/slide-components/split-video-clip.d.ts.map +1 -1
  236. package/dist/src/slide-components/split-video-clip.js +3 -3
  237. package/dist/src/slide-components/split-video-clip.js.map +1 -1
  238. package/dist/src/slide-components/text-effect.d.ts +2 -2
  239. package/dist/src/slide-components/text-effect.d.ts.map +1 -1
  240. package/dist/src/slide-components/traditional-text.d.ts +4 -4
  241. package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
  242. package/dist/src/slide-components/traditional-text.js +3 -3
  243. package/dist/src/slide-components/traditional-text.js.map +1 -1
  244. package/dist/src/slide-components/video-clip.d.ts +17 -5
  245. package/dist/src/slide-components/video-clip.d.ts.map +1 -1
  246. package/dist/src/slide-components/video-clip.js +52 -11
  247. package/dist/src/slide-components/video-clip.js.map +1 -1
  248. package/dist/src/slide-components/video-info.d.ts +11 -11
  249. package/dist/src/slide-components/video-info.d.ts.map +1 -1
  250. package/dist/src/slide-components/video-info.js +32 -21
  251. package/dist/src/slide-components/video-info.js.map +1 -1
  252. package/dist/src/slow-image-sources.d.ts +7 -1
  253. package/dist/src/slow-image-sources.d.ts.map +1 -1
  254. package/dist/src/slow-image-sources.js +36 -5
  255. package/dist/src/slow-image-sources.js.map +1 -1
  256. package/dist/src/snapshot.d.ts +2 -2
  257. package/dist/src/snapshot.d.ts.map +1 -1
  258. package/dist/src/snapshot.js +4 -4
  259. package/dist/src/snapshot.js.map +1 -1
  260. package/dist/src/stroke-colors.d.ts +1 -1
  261. package/dist/src/stroke-colors.d.ts.map +1 -1
  262. package/dist/src/stroke-colors.js +4 -4
  263. package/dist/src/stroke-colors.js.map +1 -1
  264. package/dist/src/utility.d.ts +3 -4
  265. package/dist/src/utility.d.ts.map +1 -1
  266. package/dist/src/utility.js +4 -4
  267. package/dist/src/utility.js.map +1 -1
  268. package/lib/index.ts +3 -0
  269. package/lib/main-control.ts +119 -12
  270. package/package.json +7 -5
  271. package/src/binary-search.ts +2 -2
  272. package/src/corner-rounder.ts +128 -0
  273. package/src/cross-fade.ts +3 -3
  274. package/src/fancy-text.ts +255 -0
  275. package/src/glib/letters-base.ts +4 -3
  276. package/src/glib/line-font.ts +2 -2
  277. package/src/glib/paragraph-layout.ts +2 -2
  278. package/src/glib/path-shape-splitter.ts +1 -1
  279. package/src/glib/path-shape.ts +2 -2
  280. package/src/interpolate.ts +3 -3
  281. package/src/lattice.ts +1 -1
  282. package/src/local-files.ts +389 -0
  283. package/src/morph-animation.ts +2 -2
  284. package/src/peano-fourier/fourier-shared.ts +17 -4
  285. package/src/schedule-helper.ts +4 -4
  286. package/src/showable.ts +54 -4
  287. package/src/slide-components/arrow.ts +4 -4
  288. package/src/slide-components/cross-fade-transition.ts +4 -4
  289. package/src/slide-components/duration-agnostic.ts +3 -3
  290. package/src/slide-components/fixed-duration.ts +1 -1
  291. package/src/slide-components/fourier.ts +9 -9
  292. package/src/slide-components/frame-counter.ts +2 -2
  293. package/src/slide-components/function-graph.ts +4 -4
  294. package/src/slide-components/halftone-shadow.ts +4 -4
  295. package/src/slide-components/handwriting-effect.ts +7 -7
  296. package/src/slide-components/hold.ts +4 -4
  297. package/src/slide-components/image.ts +5 -5
  298. package/src/slide-components/in-parallel.ts +4 -4
  299. package/src/slide-components/in-series.ts +7 -4
  300. package/src/slide-components/live-duration.ts +1 -1
  301. package/src/slide-components/multi-text.ts +195 -30
  302. package/src/slide-components/rectangle.ts +3 -3
  303. package/src/slide-components/registry.ts +19 -19
  304. package/src/slide-components/serialize.ts +2 -2
  305. package/src/slide-components/show-error.ts +2 -2
  306. package/src/slide-components/simple-text.ts +7 -7
  307. package/src/slide-components/slide-component.ts +7 -7
  308. package/src/slide-components/slide-left.ts +4 -4
  309. package/src/slide-components/split-video-clip.ts +4 -4
  310. package/src/slide-components/text-effect.ts +2 -2
  311. package/src/slide-components/traditional-text.ts +5 -5
  312. package/src/slide-components/video-clip.ts +64 -13
  313. package/src/slide-components/video-info.ts +33 -21
  314. package/src/slow-image-sources.ts +38 -6
  315. package/src/snapshot.ts +4 -4
  316. package/src/stroke-colors.ts +4 -4
  317. package/src/utility.ts +5 -5
@@ -1,4 +1,4 @@
1
- // Generated by scripts/import-from-canvas-recorder.mjs from canvas-recorder.html. Do not edit.
1
+ // Originally generated from canvas-recorder's canvas-recorder.html. This is the master copy now.
2
2
 
3
3
  /** The contents of the player's `<body>`. {@link canvasRecorder.start} puts this in the page. */
4
4
  export const playerBodyHtml = `
@@ -16,6 +16,29 @@ export const playerBodyHtml = `
16
16
  <option value="2.00">200%</option>
17
17
  </select>
18
18
  </label>
19
+ <span
20
+ id="videoSizeControls"
21
+ style="white-space: nowrap"
22
+ title="The size of the video. Pixels: the saved file. Units: the coordinates everything is drawn in. Remembered for this video."
23
+ >Size:
24
+ <input type="number" id="videoPixelWidth" min="2" step="2" style="width: 4.5em" />
25
+ ×
26
+ <input type="number" id="videoPixelHeight" min="2" step="2" style="width: 4.5em" />
27
+ px,
28
+ <input type="number" id="videoUnitWidth" min="0" step="any" style="width: 3.5em" />
29
+ ×
30
+ <input type="number" id="videoUnitHeight" min="0" step="any" style="width: 3.5em" />
31
+ units
32
+ <span id="videoSizeWarning" style="color: #a06000"></span>
33
+ </span>
34
+ <button
35
+ type="button"
36
+ id="localFilesBtn"
37
+ hidden
38
+ title="Some of this video's files are on your computer, and the browser needs your OK before it reads them again."
39
+ >
40
+ 🔓 Allow local files
41
+ </button>
19
42
  <button type="button" id="loadJsonTestBtn">📂 Import</button>
20
43
  <!-- Each status is outside its label: clicking inside a label
21
44
  toggles the checkbox, and a status can hold buttons. -->
@@ -100,7 +123,12 @@ export const playerBodyHtml = `
100
123
  />Repeat</label
101
124
  >)&nbsp;</span
102
125
  >
103
- <input type="number" id="playPositionSeconds" value="0" />
126
+ <input
127
+ type="number"
128
+ id="playPositionSeconds"
129
+ value="0"
130
+ title="The play position, in seconds. Option-← and Option-→ step one frame."
131
+ />
104
132
  <input type="range" id="playPositionRange" value="0" step="any" />
105
133
  </div>
106
134
  </fieldset>
@@ -177,10 +205,16 @@ export const playerBodyHtml = `
177
205
  <button id="recordJustSound">Record Just Sound</button>
178
206
  <div id="info"><i>status goes here</i>...</div>
179
207
  </div>
180
- <p>
181
- Hot keys: ⌥Space to play/pause. ⌥B to go back 5 seconds and play. ⌥0
182
- to jump to the start of the current section. Alt instead of ⌥ on a PC.
183
- </p>
208
+ <div style="margin: 1em 0">
209
+ Hot keys:
210
+ <ul style="margin: 0">
211
+ <li>⌥Space to play or pause.</li>
212
+ <li>⌥B to go back 5 seconds and play.</li>
213
+ <li>⌥0 to jump to the start of the current section.</li>
214
+ <li>⌥← and ⌥→ to step one frame back or forward.</li>
215
+ </ul>
216
+ Alt instead of ⌥ on a PC.
217
+ </div>
184
218
  <br />
185
219
  <h1>Debug Log</h1>
186
220
  <button id="debugLogClearBtn" type="button">Clear</button>
@@ -343,6 +377,44 @@ export const playerBodyHtml = `
343
377
  />
344
378
  </label>
345
379
  </div>
380
+ <div style="margin-bottom: 0.6em">
381
+ <label
382
+ >Size:
383
+ <input
384
+ type="number"
385
+ id="saveWidth"
386
+ min="2"
387
+ step="2"
388
+ style="width: 6em"
389
+ />
390
+ </label>
391
+ ×
392
+ <label
393
+ ><input
394
+ type="number"
395
+ id="saveHeight"
396
+ min="2"
397
+ step="2"
398
+ style="width: 6em"
399
+ />
400
+ px</label
401
+ >
402
+ &nbsp;
403
+ <label
404
+ title="Change the other number to match, keeping the video's shape. Uncheck to stretch or squish the picture."
405
+ ><input type="checkbox" id="saveKeepAspect" checked /> Keep aspect
406
+ ratio</label
407
+ >
408
+ &nbsp;
409
+ <button
410
+ type="button"
411
+ id="saveVideoSizeBtn"
412
+ title="Use the video's own size."
413
+ >
414
+ Video size
415
+ </button>
416
+ <div id="saveSizeNote" style="font-size: 0.85em; min-height: 1.2em"></div>
417
+ </div>
346
418
  <table style="margin-bottom: 0.75em; border-collapse: collapse">
347
419
  <tr>
348
420
  <td>Start:</td>
@@ -373,6 +445,14 @@ export const playerBodyHtml = `
373
445
  ></td>
374
446
  </tr>
375
447
  </table>
448
+ <div
449
+ id="saveLocalFilesRow"
450
+ hidden
451
+ style="margin-bottom: 0.6em; color: #a06000"
452
+ >
453
+ <span id="saveLocalFilesNote"></span>
454
+ <button type="button" id="saveLocalFilesBtn">🔓 Allow</button>
455
+ </div>
376
456
  <div>
377
457
  <button type="button" id="saveOkBtn">OK — Choose File</button>
378
458
  &nbsp;
package/dev/rect-snap.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ReadOnlyRect } from "phil-lib/misc";
2
2
  import {
3
- CANVAS_HEIGHT_UNITS,
4
- CANVAS_WIDTH_UNITS,
3
+ canvasHeightUnits,
4
+ canvasWidthUnits,
5
5
  } from "../src/slide-components/video-info.ts";
6
6
 
7
7
  /**
8
8
  * One button that moves or stretches a rectangle to the canvas.
9
9
  *
10
- * The canvas is taken to be the 16×9 the component draws into, which is true
10
+ * The canvas is taken to be the whole drawing area (see canvasRecorder.width), which is true
11
11
  * unless it sits inside a transformed parent like a Slide.
12
12
  */
13
13
  export type RectSnap = {
@@ -28,12 +28,12 @@ export const ALIGN_HORIZONTALLY: readonly RectSnap[] = [
28
28
  {
29
29
  text: "⇆",
30
30
  title: "Center horizontally on the canvas",
31
- place: (r) => ({ ...r, x: (CANVAS_WIDTH_UNITS - r.width) / 2 }),
31
+ place: (r) => ({ ...r, x: (canvasWidthUnits() - r.width) / 2 }),
32
32
  },
33
33
  {
34
34
  text: "⇥",
35
35
  title: "Move the right edge to the right of the canvas",
36
- place: (r) => ({ ...r, x: CANVAS_WIDTH_UNITS - r.width }),
36
+ place: (r) => ({ ...r, x: canvasWidthUnits() - r.width }),
37
37
  },
38
38
  ];
39
39
 
@@ -47,12 +47,12 @@ export const ALIGN_VERTICALLY: readonly RectSnap[] = [
47
47
  {
48
48
  text: "⇵",
49
49
  title: "Center vertically on the canvas",
50
- place: (r) => ({ ...r, y: (CANVAS_HEIGHT_UNITS - r.height) / 2 }),
50
+ place: (r) => ({ ...r, y: (canvasHeightUnits() - r.height) / 2 }),
51
51
  },
52
52
  {
53
53
  text: "⤓",
54
54
  title: "Move the bottom edge to the bottom of the canvas",
55
- place: (r) => ({ ...r, y: CANVAS_HEIGHT_UNITS - r.height }),
55
+ place: (r) => ({ ...r, y: canvasHeightUnits() - r.height }),
56
56
  },
57
57
  ];
58
58
 
@@ -61,12 +61,12 @@ export const STRETCH_TO_CANVAS: readonly RectSnap[] = [
61
61
  {
62
62
  text: "↔",
63
63
  title: "Stretch across the full width of the canvas",
64
- place: (r) => ({ ...r, x: 0, width: CANVAS_WIDTH_UNITS }),
64
+ place: (r) => ({ ...r, x: 0, width: canvasWidthUnits() }),
65
65
  },
66
66
  {
67
67
  text: "↕",
68
68
  title: "Stretch across the full height of the canvas",
69
- place: (r) => ({ ...r, y: 0, height: CANVAS_HEIGHT_UNITS }),
69
+ place: (r) => ({ ...r, y: 0, height: canvasHeightUnits() }),
70
70
  },
71
71
  ];
72
72
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SlideComponent,
3
3
  TRANSFORM_PLACEHOLDERS,
4
- } from "../src/slide-components/slide-component";
4
+ } from "../src/slide-components/slide-component.ts";
5
5
 
6
6
  /**
7
7
  * Build the Transform Info panel shown at the top of the schedule editor
@@ -395,9 +395,17 @@ export function askHowToSplitSound(options: {
395
395
  // MARK: Behavior
396
396
  const inside = (atMs: number) => atMs > 0 && atMs < lengthMs;
397
397
 
398
- /** The quiet moment between words nearest `atMs`, inside the clip, or `atMs` itself. */
398
+ /**
399
+ * `atMs`, moved to the nearest quiet moment between words if it's in the middle of one.
400
+ *
401
+ * Anywhere between one word's `cutAfterMs` and the next word's `cutBeforeMs` is already quiet,
402
+ * so a split there stays where it is. Snapping out of a long pause moved a split a whole second.
403
+ */
399
404
  function snapped(atMs: number): number {
400
405
  if (!snapInput.checked || !words?.length) return atMs;
406
+ const fileMs = startMsIntoClip + atMs;
407
+ const inWord = words.some((w) => w.cutBeforeMs < fileMs && fileMs < w.cutAfterMs);
408
+ if (!inWord) return atMs;
401
409
  let best = atMs;
402
410
  let bestDistance = Infinity;
403
411
  for (const word of words) {
@@ -448,8 +456,11 @@ export function askHowToSplitSound(options: {
448
456
  return;
449
457
  }
450
458
  const moved = Math.abs(atMs - typed) > 0.05;
459
+ const direction = atMs < typed ? "earlier" : "later";
451
460
  whereNote.textContent =
452
- (moved ? `Snapped to ${Math.round(atMs)} ms.` : "") + aroundWords(atMs);
461
+ (moved
462
+ ? `Snapped to ${Math.round(atMs)} ms, ${Math.round(Math.abs(atMs - typed))} ms ${direction}.`
463
+ : "") + aroundWords(atMs);
453
464
  whereNote.style.color = whereNote.textContent.includes("⚠") ? "#a06000" : "#555";
454
465
 
455
466
  const kept = keep();
@@ -5,16 +5,20 @@ import {
5
5
  centeredOnCanvas,
6
6
  maxFit,
7
7
  minCover,
8
- PIXELS_PER_UNIT,
8
+ pixelsPerUnit,
9
9
  preservePixels,
10
10
  sameCenter,
11
11
  shrinkToAspect,
12
12
  } from "../src/slide-components/video-info.ts";
13
13
  import { SingleImage } from "../src/slow-image-sources.ts";
14
14
  import { ALIGN_HORIZONTALLY, ALIGN_VERTICALLY, buildSnapRow } from "./rect-snap.ts";
15
+ import { buildLocalFileRow } from "./local-file-row.ts";
16
+ import { IMAGE_FILE_TYPES, onLocalFilesChange } from "../src/local-files.ts";
15
17
 
16
18
  /** What the panel needs from the Visual Editor. It never reaches into canvas-recorder.ts directly. */
17
19
  export type StaticImagePanelHooks = {
20
+ /** The URL was changed by a button here. Save, and rebuild the schedule editor so the URL field shows it. */
21
+ readonly urlChanged: () => void;
18
22
  /** A Dest Rect keyframe's value was replaced. Sync its number fields and on-canvas handles, and save. */
19
23
  readonly rectKeyframeChanged: (keyframe: Keyframe<ReadOnlyRect>) => void;
20
24
  /** The Dest Rect keyframe in ✎ edit mode, if there is one. */
@@ -51,6 +55,23 @@ export function buildStaticImagePanel(
51
55
  legend.textContent = "Image File";
52
56
  panel.append(legend);
53
57
 
58
+ panel.append(
59
+ buildLocalFileRow({
60
+ types: IMAGE_FILE_TYPES,
61
+ pickerId: "images",
62
+ startIn: "pictures",
63
+ currentUrl: () => component.urlSchedule.at(0),
64
+ choose(url) {
65
+ if (component.urlSchedule.schedule.length > 1) {
66
+ alert("URL has several keyframes. Type the file's URL into the one you want.\n\n" + url);
67
+ return;
68
+ }
69
+ component.urlSchedule.set(url);
70
+ hooks.urlChanged();
71
+ },
72
+ }),
73
+ );
74
+
54
75
  const line = (parent: HTMLElement, cssText = "") => {
55
76
  const div = document.createElement("div");
56
77
  div.style.cssText = cssText;
@@ -75,7 +96,7 @@ export function buildStaticImagePanel(
75
96
  const rectButtons = [
76
97
  {
77
98
  text: "Fit canvas",
78
- title: "As large as possible while the whole image stays on the 16×9 canvas. Centered.",
99
+ title: "As large as possible while the whole image stays on the canvas. Centered.",
79
100
  make: (size: Size) => centeredOnCanvas(maxFit(size.width, size.height)),
80
101
  },
81
102
  {
@@ -85,7 +106,7 @@ export function buildStaticImagePanel(
85
106
  },
86
107
  {
87
108
  text: "Native pixels",
88
- title: `One image pixel per output pixel at ${PIXELS_PER_UNIT} px/unit — pixel perfect. Keeps the rectangle's center.`,
109
+ title: `One image pixel per output pixel at ${pixelsPerUnit()} px/unit — pixel perfect. Keeps the rectangle's center.`,
89
110
  make: (size: Size, rect: ReadOnlyRect) =>
90
111
  sameCenter(preservePixels(size.width, size.height), rect),
91
112
  },
@@ -156,7 +177,7 @@ export function buildStaticImagePanel(
156
177
  // native resolution. Above 1 the image is being upscaled.
157
178
  const ratios = component.destRectSchedule.schedule.map(({ value }) => {
158
179
  const drawn = shrinkToAspect(value, size.width / size.height);
159
- return (drawn.width * PIXELS_PER_UNIT) / size.width;
180
+ return (drawn.width * pixelsPerUnit()) / size.width;
160
181
  });
161
182
  const lo = Math.min(...ratios);
162
183
  const hi = Math.max(...ratios);
@@ -196,7 +217,7 @@ export function buildStaticImagePanel(
196
217
  const url = component.urlSchedule.at(
197
218
  typeof target === "string" ? 0 : target.time,
198
219
  );
199
- if (url === (image?.url ?? "")) {
220
+ if (url === (image?.url ?? "") && !image?.worthRetrying) {
200
221
  // Same file. Only the Dest Rect may have changed.
201
222
  draw();
202
223
  return;
@@ -242,6 +263,15 @@ export function buildStaticImagePanel(
242
263
  });
243
264
  }
244
265
 
266
+ // Permission granted, or a file picked again: a file that failed may open now.
267
+ const stopListening = onLocalFilesChange(() => {
268
+ if (!panel.isConnected) {
269
+ stopListening();
270
+ return;
271
+ }
272
+ refresh();
273
+ });
274
+
245
275
  refresh();
246
276
  return {
247
277
  element: panel,
@@ -138,11 +138,33 @@ export class TimelineDisplay {
138
138
 
139
139
  // ── public API ─────────────────────────────────────────────────────────────
140
140
 
141
- /** Call when the chapter changes; resets zoom/pan to show the full chapter. */
142
- setChapterDuration(durationMs: number): void {
143
- this._durationMs = Math.max(durationMs, 1);
144
- this._viewStartMs = 0;
145
- this._viewEndMs = this._durationMs;
141
+ /** The chapter last passed to {@link setChapter}. */
142
+ private _chapter: object | undefined;
143
+
144
+ /**
145
+ * Call whenever the chapter, or its length, may have changed.
146
+ *
147
+ * A different chapter shows all of itself.
148
+ * The same chapter keeps the user's zoom and pan, so an edit like ✂ Split doesn't undo them.
149
+ * The exception: a view that showed the whole chapter keeps showing the whole chapter.
150
+ * @param chapter The chapter, by identity.
151
+ * @param durationMs Its length now.
152
+ */
153
+ setChapter(chapter: object, durationMs: number): void {
154
+ const newDurationMs = Math.max(durationMs, 1);
155
+ const showingAll =
156
+ this._viewStartMs <= 0 && this._viewEndMs >= this._durationMs;
157
+ if (chapter !== this._chapter || showingAll) {
158
+ this._viewStartMs = 0;
159
+ this._viewEndMs = newDurationMs;
160
+ } else if (this._viewStartMs >= newDurationMs) {
161
+ // The chapter got shorter than where the view starts. Keep the zoom; show its end.
162
+ const span = this._viewEndMs - this._viewStartMs;
163
+ this._viewStartMs = Math.max(0, newDurationMs - span);
164
+ this._viewEndMs = this._viewStartMs + span;
165
+ }
166
+ this._chapter = chapter;
167
+ this._durationMs = newDurationMs;
146
168
  this._draw();
147
169
  }
148
170
 
@@ -180,6 +202,24 @@ export class TimelineDisplay {
180
202
  this._draw();
181
203
  }
182
204
 
205
+ /**
206
+ * An edit just moved the play head, like ✂ Split keeping only the second piece.
207
+ *
208
+ * If that took it off screen, bring it back the same way playback does: jump so it's at the
209
+ * left edge, keeping the zoom. If it was already off screen, the user put it there, so the
210
+ * view stays where it is.
211
+ * @param localMs The play head's new time, from the start of the chapter.
212
+ */
213
+ movePlayMs(localMs: number): void {
214
+ const wasVisible = this._playheadVisible();
215
+ this._playLocalMs = localMs;
216
+ if (wasVisible && !this._interacting && !this._playheadVisible()) {
217
+ this._jumpToPlayhead();
218
+ }
219
+ this._wasPlayheadVisible = this._playheadVisible();
220
+ this._draw();
221
+ }
222
+
183
223
  /**
184
224
  * The user just panned or zoomed. If that took the play head off screen,
185
225
  * that was their choice: don't follow it until it comes back into view.
@@ -210,6 +250,11 @@ export class TimelineDisplay {
210
250
  if (this._interacting || this._playheadVisible()) return;
211
251
  const justStarted = !this._wasFollowing;
212
252
  if (!this._wasPlayheadVisible && !justStarted) return;
253
+ this._jumpToPlayhead();
254
+ }
255
+
256
+ /** Put the play head at the left edge, keeping the zoom. Near the end, show the end instead. */
257
+ private _jumpToPlayhead(): void {
213
258
  const span = this._viewEndMs - this._viewStartMs;
214
259
  const start = Math.max(
215
260
  0,
@@ -1,4 +1,5 @@
1
1
  import { debugLog } from "../src/debug-log.ts";
2
+ import { fetchMedia } from "../src/local-files.ts";
2
3
  import {
3
4
  Device,
4
5
  MODELS,
@@ -221,7 +222,7 @@ export async function makeTranscript(
221
222
 
222
223
  /** The file at `url` as 16 kHz mono, the way the models want it. */
223
224
  async function decode(url: string): Promise<Float32Array> {
224
- const response = await fetch(url);
225
+ const response = await fetchMedia(url);
225
226
  if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
226
227
  // decodeAudioData resamples to its context's rate, which does the 16 kHz part.
227
228
  const context = new OfflineAudioContext(1, 1, SAMPLE_RATE);
@@ -305,13 +306,14 @@ type CacheRecord = Transcript & { readonly key: string; readonly url: string };
305
306
  async function cacheKey(url: string): Promise<string> {
306
307
  const absolute = new URL(url, location.href).href;
307
308
  const prefix = `${PIPELINE_VERSION}|${MODELS.whisper}|${absolute}|`;
308
- const head = await fetch(url, { method: "HEAD", cache: "no-cache" });
309
+ // For a local file, fetchMedia() answers with its size and modification time.
310
+ const head = await fetchMedia(url, { method: "HEAD", cache: "no-cache" });
309
311
  const etag = head.headers.get("etag");
310
312
  const modified = head.headers.get("last-modified");
311
313
  const length = head.headers.get("content-length");
312
314
  if (etag) return prefix + etag;
313
315
  if (modified && length) return `${prefix}${modified} ${length}`;
314
- const bytes = await (await fetch(url)).arrayBuffer();
316
+ const bytes = await (await fetchMedia(url)).arrayBuffer();
315
317
  const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
316
318
  return prefix + Array.from(digest, (b) => b.toString(16).padStart(2, "0")).join("");
317
319
  }