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
package/dev/canvas-recorder.ts
CHANGED
|
@@ -19,10 +19,13 @@ import {
|
|
|
19
19
|
Mp4OutputFormat,
|
|
20
20
|
AudioBufferSource,
|
|
21
21
|
QUALITY_HIGH,
|
|
22
|
+
TextSubtitleSource,
|
|
22
23
|
} from "mediabunny";
|
|
23
24
|
import {
|
|
25
|
+
choiceLabel,
|
|
24
26
|
EditorPanel,
|
|
25
27
|
EditorPanelAPI,
|
|
28
|
+
propertyLabel,
|
|
26
29
|
RootComponentEditor,
|
|
27
30
|
SerializedScalar,
|
|
28
31
|
SerializedSchedule,
|
|
@@ -38,9 +41,10 @@ import {
|
|
|
38
41
|
interpolateNumbers,
|
|
39
42
|
interpolatePoints,
|
|
40
43
|
interpolateRects,
|
|
41
|
-
|
|
44
|
+
TimedKeyframe,
|
|
42
45
|
} from "../src/interpolate.ts";
|
|
43
46
|
import { Lattice, LatticeValue } from "../src/lattice.ts";
|
|
47
|
+
import { checkPanAndZoom } from "../src/glib/transforms.ts";
|
|
44
48
|
import { ArrowValue, interpolateArrow } from "../src/schedule-helper.ts";
|
|
45
49
|
import {
|
|
46
50
|
applyJsonEntry,
|
|
@@ -63,7 +67,7 @@ import {
|
|
|
63
67
|
} from "../src/snapshot.ts";
|
|
64
68
|
import { downloadBlob, philDebug } from "../src/utility.ts";
|
|
65
69
|
import { debugLog, getNewDebugLogEntries } from "../src/debug-log.ts";
|
|
66
|
-
import { SAMPLE_RATE, Soundtrack } from "./soundtrack.ts";
|
|
70
|
+
import { collectSoundClips, SAMPLE_RATE, Soundtrack } from "./soundtrack.ts";
|
|
67
71
|
import { openVoicePanel, type VoicePanel } from "./voice/voice-panel.ts";
|
|
68
72
|
import type { RecordedClip, VoiceRecorder } from "./voice/voice-recorder.ts";
|
|
69
73
|
import { openColorPickerDialog } from "./color-picker.ts";
|
|
@@ -93,13 +97,18 @@ import {
|
|
|
93
97
|
tidyMs,
|
|
94
98
|
} from "./sound-clips.ts";
|
|
95
99
|
import { askHowToSplit, askHowToSplitSound } from "./split-dialog.ts";
|
|
96
|
-
import {
|
|
100
|
+
import {
|
|
101
|
+
onSyncStatusChange,
|
|
102
|
+
SyncedFile,
|
|
103
|
+
type SyncedFileOptions,
|
|
104
|
+
} from "./synced-file.ts";
|
|
97
105
|
import {
|
|
98
106
|
TimelineDisplay,
|
|
99
107
|
type TimelineBlock,
|
|
100
108
|
type TimelineWord,
|
|
101
109
|
} from "./timeline-display.ts";
|
|
102
110
|
import {
|
|
111
|
+
editTranscript,
|
|
103
112
|
forgetTranscriptFailures,
|
|
104
113
|
forgetTranscripts,
|
|
105
114
|
makeTranscript,
|
|
@@ -111,8 +120,16 @@ import {
|
|
|
111
120
|
transcriptsEnabled,
|
|
112
121
|
transcriptStatus,
|
|
113
122
|
transcriptsSummary,
|
|
123
|
+
transcriptVersion,
|
|
114
124
|
} from "./transcripts.ts";
|
|
115
|
-
import {
|
|
125
|
+
import {
|
|
126
|
+
transcriptFileName,
|
|
127
|
+
transcriptJson,
|
|
128
|
+
transcriptsFileText,
|
|
129
|
+
type VideoTranscript,
|
|
130
|
+
} from "./transcript-export.ts";
|
|
131
|
+
import { openTranscriptEditor } from "./transcript-editor.ts";
|
|
132
|
+
import { subtitleWords, webVtt } from "./subtitles.ts";
|
|
116
133
|
import { wordFlag } from "./transcript-align.ts";
|
|
117
134
|
import type { Device } from "./transcribe-core.ts";
|
|
118
135
|
import { canvasRecorder, type VideoSize } from "../lib/main-control.ts";
|
|
@@ -577,7 +594,7 @@ function showFrame(timeInMs: number, live: boolean) {
|
|
|
577
594
|
// Two separate things, though they usually agree:
|
|
578
595
|
//
|
|
579
596
|
// * The **root**: the component the Visual Editor works on, picked in the
|
|
580
|
-
// chapter <select>.
|
|
597
|
+
// chapter <select>. TimedKeyframe times, the timeline at the bottom, and every
|
|
581
598
|
// "now" the editors show are measured from the root's start. See
|
|
582
599
|
// rootStartMs and playheadInRootMs().
|
|
583
600
|
// * The **play limits**: where playback wraps or stops, and the ends of the
|
|
@@ -607,7 +624,7 @@ let sectionStartTime = 0;
|
|
|
607
624
|
let sectionEndTime = 0;
|
|
608
625
|
|
|
609
626
|
/**
|
|
610
|
-
* When the Visual Editor's root starts, in video time.
|
|
627
|
+
* When the Visual Editor's root starts, in video time. TimedKeyframe times, the
|
|
611
628
|
* timeline, and every "now" the editors show are measured from here.
|
|
612
629
|
*/
|
|
613
630
|
let rootStartMs = 0;
|
|
@@ -1128,6 +1145,33 @@ addEventListener("keydown", (event) => {
|
|
|
1128
1145
|
}
|
|
1129
1146
|
});
|
|
1130
1147
|
|
|
1148
|
+
// The math's self-test, once per page load. It used to run as transforms.ts loaded, which
|
|
1149
|
+
// kept PathShape and everything that uses it out of Node.
|
|
1150
|
+
checkPanAndZoom();
|
|
1151
|
+
|
|
1152
|
+
// MARK: Wheel over a number
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Chrome changes a focused number field when the wheel, or a two finger scroll, passes over
|
|
1156
|
+
* it. Here that's nearly always an accident: scrolling the properties to find the next
|
|
1157
|
+
* one. And Cmd+Z can't undo it. So the field gives up the focus first, and the wheel
|
|
1158
|
+
* scrolls as usual. Typing and the field's arrows still work.
|
|
1159
|
+
*/
|
|
1160
|
+
document.addEventListener(
|
|
1161
|
+
"wheel",
|
|
1162
|
+
(event) => {
|
|
1163
|
+
const target = event.target;
|
|
1164
|
+
if (
|
|
1165
|
+
target instanceof HTMLInputElement &&
|
|
1166
|
+
target.type === "number" &&
|
|
1167
|
+
target === document.activeElement
|
|
1168
|
+
) {
|
|
1169
|
+
target.blur();
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
{ passive: true, capture: true },
|
|
1173
|
+
);
|
|
1174
|
+
|
|
1131
1175
|
/**
|
|
1132
1176
|
* This is the status of the save. It has no purpose during live / realtime operation
|
|
1133
1177
|
* so it initialize it to blank.
|
|
@@ -1329,12 +1373,14 @@ function escapeHtml(text: string): string {
|
|
|
1329
1373
|
* Save dialog can change it, just for this file. Nothing else sees the change: the picture
|
|
1330
1374
|
* is still drawn in canvasRecorder's units, and simply stretched to this size.
|
|
1331
1375
|
* @param pixelHeight The saved file's height. See `pixelWidth`.
|
|
1376
|
+
* @param subtitles Add a subtitle track, made from the transcripts. See dev/subtitles.ts.
|
|
1332
1377
|
*/
|
|
1333
1378
|
async function startRecording(
|
|
1334
1379
|
saveStartMs = 0,
|
|
1335
1380
|
saveEndMs = toShow.duration,
|
|
1336
1381
|
pixelWidth = canvasRecorder.pixelWidth,
|
|
1337
1382
|
pixelHeight = canvasRecorder.pixelHeight,
|
|
1383
|
+
subtitles = false,
|
|
1338
1384
|
) {
|
|
1339
1385
|
stopAudio();
|
|
1340
1386
|
startRecordingButton.disabled = true;
|
|
@@ -1421,6 +1467,23 @@ async function startRecording(
|
|
|
1421
1467
|
});
|
|
1422
1468
|
output.addAudioTrack(audioSource);
|
|
1423
1469
|
|
|
1470
|
+
// The words, from the transcripts as they are now. The cues are added at the end, like
|
|
1471
|
+
// the sound, when it's known how much was recorded. A track with no cues isn't written.
|
|
1472
|
+
const spokenWords = subtitles
|
|
1473
|
+
? subtitleWords(
|
|
1474
|
+
collectSoundClips(toShow),
|
|
1475
|
+
(source) => readyTranscript(source)?.words,
|
|
1476
|
+
)
|
|
1477
|
+
: [];
|
|
1478
|
+
let subtitleSource: TextSubtitleSource | undefined;
|
|
1479
|
+
if (spokenWords.length) {
|
|
1480
|
+
subtitleSource = new TextSubtitleSource("webvtt");
|
|
1481
|
+
output.addSubtitleTrack(subtitleSource, {
|
|
1482
|
+
languageCode: "eng",
|
|
1483
|
+
name: "Subtitles",
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1424
1487
|
const startTime = performance.now();
|
|
1425
1488
|
|
|
1426
1489
|
await output.start();
|
|
@@ -1496,6 +1559,15 @@ async function startRecording(
|
|
|
1496
1559
|
await audioSource.add(trimmedAudio);
|
|
1497
1560
|
}
|
|
1498
1561
|
|
|
1562
|
+
if (subtitleSource) {
|
|
1563
|
+
const text = webVtt(
|
|
1564
|
+
spokenWords,
|
|
1565
|
+
audioStartMs,
|
|
1566
|
+
audioStartMs + actualAudioMs,
|
|
1567
|
+
);
|
|
1568
|
+
if (text) await subtitleSource.add(text);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1499
1571
|
infoDiv.innerHTML = "Frames complete. Finalizing video.";
|
|
1500
1572
|
cancelRecordingButton.disabled = true;
|
|
1501
1573
|
|
|
@@ -1682,8 +1754,81 @@ function updateSaveDialogInfo(): void {
|
|
|
1682
1754
|
saveInfoFrames.textContent = framesBetween(startMs, endMs).toLocaleString();
|
|
1683
1755
|
saveInfoFrames.style.color = invalid ? "red" : "";
|
|
1684
1756
|
updateSaveSizeNote();
|
|
1757
|
+
updateSaveSubtitlesNote(startMs, endMs);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
const saveSubtitlesCheckbox = getById("saveSubtitles", HTMLInputElement);
|
|
1761
|
+
const saveSubtitlesNote = getById("saveSubtitlesNote", HTMLSpanElement);
|
|
1762
|
+
|
|
1763
|
+
/** How many words the subtitles will have, and which sound files have no transcript yet. */
|
|
1764
|
+
function updateSaveSubtitlesNote(startMs: number, endMs: number): void {
|
|
1765
|
+
const placed = collectSoundClips(toShow);
|
|
1766
|
+
const missing = new Set(
|
|
1767
|
+
placed
|
|
1768
|
+
.map((clip) => clip.source)
|
|
1769
|
+
.filter((source) => !readyTranscript(source)),
|
|
1770
|
+
).size;
|
|
1771
|
+
const count = subtitleWords(
|
|
1772
|
+
placed,
|
|
1773
|
+
(source) => readyTranscript(source)?.words,
|
|
1774
|
+
).filter((word) => word.startMs >= startMs && word.startMs < endMs).length;
|
|
1775
|
+
const words = `${count.toLocaleString()} ${count === 1 ? "word" : "words"}`;
|
|
1776
|
+
saveSubtitlesNote.textContent = missing
|
|
1777
|
+
? `${words}. ${missing} sound ${missing === 1 ? "file has" : "files have"} no transcript yet, so ${missing === 1 ? "it isn't" : "they aren't"} included.`
|
|
1778
|
+
: words;
|
|
1779
|
+
saveSubtitlesNote.style.color = missing ? "#a06000" : "#555";
|
|
1685
1780
|
}
|
|
1686
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* The subtitles as a file of their own, for YouTube, which ignores the track inside the MP4.
|
|
1784
|
+
* The times match a video saved from the same start and end: the file starts at its first
|
|
1785
|
+
* frame, as startRecording() does.
|
|
1786
|
+
*/
|
|
1787
|
+
getById("saveSubtitlesFileBtn", HTMLButtonElement).addEventListener(
|
|
1788
|
+
"click",
|
|
1789
|
+
async () => {
|
|
1790
|
+
const startMs = (saveStartSecondsInput.valueAsNumber || 0) * 1000;
|
|
1791
|
+
const endMs = (saveEndSecondsInput.valueAsNumber || 0) * 1000;
|
|
1792
|
+
const fileStartMs = (firstFrameAtOrAfter(startMs) * 1000) / FPS;
|
|
1793
|
+
const fileEndMs =
|
|
1794
|
+
fileStartMs + (framesBetween(startMs, endMs) * 1000) / FPS;
|
|
1795
|
+
const text = webVtt(
|
|
1796
|
+
subtitleWords(
|
|
1797
|
+
collectSoundClips(toShow),
|
|
1798
|
+
(source) => readyTranscript(source)?.words,
|
|
1799
|
+
),
|
|
1800
|
+
fileStartMs,
|
|
1801
|
+
fileEndMs,
|
|
1802
|
+
);
|
|
1803
|
+
if (!text) {
|
|
1804
|
+
saveSubtitlesNote.textContent = "No words to save in that range.";
|
|
1805
|
+
saveSubtitlesNote.style.color = "#a06000";
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
try {
|
|
1809
|
+
const fileHandle = await window.showSaveFilePicker({
|
|
1810
|
+
// The same id as the video, so it opens in the same folder.
|
|
1811
|
+
id: "video-save",
|
|
1812
|
+
suggestedName: "canvas-recording.vtt",
|
|
1813
|
+
types: [
|
|
1814
|
+
{ description: "WebVTT subtitles", accept: { "text/vtt": [".vtt"] } },
|
|
1815
|
+
],
|
|
1816
|
+
});
|
|
1817
|
+
const writable = await fileHandle.createWritable();
|
|
1818
|
+
await writable.write(text);
|
|
1819
|
+
await writable.close();
|
|
1820
|
+
saveSubtitlesNote.textContent = `Saved ${fileHandle.name}.`;
|
|
1821
|
+
saveSubtitlesNote.style.color = "#555";
|
|
1822
|
+
} catch (e) {
|
|
1823
|
+
// Closing the file picker is not an error.
|
|
1824
|
+
if (e instanceof DOMException && e.name === "AbortError") return;
|
|
1825
|
+
console.error("Saving the subtitles failed:", e);
|
|
1826
|
+
saveSubtitlesNote.textContent = `Not saved: ${e instanceof Error ? e.message : String(e)}`;
|
|
1827
|
+
saveSubtitlesNote.style.color = "red";
|
|
1828
|
+
}
|
|
1829
|
+
},
|
|
1830
|
+
);
|
|
1831
|
+
|
|
1687
1832
|
function setSaveRange(startMs: number, endMs: number): void {
|
|
1688
1833
|
saveStartSecondsInput.value = (startMs / 1000).toString();
|
|
1689
1834
|
saveEndSecondsInput.value = (endMs / 1000).toString();
|
|
@@ -1784,7 +1929,7 @@ saveOkBtn.addEventListener("click", async () => {
|
|
|
1784
1929
|
// Quick: no prompts, just IndexedDB. The click still counts for the file picker afterward.
|
|
1785
1930
|
if (!(await saveDialogLocalFilesReady())) return;
|
|
1786
1931
|
saveDialog.close();
|
|
1787
|
-
startRecording(startMs, endMs, width, height);
|
|
1932
|
+
startRecording(startMs, endMs, width, height, saveSubtitlesCheckbox.checked);
|
|
1788
1933
|
});
|
|
1789
1934
|
|
|
1790
1935
|
startRecordingButton.addEventListener("click", () => {
|
|
@@ -2044,13 +2189,24 @@ philDebug.VisualEditor = {
|
|
|
2044
2189
|
get rootComponent(): Showable | undefined {
|
|
2045
2190
|
return currentRoot();
|
|
2046
2191
|
},
|
|
2192
|
+
/** What the component list shows as selected: the root, when no child is. */
|
|
2047
2193
|
get selectedComponent(): Showable | null {
|
|
2048
|
-
return selectedSlideChild;
|
|
2194
|
+
return selectedSlideChild ?? currentRoot() ?? null;
|
|
2049
2195
|
},
|
|
2050
2196
|
/** Current time in ms relative to the start of the Visual Editor's root. */
|
|
2051
2197
|
get localTimeMs(): number {
|
|
2052
2198
|
return playheadInRootMs();
|
|
2053
2199
|
},
|
|
2200
|
+
/**
|
|
2201
|
+
* After changing components from the console: show the changes. The same as
|
|
2202
|
+
* {@link VisualEditorAPI.refreshGUI}.
|
|
2203
|
+
* @param howMuch "properties" (the default) after changing values, and "structure" after
|
|
2204
|
+
* adding or removing components. Both save. "sound" rebuilds the sound from its clips, and
|
|
2205
|
+
* doesn't save.
|
|
2206
|
+
*/
|
|
2207
|
+
refreshGUI(howMuch: "sound" | "properties" | "structure" = "properties") {
|
|
2208
|
+
visualEditorAPI.refreshGUI(howMuch);
|
|
2209
|
+
},
|
|
2054
2210
|
};
|
|
2055
2211
|
|
|
2056
2212
|
const scheduleHistoryControls = getById("scheduleHistoryControls", HTMLElement);
|
|
@@ -2058,14 +2214,12 @@ const openHistoryDialogBtn = getById("openHistoryDialogBtn", HTMLButtonElement);
|
|
|
2058
2214
|
const historyDialog = getById("historyDialog", HTMLDialogElement);
|
|
2059
2215
|
const historyList = getById("historyList", HTMLUListElement);
|
|
2060
2216
|
const historyDeleteBtn = getById("historyDeleteBtn", HTMLButtonElement);
|
|
2061
|
-
const
|
|
2062
|
-
const
|
|
2063
|
-
const historyOkBtn = getById("historyOkBtn", HTMLButtonElement);
|
|
2064
|
-
const historyCancelBtn = getById("historyCancelBtn", HTMLButtonElement);
|
|
2217
|
+
const historyDoneBtn = getById("historyDoneBtn", HTMLButtonElement);
|
|
2218
|
+
const historyRevertBtn = getById("historyRevertBtn", HTMLButtonElement);
|
|
2065
2219
|
const historyDialogHint = getById("historyDialogHint", HTMLElement);
|
|
2066
2220
|
|
|
2067
2221
|
// MARK: Rect marker drag state
|
|
2068
|
-
type RectKf =
|
|
2222
|
+
type RectKf = TimedKeyframe<ReadOnlyRect>;
|
|
2069
2223
|
type RectHandle = "tl" | "tr" | "bl" | "br" | "center";
|
|
2070
2224
|
|
|
2071
2225
|
/** The single rect keyframe currently in "edit" mode (drag handles shown on canvas). At most one at a time. */
|
|
@@ -2104,7 +2258,7 @@ const DEFAULT_LATTICE: LatticeValue = {
|
|
|
2104
2258
|
cellHeight: 1,
|
|
2105
2259
|
};
|
|
2106
2260
|
|
|
2107
|
-
type LatticeKf =
|
|
2261
|
+
type LatticeKf = TimedKeyframe<LatticeValue>;
|
|
2108
2262
|
/** The rect handles, plus one more that drags the bottom-right corner of the top-left cell. */
|
|
2109
2263
|
type LatticeHandle = RectHandle | "cell";
|
|
2110
2264
|
|
|
@@ -2126,7 +2280,7 @@ let draggingLattice: {
|
|
|
2126
2280
|
} | null = null;
|
|
2127
2281
|
|
|
2128
2282
|
// MARK: Point marker drag state
|
|
2129
|
-
type PointKf =
|
|
2283
|
+
type PointKf = TimedKeyframe<{ x: number; y: number }>;
|
|
2130
2284
|
|
|
2131
2285
|
/** The single point keyframe currently in "edit" mode. At most one at a time. */
|
|
2132
2286
|
let editingPointKf: PointKf | null = null;
|
|
@@ -2148,7 +2302,10 @@ let draggingPoint: PointKf | null = null;
|
|
|
2148
2302
|
* something other than that input changes the value -- e.g. dragging a
|
|
2149
2303
|
* Multi Text's frame changes its Width and Height.
|
|
2150
2304
|
*/
|
|
2151
|
-
const numberSyncCallbacks = new Map<
|
|
2305
|
+
const numberSyncCallbacks = new Map<
|
|
2306
|
+
TimedKeyframe<number>,
|
|
2307
|
+
(n: number) => void
|
|
2308
|
+
>();
|
|
2152
2309
|
|
|
2153
2310
|
/**
|
|
2154
2311
|
* 👁 / ✎ for each Multi Text's frame, remembered across rebuilds of the
|
|
@@ -2158,7 +2315,7 @@ const numberSyncCallbacks = new Map<Keyframe<number>, (n: number) => void>();
|
|
|
2158
2315
|
const textFrameCanvasStates = new WeakMap<MultiTextComponent, CanvasState>();
|
|
2159
2316
|
|
|
2160
2317
|
// MARK: Arrow marker drag state
|
|
2161
|
-
type ArrowKf =
|
|
2318
|
+
type ArrowKf = TimedKeyframe<ArrowValue>;
|
|
2162
2319
|
type ArrowHandle = "flat" | "pointy" | "center";
|
|
2163
2320
|
|
|
2164
2321
|
/** The single arrow keyframe currently in "edit" mode. */
|
|
@@ -2608,6 +2765,7 @@ transcriptsCheckbox.addEventListener("change", () => {
|
|
|
2608
2765
|
onTranscriptsChange(() => {
|
|
2609
2766
|
transcriptsStatusSpan.textContent = transcriptsSummary();
|
|
2610
2767
|
timelineDisplay.redraw();
|
|
2768
|
+
requestTranscriptsSync();
|
|
2611
2769
|
});
|
|
2612
2770
|
|
|
2613
2771
|
// The transcript as text. It rebuilds itself when the clips or transcripts
|
|
@@ -2862,7 +3020,7 @@ function timelineWords(
|
|
|
2862
3020
|
clipStart: number,
|
|
2863
3021
|
): { words: readonly TimelineWord[]; snaps: readonly number[] } {
|
|
2864
3022
|
const fromMs = clip.startMsIntoClip ?? 0;
|
|
2865
|
-
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcript
|
|
3023
|
+
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcriptVersion(transcript)}`;
|
|
2866
3024
|
const memo = timelineWordsMemo.get(clip);
|
|
2867
3025
|
if (memo?.key === key) return memo;
|
|
2868
3026
|
// File time to chapter time.
|
|
@@ -3206,18 +3364,18 @@ function restorePlace(place: SavedPlace): void {
|
|
|
3206
3364
|
*/
|
|
3207
3365
|
function saveState() {
|
|
3208
3366
|
sessionStorage.setItem(
|
|
3209
|
-
"place",
|
|
3367
|
+
sessionKey("place"),
|
|
3210
3368
|
JSON.stringify(placeToRestore ?? currentPlace()),
|
|
3211
3369
|
);
|
|
3212
3370
|
sessionStorage.setItem(
|
|
3213
|
-
"playPositionLocal",
|
|
3371
|
+
sessionKey("playPositionLocal"),
|
|
3214
3372
|
playPositionLocal.checked ? "1" : "0",
|
|
3215
3373
|
);
|
|
3216
|
-
sessionStorage.setItem("zoomSelect", zoomSelect.value);
|
|
3217
|
-
sessionStorage.setItem("panX", panX.toString());
|
|
3218
|
-
sessionStorage.setItem("panY", panY.toString());
|
|
3374
|
+
sessionStorage.setItem(sessionKey("zoomSelect"), zoomSelect.value);
|
|
3375
|
+
sessionStorage.setItem(sessionKey("panX"), panX.toString());
|
|
3376
|
+
sessionStorage.setItem(sessionKey("panY"), panY.toString());
|
|
3219
3377
|
sessionStorage.setItem(
|
|
3220
|
-
"quality",
|
|
3378
|
+
sessionKey("quality"),
|
|
3221
3379
|
querySelector('input[name="quality"]:checked', HTMLInputElement).value,
|
|
3222
3380
|
);
|
|
3223
3381
|
|
|
@@ -3248,6 +3406,26 @@ type ScheduleInfo = NonNullable<Showable["schedules"]>[number];
|
|
|
3248
3406
|
|
|
3249
3407
|
const toShowKey = startRequest.name;
|
|
3250
3408
|
|
|
3409
|
+
/**
|
|
3410
|
+
* This video's own sessionStorage key for `name`. Two videos opened in one tab don't share
|
|
3411
|
+
* a place, a zoom or an unload backup. The pane sizes are the window's layout, so they stay
|
|
3412
|
+
* shared, under plain names.
|
|
3413
|
+
*/
|
|
3414
|
+
function sessionKey(name: (typeof PER_VIDEO_SESSION_KEYS)[number]): string {
|
|
3415
|
+
return `${name}|${toShowKey}`;
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3418
|
+
/** Everything {@link sessionKey} names. Before 0.8.4 they were plain names, shared by every video. */
|
|
3419
|
+
const PER_VIDEO_SESSION_KEYS = [
|
|
3420
|
+
"place",
|
|
3421
|
+
"playPositionLocal",
|
|
3422
|
+
"zoomSelect",
|
|
3423
|
+
"panX",
|
|
3424
|
+
"panY",
|
|
3425
|
+
"quality",
|
|
3426
|
+
"pendingScheduleSave",
|
|
3427
|
+
] as const;
|
|
3428
|
+
|
|
3251
3429
|
/** Marker written when the user deliberately chooses TypeScript defaults. */
|
|
3252
3430
|
type MarkerHistoryEntry = {
|
|
3253
3431
|
timestamp: number;
|
|
@@ -3561,6 +3739,129 @@ const diffSync = new SyncedFile({
|
|
|
3561
3739
|
...keyedSyncStorage(`__diff-save__|${toShowKey}`, false),
|
|
3562
3740
|
});
|
|
3563
3741
|
|
|
3742
|
+
/**
|
|
3743
|
+
* Every transcript the video uses, mirrored to a JSON file, so they can be read and checked
|
|
3744
|
+
* outside the editor: by you, by grep, or by Claude. It's only a copy. The transcripts
|
|
3745
|
+
* themselves, with the Transcript Editor's changes, live in IndexedDB.
|
|
3746
|
+
*/
|
|
3747
|
+
const transcriptsSync = new SyncedFile({
|
|
3748
|
+
checkbox: getById("transcriptsSyncCheckbox", HTMLInputElement),
|
|
3749
|
+
status: getById("transcriptsSyncStatus", HTMLSpanElement),
|
|
3750
|
+
picker: {
|
|
3751
|
+
id: "transcripts-save",
|
|
3752
|
+
types: JSON_FILE_TYPES,
|
|
3753
|
+
defaultName: () => `${toShowKey || "video"}-transcripts.json`,
|
|
3754
|
+
},
|
|
3755
|
+
render: () => transcriptsFileText(toShowKey, videoTranscripts()),
|
|
3756
|
+
...keyedSyncStorage(`__transcripts-save__|${toShowKey}`, false),
|
|
3757
|
+
});
|
|
3758
|
+
|
|
3759
|
+
/**
|
|
3760
|
+
* Each sound file the whole video uses, once, in order of first use. Asking about a file
|
|
3761
|
+
* starts its transcript, so this only runs while the transcripts file is being synced.
|
|
3762
|
+
*/
|
|
3763
|
+
function videoTranscripts(): VideoTranscript[] {
|
|
3764
|
+
const usesBySource = new Map<string, VideoTranscript["uses"][number][]>();
|
|
3765
|
+
const placed = collectSoundClips(toShow).sort(
|
|
3766
|
+
(a, b) => a.startMs - b.startMs,
|
|
3767
|
+
);
|
|
3768
|
+
for (const clip of placed) {
|
|
3769
|
+
let uses = usesBySource.get(clip.source);
|
|
3770
|
+
if (!uses) usesBySource.set(clip.source, (uses = []));
|
|
3771
|
+
uses.push({
|
|
3772
|
+
startsInVideoMs: clip.startMs,
|
|
3773
|
+
playsFileFromMs: clip.trimMs,
|
|
3774
|
+
playsFileToMs: Number.isFinite(clip.lengthMs)
|
|
3775
|
+
? clip.trimMs + clip.lengthMs
|
|
3776
|
+
: null,
|
|
3777
|
+
});
|
|
3778
|
+
}
|
|
3779
|
+
return [...usesBySource].map(([source, uses]) => {
|
|
3780
|
+
const status = transcriptStatus(source);
|
|
3781
|
+
return {
|
|
3782
|
+
source,
|
|
3783
|
+
transcript: status?.kind === "ready" ? status.transcript : undefined,
|
|
3784
|
+
status: !status
|
|
3785
|
+
? "transcripts are off"
|
|
3786
|
+
: (statusText(status) ?? status.kind),
|
|
3787
|
+
uses,
|
|
3788
|
+
};
|
|
3789
|
+
});
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
/** What the transcripts file was last asked to show. See {@link requestTranscriptsSync}. */
|
|
3793
|
+
let transcriptsSyncSignature = "";
|
|
3794
|
+
|
|
3795
|
+
/**
|
|
3796
|
+
* Bring the transcripts file up to date, if anything in it could have changed: a transcript,
|
|
3797
|
+
* or which part of which file the video plays. Cheap when nothing did, so call it often.
|
|
3798
|
+
*/
|
|
3799
|
+
function requestTranscriptsSync(): void {
|
|
3800
|
+
if (!transcriptsSync.handle) return;
|
|
3801
|
+
const placed = collectSoundClips(toShow);
|
|
3802
|
+
const signature = JSON.stringify(
|
|
3803
|
+
placed.map((clip) => {
|
|
3804
|
+
const transcript = readyTranscript(clip.source);
|
|
3805
|
+
return [
|
|
3806
|
+
clip.source,
|
|
3807
|
+
clip.startMs,
|
|
3808
|
+
clip.trimMs,
|
|
3809
|
+
clip.lengthMs,
|
|
3810
|
+
transcript ? transcriptVersion(transcript) : 0,
|
|
3811
|
+
];
|
|
3812
|
+
}),
|
|
3813
|
+
);
|
|
3814
|
+
if (signature === transcriptsSyncSignature) return;
|
|
3815
|
+
transcriptsSyncSignature = signature;
|
|
3816
|
+
transcriptsSync.request();
|
|
3817
|
+
}
|
|
3818
|
+
|
|
3819
|
+
// MARK: 💾 Files
|
|
3820
|
+
|
|
3821
|
+
const filesBtn = getById("filesBtn", HTMLButtonElement);
|
|
3822
|
+
const filesDialog = getById("filesDialog", HTMLDialogElement);
|
|
3823
|
+
filesBtn.addEventListener("click", () => filesDialog.showModal());
|
|
3824
|
+
getById("filesDialogCloseBtn", HTMLButtonElement).addEventListener(
|
|
3825
|
+
"click",
|
|
3826
|
+
() => filesDialog.close(),
|
|
3827
|
+
);
|
|
3828
|
+
|
|
3829
|
+
/**
|
|
3830
|
+
* The button stands for every synced file: red when one needs a click, orange while one is
|
|
3831
|
+
* waiting for the next save. Its tooltip lists them.
|
|
3832
|
+
*/
|
|
3833
|
+
function drawFilesButton(): void {
|
|
3834
|
+
const syncs = [
|
|
3835
|
+
["Sync to file", jsonSync],
|
|
3836
|
+
["Sync defaults", defaultsSync],
|
|
3837
|
+
["Sync diffs", diffSync],
|
|
3838
|
+
["Sync transcripts", transcriptsSync],
|
|
3839
|
+
] as const;
|
|
3840
|
+
const summaries = syncs.map(([, sync]) => sync.summary);
|
|
3841
|
+
const action = summaries.includes("action");
|
|
3842
|
+
const pending = summaries.includes("pending");
|
|
3843
|
+
filesBtn.textContent = `💾 Files${action ? " ⚠" : ""}`;
|
|
3844
|
+
if (pending && !action) {
|
|
3845
|
+
// Only the asterisk is orange: an orange button was too distracting.
|
|
3846
|
+
const star = document.createElement("span");
|
|
3847
|
+
star.textContent = " *";
|
|
3848
|
+
star.style.color = "#ef6c00";
|
|
3849
|
+
star.style.fontWeight = "bold";
|
|
3850
|
+
filesBtn.append(star);
|
|
3851
|
+
}
|
|
3852
|
+
filesBtn.style.background = action ? "#e53935" : "";
|
|
3853
|
+
filesBtn.style.color = action ? "white" : "";
|
|
3854
|
+
filesBtn.title = [
|
|
3855
|
+
action
|
|
3856
|
+
? "Something needs a click. Open this to see what."
|
|
3857
|
+
: "Import, Save Copy As, and the files on disk that follow your work.",
|
|
3858
|
+
"",
|
|
3859
|
+
...syncs.map(([name, sync]) => `${name}: ${sync.statusText}`),
|
|
3860
|
+
].join("\n");
|
|
3861
|
+
}
|
|
3862
|
+
onSyncStatusChange(drawFilesButton);
|
|
3863
|
+
drawFilesButton();
|
|
3864
|
+
|
|
3564
3865
|
/** The code-defined starting point, in the same format as {@link buildJsonSnapshot}. */
|
|
3565
3866
|
function buildDefaultsSnapshot(): VideoSnapshot {
|
|
3566
3867
|
return {
|
|
@@ -4244,7 +4545,7 @@ async function initFromDB(unloadBackup?: string | null): Promise<void> {
|
|
|
4244
4545
|
_loadSource = source;
|
|
4245
4546
|
_baselineTreeJson = currentTreeJson();
|
|
4246
4547
|
// The unload backup is in the database now, or older than it. See the end of "Load previous state".
|
|
4247
|
-
sessionStorage.removeItem("pendingScheduleSave");
|
|
4548
|
+
sessionStorage.removeItem(sessionKey("pendingScheduleSave"));
|
|
4248
4549
|
|
|
4249
4550
|
canvas.style.visibility = "";
|
|
4250
4551
|
canvasLoading.style.display = "none";
|
|
@@ -4287,6 +4588,7 @@ async function saveVideoState(force = false): Promise<void> {
|
|
|
4287
4588
|
} finally {
|
|
4288
4589
|
jsonSync.request();
|
|
4289
4590
|
diffSync.request();
|
|
4591
|
+
requestTranscriptsSync();
|
|
4290
4592
|
}
|
|
4291
4593
|
}
|
|
4292
4594
|
|
|
@@ -4395,7 +4697,10 @@ function saveOnUnload() {
|
|
|
4395
4697
|
// preview, not the state being backed up.
|
|
4396
4698
|
if (dirty && !previewing) void saveVideoState();
|
|
4397
4699
|
try {
|
|
4398
|
-
sessionStorage.setItem(
|
|
4700
|
+
sessionStorage.setItem(
|
|
4701
|
+
sessionKey("pendingScheduleSave"),
|
|
4702
|
+
JSON.stringify([backup]),
|
|
4703
|
+
);
|
|
4399
4704
|
} catch (e) {
|
|
4400
4705
|
// One whole tree can exceed the ~5MB sessionStorage quota on a big video. The
|
|
4401
4706
|
// IndexedDB write above already happened, so losing this backstop is survivable.
|
|
@@ -4435,17 +4740,48 @@ let _dialogFileRecords: FileRecord[] = [];
|
|
|
4435
4740
|
/** Async load state for each filename; populated after the dialog opens. */
|
|
4436
4741
|
const _dialogFileStates = new Map<string, FileEntryState>();
|
|
4437
4742
|
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
_selectedDialogIndex = index;
|
|
4743
|
+
/** What the dialog had selected when it opened, as {@link _dialogItemKey} says it. */
|
|
4744
|
+
let _initialItemKey: string | undefined;
|
|
4441
4745
|
|
|
4746
|
+
/** Names an entry, so it can be found again after the list is rebuilt. */
|
|
4747
|
+
function _dialogItemKey(item: DialogListItem | undefined): string | undefined {
|
|
4748
|
+
switch (item?.kind) {
|
|
4749
|
+
case undefined:
|
|
4750
|
+
return undefined;
|
|
4751
|
+
case "ts-defaults":
|
|
4752
|
+
return "ts-defaults";
|
|
4753
|
+
case "db-entry":
|
|
4754
|
+
return `db ${item.entry.timestamp}`;
|
|
4755
|
+
case "file-entry":
|
|
4756
|
+
return `file ${item.fileRecord.filename}`;
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4760
|
+
/** True if the selected entry isn't the one loaded when the dialog opened. */
|
|
4761
|
+
function _dialogChanged(): boolean {
|
|
4762
|
+
return (
|
|
4763
|
+
_selectedDialogIndex >= 0 &&
|
|
4764
|
+
_dialogItemKey(_dialogItems[_selectedDialogIndex]) !== _initialItemKey
|
|
4765
|
+
);
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
/** Mark an entry selected in the list, without loading it. -1 for none. */
|
|
4769
|
+
function _highlightDialogItem(index: number): void {
|
|
4770
|
+
_selectedDialogIndex = index;
|
|
4442
4771
|
for (let i = 0; i < historyList.children.length; i++) {
|
|
4443
4772
|
historyList.children[i].classList.toggle("selected", i === index);
|
|
4444
4773
|
}
|
|
4445
|
-
|
|
4446
4774
|
const item = _dialogItems[index];
|
|
4447
4775
|
// Top item (index 0) and ts-defaults are never deletable.
|
|
4448
|
-
historyDeleteBtn.disabled =
|
|
4776
|
+
historyDeleteBtn.disabled =
|
|
4777
|
+
!item || index === 0 || item.kind === "ts-defaults";
|
|
4778
|
+
historyRevertBtn.disabled = !_dialogChanged();
|
|
4779
|
+
}
|
|
4780
|
+
|
|
4781
|
+
function _dialogSelectItem(index: number, target: Showable) {
|
|
4782
|
+
if (index < 0 || index >= _dialogItems.length) return;
|
|
4783
|
+
_highlightDialogItem(index);
|
|
4784
|
+
const item = _dialogItems[index];
|
|
4449
4785
|
|
|
4450
4786
|
// Preview the selected state
|
|
4451
4787
|
if (item.kind === "ts-defaults") {
|
|
@@ -4461,11 +4797,6 @@ function _dialogSelectItem(index: number, target: Showable) {
|
|
|
4461
4797
|
updateComponentEditor(target);
|
|
4462
4798
|
updateScheduleEditor(target);
|
|
4463
4799
|
afterStateApplied();
|
|
4464
|
-
|
|
4465
|
-
// The Abandon/Save buttons are no longer used; only Keep is shown.
|
|
4466
|
-
historyOkBtn.hidden = false;
|
|
4467
|
-
historyAbandonBtn.hidden = true;
|
|
4468
|
-
historySaveBtn.hidden = true;
|
|
4469
4800
|
}
|
|
4470
4801
|
|
|
4471
4802
|
/**
|
|
@@ -4664,7 +4995,10 @@ async function openHistoryDialog(target: Showable) {
|
|
|
4664
4995
|
}
|
|
4665
4996
|
}
|
|
4666
4997
|
|
|
4998
|
+
_initialItemKey = undefined;
|
|
4667
4999
|
_rebuildDialogList(target);
|
|
5000
|
+
_initialItemKey = _dialogItemKey(_dialogItems[_selectedDialogIndex]);
|
|
5001
|
+
historyRevertBtn.disabled = true;
|
|
4668
5002
|
historyDialog.showModal();
|
|
4669
5003
|
historyList.focus();
|
|
4670
5004
|
|
|
@@ -4706,35 +5040,32 @@ async function _applyDialogSelection() {
|
|
|
4706
5040
|
afterStateApplied();
|
|
4707
5041
|
}
|
|
4708
5042
|
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
5043
|
+
// Done and Escape both close, and closing keeps the entry chosen. Every choice is already
|
|
5044
|
+
// on the canvas; this saves it, so a reload brings it back. Nothing changed, nothing saved.
|
|
5045
|
+
historyDoneBtn.addEventListener("click", () => historyDialog.close());
|
|
5046
|
+
historyDialog.addEventListener("close", () => {
|
|
5047
|
+
if (_dialogChanged()) void _applyDialogSelection();
|
|
4712
5048
|
});
|
|
4713
|
-
|
|
4714
|
-
//
|
|
4715
|
-
historyDialog.close();
|
|
4716
|
-
});
|
|
4717
|
-
historySaveBtn.addEventListener("click", () => {
|
|
4718
|
-
// No longer shown; kept for safety.
|
|
4719
|
-
historyDialog.close();
|
|
4720
|
-
});
|
|
4721
|
-
historyCancelBtn.addEventListener("click", () => {
|
|
4722
|
-
// Revert to the state before the dialog opened. The snapshot covers the whole video, so
|
|
5049
|
+
historyRevertBtn.addEventListener("click", () => {
|
|
5050
|
+
// Put back the state from before the dialog opened. The snapshot covers the whole video, so
|
|
4723
5051
|
// restore the whole video -- a preview may have been scoped to one chapter, but undoing it
|
|
4724
5052
|
// against `target` alone would apply the root's state to that chapter.
|
|
4725
5053
|
const target = _historyTarget;
|
|
4726
|
-
if (target)
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
5054
|
+
if (!target) return;
|
|
5055
|
+
applyTree(
|
|
5056
|
+
toShow,
|
|
5057
|
+
loadableTree(JSON.parse(_preDialogSnapshotJson) as SerializedFixedChild),
|
|
5058
|
+
);
|
|
5059
|
+
selectedSlideChild = null;
|
|
5060
|
+
activeRootComponentEditor?.resetAll();
|
|
5061
|
+
updateComponentEditor(target);
|
|
5062
|
+
updateScheduleEditor(target);
|
|
5063
|
+
afterStateApplied();
|
|
5064
|
+
// Select the entry it came from, without loading it again: the snapshot is exact.
|
|
5065
|
+
_highlightDialogItem(
|
|
5066
|
+
_dialogItems.findIndex((item) => _dialogItemKey(item) === _initialItemKey),
|
|
5067
|
+
);
|
|
5068
|
+
historyList.focus();
|
|
4738
5069
|
});
|
|
4739
5070
|
|
|
4740
5071
|
historyDeleteBtn.addEventListener("click", async () => {
|
|
@@ -4921,7 +5252,7 @@ function buildScheduleSection(
|
|
|
4921
5252
|
}
|
|
4922
5253
|
|
|
4923
5254
|
const legend = document.createElement("legend");
|
|
4924
|
-
legend.textContent = info
|
|
5255
|
+
legend.textContent = propertyLabel(info) + " ";
|
|
4925
5256
|
const addBtn = document.createElement("button");
|
|
4926
5257
|
addBtn.type = "button";
|
|
4927
5258
|
addBtn.textContent = "+ Add";
|
|
@@ -5063,6 +5394,15 @@ function buildScheduleSection(
|
|
|
5063
5394
|
const durationLabel = info.timeAxisLabel
|
|
5064
5395
|
? `Δ ${info.timeAxisLabel}`
|
|
5065
5396
|
: "Duration (ms)";
|
|
5397
|
+
/**
|
|
5398
|
+
* A text box takes any spare width. The table fills the panel, and its Value column asks
|
|
5399
|
+
* for all of it. That alone would squeeze the other columns to their narrowest, wrapping
|
|
5400
|
+
* "Go To", so `.grow-value` in canvas-recorder.css keeps the headers on one line until the
|
|
5401
|
+
* panel is really too narrow.
|
|
5402
|
+
*/
|
|
5403
|
+
const growValue =
|
|
5404
|
+
info.type === "string" && !info.useDialog && !info.choices?.length;
|
|
5405
|
+
if (growValue) table.style.width = "100%";
|
|
5066
5406
|
for (const h of [
|
|
5067
5407
|
showDurations ? durationLabel : timeLabel,
|
|
5068
5408
|
...valueHeaders,
|
|
@@ -5072,6 +5412,7 @@ function buildScheduleSection(
|
|
|
5072
5412
|
]) {
|
|
5073
5413
|
const th = document.createElement("th");
|
|
5074
5414
|
th.textContent = h;
|
|
5415
|
+
if (growValue && h === "Value") th.style.width = "100%";
|
|
5075
5416
|
headerRow.append(th);
|
|
5076
5417
|
}
|
|
5077
5418
|
|
|
@@ -5263,7 +5604,7 @@ function buildScheduleSection(
|
|
|
5263
5604
|
}
|
|
5264
5605
|
|
|
5265
5606
|
if (info.type === "color") {
|
|
5266
|
-
const colorKf = kf as
|
|
5607
|
+
const colorKf = kf as TimedKeyframe<string>;
|
|
5267
5608
|
const cell = row.insertCell();
|
|
5268
5609
|
const swatchBtn = document.createElement("button");
|
|
5269
5610
|
swatchBtn.type = "button";
|
|
@@ -5280,7 +5621,7 @@ function buildScheduleSection(
|
|
|
5280
5621
|
});
|
|
5281
5622
|
cell.append(swatchBtn);
|
|
5282
5623
|
} else if (info.type === "number") {
|
|
5283
|
-
const numKf = kf as
|
|
5624
|
+
const numKf = kf as TimedKeyframe<number>;
|
|
5284
5625
|
const input = buildNumericInput(numKf.value, (n) => {
|
|
5285
5626
|
numKf.value = n;
|
|
5286
5627
|
});
|
|
@@ -5289,7 +5630,7 @@ function buildScheduleSection(
|
|
|
5289
5630
|
});
|
|
5290
5631
|
row.insertCell().append(input);
|
|
5291
5632
|
} else if (info.type === "string") {
|
|
5292
|
-
const strKf = kf as
|
|
5633
|
+
const strKf = kf as TimedKeyframe<string>;
|
|
5293
5634
|
const cell = row.insertCell();
|
|
5294
5635
|
if (info.useDialog) {
|
|
5295
5636
|
// Font picker: read-only display + button that opens the dialog.
|
|
@@ -5335,18 +5676,21 @@ function buildScheduleSection(
|
|
|
5335
5676
|
input.value = strKf.value;
|
|
5336
5677
|
input.style.cssText =
|
|
5337
5678
|
"width:100%;box-sizing:border-box;resize:vertical";
|
|
5679
|
+
// See growValue.
|
|
5680
|
+
cell.style.width = "100%";
|
|
5338
5681
|
input.addEventListener("input", () => {
|
|
5339
5682
|
strKf.value = input.value;
|
|
5340
5683
|
});
|
|
5341
5684
|
cell.append(input);
|
|
5342
5685
|
}
|
|
5343
5686
|
} else if (info.type === "select") {
|
|
5344
|
-
const strKf = kf as
|
|
5687
|
+
const strKf = kf as TimedKeyframe<string>;
|
|
5345
5688
|
const cell = row.insertCell();
|
|
5346
5689
|
const sel = addName(document.createElement("select"));
|
|
5347
5690
|
for (const choice of info.choices) {
|
|
5348
5691
|
const opt = document.createElement("option");
|
|
5349
|
-
opt.value =
|
|
5692
|
+
opt.value = choice;
|
|
5693
|
+
opt.textContent = choiceLabel(info, choice);
|
|
5350
5694
|
sel.append(opt);
|
|
5351
5695
|
}
|
|
5352
5696
|
sel.value = strKf.value;
|
|
@@ -5716,7 +6060,14 @@ function buildScheduleSection(
|
|
|
5716
6060
|
refreshRippled();
|
|
5717
6061
|
|
|
5718
6062
|
table.append(tbody);
|
|
5719
|
-
|
|
6063
|
+
if (growValue) {
|
|
6064
|
+
const wrapper = document.createElement("div");
|
|
6065
|
+
wrapper.className = "grow-value";
|
|
6066
|
+
wrapper.append(table);
|
|
6067
|
+
section.append(wrapper);
|
|
6068
|
+
} else {
|
|
6069
|
+
section.append(table);
|
|
6070
|
+
}
|
|
5720
6071
|
section.addEventListener("input", () => {
|
|
5721
6072
|
activeRootComponentEditor?.update(selectable, info);
|
|
5722
6073
|
});
|
|
@@ -5935,7 +6286,7 @@ function updateComponentEditor(selectable: Showable) {
|
|
|
5935
6286
|
const pasteIntoBtn = document.createElement("button");
|
|
5936
6287
|
pasteIntoBtn.type = "button";
|
|
5937
6288
|
pasteIntoBtn.textContent = "📋 → 🖥️";
|
|
5938
|
-
pasteIntoBtn.title = `Paste into "${child.description}"`;
|
|
6289
|
+
pasteIntoBtn.title = `Paste into "${child.userEditableDescription ?? child.description}"`;
|
|
5939
6290
|
pasteIntoBtn.addEventListener("click", () =>
|
|
5940
6291
|
pasteInto(child, selectable),
|
|
5941
6292
|
);
|
|
@@ -5985,7 +6336,7 @@ function updateComponentEditor(selectable: Showable) {
|
|
|
5985
6336
|
const rootPasteBtn = document.createElement("button");
|
|
5986
6337
|
rootPasteBtn.type = "button";
|
|
5987
6338
|
rootPasteBtn.textContent = "📋 → 🖥️";
|
|
5988
|
-
rootPasteBtn.title = `Paste into "${selectable.description}"`;
|
|
6339
|
+
rootPasteBtn.title = `Paste into "${selectable.userEditableDescription ?? selectable.description}"`;
|
|
5989
6340
|
rootPasteBtn.addEventListener("click", () =>
|
|
5990
6341
|
pasteInto(selectable as Showable, selectable),
|
|
5991
6342
|
);
|
|
@@ -6312,6 +6663,48 @@ function buildSoundClipSection(selectable: Showable): HTMLElement {
|
|
|
6312
6663
|
);
|
|
6313
6664
|
});
|
|
6314
6665
|
|
|
6666
|
+
const editTranscriptBtn = document.createElement("button");
|
|
6667
|
+
editTranscriptBtn.type = "button";
|
|
6668
|
+
editTranscriptBtn.textContent = "✎";
|
|
6669
|
+
editTranscriptBtn.title =
|
|
6670
|
+
"Edit Transcript… Fix this file's words and their times, for the timeline, 📖 Text and the subtitles.";
|
|
6671
|
+
editTranscriptBtn.addEventListener("click", () => {
|
|
6672
|
+
if (!readyTranscript(clip.source)) {
|
|
6673
|
+
alert(
|
|
6674
|
+
transcriptsEnabled()
|
|
6675
|
+
? "This clip's transcript isn't ready yet. Its progress shows on the timeline."
|
|
6676
|
+
: "Transcripts are off. Turn on 🗣 Transcripts above the timeline.",
|
|
6677
|
+
);
|
|
6678
|
+
return;
|
|
6679
|
+
}
|
|
6680
|
+
const fromMs = clip.startMsIntoClip ?? 0;
|
|
6681
|
+
const playheadInFile = playheadInOwner() - clip.startMsIntoScene + fromMs;
|
|
6682
|
+
const lengthMs = soundClipLengthMs(clip) ?? Infinity;
|
|
6683
|
+
openTranscriptEditor({
|
|
6684
|
+
source: clip.source,
|
|
6685
|
+
words: () => readyTranscript(clip.source)?.words,
|
|
6686
|
+
setWords: (words) => editTranscript(clip.source, words),
|
|
6687
|
+
audio: () => soundtrack.getDecodedBuffer(clip.source),
|
|
6688
|
+
// Every clip in the video that plays this file, not just this one.
|
|
6689
|
+
used: collectSoundClips(toShow)
|
|
6690
|
+
.filter((placed) => placed.source === clip.source)
|
|
6691
|
+
.map((placed) => ({
|
|
6692
|
+
fromMs: placed.trimMs,
|
|
6693
|
+
toMs: placed.trimMs + placed.lengthMs,
|
|
6694
|
+
})),
|
|
6695
|
+
// The playhead, if it's in this clip, or else the clip's start.
|
|
6696
|
+
startAtMs:
|
|
6697
|
+
playheadInFile >= fromMs && playheadInFile < fromMs + lengthMs
|
|
6698
|
+
? playheadInFile
|
|
6699
|
+
: fromMs,
|
|
6700
|
+
pausePlayer() {
|
|
6701
|
+
playCheckBox.checked = false;
|
|
6702
|
+
stopAudio();
|
|
6703
|
+
},
|
|
6704
|
+
closed: () => timelineDisplay.redraw(),
|
|
6705
|
+
});
|
|
6706
|
+
});
|
|
6707
|
+
|
|
6315
6708
|
const splitBtn = document.createElement("button");
|
|
6316
6709
|
splitBtn.type = "button";
|
|
6317
6710
|
splitBtn.textContent = "✂";
|
|
@@ -6359,6 +6752,7 @@ function buildSoundClipSection(selectable: Showable): HTMLElement {
|
|
|
6359
6752
|
notesInput,
|
|
6360
6753
|
fromTranscriptBtn,
|
|
6361
6754
|
saveTranscriptBtn,
|
|
6755
|
+
editTranscriptBtn,
|
|
6362
6756
|
splitBtn,
|
|
6363
6757
|
upBtn,
|
|
6364
6758
|
downBtn,
|
|
@@ -7934,8 +8328,11 @@ function applyMarkerDrag(localX: number, localY: number, shiftKey = false) {
|
|
|
7934
8328
|
|
|
7935
8329
|
// MARK: Load previous state.
|
|
7936
8330
|
{
|
|
7937
|
-
//
|
|
7938
|
-
|
|
8331
|
+
// This video's unload backup, if the last session left one. Before 0.8.4 it was under a
|
|
8332
|
+
// plain name, for whichever video was open last. initFromDB() checks that it's this one's.
|
|
8333
|
+
const unloadBackup =
|
|
8334
|
+
sessionStorage.getItem(sessionKey("pendingScheduleSave")) ??
|
|
8335
|
+
sessionStorage.getItem("pendingScheduleSave");
|
|
7939
8336
|
// Hide the canvas until DB restoration is complete to prevent the TypeScript-
|
|
7940
8337
|
// default state from flashing briefly before the saved state is applied.
|
|
7941
8338
|
canvas.style.visibility = "hidden";
|
|
@@ -7967,6 +8364,7 @@ function applyMarkerDrag(localX: number, localY: number, shiftKey = false) {
|
|
|
7967
8364
|
jsonSync.request();
|
|
7968
8365
|
diffSync.request();
|
|
7969
8366
|
defaultsSync.request();
|
|
8367
|
+
requestTranscriptsSync();
|
|
7970
8368
|
});
|
|
7971
8369
|
|
|
7972
8370
|
// Sanity-check DB for timestamps in the future (clock skew, corrupted data).
|
|
@@ -7994,19 +8392,25 @@ function applyMarkerDrag(localX: number, localY: number, shiftKey = false) {
|
|
|
7994
8392
|
// So when you configure the web page, and you hit refresh, or the page automatically
|
|
7995
8393
|
// refreshes, you don't lose your settings.
|
|
7996
8394
|
try {
|
|
7997
|
-
if (sessionStorage.getItem("playPositionLocal") === "0") {
|
|
8395
|
+
if (sessionStorage.getItem(sessionKey("playPositionLocal")) === "0") {
|
|
7998
8396
|
const playheadMs = playheadInVideoMs();
|
|
7999
8397
|
playPositionLocal.checked = false;
|
|
8000
8398
|
loadPlayPositionSeconds(playheadMs);
|
|
8001
8399
|
}
|
|
8002
8400
|
// Applied when the saved tree is in: see initFromDB() above.
|
|
8003
|
-
placeToRestore = parseSavedPlace(
|
|
8004
|
-
|
|
8401
|
+
placeToRestore = parseSavedPlace(
|
|
8402
|
+
sessionStorage.getItem(sessionKey("place")),
|
|
8403
|
+
);
|
|
8404
|
+
if (sessionStorage.getItem(sessionKey("quality")) === "Low Power") {
|
|
8005
8405
|
getById("lowPower", HTMLInputElement).checked = true;
|
|
8006
8406
|
}
|
|
8007
|
-
const savedZoom = sessionStorage.getItem("zoomSelect");
|
|
8008
|
-
const savedPanX = parseFloatX(
|
|
8009
|
-
|
|
8407
|
+
const savedZoom = sessionStorage.getItem(sessionKey("zoomSelect"));
|
|
8408
|
+
const savedPanX = parseFloatX(
|
|
8409
|
+
sessionStorage.getItem(sessionKey("panX")) ?? "",
|
|
8410
|
+
);
|
|
8411
|
+
const savedPanY = parseFloatX(
|
|
8412
|
+
sessionStorage.getItem(sessionKey("panY")) ?? "",
|
|
8413
|
+
);
|
|
8010
8414
|
if (savedZoom !== null) {
|
|
8011
8415
|
zoomSelect.value = savedZoom;
|
|
8012
8416
|
}
|
|
@@ -8018,7 +8422,7 @@ function applyMarkerDrag(localX: number, localY: number, shiftKey = false) {
|
|
|
8018
8422
|
zoomToFit();
|
|
8019
8423
|
}
|
|
8020
8424
|
|
|
8021
|
-
// Restore splitter positions
|
|
8425
|
+
// Restore splitter positions. Shared by every video: they're the window's layout.
|
|
8022
8426
|
// Values are stored as "XX.XX%" (new format) or a bare number in pixels (old).
|
|
8023
8427
|
const topLeftH = sessionStorage.getItem("pane-height-top-left") ?? "";
|
|
8024
8428
|
const topRightH = sessionStorage.getItem("pane-height-top-right") ?? "";
|
|
@@ -8038,12 +8442,24 @@ function applyMarkerDrag(localX: number, localY: number, shiftKey = false) {
|
|
|
8038
8442
|
const fL = toFlex(leftColW);
|
|
8039
8443
|
if (fL) getById("left-col", HTMLDivElement).style.flex = fL;
|
|
8040
8444
|
} finally {
|
|
8041
|
-
|
|
8042
|
-
//
|
|
8043
|
-
//
|
|
8044
|
-
|
|
8445
|
+
// Each value is read once, at startup. saveState() writes them again as the page goes.
|
|
8446
|
+
// Only this video's: another video in this tab keeps its own until it loads.
|
|
8447
|
+
// The plain names are from before 0.8.4, when every video shared them.
|
|
8448
|
+
for (const name of PER_VIDEO_SESSION_KEYS) {
|
|
8449
|
+
sessionStorage.removeItem(name);
|
|
8450
|
+
// Keep the unload backup until initFromDB() has saved it. If the page reloads before
|
|
8451
|
+
// then, saveOnUnload() saves nothing, so this is the only copy.
|
|
8452
|
+
if (name !== "pendingScheduleSave") {
|
|
8453
|
+
sessionStorage.removeItem(sessionKey(name));
|
|
8454
|
+
}
|
|
8455
|
+
}
|
|
8456
|
+
if (
|
|
8457
|
+
unloadBackup !== null &&
|
|
8458
|
+
sessionStorage.getItem(sessionKey("pendingScheduleSave")) === null
|
|
8459
|
+
) {
|
|
8460
|
+
// It was under the old plain name, removed just above.
|
|
8045
8461
|
try {
|
|
8046
|
-
sessionStorage.setItem("pendingScheduleSave", unloadBackup);
|
|
8462
|
+
sessionStorage.setItem(sessionKey("pendingScheduleSave"), unloadBackup);
|
|
8047
8463
|
} catch {
|
|
8048
8464
|
// It fit a moment ago.
|
|
8049
8465
|
}
|