@vitrinka/web 0.3.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +118 -0
- package/README.md +93 -6
- package/build/hud.d.ts +4 -1
- package/build/hud.iife.js +46 -9
- package/build/one.iife.js +1 -0
- package/build/protocol/index.d.ts +55 -4
- package/build/protocol/index.js +4 -2
- package/build/recorder/RecorderProvider.js +48 -9
- package/build/recorder/api.d.ts +25 -5
- package/build/recorder/api.js +21 -9
- package/build/recorder/attachments.d.ts +19 -0
- package/build/recorder/attachments.js +31 -0
- package/build/recorder/capture/console.d.ts +2 -0
- package/build/recorder/capture/console.js +22 -2
- package/build/recorder/capture/nav.d.ts +13 -2
- package/build/recorder/capture/nav.js +49 -11
- package/build/recorder/capture/net.d.ts +2 -0
- package/build/recorder/capture/net.js +30 -4
- package/build/recorder/control.d.ts +17 -0
- package/build/recorder/control.js +39 -2
- package/build/recorder/hud/Hud.d.ts +1 -1
- package/build/recorder/hud/Hud.js +113 -30
- package/build/recorder/hud/RecorderPill.js +6 -2
- package/build/recorder/hud/Sheet.d.ts +40 -5
- package/build/recorder/hud/Sheet.js +134 -8
- package/build/recorder/hud/attach.d.ts +26 -0
- package/build/recorder/hud/attach.js +136 -0
- package/build/recorder/hud/chords.d.ts +10 -0
- package/build/recorder/hud/chords.js +34 -0
- package/build/recorder/hud/controller.d.ts +55 -3
- package/build/recorder/hud/controller.js +1 -1
- package/build/recorder/hud/flow.d.ts +22 -1
- package/build/recorder/hud/flow.js +16 -1
- package/build/recorder/hud/host.js +2 -0
- package/build/recorder/hud/icons.d.ts +3 -0
- package/build/recorder/hud/icons.js +7 -0
- package/build/recorder/hud/layer.d.ts +4 -1
- package/build/recorder/hud/layer.js +11 -3
- package/build/recorder/hud/resize.d.ts +83 -0
- package/build/recorder/hud/resize.js +236 -0
- package/build/recorder/hud/styles.d.ts +1 -1
- package/build/recorder/hud/styles.js +38 -1
- package/build/recorder/index.d.ts +1 -0
- package/build/recorder/index.js +1 -0
- package/build/recorder/lead.d.ts +90 -0
- package/build/recorder/lead.js +404 -0
- package/build/recorder/link.d.ts +4 -1
- package/build/recorder/link.js +6 -2
- package/build/recorder/me.d.ts +7 -0
- package/build/recorder/me.js +62 -12
- package/build/recorder/one-iife.d.ts +13 -0
- package/build/recorder/one-iife.js +13 -0
- package/build/recorder/one.d.ts +170 -0
- package/build/recorder/one.js +292 -0
- package/build/recorder/page-controller.js +26 -4
- package/build/recorder/queue.d.ts +33 -3
- package/build/recorder/queue.js +409 -26
- package/build/recorder/report.d.ts +9 -0
- package/build/recorder/report.js +55 -6
- package/build/recorder/session.d.ts +33 -7
- package/build/recorder/session.js +111 -31
- package/build/recorder/state.d.ts +9 -0
- package/build/recorder/state.js +7 -0
- package/build/recorder/storage/blobs.d.ts +32 -0
- package/build/recorder/storage/blobs.js +83 -0
- package/build/recorder/storage/index.js +3 -2
- package/build/recorder/version.d.ts +3 -0
- package/build/recorder/version.js +3 -0
- package/package.json +5 -3
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic control handle — `window.__vitrinkaRecorder`. The web sibling
|
|
3
|
+
* of the Expo recorder's devtools channel: an agent driving the page with
|
|
4
|
+
* Playwright can start a journey, drop notes and stop it without touching
|
|
5
|
+
* the HUD, and read a status snapshot back.
|
|
6
|
+
*
|
|
7
|
+
* ONE recorder: while the browser extension (or another recorder on the
|
|
8
|
+
* page) leads, `status()` names it (`leader`, `following`), `pause`, `stop`
|
|
9
|
+
* and `note` act on it, and `start` rejects with a `RecorderBusyError`
|
|
10
|
+
* (`code: 'recorder_busy'`).
|
|
11
|
+
*/
|
|
12
|
+
import { type Leader } from './lead';
|
|
1
13
|
import { type StartOptions } from './session';
|
|
2
14
|
export interface RecorderStatus {
|
|
15
|
+
/** A recording captures this document — this recorder's, or the leader's it follows. */
|
|
3
16
|
recording: boolean;
|
|
17
|
+
/** Who records: this page's recorder, or the one it follows. Absent = nobody. */
|
|
18
|
+
leader?: Leader;
|
|
19
|
+
/** Set while another recorder leads; pause, stop and note then act on it. */
|
|
20
|
+
following?: Leader;
|
|
4
21
|
sessionId?: string;
|
|
5
22
|
project?: string;
|
|
6
23
|
environment?: string;
|
|
@@ -3,17 +3,37 @@
|
|
|
3
3
|
* of the Expo recorder's devtools channel: an agent driving the page with
|
|
4
4
|
* Playwright can start a journey, drop notes and stop it without touching
|
|
5
5
|
* the HUD, and read a status snapshot back.
|
|
6
|
+
*
|
|
7
|
+
* ONE recorder: while the browser extension (or another recorder on the
|
|
8
|
+
* page) leads, `status()` names it (`leader`, `following`), `pause`, `stop`
|
|
9
|
+
* and `note` act on it, and `start` rejects with a `RecorderBusyError`
|
|
10
|
+
* (`code: 'recorder_busy'`).
|
|
6
11
|
*/
|
|
12
|
+
import { leadStatus, sendToLeader } from './lead';
|
|
7
13
|
import { getState, health } from './queue';
|
|
8
14
|
import { boardUrlOf } from './recents';
|
|
9
15
|
import { addNote, elapsedOf, startSession, stopSession, togglePause } from './session';
|
|
10
16
|
export function snapshot() {
|
|
17
|
+
const lead = leadStatus();
|
|
18
|
+
if (lead.following) {
|
|
19
|
+
// The leader's claim on this document (none when it records another tab).
|
|
20
|
+
const c = lead.claim && lead.claim.by === lead.following ? lead.claim : null;
|
|
21
|
+
const live = c !== null && c.state !== 'saved';
|
|
22
|
+
return {
|
|
23
|
+
recording: live,
|
|
24
|
+
leader: lead.following,
|
|
25
|
+
following: lead.following,
|
|
26
|
+
...(live && c.sessionId ? { sessionId: c.sessionId } : {}),
|
|
27
|
+
...(live ? { paused: c.state === 'paused' } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
11
30
|
const rec = getState();
|
|
12
31
|
if (!rec)
|
|
13
32
|
return { recording: false };
|
|
14
33
|
const h = health();
|
|
15
34
|
return {
|
|
16
35
|
recording: true,
|
|
36
|
+
leader: 'page',
|
|
17
37
|
sessionId: rec.sessionId,
|
|
18
38
|
project: rec.project,
|
|
19
39
|
environment: rec.environment,
|
|
@@ -34,19 +54,36 @@ export function installControl() {
|
|
|
34
54
|
const control = {
|
|
35
55
|
async start(opts = {}) {
|
|
36
56
|
// Idempotent: a second start must not orphan the first recording.
|
|
37
|
-
if (getState())
|
|
57
|
+
if (getState() && !leadStatus().following)
|
|
38
58
|
throw new Error('vitrinka: a session is already recording');
|
|
59
|
+
// Another recorder leading refuses here, before any network call (RecorderBusyError).
|
|
39
60
|
await startSession(opts);
|
|
40
61
|
return snapshot();
|
|
41
62
|
},
|
|
42
|
-
pause
|
|
63
|
+
async pause() {
|
|
64
|
+
if (!leadStatus().following)
|
|
65
|
+
return togglePause();
|
|
66
|
+
const was = snapshot().paused === true;
|
|
67
|
+
sendToLeader('pause');
|
|
68
|
+
return !was;
|
|
69
|
+
},
|
|
43
70
|
async stop() {
|
|
71
|
+
if (leadStatus().following) {
|
|
72
|
+
const captured = snapshot();
|
|
73
|
+
sendToLeader('stop');
|
|
74
|
+
return captured;
|
|
75
|
+
}
|
|
44
76
|
const captured = snapshot();
|
|
45
77
|
const done = await stopSession();
|
|
46
78
|
return { ...captured, boardUrl: boardUrlOf(done) ?? captured.boardUrl };
|
|
47
79
|
},
|
|
48
80
|
note(text) {
|
|
49
81
|
const t = text.trim();
|
|
82
|
+
if (leadStatus().following) {
|
|
83
|
+
if (!t)
|
|
84
|
+
throw new Error('vitrinka: note text is empty');
|
|
85
|
+
return sendToLeader('note', t);
|
|
86
|
+
}
|
|
50
87
|
if (!getState())
|
|
51
88
|
throw new Error('vitrinka: no session is recording');
|
|
52
89
|
if (!t)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* driven ONLY through a `HudController` (controller.ts) — the in-page
|
|
4
4
|
* recorder's, or another host's. Owns the dock (where the HUD rests), the
|
|
5
5
|
* pill's inline flows (flow.ts), the sheet (open/title/ctx/pick + the
|
|
6
|
-
* surviving draft) and where it opens, the ⋯ menu, the tooltip and details
|
|
6
|
+
* surviving draft and its images) and where it opens, the ⋯ menu, the tooltip and details
|
|
7
7
|
* floats, annotate mode, the bug report (its sheet, "Mark on screen" through
|
|
8
8
|
* annotate mode, its send flow), the keyboard shortcuts, the Esc-anywhere /
|
|
9
9
|
* click-outside close and the status line a screen reader hears while the
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* driven ONLY through a `HudController` (controller.ts) — the in-page
|
|
5
5
|
* recorder's, or another host's. Owns the dock (where the HUD rests), the
|
|
6
6
|
* pill's inline flows (flow.ts), the sheet (open/title/ctx/pick + the
|
|
7
|
-
* surviving draft) and where it opens, the ⋯ menu, the tooltip and details
|
|
7
|
+
* surviving draft and its images) and where it opens, the ⋯ menu, the tooltip and details
|
|
8
8
|
* floats, annotate mode, the bug report (its sheet, "Mark on screen" through
|
|
9
9
|
* annotate mode, its send flow), the keyboard shortcuts, the Esc-anywhere /
|
|
10
10
|
* click-outside close and the status line a screen reader hears while the
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, } from 'react';
|
|
14
14
|
import { createPortal } from 'react-dom';
|
|
15
15
|
import { AnnotateOverlay } from './AnnotateOverlay';
|
|
16
|
+
import { bindChords } from './chords';
|
|
16
17
|
import { flowReducer, NO_FLOW } from './flow';
|
|
17
18
|
import { createSheetHost, insideHud, sheetTarget } from './host';
|
|
18
19
|
import { anchoredLayer, hostOrigin, PHONE_QUERY, phoneLayer, restingBox, useFloat, useMedia, usePresence, useViewportTick, } from './layer';
|
|
@@ -21,6 +22,7 @@ import { listen } from './listen';
|
|
|
21
22
|
import { Menu } from './Menu';
|
|
22
23
|
import { alignFor, towardCentre } from './place';
|
|
23
24
|
import { RecorderPill } from './RecorderPill';
|
|
25
|
+
import { gripFor } from './resize';
|
|
24
26
|
import { Sheet } from './Sheet';
|
|
25
27
|
import { colOf, rowOf } from './spots';
|
|
26
28
|
import { fmtAgo, healthLine } from './status';
|
|
@@ -65,6 +67,12 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
65
67
|
const [sheet, setSheet] = useState(null);
|
|
66
68
|
const [draft, setDraft] = useState('');
|
|
67
69
|
const [reportDraft, setReportDraft] = useState('');
|
|
70
|
+
// The drafts' images survive a cancel like their text (canAttach only).
|
|
71
|
+
const [images, setImages] = useState([]);
|
|
72
|
+
const [reportImages, setReportImages] = useState([]);
|
|
73
|
+
// Images still preparing belong to the draft too: a sheet reopened mid-way waits for them.
|
|
74
|
+
const [preparing, setPreparing] = useState(0);
|
|
75
|
+
const [reportPreparing, setReportPreparing] = useState(0);
|
|
68
76
|
// Annotate mode is picking the report's mark (it returns to the report sheet).
|
|
69
77
|
const [marking, setMarking] = useState(false);
|
|
70
78
|
const markRef = useRef(null);
|
|
@@ -201,6 +209,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
201
209
|
return;
|
|
202
210
|
sent.then((res) => {
|
|
203
211
|
setReportDraft('');
|
|
212
|
+
setReportImages([]);
|
|
204
213
|
settle({ type: 'saved', ...res });
|
|
205
214
|
}, (e) => {
|
|
206
215
|
console.warn('vitrinka: report —', errorText(e));
|
|
@@ -212,6 +221,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
212
221
|
if (controller.getSnapshot().recording) {
|
|
213
222
|
controller.report?.(r).then(() => {
|
|
214
223
|
setReportDraft('');
|
|
224
|
+
setReportImages([]);
|
|
215
225
|
saidSaved();
|
|
216
226
|
}, (e) => console.warn('vitrinka: report —', errorText(e)));
|
|
217
227
|
return;
|
|
@@ -225,21 +235,30 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
225
235
|
setSheet(null);
|
|
226
236
|
if (!s)
|
|
227
237
|
return;
|
|
238
|
+
// Images ride only while the host takes them (a policy switched off mid-draft drops them).
|
|
239
|
+
const held = controller.getSnapshot().canAttach === true ? (s.report ? reportImages : images) : [];
|
|
240
|
+
const attachments = held.length ? { attachments: held } : {};
|
|
228
241
|
if (s.report) {
|
|
229
|
-
fileReport({ text, rect: s.pick?.rect ?? null, selector: s.pick?.selector ?? '' });
|
|
242
|
+
fileReport({ text, rect: s.pick?.rect ?? null, selector: s.pick?.selector ?? '', ...attachments });
|
|
230
243
|
return;
|
|
231
244
|
}
|
|
232
245
|
if (s.pick) {
|
|
233
|
-
controller.annotate({ text, rect: s.pick.rect, selector: s.pick.selector, task });
|
|
246
|
+
controller.annotate({ text, rect: s.pick.rect, selector: s.pick.selector, task, ...attachments });
|
|
234
247
|
setDraft('');
|
|
248
|
+
setImages([]);
|
|
235
249
|
saidSaved();
|
|
236
250
|
}
|
|
237
|
-
else if (text) {
|
|
238
|
-
|
|
251
|
+
else if (text || held.length) {
|
|
252
|
+
// An image can BE the note: text may be empty when it carries one.
|
|
253
|
+
if (held.length)
|
|
254
|
+
controller.note(text, held);
|
|
255
|
+
else
|
|
256
|
+
controller.note(text);
|
|
239
257
|
setDraft('');
|
|
258
|
+
setImages([]);
|
|
240
259
|
saidSaved();
|
|
241
260
|
}
|
|
242
|
-
}, [sheet, controller, saidSaved, fileReport]);
|
|
261
|
+
}, [sheet, controller, saidSaved, fileReport, images, reportImages]);
|
|
243
262
|
const onStart = useCallback(() => {
|
|
244
263
|
if (!controller.getSnapshot().linked) {
|
|
245
264
|
beginLink();
|
|
@@ -248,7 +267,11 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
248
267
|
setStarting(true);
|
|
249
268
|
controller
|
|
250
269
|
.start({ title: defaultTitle() })
|
|
251
|
-
.catch((e) =>
|
|
270
|
+
.catch((e) => {
|
|
271
|
+
// A refusal (another recorder leads, D12) or a failed create: the pill says why.
|
|
272
|
+
console.warn('vitrinka: start failed', e);
|
|
273
|
+
dispatch({ type: 'startFailed', message: errorText(e) });
|
|
274
|
+
})
|
|
252
275
|
.finally(() => setStarting(false));
|
|
253
276
|
}, [controller, defaultTitle, beginLink]);
|
|
254
277
|
onStartRef.current = onStart;
|
|
@@ -256,9 +279,18 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
256
279
|
void controller.togglePause();
|
|
257
280
|
}, [controller]);
|
|
258
281
|
// The inline flows. Stop drains first; a refusal (offline) keeps the session.
|
|
282
|
+
// One Stop at a time: a remote stop (D11) or a Retry arriving while a save
|
|
283
|
+
// is out never starts a second one; the flag clears as the face settles.
|
|
284
|
+
const stopInFlight = useRef(false);
|
|
259
285
|
const runStop = useCallback(() => {
|
|
286
|
+
if (stopInFlight.current)
|
|
287
|
+
return;
|
|
288
|
+
stopInFlight.current = true;
|
|
260
289
|
const t0 = Date.now();
|
|
261
|
-
const settle = (ev) => setTimeout(() =>
|
|
290
|
+
const settle = (ev) => setTimeout(() => {
|
|
291
|
+
stopInFlight.current = false;
|
|
292
|
+
dispatch(ev);
|
|
293
|
+
}, Math.max(0, MIN_SAVING_MS - (Date.now() - t0)));
|
|
262
294
|
controller.stop().then((r) => settle({ type: 'saved', ...r }), (e) => {
|
|
263
295
|
console.warn('vitrinka: stop —', errorText(e));
|
|
264
296
|
settle({ type: 'failed', message: errorText(e) });
|
|
@@ -299,6 +331,9 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
299
331
|
dispatch({ type: 'dismiss' });
|
|
300
332
|
}, [failedReport, controller]);
|
|
301
333
|
const onRetry = useCallback(() => {
|
|
334
|
+
// A refused Start has nothing to retry (and must never run a Stop).
|
|
335
|
+
if (flow.face === 'failed' && flow.start)
|
|
336
|
+
return;
|
|
302
337
|
if (failedReport) {
|
|
303
338
|
dispatch({ type: 'retry', queued: 0 });
|
|
304
339
|
if (reportRef.current)
|
|
@@ -307,7 +342,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
307
342
|
}
|
|
308
343
|
dispatch({ type: 'retry', queued: controller.getSnapshot().recording?.sync.queued ?? 0 });
|
|
309
344
|
runStop();
|
|
310
|
-
}, [failedReport, controller, runStop, runReport]);
|
|
345
|
+
}, [flow, failedReport, controller, runStop, runReport]);
|
|
311
346
|
// A stop confirm outlives nothing: the session ended under it (401, the server).
|
|
312
347
|
useEffect(() => {
|
|
313
348
|
if (!rec && flow.face === 'confirm' && flow.action === 'stop')
|
|
@@ -337,27 +372,57 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
337
372
|
void controller.getMe();
|
|
338
373
|
void controller.refreshRecents();
|
|
339
374
|
}, [menu, controller]);
|
|
340
|
-
//
|
|
341
|
-
|
|
342
|
-
//
|
|
375
|
+
// ONE recorder: another recorder leads and this HUD is its remote (D8).
|
|
376
|
+
const following = snap.following ?? null;
|
|
377
|
+
// Becoming the remote — or ceasing to be — leaves nothing open: the sheet,
|
|
378
|
+
// menu, link sheet and annotate mode close (the drafts and their images
|
|
379
|
+
// survive, as a cancel keeps them), and the pill comes back idle.
|
|
380
|
+
const wasFollowing = useRef(following);
|
|
343
381
|
useEffect(() => {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
382
|
+
if (wasFollowing.current === following)
|
|
383
|
+
return;
|
|
384
|
+
wasFollowing.current = following;
|
|
385
|
+
dispatch({ type: 'follow' });
|
|
386
|
+
if (!following)
|
|
387
|
+
return;
|
|
388
|
+
setSheet(null);
|
|
389
|
+
setMenu(false);
|
|
390
|
+
setMarking(false);
|
|
391
|
+
closeLink();
|
|
392
|
+
controller.setAnnotating(false);
|
|
393
|
+
}, [following, closeLink, controller]);
|
|
394
|
+
// A remote stop (D11) runs this HUD's own Stop flow: no second confirm.
|
|
395
|
+
const remoteStop = useRef(() => undefined);
|
|
396
|
+
remoteStop.current = () => {
|
|
397
|
+
setSheet(null);
|
|
398
|
+
setMenu(false);
|
|
399
|
+
setMarking(false);
|
|
400
|
+
controller.setAnnotating(false);
|
|
401
|
+
dispatch({ type: 'stop', queued: controller.getSnapshot().recording?.sync.queued ?? 0 });
|
|
402
|
+
runStop();
|
|
403
|
+
};
|
|
404
|
+
useEffect(() => controller.onRemoteStop?.(() => remoteStop.current()), [controller]);
|
|
405
|
+
// The controller holds its claim as `saved` while a stop's face shows (D7).
|
|
406
|
+
useEffect(() => {
|
|
407
|
+
controller.faceChanged?.(flow.face);
|
|
408
|
+
}, [flow.face, controller]);
|
|
409
|
+
useEffect(() => () => controller.faceChanged?.('none'), [controller]);
|
|
410
|
+
// Shortcuts (chords.ts): ⌥⇧A annotate · ⌥⇧N note · ⌥⇧P pause · ⌥⇧S stop —
|
|
411
|
+
// bound by the leader's HUD only (D9).
|
|
412
|
+
useEffect(() => {
|
|
413
|
+
if (following)
|
|
414
|
+
return;
|
|
415
|
+
return bindChords(window, (c) => {
|
|
416
|
+
if (c === 'annotate')
|
|
348
417
|
toggleAnnotate();
|
|
349
|
-
else if (
|
|
418
|
+
else if (c === 'note')
|
|
350
419
|
openNote();
|
|
351
|
-
else if (
|
|
420
|
+
else if (c === 'pause')
|
|
352
421
|
onPause();
|
|
353
|
-
else if (e.code === 'KeyS')
|
|
354
|
-
askStop();
|
|
355
422
|
else
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
return listen(window, 'keydown', key, { capture: true });
|
|
360
|
-
}, [toggleAnnotate, openNote, onPause, askStop]);
|
|
423
|
+
askStop();
|
|
424
|
+
});
|
|
425
|
+
}, [following, toggleAnnotate, openNote, onPause, askStop]);
|
|
361
426
|
// Esc anywhere and click-outside close the sheet (capture-phase, so the
|
|
362
427
|
// page's own dialog never sees the Esc that closed ours).
|
|
363
428
|
useEffect(() => {
|
|
@@ -440,8 +505,10 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
440
505
|
const layerOpen = sheet !== null || link !== null;
|
|
441
506
|
const vvTick = useViewportTick(layerOpen && phone);
|
|
442
507
|
// On desktop the placement is measured, so a viewport resize or a grown
|
|
443
|
-
// sheet (the textarea resizes) must place it again
|
|
508
|
+
// sheet (the textarea grows, the grip resizes) must place it again — the
|
|
509
|
+
// sheet's own report (onLayout) does it before that frame paints.
|
|
444
510
|
const [sizeTick, setSizeTick] = useState(0);
|
|
511
|
+
const placeAgain = useCallback(() => setSizeTick((n) => n + 1), []);
|
|
445
512
|
useEffect(() => {
|
|
446
513
|
if (!layerOpen || phone)
|
|
447
514
|
return;
|
|
@@ -456,14 +523,19 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
456
523
|
removeEventListener('resize', bump);
|
|
457
524
|
};
|
|
458
525
|
}, [layerOpen, phone, sheetP.mounted, linkP.mounted]);
|
|
459
|
-
const [layer, setLayer] = useState({
|
|
526
|
+
const [layer, setLayer] = useState({
|
|
527
|
+
style: {},
|
|
528
|
+
origin: 'bottom right',
|
|
529
|
+
side: 'top',
|
|
530
|
+
room: 0,
|
|
531
|
+
});
|
|
460
532
|
useLayoutEffect(() => {
|
|
461
533
|
const el = dock.ref.current;
|
|
462
534
|
if (!layerOpen || !el)
|
|
463
535
|
return;
|
|
464
536
|
const o = hostOrigin(sheet && portal ? portal.mount : hostMount);
|
|
465
537
|
if (phone) {
|
|
466
|
-
setLayer({ style: phoneLayer(o), origin: 'bottom center' });
|
|
538
|
+
setLayer({ style: phoneLayer(o), origin: 'bottom center', side: 'top', room: 0 });
|
|
467
539
|
return;
|
|
468
540
|
}
|
|
469
541
|
const pop = layerRef.current?.firstElementChild;
|
|
@@ -489,8 +561,16 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
489
561
|
if (rec)
|
|
490
562
|
lastRec.current = rec;
|
|
491
563
|
const detailRec = rec ?? lastRec.current;
|
|
492
|
-
const sheetEl = shownSheet && portal ? (_jsxs("div", { className: "hud", "data-size": snap.prefs.size, children: [portal.own ? _jsx("style", { children: HUD_CSS }) : null, _jsx("div", { ref: layerRef, className: layerCls, style: layer.style, children: _jsx(Sheet, { className: `${motionCls} ${sheetP.cls}`, origin: layer.origin, title: shownSheet.title, ctx: shownSheet.ctx, pick: shownSheet.pick !== null && !shownSheet.report, draft: shownSheet.report ? reportDraft : draft, onDraft: shownSheet.report ? setReportDraft : setDraft, onSend: onSend, onClose: closeSheet,
|
|
564
|
+
const sheetEl = shownSheet && portal ? (_jsxs("div", { className: "hud", "data-size": snap.prefs.size, children: [portal.own ? _jsx("style", { children: HUD_CSS }) : null, _jsx("div", { ref: layerRef, className: layerCls, style: layer.style, children: _jsx(Sheet, { className: `${motionCls} ${sheetP.cls}`, origin: layer.origin, title: shownSheet.title, ctx: shownSheet.ctx, pick: shownSheet.pick !== null && !shownSheet.report, draft: shownSheet.report ? reportDraft : draft, onDraft: shownSheet.report ? setReportDraft : setDraft, onSend: onSend, onClose: closeSheet, kind: shownSheet.report ? 'report' : shownSheet.pick ? 'annotation' : 'note',
|
|
565
|
+
// `|| 0`: a host's snapshot from before the sheet size lacks the fields.
|
|
566
|
+
sheetW: snap.prefs.sheetW || 0, sheetH: snap.prefs.sheetH || 0, room: layer.room,
|
|
567
|
+
// A phone's bottom sheet spans the viewport: its grip sizes the cap alone.
|
|
568
|
+
grip: gripFor(layer.side, align, phone ? 'y' : 'xy'), onResize: (sheetW, sheetH) => void controller.setPrefs({ sheetW, sheetH }), onLayout: placeAgain, ...(shownSheet.report
|
|
493
569
|
? { placeholder: 'What went wrong?', required: true, onMark: markOnScreen, marked: shownSheet.pick !== null }
|
|
570
|
+
: {}), ...(snap.canAttach === true
|
|
571
|
+
? shownSheet.report
|
|
572
|
+
? { images: reportImages, onImages: setReportImages, preparing: reportPreparing, onPreparing: setReportPreparing }
|
|
573
|
+
: { images, onImages: setImages, preparing, onPreparing: setPreparing }
|
|
494
574
|
: {}) }, shownSheet.report ? 'report' : 'note') })] })) : null;
|
|
495
575
|
// Stable phrases only: a live region re-announces on every text change.
|
|
496
576
|
const hs = rec?.sync.state ?? null;
|
|
@@ -509,5 +589,8 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
509
589
|
const dockAttrs = 'tuck' in place
|
|
510
590
|
? { 'data-tuck': place.tuck, style: { '--ty': String(place.y) } }
|
|
511
591
|
: { 'data-row': rowOf(place.spot), 'data-col': colOf(place.spot) };
|
|
512
|
-
|
|
592
|
+
// A remote shows nothing (D7: one pill per document) — except a refused
|
|
593
|
+
// Start's face, which says why the pill steps aside until it is dismissed.
|
|
594
|
+
const hidden = following !== null && !(flow.face === 'failed' && flow.start === true);
|
|
595
|
+
return (_jsxs("div", { ref: rootRef, className: "hud", "data-size": snap.prefs.size, "data-spot": 'spot' in place ? place.spot : undefined, ...(hidden ? { 'data-following': following, style: { display: 'none' } } : {}), children: [_jsx("style", { children: HUD_CSS }), annotating && (rec || marking) ? _jsx(AnnotateOverlay, { onPick: onPick, onCancel: cancelAnnotate }) : null, _jsx("div", { ref: dock.ref, className: dock.dragging ? 'dock dragging' : 'dock', ...dockAttrs, onClickCapture: dock.onClickCapture, children: _jsx(RecorderPill, { snap: snap, now: now, flow: flow, flash: flash, composing: sheet !== null, starting: starting, menuOpen: menu, place: place, dragging: dock.dragging, handle: dock.handle, pillRef: pillRef, onMove: dock.moveTo, onLink: beginLink, onStart: onStart, onPause: onPause, onNote: openNote, onAnnotate: toggleAnnotate, onMenu: toggleMenu, onAskStop: askStop, onConfirm: onConfirm, onCancel: onCancel, onRetry: onRetry, onDismiss: onDismiss }) }), menuP.mounted ? (_jsx(Menu, { snap: snap, now: now, place: place, className: `grow ${menuP.cls}`, menuRef: menuRef, onClose: () => setMenu(false), onMove: dock.moveTo, onSize: (size) => void controller.setPrefs({ size }), onVerbose: (verbose) => void controller.setPrefs({ verbose }), onAskUnlink: askUnlink, onLink: beginLink, ...(snap.canReport && controller.report ? { onReport: openReport } : {}) })) : null, _jsx(Tooltip, { root: rootRef, side: side, suppressed: dock.dragging || menu || layerOpen }), detailP.mounted && detailRec ? (_jsx("div", { ref: detailRef, className: ['float detail grow', detailP.cls, snap.prefs.verbose ? '' : 'line', line ? 'bad' : ''].filter(Boolean).join(' '), "data-e2e": "recorder-detail", "aria-hidden": "true", children: snap.prefs.verbose ? (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: "events" }), _jsx("dd", { children: detailRec.sync.events }), _jsx("dt", { children: "queue" }), _jsxs("dd", { children: [detailRec.sync.queued, detailRec.sync.chunks ? ` (${detailRec.sync.chunks} chunk${detailRec.sync.chunks === 1 ? '' : 's'})` : ''] }), _jsx("dt", { children: "last sync" }), _jsx("dd", { children: detailRec.sync.lastSyncAt === null ? '—' : `${fmtAgo(now - detailRec.sync.lastSyncAt)} · ${detailRec.sync.state}` }), _jsx("dt", { children: "server seq" }), _jsx("dd", { children: Math.max(0, detailRec.sync.serverMaxSeq) }), _jsx("dt", { children: "session" }), _jsx("dd", { children: detailRec.sessionId }), _jsx("dt", { children: "recorder" }), _jsx("dd", { children: snap.version })] }), line ? _jsx("div", { className: "warnline", children: line }) : null] })) : (line) })) : null, sheetEl && portal ? createPortal(sheetEl, portal.mount) : null, linkP.mounted && shownLink ? (_jsx("div", { ref: layerRef, className: layerCls, style: layer.style, children: _jsx(LinkSheet, { className: `${motionCls} ${linkP.cls}`, origin: layer.origin, phase: shownLink.phase, start: shownLink.flow?.start ?? null, error: shownLink.error, onRetry: beginLink, onClose: closeLink }) })) : null, _jsx("div", { className: "sr", role: "status", "aria-live": "polite", children: status })] }));
|
|
513
596
|
}
|
|
@@ -117,7 +117,10 @@ function SyncGlyph({ chip }) {
|
|
|
117
117
|
return _jsx(ArrowUpIcon, {});
|
|
118
118
|
}
|
|
119
119
|
/** "Couldn't save" in a few words; the full sentence rides the tooltip. */
|
|
120
|
-
function shortFailure(message, report) {
|
|
120
|
+
function shortFailure(message, report, start) {
|
|
121
|
+
// A refused Start (another recorder leads, D12) or one that failed.
|
|
122
|
+
if (start)
|
|
123
|
+
return /already recording|is recording|still saving/i.test(message) ? 'Already recording' : 'Couldn’t start';
|
|
121
124
|
const offline = /unreachable|offline|fetch|network/i.test(message);
|
|
122
125
|
if (report)
|
|
123
126
|
return offline ? 'Offline — not sent' : 'Couldn’t send';
|
|
@@ -309,7 +312,8 @@ export function RecorderPill(p) {
|
|
|
309
312
|
const failure = shownFlow.face === 'failed' ? shownFlow.message : '';
|
|
310
313
|
// A bug report's send: "Sending…", "Sent", "Couldn't send" — and it can always be retried.
|
|
311
314
|
const report = 'report' in shownFlow && shownFlow.report === true;
|
|
315
|
+
const startFailed = shownFlow.face === 'failed' && shownFlow.start === true;
|
|
312
316
|
return (_jsxs("div", { ref: p.pillRef, className: "pill glass", "data-e2e": "recorder-pill", "data-face": dataFace, "data-orient": orient, "data-state": state, "data-open": unfolded && face !== 'flow' ? '' : undefined, onPointerDown: onTouch, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKey, children: [_jsx(Seg, { on: face === 'idle', className: "s-idle", children: _jsxs("button", { ref: puckRef, type: "button", className: "puck", "data-state": unlinked ? 'unlinked' : p.starting ? 'busy' : 'ready', "aria-label": puckLabel, onClick: unlinked ? p.onLink : p.onStart, disabled: p.starting, ...p.handle, children: [_jsx("span", { className: "ring" }), _jsx("span", { className: "lab", "aria-hidden": "true", children: _jsx("span", { children: puckLabel }) })] }) }), _jsx(Seg, { on: face === 'idle' && unfolded, className: "s-more", children: _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "Recents \u00B7 settings", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) }) }), _jsx(Seg, { on: face === 'rec' || (confirming && rec !== null), className: "s-handle", children: _jsxs("button", { type: "button", className: "handle", "aria-label": "Recorder controls", "aria-expanded": unfolded && face === 'rec', onClick: toggle, ...p.handle, children: [_jsx("span", { className: "dot" }), _jsxs("span", { className: "clock", children: [_jsx(Seg, { on: !p.flash, className: "c-time", children: _jsx("span", { className: "time", children: shownRec ? fmtClock(elapsedOf(shownRec, p.now)) : '00:00' }) }), _jsx(Seg, { on: p.flash, className: "c-flash", children: _jsxs("span", { className: "flash", "data-e2e": "saved-flash", children: [_jsx(CheckIcon, {}), _jsx("span", { children: "Saved" })] }) })] })] }) }), _jsx(Seg, { on: face === 'rec' && unfolded, className: "s-tray", children: _jsxs("div", { className: "tools seg-row", children: [_jsx("span", { className: "sep" }), chip ? (_jsxs("span", { className: "sync", "data-kind": chip.kind, "data-tip": chip.title, role: "status", "aria-label": chip.title, "data-e2e": "sync-chip", children: [_jsx("span", { className: "swap", children: _jsx(SyncGlyph, { chip: chip }) }, `glyph-${chip.kind}`), _jsx("span", { className: "word swap", children: chip.label }, `word-${chip.label}`)] })) : null, _jsx("button", { type: "button", className: "tb b-pause", "aria-label": shownRec?.paused ? 'Resume' : 'Pause', "aria-keyshortcuts": "Alt+Shift+P", "data-tip": shownRec?.paused ? 'Resume' : 'Pause', "data-keys": `${MOD}P`, onClick: p.onPause, children: shownRec?.paused ? _jsx(PlayIcon, {}) : _jsx(PauseIcon, {}) }), _jsx("button", { type: "button", className: "tb b-note", "aria-label": "Note", "aria-keyshortcuts": "Alt+Shift+N", "data-tip": "Note", "data-keys": `${MOD}N`, onClick: p.onNote, children: _jsx(PencilIcon, {}) }), _jsx("button", { type: "button", className: annotating ? 'tb b-annotate on' : 'tb b-annotate', "aria-label": "Annotate", "aria-pressed": annotating, "aria-keyshortcuts": "Alt+Shift+A", "data-tip": "Annotate", "data-keys": `${MOD}A`, onClick: p.onAnnotate, children: _jsx(AnnotateIcon, {}) }), _jsx("button", { ref: stopRef, type: "button", className: "tb b-stop", "aria-label": "Stop", "aria-keyshortcuts": "Alt+Shift+S", "data-tip": "Stop & save", "data-keys": `${MOD}S`, onClick: p.onAskStop, children: _jsx(StopIcon, {}) }), _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "More", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'confirm', className: "s-confirm", children: _jsxs("div", { className: "flow confirm", role: "group", "aria-label": confirmAction === 'stop' ? 'Stop and save' : 'Unlink', children: [_jsx("span", { className: "q", children: confirmAction === 'stop' ? 'Stop & save?' : 'Unlink this device?' }), _jsx("button", { type: "button", className: "fb primary", onClick: p.onConfirm, children: confirmAction === 'stop' ? 'Stop' : 'Unlink' }), _jsx("button", { ref: keepRef, type: "button", className: "fb", onClick: p.onCancel, children: confirmAction === 'stop' ? 'Keep recording' : 'Cancel' })] }) }), _jsx(Seg, { on: p.flow.face === 'saving', className: "s-saving", children: _jsxs("div", { className: "flow saving", role: "status", "data-e2e": "saving", children: [_jsx(SpinnerIcon, {}), _jsx("span", { children: report ? 'Sending…' : 'Saving…' }), progress !== null && rec ? _jsxs("span", { className: "muted", children: [rec.sync.queued, " left"] }) : null, _jsx("span", { className: "bar-track", "data-indeterminate": progress === null ? '' : undefined, role: "progressbar", "aria-label": report ? 'Sending' : 'Saving', "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": progress === null ? undefined : Math.round(progress * 100), style: { '--p': String(progress ?? 0) }, children: _jsx("i", {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'saved', className: "s-saved", children: _jsxs("div", { className: "flow saved", "data-e2e": "saved", children: [_jsx("span", { className: "ok t-check", "data-state": flowShown === 'saved' ? 'in' : undefined, children: _jsx(CheckIcon, {}) }), _jsx("span", { children: report ? 'Sent' : 'Saved' }), savedUrl ? (_jsxs("a", { ref: (el) => {
|
|
313
317
|
savedRef.current = el;
|
|
314
|
-
}, className: "fb", href: savedUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open board ", _jsx(NewTabIcon, {})] })) : (_jsx("span", { className: "muted", children: "in Recents" })), _jsx("button", { ref: savedUrl ? undefined : (el) => void (savedRef.current = el), type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'failed', className: "s-failed", children: _jsxs("div", { className: "flow failed", role: "alert", "data-tip": failure, children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { className: "msg", children: shortFailure(failure, report) }), rec || report ? (_jsx("button", { type: "button", className: "fb", onClick: p.onRetry, children: "Retry" })) : null, _jsx("button", { type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) })] }));
|
|
318
|
+
}, className: "fb", href: savedUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open board ", _jsx(NewTabIcon, {})] })) : (_jsx("span", { className: "muted", children: "in Recents" })), _jsx("button", { ref: savedUrl ? undefined : (el) => void (savedRef.current = el), type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'failed', className: "s-failed", children: _jsxs("div", { className: "flow failed", role: "alert", "data-tip": failure, children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { className: "msg", children: shortFailure(failure, report, startFailed) }), _jsx("span", { className: "sr", children: failure }), (rec || report) && !startFailed ? (_jsx("button", { type: "button", className: "fb", onClick: p.onRetry, children: "Retry" })) : null, _jsx("button", { type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) })] }));
|
|
315
319
|
}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The composer sheet — the extension's hud.html, as a component:
|
|
3
|
-
* anchored to the dock (a bottom sheet on phones), a 14px textarea
|
|
4
|
-
* touch, so iOS never zooms)
|
|
2
|
+
* The composer sheet — the extension's hud.html, as a component: 440px wide
|
|
3
|
+
* by default, anchored to the dock (a bottom sheet on phones), a 14px textarea
|
|
4
|
+
* (16px on touch, so iOS never zooms) that grows with the draft up to a cap
|
|
5
|
+
* and then scrolls, a resize grip on the corner away from the dock (width
|
|
6
|
+
* and cap are HUD prefs — resize.ts), ✕ in the title row, a three-column footer
|
|
5
7
|
* (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
|
|
6
8
|
* cancels. The DRAFT is owned by the caller so a cancel keeps it until the
|
|
7
9
|
* next send (recorder-hud-polish D3); the board|task choice resets on every
|
|
8
10
|
* open — a destination is per observation, not a mode. The bug report is the
|
|
9
11
|
* same sheet: a required description and "Mark on screen" in the board|task
|
|
10
12
|
* slot.
|
|
13
|
+
*
|
|
14
|
+
* Images (recorder attachments), only when the caller passes `images`: the
|
|
15
|
+
* paperclip beside Send picks them, an image paste on the textarea and a
|
|
16
|
+
* drop onto the sheet add them (attach.ts normalizes each), a strip of
|
|
17
|
+
* thumbnails above the footer removes them, at most `MAX_ATTACHMENTS`. Like
|
|
18
|
+
* the text, the caller owns them — and the count still preparing — so a
|
|
19
|
+
* cancel keeps them and a reopened sheet still waits. A refusal (not an
|
|
20
|
+
* image, the cap) shows in the footer's context slot — one line, so the
|
|
21
|
+
* footer never moves.
|
|
11
22
|
*/
|
|
12
|
-
import { type ReactElement } from 'react';
|
|
23
|
+
import { type Dispatch, type ReactElement, type SetStateAction } from 'react';
|
|
24
|
+
import type { HudAttachment } from './controller';
|
|
25
|
+
import { type Grip } from './resize';
|
|
13
26
|
export interface SheetProps {
|
|
14
27
|
/** Presence classes (`grow`/`rise` + `is-open`/`is-closing`). */
|
|
15
28
|
className: string;
|
|
@@ -30,5 +43,27 @@ export interface SheetProps {
|
|
|
30
43
|
onMark?: () => void;
|
|
31
44
|
/** Something is marked (the button reads pressed). */
|
|
32
45
|
marked?: boolean;
|
|
46
|
+
/** The draft's images; absent = the host takes none (no paperclip, paste or drop). */
|
|
47
|
+
images?: readonly HudAttachment[];
|
|
48
|
+
onImages?: Dispatch<SetStateAction<readonly HudAttachment[]>>;
|
|
49
|
+
/**
|
|
50
|
+
* The draft's files still being normalized; Send waits for them. Owned
|
|
51
|
+
* with the images, so a sheet closed and reopened mid-way still waits.
|
|
52
|
+
*/
|
|
53
|
+
preparing?: number;
|
|
54
|
+
onPreparing?: Dispatch<SetStateAction<number>>;
|
|
55
|
+
/** What it composes — names the grip ("Resize note"). */
|
|
56
|
+
kind?: 'note' | 'annotation' | 'report';
|
|
57
|
+
/** The size prefs, CSS px (0 = the default): the width, and the cap the text box grows to. */
|
|
58
|
+
sheetW?: number;
|
|
59
|
+
sheetH?: number;
|
|
60
|
+
/** The tallest the sheet may stand where it opens (viewport px); 0 = the viewport. */
|
|
61
|
+
room?: number;
|
|
62
|
+
/** The corner the resize grip sits on and what it sizes; absent = no grip. */
|
|
63
|
+
grip?: Grip | null;
|
|
64
|
+
/** A resize ended (once per drag or key-up): persist the new size; 0, 0 = the default. */
|
|
65
|
+
onResize?: (sheetW: number, sheetH: number) => void;
|
|
66
|
+
/** The sheet's box changed size: place it again before it paints. */
|
|
67
|
+
onLayout?: () => void;
|
|
33
68
|
}
|
|
34
|
-
export declare function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder, required, onMark, marked, }: SheetProps): ReactElement;
|
|
69
|
+
export declare function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder, required, onMark, marked, images, onImages, preparing: busy, onPreparing, kind, sheetW, sheetH, room, grip, onResize, onLayout, }: SheetProps): ReactElement;
|