chrome-cdp-manager 1.2.6 → 1.2.8
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/README.md +3 -2
- package/bin/playwright-cli.js +5 -3
- package/package.json +3 -2
- package/src/index.js +27 -1
- package/types/index.d.ts +9 -1
package/README.md
CHANGED
|
@@ -140,8 +140,9 @@ playwright-cli click "Sign in"
|
|
|
140
140
|
playwright-cli --help
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
The Playwright CLI ships via `playwright-core` (a dependency of this package, so
|
|
144
|
+
it works out of the box — no browser download). The endpoint port follows your
|
|
145
|
+
saved config (`~/.config/chrome-cdp-manager/config.json`).
|
|
145
146
|
|
|
146
147
|
## Common options
|
|
147
148
|
|
package/bin/playwright-cli.js
CHANGED
|
@@ -59,10 +59,12 @@ async function main() {
|
|
|
59
59
|
let program;
|
|
60
60
|
try {
|
|
61
61
|
({ program } = require("playwright-core/lib/tools/cli-client/program"));
|
|
62
|
-
} catch {
|
|
62
|
+
} catch (error) {
|
|
63
63
|
throw new Error(
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"Could not load the Playwright CLI from playwright-core " +
|
|
65
|
+
"(a dependency of this package). Try reinstalling:\n" +
|
|
66
|
+
" npm install -g chrome-cdp-manager\n" +
|
|
67
|
+
`Original error: ${error.message}`,
|
|
66
68
|
);
|
|
67
69
|
}
|
|
68
70
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-cdp-manager",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Set up and drive a Chrome DevTools Protocol (CDP) instance on macOS or Windows through a dedicated launcher (consistent Dock/taskbar icon). Works with any Chromium-based browser — Chrome, Edge, Brave, Chromium, Vivaldi, Opera, Arc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"cheerio": "^1.2.0",
|
|
62
|
-
"commander": "^12.1.0"
|
|
62
|
+
"commander": "^12.1.0",
|
|
63
|
+
"playwright-core": "^1.61.0"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"playwright": ">=1.40.0"
|
package/src/index.js
CHANGED
|
@@ -10,11 +10,20 @@
|
|
|
10
10
|
import { loadConfig } from "./config.js";
|
|
11
11
|
import { getLauncher } from "./launcher.js";
|
|
12
12
|
import { ensureBrowserRunning } from "./browser.js";
|
|
13
|
+
import { parseProxy } from "./proxy.js";
|
|
13
14
|
|
|
14
15
|
export { CdpClient, openUrl, getPageHtml, closeBrowser } from "./cdp.js";
|
|
15
16
|
export { loadConfig, computeDefaults, DEFAULTS } from "./config.js";
|
|
16
17
|
export { getLauncher } from "./launcher.js";
|
|
17
18
|
export { ensureBrowserRunning, probeCdp, waitForCdp } from "./browser.js";
|
|
19
|
+
export {
|
|
20
|
+
parseProxy,
|
|
21
|
+
detectProxy,
|
|
22
|
+
DEFAULT_PROXY,
|
|
23
|
+
DEFAULT_PROXY_HOST,
|
|
24
|
+
DEFAULT_PROXY_PORT,
|
|
25
|
+
DEFAULT_PROXY_SCHEME,
|
|
26
|
+
} from "./proxy.js";
|
|
18
27
|
|
|
19
28
|
// Values the launcher bakes in at creation time; overriding them only takes
|
|
20
29
|
// effect if the launcher is (re)created to match.
|
|
@@ -27,6 +36,12 @@ const BAKED_KEYS = ["cdpPort", "profileDir", "browserPath"];
|
|
|
27
36
|
* @param {boolean} [opts.headless=false]
|
|
28
37
|
* @param {number} [opts.timeoutMs=30000] startup timeout in milliseconds.
|
|
29
38
|
* @param {boolean} [opts.force=false] rewrite the launcher even if it exists.
|
|
39
|
+
* @param {boolean|string} [opts.proxy] route browser traffic through a proxy.
|
|
40
|
+
* `true` / "default" → the default SOCKS5 proxy
|
|
41
|
+
* (socks5://127.0.0.1:1080); a port ("1080"), "host:port", or
|
|
42
|
+
* full "scheme://host:port" is normalised via {@link parseProxy};
|
|
43
|
+
* `false` forces a direct connection. Applies on a fresh launch
|
|
44
|
+
* only — an already-running compatible browser is reused as-is.
|
|
30
45
|
* @param {object} [opts.config] overrides merged over the persisted config
|
|
31
46
|
* (e.g. `{ cdpPort, profileDir, browserPath }`). If these
|
|
32
47
|
* differ from your saved `setup`, the launcher is rewritten so
|
|
@@ -34,9 +49,20 @@ const BAKED_KEYS = ["cdpPort", "profileDir", "browserPath"];
|
|
|
34
49
|
* silently ignored).
|
|
35
50
|
* @returns {Promise<{ config: object, endpoint: string, launched: boolean, version: object }>}
|
|
36
51
|
*/
|
|
37
|
-
export async function launch({
|
|
52
|
+
export async function launch({
|
|
53
|
+
headless = false,
|
|
54
|
+
timeoutMs = 30_000,
|
|
55
|
+
force = false,
|
|
56
|
+
proxy,
|
|
57
|
+
config: overrides,
|
|
58
|
+
} = {}) {
|
|
38
59
|
const persisted = loadConfig();
|
|
39
60
|
const config = { ...persisted, ...overrides };
|
|
61
|
+
// Per-launch proxy: true/string enables it (normalised to a --proxy-server
|
|
62
|
+
// value), false forces a direct connection. Never persisted.
|
|
63
|
+
if (proxy !== undefined) {
|
|
64
|
+
config.proxy = proxy === false ? null : parseProxy(proxy).server;
|
|
65
|
+
}
|
|
40
66
|
const launcher = getLauncher();
|
|
41
67
|
|
|
42
68
|
// If a caller overrode a baked value, the existing launcher would still use
|
package/types/index.d.ts
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* @param {boolean} [opts.headless=false]
|
|
6
6
|
* @param {number} [opts.timeoutMs=30000] startup timeout in milliseconds.
|
|
7
7
|
* @param {boolean} [opts.force=false] rewrite the launcher even if it exists.
|
|
8
|
+
* @param {boolean|string} [opts.proxy] route browser traffic through a proxy.
|
|
9
|
+
* `true` / "default" → the default SOCKS5 proxy
|
|
10
|
+
* (socks5://127.0.0.1:1080); a port ("1080"), "host:port", or
|
|
11
|
+
* full "scheme://host:port" is normalised via {@link parseProxy};
|
|
12
|
+
* `false` forces a direct connection. Applies on a fresh launch
|
|
13
|
+
* only — an already-running compatible browser is reused as-is.
|
|
8
14
|
* @param {object} [opts.config] overrides merged over the persisted config
|
|
9
15
|
* (e.g. `{ cdpPort, profileDir, browserPath }`). If these
|
|
10
16
|
* differ from your saved `setup`, the launcher is rewritten so
|
|
@@ -12,10 +18,11 @@
|
|
|
12
18
|
* silently ignored).
|
|
13
19
|
* @returns {Promise<{ config: object, endpoint: string, launched: boolean, version: object }>}
|
|
14
20
|
*/
|
|
15
|
-
export function launch({ headless, timeoutMs, force, config: overrides }?: {
|
|
21
|
+
export function launch({ headless, timeoutMs, force, proxy, config: overrides, }?: {
|
|
16
22
|
headless?: boolean;
|
|
17
23
|
timeoutMs?: number;
|
|
18
24
|
force?: boolean;
|
|
25
|
+
proxy?: boolean | string;
|
|
19
26
|
config?: object;
|
|
20
27
|
}): Promise<{
|
|
21
28
|
config: object;
|
|
@@ -27,3 +34,4 @@ export { getLauncher } from "./launcher.js";
|
|
|
27
34
|
export { CdpClient, openUrl, getPageHtml, closeBrowser } from "./cdp.js";
|
|
28
35
|
export { loadConfig, computeDefaults, DEFAULTS } from "./config.js";
|
|
29
36
|
export { ensureBrowserRunning, probeCdp, waitForCdp } from "./browser.js";
|
|
37
|
+
export { parseProxy, detectProxy, DEFAULT_PROXY, DEFAULT_PROXY_HOST, DEFAULT_PROXY_PORT, DEFAULT_PROXY_SCHEME } from "./proxy.js";
|