@vitrinka/web 0.3.2 → 0.3.4
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 +51 -0
- package/README.md +18 -0
- package/build/hud.d.ts +1 -1
- package/build/hud.iife.js +6 -6
- package/build/protocol/index.d.ts +11 -1
- package/build/recorder/control.js +2 -1
- package/build/recorder/hud/Hud.js +2 -2
- package/build/recorder/hud/RecorderPill.js +4 -1
- package/build/recorder/hud/controller.d.ts +11 -6
- package/build/recorder/hud/flow.d.ts +5 -1
- package/build/recorder/hud/flow.js +6 -1
- package/build/recorder/page-controller.js +5 -5
- package/build/recorder/queue.d.ts +33 -8
- package/build/recorder/queue.js +315 -43
- package/build/recorder/recents.d.ts +30 -0
- package/build/recorder/recents.js +53 -2
- package/build/recorder/report.d.ts +1 -0
- package/build/recorder/report.js +5 -3
- package/build/recorder/session.d.ts +7 -3
- package/build/recorder/session.js +35 -20
- package/build/recorder/storage/index.d.ts +4 -13
- package/build/recorder/storage/index.js +9 -4
- package/build/recorder/storage/lock.d.ts +2 -0
- package/build/recorder/storage/lock.js +48 -0
- package/build/recorder/tabs.d.ts +8 -0
- package/build/recorder/tabs.js +137 -0
- package/package.json +1 -1
|
@@ -65,10 +65,20 @@ export interface SessionReconcileResponse {
|
|
|
65
65
|
status?: string;
|
|
66
66
|
deletedAt?: string | null;
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* PATCH response when a session completes. The board is projected AFTER the
|
|
70
|
+
* stop, so `boardUrl` is usually absent here: `projection` says how far it
|
|
71
|
+
* got, and the session read names the board once it exists.
|
|
72
|
+
*/
|
|
69
73
|
export interface SessionDone {
|
|
70
74
|
boardSlug?: string;
|
|
75
|
+
/** The board's address, minted by the server; only once the board exists. */
|
|
76
|
+
boardUrl?: string;
|
|
77
|
+
/** An older server's spelling of `boardUrl`. */
|
|
71
78
|
board?: {
|
|
72
79
|
url?: string;
|
|
73
80
|
};
|
|
81
|
+
projection?: {
|
|
82
|
+
state?: string;
|
|
83
|
+
};
|
|
74
84
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the HUD, and read a status snapshot back.
|
|
6
6
|
*/
|
|
7
7
|
import { getState, health } from './queue';
|
|
8
|
+
import { boardUrlOf } from './recents';
|
|
8
9
|
import { addNote, elapsedOf, startSession, stopSession, togglePause } from './session';
|
|
9
10
|
export function snapshot() {
|
|
10
11
|
const rec = getState();
|
|
@@ -42,7 +43,7 @@ export function installControl() {
|
|
|
42
43
|
async stop() {
|
|
43
44
|
const captured = snapshot();
|
|
44
45
|
const done = await stopSession();
|
|
45
|
-
return { ...captured, boardUrl: done
|
|
46
|
+
return { ...captured, boardUrl: boardUrlOf(done) ?? captured.boardUrl };
|
|
46
47
|
},
|
|
47
48
|
note(text) {
|
|
48
49
|
const t = text.trim();
|
|
@@ -201,7 +201,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
201
201
|
return;
|
|
202
202
|
sent.then((res) => {
|
|
203
203
|
setReportDraft('');
|
|
204
|
-
settle({ type: 'saved', ...
|
|
204
|
+
settle({ type: 'saved', ...res });
|
|
205
205
|
}, (e) => {
|
|
206
206
|
console.warn('vitrinka: report —', errorText(e));
|
|
207
207
|
settle({ type: 'failed', message: errorText(e) });
|
|
@@ -259,7 +259,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
259
259
|
const runStop = useCallback(() => {
|
|
260
260
|
const t0 = Date.now();
|
|
261
261
|
const settle = (ev) => setTimeout(() => dispatch(ev), Math.max(0, MIN_SAVING_MS - (Date.now() - t0)));
|
|
262
|
-
controller.stop().then((r) => settle({ type: 'saved', ...
|
|
262
|
+
controller.stop().then((r) => settle({ type: 'saved', ...r }), (e) => {
|
|
263
263
|
console.warn('vitrinka: stop —', errorText(e));
|
|
264
264
|
settle({ type: 'failed', message: errorText(e) });
|
|
265
265
|
});
|
|
@@ -302,7 +302,10 @@ export function RecorderPill(p) {
|
|
|
302
302
|
};
|
|
303
303
|
const flowShown = shownFlow.face;
|
|
304
304
|
const confirmAction = shownFlow.face === 'confirm' ? shownFlow.action : 'stop';
|
|
305
|
-
|
|
305
|
+
// Saved before its board was built: the link arrives on the recent once the server names it.
|
|
306
|
+
const savedUrl = shownFlow.face === 'saved'
|
|
307
|
+
? (shownFlow.boardUrl ?? p.snap.recents.find((r) => r.sessionId === shownFlow.sessionId)?.boardUrl)
|
|
308
|
+
: undefined;
|
|
306
309
|
const failure = shownFlow.face === 'failed' ? shownFlow.message : '';
|
|
307
310
|
// A bug report's send: "Sending…", "Sent", "Couldn't send" — and it can always be retried.
|
|
308
311
|
const report = 'report' in shownFlow && shownFlow.report === true;
|
|
@@ -136,6 +136,15 @@ export interface HudReport {
|
|
|
136
136
|
/** The marked element's selector; '' for a region or no mark. */
|
|
137
137
|
selector: string;
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* What a stop or an idle report saved. `boardUrl` when the board already
|
|
141
|
+
* exists; else `sessionId` names the recent whose link the Saved face takes
|
|
142
|
+
* once the server has built the board.
|
|
143
|
+
*/
|
|
144
|
+
export interface HudSaved {
|
|
145
|
+
boardUrl?: string;
|
|
146
|
+
sessionId?: string;
|
|
147
|
+
}
|
|
139
148
|
export interface HudController {
|
|
140
149
|
getSnapshot(): HudSnapshot;
|
|
141
150
|
subscribe(listener: () => void): () => void;
|
|
@@ -144,9 +153,7 @@ export interface HudController {
|
|
|
144
153
|
}): Promise<void>;
|
|
145
154
|
togglePause(): Promise<void>;
|
|
146
155
|
/** Drains, then closes the session; rejects (session kept) while unreachable. */
|
|
147
|
-
stop(): Promise<
|
|
148
|
-
boardUrl?: string;
|
|
149
|
-
}>;
|
|
156
|
+
stop(): Promise<HudSaved>;
|
|
150
157
|
note(text: string): void;
|
|
151
158
|
annotate(a: HudAnnotation): void;
|
|
152
159
|
setAnnotating(active: boolean): void;
|
|
@@ -170,8 +177,6 @@ export interface HudController {
|
|
|
170
177
|
* second call after a rejection retries the same report. Optional: a host
|
|
171
178
|
* without it never offers the menu row.
|
|
172
179
|
*/
|
|
173
|
-
report?(r: HudReport): Promise<
|
|
174
|
-
boardUrl?: string;
|
|
175
|
-
}>;
|
|
180
|
+
report?(r: HudReport): Promise<HudSaved>;
|
|
176
181
|
}
|
|
177
182
|
export declare const DEFAULT_PREFS: HudPrefs;
|
|
@@ -25,9 +25,12 @@ export type Flow = {
|
|
|
25
25
|
face: 'saving';
|
|
26
26
|
total: number;
|
|
27
27
|
report?: true;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
/** `sessionId` lets a face saved before its board existed take the link from recents. */
|
|
30
|
+
| {
|
|
29
31
|
face: 'saved';
|
|
30
32
|
boardUrl?: string;
|
|
33
|
+
sessionId?: string;
|
|
31
34
|
report?: true;
|
|
32
35
|
} | {
|
|
33
36
|
face: 'failed';
|
|
@@ -52,6 +55,7 @@ export type FlowEvent = {
|
|
|
52
55
|
} | {
|
|
53
56
|
type: 'saved';
|
|
54
57
|
boardUrl?: string;
|
|
58
|
+
sessionId?: string;
|
|
55
59
|
} | {
|
|
56
60
|
type: 'failed';
|
|
57
61
|
message: string;
|
|
@@ -34,7 +34,12 @@ export function flowReducer(flow, ev) {
|
|
|
34
34
|
return flow.face === 'failed' ? { face: 'saving', total: ev.queued, ...reportOf(flow) } : flow;
|
|
35
35
|
case 'saved':
|
|
36
36
|
return flow.face === 'saving'
|
|
37
|
-
? {
|
|
37
|
+
? {
|
|
38
|
+
face: 'saved',
|
|
39
|
+
...(ev.boardUrl ? { boardUrl: ev.boardUrl } : {}),
|
|
40
|
+
...(ev.sessionId ? { sessionId: ev.sessionId } : {}),
|
|
41
|
+
...reportOf(flow),
|
|
42
|
+
}
|
|
38
43
|
: flow;
|
|
39
44
|
case 'failed':
|
|
40
45
|
return flow.face === 'saving' ? { face: 'failed', message: ev.message, ...reportOf(flow) } : flow;
|
|
@@ -2,7 +2,7 @@ import { readLink, recorderConfig, vitrinkaLinked } from './config';
|
|
|
2
2
|
import { forgetLink, linkDevice } from './link';
|
|
3
3
|
import { cachedAccount, cachedPrefs, fetchMe, savePrefs } from './me';
|
|
4
4
|
import { getState, health } from './queue';
|
|
5
|
-
import { readRecents, refreshRecents } from './recents';
|
|
5
|
+
import { boardUrlOf, readRecents, refreshRecents } from './recents';
|
|
6
6
|
import { canReport, holdReport, sendReport } from './report';
|
|
7
7
|
import { addAnnotation, addNote, RECORDER_ID, startSession, stopSession, togglePause } from './session';
|
|
8
8
|
import { annotateState, setAnnotating, subscribe } from './state';
|
|
@@ -71,13 +71,13 @@ export function createPageController() {
|
|
|
71
71
|
},
|
|
72
72
|
async stop() {
|
|
73
73
|
const boardUrl = getState()?.boardUrl;
|
|
74
|
-
const
|
|
74
|
+
const sessionId = getState()?.sessionId;
|
|
75
75
|
const done = await stopSession();
|
|
76
76
|
// null for a live session = the server refused to close it (ended locally, not saved).
|
|
77
|
-
if (
|
|
77
|
+
if (sessionId && done === null)
|
|
78
78
|
throw new Error('the server refused to close this session — it ended locally, not saved');
|
|
79
|
-
const url = done
|
|
80
|
-
return url ? { boardUrl: url } : {};
|
|
79
|
+
const url = boardUrlOf(done) ?? boardUrl;
|
|
80
|
+
return { ...(url ? { boardUrl: url } : {}), ...(sessionId ? { sessionId } : {}) };
|
|
81
81
|
},
|
|
82
82
|
note: (text) => addNote(text),
|
|
83
83
|
annotate: ({ text, rect, selector, task }) => addAnnotation(text, rect, selector, { task }),
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - A synchronous KV store (./storage — localStorage by default, memory when
|
|
6
6
|
* that is unavailable) holds the session record and the event buffer:
|
|
7
|
-
*
|
|
8
|
-
* flush()
|
|
9
|
-
* exactly the sent seqs on return.
|
|
7
|
+
* seq allocation is serialized across tabs by the driver's lock, reading
|
|
8
|
+
* the shared watermark inside it. flush() is single-flight within each
|
|
9
|
+
* document and removes exactly the sent seqs on return.
|
|
10
10
|
* - rrweb batches ride as CHUNKS the way the extension sends them: each batch
|
|
11
11
|
* is serialized once, split under the server's chunk cap, uploaded to
|
|
12
12
|
* `/chunk?seq=N` under a pre-allocated seq, and only then does its `rrweb`
|
|
@@ -61,7 +61,24 @@ export interface SessionState {
|
|
|
61
61
|
* reload re-applies the same rules instead of silently reverting.
|
|
62
62
|
*/
|
|
63
63
|
policy?: RedactionPolicy | null;
|
|
64
|
+
/**
|
|
65
|
+
* When (ISO) another tab last renewed its claim to be stopping this
|
|
66
|
+
* session: the copy it stores reads as paused with its clock frozen at the
|
|
67
|
+
* Stop, so every other tab stops capturing and painting rec at once, not
|
|
68
|
+
* when the save ends. The stopping tab renews the mark every
|
|
69
|
+
* `STOPPING_RENEW_MS` for as long as its Stop is out (however long a
|
|
70
|
+
* request hangs); pause and resume are refused on a mark younger than
|
|
71
|
+
* `STOPPING_TTL_MS` (`stoppingElsewhere`). An older one outlived its tab
|
|
72
|
+
* and is an ordinary pause. Stop always works.
|
|
73
|
+
*/
|
|
74
|
+
stopping?: string;
|
|
64
75
|
}
|
|
76
|
+
/** How often a tab renews its `stopping` mark while its Stop is out. */
|
|
77
|
+
export declare const STOPPING_RENEW_MS = 20000;
|
|
78
|
+
/** A mark not renewed for this long outlived its tab: several missed renewals, and past the one wake a minute Chrome allows a long-hidden tab. */
|
|
79
|
+
export declare const STOPPING_TTL_MS = 90000;
|
|
80
|
+
/** Is another tab still stopping `rec` (a fresh `stopping` mark)? */
|
|
81
|
+
export declare function stoppingElsewhere(rec: SessionState): boolean;
|
|
65
82
|
export type { RecorderEvent };
|
|
66
83
|
/** Storage key of the session record — shared by every tab of the origin. */
|
|
67
84
|
export declare const REC_KEY = "rec";
|
|
@@ -72,7 +89,16 @@ export declare const REC_KEY = "rec";
|
|
|
72
89
|
*/
|
|
73
90
|
export declare function getState(): SessionState | null;
|
|
74
91
|
export declare function setState(rec: SessionState | null): void;
|
|
92
|
+
/**
|
|
93
|
+
* This tab started (`sessionId`) or finished (null) stopping a session. Only
|
|
94
|
+
* the STORED record changes: this tab's own cache stays live, so the tail
|
|
95
|
+
* its Stop still drains (rrweb's last events, settled captures) lands.
|
|
96
|
+
* Finishing writes the record back without the mark.
|
|
97
|
+
*/
|
|
98
|
+
export declare function markStopping(sessionId: string | null, activeMs?: number, renewMs?: number): void;
|
|
75
99
|
export type StoredChange = 'joined' | 'updated' | 'ended' | 'unchanged';
|
|
100
|
+
export declare function onBeforeStop(fn: () => void): () => void;
|
|
101
|
+
export declare function runBeforeStopHooks(): void;
|
|
76
102
|
/**
|
|
77
103
|
* Another document of this origin (a second tab) wrote the session record.
|
|
78
104
|
* The store is shared, this cache is not — a tab that joined a recording on
|
|
@@ -117,11 +143,10 @@ export declare function markSessionDead(reason: string): void;
|
|
|
117
143
|
export declare function reconcile(): Promise<void>;
|
|
118
144
|
export declare function armReconcile(): void;
|
|
119
145
|
export declare function disarmReconcile(): void;
|
|
120
|
-
/**
|
|
121
|
-
export declare
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
} | null;
|
|
146
|
+
/** Document identity is not sessionStorage: duplicated tabs copy that store. */
|
|
147
|
+
export declare const RECORDER_DOCUMENT_KEY: string;
|
|
148
|
+
/** A departing document can be acknowledged by a helper only with a full journal. */
|
|
149
|
+
export declare function tailIsDurable(): boolean;
|
|
125
150
|
export declare function trackCapture(p: Promise<void>): Promise<void>;
|
|
126
151
|
export declare const CAPTURES_SETTLE_MS = 5000;
|
|
127
152
|
/** Wait for in-flight captures, bounded; false when stragglers were abandoned. */
|