@vibefield/rosetta-room 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -2
- 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/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/fixtures/index.d.ts +2 -1
- package/dist/fixtures/index.js +53 -4
- package/dist/lib/image-media.d.ts +5 -0
- package/dist/lib/image-media.js +17 -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/ports.d.ts +15 -1
- package/dist/styles/attachments.css +13 -0
- package/dist/styles/room.css +18 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,10 @@ import "@vibefield/rosetta-room/styles/room.css"; // after the host's --vf-* tok
|
|
|
20
20
|
|
|
21
21
|
`@vibefield/rosetta-room/fixtures` renders the room with no daemon at all:
|
|
22
22
|
`<HistoryRoom {...createDemoPorts()} />` (six projects, eleven sessions, a year
|
|
23
|
-
of figures, two transcripts with images
|
|
23
|
+
of figures, two transcripts with images, web lines and two sent videos (one
|
|
24
|
+
captured, one not), all relative to now). The demo commits no encoded video: a
|
|
25
|
+
video member reads as a header-only MP4, so pressing play ends at "Could not
|
|
26
|
+
play video".
|
|
24
27
|
`createColdImport({ now })` returns `{ ports, consent, daemon, controller }`
|
|
25
28
|
for a first import instead, over a seeded synthetic archive (by default the
|
|
26
29
|
MacBook trace's shape: 8,612 sessions in 1,139 trees over 119 projects;
|
|
@@ -48,7 +51,7 @@ sockets stay the simulator's.
|
|
|
48
51
|
|---|---|---|
|
|
49
52
|
| `CatalogPort` | `subscribeMeta` (runtimes, projects, every session row, live: one snapshot then mutations) · `status` → `CatalogStatus` · `projectStats(projectId, window)` → `ProjectStats` (per-day heat and per-session facts) · `usage` · `dayUsage` · `search(CatalogSearch)` · optional `onConnectionChange`, `unavailable` (the host's own words for why the index cannot answer), `boost` and `projectStatsBatch` (every listed project's figures in one ask; present, the room asks it once per refresh instead of `projectStats` per project) | its client's REST and `/ws/meta` (`catalogOver`) |
|
|
50
53
|
| `SessionPort` | `open(sessionId)` → a `SessionClient` bound to that session (its live subscription, child threads and team members each open their own; entries, report work, commands, plans, file targets, stored members), or a promise of one; `close(sessionId)` | the one client for every session; close is nothing |
|
|
51
|
-
| `AssetSource` | `imageAssetUrl(asset, variant)` → a URL, null, or a promise of either · `attachmentAssetUrl(asset)` → the attachment's address, for identity and can-open only | the daemon's own URLs |
|
|
54
|
+
| `AssetSource` | `imageAssetUrl(asset, variant)` → a URL, null, or a promise of either · `attachmentAssetUrl(asset)` → the attachment's address, for identity and can-open only · optional `mediaAssetUrl(asset)` → an address a `<video src>` can load, null, or a promise of either | the daemon's own URLs |
|
|
52
55
|
| `HostPort` (optional) | `homeDir` · `platform` · `openInBrowser(name, bytes, browserId?)` · optional `browsers()` · `favicon(site)` · optional `worktree: { open, gitFacts, fileAction, ports }` | the Electron bridge (`hostPortOver`) |
|
|
53
56
|
|
|
54
57
|
- **The room opens a session at most once at a time and follows every `open`
|
|
@@ -78,6 +81,30 @@ sockets stay the simulator's.
|
|
|
78
81
|
originals as placeholders. The SDK published as 0.1.2 answers an
|
|
79
82
|
original's `full` with its plain URL, so a host pairs this room with the
|
|
80
83
|
SDK released beside it.
|
|
84
|
+
- **A sent video plays in place, and only when asked.** A tool row's
|
|
85
|
+
attachment of kind `video` is a recorded member (`/api/assets/<digest>.mp4`
|
|
86
|
+
or `.mov`, `video/mp4` or `video/quicktime`, no `image_variants`) or a
|
|
87
|
+
reference to a file that was sent but not captured. The rail draws a
|
|
88
|
+
captured one as a tile with a play glyph, the file's name and its size, at
|
|
89
|
+
the rail's height and the video's own shape (16:9 when its dimensions are
|
|
90
|
+
unknown, never narrower than a square nor wider than 21:9). There is no
|
|
91
|
+
poster and no thumbnail: the room asks nothing for a video until the reader
|
|
92
|
+
presses play. Then it asks the optional **`mediaAssetUrl(asset)`** for an
|
|
93
|
+
address a `<video src>` can load. A host answers one only for an address
|
|
94
|
+
that honours byte ranges: served whole, without ranges, a video plays but
|
|
95
|
+
cannot seek, and no error tells the room to fall back. The daemon serves a
|
|
96
|
+
member whole, so rosetta's app leaves `mediaAssetUrl` out. A host without
|
|
97
|
+
it, one that answers null, or one whose address the element cannot load
|
|
98
|
+
needs nothing more: the room reads the member's bytes through the reading
|
|
99
|
+
session's `readAsset` and plays an object URL it makes and revokes itself,
|
|
100
|
+
which seeks. If the bytes cannot be read or played either,
|
|
101
|
+
the tile says "Could not play video" and offers Retry, which asks the host
|
|
102
|
+
again. A video that was not captured keeps the tile's shape, says "Video not
|
|
103
|
+
captured" with its name and size, and is not a button; an image sent the
|
|
104
|
+
same way says "Image not captured". A video is never passed to
|
|
105
|
+
`imageAssetUrl`, never opens the image viewer and is not in its gallery.
|
|
106
|
+
While a video has focus the rail's arrow, Home and End keys are the
|
|
107
|
+
video's. `attachmentAssetUrl` is still asked for a video, as its identity.
|
|
81
108
|
- **`boost` is optional** because a grant never opens a write: only a host
|
|
82
109
|
holding the daemon's bearer offers it. Without it the index keeps its order.
|
|
83
110
|
- **`browsers()`** returns installed browser ids, names and icon URLs. HTML
|
|
@@ -26,8 +26,10 @@ import { DayMenu, markStuckPills } from "./transcript/DayPill.js";
|
|
|
26
26
|
import { TranscriptDocument } from "./transcript/Document.js";
|
|
27
27
|
import { TranscriptLoading } from "./transcript/TranscriptLoading.js";
|
|
28
28
|
import { useTranscriptModel } from "./transcript/document-model.js";
|
|
29
|
+
import { useViewerDay } from "./transcript/viewer-day.js";
|
|
29
30
|
import { useFoldPreference } from "./transcript/fold-preference.js";
|
|
30
31
|
import { MessageViewerContext } from "./transcript/MessagePreview.js";
|
|
32
|
+
import { PromptJump } from "./transcript/PromptJump.js";
|
|
31
33
|
import { ThreadNavigationContext } from "./transcript/thread-navigation.js";
|
|
32
34
|
import { handleForMessage, messageFileSource } from "./transcript/message-file-source.js";
|
|
33
35
|
import { attachmentStatus } from "./transcript/Attachments.js";
|
|
@@ -84,7 +86,9 @@ function SessionTranscript({ session, duringBackfill, importCourse, importAgent,
|
|
|
84
86
|
const targetTimelineId = requestedTimelineId ?? metaFocus?.timelineId ?? null;
|
|
85
87
|
const targetIsMeta = requestedTimelineId === null && metaFocus !== null;
|
|
86
88
|
const cuts = useMemo(() => activityCuts(feed.rows, feed.watermark), [feed.rows, feed.watermark]);
|
|
87
|
-
|
|
89
|
+
// The viewer's day, re-read at midnight and on focus: a pill's words are the drawing's.
|
|
90
|
+
const viewerDay = useViewerDay();
|
|
91
|
+
const model = useTranscriptModel(feed.rows, session, homeDirectory, viewerDay.now, { cutBefore: cuts.cutBefore });
|
|
88
92
|
const opening = useTranscriptOpening(feed.snapshotReady, focus !== null || metaFocus !== null);
|
|
89
93
|
const loading = session !== null && opening.visible;
|
|
90
94
|
useEffect(() => {
|
|
@@ -363,7 +367,9 @@ function SessionTranscript({ session, duringBackfill, importCourse, importAgent,
|
|
|
363
367
|
// button fades, instead of leaving focus on an inert control.
|
|
364
368
|
scrollRef.current?.focus({ preventScroll: true });
|
|
365
369
|
tail.latest();
|
|
366
|
-
}, children: [_jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M8 3v10m-4-4 4 4 4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("span", { children: tail.unseen > 0 ? `${tail.unseen} new ${tail.unseen === 1 ? "message" : "messages"}` : "Latest" }), tail.unseen > 0 && _jsx("i", { "aria-hidden": "true" })] })),
|
|
370
|
+
}, children: [_jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M8 3v10m-4-4 4 4 4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("span", { children: tail.unseen > 0 ? `${tail.unseen} new ${tail.unseen === 1 ? "message" : "messages"}` : "Latest" }), tail.unseen > 0 && _jsx("i", { "aria-hidden": "true" })] })), session !== null && (
|
|
371
|
+
// A button at the side goes to the message before.
|
|
372
|
+
_jsx(PromptJump, { scrollRef: scrollRef, earlier: feed.earlier.kind, layoutKey: model.plan, onLeaveTail: tail.pause, hidden: loading })), !reader && _jsx("span", { className: "ah-tail-announcement", role: "status", "aria-live": "polite", "aria-atomic": "true", children: tail.away && tail.unseen > 0
|
|
367
373
|
? `${tail.unseen} new ${tail.unseen === 1 ? "message" : "messages"}. Scroll to latest to read.`
|
|
368
374
|
: "" }), !reader && _jsx(FileViewerDialog, { renderMarkdown: viewerTarget?.message === undefined ? undefined : (text) => _jsx(AuthoredMessage, { text: text, messageKey: viewerTarget.message.key, role: viewerTarget.message.role, preview: false, attachments: viewerTarget.message.attachments ?? [], onOpenAttachment: openAttachment, onReceipt: onReceipt }), handle: viewerTarget?.handle ?? null, source: viewerTarget?.source ?? attachments.fileSource, tint: project?.tint ?? null, homeDirectory: homeDirectory, onClose: () => {
|
|
369
375
|
viewerRequest.current += 1;
|
|
@@ -10,6 +10,8 @@ export declare function useAttachmentActions(onOpenAttachment: AttachmentOpener,
|
|
|
10
10
|
request: number;
|
|
11
11
|
} | null;
|
|
12
12
|
};
|
|
13
|
+
/** Why an attachment has no picture here, in the words of its kind. Every
|
|
14
|
+
* kind answers something: a kind this rail does not draw is never blank. */
|
|
13
15
|
export declare function attachmentStatus(fact: AttachmentFact): string;
|
|
14
16
|
export declare function Attachments({ facts, onOpenAttachment, reveal }: {
|
|
15
17
|
readonly facts: readonly AttachmentFact[];
|
|
@@ -3,6 +3,7 @@ import { createContext, useId, useLayoutEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { fmtBytes } from "../../lib/format.js";
|
|
4
4
|
import { useAttachmentReader } from "./attachment-file-source.js";
|
|
5
5
|
import { useImageUrl, useImageVisibility } from "../file-viewer/image-resource.js";
|
|
6
|
+
import { VideoTile, videoStatus } from "./VideoTile.js";
|
|
6
7
|
import "../../styles/attachments.css";
|
|
7
8
|
/** Explicitly shared only by messages whose images are gathered in this run. */
|
|
8
9
|
export const ActivityImagesContext = createContext(null);
|
|
@@ -19,17 +20,29 @@ export function useAttachmentActions(onOpenAttachment, onReceipt, facts) {
|
|
|
19
20
|
};
|
|
20
21
|
return { open, reveal };
|
|
21
22
|
}
|
|
23
|
+
/** Why an attachment has no picture here, in the words of its kind. Every
|
|
24
|
+
* kind answers something: a kind this rail does not draw is never blank. */
|
|
22
25
|
export function attachmentStatus(fact) {
|
|
23
26
|
const source = fact.ref?.source;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
switch (fact.kind) {
|
|
28
|
+
case "image":
|
|
29
|
+
// Sent by path and not captured: the record names a file, not bytes.
|
|
30
|
+
if (source?.type === "reference")
|
|
31
|
+
return "Image not captured";
|
|
32
|
+
if (source?.type === "unavailable") {
|
|
33
|
+
switch (source.reason) {
|
|
34
|
+
case "omitted": return "Image omitted from the recording";
|
|
35
|
+
case "invalid_data": return "Recorded image data is invalid";
|
|
36
|
+
case "unsupported_media": return "Image format is not supported";
|
|
37
|
+
case "not_recorded": return "Image data was not recorded";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return "Image data was not recorded";
|
|
41
|
+
case "video":
|
|
42
|
+
return videoStatus(fact);
|
|
43
|
+
default:
|
|
44
|
+
return "Attachment preview unavailable";
|
|
31
45
|
}
|
|
32
|
-
return "Image data was not recorded";
|
|
33
46
|
}
|
|
34
47
|
function Tile({ fact, index, onOpen }) {
|
|
35
48
|
const [failedUrl, setFailedUrl] = useState(null);
|
|
@@ -59,7 +72,7 @@ function Tile({ fact, index, onOpen }) {
|
|
|
59
72
|
}, [attempt, failed]);
|
|
60
73
|
const label = fact.ref?.label ?? `${fact.kind === "image" ? "Image" : "Attachment"} ${index + 1}`;
|
|
61
74
|
const details = [label, fact.name, fact.caption, fact.byteLen === null ? null : fmtBytes(fact.byteLen)].filter(Boolean).join(" · ");
|
|
62
|
-
return _jsx("figure", { ref: figureRef, "data-attachment-id": fact.key, title: details, children: resource === null || failed ? (_jsxs("div", { className: "tr-att__tile tr-att__tile--missing", tabIndex: -1, "aria-label": details, children: [_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: "3", width: "18", height: "18", rx: "4" }), _jsx("circle", { cx: "8", cy: "8", r: "1.5" }), _jsx("path", { d: "m3 17 5-5 4 4 3-3 6 6" })] }), _jsx("span", { children: failed ? "Could not load image" :
|
|
75
|
+
return _jsx("figure", { ref: figureRef, "data-attachment-id": fact.key, title: details, children: resource === null || failed ? (_jsxs("div", { className: "tr-att__tile tr-att__tile--missing", tabIndex: -1, "aria-label": details, children: [_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: "3", width: "18", height: "18", rx: "4" }), _jsx("circle", { cx: "8", cy: "8", r: "1.5" }), _jsx("path", { d: "m3 17 5-5 4 4 3-3 6 6" })] }), _jsx("span", { children: failed ? "Could not load image" : attachmentStatus(fact) }), failed && _jsx("button", { type: "button", ref: retryRef, className: "tr-att__retry", onClick: () => {
|
|
63
76
|
restoreFocus.current = true;
|
|
64
77
|
setAttempt(value => value + 1);
|
|
65
78
|
setFailedUrl(null);
|
|
@@ -125,11 +138,15 @@ export function Attachments({ facts, onOpenAttachment, reveal }) {
|
|
|
125
138
|
return null;
|
|
126
139
|
const page = (direction) => gallery.current?.scrollBy({ left: direction * gallery.current.clientWidth * 0.8,
|
|
127
140
|
behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth" });
|
|
141
|
+
const seen = { image: 0, video: 0 };
|
|
128
142
|
return _jsxs("div", { className: "tr-attachments", role: "group", "aria-label": `${facts.length} ${facts.length === 1 ? "attachment" : "attachments"}`, children: [_jsx("div", { className: "tr-att", id: id, ref: gallery, onFocusCapture: event => {
|
|
129
143
|
const tile = event.target.closest(".tr-att__tile");
|
|
130
144
|
if (tile && gallery.current)
|
|
131
145
|
revealTile(gallery.current, tile);
|
|
132
146
|
}, onKeyDown: event => {
|
|
147
|
+
// A playing video keeps its own keys: arrows seek, Home and End jump.
|
|
148
|
+
if (event.target instanceof Element && event.target.closest("video") !== null)
|
|
149
|
+
return;
|
|
133
150
|
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key) || !gallery.current)
|
|
134
151
|
return;
|
|
135
152
|
const tiles = [...gallery.current.querySelectorAll(".tr-att__tile")];
|
|
@@ -139,5 +156,13 @@ export function Attachments({ facts, onOpenAttachment, reveal }) {
|
|
|
139
156
|
event.preventDefault();
|
|
140
157
|
const next = event.key === "Home" ? 0 : event.key === "End" ? tiles.length - 1 : Math.max(0, Math.min(tiles.length - 1, index + (event.key === "ArrowRight" ? 1 : -1)));
|
|
141
158
|
tiles[next]?.focus({ preventScroll: true });
|
|
142
|
-
}, children: facts.map((fact, index) =>
|
|
159
|
+
}, children: facts.map((fact, index) => {
|
|
160
|
+
const key = `${fact.key}:${attachments.assetUrl(fact) ?? "reference"}`;
|
|
161
|
+
// An unlabelled tile is numbered among its own kind, as the gallery
|
|
162
|
+
// numbers the row's images: "Image 1" names one picture in both.
|
|
163
|
+
const ordinal = fact.kind === "image" ? seen.image++ : fact.kind === "video" ? seen.video++ : index;
|
|
164
|
+
// A video plays in place: it has no open action and no image path.
|
|
165
|
+
return fact.kind === "video" ? _jsx(VideoTile, { fact: fact, index: ordinal }, key)
|
|
166
|
+
: _jsx(Tile, { fact: fact, index: ordinal, onOpen: selected => onOpenAttachment(selected, facts) }, key);
|
|
167
|
+
}) }), (edges.before || edges.after) && _jsx("button", { className: "tr-att__nav tr-att__nav--previous", type: "button", "aria-label": "Previous images", "aria-disabled": !edges.before, "data-edge": !edges.before || undefined, "aria-controls": id, onClick: () => page(-1), children: "\u2039" }), (edges.before || edges.after) && _jsx("button", { className: "tr-att__nav tr-att__nav--next", type: "button", "aria-label": "Next images", "aria-disabled": !edges.after, "data-edge": !edges.after || undefined, "aria-controls": id, onClick: () => page(1), children: "\u203A" })] });
|
|
143
168
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
+
import { isRailMedia } from "../../lib/transcript/images.js";
|
|
3
4
|
import { ActivityImagesContext, Attachments, useAttachmentActions } from "./Attachments.js";
|
|
4
5
|
import { MessagePreview } from "./MessagePreview.js";
|
|
5
6
|
import { Prose } from "./Prose.js";
|
|
@@ -13,5 +14,5 @@ export function AuthoredMessage({ text, recordedText, attachments, messageKey, r
|
|
|
13
14
|
const content = (text !== null || recordedText?.type === "member") ? (preview
|
|
14
15
|
? _jsx(MessagePreview, { ...prose, messageKey: messageKey, role: role, recordedText: recordedText, title: title, matched: matched })
|
|
15
16
|
: _jsx(Prose, { ...prose })) : null;
|
|
16
|
-
return _jsxs(_Fragment, { children: [renderText ? renderText(content) : content, _jsx(Attachments, { facts: shared ? attachments.filter(fact => fact
|
|
17
|
+
return _jsxs(_Fragment, { children: [renderText ? renderText(content) : content, _jsx(Attachments, { facts: shared ? attachments.filter(fact => !isRailMedia(fact)) : attachments, onOpenAttachment: open, reveal: actions.reveal })] });
|
|
17
18
|
}
|
|
@@ -5,10 +5,14 @@ export interface PillText {
|
|
|
5
5
|
readonly after: string | null;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* A pill with a clock — the reader came back after a pause — leads with that
|
|
9
|
+
* clock by how far back its day is (`20:21` today,
|
|
10
|
+
* `Fri · 20:21` on one of the six days before, `Fri 6 Nov · 20:21` earlier),
|
|
11
|
+
* then `after 3h 37m`; where the day turned and inside a day alike. A pill
|
|
12
|
+
* with no clock — the day turned with no pause — keeps its day alone: `Today`,
|
|
13
|
+
* `Yesterday`, `Mon 31 Aug`. Null when the sitting is neither — a session that
|
|
14
|
+
* lives on one day with no pause draws no pill at all, because the column
|
|
15
|
+
* head's range already says when it was.
|
|
12
16
|
*/
|
|
13
17
|
export declare function pillText(sitting: SittingModel): PillText | null;
|
|
14
18
|
export interface DayPillProps {
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { duration } from "../../lib/format.js";
|
|
4
4
|
import { useReaderMode } from "./reader-context.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* A pill with a clock — the reader came back after a pause — leads with that
|
|
7
|
+
* clock by how far back its day is (`20:21` today,
|
|
8
|
+
* `Fri · 20:21` on one of the six days before, `Fri 6 Nov · 20:21` earlier),
|
|
9
|
+
* then `after 3h 37m`; where the day turned and inside a day alike. A pill
|
|
10
|
+
* with no clock — the day turned with no pause — keeps its day alone: `Today`,
|
|
11
|
+
* `Yesterday`, `Mon 31 Aug`. Null when the sitting is neither — a session that
|
|
12
|
+
* lives on one day with no pause draws no pill at all, because the column
|
|
13
|
+
* head's range already says when it was.
|
|
10
14
|
*/
|
|
11
15
|
export function pillText(sitting) {
|
|
12
16
|
const after = sitting.pauseMs === null ? null : `after ${duration(0, sitting.pauseMs)}`;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (sitting.dayChanged &&
|
|
16
|
-
return { lead:
|
|
17
|
-
}
|
|
18
|
-
if (resumed !== null)
|
|
19
|
-
return { lead: resumed, after };
|
|
17
|
+
if (sitting.clockLabel !== null)
|
|
18
|
+
return { lead: sitting.clockLabel, after };
|
|
19
|
+
if (sitting.dayChanged && sitting.dayLabel !== null)
|
|
20
|
+
return { lead: sitting.dayLabel, after };
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
export function DayPill({ sitting, onPress }) {
|
|
@@ -18,6 +18,7 @@ import { useRoom } from "../../room-context.js";
|
|
|
18
18
|
import { lastActive } from "../../lib/format.js";
|
|
19
19
|
import { sessionLastActive } from "../../lib/session-activity.js";
|
|
20
20
|
import { withinHistoryWindow } from "../../lib/transcript/history-window.js";
|
|
21
|
+
import { useViewerDay } from "./viewer-day.js";
|
|
21
22
|
import { EmptyState, Meter } from "../ui/index.js";
|
|
22
23
|
import { Anchor } from "./Anchor.js";
|
|
23
24
|
import { DayPill, Sitting } from "./DayPill.js";
|
|
@@ -90,7 +91,9 @@ function staticTimelineFeed(rows) {
|
|
|
90
91
|
function ReportWorkDocument({ session, rows, name, color, runtime, startedAt, endedAt, index, onReceipt, onOpenAttachment, onOpenPath, getRuntimeKind, homeDirectory, }) {
|
|
91
92
|
const boundedSession = useMemo(() => ({ ...session, stream_state: "indexed" }), [session]);
|
|
92
93
|
const feed = useMemo(() => staticTimelineFeed(rows), [rows]);
|
|
93
|
-
|
|
94
|
+
// A pill's words are the drawing's: the model is re-derived when the viewer's day turns.
|
|
95
|
+
const viewerDay = useViewerDay();
|
|
96
|
+
const model = useMemo(() => transcriptModel(rows, boundedSession, homeDirectory, viewerDay.now), [rows, boundedSession, homeDirectory, viewerDay.now]);
|
|
94
97
|
const scopedIndex = useMemo(() => {
|
|
95
98
|
const linked = new Set(rows.flatMap((row) => linkedChildSessionIds(row)));
|
|
96
99
|
const childrenByParent = new Map(index.childrenByParent);
|
|
@@ -119,10 +122,12 @@ export function TranscriptDocument({ session, model: baseModel, feed, duringBack
|
|
|
119
122
|
const chronology = useMemo(() => teamChronology(feed.rows, teamFeed.rowsBySession, { hasEarlier, ready: feed.snapshotReady }), [feed.rows, teamFeed.rowsBySession, hasEarlier, feed.snapshotReady]);
|
|
120
123
|
const displayedRows = chronology.rows;
|
|
121
124
|
const cuts = useMemo(() => activityCuts(feed.rows, feed.watermark, displayedRows), [feed.rows, feed.watermark, displayedRows]);
|
|
125
|
+
// A pill's words are the drawing's: the derived model is re-derived when the viewer's day turns.
|
|
126
|
+
const viewerDay = useViewerDay();
|
|
122
127
|
const model = useMemo(() => {
|
|
123
128
|
const derived = displayedRows === feed.rows
|
|
124
129
|
? baseModel
|
|
125
|
-
: transcriptModel(displayedRows, session, homeDirectory,
|
|
130
|
+
: transcriptModel(displayedRows, session, homeDirectory, viewerDay.now, {
|
|
126
131
|
sharedCollaborationSessionIds: teamIdSet,
|
|
127
132
|
cutBefore: cuts.cutBefore,
|
|
128
133
|
});
|
|
@@ -145,6 +150,7 @@ export function TranscriptDocument({ session, model: baseModel, feed, duringBack
|
|
|
145
150
|
teamIdSet,
|
|
146
151
|
chronology.duplicateRepresentatives,
|
|
147
152
|
cuts,
|
|
153
|
+
viewerDay.now,
|
|
148
154
|
]);
|
|
149
155
|
const previousReading = useRef(null);
|
|
150
156
|
const reading = useMemo(() => retainReadingIdentity(previousReading.current?.sessionId === session.id ? previousReading.current.reading : [], activityPlan(model.plan, {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EarlierState } from "../../lib/transcript/head-state.js";
|
|
2
|
+
export interface PromptJumpProps {
|
|
3
|
+
readonly scrollRef: {
|
|
4
|
+
readonly current: HTMLElement | null;
|
|
5
|
+
};
|
|
6
|
+
readonly earlier: EarlierState["kind"];
|
|
7
|
+
/** Changes whenever the document's rows may have moved: what is above is read again. */
|
|
8
|
+
readonly layoutKey: unknown;
|
|
9
|
+
/** The document stops following, as it does for any move up the page. */
|
|
10
|
+
readonly onLeaveTail: () => void;
|
|
11
|
+
/** While the transcript is still opening, the button is not there. */
|
|
12
|
+
readonly hidden: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function PromptJump({ scrollRef, earlier, layoutKey, onLeaveTail, hidden }: PromptJumpProps): import("react").JSX.Element;
|
|
@@ -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
|
+
}
|
|
@@ -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;
|