@vitrinka/web 0.1.4 → 0.2.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 +53 -0
- package/README.md +78 -21
- package/build/hud.d.ts +9 -0
- package/build/hud.iife.js +411 -0
- package/build/hud.js +8 -0
- package/build/recorder/api.d.ts +2 -0
- package/build/recorder/block.d.ts +7 -0
- package/build/recorder/block.js +7 -0
- package/build/recorder/capture/click.d.ts +2 -4
- package/build/recorder/capture/click.js +2 -31
- package/build/recorder/capture/rrweb.d.ts +2 -2
- package/build/recorder/capture/rrweb.js +2 -2
- package/build/recorder/capture/selector.d.ts +8 -0
- package/build/recorder/capture/selector.js +35 -0
- package/build/recorder/config.d.ts +6 -0
- package/build/recorder/config.js +1 -0
- package/build/recorder/hud/AnnotateOverlay.d.ts +7 -1
- package/build/recorder/hud/AnnotateOverlay.js +51 -17
- package/build/recorder/hud/Hud.d.ts +16 -1
- package/build/recorder/hud/Hud.js +251 -83
- package/build/recorder/hud/LinkSheet.d.ts +3 -3
- package/build/recorder/hud/LinkSheet.js +1 -1
- package/build/recorder/hud/Menu.d.ts +30 -0
- package/build/recorder/hud/Menu.js +73 -0
- package/build/recorder/hud/RecorderPill.d.ts +36 -27
- package/build/recorder/hud/RecorderPill.js +212 -123
- package/build/recorder/hud/Sheet.d.ts +1 -1
- package/build/recorder/hud/Sheet.js +1 -1
- package/build/recorder/hud/Tooltip.d.ts +19 -0
- package/build/recorder/hud/Tooltip.js +94 -0
- package/build/recorder/hud/controller.d.ts +148 -0
- package/build/recorder/hud/controller.js +17 -0
- package/build/recorder/hud/flow.d.ts +54 -0
- package/build/recorder/hud/flow.js +39 -0
- package/build/recorder/hud/host.js +1 -1
- package/build/recorder/hud/icons.d.ts +7 -0
- package/build/recorder/hud/icons.js +19 -0
- package/build/recorder/hud/iife.d.ts +13 -0
- package/build/recorder/hud/iife.js +11 -0
- package/build/recorder/hud/layer.d.ts +29 -6
- package/build/recorder/hud/layer.js +67 -33
- package/build/recorder/hud/mount.d.ts +13 -0
- package/build/recorder/hud/mount.js +27 -0
- package/build/recorder/hud/place.d.ts +43 -0
- package/build/recorder/hud/place.js +63 -0
- package/build/recorder/hud/spots.d.ts +45 -0
- package/build/recorder/hud/spots.js +107 -0
- package/build/recorder/hud/status.d.ts +31 -0
- package/build/recorder/hud/status.js +67 -0
- package/build/recorder/hud/styles.d.ts +28 -18
- package/build/recorder/hud/styles.js +295 -122
- package/build/recorder/hud/useDock.d.ts +9 -8
- package/build/recorder/hud/useDock.js +41 -20
- package/build/recorder/index.d.ts +4 -2
- package/build/recorder/index.js +17 -19
- package/build/recorder/link.d.ts +1 -1
- package/build/recorder/link.js +8 -2
- package/build/recorder/me.d.ts +34 -0
- package/build/recorder/me.js +172 -0
- package/build/recorder/page-controller.d.ts +12 -0
- package/build/recorder/page-controller.js +100 -0
- package/build/recorder/queue.d.ts +4 -0
- package/build/recorder/queue.js +2 -0
- package/build/recorder/recents.d.ts +23 -0
- package/build/recorder/recents.js +80 -0
- package/build/recorder/session.d.ts +2 -2
- package/build/recorder/session.js +16 -1
- package/build/recorder/storage/index.js +2 -1
- package/package.json +9 -3
|
@@ -1,42 +1,63 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* The HUD tree, rendered into the shadow host by its own React root
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* The HUD tree, rendered into the shadow host by its own React root and
|
|
4
|
+
* driven ONLY through a `HudController` (controller.ts) — the in-page
|
|
5
|
+
* recorder's, or another host's. Owns the dock (where the HUD rests), the
|
|
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
|
|
8
|
+
* floats, annotate mode, the keyboard shortcuts, the Esc-anywhere /
|
|
9
|
+
* click-outside close and the status line a screen reader hears while the
|
|
10
|
+
* pill is folded.
|
|
8
11
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
12
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, } from 'react';
|
|
11
13
|
import { createPortal } from 'react-dom';
|
|
12
|
-
import { readLink, recorderConfig, vitrinkaLinked } from '../config';
|
|
13
|
-
import { forgetLink, linkDevice, LinkExpired } from '../link';
|
|
14
|
-
import { getState, health } from '../queue';
|
|
15
|
-
import { addAnnotation, addNote, startSession, stopSession, togglePause } from '../session';
|
|
16
|
-
import { annotateState, setAnnotating, subscribe } from '../state';
|
|
17
14
|
import { AnnotateOverlay } from './AnnotateOverlay';
|
|
15
|
+
import { flowReducer, NO_FLOW } from './flow';
|
|
18
16
|
import { createSheetHost, insideHud, sheetTarget } from './host';
|
|
19
|
-
import { anchoredLayer, hostOrigin, PHONE_QUERY, phoneLayer, restingBox, useMedia, usePresence, useViewportTick } from './layer';
|
|
17
|
+
import { anchoredLayer, hostOrigin, PHONE_QUERY, phoneLayer, restingBox, useFloat, useMedia, usePresence, useViewportTick, } from './layer';
|
|
20
18
|
import { LinkSheet } from './LinkSheet';
|
|
19
|
+
import { Menu } from './Menu';
|
|
20
|
+
import { alignFor, towardCentre } from './place';
|
|
21
21
|
import { RecorderPill } from './RecorderPill';
|
|
22
22
|
import { Sheet } from './Sheet';
|
|
23
|
+
import { colOf, rowOf } from './spots';
|
|
24
|
+
import { fmtAgo, healthLine } from './status';
|
|
23
25
|
import { HUD_CSS } from './styles';
|
|
26
|
+
import { Tooltip } from './Tooltip';
|
|
24
27
|
import { useDock } from './useDock';
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
/** "Saving…" stays at least this long, so a fast save still reads as one. */
|
|
29
|
+
const MIN_SAVING_MS = 700;
|
|
30
|
+
/** How long the clock says "Saved" after a note or annotation. */
|
|
31
|
+
const FLASH_MS = 1600;
|
|
32
|
+
/** A clock that ticks every second while `active` (the timer, ages, the sync chip). */
|
|
33
|
+
function useNow(active) {
|
|
34
|
+
const [now, setNow] = useState(() => Date.now());
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!active)
|
|
37
|
+
return;
|
|
38
|
+
setNow(Date.now());
|
|
39
|
+
const t = setInterval(() => setNow(Date.now()), 1000);
|
|
40
|
+
return () => clearInterval(t);
|
|
41
|
+
}, [active]);
|
|
42
|
+
return active ? now : Date.now();
|
|
29
43
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
44
|
+
const errorText = (e) => (e instanceof Error ? e.message : String(e));
|
|
45
|
+
export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
46
|
+
const snap = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
47
|
+
const rec = snap.recording;
|
|
33
48
|
const [sheet, setSheet] = useState(null);
|
|
34
49
|
const [draft, setDraft] = useState('');
|
|
35
50
|
const [starting, setStarting] = useState(false);
|
|
36
|
-
const [
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
51
|
+
const [menu, setMenu] = useState(false);
|
|
52
|
+
const [flow, dispatch] = useReducer(flowReducer, NO_FLOW);
|
|
53
|
+
const [flash, setFlash] = useState(false);
|
|
54
|
+
const annotating = snap.annotating;
|
|
55
|
+
const now = useNow(rec !== null || menu || flow.face !== 'none');
|
|
56
|
+
const rootRef = useRef(null);
|
|
57
|
+
const pillRef = useRef(null);
|
|
58
|
+
const menuRef = useRef(null);
|
|
59
|
+
const detailRef = useRef(null);
|
|
60
|
+
const layerRef = useRef(null);
|
|
40
61
|
// Device link (Netflix-style code): the sheet paints the phase, this owns it.
|
|
41
62
|
const [link, setLink] = useState(null);
|
|
42
63
|
const linkRef = useRef(null);
|
|
@@ -45,103 +66,179 @@ export function Hud({ hostMount, defaultTitle }) {
|
|
|
45
66
|
linkRef.current = null;
|
|
46
67
|
setLink(null);
|
|
47
68
|
}, []);
|
|
69
|
+
const onStartRef = useRef(() => undefined);
|
|
48
70
|
const beginLink = useCallback(() => {
|
|
49
71
|
linkRef.current?.cancel();
|
|
50
72
|
setSheet(null);
|
|
73
|
+
setMenu(false);
|
|
51
74
|
setLink({ phase: 'starting', flow: null });
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
controller
|
|
76
|
+
.link()
|
|
77
|
+
.then((lf) => {
|
|
78
|
+
linkRef.current = lf;
|
|
79
|
+
setLink({ phase: 'waiting', flow: lf });
|
|
80
|
+
return lf.linked.then(() => {
|
|
81
|
+
if (linkRef.current !== lf)
|
|
58
82
|
return;
|
|
59
83
|
linkRef.current = null;
|
|
60
84
|
setLink(null);
|
|
61
85
|
// Linked: start recording exactly as if a key had been passed.
|
|
62
86
|
onStartRef.current();
|
|
63
87
|
}, (e) => {
|
|
64
|
-
if (linkRef.current !==
|
|
88
|
+
if (linkRef.current !== lf)
|
|
65
89
|
return;
|
|
66
90
|
linkRef.current = null;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
const name = e instanceof Error ? e.name : '';
|
|
92
|
+
if (name === 'LinkExpired')
|
|
93
|
+
setLink({ phase: 'expired', flow: lf });
|
|
94
|
+
else if (name !== 'AbortError')
|
|
95
|
+
setLink({ phase: 'error', flow: lf, error: errorText(e) });
|
|
71
96
|
});
|
|
72
97
|
})
|
|
73
|
-
.catch((e) => setLink({ phase: 'error', flow: null, error:
|
|
74
|
-
}, []);
|
|
75
|
-
const onUnlink = useCallback(() => {
|
|
76
|
-
closeLink();
|
|
77
|
-
setSheet(null);
|
|
78
|
-
setAnnotating(false);
|
|
79
|
-
forgetLink();
|
|
80
|
-
}, [closeLink]);
|
|
98
|
+
.catch((e) => setLink({ phase: 'error', flow: null, error: errorText(e) }));
|
|
99
|
+
}, [controller]);
|
|
81
100
|
const closeSheet = useCallback(() => setSheet(null), []);
|
|
82
|
-
// A drag closes the composer (its draft survives); the link sheet follows the dock.
|
|
83
|
-
const
|
|
101
|
+
// A drag closes the composer (its draft survives) and the menu; the link sheet follows the dock.
|
|
102
|
+
const onMoveStart = useCallback(() => {
|
|
103
|
+
setSheet(null);
|
|
104
|
+
setMenu(false);
|
|
105
|
+
}, []);
|
|
106
|
+
const dock = useDock(onMoveStart, storage);
|
|
84
107
|
const phone = useMedia(PHONE_QUERY);
|
|
85
108
|
const openNote = useCallback(() => {
|
|
86
|
-
if (!
|
|
109
|
+
if (!controller.getSnapshot().recording)
|
|
87
110
|
return;
|
|
88
|
-
setAnnotating(false);
|
|
111
|
+
controller.setAnnotating(false);
|
|
112
|
+
setMenu(false);
|
|
89
113
|
setSheet({ title: 'Note', ctx: `step · ${location.pathname}`, pick: null });
|
|
90
|
-
}, []);
|
|
114
|
+
}, [controller]);
|
|
91
115
|
const toggleAnnotate = useCallback(() => {
|
|
92
|
-
|
|
116
|
+
const s = controller.getSnapshot();
|
|
117
|
+
if (!s.recording)
|
|
93
118
|
return;
|
|
94
119
|
setSheet(null);
|
|
95
|
-
|
|
96
|
-
|
|
120
|
+
setMenu(false);
|
|
121
|
+
controller.setAnnotating(!s.annotating);
|
|
122
|
+
}, [controller]);
|
|
97
123
|
const onPick = useCallback((pick) => {
|
|
98
|
-
setAnnotating(false);
|
|
124
|
+
controller.setAnnotating(false);
|
|
99
125
|
const ctx = pick.selector
|
|
100
126
|
? `${pick.selector} · ${location.pathname}`
|
|
101
127
|
: `${Math.round(pick.rect.w)}×${Math.round(pick.rect.h)} · ${location.pathname}`;
|
|
102
128
|
setSheet({ title: pick.selector ? 'Annotate element' : 'Annotate region', ctx, pick });
|
|
129
|
+
}, [controller]);
|
|
130
|
+
const cancelAnnotate = useCallback(() => controller.setAnnotating(false), [controller]);
|
|
131
|
+
const flashTimer = useRef(undefined);
|
|
132
|
+
const saidSaved = useCallback(() => {
|
|
133
|
+
clearTimeout(flashTimer.current);
|
|
134
|
+
setFlash(true);
|
|
135
|
+
flashTimer.current = setTimeout(() => setFlash(false), FLASH_MS);
|
|
103
136
|
}, []);
|
|
104
|
-
|
|
137
|
+
useEffect(() => () => clearTimeout(flashTimer.current), []);
|
|
105
138
|
const onSend = useCallback((text, task) => {
|
|
106
139
|
const s = sheet;
|
|
107
140
|
setSheet(null);
|
|
108
141
|
if (!s)
|
|
109
142
|
return;
|
|
110
143
|
if (s.pick) {
|
|
111
|
-
|
|
144
|
+
controller.annotate({ text, rect: s.pick.rect, selector: s.pick.selector, task });
|
|
112
145
|
setDraft('');
|
|
146
|
+
saidSaved();
|
|
113
147
|
}
|
|
114
148
|
else if (text) {
|
|
115
|
-
|
|
149
|
+
controller.note(text);
|
|
116
150
|
setDraft('');
|
|
151
|
+
saidSaved();
|
|
117
152
|
}
|
|
118
|
-
}, [sheet]);
|
|
153
|
+
}, [sheet, controller, saidSaved]);
|
|
119
154
|
const onStart = useCallback(() => {
|
|
120
|
-
if (!
|
|
155
|
+
if (!controller.getSnapshot().linked) {
|
|
121
156
|
beginLink();
|
|
122
157
|
return;
|
|
123
158
|
}
|
|
124
159
|
setStarting(true);
|
|
125
|
-
|
|
160
|
+
controller
|
|
161
|
+
.start({ title: defaultTitle() })
|
|
126
162
|
.catch((e) => console.warn('vitrinka: start failed', e))
|
|
127
163
|
.finally(() => setStarting(false));
|
|
128
|
-
}, [defaultTitle, beginLink]);
|
|
129
|
-
const onStartRef = useRef(onStart);
|
|
164
|
+
}, [controller, defaultTitle, beginLink]);
|
|
130
165
|
onStartRef.current = onStart;
|
|
131
|
-
const
|
|
166
|
+
const onPause = useCallback(() => {
|
|
167
|
+
void controller.togglePause();
|
|
168
|
+
}, [controller]);
|
|
169
|
+
// The inline flows. Stop drains first; a refusal (offline) keeps the session.
|
|
170
|
+
const runStop = useCallback(() => {
|
|
171
|
+
const t0 = Date.now();
|
|
172
|
+
const settle = (ev) => setTimeout(() => dispatch(ev), Math.max(0, MIN_SAVING_MS - (Date.now() - t0)));
|
|
173
|
+
controller.stop().then((r) => settle({ type: 'saved', ...(r.boardUrl ? { boardUrl: r.boardUrl } : {}) }), (e) => {
|
|
174
|
+
console.warn('vitrinka: stop —', errorText(e));
|
|
175
|
+
settle({ type: 'failed', message: errorText(e) });
|
|
176
|
+
});
|
|
177
|
+
}, [controller]);
|
|
178
|
+
const askStop = useCallback(() => {
|
|
179
|
+
if (!controller.getSnapshot().recording)
|
|
180
|
+
return;
|
|
181
|
+
setSheet(null);
|
|
182
|
+
setMenu(false);
|
|
183
|
+
controller.setAnnotating(false);
|
|
184
|
+
dispatch({ type: 'ask', action: 'stop' });
|
|
185
|
+
}, [controller]);
|
|
186
|
+
const askUnlink = useCallback(() => {
|
|
132
187
|
setSheet(null);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
stopSession()
|
|
136
|
-
.catch((e) => console.warn('vitrinka: stop —', e instanceof Error ? e.message : e))
|
|
137
|
-
.finally(() => setStopping(false));
|
|
188
|
+
setMenu(false);
|
|
189
|
+
dispatch({ type: 'ask', action: 'unlink' });
|
|
138
190
|
}, []);
|
|
139
|
-
const
|
|
140
|
-
|
|
191
|
+
const onConfirm = useCallback(() => {
|
|
192
|
+
if (flow.face !== 'confirm')
|
|
193
|
+
return;
|
|
194
|
+
dispatch({ type: 'confirm', queued: controller.getSnapshot().recording?.sync.queued ?? 0 });
|
|
195
|
+
if (flow.action === 'stop') {
|
|
196
|
+
runStop();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
closeLink();
|
|
200
|
+
setSheet(null);
|
|
201
|
+
controller.setAnnotating(false);
|
|
202
|
+
controller.unlink();
|
|
203
|
+
}, [flow, controller, runStop, closeLink]);
|
|
204
|
+
const onCancel = useCallback(() => dispatch({ type: 'cancel' }), []);
|
|
205
|
+
const onDismiss = useCallback(() => dispatch({ type: 'dismiss' }), []);
|
|
206
|
+
const onRetry = useCallback(() => {
|
|
207
|
+
dispatch({ type: 'retry', queued: controller.getSnapshot().recording?.sync.queued ?? 0 });
|
|
208
|
+
runStop();
|
|
209
|
+
}, [controller, runStop]);
|
|
210
|
+
// A stop confirm outlives nothing: the session ended under it (401, the server).
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (!rec && flow.face === 'confirm' && flow.action === 'stop')
|
|
213
|
+
dispatch({ type: 'cancel' });
|
|
214
|
+
}, [rec, flow]);
|
|
215
|
+
// Who the token is (and the user's server-side prefs): on mount and once linked.
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (snap.linked)
|
|
218
|
+
void controller.getMe();
|
|
219
|
+
}, [snap.linked, controller]);
|
|
220
|
+
// A keyboard open (Enter, Space, ↓ on ⋯) moves focus to the first item, as a menu button does.
|
|
221
|
+
const focusMenu = useRef(false);
|
|
222
|
+
const toggleMenu = useCallback((byKeyboard) => {
|
|
223
|
+
focusMenu.current = byKeyboard;
|
|
224
|
+
setMenu((m) => !m);
|
|
141
225
|
}, []);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!menu || !focusMenu.current)
|
|
228
|
+
return;
|
|
229
|
+
focusMenu.current = false;
|
|
230
|
+
const raf = requestAnimationFrame(() => menuRef.current?.querySelector('[role^="menuitem"]:not([aria-disabled="true"])')?.focus({ preventScroll: true }));
|
|
231
|
+
return () => cancelAnimationFrame(raf);
|
|
232
|
+
}, [menu]);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!menu)
|
|
235
|
+
return;
|
|
236
|
+
void controller.getMe();
|
|
237
|
+
void controller.refreshRecents();
|
|
238
|
+
}, [menu, controller]);
|
|
142
239
|
// Shortcuts (window keydown, CAPTURE — the host's shield stops a keydown
|
|
143
240
|
// from a focused HUD control before it could bubble to window, and a drag
|
|
144
|
-
// leaves the handle focused): ⌥⇧A annotate · ⌥⇧N note · ⌥⇧P pause.
|
|
241
|
+
// leaves the handle focused): ⌥⇧A annotate · ⌥⇧N note · ⌥⇧P pause · ⌥⇧S stop.
|
|
145
242
|
useEffect(() => {
|
|
146
243
|
const key = (e) => {
|
|
147
244
|
if (!e.altKey || !e.shiftKey || e.metaKey || e.ctrlKey)
|
|
@@ -152,13 +249,15 @@ export function Hud({ hostMount, defaultTitle }) {
|
|
|
152
249
|
openNote();
|
|
153
250
|
else if (e.code === 'KeyP')
|
|
154
251
|
onPause();
|
|
252
|
+
else if (e.code === 'KeyS')
|
|
253
|
+
askStop();
|
|
155
254
|
else
|
|
156
255
|
return;
|
|
157
256
|
e.preventDefault();
|
|
158
257
|
};
|
|
159
258
|
window.addEventListener('keydown', key, true);
|
|
160
259
|
return () => window.removeEventListener('keydown', key, true);
|
|
161
|
-
}, [toggleAnnotate, openNote, onPause]);
|
|
260
|
+
}, [toggleAnnotate, openNote, onPause, askStop]);
|
|
162
261
|
// Esc anywhere and click-outside close the sheet (capture-phase, so the
|
|
163
262
|
// page's own dialog never sees the Esc that closed ours).
|
|
164
263
|
useEffect(() => {
|
|
@@ -182,11 +281,40 @@ export function Hud({ hostMount, defaultTitle }) {
|
|
|
182
281
|
document.removeEventListener('keydown', key, true);
|
|
183
282
|
document.removeEventListener('pointerdown', down, true);
|
|
184
283
|
};
|
|
185
|
-
}, [sheet,
|
|
186
|
-
//
|
|
187
|
-
|
|
284
|
+
}, [sheet, closeSheet]);
|
|
285
|
+
// The menu closes on Esc (focus back on its ⋯) and on a press outside it and the pill.
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (!menu)
|
|
288
|
+
return;
|
|
289
|
+
const key = (e) => {
|
|
290
|
+
if (e.key !== 'Escape')
|
|
291
|
+
return;
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
e.stopPropagation();
|
|
294
|
+
setMenu(false);
|
|
295
|
+
pillRef.current?.querySelector('.seg.on .b-more')?.focus();
|
|
296
|
+
};
|
|
297
|
+
const down = (e) => {
|
|
298
|
+
const path = e.composedPath();
|
|
299
|
+
if (!path.includes(menuRef.current) && !path.includes(pillRef.current))
|
|
300
|
+
setMenu(false);
|
|
301
|
+
};
|
|
302
|
+
document.addEventListener('keydown', key, true);
|
|
303
|
+
document.addEventListener('pointerdown', down, true);
|
|
304
|
+
return () => {
|
|
305
|
+
document.removeEventListener('keydown', key, true);
|
|
306
|
+
document.removeEventListener('pointerdown', down, true);
|
|
307
|
+
};
|
|
308
|
+
}, [menu]);
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if (dock.dragging)
|
|
311
|
+
setMenu(false);
|
|
312
|
+
}, [dock.dragging]);
|
|
313
|
+
// Sheets and the menu enter and leave (presence) with their last content
|
|
314
|
+
// kept for the closing frames.
|
|
188
315
|
const sheetP = usePresence(sheet !== null, 150);
|
|
189
316
|
const linkP = usePresence(link !== null, 150);
|
|
317
|
+
const menuP = usePresence(menu, 150);
|
|
190
318
|
const lastSheet = useRef(null);
|
|
191
319
|
const lastLink = useRef(null);
|
|
192
320
|
if (sheet)
|
|
@@ -207,25 +335,65 @@ export function Hud({ hostMount, defaultTitle }) {
|
|
|
207
335
|
return { ...h, own: true };
|
|
208
336
|
}, [sheetP.mounted, hostMount]);
|
|
209
337
|
useEffect(() => () => portal?.destroy(), [portal]);
|
|
210
|
-
// Where the open layer sits (D5):
|
|
211
|
-
//
|
|
338
|
+
// Where the open layer sits (D5): beside the dock's resting box, toward the
|
|
339
|
+
// centre and inside the viewport, or a phone bottom sheet over the visual viewport.
|
|
212
340
|
const layerOpen = sheet !== null || link !== null;
|
|
213
341
|
const vvTick = useViewportTick(layerOpen && phone);
|
|
214
|
-
|
|
342
|
+
// On desktop the placement is measured, so a viewport resize or a grown
|
|
343
|
+
// sheet (the textarea resizes) must place it again.
|
|
344
|
+
const [sizeTick, setSizeTick] = useState(0);
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
if (!layerOpen || phone)
|
|
347
|
+
return;
|
|
348
|
+
const bump = () => setSizeTick((n) => n + 1);
|
|
349
|
+
const ro = typeof ResizeObserver === 'function' ? new ResizeObserver(bump) : null;
|
|
350
|
+
const pop = layerRef.current?.firstElementChild;
|
|
351
|
+
if (ro && pop)
|
|
352
|
+
ro.observe(pop);
|
|
353
|
+
addEventListener('resize', bump);
|
|
354
|
+
return () => {
|
|
355
|
+
ro?.disconnect();
|
|
356
|
+
removeEventListener('resize', bump);
|
|
357
|
+
};
|
|
358
|
+
}, [layerOpen, phone, sheetP.mounted, linkP.mounted]);
|
|
359
|
+
const [layer, setLayer] = useState({ style: {}, origin: 'bottom right' });
|
|
215
360
|
useLayoutEffect(() => {
|
|
216
361
|
const el = dock.ref.current;
|
|
217
362
|
if (!layerOpen || !el)
|
|
218
363
|
return;
|
|
219
364
|
const o = hostOrigin(sheet && portal ? portal.mount : hostMount);
|
|
220
|
-
|
|
221
|
-
|
|
365
|
+
if (phone) {
|
|
366
|
+
setLayer({ style: phoneLayer(o), origin: 'bottom center' });
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const pop = layerRef.current?.firstElementChild;
|
|
370
|
+
const size = pop ? { w: pop.offsetWidth, h: pop.offsetHeight } : { w: 288, h: 200 };
|
|
371
|
+
setLayer(anchoredLayer(restingBox(el), size, dock.place, o));
|
|
372
|
+
}, [layerOpen, sheet, link?.phase, portal, hostMount, dock.place, dock.ref, phone, vvTick, sizeTick, snap.prefs.size]);
|
|
222
373
|
const layerCls = phone ? 'phone' : 'anchor';
|
|
223
374
|
const motionCls = phone ? 'rise' : 'grow';
|
|
224
|
-
|
|
375
|
+
// The floats: menu and details card beside the dock, toward the centre.
|
|
376
|
+
const side = towardCentre(dock.place);
|
|
377
|
+
const align = alignFor(dock.place);
|
|
378
|
+
const anchor = useCallback(() => {
|
|
379
|
+
const el = dock.ref.current;
|
|
380
|
+
return el ? { el, box: restingBox(el) } : null;
|
|
381
|
+
}, [dock.ref]);
|
|
382
|
+
useFloat(menuRef, anchor, side, align, menuP.mounted);
|
|
383
|
+
const tucked = 'tuck' in dock.place;
|
|
384
|
+
const line = rec ? healthLine(rec.sync, now) : '';
|
|
385
|
+
const detailOn = rec !== null && (snap.prefs.verbose || line !== '') && !menu && !layerOpen && flow.face === 'none' && !dock.dragging && !tucked;
|
|
386
|
+
const detailP = usePresence(detailOn, 150);
|
|
387
|
+
useFloat(detailRef, anchor, side, align, detailP.mounted);
|
|
388
|
+
const lastRec = useRef(rec);
|
|
389
|
+
if (rec)
|
|
390
|
+
lastRec.current = rec;
|
|
391
|
+
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 }) })] })) : null;
|
|
225
393
|
// Stable phrases only: a live region re-announces on every text change.
|
|
226
|
-
const hs = rec
|
|
394
|
+
const hs = rec?.sync.state ?? null;
|
|
227
395
|
const status = !rec
|
|
228
|
-
? linked
|
|
396
|
+
? snap.linked
|
|
229
397
|
? 'Recorder ready'
|
|
230
398
|
: 'Recorder not linked'
|
|
231
399
|
: hs === 'dead'
|
|
@@ -239,5 +407,5 @@ export function Hud({ hostMount, defaultTitle }) {
|
|
|
239
407
|
const dockAttrs = 'tuck' in place
|
|
240
408
|
? { 'data-tuck': place.tuck, style: { '--ty': String(place.y) } }
|
|
241
409
|
: { 'data-row': rowOf(place.spot), 'data-col': colOf(place.spot) };
|
|
242
|
-
return (_jsxs("div", { className: "hud", "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, {
|
|
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 })] }));
|
|
243
411
|
}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* Polling runs in the parent; this only paints the state.
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactElement } from 'react';
|
|
8
|
-
import type {
|
|
8
|
+
import type { HudLinkCode } from './controller';
|
|
9
9
|
export type LinkPhase = 'starting' | 'waiting' | 'expired' | 'error';
|
|
10
10
|
export interface LinkSheetProps {
|
|
11
11
|
/** Presence classes (`grow`/`rise` + `is-open`/`is-closing`). */
|
|
12
12
|
className: string;
|
|
13
|
-
/**
|
|
13
|
+
/** CSS transform-origin: the point nearest the dock it grows from. */
|
|
14
14
|
origin: string;
|
|
15
15
|
phase: LinkPhase;
|
|
16
|
-
start:
|
|
16
|
+
start: HudLinkCode | null;
|
|
17
17
|
error?: string;
|
|
18
18
|
onRetry: () => void;
|
|
19
19
|
onClose: () => void;
|
|
@@ -15,5 +15,5 @@ export const LINK_STRINGS = {
|
|
|
15
15
|
export function LinkSheet({ className, origin, phase, start, error, onRetry, onClose }) {
|
|
16
16
|
// The QR serves the desktop→phone path; a touch device cannot scan itself (D5).
|
|
17
17
|
const qr = useMedia(FINE_QUERY);
|
|
18
|
-
return (_jsxs("div", { className: `pop link ${className}`,
|
|
18
|
+
return (_jsxs("div", { className: `pop link ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-labelledby": "vt-link-title", "data-e2e": "link-sheet", children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-link-title", children: LINK_STRINGS.title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), phase === 'starting' || !start ? (_jsx("div", { className: "linkline", children: phase === 'error' ? error || 'could not start the link' : LINK_STRINGS.starting })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: qr ? 'linkgrid' : 'linkgrid noqr', children: [_jsx("div", { className: "code", "data-e2e": "link-code", children: start.user_code }), _jsxs("a", { className: "sendb", href: start.verifyUrl, target: "_blank", rel: "noopener noreferrer", children: [_jsx(NewTabIcon, {}), _jsx("span", { children: LINK_STRINGS.open })] }), qr ? _jsx("img", { className: "qr", src: start.qrUrl, alt: LINK_STRINGS.qrAlt, width: 76, height: 76 }) : null] }), _jsxs("div", { className: phase === 'expired' || phase === 'error' ? 'linkline bad' : 'linkline', children: [phase === 'waiting' ? LINK_STRINGS.waiting : phase === 'expired' ? LINK_STRINGS.expired : error, phase === 'expired' || phase === 'error' ? (_jsx("button", { type: "button", className: "retry", onClick: onRetry, children: LINK_STRINGS.retry })) : null] })] })), _jsx("div", { className: "hints", children: qr ? LINK_STRINGS.hint : LINK_STRINGS.hintTouch })] }));
|
|
19
19
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ⋯ menu: who the recorder is linked as, the open board, the device's
|
|
3
|
+
* recent recordings and "Go to vitrinka", then the HUD's own settings —
|
|
4
|
+
* size, verbose details, position (a miniature screen of the eight spots) —
|
|
5
|
+
* and Unlink. A fixed float placed beside the dock by the caller; ↑/↓ move
|
|
6
|
+
* between items, Esc closes.
|
|
7
|
+
*/
|
|
8
|
+
import { type ReactElement, type RefObject } from 'react';
|
|
9
|
+
import type { HudAccount, HudSize, HudSnapshot } from './controller';
|
|
10
|
+
import { type Place } from './spots';
|
|
11
|
+
/** The account line: `lukas@… · ADF`, or the key build's `Recorder key · <name> · project <p>`. */
|
|
12
|
+
export declare function accountLines(account: HudAccount | null, linked: boolean): {
|
|
13
|
+
who: string;
|
|
14
|
+
ws: string;
|
|
15
|
+
sub: string;
|
|
16
|
+
};
|
|
17
|
+
export interface MenuProps {
|
|
18
|
+
snap: HudSnapshot;
|
|
19
|
+
now: number;
|
|
20
|
+
place: Place;
|
|
21
|
+
className: string;
|
|
22
|
+
menuRef: RefObject<HTMLDivElement | null>;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
onMove: (place: Place) => void;
|
|
25
|
+
onSize: (size: HudSize) => void;
|
|
26
|
+
onVerbose: (on: boolean) => void;
|
|
27
|
+
onAskUnlink: () => void;
|
|
28
|
+
onLink: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function Menu(p: MenuProps): ReactElement;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { HomeIcon, NewTabIcon, UnlinkIcon } from './icons';
|
|
3
|
+
import { isVertical, SPOT_NAMES, SPOTS } from './spots';
|
|
4
|
+
import { fmtAgo, fmtDuration } from './status';
|
|
5
|
+
const SIZES = [
|
|
6
|
+
{ size: 'sm', label: 'S', name: 'Small' },
|
|
7
|
+
{ size: 'md', label: 'M', name: 'Medium' },
|
|
8
|
+
{ size: 'lg', label: 'L', name: 'Large' },
|
|
9
|
+
];
|
|
10
|
+
const STATUS_WORDS = { recording: 'recording', saved: 'saved', unsaved: 'not stopped', deleted: 'deleted' };
|
|
11
|
+
/** The account line: `lukas@… · ADF`, or the key build's `Recorder key · <name> · project <p>`. */
|
|
12
|
+
export function accountLines(account, linked) {
|
|
13
|
+
if (!linked)
|
|
14
|
+
return { who: 'Not linked', ws: '', sub: 'Link this device to record' };
|
|
15
|
+
if (!account)
|
|
16
|
+
return { who: 'Linked device', ws: '', sub: 'checking who this is…' };
|
|
17
|
+
if (account.kind === 'key') {
|
|
18
|
+
const bits = ['Recorder key', account.label, account.project ? `project ${account.project}` : null].filter(Boolean);
|
|
19
|
+
return { who: bits.join(' · '), ws: '', sub: account.workspace.name };
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
who: account.user?.email || account.user?.name || 'Linked device',
|
|
23
|
+
ws: account.workspace.name,
|
|
24
|
+
sub: account.label ? `this device · ${account.label}` : 'this device',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function Menu(p) {
|
|
28
|
+
const { snap } = p;
|
|
29
|
+
const lines = accountLines(snap.account, snap.linked);
|
|
30
|
+
const current = 'spot' in p.place ? p.place.spot : null;
|
|
31
|
+
const rec = snap.recording;
|
|
32
|
+
const sizeIndex = SIZES.findIndex((s) => s.size === snap.prefs.size);
|
|
33
|
+
// ↑/↓ walk the items (radios included); Home/End jump.
|
|
34
|
+
const onKey = (e) => {
|
|
35
|
+
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(e.key))
|
|
36
|
+
return;
|
|
37
|
+
const items = [...e.currentTarget.querySelectorAll('[role^="menuitem"]:not([aria-disabled="true"])')];
|
|
38
|
+
if (!items.length)
|
|
39
|
+
return;
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
const root = e.currentTarget.getRootNode();
|
|
43
|
+
const at = items.indexOf(root.activeElement);
|
|
44
|
+
const next = e.key === 'Home' ? 0 : e.key === 'End' ? items.length - 1 : (at + (e.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length;
|
|
45
|
+
items[next]?.focus();
|
|
46
|
+
};
|
|
47
|
+
const act = (fn) => () => {
|
|
48
|
+
p.onClose();
|
|
49
|
+
fn();
|
|
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) => {
|
|
52
|
+
const live = rec?.sessionId === r.sessionId;
|
|
53
|
+
const meta = [
|
|
54
|
+
live ? 'now' : fmtAgo(p.now - r.startedAt),
|
|
55
|
+
r.durationMs !== undefined ? fmtDuration(r.durationMs) : null,
|
|
56
|
+
live ? 'recording' : STATUS_WORDS[r.status],
|
|
57
|
+
].filter(Boolean);
|
|
58
|
+
const status = live ? 'recording' : r.status;
|
|
59
|
+
const body = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "r-main", children: [_jsx("span", { className: "r-title", children: r.title || 'Untitled recording' }), _jsxs("span", { className: "r-meta", children: [_jsx("i", { "data-status": status }), meta.join(' · ')] })] }), r.boardUrl ? (_jsx("span", { className: "end", children: _jsx(NewTabIcon, {}) })) : null] }));
|
|
60
|
+
return r.boardUrl ? (_jsx("a", { role: "menuitem", className: "mi recent", href: r.boardUrl, target: "_blank", rel: "noopener noreferrer", onClick: p.onClose, "data-e2e": "recent", children: body }, r.sessionId)) : (_jsx("div", { role: "menuitem", "aria-disabled": "true", className: "mi recent", "data-e2e": "recent", children: body }, r.sessionId));
|
|
61
|
+
}), _jsxs("a", { role: "menuitem", className: "mi", href: snap.workspaceUrl, target: "_blank", rel: "noopener noreferrer", onClick: p.onClose, children: [_jsx(HomeIcon, {}), " Go to vitrinka", _jsx("span", { className: "end", children: _jsx(NewTabIcon, {}) })] }), _jsx("div", { className: "m-rule" }), _jsxs("div", { className: "m-row", children: [_jsx("span", { id: "vt-size", children: "Size" }), _jsx("span", { className: "sizes", role: "group", "aria-labelledby": "vt-size", style: { '--i': String(Math.max(0, sizeIndex)) }, children: SIZES.map((s) => (_jsx("button", { type: "button", role: "menuitemradio", "aria-checked": snap.prefs.size === s.size, "aria-label": `Size ${s.name}`, onClick: () => p.onSize(s.size), children: s.label }, s.size))) })] }), _jsxs("div", { className: "m-row toggle", role: "menuitemcheckbox", "aria-checked": snap.prefs.verbose, tabIndex: 0, onClick: () => p.onVerbose(!snap.prefs.verbose), onKeyDown: (e) => {
|
|
62
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
63
|
+
return;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
p.onVerbose(!snap.prefs.verbose);
|
|
66
|
+
}, children: [_jsx("span", { children: "Technical details" }), _jsx("span", { className: "switch", "data-on": String(snap.prefs.verbose) })] }), _jsxs("div", { className: "m-row", children: [_jsx("span", { id: "vt-move", children: "Position" }), _jsx("span", { className: "screen", role: "group", "aria-labelledby": "vt-move", children: SPOTS.map((s) => (_jsx("button", { type: "button", role: "menuitemradio", "aria-checked": current === s, "aria-label": `Move to ${SPOT_NAMES[s]}`, "data-v": isVertical(s) ? '' : undefined, style: gridCell(s), onClick: act(() => p.onMove({ spot: s })) }, s))) })] }), snap.canUnlink ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "m-rule" }), _jsxs("button", { type: "button", role: "menuitem", className: "mi danger", onClick: act(p.onAskUnlink), children: [_jsx(UnlinkIcon, {}), " Unlink this device"] })] })) : null, snap.prefs.verbose ? _jsx("div", { className: "m-foot", children: snap.version }) : null] }));
|
|
67
|
+
}
|
|
68
|
+
/** The cell a spot takes in the 3×3 miniature (the centre stays empty). */
|
|
69
|
+
function gridCell(s) {
|
|
70
|
+
const row = { t: 1, m: 2, b: 3 }[s[0]];
|
|
71
|
+
const col = { l: 1, c: 2, r: 3 }[s[1]];
|
|
72
|
+
return { gridRow: row, gridColumn: col };
|
|
73
|
+
}
|