@minded-ai/mindedjs 2.0.9-beta.2 → 2.0.9-beta.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localBrowserTask.d.ts","sourceRoot":"","sources":["../../src/browserTask/localBrowserTask.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localBrowserTask.d.ts","sourceRoot":"","sources":["../../src/browserTask/localBrowserTask.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,oBAAoB,GAAG;IACjC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,0GAA0G;IAC1G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAgH7B;AAwBD,wBAAsB,IAAI,kBAMzB"}
|
|
@@ -28,12 +28,12 @@ exports.kill = kill;
|
|
|
28
28
|
// getOrStartLocalCDP.ts
|
|
29
29
|
const child_process_1 = require("child_process");
|
|
30
30
|
const fs = __importStar(require("fs/promises"));
|
|
31
|
-
const fscb = __importStar(require("fs"));
|
|
32
31
|
const path = __importStar(require("path"));
|
|
33
32
|
const playwright_1 = require("playwright");
|
|
34
33
|
const logger_1 = require("../utils/logger");
|
|
35
34
|
const wait_1 = require("../utils/wait");
|
|
36
35
|
let localBrowserTask = null;
|
|
36
|
+
const port = 9222;
|
|
37
37
|
/**
|
|
38
38
|
* Launch Chromium with --remote-debugging-port=0 and return the CDP ws URL.
|
|
39
39
|
* Works with Chrome/Chromium/Chrome for Testing.
|
|
@@ -45,7 +45,7 @@ async function getOrStartLocalCDP(opts) {
|
|
|
45
45
|
cdpUrl: localBrowserTask.cdpUrl,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
const { env
|
|
48
|
+
const { env } = opts;
|
|
49
49
|
const executablePath = playwright_1.chromium.executablePath();
|
|
50
50
|
const profileDir = path.join(__dirname, "profile");
|
|
51
51
|
await fs.mkdir(profileDir, { recursive: true });
|
|
@@ -115,7 +115,7 @@ async function getOrStartLocalCDP(opts) {
|
|
|
115
115
|
"--enable-extensions",
|
|
116
116
|
"--disable-extensions-file-access-check",
|
|
117
117
|
"--enable-extension-activity-logging",
|
|
118
|
-
`--remote-debugging-port
|
|
118
|
+
`--remote-debugging-port=${port}`,
|
|
119
119
|
"--remote-debugging-address=0.0.0.0",
|
|
120
120
|
"about:blank",
|
|
121
121
|
];
|
|
@@ -129,40 +129,12 @@ async function getOrStartLocalCDP(opts) {
|
|
|
129
129
|
proc.on("exit", (code, signal) => {
|
|
130
130
|
logger_1.logger.error({ message: 'Chromium exited', code, signal });
|
|
131
131
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
// Access succeeds once the file is written.
|
|
139
|
-
await fs.access(devtoolsPortFile, fscb.constants.F_OK);
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
catch (_a) {
|
|
143
|
-
await (0, wait_1.wait)(50);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// If still not there, bail.
|
|
147
|
-
await fs.access(devtoolsPortFile, fscb.constants.F_OK).catch(() => {
|
|
148
|
-
throw new Error(`Timed out after ${timeoutMs}ms waiting for DevToolsActivePort at ${devtoolsPortFile}`);
|
|
149
|
-
});
|
|
150
|
-
const raw = await fs.readFile(devtoolsPortFile, "utf8");
|
|
151
|
-
const [portLine] = raw.trim().split(/\r?\n/);
|
|
152
|
-
const port = Number(portLine);
|
|
153
|
-
if (!Number.isFinite(port)) {
|
|
154
|
-
throw new Error(`Invalid DevTools port read from file: "${portLine}"`);
|
|
155
|
-
}
|
|
156
|
-
// Ensure the CDP endpoint is responsive by polling /json/version
|
|
157
|
-
await waitForCdpEndpoint(port, 30);
|
|
158
|
-
const cdpUrl = `http://127.0.0.1:${port}`;
|
|
159
|
-
localBrowserTask = {
|
|
160
|
-
cdpUrl,
|
|
161
|
-
proc,
|
|
162
|
-
};
|
|
163
|
-
return { cdpUrl };
|
|
132
|
+
await waitForCdpEndpoint(port, 30);
|
|
133
|
+
const cdpUrl = `http://127.0.0.1:${port}`;
|
|
134
|
+
localBrowserTask = {
|
|
135
|
+
cdpUrl,
|
|
136
|
+
proc,
|
|
164
137
|
};
|
|
165
|
-
const { cdpUrl } = await whenReady();
|
|
166
138
|
logger_1.logger.info({ message: 'Local browser task started', cdpUrl });
|
|
167
139
|
return { cdpUrl };
|
|
168
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localBrowserTask.js","sourceRoot":"","sources":["../../src/browserTask/localBrowserTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"localBrowserTask.js","sourceRoot":"","sources":["../../src/browserTask/localBrowserTask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,gDAkHC;AAwBD,oBAMC;AAhLD,wBAAwB;AACxB,iDAAoD;AACpD,gDAAkC;AAClC,2CAA6B;AAC7B,2CAAsC;AACtC,4CAAyC;AACzC,wCAAqC;AAErC,IAAI,gBAAgB,GAGT,IAAI,CAAC;AAEhB,MAAM,IAAI,GAAG,IAAI,CAAC;AAelB;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACtC,IAA0B;;IAG1B,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;SAChC,CAAC;IACJ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import * as fscb from "fs";
|
|
5
4
|
import * as path from "path";
|
|
6
5
|
import { chromium } from "playwright";
|
|
7
6
|
import { logger } from "../utils/logger";
|
|
@@ -12,6 +11,8 @@ let localBrowserTask: {
|
|
|
12
11
|
proc: ChildProcess;
|
|
13
12
|
} | null = null;
|
|
14
13
|
|
|
14
|
+
const port = 9222;
|
|
15
|
+
|
|
15
16
|
export type StartChromiumOptions = {
|
|
16
17
|
/** Headless by default. Set to false to see a window. */
|
|
17
18
|
headless?: boolean;
|
|
@@ -39,10 +40,7 @@ export async function getOrStartLocalCDP(
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
const {
|
|
43
|
-
env,
|
|
44
|
-
timeoutMs = 10_000,
|
|
45
|
-
} = opts;
|
|
43
|
+
const { env } = opts;
|
|
46
44
|
|
|
47
45
|
const executablePath = chromium.executablePath();
|
|
48
46
|
|
|
@@ -116,7 +114,7 @@ export async function getOrStartLocalCDP(
|
|
|
116
114
|
"--enable-extensions",
|
|
117
115
|
"--disable-extensions-file-access-check",
|
|
118
116
|
"--enable-extension-activity-logging",
|
|
119
|
-
`--remote-debugging-port
|
|
117
|
+
`--remote-debugging-port=${port}`,
|
|
120
118
|
"--remote-debugging-address=0.0.0.0",
|
|
121
119
|
"about:blank",
|
|
122
120
|
];
|
|
@@ -134,49 +132,15 @@ export async function getOrStartLocalCDP(
|
|
|
134
132
|
logger.error({ message: 'Chromium exited', code, signal });
|
|
135
133
|
});
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// Wait for DevToolsActivePort file to appear, then read it for port + browserId.
|
|
140
|
-
const whenReady = async () => {
|
|
141
|
-
const startedAt = Date.now();
|
|
142
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
143
|
-
try {
|
|
144
|
-
// Access succeeds once the file is written.
|
|
145
|
-
await fs.access(devtoolsPortFile, fscb.constants.F_OK);
|
|
146
|
-
break;
|
|
147
|
-
} catch {
|
|
148
|
-
await wait(50);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// If still not there, bail.
|
|
152
|
-
await fs.access(devtoolsPortFile, fscb.constants.F_OK).catch(() => {
|
|
153
|
-
throw new Error(
|
|
154
|
-
`Timed out after ${timeoutMs}ms waiting for DevToolsActivePort at ${devtoolsPortFile}`
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const raw = await fs.readFile(devtoolsPortFile, "utf8");
|
|
159
|
-
const [portLine] = raw.trim().split(/\r?\n/);
|
|
160
|
-
const port = Number(portLine);
|
|
161
|
-
if (!Number.isFinite(port)) {
|
|
162
|
-
throw new Error(`Invalid DevTools port read from file: "${portLine}"`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Ensure the CDP endpoint is responsive by polling /json/version
|
|
166
|
-
await waitForCdpEndpoint(port, 30);
|
|
167
|
-
|
|
168
|
-
const cdpUrl = `http://127.0.0.1:${port}`;
|
|
135
|
+
await waitForCdpEndpoint(port, 30);
|
|
169
136
|
|
|
170
|
-
|
|
171
|
-
cdpUrl,
|
|
172
|
-
proc,
|
|
173
|
-
};
|
|
137
|
+
const cdpUrl = `http://127.0.0.1:${port}`;
|
|
174
138
|
|
|
175
|
-
|
|
139
|
+
localBrowserTask = {
|
|
140
|
+
cdpUrl,
|
|
141
|
+
proc,
|
|
176
142
|
};
|
|
177
143
|
|
|
178
|
-
const { cdpUrl } = await whenReady();
|
|
179
|
-
|
|
180
144
|
logger.info({ message: 'Local browser task started', cdpUrl });
|
|
181
145
|
|
|
182
146
|
return { cdpUrl };
|