canvas-recorder-lib 0.5.0 → 0.7.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.
- package/BREAKING-CHANGES.md +24 -0
- package/README.md +131 -25
- package/dev/audio-builder.ts +69 -161
- package/dev/canvas-recorder.css +59 -0
- package/dev/canvas-recorder.ts +1006 -212
- package/dev/delay-files.ts +1 -1
- package/dev/font-utils.ts +8 -1
- package/dev/format-editor.ts +734 -0
- package/dev/format-string.ts +110 -0
- package/dev/local-file-row.ts +107 -0
- package/dev/multi-text-dialog.ts +360 -0
- package/dev/multi-text-panel.ts +11 -0
- package/dev/player-body.ts +94 -6
- package/dev/rect-snap.ts +9 -9
- package/dev/slide-panel.ts +1 -1
- package/dev/sound-clips.ts +3 -2
- package/dev/soundtrack.ts +434 -0
- package/dev/split-dialog.ts +13 -2
- package/dev/static-image-panel.ts +35 -5
- package/dev/timeline-display.ts +50 -5
- package/dev/transcripts.ts +5 -3
- package/dev/video-clip-panel.ts +202 -16
- package/dev/voice/chirp.ts +129 -0
- package/dev/voice/folder.ts +84 -0
- package/dev/voice/voice-panel.ts +513 -0
- package/dev/voice/voice-recorder.ts +603 -0
- package/dist/dev/audio-builder.d.ts +14 -31
- package/dist/dev/audio-builder.d.ts.map +1 -1
- package/dist/dev/audio-builder.js +62 -134
- package/dist/dev/audio-builder.js.map +1 -1
- package/dist/dev/canvas-recorder.css +59 -0
- package/dist/dev/canvas-recorder.js +926 -198
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/delay-files.js +1 -1
- package/dist/dev/delay-files.js.map +1 -1
- package/dist/dev/font-utils.d.ts.map +1 -1
- package/dist/dev/font-utils.js +9 -1
- package/dist/dev/font-utils.js.map +1 -1
- package/dist/dev/format-editor.d.ts +75 -0
- package/dist/dev/format-editor.d.ts.map +1 -0
- package/dist/dev/format-editor.js +642 -0
- package/dist/dev/format-editor.js.map +1 -0
- package/dist/dev/format-string.d.ts +62 -0
- package/dist/dev/format-string.d.ts.map +1 -0
- package/dist/dev/format-string.js +86 -0
- package/dist/dev/format-string.js.map +1 -0
- package/dist/dev/local-file-row.d.ts +22 -0
- package/dist/dev/local-file-row.d.ts.map +1 -0
- package/dist/dev/local-file-row.js +84 -0
- package/dist/dev/local-file-row.js.map +1 -0
- package/dist/dev/multi-text-dialog.d.ts +30 -0
- package/dist/dev/multi-text-dialog.d.ts.map +1 -0
- package/dist/dev/multi-text-dialog.js +297 -0
- package/dist/dev/multi-text-dialog.js.map +1 -0
- package/dist/dev/multi-text-panel.d.ts +2 -0
- package/dist/dev/multi-text-panel.d.ts.map +1 -1
- package/dist/dev/multi-text-panel.js +4 -0
- package/dist/dev/multi-text-panel.js.map +1 -1
- package/dist/dev/player-body.d.ts +1 -1
- package/dist/dev/player-body.d.ts.map +1 -1
- package/dist/dev/player-body.js +94 -6
- package/dist/dev/player-body.js.map +1 -1
- package/dist/dev/rect-snap.d.ts +1 -1
- package/dist/dev/rect-snap.js +7 -7
- package/dist/dev/rect-snap.js.map +1 -1
- package/dist/dev/slide-panel.d.ts +1 -1
- package/dist/dev/slide-panel.d.ts.map +1 -1
- package/dist/dev/slide-panel.js +1 -1
- package/dist/dev/slide-panel.js.map +1 -1
- package/dist/dev/sound-clips.d.ts +3 -2
- package/dist/dev/sound-clips.d.ts.map +1 -1
- package/dist/dev/sound-clips.js +3 -2
- package/dist/dev/sound-clips.js.map +1 -1
- package/dist/dev/soundtrack.d.ts +115 -0
- package/dist/dev/soundtrack.d.ts.map +1 -0
- package/dist/dev/soundtrack.js +369 -0
- package/dist/dev/soundtrack.js.map +1 -0
- package/dist/dev/split-dialog.d.ts.map +1 -1
- package/dist/dev/split-dialog.js +14 -2
- package/dist/dev/split-dialog.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts +2 -0
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/static-image-panel.js +29 -5
- package/dist/dev/static-image-panel.js.map +1 -1
- package/dist/dev/timeline-display.d.ts +23 -2
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +47 -5
- package/dist/dev/timeline-display.js.map +1 -1
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +5 -3
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts +8 -0
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/dev/video-clip-panel.js +176 -10
- package/dist/dev/video-clip-panel.js.map +1 -1
- package/dist/dev/voice/chirp.d.ts +27 -0
- package/dist/dev/voice/chirp.d.ts.map +1 -0
- package/dist/dev/voice/chirp.js +107 -0
- package/dist/dev/voice/chirp.js.map +1 -0
- package/dist/dev/voice/folder.d.ts +18 -0
- package/dist/dev/voice/folder.d.ts.map +1 -0
- package/dist/dev/voice/folder.js +68 -0
- package/dist/dev/voice/folder.js.map +1 -0
- package/dist/dev/voice/voice-panel.d.ts +44 -0
- package/dist/dev/voice/voice-panel.d.ts.map +1 -0
- package/dist/dev/voice/voice-panel.js +418 -0
- package/dist/dev/voice/voice-panel.js.map +1 -0
- package/dist/dev/voice/voice-recorder.d.ts +141 -0
- package/dist/dev/voice/voice-recorder.d.ts.map +1 -0
- package/dist/dev/voice/voice-recorder.js +506 -0
- package/dist/dev/voice/voice-recorder.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main-control.d.ts +50 -4
- package/dist/lib/main-control.d.ts.map +1 -1
- package/dist/lib/main-control.js +94 -12
- package/dist/lib/main-control.js.map +1 -1
- package/dist/src/binary-search.js +1 -1
- package/dist/src/binary-search.js.map +1 -1
- package/dist/src/corner-rounder.d.ts +17 -0
- package/dist/src/corner-rounder.d.ts.map +1 -0
- package/dist/src/corner-rounder.js +89 -0
- package/dist/src/corner-rounder.js.map +1 -0
- package/dist/src/cross-fade.d.ts +1 -1
- package/dist/src/cross-fade.d.ts.map +1 -1
- package/dist/src/cross-fade.js +3 -3
- package/dist/src/cross-fade.js.map +1 -1
- package/dist/src/fancy-text.d.ts +116 -0
- package/dist/src/fancy-text.d.ts.map +1 -0
- package/dist/src/fancy-text.js +211 -0
- package/dist/src/fancy-text.js.map +1 -0
- package/dist/src/glib/letters-base.d.ts +1 -1
- package/dist/src/glib/letters-base.d.ts.map +1 -1
- package/dist/src/glib/letters-base.js +4 -3
- package/dist/src/glib/letters-base.js.map +1 -1
- package/dist/src/glib/line-font.d.ts +2 -2
- package/dist/src/glib/line-font.d.ts.map +1 -1
- package/dist/src/glib/line-font.js +2 -2
- package/dist/src/glib/line-font.js.map +1 -1
- package/dist/src/glib/paragraph-layout.d.ts +2 -2
- package/dist/src/glib/paragraph-layout.d.ts.map +1 -1
- package/dist/src/glib/paragraph-layout.js +1 -1
- package/dist/src/glib/paragraph-layout.js.map +1 -1
- package/dist/src/glib/path-shape-splitter.d.ts +1 -1
- package/dist/src/glib/path-shape-splitter.d.ts.map +1 -1
- package/dist/src/glib/path-shape-splitter.js +1 -1
- package/dist/src/glib/path-shape-splitter.js.map +1 -1
- package/dist/src/glib/path-shape.js +2 -2
- package/dist/src/glib/path-shape.js.map +1 -1
- package/dist/src/interpolate.d.ts +2 -2
- package/dist/src/interpolate.d.ts.map +1 -1
- package/dist/src/interpolate.js +1 -1
- package/dist/src/interpolate.js.map +1 -1
- package/dist/src/lattice.d.ts +1 -1
- package/dist/src/lattice.d.ts.map +1 -1
- package/dist/src/local-files.d.ts +129 -0
- package/dist/src/local-files.d.ts.map +1 -0
- package/dist/src/local-files.js +327 -0
- package/dist/src/local-files.js.map +1 -0
- package/dist/src/morph-animation.d.ts +1 -1
- package/dist/src/morph-animation.d.ts.map +1 -1
- package/dist/src/morph-animation.js +2 -2
- package/dist/src/morph-animation.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +17 -4
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/schedule-helper.d.ts +4 -4
- package/dist/src/schedule-helper.d.ts.map +1 -1
- package/dist/src/schedule-helper.js +2 -2
- package/dist/src/schedule-helper.js.map +1 -1
- package/dist/src/showable.d.ts +45 -4
- package/dist/src/showable.d.ts.map +1 -1
- package/dist/src/showable.js +37 -1
- package/dist/src/showable.js.map +1 -1
- package/dist/src/slide-components/arrow.d.ts +4 -4
- package/dist/src/slide-components/arrow.d.ts.map +1 -1
- package/dist/src/slide-components/arrow.js +2 -2
- package/dist/src/slide-components/arrow.js.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts +3 -3
- package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.js +3 -3
- package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
- package/dist/src/slide-components/duration-agnostic.d.ts +3 -3
- package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
- package/dist/src/slide-components/duration-agnostic.js +1 -1
- package/dist/src/slide-components/duration-agnostic.js.map +1 -1
- package/dist/src/slide-components/fixed-duration.d.ts +1 -1
- package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
- package/dist/src/slide-components/fixed-duration.js +1 -1
- package/dist/src/slide-components/fixed-duration.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts +6 -6
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +6 -6
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/frame-counter.d.ts +2 -2
- package/dist/src/slide-components/frame-counter.d.ts.map +1 -1
- package/dist/src/slide-components/frame-counter.js +1 -1
- package/dist/src/slide-components/frame-counter.js.map +1 -1
- package/dist/src/slide-components/function-graph.d.ts +2 -2
- package/dist/src/slide-components/function-graph.d.ts.map +1 -1
- package/dist/src/slide-components/function-graph.js +3 -3
- package/dist/src/slide-components/function-graph.js.map +1 -1
- package/dist/src/slide-components/halftone-shadow.d.ts +4 -4
- package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
- package/dist/src/slide-components/halftone-shadow.js +2 -2
- package/dist/src/slide-components/halftone-shadow.js.map +1 -1
- package/dist/src/slide-components/handwriting-effect.d.ts +5 -5
- package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
- package/dist/src/slide-components/handwriting-effect.js +5 -5
- package/dist/src/slide-components/handwriting-effect.js.map +1 -1
- package/dist/src/slide-components/hold.d.ts +3 -3
- package/dist/src/slide-components/hold.d.ts.map +1 -1
- package/dist/src/slide-components/hold.js +3 -3
- package/dist/src/slide-components/hold.js.map +1 -1
- package/dist/src/slide-components/image.d.ts +3 -3
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +3 -3
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts +3 -3
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js +2 -2
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/in-series.d.ts +4 -4
- package/dist/src/slide-components/in-series.d.ts.map +1 -1
- package/dist/src/slide-components/in-series.js +5 -1
- package/dist/src/slide-components/in-series.js.map +1 -1
- package/dist/src/slide-components/live-duration.d.ts +1 -1
- package/dist/src/slide-components/live-duration.d.ts.map +1 -1
- package/dist/src/slide-components/live-duration.js +1 -1
- package/dist/src/slide-components/live-duration.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts +76 -15
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +170 -25
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts +3 -3
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +1 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.d.ts +1 -1
- package/dist/src/slide-components/registry.d.ts.map +1 -1
- package/dist/src/slide-components/registry.js +18 -18
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/serialize.d.ts +1 -1
- package/dist/src/slide-components/serialize.d.ts.map +1 -1
- package/dist/src/slide-components/serialize.js +2 -2
- package/dist/src/slide-components/serialize.js.map +1 -1
- package/dist/src/slide-components/show-error.js +2 -2
- package/dist/src/slide-components/show-error.js.map +1 -1
- package/dist/src/slide-components/simple-text.d.ts +4 -4
- package/dist/src/slide-components/simple-text.d.ts.map +1 -1
- package/dist/src/slide-components/simple-text.js +4 -4
- package/dist/src/slide-components/simple-text.js.map +1 -1
- package/dist/src/slide-components/slide-component.d.ts +5 -5
- package/dist/src/slide-components/slide-component.d.ts.map +1 -1
- package/dist/src/slide-components/slide-component.js +4 -4
- package/dist/src/slide-components/slide-component.js.map +1 -1
- package/dist/src/slide-components/slide-left.d.ts +3 -3
- package/dist/src/slide-components/slide-left.d.ts.map +1 -1
- package/dist/src/slide-components/slide-left.js +3 -3
- package/dist/src/slide-components/slide-left.js.map +1 -1
- package/dist/src/slide-components/split-video-clip.d.ts +2 -2
- package/dist/src/slide-components/split-video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/split-video-clip.js +3 -3
- package/dist/src/slide-components/split-video-clip.js.map +1 -1
- package/dist/src/slide-components/text-effect.d.ts +2 -2
- package/dist/src/slide-components/text-effect.d.ts.map +1 -1
- package/dist/src/slide-components/traditional-text.d.ts +4 -4
- package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
- package/dist/src/slide-components/traditional-text.js +3 -3
- package/dist/src/slide-components/traditional-text.js.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts +17 -5
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +52 -11
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/dist/src/slide-components/video-info.d.ts +11 -11
- package/dist/src/slide-components/video-info.d.ts.map +1 -1
- package/dist/src/slide-components/video-info.js +32 -21
- package/dist/src/slide-components/video-info.js.map +1 -1
- package/dist/src/slow-image-sources.d.ts +7 -1
- package/dist/src/slow-image-sources.d.ts.map +1 -1
- package/dist/src/slow-image-sources.js +36 -5
- package/dist/src/slow-image-sources.js.map +1 -1
- package/dist/src/snapshot.d.ts +2 -2
- package/dist/src/snapshot.d.ts.map +1 -1
- package/dist/src/snapshot.js +31 -15
- package/dist/src/snapshot.js.map +1 -1
- package/dist/src/stroke-colors.d.ts +1 -1
- package/dist/src/stroke-colors.d.ts.map +1 -1
- package/dist/src/stroke-colors.js +4 -4
- package/dist/src/stroke-colors.js.map +1 -1
- package/dist/src/utility.d.ts +3 -4
- package/dist/src/utility.d.ts.map +1 -1
- package/dist/src/utility.js +4 -4
- package/dist/src/utility.js.map +1 -1
- package/lib/index.ts +3 -0
- package/lib/main-control.ts +119 -12
- package/package.json +7 -5
- package/src/binary-search.ts +2 -2
- package/src/corner-rounder.ts +128 -0
- package/src/cross-fade.ts +3 -3
- package/src/fancy-text.ts +255 -0
- package/src/glib/letters-base.ts +4 -3
- package/src/glib/line-font.ts +2 -2
- package/src/glib/paragraph-layout.ts +2 -2
- package/src/glib/path-shape-splitter.ts +1 -1
- package/src/glib/path-shape.ts +2 -2
- package/src/interpolate.ts +3 -3
- package/src/lattice.ts +1 -1
- package/src/local-files.ts +389 -0
- package/src/morph-animation.ts +2 -2
- package/src/peano-fourier/fourier-shared.ts +17 -4
- package/src/schedule-helper.ts +4 -4
- package/src/showable.ts +63 -4
- package/src/slide-components/arrow.ts +4 -4
- package/src/slide-components/cross-fade-transition.ts +4 -4
- package/src/slide-components/duration-agnostic.ts +3 -3
- package/src/slide-components/fixed-duration.ts +1 -1
- package/src/slide-components/fourier.ts +9 -9
- package/src/slide-components/frame-counter.ts +2 -2
- package/src/slide-components/function-graph.ts +4 -4
- package/src/slide-components/halftone-shadow.ts +4 -4
- package/src/slide-components/handwriting-effect.ts +7 -7
- package/src/slide-components/hold.ts +4 -4
- package/src/slide-components/image.ts +5 -5
- package/src/slide-components/in-parallel.ts +4 -4
- package/src/slide-components/in-series.ts +7 -4
- package/src/slide-components/live-duration.ts +1 -1
- package/src/slide-components/multi-text.ts +195 -30
- package/src/slide-components/rectangle.ts +3 -3
- package/src/slide-components/registry.ts +19 -19
- package/src/slide-components/serialize.ts +2 -2
- package/src/slide-components/show-error.ts +2 -2
- package/src/slide-components/simple-text.ts +7 -7
- package/src/slide-components/slide-component.ts +7 -7
- package/src/slide-components/slide-left.ts +4 -4
- package/src/slide-components/split-video-clip.ts +4 -4
- package/src/slide-components/text-effect.ts +2 -2
- package/src/slide-components/traditional-text.ts +5 -5
- package/src/slide-components/video-clip.ts +64 -13
- package/src/slide-components/video-info.ts +33 -21
- package/src/slow-image-sources.ts +38 -6
- package/src/snapshot.ts +34 -19
- package/src/stroke-colors.ts +4 -4
- package/src/utility.ts +5 -5
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import type { Showable } from "./showable.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Video, sound and image files on the user's own computer, instead of on a web server.
|
|
5
|
+
*
|
|
6
|
+
* A component stores a URL like `local:Screen Recording 2026-10-18 at 10.00.00.mov`.
|
|
7
|
+
* That string can go anywhere a URL can: a JSON save file, the clipboard, a sound clip's source.
|
|
8
|
+
* The file handle itself can't, so this module keeps the list of handles, in IndexedDB,
|
|
9
|
+
* and looks each name up when the file is needed.
|
|
10
|
+
*
|
|
11
|
+
* The list is shared by every video on this origin, so a file picked in one video can be
|
|
12
|
+
* picked from the list in another.
|
|
13
|
+
*
|
|
14
|
+
* **Permission.** The browser may forget its permission to read a file, typically when the
|
|
15
|
+
* page reloads. Asking again needs a click, so a component can't just ask when it needs the
|
|
16
|
+
* file. Instead, {@link getLocalFile} fails with a {@link LocalFileError}, the file goes on
|
|
17
|
+
* the {@link localFilesNeedingPermission} list, and the player shows a 🔓 button that calls
|
|
18
|
+
* {@link requestLocalFileAccess}. {@link onLocalFilesChange} tells everyone to try again.
|
|
19
|
+
*
|
|
20
|
+
* A file handle only means something in the browser profile that picked it.
|
|
21
|
+
* A project that uses local files works on this computer, not on someone else's.
|
|
22
|
+
*
|
|
23
|
+
* See development-plans/loading-video-clips-from-local-files.md.
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// MARK: URLs
|
|
28
|
+
|
|
29
|
+
/** Every local file URL starts with this. */
|
|
30
|
+
export const LOCAL_FILE_PREFIX = "local:";
|
|
31
|
+
|
|
32
|
+
/** True for a URL made by {@link localFileUrl}. */
|
|
33
|
+
export function isLocalFileUrl(url: string): boolean {
|
|
34
|
+
return url.startsWith(LOCAL_FILE_PREFIX);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The URL that stands for the local file with this name. */
|
|
38
|
+
export function localFileUrl(name: string): string {
|
|
39
|
+
return LOCAL_FILE_PREFIX + name;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The file name in a local file URL. */
|
|
43
|
+
export function localFileName(url: string): string {
|
|
44
|
+
if (!isLocalFileUrl(url)) {
|
|
45
|
+
throw new Error(`"${url}" is not a local file URL.`);
|
|
46
|
+
}
|
|
47
|
+
return url.slice(LOCAL_FILE_PREFIX.length);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Why a local file couldn't be read. */
|
|
51
|
+
export class LocalFileError extends Error {
|
|
52
|
+
constructor(
|
|
53
|
+
message: string,
|
|
54
|
+
/** The file's name, without the `local:` prefix. */
|
|
55
|
+
readonly fileName: string,
|
|
56
|
+
/**
|
|
57
|
+
* - `unknown`: this browser has never seen a file by this name. Pick it again.
|
|
58
|
+
* - `permission`: the browser needs the user's OK. See {@link requestLocalFileAccess}.
|
|
59
|
+
* - `unreadable`: the file was moved, deleted or changed. Pick it again.
|
|
60
|
+
*/
|
|
61
|
+
readonly reason: "unknown" | "permission" | "unreadable",
|
|
62
|
+
) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = "LocalFileError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// MARK: Change notifications
|
|
69
|
+
|
|
70
|
+
let generation = 0;
|
|
71
|
+
const listeners = new Set<() => void>();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A number that goes up whenever the list of files or their permissions change.
|
|
75
|
+
* A component that caches a failed attempt to open a local file can compare this to
|
|
76
|
+
* know when to try again.
|
|
77
|
+
*/
|
|
78
|
+
export function localFilesGeneration(): number {
|
|
79
|
+
return generation;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Call `listener` whenever the list of files or their permissions change.
|
|
84
|
+
* @returns A function that removes the listener.
|
|
85
|
+
*/
|
|
86
|
+
export function onLocalFilesChange(listener: () => void): () => void {
|
|
87
|
+
listeners.add(listener);
|
|
88
|
+
return () => listeners.delete(listener);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function changed() {
|
|
92
|
+
generation++;
|
|
93
|
+
for (const listener of listeners) {
|
|
94
|
+
listener();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// MARK: The list of handles (IndexedDB)
|
|
99
|
+
|
|
100
|
+
type HandleRecord = {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly handle: FileSystemFileHandle;
|
|
103
|
+
readonly addedAt: number;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const DB_NAME = "canvas-recorder-local-files";
|
|
107
|
+
const STORE = "handles";
|
|
108
|
+
|
|
109
|
+
let dbPromise: Promise<IDBDatabase> | undefined;
|
|
110
|
+
function openDb(): Promise<IDBDatabase> {
|
|
111
|
+
dbPromise ??= new Promise((resolve, reject) => {
|
|
112
|
+
const request = indexedDB.open(DB_NAME, 1);
|
|
113
|
+
request.onupgradeneeded = () =>
|
|
114
|
+
request.result.createObjectStore(STORE, { keyPath: "name" });
|
|
115
|
+
request.onsuccess = () => resolve(request.result);
|
|
116
|
+
request.onerror = () => reject(request.error);
|
|
117
|
+
});
|
|
118
|
+
return dbPromise;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function readRecord(name: string): Promise<HandleRecord | undefined> {
|
|
122
|
+
const db = await openDb();
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
const request = db.transaction(STORE).objectStore(STORE).get(name);
|
|
125
|
+
request.onsuccess = () => resolve(request.result as HandleRecord | undefined);
|
|
126
|
+
request.onerror = () => reject(request.error);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function readAllRecords(): Promise<HandleRecord[]> {
|
|
131
|
+
const db = await openDb();
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
const request = db.transaction(STORE).objectStore(STORE).getAll();
|
|
134
|
+
request.onsuccess = () => resolve(request.result as HandleRecord[]);
|
|
135
|
+
request.onerror = () => reject(request.error);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function writeRecord(record: HandleRecord): Promise<void> {
|
|
140
|
+
const db = await openDb();
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
const transaction = db.transaction(STORE, "readwrite");
|
|
143
|
+
transaction.objectStore(STORE).put(record);
|
|
144
|
+
transaction.oncomplete = () => resolve();
|
|
145
|
+
transaction.onerror = () => reject(transaction.error);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Handles already read from IndexedDB. The list is short, so this never needs trimming. */
|
|
150
|
+
const handles = new Map<string, FileSystemFileHandle>();
|
|
151
|
+
|
|
152
|
+
async function findHandle(name: string): Promise<FileSystemFileHandle | undefined> {
|
|
153
|
+
let handle = handles.get(name);
|
|
154
|
+
if (!handle) {
|
|
155
|
+
handle = (await readRecord(name))?.handle;
|
|
156
|
+
if (handle) handles.set(name, handle);
|
|
157
|
+
}
|
|
158
|
+
return handle;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// MARK: Adding files
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Remember this file, and return the URL that stands for it.
|
|
165
|
+
*
|
|
166
|
+
* A file with the same name replaces the old one. That's how a moved file gets fixed:
|
|
167
|
+
* pick it again from its new place.
|
|
168
|
+
*/
|
|
169
|
+
export async function addLocalFile(handle: FileSystemFileHandle): Promise<string> {
|
|
170
|
+
await writeRecord({ name: handle.name, handle, addedAt: Date.now() });
|
|
171
|
+
handles.set(handle.name, handle);
|
|
172
|
+
needingPermission.delete(handle.name);
|
|
173
|
+
changed();
|
|
174
|
+
return localFileUrl(handle.name);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Video files, for {@link pickLocalFile}. */
|
|
178
|
+
export const VIDEO_FILE_TYPES: FilePickerAcceptType[] = [
|
|
179
|
+
{
|
|
180
|
+
description: "Video",
|
|
181
|
+
accept: { "video/*": [".mp4", ".mov", ".m4v", ".webm", ".mkv"] },
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
/** Image files, for {@link pickLocalFile}. */
|
|
186
|
+
export const IMAGE_FILE_TYPES: FilePickerAcceptType[] = [
|
|
187
|
+
{
|
|
188
|
+
description: "Image",
|
|
189
|
+
accept: { "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".avif"] },
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Ask the user for a file, remember it, and return its URL.
|
|
195
|
+
* Call this from a click handler: the browser only shows a file picker for a click.
|
|
196
|
+
* @param options `id` makes the picker remember its own folder, e.g. "video-clips".
|
|
197
|
+
* @returns The new URL, or undefined if the user canceled.
|
|
198
|
+
*/
|
|
199
|
+
export async function pickLocalFile(options: {
|
|
200
|
+
id?: string;
|
|
201
|
+
types?: FilePickerAcceptType[];
|
|
202
|
+
/** Where the picker starts the first time, before `id` remembers a folder. The default is "videos". */
|
|
203
|
+
startIn?: WellKnownDirectory;
|
|
204
|
+
}): Promise<string | undefined> {
|
|
205
|
+
let handle: FileSystemFileHandle;
|
|
206
|
+
try {
|
|
207
|
+
[handle] = await window.showOpenFilePicker({
|
|
208
|
+
id: options.id,
|
|
209
|
+
types: options.types,
|
|
210
|
+
startIn: options.startIn ?? "videos",
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
return addLocalFile(handle);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** One entry in {@link listLocalFiles}. */
|
|
222
|
+
export type LocalFileInfo = {
|
|
223
|
+
readonly name: string;
|
|
224
|
+
readonly url: string;
|
|
225
|
+
readonly addedAt: number;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/** Every file this browser remembers, newest first. */
|
|
229
|
+
export async function listLocalFiles(): Promise<LocalFileInfo[]> {
|
|
230
|
+
const records = await readAllRecords();
|
|
231
|
+
return records
|
|
232
|
+
.toSorted((a, b) => b.addedAt - a.addedAt)
|
|
233
|
+
.map(({ name, addedAt }) => ({ name, url: localFileUrl(name), addedAt }));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// MARK: Reading files
|
|
237
|
+
|
|
238
|
+
/** Names whose permission was found missing, and not yet granted. */
|
|
239
|
+
const needingPermission = new Set<string>();
|
|
240
|
+
|
|
241
|
+
/** The files that need a click on 🔓 before they can be read. See {@link requestLocalFileAccess}. */
|
|
242
|
+
export function localFilesNeedingPermission(): readonly string[] {
|
|
243
|
+
return [...needingPermission];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function permissionNeeded(name: string): LocalFileError {
|
|
247
|
+
if (!needingPermission.has(name)) {
|
|
248
|
+
needingPermission.add(name);
|
|
249
|
+
changed();
|
|
250
|
+
}
|
|
251
|
+
return new LocalFileError(
|
|
252
|
+
`"${name}" is on your computer. Click 🔓 to let the browser read it.`,
|
|
253
|
+
name,
|
|
254
|
+
"permission",
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The file for a local file URL, as it is right now.
|
|
260
|
+
*
|
|
261
|
+
* This never asks the user anything. If the browser needs permission, this fails with a
|
|
262
|
+
* {@link LocalFileError} whose reason is `permission`, and adds the file to
|
|
263
|
+
* {@link localFilesNeedingPermission}.
|
|
264
|
+
*/
|
|
265
|
+
export async function getLocalFile(url: string): Promise<File> {
|
|
266
|
+
const name = localFileName(url);
|
|
267
|
+
const handle = await findHandle(name);
|
|
268
|
+
if (!handle) {
|
|
269
|
+
throw new LocalFileError(
|
|
270
|
+
`"${name}" isn't in this browser's list of local files. Pick it again.`,
|
|
271
|
+
name,
|
|
272
|
+
"unknown",
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
if ((await handle.queryPermission({ mode: "read" })) !== "granted") {
|
|
276
|
+
throw permissionNeeded(name);
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
return await handle.getFile();
|
|
280
|
+
} catch (error) {
|
|
281
|
+
throw new LocalFileError(
|
|
282
|
+
`Can't read "${name}". It may have been moved or deleted. Pick it again. (${error})`,
|
|
283
|
+
name,
|
|
284
|
+
"unreadable",
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Ask the user for permission to read every file in {@link localFilesNeedingPermission}.
|
|
291
|
+
* Call this from a click handler.
|
|
292
|
+
*
|
|
293
|
+
* The browser may only show one prompt per click. Any file it skips stays on the list,
|
|
294
|
+
* so the user can click again.
|
|
295
|
+
*/
|
|
296
|
+
export async function requestLocalFileAccess(): Promise<void> {
|
|
297
|
+
let anyGranted = false;
|
|
298
|
+
for (const name of [...needingPermission]) {
|
|
299
|
+
const handle = await findHandle(name);
|
|
300
|
+
if (!handle) {
|
|
301
|
+
needingPermission.delete(name);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
if ((await handle.requestPermission({ mode: "read" })) === "granted") {
|
|
306
|
+
needingPermission.delete(name);
|
|
307
|
+
anyGranted = true;
|
|
308
|
+
}
|
|
309
|
+
} catch (error) {
|
|
310
|
+
// Usually "user activation is required": this click was used up by an earlier prompt.
|
|
311
|
+
console.info(`Couldn't ask about "${name}" yet. Click again.`, error);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (anyGranted) {
|
|
316
|
+
changed();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Check, without asking the user anything, that every local file in `urls` can be read.
|
|
322
|
+
* Any that need permission go on {@link localFilesNeedingPermission}.
|
|
323
|
+
* @returns One problem per file that can't be read now. Empty when everything is ready.
|
|
324
|
+
*/
|
|
325
|
+
export async function checkLocalFiles(
|
|
326
|
+
urls: Iterable<string>,
|
|
327
|
+
): Promise<LocalFileError[]> {
|
|
328
|
+
const problems: LocalFileError[] = [];
|
|
329
|
+
const seen = new Set<string>();
|
|
330
|
+
for (const url of urls) {
|
|
331
|
+
if (!isLocalFileUrl(url) || seen.has(url)) continue;
|
|
332
|
+
seen.add(url);
|
|
333
|
+
try {
|
|
334
|
+
await getLocalFile(url);
|
|
335
|
+
} catch (error) {
|
|
336
|
+
problems.push(
|
|
337
|
+
error instanceof LocalFileError
|
|
338
|
+
? error
|
|
339
|
+
: new LocalFileError(String(error), localFileName(url), "unreadable"),
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return problems;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Every local file URL used anywhere in this showable or its descendants:
|
|
348
|
+
* in scalars, in string schedules, and in sound clips.
|
|
349
|
+
*/
|
|
350
|
+
export function localFileUrlsIn(showable: Showable): Set<string> {
|
|
351
|
+
const found = new Set<string>();
|
|
352
|
+
const visit = (current: Showable) => {
|
|
353
|
+
for (const scalar of current.scalars ?? []) {
|
|
354
|
+
if (typeof scalar.value === "string" && isLocalFileUrl(scalar.value)) {
|
|
355
|
+
found.add(scalar.value);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
for (const schedule of current.schedules ?? []) {
|
|
359
|
+
for (const keyframe of schedule.schedule) {
|
|
360
|
+
if (typeof keyframe.value === "string" && isLocalFileUrl(keyframe.value)) {
|
|
361
|
+
found.add(keyframe.value);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
for (const sound of current.soundClips ?? []) {
|
|
366
|
+
if (isLocalFileUrl(sound.source)) found.add(sound.source);
|
|
367
|
+
}
|
|
368
|
+
current.children?.forEach(({ child }) => visit(child));
|
|
369
|
+
};
|
|
370
|
+
visit(showable);
|
|
371
|
+
return found;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Like `fetch()`, but it also understands local file URLs.
|
|
376
|
+
* Use this anywhere media is read by URL, so local files work there too.
|
|
377
|
+
*/
|
|
378
|
+
export async function fetchMedia(url: string, init?: RequestInit): Promise<Response> {
|
|
379
|
+
if (isLocalFileUrl(url)) {
|
|
380
|
+
const file = await getLocalFile(url);
|
|
381
|
+
return new Response(init?.method === "HEAD" ? null : file, {
|
|
382
|
+
headers: {
|
|
383
|
+
"content-length": String(file.size),
|
|
384
|
+
"last-modified": new Date(file.lastModified).toUTCString(),
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return fetch(url, init);
|
|
389
|
+
}
|
package/src/morph-animation.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { angleBetween, radiansPerDegree, zip } from "phil-lib/misc";
|
|
2
|
-
import { Command, QCommand, LCommand, PathShape } from "./glib/path-shape";
|
|
3
|
-
import { qCommandInterpolation } from "./interpolate";
|
|
2
|
+
import { Command, QCommand, LCommand, PathShape } from "./glib/path-shape.ts";
|
|
3
|
+
import { qCommandInterpolation } from "./interpolate.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* If the angle between two pieces is less than 1/2°, so we'll call it good enough.
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ParametricFunction,
|
|
6
6
|
PathShape,
|
|
7
7
|
Point,
|
|
8
|
-
} from "../glib/path-shape";
|
|
8
|
+
} from "../glib/path-shape.ts";
|
|
9
9
|
import {
|
|
10
10
|
assertNonNullable,
|
|
11
11
|
initializedArray,
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
makeLinear,
|
|
15
15
|
sum,
|
|
16
16
|
} from "phil-lib/misc";
|
|
17
|
-
import { ease } from "../interpolate";
|
|
18
|
-
import { PathShapeSplitter } from "../glib/path-shape-splitter";
|
|
19
|
-
import { philDebug, Random } from "../utility";
|
|
17
|
+
import { ease } from "../interpolate.ts";
|
|
18
|
+
import { PathShapeSplitter } from "../glib/path-shape-splitter.ts";
|
|
19
|
+
import { philDebug, Random } from "../utility.ts";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Transform a path.
|
|
@@ -138,6 +138,19 @@ export function samplesToFourier(samples: readonly Complex[]): FourierTerm[] {
|
|
|
138
138
|
return keepNonZeroTerms(terms);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Hits and misses for the small cache inside each function {@link termsToParametricFunction}
|
|
143
|
+
* returns: one `Map` from `t` to a point. Shown as `philDebug.cacheHealth`.
|
|
144
|
+
*
|
|
145
|
+
* Probably not the cache you're looking for. The big ones are `#termsCache` and
|
|
146
|
+
* `#animationCache` in `FourierComponent`.
|
|
147
|
+
*
|
|
148
|
+
* This one helps because `addParametricPath()` estimates each sample's direction from
|
|
149
|
+
* `f(t ± ε)`, and the same values of `t` come back every frame.
|
|
150
|
+
* Its `Map` never removes anything. While the dot grows into the first curve, `t` is scaled
|
|
151
|
+
* by `safePartEnds`, which changes every frame, so each frame adds a few hundred entries.
|
|
152
|
+
* They're freed when `FourierComponent` replaces its animation cache.
|
|
153
|
+
*/
|
|
141
154
|
const cacheHealth = { miss: 0, hit: 0 };
|
|
142
155
|
philDebug.cacheHealth = cacheHealth;
|
|
143
156
|
|
package/src/schedule-helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scalar } from "./showable";
|
|
1
|
+
import { Scalar } from "./showable.ts";
|
|
2
2
|
import {
|
|
3
3
|
discreteKeyframes,
|
|
4
4
|
durationKeyframes,
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
interpolatePoints,
|
|
9
9
|
interpolateRects,
|
|
10
10
|
Keyframe,
|
|
11
|
-
} from "./interpolate";
|
|
11
|
+
} from "./interpolate.ts";
|
|
12
12
|
import { ReadOnlyRect } from "phil-lib/misc";
|
|
13
|
-
import { Point } from "./glib/path-shape";
|
|
14
|
-
import { Lattice, LatticeValue } from "./lattice";
|
|
13
|
+
import { Point } from "./glib/path-shape.ts";
|
|
14
|
+
import { Lattice, LatticeValue } from "./lattice.ts";
|
|
15
15
|
|
|
16
16
|
// This code is often used to create schedules for Showable.schedules.
|
|
17
17
|
// This interface makes it easier for the TypeScript programmer to access the data.
|
package/src/showable.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { positiveModulo, ReadOnlyRect } from "phil-lib/misc";
|
|
2
|
-
import { ease, easeIn, easeOut, Keyframe } from "./interpolate";
|
|
3
|
-
import { Point } from "./glib/path-shape";
|
|
4
|
-
import { LatticeValue } from "./lattice";
|
|
2
|
+
import { ease, easeIn, easeOut, Keyframe } from "./interpolate.ts";
|
|
3
|
+
import { Point } from "./glib/path-shape.ts";
|
|
4
|
+
import { LatticeValue } from "./lattice.ts";
|
|
5
5
|
// Type-only, so it is erased at runtime: registry.ts imports this module.
|
|
6
|
-
import type { ComponentRegistryEntry } from "./slide-components/registry";
|
|
6
|
+
import type { ComponentRegistryEntry } from "./slide-components/registry.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The content shouldn't know much about the Visual Editor.
|
|
@@ -38,6 +38,8 @@ export type VisualEditorAPI = {
|
|
|
38
38
|
* Returns the decoded PCM buffer for a source URL if it has already been
|
|
39
39
|
* fetched and decoded by the audio system, or null if it hasn't yet.
|
|
40
40
|
* Used for drawing in-timeline waveforms without a second fetch.
|
|
41
|
+
*
|
|
42
|
+
* Always mono, at 48 kHz: a file with more channels is averaged down to one.
|
|
41
43
|
*/
|
|
42
44
|
getDecodedBuffer?(url: string): AudioBuffer | null;
|
|
43
45
|
};
|
|
@@ -283,6 +285,13 @@ export type Showable = {
|
|
|
283
285
|
readonly child: Showable;
|
|
284
286
|
}[];
|
|
285
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Sounds that play with this component, timed from its start.
|
|
290
|
+
*
|
|
291
|
+
* Every Showable can hold sound clips. `undefined` just means none yet:
|
|
292
|
+
* anything that adds a clip creates the list first (`soundClips ??= []`).
|
|
293
|
+
* Loading a saved state creates it too, and treats a missing list as an empty one.
|
|
294
|
+
*/
|
|
286
295
|
soundClips?: SoundClip[];
|
|
287
296
|
|
|
288
297
|
/**
|
|
@@ -399,6 +408,19 @@ export type Showable = {
|
|
|
399
408
|
set: Pick<Set<Promise<unknown>>, "add">,
|
|
400
409
|
) => void;
|
|
401
410
|
|
|
411
|
+
/**
|
|
412
|
+
* This object will be shown soon. Start loading what its first frame needs. Draw nothing.
|
|
413
|
+
*
|
|
414
|
+
* The live-playback counterpart of {@link getFramePromises}. In real time nobody can wait,
|
|
415
|
+
* so anything slow, like decoding a video frame, has to be asked for before it's needed.
|
|
416
|
+
*
|
|
417
|
+
* An In Series (`InSeriesComponent`) calls this on every frame of live playback, for each child that
|
|
418
|
+
* hasn't started yet. Never while recording.
|
|
419
|
+
* @param timeInMs This object's own time, which is negative: -2000 means it starts in 2 seconds
|
|
420
|
+
* of the video's time (not the wall clock's). The object decides how far ahead is worth it.
|
|
421
|
+
*/
|
|
422
|
+
getReady?: (timeInMs: number) => void;
|
|
423
|
+
|
|
402
424
|
/**
|
|
403
425
|
* Draw this object to the canvas.
|
|
404
426
|
*
|
|
@@ -723,12 +745,34 @@ function notNegative(value: number) {
|
|
|
723
745
|
}
|
|
724
746
|
}
|
|
725
747
|
|
|
748
|
+
// MARK: Old builders
|
|
749
|
+
//
|
|
750
|
+
// Everything from here to the end of the file is deprecated: MakeShowableInParallel,
|
|
751
|
+
// MakeShowableInSeries, makeRepeater(), addMargins() and reschedule().
|
|
752
|
+
// They're from canvas-recorder, before components, and nothing in the library uses them.
|
|
753
|
+
// See development-plans/release-1.0.md.
|
|
754
|
+
//
|
|
755
|
+
// **They only pass along show().** Not getFramePromises(), not getReady(), and not anything
|
|
756
|
+
// added to Showable since. So they're only safe for *fast content*: something that draws its
|
|
757
|
+
// complete, final picture the first time show() is called, from code alone.
|
|
758
|
+
//
|
|
759
|
+
// Not fast content: anything that loads a file or a font, or decodes video.
|
|
760
|
+
// That's SingleImageComponent, VideoClipComponent and TraditionalTextComponent, any component
|
|
761
|
+
// with a getFramePromises() or getReady() of its own, and any container holding one of those.
|
|
762
|
+
// Inside an old builder, recording doesn't wait for them, so it can save a fallback font, a
|
|
763
|
+
// blank image or a red ✕. And live playback doesn't warn them before they start.
|
|
764
|
+
|
|
726
765
|
/**
|
|
727
766
|
* Creates a new Showable object which passes each show() call to all of its children.
|
|
728
767
|
*
|
|
729
768
|
* You might have multiple things all running at the same time.
|
|
730
769
|
* You might have things that overlap arbitrarily.
|
|
731
770
|
* For example, the background is **always** showing.
|
|
771
|
+
*
|
|
772
|
+
* @deprecated Use `InParallelComponent`, or one of its subclasses like
|
|
773
|
+
* `ComponentWithFixedDuration` or `DurationAgnosticComponent`.
|
|
774
|
+
* This only passes along show(), not getFramePromises() or getReady(), so only use it for fast
|
|
775
|
+
* content: nothing that loads an image, a video or a font. See "Old builders" in showable.ts.
|
|
732
776
|
*/
|
|
733
777
|
export class MakeShowableInParallel {
|
|
734
778
|
constructor(readonly description: string) {}
|
|
@@ -840,6 +884,10 @@ export class MakeShowableInParallel {
|
|
|
840
884
|
/**
|
|
841
885
|
* Build a new Showable that contains a set of Showable children.
|
|
842
886
|
* Each one runs right after the previous one.
|
|
887
|
+
*
|
|
888
|
+
* @deprecated Use `InSeriesComponent`.
|
|
889
|
+
* This only passes along show(), not getFramePromises() or getReady(), so only use it for fast
|
|
890
|
+
* content: nothing that loads an image, a video or a font. See "Old builders" in showable.ts.
|
|
843
891
|
*/
|
|
844
892
|
export class MakeShowableInSeries {
|
|
845
893
|
constructor(readonly description: string) {}
|
|
@@ -958,6 +1006,9 @@ export class MakeShowableInSeries {
|
|
|
958
1006
|
* This only affects the duration.
|
|
959
1007
|
* If you continue calling this it will repeat forever.
|
|
960
1008
|
* @returns A new `Showable` object that will call the original multiple times.
|
|
1009
|
+
* @deprecated There's no component that does this yet.
|
|
1010
|
+
* This only passes along show(), not getFramePromises() or getReady(), so only use it for fast
|
|
1011
|
+
* content: nothing that loads an image, a video or a font. See "Old builders" in showable.ts.
|
|
961
1012
|
*/
|
|
962
1013
|
export function makeRepeater(showable: Showable, count = Infinity): Showable {
|
|
963
1014
|
const period = showable.duration;
|
|
@@ -984,6 +1035,10 @@ export function makeRepeater(showable: Showable, count = Infinity): Showable {
|
|
|
984
1035
|
* * frozenBefore Hold the initial image of `base` for this many milliseconds. Default is 0.
|
|
985
1036
|
* * frozenAfter Hold the final image of `base` for this many milliseconds. Default is 0.
|
|
986
1037
|
* @returns
|
|
1038
|
+
* @deprecated Use `PaddingComponent`: Initial Time and Extra Time add the time, and Show
|
|
1039
|
+
* Before and Show After choose hide or freeze.
|
|
1040
|
+
* This only passes along show(), not getFramePromises() or getReady(), so only use it for fast
|
|
1041
|
+
* content: nothing that loads an image, a video or a font. See "Old builders" in showable.ts.
|
|
987
1042
|
*/
|
|
988
1043
|
export function addMargins(
|
|
989
1044
|
base: Showable,
|
|
@@ -1033,6 +1088,10 @@ export function addMargins(
|
|
|
1033
1088
|
* @param offset Start this many milliseconds into the new Showable.
|
|
1034
1089
|
* Defaults to 0, starting at the beginning.
|
|
1035
1090
|
* @returns The newly created Showable
|
|
1091
|
+
* @deprecated Use `PaddingComponent`, with Show Before and Show After set to "live".
|
|
1092
|
+
* A negative Initial Time starts the child partway through.
|
|
1093
|
+
* This only passes along show(), not getFramePromises() or getReady(), so only use it for fast
|
|
1094
|
+
* content: nothing that loads an image, a video or a font. See "Old builders" in showable.ts.
|
|
1036
1095
|
*/
|
|
1037
1096
|
export function reschedule(
|
|
1038
1097
|
base: Showable,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
NumberScheduleInfo,
|
|
5
5
|
ColorScheduleInfo,
|
|
6
6
|
ArrowValue,
|
|
7
|
-
} from "../schedule-helper";
|
|
8
|
-
import { ShowOptions } from "../showable";
|
|
9
|
-
import { DurationAgnosticComponent } from "./duration-agnostic";
|
|
10
|
-
import { Keyframe } from "../interpolate";
|
|
7
|
+
} from "../schedule-helper.ts";
|
|
8
|
+
import { ShowOptions } from "../showable.ts";
|
|
9
|
+
import { DurationAgnosticComponent } from "./duration-agnostic.ts";
|
|
10
|
+
import { Keyframe } from "../interpolate.ts";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Standard registry component: a directed arrow with a rectangular shaft and
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Showable, ShowOptions } from "../showable";
|
|
2
|
-
import { InSeriesComponent, Transition } from "./in-series";
|
|
3
|
-
import { ComponentWithLiveDuration } from "./live-duration";
|
|
4
|
-
import { showError } from "./show-error";
|
|
1
|
+
import { Showable, ShowOptions } from "../showable.ts";
|
|
2
|
+
import { InSeriesComponent, Transition } from "./in-series.ts";
|
|
3
|
+
import { ComponentWithLiveDuration } from "./live-duration.ts";
|
|
4
|
+
import { showError } from "./show-error.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A {@link Transition} that cross-dissolves between the last frame of `before`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Scalar } from "../showable";
|
|
2
|
-
import { Mutable } from "../utility";
|
|
3
|
-
import { InParallelComponent, ParallelChildInfo } from "./in-parallel";
|
|
1
|
+
import { Scalar } from "../showable.ts";
|
|
2
|
+
import { Mutable } from "../utility.ts";
|
|
3
|
+
import { InParallelComponent, ParallelChildInfo } from "./in-parallel.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* I like this as a base class for a lot of generic containers.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReadOnlyRect } from "phil-lib/misc";
|
|
2
|
-
import { myRainbow } from "../glib/my-rainbow";
|
|
3
|
-
import { ParametricFunction, PathShape } from "../glib/path-shape";
|
|
4
|
-
import { panAndZoom } from "../glib/transforms";
|
|
5
|
-
import { Keyframe } from "../interpolate";
|
|
2
|
+
import { myRainbow } from "../glib/my-rainbow.ts";
|
|
3
|
+
import { ParametricFunction, PathShape } from "../glib/path-shape.ts";
|
|
4
|
+
import { panAndZoom } from "../glib/transforms.ts";
|
|
5
|
+
import { Keyframe } from "../interpolate.ts";
|
|
6
6
|
import {
|
|
7
7
|
Complex,
|
|
8
8
|
FourierTerm,
|
|
@@ -13,17 +13,17 @@ import {
|
|
|
13
13
|
samplesFromPath,
|
|
14
14
|
samplesToFourier,
|
|
15
15
|
termsToParametricFunction,
|
|
16
|
-
} from "../peano-fourier/fourier-shared";
|
|
16
|
+
} from "../peano-fourier/fourier-shared.ts";
|
|
17
17
|
import {
|
|
18
18
|
ColorScheduleInfo,
|
|
19
19
|
NumberScheduleInfo,
|
|
20
20
|
RectangleScheduleInfo,
|
|
21
21
|
SelectScheduleInfo,
|
|
22
22
|
StringScheduleInfo,
|
|
23
|
-
} from "../schedule-helper";
|
|
24
|
-
import { ShowOptions } from "../showable";
|
|
25
|
-
import { DurationAgnosticComponent } from "./duration-agnostic";
|
|
26
|
-
import { showError } from "./show-error";
|
|
23
|
+
} from "../schedule-helper.ts";
|
|
24
|
+
import { ShowOptions } from "../showable.ts";
|
|
25
|
+
import { DurationAgnosticComponent } from "./duration-agnostic.ts";
|
|
26
|
+
import { showError } from "./show-error.ts";
|
|
27
27
|
|
|
28
28
|
// MARK: Sources
|
|
29
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FIGURE_SPACE } from "phil-lib/misc";
|
|
2
|
-
import { ShowOptions } from "../showable";
|
|
3
|
-
import { TraditionalTextComponent } from "./traditional-text";
|
|
2
|
+
import { ShowOptions } from "../showable.ts";
|
|
3
|
+
import { TraditionalTextComponent } from "./traditional-text.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This component displays text like "0:00 0/60" to tell you the current timeInMs of this component.
|