@vibefield/rosetta-room 0.1.10 → 0.1.12
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 +65 -3
- package/dist/components/Transcript.js +6 -2
- package/dist/components/file-viewer/FileViewerDialog.js +3 -2
- package/dist/components/file-viewer/diff/parse.js +7 -0
- package/dist/components/file-viewer/kinds.d.ts +22 -0
- package/dist/components/file-viewer/kinds.js +57 -0
- package/dist/components/file-viewer/markdown/render.d.ts +7 -1
- package/dist/components/file-viewer/markdown/render.js +16 -12
- package/dist/components/file-viewer/registry.d.ts +2 -2
- package/dist/components/file-viewer/registry.js +20 -59
- package/dist/components/file-viewer/views/DiffBody.js +7 -2
- package/dist/components/git/CommitViewer.js +3 -2
- package/dist/components/transcript/Activity.d.ts +10 -4
- package/dist/components/transcript/Activity.js +36 -11
- package/dist/components/transcript/Anchor.js +3 -2
- package/dist/components/transcript/Compaction.d.ts +9 -0
- package/dist/components/transcript/Compaction.js +10 -5
- package/dist/components/transcript/Document.js +150 -208
- package/dist/components/transcript/PromptJump.js +28 -8
- package/dist/components/transcript/Prose.d.ts +5 -1
- package/dist/components/transcript/Prose.js +7 -6
- package/dist/components/transcript/ReadingBlocks.d.ts +71 -0
- package/dist/components/transcript/ReadingBlocks.js +279 -0
- package/dist/components/transcript/activity-plan.d.ts +38 -7
- package/dist/components/transcript/activity-plan.js +198 -28
- package/dist/components/transcript/attachment-file-source.d.ts +1 -2
- package/dist/components/transcript/attachment-file-source.js +7 -5
- package/dist/components/transcript/disclosure-state.d.ts +2 -0
- package/dist/components/transcript/disclosure-state.js +6 -2
- package/dist/components/transcript/document-model.js +53 -9
- package/dist/components/transcript/document-plan.js +263 -98
- package/dist/components/transcript/reading-identity.d.ts +14 -1
- package/dist/components/transcript/reading-identity.js +126 -10
- package/dist/components/worktree/WorktreeColumn.js +12 -1
- package/dist/components/worktree/WorktreeList.d.ts +8 -2
- package/dist/components/worktree/WorktreeList.js +200 -5
- package/dist/components/worktree/worktree-ledger.d.ts +40 -0
- package/dist/components/worktree/worktree-ledger.js +68 -0
- package/dist/conversation/ConversationGallery.d.ts +11 -0
- package/dist/conversation/ConversationGallery.js +14 -0
- package/dist/conversation/ConversationMedia.d.ts +44 -0
- package/dist/conversation/ConversationMedia.js +210 -0
- package/dist/conversation/ConversationProse.d.ts +13 -0
- package/dist/conversation/ConversationProse.js +6 -0
- package/dist/conversation/ConversationRunRows.d.ts +57 -0
- package/dist/conversation/ConversationRunRows.js +84 -0
- package/dist/conversation/ConversationTurnView.d.ts +64 -0
- package/dist/conversation/ConversationTurnView.js +169 -0
- package/dist/conversation/ConversationView.d.ts +3 -0
- package/dist/conversation/ConversationView.js +257 -0
- package/dist/conversation/feed-reads.d.ts +36 -0
- package/dist/conversation/feed-reads.js +155 -0
- package/dist/conversation/feed.d.ts +106 -0
- package/dist/conversation/feed.js +884 -0
- package/dist/conversation/index.d.ts +11 -0
- package/dist/conversation/index.js +25 -0
- package/dist/conversation/model.d.ts +108 -0
- package/dist/conversation/model.js +257 -0
- package/dist/conversation/ports.d.ts +194 -0
- package/dist/conversation/ports.js +9 -0
- package/dist/conversation/rosetta-client.d.ts +8 -0
- package/dist/conversation/rosetta-client.js +1 -0
- package/dist/conversation/use-conversation-feed.d.ts +16 -0
- package/dist/conversation/use-conversation-feed.js +41 -0
- package/dist/conversation/use-conversation-window.d.ts +50 -0
- package/dist/conversation/use-conversation-window.js +336 -0
- package/dist/conversation/words.d.ts +51 -0
- package/dist/conversation/words.js +79 -0
- package/dist/fixtures/conversation.d.ts +34 -0
- package/dist/fixtures/conversation.js +723 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/lib/hooks.js +6 -1
- package/dist/lib/session-leases.d.ts +11 -8
- package/dist/lib/transcript/collaboration.js +53 -19
- package/dist/lib/transcript/head-of-document.js +9 -3
- package/dist/lib/transcript/index.d.ts +1 -1
- package/dist/lib/transcript/index.js +1 -1
- package/dist/lib/transcript/prompt-jump.d.ts +2 -0
- package/dist/lib/transcript/prompt-jump.js +5 -1
- package/dist/lib/transcript/sittings.d.ts +2 -1
- package/dist/lib/transcript/sittings.js +72 -10
- package/dist/lib/transcript/tail-state.d.ts +9 -0
- package/dist/lib/transcript/tail-state.js +25 -1
- package/dist/lib/transcript/turns.d.ts +5 -0
- package/dist/lib/transcript/turns.js +221 -57
- package/dist/lib/transcript/use-transcript-tail.js +17 -3
- package/dist/lib/transcript/vocabulary.d.ts +2 -1
- package/dist/lib/transcript/vocabulary.js +11 -1
- package/dist/parts-context.d.ts +25 -0
- package/dist/parts-context.js +32 -0
- package/dist/ports.d.ts +36 -0
- package/dist/room-context.d.ts +1 -2
- package/dist/room-context.js +11 -9
- package/dist/styles/conversation-turn.css +147 -0
- package/dist/styles/conversation.css +45 -0
- package/dist/styles/room.css +102 -12
- package/dist/styles/transcript.css +11 -2
- package/package.json +9 -4
|
@@ -1,12 +1,207 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// The repository's other checkouts, under the tree that is showing one of
|
|
3
|
+
// them. Only worth drawing when there is more than one: a repository with a
|
|
4
|
+
// single worktree has nothing to disambiguate, and a list of one is a label.
|
|
5
|
+
//
|
|
6
|
+
// It is a ledger of disk. A repository's worktrees hold the same tracked
|
|
7
|
+
// files, so what tells them apart on a disk is what git does not track (the
|
|
8
|
+
// installed packages, the build output), and a reader deciding which checkout
|
|
9
|
+
// to let go of wants that figure first. So the rows stand heaviest first,
|
|
10
|
+
// each a name with its size at the edge over a bar scaled to the heaviest;
|
|
11
|
+
// where the folder is and how dirty the open one is are on the row's hover.
|
|
12
|
+
//
|
|
13
|
+
// A FIGURE IS A WALK OF A FOLDER, AND A REPOSITORY CAN HAVE HUNDREDS OF
|
|
14
|
+
// WORKTREES. So the list asks its host only for the rows that are on screen,
|
|
15
|
+
// again as the reader scrolls, and a host keeps what it measured: the next
|
|
16
|
+
// opening shows those figures at once and walks nothing. A row whose figure
|
|
17
|
+
// is owed shows that it is being weighed, never a blank.
|
|
18
|
+
//
|
|
19
|
+
// Figures arrive one at a time while the list is being read. A row keeps its
|
|
20
|
+
// place until the list is at rest (at its top, no pointer or keyboard in it);
|
|
21
|
+
// only then does it take its rank (`settleOrder`).
|
|
22
|
+
//
|
|
23
|
+
// A row is named by its branch, or, with no branch, by its folder's own name
|
|
24
|
+
// with its commit beside it. The whole path of a branchless checkout was four
|
|
25
|
+
// lines of this column, with the one part that told two apart at the very end.
|
|
26
|
+
//
|
|
27
|
+
// A press copies the name. That is the room's one act here: switching
|
|
28
|
+
// worktrees is an act on a repository, and this room reads history.
|
|
29
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
30
|
+
import { fmtBytes, tildePath } from "../../lib/format.js";
|
|
31
|
+
import { CopyGlyph } from "../../lib/icons.js";
|
|
32
|
+
import { useCopyText } from "../../room-context.js";
|
|
33
|
+
import { ledgerOf, settleOrder } from "./worktree-ledger.js";
|
|
34
|
+
/** How long a scroll settles before the rows on screen are asked for. */
|
|
35
|
+
const SETTLE_MS = 160;
|
|
36
|
+
/** How often the rows on screen that are still being weighed are asked again. */
|
|
37
|
+
const POLL_MS = 1500;
|
|
38
|
+
/** Rows one ask names at most: more than a column shows at once. */
|
|
39
|
+
const ASK_ROWS = 32;
|
|
40
|
+
/** Rows just off screen that count as shown, so a short scroll finds them weighed. */
|
|
41
|
+
const NEAR = "96px 0px";
|
|
42
|
+
export function WorktreeList({ facts, openRoot, homeDirectory, onReceipt, measure, }) {
|
|
43
|
+
const copy = useCopyText();
|
|
44
|
+
const [answers, setAnswers] = useState(new Map());
|
|
45
|
+
useEffect(() => setAnswers(new Map()), [measure]);
|
|
46
|
+
const ledger = useMemo(() => {
|
|
47
|
+
const sizeOf = (worktree) => {
|
|
48
|
+
const said = answers.get(worktree.path);
|
|
49
|
+
// a figure the host already held stands while the folder is walked again
|
|
50
|
+
const kept = typeof worktree.sizeBytes === "number" ? worktree.sizeBytes : undefined;
|
|
51
|
+
if (said !== undefined)
|
|
52
|
+
return said === "none" ? undefined : (said ?? kept ?? null);
|
|
53
|
+
if (kept !== undefined)
|
|
54
|
+
return kept;
|
|
55
|
+
// owed: asked for once the row is on screen
|
|
56
|
+
return measure === undefined ? undefined : null;
|
|
57
|
+
};
|
|
58
|
+
return ledgerOf(facts.worktrees, openRoot, sizeOf);
|
|
59
|
+
}, [facts.worktrees, openRoot, answers, measure]);
|
|
60
|
+
const byPath = useMemo(() => new Map(ledger.rows.map((row) => [row.path, row])), [ledger]);
|
|
61
|
+
const ranked = useMemo(() => ledger.rows.map((row) => row.path), [ledger]);
|
|
62
|
+
// ── the drawn order: the ledger's while at rest, each row's own place otherwise
|
|
63
|
+
const scroller = useRef(null);
|
|
64
|
+
const held = useRef({ pointer: false, keyboard: false, scrolled: false });
|
|
65
|
+
const [restTick, setRestTick] = useState(0);
|
|
66
|
+
const atRest = () => !held.current.pointer && !held.current.keyboard && !held.current.scrolled;
|
|
67
|
+
const hold = (what, value) => {
|
|
68
|
+
if (held.current[what] === value)
|
|
69
|
+
return;
|
|
70
|
+
held.current[what] = value;
|
|
71
|
+
if (atRest())
|
|
72
|
+
setRestTick((tick) => tick + 1);
|
|
73
|
+
};
|
|
74
|
+
const [order, setOrder] = useState([]);
|
|
75
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: restTick is the rest's own signal
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
setOrder((drawn) => settleOrder(drawn, ranked, atRest()));
|
|
78
|
+
}, [ranked, restTick]);
|
|
79
|
+
const drawn = useMemo(() => settleOrder(order, ranked, false), [order, ranked]);
|
|
80
|
+
// ── the rows on screen, and what the host is asked of them
|
|
81
|
+
const shown = useRef(new Set());
|
|
82
|
+
const [seenTick, setSeenTick] = useState(0);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const root = scroller.current;
|
|
85
|
+
if (root === null || measure === undefined)
|
|
86
|
+
return;
|
|
87
|
+
const rows = [...root.querySelectorAll("[data-worktree]")];
|
|
88
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
89
|
+
shown.current = new Set(rows.slice(0, 12).map((row) => row.dataset["worktree"] ?? ""));
|
|
90
|
+
setSeenTick((tick) => tick + 1);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let timer;
|
|
94
|
+
const observer = new IntersectionObserver((entries) => {
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
const path = entry.target.dataset["worktree"];
|
|
97
|
+
if (path === undefined)
|
|
98
|
+
continue;
|
|
99
|
+
if (entry.isIntersecting)
|
|
100
|
+
shown.current.add(path);
|
|
101
|
+
else
|
|
102
|
+
shown.current.delete(path);
|
|
103
|
+
}
|
|
104
|
+
window.clearTimeout(timer);
|
|
105
|
+
timer = window.setTimeout(() => setSeenTick((tick) => tick + 1), SETTLE_MS);
|
|
106
|
+
}, { root, rootMargin: NEAR });
|
|
107
|
+
shown.current = new Set();
|
|
108
|
+
for (const row of rows)
|
|
109
|
+
observer.observe(row);
|
|
110
|
+
return () => {
|
|
111
|
+
window.clearTimeout(timer);
|
|
112
|
+
observer.disconnect();
|
|
113
|
+
};
|
|
114
|
+
}, [drawn, measure]);
|
|
115
|
+
const settled = useRef(new Set());
|
|
116
|
+
const asking = useRef(false);
|
|
117
|
+
const [pollTick, setPollTick] = useState(0);
|
|
118
|
+
const gone = useMemo(() => new Set(ledger.rows.filter((row) => row.gone).map((row) => row.path)), [ledger]);
|
|
119
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the ticks are the signals
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (measure === undefined || asking.current)
|
|
122
|
+
return;
|
|
123
|
+
const want = drawn
|
|
124
|
+
.filter((path) => shown.current.has(path) && !gone.has(path) && !settled.current.has(path))
|
|
125
|
+
.slice(0, ASK_ROWS);
|
|
126
|
+
if (want.length === 0)
|
|
127
|
+
return;
|
|
128
|
+
let live = true;
|
|
129
|
+
let again;
|
|
130
|
+
asking.current = true;
|
|
131
|
+
measure(want)
|
|
132
|
+
.then((said) => {
|
|
133
|
+
if (!live)
|
|
134
|
+
return;
|
|
135
|
+
let owed = false;
|
|
136
|
+
const next = new Map();
|
|
137
|
+
for (const path of want) {
|
|
138
|
+
const row = said.find((one) => one.path === path);
|
|
139
|
+
const size = row?.sizeBytes;
|
|
140
|
+
if (typeof size === "number")
|
|
141
|
+
next.set(path, size);
|
|
142
|
+
else if (size === null)
|
|
143
|
+
next.set(path, null);
|
|
144
|
+
else
|
|
145
|
+
next.set(path, "none");
|
|
146
|
+
if (size === null)
|
|
147
|
+
owed = true;
|
|
148
|
+
else
|
|
149
|
+
settled.current.add(path);
|
|
150
|
+
}
|
|
151
|
+
setAnswers((before) => {
|
|
152
|
+
const merged = new Map(before);
|
|
153
|
+
for (const [path, answer] of next)
|
|
154
|
+
merged.set(path, answer);
|
|
155
|
+
return merged;
|
|
156
|
+
});
|
|
157
|
+
if (owed)
|
|
158
|
+
again = window.setTimeout(() => setPollTick((tick) => tick + 1), POLL_MS);
|
|
159
|
+
})
|
|
160
|
+
.catch(() => {
|
|
161
|
+
// the host could not say: the rows stay as they are, and the next
|
|
162
|
+
// scroll asks again
|
|
163
|
+
})
|
|
164
|
+
.finally(() => {
|
|
165
|
+
asking.current = false;
|
|
166
|
+
});
|
|
167
|
+
return () => {
|
|
168
|
+
live = false;
|
|
169
|
+
window.clearTimeout(again);
|
|
170
|
+
};
|
|
171
|
+
}, [seenTick, pollTick, measure, gone]);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
settled.current = new Set();
|
|
174
|
+
}, [measure]);
|
|
175
|
+
const press = useCallback((name) => {
|
|
176
|
+
void copy(name)
|
|
177
|
+
.then(() => onReceipt("worktree name copied"))
|
|
178
|
+
.catch(() => onReceipt("the clipboard refused"));
|
|
179
|
+
}, [copy, onReceipt]);
|
|
4
180
|
// `ah-rail*` is the design record's name for this column; room.css is a
|
|
5
181
|
// port of the proto and keeps its vocabulary.
|
|
6
|
-
return (_jsxs("div", { className: "ah-railfoot",
|
|
182
|
+
return (_jsxs("div", { className: "ah-railfoot", onPointerEnter: () => hold("pointer", true), onPointerLeave: () => hold("pointer", false), onFocusCapture: (event) => {
|
|
183
|
+
if (event.target.matches(":focus-visible"))
|
|
184
|
+
hold("keyboard", true);
|
|
185
|
+
}, onBlurCapture: (event) => {
|
|
186
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
187
|
+
hold("keyboard", false);
|
|
188
|
+
}, children: [_jsxs("div", { className: "ah-railsplit", children: [_jsx("span", { className: "ah-eyebrow", children: "Worktrees" }), _jsxs("span", { className: "ah-railsplit__sum tnum", children: [ledger.rows.length, ledger.totalBytes !== null &&
|
|
189
|
+
` · ${fmtBytes(ledger.totalBytes)}${ledger.partial ? "+" : ""}`] })] }), _jsx("div", { className: "ah-railfoot__list", role: "list", "aria-label": "Worktrees", ref: scroller, onScroll: (event) => hold("scrolled", event.currentTarget.scrollTop > 0), children: drawn.map((path) => {
|
|
190
|
+
const row = byPath.get(path);
|
|
191
|
+
if (row === undefined)
|
|
192
|
+
return null;
|
|
7
193
|
// The count belongs to the checkout the shell actually read, and
|
|
8
194
|
// git reports it for one worktree at a time.
|
|
9
|
-
const dirty =
|
|
10
|
-
|
|
195
|
+
const dirty = row.open ? facts.dirty : null;
|
|
196
|
+
const weighing = row.sizeBytes === null;
|
|
197
|
+
const hover = [
|
|
198
|
+
tildePath(row.path, homeDirectory),
|
|
199
|
+
row.gone ? "its folder is gone" : null,
|
|
200
|
+
dirty === null ? null : dirty > 0 ? `${dirty} dirty` : "clean",
|
|
201
|
+
"Press to copy the name",
|
|
202
|
+
]
|
|
203
|
+
.filter((part) => part !== null)
|
|
204
|
+
.join(" · ");
|
|
205
|
+
return (_jsx("div", { role: "listitem", children: _jsxs("button", { type: "button", className: "ah-worktree", title: hover, "data-worktree": row.path, "data-open": row.open ? "" : undefined, "data-gone": row.gone ? "" : undefined, "data-weighing": weighing ? "" : undefined, "aria-busy": weighing || undefined, onClick: () => press(row.name), children: [_jsxs("span", { className: "ah-worktree__name", children: [_jsx("span", { className: "ah-worktree__label", children: row.name }), row.commit !== null && _jsx("code", { children: row.commit }), _jsx("span", { className: "ah-worktree__copy", children: _jsx(CopyGlyph, {}) })] }), _jsx("span", { className: "ah-worktree__size tnum", children: row.gone ? ("gone") : typeof row.sizeBytes === "number" ? (fmtBytes(row.sizeBytes)) : weighing ? (_jsx("span", { className: "ah-worktree__wait", role: "img", "aria-label": "measuring" })) : null }), (row.share !== null || weighing) && (_jsx("span", { className: "ah-worktree__bar", "aria-hidden": "true", children: row.share !== null && (_jsx("span", { style: { width: `${Math.max(row.share * 100, 1.5).toFixed(2)}%` } })) }))] }) }, row.path));
|
|
11
206
|
}) })] }));
|
|
12
207
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { GitWorktree } from "../../ports.js";
|
|
2
|
+
/** One drawn row. */
|
|
3
|
+
export interface LedgerRow {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** What the row says and what a press copies: the branch, or for a checkout
|
|
6
|
+
* with no branch its folder's own name. */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** The commit beside a folder's name, abbreviated; null beside a branch,
|
|
9
|
+
* which already names what is checked out. */
|
|
10
|
+
readonly commit: string | null;
|
|
11
|
+
readonly open: boolean;
|
|
12
|
+
readonly gone: boolean;
|
|
13
|
+
/** Bytes; null while the figure is owed (asked for, or to be asked once the
|
|
14
|
+
* row is on screen); undefined when there will be none. */
|
|
15
|
+
readonly sizeBytes: number | null | undefined;
|
|
16
|
+
/** The bar: this row's share of the heaviest row, 0 to 1. null with no figure. */
|
|
17
|
+
readonly share: number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface Ledger {
|
|
20
|
+
/** Measured rows heaviest first, then the ones owed a figure in git's own
|
|
21
|
+
* order, then the ones whose folder is gone. */
|
|
22
|
+
readonly rows: readonly LedgerRow[];
|
|
23
|
+
/** The sum of the figures there are; null while there is none. */
|
|
24
|
+
readonly totalBytes: number | null;
|
|
25
|
+
/** True while some row is owed a figure, so the sum is a floor. */
|
|
26
|
+
readonly partial: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The ledger over what git listed. `sizeOf` says each worktree's figure as
|
|
29
|
+
* the list knows it now (the host's kept figure, or a later answer): bytes,
|
|
30
|
+
* null while owed, undefined when there will be none. Absent, the figure is
|
|
31
|
+
* the one the worktree came with. */
|
|
32
|
+
export declare function ledgerOf(worktrees: readonly GitWorktree[], openRoot: string | null, sizeOf?: (worktree: GitWorktree) => number | null | undefined): Ledger;
|
|
33
|
+
/** The order the rows are DRAWN in. The ledger's own order is by weight, but
|
|
34
|
+
* figures arrive one at a time while the list is being read, and a row that
|
|
35
|
+
* leaves for its rank the moment it is weighed takes the reader's place with
|
|
36
|
+
* it. So the drawn order follows the ledger only while the list is at rest
|
|
37
|
+
* (at its top, with no pointer or focus in it); otherwise each row stays
|
|
38
|
+
* where it was, a row new to the list goes after them in the ledger's order,
|
|
39
|
+
* and a row no longer listed goes. */
|
|
40
|
+
export declare function settleOrder(drawn: readonly string[], ledger: readonly string[], atRest: boolean): readonly string[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The worktree list as a ledger of disk: who holds how much, heaviest first.
|
|
2
|
+
// Pure, so the order and the bars are testable without a window.
|
|
3
|
+
/** git's abbreviation length, the one `git log --oneline` prints. */
|
|
4
|
+
const COMMIT_CHARS = 7;
|
|
5
|
+
function folderName(path) {
|
|
6
|
+
const trimmed = path.replace(/[\\/]+$/, "");
|
|
7
|
+
const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
8
|
+
const name = at === -1 ? trimmed : trimmed.slice(at + 1);
|
|
9
|
+
return name === "" ? path : name;
|
|
10
|
+
}
|
|
11
|
+
/** The ledger over what git listed. `sizeOf` says each worktree's figure as
|
|
12
|
+
* the list knows it now (the host's kept figure, or a later answer): bytes,
|
|
13
|
+
* null while owed, undefined when there will be none. Absent, the figure is
|
|
14
|
+
* the one the worktree came with. */
|
|
15
|
+
export function ledgerOf(worktrees, openRoot, sizeOf = (w) => w.sizeBytes) {
|
|
16
|
+
const sized = worktrees.map((worktree, at) => ({
|
|
17
|
+
worktree,
|
|
18
|
+
at,
|
|
19
|
+
gone: worktree.gone === true,
|
|
20
|
+
size: worktree.gone === true ? undefined : sizeOf(worktree),
|
|
21
|
+
}));
|
|
22
|
+
const heaviest = sized.reduce((most, row) => (typeof row.size === "number" ? Math.max(most, row.size) : most), 0);
|
|
23
|
+
const rank = (row) => row.gone ? 2 : typeof row.size === "number" ? 0 : 1;
|
|
24
|
+
const rows = [...sized]
|
|
25
|
+
.sort((a, b) => {
|
|
26
|
+
const byRank = rank(a) - rank(b);
|
|
27
|
+
if (byRank !== 0)
|
|
28
|
+
return byRank;
|
|
29
|
+
if (rank(a) === 0) {
|
|
30
|
+
const bySize = b.size - a.size;
|
|
31
|
+
if (bySize !== 0)
|
|
32
|
+
return bySize;
|
|
33
|
+
}
|
|
34
|
+
return a.at - b.at;
|
|
35
|
+
})
|
|
36
|
+
.map(({ worktree, gone, size }) => ({
|
|
37
|
+
path: worktree.path,
|
|
38
|
+
name: worktree.branch ?? folderName(worktree.path),
|
|
39
|
+
commit: worktree.branch === null && typeof worktree.head === "string" && worktree.head !== ""
|
|
40
|
+
? worktree.head.slice(0, COMMIT_CHARS)
|
|
41
|
+
: null,
|
|
42
|
+
open: worktree.path === openRoot,
|
|
43
|
+
gone,
|
|
44
|
+
sizeBytes: size,
|
|
45
|
+
share: typeof size === "number" ? (heaviest > 0 ? size / heaviest : 0) : null,
|
|
46
|
+
}));
|
|
47
|
+
const measured = sized.filter((row) => typeof row.size === "number");
|
|
48
|
+
return {
|
|
49
|
+
rows,
|
|
50
|
+
totalBytes: measured.length === 0 ? null : measured.reduce((sum, row) => sum + row.size, 0),
|
|
51
|
+
partial: sized.some((row) => !row.gone && row.size === null),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** The order the rows are DRAWN in. The ledger's own order is by weight, but
|
|
55
|
+
* figures arrive one at a time while the list is being read, and a row that
|
|
56
|
+
* leaves for its rank the moment it is weighed takes the reader's place with
|
|
57
|
+
* it. So the drawn order follows the ledger only while the list is at rest
|
|
58
|
+
* (at its top, with no pointer or focus in it); otherwise each row stays
|
|
59
|
+
* where it was, a row new to the list goes after them in the ledger's order,
|
|
60
|
+
* and a row no longer listed goes. */
|
|
61
|
+
export function settleOrder(drawn, ledger, atRest) {
|
|
62
|
+
if (atRest || drawn.length === 0)
|
|
63
|
+
return ledger;
|
|
64
|
+
const listed = new Set(ledger);
|
|
65
|
+
const kept = drawn.filter((path) => listed.has(path));
|
|
66
|
+
const seen = new Set(kept);
|
|
67
|
+
return [...kept, ...ledger.filter((path) => !seen.has(path))];
|
|
68
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../styles/room.css";
|
|
2
|
+
import type { AttachmentReader } from "../components/transcript/attachment-file-source.js";
|
|
3
|
+
import type { AttachmentFact } from "../lib/transcript/index.js";
|
|
4
|
+
export declare function ConversationGallery({ reader, fact, row, homeDir, onClose, onReceipt }: {
|
|
5
|
+
readonly reader: AttachmentReader;
|
|
6
|
+
readonly fact: AttachmentFact;
|
|
7
|
+
readonly row: readonly AttachmentFact[];
|
|
8
|
+
readonly homeDir: string | null;
|
|
9
|
+
readonly onClose: () => void;
|
|
10
|
+
readonly onReceipt: (message: string) => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The room's gallery over the conversation view's pictures. Loaded only when
|
|
3
|
+
// a reader presses a picture and the host takes no press of its own: this
|
|
4
|
+
// module brings the file viewer's dialog and the room's sheet for it, which
|
|
5
|
+
// the view's own entry never imports.
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import "../styles/room.css";
|
|
8
|
+
import { ImageGalleryDialog } from "../components/file-viewer/ImageGalleryDialog.js";
|
|
9
|
+
import { attachmentGallery, createAttachmentGallerySource } from "../components/transcript/attachment-gallery.js";
|
|
10
|
+
export function ConversationGallery({ reader, fact, row, homeDir, onClose, onReceipt }) {
|
|
11
|
+
const source = useMemo(() => createAttachmentGallerySource(reader), [reader]);
|
|
12
|
+
const { images, initialKey } = attachmentGallery(reader, fact, row);
|
|
13
|
+
return (_jsx(ImageGalleryDialog, { images: images, initialKey: initialKey, source: source, tint: null, homeDirectory: homeDir, onClose: onClose, onReceipt: onReceipt, openInBrowser: null }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { AttachmentRef } from "@vibefield/rosetta-protocol";
|
|
3
|
+
import type { AttachmentFact } from "../lib/transcript/index.js";
|
|
4
|
+
import type { AttachmentReader } from "../components/transcript/attachment-file-source.js";
|
|
5
|
+
import type { ConversationMedia, ConversationViewWords } from "./ports.js";
|
|
6
|
+
/** One medium of a reply or a run, by the row that holds it. */
|
|
7
|
+
export interface ConversationMediaItem {
|
|
8
|
+
readonly timelineId: string;
|
|
9
|
+
readonly attachment: AttachmentRef;
|
|
10
|
+
}
|
|
11
|
+
/** The words the media draw themselves. */
|
|
12
|
+
export declare const CONVERSATION_MEDIA_WORDS: Readonly<{
|
|
13
|
+
failed: "Could not load image";
|
|
14
|
+
retry: "Retry";
|
|
15
|
+
play: "Play video";
|
|
16
|
+
}>;
|
|
17
|
+
/** The media's lines, each whole, as the view's `words` name them. */
|
|
18
|
+
export type MediaLines = Pick<ConversationViewWords, "mediaFailed" | "mediaRetry" | "mediaPlay">;
|
|
19
|
+
export declare const MEDIA_LINES: MediaLines;
|
|
20
|
+
/** The room's fact for one medium, keyed as the room keys a message's own. */
|
|
21
|
+
export declare function mediaFactOf(sessionId: string, item: ConversationMediaItem): AttachmentFact;
|
|
22
|
+
/** Opens the room's gallery on one picture among its row's. */
|
|
23
|
+
export type ConversationGalleryOpener = (reader: AttachmentReader, fact: AttachmentFact, row: readonly AttachmentFact[]) => void;
|
|
24
|
+
/** Where the room's gallery opens for the view's pictures; the view mounts
|
|
25
|
+
* one around its rows. */
|
|
26
|
+
export declare function ConversationGalleryHost({ children, homeDir, onReceipt }: {
|
|
27
|
+
readonly children: ReactNode;
|
|
28
|
+
readonly homeDir: string | null;
|
|
29
|
+
readonly onReceipt: (message: string) => void;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
/** A length in seconds as a clock: `0:07`, `12:30`, `1:02:03`; null when the
|
|
32
|
+
* element could not say (a recording that names no duration). */
|
|
33
|
+
export declare function lengthText(seconds: number | null): string | null;
|
|
34
|
+
export interface ConversationMediaListProps {
|
|
35
|
+
readonly sessionId: string;
|
|
36
|
+
readonly items: readonly ConversationMediaItem[];
|
|
37
|
+
readonly onOpenMedia?: ((media: ConversationMedia) => void) | undefined;
|
|
38
|
+
/** The lines a picture or a video draws itself; rosetta's own when absent. */
|
|
39
|
+
readonly words?: MediaLines;
|
|
40
|
+
}
|
|
41
|
+
/** Always the room's rail, however many: a prompt's own pictures. */
|
|
42
|
+
export declare function ConversationMediaRail({ sessionId, items, onOpenMedia }: ConversationMediaListProps): import("react").JSX.Element | null;
|
|
43
|
+
/** Draws nothing for no media. */
|
|
44
|
+
export declare function ConversationMediaList({ sessionId, items, onOpenMedia, words }: ConversationMediaListProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A reply's or a run's pictures and videos, as the conversation view draws
|
|
3
|
+
// them:
|
|
4
|
+
//
|
|
5
|
+
// - one picture, as wide as the reply up to the host's `--tr-conv-media-max`,
|
|
6
|
+
// drawn from its preview rendition;
|
|
7
|
+
// - two or more, or pictures with videos, as the room's own rail;
|
|
8
|
+
// - one video with its first frame, its length and its size, played in place
|
|
9
|
+
// with the element's own controls, when the host's address honours byte
|
|
10
|
+
// ranges and may be asked before play (`AssetSource.mediaFirstFrame`).
|
|
11
|
+
// Otherwise, or when that address fails, the room's tile, which asks for
|
|
12
|
+
// nothing until the reader presses play.
|
|
13
|
+
//
|
|
14
|
+
// A press on a picture is the host's (`onOpenMedia`). With none, the room's
|
|
15
|
+
// gallery opens, and its code (the file viewer's dialog and its sheet) is
|
|
16
|
+
// loaded only then: it is never in the view's static import graph.
|
|
17
|
+
import { createContext, lazy, Suspense, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
18
|
+
import { fmtBytes } from "../lib/format.js";
|
|
19
|
+
import { readAttachments } from "../lib/transcript/index.js";
|
|
20
|
+
import { useParts } from "../parts-context.js";
|
|
21
|
+
import { useImageUrl } from "../components/file-viewer/image-resource.js";
|
|
22
|
+
import { Attachments } from "../components/transcript/Attachments.js";
|
|
23
|
+
import { useAttachmentReader } from "../components/transcript/attachment-file-source.js";
|
|
24
|
+
import { VideoFace, videoAspect } from "../components/transcript/VideoTile.js";
|
|
25
|
+
import { IDLE_VIDEO, createVideoSource } from "../components/transcript/video-source.js";
|
|
26
|
+
/** The words the media draw themselves. */
|
|
27
|
+
export const CONVERSATION_MEDIA_WORDS = Object.freeze({
|
|
28
|
+
failed: "Could not load image",
|
|
29
|
+
retry: "Retry",
|
|
30
|
+
play: "Play video",
|
|
31
|
+
});
|
|
32
|
+
export const MEDIA_LINES = Object.freeze({
|
|
33
|
+
mediaFailed: CONVERSATION_MEDIA_WORDS.failed,
|
|
34
|
+
mediaRetry: CONVERSATION_MEDIA_WORDS.retry,
|
|
35
|
+
mediaPlay: CONVERSATION_MEDIA_WORDS.play,
|
|
36
|
+
});
|
|
37
|
+
/** The room's fact for one medium, keyed as the room keys a message's own. */
|
|
38
|
+
export function mediaFactOf(sessionId, item) {
|
|
39
|
+
const [fact] = readAttachments(null, [item.attachment]).attachments;
|
|
40
|
+
return { ...fact, key: `${sessionId}:${item.timelineId}:attachment:${fact.key}` };
|
|
41
|
+
}
|
|
42
|
+
const GalleryContext = createContext(null);
|
|
43
|
+
const LazyGallery = lazy(() => import("./ConversationGallery.js").then((module) => ({ default: module.ConversationGallery })));
|
|
44
|
+
/** Where the room's gallery opens for the view's pictures; the view mounts
|
|
45
|
+
* one around its rows. */
|
|
46
|
+
export function ConversationGalleryHost({ children, homeDir, onReceipt }) {
|
|
47
|
+
const [shown, setShown] = useState(null);
|
|
48
|
+
const open = useCallback((reader, fact, row) => setShown({ reader, fact, row }), []);
|
|
49
|
+
return (_jsxs(GalleryContext.Provider, { value: open, children: [children, shown !== null && (_jsx(Suspense, { fallback: null, children: _jsx(LazyGallery, { ...shown, homeDir: homeDir, onReceipt: onReceipt, onClose: () => setShown(null) }) }))] }));
|
|
50
|
+
}
|
|
51
|
+
/* ── one picture ─────────────────────────────────────────────────────────── */
|
|
52
|
+
function OnePicture({ fact, onOpen, words }) {
|
|
53
|
+
const reader = useAttachmentReader();
|
|
54
|
+
const resource = reader.imageResource(fact);
|
|
55
|
+
const [attempt, setAttempt] = useState(0);
|
|
56
|
+
const [failedUrl, setFailedUrl] = useState(null);
|
|
57
|
+
const { url, pending } = useImageUrl(resource, "preview", attempt);
|
|
58
|
+
const label = fact.ref?.label ?? "Image";
|
|
59
|
+
const failed = !pending && (url === null || failedUrl === url);
|
|
60
|
+
const style = fact.width !== null && fact.height !== null && fact.width > 0 && fact.height > 0
|
|
61
|
+
? { "--tr-conv-media-aspect": `${fact.width} / ${fact.height}` }
|
|
62
|
+
: undefined;
|
|
63
|
+
return (_jsx("figure", { className: "tr-conv-media", "data-count": "1", "data-attachment-id": fact.key, style: style, children: failed ? (_jsxs("div", { className: "tr-conv-media__missing", role: "status", children: [_jsx("span", { children: words.mediaFailed }), _jsx("button", { type: "button", onClick: () => { setFailedUrl(null); setAttempt((value) => value + 1); }, children: words.mediaRetry })] })) : (_jsx("button", { type: "button", className: "tr-conv-media__open", "aria-haspopup": "dialog", "aria-busy": pending, "aria-label": `Open ${label}${fact.name ? `, ${fact.name}` : ""}`, onClick: () => onOpen(fact), children: url !== null && _jsx("img", { src: url, alt: fact.name ?? label, decoding: "async", onError: () => setFailedUrl(url) }, url) })) }));
|
|
64
|
+
}
|
|
65
|
+
/* ── one video ───────────────────────────────────────────────────────────── */
|
|
66
|
+
/** A length in seconds as a clock: `0:07`, `12:30`, `1:02:03`; null when the
|
|
67
|
+
* element could not say (a recording that names no duration). */
|
|
68
|
+
export function lengthText(seconds) {
|
|
69
|
+
if (seconds === null || !Number.isFinite(seconds) || seconds <= 0)
|
|
70
|
+
return null;
|
|
71
|
+
const whole = Math.max(1, Math.round(seconds));
|
|
72
|
+
const h = Math.floor(whole / 3600);
|
|
73
|
+
const m = Math.floor((whole % 3600) / 60);
|
|
74
|
+
const s = String(whole % 60).padStart(2, "0");
|
|
75
|
+
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
76
|
+
}
|
|
77
|
+
function PlayGlyph() {
|
|
78
|
+
return (_jsxs("svg", { width: "32", height: "32", 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" })] }));
|
|
79
|
+
}
|
|
80
|
+
/** The host's address, asked at mount: a first frame, a length and a size
|
|
81
|
+
* before play, and the same element plays in place. */
|
|
82
|
+
function FirstFrame({ fact, asset, reader, onFallback, words }) {
|
|
83
|
+
const [url, setUrl] = useState(null);
|
|
84
|
+
const [phase, setPhase] = useState("idle");
|
|
85
|
+
const [length, setLength] = useState(null);
|
|
86
|
+
const element = useRef(null);
|
|
87
|
+
const fallback = useRef(onFallback);
|
|
88
|
+
fallback.current = onFallback;
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
let live = true;
|
|
91
|
+
let answer = null;
|
|
92
|
+
try {
|
|
93
|
+
answer = reader.mediaAssetUrl?.(asset) ?? null;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
answer = null;
|
|
97
|
+
}
|
|
98
|
+
Promise.resolve(answer).then((address) => {
|
|
99
|
+
if (!live)
|
|
100
|
+
return;
|
|
101
|
+
if (typeof address === "string" && address !== "")
|
|
102
|
+
setUrl(address);
|
|
103
|
+
else
|
|
104
|
+
fallback.current();
|
|
105
|
+
}, () => {
|
|
106
|
+
if (live)
|
|
107
|
+
fallback.current();
|
|
108
|
+
});
|
|
109
|
+
return () => {
|
|
110
|
+
live = false;
|
|
111
|
+
};
|
|
112
|
+
}, [asset.digest, reader]);
|
|
113
|
+
const name = fact.name?.trim() || fact.ref?.label || "Video";
|
|
114
|
+
const facts = [name, lengthText(length), fact.byteLen === null ? null : fmtBytes(fact.byteLen)].filter(Boolean).join(" · ");
|
|
115
|
+
const style = { "--tr-video-aspect": videoAspect(fact.width, fact.height).toFixed(4) };
|
|
116
|
+
const play = () => {
|
|
117
|
+
const video = element.current;
|
|
118
|
+
if (video === null)
|
|
119
|
+
return;
|
|
120
|
+
setPhase("ready");
|
|
121
|
+
video.play().catch(() => fallback.current());
|
|
122
|
+
};
|
|
123
|
+
return (_jsxs("figure", { className: "tr-conv-video", "data-video": phase, "data-attachment-id": fact.key, style: style, children: [_jsxs("div", { className: "tr-conv-video__stage", children: [url !== null && (_jsx("video", { ref: element, src: `${url}#t=0.001`, preload: "metadata", playsInline: true, controls: phase === "ready", "aria-label": name, onLoadedMetadata: (event) => setLength(event.currentTarget.duration), onLoadedData: () => setPhase((now) => (now === "idle" ? "frame" : now)), onError: () => fallback.current() })), phase !== "ready" && (_jsx("button", { type: "button", className: "tr-conv-video__play", "aria-label": `${words.mediaPlay}, ${facts}`, "aria-busy": phase === "idle", onClick: play, children: _jsx(PlayGlyph, {}) }))] }), _jsx("figcaption", { className: "tr-conv-video__facts", children: facts })] }));
|
|
124
|
+
}
|
|
125
|
+
/** The room's tile over its own load: nothing is asked until play. */
|
|
126
|
+
function Tile({ fact, asset, reader }) {
|
|
127
|
+
const [state, setState] = useState(IDLE_VIDEO);
|
|
128
|
+
const source = useRef(null);
|
|
129
|
+
const target = useRef(null);
|
|
130
|
+
const restoreFocus = useRef(false);
|
|
131
|
+
useEffect(() => () => {
|
|
132
|
+
source.current?.dispose();
|
|
133
|
+
source.current = null;
|
|
134
|
+
setState(IDLE_VIDEO);
|
|
135
|
+
}, [asset?.digest, reader]);
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
if (!restoreFocus.current)
|
|
138
|
+
return;
|
|
139
|
+
restoreFocus.current = false;
|
|
140
|
+
target.current?.focus({ preventScroll: true });
|
|
141
|
+
}, [state]);
|
|
142
|
+
const play = () => {
|
|
143
|
+
if (asset === null)
|
|
144
|
+
return;
|
|
145
|
+
restoreFocus.current = true;
|
|
146
|
+
source.current ??= createVideoSource(asset, {
|
|
147
|
+
mediaAssetUrl: reader.mediaAssetUrl,
|
|
148
|
+
readAsset: reader.readAsset,
|
|
149
|
+
createObjectURL: (bytes, mediaType) => URL.createObjectURL(new Blob([bytes], { type: mediaType })),
|
|
150
|
+
revokeObjectURL: (url) => URL.revokeObjectURL(url),
|
|
151
|
+
onChange: setState,
|
|
152
|
+
});
|
|
153
|
+
source.current.play();
|
|
154
|
+
};
|
|
155
|
+
const playable = asset !== null;
|
|
156
|
+
const phase = !playable ? "uncaptured" : state.phase === "loading" ? "idle" : state.phase;
|
|
157
|
+
return (_jsx("figure", { className: "tr-conv-video", "data-video": phase, "data-attachment-id": fact.key, children: _jsx(VideoFace, { fact: fact, index: 0, playable: playable, state: state, onPlay: play, onElementError: (url) => source.current?.elementFailed(url), focusRef: (element) => { target.current = element; } }) }));
|
|
158
|
+
}
|
|
159
|
+
function OneVideo({ fact, words }) {
|
|
160
|
+
const reader = useAttachmentReader();
|
|
161
|
+
const { assets } = useParts();
|
|
162
|
+
const asset = reader.videoAsset(fact);
|
|
163
|
+
const early = asset !== null && assets.mediaFirstFrame === true && reader.mediaAssetUrl !== undefined;
|
|
164
|
+
// A first frame needs the host's address; one that fails, or a host that
|
|
165
|
+
// answers none, is the tile from then on.
|
|
166
|
+
const [tile, setTile] = useState(false);
|
|
167
|
+
if (!early || tile || asset === null)
|
|
168
|
+
return _jsx(Tile, { fact: fact, asset: asset, reader: reader });
|
|
169
|
+
return _jsx(FirstFrame, { fact: fact, asset: asset, reader: reader, onFallback: () => setTile(true), words: words });
|
|
170
|
+
}
|
|
171
|
+
/** A press on one of `items`' pictures: the host's, else the room's gallery. */
|
|
172
|
+
function useMediaOpener(sessionId, items, facts, onOpenMedia) {
|
|
173
|
+
const reader = useAttachmentReader();
|
|
174
|
+
const gallery = useContext(GalleryContext);
|
|
175
|
+
return {
|
|
176
|
+
reader,
|
|
177
|
+
open(fact, row = facts) {
|
|
178
|
+
const item = items[facts.findIndex((each) => each.key === fact.key)];
|
|
179
|
+
if (onOpenMedia !== undefined) {
|
|
180
|
+
if (item !== undefined)
|
|
181
|
+
onOpenMedia({ sessionId, timelineId: item.timelineId, attachment: item.attachment });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (fact.kind === "image" && reader.canOpen(fact))
|
|
185
|
+
gallery?.(reader, fact, row);
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** Always the room's rail, however many: a prompt's own pictures. */
|
|
190
|
+
export function ConversationMediaRail({ sessionId, items, onOpenMedia }) {
|
|
191
|
+
const facts = items.map((item) => mediaFactOf(sessionId, item));
|
|
192
|
+
const { open } = useMediaOpener(sessionId, items, facts, onOpenMedia);
|
|
193
|
+
return facts.length === 0 ? null : _jsx(Attachments, { facts: facts, onOpenAttachment: open });
|
|
194
|
+
}
|
|
195
|
+
/** Draws nothing for no media. */
|
|
196
|
+
export function ConversationMediaList({ sessionId, items, onOpenMedia, words = MEDIA_LINES }) {
|
|
197
|
+
const facts = items.map((item) => mediaFactOf(sessionId, item));
|
|
198
|
+
const { reader, open } = useMediaOpener(sessionId, items, facts, onOpenMedia);
|
|
199
|
+
if (items.length === 0)
|
|
200
|
+
return null;
|
|
201
|
+
const [only] = facts;
|
|
202
|
+
if (facts.length === 1 && only !== undefined) {
|
|
203
|
+
if (only.kind === "image" && reader.imageResource(only) !== null) {
|
|
204
|
+
return _jsx(OnePicture, { fact: only, onOpen: (fact) => open(fact), words: words });
|
|
205
|
+
}
|
|
206
|
+
if (only.kind === "video")
|
|
207
|
+
return _jsx(OneVideo, { fact: only, words: words });
|
|
208
|
+
}
|
|
209
|
+
return (_jsx("figure", { className: "tr-conv-media", "data-count": facts.length, children: _jsx(Attachments, { facts: facts, onOpenAttachment: open }) }));
|
|
210
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/** What a reply's words take. */
|
|
3
|
+
export interface ConversationProseProps {
|
|
4
|
+
/** The reply's words, as markdown. */
|
|
5
|
+
readonly text: string;
|
|
6
|
+
/** What a link draws: `"open"` (the default, as the view's) a link the host
|
|
7
|
+
* opens, `"inert"` its words alone. A host passes the view's own `links`. */
|
|
8
|
+
readonly links?: "open" | "inert";
|
|
9
|
+
/** Told how a code bar's copy went ("Copied", or why not). Absent, nothing
|
|
10
|
+
* is said. */
|
|
11
|
+
readonly onReceipt?: (message: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function ConversationProse({ text, links, onReceipt }: ConversationProseProps): ReactElement;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Prose } from "../components/transcript/Prose.js";
|
|
3
|
+
const SAY_NOTHING = () => { };
|
|
4
|
+
export function ConversationProse({ text, links = "open", onReceipt = SAY_NOTHING }) {
|
|
5
|
+
return (_jsx("div", { className: "tr-prose ah-syntax tr-conv__prose", children: _jsx(Prose, { text: text, onReceipt: onReceipt, links: links }) }));
|
|
6
|
+
}
|