extension 3.13.5 → 3.14.0-next.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/dist/{728.cjs → 631.cjs} +130 -23
- package/dist/browsers.cjs +209 -45
- package/dist/cli.cjs +324 -108
- package/dist/extension/browsers/browsers-types.d.ts +1 -1
- package/dist/extension/browsers/index.d.ts +4 -1
- package/dist/extension/browsers/run-chromium/chromium-launch/setup-cdp-after-launch.d.ts +5 -1
- package/dist/extension/browsers/run-chromium/chromium-launch/wsl-support.d.ts +2 -2
- package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-client.d.ts +7 -0
- package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/connect.d.ts +3 -1
- package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/index.d.ts +5 -0
- package/dist/extension/browsers/run-chromium/chromium-source-inspection/discovery.d.ts +1 -1
- package/dist/extension/browsers/run-firefox/firefox-launch/binary-detector.d.ts +3 -0
- package/dist/extension/browsers/run-firefox/firefox-source-inspection/remote-firefox/transport.d.ts +1 -1
- package/dist/extension/helpers/messages.d.ts +8 -1
- package/package.json +4 -4
package/dist/{728.cjs → 631.cjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.ids = [
|
|
3
|
-
"
|
|
3
|
+
"631"
|
|
4
4
|
];
|
|
5
5
|
exports.modules = {
|
|
6
6
|
"./browsers/run-chromium/chromium-launch/setup-cdp-after-launch.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -674,6 +674,7 @@ exports.modules = {
|
|
|
674
674
|
});
|
|
675
675
|
this.ws = null;
|
|
676
676
|
});
|
|
677
|
+
this.transport = 'websocket';
|
|
677
678
|
this.startHeartbeat();
|
|
678
679
|
if (this.isDev()) console.log(messages.M3V(this.host, this.port));
|
|
679
680
|
resolve();
|
|
@@ -683,8 +684,54 @@ exports.modules = {
|
|
|
683
684
|
}
|
|
684
685
|
});
|
|
685
686
|
}
|
|
687
|
+
async connectViaPipe(input, output) {
|
|
688
|
+
this.transport = 'pipe';
|
|
689
|
+
this.pipeIn = input;
|
|
690
|
+
this.pipeOut = output;
|
|
691
|
+
this.pipeBuffer = Buffer.alloc(0);
|
|
692
|
+
input.on('data', (chunk)=>{
|
|
693
|
+
this.pipeBuffer = Buffer.concat([
|
|
694
|
+
this.pipeBuffer,
|
|
695
|
+
chunk
|
|
696
|
+
]);
|
|
697
|
+
let idx;
|
|
698
|
+
while(-1 !== (idx = this.pipeBuffer.indexOf(0))){
|
|
699
|
+
const msg = this.pipeBuffer.subarray(0, idx).toString('utf-8');
|
|
700
|
+
this.pipeBuffer = this.pipeBuffer.subarray(idx + 1);
|
|
701
|
+
this.handleMessage(msg);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
input.on('error', (error)=>{
|
|
705
|
+
if (this.isDev()) console.error(`[CDP] Pipe read error: ${error.message}`);
|
|
706
|
+
this.rejectAllPending('CDP pipe read error');
|
|
707
|
+
});
|
|
708
|
+
input.on('close', ()=>{
|
|
709
|
+
if (this.isDev()) console.log('[CDP] Pipe closed');
|
|
710
|
+
this.rejectAllPending('CDP pipe closed');
|
|
711
|
+
this.pipeIn = null;
|
|
712
|
+
});
|
|
713
|
+
this.startHeartbeat();
|
|
714
|
+
if (this.isDev()) console.log(messages.M3V(this.host, this.port));
|
|
715
|
+
}
|
|
716
|
+
rejectAllPending(reason) {
|
|
717
|
+
this.pendingRequests.forEach(({ reject, timeout }, id)=>{
|
|
718
|
+
try {
|
|
719
|
+
reject(new Error(reason));
|
|
720
|
+
} catch {}
|
|
721
|
+
if (timeout) clearTimeout(timeout);
|
|
722
|
+
this.pendingRequests.delete(id);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
686
725
|
disconnect() {
|
|
687
726
|
this.stopHeartbeat();
|
|
727
|
+
if ('pipe' === this.transport) {
|
|
728
|
+
try {
|
|
729
|
+
this.pipeIn?.removeAllListeners();
|
|
730
|
+
this.pipeOut?.end();
|
|
731
|
+
} catch {}
|
|
732
|
+
this.pipeIn = null;
|
|
733
|
+
this.pipeOut = null;
|
|
734
|
+
}
|
|
688
735
|
if (this.ws) {
|
|
689
736
|
try {
|
|
690
737
|
this.ws.close();
|
|
@@ -712,6 +759,7 @@ exports.modules = {
|
|
|
712
759
|
}
|
|
713
760
|
}
|
|
714
761
|
isConnected() {
|
|
762
|
+
if ('pipe' === this.transport) return !!this.pipeIn && !this.pipeIn.destroyed && !!this.pipeOut && !this.pipeOut.destroyed;
|
|
715
763
|
return !!this.ws && this.ws.readyState === external_ws_default().OPEN;
|
|
716
764
|
}
|
|
717
765
|
onProtocolEvent(handler) {
|
|
@@ -747,7 +795,7 @@ exports.modules = {
|
|
|
747
795
|
}
|
|
748
796
|
async sendCommand(method, params = {}, sessionId, timeoutMs = constants.Ns) {
|
|
749
797
|
return new Promise((resolve, reject)=>{
|
|
750
|
-
if (!this.
|
|
798
|
+
if (!this.isConnected()) return reject(new Error('CDP transport is not open'));
|
|
751
799
|
const id = ++this.messageId;
|
|
752
800
|
const message = {
|
|
753
801
|
id,
|
|
@@ -768,7 +816,9 @@ exports.modules = {
|
|
|
768
816
|
timeout,
|
|
769
817
|
method
|
|
770
818
|
});
|
|
771
|
-
|
|
819
|
+
const data = JSON.stringify(message);
|
|
820
|
+
if ('pipe' === this.transport && this.pipeOut) this.pipeOut.write(data + '\0');
|
|
821
|
+
else if (this.ws) this.ws.send(data);
|
|
772
822
|
} catch (error) {
|
|
773
823
|
const pending = this.pendingRequests.get(id);
|
|
774
824
|
if (pending?.timeout) clearTimeout(pending.timeout);
|
|
@@ -937,7 +987,11 @@ exports.modules = {
|
|
|
937
987
|
constructor(port = 9222, host = '127.0.0.1'){
|
|
938
988
|
_define_property(this, "port", void 0);
|
|
939
989
|
_define_property(this, "host", void 0);
|
|
990
|
+
_define_property(this, "transport", 'websocket');
|
|
940
991
|
_define_property(this, "ws", null);
|
|
992
|
+
_define_property(this, "pipeIn", null);
|
|
993
|
+
_define_property(this, "pipeOut", null);
|
|
994
|
+
_define_property(this, "pipeBuffer", Buffer.alloc(0));
|
|
941
995
|
_define_property(this, "targetWebSocketUrl", null);
|
|
942
996
|
_define_property(this, "eventCallbacks", new Set());
|
|
943
997
|
_define_property(this, "messageId", 0);
|
|
@@ -949,14 +1003,32 @@ exports.modules = {
|
|
|
949
1003
|
}
|
|
950
1004
|
function isRecoverableBootstrapError(error) {
|
|
951
1005
|
const msg = String(error?.message || error || '').toLowerCase();
|
|
952
|
-
return msg.includes('econnreset') || msg.includes('websocket is not open') || msg.includes('cdp connection closed') || msg.includes('socket hang up') || msg.includes('timed out') || msg.includes('no cdp websocket url');
|
|
1006
|
+
return msg.includes('econnreset') || msg.includes('websocket is not open') || msg.includes('cdp transport is not open') || msg.includes('cdp connection closed') || msg.includes('cdp pipe closed') || msg.includes('socket hang up') || msg.includes('timed out') || msg.includes('no cdp websocket url');
|
|
1007
|
+
}
|
|
1008
|
+
async function connectToChromeCdpViaPipe(pipeIn, pipeOut, cdpPort = 0, cdpHost = '127.0.0.1') {
|
|
1009
|
+
const cdp = new CDPClient(cdpPort, cdpHost);
|
|
1010
|
+
try {
|
|
1011
|
+
await cdp.connectViaPipe(pipeIn, pipeOut);
|
|
1012
|
+
await cdp.sendCommand('Target.setDiscoverTargets', {
|
|
1013
|
+
discover: true
|
|
1014
|
+
});
|
|
1015
|
+
await cdp.sendCommand('Target.setAutoAttach', {
|
|
1016
|
+
autoAttach: true,
|
|
1017
|
+
waitForDebuggerOnStart: false,
|
|
1018
|
+
flatten: true
|
|
1019
|
+
});
|
|
1020
|
+
return cdp;
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
cdp.disconnect();
|
|
1023
|
+
throw error;
|
|
1024
|
+
}
|
|
953
1025
|
}
|
|
954
|
-
async function connectToChromeCdp(cdpPort) {
|
|
1026
|
+
async function connectToChromeCdp(cdpPort, cdpHost = '127.0.0.1') {
|
|
955
1027
|
let retries = 0;
|
|
956
1028
|
const maxRetries = 60;
|
|
957
1029
|
const backoffMs = 250;
|
|
958
1030
|
while(retries < maxRetries){
|
|
959
|
-
const ready = await (0, discovery.z)(cdpPort);
|
|
1031
|
+
const ready = await (0, discovery.z)(cdpPort, cdpHost);
|
|
960
1032
|
if (ready) break;
|
|
961
1033
|
retries++;
|
|
962
1034
|
await new Promise((r)=>setTimeout(r, backoffMs));
|
|
@@ -964,7 +1036,7 @@ exports.modules = {
|
|
|
964
1036
|
const maxBootstrapAttempts = 4;
|
|
965
1037
|
let lastError = null;
|
|
966
1038
|
for(let attempt = 1; attempt <= maxBootstrapAttempts; attempt++){
|
|
967
|
-
const cdp = new CDPClient(cdpPort,
|
|
1039
|
+
const cdp = new CDPClient(cdpPort, cdpHost);
|
|
968
1040
|
try {
|
|
969
1041
|
await cdp.connect();
|
|
970
1042
|
await cdp.sendCommand('Target.setDiscoverTargets', {
|
|
@@ -992,18 +1064,7 @@ exports.modules = {
|
|
|
992
1064
|
}
|
|
993
1065
|
throw lastError instanceof Error ? lastError : new Error('Failed to bootstrap CDP connection');
|
|
994
1066
|
}
|
|
995
|
-
|
|
996
|
-
try {
|
|
997
|
-
const manifestPath = external_path_.join(outPath, 'manifest.json');
|
|
998
|
-
const manifest = JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8'));
|
|
999
|
-
return {
|
|
1000
|
-
name: manifest?.name,
|
|
1001
|
-
version: manifest?.version
|
|
1002
|
-
};
|
|
1003
|
-
} catch {
|
|
1004
|
-
return null;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1067
|
+
var ensure = __webpack_require__("./browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/ensure.ts");
|
|
1007
1068
|
function registerAutoEnableLogging(cdp, getExtensionId) {
|
|
1008
1069
|
cdp.onProtocolEvent((message)=>{
|
|
1009
1070
|
try {
|
|
@@ -1050,6 +1111,11 @@ exports.modules = {
|
|
|
1050
1111
|
if (!this.cdp) throw new Error('CDP not connected');
|
|
1051
1112
|
const exists = external_fs_.existsSync(this.outPath);
|
|
1052
1113
|
if (!exists) throw new Error(`Output path not found: ${this.outPath}`);
|
|
1114
|
+
if (!this.extensionId) try {
|
|
1115
|
+
const { loadUnpackedIfNeeded } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/ensure.ts"));
|
|
1116
|
+
const cdpId = await loadUnpackedIfNeeded(this.cdp, this.outPath);
|
|
1117
|
+
if (cdpId) this.extensionId = cdpId;
|
|
1118
|
+
} catch {}
|
|
1053
1119
|
if (!this.extensionId) {
|
|
1054
1120
|
const id = await this.deriveExtensionIdFromTargets();
|
|
1055
1121
|
if (id) this.extensionId = id;
|
|
@@ -1089,7 +1155,7 @@ exports.modules = {
|
|
|
1089
1155
|
version = info?.extensionInfo?.version;
|
|
1090
1156
|
} catch (error) {
|
|
1091
1157
|
try {
|
|
1092
|
-
const manifest =
|
|
1158
|
+
const manifest = (0, ensure.M)(this.outPath);
|
|
1093
1159
|
name = String(manifest?.name || '') || void 0;
|
|
1094
1160
|
version = String(manifest?.version || '') || void 0;
|
|
1095
1161
|
} catch (e2) {
|
|
@@ -1407,7 +1473,8 @@ exports.modules = {
|
|
|
1407
1473
|
}
|
|
1408
1474
|
}
|
|
1409
1475
|
async connectFreshClient() {
|
|
1410
|
-
this.cdp = await
|
|
1476
|
+
if (this.pipeIn && this.pipeOut && !this.pipeIn.destroyed) this.cdp = await connectToChromeCdpViaPipe(this.pipeIn, this.pipeOut, this.cdpPort);
|
|
1477
|
+
else this.cdp = await connectToChromeCdp(this.cdpPort);
|
|
1411
1478
|
try {
|
|
1412
1479
|
await this.cdp.sendCommand('Target.setDiscoverTargets', {
|
|
1413
1480
|
discover: true
|
|
@@ -1763,6 +1830,8 @@ exports.modules = {
|
|
|
1763
1830
|
cdp_extension_controller_define_property(this, "cdpPort", void 0);
|
|
1764
1831
|
cdp_extension_controller_define_property(this, "profilePath", void 0);
|
|
1765
1832
|
cdp_extension_controller_define_property(this, "extensionPaths", void 0);
|
|
1833
|
+
cdp_extension_controller_define_property(this, "pipeIn", void 0);
|
|
1834
|
+
cdp_extension_controller_define_property(this, "pipeOut", void 0);
|
|
1766
1835
|
cdp_extension_controller_define_property(this, "cdp", null);
|
|
1767
1836
|
cdp_extension_controller_define_property(this, "extensionId", null);
|
|
1768
1837
|
cdp_extension_controller_define_property(this, "lastRuntimeReinjectionReport", null);
|
|
@@ -1771,10 +1840,12 @@ exports.modules = {
|
|
|
1771
1840
|
this.cdpPort = args.cdpPort;
|
|
1772
1841
|
this.profilePath = args.profilePath;
|
|
1773
1842
|
this.extensionPaths = args.extensionPaths;
|
|
1843
|
+
this.pipeIn = args.pipeIn;
|
|
1844
|
+
this.pipeOut = args.pipeOut;
|
|
1774
1845
|
}
|
|
1775
1846
|
}
|
|
1776
1847
|
var extension_output_path = __webpack_require__("./browsers/run-chromium/chromium-launch/extension-output-path.ts");
|
|
1777
|
-
async function setupCdpAfterLaunch(compilation, plugin, chromiumArgs) {
|
|
1848
|
+
async function setupCdpAfterLaunch(compilation, plugin, chromiumArgs, pipeStreams) {
|
|
1778
1849
|
const loadExtensionFlag = chromiumArgs.find((flag)=>flag.startsWith('--load-extension='));
|
|
1779
1850
|
const extensionOutputPath = (0, extension_output_path.W)(compilation, loadExtensionFlag);
|
|
1780
1851
|
const extensionPaths = loadExtensionFlag ? loadExtensionFlag.replace('--load-extension=', '').split(',').map((s)=>s.trim()).filter(Boolean) : [];
|
|
@@ -1794,7 +1865,9 @@ exports.modules = {
|
|
|
1794
1865
|
browser: 'chromium-based' === plugin.browser ? 'chrome' : plugin.browser,
|
|
1795
1866
|
cdpPort: chromeRemoteDebugPort,
|
|
1796
1867
|
profilePath: userDataDir || void 0,
|
|
1797
|
-
extensionPaths: selectedExtensionPaths
|
|
1868
|
+
extensionPaths: selectedExtensionPaths,
|
|
1869
|
+
pipeIn: pipeStreams?.input,
|
|
1870
|
+
pipeOut: pipeStreams?.output
|
|
1798
1871
|
});
|
|
1799
1872
|
await cdpExtensionController.connect();
|
|
1800
1873
|
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.M3V('127.0.0.1', chromeRemoteDebugPort));
|
|
@@ -1886,5 +1959,39 @@ exports.modules = {
|
|
|
1886
1959
|
}
|
|
1887
1960
|
plugin.cdpController = cdpExtensionController;
|
|
1888
1961
|
}
|
|
1962
|
+
},
|
|
1963
|
+
"./browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/ensure.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1964
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1965
|
+
M: ()=>readManifestInfo,
|
|
1966
|
+
loadUnpackedIfNeeded: ()=>loadUnpackedIfNeeded
|
|
1967
|
+
});
|
|
1968
|
+
var fs__rspack_import_0 = __webpack_require__("fs");
|
|
1969
|
+
var path__rspack_import_1 = __webpack_require__("path");
|
|
1970
|
+
async function loadUnpackedIfNeeded(cdp, outPath) {
|
|
1971
|
+
try {
|
|
1972
|
+
const response = await cdp.sendCommand('Extensions.loadUnpacked', {
|
|
1973
|
+
extensionPath: outPath,
|
|
1974
|
+
options: {
|
|
1975
|
+
failOnError: false
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
const id = String(response?.extensionId || '');
|
|
1979
|
+
return id || null;
|
|
1980
|
+
} catch {
|
|
1981
|
+
return null;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
function readManifestInfo(outPath) {
|
|
1985
|
+
try {
|
|
1986
|
+
const manifestPath = path__rspack_import_1.join(outPath, 'manifest.json');
|
|
1987
|
+
const manifest = JSON.parse(fs__rspack_import_0.readFileSync(manifestPath, 'utf-8'));
|
|
1988
|
+
return {
|
|
1989
|
+
name: manifest?.name,
|
|
1990
|
+
version: manifest?.version
|
|
1991
|
+
};
|
|
1992
|
+
} catch {
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1889
1996
|
}
|
|
1890
1997
|
};
|