@vitrinka/web 0.2.1 → 0.3.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 +44 -0
- package/README.md +49 -7
- package/build/hud.d.ts +1 -1
- package/build/hud.iife.js +9 -8
- package/build/recorder/RecorderProvider.d.ts +2 -1
- package/build/recorder/RecorderProvider.js +18 -4
- package/build/recorder/capture/click.d.ts +6 -0
- package/build/recorder/capture/click.js +15 -4
- package/build/recorder/capture/net.js +16 -10
- package/build/recorder/capture/redact.d.ts +11 -0
- package/build/recorder/capture/redact.js +18 -13
- package/build/recorder/capture/rrweb.d.ts +7 -1
- package/build/recorder/capture/rrweb.js +23 -7
- package/build/recorder/capture/selector.d.ts +7 -1
- package/build/recorder/capture/selector.js +14 -4
- package/build/recorder/config.d.ts +6 -0
- package/build/recorder/config.js +1 -0
- package/build/recorder/flight.d.ts +63 -0
- package/build/recorder/flight.js +93 -0
- package/build/recorder/hud/Hud.d.ts +2 -1
- package/build/recorder/hud/Hud.js +113 -11
- package/build/recorder/hud/Menu.d.ts +4 -2
- package/build/recorder/hud/Menu.js +2 -2
- package/build/recorder/hud/RecorderPill.d.ts +2 -1
- package/build/recorder/hud/RecorderPill.js +11 -5
- package/build/recorder/hud/Sheet.d.ts +11 -2
- package/build/recorder/hud/Sheet.js +13 -4
- package/build/recorder/hud/controller.d.ts +29 -0
- package/build/recorder/hud/flow.d.ts +13 -3
- package/build/recorder/hud/flow.js +17 -6
- package/build/recorder/hud/icons.d.ts +1 -0
- package/build/recorder/hud/icons.js +3 -0
- package/build/recorder/hud/styles.d.ts +1 -1
- package/build/recorder/hud/styles.js +1 -0
- package/build/recorder/index.d.ts +5 -0
- package/build/recorder/index.js +9 -1
- package/build/recorder/page-controller.js +4 -0
- package/build/recorder/queue.d.ts +11 -4
- package/build/recorder/queue.js +15 -8
- package/build/recorder/report.d.ts +36 -0
- package/build/recorder/report.js +250 -0
- package/build/recorder/session.d.ts +12 -2
- package/build/recorder/session.js +25 -12
- package/package.json +2 -2
|
@@ -5,7 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
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
7
|
* surviving draft) and where it opens, the ⋯ menu, the tooltip and details
|
|
8
|
-
* floats, annotate mode, the
|
|
8
|
+
* floats, annotate mode, the bug report (its sheet, "Mark on screen" through
|
|
9
|
+
* annotate mode, its send flow), the keyboard shortcuts, the Esc-anywhere /
|
|
9
10
|
* click-outside close and the status line a screen reader hears while the
|
|
10
11
|
* pill is folded.
|
|
11
12
|
*/
|
|
@@ -26,6 +27,21 @@ import { fmtAgo, healthLine } from './status';
|
|
|
26
27
|
import { HUD_CSS } from './styles';
|
|
27
28
|
import { Tooltip } from './Tooltip';
|
|
28
29
|
import { useDock } from './useDock';
|
|
30
|
+
/** What a pick names in the sheet's context line. */
|
|
31
|
+
function pickCtx(pick) {
|
|
32
|
+
return pick.selector
|
|
33
|
+
? `${pick.selector} · ${location.pathname}`
|
|
34
|
+
: `${Math.round(pick.rect.w)}×${Math.round(pick.rect.h)} · ${location.pathname}`;
|
|
35
|
+
}
|
|
36
|
+
/** The bug report sheet: the mark (null = the whole viewport) and what the report carries. */
|
|
37
|
+
function reportSheet(mark, recording) {
|
|
38
|
+
return {
|
|
39
|
+
title: 'Report a bug',
|
|
40
|
+
ctx: mark ? pickCtx(mark) : `${recording ? 'this recording' : 'last minute'} · ${location.pathname}`,
|
|
41
|
+
pick: mark,
|
|
42
|
+
report: true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
29
45
|
/** "Saving…" stays at least this long, so a fast save still reads as one. */
|
|
30
46
|
const MIN_SAVING_MS = 700;
|
|
31
47
|
/** How long the clock says "Saved" after a note or annotation. */
|
|
@@ -48,6 +64,11 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
48
64
|
const rec = snap.recording;
|
|
49
65
|
const [sheet, setSheet] = useState(null);
|
|
50
66
|
const [draft, setDraft] = useState('');
|
|
67
|
+
const [reportDraft, setReportDraft] = useState('');
|
|
68
|
+
// Annotate mode is picking the report's mark (it returns to the report sheet).
|
|
69
|
+
const [marking, setMarking] = useState(false);
|
|
70
|
+
const markRef = useRef(null);
|
|
71
|
+
const reportRef = useRef(null);
|
|
51
72
|
const [starting, setStarting] = useState(false);
|
|
52
73
|
const [menu, setMenu] = useState(false);
|
|
53
74
|
const [flow, dispatch] = useReducer(flowReducer, NO_FLOW);
|
|
@@ -119,16 +140,44 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
119
140
|
return;
|
|
120
141
|
setSheet(null);
|
|
121
142
|
setMenu(false);
|
|
143
|
+
setMarking(false);
|
|
122
144
|
controller.setAnnotating(!s.annotating);
|
|
123
145
|
}, [controller]);
|
|
124
146
|
const onPick = useCallback((pick) => {
|
|
125
147
|
controller.setAnnotating(false);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
148
|
+
if (marking) {
|
|
149
|
+
setMarking(false);
|
|
150
|
+
setSheet(reportSheet(pick, controller.getSnapshot().recording !== null));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
setSheet({ title: pick.selector ? 'Annotate element' : 'Annotate region', ctx: pickCtx(pick), pick });
|
|
154
|
+
}, [controller, marking]);
|
|
155
|
+
const cancelAnnotate = useCallback(() => {
|
|
156
|
+
controller.setAnnotating(false);
|
|
157
|
+
if (!marking)
|
|
158
|
+
return;
|
|
159
|
+
// Back to the report as it was (its earlier mark, if any).
|
|
160
|
+
setMarking(false);
|
|
161
|
+
setSheet(reportSheet(markRef.current, controller.getSnapshot().recording !== null));
|
|
162
|
+
}, [controller, marking]);
|
|
163
|
+
// "Report a bug" (⋯ menu): idle, the last minute is frozen as the sheet opens.
|
|
164
|
+
const openReport = useCallback(() => {
|
|
165
|
+
const s = controller.getSnapshot();
|
|
166
|
+
if (!s.canReport || !controller.report)
|
|
167
|
+
return;
|
|
168
|
+
setMenu(false);
|
|
169
|
+
setMarking(false);
|
|
170
|
+
controller.setAnnotating(false);
|
|
171
|
+
controller.holdReport?.(true);
|
|
172
|
+
setSheet(reportSheet(null, s.recording !== null));
|
|
130
173
|
}, [controller]);
|
|
131
|
-
|
|
174
|
+
// "Mark on screen": the sheet steps aside (draft and frozen clip kept) for annotate mode.
|
|
175
|
+
const markOnScreen = useCallback(() => {
|
|
176
|
+
markRef.current = sheet?.pick ?? null;
|
|
177
|
+
setSheet(null);
|
|
178
|
+
setMarking(true);
|
|
179
|
+
controller.setAnnotating(true);
|
|
180
|
+
}, [sheet, controller]);
|
|
132
181
|
const flashTimer = useRef(undefined);
|
|
133
182
|
const saidSaved = useCallback(() => {
|
|
134
183
|
clearTimeout(flashTimer.current);
|
|
@@ -136,11 +185,50 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
136
185
|
flashTimer.current = setTimeout(() => setFlash(false), FLASH_MS);
|
|
137
186
|
}, []);
|
|
138
187
|
useEffect(() => () => clearTimeout(flashTimer.current), []);
|
|
188
|
+
// The frozen last minute lives while the report is composed (sheet open or
|
|
189
|
+
// marking); any other close drops it. A send already took it.
|
|
190
|
+
const composingReport = sheet?.report === true || marking;
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (!composingReport)
|
|
193
|
+
controller.holdReport?.(false);
|
|
194
|
+
}, [composingReport, controller]);
|
|
195
|
+
// Idle, a report is its own short session: the pill says Sending…, then Sent · Open board.
|
|
196
|
+
const runReport = useCallback((r) => {
|
|
197
|
+
const t0 = Date.now();
|
|
198
|
+
const settle = (ev) => setTimeout(() => dispatch(ev), Math.max(0, MIN_SAVING_MS - (Date.now() - t0)));
|
|
199
|
+
const sent = controller.report?.(r);
|
|
200
|
+
if (!sent)
|
|
201
|
+
return;
|
|
202
|
+
sent.then((res) => {
|
|
203
|
+
setReportDraft('');
|
|
204
|
+
settle({ type: 'saved', ...(res.boardUrl ? { boardUrl: res.boardUrl } : {}) });
|
|
205
|
+
}, (e) => {
|
|
206
|
+
console.warn('vitrinka: report —', errorText(e));
|
|
207
|
+
settle({ type: 'failed', message: errorText(e) });
|
|
208
|
+
});
|
|
209
|
+
}, [controller]);
|
|
210
|
+
const fileReport = useCallback((r) => {
|
|
211
|
+
// Recording: a task annotation in the session — the clock says Saved.
|
|
212
|
+
if (controller.getSnapshot().recording) {
|
|
213
|
+
controller.report?.(r).then(() => {
|
|
214
|
+
setReportDraft('');
|
|
215
|
+
saidSaved();
|
|
216
|
+
}, (e) => console.warn('vitrinka: report —', errorText(e)));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
reportRef.current = r;
|
|
220
|
+
dispatch({ type: 'send' });
|
|
221
|
+
runReport(r);
|
|
222
|
+
}, [controller, runReport, saidSaved]);
|
|
139
223
|
const onSend = useCallback((text, task) => {
|
|
140
224
|
const s = sheet;
|
|
141
225
|
setSheet(null);
|
|
142
226
|
if (!s)
|
|
143
227
|
return;
|
|
228
|
+
if (s.report) {
|
|
229
|
+
fileReport({ text, rect: s.pick?.rect ?? null, selector: s.pick?.selector ?? '' });
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
144
232
|
if (s.pick) {
|
|
145
233
|
controller.annotate({ text, rect: s.pick.rect, selector: s.pick.selector, task });
|
|
146
234
|
setDraft('');
|
|
@@ -151,7 +239,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
151
239
|
setDraft('');
|
|
152
240
|
saidSaved();
|
|
153
241
|
}
|
|
154
|
-
}, [sheet, controller, saidSaved]);
|
|
242
|
+
}, [sheet, controller, saidSaved, fileReport]);
|
|
155
243
|
const onStart = useCallback(() => {
|
|
156
244
|
if (!controller.getSnapshot().linked) {
|
|
157
245
|
beginLink();
|
|
@@ -203,11 +291,23 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
203
291
|
controller.unlink();
|
|
204
292
|
}, [flow, controller, runStop, closeLink]);
|
|
205
293
|
const onCancel = useCallback(() => dispatch({ type: 'cancel' }), []);
|
|
206
|
-
const
|
|
294
|
+
const failedReport = flow.face === 'failed' && flow.report === true;
|
|
295
|
+
const onDismiss = useCallback(() => {
|
|
296
|
+
// A report not sent is dropped with its failure.
|
|
297
|
+
if (failedReport)
|
|
298
|
+
controller.holdReport?.(false);
|
|
299
|
+
dispatch({ type: 'dismiss' });
|
|
300
|
+
}, [failedReport, controller]);
|
|
207
301
|
const onRetry = useCallback(() => {
|
|
302
|
+
if (failedReport) {
|
|
303
|
+
dispatch({ type: 'retry', queued: 0 });
|
|
304
|
+
if (reportRef.current)
|
|
305
|
+
runReport(reportRef.current);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
208
308
|
dispatch({ type: 'retry', queued: controller.getSnapshot().recording?.sync.queued ?? 0 });
|
|
209
309
|
runStop();
|
|
210
|
-
}, [controller, runStop]);
|
|
310
|
+
}, [failedReport, controller, runStop, runReport]);
|
|
211
311
|
// A stop confirm outlives nothing: the session ended under it (401, the server).
|
|
212
312
|
useEffect(() => {
|
|
213
313
|
if (!rec && flow.face === 'confirm' && flow.action === 'stop')
|
|
@@ -389,7 +489,9 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
389
489
|
if (rec)
|
|
390
490
|
lastRec.current = rec;
|
|
391
491
|
const detailRec = rec ?? lastRec.current;
|
|
392
|
-
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, draft: draft, onDraft: setDraft, onSend: onSend, onClose: closeSheet
|
|
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, ...(shownSheet.report
|
|
493
|
+
? { placeholder: 'What went wrong?', required: true, onMark: markOnScreen, marked: shownSheet.pick !== null }
|
|
494
|
+
: {}) }, shownSheet.report ? 'report' : 'note') })] })) : null;
|
|
393
495
|
// Stable phrases only: a live region re-announces on every text change.
|
|
394
496
|
const hs = rec?.sync.state ?? null;
|
|
395
497
|
const status = !rec
|
|
@@ -407,5 +509,5 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
407
509
|
const dockAttrs = 'tuck' in place
|
|
408
510
|
? { 'data-tuck': place.tuck, style: { '--ty': String(place.y) } }
|
|
409
511
|
: { 'data-row': rowOf(place.spot), 'data-col': colOf(place.spot) };
|
|
410
|
-
return (_jsxs("div", { ref: rootRef, className: "hud", "data-size": snap.prefs.size, "data-spot": 'spot' in place ? place.spot : undefined, children: [_jsx("style", { children: HUD_CSS }), annotating && rec ? _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 })) : 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 })] }));
|
|
512
|
+
return (_jsxs("div", { ref: rootRef, className: "hud", "data-size": snap.prefs.size, "data-spot": 'spot' in place ? place.spot : undefined, 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 })] }));
|
|
411
513
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The ⋯ menu: who the recorder is linked as, the open board,
|
|
3
|
-
* recent recordings and "Go to vitrinka", then the HUD's own settings —
|
|
2
|
+
* The ⋯ menu: who the recorder is linked as, "Report a bug", the open board,
|
|
3
|
+
* the device's recent recordings and "Go to vitrinka", then the HUD's own settings —
|
|
4
4
|
* size, verbose details, position (a miniature screen of the eight spots) —
|
|
5
5
|
* and Unlink. A fixed float placed beside the dock by the caller; ↑/↓ move
|
|
6
6
|
* between items, Esc closes.
|
|
@@ -26,5 +26,7 @@ export interface MenuProps {
|
|
|
26
26
|
onVerbose: (on: boolean) => void;
|
|
27
27
|
onAskUnlink: () => void;
|
|
28
28
|
onLink: () => void;
|
|
29
|
+
/** Opens the bug report sheet; the row shows only when set. */
|
|
30
|
+
onReport?: () => void;
|
|
29
31
|
}
|
|
30
32
|
export declare function Menu(p: MenuProps): ReactElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { HomeIcon, NewTabIcon, UnlinkIcon } from './icons';
|
|
2
|
+
import { BugIcon, HomeIcon, NewTabIcon, UnlinkIcon } from './icons';
|
|
3
3
|
import { isVertical, SPOT_NAMES, SPOTS } from './spots';
|
|
4
4
|
import { fmtAgo, fmtDuration } from './status';
|
|
5
5
|
const SIZES = [
|
|
@@ -48,7 +48,7 @@ export function Menu(p) {
|
|
|
48
48
|
p.onClose();
|
|
49
49
|
fn();
|
|
50
50
|
};
|
|
51
|
-
return (_jsxs("div", { ref: p.menuRef, className: `float menu ${p.className}`, role: "menu", "aria-label": "Recorder", "data-e2e": "recorder-menu", onKeyDown: onKey, children: [_jsxs("div", { className: "m-head", "data-e2e": "menu-account", children: [_jsxs("div", { className: snap.account?.kind === 'key' ? 'm-who wraps' : 'm-who', children: [_jsx("span", { className: "email", children: lines.who }), lines.ws ? _jsxs("span", { className: "ws", children: ["\u00B7 ", lines.ws] }) : null] }), _jsxs("div", { className: "m-sub", children: [rec ? _jsx("span", { className: "live", children: "\u25CF recording \u00B7 " }) : null, lines.sub] })] }), !snap.linked ? (_jsx("button", { type: "button", role: "menuitem", className: "mi", onClick: act(p.onLink), children: _jsx("span", { children: "Link recorder" }) })) : null, rec?.boardUrl ? (_jsxs("a", { role: "menuitem", className: "mi", href: rec.boardUrl, target: "_blank", rel: "noopener noreferrer", onClick: p.onClose, children: [_jsx(NewTabIcon, {}), " Open this board"] })) : null, _jsx("div", { className: "m-rule" }), _jsx("div", { className: "m-label", "aria-hidden": "true", children: "Recent" }), snap.recents.length === 0 ? _jsx("div", { className: "m-empty", children: "No recordings on this device yet" }) : null, snap.recents.map((r) => {
|
|
51
|
+
return (_jsxs("div", { ref: p.menuRef, className: `float menu ${p.className}`, role: "menu", "aria-label": "Recorder", "data-e2e": "recorder-menu", onKeyDown: onKey, children: [_jsxs("div", { className: "m-head", "data-e2e": "menu-account", children: [_jsxs("div", { className: snap.account?.kind === 'key' ? 'm-who wraps' : 'm-who', children: [_jsx("span", { className: "email", children: lines.who }), lines.ws ? _jsxs("span", { className: "ws", children: ["\u00B7 ", lines.ws] }) : null] }), _jsxs("div", { className: "m-sub", children: [rec ? _jsx("span", { className: "live", children: "\u25CF recording \u00B7 " }) : null, lines.sub] })] }), !snap.linked ? (_jsx("button", { type: "button", role: "menuitem", className: "mi", onClick: act(p.onLink), children: _jsx("span", { children: "Link recorder" }) })) : null, p.onReport ? (_jsxs("button", { type: "button", role: "menuitem", className: "mi", onClick: act(p.onReport), children: [_jsx(BugIcon, {}), " Report a bug"] })) : null, rec?.boardUrl ? (_jsxs("a", { role: "menuitem", className: "mi", href: rec.boardUrl, target: "_blank", rel: "noopener noreferrer", onClick: p.onClose, children: [_jsx(NewTabIcon, {}), " Open this board"] })) : null, _jsx("div", { className: "m-rule" }), _jsx("div", { className: "m-label", "aria-hidden": "true", children: "Recent" }), snap.recents.length === 0 ? _jsx("div", { className: "m-empty", children: "No recordings on this device yet" }) : null, snap.recents.map((r) => {
|
|
52
52
|
const live = rec?.sessionId === r.sessionId;
|
|
53
53
|
const meta = [
|
|
54
54
|
live ? 'now' : fmtAgo(p.now - r.startedAt),
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* vertical pill (a measured morph, see useMorph).
|
|
11
11
|
* - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
|
|
12
12
|
* device?", spins while saving, says "Saved · Open board" until dismissed,
|
|
13
|
-
* or says why it could not save
|
|
13
|
+
* or says why it could not save (a bug report: "Sending…", "Sent",
|
|
14
|
+
* "Couldn't send"). Always horizontal.
|
|
14
15
|
* - Tucked: a 6px edge tab.
|
|
15
16
|
* The handle, the puck and the tab are the drag handles. Tooltips are
|
|
16
17
|
* `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
|
|
@@ -11,7 +11,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
* vertical pill (a measured morph, see useMorph).
|
|
12
12
|
* - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
|
|
13
13
|
* device?", spins while saving, says "Saved · Open board" until dismissed,
|
|
14
|
-
* or says why it could not save
|
|
14
|
+
* or says why it could not save (a bug report: "Sending…", "Sent",
|
|
15
|
+
* "Couldn't send"). Always horizontal.
|
|
15
16
|
* - Tucked: a 6px edge tab.
|
|
16
17
|
* The handle, the puck and the tab are the drag handles. Tooltips are
|
|
17
18
|
* `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
|
|
@@ -116,8 +117,11 @@ function SyncGlyph({ chip }) {
|
|
|
116
117
|
return _jsx(ArrowUpIcon, {});
|
|
117
118
|
}
|
|
118
119
|
/** "Couldn't save" in a few words; the full sentence rides the tooltip. */
|
|
119
|
-
function shortFailure(message) {
|
|
120
|
-
|
|
120
|
+
function shortFailure(message, report) {
|
|
121
|
+
const offline = /unreachable|offline|fetch|network/i.test(message);
|
|
122
|
+
if (report)
|
|
123
|
+
return offline ? 'Offline — not sent' : 'Couldn’t send';
|
|
124
|
+
if (offline)
|
|
121
125
|
return 'Offline — kept here';
|
|
122
126
|
if (/ended locally|rejected/i.test(message))
|
|
123
127
|
return 'Ended by the server';
|
|
@@ -295,7 +299,9 @@ export function RecorderPill(p) {
|
|
|
295
299
|
const confirmAction = shownFlow.face === 'confirm' ? shownFlow.action : 'stop';
|
|
296
300
|
const savedUrl = shownFlow.face === 'saved' ? shownFlow.boardUrl : undefined;
|
|
297
301
|
const failure = shownFlow.face === 'failed' ? shownFlow.message : '';
|
|
298
|
-
|
|
302
|
+
// A bug report's send: "Sending…", "Sent", "Couldn't send" — and it can always be retried.
|
|
303
|
+
const report = 'report' in shownFlow && shownFlow.report === true;
|
|
304
|
+
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) => {
|
|
299
305
|
savedRef.current = el;
|
|
300
|
-
}, 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) }), rec ? (_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, {}) })] }) })] }));
|
|
306
|
+
}, 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, {}) })] }) })] }));
|
|
301
307
|
}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
|
|
6
6
|
* cancels. The DRAFT is owned by the caller so a cancel keeps it until the
|
|
7
7
|
* next send (recorder-hud-polish D3); the board|task choice resets on every
|
|
8
|
-
* open — a destination is per observation, not a mode.
|
|
8
|
+
* open — a destination is per observation, not a mode. The bug report is the
|
|
9
|
+
* same sheet: a required description and "Mark on screen" in the board|task
|
|
10
|
+
* slot.
|
|
9
11
|
*/
|
|
10
12
|
import { type ReactElement } from 'react';
|
|
11
13
|
export interface SheetProps {
|
|
@@ -21,5 +23,12 @@ export interface SheetProps {
|
|
|
21
23
|
onDraft: (text: string) => void;
|
|
22
24
|
onSend: (text: string, task: boolean) => void;
|
|
23
25
|
onClose: () => void;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** Send stays off until the description has text. */
|
|
28
|
+
required?: boolean;
|
|
29
|
+
/** Shows "Mark on screen" (instead of board|task): pick a region or element. */
|
|
30
|
+
onMark?: () => void;
|
|
31
|
+
/** Something is marked (the button reads pressed). */
|
|
32
|
+
marked?: boolean;
|
|
24
33
|
}
|
|
25
|
-
export declare function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose }: SheetProps): ReactElement;
|
|
34
|
+
export declare function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder, required, onMark, marked, }: SheetProps): ReactElement;
|
|
@@ -6,11 +6,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
|
|
7
7
|
* cancels. The DRAFT is owned by the caller so a cancel keeps it until the
|
|
8
8
|
* next send (recorder-hud-polish D3); the board|task choice resets on every
|
|
9
|
-
* open — a destination is per observation, not a mode.
|
|
9
|
+
* open — a destination is per observation, not a mode. The bug report is the
|
|
10
|
+
* same sheet: a required description and "Mark on screen" in the board|task
|
|
11
|
+
* slot.
|
|
10
12
|
*/
|
|
11
13
|
import { useEffect, useRef, useState } from 'react';
|
|
12
14
|
import { ArrowUpIcon, CloseIcon } from './icons';
|
|
13
|
-
export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose }) {
|
|
15
|
+
export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder = "what's wrong / what to refine…", required = false, onMark, marked = false, }) {
|
|
14
16
|
const ta = useRef(null);
|
|
15
17
|
const [task, setTask] = useState(false);
|
|
16
18
|
useEffect(() => {
|
|
@@ -20,7 +22,14 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
|
|
|
20
22
|
el.focus();
|
|
21
23
|
el.setSelectionRange(el.value.length, el.value.length);
|
|
22
24
|
}, []);
|
|
23
|
-
const
|
|
25
|
+
const empty = required && draft.trim() === '';
|
|
26
|
+
const send = () => {
|
|
27
|
+
if (empty) {
|
|
28
|
+
ta.current?.focus();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
onSend(draft.trim(), task);
|
|
32
|
+
};
|
|
24
33
|
const onKey = (e) => {
|
|
25
34
|
if (e.key === 'Escape') {
|
|
26
35
|
e.preventDefault();
|
|
@@ -33,5 +42,5 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
|
|
|
33
42
|
send();
|
|
34
43
|
}
|
|
35
44
|
};
|
|
36
|
-
return (_jsxs("div", { className: `pop ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: "
|
|
45
|
+
return (_jsxs("div", { className: `pop ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: placeholder, "aria-required": required || undefined, value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey }), _jsxs("div", { className: pick || onMark ? 'row' : 'row nodest', children: [onMark ? (_jsx("span", { className: "dest", children: _jsx("button", { type: "button", "aria-pressed": marked, onClick: onMark, children: "Mark on screen" }) })) : pick ? (_jsxs("span", { className: "dest", role: "group", "aria-label": "Where this snap lands", children: [_jsx("button", { type: "button", "aria-pressed": !task, onClick: () => setTask(false), children: "board" }), _jsx("button", { type: "button", "aria-pressed": task, onClick: () => setTask(true), children: "task" })] })) : null, _jsx("span", { className: "ctx", children: ctx }), _jsxs("button", { type: "button", className: "sendb", "aria-disabled": empty || undefined, onClick: send, children: [_jsx(ArrowUpIcon, {}), _jsx("span", { children: "Send" })] })] }), _jsx("div", { className: "hints", children: "\u21A9 send \u00B7 \u21E7\u21A9 newline \u00B7 esc cancel" })] }));
|
|
37
46
|
}
|
|
@@ -94,6 +94,11 @@ export interface HudSnapshot {
|
|
|
94
94
|
workspaceUrl: string;
|
|
95
95
|
/** Recorder id, e.g. `web/0.2.1` (verbose mode shows it). */
|
|
96
96
|
version: string;
|
|
97
|
+
/**
|
|
98
|
+
* "Report a bug" can file now (the ⋯ menu shows the row): into the live
|
|
99
|
+
* session, or, idle, with the last minute the host keeps. Absent = never.
|
|
100
|
+
*/
|
|
101
|
+
canReport?: boolean;
|
|
97
102
|
}
|
|
98
103
|
/** The code half of a device link, as the link sheet paints it. */
|
|
99
104
|
export interface HudLinkCode {
|
|
@@ -122,6 +127,15 @@ export interface HudAnnotation {
|
|
|
122
127
|
/** Also file it as an intake task. */
|
|
123
128
|
task: boolean;
|
|
124
129
|
}
|
|
130
|
+
/** What "Report a bug" sends from the sheet. */
|
|
131
|
+
export interface HudReport {
|
|
132
|
+
/** The description (required); its first line titles the report. */
|
|
133
|
+
text: string;
|
|
134
|
+
/** The region marked on screen, CSS px; null = the whole viewport. */
|
|
135
|
+
rect: HudRect | null;
|
|
136
|
+
/** The marked element's selector; '' for a region or no mark. */
|
|
137
|
+
selector: string;
|
|
138
|
+
}
|
|
125
139
|
export interface HudController {
|
|
126
140
|
getSnapshot(): HudSnapshot;
|
|
127
141
|
subscribe(listener: () => void): () => void;
|
|
@@ -144,5 +158,20 @@ export interface HudController {
|
|
|
144
158
|
setPrefs(patch: Partial<HudPrefs>): Promise<void>;
|
|
145
159
|
/** Fill missing board links of recents from the server. Never rejects. */
|
|
146
160
|
refreshRecents(): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* The report sheet opened (`true`: idle, freeze the last minute it will
|
|
163
|
+
* send) or was dismissed (`false`: drop it). Optional, with `report`.
|
|
164
|
+
*/
|
|
165
|
+
holdReport?(on: boolean): void;
|
|
166
|
+
/**
|
|
167
|
+
* File a bug report. Recording: a task annotation in the live session
|
|
168
|
+
* (resolves at once). Idle: the held last minute as its own short session
|
|
169
|
+
* — resolves `{boardUrl?}` once it is done, rejects with the reason; a
|
|
170
|
+
* second call after a rejection retries the same report. Optional: a host
|
|
171
|
+
* without it never offers the menu row.
|
|
172
|
+
*/
|
|
173
|
+
report?(r: HudReport): Promise<{
|
|
174
|
+
boardUrl?: string;
|
|
175
|
+
}>;
|
|
147
176
|
}
|
|
148
177
|
export declare const DEFAULT_PREFS: HudPrefs;
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
* │ └─failed→ failed ─retry→ saving
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
|
+
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
8
9
|
*
|
|
9
|
-
* Saved stays until the tester dismisses it. A
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
10
|
+
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
|
+
* failed faces carry `report: true` through retries, so the pill can say
|
|
12
|
+
* "Sending…" / "Sent". A pure reducer, so the HUD's transitions are testable
|
|
13
|
+
* without a DOM; an event that does not apply to the current state leaves it
|
|
14
|
+
* unchanged.
|
|
12
15
|
*/
|
|
13
16
|
export type ConfirmAction = 'stop' | 'unlink';
|
|
14
17
|
export type Flow = {
|
|
@@ -21,12 +24,15 @@ export type Flow = {
|
|
|
21
24
|
| {
|
|
22
25
|
face: 'saving';
|
|
23
26
|
total: number;
|
|
27
|
+
report?: true;
|
|
24
28
|
} | {
|
|
25
29
|
face: 'saved';
|
|
26
30
|
boardUrl?: string;
|
|
31
|
+
report?: true;
|
|
27
32
|
} | {
|
|
28
33
|
face: 'failed';
|
|
29
34
|
message: string;
|
|
35
|
+
report?: true;
|
|
30
36
|
};
|
|
31
37
|
export type FlowEvent = {
|
|
32
38
|
type: 'ask';
|
|
@@ -36,6 +42,10 @@ export type FlowEvent = {
|
|
|
36
42
|
} | {
|
|
37
43
|
type: 'confirm';
|
|
38
44
|
queued: number;
|
|
45
|
+
}
|
|
46
|
+
/** A bug report went out (idle: its own short session). */
|
|
47
|
+
| {
|
|
48
|
+
type: 'send';
|
|
39
49
|
} | {
|
|
40
50
|
type: 'retry';
|
|
41
51
|
queued: number;
|
|
@@ -5,12 +5,19 @@
|
|
|
5
5
|
* │ └─failed→ failed ─retry→ saving
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
|
+
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
8
9
|
*
|
|
9
|
-
* Saved stays until the tester dismisses it. A
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
10
|
+
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
|
+
* failed faces carry `report: true` through retries, so the pill can say
|
|
12
|
+
* "Sending…" / "Sent". A pure reducer, so the HUD's transitions are testable
|
|
13
|
+
* without a DOM; an event that does not apply to the current state leaves it
|
|
14
|
+
* unchanged.
|
|
12
15
|
*/
|
|
13
16
|
export const NO_FLOW = { face: 'none' };
|
|
17
|
+
/** `{report: true}` when the flow is a bug report's — spread into the next face. */
|
|
18
|
+
function reportOf(flow) {
|
|
19
|
+
return 'report' in flow && flow.report ? { report: true } : {};
|
|
20
|
+
}
|
|
14
21
|
export function flowReducer(flow, ev) {
|
|
15
22
|
switch (ev.type) {
|
|
16
23
|
case 'ask':
|
|
@@ -21,12 +28,16 @@ export function flowReducer(flow, ev) {
|
|
|
21
28
|
if (flow.face !== 'confirm')
|
|
22
29
|
return flow;
|
|
23
30
|
return flow.action === 'stop' ? { face: 'saving', total: ev.queued } : NO_FLOW;
|
|
31
|
+
case 'send':
|
|
32
|
+
return flow.face === 'none' ? { face: 'saving', total: 0, report: true } : flow;
|
|
24
33
|
case 'retry':
|
|
25
|
-
return flow.face === 'failed' ? { face: 'saving', total: ev.queued } : flow;
|
|
34
|
+
return flow.face === 'failed' ? { face: 'saving', total: ev.queued, ...reportOf(flow) } : flow;
|
|
26
35
|
case 'saved':
|
|
27
|
-
return flow.face === 'saving'
|
|
36
|
+
return flow.face === 'saving'
|
|
37
|
+
? { face: 'saved', ...(ev.boardUrl ? { boardUrl: ev.boardUrl } : {}), ...reportOf(flow) }
|
|
38
|
+
: flow;
|
|
28
39
|
case 'failed':
|
|
29
|
-
return flow.face === 'saving' ? { face: 'failed', message: ev.message } : flow;
|
|
40
|
+
return flow.face === 'saving' ? { face: 'failed', message: ev.message, ...reportOf(flow) } : flow;
|
|
30
41
|
case 'dismiss':
|
|
31
42
|
return flow.face === 'saved' || flow.face === 'failed' ? NO_FLOW : flow;
|
|
32
43
|
}
|
|
@@ -19,4 +19,5 @@ export declare function AlertIcon(): ReactElement;
|
|
|
19
19
|
/** A ring with a gap; spun by `.spin`. */
|
|
20
20
|
export declare function SpinnerIcon(): ReactElement;
|
|
21
21
|
export declare function UnlinkIcon(): ReactElement;
|
|
22
|
+
export declare function BugIcon(): ReactElement;
|
|
22
23
|
export declare function HomeIcon(): ReactElement;
|
|
@@ -54,6 +54,9 @@ export function SpinnerIcon() {
|
|
|
54
54
|
export function UnlinkIcon() {
|
|
55
55
|
return (_jsxs("svg", { ...base, children: [_jsx("path", { d: "m18.8 12.7 1.7-1.7a5 5 0 0 0-7.1-7.1l-1.7 1.7" }), _jsx("path", { d: "m5.2 11.3-1.7 1.7a5 5 0 0 0 7.1 7.1l1.7-1.7" }), _jsx("path", { d: "M8 2v3" }), _jsx("path", { d: "M2 8h3" }), _jsx("path", { d: "M16 22v-3" }), _jsx("path", { d: "M22 16h-3" })] }));
|
|
56
56
|
}
|
|
57
|
+
export function BugIcon() {
|
|
58
|
+
return (_jsxs("svg", { ...base, children: [_jsx("path", { d: "m8 2 1.88 1.88" }), _jsx("path", { d: "M14.12 3.88 16 2" }), _jsx("path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1" }), _jsx("path", { d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6" }), _jsx("path", { d: "M12 20v-9" }), _jsx("path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5" }), _jsx("path", { d: "M6 13H2" }), _jsx("path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4" }), _jsx("path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4" }), _jsx("path", { d: "M22 13h-4" }), _jsx("path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4" })] }));
|
|
59
|
+
}
|
|
57
60
|
export function HomeIcon() {
|
|
58
61
|
return (_jsxs("svg", { ...base, children: [_jsx("path", { d: "M3 10.5 12 3l9 7.5" }), _jsx("path", { d: "M5 9v11h14V9" })] }));
|
|
59
62
|
}
|