@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.
Files changed (39) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +34 -1
  3. package/build/hud.d.ts +4 -1
  4. package/build/hud.iife.js +6 -6
  5. package/build/one.iife.js +1 -0
  6. package/build/recorder/RecorderProvider.js +48 -9
  7. package/build/recorder/capture/console.d.ts +2 -0
  8. package/build/recorder/capture/console.js +22 -2
  9. package/build/recorder/capture/nav.d.ts +13 -2
  10. package/build/recorder/capture/nav.js +49 -11
  11. package/build/recorder/capture/net.d.ts +2 -0
  12. package/build/recorder/capture/net.js +30 -4
  13. package/build/recorder/control.d.ts +17 -0
  14. package/build/recorder/control.js +39 -2
  15. package/build/recorder/hud/Hud.js +70 -20
  16. package/build/recorder/hud/RecorderPill.js +6 -2
  17. package/build/recorder/hud/chords.d.ts +10 -0
  18. package/build/recorder/hud/chords.js +34 -0
  19. package/build/recorder/hud/controller.d.ts +24 -0
  20. package/build/recorder/hud/flow.d.ts +22 -1
  21. package/build/recorder/hud/flow.js +16 -1
  22. package/build/recorder/index.d.ts +1 -0
  23. package/build/recorder/index.js +1 -0
  24. package/build/recorder/lead.d.ts +90 -0
  25. package/build/recorder/lead.js +404 -0
  26. package/build/recorder/one-iife.d.ts +13 -0
  27. package/build/recorder/one-iife.js +13 -0
  28. package/build/recorder/one.d.ts +170 -0
  29. package/build/recorder/one.js +292 -0
  30. package/build/recorder/page-controller.js +23 -2
  31. package/build/recorder/queue.js +5 -2
  32. package/build/recorder/report.js +9 -2
  33. package/build/recorder/session.d.ts +22 -4
  34. package/build/recorder/session.js +70 -20
  35. package/build/recorder/state.d.ts +9 -0
  36. package/build/recorder/state.js +7 -0
  37. package/build/recorder/version.d.ts +3 -0
  38. package/build/recorder/version.js +3 -0
  39. package/package.json +5 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # @vitrinka/web
2
2
 
3
+ ## 0.5.0
4
+
5
+ - **The page recorder and the Vitrinka extension are one recorder.** A page
6
+ could embed this recorder while the tester's browser ran the extension,
7
+ and the two fought. The extension's shortcuts swallowed the pill's ⌥⇧A/N/P,
8
+ either one could start its own recording, and two pills could show. Now the
9
+ first to start leads and the other becomes its remote: its pill hides, it
10
+ captures nothing (no rrweb, click, nav, console or net lane, no flight
11
+ recorder), and its pause, stop, note and shortcuts act on the leader. Two
12
+ recordings never run at once. The session lands where the leader is
13
+ configured; neither side ever borrows the other's credential.
14
+ - **They speak over the DOM, the one thing their worlds share.** The
15
+ recorder marks the document with `data-vitrinka-page="web/0.5.0"` on
16
+ `<html>`. Whoever records holds `data-vitrinka-lead`, a JSON claim
17
+ (`{v, by, id, state, sessionId, since}`) written only by its holder and
18
+ taken by a synchronous check-and-set before any network call. Actions are
19
+ `window` CustomEvents with a JSON-string `detail`: `vitrinka:hello`,
20
+ `vitrinka:command` (`pause`, `stop`, `note`) and `vitrinka:ack`. Each is
21
+ answered inside its own dispatch, so a page never waits on a timer. A
22
+ holder that no longer answers (an extension reloaded or uninstalled) is
23
+ cleared under its own id. The page writes nothing until its root's effect
24
+ runs, so a server-rendered `<html>` hydrates untouched.
25
+ - **Start is refused while the other side leads.** The pill's Start and
26
+ `__vitrinkaRecorder.start()` check before any network call and reject with
27
+ a `RecorderBusyError` (`code: 'recorder_busy'`, `leader`). The pill shows
28
+ the reason (**Already recording**, the full sentence on hover) until you
29
+ dismiss it, for example "the Vitrinka extension is recording in another tab
30
+ — stop it there first". Any other failed Start now shows **Couldn't start**
31
+ on the pill instead of only reaching the console.
32
+ - **A recording that comes back never preempts.** A session resumed after a
33
+ reload, or joined from another tab, into a document or browser the
34
+ extension leads waits as a follower, capturing nothing. It resumes when the
35
+ extension lets go. Nothing is stopped on your behalf.
36
+ - **Relayed shortcuts keep working.** Chrome hands the extension's command
37
+ chords to its worker, never to the page. The extension relays them as a
38
+ synthetic keydown, and the leading HUD acts on it (`isTrusted: false`
39
+ included). It takes the key with `preventDefault` only, so a host that
40
+ skips `defaultPrevented` keys leaves it alone. A follower's HUD binds no
41
+ chord.
42
+ - `__vitrinkaRecorder.status()` gains `leader` (`'page' | 'extension'`) and
43
+ `following`. While the extension leads, `pause`, `stop` and `note` act on
44
+ it, and a note it can no longer take rejects with "the recording ended
45
+ before the note arrived" instead of landing in a later session.
46
+ - `HudController`: `HudSnapshot.following` hides the HUD as the leader's
47
+ remote. It closes the sheet, menu, link sheet and annotate mode, keeps the
48
+ drafts and their images and keeps the dock spot. `onRemoteStop(run)`
49
+ registers the HUD's Stop flow, which a remote stop runs with no second
50
+ confirm. `faceChanged(face)` reports the inline flow face, so the host
51
+ holds its claim as `saved` while **Saved · Open board** shows. `HudFace`
52
+ is exported from `@vitrinka/web/hud`.
53
+ - **`@vitrinka/web/one.iife.js`** (`build/one.iife.js`) is the protocol as
54
+ one 5 KB script defining `globalThis.VitrinkaOne`, for the extension's
55
+ content scripts. The extension vendors it beside `hud.iife.js` under the
56
+ same pin. The protocol types (`Claim`, `Hello`, `Command`, `Ack`, …) are
57
+ exported from `@vitrinka/web/hud`.
58
+ - An older extension (≤ 0.10) is invisible to the protocol, and both behave
59
+ as before.
60
+
3
61
  ## 0.4.0
4
62
 
5
63
  - **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 |
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';