browser-commander 0.13.0 → 0.14.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/CHANGELOG.md +6 -0
- package/README.md +6 -4
- package/package.json +1 -1
- package/src/browser/real-browser.js +9 -0
- package/src/exports.js +4 -1
- package/tests/unit/browser/real-browser.test.js +7 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -118,16 +118,16 @@ const { browser, page } = await connectBrowser({
|
|
|
118
118
|
const commander = makeBrowserCommander({ page });
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
`
|
|
121
|
+
`launchRealBrowser()` can find and start a genuine installed Chrome,
|
|
122
122
|
Edge, Brave, or Chromium with a loopback CDP endpoint and then attach to it. It
|
|
123
123
|
always uses a dedicated profile; Chrome 136 and newer do not honor remote
|
|
124
124
|
debugging switches for the default profile. See the
|
|
125
125
|
[Chrome remote-debugging security change](https://developer.chrome.com/blog/remote-debugging-port).
|
|
126
126
|
|
|
127
127
|
```javascript
|
|
128
|
-
import {
|
|
128
|
+
import { launchRealBrowser } from 'browser-commander';
|
|
129
129
|
|
|
130
|
-
const connection = await
|
|
130
|
+
const connection = await launchRealBrowser({
|
|
131
131
|
engine: 'puppeteer',
|
|
132
132
|
channel: 'chrome',
|
|
133
133
|
userDataDir: '/tmp/my-automation-profile',
|
|
@@ -140,6 +140,7 @@ await connection.browser.close();
|
|
|
140
140
|
|
|
141
141
|
Cookie seeding copies only cookies you explicitly provide; the helper does not
|
|
142
142
|
read, decrypt, or expose cookies from a browser's default profile.
|
|
143
|
+
`launchAndConnectRealBrowser()` remains available as a descriptive alias.
|
|
143
144
|
|
|
144
145
|
Reuse a saved authenticated session by passing Playwright-compatible storage
|
|
145
146
|
state as a JSON file path or object. Cookies and localStorage are restored for
|
|
@@ -359,7 +360,7 @@ const { browser, page } = await connectBrowser({
|
|
|
359
360
|
Playwright accepts `timeout` and Puppeteer accepts `protocolTimeout`.
|
|
360
361
|
`storageState` can also seed Playwright-compatible cookies and localStorage.
|
|
361
362
|
|
|
362
|
-
###
|
|
363
|
+
### launchRealBrowser(options)
|
|
363
364
|
|
|
364
365
|
Start an installed browser and connect through `connectBrowser()`. Use
|
|
365
366
|
`channel` (`chrome`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge`,
|
|
@@ -369,6 +370,7 @@ a managed directory under `~/.browser-commander/real-browser/`, rejects known
|
|
|
369
370
|
default browser-profile paths, protects its remote-debugging arguments, and
|
|
370
371
|
returns the spawned `browserProcess`, resolved `cdpEndpoint`, executable path,
|
|
371
372
|
and profile path alongside `{ browser, page }`.
|
|
373
|
+
`launchAndConnectRealBrowser()` is an alias with identical behavior.
|
|
372
374
|
|
|
373
375
|
### saveStorageState(page, filePath)
|
|
374
376
|
|
package/package.json
CHANGED
|
@@ -362,6 +362,15 @@ export async function launchAndConnectRealBrowser(options = {}) {
|
|
|
362
362
|
return await launchAndConnectRealBrowserWithDependencies(options);
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Short Playwright-style name for {@link launchAndConnectRealBrowser}.
|
|
367
|
+
*
|
|
368
|
+
* Both names are the same function so existing callers can keep using the
|
|
369
|
+
* descriptive name while new code can use the API proposed for real-browser
|
|
370
|
+
* launch.
|
|
371
|
+
*/
|
|
372
|
+
export const launchRealBrowser = launchAndConnectRealBrowser;
|
|
373
|
+
|
|
365
374
|
/** Dependency-injected implementation used by the public helper and tests. */
|
|
366
375
|
export async function launchAndConnectRealBrowserWithDependencies(
|
|
367
376
|
options = {},
|
package/src/exports.js
CHANGED
|
@@ -43,7 +43,10 @@ export {
|
|
|
43
43
|
|
|
44
44
|
// Re-export browser management
|
|
45
45
|
export { connectBrowser } from './browser/connector.js';
|
|
46
|
-
export {
|
|
46
|
+
export {
|
|
47
|
+
launchAndConnectRealBrowser,
|
|
48
|
+
launchRealBrowser,
|
|
49
|
+
} from './browser/real-browser.js';
|
|
47
50
|
export { launchBrowser } from './browser/launcher.js';
|
|
48
51
|
export { saveStorageState } from './browser/storage-state.js';
|
|
49
52
|
export { emulateMedia } from './browser/media.js';
|
|
@@ -9,8 +9,12 @@ import {
|
|
|
9
9
|
buildRealBrowserArgs,
|
|
10
10
|
launchAndConnectRealBrowser,
|
|
11
11
|
launchAndConnectRealBrowserWithDependencies,
|
|
12
|
+
launchRealBrowser,
|
|
12
13
|
} from '../../../src/browser/real-browser.js';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
launchAndConnectRealBrowser as publicHelper,
|
|
16
|
+
launchRealBrowser as publicShortHelper,
|
|
17
|
+
} from '../../../src/index.js';
|
|
14
18
|
|
|
15
19
|
describe('launchAndConnectRealBrowser', () => {
|
|
16
20
|
let temporaryDirectory;
|
|
@@ -24,6 +28,8 @@ describe('launchAndConnectRealBrowser', () => {
|
|
|
24
28
|
|
|
25
29
|
it('is exported from the package API', () => {
|
|
26
30
|
assert.equal(publicHelper, launchAndConnectRealBrowser);
|
|
31
|
+
assert.equal(launchRealBrowser, launchAndConnectRealBrowser);
|
|
32
|
+
assert.equal(publicShortHelper, launchRealBrowser);
|
|
27
33
|
});
|
|
28
34
|
|
|
29
35
|
it('builds a loopback-only CDP command with a dedicated profile', () => {
|