@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { api, VitrinkaApiError } from './api';
|
|
2
|
+
import { notify } from './state';
|
|
3
|
+
import { getRecorderStorage } from './storage';
|
|
4
|
+
export const RECENTS_KEY = 'recents';
|
|
5
|
+
export const MAX_RECENTS = 5;
|
|
6
|
+
const STATUSES = ['recording', 'saved', 'unsaved', 'deleted'];
|
|
7
|
+
function valid(r) {
|
|
8
|
+
if (!r || typeof r !== 'object')
|
|
9
|
+
return false;
|
|
10
|
+
const o = r;
|
|
11
|
+
return (typeof o.sessionId === 'string' &&
|
|
12
|
+
typeof o.title === 'string' &&
|
|
13
|
+
typeof o.startedAt === 'number' &&
|
|
14
|
+
STATUSES.includes(o.status));
|
|
15
|
+
}
|
|
16
|
+
let cache;
|
|
17
|
+
export function readRecents() {
|
|
18
|
+
if (cache === undefined) {
|
|
19
|
+
try {
|
|
20
|
+
const raw = JSON.parse(getRecorderStorage().getString(RECENTS_KEY) ?? '[]');
|
|
21
|
+
cache = Array.isArray(raw) ? raw.filter(valid).slice(0, MAX_RECENTS) : [];
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
cache = [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return cache;
|
|
28
|
+
}
|
|
29
|
+
function write(list) {
|
|
30
|
+
cache = list.slice(0, MAX_RECENTS);
|
|
31
|
+
try {
|
|
32
|
+
getRecorderStorage().set(RECENTS_KEY, JSON.stringify(cache));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.warn('vitrinka: could not store recent recordings', e);
|
|
36
|
+
}
|
|
37
|
+
notify();
|
|
38
|
+
}
|
|
39
|
+
/** Add (or move to the front) a recording. */
|
|
40
|
+
export function noteRecent(entry) {
|
|
41
|
+
write([entry, ...readRecents().filter((r) => r.sessionId !== entry.sessionId)]);
|
|
42
|
+
}
|
|
43
|
+
/** Patch a recording in place; a no-op for one not listed. */
|
|
44
|
+
export function updateRecent(sessionId, patch) {
|
|
45
|
+
const list = readRecents();
|
|
46
|
+
if (!list.some((r) => r.sessionId === sessionId))
|
|
47
|
+
return;
|
|
48
|
+
write(list.map((r) => (r.sessionId === sessionId ? { ...r, ...patch } : r)));
|
|
49
|
+
}
|
|
50
|
+
/** Ids already asked this document — a refused read is not retried on every menu open. */
|
|
51
|
+
const asked = new Set();
|
|
52
|
+
/**
|
|
53
|
+
* Fill the board links the list lacks — `live` (the recording in progress)
|
|
54
|
+
* is skipped, its link arrives with its stop. Never rejects.
|
|
55
|
+
*/
|
|
56
|
+
export async function refreshRecents(live) {
|
|
57
|
+
const missing = readRecents().filter((r) => !r.boardUrl && r.status !== 'deleted' && r.sessionId !== live && !asked.has(r.sessionId));
|
|
58
|
+
for (const r of missing) {
|
|
59
|
+
asked.add(r.sessionId);
|
|
60
|
+
try {
|
|
61
|
+
const s = await api('GET', `/api/v1/sessions/${r.sessionId}`);
|
|
62
|
+
const boardUrl = s.boardUrl ?? s.board?.url;
|
|
63
|
+
if (s.deletedAt)
|
|
64
|
+
updateRecent(r.sessionId, { status: 'deleted' });
|
|
65
|
+
else if (boardUrl)
|
|
66
|
+
updateRecent(r.sessionId, { boardUrl, ...(s.status === 'done' ? { status: 'saved' } : {}) });
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (e instanceof VitrinkaApiError && e.status === 404)
|
|
70
|
+
updateRecent(r.sessionId, { status: 'deleted' });
|
|
71
|
+
else
|
|
72
|
+
console.warn(`vitrinka: could not refresh recent session ${r.sessionId}`, e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Test-only: forget the in-memory list (storage stays). */
|
|
77
|
+
export function __resetRecentsForTests() {
|
|
78
|
+
cache = undefined;
|
|
79
|
+
asked.clear();
|
|
80
|
+
}
|
|
@@ -17,8 +17,8 @@ import { type SessionState } from './queue';
|
|
|
17
17
|
export { currentRoute, notify, subscribe } from './state';
|
|
18
18
|
export type { SessionDone } from '../protocol';
|
|
19
19
|
/** Sent as `meta.recorder`; bumped with the package version. */
|
|
20
|
-
export declare const RECORDER_VERSION = "0.
|
|
21
|
-
export declare const RECORDER_ID = "web/0.
|
|
20
|
+
export declare const RECORDER_VERSION = "0.2.0";
|
|
21
|
+
export declare const RECORDER_ID = "web/0.2.0";
|
|
22
22
|
/** What `POST /api/v1/sessions` answers (the fields this recorder keeps). */
|
|
23
23
|
export interface SessionOut {
|
|
24
24
|
id: string;
|
|
@@ -2,10 +2,11 @@ import { api, fetchPolicy, permanentStatus, VitrinkaApiError } from './api';
|
|
|
2
2
|
import { setRedactionPolicy } from './capture/redact';
|
|
3
3
|
import { recorderConfig } from './config';
|
|
4
4
|
import { armReconcile, capturesSettled, disarmReconcile, drainBuffer, getState, pushEvent, queuedCount, resetHealth, resetIdle, resetQueues, setState, } from './queue';
|
|
5
|
+
import { noteRecent, updateRecent } from './recents';
|
|
5
6
|
import { currentRoute, notify } from './state';
|
|
6
7
|
export { currentRoute, notify, subscribe } from './state';
|
|
7
8
|
/** Sent as `meta.recorder`; bumped with the package version. */
|
|
8
|
-
export const RECORDER_VERSION = '0.
|
|
9
|
+
export const RECORDER_VERSION = '0.2.0';
|
|
9
10
|
export const RECORDER_ID = `web/${RECORDER_VERSION}`;
|
|
10
11
|
/**
|
|
11
12
|
* Re-apply a RECOVERED session's redaction policy after a reload — and
|
|
@@ -64,6 +65,7 @@ export async function startSession(opts = {}) {
|
|
|
64
65
|
const ses = await api('POST', '/api/v1/sessions', {
|
|
65
66
|
host: pageHost(),
|
|
66
67
|
title: opts.title || '',
|
|
68
|
+
...(cfg.project ? { project: cfg.project } : {}),
|
|
67
69
|
...(environment ? { environment } : {}),
|
|
68
70
|
meta: {
|
|
69
71
|
recorder: RECORDER_ID,
|
|
@@ -94,6 +96,13 @@ export async function startSession(opts = {}) {
|
|
|
94
96
|
resetQueues();
|
|
95
97
|
resetHealth();
|
|
96
98
|
resetIdle();
|
|
99
|
+
noteRecent({
|
|
100
|
+
sessionId: ses.id,
|
|
101
|
+
title: ses.title,
|
|
102
|
+
startedAt: Date.now(),
|
|
103
|
+
status: 'recording',
|
|
104
|
+
...(ses.boardUrl ? { boardUrl: ses.boardUrl } : {}),
|
|
105
|
+
});
|
|
97
106
|
await attachTags(ses.id, opts.tags);
|
|
98
107
|
armReconcile();
|
|
99
108
|
pushEvent('nav', { url: currentUrl(), route: currentRoute.pathname }, { tabId: currentRoute.tabId, tabHost: currentRoute.tabHost });
|
|
@@ -187,6 +196,8 @@ export async function stopSession() {
|
|
|
187
196
|
const rec = getState();
|
|
188
197
|
if (!rec)
|
|
189
198
|
return null;
|
|
199
|
+
// The recording's length is what the tester saw at Stop, not Stop + drain.
|
|
200
|
+
const durationMs = elapsedOf(rec);
|
|
190
201
|
disarmReconcile();
|
|
191
202
|
for (const fn of beforeStopHooks) {
|
|
192
203
|
try {
|
|
@@ -198,6 +209,7 @@ export async function stopSession() {
|
|
|
198
209
|
}
|
|
199
210
|
const completeDeadStop = (reason) => {
|
|
200
211
|
const kept = queuedCount();
|
|
212
|
+
updateRecent(rec.sessionId, { status: 'unsaved', durationMs });
|
|
201
213
|
setState(null);
|
|
202
214
|
setRedactionPolicy(null);
|
|
203
215
|
resetQueues();
|
|
@@ -238,6 +250,9 @@ export async function stopSession() {
|
|
|
238
250
|
throw e;
|
|
239
251
|
}
|
|
240
252
|
}
|
|
253
|
+
// A permanent refusal still ends the recording locally, but it was not saved.
|
|
254
|
+
const boardUrl = done?.board?.url ?? rec.boardUrl;
|
|
255
|
+
updateRecent(rec.sessionId, { status: done ? 'saved' : 'unsaved', durationMs, ...(boardUrl ? { boardUrl } : {}) });
|
|
241
256
|
setState(null);
|
|
242
257
|
setRedactionPolicy(null);
|
|
243
258
|
resetQueues();
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* back to the in-memory driver: capture still works for the life of the
|
|
12
12
|
* document, only the reload-survival guarantee is lost — and it says so once.
|
|
13
13
|
*/
|
|
14
|
-
// Keys land as `vitrinka.recorder.<key>`: rec · buffer · chunks · link
|
|
14
|
+
// Keys land as `vitrinka.recorder.<key>`: rec · buffer · chunks · link (the
|
|
15
|
+
// recorder) and dock · prefs · me · recents (the HUD).
|
|
15
16
|
const PREFIX = 'vitrinka.recorder.';
|
|
16
17
|
let current = null;
|
|
17
18
|
let used = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrinka/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "vitrinka toolkit for React DOM apps — the journey recorder: capture manual-testing sessions (rrweb DOM stream, clicks, navigation, network, console, notes) straight into vitrinka boards.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"types": "./build/next.d.ts",
|
|
30
30
|
"default": "./build/next.js"
|
|
31
31
|
},
|
|
32
|
+
"./hud": {
|
|
33
|
+
"types": "./build/hud.d.ts",
|
|
34
|
+
"default": "./build/hud.js"
|
|
35
|
+
},
|
|
36
|
+
"./hud.iife.js": "./build/hud.iife.js",
|
|
32
37
|
"./package.json": "./package.json"
|
|
33
38
|
},
|
|
34
39
|
"files": [
|
|
@@ -38,11 +43,12 @@
|
|
|
38
43
|
],
|
|
39
44
|
"sideEffects": false,
|
|
40
45
|
"scripts": {
|
|
41
|
-
"build": "tsc -p tsconfig.build.json",
|
|
46
|
+
"build": "tsc -p tsconfig.build.json && bun run build:hud",
|
|
47
|
+
"build:hud": "bun build src/recorder/hud/iife.ts --format=iife --minify --target=browser --define process.env.NODE_ENV='\"production\"' --outfile build/hud.iife.js",
|
|
42
48
|
"typecheck": "tsc --noEmit",
|
|
43
49
|
"test": "bun test src",
|
|
44
50
|
"test:e2e": "playwright test -c playwright.config.ts --workers 1",
|
|
45
|
-
"prepublishOnly": "tsc -p tsconfig.build.json"
|
|
51
|
+
"prepublishOnly": "tsc -p tsconfig.build.json && bun run build:hud"
|
|
46
52
|
},
|
|
47
53
|
"dependencies": {
|
|
48
54
|
"@vitrinka/link": "^0.1.2",
|