@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.
Files changed (69) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +78 -21
  3. package/build/hud.d.ts +9 -0
  4. package/build/hud.iife.js +411 -0
  5. package/build/hud.js +8 -0
  6. package/build/recorder/api.d.ts +2 -0
  7. package/build/recorder/block.d.ts +7 -0
  8. package/build/recorder/block.js +7 -0
  9. package/build/recorder/capture/click.d.ts +2 -4
  10. package/build/recorder/capture/click.js +2 -31
  11. package/build/recorder/capture/rrweb.d.ts +2 -2
  12. package/build/recorder/capture/rrweb.js +2 -2
  13. package/build/recorder/capture/selector.d.ts +8 -0
  14. package/build/recorder/capture/selector.js +35 -0
  15. package/build/recorder/config.d.ts +6 -0
  16. package/build/recorder/config.js +1 -0
  17. package/build/recorder/hud/AnnotateOverlay.d.ts +7 -1
  18. package/build/recorder/hud/AnnotateOverlay.js +51 -17
  19. package/build/recorder/hud/Hud.d.ts +16 -1
  20. package/build/recorder/hud/Hud.js +251 -83
  21. package/build/recorder/hud/LinkSheet.d.ts +3 -3
  22. package/build/recorder/hud/LinkSheet.js +1 -1
  23. package/build/recorder/hud/Menu.d.ts +30 -0
  24. package/build/recorder/hud/Menu.js +73 -0
  25. package/build/recorder/hud/RecorderPill.d.ts +36 -27
  26. package/build/recorder/hud/RecorderPill.js +212 -123
  27. package/build/recorder/hud/Sheet.d.ts +1 -1
  28. package/build/recorder/hud/Sheet.js +1 -1
  29. package/build/recorder/hud/Tooltip.d.ts +19 -0
  30. package/build/recorder/hud/Tooltip.js +94 -0
  31. package/build/recorder/hud/controller.d.ts +148 -0
  32. package/build/recorder/hud/controller.js +17 -0
  33. package/build/recorder/hud/flow.d.ts +54 -0
  34. package/build/recorder/hud/flow.js +39 -0
  35. package/build/recorder/hud/host.js +1 -1
  36. package/build/recorder/hud/icons.d.ts +7 -0
  37. package/build/recorder/hud/icons.js +19 -0
  38. package/build/recorder/hud/iife.d.ts +13 -0
  39. package/build/recorder/hud/iife.js +11 -0
  40. package/build/recorder/hud/layer.d.ts +29 -6
  41. package/build/recorder/hud/layer.js +67 -33
  42. package/build/recorder/hud/mount.d.ts +13 -0
  43. package/build/recorder/hud/mount.js +27 -0
  44. package/build/recorder/hud/place.d.ts +43 -0
  45. package/build/recorder/hud/place.js +63 -0
  46. package/build/recorder/hud/spots.d.ts +45 -0
  47. package/build/recorder/hud/spots.js +107 -0
  48. package/build/recorder/hud/status.d.ts +31 -0
  49. package/build/recorder/hud/status.js +67 -0
  50. package/build/recorder/hud/styles.d.ts +28 -18
  51. package/build/recorder/hud/styles.js +295 -122
  52. package/build/recorder/hud/useDock.d.ts +9 -8
  53. package/build/recorder/hud/useDock.js +41 -20
  54. package/build/recorder/index.d.ts +4 -2
  55. package/build/recorder/index.js +17 -19
  56. package/build/recorder/link.d.ts +1 -1
  57. package/build/recorder/link.js +8 -2
  58. package/build/recorder/me.d.ts +34 -0
  59. package/build/recorder/me.js +172 -0
  60. package/build/recorder/page-controller.d.ts +12 -0
  61. package/build/recorder/page-controller.js +100 -0
  62. package/build/recorder/queue.d.ts +4 -0
  63. package/build/recorder/queue.js +2 -0
  64. package/build/recorder/recents.d.ts +23 -0
  65. package/build/recorder/recents.js +80 -0
  66. package/build/recorder/session.d.ts +2 -2
  67. package/build/recorder/session.js +16 -1
  68. package/build/recorder/storage/index.js +2 -1
  69. package/package.json +9 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @vitrinka/web
2
2
 
3
+ ## 0.2.0
4
+
5
+ - **Stop is in the pill.** A ■ next to the other tools. It asks inline
6
+ ("Stop & save? Stop · Keep recording"; Esc or Keep cancels). Then the pill
7
+ says **Saving…**, with a spinner and a progress bar while the tail drains.
8
+ Then it says **Saved · Open board**, with the server's board link. That
9
+ stays until you dismiss it. If the server cannot be reached, the pill says
10
+ so and offers **Retry**. Nothing is lost. Unlink asks the same way.
11
+ - **Recents and the account.** The ⋯ menu (now on the idle puck too) names
12
+ who the recorder is linked as: `you@… · Workspace`, or `Recorder key ·
13
+ <name> · project <p>` for a key build. It lists the device's last five
14
+ recordings, with age, length, status and a link to each board. It has
15
+ **Go to vitrinka**. A recent without a board link is refreshed from the
16
+ session's own read.
17
+ - **Eight spots, and a vertical pill.** Move to is a miniature screen with
18
+ eight spots: a 3×3 grid without the centre. At middle left and middle
19
+ right, the recording pill stands up and becomes vertical. Its menu,
20
+ tooltips and sheets open sideways. A pushed-away tab comes back to the
21
+ nearest third of its edge.
22
+ - **Tooltips never clip.** There is one tooltip, and it shows the shortcut.
23
+ It is placed inside the viewport, flipping and shifting as needed from
24
+ every spot. Menus, sheets and the details card follow the same placement.
25
+ - **A sync chip you can read.** `synced`, `sending N`, `offline · N` or
26
+ `ended`, with an icon and a colour for each, and no hover needed. A routine
27
+ 2s flush does not flicker it.
28
+ - **Size and technical details.** S · M · L scales the whole HUD. Technical
29
+ details shows events, queue and chunks, last sync, server seq, session id
30
+ and recorder version. Both are user prefs (`GET`/`PATCH
31
+ /api/v1/recorder/me`) and are cached on the device. They stay on the
32
+ device for key builds, servers without the route, and offline.
33
+ - **"Saved" on the pill** for a moment after a note or annotation.
34
+ - **Annotate does not touch the page.** A drag over text no longer selects
35
+ it. Presses, moves and hovers no longer reach the app. The crosshair is
36
+ set by a blocked stylesheet, so the page's `<html>` is never restyled.
37
+ - The record dot's ripple is drawn outside layout, so the dot and the clock
38
+ are spaced evenly.
39
+ - **The HUD is a seam.** `@vitrinka/web/hud` exports
40
+ `mountRecorderHud(controller, opts)` and the `HudController` contract. The
41
+ in-page recorder is one implementation of it. `build/hud.iife.js`
42
+ (`@vitrinka/web/hud.iife.js`) is the same mount as one self-contained
43
+ script with React bundled in. It defines `globalThis.VitrinkaHud.mount`.
44
+ - The HUD's surfaces stay out of the recording. The rrweb-blocked host is
45
+ 0×0. rrweb 2 cannot drop a blocked node entirely, so it leaves an empty,
46
+ zero-size placeholder. Clicks, the recorder's own requests and `vitrinka:`
47
+ logs are not captured.
48
+
49
+ ## 0.1.5
50
+
51
+ - **A `project` prop.** `VitrinkaRecorderRoot` takes `project`. A
52
+ device-linked session then files into that project instead of the one the
53
+ host's rule picks. One origin that serves several apps by path can now send
54
+ each app's sessions to its own project. A recorder key's pin still wins.
55
+
3
56
  ## 0.1.4
4
57
 
5
58
  - **Annotate works by finger.** On a phone or tablet, a drag in annotate
package/README.md CHANGED
@@ -82,6 +82,11 @@ Vite and plain React work the same way — pass `url` / `recorderKey` from
82
82
  `import.meta.env` (the `NEXT_PUBLIC_*` fallback only applies where a
83
83
  bundler inlines `process.env`).
84
84
 
85
+ One origin serving several apps by path (`/portal/`, `/designer/`, …)
86
+ can file each app's sessions into its own project: pass `project` per app.
87
+ Without it, the host's project rule decides; a recorder key's project pin
88
+ always wins, and a different `project` is refused.
89
+
85
90
  ### Env vars
86
91
 
87
92
  | Var | What |
@@ -113,31 +118,45 @@ returned unchanged otherwise.
113
118
 
114
119
  Idle, the HUD is a 28px glass puck: a hollow ring until the device is linked
115
120
  (**Link recorder**), a muted dot once it is (**Start recording** — the session
116
- title is `document.title`, or the `title` prop); the label slides out on hover
117
- or focus. Recording, it rests as a dot + timer capsule (**Recorder controls**)
118
- that unfolds into the tools on hover, focus or tap and folds back 2.5s after
119
- you leave (keycaps show on hover):
121
+ title is `document.title`, or the `title` prop); the label and a ⋯ slide out
122
+ on hover or focus. Recording, it rests as a dot + timer capsule (**Recorder
123
+ controls**) that unfolds into the tools on hover, focus or tap and folds back
124
+ 2.5s after you leave (a tooltip names each tool and its shortcut):
120
125
 
121
126
  | Control | Shortcut | What |
122
127
  |---|---|---|
128
+ | sync chip | | `synced` · `sending N` · `offline · N` · `ended` — readable without hovering |
123
129
  | ⏸ Pause / ▶ Resume | ⌥⇧P (Alt⇧P) | freezes the clock and capture |
124
- | ✎ Note | ⌥⇧N | the note sheet — Enter sends, ⇧Enter newline, Esc / ✕ / click-outside cancel (the draft survives a cancel) |
125
- | ⌖ Annotate | ⌥⇧A | click or tap an element, or drag a region (a finger too — the page does not scroll or press while annotating), then describe it; `board` (an annotation on the board) or `task` (also filed as an intake draft) |
126
- | ⋯ | | **Open board** (the server-minted link) · **Stop recording** · **Unlink** · **Move to** |
127
-
128
- Move it anywhere: drag the puck or capsule and it lands on one of six spots
129
- (corners, top and bottom centre) — a flick lands where it is thrown; push it
130
- past a side edge and it tucks into a 6px tab (**Show recorder** brings it
131
- back). Arrow keys on the focused handle and **Move to** do the same without a
132
- drag; the spot is remembered per site. Sheets (≤ 288px) open toward the
133
- middle of the page from wherever it sits; on a phone they are a bottom sheet
134
- above the keyboard and the link sheet drops the QR.
135
-
136
- The sync glyph is honest: ✓ means the server confirmed it holds everything
137
- captured; a second line unfolds only for a backlog, an outage (`offline ·
138
- N held · retrying` — nothing is dropped, the tail is kept in `localStorage`)
139
- or a session the server closed. Stop drains first and refuses while the
140
- server is unreachable — stop again once online.
130
+ | ✎ Note | ⌥⇧N | the note sheet — Enter sends, ⇧Enter newline, Esc / ✕ / click-outside cancel (the draft survives a cancel); the pill says **Saved** |
131
+ | ⌖ Annotate | ⌥⇧A | click or tap an element, or drag a region (a finger too). While annotating, the page gets no press, move or hover, does not scroll, and selects no text. Then describe it: `board` (an annotation on the board) or `task` (also filed as an intake draft) |
132
+ | ■ Stop | ⌥⇧S | the pill asks **Stop & save?** (Esc / **Keep recording** cancels), shows **Saving…** with progress while the tail drains, then **Saved · Open board** until you dismiss it |
133
+ | ⋯ | | the linked account · **Open this board** · **Recent** (this device's last five recordings, each linked to its board) · **Go to vitrinka** · **Size** S/M/L · **Technical details** · **Position** · **Unlink this device** (asks first) |
134
+
135
+ Move it anywhere: drag the puck or capsule and it lands on one of eight
136
+ spots (a 3×3 grid without the centre). A flick lands where it is thrown.
137
+ Push it past a side edge and it tucks into a 6px tab (**Show recorder**
138
+ brings it back). At middle left and middle right the recording pill stands
139
+ up into a vertical bar. Arrow keys on the focused handle and **Position** do
140
+ the same without a drag; the spot is remembered per site. Tooltips, the
141
+ menu and sheets (≤ 288px at M) open toward the middle of the page from
142
+ wherever the HUD sits: sideways from a vertical one. They flip and shift so
143
+ they never leave the viewport. On a phone, sheets are a bottom sheet above
144
+ the keyboard and the link sheet drops the QR.
145
+
146
+ The sync chip is honest: `synced` means the server confirmed it holds
147
+ everything captured. A backlog reads `sending N`. An outage reads
148
+ `offline · N` (nothing is dropped; the tail is kept in `localStorage`). A
149
+ session the server closed reads `ended`. A one-line detail also unfolds for
150
+ an outage or an ended session. Stop drains first and refuses while the server
151
+ is unreachable: the pill says so and offers **Retry**.
152
+
153
+ **Size** and **Technical details** are user preferences. For a linked device
154
+ they are stored in vitrinka (`GET`/`PATCH /api/v1/recorder/me`), so they follow
155
+ the user, and are cached on the device for an instant first paint and for
156
+ offline use. A key build, or a server without the route, keeps them on the
157
+ device only. Technical details shows events captured, queue and pending
158
+ chunks, the last sync and its state, the server's seq, the session id and
159
+ the recorder version.
141
160
 
142
161
  The sheet renders inside the topmost open dialog when one exists, so a
143
162
  Radix focus trap or a `<dialog>.showModal()` never fights it, and nothing
@@ -155,6 +174,38 @@ const { boardUrl } = await __vitrinkaRecorder.stop();
155
174
  __vitrinkaRecorder.status(); // { recording, sessionId, elapsedMs, queued, synced, … }
156
175
  ```
157
176
 
177
+ ## The HUD on its own (`@vitrinka/web/hud`)
178
+
179
+ The HUD is driven only through a `HudController`. The in-page recorder is one
180
+ implementation; another host (the browser extension) mounts the same HUD with
181
+ its own:
182
+
183
+ ```ts
184
+ import { mountRecorderHud, type HudController } from '@vitrinka/web/hud';
185
+
186
+ const unmount = mountRecorderHud(controller, { title: () => document.title });
187
+ ```
188
+
189
+ `HudController` is a snapshot plus actions:
190
+
191
+ - `getSnapshot()` returns the same object until something changes;
192
+ `subscribe(fn)` calls back after a change. The snapshot holds `linked`,
193
+ `canUnlink`, `annotating`, `recording` (session, clock, sync), `account`,
194
+ `prefs`, `recents`, `workspaceUrl` and `version`.
195
+ - Actions: `start`, `togglePause`, `stop` (resolves `{boardUrl?}`, rejects
196
+ while the server is unreachable), `note`, `annotate`, `setAnnotating`,
197
+ `link`, `unlink`, `getMe`, `setPrefs` and `refreshRecents`.
198
+
199
+ The full contract is in `src/recorder/hud/controller.ts`.
200
+
201
+ Without a bundler, `@vitrinka/web/hud.iife.js` (`build/hud.iife.js`) is the
202
+ same mount as one self-contained script with React bundled in:
203
+
204
+ ```html
205
+ <script src="hud.iife.js"></script>
206
+ <script>const unmount = VitrinkaHud.mount(controller);</script>
207
+ ```
208
+
158
209
  ## What is captured, exactly
159
210
 
160
211
  | Lane | Event `kind` | Payload |
@@ -169,6 +220,12 @@ __vitrinkaRecorder.status(); // { recording, sessionId, elapsedMs, queued, synce
169
220
  Data goes to your vitrinka server only. Details, the redaction rules and the
170
221
  policy fetch: [`docs/PROTOCOL.md`](../../docs/PROTOCOL.md).
171
222
 
223
+ The HUD itself never enters a recording. Every surface sits under one 0×0
224
+ shadow host carrying rrweb's block attribute. rrweb 2 always leaves a
225
+ placeholder for a blocked node; this one is empty, so the replay shows no
226
+ box. The HUD's clicks, its requests to your server and its `vitrinka:` logs
227
+ are not captured.
228
+
172
229
  ## Storage
173
230
 
174
231
  The undelivered tail lives in `localStorage` (a recording survives a reload
package/build/hud.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `@vitrinka/web/hud` — the recorder HUD on its own, for hosts that bring
3
+ * their own recorder (the browser extension). Implement `HudController` and
4
+ * mount it; `build/hud.iife.js` is the same mount as a self-contained script
5
+ * defining `globalThis.VitrinkaHud.mount`.
6
+ */
7
+ export { mountRecorderHud, type MountHudOptions } from './recorder/hud/mount';
8
+ export { DEFAULT_PREFS, type HudAccount, type HudAnnotation, type HudController, type HudLinkCode, type HudLinkFlow, type HudPrefs, type HudRecent, type HudRecentStatus, type HudRecording, type HudRect, type HudSize, type HudSnapshot, type HudSync, type HudSyncState, } from './recorder/hud/controller';
9
+ export type { RecorderStorage } from './recorder/storage';