@vitrinka/web 0.4.0 → 0.5.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 +77 -0
- package/README.md +37 -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 +2 -0
- package/build/recorder/index.js +2 -0
- package/build/recorder/lead.d.ts +90 -0
- package/build/recorder/lead.js +414 -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 +293 -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 +72 -21
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
# @vitrinka/web
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
- **A claim names its session.** The server answers a session's id as a
|
|
6
|
+
number, and 0.5.0 wrote it into `data-vitrinka-lead` as one. The codec
|
|
7
|
+
reads only a string, so the extension's refusals lost their `#N`, and the
|
|
8
|
+
page re-announced its hello on every state change. The recorder now keys a
|
|
9
|
+
session by the id's string from the moment it is created. The codec also
|
|
10
|
+
reads a 0.5.0 page's numeric id.
|
|
11
|
+
- **A page that holds the claim yields to the extension recording
|
|
12
|
+
elsewhere.** A tab that thaws after the extension started in another tab
|
|
13
|
+
(its Start probe could not reach a frozen tab) kept recording, so two
|
|
14
|
+
recordings ran. The page now releases its claim and waits, capturing
|
|
15
|
+
nothing, and resumes when the extension stops (D14). A Stop that is
|
|
16
|
+
already saving keeps its claim and its face.
|
|
17
|
+
- **`withRecorderLock` is exported** from `@vitrinka/web/recorder`. A custom
|
|
18
|
+
storage driver shared with the package's own driver on one origin (a
|
|
19
|
+
host's own dock key, say) can take the very lock the package numbers
|
|
20
|
+
events under, instead of copying it.
|
|
21
|
+
|
|
22
|
+
## 0.5.0
|
|
23
|
+
|
|
24
|
+
- **The page recorder and the Vitrinka extension are one recorder.** A page
|
|
25
|
+
could embed this recorder while the tester's browser ran the extension,
|
|
26
|
+
and the two fought. The extension's shortcuts swallowed the pill's ⌥⇧A/N/P,
|
|
27
|
+
either one could start its own recording, and two pills could show. Now the
|
|
28
|
+
first to start leads and the other becomes its remote: its pill hides, it
|
|
29
|
+
captures nothing (no rrweb, click, nav, console or net lane, no flight
|
|
30
|
+
recorder), and its pause, stop, note and shortcuts act on the leader. Two
|
|
31
|
+
recordings never run at once. The session lands where the leader is
|
|
32
|
+
configured; neither side ever borrows the other's credential.
|
|
33
|
+
- **They speak over the DOM, the one thing their worlds share.** The
|
|
34
|
+
recorder marks the document with `data-vitrinka-page="web/0.5.0"` on
|
|
35
|
+
`<html>`. Whoever records holds `data-vitrinka-lead`, a JSON claim
|
|
36
|
+
(`{v, by, id, state, sessionId, since}`) written only by its holder and
|
|
37
|
+
taken by a synchronous check-and-set before any network call. Actions are
|
|
38
|
+
`window` CustomEvents with a JSON-string `detail`: `vitrinka:hello`,
|
|
39
|
+
`vitrinka:command` (`pause`, `stop`, `note`) and `vitrinka:ack`. Each is
|
|
40
|
+
answered inside its own dispatch, so a page never waits on a timer. A
|
|
41
|
+
holder that no longer answers (an extension reloaded or uninstalled) is
|
|
42
|
+
cleared under its own id. The page writes nothing until its root's effect
|
|
43
|
+
runs, so a server-rendered `<html>` hydrates untouched.
|
|
44
|
+
- **Start is refused while the other side leads.** The pill's Start and
|
|
45
|
+
`__vitrinkaRecorder.start()` check before any network call and reject with
|
|
46
|
+
a `RecorderBusyError` (`code: 'recorder_busy'`, `leader`). The pill shows
|
|
47
|
+
the reason (**Already recording**, the full sentence on hover) until you
|
|
48
|
+
dismiss it, for example "the Vitrinka extension is recording in another tab
|
|
49
|
+
— stop it there first". Any other failed Start now shows **Couldn't start**
|
|
50
|
+
on the pill instead of only reaching the console.
|
|
51
|
+
- **A recording that comes back never preempts.** A session resumed after a
|
|
52
|
+
reload, or joined from another tab, into a document or browser the
|
|
53
|
+
extension leads waits as a follower, capturing nothing. It resumes when the
|
|
54
|
+
extension lets go. Nothing is stopped on your behalf.
|
|
55
|
+
- **Relayed shortcuts keep working.** Chrome hands the extension's command
|
|
56
|
+
chords to its worker, never to the page. The extension relays them as a
|
|
57
|
+
synthetic keydown, and the leading HUD acts on it (`isTrusted: false`
|
|
58
|
+
included). It takes the key with `preventDefault` only, so a host that
|
|
59
|
+
skips `defaultPrevented` keys leaves it alone. A follower's HUD binds no
|
|
60
|
+
chord.
|
|
61
|
+
- `__vitrinkaRecorder.status()` gains `leader` (`'page' | 'extension'`) and
|
|
62
|
+
`following`. While the extension leads, `pause`, `stop` and `note` act on
|
|
63
|
+
it, and a note it can no longer take rejects with "the recording ended
|
|
64
|
+
before the note arrived" instead of landing in a later session.
|
|
65
|
+
- `HudController`: `HudSnapshot.following` hides the HUD as the leader's
|
|
66
|
+
remote. It closes the sheet, menu, link sheet and annotate mode, keeps the
|
|
67
|
+
drafts and their images and keeps the dock spot. `onRemoteStop(run)`
|
|
68
|
+
registers the HUD's Stop flow, which a remote stop runs with no second
|
|
69
|
+
confirm. `faceChanged(face)` reports the inline flow face, so the host
|
|
70
|
+
holds its claim as `saved` while **Saved · Open board** shows. `HudFace`
|
|
71
|
+
is exported from `@vitrinka/web/hud`.
|
|
72
|
+
- **`@vitrinka/web/one.iife.js`** (`build/one.iife.js`) is the protocol as
|
|
73
|
+
one 5 KB script defining `globalThis.VitrinkaOne`, for the extension's
|
|
74
|
+
content scripts. The extension vendors it beside `hud.iife.js` under the
|
|
75
|
+
same pin. The protocol types (`Claim`, `Hello`, `Command`, `Ack`, …) are
|
|
76
|
+
exported from `@vitrinka/web/hud`.
|
|
77
|
+
- An older extension (≤ 0.10) is invisible to the protocol, and both behave
|
|
78
|
+
as before.
|
|
79
|
+
|
|
3
80
|
## 0.4.0
|
|
4
81
|
|
|
5
82
|
- **Notes, annotations and bug reports carry images.** Testers asked to
|
package/README.md
CHANGED
|
@@ -174,6 +174,25 @@ Radix focus trap or a `<dialog>.showModal()` never fights it, and nothing
|
|
|
174
174
|
you do on the pill reaches the page (a "close on outside click" never fires
|
|
175
175
|
because of the recorder).
|
|
176
176
|
|
|
177
|
+
## With the Vitrinka extension
|
|
178
|
+
|
|
179
|
+
A tester's browser may also run the Vitrinka extension. The two are one
|
|
180
|
+
recorder: whichever starts first leads, and the other becomes its remote.
|
|
181
|
+
While the extension records (this tab or another), the pill hides and this
|
|
182
|
+
recorder captures nothing; its shortcuts and `__vitrinkaRecorder` act on the
|
|
183
|
+
extension's recording. While the pill records, the extension relays its
|
|
184
|
+
⌥⇧A/N/P to the pill. A Start pressed while the other side leads is refused
|
|
185
|
+
before anything is created, and the pill says why until you dismiss it. A
|
|
186
|
+
recording resumed after a reload into a browser the extension leads waits,
|
|
187
|
+
capturing nothing, and resumes when the extension stops. The session lands
|
|
188
|
+
where the leader is configured.
|
|
189
|
+
|
|
190
|
+
They coordinate through two attributes on `<html>`: `data-vitrinka-page`
|
|
191
|
+
(this recorder is mounted) and `data-vitrinka-lead` (who records), plus
|
|
192
|
+
`vitrinka:*` window events. The page writes them from an effect, after
|
|
193
|
+
hydration. The protocol is `src/recorder/one.ts`; `@vitrinka/web/one.iife.js`
|
|
194
|
+
is the same code for the extension.
|
|
195
|
+
|
|
177
196
|
## Report a bug
|
|
178
197
|
|
|
179
198
|
**Report a bug** (⋯ menu) files what led up to a bug — no recording needed.
|
|
@@ -250,9 +269,14 @@ What goes over the wire: [`docs/PROTOCOL.md`](../../docs/PROTOCOL.md#attached-im
|
|
|
250
269
|
await __vitrinkaRecorder.start({ title: 'checkout', tags: ['ai'] });
|
|
251
270
|
__vitrinkaRecorder.note('price flashes on hover');
|
|
252
271
|
const { boardUrl } = await __vitrinkaRecorder.stop();
|
|
253
|
-
__vitrinkaRecorder.status(); // { recording, sessionId, elapsedMs, queued, synced, … }
|
|
272
|
+
__vitrinkaRecorder.status(); // { recording, leader, sessionId, elapsedMs, queued, synced, … }
|
|
254
273
|
```
|
|
255
274
|
|
|
275
|
+
While the extension leads, `status()` says `leader: 'extension'` and
|
|
276
|
+
`following: 'extension'`, and `pause`, `stop` and `note` act on its
|
|
277
|
+
recording. `start()` rejects with a `RecorderBusyError` (`code:
|
|
278
|
+
'recorder_busy'`, exported from `@vitrinka/web/recorder`).
|
|
279
|
+
|
|
256
280
|
## The HUD on its own (`@vitrinka/web/hud`)
|
|
257
281
|
|
|
258
282
|
The HUD is driven only through a `HudController`. The in-page recorder is one
|
|
@@ -280,6 +304,12 @@ const unmount = mountRecorderHud(controller, { title: () => document.title });
|
|
|
280
304
|
`annotate({…, attachments})` and `report({…, attachments})` hand over
|
|
281
305
|
`HudAttachment`s (`{name, blob, w, h}`) the HUD has already re-encoded —
|
|
282
306
|
png, webp or jpeg, ≤ 2560 px, ≤ 12 MiB. Uploading them is the host's job.
|
|
307
|
+
- One recorder with the page's own: `following: 'page' | 'extension'` in
|
|
308
|
+
the snapshot hides the HUD as the leader's remote (sheets and annotate
|
|
309
|
+
mode close, the drafts survive, no shortcut is bound). Optionally,
|
|
310
|
+
`onRemoteStop(run)` registers the HUD's Stop flow for a remote stop (no
|
|
311
|
+
second confirm), and `faceChanged(face)` reports the pill's inline flow
|
|
312
|
+
face so the host can hold its claim while **Saved** shows.
|
|
283
313
|
|
|
284
314
|
The full contract is in `src/recorder/hud/controller.ts`.
|
|
285
315
|
|
|
@@ -291,6 +321,9 @@ same mount as one self-contained script with React bundled in:
|
|
|
291
321
|
<script>const unmount = VitrinkaHud.mount(controller);</script>
|
|
292
322
|
```
|
|
293
323
|
|
|
324
|
+
`@vitrinka/web/one.iife.js` is the page↔extension protocol the same way
|
|
325
|
+
(`globalThis.VitrinkaOne`, no React, about 5 KB).
|
|
326
|
+
|
|
294
327
|
## What is captured, exactly
|
|
295
328
|
|
|
296
329
|
| Lane | Event `kind` | Payload |
|
|
@@ -329,6 +362,9 @@ Web Lock, or an IndexedDB transaction on hosts without Web Locks. Stop
|
|
|
329
362
|
waits for these allocations before draining. A custom driver shared across
|
|
330
363
|
documents must implement `withLock(name, run)` and run the synchronous
|
|
331
364
|
callback exclusively across them; a document-local driver needs no lock.
|
|
365
|
+
A driver that shares an origin with the package's own (e.g. one that
|
|
366
|
+
re-keys a single entry) passes the package's `withRecorderLock` from
|
|
367
|
+
`@vitrinka/web/recorder`, so both number events under the same lock.
|
|
332
368
|
Shared drivers also implement `keys()` to coordinate Stop: each mounted tab
|
|
333
369
|
ships its last rrweb batch and drains its captures before acknowledging.
|
|
334
370
|
An undelivered sibling tail refuses Stop and stays queued for retry.
|
package/build/hud.d.ts
CHANGED
|
@@ -5,5 +5,8 @@
|
|
|
5
5
|
* defining `globalThis.VitrinkaHud.mount`.
|
|
6
6
|
*/
|
|
7
7
|
export { mountRecorderHud, type MountHudOptions } from './recorder/hud/mount';
|
|
8
|
-
export { DEFAULT_PREFS, type HudAccount, type HudAnnotation, type HudAttachment, type HudController, type HudLinkCode, type HudLinkFlow, type HudPrefs, type HudRecent, type HudRecentStatus, type HudRecording, type HudRect, type HudReport, type HudSaved, type HudSize, type HudSnapshot, type HudSync, type HudSyncState, } from './recorder/hud/controller';
|
|
8
|
+
export { DEFAULT_PREFS, type HudAccount, type HudAnnotation, type HudAttachment, type HudController, type HudFace, type HudLinkCode, type HudLinkFlow, type HudPrefs, type HudRecent, type HudRecentStatus, type HudRecording, type HudRect, type HudReport, type HudSaved, type HudSize, type HudSnapshot, type HudSync, type HudSyncState, } from './recorder/hud/controller';
|
|
9
9
|
export type { RecorderStorage } from './recorder/storage';
|
|
10
|
+
/** ONE recorder: the protocol the page recorder and the extension speak (`build/one.iife.js` = `globalThis.VitrinkaOne`). */
|
|
11
|
+
export type { Ack, AckCode, Claim, ClaimRoot, ClaimState, Command, CommandOp, CommandReply, Hello, Live, OneEnv, OneParty, OneSelf, } from './recorder/one';
|
|
12
|
+
export type { VitrinkaOneGlobal } from './recorder/one-iife';
|