rvlib-shipkit 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- package/src/checks/SK004-gitignore-policy.check.ts +6 -3
- package/src/checks/SK040-release-words.check.ts +43 -0
- package/src/checks/SK041-annex-links.check.ts +28 -0
- package/src/checks/SK042-post-kinds.check.ts +73 -0
- package/src/cli/cmd_Annex.ts +179 -0
- package/src/cli/cmd_Commands.ts +4 -1
- package/src/cli/cmd_GlobalProcesses.ts +2 -107
- package/src/cli/cmd_Home.ts +4 -3
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Overview.ts +2 -1
- package/src/cli/cmd_Releases.ts +84 -0
- package/src/cli/cmd_Review.ts +176 -12
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +151 -8
- package/src/cli/cmd_Sound.ts +17 -4
- package/src/cli/cmd_Trailer.ts +67 -1
- package/src/cli/family-pages.ts +2 -0
- package/src/cli/kit/index.ts +1 -1
- package/src/cli/kit/verb.ts +11 -3
- package/src/cli/registry.ts +7 -1
- package/src/collections/collection-types.ts +8 -1
- package/src/collections/providers.ts +4 -1
- package/src/collections/review.ts +23 -4
- package/src/commands/model.ts +36 -0
- package/src/commands/registry.ts +49 -0
- package/src/commands/routes.ts +59 -0
- package/src/commands/runner.ts +35 -0
- package/src/commands/runs.ts +112 -0
- package/src/core/app-icon.ts +4 -3
- package/src/core/icon-type.ts +8 -0
- package/src/core/jobs.ts +4 -3
- package/src/core/layout.ts +11 -2
- package/src/core/squircle.ts +95 -0
- package/src/home/daemon-jobs.ts +26 -2
- package/src/home/global-units.ts +3 -0
- package/src/home/gui-app/ShipkitGui.swift +337 -5
- package/src/home/gui-app.ts +64 -33
- package/src/home/hmr-keep.ts +134 -0
- package/src/home/home-start.ts +2 -2
- package/src/home/lib-watch.ts +21 -11
- package/src/home/pm-switch.ts +112 -0
- package/src/home/pm.ts +1 -1
- package/src/home/process-apps.ts +181 -0
- package/src/home/resources.ts +3 -3
- package/src/home/run-web.ts +7 -4
- package/src/home/serve-web.ts +64 -14
- package/src/identities/collection.ts +49 -0
- package/src/identities/identities.ts +121 -14
- package/src/identities/machine.ts +4 -3
- package/src/identities/rating.ts +33 -0
- package/src/identities/shown.ts +170 -0
- package/src/identities/steps.ts +5 -0
- package/src/media-store/purge.ts +15 -1
- package/src/media-store/remote.ts +22 -6
- package/src/messages/brief.ts +117 -0
- package/src/messages/collection.ts +40 -0
- package/src/messages/model.ts +171 -0
- package/src/messages/routes.ts +15 -0
- package/src/messages/score.ts +182 -0
- package/src/messages/tabs.ts +13 -0
- package/src/release/notes.ts +130 -0
- package/src/release/run-bump.ts +41 -18
- package/src/release/run-release.ts +22 -4
- package/src/release/run-releases.ts +17 -15
- package/src/release/unit-resolve.ts +9 -0
- package/src/releases/add.ts +94 -0
- package/src/releases/before.ts +31 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +151 -0
- package/src/releases/model.ts +327 -0
- package/src/releases/pictures.ts +110 -0
- package/src/releases/routes.ts +36 -0
- package/src/releases/store.ts +71 -0
- package/src/repo-config.ts +5 -0
- package/src/review/cells.ts +0 -11
- package/src/review/format.ts +10 -6
- package/src/review/http.ts +1 -1
- package/src/review/model.ts +102 -3
- package/src/review/notes.ts +2 -48
- package/src/review/routes.ts +28 -10
- package/src/review/stage-card.ts +197 -0
- package/src/review/stage-routes.ts +123 -0
- package/src/review/store.ts +47 -1
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +76 -4
- package/src/review/trailer-model.ts +106 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +119 -13
- package/src/review/trailer-voices.ts +144 -0
- package/src/review/watchers.ts +58 -1
- package/src/serve/hub-app/app-bridge.ts +71 -0
- package/src/serve/hub-app/benign-errors.ts +22 -0
- package/src/serve/hub-app/commands/commands-page.tsx +122 -0
- package/src/serve/hub-app/commands/commands-st.ts +177 -0
- package/src/serve/hub-app/commands.css +24 -0
- package/src/serve/hub-app/hash-route.ts +59 -8
- package/src/serve/hub-app/home-st.ts +19 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +8 -0
- package/src/serve/hub-app/icons.tsx +5 -0
- package/src/serve/hub-app/identities-view.tsx +4 -1
- package/src/serve/hub-app/identities.css +1 -0
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +41 -10
- package/src/serve/hub-app/messages/messages-page.tsx +354 -0
- package/src/serve/hub-app/messages/messages-st.ts +74 -0
- package/src/serve/hub-app/messages.css +35 -0
- package/src/serve/hub-app/project-list.css +7 -2
- package/src/serve/hub-app/project-list.tsx +9 -0
- package/src/serve/hub-app/projects-svc.ts +16 -6
- package/src/serve/hub-app/releases/releases-page.tsx +187 -0
- package/src/serve/hub-app/releases/releases-st.ts +111 -0
- package/src/serve/hub-app/releases.css +52 -0
- package/src/serve/hub-app/repo-sections.ts +16 -2
- package/src/serve/hub-app/repo-st.ts +66 -10
- package/src/serve/hub-app/review/clip-st.ts +34 -4
- package/src/serve/hub-app/review/kit.tsx +3 -3
- package/src/serve/hub-app/review/note-place.ts +31 -0
- package/src/serve/hub-app/review/review-cells.tsx +27 -3
- package/src/serve/hub-app/review/review-st.ts +77 -2
- package/src/serve/hub-app/review/review-thread.tsx +9 -31
- package/src/serve/hub-app/review/review-views.tsx +164 -58
- package/src/serve/hub-app/review/thread-st.ts +108 -41
- package/src/serve/hub-app/review/trailer-card.tsx +187 -0
- package/src/serve/hub-app/review/trailer-page.tsx +92 -36
- package/src/serve/hub-app/review/trailer-st.ts +306 -34
- package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
- package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
- package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
- package/src/serve/hub-app/review.css +137 -6
- package/src/serve/hub-app/social/comms-page.tsx +65 -28
- package/src/serve/hub-app/social/identity-pictures.ts +46 -8
- package/src/serve/hub-app/social/kit.tsx +9 -6
- package/src/serve/hub-app/social/next-release.tsx +118 -0
- package/src/serve/hub-app/social/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +39 -3
- package/src/serve/hub-app/social/social-page.tsx +179 -65
- package/src/serve/hub-app/social/social-st.ts +117 -27
- package/src/serve/hub-app/social/stage-popup.tsx +268 -0
- package/src/serve/hub-app/social/stage-st.ts +310 -0
- package/src/serve/hub-app/social/step-layout.ts +42 -0
- package/src/serve/hub-app/social.css +68 -1
- package/src/serve/hub-app/tree-build.ts +40 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.ts +12 -2
- package/src/serve/project-gutter.ts +4 -2
- package/src/serve/same-origin.ts +24 -1
- package/src/serve/serve-hub.ts +15 -1
- package/src/shipkit-files.ts +9 -7
- package/src/shot/box.ts +33 -12
- package/src/shot/client.ts +1 -1
- package/src/shot/shooter.ts +22 -12
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/desk-index.ts +49 -8
- package/src/social/discord-layout.ts +54 -7
- package/src/social/drafts.ts +1 -1
- package/src/social/fit.ts +84 -0
- package/src/social/identity-words.ts +74 -0
- package/src/social/kind-pages.ts +41 -0
- package/src/social/kinds.ts +93 -0
- package/src/social/load.ts +125 -10
- package/src/social/media-limit.ts +63 -2
- package/src/social/presence.ts +1 -1
- package/src/social/publish/bluesky.ts +58 -19
- package/src/social/publish/index.ts +47 -6
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +277 -0
- package/src/social/routes.ts +44 -8
- package/src/social/stage.ts +246 -0
- package/src/social/strip.ts +85 -0
- package/src/social/text.ts +6 -2
- package/src/social/unit.ts +57 -1
- package/src/social/writes.ts +11 -0
- package/src/trailer/bed.ts +111 -0
- package/src/trailer/build.ts +72 -40
- package/src/trailer/ffmpeg.ts +6 -0
- package/src/trailer/grammar.ts +37 -6
- package/src/trailer/graph.ts +12 -1
- package/src/trailer/public-words.ts +41 -0
- package/src/trailer/shot-plan.ts +75 -0
- package/src/trailer/shot-state.ts +191 -0
- package/src/trailer/sound/audio.ts +28 -0
- package/src/trailer/sound/brand.ts +53 -3
- package/src/trailer/sound/gen.ts +61 -2
- package/src/trailer/sound/index.ts +25 -11
- package/src/trailer/sound/presets.ts +86 -5
- package/src/trailer/sound/run.ts +1 -1
- package/src/trailer/sound/takes.ts +94 -0
- package/src/trailer/titles.ts +36 -0
- package/src/trailer/url.ts +1 -1
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
// the trailer page's timeline: the sections, the shots, the captions and the notes of the render on screen
|
|
2
|
-
//
|
|
1
|
+
// the trailer page's timeline: the sections, the shots, the captions and the notes lane of the render on screen (a
|
|
2
|
+
// card's notes or the page's frame notes, one marker each at its time), a playhead, a click or a drag to seek, a hover
|
|
3
|
+
// with the shot's frame from the contact strip; then every shot as a card
|
|
3
4
|
import { observer } from 'mobx-react-lite'
|
|
4
5
|
import { useEffect, useRef, useState, type CSSProperties, type RefObject } from 'react'
|
|
5
|
-
import { clock, shotAt, type ShotSpan, type Timeline } from '../../../review/trailer-model.ts'
|
|
6
|
-
import { captionText, type
|
|
6
|
+
import { clock, shotAt, type LaneMark, type ShotSpan, type Timeline } from '../../../review/trailer-model.ts'
|
|
7
|
+
import { captionText, type TrailerSt } from './trailer-st.ts'
|
|
8
|
+
import type { ShotStatus } from '../../../trailer/shot-state.ts'
|
|
7
9
|
|
|
8
10
|
const RULER = 18
|
|
9
11
|
const SECTIONS = 22
|
|
10
12
|
const SHOTS = 46
|
|
11
13
|
const CAPTIONS = 22
|
|
14
|
+
const NOTES = 26
|
|
12
15
|
const GAP = 3
|
|
13
|
-
const HEIGHT = RULER + SECTIONS + SHOTS + CAPTIONS + GAP *
|
|
14
|
-
const ROW = { ruler: 0, sections: RULER + GAP, shots: RULER + SECTIONS + GAP * 2, captions: RULER + SECTIONS + SHOTS + GAP * 3 }
|
|
16
|
+
const HEIGHT = RULER + SECTIONS + SHOTS + CAPTIONS + NOTES + GAP * 4
|
|
17
|
+
const ROW = { ruler: 0, sections: RULER + GAP, shots: RULER + SECTIONS + GAP * 2, captions: RULER + SECTIONS + SHOTS + GAP * 3, notes: RULER + SECTIONS + SHOTS + CAPTIONS + GAP * 4 }
|
|
18
|
+
|
|
19
|
+
/** the hover card's height: it shows under the timeline when this much room is left there */
|
|
20
|
+
const HOVER_H = 180
|
|
21
|
+
|
|
22
|
+
/** a length in seconds as the page writes it: `2.6 s`, `0.55 s` */
|
|
23
|
+
export const secsOf = (s: number): string => `${Number(s.toFixed(s < 1 ? 2 : 1))} s`
|
|
15
24
|
|
|
16
25
|
/** a section's hue, one of the page's kind hues by its order: the shot blocks of a section share it */
|
|
17
26
|
export const hueOf = (tl: Timeline, section: string | null): string => {
|
|
@@ -107,7 +116,7 @@ export const TrailerTimeline = observer(({ st }: { st: TrailerSt }) => {
|
|
|
107
116
|
{s.name}
|
|
108
117
|
</div>
|
|
109
118
|
))}
|
|
110
|
-
{tl.shots.map((s, i) => <ShotBlock key={`${s.name}@${i}`} s={s} i={i} x={xOf(s.start)} w={xOf(s.end) - xOf(s.start)} on={cur === s} hue={hueOf(tl, s.section)} />)}
|
|
119
|
+
{tl.shots.map((s, i) => <ShotBlock key={`${s.name}@${i}`} s={s} i={i} x={xOf(s.start)} w={xOf(s.end) - xOf(s.start)} on={cur === s} hue={hueOf(tl, s.section)} changed={st.changed.has(s.name)} status={st.shotStates?.states[s.name]} />)}
|
|
111
120
|
{tl.shots.flatMap((s) =>
|
|
112
121
|
s.captions.map((c, j) => (
|
|
113
122
|
<div key={`${s.name}-${j}`} className={`tr-caption${lit.has(`${c.start}|${c.text}`) ? ' on' : ''}`} title={captionText(c)}
|
|
@@ -116,7 +125,8 @@ export const TrailerTimeline = observer(({ st }: { st: TrailerSt }) => {
|
|
|
116
125
|
</div>
|
|
117
126
|
)),
|
|
118
127
|
)}
|
|
119
|
-
|
|
128
|
+
<div className="tr-lanelabel" style={{ top: ROW.notes, height: NOTES, lineHeight: `${NOTES}px` }}>notes</div>
|
|
129
|
+
{st.lane.map((m) => <LaneMarker key={m.key} m={m} x={xOf(m.at)} />)}
|
|
120
130
|
{st.draft ? <div className="tr-draftmark" style={{ left: xOf(st.draft.time) - 1, height: HEIGHT }} /> : null}
|
|
121
131
|
<Playhead st={st} W={W} total={tl.total} scroller={scroller} />
|
|
122
132
|
</div>
|
|
@@ -126,25 +136,54 @@ export const TrailerTimeline = observer(({ st }: { st: TrailerSt }) => {
|
|
|
126
136
|
)
|
|
127
137
|
})
|
|
128
138
|
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
/** a shot's state as its tooltip says it: the state, the lane and why, the card, then the dim details */
|
|
140
|
+
export const stateTip = (st: ShotStatus): string =>
|
|
141
|
+
[`${st.word}${st.state === 'waiting' && st.card ? ` on card ${st.card}` : ''}${st.by && st.state !== 'ready' ? ` · by ${st.by}` : ''}`, ...(st.why ? [`why: ${st.why}`] : []), ...st.detail].join('\n')
|
|
142
|
+
|
|
143
|
+
const ShotBlock = ({ s, i, x, w, on, hue, changed, status }: { s: ShotSpan; i: number; x: number; w: number; on: boolean; hue: string; changed: boolean; status: ShotStatus | undefined }) => (
|
|
144
|
+
<div className={`tr-shot ${hue}${on ? ' on' : ''}${i % 2 ? ' odd' : ''}${changed ? ' changed' : ''}`} title={`${s.name} · ${clock(s.start)} · ${secsOf(s.length)}${changed ? ' · changed' : ''}${status ? `\n${stateTip(status)}` : ''}`}
|
|
131
145
|
style={{ left: x + 0.5, width: Math.max(1, w - 1), top: ROW.shots, height: SHOTS }}>
|
|
132
146
|
{w > 26 ? s.name : ''}
|
|
133
147
|
{w > 44 ? <div className="tr-shottime">{clock(s.start)}</div> : null}
|
|
148
|
+
{status ? <div className={`tr-sbar ss-${status.state}`} /> : null}
|
|
134
149
|
</div>
|
|
135
150
|
)
|
|
136
151
|
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
/** the cut at a glance, over its timeline: how many shots are ready, queued, filming, not filmed, and the cards whose
|
|
153
|
+
* new takes wait for the owner's answer */
|
|
154
|
+
export const ShotSummary = observer(({ st }: { st: TrailerSt }) => {
|
|
155
|
+
const ss = st.shotStates
|
|
156
|
+
if (!ss) return null
|
|
157
|
+
const { counts: c, total, cards } = ss.summary
|
|
158
|
+
const cut = st.cut?.cut
|
|
139
159
|
return (
|
|
140
|
-
|
|
141
|
-
<
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
<div className="tr-summary" title="each shot's state: a coloured bar under it on the timeline, a line on its card; a lane writes it with sk trailer plan">
|
|
161
|
+
<span className="ss-ready"><span className="tr-sdot" /><b>{c.ready} of {total}</b> shots ready</span>
|
|
162
|
+
<span className="ss-queued"><span className="tr-sdot" />{c.queued} queued</span>
|
|
163
|
+
<span className="ss-filming"><span className="tr-sdot" />{c.filming} filming</span>
|
|
164
|
+
{c.unfilmed > 0 ? <span className="ss-unfilmed"><span className="tr-sdot" />{c.unfilmed} not filmed</span> : null}
|
|
165
|
+
<span className="ss-waiting">
|
|
166
|
+
<span className="tr-sdot" />cards waiting: {cards.length === 0 ? 'none' : cards.map((x) => (
|
|
167
|
+
<button key={x.card} type="button" className="tr-cardlink" title={`open card ${x.card}: the new take of ${x.shots.join(', ')}`} onClick={() => st.openCard(x.card)}>{x.card} ({x.shots.join(', ')})</button>
|
|
168
|
+
))}
|
|
169
|
+
</span>
|
|
170
|
+
{ss.plan !== cut ? <span className="tr-dim tr-small">the plan of {ss.plan}, the cut this version keeps</span> : null}
|
|
171
|
+
{ss.read === null && !st.cut?.version ? <span className="tr-dim tr-small">takes not read yet: sk trailer check shows which are filmed</span> : null}
|
|
172
|
+
</div>
|
|
145
173
|
)
|
|
146
174
|
})
|
|
147
175
|
|
|
176
|
+
/** one note on the lane, numbered in the order of the cut: a click lands on its frame */
|
|
177
|
+
const LaneMarker = ({ m, x }: { m: LaneMark; x: number }) => (
|
|
178
|
+
<>
|
|
179
|
+
<div className={`tr-noteline ns-${m.tone}${m.selected ? ' on' : ''}`} style={{ left: x, top: ROW.sections, height: ROW.notes - ROW.sections }} />
|
|
180
|
+
<button type="button" data-note className={`tr-lanemark ns-${m.tone}${m.selected ? ' on' : ''}`} title={`${m.n} · ${clock(m.at)} · ${m.text}`} style={{ left: Math.max(0, x - 11), top: ROW.notes + 2 }}
|
|
181
|
+
onPointerDown={(e) => e.stopPropagation()} onMouseDown={(e) => e.preventDefault()} onClick={() => m.go()}>
|
|
182
|
+
{m.n}
|
|
183
|
+
</button>
|
|
184
|
+
</>
|
|
185
|
+
)
|
|
186
|
+
|
|
148
187
|
/** the playhead; while it plays, the timeline scrolls to keep it in view */
|
|
149
188
|
const Playhead = observer(({ st, W, total, scroller }: { st: TrailerSt; W: number; total: number; scroller: RefObject<HTMLDivElement | null> }) => {
|
|
150
189
|
const x = (st.time / total) * W
|
|
@@ -163,12 +202,15 @@ const HoverCard = observer(({ st, t, x, scroller }: { st: TrailerSt; t: number;
|
|
|
163
202
|
const s = shotAt(tl, t)
|
|
164
203
|
if (!s) return null
|
|
165
204
|
const i = tl.shots.indexOf(s)
|
|
166
|
-
const
|
|
205
|
+
const b = scroller.current?.getBoundingClientRect()
|
|
206
|
+
// under the timeline when it fits there, so it never covers the frame or the card's header
|
|
207
|
+
const under = b ? window.innerHeight - b.bottom > HOVER_H : false
|
|
208
|
+
const place = under ? { top: (b?.bottom ?? 0) + 8 } : { bottom: window.innerHeight - ((b?.top ?? 0) - 8) }
|
|
167
209
|
return (
|
|
168
|
-
<div className="tr-hover" style={{ left: Math.max(8, Math.min(window.innerWidth - 216, x - 104)),
|
|
210
|
+
<div className="tr-hover" style={{ left: Math.max(8, Math.min(window.innerWidth - 216, x - 104)), ...place }}>
|
|
169
211
|
<Thumb st={st} index={i} w={192} />
|
|
170
212
|
<div className="tr-hoverrow"><b>{s.name}</b><span>{clock(t)}</span></div>
|
|
171
|
-
<div className="tr-dim">{s.section ?? 'opening'} · shot {i + 1}/{tl.shots.length} · {s.length}
|
|
213
|
+
<div className="tr-dim">{s.section ?? 'opening'} · shot {i + 1}/{tl.shots.length} · {secsOf(s.length)}</div>
|
|
172
214
|
</div>
|
|
173
215
|
)
|
|
174
216
|
})
|
|
@@ -193,11 +235,14 @@ export const ShotCards = observer(({ st }: { st: TrailerSt }) => {
|
|
|
193
235
|
<div ref={box} className="tr-shotcards">
|
|
194
236
|
{tl.shots.map((s, i) => {
|
|
195
237
|
const n = counts.get(s.name) ?? 0
|
|
238
|
+
const changed = st.changed.has(s.name)
|
|
239
|
+
const status = st.shotStates?.states[s.name]
|
|
196
240
|
return (
|
|
197
|
-
<button type="button" key={`${s.name}@${i}`} className={`tr-shotcard ${hueOf(tl, s.section)}${i === cur ? ' on' : ''}`} onMouseDown={(e) => e.preventDefault()} onClick={() => st.seek(s.start)}>
|
|
241
|
+
<button type="button" key={`${s.name}@${i}`} className={`tr-shotcard ${hueOf(tl, s.section)}${i === cur ? ' on' : ''}${changed ? ' changed' : ''}`} title={status ? stateTip(status) : undefined} onMouseDown={(e) => e.preventDefault()} onClick={() => st.seek(s.start)}>
|
|
198
242
|
<Thumb st={st} index={i} w={136} />
|
|
199
|
-
<div className="tr-shotname"><span className="tr-dim">{i + 1} </span>{s.name}</div>
|
|
200
|
-
<div className="tr-dim tr-small">{clock(s.start)} · {s.length}
|
|
243
|
+
<div className="tr-shotname"><span className="tr-dim">{i + 1} </span>{s.name}{changed ? <span className="tr-changed" title="the change touched this shot">changed</span> : null}</div>
|
|
244
|
+
<div className="tr-dim tr-small">{clock(s.start)} · {secsOf(s.length)}{s.captions.length > 0 ? ` · ${s.captions.length} title${s.captions.length > 1 ? 's' : ''}` : ''}</div>
|
|
245
|
+
{status ? <div className={`tr-sstate ss-${status.state}`}><span className="tr-sdot" />{status.word}{status.state === 'waiting' && status.card ? <span className="tr-dim">{status.card}</span> : status.why && status.state !== 'ready' ? <span className="tr-dim">{status.why}</span> : null}</div> : null}
|
|
201
246
|
{n > 0 ? <span className="tr-shotnotes">{n}</span> : null}
|
|
202
247
|
</button>
|
|
203
248
|
)
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// the trailer page's Voices as state (wiki tools/trailer/trailer-sound.md, Your own voice): every line of the trailer
|
|
2
|
+
// on screen, the one open with its clip, and his microphone while he records it. A take goes up as the browser
|
|
3
|
+
// recorded it; the build trims and levels it. Read with the trailer page's poll
|
|
4
|
+
import { makeAutoObservable, runInAction } from 'mobx'
|
|
5
|
+
import type { VoiceLine, VoicesDesk, VoiceUse } from '../../../review/trailer-model.ts'
|
|
6
|
+
import { reach } from '../reach.ts'
|
|
7
|
+
import type { RepoSt } from '../repo-st.ts'
|
|
8
|
+
|
|
9
|
+
/** the line's state, in the order the list shows them: his to record first */
|
|
10
|
+
export type VoiceState = 'waiting' | 'recorded' | 'other'
|
|
11
|
+
export const stateOfLine = (l: VoiceLine): VoiceState => (l.mine ? (l.take ? 'recorded' : 'waiting') : 'other')
|
|
12
|
+
const RANK: Record<VoiceState, number> = { waiting: 0, recorded: 1, other: 2 }
|
|
13
|
+
|
|
14
|
+
/** the input he picked, kept by this browser */
|
|
15
|
+
const MIC_KEY = 'shipkit.voices.mic'
|
|
16
|
+
/** the clip's playback level, kept by this browser */
|
|
17
|
+
const VOLUME_KEY = 'shipkit.voices.volume'
|
|
18
|
+
|
|
19
|
+
function readVolume(): number {
|
|
20
|
+
try {
|
|
21
|
+
const v = Number(localStorage.getItem(VOLUME_KEY))
|
|
22
|
+
return localStorage.getItem(VOLUME_KEY) !== null && Number.isFinite(v) ? Math.max(0, Math.min(1, v)) : 1
|
|
23
|
+
} catch {
|
|
24
|
+
return 1
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** the mime the browser records in: Chrome and Firefox take webm/opus, Safari mp4 */
|
|
29
|
+
const recMime = (): string => ['audio/webm;codecs=opus', 'audio/webm', 'audio/mp4', 'audio/ogg'].find((m) => typeof MediaRecorder !== 'undefined' && MediaRecorder.isTypeSupported(m)) ?? ''
|
|
30
|
+
|
|
31
|
+
interface Mic {
|
|
32
|
+
key: string
|
|
33
|
+
stream: MediaStream
|
|
34
|
+
rec: MediaRecorder
|
|
35
|
+
chunks: Blob[]
|
|
36
|
+
ctx: AudioContext
|
|
37
|
+
meter: AnalyserNode
|
|
38
|
+
raf: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class VoicesSt {
|
|
42
|
+
/** the Voices view shows in place of the player */
|
|
43
|
+
on = false
|
|
44
|
+
desk: VoicesDesk | null = null
|
|
45
|
+
error: string | null = null
|
|
46
|
+
/** each trailer's lines waiting for him */
|
|
47
|
+
counts: Record<string, number> = {}
|
|
48
|
+
openKey: string | null = null
|
|
49
|
+
/** recording: the line, since when, the mic's level 0 to 1 */
|
|
50
|
+
recording: { key: string; since: number; level: number } | null = null
|
|
51
|
+
saving: string | null = null
|
|
52
|
+
/** the audio inputs of this machine, and the one a take records from ('' the system's default), kept by this browser */
|
|
53
|
+
mics: { id: string; label: string }[] = []
|
|
54
|
+
micId = ''
|
|
55
|
+
private mic: Mic | null = null
|
|
56
|
+
|
|
57
|
+
constructor(
|
|
58
|
+
private readonly st: RepoSt,
|
|
59
|
+
private readonly trailerId: () => string | null,
|
|
60
|
+
) {
|
|
61
|
+
try {
|
|
62
|
+
this.micId = localStorage.getItem(MIC_KEY) ?? ''
|
|
63
|
+
} catch {
|
|
64
|
+
// a blocked storage records from the default input
|
|
65
|
+
}
|
|
66
|
+
makeAutoObservable<this, 'st' | 'mic' | 'trailerId'>(this, { st: false, mic: false, trailerId: false })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
show(on: boolean): void {
|
|
70
|
+
this.on = on
|
|
71
|
+
if (on) {
|
|
72
|
+
void this.refresh()
|
|
73
|
+
void this.loadMics()
|
|
74
|
+
} else void this.cancel()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** the inputs as the browser lists them: a name each once the page was given the microphone, else a number */
|
|
78
|
+
async loadMics(): Promise<void> {
|
|
79
|
+
if (typeof navigator.mediaDevices?.enumerateDevices !== 'function') return
|
|
80
|
+
if (!this.micsWatched) {
|
|
81
|
+
this.micsWatched = true
|
|
82
|
+
navigator.mediaDevices.addEventListener('devicechange', () => void this.loadMics())
|
|
83
|
+
}
|
|
84
|
+
const all = await navigator.mediaDevices.enumerateDevices()
|
|
85
|
+
runInAction(() => {
|
|
86
|
+
this.mics = all.filter((d) => d.kind === 'audioinput' && d.deviceId !== 'default' && d.deviceId !== '').map((d, i) => ({ id: d.deviceId, label: d.label || `microphone ${i + 1}` }))
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pickMic(id: string): void {
|
|
91
|
+
this.micId = id
|
|
92
|
+
try {
|
|
93
|
+
localStorage.setItem(MIC_KEY, id)
|
|
94
|
+
} catch {
|
|
95
|
+
// the pick holds for this page only
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private micsWatched = false
|
|
100
|
+
|
|
101
|
+
/** the view on a line, by its key (a tree row); the first waiting one when null */
|
|
102
|
+
open(key: string | null): void {
|
|
103
|
+
this.on = true
|
|
104
|
+
this.openKey = key
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
pick(key: string): void {
|
|
108
|
+
if (this.recording && this.recording.key !== key) void this.cancel()
|
|
109
|
+
this.openKey = key
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async refresh(): Promise<void> {
|
|
113
|
+
try {
|
|
114
|
+
const counts = await this.get<Record<string, number>>('/api/trailer/voices')
|
|
115
|
+
const id = this.trailerId()
|
|
116
|
+
const desk = this.on && id ? await this.get<VoicesDesk>(`/api/trailer/voices/${id}`) : null
|
|
117
|
+
runInAction(() => {
|
|
118
|
+
this.counts = counts
|
|
119
|
+
if (desk) this.desk = desk
|
|
120
|
+
this.error = null
|
|
121
|
+
})
|
|
122
|
+
} catch (e) {
|
|
123
|
+
runInAction(() => (this.error = (e as Error).message))
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get root(): string {
|
|
128
|
+
return this.st.root
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get count(): number {
|
|
132
|
+
return Object.values(this.counts).reduce((a, b) => a + b, 0)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** the trailer on screen's lines, his to record first, then in the order the cuts speak them */
|
|
136
|
+
get lines(): VoiceLine[] {
|
|
137
|
+
const d = this.desk
|
|
138
|
+
if (!d || d.trailer !== this.trailerId()) return []
|
|
139
|
+
return [...d.lines].sort((a, b) => RANK[stateOfLine(a)] - RANK[stateOfLine(b)] || (a.uses[0]?.cut ?? '').localeCompare(b.uses[0]?.cut ?? '') || (a.uses[0]?.at ?? 0) - (b.uses[0]?.at ?? 0))
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get line(): VoiceLine | null {
|
|
143
|
+
const ls = this.lines
|
|
144
|
+
return ls.find((l) => l.key === this.openKey) ?? ls.find((l) => stateOfLine(l) === 'waiting') ?? ls[0] ?? null
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** the use the clip shows: one of his voice first, then the first */
|
|
148
|
+
useOf(l: VoiceLine): VoiceUse | null {
|
|
149
|
+
return l.uses.find((u) => u.mine && u.video) ?? l.uses.find((u) => u.video) ?? l.uses[0] ?? null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** the version of a line the clip plays: the reference or his take, the same on every line */
|
|
153
|
+
hear: 'ref' | 'take' = 'take'
|
|
154
|
+
|
|
155
|
+
setHear(h: 'ref' | 'take'): void {
|
|
156
|
+
this.hear = h
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** the clip's range plays over and over, on every line */
|
|
160
|
+
loop = false
|
|
161
|
+
|
|
162
|
+
setLoop(on: boolean): void {
|
|
163
|
+
this.loop = on
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** the level the clip and a lane alone play at, 0 to 1, and its mute; kept by this browser */
|
|
167
|
+
volume = readVolume()
|
|
168
|
+
muted = false
|
|
169
|
+
|
|
170
|
+
setVolume(v: number): void {
|
|
171
|
+
this.volume = Math.max(0, Math.min(1, v))
|
|
172
|
+
this.muted = false
|
|
173
|
+
try {
|
|
174
|
+
localStorage.setItem(VOLUME_KEY, String(this.volume))
|
|
175
|
+
} catch {
|
|
176
|
+
// the level holds for this page only
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
toggleMute(): void {
|
|
181
|
+
this.muted = !this.muted
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** what a media element's volume is set to */
|
|
185
|
+
get level(): number {
|
|
186
|
+
return this.muted ? 0 : this.volume
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** a line's passage, picture and music and one version of it (none while he records), made by the hub on first
|
|
190
|
+
* ask; a new render, a new take or an edit of it is another url */
|
|
191
|
+
passageUrl(l: VoiceLine, u: VoiceUse, hear: 'ref' | 'take' | 'none'): string | null {
|
|
192
|
+
const id = this.trailerId()
|
|
193
|
+
if (!id || !u.video) return null
|
|
194
|
+
const v = [u.video.mtime, u.standin?.made ?? u.made ?? '', l.take?.made ?? ''].join('-')
|
|
195
|
+
return this.st.url(`/api/trailer/voices/passage/${id}/${l.key}/${u.cut}/${u.line}/${hear}.mp4?v=${v}`)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
madeUrlOf(key: string): string {
|
|
199
|
+
return this.st.url(`/api/trailer/voices/made/${key}.wav`)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
madeUrl(u: VoiceUse): string | null {
|
|
203
|
+
return u.made ? this.madeUrlOf(u.made) : null
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
takeUrl(l: VoiceLine): string | null {
|
|
207
|
+
const id = this.trailerId()
|
|
208
|
+
return l.take && id ? this.st.url(`/api/trailer/voices/${id}/take/${l.key}?v=${Math.round(l.take.mtime)}`) : null
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** the next line after the open one, the list's order */
|
|
212
|
+
next(): void {
|
|
213
|
+
const ls = this.lines
|
|
214
|
+
const i = ls.findIndex((l) => l.key === this.line?.key)
|
|
215
|
+
const n = ls[i + 1]
|
|
216
|
+
if (n) this.pick(n.key)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async record(key: string): Promise<void> {
|
|
220
|
+
if (this.recording) return
|
|
221
|
+
this.openKey = key
|
|
222
|
+
try {
|
|
223
|
+
// a window that gives the page no microphone api says so, with what decides it, instead of a type error
|
|
224
|
+
if (typeof navigator.mediaDevices?.getUserMedia !== 'function')
|
|
225
|
+
throw new Error(`this window gives the page no microphone (${location.origin}, secure context ${String(window.isSecureContext)}): quit and reopen the app with sk gui, or open this page in Chrome`)
|
|
226
|
+
const device = this.micId ? { deviceId: { exact: this.micId } } : {}
|
|
227
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: { ...device, echoCancellation: false, noiseSuppression: true, autoGainControl: false, channelCount: 1 } })
|
|
228
|
+
// the names of the inputs show once the page may use the microphone
|
|
229
|
+
void this.loadMics()
|
|
230
|
+
const mime = recMime()
|
|
231
|
+
const rec = new MediaRecorder(stream, mime ? { mimeType: mime } : {})
|
|
232
|
+
const ctx = new AudioContext()
|
|
233
|
+
const meter = ctx.createAnalyser()
|
|
234
|
+
meter.fftSize = 1024
|
|
235
|
+
ctx.createMediaStreamSource(stream).connect(meter)
|
|
236
|
+
const mic: Mic = { key, stream, rec, chunks: [], ctx, meter, raf: 0 }
|
|
237
|
+
rec.ondataavailable = (e) => void (e.data.size > 0 && mic.chunks.push(e.data))
|
|
238
|
+
rec.start(250)
|
|
239
|
+
this.mic = mic
|
|
240
|
+
runInAction(() => (this.recording = { key, since: Date.now(), level: 0 }))
|
|
241
|
+
const buf = new Float32Array(meter.fftSize)
|
|
242
|
+
const tick = (): void => {
|
|
243
|
+
meter.getFloatTimeDomainData(buf)
|
|
244
|
+
let peak = 0
|
|
245
|
+
for (const x of buf) peak = Math.max(peak, Math.abs(x))
|
|
246
|
+
runInAction(() => {
|
|
247
|
+
if (this.recording) this.recording.level = peak
|
|
248
|
+
})
|
|
249
|
+
mic.raf = requestAnimationFrame(tick)
|
|
250
|
+
}
|
|
251
|
+
tick()
|
|
252
|
+
} catch (e) {
|
|
253
|
+
this.release()
|
|
254
|
+
// the input picked is gone (unplugged): back to the default one, said, and he presses again
|
|
255
|
+
const gone = this.micId !== '' && ['OverconstrainedError', 'NotFoundError'].includes((e as Error).name)
|
|
256
|
+
if (gone) this.pickMic('')
|
|
257
|
+
runInAction(() => (this.error = gone ? 'the microphone picked is not here any more: back to the default input, press Record again' : `the microphone: ${(e as Error).message}`))
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** the take stopped and kept: it replaces the one before */
|
|
262
|
+
async stop(): Promise<void> {
|
|
263
|
+
const mic = this.mic
|
|
264
|
+
if (!mic) return
|
|
265
|
+
const blob = await this.finish(mic)
|
|
266
|
+
const id = this.trailerId()
|
|
267
|
+
if (!id) return
|
|
268
|
+
runInAction(() => (this.saving = mic.key))
|
|
269
|
+
try {
|
|
270
|
+
const type = (blob.type || 'audio/webm').split(';')[0] ?? 'audio/webm'
|
|
271
|
+
await this.call(`/api/trailer/voices/${id}/take/${mic.key}`, 'PUT', { type, body: blob })
|
|
272
|
+
await this.refresh()
|
|
273
|
+
} catch (e) {
|
|
274
|
+
runInAction(() => (this.error = `the take was not kept: ${(e as Error).message}`))
|
|
275
|
+
} finally {
|
|
276
|
+
runInAction(() => (this.saving = null))
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** the recording dropped, nothing kept */
|
|
281
|
+
async cancel(): Promise<void> {
|
|
282
|
+
if (this.mic) await this.finish(this.mic)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** his drag and his mask on a take kept (offset null: back to its first sound); the line is made again before the
|
|
286
|
+
* answer, so the next read draws and plays it */
|
|
287
|
+
async editTake(l: VoiceLine, edit: { offset: number | null; mask: [number, number][] }): Promise<void> {
|
|
288
|
+
const id = this.trailerId()
|
|
289
|
+
if (!id || !l.take) return
|
|
290
|
+
runInAction(() => (this.saving = l.key))
|
|
291
|
+
try {
|
|
292
|
+
await this.call(`/api/trailer/voices/${id}/take/${l.key}/edit`, 'POST', { type: 'application/json', body: JSON.stringify(edit) })
|
|
293
|
+
await this.refresh()
|
|
294
|
+
} catch (e) {
|
|
295
|
+
runInAction(() => (this.error = `the edit was not kept: ${(e as Error).message}`))
|
|
296
|
+
} finally {
|
|
297
|
+
runInAction(() => (this.saving = null))
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async drop(l: VoiceLine): Promise<void> {
|
|
302
|
+
const id = this.trailerId()
|
|
303
|
+
if (!id || !l.take) return
|
|
304
|
+
try {
|
|
305
|
+
await this.call(`/api/trailer/voices/${id}/take/${l.key}`, 'DELETE')
|
|
306
|
+
await this.refresh()
|
|
307
|
+
} catch (e) {
|
|
308
|
+
runInAction(() => (this.error = (e as Error).message))
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** R records the open line or stops it, Esc drops a recording, N goes to the next line; true when used */
|
|
313
|
+
key(e: Pick<KeyboardEvent, 'key'>): boolean {
|
|
314
|
+
const l = this.line
|
|
315
|
+
if (e.key === 'r' || e.key === 'R') {
|
|
316
|
+
if (this.recording) void this.stop()
|
|
317
|
+
else if (l) void this.record(l.key)
|
|
318
|
+
return true
|
|
319
|
+
}
|
|
320
|
+
if (e.key === 'Escape' && this.recording) {
|
|
321
|
+
void this.cancel()
|
|
322
|
+
return true
|
|
323
|
+
}
|
|
324
|
+
if ((e.key === 'n' || e.key === 'N') && !this.recording) {
|
|
325
|
+
this.next()
|
|
326
|
+
return true
|
|
327
|
+
}
|
|
328
|
+
return false
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private finish(mic: Mic): Promise<Blob> {
|
|
332
|
+
return new Promise((done) => {
|
|
333
|
+
mic.rec.onstop = () => {
|
|
334
|
+
this.release()
|
|
335
|
+
done(new Blob(mic.chunks, { type: mic.rec.mimeType }))
|
|
336
|
+
}
|
|
337
|
+
if (mic.rec.state === 'inactive') mic.rec.onstop(new Event('stop'))
|
|
338
|
+
else mic.rec.stop()
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private release(): void {
|
|
343
|
+
const mic = this.mic
|
|
344
|
+
this.mic = null
|
|
345
|
+
if (mic) {
|
|
346
|
+
cancelAnimationFrame(mic.raf)
|
|
347
|
+
for (const t of mic.stream.getTracks()) t.stop()
|
|
348
|
+
void mic.ctx.close()
|
|
349
|
+
}
|
|
350
|
+
runInAction(() => (this.recording = null))
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private get<T>(path: string): Promise<T> {
|
|
354
|
+
return this.call<T>(path, 'GET')
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** one call of the hub, its error said in the hub's words */
|
|
358
|
+
private async call<T>(path: string, method: 'GET' | 'PUT' | 'POST' | 'DELETE', body?: { type: string; body: Blob | string }): Promise<T> {
|
|
359
|
+
const r = await reach(this.st.url(path), { method, ...(body ? { headers: { 'content-type': body.type }, body: body.body } : {}) })
|
|
360
|
+
const text = await r.text()
|
|
361
|
+
let json: unknown = null
|
|
362
|
+
try {
|
|
363
|
+
json = JSON.parse(text)
|
|
364
|
+
} catch {
|
|
365
|
+
// a plain text answer says it already
|
|
366
|
+
}
|
|
367
|
+
if (!r.ok) throw new Error((json as { error?: string } | null)?.error ?? (text || `HTTP ${r.status}`))
|
|
368
|
+
return json as T
|
|
369
|
+
}
|
|
370
|
+
}
|