@open-wa/wa-automate 4.27.1 → 4.27.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.
@@ -9,4 +9,4 @@ export declare function injectApi(page: Page): Promise<Page>;
|
|
9
9
|
/**
|
10
10
|
* @internal
|
11
11
|
*/
|
12
|
-
export declare const kill: (p: Page, b?: Browser, exit?: boolean) => Promise<void>;
|
12
|
+
export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number) => Promise<void>;
|
@@ -324,6 +324,9 @@ function initBrowser(sessionId, config = {}) {
|
|
324
324
|
}
|
325
325
|
if (config === null || config === void 0 ? void 0 : config.corsFix)
|
326
326
|
args.push('--disable-web-security');
|
327
|
+
if (config["userDataDir"] && !fs.existsSync(config["userDataDir"])) {
|
328
|
+
fs.mkdirSync(config["userDataDir"], { recursive: true });
|
329
|
+
}
|
327
330
|
const browser = (config === null || config === void 0 ? void 0 : config.browserWSEndpoint) ? yield puppeteer.connect(Object.assign({}, config)) : yield puppeteer.launch(Object.assign(Object.assign({ headless: true, args }, config), { devtools: false }));
|
328
331
|
//devtools
|
329
332
|
if (config === null || config === void 0 ? void 0 : config.devtools) {
|
@@ -366,27 +369,27 @@ death_1.default(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
369
|
/**
|
367
370
|
* @internal
|
368
371
|
*/
|
369
|
-
const kill = (p, b, exit) => __awaiter(void 0, void 0, void 0, function* () {
|
372
|
+
const kill = (p, b, exit, pid) => __awaiter(void 0, void 0, void 0, function* () {
|
370
373
|
const killBrowser = (browser) => __awaiter(void 0, void 0, void 0, function* () {
|
371
374
|
if (!browser)
|
372
375
|
return;
|
373
|
-
|
376
|
+
pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? browser === null || browser === void 0 ? void 0 : browser.process().pid : null;
|
374
377
|
if (!pid)
|
375
378
|
return;
|
376
379
|
if (!(p === null || p === void 0 ? void 0 : p.isClosed()))
|
377
380
|
yield (p === null || p === void 0 ? void 0 : p.close());
|
378
381
|
if (browser)
|
379
382
|
yield (browser === null || browser === void 0 ? void 0 : browser.close().catch(() => { }));
|
380
|
-
if (pid)
|
381
|
-
tree_kill_1.default(pid, 'SIGKILL');
|
382
383
|
});
|
383
384
|
if (p) {
|
384
|
-
const browser = p === null || p === void 0 ? void 0 : p.browser();
|
385
|
+
const browser = (p === null || p === void 0 ? void 0 : p.browser) && typeof (p === null || p === void 0 ? void 0 : p.browser) === 'function' && (p === null || p === void 0 ? void 0 : p.browser());
|
385
386
|
yield killBrowser(browser);
|
386
387
|
}
|
387
388
|
else if (b) {
|
388
389
|
yield killBrowser(b);
|
389
390
|
}
|
391
|
+
if (pid)
|
392
|
+
tree_kill_1.default(pid, 'SIGKILL');
|
390
393
|
if (exit)
|
391
394
|
process.exit();
|
392
395
|
return;
|
package/package.json
CHANGED