@iflyrpa/playwright 1.1.2-beta.1 → 1.1.2-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.
- package/dist/index.cjs +405 -75019
- package/dist/index.d.ts +93 -86
- package/dist/index.js +391 -0
- package/package.json +17 -17
- package/dist/chunks/index.cjs +0 -170
- package/dist/chunks/index.mjs +0 -167
- package/dist/index.d.cts +0 -86
- package/dist/index.d.mts +0 -86
- package/dist/index.mjs +0 -75014
package/dist/chunks/index.cjs
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
async function pMap(
|
|
4
|
-
iterable,
|
|
5
|
-
mapper,
|
|
6
|
-
{
|
|
7
|
-
concurrency = Number.POSITIVE_INFINITY,
|
|
8
|
-
stopOnError = true,
|
|
9
|
-
signal,
|
|
10
|
-
} = {},
|
|
11
|
-
) {
|
|
12
|
-
return new Promise((resolve, reject_) => {
|
|
13
|
-
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
14
|
-
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof mapper !== 'function') {
|
|
18
|
-
throw new TypeError('Mapper function is required');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
|
22
|
-
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const result = [];
|
|
26
|
-
const errors = [];
|
|
27
|
-
const skippedIndexesMap = new Map();
|
|
28
|
-
let isRejected = false;
|
|
29
|
-
let isResolved = false;
|
|
30
|
-
let isIterableDone = false;
|
|
31
|
-
let resolvingCount = 0;
|
|
32
|
-
let currentIndex = 0;
|
|
33
|
-
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
34
|
-
|
|
35
|
-
const reject = reason => {
|
|
36
|
-
isRejected = true;
|
|
37
|
-
isResolved = true;
|
|
38
|
-
reject_(reason);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (signal) {
|
|
42
|
-
if (signal.aborted) {
|
|
43
|
-
reject(signal.reason);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
signal.addEventListener('abort', () => {
|
|
47
|
-
reject(signal.reason);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const next = async () => {
|
|
52
|
-
if (isResolved) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const nextItem = await iterator.next();
|
|
57
|
-
|
|
58
|
-
const index = currentIndex;
|
|
59
|
-
currentIndex++;
|
|
60
|
-
|
|
61
|
-
// Note: `iterator.next()` can be called many times in parallel.
|
|
62
|
-
// This can cause multiple calls to this `next()` function to
|
|
63
|
-
// receive a `nextItem` with `done === true`.
|
|
64
|
-
// The shutdown logic that rejects/resolves must be protected
|
|
65
|
-
// so it runs only one time as the `skippedIndex` logic is
|
|
66
|
-
// non-idempotent.
|
|
67
|
-
if (nextItem.done) {
|
|
68
|
-
isIterableDone = true;
|
|
69
|
-
|
|
70
|
-
if (resolvingCount === 0 && !isResolved) {
|
|
71
|
-
if (!stopOnError && errors.length > 0) {
|
|
72
|
-
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
isResolved = true;
|
|
77
|
-
|
|
78
|
-
if (skippedIndexesMap.size === 0) {
|
|
79
|
-
resolve(result);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const pureResult = [];
|
|
84
|
-
|
|
85
|
-
// Support multiple `pMapSkip`'s.
|
|
86
|
-
for (const [index, value] of result.entries()) {
|
|
87
|
-
if (skippedIndexesMap.get(index) === pMapSkip) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
pureResult.push(value);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
resolve(pureResult);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
resolvingCount++;
|
|
101
|
-
|
|
102
|
-
// Intentionally detached
|
|
103
|
-
(async () => {
|
|
104
|
-
try {
|
|
105
|
-
const element = await nextItem.value;
|
|
106
|
-
|
|
107
|
-
if (isResolved) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const value = await mapper(element, index);
|
|
112
|
-
|
|
113
|
-
// Use Map to stage the index of the element.
|
|
114
|
-
if (value === pMapSkip) {
|
|
115
|
-
skippedIndexesMap.set(index, value);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
result[index] = value;
|
|
119
|
-
|
|
120
|
-
resolvingCount--;
|
|
121
|
-
await next();
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (stopOnError) {
|
|
124
|
-
reject(error);
|
|
125
|
-
} else {
|
|
126
|
-
errors.push(error);
|
|
127
|
-
resolvingCount--;
|
|
128
|
-
|
|
129
|
-
// In that case we can't really continue regardless of `stopOnError` state
|
|
130
|
-
// since an iterable is likely to continue throwing after it throws once.
|
|
131
|
-
// If we continue calling `next()` indefinitely we will likely end up
|
|
132
|
-
// in an infinite loop of failed iteration.
|
|
133
|
-
try {
|
|
134
|
-
await next();
|
|
135
|
-
} catch (error) {
|
|
136
|
-
reject(error);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
})();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// Create the concurrent runners in a detached (non-awaited)
|
|
144
|
-
// promise. We need this so we can await the `next()` calls
|
|
145
|
-
// to stop creating runners before hitting the concurrency limit
|
|
146
|
-
// if the iterable has already been marked as done.
|
|
147
|
-
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
|
148
|
-
// infinite `next()` calls by default and never start the event loop.
|
|
149
|
-
(async () => {
|
|
150
|
-
for (let index = 0; index < concurrency; index++) {
|
|
151
|
-
try {
|
|
152
|
-
// eslint-disable-next-line no-await-in-loop
|
|
153
|
-
await next();
|
|
154
|
-
} catch (error) {
|
|
155
|
-
reject(error);
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (isIterableDone || isRejected) {
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
})();
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const pMapSkip = Symbol('skip');
|
|
168
|
-
|
|
169
|
-
exports.default = pMap;
|
|
170
|
-
exports.pMapSkip = pMapSkip;
|
package/dist/chunks/index.mjs
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
async function pMap(
|
|
2
|
-
iterable,
|
|
3
|
-
mapper,
|
|
4
|
-
{
|
|
5
|
-
concurrency = Number.POSITIVE_INFINITY,
|
|
6
|
-
stopOnError = true,
|
|
7
|
-
signal,
|
|
8
|
-
} = {},
|
|
9
|
-
) {
|
|
10
|
-
return new Promise((resolve, reject_) => {
|
|
11
|
-
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
12
|
-
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (typeof mapper !== 'function') {
|
|
16
|
-
throw new TypeError('Mapper function is required');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
|
20
|
-
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const result = [];
|
|
24
|
-
const errors = [];
|
|
25
|
-
const skippedIndexesMap = new Map();
|
|
26
|
-
let isRejected = false;
|
|
27
|
-
let isResolved = false;
|
|
28
|
-
let isIterableDone = false;
|
|
29
|
-
let resolvingCount = 0;
|
|
30
|
-
let currentIndex = 0;
|
|
31
|
-
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
32
|
-
|
|
33
|
-
const reject = reason => {
|
|
34
|
-
isRejected = true;
|
|
35
|
-
isResolved = true;
|
|
36
|
-
reject_(reason);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
if (signal) {
|
|
40
|
-
if (signal.aborted) {
|
|
41
|
-
reject(signal.reason);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
signal.addEventListener('abort', () => {
|
|
45
|
-
reject(signal.reason);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const next = async () => {
|
|
50
|
-
if (isResolved) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const nextItem = await iterator.next();
|
|
55
|
-
|
|
56
|
-
const index = currentIndex;
|
|
57
|
-
currentIndex++;
|
|
58
|
-
|
|
59
|
-
// Note: `iterator.next()` can be called many times in parallel.
|
|
60
|
-
// This can cause multiple calls to this `next()` function to
|
|
61
|
-
// receive a `nextItem` with `done === true`.
|
|
62
|
-
// The shutdown logic that rejects/resolves must be protected
|
|
63
|
-
// so it runs only one time as the `skippedIndex` logic is
|
|
64
|
-
// non-idempotent.
|
|
65
|
-
if (nextItem.done) {
|
|
66
|
-
isIterableDone = true;
|
|
67
|
-
|
|
68
|
-
if (resolvingCount === 0 && !isResolved) {
|
|
69
|
-
if (!stopOnError && errors.length > 0) {
|
|
70
|
-
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
isResolved = true;
|
|
75
|
-
|
|
76
|
-
if (skippedIndexesMap.size === 0) {
|
|
77
|
-
resolve(result);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const pureResult = [];
|
|
82
|
-
|
|
83
|
-
// Support multiple `pMapSkip`'s.
|
|
84
|
-
for (const [index, value] of result.entries()) {
|
|
85
|
-
if (skippedIndexesMap.get(index) === pMapSkip) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
pureResult.push(value);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
resolve(pureResult);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
resolvingCount++;
|
|
99
|
-
|
|
100
|
-
// Intentionally detached
|
|
101
|
-
(async () => {
|
|
102
|
-
try {
|
|
103
|
-
const element = await nextItem.value;
|
|
104
|
-
|
|
105
|
-
if (isResolved) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const value = await mapper(element, index);
|
|
110
|
-
|
|
111
|
-
// Use Map to stage the index of the element.
|
|
112
|
-
if (value === pMapSkip) {
|
|
113
|
-
skippedIndexesMap.set(index, value);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
result[index] = value;
|
|
117
|
-
|
|
118
|
-
resolvingCount--;
|
|
119
|
-
await next();
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (stopOnError) {
|
|
122
|
-
reject(error);
|
|
123
|
-
} else {
|
|
124
|
-
errors.push(error);
|
|
125
|
-
resolvingCount--;
|
|
126
|
-
|
|
127
|
-
// In that case we can't really continue regardless of `stopOnError` state
|
|
128
|
-
// since an iterable is likely to continue throwing after it throws once.
|
|
129
|
-
// If we continue calling `next()` indefinitely we will likely end up
|
|
130
|
-
// in an infinite loop of failed iteration.
|
|
131
|
-
try {
|
|
132
|
-
await next();
|
|
133
|
-
} catch (error) {
|
|
134
|
-
reject(error);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
})();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// Create the concurrent runners in a detached (non-awaited)
|
|
142
|
-
// promise. We need this so we can await the `next()` calls
|
|
143
|
-
// to stop creating runners before hitting the concurrency limit
|
|
144
|
-
// if the iterable has already been marked as done.
|
|
145
|
-
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
|
146
|
-
// infinite `next()` calls by default and never start the event loop.
|
|
147
|
-
(async () => {
|
|
148
|
-
for (let index = 0; index < concurrency; index++) {
|
|
149
|
-
try {
|
|
150
|
-
// eslint-disable-next-line no-await-in-loop
|
|
151
|
-
await next();
|
|
152
|
-
} catch (error) {
|
|
153
|
-
reject(error);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (isIterableDone || isRejected) {
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
})();
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const pMapSkip = Symbol('skip');
|
|
166
|
-
|
|
167
|
-
export { pMap as default, pMapSkip };
|
package/dist/index.d.cts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Action } from '@iflyrpa/actions';
|
|
2
|
-
export { ActionMethodParams } from '@iflyrpa/actions';
|
|
3
|
-
import * as playwright_core from 'playwright-core';
|
|
4
|
-
import { LoggerImplement, AutomateTask, ElectronApplication, PageParams } from '@iflyrpa/share';
|
|
5
|
-
|
|
6
|
-
declare class Logger implements LoggerImplement {
|
|
7
|
-
static instance: Logger | null;
|
|
8
|
-
private stream;
|
|
9
|
-
constructor(cachePath: string);
|
|
10
|
-
static getInstance(cachePath: string): Logger;
|
|
11
|
-
debug(...msg: any[]): void;
|
|
12
|
-
info(...msg: any[]): void;
|
|
13
|
-
warn(...msg: any[]): void;
|
|
14
|
-
error(prefix: string, err?: unknown): void;
|
|
15
|
-
close(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare class PackageManager {
|
|
19
|
-
private task;
|
|
20
|
-
constructor(task: Task);
|
|
21
|
-
private getManifest;
|
|
22
|
-
private extract;
|
|
23
|
-
require(module: string): any;
|
|
24
|
-
install(name: string, version: string): Promise<void>;
|
|
25
|
-
update(name: string): Promise<string>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface TaskParams {
|
|
29
|
-
debug?: boolean;
|
|
30
|
-
cachePath: string;
|
|
31
|
-
forceUpdate?: boolean;
|
|
32
|
-
}
|
|
33
|
-
declare class Task implements AutomateTask {
|
|
34
|
-
logger: Logger;
|
|
35
|
-
cachePath: string;
|
|
36
|
-
debug: boolean;
|
|
37
|
-
packagesDir: string;
|
|
38
|
-
packageManager: PackageManager;
|
|
39
|
-
private playwrightPackage;
|
|
40
|
-
private electronPackage;
|
|
41
|
-
private _electronApp;
|
|
42
|
-
/**
|
|
43
|
-
* 应用是否已关闭
|
|
44
|
-
*/
|
|
45
|
-
isClosed: boolean;
|
|
46
|
-
constructor({ cachePath, debug }: TaskParams);
|
|
47
|
-
/**
|
|
48
|
-
* 安装 playwright
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
private installPlaywright;
|
|
52
|
-
/**
|
|
53
|
-
* 安装 electron
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
private installElectron;
|
|
57
|
-
/**
|
|
58
|
-
* 启动 Electron
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
launchApp(): Promise<ElectronApplication>;
|
|
62
|
-
/**
|
|
63
|
-
* 临时文件目录
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
getTmpPath(): string;
|
|
67
|
-
/**
|
|
68
|
-
* 清空临时文件
|
|
69
|
-
*/
|
|
70
|
-
private clearTmpPath;
|
|
71
|
-
/**
|
|
72
|
-
* 关闭 playwright 启动的 electron 客户端
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
close(): Promise<void>;
|
|
76
|
-
createPage(pageParams: PageParams): Promise<playwright_core.Page>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
declare class RpaTask extends Task {
|
|
80
|
-
actions: Action;
|
|
81
|
-
constructor(params: TaskParams);
|
|
82
|
-
private update;
|
|
83
|
-
}
|
|
84
|
-
declare const version: string;
|
|
85
|
-
|
|
86
|
-
export { RpaTask, version };
|
package/dist/index.d.mts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Action } from '@iflyrpa/actions';
|
|
2
|
-
export { ActionMethodParams } from '@iflyrpa/actions';
|
|
3
|
-
import * as playwright_core from 'playwright-core';
|
|
4
|
-
import { LoggerImplement, AutomateTask, ElectronApplication, PageParams } from '@iflyrpa/share';
|
|
5
|
-
|
|
6
|
-
declare class Logger implements LoggerImplement {
|
|
7
|
-
static instance: Logger | null;
|
|
8
|
-
private stream;
|
|
9
|
-
constructor(cachePath: string);
|
|
10
|
-
static getInstance(cachePath: string): Logger;
|
|
11
|
-
debug(...msg: any[]): void;
|
|
12
|
-
info(...msg: any[]): void;
|
|
13
|
-
warn(...msg: any[]): void;
|
|
14
|
-
error(prefix: string, err?: unknown): void;
|
|
15
|
-
close(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare class PackageManager {
|
|
19
|
-
private task;
|
|
20
|
-
constructor(task: Task);
|
|
21
|
-
private getManifest;
|
|
22
|
-
private extract;
|
|
23
|
-
require(module: string): any;
|
|
24
|
-
install(name: string, version: string): Promise<void>;
|
|
25
|
-
update(name: string): Promise<string>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface TaskParams {
|
|
29
|
-
debug?: boolean;
|
|
30
|
-
cachePath: string;
|
|
31
|
-
forceUpdate?: boolean;
|
|
32
|
-
}
|
|
33
|
-
declare class Task implements AutomateTask {
|
|
34
|
-
logger: Logger;
|
|
35
|
-
cachePath: string;
|
|
36
|
-
debug: boolean;
|
|
37
|
-
packagesDir: string;
|
|
38
|
-
packageManager: PackageManager;
|
|
39
|
-
private playwrightPackage;
|
|
40
|
-
private electronPackage;
|
|
41
|
-
private _electronApp;
|
|
42
|
-
/**
|
|
43
|
-
* 应用是否已关闭
|
|
44
|
-
*/
|
|
45
|
-
isClosed: boolean;
|
|
46
|
-
constructor({ cachePath, debug }: TaskParams);
|
|
47
|
-
/**
|
|
48
|
-
* 安装 playwright
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
private installPlaywright;
|
|
52
|
-
/**
|
|
53
|
-
* 安装 electron
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
private installElectron;
|
|
57
|
-
/**
|
|
58
|
-
* 启动 Electron
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
launchApp(): Promise<ElectronApplication>;
|
|
62
|
-
/**
|
|
63
|
-
* 临时文件目录
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
getTmpPath(): string;
|
|
67
|
-
/**
|
|
68
|
-
* 清空临时文件
|
|
69
|
-
*/
|
|
70
|
-
private clearTmpPath;
|
|
71
|
-
/**
|
|
72
|
-
* 关闭 playwright 启动的 electron 客户端
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
close(): Promise<void>;
|
|
76
|
-
createPage(pageParams: PageParams): Promise<playwright_core.Page>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
declare class RpaTask extends Task {
|
|
80
|
-
actions: Action;
|
|
81
|
-
constructor(params: TaskParams);
|
|
82
|
-
private update;
|
|
83
|
-
}
|
|
84
|
-
declare const version: string;
|
|
85
|
-
|
|
86
|
-
export { RpaTask, version };
|