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.
Files changed (242) hide show
  1. package/README.md +10 -2
  2. package/dev/canvas-recorder.css +14 -0
  3. package/dev/canvas-recorder.ts +500 -84
  4. package/dev/color-picker.ts +13 -0
  5. package/dev/component-picker.ts +60 -11
  6. package/dev/font-widgets.ts +2 -2
  7. package/dev/format-editor.ts +3 -1
  8. package/dev/fourier-panel.ts +7 -3
  9. package/dev/handwriting-panel.ts +7 -7
  10. package/dev/multi-text-dialog.ts +28 -15
  11. package/dev/player-body.ts +95 -36
  12. package/dev/schedule-helpers.ts +10 -3
  13. package/dev/static-image-panel.ts +4 -4
  14. package/dev/subtitles.ts +170 -0
  15. package/dev/synced-file.ts +34 -0
  16. package/dev/timeline-display.ts +1 -1
  17. package/dev/transcript-align.ts +4 -1
  18. package/dev/transcript-editor.ts +1205 -0
  19. package/dev/transcript-export.ts +90 -0
  20. package/dev/transcript-view.ts +8 -5
  21. package/dev/transcripts.ts +140 -15
  22. package/dev/video-clip-panel.ts +4 -4
  23. package/dist/dev/canvas-recorder.css +14 -0
  24. package/dist/dev/canvas-recorder.js +408 -74
  25. package/dist/dev/canvas-recorder.js.map +1 -1
  26. package/dist/dev/color-picker.d.ts.map +1 -1
  27. package/dist/dev/color-picker.js +15 -0
  28. package/dist/dev/color-picker.js.map +1 -1
  29. package/dist/dev/component-picker.d.ts +2 -1
  30. package/dist/dev/component-picker.d.ts.map +1 -1
  31. package/dist/dev/component-picker.js +56 -11
  32. package/dist/dev/component-picker.js.map +1 -1
  33. package/dist/dev/font-widgets.d.ts +2 -2
  34. package/dist/dev/font-widgets.d.ts.map +1 -1
  35. package/dist/dev/font-widgets.js.map +1 -1
  36. package/dist/dev/format-editor.d.ts.map +1 -1
  37. package/dist/dev/format-editor.js +3 -1
  38. package/dist/dev/format-editor.js.map +1 -1
  39. package/dist/dev/fourier-panel.d.ts.map +1 -1
  40. package/dist/dev/fourier-panel.js +4 -3
  41. package/dist/dev/fourier-panel.js.map +1 -1
  42. package/dist/dev/handwriting-panel.d.ts +4 -4
  43. package/dist/dev/handwriting-panel.d.ts.map +1 -1
  44. package/dist/dev/handwriting-panel.js.map +1 -1
  45. package/dist/dev/multi-text-dialog.d.ts.map +1 -1
  46. package/dist/dev/multi-text-dialog.js +23 -12
  47. package/dist/dev/multi-text-dialog.js.map +1 -1
  48. package/dist/dev/player-body.d.ts +1 -1
  49. package/dist/dev/player-body.d.ts.map +1 -1
  50. package/dist/dev/player-body.js +95 -36
  51. package/dist/dev/player-body.js.map +1 -1
  52. package/dist/dev/schedule-helpers.d.ts.map +1 -1
  53. package/dist/dev/schedule-helpers.js +4 -2
  54. package/dist/dev/schedule-helpers.js.map +1 -1
  55. package/dist/dev/static-image-panel.d.ts +3 -3
  56. package/dist/dev/static-image-panel.d.ts.map +1 -1
  57. package/dist/dev/subtitles.d.ts +36 -0
  58. package/dist/dev/subtitles.d.ts.map +1 -0
  59. package/dist/dev/subtitles.js +135 -0
  60. package/dist/dev/subtitles.js.map +1 -0
  61. package/dist/dev/synced-file.d.ts +14 -0
  62. package/dist/dev/synced-file.d.ts.map +1 -1
  63. package/dist/dev/synced-file.js +22 -0
  64. package/dist/dev/synced-file.js.map +1 -1
  65. package/dist/dev/timeline-display.d.ts +5 -0
  66. package/dist/dev/timeline-display.d.ts.map +1 -1
  67. package/dist/dev/timeline-display.js +1 -1
  68. package/dist/dev/timeline-display.js.map +1 -1
  69. package/dist/dev/transcript-align.d.ts +3 -1
  70. package/dist/dev/transcript-align.d.ts.map +1 -1
  71. package/dist/dev/transcript-align.js +2 -0
  72. package/dist/dev/transcript-align.js.map +1 -1
  73. package/dist/dev/transcript-editor.d.ts +36 -0
  74. package/dist/dev/transcript-editor.d.ts.map +1 -0
  75. package/dist/dev/transcript-editor.js +964 -0
  76. package/dist/dev/transcript-editor.js.map +1 -0
  77. package/dist/dev/transcript-export.d.ts +21 -0
  78. package/dist/dev/transcript-export.d.ts.map +1 -1
  79. package/dist/dev/transcript-export.js +65 -0
  80. package/dist/dev/transcript-export.js.map +1 -1
  81. package/dist/dev/transcript-view.d.ts +2 -0
  82. package/dist/dev/transcript-view.d.ts.map +1 -1
  83. package/dist/dev/transcript-view.js +1 -1
  84. package/dist/dev/transcript-view.js.map +1 -1
  85. package/dist/dev/transcripts.d.ts +18 -1
  86. package/dist/dev/transcripts.d.ts.map +1 -1
  87. package/dist/dev/transcripts.js +102 -12
  88. package/dist/dev/transcripts.js.map +1 -1
  89. package/dist/dev/video-clip-panel.d.ts +3 -3
  90. package/dist/dev/video-clip-panel.d.ts.map +1 -1
  91. package/dist/lib/index.d.ts +1 -0
  92. package/dist/lib/index.d.ts.map +1 -1
  93. package/dist/lib/index.js +1 -0
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/src/glib/line-font.d.ts +6 -0
  96. package/dist/src/glib/line-font.d.ts.map +1 -1
  97. package/dist/src/glib/line-font.js +9 -0
  98. package/dist/src/glib/line-font.js.map +1 -1
  99. package/dist/src/glib/path-shape.d.ts +16 -0
  100. package/dist/src/glib/path-shape.d.ts.map +1 -1
  101. package/dist/src/glib/path-shape.js +23 -0
  102. package/dist/src/glib/path-shape.js.map +1 -1
  103. package/dist/src/glib/transforms.d.ts +9 -0
  104. package/dist/src/glib/transforms.d.ts.map +1 -1
  105. package/dist/src/glib/transforms.js +7 -4
  106. package/dist/src/glib/transforms.js.map +1 -1
  107. package/dist/src/interpolate.d.ts +17 -10
  108. package/dist/src/interpolate.d.ts.map +1 -1
  109. package/dist/src/interpolate.js +1 -17
  110. package/dist/src/interpolate.js.map +1 -1
  111. package/dist/src/morph-animation.js +1 -1
  112. package/dist/src/morph-animation.js.map +1 -1
  113. package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
  114. package/dist/src/peano-fourier/fourier-shared.js +4 -2
  115. package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
  116. package/dist/src/schedule-helper.d.ts +50 -28
  117. package/dist/src/schedule-helper.d.ts.map +1 -1
  118. package/dist/src/schedule-helper.js +22 -0
  119. package/dist/src/schedule-helper.js.map +1 -1
  120. package/dist/src/showable.d.ts +59 -11
  121. package/dist/src/showable.d.ts.map +1 -1
  122. package/dist/src/showable.js +19 -0
  123. package/dist/src/showable.js.map +1 -1
  124. package/dist/src/slide-components/arrow.d.ts +4 -4
  125. package/dist/src/slide-components/arrow.d.ts.map +1 -1
  126. package/dist/src/slide-components/cross-fade-transition.d.ts +2 -1
  127. package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
  128. package/dist/src/slide-components/cross-fade-transition.js +2 -1
  129. package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
  130. package/dist/src/slide-components/duration-agnostic.d.ts +3 -2
  131. package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
  132. package/dist/src/slide-components/duration-agnostic.js +4 -2
  133. package/dist/src/slide-components/duration-agnostic.js.map +1 -1
  134. package/dist/src/slide-components/fixed-duration.d.ts +3 -1
  135. package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
  136. package/dist/src/slide-components/fixed-duration.js +4 -2
  137. package/dist/src/slide-components/fixed-duration.js.map +1 -1
  138. package/dist/src/slide-components/fourier.d.ts +19 -12
  139. package/dist/src/slide-components/fourier.d.ts.map +1 -1
  140. package/dist/src/slide-components/fourier.js +70 -22
  141. package/dist/src/slide-components/fourier.js.map +1 -1
  142. package/dist/src/slide-components/function-graph.d.ts +4 -3
  143. package/dist/src/slide-components/function-graph.d.ts.map +1 -1
  144. package/dist/src/slide-components/function-graph.js +6 -2
  145. package/dist/src/slide-components/function-graph.js.map +1 -1
  146. package/dist/src/slide-components/halftone-shadow.d.ts +8 -7
  147. package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
  148. package/dist/src/slide-components/halftone-shadow.js +2 -1
  149. package/dist/src/slide-components/halftone-shadow.js.map +1 -1
  150. package/dist/src/slide-components/handwriting-effect.d.ts +8 -6
  151. package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
  152. package/dist/src/slide-components/handwriting-effect.js +4 -2
  153. package/dist/src/slide-components/handwriting-effect.js.map +1 -1
  154. package/dist/src/slide-components/hold.d.ts +4 -2
  155. package/dist/src/slide-components/hold.d.ts.map +1 -1
  156. package/dist/src/slide-components/hold.js +4 -2
  157. package/dist/src/slide-components/hold.js.map +1 -1
  158. package/dist/src/slide-components/image.d.ts +7 -7
  159. package/dist/src/slide-components/image.d.ts.map +1 -1
  160. package/dist/src/slide-components/image.js +4 -2
  161. package/dist/src/slide-components/image.js.map +1 -1
  162. package/dist/src/slide-components/in-parallel.d.ts +12 -3
  163. package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
  164. package/dist/src/slide-components/in-parallel.js +27 -2
  165. package/dist/src/slide-components/in-parallel.js.map +1 -1
  166. package/dist/src/slide-components/in-series.d.ts +2 -1
  167. package/dist/src/slide-components/in-series.d.ts.map +1 -1
  168. package/dist/src/slide-components/in-series.js +2 -1
  169. package/dist/src/slide-components/in-series.js.map +1 -1
  170. package/dist/src/slide-components/live-duration.d.ts +3 -1
  171. package/dist/src/slide-components/live-duration.d.ts.map +1 -1
  172. package/dist/src/slide-components/live-duration.js +4 -2
  173. package/dist/src/slide-components/live-duration.js.map +1 -1
  174. package/dist/src/slide-components/multi-text.d.ts +39 -26
  175. package/dist/src/slide-components/multi-text.d.ts.map +1 -1
  176. package/dist/src/slide-components/multi-text.js +44 -29
  177. package/dist/src/slide-components/multi-text.js.map +1 -1
  178. package/dist/src/slide-components/rectangle.d.ts +5 -4
  179. package/dist/src/slide-components/rectangle.d.ts.map +1 -1
  180. package/dist/src/slide-components/rectangle.js +2 -1
  181. package/dist/src/slide-components/rectangle.js.map +1 -1
  182. package/dist/src/slide-components/registry.d.ts +5 -0
  183. package/dist/src/slide-components/registry.d.ts.map +1 -1
  184. package/dist/src/slide-components/registry.js +28 -27
  185. package/dist/src/slide-components/registry.js.map +1 -1
  186. package/dist/src/slide-components/show-error.d.ts.map +1 -1
  187. package/dist/src/slide-components/show-error.js +3 -2
  188. package/dist/src/slide-components/show-error.js.map +1 -1
  189. package/dist/src/slide-components/simple-text.d.ts +11 -10
  190. package/dist/src/slide-components/simple-text.d.ts.map +1 -1
  191. package/dist/src/slide-components/simple-text.js +5 -3
  192. package/dist/src/slide-components/simple-text.js.map +1 -1
  193. package/dist/src/slide-components/slide-component.d.ts +14 -13
  194. package/dist/src/slide-components/slide-component.d.ts.map +1 -1
  195. package/dist/src/slide-components/slide-component.js +2 -1
  196. package/dist/src/slide-components/slide-component.js.map +1 -1
  197. package/dist/src/slide-components/slide-left.d.ts +2 -1
  198. package/dist/src/slide-components/slide-left.d.ts.map +1 -1
  199. package/dist/src/slide-components/slide-left.js +2 -1
  200. package/dist/src/slide-components/slide-left.js.map +1 -1
  201. package/dist/src/slide-components/text-effect.d.ts +9 -1
  202. package/dist/src/slide-components/text-effect.d.ts.map +1 -1
  203. package/dist/src/slide-components/text-effect.js.map +1 -1
  204. package/dist/src/slide-components/traditional-text.d.ts +8 -8
  205. package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
  206. package/dist/src/slide-components/video-clip.d.ts +5 -4
  207. package/dist/src/slide-components/video-clip.d.ts.map +1 -1
  208. package/dist/src/slide-components/video-clip.js +5 -2
  209. package/dist/src/slide-components/video-clip.js.map +1 -1
  210. package/lib/index.ts +1 -0
  211. package/package.json +2 -2
  212. package/src/glib/line-font.ts +9 -0
  213. package/src/glib/path-shape.ts +35 -0
  214. package/src/glib/transforms.ts +7 -4
  215. package/src/interpolate.ts +18 -27
  216. package/src/morph-animation.ts +1 -1
  217. package/src/peano-fourier/fourier-shared.ts +4 -2
  218. package/src/schedule-helper.ts +50 -28
  219. package/src/showable.ts +81 -11
  220. package/src/slide-components/arrow.ts +4 -4
  221. package/src/slide-components/cross-fade-transition.ts +9 -2
  222. package/src/slide-components/duration-agnostic.ts +4 -3
  223. package/src/slide-components/fixed-duration.ts +4 -2
  224. package/src/slide-components/fourier.ts +89 -32
  225. package/src/slide-components/function-graph.ts +7 -3
  226. package/src/slide-components/halftone-shadow.ts +9 -7
  227. package/src/slide-components/handwriting-effect.ts +8 -6
  228. package/src/slide-components/hold.ts +18 -4
  229. package/src/slide-components/image.ts +9 -7
  230. package/src/slide-components/in-parallel.ts +31 -1
  231. package/src/slide-components/in-series.ts +3 -1
  232. package/src/slide-components/live-duration.ts +4 -2
  233. package/src/slide-components/multi-text.ts +71 -44
  234. package/src/slide-components/rectangle.ts +6 -4
  235. package/src/slide-components/registry.ts +33 -27
  236. package/src/slide-components/show-error.ts +4 -2
  237. package/src/slide-components/simple-text.ts +22 -12
  238. package/src/slide-components/slide-component.ts +15 -13
  239. package/src/slide-components/slide-left.ts +9 -2
  240. package/src/slide-components/text-effect.ts +9 -0
  241. package/src/slide-components/traditional-text.ts +8 -8
  242. package/src/slide-components/video-clip.ts +9 -5
@@ -0,0 +1,170 @@
1
+ import type { PlacedSoundClip } from "./soundtrack.ts";
2
+ import type { TranscriptWord } from "./transcript-align.ts";
3
+
4
+ /**
5
+ * Subtitles for a saved video, made from the transcripts of its sound clips.
6
+ *
7
+ * Word by word, the way YouTube shows its own automatic captions: each word appears as it's
8
+ * spoken, and the line before stays on screen above the one being spoken. Every change is its
9
+ * own cue, so any player shows it this way, with no styling and no timestamps inside a cue.
10
+ *
11
+ * See "Transcript Editor" in development-plans/saturday-afternoon.md.
12
+ */
13
+
14
+ /** One word, in the video's time. */
15
+ export type SubtitleWord = {
16
+ readonly text: string;
17
+ readonly startMs: number;
18
+ readonly endMs: number;
19
+ };
20
+
21
+ /** A line breaks before it gets longer than this. About as long as YouTube's own lines. */
22
+ const MAX_LINE_CHARACTERS = 42;
23
+ /** A silence this long starts a new line. */
24
+ const PAUSE_MS = 1000;
25
+ /** How long the last line stays up after its last word, unless the next line comes sooner. */
26
+ const HOLD_MS = 1500;
27
+
28
+ /**
29
+ * Every word the video says, in the video's time, in order.
30
+ *
31
+ * A word belongs to the clip that plays its start. Speech Whisper left out (timing `letters`)
32
+ * isn't included: it's nearly always a repeat, a false start or an um. Editing one in the
33
+ * Transcript Editor makes it a real word.
34
+ *
35
+ * @param clips Every sound clip in the video.
36
+ * @param wordsOf A file's words, or undefined if its transcript isn't ready.
37
+ */
38
+ export function subtitleWords(
39
+ clips: readonly PlacedSoundClip[],
40
+ wordsOf: (source: string) => readonly TranscriptWord[] | undefined,
41
+ ): SubtitleWord[] {
42
+ const result: SubtitleWord[] = [];
43
+ for (const clip of clips) {
44
+ const words = wordsOf(clip.source);
45
+ if (!words) continue;
46
+ const fromMs = clip.trimMs;
47
+ const toMs = clip.trimMs + clip.lengthMs;
48
+ /** File time to video time. */
49
+ const shift = clip.startMs - clip.trimMs;
50
+ for (const word of words) {
51
+ if (word.startMs < fromMs || word.startMs >= toMs) continue;
52
+ if (word.timing === "letters") continue;
53
+ const text = word.text.trim();
54
+ if (text === "") continue;
55
+ result.push({
56
+ text,
57
+ startMs: word.startMs + shift,
58
+ endMs: Math.max(word.startMs, Math.min(word.endMs, toMs)) + shift,
59
+ });
60
+ }
61
+ }
62
+ return result.sort((a, b) => a.startMs - b.startMs);
63
+ }
64
+
65
+ /** Group the words into lines, breaking at the length limit, a pause, or the end of a sentence. */
66
+ function toLines(words: readonly SubtitleWord[]): SubtitleWord[][] {
67
+ const lines: SubtitleWord[][] = [];
68
+ let line: SubtitleWord[] = [];
69
+ let length = 0;
70
+ for (const word of words) {
71
+ const previous = line.at(-1);
72
+ if (
73
+ previous &&
74
+ (length + 1 + word.text.length > MAX_LINE_CHARACTERS ||
75
+ word.startMs - previous.endMs > PAUSE_MS ||
76
+ /[.?!]["'”’)]*$/.test(previous.text))
77
+ ) {
78
+ lines.push(line);
79
+ line = [];
80
+ length = 0;
81
+ }
82
+ length += (line.length ? 1 : 0) + word.text.length;
83
+ line.push(word);
84
+ }
85
+ if (line.length) lines.push(line);
86
+ return lines;
87
+ }
88
+
89
+ type Cue = {
90
+ readonly startMs: number;
91
+ readonly endMs: number;
92
+ readonly text: string;
93
+ };
94
+
95
+ /**
96
+ * One cue for each word: the line so far, under the previous line when there was no gap.
97
+ * The cues are in order and never overlap.
98
+ */
99
+ function toCues(words: readonly SubtitleWord[]): Cue[] {
100
+ const lines = toLines(words);
101
+ const result: Cue[] = [];
102
+ /** The previous line, while it's still on screen. */
103
+ let above: string | undefined;
104
+ for (let l = 0; l < lines.length; l++) {
105
+ const line = lines[l]!;
106
+ const nextStart = lines[l + 1]?.[0]!.startMs ?? Infinity;
107
+ const lineEnd = Math.min(nextStart, line.at(-1)!.endMs + HOLD_MS);
108
+ for (let i = 0; i < line.length; i++) {
109
+ const startMs = line[i]!.startMs;
110
+ const endMs = i + 1 < line.length ? line[i + 1]!.startMs : lineEnd;
111
+ // Two words at the same moment: the next cue shows both.
112
+ if (endMs <= startMs) continue;
113
+ const spoken = line
114
+ .slice(0, i + 1)
115
+ .map((word) => word.text)
116
+ .join(" ");
117
+ result.push({
118
+ startMs,
119
+ endMs,
120
+ text: above === undefined ? spoken : `${above}\n${spoken}`,
121
+ });
122
+ }
123
+ // The next line keeps this one above it only if they touch.
124
+ above =
125
+ lineEnd >= nextStart
126
+ ? line.map((word) => word.text).join(" ")
127
+ : undefined;
128
+ }
129
+ return result;
130
+ }
131
+
132
+ /**
133
+ * A WebVTT file for part of the video.
134
+ * @param fromMs Where the saved file starts, in the video's time. It becomes 0.
135
+ * @param toMs Where the saved file ends.
136
+ * @returns Undefined if no words are spoken in that time.
137
+ */
138
+ export function webVtt(
139
+ words: readonly SubtitleWord[],
140
+ fromMs: number,
141
+ toMs: number,
142
+ ): string | undefined {
143
+ const cues: string[] = [];
144
+ for (const cue of toCues(words)) {
145
+ const startMs = Math.round(Math.max(cue.startMs, fromMs) - fromMs);
146
+ const endMs = Math.round(Math.min(cue.endMs, toMs) - fromMs);
147
+ if (endMs <= startMs) continue;
148
+ cues.push(
149
+ `${timestamp(startMs)} --> ${timestamp(endMs)}\n${escapeCueText(cue.text)}`,
150
+ );
151
+ }
152
+ return cues.length ? `WEBVTT\n\n${cues.join("\n\n")}\n` : undefined;
153
+ }
154
+
155
+ /** hh:mm:ss.ttt, as WebVTT wants. */
156
+ function timestamp(ms: number): string {
157
+ const pad = (n: number, width = 2) => String(n).padStart(width, "0");
158
+ const hours = Math.floor(ms / 3_600_000);
159
+ const minutes = Math.floor(ms / 60_000) % 60;
160
+ const seconds = Math.floor(ms / 1000) % 60;
161
+ return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}.${pad(ms % 1000, 3)}`;
162
+ }
163
+
164
+ /** WebVTT cue text is a little like HTML. This also rules out "-->". */
165
+ function escapeCueText(text: string): string {
166
+ return text
167
+ .replace(/&/g, "&amp;")
168
+ .replace(/</g, "&lt;")
169
+ .replace(/>/g, "&gt;");
170
+ }
@@ -55,6 +55,22 @@ export type SyncedFileOptions = {
55
55
  readonly showPending?: boolean;
56
56
  };
57
57
 
58
+ /**
59
+ * A synced file's state in one word, for a button that stands for several files.
60
+ * * `off`: the checkbox is off.
61
+ * * `ok`: the file matches, or will in a moment with nothing for anyone to do.
62
+ * * `pending`: memory is ahead of the file, waiting for the next save.
63
+ * * `action`: someone has to click something: permission, a conflict or an error.
64
+ */
65
+ export type SyncSummary = "off" | "ok" | "pending" | "action";
66
+
67
+ const summaryListeners = new Set<() => void>();
68
+
69
+ /** Called whenever any synced file's status is redrawn. See {@link SyncedFile.summary}. */
70
+ export function onSyncStatusChange(listener: () => void): void {
71
+ summaryListeners.add(listener);
72
+ }
73
+
58
74
  type State =
59
75
  | { kind: "starting" }
60
76
  | { kind: "off" }
@@ -73,6 +89,7 @@ export class SyncedFile {
73
89
  #again = false;
74
90
  /** The next sync may overwrite a file someone else changed: the user said so. */
75
91
  #forceNext = false;
92
+ #summary: SyncSummary = "off";
76
93
 
77
94
  constructor(options: SyncedFileOptions) {
78
95
  this.#options = options;
@@ -135,6 +152,16 @@ export class SyncedFile {
135
152
  })();
136
153
  }
137
154
 
155
+ /** The state in one word, as of the last redraw. */
156
+ get summary(): SyncSummary {
157
+ return this.#summary;
158
+ }
159
+
160
+ /** What the status shows, as plain text, for a tooltip. */
161
+ get statusText(): string {
162
+ return this.#options.status.textContent ?? "";
163
+ }
164
+
138
165
  /** Redraw, e.g. to show or clear the pending " *" after an edit. Cheap; does no I/O. */
139
166
  refreshStatus(): void {
140
167
  this.#draw();
@@ -288,14 +315,17 @@ export class SyncedFile {
288
315
  case "starting":
289
316
  text("…");
290
317
  status.style.color = "gray";
318
+ this.#summary = "ok";
291
319
  break;
292
320
  case "off":
293
321
  text("off");
294
322
  status.style.color = "gray";
323
+ this.#summary = "off";
295
324
  break;
296
325
  case "synced": {
297
326
  const pending =
298
327
  showPending && render() !== this.#record?.lastWrittenBody;
328
+ this.#summary = pending ? "pending" : "ok";
299
329
  text(`${name} ${pending ? "*" : "✓"}`);
300
330
  status.style.color = pending ? "darkorange" : "";
301
331
  status.title = pending
@@ -311,12 +341,14 @@ export class SyncedFile {
311
341
  "The browser needs your permission again to write this file. " +
312
342
  'Choosing "Allow on every visit" stops it asking.';
313
343
  status.onclick = () => void this.#allow();
344
+ this.#summary = "action";
314
345
  break;
315
346
  case "conflict":
316
347
  text(`${name} ⚠ changed on disk`);
317
348
  status.style.color = "darkorange";
318
349
  status.title =
319
350
  "Something else changed this file since it was last synced, so it hasn't been overwritten.";
351
+ this.#summary = "action";
320
352
  button("Overwrite", `Replace ${name} with the current state`, () =>
321
353
  this.request(true),
322
354
  );
@@ -334,8 +366,10 @@ export class SyncedFile {
334
366
  status.style.cursor = "pointer";
335
367
  status.title = this.#state.message;
336
368
  status.onclick = () => this.request();
369
+ this.#summary = "action";
337
370
  break;
338
371
  }
372
+ for (const listener of summaryListeners) listener();
339
373
  }
340
374
  }
341
375
 
@@ -78,7 +78,7 @@ export type TimelineWord = {
78
78
  };
79
79
 
80
80
  /** Background colors for flagged words. The 📖 Text view uses lighter versions of the same colors. */
81
- const WORD_FLAG_COLORS = {
81
+ export const WORD_FLAG_COLORS = {
82
82
  "left out": "rgba(225, 30, 30, 0.9)",
83
83
  doubtful: "rgba(255, 140, 0, 0.8)",
84
84
  } as const;
@@ -41,8 +41,10 @@ export type TranscriptWord = {
41
41
  * * `letters`: speech Whisper **left out**, such as a repeated word, a false
42
42
  * start or an "um". Whisper tidies what it hears; the letter model doesn't.
43
43
  * See {@link recoverSkippedSpeech}.
44
+ * * `edited`: a person typed, timed or checked this word in the Transcript
45
+ * Editor. Never flagged, and always in the subtitles.
44
46
  */
45
- readonly timing: "aligned" | "whisper" | "letters";
47
+ readonly timing: "aligned" | "whisper" | "letters" | "edited";
46
48
  /**
47
49
  * How sure the letter model was, 0 to 1: the average probability it gave
48
50
  * the letters it was made to hear. Low in noise and mumbling. Only
@@ -588,6 +590,7 @@ const squash = (s: string) => s.toLowerCase().replace(/[^a-z']/g, "");
588
590
  export function wordFlag(
589
591
  word: TranscriptWord,
590
592
  ): "left out" | "doubtful" | undefined {
593
+ if (word.timing === "edited") return undefined;
591
594
  if (word.timing === "letters") return "left out";
592
595
  const text = squash(word.text);
593
596
  // `heard` is missing from transcripts made before it existed.