@deot/dev-test 2.3.2 → 2.5.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/dist/{index.cjs.js → index.cjs} +12 -15
- package/dist/index.d.ts +5 -2
- package/dist/index.es.js +12 -15
- package/package.json +11 -4
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const devShared = require('@deot/dev-shared');
|
|
6
5
|
const childProcess = require('child_process');
|
|
6
|
+
const devShared = require('@deot/dev-shared');
|
|
7
7
|
const puppeteer = require('puppeteer');
|
|
8
8
|
const http = require('http');
|
|
9
9
|
const os = require('os');
|
|
@@ -300,8 +300,10 @@ class Launch {
|
|
|
300
300
|
operater;
|
|
301
301
|
_browser;
|
|
302
302
|
_page;
|
|
303
|
+
puppeteerOptions;
|
|
303
304
|
options;
|
|
304
|
-
constructor() {
|
|
305
|
+
constructor(options) {
|
|
306
|
+
this.options = options || { logLevel: "slient" };
|
|
305
307
|
this.operater = new Proxy({}, {
|
|
306
308
|
get: () => {
|
|
307
309
|
throw new Error("operater is not defined. create* invote first");
|
|
@@ -317,10 +319,8 @@ class Launch {
|
|
|
317
319
|
throw new Error("page is not defined. createPage invote first");
|
|
318
320
|
}
|
|
319
321
|
});
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
{ args: ["--no-sandbox", "--disable-setuid-sandbox"] }
|
|
323
|
-
) : {};
|
|
322
|
+
/* istanbul ignore next -- @preserve */
|
|
323
|
+
this.puppeteerOptions = process.env.CI ? { args: ["--no-sandbox", "--disable-setuid-sandbox"] } : {};
|
|
324
324
|
}
|
|
325
325
|
createBrowser(force) {
|
|
326
326
|
if (force || !this._browser) {
|
|
@@ -330,7 +330,7 @@ class Launch {
|
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
this._browser = puppeteer.launch({
|
|
333
|
-
...this.
|
|
333
|
+
...this.puppeteerOptions,
|
|
334
334
|
headless: "new"
|
|
335
335
|
});
|
|
336
336
|
this._browser.then((browser) => {
|
|
@@ -356,14 +356,11 @@ class Launch {
|
|
|
356
356
|
localStorage.clear();
|
|
357
357
|
}
|
|
358
358
|
);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
(e) =>
|
|
363
|
-
|
|
364
|
-
console[key].call(console[key], `${key} from puppeteer: `, ...e.args().map((i) => i.remoteObject()));
|
|
365
|
-
}
|
|
366
|
-
);
|
|
359
|
+
/* istanbul ignore next -- @preserve */
|
|
360
|
+
this.options.logLevel !== "slient" && page.on("console", (e) => {
|
|
361
|
+
const key = e.type();
|
|
362
|
+
console[key].call(console[key], `${key} from puppeteer: `, ...e.args().map((i) => i.remoteObject()));
|
|
363
|
+
});
|
|
367
364
|
this.page = page;
|
|
368
365
|
this.operater = new Operater(page);
|
|
369
366
|
resolve(page);
|
package/dist/index.d.ts
CHANGED
|
@@ -62,8 +62,11 @@ export declare class Launch {
|
|
|
62
62
|
operater: Operater;
|
|
63
63
|
private _browser;
|
|
64
64
|
private _page;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
puppeteerOptions: PuppeteerLaunchOptions;
|
|
66
|
+
options: {
|
|
67
|
+
logLevel?: string;
|
|
68
|
+
};
|
|
69
|
+
constructor(options?: Launch['options']);
|
|
67
70
|
createBrowser(force?: boolean): Promise<Browser>;
|
|
68
71
|
createPage(force?: boolean): Promise<Page>;
|
|
69
72
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Shell } from '@deot/dev-shared';
|
|
2
1
|
import * as childProcess from 'child_process';
|
|
2
|
+
import { Shell } from '@deot/dev-shared';
|
|
3
3
|
import puppeteer from 'puppeteer';
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
import * as os from 'os';
|
|
@@ -275,8 +275,10 @@ class Launch {
|
|
|
275
275
|
operater;
|
|
276
276
|
_browser;
|
|
277
277
|
_page;
|
|
278
|
+
puppeteerOptions;
|
|
278
279
|
options;
|
|
279
|
-
constructor() {
|
|
280
|
+
constructor(options) {
|
|
281
|
+
this.options = options || { logLevel: "slient" };
|
|
280
282
|
this.operater = new Proxy({}, {
|
|
281
283
|
get: () => {
|
|
282
284
|
throw new Error("operater is not defined. create* invote first");
|
|
@@ -292,10 +294,8 @@ class Launch {
|
|
|
292
294
|
throw new Error("page is not defined. createPage invote first");
|
|
293
295
|
}
|
|
294
296
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
{ args: ["--no-sandbox", "--disable-setuid-sandbox"] }
|
|
298
|
-
) : {};
|
|
297
|
+
/* istanbul ignore next -- @preserve */
|
|
298
|
+
this.puppeteerOptions = process.env.CI ? { args: ["--no-sandbox", "--disable-setuid-sandbox"] } : {};
|
|
299
299
|
}
|
|
300
300
|
createBrowser(force) {
|
|
301
301
|
if (force || !this._browser) {
|
|
@@ -305,7 +305,7 @@ class Launch {
|
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
this._browser = puppeteer.launch({
|
|
308
|
-
...this.
|
|
308
|
+
...this.puppeteerOptions,
|
|
309
309
|
headless: "new"
|
|
310
310
|
});
|
|
311
311
|
this._browser.then((browser) => {
|
|
@@ -331,14 +331,11 @@ class Launch {
|
|
|
331
331
|
localStorage.clear();
|
|
332
332
|
}
|
|
333
333
|
);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
(e) =>
|
|
338
|
-
|
|
339
|
-
console[key].call(console[key], `${key} from puppeteer: `, ...e.args().map((i) => i.remoteObject()));
|
|
340
|
-
}
|
|
341
|
-
);
|
|
334
|
+
/* istanbul ignore next -- @preserve */
|
|
335
|
+
this.options.logLevel !== "slient" && page.on("console", (e) => {
|
|
336
|
+
const key = e.type();
|
|
337
|
+
console[key].call(console[key], `${key} from puppeteer: `, ...e.args().map((i) => i.remoteObject()));
|
|
338
|
+
});
|
|
342
339
|
this.page = page;
|
|
343
340
|
this.operater = new Operater(page);
|
|
344
341
|
resolve(page);
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/dev-test",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "dist/index.es.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
6
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.es.js",
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"files": [
|
|
8
15
|
"dist"
|
|
9
16
|
],
|
|
@@ -12,7 +19,7 @@
|
|
|
12
19
|
"access": "public"
|
|
13
20
|
},
|
|
14
21
|
"dependencies": {
|
|
15
|
-
"@deot/dev-shared": "^2.
|
|
16
|
-
"puppeteer": "^21.
|
|
22
|
+
"@deot/dev-shared": "^2.5.0",
|
|
23
|
+
"puppeteer": "^21.1.1"
|
|
17
24
|
}
|
|
18
25
|
}
|