cdp-tunnel 2.7.9 → 2.8.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/extension-new/background.js +234 -130
- package/extension-new/cdp/handler/forward.js +9 -7
- package/extension-new/cdp/handler/local.js +60 -39
- package/extension-new/cdp/handler/special.js +145 -119
- package/extension-new/cdp/index.js +16 -7
- package/extension-new/cdp/response.js +12 -4
- package/extension-new/config-page-preview.html +174 -57
- package/extension-new/config-page.js +169 -70
- package/extension-new/core/connection-manager.js +120 -0
- package/extension-new/core/connection-state.js +355 -0
- package/extension-new/core/debugger.js +65 -52
- package/extension-new/core/state.js +87 -438
- package/extension-new/core/websocket.js +345 -279
- package/extension-new/features/screencast.js +42 -20
- package/extension-new/manifest.json +3 -2
- package/extension-new/utils/config.js +83 -2
- package/extension-new/utils/helpers.js +5 -4
- package/package.json +1 -1
|
@@ -71,8 +71,19 @@ var Screencast = (function() {
|
|
|
71
71
|
};
|
|
72
72
|
})();
|
|
73
73
|
|
|
74
|
-
function
|
|
75
|
-
|
|
74
|
+
function _getStateForTab(tabId) {
|
|
75
|
+
var entry = ConnectionManager.getConnectionByTabId(tabId);
|
|
76
|
+
return entry ? entry.state : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _getWSManagerForTab(tabId) {
|
|
80
|
+
var entry = ConnectionManager.getConnectionByTabId(tabId);
|
|
81
|
+
return entry ? entry.wsManager : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function startPolling(tabId, params, sessionId, state) {
|
|
85
|
+
var connState = state || _getStateForTab(tabId);
|
|
86
|
+
stopPolling(tabId, connState);
|
|
76
87
|
|
|
77
88
|
var session = {
|
|
78
89
|
tabId: tabId,
|
|
@@ -89,27 +100,33 @@ var Screencast = (function() {
|
|
|
89
100
|
frameId: 0
|
|
90
101
|
};
|
|
91
102
|
|
|
92
|
-
|
|
103
|
+
if (connState) connState.setScreencastSession(tabId, session);
|
|
93
104
|
|
|
94
105
|
return injectChangeDetector(tabId).then(function() {
|
|
95
|
-
captureAndSendFrame(session);
|
|
106
|
+
captureAndSendFrame(session, connState);
|
|
96
107
|
});
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
function stopPolling(tabId) {
|
|
100
|
-
var
|
|
101
|
-
if (
|
|
102
|
-
session
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
function stopPolling(tabId, state) {
|
|
111
|
+
var connState = state || _getStateForTab(tabId);
|
|
112
|
+
if (connState) {
|
|
113
|
+
var session = connState.getScreencastSession(tabId);
|
|
114
|
+
if (session) {
|
|
115
|
+
session.stopped = true;
|
|
116
|
+
connState.deleteScreencastSession(tabId);
|
|
117
|
+
disableChangeNotify(tabId);
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
|
|
108
|
-
function ackFrame(tabId, ackSessionId) {
|
|
109
|
-
var
|
|
110
|
-
if (
|
|
111
|
-
session
|
|
112
|
-
|
|
122
|
+
function ackFrame(tabId, ackSessionId, state) {
|
|
123
|
+
var connState = state || _getStateForTab(tabId);
|
|
124
|
+
if (connState) {
|
|
125
|
+
var session = connState.getScreencastSession(tabId);
|
|
126
|
+
if (session) {
|
|
127
|
+
session.pendingAck = false;
|
|
128
|
+
captureAndSendFrame(session, connState);
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
|
|
@@ -154,12 +171,14 @@ var Screencast = (function() {
|
|
|
154
171
|
).catch(function() {});
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
function captureAndSendFrame(session) {
|
|
174
|
+
function captureAndSendFrame(session, connState) {
|
|
158
175
|
if (session.stopped) return;
|
|
159
176
|
|
|
160
177
|
session.frameCount++;
|
|
161
178
|
if (session.frameCount % session.everyNthFrame !== 0) return;
|
|
162
179
|
|
|
180
|
+
var wsManager = _getWSManagerForTab(session.tabId);
|
|
181
|
+
|
|
163
182
|
chrome.debugger.sendCommand(
|
|
164
183
|
{ tabId: session.tabId },
|
|
165
184
|
'Page.captureScreenshot',
|
|
@@ -195,7 +214,7 @@ var Screencast = (function() {
|
|
|
195
214
|
scrollOffsetY: 0,
|
|
196
215
|
timestamp: Date.now()
|
|
197
216
|
}
|
|
198
|
-
}, session.sessionId);
|
|
217
|
+
}, session.sessionId, wsManager);
|
|
199
218
|
|
|
200
219
|
session.pendingAck = true;
|
|
201
220
|
}).catch(function(error) {
|
|
@@ -206,9 +225,12 @@ var Screencast = (function() {
|
|
|
206
225
|
}
|
|
207
226
|
|
|
208
227
|
function onNotify(tabId) {
|
|
209
|
-
var
|
|
210
|
-
if (
|
|
211
|
-
|
|
228
|
+
var connState = _getStateForTab(tabId);
|
|
229
|
+
if (connState) {
|
|
230
|
+
var session = connState.getScreencastSession(tabId);
|
|
231
|
+
if (session && !session.pendingAck && !session.stopped) {
|
|
232
|
+
captureAndSendFrame(session, connState);
|
|
233
|
+
}
|
|
212
234
|
}
|
|
213
235
|
}
|
|
214
236
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "CDP Bridge",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.8.0",
|
|
5
5
|
"description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"debugger",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
{
|
|
38
38
|
"resources": [
|
|
39
39
|
"config-page-preview.html",
|
|
40
|
-
"config-page.js"
|
|
40
|
+
"config-page.js",
|
|
41
|
+
"utils/config.js"
|
|
41
42
|
],
|
|
42
43
|
"matches": [
|
|
43
44
|
"<all_urls>"
|
|
@@ -12,11 +12,91 @@ var Config = {
|
|
|
12
12
|
},
|
|
13
13
|
DEFAULT_BROWSER_CONTEXT: 'default',
|
|
14
14
|
DEBUG: true,
|
|
15
|
+
|
|
15
16
|
getWsUrl: function(callback) {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
Config.getConnections(function(connections) {
|
|
18
|
+
var enabled = (connections || []).filter(function(c) { return c.enabled; });
|
|
19
|
+
if (enabled.length > 0) {
|
|
20
|
+
callback(enabled[0].url);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
callback(Config.WS_URL);
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
getConnections: function(callback) {
|
|
28
|
+
chrome.storage.local.get(['connections', 'wsAddress'], function(result) {
|
|
29
|
+
if (result.connections) {
|
|
30
|
+
callback(result.connections);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (result.wsAddress) {
|
|
34
|
+
var migrated = [
|
|
35
|
+
{
|
|
36
|
+
id: 'conn_' + Date.now(),
|
|
37
|
+
tag: 'default',
|
|
38
|
+
url: result.wsAddress,
|
|
39
|
+
enabled: true
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
chrome.storage.local.set({ connections: migrated }, function() {
|
|
43
|
+
callback(migrated);
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
callback([]);
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
setConnections: function(connections, callback) {
|
|
52
|
+
chrome.storage.local.set({ connections: connections }, callback || function() {});
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
addConnection: function(opts, callback) {
|
|
56
|
+
Config.getConnections(function(connections) {
|
|
57
|
+
var conn = {
|
|
58
|
+
id: 'conn_' + Date.now() + '_' + Math.random().toString(36).substr(2, 6),
|
|
59
|
+
tag: opts.tag || 'unnamed',
|
|
60
|
+
url: opts.url || '',
|
|
61
|
+
enabled: opts.enabled !== undefined ? opts.enabled : true
|
|
62
|
+
};
|
|
63
|
+
connections.push(conn);
|
|
64
|
+
Config.setConnections(connections, function() {
|
|
65
|
+
if (callback) callback(conn);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
removeConnection: function(id, callback) {
|
|
71
|
+
Config.getConnections(function(connections) {
|
|
72
|
+
var filtered = connections.filter(function(c) { return c.id !== id; });
|
|
73
|
+
Config.setConnections(filtered, callback);
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
toggleConnection: function(id, enabled, callback) {
|
|
78
|
+
Config.getConnections(function(connections) {
|
|
79
|
+
connections.forEach(function(c) {
|
|
80
|
+
if (c.id === id) {
|
|
81
|
+
c.enabled = enabled;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Config.setConnections(connections, callback);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
updateConnection: function(id, updates, callback) {
|
|
89
|
+
Config.getConnections(function(connections) {
|
|
90
|
+
connections.forEach(function(c) {
|
|
91
|
+
if (c.id === id) {
|
|
92
|
+
if (updates.tag !== undefined) c.tag = updates.tag;
|
|
93
|
+
if (updates.url !== undefined) c.url = updates.url;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Config.setConnections(connections, callback);
|
|
18
97
|
});
|
|
19
98
|
},
|
|
99
|
+
|
|
20
100
|
getPluginId: function(callback) {
|
|
21
101
|
chrome.storage.local.get(['pluginId'], function(result) {
|
|
22
102
|
if (result.pluginId) {
|
|
@@ -29,6 +109,7 @@ var Config = {
|
|
|
29
109
|
}
|
|
30
110
|
});
|
|
31
111
|
},
|
|
112
|
+
|
|
32
113
|
AUTO_MUTE: true,
|
|
33
114
|
getAutoMute: function(callback) {
|
|
34
115
|
chrome.storage.local.get(['autoMute'], function(result) {
|
|
@@ -42,7 +42,7 @@ var CDPUtils = (function() {
|
|
|
42
42
|
return 0;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function buildGroupName(clientId) {
|
|
45
|
+
function buildGroupName(clientId, connectionTag) {
|
|
46
46
|
if (!clientId) return 'CDP';
|
|
47
47
|
var hash = 0;
|
|
48
48
|
for (var i = 0; i < clientId.length; i++) {
|
|
@@ -51,11 +51,12 @@ var CDPUtils = (function() {
|
|
|
51
51
|
hash = hash | 0;
|
|
52
52
|
}
|
|
53
53
|
var suffix = Math.abs(hash).toString(16).substring(0, 8).padStart(8, '0');
|
|
54
|
-
|
|
54
|
+
var tag = (connectionTag && connectionTag !== 'default') ? connectionTag + '-' : '';
|
|
55
|
+
return 'CDP-' + tag + suffix;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
function getGroupBaseName(clientId) {
|
|
58
|
-
return buildGroupName(clientId);
|
|
58
|
+
function getGroupBaseName(clientId, connectionTag) {
|
|
59
|
+
return buildGroupName(clientId, connectionTag);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
function findGroupByName(allGroups, baseName) {
|
package/package.json
CHANGED