@mefistofelix/cdp.js 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +35 -4
  2. package/cdp.js +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -199,6 +199,7 @@ local configuration.
199
199
  | `user_data_dir` | absolute path string, `<base_path>/<name>` | Chromium user-data directory containing profiles such as `Default`. The generated default is absolute; explicit overrides should be absolute too. |
200
200
  | `executable_path` | string, automatic discovery | Executable to spawn; takes precedence over `CDP_BROWSER`. |
201
201
  | `headless` | boolean, `false` | When true, add `headless: 'new'` and default `window-size: '1440,900'`. |
202
+ | `windowsHide` | boolean, effective headless mode | Hide the spawned process's console on Windows. Defaults to true when the final arguments include `--headless`, false otherwise; an explicit value wins. Does not hide the parent terminal. |
202
203
  | `extensions` | boolean, `false` | When true, omit the two extension-disabling switches; does not install extensions. |
203
204
  | `images` | boolean, `true` | When false, request `blink-settings: 'imagesEnabled=false'`; controls loading, not image processing. |
204
205
  | `translations` | boolean, `false` | Set translation preferences and, unless true, disable translation feature IDs. |
@@ -207,6 +208,7 @@ local configuration.
207
208
  | `preferences` | object, `{}` | Dotted JSON preference overrides applied after generated preference defaults. |
208
209
  | `connect_timeout_ms` | number, `15000` | Timeout for each discovery, launch-readiness or socket-opening wait; not one combined deadline. |
209
210
  | `request_timeout_ms` | number, `30000` | Default timeout for each protocol request on this browser's socket. |
211
+ | `waitForDebuggerOnStart` | boolean, `false` | Ask Chromium to pause newly auto-attached targets. Applied to `Target.setAutoAttach` when connecting; not a CLI argument or target option. |
210
212
  | `websocket_url` | string, unset | Attach directly to a browser WebSocket endpoint. |
211
213
  | `http_url` | string, unset | Discover the endpoint from an HTTP(S) base URL or exact `/json/version` URL. |
212
214
  | `port` | number, unset | Discover an existing browser at `http://<host>:<port>/json/version`. |
@@ -458,6 +460,8 @@ writes with a running browser, which may overwrite the file itself.
458
460
  | --- | --- |
459
461
  | `headless: true` plus `args.headless: false` | Omit `--headless`; the generated window-size argument remains unless also overridden. |
460
462
  | `headless: false` plus `args.headless: 'new'` | Send `--headless=new`; no automatic headless window-size default was generated. |
463
+ | `windowsHide` omitted plus a raw `args.headless` override | Follow the effective `--headless` switch after the override. |
464
+ | Explicit `windowsHide: true` or `false` | Pass that value to Node's `spawn`, regardless of headless mode. |
461
465
  | `extensions: true` plus `args['disable-extensions']: true` | The raw extension-disabling switch still wins. |
462
466
  | `extensions: false` plus only `args['disable-extensions']: false` | Remove that flag, but retain `disable-component-extensions-with-background-pages`. Use `extensions: true` to omit both generated flags. |
463
467
  | `images: false` plus an overridden `blink-settings` | Replace the whole string; image disabling is not appended to the caller's value. |
@@ -534,8 +538,35 @@ Domain options set to false skip setup commands; they do not actively disable a
534
538
  domain already enabled by another caller. Likewise, `binding: false` does not
535
539
  remove a previously installed binding. Use native CDP commands for immediate
536
540
  changes. `initialize: false` skips binding installation too;
537
- `Runtime.runIfWaitingForDebugger` is still sent at the end. Auto-attachment uses
538
- `waitForDebuggerOnStart: false`.
541
+ `Runtime.runIfWaitingForDebugger` is still sent at the end. The browser option
542
+ `waitForDebuggerOnStart` defaults to `false`. With `true`, auto-attachment requests
543
+ a pause. Bootstrap setup sends `Runtime.disable` before the resume command.
544
+ To ensure setup completes before navigating, keep the initial `about:blank` and
545
+ use `Page.navigate` afterward, as below. The pause flag alone does not guarantee
546
+ that a URL supplied through `create_params.url` waits for setup; Chromium can
547
+ execute that navigation's scripts during initialization.
548
+
549
+ Set this option in constructor browser defaults or in `params.browser`:
550
+
551
+ ```js
552
+ await client.call({
553
+ method: 'Page.navigate',
554
+ params: {
555
+ browser: {
556
+ name: 'paused',
557
+ waitForDebuggerOnStart: true,
558
+ },
559
+ target: 'page',
560
+ url: 'https://example.com/',
561
+ },
562
+ })
563
+ ```
564
+
565
+ The setting affects auto-attachment across that browser connection. Only targets
566
+ selected through `params.target` receive setup and automatic resume. Other newly
567
+ auto-attached tabs can remain paused: select their physical ID using
568
+ `params.target.targetId`, or send `Runtime.runIfWaitingForDebugger` through the
569
+ browser socket with their `sessionId`.
539
570
 
540
571
  Setup CDP errors are collected as strings in `target.setup_errors`, allowing the
541
572
  sequence to continue when a browser/target does not support a setup command.
@@ -822,8 +853,8 @@ workflow for detecting new conversations and extracting connector session handle
822
853
  from tool-call history. It is a caller-side recipe, not additional library API.
823
854
 
824
855
  For npm packaging, account setup, and GitHub publishing, see
825
- [Publishing](npm/PUBLISHING.md). `build.bat` prepares the package on Windows;
826
- `node npm/prepare.mjs` prepares its files on any supported Node platform.
856
+ [Publishing](npm/PUBLISHING.md). Publishing only copies `cdp.js` and this README
857
+ into `npm/` alongside its manifest; no build script is needed.
827
858
 
828
859
  ```sh
829
860
  node --check cdp.js
package/cdp.js CHANGED
@@ -209,7 +209,7 @@ export class browser {
209
209
  ...options.preferences,
210
210
  })
211
211
  const proc = child_process.spawn(options.executable_path || browser.find_executable_path(), [...util.args_to_strings(args), 'about:blank'], {
212
- windowsHide: true,
212
+ windowsHide: options.windowsHide ?? (args.headless != null && args.headless !== false),
213
213
  stdio: ['ignore', 'ignore', 'pipe'],
214
214
  })
215
215
  let diagnostic = ''
@@ -386,7 +386,7 @@ export class cdp extends EventTarget {
386
386
  params: {
387
387
  autoAttach: true,
388
388
  flatten: true,
389
- waitForDebuggerOnStart: false,
389
+ waitForDebuggerOnStart: record.waitForDebuggerOnStart ?? false,
390
390
  },
391
391
  })
392
392
  await socket.req({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mefistofelix/cdp.js",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Low-level Chromium DevTools Protocol client for Node.js, with no runtime dependencies.",
5
5
  "type": "module",
6
6
  "exports": "./cdp.js",