canvas-recorder-lib 0.8.3 → 0.8.5
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/README.md +10 -2
- package/dev/canvas-recorder.css +14 -0
- package/dev/canvas-recorder.ts +500 -84
- package/dev/color-picker.ts +13 -0
- package/dev/component-picker.ts +60 -11
- package/dev/font-widgets.ts +2 -2
- package/dev/format-editor.ts +3 -1
- package/dev/fourier-panel.ts +7 -3
- package/dev/handwriting-panel.ts +7 -7
- package/dev/multi-text-dialog.ts +28 -15
- package/dev/player-body.ts +95 -36
- package/dev/schedule-helpers.ts +10 -3
- package/dev/static-image-panel.ts +4 -4
- package/dev/subtitles.ts +170 -0
- package/dev/synced-file.ts +34 -0
- package/dev/timeline-display.ts +1 -1
- package/dev/transcript-align.ts +4 -1
- package/dev/transcript-editor.ts +1205 -0
- package/dev/transcript-export.ts +90 -0
- package/dev/transcript-view.ts +8 -5
- package/dev/transcripts.ts +140 -15
- package/dev/video-clip-panel.ts +4 -4
- package/dist/dev/canvas-recorder.css +14 -0
- package/dist/dev/canvas-recorder.js +408 -74
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/color-picker.d.ts.map +1 -1
- package/dist/dev/color-picker.js +15 -0
- package/dist/dev/color-picker.js.map +1 -1
- package/dist/dev/component-picker.d.ts +2 -1
- package/dist/dev/component-picker.d.ts.map +1 -1
- package/dist/dev/component-picker.js +56 -11
- package/dist/dev/component-picker.js.map +1 -1
- package/dist/dev/font-widgets.d.ts +2 -2
- package/dist/dev/font-widgets.d.ts.map +1 -1
- package/dist/dev/font-widgets.js.map +1 -1
- package/dist/dev/format-editor.d.ts.map +1 -1
- package/dist/dev/format-editor.js +3 -1
- package/dist/dev/format-editor.js.map +1 -1
- package/dist/dev/fourier-panel.d.ts.map +1 -1
- package/dist/dev/fourier-panel.js +4 -3
- package/dist/dev/fourier-panel.js.map +1 -1
- package/dist/dev/handwriting-panel.d.ts +4 -4
- package/dist/dev/handwriting-panel.d.ts.map +1 -1
- package/dist/dev/handwriting-panel.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +23 -12
- package/dist/dev/multi-text-dialog.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 +95 -36
- package/dist/dev/player-body.js.map +1 -1
- package/dist/dev/schedule-helpers.d.ts.map +1 -1
- package/dist/dev/schedule-helpers.js +4 -2
- package/dist/dev/schedule-helpers.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts +3 -3
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/subtitles.d.ts +36 -0
- package/dist/dev/subtitles.d.ts.map +1 -0
- package/dist/dev/subtitles.js +135 -0
- package/dist/dev/subtitles.js.map +1 -0
- package/dist/dev/synced-file.d.ts +14 -0
- package/dist/dev/synced-file.d.ts.map +1 -1
- package/dist/dev/synced-file.js +22 -0
- package/dist/dev/synced-file.js.map +1 -1
- package/dist/dev/timeline-display.d.ts +5 -0
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +1 -1
- package/dist/dev/timeline-display.js.map +1 -1
- package/dist/dev/transcript-align.d.ts +3 -1
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +2 -0
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/dev/transcript-editor.d.ts +36 -0
- package/dist/dev/transcript-editor.d.ts.map +1 -0
- package/dist/dev/transcript-editor.js +964 -0
- package/dist/dev/transcript-editor.js.map +1 -0
- package/dist/dev/transcript-export.d.ts +21 -0
- package/dist/dev/transcript-export.d.ts.map +1 -1
- package/dist/dev/transcript-export.js +65 -0
- package/dist/dev/transcript-export.js.map +1 -1
- package/dist/dev/transcript-view.d.ts +2 -0
- package/dist/dev/transcript-view.d.ts.map +1 -1
- package/dist/dev/transcript-view.js +1 -1
- package/dist/dev/transcript-view.js.map +1 -1
- package/dist/dev/transcripts.d.ts +18 -1
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +102 -12
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts +3 -3
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/src/glib/line-font.d.ts +6 -0
- package/dist/src/glib/line-font.d.ts.map +1 -1
- package/dist/src/glib/line-font.js +9 -0
- package/dist/src/glib/line-font.js.map +1 -1
- package/dist/src/glib/path-shape.d.ts +16 -0
- package/dist/src/glib/path-shape.d.ts.map +1 -1
- package/dist/src/glib/path-shape.js +23 -0
- package/dist/src/glib/path-shape.js.map +1 -1
- package/dist/src/glib/transforms.d.ts +9 -0
- package/dist/src/glib/transforms.d.ts.map +1 -1
- package/dist/src/glib/transforms.js +7 -4
- package/dist/src/glib/transforms.js.map +1 -1
- package/dist/src/interpolate.d.ts +17 -10
- package/dist/src/interpolate.d.ts.map +1 -1
- package/dist/src/interpolate.js +1 -17
- package/dist/src/interpolate.js.map +1 -1
- package/dist/src/morph-animation.js +1 -1
- package/dist/src/morph-animation.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +4 -2
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/schedule-helper.d.ts +50 -28
- package/dist/src/schedule-helper.d.ts.map +1 -1
- package/dist/src/schedule-helper.js +22 -0
- package/dist/src/schedule-helper.js.map +1 -1
- package/dist/src/showable.d.ts +59 -11
- package/dist/src/showable.d.ts.map +1 -1
- package/dist/src/showable.js +19 -0
- 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/cross-fade-transition.d.ts +2 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.js +2 -1
- package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
- package/dist/src/slide-components/duration-agnostic.d.ts +3 -2
- package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
- package/dist/src/slide-components/duration-agnostic.js +4 -2
- package/dist/src/slide-components/duration-agnostic.js.map +1 -1
- package/dist/src/slide-components/fixed-duration.d.ts +3 -1
- package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
- package/dist/src/slide-components/fixed-duration.js +4 -2
- package/dist/src/slide-components/fixed-duration.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts +19 -12
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +70 -22
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/function-graph.d.ts +4 -3
- package/dist/src/slide-components/function-graph.d.ts.map +1 -1
- package/dist/src/slide-components/function-graph.js +6 -2
- package/dist/src/slide-components/function-graph.js.map +1 -1
- package/dist/src/slide-components/halftone-shadow.d.ts +8 -7
- package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
- package/dist/src/slide-components/halftone-shadow.js +2 -1
- package/dist/src/slide-components/halftone-shadow.js.map +1 -1
- package/dist/src/slide-components/handwriting-effect.d.ts +8 -6
- package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
- package/dist/src/slide-components/handwriting-effect.js +4 -2
- package/dist/src/slide-components/handwriting-effect.js.map +1 -1
- package/dist/src/slide-components/hold.d.ts +4 -2
- package/dist/src/slide-components/hold.d.ts.map +1 -1
- package/dist/src/slide-components/hold.js +4 -2
- package/dist/src/slide-components/hold.js.map +1 -1
- package/dist/src/slide-components/image.d.ts +7 -7
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +4 -2
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts +12 -3
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js +27 -2
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/in-series.d.ts +2 -1
- package/dist/src/slide-components/in-series.d.ts.map +1 -1
- package/dist/src/slide-components/in-series.js +2 -1
- package/dist/src/slide-components/in-series.js.map +1 -1
- package/dist/src/slide-components/live-duration.d.ts +3 -1
- package/dist/src/slide-components/live-duration.d.ts.map +1 -1
- package/dist/src/slide-components/live-duration.js +4 -2
- package/dist/src/slide-components/live-duration.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts +39 -26
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +44 -29
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts +5 -4
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +2 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.d.ts +5 -0
- package/dist/src/slide-components/registry.d.ts.map +1 -1
- package/dist/src/slide-components/registry.js +28 -27
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/show-error.d.ts.map +1 -1
- package/dist/src/slide-components/show-error.js +3 -2
- package/dist/src/slide-components/show-error.js.map +1 -1
- package/dist/src/slide-components/simple-text.d.ts +11 -10
- package/dist/src/slide-components/simple-text.d.ts.map +1 -1
- package/dist/src/slide-components/simple-text.js +5 -3
- package/dist/src/slide-components/simple-text.js.map +1 -1
- package/dist/src/slide-components/slide-component.d.ts +14 -13
- package/dist/src/slide-components/slide-component.d.ts.map +1 -1
- package/dist/src/slide-components/slide-component.js +2 -1
- package/dist/src/slide-components/slide-component.js.map +1 -1
- package/dist/src/slide-components/slide-left.d.ts +2 -1
- package/dist/src/slide-components/slide-left.d.ts.map +1 -1
- package/dist/src/slide-components/slide-left.js +2 -1
- package/dist/src/slide-components/slide-left.js.map +1 -1
- package/dist/src/slide-components/text-effect.d.ts +9 -1
- package/dist/src/slide-components/text-effect.d.ts.map +1 -1
- package/dist/src/slide-components/text-effect.js.map +1 -1
- package/dist/src/slide-components/traditional-text.d.ts +8 -8
- package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts +5 -4
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +5 -2
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/lib/index.ts +1 -0
- package/package.json +2 -2
- package/src/glib/line-font.ts +9 -0
- package/src/glib/path-shape.ts +35 -0
- package/src/glib/transforms.ts +7 -4
- package/src/interpolate.ts +18 -27
- package/src/morph-animation.ts +1 -1
- package/src/peano-fourier/fourier-shared.ts +4 -2
- package/src/schedule-helper.ts +50 -28
- package/src/showable.ts +81 -11
- package/src/slide-components/arrow.ts +4 -4
- package/src/slide-components/cross-fade-transition.ts +9 -2
- package/src/slide-components/duration-agnostic.ts +4 -3
- package/src/slide-components/fixed-duration.ts +4 -2
- package/src/slide-components/fourier.ts +89 -32
- package/src/slide-components/function-graph.ts +7 -3
- package/src/slide-components/halftone-shadow.ts +9 -7
- package/src/slide-components/handwriting-effect.ts +8 -6
- package/src/slide-components/hold.ts +18 -4
- package/src/slide-components/image.ts +9 -7
- package/src/slide-components/in-parallel.ts +31 -1
- package/src/slide-components/in-series.ts +3 -1
- package/src/slide-components/live-duration.ts +4 -2
- package/src/slide-components/multi-text.ts +71 -44
- package/src/slide-components/rectangle.ts +6 -4
- package/src/slide-components/registry.ts +33 -27
- package/src/slide-components/show-error.ts +4 -2
- package/src/slide-components/simple-text.ts +22 -12
- package/src/slide-components/slide-component.ts +15 -13
- package/src/slide-components/slide-left.ts +9 -2
- package/src/slide-components/text-effect.ts +9 -0
- package/src/slide-components/traditional-text.ts +8 -8
- package/src/slide-components/video-clip.ts +9 -5
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./canvas-recorder.css";
|
|
2
2
|
import { assertNonNullable, FIGURE_SPACE, parseFloatX, } from "phil-lib/misc";
|
|
3
3
|
import { AnimationLoop, getById, querySelector, } from "phil-lib/client-misc";
|
|
4
|
-
import { Output, StreamTarget, CanvasSource, Mp4OutputFormat, AudioBufferSource, QUALITY_HIGH, } from "mediabunny";
|
|
4
|
+
import { Output, StreamTarget, CanvasSource, Mp4OutputFormat, AudioBufferSource, QUALITY_HIGH, TextSubtitleSource, } from "mediabunny";
|
|
5
|
+
import { choiceLabel, propertyLabel, } from "../src/showable.js";
|
|
5
6
|
import { discreteKeyframes, interpolateColors, interpolateLattices, interpolateNumbers, interpolatePoints, interpolateRects, } from "../src/interpolate.js";
|
|
6
7
|
import { Lattice } from "../src/lattice.js";
|
|
8
|
+
import { checkPanAndZoom } from "../src/glib/transforms.js";
|
|
7
9
|
import { interpolateArrow } from "../src/schedule-helper.js";
|
|
8
10
|
import { applyJsonEntry, applyTree, counterparts, fillTreeDefaults, findSerializedNode, isVideoSnapshot, omitComponentDefaults, registryDefault, omitTreeDefaults, serializeComponents, serializeScalars, serializeSchedules, serializeTree, SNAPSHOT_FORMAT_VERSION, } from "../src/snapshot.js";
|
|
9
11
|
import { downloadBlob, philDebug } from "../src/utility.js";
|
|
10
12
|
import { getNewDebugLogEntries } from "../src/debug-log.js";
|
|
11
|
-
import { SAMPLE_RATE, Soundtrack } from "./soundtrack.js";
|
|
13
|
+
import { collectSoundClips, SAMPLE_RATE, Soundtrack } from "./soundtrack.js";
|
|
12
14
|
import { openVoicePanel } from "./voice/voice-panel.js";
|
|
13
15
|
import { openColorPickerDialog } from "./color-picker.js";
|
|
14
16
|
import { setSwatchColor } from "./color-utils.js";
|
|
@@ -20,10 +22,12 @@ import { buildTextFramePanel } from "./multi-text-panel.js";
|
|
|
20
22
|
import { openMultiTextDialog } from "./multi-text-dialog.js";
|
|
21
23
|
import { ownerOf, parseSoundClips, rehomeSoundClip, soundOwners, startWithin, tidyMs, } from "./sound-clips.js";
|
|
22
24
|
import { askHowToSplit, askHowToSplitSound } from "./split-dialog.js";
|
|
23
|
-
import { SyncedFile } from "./synced-file.js";
|
|
25
|
+
import { onSyncStatusChange, SyncedFile, } from "./synced-file.js";
|
|
24
26
|
import { TimelineDisplay, } from "./timeline-display.js";
|
|
25
|
-
import { forgetTranscriptFailures, forgetTranscripts, makeTranscript, onTranscriptsChange, readyTranscript, setTranscriptsEnabled, statusText, transcriptsEnabled, transcriptStatus, transcriptsSummary, } from "./transcripts.js";
|
|
26
|
-
import { transcriptFileName, transcriptJson } from "./transcript-export.js";
|
|
27
|
+
import { editTranscript, forgetTranscriptFailures, forgetTranscripts, makeTranscript, onTranscriptsChange, readyTranscript, setTranscriptsEnabled, statusText, transcriptsEnabled, transcriptStatus, transcriptsSummary, transcriptVersion, } from "./transcripts.js";
|
|
28
|
+
import { transcriptFileName, transcriptJson, transcriptsFileText, } from "./transcript-export.js";
|
|
29
|
+
import { openTranscriptEditor } from "./transcript-editor.js";
|
|
30
|
+
import { subtitleWords, webVtt } from "./subtitles.js";
|
|
27
31
|
import { wordFlag } from "./transcript-align.js";
|
|
28
32
|
import { canvasRecorder } from "../lib/main-control.js";
|
|
29
33
|
import { watchServiceWorkerReady } from "./delay-files.js";
|
|
@@ -416,7 +420,7 @@ window.showFrame = showFrame;
|
|
|
416
420
|
// Two separate things, though they usually agree:
|
|
417
421
|
//
|
|
418
422
|
// * The **root**: the component the Visual Editor works on, picked in the
|
|
419
|
-
// chapter <select>.
|
|
423
|
+
// chapter <select>. TimedKeyframe times, the timeline at the bottom, and every
|
|
420
424
|
// "now" the editors show are measured from the root's start. See
|
|
421
425
|
// rootStartMs and playheadInRootMs().
|
|
422
426
|
// * The **play limits**: where playback wraps or stops, and the ends of the
|
|
@@ -443,7 +447,7 @@ let sectionStartTime = 0;
|
|
|
443
447
|
*/
|
|
444
448
|
let sectionEndTime = 0;
|
|
445
449
|
/**
|
|
446
|
-
* When the Visual Editor's root starts, in video time.
|
|
450
|
+
* When the Visual Editor's root starts, in video time. TimedKeyframe times, the
|
|
447
451
|
* timeline, and every "now" the editors show are measured from here.
|
|
448
452
|
*/
|
|
449
453
|
let rootStartMs = 0;
|
|
@@ -919,6 +923,24 @@ addEventListener("keydown", (event) => {
|
|
|
919
923
|
event.preventDefault();
|
|
920
924
|
}
|
|
921
925
|
});
|
|
926
|
+
// The math's self-test, once per page load. It used to run as transforms.ts loaded, which
|
|
927
|
+
// kept PathShape and everything that uses it out of Node.
|
|
928
|
+
checkPanAndZoom();
|
|
929
|
+
// MARK: Wheel over a number
|
|
930
|
+
/**
|
|
931
|
+
* Chrome changes a focused number field when the wheel, or a two finger scroll, passes over
|
|
932
|
+
* it. Here that's nearly always an accident: scrolling the properties to find the next
|
|
933
|
+
* one. And Cmd+Z can't undo it. So the field gives up the focus first, and the wheel
|
|
934
|
+
* scrolls as usual. Typing and the field's arrows still work.
|
|
935
|
+
*/
|
|
936
|
+
document.addEventListener("wheel", (event) => {
|
|
937
|
+
const target = event.target;
|
|
938
|
+
if (target instanceof HTMLInputElement &&
|
|
939
|
+
target.type === "number" &&
|
|
940
|
+
target === document.activeElement) {
|
|
941
|
+
target.blur();
|
|
942
|
+
}
|
|
943
|
+
}, { passive: true, capture: true });
|
|
922
944
|
/**
|
|
923
945
|
* This is the status of the save. It has no purpose during live / realtime operation
|
|
924
946
|
* so it initialize it to blank.
|
|
@@ -1100,8 +1122,9 @@ function escapeHtml(text) {
|
|
|
1100
1122
|
* Save dialog can change it, just for this file. Nothing else sees the change: the picture
|
|
1101
1123
|
* is still drawn in canvasRecorder's units, and simply stretched to this size.
|
|
1102
1124
|
* @param pixelHeight The saved file's height. See `pixelWidth`.
|
|
1125
|
+
* @param subtitles Add a subtitle track, made from the transcripts. See dev/subtitles.ts.
|
|
1103
1126
|
*/
|
|
1104
|
-
async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixelWidth = canvasRecorder.pixelWidth, pixelHeight = canvasRecorder.pixelHeight) {
|
|
1127
|
+
async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixelWidth = canvasRecorder.pixelWidth, pixelHeight = canvasRecorder.pixelHeight, subtitles = false) {
|
|
1105
1128
|
stopAudio();
|
|
1106
1129
|
startRecordingButton.disabled = true;
|
|
1107
1130
|
liveControls.disabled = true;
|
|
@@ -1175,6 +1198,19 @@ async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixe
|
|
|
1175
1198
|
bitrate: QUALITY_HIGH,
|
|
1176
1199
|
});
|
|
1177
1200
|
output.addAudioTrack(audioSource);
|
|
1201
|
+
// The words, from the transcripts as they are now. The cues are added at the end, like
|
|
1202
|
+
// the sound, when it's known how much was recorded. A track with no cues isn't written.
|
|
1203
|
+
const spokenWords = subtitles
|
|
1204
|
+
? subtitleWords(collectSoundClips(toShow), (source) => readyTranscript(source)?.words)
|
|
1205
|
+
: [];
|
|
1206
|
+
let subtitleSource;
|
|
1207
|
+
if (spokenWords.length) {
|
|
1208
|
+
subtitleSource = new TextSubtitleSource("webvtt");
|
|
1209
|
+
output.addSubtitleTrack(subtitleSource, {
|
|
1210
|
+
languageCode: "eng",
|
|
1211
|
+
name: "Subtitles",
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1178
1214
|
const startTime = performance.now();
|
|
1179
1215
|
await output.start();
|
|
1180
1216
|
infoDiv.innerHTML = "Recording in progress...";
|
|
@@ -1239,6 +1275,11 @@ async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixe
|
|
|
1239
1275
|
}
|
|
1240
1276
|
await audioSource.add(trimmedAudio);
|
|
1241
1277
|
}
|
|
1278
|
+
if (subtitleSource) {
|
|
1279
|
+
const text = webVtt(spokenWords, audioStartMs, audioStartMs + actualAudioMs);
|
|
1280
|
+
if (text)
|
|
1281
|
+
await subtitleSource.add(text);
|
|
1282
|
+
}
|
|
1242
1283
|
infoDiv.innerHTML = "Frames complete. Finalizing video.";
|
|
1243
1284
|
cancelRecordingButton.disabled = true;
|
|
1244
1285
|
await output.finalize(); // Finishes encoding + closes stream automatically
|
|
@@ -1410,7 +1451,63 @@ function updateSaveDialogInfo() {
|
|
|
1410
1451
|
saveInfoFrames.textContent = framesBetween(startMs, endMs).toLocaleString();
|
|
1411
1452
|
saveInfoFrames.style.color = invalid ? "red" : "";
|
|
1412
1453
|
updateSaveSizeNote();
|
|
1413
|
-
|
|
1454
|
+
updateSaveSubtitlesNote(startMs, endMs);
|
|
1455
|
+
}
|
|
1456
|
+
const saveSubtitlesCheckbox = getById("saveSubtitles", HTMLInputElement);
|
|
1457
|
+
const saveSubtitlesNote = getById("saveSubtitlesNote", HTMLSpanElement);
|
|
1458
|
+
/** How many words the subtitles will have, and which sound files have no transcript yet. */
|
|
1459
|
+
function updateSaveSubtitlesNote(startMs, endMs) {
|
|
1460
|
+
const placed = collectSoundClips(toShow);
|
|
1461
|
+
const missing = new Set(placed
|
|
1462
|
+
.map((clip) => clip.source)
|
|
1463
|
+
.filter((source) => !readyTranscript(source))).size;
|
|
1464
|
+
const count = subtitleWords(placed, (source) => readyTranscript(source)?.words).filter((word) => word.startMs >= startMs && word.startMs < endMs).length;
|
|
1465
|
+
const words = `${count.toLocaleString()} ${count === 1 ? "word" : "words"}`;
|
|
1466
|
+
saveSubtitlesNote.textContent = missing
|
|
1467
|
+
? `${words}. ${missing} sound ${missing === 1 ? "file has" : "files have"} no transcript yet, so ${missing === 1 ? "it isn't" : "they aren't"} included.`
|
|
1468
|
+
: words;
|
|
1469
|
+
saveSubtitlesNote.style.color = missing ? "#a06000" : "#555";
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* The subtitles as a file of their own, for YouTube, which ignores the track inside the MP4.
|
|
1473
|
+
* The times match a video saved from the same start and end: the file starts at its first
|
|
1474
|
+
* frame, as startRecording() does.
|
|
1475
|
+
*/
|
|
1476
|
+
getById("saveSubtitlesFileBtn", HTMLButtonElement).addEventListener("click", async () => {
|
|
1477
|
+
const startMs = (saveStartSecondsInput.valueAsNumber || 0) * 1000;
|
|
1478
|
+
const endMs = (saveEndSecondsInput.valueAsNumber || 0) * 1000;
|
|
1479
|
+
const fileStartMs = (firstFrameAtOrAfter(startMs) * 1000) / FPS;
|
|
1480
|
+
const fileEndMs = fileStartMs + (framesBetween(startMs, endMs) * 1000) / FPS;
|
|
1481
|
+
const text = webVtt(subtitleWords(collectSoundClips(toShow), (source) => readyTranscript(source)?.words), fileStartMs, fileEndMs);
|
|
1482
|
+
if (!text) {
|
|
1483
|
+
saveSubtitlesNote.textContent = "No words to save in that range.";
|
|
1484
|
+
saveSubtitlesNote.style.color = "#a06000";
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
try {
|
|
1488
|
+
const fileHandle = await window.showSaveFilePicker({
|
|
1489
|
+
// The same id as the video, so it opens in the same folder.
|
|
1490
|
+
id: "video-save",
|
|
1491
|
+
suggestedName: "canvas-recording.vtt",
|
|
1492
|
+
types: [
|
|
1493
|
+
{ description: "WebVTT subtitles", accept: { "text/vtt": [".vtt"] } },
|
|
1494
|
+
],
|
|
1495
|
+
});
|
|
1496
|
+
const writable = await fileHandle.createWritable();
|
|
1497
|
+
await writable.write(text);
|
|
1498
|
+
await writable.close();
|
|
1499
|
+
saveSubtitlesNote.textContent = `Saved ${fileHandle.name}.`;
|
|
1500
|
+
saveSubtitlesNote.style.color = "#555";
|
|
1501
|
+
}
|
|
1502
|
+
catch (e) {
|
|
1503
|
+
// Closing the file picker is not an error.
|
|
1504
|
+
if (e instanceof DOMException && e.name === "AbortError")
|
|
1505
|
+
return;
|
|
1506
|
+
console.error("Saving the subtitles failed:", e);
|
|
1507
|
+
saveSubtitlesNote.textContent = `Not saved: ${e instanceof Error ? e.message : String(e)}`;
|
|
1508
|
+
saveSubtitlesNote.style.color = "red";
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1414
1511
|
function setSaveRange(startMs, endMs) {
|
|
1415
1512
|
saveStartSecondsInput.value = (startMs / 1000).toString();
|
|
1416
1513
|
saveEndSecondsInput.value = (endMs / 1000).toString();
|
|
@@ -1491,7 +1588,7 @@ saveOkBtn.addEventListener("click", async () => {
|
|
|
1491
1588
|
if (!(await saveDialogLocalFilesReady()))
|
|
1492
1589
|
return;
|
|
1493
1590
|
saveDialog.close();
|
|
1494
|
-
startRecording(startMs, endMs, width, height);
|
|
1591
|
+
startRecording(startMs, endMs, width, height, saveSubtitlesCheckbox.checked);
|
|
1495
1592
|
});
|
|
1496
1593
|
startRecordingButton.addEventListener("click", () => {
|
|
1497
1594
|
populateSaveChapterSelect();
|
|
@@ -1696,23 +1793,32 @@ philDebug.VisualEditor = {
|
|
|
1696
1793
|
get rootComponent() {
|
|
1697
1794
|
return currentRoot();
|
|
1698
1795
|
},
|
|
1796
|
+
/** What the component list shows as selected: the root, when no child is. */
|
|
1699
1797
|
get selectedComponent() {
|
|
1700
|
-
return selectedSlideChild;
|
|
1798
|
+
return selectedSlideChild ?? currentRoot() ?? null;
|
|
1701
1799
|
},
|
|
1702
1800
|
/** Current time in ms relative to the start of the Visual Editor's root. */
|
|
1703
1801
|
get localTimeMs() {
|
|
1704
1802
|
return playheadInRootMs();
|
|
1705
1803
|
},
|
|
1804
|
+
/**
|
|
1805
|
+
* After changing components from the console: show the changes. The same as
|
|
1806
|
+
* {@link VisualEditorAPI.refreshGUI}.
|
|
1807
|
+
* @param howMuch "properties" (the default) after changing values, and "structure" after
|
|
1808
|
+
* adding or removing components. Both save. "sound" rebuilds the sound from its clips, and
|
|
1809
|
+
* doesn't save.
|
|
1810
|
+
*/
|
|
1811
|
+
refreshGUI(howMuch = "properties") {
|
|
1812
|
+
visualEditorAPI.refreshGUI(howMuch);
|
|
1813
|
+
},
|
|
1706
1814
|
};
|
|
1707
1815
|
const scheduleHistoryControls = getById("scheduleHistoryControls", HTMLElement);
|
|
1708
1816
|
const openHistoryDialogBtn = getById("openHistoryDialogBtn", HTMLButtonElement);
|
|
1709
1817
|
const historyDialog = getById("historyDialog", HTMLDialogElement);
|
|
1710
1818
|
const historyList = getById("historyList", HTMLUListElement);
|
|
1711
1819
|
const historyDeleteBtn = getById("historyDeleteBtn", HTMLButtonElement);
|
|
1712
|
-
const
|
|
1713
|
-
const
|
|
1714
|
-
const historyOkBtn = getById("historyOkBtn", HTMLButtonElement);
|
|
1715
|
-
const historyCancelBtn = getById("historyCancelBtn", HTMLButtonElement);
|
|
1820
|
+
const historyDoneBtn = getById("historyDoneBtn", HTMLButtonElement);
|
|
1821
|
+
const historyRevertBtn = getById("historyRevertBtn", HTMLButtonElement);
|
|
1716
1822
|
const historyDialogHint = getById("historyDialogHint", HTMLElement);
|
|
1717
1823
|
/** The single rect keyframe currently in "edit" mode (drag handles shown on canvas). At most one at a time. */
|
|
1718
1824
|
let editingRectKf = null;
|
|
@@ -2158,6 +2264,7 @@ transcriptsCheckbox.addEventListener("change", () => {
|
|
|
2158
2264
|
onTranscriptsChange(() => {
|
|
2159
2265
|
transcriptsStatusSpan.textContent = transcriptsSummary();
|
|
2160
2266
|
timelineDisplay.redraw();
|
|
2267
|
+
requestTranscriptsSync();
|
|
2161
2268
|
});
|
|
2162
2269
|
// The transcript as text. It rebuilds itself when the clips or transcripts
|
|
2163
2270
|
// change, so it needs no calls besides the one in showFrame().
|
|
@@ -2387,7 +2494,7 @@ function clipText(clip, maxWords = Infinity) {
|
|
|
2387
2494
|
*/
|
|
2388
2495
|
function timelineWords(clip, transcript, clipStart) {
|
|
2389
2496
|
const fromMs = clip.startMsIntoClip ?? 0;
|
|
2390
|
-
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcript
|
|
2497
|
+
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcriptVersion(transcript)}`;
|
|
2391
2498
|
const memo = timelineWordsMemo.get(clip);
|
|
2392
2499
|
if (memo?.key === key)
|
|
2393
2500
|
return memo;
|
|
@@ -2689,12 +2796,12 @@ function restorePlace(place) {
|
|
|
2689
2796
|
* restart the user with the same gui settings.
|
|
2690
2797
|
*/
|
|
2691
2798
|
function saveState() {
|
|
2692
|
-
sessionStorage.setItem("place", JSON.stringify(placeToRestore ?? currentPlace()));
|
|
2693
|
-
sessionStorage.setItem("playPositionLocal", playPositionLocal.checked ? "1" : "0");
|
|
2694
|
-
sessionStorage.setItem("zoomSelect", zoomSelect.value);
|
|
2695
|
-
sessionStorage.setItem("panX", panX.toString());
|
|
2696
|
-
sessionStorage.setItem("panY", panY.toString());
|
|
2697
|
-
sessionStorage.setItem("quality", querySelector('input[name="quality"]:checked', HTMLInputElement).value);
|
|
2799
|
+
sessionStorage.setItem(sessionKey("place"), JSON.stringify(placeToRestore ?? currentPlace()));
|
|
2800
|
+
sessionStorage.setItem(sessionKey("playPositionLocal"), playPositionLocal.checked ? "1" : "0");
|
|
2801
|
+
sessionStorage.setItem(sessionKey("zoomSelect"), zoomSelect.value);
|
|
2802
|
+
sessionStorage.setItem(sessionKey("panX"), panX.toString());
|
|
2803
|
+
sessionStorage.setItem(sessionKey("panY"), panY.toString());
|
|
2804
|
+
sessionStorage.setItem(sessionKey("quality"), querySelector('input[name="quality"]:checked', HTMLInputElement).value);
|
|
2698
2805
|
// Splitter positions — only persist if an explicit size was set by drag or restore.
|
|
2699
2806
|
const topLeft = getById("top-left", HTMLDivElement);
|
|
2700
2807
|
const topRight = getById("top-right", HTMLDivElement);
|
|
@@ -2711,6 +2818,24 @@ addEventListener("pagehide", (_event) => {
|
|
|
2711
2818
|
});
|
|
2712
2819
|
// MARK: Schedule persistence (IndexedDB)
|
|
2713
2820
|
const toShowKey = startRequest.name;
|
|
2821
|
+
/**
|
|
2822
|
+
* This video's own sessionStorage key for `name`. Two videos opened in one tab don't share
|
|
2823
|
+
* a place, a zoom or an unload backup. The pane sizes are the window's layout, so they stay
|
|
2824
|
+
* shared, under plain names.
|
|
2825
|
+
*/
|
|
2826
|
+
function sessionKey(name) {
|
|
2827
|
+
return `${name}|${toShowKey}`;
|
|
2828
|
+
}
|
|
2829
|
+
/** Everything {@link sessionKey} names. Before 0.8.4 they were plain names, shared by every video. */
|
|
2830
|
+
const PER_VIDEO_SESSION_KEYS = [
|
|
2831
|
+
"place",
|
|
2832
|
+
"playPositionLocal",
|
|
2833
|
+
"zoomSelect",
|
|
2834
|
+
"panX",
|
|
2835
|
+
"panY",
|
|
2836
|
+
"quality",
|
|
2837
|
+
"pendingScheduleSave",
|
|
2838
|
+
];
|
|
2714
2839
|
function isMarker(e) {
|
|
2715
2840
|
return "kind" in e;
|
|
2716
2841
|
}
|
|
@@ -2956,6 +3081,118 @@ const diffSync = new SyncedFile({
|
|
|
2956
3081
|
// The old Save Diffs button asked every time; its record is only a suggestion.
|
|
2957
3082
|
...keyedSyncStorage(`__diff-save__|${toShowKey}`, false),
|
|
2958
3083
|
});
|
|
3084
|
+
/**
|
|
3085
|
+
* Every transcript the video uses, mirrored to a JSON file, so they can be read and checked
|
|
3086
|
+
* outside the editor: by you, by grep, or by Claude. It's only a copy. The transcripts
|
|
3087
|
+
* themselves, with the Transcript Editor's changes, live in IndexedDB.
|
|
3088
|
+
*/
|
|
3089
|
+
const transcriptsSync = new SyncedFile({
|
|
3090
|
+
checkbox: getById("transcriptsSyncCheckbox", HTMLInputElement),
|
|
3091
|
+
status: getById("transcriptsSyncStatus", HTMLSpanElement),
|
|
3092
|
+
picker: {
|
|
3093
|
+
id: "transcripts-save",
|
|
3094
|
+
types: JSON_FILE_TYPES,
|
|
3095
|
+
defaultName: () => `${toShowKey || "video"}-transcripts.json`,
|
|
3096
|
+
},
|
|
3097
|
+
render: () => transcriptsFileText(toShowKey, videoTranscripts()),
|
|
3098
|
+
...keyedSyncStorage(`__transcripts-save__|${toShowKey}`, false),
|
|
3099
|
+
});
|
|
3100
|
+
/**
|
|
3101
|
+
* Each sound file the whole video uses, once, in order of first use. Asking about a file
|
|
3102
|
+
* starts its transcript, so this only runs while the transcripts file is being synced.
|
|
3103
|
+
*/
|
|
3104
|
+
function videoTranscripts() {
|
|
3105
|
+
const usesBySource = new Map();
|
|
3106
|
+
const placed = collectSoundClips(toShow).sort((a, b) => a.startMs - b.startMs);
|
|
3107
|
+
for (const clip of placed) {
|
|
3108
|
+
let uses = usesBySource.get(clip.source);
|
|
3109
|
+
if (!uses)
|
|
3110
|
+
usesBySource.set(clip.source, (uses = []));
|
|
3111
|
+
uses.push({
|
|
3112
|
+
startsInVideoMs: clip.startMs,
|
|
3113
|
+
playsFileFromMs: clip.trimMs,
|
|
3114
|
+
playsFileToMs: Number.isFinite(clip.lengthMs)
|
|
3115
|
+
? clip.trimMs + clip.lengthMs
|
|
3116
|
+
: null,
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
return [...usesBySource].map(([source, uses]) => {
|
|
3120
|
+
const status = transcriptStatus(source);
|
|
3121
|
+
return {
|
|
3122
|
+
source,
|
|
3123
|
+
transcript: status?.kind === "ready" ? status.transcript : undefined,
|
|
3124
|
+
status: !status
|
|
3125
|
+
? "transcripts are off"
|
|
3126
|
+
: (statusText(status) ?? status.kind),
|
|
3127
|
+
uses,
|
|
3128
|
+
};
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3131
|
+
/** What the transcripts file was last asked to show. See {@link requestTranscriptsSync}. */
|
|
3132
|
+
let transcriptsSyncSignature = "";
|
|
3133
|
+
/**
|
|
3134
|
+
* Bring the transcripts file up to date, if anything in it could have changed: a transcript,
|
|
3135
|
+
* or which part of which file the video plays. Cheap when nothing did, so call it often.
|
|
3136
|
+
*/
|
|
3137
|
+
function requestTranscriptsSync() {
|
|
3138
|
+
if (!transcriptsSync.handle)
|
|
3139
|
+
return;
|
|
3140
|
+
const placed = collectSoundClips(toShow);
|
|
3141
|
+
const signature = JSON.stringify(placed.map((clip) => {
|
|
3142
|
+
const transcript = readyTranscript(clip.source);
|
|
3143
|
+
return [
|
|
3144
|
+
clip.source,
|
|
3145
|
+
clip.startMs,
|
|
3146
|
+
clip.trimMs,
|
|
3147
|
+
clip.lengthMs,
|
|
3148
|
+
transcript ? transcriptVersion(transcript) : 0,
|
|
3149
|
+
];
|
|
3150
|
+
}));
|
|
3151
|
+
if (signature === transcriptsSyncSignature)
|
|
3152
|
+
return;
|
|
3153
|
+
transcriptsSyncSignature = signature;
|
|
3154
|
+
transcriptsSync.request();
|
|
3155
|
+
}
|
|
3156
|
+
// MARK: 💾 Files
|
|
3157
|
+
const filesBtn = getById("filesBtn", HTMLButtonElement);
|
|
3158
|
+
const filesDialog = getById("filesDialog", HTMLDialogElement);
|
|
3159
|
+
filesBtn.addEventListener("click", () => filesDialog.showModal());
|
|
3160
|
+
getById("filesDialogCloseBtn", HTMLButtonElement).addEventListener("click", () => filesDialog.close());
|
|
3161
|
+
/**
|
|
3162
|
+
* The button stands for every synced file: red when one needs a click, orange while one is
|
|
3163
|
+
* waiting for the next save. Its tooltip lists them.
|
|
3164
|
+
*/
|
|
3165
|
+
function drawFilesButton() {
|
|
3166
|
+
const syncs = [
|
|
3167
|
+
["Sync to file", jsonSync],
|
|
3168
|
+
["Sync defaults", defaultsSync],
|
|
3169
|
+
["Sync diffs", diffSync],
|
|
3170
|
+
["Sync transcripts", transcriptsSync],
|
|
3171
|
+
];
|
|
3172
|
+
const summaries = syncs.map(([, sync]) => sync.summary);
|
|
3173
|
+
const action = summaries.includes("action");
|
|
3174
|
+
const pending = summaries.includes("pending");
|
|
3175
|
+
filesBtn.textContent = `💾 Files${action ? " ⚠" : ""}`;
|
|
3176
|
+
if (pending && !action) {
|
|
3177
|
+
// Only the asterisk is orange: an orange button was too distracting.
|
|
3178
|
+
const star = document.createElement("span");
|
|
3179
|
+
star.textContent = " *";
|
|
3180
|
+
star.style.color = "#ef6c00";
|
|
3181
|
+
star.style.fontWeight = "bold";
|
|
3182
|
+
filesBtn.append(star);
|
|
3183
|
+
}
|
|
3184
|
+
filesBtn.style.background = action ? "#e53935" : "";
|
|
3185
|
+
filesBtn.style.color = action ? "white" : "";
|
|
3186
|
+
filesBtn.title = [
|
|
3187
|
+
action
|
|
3188
|
+
? "Something needs a click. Open this to see what."
|
|
3189
|
+
: "Import, Save Copy As, and the files on disk that follow your work.",
|
|
3190
|
+
"",
|
|
3191
|
+
...syncs.map(([name, sync]) => `${name}: ${sync.statusText}`),
|
|
3192
|
+
].join("\n");
|
|
3193
|
+
}
|
|
3194
|
+
onSyncStatusChange(drawFilesButton);
|
|
3195
|
+
drawFilesButton();
|
|
2959
3196
|
/** The code-defined starting point, in the same format as {@link buildJsonSnapshot}. */
|
|
2960
3197
|
function buildDefaultsSnapshot() {
|
|
2961
3198
|
return {
|
|
@@ -3488,7 +3725,7 @@ async function initFromDB(unloadBackup) {
|
|
|
3488
3725
|
_loadSource = source;
|
|
3489
3726
|
_baselineTreeJson = currentTreeJson();
|
|
3490
3727
|
// The unload backup is in the database now, or older than it. See the end of "Load previous state".
|
|
3491
|
-
sessionStorage.removeItem("pendingScheduleSave");
|
|
3728
|
+
sessionStorage.removeItem(sessionKey("pendingScheduleSave"));
|
|
3492
3729
|
canvas.style.visibility = "";
|
|
3493
3730
|
canvasLoading.style.display = "none";
|
|
3494
3731
|
const currentSel = currentRoot();
|
|
@@ -3529,6 +3766,7 @@ async function saveVideoState(force = false) {
|
|
|
3529
3766
|
finally {
|
|
3530
3767
|
jsonSync.request();
|
|
3531
3768
|
diffSync.request();
|
|
3769
|
+
requestTranscriptsSync();
|
|
3532
3770
|
}
|
|
3533
3771
|
}
|
|
3534
3772
|
async function saveVideoStateToDb(force) {
|
|
@@ -3629,7 +3867,7 @@ function saveOnUnload() {
|
|
|
3629
3867
|
if (dirty && !previewing)
|
|
3630
3868
|
void saveVideoState();
|
|
3631
3869
|
try {
|
|
3632
|
-
sessionStorage.setItem("pendingScheduleSave", JSON.stringify([backup]));
|
|
3870
|
+
sessionStorage.setItem(sessionKey("pendingScheduleSave"), JSON.stringify([backup]));
|
|
3633
3871
|
}
|
|
3634
3872
|
catch (e) {
|
|
3635
3873
|
// One whole tree can exceed the ~5MB sessionStorage quota on a big video. The
|
|
@@ -3649,16 +3887,43 @@ let _allHistoryEntries = [];
|
|
|
3649
3887
|
let _dialogFileRecords = [];
|
|
3650
3888
|
/** Async load state for each filename; populated after the dialog opens. */
|
|
3651
3889
|
const _dialogFileStates = new Map();
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3890
|
+
/** What the dialog had selected when it opened, as {@link _dialogItemKey} says it. */
|
|
3891
|
+
let _initialItemKey;
|
|
3892
|
+
/** Names an entry, so it can be found again after the list is rebuilt. */
|
|
3893
|
+
function _dialogItemKey(item) {
|
|
3894
|
+
switch (item?.kind) {
|
|
3895
|
+
case undefined:
|
|
3896
|
+
return undefined;
|
|
3897
|
+
case "ts-defaults":
|
|
3898
|
+
return "ts-defaults";
|
|
3899
|
+
case "db-entry":
|
|
3900
|
+
return `db ${item.entry.timestamp}`;
|
|
3901
|
+
case "file-entry":
|
|
3902
|
+
return `file ${item.fileRecord.filename}`;
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
/** True if the selected entry isn't the one loaded when the dialog opened. */
|
|
3906
|
+
function _dialogChanged() {
|
|
3907
|
+
return (_selectedDialogIndex >= 0 &&
|
|
3908
|
+
_dialogItemKey(_dialogItems[_selectedDialogIndex]) !== _initialItemKey);
|
|
3909
|
+
}
|
|
3910
|
+
/** Mark an entry selected in the list, without loading it. -1 for none. */
|
|
3911
|
+
function _highlightDialogItem(index) {
|
|
3655
3912
|
_selectedDialogIndex = index;
|
|
3656
3913
|
for (let i = 0; i < historyList.children.length; i++) {
|
|
3657
3914
|
historyList.children[i].classList.toggle("selected", i === index);
|
|
3658
3915
|
}
|
|
3659
3916
|
const item = _dialogItems[index];
|
|
3660
3917
|
// Top item (index 0) and ts-defaults are never deletable.
|
|
3661
|
-
historyDeleteBtn.disabled =
|
|
3918
|
+
historyDeleteBtn.disabled =
|
|
3919
|
+
!item || index === 0 || item.kind === "ts-defaults";
|
|
3920
|
+
historyRevertBtn.disabled = !_dialogChanged();
|
|
3921
|
+
}
|
|
3922
|
+
function _dialogSelectItem(index, target) {
|
|
3923
|
+
if (index < 0 || index >= _dialogItems.length)
|
|
3924
|
+
return;
|
|
3925
|
+
_highlightDialogItem(index);
|
|
3926
|
+
const item = _dialogItems[index];
|
|
3662
3927
|
// Preview the selected state
|
|
3663
3928
|
if (item.kind === "ts-defaults") {
|
|
3664
3929
|
applyTsDefaults(target);
|
|
@@ -3675,10 +3940,6 @@ function _dialogSelectItem(index, target) {
|
|
|
3675
3940
|
updateComponentEditor(target);
|
|
3676
3941
|
updateScheduleEditor(target);
|
|
3677
3942
|
afterStateApplied();
|
|
3678
|
-
// The Abandon/Save buttons are no longer used; only Keep is shown.
|
|
3679
|
-
historyOkBtn.hidden = false;
|
|
3680
|
-
historyAbandonBtn.hidden = true;
|
|
3681
|
-
historySaveBtn.hidden = true;
|
|
3682
3943
|
}
|
|
3683
3944
|
/**
|
|
3684
3945
|
* Rebuilds _dialogItems and the list DOM by merging DB entries, file records,
|
|
@@ -3864,7 +4125,10 @@ async function openHistoryDialog(target) {
|
|
|
3864
4125
|
_dialogFileStates.set(fr.filename, { status: "loading" });
|
|
3865
4126
|
}
|
|
3866
4127
|
}
|
|
4128
|
+
_initialItemKey = undefined;
|
|
3867
4129
|
_rebuildDialogList(target);
|
|
4130
|
+
_initialItemKey = _dialogItemKey(_dialogItems[_selectedDialogIndex]);
|
|
4131
|
+
historyRevertBtn.disabled = true;
|
|
3868
4132
|
historyDialog.showModal();
|
|
3869
4133
|
historyList.focus();
|
|
3870
4134
|
// Populate file entry contents asynchronously (grayed out until ready).
|
|
@@ -3904,32 +4168,29 @@ async function _applyDialogSelection() {
|
|
|
3904
4168
|
updateScheduleEditor(target);
|
|
3905
4169
|
afterStateApplied();
|
|
3906
4170
|
}
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
4171
|
+
// Done and Escape both close, and closing keeps the entry chosen. Every choice is already
|
|
4172
|
+
// on the canvas; this saves it, so a reload brings it back. Nothing changed, nothing saved.
|
|
4173
|
+
historyDoneBtn.addEventListener("click", () => historyDialog.close());
|
|
4174
|
+
historyDialog.addEventListener("close", () => {
|
|
4175
|
+
if (_dialogChanged())
|
|
4176
|
+
void _applyDialogSelection();
|
|
3910
4177
|
});
|
|
3911
|
-
|
|
3912
|
-
//
|
|
3913
|
-
historyDialog.close();
|
|
3914
|
-
});
|
|
3915
|
-
historySaveBtn.addEventListener("click", () => {
|
|
3916
|
-
// No longer shown; kept for safety.
|
|
3917
|
-
historyDialog.close();
|
|
3918
|
-
});
|
|
3919
|
-
historyCancelBtn.addEventListener("click", () => {
|
|
3920
|
-
// Revert to the state before the dialog opened. The snapshot covers the whole video, so
|
|
4178
|
+
historyRevertBtn.addEventListener("click", () => {
|
|
4179
|
+
// Put back the state from before the dialog opened. The snapshot covers the whole video, so
|
|
3921
4180
|
// restore the whole video -- a preview may have been scoped to one chapter, but undoing it
|
|
3922
4181
|
// against `target` alone would apply the root's state to that chapter.
|
|
3923
4182
|
const target = _historyTarget;
|
|
3924
|
-
if (target)
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
4183
|
+
if (!target)
|
|
4184
|
+
return;
|
|
4185
|
+
applyTree(toShow, loadableTree(JSON.parse(_preDialogSnapshotJson)));
|
|
4186
|
+
selectedSlideChild = null;
|
|
4187
|
+
activeRootComponentEditor?.resetAll();
|
|
4188
|
+
updateComponentEditor(target);
|
|
4189
|
+
updateScheduleEditor(target);
|
|
4190
|
+
afterStateApplied();
|
|
4191
|
+
// Select the entry it came from, without loading it again: the snapshot is exact.
|
|
4192
|
+
_highlightDialogItem(_dialogItems.findIndex((item) => _dialogItemKey(item) === _initialItemKey));
|
|
4193
|
+
historyList.focus();
|
|
3933
4194
|
});
|
|
3934
4195
|
historyDeleteBtn.addEventListener("click", async () => {
|
|
3935
4196
|
const target = _historyTarget;
|
|
@@ -4107,7 +4368,7 @@ function buildScheduleSection(info, selectable) {
|
|
|
4107
4368
|
rebuild();
|
|
4108
4369
|
}
|
|
4109
4370
|
const legend = document.createElement("legend");
|
|
4110
|
-
legend.textContent = info
|
|
4371
|
+
legend.textContent = propertyLabel(info) + " ";
|
|
4111
4372
|
const addBtn = document.createElement("button");
|
|
4112
4373
|
addBtn.type = "button";
|
|
4113
4374
|
addBtn.textContent = "+ Add";
|
|
@@ -4228,6 +4489,15 @@ function buildScheduleSection(info, selectable) {
|
|
|
4228
4489
|
const durationLabel = info.timeAxisLabel
|
|
4229
4490
|
? `Δ ${info.timeAxisLabel}`
|
|
4230
4491
|
: "Duration (ms)";
|
|
4492
|
+
/**
|
|
4493
|
+
* A text box takes any spare width. The table fills the panel, and its Value column asks
|
|
4494
|
+
* for all of it. That alone would squeeze the other columns to their narrowest, wrapping
|
|
4495
|
+
* "Go To", so `.grow-value` in canvas-recorder.css keeps the headers on one line until the
|
|
4496
|
+
* panel is really too narrow.
|
|
4497
|
+
*/
|
|
4498
|
+
const growValue = info.type === "string" && !info.useDialog && !info.choices?.length;
|
|
4499
|
+
if (growValue)
|
|
4500
|
+
table.style.width = "100%";
|
|
4231
4501
|
for (const h of [
|
|
4232
4502
|
showDurations ? durationLabel : timeLabel,
|
|
4233
4503
|
...valueHeaders,
|
|
@@ -4237,6 +4507,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4237
4507
|
]) {
|
|
4238
4508
|
const th = document.createElement("th");
|
|
4239
4509
|
th.textContent = h;
|
|
4510
|
+
if (growValue && h === "Value")
|
|
4511
|
+
th.style.width = "100%";
|
|
4240
4512
|
headerRow.append(th);
|
|
4241
4513
|
}
|
|
4242
4514
|
// Maps each keyframe object to its ease cell, so visibility updates
|
|
@@ -4484,6 +4756,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4484
4756
|
input.value = strKf.value;
|
|
4485
4757
|
input.style.cssText =
|
|
4486
4758
|
"width:100%;box-sizing:border-box;resize:vertical";
|
|
4759
|
+
// See growValue.
|
|
4760
|
+
cell.style.width = "100%";
|
|
4487
4761
|
input.addEventListener("input", () => {
|
|
4488
4762
|
strKf.value = input.value;
|
|
4489
4763
|
});
|
|
@@ -4496,7 +4770,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4496
4770
|
const sel = addName(document.createElement("select"));
|
|
4497
4771
|
for (const choice of info.choices) {
|
|
4498
4772
|
const opt = document.createElement("option");
|
|
4499
|
-
opt.value =
|
|
4773
|
+
opt.value = choice;
|
|
4774
|
+
opt.textContent = choiceLabel(info, choice);
|
|
4500
4775
|
sel.append(opt);
|
|
4501
4776
|
}
|
|
4502
4777
|
sel.value = strKf.value;
|
|
@@ -4852,7 +5127,15 @@ function buildScheduleSection(info, selectable) {
|
|
|
4852
5127
|
// Also fills in the "at …" labels in Durations mode.
|
|
4853
5128
|
refreshRippled();
|
|
4854
5129
|
table.append(tbody);
|
|
4855
|
-
|
|
5130
|
+
if (growValue) {
|
|
5131
|
+
const wrapper = document.createElement("div");
|
|
5132
|
+
wrapper.className = "grow-value";
|
|
5133
|
+
wrapper.append(table);
|
|
5134
|
+
section.append(wrapper);
|
|
5135
|
+
}
|
|
5136
|
+
else {
|
|
5137
|
+
section.append(table);
|
|
5138
|
+
}
|
|
4856
5139
|
section.addEventListener("input", () => {
|
|
4857
5140
|
activeRootComponentEditor?.update(selectable, info);
|
|
4858
5141
|
});
|
|
@@ -5041,7 +5324,7 @@ function updateComponentEditor(selectable) {
|
|
|
5041
5324
|
const pasteIntoBtn = document.createElement("button");
|
|
5042
5325
|
pasteIntoBtn.type = "button";
|
|
5043
5326
|
pasteIntoBtn.textContent = "📋 → 🖥️";
|
|
5044
|
-
pasteIntoBtn.title = `Paste into "${child.description}"`;
|
|
5327
|
+
pasteIntoBtn.title = `Paste into "${child.userEditableDescription ?? child.description}"`;
|
|
5045
5328
|
pasteIntoBtn.addEventListener("click", () => pasteInto(child, selectable));
|
|
5046
5329
|
row.append(pasteIntoBtn);
|
|
5047
5330
|
}
|
|
@@ -5080,7 +5363,7 @@ function updateComponentEditor(selectable) {
|
|
|
5080
5363
|
const rootPasteBtn = document.createElement("button");
|
|
5081
5364
|
rootPasteBtn.type = "button";
|
|
5082
5365
|
rootPasteBtn.textContent = "📋 → 🖥️";
|
|
5083
|
-
rootPasteBtn.title = `Paste into "${selectable.description}"`;
|
|
5366
|
+
rootPasteBtn.title = `Paste into "${selectable.userEditableDescription ?? selectable.description}"`;
|
|
5084
5367
|
rootPasteBtn.addEventListener("click", () => pasteInto(selectable, selectable));
|
|
5085
5368
|
rootRow.append(rootEditBtn);
|
|
5086
5369
|
if (selectable.setDuration !== undefined) {
|
|
@@ -5381,6 +5664,44 @@ function buildSoundClipSection(selectable) {
|
|
|
5381
5664
|
});
|
|
5382
5665
|
downloadBlob(transcriptFileName(clip.source), new Blob([json], { type: "application/json" }));
|
|
5383
5666
|
});
|
|
5667
|
+
const editTranscriptBtn = document.createElement("button");
|
|
5668
|
+
editTranscriptBtn.type = "button";
|
|
5669
|
+
editTranscriptBtn.textContent = "✎";
|
|
5670
|
+
editTranscriptBtn.title =
|
|
5671
|
+
"Edit Transcript… Fix this file's words and their times, for the timeline, 📖 Text and the subtitles.";
|
|
5672
|
+
editTranscriptBtn.addEventListener("click", () => {
|
|
5673
|
+
if (!readyTranscript(clip.source)) {
|
|
5674
|
+
alert(transcriptsEnabled()
|
|
5675
|
+
? "This clip's transcript isn't ready yet. Its progress shows on the timeline."
|
|
5676
|
+
: "Transcripts are off. Turn on 🗣 Transcripts above the timeline.");
|
|
5677
|
+
return;
|
|
5678
|
+
}
|
|
5679
|
+
const fromMs = clip.startMsIntoClip ?? 0;
|
|
5680
|
+
const playheadInFile = playheadInOwner() - clip.startMsIntoScene + fromMs;
|
|
5681
|
+
const lengthMs = soundClipLengthMs(clip) ?? Infinity;
|
|
5682
|
+
openTranscriptEditor({
|
|
5683
|
+
source: clip.source,
|
|
5684
|
+
words: () => readyTranscript(clip.source)?.words,
|
|
5685
|
+
setWords: (words) => editTranscript(clip.source, words),
|
|
5686
|
+
audio: () => soundtrack.getDecodedBuffer(clip.source),
|
|
5687
|
+
// Every clip in the video that plays this file, not just this one.
|
|
5688
|
+
used: collectSoundClips(toShow)
|
|
5689
|
+
.filter((placed) => placed.source === clip.source)
|
|
5690
|
+
.map((placed) => ({
|
|
5691
|
+
fromMs: placed.trimMs,
|
|
5692
|
+
toMs: placed.trimMs + placed.lengthMs,
|
|
5693
|
+
})),
|
|
5694
|
+
// The playhead, if it's in this clip, or else the clip's start.
|
|
5695
|
+
startAtMs: playheadInFile >= fromMs && playheadInFile < fromMs + lengthMs
|
|
5696
|
+
? playheadInFile
|
|
5697
|
+
: fromMs,
|
|
5698
|
+
pausePlayer() {
|
|
5699
|
+
playCheckBox.checked = false;
|
|
5700
|
+
stopAudio();
|
|
5701
|
+
},
|
|
5702
|
+
closed: () => timelineDisplay.redraw(),
|
|
5703
|
+
});
|
|
5704
|
+
});
|
|
5384
5705
|
const splitBtn = document.createElement("button");
|
|
5385
5706
|
splitBtn.type = "button";
|
|
5386
5707
|
splitBtn.textContent = "✂";
|
|
@@ -5420,7 +5741,7 @@ function buildSoundClipSection(selectable) {
|
|
|
5420
5741
|
selectedSoundClip = kept[0];
|
|
5421
5742
|
afterStructureChange();
|
|
5422
5743
|
});
|
|
5423
|
-
row1.append(notesInput, fromTranscriptBtn, saveTranscriptBtn, splitBtn, upBtn, downBtn, delBtn);
|
|
5744
|
+
row1.append(notesInput, fromTranscriptBtn, saveTranscriptBtn, editTranscriptBtn, splitBtn, upBtn, downBtn, delBtn);
|
|
5424
5745
|
// Row 2: source URL
|
|
5425
5746
|
const row2 = document.createElement("div");
|
|
5426
5747
|
row2.style.cssText =
|
|
@@ -6799,8 +7120,10 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6799
7120
|
}
|
|
6800
7121
|
// MARK: Load previous state.
|
|
6801
7122
|
{
|
|
6802
|
-
//
|
|
6803
|
-
|
|
7123
|
+
// This video's unload backup, if the last session left one. Before 0.8.4 it was under a
|
|
7124
|
+
// plain name, for whichever video was open last. initFromDB() checks that it's this one's.
|
|
7125
|
+
const unloadBackup = sessionStorage.getItem(sessionKey("pendingScheduleSave")) ??
|
|
7126
|
+
sessionStorage.getItem("pendingScheduleSave");
|
|
6804
7127
|
// Hide the canvas until DB restoration is complete to prevent the TypeScript-
|
|
6805
7128
|
// default state from flashing briefly before the saved state is applied.
|
|
6806
7129
|
canvas.style.visibility = "hidden";
|
|
@@ -6832,6 +7155,7 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6832
7155
|
jsonSync.request();
|
|
6833
7156
|
diffSync.request();
|
|
6834
7157
|
defaultsSync.request();
|
|
7158
|
+
requestTranscriptsSync();
|
|
6835
7159
|
});
|
|
6836
7160
|
// Sanity-check DB for timestamps in the future (clock skew, corrupted data).
|
|
6837
7161
|
void (async () => {
|
|
@@ -6853,19 +7177,19 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6853
7177
|
// So when you configure the web page, and you hit refresh, or the page automatically
|
|
6854
7178
|
// refreshes, you don't lose your settings.
|
|
6855
7179
|
try {
|
|
6856
|
-
if (sessionStorage.getItem("playPositionLocal") === "0") {
|
|
7180
|
+
if (sessionStorage.getItem(sessionKey("playPositionLocal")) === "0") {
|
|
6857
7181
|
const playheadMs = playheadInVideoMs();
|
|
6858
7182
|
playPositionLocal.checked = false;
|
|
6859
7183
|
loadPlayPositionSeconds(playheadMs);
|
|
6860
7184
|
}
|
|
6861
7185
|
// Applied when the saved tree is in: see initFromDB() above.
|
|
6862
|
-
placeToRestore = parseSavedPlace(sessionStorage.getItem("place"));
|
|
6863
|
-
if (sessionStorage.getItem("quality") === "Low Power") {
|
|
7186
|
+
placeToRestore = parseSavedPlace(sessionStorage.getItem(sessionKey("place")));
|
|
7187
|
+
if (sessionStorage.getItem(sessionKey("quality")) === "Low Power") {
|
|
6864
7188
|
getById("lowPower", HTMLInputElement).checked = true;
|
|
6865
7189
|
}
|
|
6866
|
-
const savedZoom = sessionStorage.getItem("zoomSelect");
|
|
6867
|
-
const savedPanX = parseFloatX(sessionStorage.getItem("panX") ?? "");
|
|
6868
|
-
const savedPanY = parseFloatX(sessionStorage.getItem("panY") ?? "");
|
|
7190
|
+
const savedZoom = sessionStorage.getItem(sessionKey("zoomSelect"));
|
|
7191
|
+
const savedPanX = parseFloatX(sessionStorage.getItem(sessionKey("panX")) ?? "");
|
|
7192
|
+
const savedPanY = parseFloatX(sessionStorage.getItem(sessionKey("panY")) ?? "");
|
|
6869
7193
|
if (savedZoom !== null) {
|
|
6870
7194
|
zoomSelect.value = savedZoom;
|
|
6871
7195
|
}
|
|
@@ -6878,7 +7202,7 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6878
7202
|
else {
|
|
6879
7203
|
zoomToFit();
|
|
6880
7204
|
}
|
|
6881
|
-
// Restore splitter positions
|
|
7205
|
+
// Restore splitter positions. Shared by every video: they're the window's layout.
|
|
6882
7206
|
// Values are stored as "XX.XX%" (new format) or a bare number in pixels (old).
|
|
6883
7207
|
const topLeftH = sessionStorage.getItem("pane-height-top-left") ?? "";
|
|
6884
7208
|
const topRightH = sessionStorage.getItem("pane-height-top-right") ?? "";
|
|
@@ -6900,12 +7224,22 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6900
7224
|
getById("left-col", HTMLDivElement).style.flex = fL;
|
|
6901
7225
|
}
|
|
6902
7226
|
finally {
|
|
6903
|
-
|
|
6904
|
-
//
|
|
6905
|
-
//
|
|
6906
|
-
|
|
7227
|
+
// Each value is read once, at startup. saveState() writes them again as the page goes.
|
|
7228
|
+
// Only this video's: another video in this tab keeps its own until it loads.
|
|
7229
|
+
// The plain names are from before 0.8.4, when every video shared them.
|
|
7230
|
+
for (const name of PER_VIDEO_SESSION_KEYS) {
|
|
7231
|
+
sessionStorage.removeItem(name);
|
|
7232
|
+
// Keep the unload backup until initFromDB() has saved it. If the page reloads before
|
|
7233
|
+
// then, saveOnUnload() saves nothing, so this is the only copy.
|
|
7234
|
+
if (name !== "pendingScheduleSave") {
|
|
7235
|
+
sessionStorage.removeItem(sessionKey(name));
|
|
7236
|
+
}
|
|
7237
|
+
}
|
|
7238
|
+
if (unloadBackup !== null &&
|
|
7239
|
+
sessionStorage.getItem(sessionKey("pendingScheduleSave")) === null) {
|
|
7240
|
+
// It was under the old plain name, removed just above.
|
|
6907
7241
|
try {
|
|
6908
|
-
sessionStorage.setItem("pendingScheduleSave", unloadBackup);
|
|
7242
|
+
sessionStorage.setItem(sessionKey("pendingScheduleSave"), unloadBackup);
|
|
6909
7243
|
}
|
|
6910
7244
|
catch {
|
|
6911
7245
|
// It fit a moment ago.
|