@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,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} StyleScope
|
|
3
|
+
* @property {'document'|'shadow'|'frame'} kind
|
|
4
|
+
* @property {string} [hostNid] Shadow host nid when kind is 'shadow'
|
|
5
|
+
* @property {string} [frameNid] Iframe nid when kind is 'frame'
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} StyleSource
|
|
9
|
+
* @property {string} sourceId
|
|
10
|
+
* @property {StyleScope} scope
|
|
11
|
+
* @property {'link'|'style'|'constructable'|'adopted'|'fallback'} ownerKind
|
|
12
|
+
* @property {number} order
|
|
13
|
+
* @property {string|null} [href]
|
|
14
|
+
* @property {string} [media]
|
|
15
|
+
* @property {boolean} [disabled]
|
|
16
|
+
* @property {string} [cssText]
|
|
17
|
+
* @property {{reason: string}|null} [fallback]
|
|
18
|
+
* @property {number} [approxBytes]
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} StyleStrategy
|
|
22
|
+
* @property {'computed'|'cssom'} mode
|
|
23
|
+
* @property {number} sourceCount
|
|
24
|
+
* @property {number} fallbackCount
|
|
25
|
+
* @property {number} computedFallbackCount
|
|
26
|
+
* @property {number} approxCssBytes
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} StyleSourceDiffOp
|
|
30
|
+
* @property {'style-source'} op
|
|
31
|
+
* @property {'upsert'|'replace'|'remove'} action
|
|
32
|
+
* @property {string} sourceId
|
|
33
|
+
* @property {StyleScope} scope
|
|
34
|
+
* @property {StyleSource} [source]
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {Object} AddDiffOp
|
|
38
|
+
* @property {'add'} op
|
|
39
|
+
* @property {string} parentNid Parent node id in the current mirror
|
|
40
|
+
* @property {string} html Serialized subtree HTML, without framework identity attrs
|
|
41
|
+
* @property {string|null} beforeNid Insert before this sibling nid, or append when null
|
|
42
|
+
* @property {string[]} nodeIds Preorder ids for every serialized element in html
|
|
43
|
+
* @property {ShadowRootPayload[]} [shadowRoots] Open shadow root sidecars inside this added subtree
|
|
44
|
+
* @property {FramePayload[]} [frames] Same-origin/cross-origin frame sidecars inside this added subtree
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} ShadowRootPayload
|
|
48
|
+
* @property {string} hostNid Host element nid that owns this shadow root
|
|
49
|
+
* @property {'open'} mode Mirrored roots are open; closed roots are not introspected
|
|
50
|
+
* @property {string} html Serialized shadow root child HTML
|
|
51
|
+
* @property {string[]} nodeIds Preorder ids for shadow descendant elements
|
|
52
|
+
* @property {string} slotAssignment Content-free slot assignment hint/diagnostic
|
|
53
|
+
* @property {StyleSource[]} [styleSources] Scoped CSSOM sources for this shadow root
|
|
54
|
+
* @property {StyleStrategy} [styleStrategy] CSSOM strategy counters for this scope
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {Object} FramePayload
|
|
58
|
+
* @property {string} frameNid Iframe element nid
|
|
59
|
+
* @property {string} kind Frame policy kind, e.g. 'same-origin' or 'cross-origin'
|
|
60
|
+
* @property {string} [html] Serialized frame body HTML for accessible frames
|
|
61
|
+
* @property {string[]} [nodeIds] Preorder ids for serialized frame elements
|
|
62
|
+
* @property {string[]} [stylesheets] Absolutified stylesheet URLs
|
|
63
|
+
* @property {string[]} [inlineStyles] Sanitized inline style blocks
|
|
64
|
+
* @property {StyleSource[]} [styleSources] Scoped CSSOM sources for this frame document
|
|
65
|
+
* @property {StyleStrategy} [styleStrategy] CSSOM strategy counters for this scope
|
|
66
|
+
* @property {Object} [htmlAttrs] Sanitized frame <html> attributes
|
|
67
|
+
* @property {Object} [bodyAttrs] Sanitized frame <body> attributes
|
|
68
|
+
* @property {string} [htmlStyle] Computed shell style for frame <html>
|
|
69
|
+
* @property {string} [bodyStyle] Computed shell style for frame <body>
|
|
70
|
+
* @property {string} [label] Content-free placeholder label
|
|
71
|
+
* @property {string} [src] Frame src URL when safe to disclose
|
|
72
|
+
* @property {string} [origin] Frame origin metadata when safe to disclose
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {Object} ValueDiffOp
|
|
76
|
+
* @property {'value'} op
|
|
77
|
+
* @property {string} nid
|
|
78
|
+
* @property {string} [value] Textual value for input/textarea/select-like controls
|
|
79
|
+
* @property {boolean} [checked] Checked state for checkbox/radio controls
|
|
80
|
+
* @property {string[]} [selectedValues] Selected option values for multi-select controls
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* @typedef {Object} SubtreeRequestPayload
|
|
84
|
+
* @property {string} requestId
|
|
85
|
+
* @property {string} nid
|
|
86
|
+
* @property {string} streamSessionId
|
|
87
|
+
* @property {number} snapshotId
|
|
88
|
+
* @property {string} [reason]
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} SubtreeResponsePayload
|
|
92
|
+
* @property {string} requestId
|
|
93
|
+
* @property {string} nid
|
|
94
|
+
* @property {string} status 'ok' or a content-free miss status
|
|
95
|
+
* @property {string} [html] Serialized subtree HTML when status is 'ok'
|
|
96
|
+
* @property {string[]} [nodeIds] Preorder ids for serialized subtree elements
|
|
97
|
+
* @property {ShadowRootPayload[]} [shadowRoots] Open shadow roots inside the subtree
|
|
98
|
+
* @property {FramePayload[]} [frames] Frame sidecars inside the subtree
|
|
99
|
+
* @property {StyleSource[]} [styleSources] Scoped CSSOM sources inside the subtree
|
|
100
|
+
* @property {StyleStrategy} [styleStrategy] CSSOM strategy counters for subtree sources
|
|
101
|
+
* @property {string} streamSessionId
|
|
102
|
+
* @property {number} snapshotId
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {Object} SnapshotPayload
|
|
106
|
+
* @property {string} html Serialized body innerHTML (style-inlined; framework identity-clean)
|
|
107
|
+
* @property {string[]} nodeIds Preorder ids for every serialized element in html
|
|
108
|
+
* @property {ShadowRootPayload[]} [shadowRoots] Open shadow roots keyed by host nid
|
|
109
|
+
* @property {FramePayload[]} [frames] Frame sidecars keyed by iframe nid
|
|
110
|
+
* @property {boolean} truncated True if the size budget forced subtree drops
|
|
111
|
+
* @property {number} missingDescendants Count of dropped subtrees
|
|
112
|
+
* @property {string[]} stylesheets Absolutified <link rel=stylesheet> URLs
|
|
113
|
+
* @property {string[]} inlineStyles Inline <style> text blocks from <head>
|
|
114
|
+
* @property {StyleSource[]} [styleSources] Scoped CSSOM sources for document/shadow/frame scopes
|
|
115
|
+
* @property {StyleStrategy} [styleStrategy] CSSOM strategy counters for document-level sources
|
|
116
|
+
* @property {Object} htmlAttrs Sanitized <html> attributes
|
|
117
|
+
* @property {Object} bodyAttrs Sanitized <body> attributes
|
|
118
|
+
* @property {string} htmlStyle Shell computed style for <html>
|
|
119
|
+
* @property {string} bodyStyle Shell computed style for <body>
|
|
120
|
+
* @property {number} scrollX
|
|
121
|
+
* @property {number} scrollY
|
|
122
|
+
* @property {number} viewportWidth
|
|
123
|
+
* @property {number} viewportHeight
|
|
124
|
+
* @property {number} pageWidth
|
|
125
|
+
* @property {number} pageHeight
|
|
126
|
+
* @property {string} url
|
|
127
|
+
* @property {string} title
|
|
128
|
+
* @property {string} streamSessionId Identity: minted per stream session
|
|
129
|
+
* @property {number} snapshotId Identity: minted per snapshot
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* @typedef {Object} DialogPayload
|
|
133
|
+
* @property {'alert'|'confirm'|'prompt'} type
|
|
134
|
+
* @property {'open'|'closed'} state
|
|
135
|
+
* @property {string} [message]
|
|
136
|
+
* @property {string} [defaultValue] prompt only
|
|
137
|
+
* @property {*} [result] on close: confirm boolean / prompt string|null
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* Mint a stream session id. Caller supplies entropy so the protocol layer
|
|
141
|
+
* stays pure (and replayable in tests).
|
|
142
|
+
* @param {number} nowMs e.g. Date.now()
|
|
143
|
+
* @param {string} rand short random suffix, e.g. Math.random().toString(36).slice(2, 8)
|
|
144
|
+
*/
|
|
145
|
+
export function createStreamSessionId(nowMs: number, rand: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* Staleness guard: should a viewer accept a message for the currently
|
|
148
|
+
* active stream identity? Messages with no identity are accepted
|
|
149
|
+
* (backward compatibility); messages with a mismatched identity are stale.
|
|
150
|
+
*
|
|
151
|
+
* @param {{streamSessionId?: string, snapshotId?: number}} msg
|
|
152
|
+
* @param {{streamSessionId?: string, snapshotId?: number}} active
|
|
153
|
+
* @returns {boolean}
|
|
154
|
+
*/
|
|
155
|
+
export function isCurrentStream(msg: {
|
|
156
|
+
streamSessionId?: string;
|
|
157
|
+
snapshotId?: number;
|
|
158
|
+
}, active: {
|
|
159
|
+
streamSessionId?: string;
|
|
160
|
+
snapshotId?: number;
|
|
161
|
+
}): boolean;
|
|
162
|
+
export namespace CONTROL {
|
|
163
|
+
let START: string;
|
|
164
|
+
let STOP: string;
|
|
165
|
+
let PAUSE: string;
|
|
166
|
+
let RESUME: string;
|
|
167
|
+
let SUBTREE_REQUEST: string;
|
|
168
|
+
}
|
|
169
|
+
export namespace STREAM {
|
|
170
|
+
let SNAPSHOT: string;
|
|
171
|
+
let MUTATIONS: string;
|
|
172
|
+
let SCROLL: string;
|
|
173
|
+
let OVERLAY: string;
|
|
174
|
+
let DIALOG: string;
|
|
175
|
+
let READY: string;
|
|
176
|
+
let REQUEST_SNAPSHOT: string;
|
|
177
|
+
let STATE: string;
|
|
178
|
+
let SUBTREE_RESPONSE: string;
|
|
179
|
+
}
|
|
180
|
+
export namespace REMOTE_CONTROL {
|
|
181
|
+
export let REQUEST: string;
|
|
182
|
+
let STOP_1: string;
|
|
183
|
+
export { STOP_1 as STOP };
|
|
184
|
+
export let CLICK: string;
|
|
185
|
+
export let TEXT: string;
|
|
186
|
+
export let KEY: string;
|
|
187
|
+
let SCROLL_1: string;
|
|
188
|
+
export { SCROLL_1 as SCROLL };
|
|
189
|
+
let STATE_1: string;
|
|
190
|
+
export { STATE_1 as STATE };
|
|
191
|
+
}
|
|
192
|
+
export { REMOTE_CONTROL_STATE_VALUES as REMOTE_CONTROL_STATE };
|
|
193
|
+
export namespace DIFF_OP {
|
|
194
|
+
export let ADD: string;
|
|
195
|
+
export let REMOVE: string;
|
|
196
|
+
export let ATTR: string;
|
|
197
|
+
let TEXT_1: string;
|
|
198
|
+
export { TEXT_1 as TEXT };
|
|
199
|
+
export let VALUE: string;
|
|
200
|
+
export let SHADOW_ROOT: string;
|
|
201
|
+
export let FRAME: string;
|
|
202
|
+
export let STYLE_SOURCE: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Legacy identity attribute name retained for compatibility with renderer
|
|
206
|
+
* and fixture code that still consumes nid-stamped mirror DOM. Capture-side
|
|
207
|
+
* framework identity now travels through SnapshotPayload.nodeIds and add-op
|
|
208
|
+
* nodeIds sidecars instead of mutating observed page elements.
|
|
209
|
+
*/
|
|
210
|
+
export const NID_ATTR: "data-fsb-nid";
|
|
211
|
+
export type StyleScope = {
|
|
212
|
+
kind: "document" | "shadow" | "frame";
|
|
213
|
+
/**
|
|
214
|
+
* Shadow host nid when kind is 'shadow'
|
|
215
|
+
*/
|
|
216
|
+
hostNid?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Iframe nid when kind is 'frame'
|
|
219
|
+
*/
|
|
220
|
+
frameNid?: string;
|
|
221
|
+
};
|
|
222
|
+
export type StyleSource = {
|
|
223
|
+
sourceId: string;
|
|
224
|
+
scope: StyleScope;
|
|
225
|
+
ownerKind: "link" | "style" | "constructable" | "adopted" | "fallback";
|
|
226
|
+
order: number;
|
|
227
|
+
href?: string | null;
|
|
228
|
+
media?: string;
|
|
229
|
+
disabled?: boolean;
|
|
230
|
+
cssText?: string;
|
|
231
|
+
fallback?: {
|
|
232
|
+
reason: string;
|
|
233
|
+
} | null;
|
|
234
|
+
approxBytes?: number;
|
|
235
|
+
};
|
|
236
|
+
export type StyleStrategy = {
|
|
237
|
+
mode: "computed" | "cssom";
|
|
238
|
+
sourceCount: number;
|
|
239
|
+
fallbackCount: number;
|
|
240
|
+
computedFallbackCount: number;
|
|
241
|
+
approxCssBytes: number;
|
|
242
|
+
};
|
|
243
|
+
export type StyleSourceDiffOp = {
|
|
244
|
+
op: "style-source";
|
|
245
|
+
action: "upsert" | "replace" | "remove";
|
|
246
|
+
sourceId: string;
|
|
247
|
+
scope: StyleScope;
|
|
248
|
+
source?: StyleSource;
|
|
249
|
+
};
|
|
250
|
+
export type AddDiffOp = {
|
|
251
|
+
op: "add";
|
|
252
|
+
/**
|
|
253
|
+
* Parent node id in the current mirror
|
|
254
|
+
*/
|
|
255
|
+
parentNid: string;
|
|
256
|
+
/**
|
|
257
|
+
* Serialized subtree HTML, without framework identity attrs
|
|
258
|
+
*/
|
|
259
|
+
html: string;
|
|
260
|
+
/**
|
|
261
|
+
* Insert before this sibling nid, or append when null
|
|
262
|
+
*/
|
|
263
|
+
beforeNid: string | null;
|
|
264
|
+
/**
|
|
265
|
+
* Preorder ids for every serialized element in html
|
|
266
|
+
*/
|
|
267
|
+
nodeIds: string[];
|
|
268
|
+
/**
|
|
269
|
+
* Open shadow root sidecars inside this added subtree
|
|
270
|
+
*/
|
|
271
|
+
shadowRoots?: ShadowRootPayload[];
|
|
272
|
+
/**
|
|
273
|
+
* Same-origin/cross-origin frame sidecars inside this added subtree
|
|
274
|
+
*/
|
|
275
|
+
frames?: FramePayload[];
|
|
276
|
+
};
|
|
277
|
+
export type ShadowRootPayload = {
|
|
278
|
+
/**
|
|
279
|
+
* Host element nid that owns this shadow root
|
|
280
|
+
*/
|
|
281
|
+
hostNid: string;
|
|
282
|
+
/**
|
|
283
|
+
* Mirrored roots are open; closed roots are not introspected
|
|
284
|
+
*/
|
|
285
|
+
mode: "open";
|
|
286
|
+
/**
|
|
287
|
+
* Serialized shadow root child HTML
|
|
288
|
+
*/
|
|
289
|
+
html: string;
|
|
290
|
+
/**
|
|
291
|
+
* Preorder ids for shadow descendant elements
|
|
292
|
+
*/
|
|
293
|
+
nodeIds: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Content-free slot assignment hint/diagnostic
|
|
296
|
+
*/
|
|
297
|
+
slotAssignment: string;
|
|
298
|
+
/**
|
|
299
|
+
* Scoped CSSOM sources for this shadow root
|
|
300
|
+
*/
|
|
301
|
+
styleSources?: StyleSource[];
|
|
302
|
+
/**
|
|
303
|
+
* CSSOM strategy counters for this scope
|
|
304
|
+
*/
|
|
305
|
+
styleStrategy?: StyleStrategy;
|
|
306
|
+
};
|
|
307
|
+
export type FramePayload = {
|
|
308
|
+
/**
|
|
309
|
+
* Iframe element nid
|
|
310
|
+
*/
|
|
311
|
+
frameNid: string;
|
|
312
|
+
/**
|
|
313
|
+
* Frame policy kind, e.g. 'same-origin' or 'cross-origin'
|
|
314
|
+
*/
|
|
315
|
+
kind: string;
|
|
316
|
+
/**
|
|
317
|
+
* Serialized frame body HTML for accessible frames
|
|
318
|
+
*/
|
|
319
|
+
html?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Preorder ids for serialized frame elements
|
|
322
|
+
*/
|
|
323
|
+
nodeIds?: string[];
|
|
324
|
+
/**
|
|
325
|
+
* Absolutified stylesheet URLs
|
|
326
|
+
*/
|
|
327
|
+
stylesheets?: string[];
|
|
328
|
+
/**
|
|
329
|
+
* Sanitized inline style blocks
|
|
330
|
+
*/
|
|
331
|
+
inlineStyles?: string[];
|
|
332
|
+
/**
|
|
333
|
+
* Scoped CSSOM sources for this frame document
|
|
334
|
+
*/
|
|
335
|
+
styleSources?: StyleSource[];
|
|
336
|
+
/**
|
|
337
|
+
* CSSOM strategy counters for this scope
|
|
338
|
+
*/
|
|
339
|
+
styleStrategy?: StyleStrategy;
|
|
340
|
+
/**
|
|
341
|
+
* Sanitized frame <html> attributes
|
|
342
|
+
*/
|
|
343
|
+
htmlAttrs?: any;
|
|
344
|
+
/**
|
|
345
|
+
* Sanitized frame <body> attributes
|
|
346
|
+
*/
|
|
347
|
+
bodyAttrs?: any;
|
|
348
|
+
/**
|
|
349
|
+
* Computed shell style for frame <html>
|
|
350
|
+
*/
|
|
351
|
+
htmlStyle?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Computed shell style for frame <body>
|
|
354
|
+
*/
|
|
355
|
+
bodyStyle?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Content-free placeholder label
|
|
358
|
+
*/
|
|
359
|
+
label?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Frame src URL when safe to disclose
|
|
362
|
+
*/
|
|
363
|
+
src?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Frame origin metadata when safe to disclose
|
|
366
|
+
*/
|
|
367
|
+
origin?: string;
|
|
368
|
+
};
|
|
369
|
+
export type ValueDiffOp = {
|
|
370
|
+
op: "value";
|
|
371
|
+
nid: string;
|
|
372
|
+
/**
|
|
373
|
+
* Textual value for input/textarea/select-like controls
|
|
374
|
+
*/
|
|
375
|
+
value?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Checked state for checkbox/radio controls
|
|
378
|
+
*/
|
|
379
|
+
checked?: boolean;
|
|
380
|
+
/**
|
|
381
|
+
* Selected option values for multi-select controls
|
|
382
|
+
*/
|
|
383
|
+
selectedValues?: string[];
|
|
384
|
+
};
|
|
385
|
+
export type SubtreeRequestPayload = {
|
|
386
|
+
requestId: string;
|
|
387
|
+
nid: string;
|
|
388
|
+
streamSessionId: string;
|
|
389
|
+
snapshotId: number;
|
|
390
|
+
reason?: string;
|
|
391
|
+
};
|
|
392
|
+
export type SubtreeResponsePayload = {
|
|
393
|
+
requestId: string;
|
|
394
|
+
nid: string;
|
|
395
|
+
/**
|
|
396
|
+
* 'ok' or a content-free miss status
|
|
397
|
+
*/
|
|
398
|
+
status: string;
|
|
399
|
+
/**
|
|
400
|
+
* Serialized subtree HTML when status is 'ok'
|
|
401
|
+
*/
|
|
402
|
+
html?: string;
|
|
403
|
+
/**
|
|
404
|
+
* Preorder ids for serialized subtree elements
|
|
405
|
+
*/
|
|
406
|
+
nodeIds?: string[];
|
|
407
|
+
/**
|
|
408
|
+
* Open shadow roots inside the subtree
|
|
409
|
+
*/
|
|
410
|
+
shadowRoots?: ShadowRootPayload[];
|
|
411
|
+
/**
|
|
412
|
+
* Frame sidecars inside the subtree
|
|
413
|
+
*/
|
|
414
|
+
frames?: FramePayload[];
|
|
415
|
+
/**
|
|
416
|
+
* Scoped CSSOM sources inside the subtree
|
|
417
|
+
*/
|
|
418
|
+
styleSources?: StyleSource[];
|
|
419
|
+
/**
|
|
420
|
+
* CSSOM strategy counters for subtree sources
|
|
421
|
+
*/
|
|
422
|
+
styleStrategy?: StyleStrategy;
|
|
423
|
+
streamSessionId: string;
|
|
424
|
+
snapshotId: number;
|
|
425
|
+
};
|
|
426
|
+
export type SnapshotPayload = {
|
|
427
|
+
/**
|
|
428
|
+
* Serialized body innerHTML (style-inlined; framework identity-clean)
|
|
429
|
+
*/
|
|
430
|
+
html: string;
|
|
431
|
+
/**
|
|
432
|
+
* Preorder ids for every serialized element in html
|
|
433
|
+
*/
|
|
434
|
+
nodeIds: string[];
|
|
435
|
+
/**
|
|
436
|
+
* Open shadow roots keyed by host nid
|
|
437
|
+
*/
|
|
438
|
+
shadowRoots?: ShadowRootPayload[];
|
|
439
|
+
/**
|
|
440
|
+
* Frame sidecars keyed by iframe nid
|
|
441
|
+
*/
|
|
442
|
+
frames?: FramePayload[];
|
|
443
|
+
/**
|
|
444
|
+
* True if the size budget forced subtree drops
|
|
445
|
+
*/
|
|
446
|
+
truncated: boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Count of dropped subtrees
|
|
449
|
+
*/
|
|
450
|
+
missingDescendants: number;
|
|
451
|
+
/**
|
|
452
|
+
* Absolutified <link rel=stylesheet> URLs
|
|
453
|
+
*/
|
|
454
|
+
stylesheets: string[];
|
|
455
|
+
/**
|
|
456
|
+
* Inline <style> text blocks from <head>
|
|
457
|
+
*/
|
|
458
|
+
inlineStyles: string[];
|
|
459
|
+
/**
|
|
460
|
+
* Scoped CSSOM sources for document/shadow/frame scopes
|
|
461
|
+
*/
|
|
462
|
+
styleSources?: StyleSource[];
|
|
463
|
+
/**
|
|
464
|
+
* CSSOM strategy counters for document-level sources
|
|
465
|
+
*/
|
|
466
|
+
styleStrategy?: StyleStrategy;
|
|
467
|
+
/**
|
|
468
|
+
* Sanitized <html> attributes
|
|
469
|
+
*/
|
|
470
|
+
htmlAttrs: any;
|
|
471
|
+
/**
|
|
472
|
+
* Sanitized <body> attributes
|
|
473
|
+
*/
|
|
474
|
+
bodyAttrs: any;
|
|
475
|
+
/**
|
|
476
|
+
* Shell computed style for <html>
|
|
477
|
+
*/
|
|
478
|
+
htmlStyle: string;
|
|
479
|
+
/**
|
|
480
|
+
* Shell computed style for <body>
|
|
481
|
+
*/
|
|
482
|
+
bodyStyle: string;
|
|
483
|
+
scrollX: number;
|
|
484
|
+
scrollY: number;
|
|
485
|
+
viewportWidth: number;
|
|
486
|
+
viewportHeight: number;
|
|
487
|
+
pageWidth: number;
|
|
488
|
+
pageHeight: number;
|
|
489
|
+
url: string;
|
|
490
|
+
title: string;
|
|
491
|
+
/**
|
|
492
|
+
* Identity: minted per stream session
|
|
493
|
+
*/
|
|
494
|
+
streamSessionId: string;
|
|
495
|
+
/**
|
|
496
|
+
* Identity: minted per snapshot
|
|
497
|
+
*/
|
|
498
|
+
snapshotId: number;
|
|
499
|
+
};
|
|
500
|
+
export type DialogPayload = {
|
|
501
|
+
type: "alert" | "confirm" | "prompt";
|
|
502
|
+
state: "open" | "closed";
|
|
503
|
+
message?: string;
|
|
504
|
+
/**
|
|
505
|
+
* prompt only
|
|
506
|
+
*/
|
|
507
|
+
defaultValue?: string;
|
|
508
|
+
/**
|
|
509
|
+
* on close: confirm boolean / prompt string|null
|
|
510
|
+
*/
|
|
511
|
+
result?: any;
|
|
512
|
+
};
|
|
513
|
+
declare namespace REMOTE_CONTROL_STATE_VALUES {
|
|
514
|
+
let LOCKED: string;
|
|
515
|
+
let REQUESTING: string;
|
|
516
|
+
let ACTIVE: string;
|
|
517
|
+
let DENIED: string;
|
|
518
|
+
let STOPPED: string;
|
|
519
|
+
}
|
|
520
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/protocol/messages.js"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} RemoteControlAction
|
|
3
|
+
* @property {string} type
|
|
4
|
+
* @property {string} kind
|
|
5
|
+
* @property {number} [x]
|
|
6
|
+
* @property {number} [y]
|
|
7
|
+
* @property {number} [deltaX]
|
|
8
|
+
* @property {number} [deltaY]
|
|
9
|
+
* @property {'left'|'middle'|'right'} [button]
|
|
10
|
+
* @property {number} [clickCount]
|
|
11
|
+
* @property {string} [key]
|
|
12
|
+
* @property {'down'|'up'} [event]
|
|
13
|
+
* @property {string} [text]
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Is this a PhantomStream remote-control protocol frame type?
|
|
17
|
+
* @param {string} type
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export function isRemoteControlType(type: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Validate and normalize an untrusted remote-control message.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} type
|
|
25
|
+
* @param {Object} payload
|
|
26
|
+
* @returns {{ok: true, action: RemoteControlAction} | {ok: false, error: string}}
|
|
27
|
+
*/
|
|
28
|
+
export function validateRemoteControlMessage(type: string, payload: any): {
|
|
29
|
+
ok: true;
|
|
30
|
+
action: RemoteControlAction;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
error: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Return a content-free action summary suitable for logs/state telemetry.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} type
|
|
39
|
+
* @param {Object} payload
|
|
40
|
+
* @returns {Object}
|
|
41
|
+
*/
|
|
42
|
+
export function summarizeRemoteControlAction(type: string, payload: any): any;
|
|
43
|
+
/**
|
|
44
|
+
* Create a content-free remote-control state event.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} state
|
|
47
|
+
* @param {string} reason
|
|
48
|
+
* @param {Object} [extra]
|
|
49
|
+
* @returns {{state: string, reason: string, counts?: Object}}
|
|
50
|
+
*/
|
|
51
|
+
export function createRemoteControlStateEvent(state: string, reason: string, extra?: any): {
|
|
52
|
+
state: string;
|
|
53
|
+
reason: string;
|
|
54
|
+
counts?: any;
|
|
55
|
+
};
|
|
56
|
+
export const REMOTE_TEXT_MAX_CHARS: 4096;
|
|
57
|
+
export type RemoteControlAction = {
|
|
58
|
+
type: string;
|
|
59
|
+
kind: string;
|
|
60
|
+
x?: number;
|
|
61
|
+
y?: number;
|
|
62
|
+
deltaX?: number;
|
|
63
|
+
deltaY?: number;
|
|
64
|
+
button?: "left" | "middle" | "right";
|
|
65
|
+
clickCount?: number;
|
|
66
|
+
key?: string;
|
|
67
|
+
event?: "down" | "up";
|
|
68
|
+
text?: string;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=remote-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-control.d.ts","sourceRoot":"","sources":["../../../src/protocol/remote-control.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,0CAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;;GAMG;AACH,mDAJW,MAAM,iBAEJ;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAC,GAAG;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAyBhF;AAED;;;;;;GAMG;AACH,mDAJW,MAAM,qBAuDhB;AAED;;;;;;;GAOG;AACH,qDALW,MAAM,UACN,MAAM,gBAEJ;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,MAAQ;CAAC,CAY5D;AA1JD,oCAAqC,IAAI,CAAC;;UAsB5B,MAAM;UACN,MAAM;QACN,MAAM;QACN,MAAM;aACN,MAAM;aACN,MAAM;aACN,MAAM,GAAC,QAAQ,GAAC,OAAO;iBACvB,MAAM;UACN,MAAM;YACN,MAAM,GAAC,IAAI;WACX,MAAM"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} WebSocketRelayBackendOptions
|
|
3
|
+
* @property {import('node:http').Server} server
|
|
4
|
+
* @property {{
|
|
5
|
+
* addClient: Function,
|
|
6
|
+
* removeClient: Function,
|
|
7
|
+
* receive: Function
|
|
8
|
+
* }} relay
|
|
9
|
+
* @property {string} [path]
|
|
10
|
+
* @property {number} [capBytes]
|
|
11
|
+
* @property {{info?: Function, warn?: Function, error?: Function}} [logger]
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Bind a ws WebSocketServer to an existing Node HTTP server.
|
|
15
|
+
*
|
|
16
|
+
* @param {WebSocketRelayBackendOptions} options
|
|
17
|
+
* @returns {{wss: WebSocketServer, close: () => Promise<void>, options: Object}}
|
|
18
|
+
*/
|
|
19
|
+
export function createWebSocketRelayBackend(options: WebSocketRelayBackendOptions): {
|
|
20
|
+
wss: WebSocketServer;
|
|
21
|
+
close: () => Promise<void>;
|
|
22
|
+
options: any;
|
|
23
|
+
};
|
|
24
|
+
export type WebSocketRelayBackendOptions = {
|
|
25
|
+
server: any;
|
|
26
|
+
relay: {
|
|
27
|
+
addClient: Function;
|
|
28
|
+
removeClient: Function;
|
|
29
|
+
receive: Function;
|
|
30
|
+
};
|
|
31
|
+
path?: string;
|
|
32
|
+
capBytes?: number;
|
|
33
|
+
logger?: {
|
|
34
|
+
info?: Function;
|
|
35
|
+
warn?: Function;
|
|
36
|
+
error?: Function;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=ws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../../src/relay/backends/ws.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,qDAHW,4BAA4B,GAC1B;IAAC,GAAG,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,OAAO,MAAQ;CAAC,CA6F/E;;;WA3Ga;QACT,SAAS,WAAW;QACpB,YAAY,WAAW;QACvB,OAAO,WAAU;KAClB;WACU,MAAM;eACN,MAAM;aACN;QAAC,IAAI,CAAC,WAAW;QAAC,IAAI,CAAC,WAAW;QAAC,KAAK,CAAC,WAAU;KAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/relay/index.js"],"names":[],"mappings":""}
|