@vitrinka/web 0.2.0 → 0.2.1
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 +17 -0
- package/build/hud.iife.js +6 -6
- package/build/recorder/hud/AnnotateOverlay.js +19 -23
- package/build/recorder/hud/Hud.js +6 -6
- package/build/recorder/hud/controller.d.ts +1 -1
- package/build/recorder/hud/listen.d.ts +24 -0
- package/build/recorder/hud/listen.js +27 -0
- package/build/recorder/hud/useDock.js +2 -2
- package/build/recorder/link.js +1 -1
- package/build/recorder/session.d.ts +2 -2
- package/build/recorder/session.js +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,7 @@ import { elementText, shortSelector } from '../capture/selector';
|
|
|
30
30
|
import { RRWEB_BLOCK_ATTR } from '../block';
|
|
31
31
|
import { AnnotateIcon } from './icons';
|
|
32
32
|
import { insideHud } from './host';
|
|
33
|
+
import { listen } from './listen';
|
|
33
34
|
import { ANNOTATE_PAGE_CSS } from './styles';
|
|
34
35
|
const TOUCH = ['touchstart', 'touchmove', 'touchend'];
|
|
35
36
|
const TAIL = ['touchend', 'mousedown', 'mouseup', 'click'];
|
|
@@ -60,13 +61,12 @@ function swallowGestureTail() {
|
|
|
60
61
|
if (e.type === 'click')
|
|
61
62
|
off();
|
|
62
63
|
};
|
|
64
|
+
const offs = TAIL.map((t) => listen(window, t, eat, { capture: true }));
|
|
63
65
|
const off = () => {
|
|
64
|
-
for (const
|
|
65
|
-
|
|
66
|
+
for (const o of offs)
|
|
67
|
+
o();
|
|
66
68
|
window.removeEventListener('pointerdown', off, true);
|
|
67
69
|
};
|
|
68
|
-
for (const t of TAIL)
|
|
69
|
-
window.addEventListener(t, eat, { capture: true, passive: false });
|
|
70
70
|
window.addEventListener('pointerdown', off, true);
|
|
71
71
|
}
|
|
72
72
|
export function AnnotateOverlay({ onPick, onCancel }) {
|
|
@@ -224,36 +224,32 @@ export function AnnotateOverlay({ onPick, onCancel }) {
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
window.addEventListener('pointermove', move, true);
|
|
227
|
-
window.addEventListener('pointerdown', down, true);
|
|
228
|
-
window.addEventListener('pointerup', up, true);
|
|
229
|
-
window.addEventListener('click', swallowClick, true);
|
|
230
227
|
window.addEventListener('pointercancel', cancel, true);
|
|
231
|
-
window.addEventListener('dragstart', noDrag, true);
|
|
232
|
-
window.addEventListener('mousedown', noSelect, true);
|
|
233
|
-
window.addEventListener('selectstart', noSelect, true);
|
|
234
228
|
for (const t of HUSHED)
|
|
235
229
|
window.addEventListener(t, hush, true);
|
|
236
|
-
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
230
|
+
// Every cancelling listener goes through `listen`: non-passive (window
|
|
231
|
+
// touch listeners default to passive) and native, so a zone.js host
|
|
232
|
+
// cannot fold it into a passive listener registered before it.
|
|
233
|
+
const offs = [
|
|
234
|
+
listen(window, 'pointerdown', down, { capture: true }),
|
|
235
|
+
listen(window, 'pointerup', up, { capture: true }),
|
|
236
|
+
listen(window, 'click', swallowClick, { capture: true }),
|
|
237
|
+
listen(window, 'dragstart', noDrag, { capture: true }),
|
|
238
|
+
listen(window, 'mousedown', noSelect, { capture: true }),
|
|
239
|
+
listen(window, 'selectstart', noSelect, { capture: true }),
|
|
240
|
+
listen(document, 'keydown', key, { capture: true }),
|
|
241
|
+
...TOUCH.map((t) => listen(window, t, blockTouch, { capture: true })),
|
|
242
|
+
];
|
|
240
243
|
return () => {
|
|
241
244
|
pageCss.remove();
|
|
242
245
|
if (raf !== 0)
|
|
243
246
|
cancelAnimationFrame(raf);
|
|
244
247
|
window.removeEventListener('pointermove', move, true);
|
|
245
|
-
window.removeEventListener('pointerdown', down, true);
|
|
246
|
-
window.removeEventListener('pointerup', up, true);
|
|
247
|
-
window.removeEventListener('click', swallowClick, true);
|
|
248
248
|
window.removeEventListener('pointercancel', cancel, true);
|
|
249
|
-
window.removeEventListener('dragstart', noDrag, true);
|
|
250
|
-
window.removeEventListener('mousedown', noSelect, true);
|
|
251
|
-
window.removeEventListener('selectstart', noSelect, true);
|
|
252
249
|
for (const t of HUSHED)
|
|
253
250
|
window.removeEventListener(t, hush, true);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
window.removeEventListener(t, blockTouch, true);
|
|
251
|
+
for (const off of offs)
|
|
252
|
+
off();
|
|
257
253
|
};
|
|
258
254
|
}, [onPick, onCancel]);
|
|
259
255
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "dim", "data-e2e": "annotate-dim" }), box ? (_jsx("div", { className: "outline", style: { left: box.x, top: box.y, width: box.w, height: box.h } })) : null, _jsxs("div", { className: "hint", children: [_jsx(AnnotateIcon, {}), " Click an element or drag an area", _jsx("span", { className: "keys", children: " \u00B7 esc cancels" })] })] }));
|
|
@@ -16,6 +16,7 @@ import { flowReducer, NO_FLOW } from './flow';
|
|
|
16
16
|
import { createSheetHost, insideHud, sheetTarget } from './host';
|
|
17
17
|
import { anchoredLayer, hostOrigin, PHONE_QUERY, phoneLayer, restingBox, useFloat, useMedia, usePresence, useViewportTick, } from './layer';
|
|
18
18
|
import { LinkSheet } from './LinkSheet';
|
|
19
|
+
import { listen } from './listen';
|
|
19
20
|
import { Menu } from './Menu';
|
|
20
21
|
import { alignFor, towardCentre } from './place';
|
|
21
22
|
import { RecorderPill } from './RecorderPill';
|
|
@@ -255,8 +256,7 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
255
256
|
return;
|
|
256
257
|
e.preventDefault();
|
|
257
258
|
};
|
|
258
|
-
window
|
|
259
|
-
return () => window.removeEventListener('keydown', key, true);
|
|
259
|
+
return listen(window, 'keydown', key, { capture: true });
|
|
260
260
|
}, [toggleAnnotate, openNote, onPause, askStop]);
|
|
261
261
|
// Esc anywhere and click-outside close the sheet (capture-phase, so the
|
|
262
262
|
// page's own dialog never sees the Esc that closed ours).
|
|
@@ -275,10 +275,10 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
275
275
|
return;
|
|
276
276
|
closeSheet();
|
|
277
277
|
};
|
|
278
|
-
document
|
|
278
|
+
const offKey = listen(document, 'keydown', key, { capture: true });
|
|
279
279
|
document.addEventListener('pointerdown', down, true);
|
|
280
280
|
return () => {
|
|
281
|
-
|
|
281
|
+
offKey();
|
|
282
282
|
document.removeEventListener('pointerdown', down, true);
|
|
283
283
|
};
|
|
284
284
|
}, [sheet, closeSheet]);
|
|
@@ -299,10 +299,10 @@ export function Hud({ controller, hostMount, defaultTitle, storage }) {
|
|
|
299
299
|
if (!path.includes(menuRef.current) && !path.includes(pillRef.current))
|
|
300
300
|
setMenu(false);
|
|
301
301
|
};
|
|
302
|
-
document
|
|
302
|
+
const offKey = listen(document, 'keydown', key, { capture: true });
|
|
303
303
|
document.addEventListener('pointerdown', down, true);
|
|
304
304
|
return () => {
|
|
305
|
-
|
|
305
|
+
offKey();
|
|
306
306
|
document.removeEventListener('pointerdown', down, true);
|
|
307
307
|
};
|
|
308
308
|
}, [menu]);
|
|
@@ -92,7 +92,7 @@ export interface HudSnapshot {
|
|
|
92
92
|
recents: readonly HudRecent[];
|
|
93
93
|
/** "Go to vitrinka": the configured workspace URL. */
|
|
94
94
|
workspaceUrl: string;
|
|
95
|
-
/** Recorder id, e.g. `web/0.2.
|
|
95
|
+
/** Recorder id, e.g. `web/0.2.1` (verbose mode shows it). */
|
|
96
96
|
version: string;
|
|
97
97
|
}
|
|
98
98
|
/** The code half of a device link, as the link sheet paints it. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `listen` — the ONE way the HUD registers a window/document listener that
|
|
3
|
+
* cancels its event (`preventDefault`). It is always `{ passive: false }` and
|
|
4
|
+
* always the browser's own registration, never a host's patched one.
|
|
5
|
+
*
|
|
6
|
+
* Why not plain `addEventListener(…, { passive: false })`: zone.js (every
|
|
7
|
+
* Angular host) patches `addEventListener` and funnels every listener of one
|
|
8
|
+
* target + type + phase through ONE native listener, registered with the
|
|
9
|
+
* options of whoever came FIRST. Angular CDK's InputModalityDetector registers
|
|
10
|
+
* `keydown`, `mousedown` and `touchstart` on document `{ passive: true,
|
|
11
|
+
* capture: true }` at boot, so the HUD's Esc handler ran inside a passive
|
|
12
|
+
* invocation: Chrome logged "Unable to preventDefault inside passive event
|
|
13
|
+
* listener invocation" and the default went ahead anyway. zone.js keeps the
|
|
14
|
+
* unpatched functions under `__zone_symbol__addEventListener` /
|
|
15
|
+
* `__zone_symbol__removeEventListener`; registering through them gives the
|
|
16
|
+
* handler its own native listener with its own options (and keeps the HUD's
|
|
17
|
+
* pointer traffic out of the host's change detection).
|
|
18
|
+
*/
|
|
19
|
+
export interface ListenOptions {
|
|
20
|
+
capture?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function listen<K extends keyof WindowEventMap>(target: Window, type: K, fn: (e: WindowEventMap[K]) => void, opts?: ListenOptions): () => void;
|
|
23
|
+
export declare function listen<K extends keyof DocumentEventMap>(target: Document, type: K, fn: (e: DocumentEventMap[K]) => void, opts?: ListenOptions): () => void;
|
|
24
|
+
export declare function listen(target: EventTarget, type: string, fn: (e: Event) => void, opts?: ListenOptions): () => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `listen` — the ONE way the HUD registers a window/document listener that
|
|
3
|
+
* cancels its event (`preventDefault`). It is always `{ passive: false }` and
|
|
4
|
+
* always the browser's own registration, never a host's patched one.
|
|
5
|
+
*
|
|
6
|
+
* Why not plain `addEventListener(…, { passive: false })`: zone.js (every
|
|
7
|
+
* Angular host) patches `addEventListener` and funnels every listener of one
|
|
8
|
+
* target + type + phase through ONE native listener, registered with the
|
|
9
|
+
* options of whoever came FIRST. Angular CDK's InputModalityDetector registers
|
|
10
|
+
* `keydown`, `mousedown` and `touchstart` on document `{ passive: true,
|
|
11
|
+
* capture: true }` at boot, so the HUD's Esc handler ran inside a passive
|
|
12
|
+
* invocation: Chrome logged "Unable to preventDefault inside passive event
|
|
13
|
+
* listener invocation" and the default went ahead anyway. zone.js keeps the
|
|
14
|
+
* unpatched functions under `__zone_symbol__addEventListener` /
|
|
15
|
+
* `__zone_symbol__removeEventListener`; registering through them gives the
|
|
16
|
+
* handler its own native listener with its own options (and keeps the HUD's
|
|
17
|
+
* pointer traffic out of the host's change detection).
|
|
18
|
+
*/
|
|
19
|
+
/** Register a cancelling listener natively and non-passive; returns its remover. */
|
|
20
|
+
export function listen(target, type, fn, opts = {}) {
|
|
21
|
+
const zone = target;
|
|
22
|
+
const add = zone.__zone_symbol__addEventListener ?? target.addEventListener;
|
|
23
|
+
const remove = zone.__zone_symbol__removeEventListener ?? target.removeEventListener;
|
|
24
|
+
const capture = opts.capture ?? false;
|
|
25
|
+
add.call(target, type, fn, { capture, passive: false });
|
|
26
|
+
return () => remove.call(target, type, fn, capture);
|
|
27
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* remembered per origin in the HUD's storage.
|
|
10
10
|
*/
|
|
11
11
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
12
|
+
import { listen } from './listen';
|
|
12
13
|
import { colOf, neighbour, parsePlace, rowOf, settle, untuck } from './spots';
|
|
13
14
|
const DOCK_KEY = 'dock';
|
|
14
15
|
/** Travel before a press becomes a drag — below it a press stays a tap. */
|
|
@@ -120,8 +121,7 @@ export function useDock(onMoveStart, storage) {
|
|
|
120
121
|
if (press.current)
|
|
121
122
|
e.preventDefault();
|
|
122
123
|
};
|
|
123
|
-
document
|
|
124
|
-
return () => document.removeEventListener('dragstart', guard, true);
|
|
124
|
+
return listen(document, 'dragstart', guard, { capture: true });
|
|
125
125
|
}, []);
|
|
126
126
|
const release = useCallback((e, cancelled) => {
|
|
127
127
|
const p = press.current;
|
package/build/recorder/link.js
CHANGED
|
@@ -21,7 +21,7 @@ export async function linkDevice() {
|
|
|
21
21
|
const workspace = linkWorkspace(url);
|
|
22
22
|
const start = await startLink(url, { label: defaultLinkLabel(), workspace });
|
|
23
23
|
const ac = new AbortController();
|
|
24
|
-
const linked = pollLink(url, start.device_code, { interval: start.interval, workspace, signal: ac.signal }).then((l) => {
|
|
24
|
+
const linked = pollLink(url, start.device_code, { interval: start.interval, expiresIn: start.expires_in, workspace, signal: ac.signal }).then((l) => {
|
|
25
25
|
storeLink(l);
|
|
26
26
|
return l;
|
|
27
27
|
});
|
|
@@ -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.2.
|
|
21
|
-
export declare const RECORDER_ID = "web/0.2.
|
|
20
|
+
export declare const RECORDER_VERSION = "0.2.1";
|
|
21
|
+
export declare const RECORDER_ID = "web/0.2.1";
|
|
22
22
|
/** What `POST /api/v1/sessions` answers (the fields this recorder keeps). */
|
|
23
23
|
export interface SessionOut {
|
|
24
24
|
id: string;
|
|
@@ -6,7 +6,7 @@ import { noteRecent, updateRecent } from './recents';
|
|
|
6
6
|
import { currentRoute, notify } from './state';
|
|
7
7
|
export { currentRoute, notify, subscribe } from './state';
|
|
8
8
|
/** Sent as `meta.recorder`; bumped with the package version. */
|
|
9
|
-
export const RECORDER_VERSION = '0.2.
|
|
9
|
+
export const RECORDER_VERSION = '0.2.1';
|
|
10
10
|
export const RECORDER_ID = `web/${RECORDER_VERSION}`;
|
|
11
11
|
/**
|
|
12
12
|
* Re-apply a RECOVERED session's redaction policy after a reload — and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrinka/web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"prepublishOnly": "tsc -p tsconfig.build.json && bun run build:hud"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vitrinka/link": "^0.1.
|
|
54
|
+
"@vitrinka/link": "^0.1.3",
|
|
55
55
|
"@vitrinka/redact": "^0.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|