chrome-cdp-manager 1.2.7 → 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/package.json +1 -1
- package/src/index.js +27 -1
- package/types/index.d.ts +9 -1
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",
|
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";
|