@vibefield/rosetta-room 0.1.5 → 0.1.7
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/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/HistoryRoom.js +21 -5
- package/dist/components/ColdStart.d.ts +15 -0
- package/dist/components/ColdStart.js +27 -0
- package/dist/components/IngestStatus.js +43 -6
- package/dist/components/Transcript.js +8 -2
- package/dist/components/transcript/Attachments.d.ts +2 -0
- package/dist/components/transcript/Attachments.js +35 -10
- package/dist/components/transcript/AuthoredMessage.js +2 -1
- package/dist/components/transcript/DayPill.d.ts +8 -4
- package/dist/components/transcript/DayPill.js +13 -12
- package/dist/components/transcript/Document.js +8 -2
- package/dist/components/transcript/PromptJump.d.ts +14 -0
- package/dist/components/transcript/PromptJump.js +116 -0
- package/dist/components/transcript/TranscriptLoading.js +9 -0
- package/dist/components/transcript/VideoTile.d.ts +28 -0
- package/dist/components/transcript/VideoTile.js +99 -0
- package/dist/components/transcript/attachment-file-source.d.ts +9 -1
- package/dist/components/transcript/attachment-file-source.js +9 -1
- package/dist/components/transcript/document-model.js +6 -4
- package/dist/components/transcript/video-source.d.ts +39 -0
- package/dist/components/transcript/video-source.js +110 -0
- package/dist/components/transcript/viewer-day.d.ts +7 -0
- package/dist/components/transcript/viewer-day.js +44 -0
- package/dist/components/ui/Hold.d.ts +25 -0
- package/dist/components/ui/Hold.js +44 -0
- package/dist/components/ui/Meter.d.ts +1 -1
- package/dist/components/ui/Meter.js +10 -0
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/fixtures/index.d.ts +2 -1
- package/dist/fixtures/index.js +53 -4
- package/dist/host-inputs.d.ts +25 -0
- package/dist/host-inputs.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/lib/image-media.d.ts +5 -0
- package/dist/lib/image-media.js +17 -0
- package/dist/lib/ingest-activity.d.ts +6 -0
- package/dist/lib/ingest-activity.js +6 -0
- package/dist/lib/transcript/images.d.ts +6 -2
- package/dist/lib/transcript/images.js +10 -4
- package/dist/lib/transcript/index.d.ts +3 -1
- package/dist/lib/transcript/index.js +2 -1
- package/dist/lib/transcript/prompt-jump.d.ts +30 -0
- package/dist/lib/transcript/prompt-jump.js +65 -0
- package/dist/lib/transcript/sittings.d.ts +26 -0
- package/dist/lib/transcript/sittings.js +46 -1
- package/dist/lib/use-standing-hold.d.ts +17 -0
- package/dist/lib/use-standing-hold.js +70 -0
- package/dist/ports.d.ts +15 -1
- package/dist/styles/attachments.css +13 -0
- package/dist/styles/hold.css +47 -0
- package/dist/styles/ingest.css +14 -0
- package/dist/styles/room.css +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// A button at the side goes to the message before: a round glass button,
|
|
3
|
+
// level with the Latest pill and 16 px in from the transcript column's edge,
|
|
4
|
+
// holding a chevron up and no word; its name and tooltip are
|
|
5
|
+
// `Previous message`.
|
|
6
|
+
//
|
|
7
|
+
// A press goes to the nearest message of the person's own that begins above
|
|
8
|
+
// the top of the view and stands its top 12 under the head; pressed again, the
|
|
9
|
+
// one before. More than a screen away it goes at once, nearer on the 300 ms
|
|
10
|
+
// ease, never animated under Reduce Motion; the document stops following, as
|
|
11
|
+
// it does for any move up the page. Nothing else marks the message: its place
|
|
12
|
+
// at the top of the view is the mark. The button is there only while such a
|
|
13
|
+
// message begins above, or rows above are not yet read, and it fades over
|
|
14
|
+
// 200 ms; hidden, it takes no press. The decisions are `lib/transcript/
|
|
15
|
+
// prompt-jump.ts`; this reads the layout and moves the scroller.
|
|
16
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
17
|
+
import { prefersReducedMotion } from "../../lib/motion.js";
|
|
18
|
+
import { PROMPT_JUMP_EASE_MS, jumpMotion, previousMessageTarget, promptJumpPlan, promptJumpShown, settleEase, } from "../../lib/transcript/index.js";
|
|
19
|
+
/** The person's own messages: the prompt panel alone (a setting command wears a pill, a machine prompt an activity
|
|
20
|
+
* row), and never one inside a worker's thread nested in the document. */
|
|
21
|
+
const OWN_MESSAGE = ".tr-prompt-message";
|
|
22
|
+
const NESTED = ".tr-sub";
|
|
23
|
+
/** Any of these from the reader ends a jump in flight: the reader has the page again. */
|
|
24
|
+
const READER_INPUT = ["wheel", "pointerdown", "touchstart", "keydown"];
|
|
25
|
+
/**
|
|
26
|
+
* The own messages' tops and the view's top, from the top of the scroller's frame. The head is the edge content
|
|
27
|
+
* scrolls under: in a document that draws day pills, the band a pinned pill holds (its inset and its height), so a
|
|
28
|
+
* landed message is never under the pill.
|
|
29
|
+
*/
|
|
30
|
+
function readView(scroller) {
|
|
31
|
+
const frame = scroller.getBoundingClientRect();
|
|
32
|
+
const day = scroller.querySelector(".tr-day");
|
|
33
|
+
const pill = day?.querySelector(".tr-day__pill") ?? null;
|
|
34
|
+
const viewTop = day === null || pill === null
|
|
35
|
+
? 0
|
|
36
|
+
: (Number.parseFloat(getComputedStyle(day).top) || 0) + pill.getBoundingClientRect().height;
|
|
37
|
+
const tops = Array.from(scroller.querySelectorAll(OWN_MESSAGE))
|
|
38
|
+
.filter((element) => element.closest(NESTED) === null && element.getClientRects().length > 0)
|
|
39
|
+
.map((element) => element.getBoundingClientRect().top - frame.top);
|
|
40
|
+
return { tops, viewTop };
|
|
41
|
+
}
|
|
42
|
+
export function PromptJump({ scrollRef, earlier, layoutKey, onLeaveTail, hidden }) {
|
|
43
|
+
const [above, setAbove] = useState(false);
|
|
44
|
+
const inFlight = useRef(null);
|
|
45
|
+
// What is above, read once a frame on scroll, on a resize, and when the document changes.
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const scroller = scrollRef.current;
|
|
48
|
+
if (scroller === null)
|
|
49
|
+
return;
|
|
50
|
+
let frame = null;
|
|
51
|
+
const measure = () => {
|
|
52
|
+
frame = null;
|
|
53
|
+
const view = readView(scroller);
|
|
54
|
+
setAbove(previousMessageTarget(view.tops, view.viewTop) !== null);
|
|
55
|
+
};
|
|
56
|
+
const schedule = () => {
|
|
57
|
+
if (frame === null)
|
|
58
|
+
frame = requestAnimationFrame(measure);
|
|
59
|
+
};
|
|
60
|
+
measure();
|
|
61
|
+
scroller.addEventListener("scroll", schedule, { passive: true });
|
|
62
|
+
const observer = new ResizeObserver(schedule);
|
|
63
|
+
observer.observe(scroller);
|
|
64
|
+
const content = scroller.querySelector(".tr-col");
|
|
65
|
+
if (content !== null)
|
|
66
|
+
observer.observe(content);
|
|
67
|
+
return () => {
|
|
68
|
+
if (frame !== null)
|
|
69
|
+
cancelAnimationFrame(frame);
|
|
70
|
+
scroller.removeEventListener("scroll", schedule);
|
|
71
|
+
observer.disconnect();
|
|
72
|
+
};
|
|
73
|
+
}, [scrollRef, layoutKey]);
|
|
74
|
+
useEffect(() => () => inFlight.current?.(), []);
|
|
75
|
+
const press = useCallback(() => {
|
|
76
|
+
const scroller = scrollRef.current;
|
|
77
|
+
if (scroller === null)
|
|
78
|
+
return;
|
|
79
|
+
inFlight.current?.();
|
|
80
|
+
const view = readView(scroller);
|
|
81
|
+
const plan = promptJumpPlan({ ...view, scrollTop: scroller.scrollTop, earlier });
|
|
82
|
+
// Keyboard navigation stays on the reading surface, as after the Latest pill.
|
|
83
|
+
scroller.focus({ preventScroll: true });
|
|
84
|
+
if (plan === null)
|
|
85
|
+
return;
|
|
86
|
+
onLeaveTail();
|
|
87
|
+
const from = scroller.scrollTop;
|
|
88
|
+
const distance = plan.scrollTop - from;
|
|
89
|
+
if (jumpMotion(distance, scroller.clientHeight, prefersReducedMotion()) === "instant") {
|
|
90
|
+
scroller.scrollTop = plan.scrollTop;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const start = performance.now();
|
|
94
|
+
let frame = 0;
|
|
95
|
+
const stop = () => {
|
|
96
|
+
cancelAnimationFrame(frame);
|
|
97
|
+
for (const type of READER_INPUT)
|
|
98
|
+
scroller.removeEventListener(type, stop);
|
|
99
|
+
inFlight.current = null;
|
|
100
|
+
};
|
|
101
|
+
const tick = (time) => {
|
|
102
|
+
const progress = Math.min(1, Math.max(0, (time - start) / PROMPT_JUMP_EASE_MS));
|
|
103
|
+
scroller.scrollTop = from + distance * settleEase(progress);
|
|
104
|
+
if (progress < 1)
|
|
105
|
+
frame = requestAnimationFrame(tick);
|
|
106
|
+
else
|
|
107
|
+
stop();
|
|
108
|
+
};
|
|
109
|
+
for (const type of READER_INPUT)
|
|
110
|
+
scroller.addEventListener(type, stop, { passive: true });
|
|
111
|
+
inFlight.current = stop;
|
|
112
|
+
frame = requestAnimationFrame(tick);
|
|
113
|
+
}, [scrollRef, earlier, onLeaveTail]);
|
|
114
|
+
const shown = !hidden && promptJumpShown(above, earlier);
|
|
115
|
+
return (_jsx("button", { type: "button", className: "tr-prompt-jump", "data-visible": shown || undefined, inert: !shown, "aria-hidden": !shown || undefined, "aria-label": "Previous message", title: "Previous message", onClick: press, children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 10.25 8 5.75l4.5 4.5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }) }));
|
|
116
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useHostInputs } from "../../host-inputs.js";
|
|
3
|
+
import { Hold } from "../ui/Hold.js";
|
|
2
4
|
import "../../styles/transcript-loading.css";
|
|
3
5
|
/** Which wait the loader shows: its words, keyed by the inert
|
|
4
6
|
* `data-loading-label` the DOM contract reads instead of the copy. */
|
|
@@ -15,6 +17,13 @@ export function TranscriptLoading({ error, waitingForTeam, seeking, canContinue,
|
|
|
15
17
|
: seeking ? "seeking"
|
|
16
18
|
: indexing ? "preparing" : "loading";
|
|
17
19
|
const label = LOADING_LABELS[shown];
|
|
20
|
+
const { waitMark } = useHostInputs();
|
|
21
|
+
// R10 — in the host's mark, a conversation's wait is a hold in its column:
|
|
22
|
+
// the mark and its words, no sketch and no sweep. A load that failed is no
|
|
23
|
+
// wait, so it keeps the loader's own face with Try again.
|
|
24
|
+
if (waitMark !== undefined && error === null) {
|
|
25
|
+
return _jsx("div", { className: "tr-loading", "data-loading-label": shown, "data-marked": "", children: _jsx(Hold, { place: "column", face: "transcript-loading", words: { key: shown, line: label }, act: canContinue ? _jsx("button", { type: "button", onClick: onContinue, children: "Read available messages" }) : null }) });
|
|
26
|
+
}
|
|
18
27
|
return _jsx("div", { className: "tr-loading", "data-error": error !== null || undefined, "data-loading-label": shown, children: _jsxs("div", { className: "tr-loading__body", children: [_jsxs("div", { className: "tr-loading__sketch", "aria-hidden": "true", children: [_jsxs("div", { className: "tr-loading__prompt", children: [_jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { className: "tr-loading__reply", children: [_jsxs("div", { className: "tr-loading__byline", children: [_jsx("b", {}), _jsx("i", {})] }), _jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), _jsxs("div", { className: "tr-loading__fold", children: [_jsx("b", { children: "\u203A" }), _jsx("i", {})] })] }), _jsxs("div", { className: "tr-loading__status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: [error === null && _jsx("div", { className: "tr-loading__meter", "aria-hidden": "true", children: _jsx("i", {}) }), _jsx("strong", { children: label }), error !== null && _jsx("p", { children: error })] }), error !== null ? _jsx("button", { type: "button", onClick: onRetry, children: "Try again" })
|
|
19
28
|
: canContinue && _jsx("button", { type: "button", onClick: onContinue, children: "Read available messages" })] }) });
|
|
20
29
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AttachmentFact } from "../../lib/transcript/index.js";
|
|
2
|
+
import type { VideoState } from "./video-source.js";
|
|
3
|
+
/** Width over height for the tile at the rail's height: the video's own
|
|
4
|
+
* shape, 16:9 when it was not measured. Never narrower than the square image
|
|
5
|
+
* tile beside it, nor wider than 21:9; the video letterboxes inside. */
|
|
6
|
+
export declare function videoAspect(width: number | null, height: number | null): number;
|
|
7
|
+
/** Why a video cannot be played here. */
|
|
8
|
+
export declare function videoStatus(fact: AttachmentFact): string;
|
|
9
|
+
export interface VideoFaceProps {
|
|
10
|
+
readonly fact: AttachmentFact;
|
|
11
|
+
/** The video's place among the rail's videos, for an unlabelled one's name. */
|
|
12
|
+
readonly index: number;
|
|
13
|
+
/** False: sent but not captured, or a member this host does not offer. */
|
|
14
|
+
readonly playable: boolean;
|
|
15
|
+
readonly state: VideoState;
|
|
16
|
+
readonly onPlay?: (() => void) | undefined;
|
|
17
|
+
readonly onElementError?: ((url: string) => void) | undefined;
|
|
18
|
+
/** The face's one focus target: the play button, the video, or Retry. */
|
|
19
|
+
readonly focusRef?: ((element: HTMLElement | null) => void) | undefined;
|
|
20
|
+
readonly figureRef?: ((element: HTMLElement | null) => void) | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** One state of the tile, drawn from its props alone. */
|
|
23
|
+
export declare function VideoFace({ fact, index, playable, state, onPlay, onElementError, focusRef, figureRef }: VideoFaceProps): import("react").JSX.Element;
|
|
24
|
+
/** The tile over its load: nothing is asked until the reader presses play. */
|
|
25
|
+
export declare function VideoTile({ fact, index }: {
|
|
26
|
+
readonly fact: AttachmentFact;
|
|
27
|
+
readonly index: number;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A video an agent sent, in the attachment rail. Before the reader asks, it is
|
|
3
|
+
// a tile with a play glyph, the file's name and its size: no poster, no
|
|
4
|
+
// thumbnail, no request. A press plays it in place. A video that was sent but
|
|
5
|
+
// not captured keeps the same tile shape and says so; it is not a button.
|
|
6
|
+
// A video never opens the image viewer and never asks an image rendition.
|
|
7
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
8
|
+
import { fmtBytes } from "../../lib/format.js";
|
|
9
|
+
import { useAttachmentReader } from "./attachment-file-source.js";
|
|
10
|
+
import { IDLE_VIDEO, createVideoSource } from "./video-source.js";
|
|
11
|
+
const WIDEST = 21 / 9;
|
|
12
|
+
/** Width over height for the tile at the rail's height: the video's own
|
|
13
|
+
* shape, 16:9 when it was not measured. Never narrower than the square image
|
|
14
|
+
* tile beside it, nor wider than 21:9; the video letterboxes inside. */
|
|
15
|
+
export function videoAspect(width, height) {
|
|
16
|
+
if (width === null || height === null || !(width > 0) || !(height > 0))
|
|
17
|
+
return 16 / 9;
|
|
18
|
+
return Math.min(WIDEST, Math.max(1, width / height));
|
|
19
|
+
}
|
|
20
|
+
/** Why a video cannot be played here. */
|
|
21
|
+
export function videoStatus(fact) {
|
|
22
|
+
const source = fact.ref?.source;
|
|
23
|
+
if (source?.type === "reference")
|
|
24
|
+
return "Video not captured";
|
|
25
|
+
// Recorded, but not a member this room can address: the host offers no
|
|
26
|
+
// address for it, or it is not an MP4 or QuickTime member under its digest.
|
|
27
|
+
if (source?.type === "asset")
|
|
28
|
+
return "Video is not available here";
|
|
29
|
+
if (source?.type === "unavailable") {
|
|
30
|
+
switch (source.reason) {
|
|
31
|
+
case "omitted": return "Video omitted from the recording";
|
|
32
|
+
case "invalid_data": return "Recorded video data is invalid";
|
|
33
|
+
case "unsupported_media": return "Video format is not supported";
|
|
34
|
+
case "not_recorded": return "Video data was not recorded";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return "Video data was not recorded";
|
|
38
|
+
}
|
|
39
|
+
function PlayGlyph() {
|
|
40
|
+
return _jsxs("svg", { width: "28", height: "28", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "14", cy: "14", r: "12.5", stroke: "currentColor", strokeWidth: "1.3" }), _jsx("path", { d: "M11.5 9.2v9.6l8-4.8z", fill: "currentColor" })] });
|
|
41
|
+
}
|
|
42
|
+
function FilmGlyph() {
|
|
43
|
+
return _jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.3", "aria-hidden": "true", children: [_jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "3" }), _jsx("path", { d: "m10 9.5 4.5 2.5-4.5 2.5z" })] });
|
|
44
|
+
}
|
|
45
|
+
/** One state of the tile, drawn from its props alone. */
|
|
46
|
+
export function VideoFace({ fact, index, playable, state, onPlay, onElementError, focusRef, figureRef }) {
|
|
47
|
+
const label = fact.ref?.label ?? `Video ${index + 1}`;
|
|
48
|
+
const name = fact.name?.trim() || label;
|
|
49
|
+
const size = fact.byteLen === null ? null : fmtBytes(fact.byteLen);
|
|
50
|
+
const facts = [name, size].filter(Boolean).join(" · ");
|
|
51
|
+
const details = [label, fact.name, fact.caption, size].filter(Boolean).join(" · ");
|
|
52
|
+
const style = { "--tr-video-aspect": videoAspect(fact.width, fact.height).toFixed(4) };
|
|
53
|
+
const playing = playable && state.phase === "ready";
|
|
54
|
+
return _jsx("figure", { ref: figureRef, className: "tr-att__video", "data-attachment-id": fact.key, "data-video": playable ? state.phase : "uncaptured", title: playing ? undefined : details, style: style, children: !playable ? (_jsxs("div", { className: "tr-att__tile tr-att__tile--video tr-att__tile--missing", tabIndex: -1, "aria-label": `${videoStatus(fact)} — ${details}`, children: [_jsx(FilmGlyph, {}), _jsx("span", { children: videoStatus(fact) }), _jsx("span", { className: "tr-att__facts", children: facts })] })) : state.phase === "failed" ? (_jsxs("div", { className: "tr-att__tile tr-att__tile--video tr-att__tile--missing", tabIndex: -1, "aria-label": `Could not play video — ${details}`, children: [_jsx(FilmGlyph, {}), _jsx("span", { children: "Could not play video" }), _jsx("button", { type: "button", ref: focusRef, className: "tr-att__retry", "aria-label": `Retry video — ${name}`, onClick: onPlay, children: "Retry" })] })) : state.phase === "ready" ? (_jsx("div", { className: "tr-att__tile tr-att__tile--video tr-att__tile--playing", tabIndex: -1, children: _jsx("video", { ref: focusRef, src: state.url, controls: true, autoPlay: true, playsInline: true, preload: "auto", "aria-label": name, onError: () => onElementError?.(state.url) }, state.url) })) : (_jsxs("button", { type: "button", ref: focusRef, "aria-busy": state.phase === "loading", className: state.phase === "loading" ? "tr-att__tile tr-att__tile--video tr-att__tile--loading" : "tr-att__tile tr-att__tile--video", "aria-label": state.phase === "loading" ? `Loading video — ${name}` : `Play video — ${facts}`, onClick: onPlay, children: [_jsx(PlayGlyph, {}), _jsx("span", { className: "tr-att__name", children: name }), _jsx("span", { className: "tr-att__facts", children: state.phase === "loading" ? "Loading video…" : size ?? "Video" })] })) });
|
|
55
|
+
}
|
|
56
|
+
/** The tile over its load: nothing is asked until the reader presses play. */
|
|
57
|
+
export function VideoTile({ fact, index }) {
|
|
58
|
+
const attachments = useAttachmentReader();
|
|
59
|
+
const asset = attachments.videoAsset(fact);
|
|
60
|
+
const digest = asset?.digest ?? null;
|
|
61
|
+
const [state, setState] = useState(IDLE_VIDEO);
|
|
62
|
+
const source = useRef(null);
|
|
63
|
+
const figure = useRef(null);
|
|
64
|
+
const target = useRef(null);
|
|
65
|
+
const restoreFocus = useRef(false);
|
|
66
|
+
// Leaving the rail, or the member or its reader changing, ends the load:
|
|
67
|
+
// the read is aborted and an object URL made for it is revoked.
|
|
68
|
+
useEffect(() => () => {
|
|
69
|
+
source.current?.dispose();
|
|
70
|
+
source.current = null;
|
|
71
|
+
setState(IDLE_VIDEO);
|
|
72
|
+
}, [digest, attachments]);
|
|
73
|
+
// A press swaps the button for the video (or for Retry). Keep the reader's
|
|
74
|
+
// focus on the tile through each swap, unless they have moved elsewhere.
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
if (!restoreFocus.current)
|
|
77
|
+
return;
|
|
78
|
+
const active = document.activeElement;
|
|
79
|
+
if (active !== null && active !== document.body && !figure.current?.contains(active)) {
|
|
80
|
+
restoreFocus.current = false;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
target.current?.focus({ preventScroll: true });
|
|
84
|
+
}, [state]);
|
|
85
|
+
const play = () => {
|
|
86
|
+
if (asset === null)
|
|
87
|
+
return;
|
|
88
|
+
restoreFocus.current = true;
|
|
89
|
+
source.current ??= createVideoSource(asset, {
|
|
90
|
+
mediaAssetUrl: attachments.mediaAssetUrl,
|
|
91
|
+
readAsset: attachments.readAsset,
|
|
92
|
+
createObjectURL: (bytes, mediaType) => URL.createObjectURL(new Blob([bytes], { type: mediaType })),
|
|
93
|
+
revokeObjectURL: (url) => URL.revokeObjectURL(url),
|
|
94
|
+
onChange: setState,
|
|
95
|
+
});
|
|
96
|
+
source.current.play();
|
|
97
|
+
};
|
|
98
|
+
return _jsx(VideoFace, { fact: fact, index: index, playable: asset !== null, state: state, onPlay: play, onElementError: (url) => source.current?.elementFailed(url), focusRef: (element) => { target.current = element; }, figureRef: (element) => { figure.current = element; } });
|
|
99
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AssetRef } from "@vibefield/rosetta-protocol";
|
|
2
2
|
import type { AttachmentFact } from "../../lib/transcript/index.js";
|
|
3
|
-
import type { AssetSource } from "../../ports.js";
|
|
3
|
+
import type { AssetSource, AssetUrl } from "../../ports.js";
|
|
4
4
|
import type { FileHandle, FileSource } from "../file-viewer/index.js";
|
|
5
5
|
import type { ImageResource } from "../file-viewer/types.js";
|
|
6
6
|
/** Reads one stored member's bytes. */
|
|
@@ -9,8 +9,16 @@ export interface AttachmentReader {
|
|
|
9
9
|
/** The address of bytes the daemon kept, never a provider-authored path. */
|
|
10
10
|
assetUrl(fact: AttachmentFact): string | null;
|
|
11
11
|
imageResource(fact: AttachmentFact): ImageResource | null;
|
|
12
|
+
/** The recorded member of a sent video the room may play, or null: not a
|
|
13
|
+
* video, not captured, or a member the host does not offer. Never an image
|
|
14
|
+
* resource: a video asks no rendition. */
|
|
15
|
+
videoAsset(fact: AttachmentFact): AssetRef | null;
|
|
16
|
+
/** The host's address for a `<video src>`, asked only on play; undefined on
|
|
17
|
+
* a host that offers none (the bytes are read instead). */
|
|
18
|
+
readonly mediaAssetUrl: ((asset: AssetRef) => AssetUrl) | undefined;
|
|
12
19
|
/** A stored transcript asset as the generic file viewer understands it. */
|
|
13
20
|
handleFor(fact: AttachmentFact): FileHandle | null;
|
|
21
|
+
/** Images only: the viewer and its gallery never take a video. */
|
|
14
22
|
canOpen(fact: AttachmentFact): boolean;
|
|
15
23
|
/** Stable by construction: `useFileContent` treats source identity as a read. */
|
|
16
24
|
readonly fileSource: FileSource;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { useMemo } from "react";
|
|
10
10
|
import { useReadingSession, useRoom } from "../../room-context.js";
|
|
11
11
|
import { resolveKind } from "../file-viewer/index.js";
|
|
12
|
-
import { isRecordedImageAsset } from "../../lib/image-media.js";
|
|
12
|
+
import { isRecordedImageAsset, isRecordedVideoAsset } from "../../lib/image-media.js";
|
|
13
13
|
const EXTENSION_BY_MEDIA_TYPE = new Map([
|
|
14
14
|
["image/png", "png"],
|
|
15
15
|
["image/jpeg", "jpg"],
|
|
@@ -45,6 +45,8 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
45
45
|
return null;
|
|
46
46
|
if (fact.kind === "image" && !isRecordedImageAsset(source.asset))
|
|
47
47
|
return null;
|
|
48
|
+
if (fact.kind === "video" && !isRecordedVideoAsset(source.asset))
|
|
49
|
+
return null;
|
|
48
50
|
return assets.attachmentAssetUrl(source.asset);
|
|
49
51
|
}
|
|
50
52
|
function imageResource(fact) {
|
|
@@ -54,6 +56,10 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
54
56
|
return null;
|
|
55
57
|
return imageOf(assets, asset, fact.ref?.dimensions?.width, fact.ref?.dimensions?.height);
|
|
56
58
|
}
|
|
59
|
+
function videoAsset(fact) {
|
|
60
|
+
const source = fact.ref?.source;
|
|
61
|
+
return fact.kind === "video" && source?.type === "asset" && assetUrl(fact) !== null ? source.asset : null;
|
|
62
|
+
}
|
|
57
63
|
function handleFor(fact) {
|
|
58
64
|
const source = fact.ref?.source;
|
|
59
65
|
const url = assetUrl(fact);
|
|
@@ -84,6 +90,8 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
84
90
|
return {
|
|
85
91
|
assetUrl,
|
|
86
92
|
imageResource,
|
|
93
|
+
videoAsset,
|
|
94
|
+
mediaAssetUrl: assets.mediaAssetUrl === undefined ? undefined : (asset) => assets.mediaAssetUrl?.(asset) ?? null,
|
|
87
95
|
handleFor,
|
|
88
96
|
canOpen: (fact) => fact.kind === "image" && handleFor(fact) !== null,
|
|
89
97
|
fileSource,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// so a jump is a real absence — D33's data gap, stated rather than
|
|
15
15
|
// silently closed over.
|
|
16
16
|
import { useMemo } from "react";
|
|
17
|
-
import { dayList, documentTurns, sittings } from "../../lib/transcript/index.js";
|
|
17
|
+
import { calendarDayKey, dayList, documentTurns, sittings } from "../../lib/transcript/index.js";
|
|
18
18
|
import { documentPlan } from "./document-plan.js";
|
|
19
19
|
function buildRepresentatives(turns) {
|
|
20
20
|
const map = new Map();
|
|
@@ -91,14 +91,16 @@ export function useTranscriptModel(rows, session, homeDirectory, now, options =
|
|
|
91
91
|
const cwd = session?.cwd ?? null;
|
|
92
92
|
const sharedKey = [...(options.sharedCollaborationSessionIds ?? [])].sort().join("\u0000");
|
|
93
93
|
const cutKey = [...(options.cutBefore ?? [])].sort().join("\u0000");
|
|
94
|
+
const day = calendarDayKey(now);
|
|
94
95
|
return useMemo(() => {
|
|
95
96
|
const sharedCollaborationSessionIds = new Set(sharedKey === "" ? [] : sharedKey.split("\u0000"));
|
|
96
97
|
return transcriptModel(rows, session, homeDirectory, now, {
|
|
97
98
|
...options,
|
|
98
99
|
sharedCollaborationSessionIds,
|
|
99
100
|
});
|
|
100
|
-
// `now` only names the day a stamp falls in
|
|
101
|
-
// document
|
|
101
|
+
// `now` only names the day a stamp falls in, so the memo keys on that day:
|
|
102
|
+
// the document is re-derived when the viewer's day turns (a pill's words
|
|
103
|
+
// are the drawing's) and never on a clock tick.
|
|
102
104
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
-
}, [rows, cwd, homeDirectory, sharedKey, cutKey]);
|
|
105
|
+
}, [rows, cwd, homeDirectory, sharedKey, cutKey, day]);
|
|
104
106
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AssetRef } from "@vibefield/rosetta-protocol";
|
|
2
|
+
import type { AssetUrl } from "../../ports.js";
|
|
3
|
+
export type VideoState = {
|
|
4
|
+
readonly phase: "idle";
|
|
5
|
+
} | {
|
|
6
|
+
readonly phase: "loading";
|
|
7
|
+
}
|
|
8
|
+
/** `from` says whose address plays: the host's, or the bytes read here. */
|
|
9
|
+
| {
|
|
10
|
+
readonly phase: "ready";
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly from: "host" | "bytes";
|
|
13
|
+
} | {
|
|
14
|
+
readonly phase: "failed";
|
|
15
|
+
};
|
|
16
|
+
export declare const IDLE_VIDEO: VideoState;
|
|
17
|
+
export interface VideoSourceDoors {
|
|
18
|
+
/** The host's address for a `<video src>`; absent on a host that offers none. */
|
|
19
|
+
readonly mediaAssetUrl?: ((asset: AssetRef) => AssetUrl) | undefined;
|
|
20
|
+
/** The member's bytes, through the reading session's client. */
|
|
21
|
+
readonly readAsset: (asset: AssetRef, signal: AbortSignal) => Promise<Uint8Array>;
|
|
22
|
+
readonly createObjectURL: (bytes: Uint8Array, mediaType: string) => string;
|
|
23
|
+
readonly revokeObjectURL: (url: string) => void;
|
|
24
|
+
/** Every state after the first, in order. Never called after `dispose`. */
|
|
25
|
+
readonly onChange?: ((state: VideoState) => void) | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface VideoSource {
|
|
28
|
+
state(): VideoState;
|
|
29
|
+
/** The reader asked to play, or to try again after a failure. A press while
|
|
30
|
+
* loading or ready is nothing. */
|
|
31
|
+
play(): void;
|
|
32
|
+
/** The element could not load or decode `url`. The host's address falls
|
|
33
|
+
* back to the bytes; the bytes' own failure is the failed face. A report
|
|
34
|
+
* about an address that is no longer the current one is nothing. */
|
|
35
|
+
elementFailed(url: string): void;
|
|
36
|
+
/** Abort a read in flight and revoke any object URL made here. */
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createVideoSource(asset: AssetRef, doors: VideoSourceDoors): VideoSource;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export const IDLE_VIDEO = { phase: "idle" };
|
|
2
|
+
export function createVideoSource(asset, doors) {
|
|
3
|
+
let state = IDLE_VIDEO;
|
|
4
|
+
let disposed = false;
|
|
5
|
+
// Each press is its own run: an answer that arrives for an older run, or
|
|
6
|
+
// after disposal, is dropped.
|
|
7
|
+
let run = 0;
|
|
8
|
+
let reading = null;
|
|
9
|
+
let objectUrl = null;
|
|
10
|
+
const set = (next) => {
|
|
11
|
+
state = next;
|
|
12
|
+
doors.onChange?.(next);
|
|
13
|
+
};
|
|
14
|
+
const current = (id) => !disposed && id === run;
|
|
15
|
+
const release = () => {
|
|
16
|
+
if (objectUrl === null)
|
|
17
|
+
return;
|
|
18
|
+
const url = objectUrl;
|
|
19
|
+
objectUrl = null;
|
|
20
|
+
doors.revokeObjectURL(url);
|
|
21
|
+
};
|
|
22
|
+
function readBytes(id) {
|
|
23
|
+
const controller = new AbortController();
|
|
24
|
+
reading = controller;
|
|
25
|
+
if (state.phase !== "loading")
|
|
26
|
+
set({ phase: "loading" });
|
|
27
|
+
const settle = () => {
|
|
28
|
+
if (reading === controller)
|
|
29
|
+
reading = null;
|
|
30
|
+
return current(id);
|
|
31
|
+
};
|
|
32
|
+
let read;
|
|
33
|
+
try {
|
|
34
|
+
read = Promise.resolve(doors.readAsset(asset, controller.signal));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
read = Promise.reject(error);
|
|
38
|
+
}
|
|
39
|
+
read.then((bytes) => {
|
|
40
|
+
if (!settle())
|
|
41
|
+
return;
|
|
42
|
+
try {
|
|
43
|
+
objectUrl = doors.createObjectURL(bytes, asset.media_type);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
set({ phase: "failed" });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
set({ phase: "ready", url: objectUrl, from: "bytes" });
|
|
50
|
+
}, () => {
|
|
51
|
+
if (settle())
|
|
52
|
+
set({ phase: "failed" });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
state: () => state,
|
|
57
|
+
play() {
|
|
58
|
+
if (disposed || state.phase === "loading" || state.phase === "ready")
|
|
59
|
+
return;
|
|
60
|
+
const id = (run += 1);
|
|
61
|
+
release();
|
|
62
|
+
let answer = null;
|
|
63
|
+
try {
|
|
64
|
+
if (doors.mediaAssetUrl !== undefined)
|
|
65
|
+
answer = doors.mediaAssetUrl(asset);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
answer = null;
|
|
69
|
+
}
|
|
70
|
+
if (typeof answer === "string" && answer !== "") {
|
|
71
|
+
set({ phase: "ready", url: answer, from: "host" });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (answer === null || typeof answer === "string") {
|
|
75
|
+
readBytes(id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
set({ phase: "loading" });
|
|
79
|
+
Promise.resolve(answer).then((url) => {
|
|
80
|
+
if (!current(id))
|
|
81
|
+
return;
|
|
82
|
+
if (typeof url === "string" && url !== "")
|
|
83
|
+
set({ phase: "ready", url, from: "host" });
|
|
84
|
+
else
|
|
85
|
+
readBytes(id);
|
|
86
|
+
}, () => {
|
|
87
|
+
if (current(id))
|
|
88
|
+
readBytes(id);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
elementFailed(url) {
|
|
92
|
+
if (disposed || state.phase !== "ready" || state.url !== url)
|
|
93
|
+
return;
|
|
94
|
+
if (state.from === "host") {
|
|
95
|
+
readBytes(run);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
release();
|
|
99
|
+
set({ phase: "failed" });
|
|
100
|
+
},
|
|
101
|
+
dispose() {
|
|
102
|
+
if (disposed)
|
|
103
|
+
return;
|
|
104
|
+
disposed = true;
|
|
105
|
+
reading?.abort();
|
|
106
|
+
reading = null;
|
|
107
|
+
release();
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ViewerDay {
|
|
2
|
+
/** The clock as read when the viewer's current day began for this document. */
|
|
3
|
+
readonly now: number;
|
|
4
|
+
/** `YYYY-MM-DD`, viewer-local: what a memo over the document keys on. */
|
|
5
|
+
readonly dayKey: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useViewerDay(): ViewerDay;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The transcript's clock (§07). A pill's words are made when
|
|
2
|
+
// the document is drawn, by the viewer's own calendar days — so a document left
|
|
3
|
+
// open over midnight is drawn again at midnight, and a pill read today and
|
|
4
|
+
// looked at tomorrow says tomorrow's words.
|
|
5
|
+
//
|
|
6
|
+
// The clock is re-read at the viewer's next midnight (one timer, re-armed each
|
|
7
|
+
// read) and whenever the window comes back (`focus`, `visibilitychange`), in
|
|
8
|
+
// case the timer slept with the machine. The value changes only when the DAY
|
|
9
|
+
// does, so a document keyed by it is re-derived once a day, never per tick.
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { calendarDayKey, msToNextViewerDay } from "../../lib/transcript/index.js";
|
|
12
|
+
/** A timer this far past midnight reads the new day, not the old one's last instant. */
|
|
13
|
+
const PAST_MIDNIGHT_MS = 1_000;
|
|
14
|
+
function readViewerDay() {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
return { now, dayKey: calendarDayKey(now) };
|
|
17
|
+
}
|
|
18
|
+
export function useViewerDay() {
|
|
19
|
+
const [day, setDay] = useState(readViewerDay);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let timer;
|
|
22
|
+
const refresh = () => {
|
|
23
|
+
const read = readViewerDay();
|
|
24
|
+
setDay((current) => (current.dayKey === read.dayKey ? current : read));
|
|
25
|
+
if (timer !== undefined)
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
timer = setTimeout(refresh, msToNextViewerDay(read.now) + PAST_MIDNIGHT_MS);
|
|
28
|
+
};
|
|
29
|
+
const onVisibility = () => {
|
|
30
|
+
if (document.visibilityState === "visible")
|
|
31
|
+
refresh();
|
|
32
|
+
};
|
|
33
|
+
refresh();
|
|
34
|
+
window.addEventListener("focus", refresh);
|
|
35
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
36
|
+
return () => {
|
|
37
|
+
if (timer !== undefined)
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
window.removeEventListener("focus", refresh);
|
|
40
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
return day;
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RoomWaitPlace } from "../../host-inputs.js";
|
|
3
|
+
import "../../styles/hold.css";
|
|
4
|
+
/** A hold's words: its line, and the count under it. */
|
|
5
|
+
export interface HoldWords {
|
|
6
|
+
/** What makes a new line, and so its crossfade: the words' identity, never
|
|
7
|
+
* their render (a count under the same line only counts). */
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly line: ReactNode;
|
|
10
|
+
readonly sub?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function Hold({ place, words, resting, carried, leaving, face, act }: {
|
|
13
|
+
readonly place: Exclude<RoomWaitPlace, "card">;
|
|
14
|
+
readonly words: HoldWords;
|
|
15
|
+
/** Its work is paused: the mark stands at rest. */
|
|
16
|
+
readonly resting?: boolean;
|
|
17
|
+
/** The host's own hold stood here as this one came: at once, no fade. */
|
|
18
|
+
readonly carried?: boolean;
|
|
19
|
+
/** Its wait is over and it fades away (280ms) before what comes next. */
|
|
20
|
+
readonly leaving?: boolean;
|
|
21
|
+
/** The face it stands for, as the room's other faces name theirs. */
|
|
22
|
+
readonly face: string;
|
|
23
|
+
/** An act under its words, where the wait offers one. */
|
|
24
|
+
readonly act?: ReactNode;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The hold — a wait that fills a place, in the host's mark (R10,
|
|
3
|
+
// `RoomWaitMark`). The mark at the centre of its place, one line 26 under it
|
|
4
|
+
// and its count 4 under that, so a host's own load and the room's read as one
|
|
5
|
+
// look (VibeField holds its Setup Assistant's loads so). Late, as the veil is:
|
|
6
|
+
// nothing for 120ms, then the words over 180ms and the mark over 400ms — at
|
|
7
|
+
// once when the host's own hold already stands there (`carried`). A new line
|
|
8
|
+
// crossfades in place, 140ms out and then 240ms in; a new count under the same
|
|
9
|
+
// line only counts. The mark only ever fades: it never moves or scales, and it
|
|
10
|
+
// stands at rest while its work is paused. Drawn only while the host gives a
|
|
11
|
+
// mark: without one the room's own waits stand, as rosetta's app shows them.
|
|
12
|
+
import { useEffect, useRef, useState } from "react";
|
|
13
|
+
import { useHostInputs } from "../../host-inputs.js";
|
|
14
|
+
import "../../styles/hold.css";
|
|
15
|
+
/** The words' leaving, before a new line comes in. */
|
|
16
|
+
const LINE_OUT_MS = 140;
|
|
17
|
+
/** The line as it shows: the old words while they leave, then the new. Words
|
|
18
|
+
* that come back while their line is leaving come in again at once. */
|
|
19
|
+
function useCrossfade(words) {
|
|
20
|
+
const [shown, setShown] = useState({ words, phase: "first" });
|
|
21
|
+
const latest = useRef(words);
|
|
22
|
+
latest.current = words;
|
|
23
|
+
const changed = words.key !== shown.words.key;
|
|
24
|
+
const leaving = shown.phase === "out";
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!changed) {
|
|
27
|
+
if (leaving)
|
|
28
|
+
setShown({ words: latest.current, phase: "in" });
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (!leaving) {
|
|
32
|
+
setShown((now) => ({ words: now.words, phase: "out" }));
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const timer = setTimeout(() => setShown({ words: latest.current, phase: "in" }), LINE_OUT_MS);
|
|
36
|
+
return () => clearTimeout(timer);
|
|
37
|
+
}, [changed, leaving, words.key]);
|
|
38
|
+
return changed ? shown : { words, phase: shown.phase };
|
|
39
|
+
}
|
|
40
|
+
export function Hold({ place, words, resting = false, carried = false, leaving = false, face, act }) {
|
|
41
|
+
const { waitMark } = useHostInputs();
|
|
42
|
+
const shown = useCrossfade(words);
|
|
43
|
+
return (_jsxs("div", { className: "ah-hold", "data-place": place, "data-face": face, "data-carried": carried ? "" : undefined, "data-leaving": leaving ? "" : undefined, role: "status", "aria-live": "polite", "aria-atomic": "true", children: [_jsx("div", { className: "ah-hold__mark", "aria-hidden": "true", children: waitMark?.mark(place, { resting }) }), _jsxs("div", { className: "ah-hold__words", "data-line": shown.phase, children: [_jsx("p", { className: "ah-hold__line", children: shown.words.line }), _jsx("p", { className: "ah-hold__sub", children: shown.words.sub }), act !== undefined && act !== null && _jsx("div", { className: "ah-hold__act", children: act })] })] }));
|
|
44
|
+
}
|
|
@@ -5,4 +5,4 @@ export interface MeterProps {
|
|
|
5
5
|
/** The width a known fraction draws: clamped, and never less than a sliver
|
|
6
6
|
* once something is known, so a started step is never drawn as empty. */
|
|
7
7
|
export declare function meterWidth(fraction: number): string;
|
|
8
|
-
export declare function Meter({ fraction }: MeterProps): import("react").JSX.Element;
|
|
8
|
+
export declare function Meter({ fraction }: MeterProps): import("react").JSX.Element | null;
|