@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.
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/bin/phantom-stream.js +193 -0
- package/dist/types/adapters/bookmarklet.d.ts +22 -0
- package/dist/types/adapters/bookmarklet.d.ts.map +1 -0
- package/dist/types/adapters/browser-inject.d.ts +7 -0
- package/dist/types/adapters/browser-inject.d.ts.map +1 -0
- package/dist/types/adapters/extension.d.ts +43 -0
- package/dist/types/adapters/extension.d.ts.map +1 -0
- package/dist/types/adapters/playwright-inject.d.ts +2 -0
- package/dist/types/adapters/playwright-inject.d.ts.map +1 -0
- package/dist/types/adapters/playwright.d.ts +14 -0
- package/dist/types/adapters/playwright.d.ts.map +1 -0
- package/dist/types/capture/index.d.ts +241 -0
- package/dist/types/capture/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/constants.d.ts +35 -0
- package/dist/types/protocol/constants.d.ts.map +1 -0
- package/dist/types/protocol/envelope.d.ts +41 -0
- package/dist/types/protocol/envelope.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +5 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/messages.d.ts +520 -0
- package/dist/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/protocol/remote-control.d.ts +70 -0
- package/dist/types/protocol/remote-control.d.ts.map +1 -0
- package/dist/types/relay/backends/ws.d.ts +39 -0
- package/dist/types/relay/backends/ws.d.ts.map +1 -0
- package/dist/types/relay/index.d.ts +4 -0
- package/dist/types/relay/index.d.ts.map +1 -0
- package/dist/types/relay/limits.d.ts +54 -0
- package/dist/types/relay/limits.d.ts.map +1 -0
- package/dist/types/relay/relay.d.ts +73 -0
- package/dist/types/relay/relay.d.ts.map +1 -0
- package/dist/types/renderer/diff.d.ts +62 -0
- package/dist/types/renderer/diff.d.ts.map +1 -0
- package/dist/types/renderer/index.d.ts +211 -0
- package/dist/types/renderer/index.d.ts.map +1 -0
- package/dist/types/renderer/overlays.d.ts +166 -0
- package/dist/types/renderer/overlays.d.ts.map +1 -0
- package/dist/types/renderer/sanitize.d.ts +73 -0
- package/dist/types/renderer/sanitize.d.ts.map +1 -0
- package/dist/types/renderer/snapshot.d.ts +41 -0
- package/dist/types/renderer/snapshot.d.ts.map +1 -0
- package/dist/types/transport/websocket.d.ts +44 -0
- package/dist/types/transport/websocket.d.ts.map +1 -0
- package/docs/ARCHITECTURE.md +273 -0
- package/docs/DESIGN-HISTORY.md +120 -0
- package/docs/QUICKSTARTS.md +289 -0
- package/docs/RELEASE.md +60 -0
- package/docs/SECURITY.md +156 -0
- package/docs/paper/OUTLINE.md +100 -0
- package/examples/bookmarklet-demo/demo.css +102 -0
- package/examples/bookmarklet-demo/server.js +297 -0
- package/examples/bookmarklet-demo/source.html +52 -0
- package/examples/bookmarklet-demo/viewer.html +48 -0
- package/examples/extension-mv3/demo.css +102 -0
- package/examples/extension-mv3/server.js +350 -0
- package/examples/extension-mv3/source.html +48 -0
- package/examples/extension-mv3/viewer.html +48 -0
- package/examples/loopback-mirror.html +369 -0
- package/examples/loopback-transport.js +65 -0
- package/examples/playwright-demo/demo.css +462 -0
- package/examples/playwright-demo/fixture.html +56 -0
- package/examples/playwright-demo/fixture.js +57 -0
- package/examples/playwright-demo/server.js +517 -0
- package/examples/playwright-demo/viewer.html +112 -0
- package/examples/playwright-demo/viewer.js +414 -0
- package/examples/serve.js +97 -0
- package/examples/two-tab-demo/demo.css +266 -0
- package/examples/two-tab-demo/server.js +233 -0
- package/examples/two-tab-demo/source.html +70 -0
- package/examples/two-tab-demo/source.js +213 -0
- package/examples/two-tab-demo/viewer.html +72 -0
- package/examples/two-tab-demo/viewer.js +121 -0
- package/package.json +107 -0
- package/src/adapters/bookmarklet.js +98 -0
- package/src/adapters/browser-inject.js +17 -0
- package/src/adapters/extension.js +322 -0
- package/src/adapters/playwright-inject.js +4401 -0
- package/src/adapters/playwright.js +540 -0
- package/src/capture/README.md +302 -0
- package/src/capture/index.js +4361 -0
- package/src/index.js +5 -0
- package/src/protocol/constants.js +49 -0
- package/src/protocol/envelope.js +75 -0
- package/src/protocol/index.js +4 -0
- package/src/protocol/messages.js +268 -0
- package/src/protocol/remote-control.js +300 -0
- package/src/relay/README.md +22 -0
- package/src/relay/backends/ws.js +186 -0
- package/src/relay/index.js +3 -0
- package/src/relay/limits.js +105 -0
- package/src/relay/relay.js +397 -0
- package/src/renderer/README.md +443 -0
- package/src/renderer/diff.js +389 -0
- package/src/renderer/index.js +1401 -0
- package/src/renderer/overlays.js +528 -0
- package/src/renderer/sanitize.js +366 -0
- package/src/renderer/snapshot.js +202 -0
- package/src/transport/websocket.js +553 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-injected message sink. `send` mirrors the fire-and-forget
|
|
3
|
+
* semantics of the reference's messaging call: the capture core never awaits
|
|
4
|
+
* delivery and never lets a transport failure propagate into the capture
|
|
5
|
+
* path (errors are routed to the injected logger instead — D-07).
|
|
6
|
+
*
|
|
7
|
+
* The implementation is injected rather than imported so this module works
|
|
8
|
+
* in any runtime and injection context (same pattern as the LZCodec seam in
|
|
9
|
+
* src/protocol/envelope.js).
|
|
10
|
+
*
|
|
11
|
+
* @typedef {Object} Transport
|
|
12
|
+
* @property {(type: string, payload: Object) => void} send
|
|
13
|
+
* Deliver one wire message. `type` is a STREAM.* protocol type; `payload`
|
|
14
|
+
* is the message payload (snapshot object, mutation batch, etc.).
|
|
15
|
+
* @property {() => void} [flush]
|
|
16
|
+
* Optional: drain any host-side buffering. Defaults to a no-op; invoked
|
|
17
|
+
* once at the end of stop().
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} CaptureLogger
|
|
21
|
+
* @property {(...args: *) => void} info
|
|
22
|
+
* @property {(...args: *) => void} warn
|
|
23
|
+
* @property {(...args: *) => void} error
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Overlay side-channel state returned by an overlayProvider. `glow` and
|
|
27
|
+
* `progress` are the reference built-ins; every OTHER own enumerable key is
|
|
28
|
+
* forwarded on the wire as a custom overlay kind (Phase 2 VIEW-04 pass-
|
|
29
|
+
* through -- see broadcastOverlayState and README entry E1). The identity
|
|
30
|
+
* keys `streamSessionId` / `snapshotId` are reserved: the capture core
|
|
31
|
+
* stamps them after the provider keys, so a provider can never overwrite
|
|
32
|
+
* stream identity.
|
|
33
|
+
* @typedef {Object} OverlayState
|
|
34
|
+
* @property {Object|null} [glow] Action-highlight rect/state, or null
|
|
35
|
+
* @property {Object|null} [progress] Progress-card state, or null
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {Object} CaptureOptions
|
|
39
|
+
* @property {Transport} transport
|
|
40
|
+
* Required. Factory throws Error('transport-send-required') when
|
|
41
|
+
* transport.send is not a function (factory-time validation may throw;
|
|
42
|
+
* the capture path after start never does).
|
|
43
|
+
* @property {CaptureLogger} [logger]
|
|
44
|
+
* Optional. Defaults to a console-backed logger.
|
|
45
|
+
* @property {(() => OverlayState|null)} [overlayProvider]
|
|
46
|
+
* Optional. Called by the overlay broadcaster to read host overlay state.
|
|
47
|
+
* ALL own enumerable provider keys are forwarded as overlay kinds (custom
|
|
48
|
+
* kinds included); glow/progress default null when omitted; the identity
|
|
49
|
+
* keys (streamSessionId / snapshotId) are reserved and never overwritten.
|
|
50
|
+
* Default null: overlay messages carry { glow: null, progress: null },
|
|
51
|
+
* preserving the reference's wire shape when no overlay system is present.
|
|
52
|
+
* @property {(el: Element) => boolean} [skipElement]
|
|
53
|
+
* Optional. Predicate marking elements the host wants excluded from
|
|
54
|
+
* capture (its own UI). Default returns false (nothing skipped).
|
|
55
|
+
* Applied ancestor-inclusively (closest()-like, reference parity): an
|
|
56
|
+
* element is excluded when the predicate matches it OR any of its
|
|
57
|
+
* ancestors, and skipped subtrees receive NO node-id assignment during
|
|
58
|
+
* serialization -- a root-only predicate (e.g. el.id === 'my-overlay')
|
|
59
|
+
* therefore excludes its whole subtree from both snapshots and diffs.
|
|
60
|
+
* @property {string} [blockSelector]
|
|
61
|
+
* Optional (SEC-03). CSS selector: matching elements are replaced on the
|
|
62
|
+
* wire by a dimension-preserving placeholder carrying ONLY rr_width /
|
|
63
|
+
* rr_height (px, from the live rect) and the nid -- no attributes, no
|
|
64
|
+
* children, no text; mutations anywhere inside a blocked subtree emit
|
|
65
|
+
* nothing. Invalid selectors THROW Error('invalid-mask-selector') at
|
|
66
|
+
* factory time (fail closed and loud -- a silently dropped mask selector
|
|
67
|
+
* would be a privacy leak).
|
|
68
|
+
* @property {string} [maskTextSelector]
|
|
69
|
+
* Optional (SEC-03). CSS selector: text of matching elements AND their
|
|
70
|
+
* descendants is masked (default mask: '*' per non-whitespace character,
|
|
71
|
+
* whitespace and length preserved -- rrweb-compatible). Same factory-time
|
|
72
|
+
* validation as blockSelector.
|
|
73
|
+
* @property {boolean} [maskInputs]
|
|
74
|
+
* Optional (SEC-03), default false. When true, ALL input/textarea/select
|
|
75
|
+
* values are masked. Independent of this option, input[type=password]
|
|
76
|
+
* values are ALWAYS masked (non-configurable rrweb-parity default).
|
|
77
|
+
* @property {(text: string, element: Element) => string} [maskTextFn]
|
|
78
|
+
* Optional (SEC-03). Custom text mask (rrweb signature). A THROWING fn
|
|
79
|
+
* falls back to the default asterisk mask -- raw text never leaks.
|
|
80
|
+
* @property {(text: string, element: Element) => string} [maskInputFn]
|
|
81
|
+
* Optional (SEC-03). Custom input-value mask (rrweb signature). Same
|
|
82
|
+
* fail-closed containment as maskTextFn.
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {Object} CaptureHandle
|
|
86
|
+
* @property {() => void} start Fresh session: mint ids, snapshot, observe.
|
|
87
|
+
* @property {() => void} stop Stop observers (final flush included).
|
|
88
|
+
* @property {() => void} pause Stop observers, keep the session alive.
|
|
89
|
+
* @property {() => void} resume Re-arm observers; same session, no snapshot.
|
|
90
|
+
* @property {(element: Element) => string|null} getNodeId
|
|
91
|
+
* getNodeId(element) -> string|null
|
|
92
|
+
* Return the active PhantomStream nid for a tracked live element, or null
|
|
93
|
+
* for untracked, skipped, disconnected, or inactive-session nodes.
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* Create a capture instance bound to the ambient window/document.
|
|
97
|
+
*
|
|
98
|
+
* All reference module state lives in this closure, so multiple captures can
|
|
99
|
+
* coexist in one process (each against its own globals). No DOM access
|
|
100
|
+
* happens at module import time; the ambient globals are dereferenced when
|
|
101
|
+
* the factory and its functions run.
|
|
102
|
+
*
|
|
103
|
+
* @param {CaptureOptions} config
|
|
104
|
+
* @returns {CaptureHandle}
|
|
105
|
+
*/
|
|
106
|
+
export function createCapture(config: CaptureOptions): CaptureHandle;
|
|
107
|
+
/**
|
|
108
|
+
* The host-injected message sink. `send` mirrors the fire-and-forget
|
|
109
|
+
* semantics of the reference's messaging call: the capture core never awaits
|
|
110
|
+
* delivery and never lets a transport failure propagate into the capture
|
|
111
|
+
* path (errors are routed to the injected logger instead — D-07).
|
|
112
|
+
*
|
|
113
|
+
* The implementation is injected rather than imported so this module works
|
|
114
|
+
* in any runtime and injection context (same pattern as the LZCodec seam in
|
|
115
|
+
* src/protocol/envelope.js).
|
|
116
|
+
*/
|
|
117
|
+
export type Transport = {
|
|
118
|
+
/**
|
|
119
|
+
* Deliver one wire message. `type` is a STREAM.* protocol type; `payload`
|
|
120
|
+
* is the message payload (snapshot object, mutation batch, etc.).
|
|
121
|
+
*/
|
|
122
|
+
send: (type: string, payload: any) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Optional: drain any host-side buffering. Defaults to a no-op; invoked
|
|
125
|
+
* once at the end of stop().
|
|
126
|
+
*/
|
|
127
|
+
flush?: () => void;
|
|
128
|
+
};
|
|
129
|
+
export type CaptureLogger = {
|
|
130
|
+
info: (...args: any) => void;
|
|
131
|
+
warn: (...args: any) => void;
|
|
132
|
+
error: (...args: any) => void;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Overlay side-channel state returned by an overlayProvider. `glow` and
|
|
136
|
+
* `progress` are the reference built-ins; every OTHER own enumerable key is
|
|
137
|
+
* forwarded on the wire as a custom overlay kind (Phase 2 VIEW-04 pass-
|
|
138
|
+
* through -- see broadcastOverlayState and README entry E1). The identity
|
|
139
|
+
* keys `streamSessionId` / `snapshotId` are reserved: the capture core
|
|
140
|
+
* stamps them after the provider keys, so a provider can never overwrite
|
|
141
|
+
* stream identity.
|
|
142
|
+
*/
|
|
143
|
+
export type OverlayState = {
|
|
144
|
+
/**
|
|
145
|
+
* Action-highlight rect/state, or null
|
|
146
|
+
*/
|
|
147
|
+
glow?: any | null;
|
|
148
|
+
/**
|
|
149
|
+
* Progress-card state, or null
|
|
150
|
+
*/
|
|
151
|
+
progress?: any | null;
|
|
152
|
+
};
|
|
153
|
+
export type CaptureOptions = {
|
|
154
|
+
/**
|
|
155
|
+
* Required. Factory throws Error('transport-send-required') when
|
|
156
|
+
* transport.send is not a function (factory-time validation may throw;
|
|
157
|
+
* the capture path after start never does).
|
|
158
|
+
*/
|
|
159
|
+
transport: Transport;
|
|
160
|
+
/**
|
|
161
|
+
* Optional. Defaults to a console-backed logger.
|
|
162
|
+
*/
|
|
163
|
+
logger?: CaptureLogger;
|
|
164
|
+
/**
|
|
165
|
+
* Optional. Called by the overlay broadcaster to read host overlay state.
|
|
166
|
+
* ALL own enumerable provider keys are forwarded as overlay kinds (custom
|
|
167
|
+
* kinds included); glow/progress default null when omitted; the identity
|
|
168
|
+
* keys (streamSessionId / snapshotId) are reserved and never overwritten.
|
|
169
|
+
* Default null: overlay messages carry { glow: null, progress: null },
|
|
170
|
+
* preserving the reference's wire shape when no overlay system is present.
|
|
171
|
+
*/
|
|
172
|
+
overlayProvider?: (() => OverlayState | null);
|
|
173
|
+
/**
|
|
174
|
+
* Optional. Predicate marking elements the host wants excluded from
|
|
175
|
+
* capture (its own UI). Default returns false (nothing skipped).
|
|
176
|
+
* Applied ancestor-inclusively (closest()-like, reference parity): an
|
|
177
|
+
* element is excluded when the predicate matches it OR any of its
|
|
178
|
+
* ancestors, and skipped subtrees receive NO node-id assignment during
|
|
179
|
+
* serialization -- a root-only predicate (e.g. el.id === 'my-overlay')
|
|
180
|
+
* therefore excludes its whole subtree from both snapshots and diffs.
|
|
181
|
+
*/
|
|
182
|
+
skipElement?: (el: Element) => boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Optional (SEC-03). CSS selector: matching elements are replaced on the
|
|
185
|
+
* wire by a dimension-preserving placeholder carrying ONLY rr_width /
|
|
186
|
+
* rr_height (px, from the live rect) and the nid -- no attributes, no
|
|
187
|
+
* children, no text; mutations anywhere inside a blocked subtree emit
|
|
188
|
+
* nothing. Invalid selectors THROW Error('invalid-mask-selector') at
|
|
189
|
+
* factory time (fail closed and loud -- a silently dropped mask selector
|
|
190
|
+
* would be a privacy leak).
|
|
191
|
+
*/
|
|
192
|
+
blockSelector?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Optional (SEC-03). CSS selector: text of matching elements AND their
|
|
195
|
+
* descendants is masked (default mask: '*' per non-whitespace character,
|
|
196
|
+
* whitespace and length preserved -- rrweb-compatible). Same factory-time
|
|
197
|
+
* validation as blockSelector.
|
|
198
|
+
*/
|
|
199
|
+
maskTextSelector?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Optional (SEC-03), default false. When true, ALL input/textarea/select
|
|
202
|
+
* values are masked. Independent of this option, input[type=password]
|
|
203
|
+
* values are ALWAYS masked (non-configurable rrweb-parity default).
|
|
204
|
+
*/
|
|
205
|
+
maskInputs?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Optional (SEC-03). Custom text mask (rrweb signature). A THROWING fn
|
|
208
|
+
* falls back to the default asterisk mask -- raw text never leaks.
|
|
209
|
+
*/
|
|
210
|
+
maskTextFn?: (text: string, element: Element) => string;
|
|
211
|
+
/**
|
|
212
|
+
* Optional (SEC-03). Custom input-value mask (rrweb signature). Same
|
|
213
|
+
* fail-closed containment as maskTextFn.
|
|
214
|
+
*/
|
|
215
|
+
maskInputFn?: (text: string, element: Element) => string;
|
|
216
|
+
};
|
|
217
|
+
export type CaptureHandle = {
|
|
218
|
+
/**
|
|
219
|
+
* Fresh session: mint ids, snapshot, observe.
|
|
220
|
+
*/
|
|
221
|
+
start: () => void;
|
|
222
|
+
/**
|
|
223
|
+
* Stop observers (final flush included).
|
|
224
|
+
*/
|
|
225
|
+
stop: () => void;
|
|
226
|
+
/**
|
|
227
|
+
* Stop observers, keep the session alive.
|
|
228
|
+
*/
|
|
229
|
+
pause: () => void;
|
|
230
|
+
/**
|
|
231
|
+
* Re-arm observers; same session, no snapshot.
|
|
232
|
+
*/
|
|
233
|
+
resume: () => void;
|
|
234
|
+
/**
|
|
235
|
+
* getNodeId(element) -> string|null
|
|
236
|
+
* Return the active PhantomStream nid for a tracked live element, or null
|
|
237
|
+
* for untracked, skipped, disconnected, or inactive-session nodes.
|
|
238
|
+
*/
|
|
239
|
+
getNodeId: (element: Element) => string | null;
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/capture/index.js"],"names":[],"mappings":"AAqVA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AACH,sCAHW,cAAc,GACZ,aAAa,CAu0HzB;;;;;;;;;;;;;;;;UAx6Ha,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAQ,KAAK,IAAI;;;;;YAGvC,MAAM,IAAI;;;UAOV,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;UACpB,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;WACpB,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;;;;;;;;;;;;;;;WAYpB,MAAO,IAAI;;;;eACX,MAAO,IAAI;;;;;;;;eAKX,SAAS;;;;aAIT,aAAa;;;;;;;;;sBAEb,CAAC,MAAM,YAAY,GAAC,IAAI,CAAC;;;;;;;;;;kBAOzB,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO;;;;;;;;;;oBAQxB,MAAM;;;;;;;uBAQN,MAAM;;;;;;iBAKN,OAAO;;;;;iBAIP,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM;;;;;kBAG1C,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM;;;;;;WAO1C,MAAM,IAAI;;;;UACV,MAAM,IAAI;;;;WACV,MAAM,IAAI;;;;YACV,MAAM,IAAI;;;;;;eACV,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAC,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hard per-message size cap enforced by the relay (bytes).
|
|
3
|
+
* Capture-side snapshot truncation budgets derive from this value.
|
|
4
|
+
*/
|
|
5
|
+
export const RELAY_PER_MESSAGE_LIMIT_BYTES: 1048576;
|
|
6
|
+
/**
|
|
7
|
+
* Fraction of the relay cap a serialized snapshot may occupy. The remaining
|
|
8
|
+
* headroom absorbs envelope overhead and compression-resistant payloads
|
|
9
|
+
* where LZ does not reduce size.
|
|
10
|
+
*/
|
|
11
|
+
export const SNAPSHOT_BUDGET_FRACTION: 0.8;
|
|
12
|
+
/** Snapshot truncation byte budget. */
|
|
13
|
+
export const SNAPSHOT_BUDGET_BYTES: number;
|
|
14
|
+
/**
|
|
15
|
+
* During truncation, subtrees whose live top exceeds this many viewport
|
|
16
|
+
* heights are dropped first (content far below the fold).
|
|
17
|
+
*/
|
|
18
|
+
export const TRUNCATION_VIEWPORT_MULTIPLIER: 3;
|
|
19
|
+
/** Scroll side-channel throttle: at most one event per this many ms. */
|
|
20
|
+
export const SCROLL_THROTTLE_MS: 200;
|
|
21
|
+
/** Overlay side-channel throttle: at most one broadcast per this many ms. */
|
|
22
|
+
export const OVERLAY_THROTTLE_MS: 500;
|
|
23
|
+
/**
|
|
24
|
+
* Capture-side watchdog: if mutations are pending and nothing has drained
|
|
25
|
+
* for this long, force a flush and count a stale rescue.
|
|
26
|
+
*/
|
|
27
|
+
export const MUTATION_STALE_THRESHOLD_MS: 5000;
|
|
28
|
+
/** Capture-side watchdog tick cadence. */
|
|
29
|
+
export const WATCHDOG_TICK_MS: 500;
|
|
30
|
+
/** Readiness probe: poll interval and total budget. */
|
|
31
|
+
export const READY_PROBE_INTERVAL_MS: 200;
|
|
32
|
+
export const READY_PROBE_BUDGET_MS: 5000;
|
|
33
|
+
/** Inline <style> tags larger than this are skipped during snapshot capture. */
|
|
34
|
+
export const INLINE_STYLE_MAX_BYTES: 500000;
|
|
35
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/protocol/constants.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH,4CAA6C,OAAO,CAAC;AAErD;;;;GAIG;AACH,uCAAwC,GAAG,CAAC;AAE5C,uCAAuC;AACvC,2CAEE;AAEF;;;GAGG;AACH,6CAA8C,CAAC,CAAC;AAEhD,wEAAwE;AACxE,iCAAkC,GAAG,CAAC;AAEtC,6EAA6E;AAC7E,kCAAmC,GAAG,CAAC;AAEvC;;;GAGG;AACH,0CAA2C,IAAI,CAAC;AAEhD,0CAA0C;AAC1C,+BAAgC,GAAG,CAAC;AAEpC,uDAAuD;AACvD,sCAAuC,GAAG,CAAC;AAC3C,oCAAqC,IAAI,CAAC;AAE1C,gFAAgF;AAChF,qCAAsC,MAAM,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} LZCodec
|
|
3
|
+
* @property {(s: string) => string} compressToBase64
|
|
4
|
+
* @property {(s: string) => string|null} decompressFromBase64
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Encode a message object for the wire.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} msg The full message ({ type, payload, ... })
|
|
10
|
+
* @param {LZCodec} lz LZ-string (or compatible) codec
|
|
11
|
+
* @param {number} [thresholdBytes=0] Compress only when the JSON exceeds this size;
|
|
12
|
+
* 0 compresses everything
|
|
13
|
+
* @returns {string} JSON string ready to send
|
|
14
|
+
*/
|
|
15
|
+
export function encodeEnvelope(msg: any, lz: LZCodec, thresholdBytes?: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Decode a wire string into a message object. Detects the compressed
|
|
18
|
+
* envelope by shape; falls through to plain JSON otherwise.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} raw
|
|
21
|
+
* @param {LZCodec} [lz]
|
|
22
|
+
* @returns {{ok: true, msg: Object} | {ok: false, error: string}}
|
|
23
|
+
*/
|
|
24
|
+
export function decodeEnvelope(raw: string, lz?: LZCodec): {
|
|
25
|
+
ok: true;
|
|
26
|
+
msg: any;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
error: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Is this decoded wire object a compressed envelope (vs. a plain message)?
|
|
33
|
+
* Useful for relay-side diagnostics that classify traffic without decoding.
|
|
34
|
+
* @param {Object} obj
|
|
35
|
+
*/
|
|
36
|
+
export function isCompressedEnvelope(obj: any): boolean;
|
|
37
|
+
export type LZCodec = {
|
|
38
|
+
compressToBase64: (s: string) => string;
|
|
39
|
+
decompressFromBase64: (s: string) => string | null;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/protocol/envelope.js"],"names":[],"mappings":"AAWA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,6CALW,OAAO,mBACP,MAAM,GAEJ,MAAM,CASlB;AAED;;;;;;;GAOG;AACH,oCAJW,MAAM,OACN,OAAO,GACL;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,MAAQ;CAAC,GAAG;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAwBhE;AAED;;;;GAIG;AACH,wDAEC;;sBA7Da,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM;0BACrB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAC,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocol/index.js"],"names":[],"mappings":""}
|