@vitrinka/web 0.4.0 → 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 +58 -0
- package/README.md +34 -1
- package/build/hud.d.ts +4 -1
- package/build/hud.iife.js +6 -6
- package/build/one.iife.js +1 -0
- package/build/recorder/RecorderProvider.js +48 -9
- 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.js +70 -20
- package/build/recorder/hud/RecorderPill.js +6 -2
- package/build/recorder/hud/chords.d.ts +10 -0
- package/build/recorder/hud/chords.js +34 -0
- package/build/recorder/hud/controller.d.ts +24 -0
- package/build/recorder/hud/flow.d.ts +22 -1
- package/build/recorder/hud/flow.js +16 -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/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 +23 -2
- package/build/recorder/queue.js +5 -2
- package/build/recorder/report.js +9 -2
- package/build/recorder/session.d.ts +22 -4
- package/build/recorder/session.js +70 -20
- package/build/recorder/state.d.ts +9 -0
- package/build/recorder/state.js +7 -0
- package/build/recorder/version.d.ts +3 -0
- package/build/recorder/version.js +3 -0
- package/package.json +5 -3
|
@@ -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
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Chord = 'annotate' | 'note' | 'pause' | 'stop';
|
|
2
|
+
export type ChordKey = Pick<KeyboardEvent, 'altKey' | 'shiftKey' | 'metaKey' | 'ctrlKey' | 'code'>;
|
|
3
|
+
/** The chord a keydown is, by its physical key (⌥ rewrites `key` on a Mac); null for anything else. */
|
|
4
|
+
export declare function chordOf(e: ChordKey): Chord | null;
|
|
5
|
+
/**
|
|
6
|
+
* Bind the chords on `target` (window), capture phase — the host's shield
|
|
7
|
+
* stops a keydown from a focused HUD control before it could bubble there,
|
|
8
|
+
* and a drag leaves the handle focused. Returns the unbind.
|
|
9
|
+
*/
|
|
10
|
+
export declare function bindChords(target: EventTarget, on: (c: Chord) => void): () => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recorder shortcuts: ⌥⇧A annotate · ⌥⇧N note · ⌥⇧P pause · ⌥⇧S stop.
|
|
3
|
+
*
|
|
4
|
+
* Only the LEADER's HUD binds them (ONE recorder D9): a keydown on `window`
|
|
5
|
+
* reaches the listeners of the page's world and the extension's alike, so a
|
|
6
|
+
* follower that bound them too would act twice. Untrusted (synthetic)
|
|
7
|
+
* keydowns are taken on purpose: Chrome hands the extension's command chords
|
|
8
|
+
* to its worker, never to the page, and the worker relays them as a
|
|
9
|
+
* synthetic keydown — `isTrusted: false` (D10). A taken chord is
|
|
10
|
+
* `preventDefault`ed, never stopped, so a host that skips `defaultPrevented`
|
|
11
|
+
* keys (forge-studio's CommandProvider) leaves it alone.
|
|
12
|
+
*/
|
|
13
|
+
import { listen } from './listen';
|
|
14
|
+
const BY_CODE = { KeyA: 'annotate', KeyN: 'note', KeyP: 'pause', KeyS: 'stop' };
|
|
15
|
+
/** The chord a keydown is, by its physical key (⌥ rewrites `key` on a Mac); null for anything else. */
|
|
16
|
+
export function chordOf(e) {
|
|
17
|
+
if (!e.altKey || !e.shiftKey || e.metaKey || e.ctrlKey)
|
|
18
|
+
return null;
|
|
19
|
+
return BY_CODE[e.code] ?? null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bind the chords on `target` (window), capture phase — the host's shield
|
|
23
|
+
* stops a keydown from a focused HUD control before it could bubble there,
|
|
24
|
+
* and a drag leaves the handle focused. Returns the unbind.
|
|
25
|
+
*/
|
|
26
|
+
export function bindChords(target, on) {
|
|
27
|
+
return listen(target, 'keydown', (e) => {
|
|
28
|
+
const c = chordOf(e);
|
|
29
|
+
if (!c)
|
|
30
|
+
return;
|
|
31
|
+
on(c);
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
}, { capture: true });
|
|
34
|
+
}
|
|
@@ -108,7 +108,17 @@ export interface HudSnapshot {
|
|
|
108
108
|
* `attachments: true` to the policy read. Absent or false = text only.
|
|
109
109
|
*/
|
|
110
110
|
canAttach?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* ONE recorder: another recorder leads this browser's recording — the
|
|
113
|
+
* extension, or the page's own recorder — and this HUD is its remote. The
|
|
114
|
+
* HUD hides, closes its sheet, menu, link sheet and annotate mode (the
|
|
115
|
+
* drafts and their images survive, as a cancel keeps them; the dock spot
|
|
116
|
+
* stays) and binds no shortcut. Absent = this HUD's host leads or is idle.
|
|
117
|
+
*/
|
|
118
|
+
following?: 'page' | 'extension';
|
|
111
119
|
}
|
|
120
|
+
/** The pill's inline flow face (`hud/flow.ts`), as `faceChanged` reports it. */
|
|
121
|
+
export type HudFace = 'none' | 'confirm' | 'saving' | 'saved' | 'failed';
|
|
112
122
|
/** One image a tester attached, already normalized by the HUD:
|
|
113
123
|
* re-encoded (EXIF/GPS gone), long edge ≤ 2560 px, ≤ 12 MiB. */
|
|
114
124
|
export interface HudAttachment {
|
|
@@ -206,5 +216,19 @@ export interface HudController {
|
|
|
206
216
|
* without it never offers the menu row.
|
|
207
217
|
*/
|
|
208
218
|
report?(r: HudReport): Promise<HudSaved>;
|
|
219
|
+
/**
|
|
220
|
+
* ONE recorder D11: the HUD registers its own Stop flow; the controller
|
|
221
|
+
* runs it when the other side stops the recording remotely (its open sheet
|
|
222
|
+
* closes keeping the draft, annotate exits, Saving → Saved on this pill,
|
|
223
|
+
* no second confirm). Returns the unregister. A host whose HUD is not
|
|
224
|
+
* mounted stops directly. Optional.
|
|
225
|
+
*/
|
|
226
|
+
onRemoteStop?(run: () => void): () => void;
|
|
227
|
+
/**
|
|
228
|
+
* ONE recorder D7: the HUD reports its inline flow face, so the controller
|
|
229
|
+
* holds its claim as `saved` while Saving / Saved / failed shows after a
|
|
230
|
+
* stop. Optional.
|
|
231
|
+
*/
|
|
232
|
+
faceChanged?(face: HudFace): void;
|
|
209
233
|
}
|
|
210
234
|
export declare const DEFAULT_PREFS: HudPrefs;
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
8
|
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
9
|
+
* any but saving ─stop→ saving … (a remote stop: no confirm, ONE recorder D11)
|
|
10
|
+
* none ─startFailed→ failed ─dismiss→ none (a refused or failed Start, `start: true`, D12)
|
|
11
|
+
* confirm | saved | failed ─follow→ none (another recorder leads, or let go: the pill comes back
|
|
12
|
+
* idle; a refused Start's face stays until dismissed)
|
|
9
13
|
*
|
|
10
14
|
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
15
|
* failed faces carry `report: true` through retries, so the pill can say
|
|
@@ -32,10 +36,13 @@ export type Flow = {
|
|
|
32
36
|
boardUrl?: string;
|
|
33
37
|
sessionId?: string;
|
|
34
38
|
report?: true;
|
|
35
|
-
}
|
|
39
|
+
}
|
|
40
|
+
/** `start`: a Start that was refused or failed — nothing to retry, only dismiss. */
|
|
41
|
+
| {
|
|
36
42
|
face: 'failed';
|
|
37
43
|
message: string;
|
|
38
44
|
report?: true;
|
|
45
|
+
start?: true;
|
|
39
46
|
};
|
|
40
47
|
export type FlowEvent = {
|
|
41
48
|
type: 'ask';
|
|
@@ -61,6 +68,20 @@ export type FlowEvent = {
|
|
|
61
68
|
message: string;
|
|
62
69
|
} | {
|
|
63
70
|
type: 'dismiss';
|
|
71
|
+
}
|
|
72
|
+
/** The other recorder stopped this one's recording (D11): straight to saving. */
|
|
73
|
+
| {
|
|
74
|
+
type: 'stop';
|
|
75
|
+
queued: number;
|
|
76
|
+
}
|
|
77
|
+
/** A Start was refused (`recorder_busy`) or failed (D12). */
|
|
78
|
+
| {
|
|
79
|
+
type: 'startFailed';
|
|
80
|
+
message: string;
|
|
81
|
+
}
|
|
82
|
+
/** This HUD became, or stopped being, the other recorder's remote: nothing stays open. */
|
|
83
|
+
| {
|
|
84
|
+
type: 'follow';
|
|
64
85
|
};
|
|
65
86
|
export declare const NO_FLOW: Flow;
|
|
66
87
|
export declare function flowReducer(flow: Flow, ev: FlowEvent): Flow;
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
8
|
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
9
|
+
* any but saving ─stop→ saving … (a remote stop: no confirm, ONE recorder D11)
|
|
10
|
+
* none ─startFailed→ failed ─dismiss→ none (a refused or failed Start, `start: true`, D12)
|
|
11
|
+
* confirm | saved | failed ─follow→ none (another recorder leads, or let go: the pill comes back
|
|
12
|
+
* idle; a refused Start's face stays until dismissed)
|
|
9
13
|
*
|
|
10
14
|
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
15
|
* failed faces carry `report: true` through retries, so the pill can say
|
|
@@ -31,7 +35,8 @@ export function flowReducer(flow, ev) {
|
|
|
31
35
|
case 'send':
|
|
32
36
|
return flow.face === 'none' ? { face: 'saving', total: 0, report: true } : flow;
|
|
33
37
|
case 'retry':
|
|
34
|
-
|
|
38
|
+
// A failed Start has nothing to retry: pressing Start again is the retry.
|
|
39
|
+
return flow.face === 'failed' && !flow.start ? { face: 'saving', total: ev.queued, ...reportOf(flow) } : flow;
|
|
35
40
|
case 'saved':
|
|
36
41
|
return flow.face === 'saving'
|
|
37
42
|
? {
|
|
@@ -45,6 +50,16 @@ export function flowReducer(flow, ev) {
|
|
|
45
50
|
return flow.face === 'saving' ? { face: 'failed', message: ev.message, ...reportOf(flow) } : flow;
|
|
46
51
|
case 'dismiss':
|
|
47
52
|
return flow.face === 'saved' || flow.face === 'failed' ? NO_FLOW : flow;
|
|
53
|
+
case 'stop':
|
|
54
|
+
return flow.face === 'saving' ? flow : { face: 'saving', total: ev.queued };
|
|
55
|
+
case 'startFailed':
|
|
56
|
+
return flow.face === 'none' ? { face: 'failed', message: ev.message, start: true } : flow;
|
|
57
|
+
case 'follow':
|
|
58
|
+
// A save in flight keeps its face (it settles on its own), and so does
|
|
59
|
+
// a refused Start: it is what tells the tester why the pill steps aside.
|
|
60
|
+
if (flow.face === 'none' || flow.face === 'saving' || (flow.face === 'failed' && flow.start))
|
|
61
|
+
return flow;
|
|
62
|
+
return NO_FLOW;
|
|
48
63
|
}
|
|
49
64
|
}
|
|
50
65
|
/** Save progress 0…1 while draining `total` items of which `queued` remain; null = indeterminate. */
|
|
@@ -13,6 +13,7 @@ import { useRecorderRoute } from './RecorderProvider';
|
|
|
13
13
|
export { useRecorderRoute };
|
|
14
14
|
export type { RecorderControl, RecorderStatus } from './control';
|
|
15
15
|
export type { RecorderConfig } from './config';
|
|
16
|
+
export { type Leader, RecorderBusyError } from './lead';
|
|
16
17
|
export { configureRecorderStorage, type RecorderStorage } from './storage';
|
|
17
18
|
export interface VitrinkaRecorderRootProps {
|
|
18
19
|
/** vitrinka base URL; defaults to `NEXT_PUBLIC_VITRINKA_URL`. */
|
package/build/recorder/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { RecorderProvider, useRecorderRoute } from './RecorderProvider';
|
|
|
16
16
|
import { wantFlight } from './report';
|
|
17
17
|
import { getRecorderStorage } from './storage';
|
|
18
18
|
export { useRecorderRoute };
|
|
19
|
+
export { RecorderBusyError } from './lead';
|
|
19
20
|
export { configureRecorderStorage } from './storage';
|
|
20
21
|
/** Wrap the app root. Starts the capture lanes only when `url` + `key` are present. */
|
|
21
22
|
export function VitrinkaRecorderRoot(props) {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page side of ONE recorder (extension + page recorder decisions,
|
|
3
|
+
* 2026-10-12): this document's recorder either LEADS — holds the claim on
|
|
4
|
+
* `<html>` — or FOLLOWS the recorder that does: the browser extension, or
|
|
5
|
+
* another recorder bundle on the page. The protocol itself is `one.ts`.
|
|
6
|
+
*
|
|
7
|
+
* Started by the recorder root (`startLead`, RecorderProvider). While it runs:
|
|
8
|
+
* - `data-vitrinka-page` marks the document, written before the first ask
|
|
9
|
+
* (the extension's `one.js` answers only where it stands).
|
|
10
|
+
* - It answers `hello` asks with what it leads; the extension's hellos tell
|
|
11
|
+
* it the extension records — here (its claim) or in another tab (D6).
|
|
12
|
+
* - Following: `leadState.following` is set, every lane and the flight
|
|
13
|
+
* recorder go quiet, the HUD hides; a session of its own (resumed after a
|
|
14
|
+
* reload, joined from another tab) waits, capturing nothing, and resumes
|
|
15
|
+
* once the leader lets go (D14). The follower pings the holder when the
|
|
16
|
+
* claim changes, every 10 s, on becoming visible and before any remote
|
|
17
|
+
* command; a holder that does not answer is cleared under its own id (D5).
|
|
18
|
+
* - Leading: it holds the claim through every transition — starting,
|
|
19
|
+
* recording, paused, stopping, and `saved` while the HUD's stop face shows
|
|
20
|
+
* (D7) — and answers the holder's commands synchronously (D11).
|
|
21
|
+
*/
|
|
22
|
+
import type { HudFace } from './hud/controller';
|
|
23
|
+
import { type Claim, type CommandOp, type OneEnv, type OneParty } from './one';
|
|
24
|
+
export type Leader = OneParty;
|
|
25
|
+
/**
|
|
26
|
+
* A Start refused because another recorder leads (D12). `code` is
|
|
27
|
+
* `recorder_busy`; the message is shown verbatim where Start was pressed.
|
|
28
|
+
*/
|
|
29
|
+
export declare class RecorderBusyError extends Error {
|
|
30
|
+
readonly code: "recorder_busy";
|
|
31
|
+
readonly leader: Leader;
|
|
32
|
+
constructor(message: string, leader: Leader);
|
|
33
|
+
}
|
|
34
|
+
/** The leader's own doors, which a remote command opens (the root supplies them). */
|
|
35
|
+
export interface LeadHandlers {
|
|
36
|
+
pause(): void;
|
|
37
|
+
/** The direct stop, for when no HUD registered its Stop flow. */
|
|
38
|
+
stop(): void;
|
|
39
|
+
note(text: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Re-read the durable session record before a waiting session resumes
|
|
42
|
+
* (`resyncStoredSession`); false when the cached one ended or was replaced.
|
|
43
|
+
*/
|
|
44
|
+
resync?(): boolean;
|
|
45
|
+
}
|
|
46
|
+
/** How often a follower pings the holder. */
|
|
47
|
+
export declare const PING_MS = 10000;
|
|
48
|
+
/**
|
|
49
|
+
* Ping (D5): ask who is here, take the extension's word, clear a holder that
|
|
50
|
+
* no longer answers (under its own id), re-derive. A follower runs it every
|
|
51
|
+
* `PING_MS`, on becoming visible and before a remote command, so a page
|
|
52
|
+
* never waits on an extension that was reloaded or uninstalled.
|
|
53
|
+
*/
|
|
54
|
+
export declare function pingLeader(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Join the channel for this document; returns the leave. Idempotent across
|
|
57
|
+
* mounts (the last handlers win). `at` is the document's env unless a test
|
|
58
|
+
* passes its own.
|
|
59
|
+
*/
|
|
60
|
+
export declare function startLead(h: LeadHandlers, at?: OneEnv | null): () => void;
|
|
61
|
+
/**
|
|
62
|
+
* The Start check-and-set (D4, D12): synchronous, before any network call.
|
|
63
|
+
* Throws a `RecorderBusyError` while another recorder leads — a live claim
|
|
64
|
+
* whose holder answers, or the extension recording in another tab — else
|
|
65
|
+
* claims the document as `starting`. A no-op without a mounted root.
|
|
66
|
+
*/
|
|
67
|
+
export declare function claimForStart(): void;
|
|
68
|
+
/** The Start settled: created (the claim moves on with the session) or not (it goes). */
|
|
69
|
+
export declare function settleStart(created: boolean): void;
|
|
70
|
+
/** This document's Stop is draining `sessionId` (null: it settled). */
|
|
71
|
+
export declare function setLeadStopping(sessionId: string | null): void;
|
|
72
|
+
/** The HUD's flow face (D7). */
|
|
73
|
+
export declare function holdFace(f: HudFace): void;
|
|
74
|
+
/** The HUD's Stop flow, run by a remote stop (D11); returns the unregister. */
|
|
75
|
+
export declare function setRemoteStop(run: () => void): () => void;
|
|
76
|
+
/** Who leads now: this recorder (`page`), the one it follows, or nobody. */
|
|
77
|
+
export interface LeadStatus {
|
|
78
|
+
leader: Leader | null;
|
|
79
|
+
following: Leader | null;
|
|
80
|
+
/** This document's claim (any holder). */
|
|
81
|
+
claim: Claim | null;
|
|
82
|
+
}
|
|
83
|
+
export declare function leadStatus(): LeadStatus;
|
|
84
|
+
/**
|
|
85
|
+
* A follower's pause, stop or note, acted on by the leader (D11). Pings the
|
|
86
|
+
* holder first; throws with the reason when it is gone, refused, or the
|
|
87
|
+
* extension leads from another tab (whose endpoint here takes no command).
|
|
88
|
+
*/
|
|
89
|
+
export declare function sendToLeader(op: CommandOp, text?: string): void;
|
|
90
|
+
export declare function __resetLeadForTests(): void;
|