@lynx-js/devtool-connector 0.9.4 → 0.13.1
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/CHANGELOG.md +6 -0
- package/LICENSE +1 -1
- package/dist/346.js +635 -0
- package/dist/390.js +262 -35
- package/dist/556.js +9 -4
- package/dist/61.js +3432 -0
- package/dist/63.js +112 -30
- package/dist/712.js +28 -2
- package/dist/872.js +552 -122
- package/dist/962.js +38 -31
- package/dist/client-discovery-errors.d.ts +1 -0
- package/dist/client-id.d.ts +9 -2
- package/dist/command/client.d.ts +28 -0
- package/dist/command/contract.d.ts +255 -0
- package/dist/command/core.d.ts +32 -0
- package/dist/command/index.d.ts +20 -0
- package/dist/command/index.js +224 -0
- package/dist/command/query.d.ts +5 -0
- package/dist/command/reactlynx/controller.d.ts +71 -0
- package/dist/command/reactlynx/model.d.ts +48 -0
- package/dist/command/reactlynx/protocol.d.ts +40 -0
- package/dist/command/reactlynx/session.d.ts +43 -0
- package/dist/command/reactlynx/types.d.ts +73 -0
- package/dist/command/ref-actions.d.ts +17 -0
- package/dist/command/result.d.ts +29 -0
- package/dist/command/screenshot-annotation.d.ts +22 -0
- package/dist/command/screenshot.d.ts +28 -0
- package/dist/command/snapshot.d.ts +79 -0
- package/dist/command/targets.d.ts +15 -0
- package/dist/daemon/device-connection.d.ts +3 -1
- package/dist/daemon/entry.js +11 -0
- package/dist/daemon/index.d.ts +1 -0
- package/dist/daemon/index.js +3 -0
- package/dist/daemon/manager.d.ts +11 -9
- package/dist/daemon/protocol.d.ts +24 -3
- package/dist/daemon/server.d.ts +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -454
- package/dist/streams/customized.d.ts +2 -1
- package/dist/transport/android.d.ts +1 -1
- package/dist/transport/desktop.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/transport/ios.d.ts +1 -1
- package/dist/transport/transport.d.ts +7 -1
- package/dist/transport/ws-stream.d.ts +9 -0
- package/dist/types.d.ts +35 -0
- package/package.json +11 -3
- package/dist/187.js +0 -272
- package/dist/43.js +0 -20
- package/dist/677.js +0 -19
package/dist/63.js
CHANGED
|
@@ -1,7 +1,102 @@
|
|
|
1
1
|
import { ReadableStream, WritableStream } from "node:stream/web";
|
|
2
2
|
import { WebSocket } from "ws";
|
|
3
|
+
function stringifyWebSocketData(data) {
|
|
4
|
+
return 'string' == typeof data ? data : data.toString();
|
|
5
|
+
}
|
|
6
|
+
const NORMAL_CLOSE_CODES = new Set([
|
|
7
|
+
1000,
|
|
8
|
+
1001,
|
|
9
|
+
1005
|
|
10
|
+
]);
|
|
11
|
+
function createWebSocketCloseError(code, reason) {
|
|
12
|
+
if (NORMAL_CLOSE_CODES.has(code)) return null;
|
|
13
|
+
const text = reason.toString('utf8');
|
|
14
|
+
return Object.assign(new Error(`WebSocket closed abnormally (${code})${text ? `: ${text}` : ''}`), {
|
|
15
|
+
code,
|
|
16
|
+
reason: text
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function createOwnedWebSocketReadable(ws) {
|
|
20
|
+
let cleanup = ()=>{};
|
|
21
|
+
let prepareForClose = ()=>{};
|
|
22
|
+
let resume = ()=>{};
|
|
23
|
+
const readable = new ReadableStream({
|
|
24
|
+
start (controller) {
|
|
25
|
+
let active = true;
|
|
26
|
+
let acceptingMessages = true;
|
|
27
|
+
let paused = false;
|
|
28
|
+
resume = ()=>{
|
|
29
|
+
if (!active || !paused) return;
|
|
30
|
+
paused = false;
|
|
31
|
+
ws.resume();
|
|
32
|
+
};
|
|
33
|
+
const stop = ()=>{
|
|
34
|
+
if (!active) return;
|
|
35
|
+
active = false;
|
|
36
|
+
acceptingMessages = false;
|
|
37
|
+
if (paused) {
|
|
38
|
+
paused = false;
|
|
39
|
+
ws.resume();
|
|
40
|
+
}
|
|
41
|
+
ws.off('message', onMessage);
|
|
42
|
+
ws.off('close', onClose);
|
|
43
|
+
ws.off('error', onError);
|
|
44
|
+
};
|
|
45
|
+
const stopAcceptingMessages = ()=>{
|
|
46
|
+
if (!active || !acceptingMessages) return;
|
|
47
|
+
acceptingMessages = false;
|
|
48
|
+
ws.off('message', onMessage);
|
|
49
|
+
resume();
|
|
50
|
+
};
|
|
51
|
+
const onMessage = (data)=>{
|
|
52
|
+
if (!active || !acceptingMessages) return;
|
|
53
|
+
controller.enqueue(stringifyWebSocketData(data));
|
|
54
|
+
if (null !== controller.desiredSize && controller.desiredSize <= 0) {
|
|
55
|
+
paused = true;
|
|
56
|
+
ws.pause();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const onClose = (code, reason)=>{
|
|
60
|
+
const error = createWebSocketCloseError(code, reason);
|
|
61
|
+
stop();
|
|
62
|
+
try {
|
|
63
|
+
if (error) controller.error(error);
|
|
64
|
+
else controller.close();
|
|
65
|
+
} catch {}
|
|
66
|
+
};
|
|
67
|
+
const onError = (err)=>{
|
|
68
|
+
stop();
|
|
69
|
+
try {
|
|
70
|
+
controller.error(err);
|
|
71
|
+
} catch {}
|
|
72
|
+
};
|
|
73
|
+
cleanup = stop;
|
|
74
|
+
prepareForClose = stopAcceptingMessages;
|
|
75
|
+
ws.on('message', onMessage);
|
|
76
|
+
ws.on('close', onClose);
|
|
77
|
+
ws.on('error', onError);
|
|
78
|
+
},
|
|
79
|
+
pull () {
|
|
80
|
+
resume();
|
|
81
|
+
},
|
|
82
|
+
cancel () {
|
|
83
|
+
cleanup();
|
|
84
|
+
ws.close();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
readable,
|
|
89
|
+
prepareForClose () {
|
|
90
|
+
prepareForClose();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function createWebSocketReadable(ws) {
|
|
95
|
+
return createOwnedWebSocketReadable(ws).readable;
|
|
96
|
+
}
|
|
3
97
|
class WsWebSocketStream {
|
|
4
98
|
#ws;
|
|
99
|
+
#prepareReadableForClose = ()=>{};
|
|
5
100
|
opened;
|
|
6
101
|
closed;
|
|
7
102
|
#resolveClosed;
|
|
@@ -19,10 +114,12 @@ class WsWebSocketStream {
|
|
|
19
114
|
reject(err);
|
|
20
115
|
this.#rejectClosed(err);
|
|
21
116
|
};
|
|
22
|
-
const onClose = ()=>{
|
|
117
|
+
const onClose = (code, reason)=>{
|
|
23
118
|
cleanup();
|
|
24
|
-
|
|
25
|
-
|
|
119
|
+
const error = createWebSocketCloseError(code, reason);
|
|
120
|
+
reject(error ?? new Error('WebSocket closed before opening.'));
|
|
121
|
+
if (error) this.#rejectClosed(error);
|
|
122
|
+
else this.#resolveClosed();
|
|
26
123
|
};
|
|
27
124
|
const cleanup = ()=>{
|
|
28
125
|
ws.removeListener('error', onError);
|
|
@@ -30,26 +127,8 @@ class WsWebSocketStream {
|
|
|
30
127
|
};
|
|
31
128
|
ws.once('open', ()=>{
|
|
32
129
|
cleanup();
|
|
33
|
-
const readable =
|
|
34
|
-
|
|
35
|
-
ws.on('message', (data)=>{
|
|
36
|
-
controller.enqueue('string' == typeof data ? data : data.toString());
|
|
37
|
-
});
|
|
38
|
-
ws.on('close', ()=>{
|
|
39
|
-
try {
|
|
40
|
-
controller.close();
|
|
41
|
-
} catch {}
|
|
42
|
-
});
|
|
43
|
-
ws.on('error', (err)=>{
|
|
44
|
-
try {
|
|
45
|
-
controller.error(err);
|
|
46
|
-
} catch {}
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
cancel () {
|
|
50
|
-
ws.close();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
130
|
+
const { readable, prepareForClose } = createOwnedWebSocketReadable(ws);
|
|
131
|
+
this.#prepareReadableForClose = prepareForClose;
|
|
53
132
|
const writable = new WritableStream({
|
|
54
133
|
write (chunk) {
|
|
55
134
|
return new Promise((res, rej)=>{
|
|
@@ -59,19 +138,21 @@ class WsWebSocketStream {
|
|
|
59
138
|
});
|
|
60
139
|
});
|
|
61
140
|
},
|
|
62
|
-
close ()
|
|
63
|
-
|
|
141
|
+
close: ()=>{
|
|
142
|
+
this.close();
|
|
64
143
|
},
|
|
65
|
-
abort ()
|
|
66
|
-
|
|
144
|
+
abort: ()=>{
|
|
145
|
+
this.close();
|
|
67
146
|
}
|
|
68
147
|
});
|
|
69
148
|
resolve({
|
|
70
149
|
readable,
|
|
71
150
|
writable
|
|
72
151
|
});
|
|
73
|
-
ws.on('close', ()=>{
|
|
74
|
-
|
|
152
|
+
ws.on('close', (code, reason)=>{
|
|
153
|
+
const error = createWebSocketCloseError(code, reason);
|
|
154
|
+
if (error) this.#rejectClosed(error);
|
|
155
|
+
else this.#resolveClosed();
|
|
75
156
|
});
|
|
76
157
|
ws.on('error', (err)=>{
|
|
77
158
|
this.#rejectClosed(err);
|
|
@@ -82,6 +163,7 @@ class WsWebSocketStream {
|
|
|
82
163
|
});
|
|
83
164
|
}
|
|
84
165
|
close() {
|
|
166
|
+
this.#prepareReadableForClose();
|
|
85
167
|
this.#ws.close();
|
|
86
168
|
}
|
|
87
169
|
}
|
|
@@ -90,4 +172,4 @@ const wsStreams = {
|
|
|
90
172
|
return new WsWebSocketStream(url);
|
|
91
173
|
}
|
|
92
174
|
};
|
|
93
|
-
export { WsWebSocketStream, wsStreams };
|
|
175
|
+
export { WsWebSocketStream, createWebSocketReadable, wsStreams };
|
package/dist/712.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { randomInt } from "node:crypto";
|
|
2
2
|
import { TransformStream } from "node:stream/web";
|
|
3
|
-
|
|
3
|
+
function isInitializeResponse(response) {
|
|
4
|
+
return 'Register' === response.event;
|
|
5
|
+
}
|
|
6
|
+
function isHeadlessPrepareResponse(response) {
|
|
7
|
+
return 'Customized' === response.event && 'HeadlessPrepare' === response.data.type;
|
|
8
|
+
}
|
|
9
|
+
function isListSessionResponse(response) {
|
|
10
|
+
return 'Customized' === response.event && 'SessionList' === response.data.type;
|
|
11
|
+
}
|
|
12
|
+
function createCorrelatedFilter(baseFilter, requestId) {
|
|
13
|
+
return (response)=>{
|
|
14
|
+
if (!baseFilter(response)) return false;
|
|
15
|
+
if ('Customized' !== response.event) return true;
|
|
16
|
+
const responseId = response.data.id;
|
|
17
|
+
if (void 0 === responseId) return true;
|
|
18
|
+
return responseId === requestId;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isGetGlobalSwitchResponse(response) {
|
|
22
|
+
return 'Customized' === response.event && 'GetGlobalSwitch' === response.data.type;
|
|
23
|
+
}
|
|
24
|
+
function isSetGlobalSwitchResponse(response) {
|
|
25
|
+
return 'Customized' === response.event && 'SetGlobalSwitch' === response.data.type;
|
|
26
|
+
}
|
|
27
|
+
function isCustomizedResponseWithType(response, type) {
|
|
28
|
+
return 'Customized' === response.event && response.data.type === type;
|
|
29
|
+
}
|
|
4
30
|
class CustomizedClientIdTransformStream extends TransformStream {
|
|
5
31
|
constructor(clientId){
|
|
6
32
|
super({
|
|
@@ -177,4 +203,4 @@ class SessionGuardTransformStream extends TransformStream {
|
|
|
177
203
|
});
|
|
178
204
|
}
|
|
179
205
|
}
|
|
180
|
-
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream };
|
|
206
|
+
export { AppResponseTransformStream, CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, CustomizedClientIdTransformStream, CustomizedRequestTransformStream, CustomizedResponseTransformStream, FilterTransformStream, GlobalSwitchRequestTransformStream, InspectStream, ResponseParserTransformStream, SessionGuardTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isHeadlessPrepareResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse };
|