@deot/dev-test 2.7.0 → 2.8.1
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 +59 -6
- package/dist/index.d.ts +17 -0
- package/dist/index.js +59 -7
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -349,7 +349,7 @@ class Launch {
|
|
|
349
349
|
}
|
|
350
350
|
this._page = new Promise((resolve) => {
|
|
351
351
|
(async () => {
|
|
352
|
-
|
|
352
|
+
const page = await this.browser.newPage();
|
|
353
353
|
await page.evaluateOnNewDocument(
|
|
354
354
|
/* istanbul ignore next */
|
|
355
355
|
() => {
|
|
@@ -371,9 +371,61 @@ class Launch {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
class Scheduler {
|
|
375
|
+
_success;
|
|
376
|
+
_fail;
|
|
377
|
+
_task;
|
|
378
|
+
_finish = false;
|
|
379
|
+
constructor() {
|
|
380
|
+
this.next();
|
|
381
|
+
}
|
|
382
|
+
next = (v) => {
|
|
383
|
+
if (!this._finish) {
|
|
384
|
+
this._success?.(v);
|
|
385
|
+
this._task = new Promise((resolve, reject) => {
|
|
386
|
+
this._success = (value) => {
|
|
387
|
+
this._fail = void 0;
|
|
388
|
+
resolve(value);
|
|
389
|
+
};
|
|
390
|
+
this._fail = (value) => {
|
|
391
|
+
this._success = void 0;
|
|
392
|
+
reject(value);
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return this;
|
|
397
|
+
};
|
|
398
|
+
nextWithError = (v) => {
|
|
399
|
+
if (!this._finish) {
|
|
400
|
+
this._fail?.(v);
|
|
401
|
+
this.next();
|
|
402
|
+
}
|
|
403
|
+
return this;
|
|
404
|
+
};
|
|
405
|
+
finish = (v) => {
|
|
406
|
+
this._success?.(v);
|
|
407
|
+
this._finish = true;
|
|
408
|
+
return this;
|
|
409
|
+
};
|
|
410
|
+
finishWithError = (v) => {
|
|
411
|
+
this._fail?.(v);
|
|
412
|
+
this._finish = true;
|
|
413
|
+
return this;
|
|
414
|
+
};
|
|
415
|
+
then(resolve, reject) {
|
|
416
|
+
return this._task.then(resolve, reject);
|
|
417
|
+
}
|
|
418
|
+
catch(callback) {
|
|
419
|
+
return this._task.catch(callback);
|
|
420
|
+
}
|
|
421
|
+
finally(callback) {
|
|
422
|
+
return this._task.finally(callback);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
374
426
|
const TIME_OUT = 60 * 1e3;
|
|
375
427
|
const impl = () => {
|
|
376
|
-
|
|
428
|
+
const launch = new Launch();
|
|
377
429
|
beforeAll(async () => {
|
|
378
430
|
await launch.createBrowser();
|
|
379
431
|
}, 2e4);
|
|
@@ -438,11 +490,11 @@ let defaultHost = "";
|
|
|
438
490
|
const host = (force) => {
|
|
439
491
|
if (!force && defaultHost)
|
|
440
492
|
return defaultHost;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
for (
|
|
493
|
+
const ips = [];
|
|
494
|
+
const ntwk = os__namespace.networkInterfaces();
|
|
495
|
+
for (const k in ntwk) {
|
|
444
496
|
for (let i = 0; i < ntwk[k].length; i++) {
|
|
445
|
-
|
|
497
|
+
const _add = ntwk[k][i].address;
|
|
446
498
|
if (_add && _add.split(".").length == 4 && !ntwk[k][i].internal && ntwk[k][i].family == "IPv4") {
|
|
447
499
|
ips.push(ntwk[k][i].address);
|
|
448
500
|
}
|
|
@@ -498,5 +550,6 @@ exports.Command = Command;
|
|
|
498
550
|
exports.E2E = e2e;
|
|
499
551
|
exports.Launch = Launch;
|
|
500
552
|
exports.Operater = Operater;
|
|
553
|
+
exports.Scheduler = Scheduler;
|
|
501
554
|
exports.Server = server;
|
|
502
555
|
exports.Utils = utils;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ declare interface ExpectByPollingOptions {
|
|
|
52
52
|
to?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
declare type Func<T> = (_?: T) => void;
|
|
56
|
+
|
|
55
57
|
declare const host: (force?: boolean) => string;
|
|
56
58
|
|
|
57
59
|
declare const impl: () => Launch;
|
|
@@ -94,6 +96,21 @@ export declare class Operater {
|
|
|
94
96
|
|
|
95
97
|
declare const port: (host$?: string, port$?: number) => Promise<unknown>;
|
|
96
98
|
|
|
99
|
+
export declare class Scheduler<T = any> {
|
|
100
|
+
_success?: Func<any>;
|
|
101
|
+
_fail?: Func<any>;
|
|
102
|
+
_task: Promise<any>;
|
|
103
|
+
_finish: boolean;
|
|
104
|
+
constructor();
|
|
105
|
+
next: (v?: T) => this;
|
|
106
|
+
nextWithError: (v?: any) => this;
|
|
107
|
+
finish: (v?: T) => this;
|
|
108
|
+
finishWithError: (v?: T) => this;
|
|
109
|
+
then(resolve: Func<T>, reject: Func<T>): Promise<void>;
|
|
110
|
+
catch(callback?: Func<T>): Promise<any>;
|
|
111
|
+
finally(callback?: Func<void>): Promise<any>;
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
declare namespace Server {
|
|
98
115
|
export {
|
|
99
116
|
host,
|
package/dist/index.js
CHANGED
|
@@ -324,7 +324,7 @@ class Launch {
|
|
|
324
324
|
}
|
|
325
325
|
this._page = new Promise((resolve) => {
|
|
326
326
|
(async () => {
|
|
327
|
-
|
|
327
|
+
const page = await this.browser.newPage();
|
|
328
328
|
await page.evaluateOnNewDocument(
|
|
329
329
|
/* istanbul ignore next */
|
|
330
330
|
() => {
|
|
@@ -346,9 +346,61 @@ class Launch {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
class Scheduler {
|
|
350
|
+
_success;
|
|
351
|
+
_fail;
|
|
352
|
+
_task;
|
|
353
|
+
_finish = false;
|
|
354
|
+
constructor() {
|
|
355
|
+
this.next();
|
|
356
|
+
}
|
|
357
|
+
next = (v) => {
|
|
358
|
+
if (!this._finish) {
|
|
359
|
+
this._success?.(v);
|
|
360
|
+
this._task = new Promise((resolve, reject) => {
|
|
361
|
+
this._success = (value) => {
|
|
362
|
+
this._fail = void 0;
|
|
363
|
+
resolve(value);
|
|
364
|
+
};
|
|
365
|
+
this._fail = (value) => {
|
|
366
|
+
this._success = void 0;
|
|
367
|
+
reject(value);
|
|
368
|
+
};
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return this;
|
|
372
|
+
};
|
|
373
|
+
nextWithError = (v) => {
|
|
374
|
+
if (!this._finish) {
|
|
375
|
+
this._fail?.(v);
|
|
376
|
+
this.next();
|
|
377
|
+
}
|
|
378
|
+
return this;
|
|
379
|
+
};
|
|
380
|
+
finish = (v) => {
|
|
381
|
+
this._success?.(v);
|
|
382
|
+
this._finish = true;
|
|
383
|
+
return this;
|
|
384
|
+
};
|
|
385
|
+
finishWithError = (v) => {
|
|
386
|
+
this._fail?.(v);
|
|
387
|
+
this._finish = true;
|
|
388
|
+
return this;
|
|
389
|
+
};
|
|
390
|
+
then(resolve, reject) {
|
|
391
|
+
return this._task.then(resolve, reject);
|
|
392
|
+
}
|
|
393
|
+
catch(callback) {
|
|
394
|
+
return this._task.catch(callback);
|
|
395
|
+
}
|
|
396
|
+
finally(callback) {
|
|
397
|
+
return this._task.finally(callback);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
349
401
|
const TIME_OUT = 60 * 1e3;
|
|
350
402
|
const impl = () => {
|
|
351
|
-
|
|
403
|
+
const launch = new Launch();
|
|
352
404
|
beforeAll(async () => {
|
|
353
405
|
await launch.createBrowser();
|
|
354
406
|
}, 2e4);
|
|
@@ -413,11 +465,11 @@ let defaultHost = "";
|
|
|
413
465
|
const host = (force) => {
|
|
414
466
|
if (!force && defaultHost)
|
|
415
467
|
return defaultHost;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
for (
|
|
468
|
+
const ips = [];
|
|
469
|
+
const ntwk = os.networkInterfaces();
|
|
470
|
+
for (const k in ntwk) {
|
|
419
471
|
for (let i = 0; i < ntwk[k].length; i++) {
|
|
420
|
-
|
|
472
|
+
const _add = ntwk[k][i].address;
|
|
421
473
|
if (_add && _add.split(".").length == 4 && !ntwk[k][i].internal && ntwk[k][i].family == "IPv4") {
|
|
422
474
|
ips.push(ntwk[k][i].address);
|
|
423
475
|
}
|
|
@@ -469,4 +521,4 @@ const server = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
469
521
|
port
|
|
470
522
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
471
523
|
|
|
472
|
-
export { Command, e2e as E2E, Launch, Operater, server as Server, utils as Utils };
|
|
524
|
+
export { Command, e2e as E2E, Launch, Operater, Scheduler, server as Server, utils as Utils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/dev-test",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@deot/dev-shared": "^2.
|
|
23
|
-
"puppeteer": "^21.
|
|
22
|
+
"@deot/dev-shared": "^2.8.0",
|
|
23
|
+
"puppeteer": "^21.6.1"
|
|
24
24
|
}
|
|
25
25
|
}
|