@full-self-browsing/phantom-stream 0.1.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 (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +263 -0
  3. package/bin/phantom-stream.js +193 -0
  4. package/dist/types/adapters/bookmarklet.d.ts +22 -0
  5. package/dist/types/adapters/bookmarklet.d.ts.map +1 -0
  6. package/dist/types/adapters/browser-inject.d.ts +7 -0
  7. package/dist/types/adapters/browser-inject.d.ts.map +1 -0
  8. package/dist/types/adapters/extension.d.ts +43 -0
  9. package/dist/types/adapters/extension.d.ts.map +1 -0
  10. package/dist/types/adapters/playwright-inject.d.ts +2 -0
  11. package/dist/types/adapters/playwright-inject.d.ts.map +1 -0
  12. package/dist/types/adapters/playwright.d.ts +14 -0
  13. package/dist/types/adapters/playwright.d.ts.map +1 -0
  14. package/dist/types/capture/index.d.ts +241 -0
  15. package/dist/types/capture/index.d.ts.map +1 -0
  16. package/dist/types/index.d.ts +6 -0
  17. package/dist/types/index.d.ts.map +1 -0
  18. package/dist/types/protocol/constants.d.ts +35 -0
  19. package/dist/types/protocol/constants.d.ts.map +1 -0
  20. package/dist/types/protocol/envelope.d.ts +41 -0
  21. package/dist/types/protocol/envelope.d.ts.map +1 -0
  22. package/dist/types/protocol/index.d.ts +5 -0
  23. package/dist/types/protocol/index.d.ts.map +1 -0
  24. package/dist/types/protocol/messages.d.ts +520 -0
  25. package/dist/types/protocol/messages.d.ts.map +1 -0
  26. package/dist/types/protocol/remote-control.d.ts +70 -0
  27. package/dist/types/protocol/remote-control.d.ts.map +1 -0
  28. package/dist/types/relay/backends/ws.d.ts +39 -0
  29. package/dist/types/relay/backends/ws.d.ts.map +1 -0
  30. package/dist/types/relay/index.d.ts +4 -0
  31. package/dist/types/relay/index.d.ts.map +1 -0
  32. package/dist/types/relay/limits.d.ts +54 -0
  33. package/dist/types/relay/limits.d.ts.map +1 -0
  34. package/dist/types/relay/relay.d.ts +73 -0
  35. package/dist/types/relay/relay.d.ts.map +1 -0
  36. package/dist/types/renderer/diff.d.ts +62 -0
  37. package/dist/types/renderer/diff.d.ts.map +1 -0
  38. package/dist/types/renderer/index.d.ts +211 -0
  39. package/dist/types/renderer/index.d.ts.map +1 -0
  40. package/dist/types/renderer/overlays.d.ts +166 -0
  41. package/dist/types/renderer/overlays.d.ts.map +1 -0
  42. package/dist/types/renderer/sanitize.d.ts +73 -0
  43. package/dist/types/renderer/sanitize.d.ts.map +1 -0
  44. package/dist/types/renderer/snapshot.d.ts +41 -0
  45. package/dist/types/renderer/snapshot.d.ts.map +1 -0
  46. package/dist/types/transport/websocket.d.ts +44 -0
  47. package/dist/types/transport/websocket.d.ts.map +1 -0
  48. package/docs/ARCHITECTURE.md +273 -0
  49. package/docs/DESIGN-HISTORY.md +120 -0
  50. package/docs/QUICKSTARTS.md +289 -0
  51. package/docs/RELEASE.md +60 -0
  52. package/docs/SECURITY.md +156 -0
  53. package/docs/paper/OUTLINE.md +100 -0
  54. package/examples/bookmarklet-demo/demo.css +102 -0
  55. package/examples/bookmarklet-demo/server.js +297 -0
  56. package/examples/bookmarklet-demo/source.html +52 -0
  57. package/examples/bookmarklet-demo/viewer.html +48 -0
  58. package/examples/extension-mv3/demo.css +102 -0
  59. package/examples/extension-mv3/server.js +350 -0
  60. package/examples/extension-mv3/source.html +48 -0
  61. package/examples/extension-mv3/viewer.html +48 -0
  62. package/examples/loopback-mirror.html +369 -0
  63. package/examples/loopback-transport.js +65 -0
  64. package/examples/playwright-demo/demo.css +462 -0
  65. package/examples/playwright-demo/fixture.html +56 -0
  66. package/examples/playwright-demo/fixture.js +57 -0
  67. package/examples/playwright-demo/server.js +517 -0
  68. package/examples/playwright-demo/viewer.html +112 -0
  69. package/examples/playwright-demo/viewer.js +414 -0
  70. package/examples/serve.js +97 -0
  71. package/examples/two-tab-demo/demo.css +266 -0
  72. package/examples/two-tab-demo/server.js +233 -0
  73. package/examples/two-tab-demo/source.html +70 -0
  74. package/examples/two-tab-demo/source.js +213 -0
  75. package/examples/two-tab-demo/viewer.html +72 -0
  76. package/examples/two-tab-demo/viewer.js +121 -0
  77. package/package.json +107 -0
  78. package/src/adapters/bookmarklet.js +98 -0
  79. package/src/adapters/browser-inject.js +17 -0
  80. package/src/adapters/extension.js +322 -0
  81. package/src/adapters/playwright-inject.js +4401 -0
  82. package/src/adapters/playwright.js +540 -0
  83. package/src/capture/README.md +302 -0
  84. package/src/capture/index.js +4361 -0
  85. package/src/index.js +5 -0
  86. package/src/protocol/constants.js +49 -0
  87. package/src/protocol/envelope.js +75 -0
  88. package/src/protocol/index.js +4 -0
  89. package/src/protocol/messages.js +268 -0
  90. package/src/protocol/remote-control.js +300 -0
  91. package/src/relay/README.md +22 -0
  92. package/src/relay/backends/ws.js +186 -0
  93. package/src/relay/index.js +3 -0
  94. package/src/relay/limits.js +105 -0
  95. package/src/relay/relay.js +397 -0
  96. package/src/renderer/README.md +443 -0
  97. package/src/renderer/diff.js +389 -0
  98. package/src/renderer/index.js +1401 -0
  99. package/src/renderer/overlays.js +528 -0
  100. package/src/renderer/sanitize.js +366 -0
  101. package/src/renderer/snapshot.js +202 -0
  102. package/src/transport/websocket.js +553 -0
@@ -0,0 +1,302 @@
1
+ # capture
2
+
3
+ Page-side capture core: DOM snapshot + MutationObserver diff streaming behind an
4
+ injected `Transport` seam. Single-file extraction of the FSB reference
5
+ implementation (`reference/extension/dom-stream.js`, shipped as FSB milestone
6
+ v0.9.9.1), proven op-stream-equivalent to the reference by the differential
7
+ oracle in `tests/differential/`.
8
+
9
+ Runs in any injection context — extension content script, Playwright/CDP
10
+ `Page.addScriptToEvaluateOnNewDocument`, bookmarklet, or an embedded SDK.
11
+ `window`/`document` and friends are ambient globals dereferenced only inside
12
+ the factory and the functions it builds, so importing this module in bare Node
13
+ is side-effect free.
14
+
15
+ ## Factory
16
+
17
+ ```js
18
+ import { createCapture } from '@full-self-browsing/phantom-stream/capture';
19
+
20
+ const capture = createCapture({
21
+ transport,
22
+ logger,
23
+ overlayProvider,
24
+ skipElement,
25
+ styleMode: 'computed',
26
+ });
27
+ // -> { start, stop, pause, resume, getNodeId, handleControl }
28
+ ```
29
+
30
+ | Option | Required | Default | Purpose |
31
+ |--------|----------|---------|---------|
32
+ | `transport` | yes | — | Message sink: `{ send(type, payload), flush?() }`. The factory throws `Error('transport-send-required')` when `transport.send` is not a function — factory-time validation is the only place the capture may throw. |
33
+ | `logger` | no | console-backed (`info`/`warn`/`error`) | Receives lifecycle logs and every contained transport error. |
34
+ | `overlayProvider` | no | `null` | `() => ({ glow, progress, ...customKinds })` — read host overlay state for the overlay side channel. **All** own enumerable provider keys are forwarded on the wire as overlay kinds (extension E1 below); `glow`/`progress` default `null` when omitted; the identity keys (`streamSessionId`/`snapshotId`) are reserved and never overwritten. With no provider, overlay messages carry `{ glow: null, progress: null }` (reference wire shape for an overlay-free page). |
35
+ | `skipElement` | no | `() => false` | `(el) => boolean` — predicate marking elements the host wants excluded from capture (its own UI). Applied **ancestor-inclusively** (like `closest()`, matching the reference's overlay handling): an element is excluded when the predicate matches it or any of its ancestors, so a root-only predicate (e.g. `el.id === 'my-overlay'`) excludes its whole subtree. Skipped subtrees receive no node-id assignment during serialization, and mutations anywhere inside them are dropped during diffing. |
36
+ | `blockSelector` | no | `null` | CSS selector for private regions that must never reach the wire. Matching elements serialize as placeholders with `rr_width` and `rr_height` only; their attrs, children, and text are omitted. Placeholder identity travels in the `nodeIds` sidecar. |
37
+ | `maskTextSelector` | no | `null` | CSS selector for text that should be masked before transport. Non-whitespace chars become `*` by default, preserving whitespace and length. |
38
+ | `maskInputs` | no | `false` | When true, masks form control values. Password inputs are always masked even when this is false. |
39
+ | `maskTextFn` / `maskInputFn` | no | asterisk mask | Custom masking functions. They are fail-closed: thrown errors are logged and the default mask is used. |
40
+ | `styleMode` | no | `'computed'` | <code>'computed' &#124; 'cssom'</code> — default mode preserves the legacy curated computed-style snapshot path. CSSOM mode omits generated computed inline styles and transports scoped `styleSources[]` plus `styleStrategy` instead. |
41
+ | `fetchStylesheet` | no | `null` | Optional synchronous hook used only by CSSOM mode when a stylesheet cannot expose readable `cssRules` and cannot be safely re-linked. Called as `fetchStylesheet({ href, scope, ownerKind })`; PhantomStream never performs hidden network fetches. |
42
+
43
+ A readiness ping (`STREAM.READY`) is emitted once, at factory creation
44
+ (divergence-ledger entry D3 — the reference pinged at script-load time).
45
+
46
+ ## Transport contract (D-07)
47
+
48
+ - `send(type, payload)` — **required.** Fire-and-forget, mirroring
49
+ `chrome.runtime.sendMessage` semantics: the capture never awaits delivery.
50
+ `type` is a `STREAM.*` protocol string from `src/protocol/messages.js`.
51
+ - `flush()` — **optional**, defaults to a no-op. Invoked once at the end of
52
+ `stop()`, the one deterministic drain point the core offers buffering hosts.
53
+ Wire-invisible with the default.
54
+ - **Transport errors never propagate into the capture path.** Synchronous
55
+ throws and rejected promises from `send`/`flush` are routed to the injected
56
+ logger; capture continues. Enforced by test
57
+ (`tests/capture-lifecycle.test.js`), not just convention.
58
+
59
+ ## Lifecycle host contract (D-06)
60
+
61
+ - `start()` — begins a **fresh session**: mints a new `streamSessionId` and a
62
+ new `snapshotId`, serializes and sends a full snapshot, then arms the
63
+ mutation observer and scroll tracker. Calling `start()` while streaming
64
+ restarts cleanly (re-injection guard).
65
+ - `stop()` — halts observers (a final mutation flush included), then invokes
66
+ the transport's `flush()` drain point. `stop()` then `start()` = fresh
67
+ session, matching the reference implementation.
68
+ - `pause()` — suspends observers and flushing but keeps the session alive.
69
+ - `resume()` — re-arms observers and continues the **same**
70
+ `streamSessionId`/`snapshotId` **without re-snapshotting**. Mutations that
71
+ occurred while paused are **missed by design**. Guidance: *pause when the
72
+ page is quiescent, or `stop()`/`start()` to force a fresh snapshot.*
73
+
74
+ There is no `refresh()` method in this version — deliberate: the factory
75
+ surface is exactly the four methods above (D-05). Hosts needing a fresh view
76
+ call `stop()` then `start()`.
77
+
78
+ ## Node identity and semantic addressing
79
+
80
+ Capture owns node identity in closure-local state, not in the observed page.
81
+ Tracked live elements are mapped with an internal `WeakMap<Element, string>`
82
+ and reverse lookup used by mutation batching. PhantomStream does not write or
83
+ read framework-owned `data-fsb-nid` attributes on the live page; page-owned
84
+ attributes with that name remain ordinary page data.
85
+
86
+ Snapshot payloads and add ops carry identity as `nodeIds` sidecars ordered by
87
+ the serialized element preorder. The renderer pairs those sidecars with the
88
+ sanitized mirror nodes to rebuild its own index while the HTML stays free of
89
+ framework identity attributes.
90
+
91
+ Trusted host code can call:
92
+
93
+ ```js
94
+ const nid = capture.getNodeId(element);
95
+ // -> string | null
96
+ ```
97
+
98
+ `getNodeId(element)` returns the active PhantomStream nid for a tracked, live
99
+ `Element`, or `null` for inactive sessions, skipped nodes, untracked nodes,
100
+ non-elements, and disconnected elements. It is the capture-side bridge for
101
+ semantic addressing; it exposes identity only, never mirrored content.
102
+
103
+ ## Phase 8 fidelity surfaces
104
+
105
+ Open shadow roots, same-origin iframes, live form values, late-added computed
106
+ styles, and truncated subtree recovery extend the same Phase 7 identity model.
107
+ They do not reintroduce live-page `data-fsb-nid` writes or selector fallback.
108
+
109
+ ### Open shadow roots
110
+
111
+ Snapshot and add-op serialization traverses every discovered open `shadowRoot`
112
+ and emits `shadowRoots[]` sidecars keyed by the light-DOM host nid. The host
113
+ stays in the main `html`; shadow content travels as sanitized shadow HTML plus
114
+ its own `nodeIds`. `<slot>` elements remain in the shadow payload, while
115
+ slotted light-DOM children remain owned by the host's normal child list, so
116
+ slot projection is not duplicated.
117
+
118
+ Capture observes open shadow roots deliberately. Existing roots are observed
119
+ when streaming starts, newly attached roots are discovered through the
120
+ `attachShadow` wrapper, and later shadow mutations emit `DIFF_OP.SHADOW_ROOT`
121
+ replacement ops keyed by `hostNid`. Closed shadow roots are not introspectable
122
+ and are not captured.
123
+
124
+ ### Iframes
125
+
126
+ Same-origin iframes serialize through `frames[]` sidecars keyed by `frameNid`.
127
+ Accessible frame documents carry sanitized body HTML, frame-local `nodeIds`,
128
+ frame shell attrs/styles, nested `frames[]`, and head stylesheet metadata.
129
+ Frame document roots are observed so same-origin frame mutations and value
130
+ diffs stream with frame-scoped identity.
131
+
132
+ Cross-origin iframe content is never read. Inaccessible frames emit
133
+ content-free metadata only: kind, safe src/origin labels, and dimensions where
134
+ available. The main payload keeps the iframe host but not remote document
135
+ content.
136
+
137
+ ### Live value diffs
138
+
139
+ MutationObserver cannot see property-only form value drift, so capture installs
140
+ `input` and `change` listeners on the main document, open shadow roots, and
141
+ same-origin frame documents. Listener output is a narrow `DIFF_OP.VALUE` op
142
+ with the control nid plus only the relevant state: `value`, `checked`, and/or
143
+ `selectedValues`.
144
+
145
+ All value-bearing fields pass through the existing masking chokepoint before
146
+ transport. Password values remain always masked; `maskInputs` and
147
+ `maskInputFn` apply to value diffs exactly as they do to snapshot and attr
148
+ paths. Diagnostics and health telemetry do not carry typed values.
149
+
150
+ ### Added-node styles
151
+
152
+ Add ops now collect curated computed styles for each live element in the added
153
+ subtree before mutating the detached wire clone. This reuses `CURATED_PROPS`
154
+ and `STYLE_DEFAULTS`, appending declarations to existing inline styles before
155
+ `sanitizeForWire('subtree')`. The capture does not enumerate every computed
156
+ property and does not implement full CSSOM capture; stylesheet-centric CSSOM
157
+ mode remains Phase 9.
158
+
159
+ ### Subtree requests
160
+
161
+ Budget truncation replaces dropped roots with
162
+ `data-phantomstream-truncated="true"` markers while preserving their nids in
163
+ `nodeIds`. Hosts/viewers can request a specific missing or truncated nid by
164
+ calling capture through:
165
+
166
+ ```js
167
+ capture.handleControl(CONTROL.SUBTREE_REQUEST, {
168
+ requestId,
169
+ nid,
170
+ streamSessionId,
171
+ snapshotId,
172
+ reason,
173
+ });
174
+ ```
175
+
176
+ `handleControl` emits `STREAM.SUBTREE_RESPONSE` with `status: 'ok'`, `stale`,
177
+ `gone`, `skipped`, `blocked`, or `untracked`. Successful responses reuse the
178
+ add-op serialization policy: sanitized HTML, masking, URL absolutification,
179
+ curated styles, `nodeIds`, `shadowRoots[]`, and `frames[]`. Miss responses are
180
+ content-free and clear the request path without exposing page data.
181
+
182
+ ## Phase 9 CSSOM style mode
183
+
184
+ `styleMode: 'computed' | 'cssom'` controls how visual style fidelity is
185
+ transported:
186
+
187
+ - `'computed'` is the default and preserves the Phase 8 behavior: curated
188
+ computed declarations are written into snapshot and add-op HTML. Default
189
+ payloads do not include `styleSources[]` or `styleStrategy`.
190
+ - `'cssom'` switches snapshots to stylesheet-centric capture. Document,
191
+ open-shadow-root, and same-origin-frame scopes carry sanitized
192
+ `styleSources[]` entries plus a `styleStrategy` summary. Generated computed
193
+ inline styles are not written into cloned HTML.
194
+
195
+ A `styleSources[]` entry includes a stable `sourceId`, `scope`
196
+ (`{ kind: 'document' }`, `{ kind: 'shadow', hostNid }`, or
197
+ `{ kind: 'frame', frameNid }`), `ownerKind`, `order`, and either sanitized
198
+ `cssText` or a safe `href`. `styleStrategy` records mode, source counts, byte
199
+ counts, and fallback counts for diagnostics.
200
+
201
+ Stylesheet fallback reasons are explicit and wire-visible:
202
+
203
+ - `cssRules-blocked` — the browser denied `sheet.cssRules`.
204
+ - `href-relinked` — an inaccessible external stylesheet had a safe URL, so
205
+ the renderer can install a link instead of inlining CSS.
206
+ - `adapter-fetch` — the host-provided `fetchStylesheet({ href, scope, ownerKind })`
207
+ hook supplied CSS text.
208
+ - `computed-fallback` — no readable/relinkable/fetched stylesheet source was
209
+ available for that owner.
210
+
211
+ Live stylesheet changes stream as `DIFF_OP.STYLE_SOURCE` ops with
212
+ `action: 'upsert' | 'replace' | 'remove'`. The payload is scoped the same way
213
+ as snapshots. `CSSStyleSheet.insertRule` / `deleteRule` / `replaceSync` are
214
+ patched while streaming in CSSOM mode; if a hook cannot be installed, capture
215
+ logs `cssom-hook-unavailable` and sends a fresh snapshot rather than guessing.
216
+ If a known style owner cannot be reconciled, the op carries
217
+ `cssom-style-source-stale` so the renderer can request recovery. Renderer-side
218
+ scope misses surface as `stale-style-scope`.
219
+
220
+ The boundary rules are unchanged: closed shadow roots, cross-origin iframe
221
+ content, and media pixels/streams are not captured. CSSOM mode is an opt-in
222
+ capture path only; it does not publish the npm package, swap the FSB reference
223
+ into production, or provide the Phase 12 baseline/ablation tables.
224
+
225
+ ## Module layout
226
+
227
+ Single-file core (`index.js`) per the Phase 1 user override (D-10); the
228
+ serializer/differ/side-channels/session split sketched in earlier drafts is
229
+ deferred to a later phase — parity with the reference, proven by the
230
+ differential oracle, was the Phase 1 exit bar.
231
+
232
+ `tests/differential/divergence-ledger.js` is the **machine-readable record of
233
+ intentional divergences** from the reference; human-readable divergence docs
234
+ (including this file) derive from the ledger, never the reverse (D-03).
235
+ Notable entries:
236
+
237
+ - **D1** — resume semantics: the reference re-snapshots with a fresh session
238
+ on resume; this core continues the session (see contract above).
239
+ - **D4** — the `pingDomStream` readiness probe is dropped from the core
240
+ (hosts call the lifecycle functions directly).
241
+ - **D5** — the `domStreamRequestOverlay` on-demand overlay rebroadcast
242
+ control path is dropped from the core.
243
+
244
+ D4 and D5 are reintroduced host-side by the Phase 6 MV3 adapter (ADPT-01).
245
+
246
+ Phase 2 extension (additive, default-off — not a Phase 1 reference
247
+ divergence, so it lives here rather than in the differential ledger):
248
+
249
+ - **E1 (Phase 2, VIEW-04)** — overlay key forwarding: `broadcastOverlayState`
250
+ forwards **every** own enumerable key the `overlayProvider` returns as an
251
+ overlay kind on the `STREAM.OVERLAY` wire, so custom DOM-anchored overlays
252
+ reach the viewer's `registerOverlay` seam end-to-end. Constraints:
253
+ `glow`/`progress` still default `null` when the provider omits them, and
254
+ the identity keys (`streamSessionId`/`snapshotId`) are stamped **last** so
255
+ a provider can never overwrite stream identity. Wire-compatible when no
256
+ provider is present: with no provider (or a throwing provider) the message
257
+ is byte-identical to the reference shape
258
+ `{ glow: null, progress: null, streamSessionId, snapshotId }` — re-proven
259
+ oracle-safe by the full differential suite (no fixture configures an
260
+ overlayProvider). Pinned by `tests/capture-overlay-forward.test.js`.
261
+ - **E2 (Phase 2, fidelity fix)** — bare text-node childList mutations
262
+ (`el.textContent = '...'` replaces the text child as a childList record,
263
+ not characterData) now emit a `text` op for the mutation target element,
264
+ deduplicated per batch; the reference drops them entirely (silent mirror
265
+ text drift, found at the Phase 2 real-browser checkpoint). Declared as
266
+ differential ledger entry D6 (pinned by the `text-childlist` oracle
267
+ scenario) and covered end-to-end in `tests/renderer-loopback.test.js`.
268
+ **Mixed-content guard (review CR-01):** emission is gated on the live
269
+ target having no element children at flush time (`firstElementChild`) —
270
+ the renderer applies the op as `textContent =`, which would otherwise
271
+ destroy mirrored element subtrees that still exist live (text-node
272
+ appends into mixed containers, `innerHTML` with mixed content). The
273
+ `textContent = '...'` shape keeps emitting (its element children were
274
+ just removed, so the live read is null). Residual gap (accepted,
275
+ reference drop behavior): bare text changes inside mixed-content
276
+ containers drift in the mirror until the next snapshot/resync — text
277
+ drift, never structural flattening. Pinned by the mixed-content shapes
278
+ in `tests/renderer-loopback.test.js`.
279
+ - **E3 (Phase 3, SEC-01/SEC-03)** — capture-side sanitization and privacy
280
+ masking now run before transport through the named `sanitizeForWire`
281
+ chokepoint. Snapshot walks, add-op subtrees, attr ops, characterData text
282
+ ops, E2 text-childlist ops, and inline head CSS all route through the
283
+ chokepoint; `on*` attrs, dangerous URL schemes, `srcdoc`, object/embed
284
+ subtrees, hostile CSS values, and configured private text/form values are
285
+ stripped, neutralized, dropped, or masked before they can leave the page.
286
+ Password values are always masked, `blockSelector` placeholders use the
287
+ rrweb vocabulary (`rr_width`/`rr_height`), and selector validation fails
288
+ at factory time. This is the deliberate reference divergence ledgered as
289
+ **D7** in `tests/differential/divergence-ledger.js`, backed by
290
+ `tests/security-sanitize-capture.test.js`, `tests/security-mask.test.js`,
291
+ and the sanitize-divergence oracle scenario.
292
+ - **E4 (Phase 7, CAPT-07/VIEW-03)** — node identity moved from live-page
293
+ attributes to an internal `WeakMap` mirror plus `nodeIds` sidecars on
294
+ snapshots and add ops. The observed page is no longer mutated for
295
+ framework identity, page-owned `data-fsb-nid` remains page data, and
296
+ `getNodeId(element) -> string|null` is the public live-element lookup.
297
+
298
+ ## Environment
299
+
300
+ Running the test suite requires Node >= 20.19 (jsdom 29 engines floor); the
301
+ library itself (`src/`) remains Node 18+-compatible — the documented runtime
302
+ floor for shipped code is unchanged.