@iflyrpa/playwright 1.2.3 → 1.2.4
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/README.md +2 -4
- package/dist/index.cjs +78 -62
- package/dist/index.d.ts +9 -4
- package/dist/index.js +77 -62
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ const automateTask = new RpaTask({
|
|
|
41
41
|
cachePath, // 缓存目录
|
|
42
42
|
debug: true, // debug 模式下可视化展示所有操作
|
|
43
43
|
forceUpdate: false, // 是否使用远程最新版本
|
|
44
|
+
user: { id: "xx", email: "xx@xx.com" }, // 用户信息
|
|
45
|
+
enverionment: "development", // 环境变量(主要用于在日志中区分环境)
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
// 3. 执行脚本,支持的脚本如上
|
|
@@ -77,7 +79,3 @@ export const xiaohonshuPublishParams: ActionMethodParams['xiaohongshuPublish'] =
|
|
|
77
79
|
|
|
78
80
|
automateTask.actions.xiaohongshuPublish(xiaohonshuPublishParams)
|
|
79
81
|
```
|
|
80
|
-
|
|
81
|
-
**3. 云端日志**
|
|
82
|
-
|
|
83
|
-
<https://sentry-new.iflyrpa.com/rpa/turbodesk-rpa>
|
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
44
44
|
});
|
|
45
45
|
const actions_namespaceObject = require("@iflyrpa/actions");
|
|
46
46
|
var package_namespaceObject = {
|
|
47
|
-
i8: "1.2.
|
|
47
|
+
i8: "1.2.4"
|
|
48
48
|
};
|
|
49
49
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
50
50
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -145,9 +145,44 @@ class ElectronInstall {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
148
|
+
const template = `
|
|
149
|
+
const { app } = require("electron");
|
|
150
|
+
|
|
151
|
+
app.whenReady().then(() => {});
|
|
152
|
+
|
|
153
|
+
app.on("window-all-closed", (e) => e.preventDefault());
|
|
154
|
+
`;
|
|
155
|
+
const generateFile = async (dir)=>{
|
|
156
|
+
const filePath = external_node_path_default().join(dir, "main.js");
|
|
157
|
+
const isPathExists = await (0, share_namespaceObject.pathExists)(filePath);
|
|
158
|
+
if (!isPathExists) {
|
|
159
|
+
await (0, share_namespaceObject.ensureFile)(filePath);
|
|
160
|
+
await (0, share_namespaceObject.writeFile)(filePath, template);
|
|
161
|
+
}
|
|
162
|
+
return filePath;
|
|
163
|
+
};
|
|
164
|
+
const launchElectronApp = async (task, playwright, electronPath)=>{
|
|
165
|
+
const { logger, cachePath } = task;
|
|
166
|
+
try {
|
|
167
|
+
const mainPath = await generateFile(cachePath);
|
|
168
|
+
const electronApp = await playwright._electron.launch({
|
|
169
|
+
executablePath: electronPath,
|
|
170
|
+
args: [
|
|
171
|
+
mainPath
|
|
172
|
+
],
|
|
173
|
+
cwd: cachePath
|
|
174
|
+
});
|
|
175
|
+
logger.info(`electron 启动成功:${electronPath} ${mainPath}`);
|
|
176
|
+
return electronApp;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
logger.error("electron 启动失败:", error);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
148
182
|
const external_loglevel_namespaceObject = require("loglevel");
|
|
149
183
|
var external_loglevel_default = /*#__PURE__*/ __webpack_require__.n(external_loglevel_namespaceObject);
|
|
150
184
|
const node_namespaceObject = require("@sentry/node");
|
|
185
|
+
var node_default = /*#__PURE__*/ __webpack_require__.n(node_namespaceObject);
|
|
151
186
|
function sentry_define_property(obj, key, value) {
|
|
152
187
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
153
188
|
value: value,
|
|
@@ -158,21 +193,35 @@ function sentry_define_property(obj, key, value) {
|
|
|
158
193
|
else obj[key] = value;
|
|
159
194
|
return obj;
|
|
160
195
|
}
|
|
196
|
+
const DEFAULT_SENTRY_DSN = "https://0ad25bf248b74b3d9950ff426c8e2240@bzrobottest.iflysec.com/6";
|
|
161
197
|
class SentryInstance {
|
|
198
|
+
updateCoreVersion(version) {
|
|
199
|
+
this.coreVersion = version;
|
|
200
|
+
}
|
|
162
201
|
captureException(error) {
|
|
163
|
-
|
|
164
|
-
|
|
202
|
+
node_default().withScope((scope)=>{
|
|
203
|
+
var _this_sentry;
|
|
204
|
+
scope.setTag("coreVersion", this.coreVersion);
|
|
205
|
+
null === (_this_sentry = this.sentry) || void 0 === _this_sentry || _this_sentry.captureException(error);
|
|
206
|
+
});
|
|
165
207
|
}
|
|
166
|
-
constructor(
|
|
208
|
+
constructor(taskParams, coreVersion){
|
|
167
209
|
sentry_define_property(this, "sentry", void 0);
|
|
168
|
-
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
210
|
+
sentry_define_property(this, "coreVersion", void 0);
|
|
211
|
+
this.coreVersion = coreVersion;
|
|
212
|
+
this.sentry = node_default().initWithoutDefaultIntegrations({
|
|
213
|
+
dsn: DEFAULT_SENTRY_DSN,
|
|
214
|
+
environment: taskParams.enverionment || "development",
|
|
215
|
+
initialScope: {
|
|
216
|
+
user: taskParams.user,
|
|
217
|
+
tags: {
|
|
218
|
+
platform: package_namespaceObject.i8,
|
|
219
|
+
coreVersion
|
|
220
|
+
}
|
|
221
|
+
}
|
|
172
222
|
});
|
|
173
223
|
}
|
|
174
224
|
}
|
|
175
|
-
const sentry = new SentryInstance(process.env.RPA_SENTRY_DSN);
|
|
176
225
|
function logger_define_property(obj, key, value) {
|
|
177
226
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
178
227
|
value: value,
|
|
@@ -184,9 +233,8 @@ function logger_define_property(obj, key, value) {
|
|
|
184
233
|
return obj;
|
|
185
234
|
}
|
|
186
235
|
class Logger {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return Logger.instance;
|
|
236
|
+
updateCoreVersion(version) {
|
|
237
|
+
this.sentry.updateCoreVersion(version);
|
|
190
238
|
}
|
|
191
239
|
debug(...msg) {
|
|
192
240
|
external_loglevel_default().debug(...msg);
|
|
@@ -202,15 +250,16 @@ class Logger {
|
|
|
202
250
|
if (err instanceof Error) err.message = `${prefix}:${err.message}`;
|
|
203
251
|
if ("object" == typeof err) error = `${prefix}:${JSON.stringify(err)}`;
|
|
204
252
|
external_loglevel_default().error(error);
|
|
205
|
-
sentry.captureException(error);
|
|
253
|
+
this.sentry.captureException(error);
|
|
206
254
|
}
|
|
207
255
|
close() {
|
|
208
256
|
this.stream.end();
|
|
209
257
|
}
|
|
210
|
-
constructor(
|
|
258
|
+
constructor(taskParams, coreVersion){
|
|
211
259
|
logger_define_property(this, "stream", void 0);
|
|
212
|
-
|
|
213
|
-
|
|
260
|
+
logger_define_property(this, "sentry", void 0);
|
|
261
|
+
this.sentry = new SentryInstance(taskParams, coreVersion);
|
|
262
|
+
const logFile = external_node_path_default().join(taskParams.cachePath, "rpa.log");
|
|
214
263
|
(0, share_namespaceObject.ensureFileSync)(logFile);
|
|
215
264
|
this.stream = external_node_fs_default().createWriteStream(logFile, {
|
|
216
265
|
flags: "a"
|
|
@@ -229,44 +278,8 @@ class Logger {
|
|
|
229
278
|
logToFile(methodName, formattedMessage);
|
|
230
279
|
};
|
|
231
280
|
external_loglevel_default().setLevel(external_loglevel_default().getLevel());
|
|
232
|
-
Logger.instance = this;
|
|
233
281
|
}
|
|
234
282
|
}
|
|
235
|
-
logger_define_property(Logger, "instance", null);
|
|
236
|
-
const template = `
|
|
237
|
-
const { app } = require("electron");
|
|
238
|
-
|
|
239
|
-
app.whenReady().then(() => {});
|
|
240
|
-
|
|
241
|
-
app.on("window-all-closed", (e) => e.preventDefault());
|
|
242
|
-
`;
|
|
243
|
-
const generateFile = async (dir)=>{
|
|
244
|
-
const filePath = external_node_path_default().join(dir, "main.js");
|
|
245
|
-
const isPathExists = await (0, share_namespaceObject.pathExists)(filePath);
|
|
246
|
-
if (!isPathExists) {
|
|
247
|
-
await (0, share_namespaceObject.ensureFile)(filePath);
|
|
248
|
-
await (0, share_namespaceObject.writeFile)(filePath, template);
|
|
249
|
-
}
|
|
250
|
-
return filePath;
|
|
251
|
-
};
|
|
252
|
-
const launchElectronApp = async (cachePath, playwright, electronPath)=>{
|
|
253
|
-
const logger = Logger.getInstance(cachePath);
|
|
254
|
-
try {
|
|
255
|
-
const mainPath = await generateFile(cachePath);
|
|
256
|
-
const electronApp = await playwright._electron.launch({
|
|
257
|
-
executablePath: electronPath,
|
|
258
|
-
args: [
|
|
259
|
-
mainPath
|
|
260
|
-
],
|
|
261
|
-
cwd: cachePath
|
|
262
|
-
});
|
|
263
|
-
logger.info(`electron 启动成功:${electronPath} ${mainPath}`);
|
|
264
|
-
return electronApp;
|
|
265
|
-
} catch (error) {
|
|
266
|
-
logger.error("electron 启动失败:", error);
|
|
267
|
-
throw error;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
283
|
const pacote_namespaceObject = require("@iflyrpa/pacote");
|
|
271
284
|
var pacote_default = /*#__PURE__*/ __webpack_require__.n(pacote_namespaceObject);
|
|
272
285
|
function packageManager_define_property(obj, key, value) {
|
|
@@ -359,7 +372,7 @@ class Task {
|
|
|
359
372
|
this.playwrightPackage,
|
|
360
373
|
this.electronPackage
|
|
361
374
|
]);
|
|
362
|
-
this._electronApp = await launchElectronApp(this
|
|
375
|
+
this._electronApp = await launchElectronApp(this, playwright, electronPath);
|
|
363
376
|
}
|
|
364
377
|
return this._electronApp;
|
|
365
378
|
}
|
|
@@ -408,7 +421,10 @@ class Task {
|
|
|
408
421
|
]);
|
|
409
422
|
return page;
|
|
410
423
|
}
|
|
411
|
-
|
|
424
|
+
updateLogVersion(version) {
|
|
425
|
+
this.logger.updateCoreVersion(version);
|
|
426
|
+
}
|
|
427
|
+
constructor(taskParam, coreVersion){
|
|
412
428
|
task_define_property(this, "logger", void 0);
|
|
413
429
|
task_define_property(this, "cachePath", void 0);
|
|
414
430
|
task_define_property(this, "debug", void 0);
|
|
@@ -418,10 +434,10 @@ class Task {
|
|
|
418
434
|
task_define_property(this, "electronPackage", void 0);
|
|
419
435
|
task_define_property(this, "_electronApp", null);
|
|
420
436
|
task_define_property(this, "isClosed", false);
|
|
421
|
-
this.cachePath = cachePath;
|
|
422
|
-
this.packagesDir = external_node_path_default().join(cachePath, "packages");
|
|
423
|
-
this.debug = debug || false;
|
|
424
|
-
this.logger = Logger
|
|
437
|
+
this.cachePath = taskParam.cachePath;
|
|
438
|
+
this.packagesDir = external_node_path_default().join(taskParam.cachePath, "packages");
|
|
439
|
+
this.debug = taskParam.debug || false;
|
|
440
|
+
this.logger = new Logger(taskParam, coreVersion);
|
|
425
441
|
this.packageManager = new PackageManager(this);
|
|
426
442
|
this.playwrightPackage = this.installPlaywright();
|
|
427
443
|
this.electronPackage = this.installElectron();
|
|
@@ -440,16 +456,16 @@ function src_define_property(obj, key, value) {
|
|
|
440
456
|
class RpaTask extends Task {
|
|
441
457
|
async update() {
|
|
442
458
|
try {
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
|
|
459
|
+
const version = await this.packageManager.update(this.actionName);
|
|
460
|
+
const actionPackage = this.packageManager.require(`${this.actionName}@${version}`);
|
|
461
|
+
this.updateLogVersion(version);
|
|
446
462
|
(null == actionPackage ? void 0 : actionPackage.actions) && (this.actions = actionPackage.actions);
|
|
447
463
|
} catch (error) {
|
|
448
464
|
this.logger.error("更新依赖失败", error);
|
|
449
465
|
}
|
|
450
466
|
}
|
|
451
467
|
constructor(params){
|
|
452
|
-
super(params), src_define_property(this, "actions", void 0);
|
|
468
|
+
super(params, actions_namespaceObject.version), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions");
|
|
453
469
|
this.actions = new actions_namespaceObject.Action(this);
|
|
454
470
|
params.forceUpdate && this.update();
|
|
455
471
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,15 @@ import type { ElectronApplication } from '@iflyrpa/share';
|
|
|
5
5
|
import { LoggerImplement } from '@iflyrpa/share';
|
|
6
6
|
import { Page } from 'playwright-core';
|
|
7
7
|
import type { PageParams } from '@iflyrpa/share';
|
|
8
|
+
import { User } from '@sentry/node';
|
|
8
9
|
|
|
9
10
|
export { ActionMethodParams }
|
|
10
11
|
|
|
11
12
|
declare class Logger implements LoggerImplement {
|
|
12
|
-
static instance: Logger | null;
|
|
13
13
|
private stream;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
private sentry;
|
|
15
|
+
constructor(taskParams: TaskParams, coreVersion: string);
|
|
16
|
+
updateCoreVersion(version: string): void;
|
|
16
17
|
debug(...msg: any[]): void;
|
|
17
18
|
info(...msg: any[]): void;
|
|
18
19
|
warn(...msg: any[]): void;
|
|
@@ -32,6 +33,7 @@ declare class PackageManager {
|
|
|
32
33
|
|
|
33
34
|
export declare class RpaTask extends Task {
|
|
34
35
|
actions: Action;
|
|
36
|
+
private actionName;
|
|
35
37
|
constructor(params: TaskParams);
|
|
36
38
|
private update;
|
|
37
39
|
}
|
|
@@ -49,7 +51,7 @@ declare class Task implements AutomateTask {
|
|
|
49
51
|
* 应用是否已关闭
|
|
50
52
|
*/
|
|
51
53
|
isClosed: boolean;
|
|
52
|
-
constructor(
|
|
54
|
+
constructor(taskParam: TaskParams, coreVersion: string);
|
|
53
55
|
/**
|
|
54
56
|
* 安装 playwright
|
|
55
57
|
* @returns
|
|
@@ -80,12 +82,15 @@ declare class Task implements AutomateTask {
|
|
|
80
82
|
*/
|
|
81
83
|
close(): Promise<void>;
|
|
82
84
|
createPage(pageParams: PageParams): Promise<Page>;
|
|
85
|
+
updateLogVersion(version: string): void;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
declare interface TaskParams {
|
|
86
89
|
debug?: boolean;
|
|
87
90
|
cachePath: string;
|
|
88
91
|
forceUpdate?: boolean;
|
|
92
|
+
user?: User;
|
|
93
|
+
enverionment?: string;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
export declare const version: string;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_loglevel__ from "loglevel";
|
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE__sentry_node_4658624b__ from "@sentry/node";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_pacote_56da1cff__ from "@iflyrpa/pacote";
|
|
12
12
|
var package_namespaceObject = {
|
|
13
|
-
i8: "1.2.
|
|
13
|
+
i8: "1.2.4"
|
|
14
14
|
};
|
|
15
15
|
function _define_property(obj, key, value) {
|
|
16
16
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -99,6 +99,40 @@ class ElectronInstall {
|
|
|
99
99
|
this.electronPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(this.rootDir, this.platformPath);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
const template = `
|
|
103
|
+
const { app } = require("electron");
|
|
104
|
+
|
|
105
|
+
app.whenReady().then(() => {});
|
|
106
|
+
|
|
107
|
+
app.on("window-all-closed", (e) => e.preventDefault());
|
|
108
|
+
`;
|
|
109
|
+
const generateFile = async (dir)=>{
|
|
110
|
+
const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, "main.js");
|
|
111
|
+
const isPathExists = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.pathExists)(filePath);
|
|
112
|
+
if (!isPathExists) {
|
|
113
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.ensureFile)(filePath);
|
|
114
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.writeFile)(filePath, template);
|
|
115
|
+
}
|
|
116
|
+
return filePath;
|
|
117
|
+
};
|
|
118
|
+
const launchElectronApp = async (task, playwright, electronPath)=>{
|
|
119
|
+
const { logger, cachePath } = task;
|
|
120
|
+
try {
|
|
121
|
+
const mainPath = await generateFile(cachePath);
|
|
122
|
+
const electronApp = await playwright._electron.launch({
|
|
123
|
+
executablePath: electronPath,
|
|
124
|
+
args: [
|
|
125
|
+
mainPath
|
|
126
|
+
],
|
|
127
|
+
cwd: cachePath
|
|
128
|
+
});
|
|
129
|
+
logger.info(`electron 启动成功:${electronPath} ${mainPath}`);
|
|
130
|
+
return electronApp;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
logger.error("electron 启动失败:", error);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
102
136
|
function sentry_define_property(obj, key, value) {
|
|
103
137
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
104
138
|
value: value,
|
|
@@ -109,21 +143,35 @@ function sentry_define_property(obj, key, value) {
|
|
|
109
143
|
else obj[key] = value;
|
|
110
144
|
return obj;
|
|
111
145
|
}
|
|
146
|
+
const DEFAULT_SENTRY_DSN = "https://0ad25bf248b74b3d9950ff426c8e2240@bzrobottest.iflysec.com/6";
|
|
112
147
|
class SentryInstance {
|
|
148
|
+
updateCoreVersion(version) {
|
|
149
|
+
this.coreVersion = version;
|
|
150
|
+
}
|
|
113
151
|
captureException(error) {
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
__WEBPACK_EXTERNAL_MODULE__sentry_node_4658624b__["default"].withScope((scope)=>{
|
|
153
|
+
var _this_sentry;
|
|
154
|
+
scope.setTag("coreVersion", this.coreVersion);
|
|
155
|
+
null === (_this_sentry = this.sentry) || void 0 === _this_sentry || _this_sentry.captureException(error);
|
|
156
|
+
});
|
|
116
157
|
}
|
|
117
|
-
constructor(
|
|
158
|
+
constructor(taskParams, coreVersion){
|
|
118
159
|
sentry_define_property(this, "sentry", void 0);
|
|
119
|
-
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
|
|
160
|
+
sentry_define_property(this, "coreVersion", void 0);
|
|
161
|
+
this.coreVersion = coreVersion;
|
|
162
|
+
this.sentry = __WEBPACK_EXTERNAL_MODULE__sentry_node_4658624b__["default"].initWithoutDefaultIntegrations({
|
|
163
|
+
dsn: DEFAULT_SENTRY_DSN,
|
|
164
|
+
environment: taskParams.enverionment || "development",
|
|
165
|
+
initialScope: {
|
|
166
|
+
user: taskParams.user,
|
|
167
|
+
tags: {
|
|
168
|
+
platform: package_namespaceObject.i8,
|
|
169
|
+
coreVersion
|
|
170
|
+
}
|
|
171
|
+
}
|
|
123
172
|
});
|
|
124
173
|
}
|
|
125
174
|
}
|
|
126
|
-
const sentry = new SentryInstance(process.env.RPA_SENTRY_DSN);
|
|
127
175
|
function logger_define_property(obj, key, value) {
|
|
128
176
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
129
177
|
value: value,
|
|
@@ -135,9 +183,8 @@ function logger_define_property(obj, key, value) {
|
|
|
135
183
|
return obj;
|
|
136
184
|
}
|
|
137
185
|
class Logger {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return Logger.instance;
|
|
186
|
+
updateCoreVersion(version) {
|
|
187
|
+
this.sentry.updateCoreVersion(version);
|
|
141
188
|
}
|
|
142
189
|
debug(...msg) {
|
|
143
190
|
__WEBPACK_EXTERNAL_MODULE_loglevel__["default"].debug(...msg);
|
|
@@ -153,15 +200,16 @@ class Logger {
|
|
|
153
200
|
if (err instanceof Error) err.message = `${prefix}:${err.message}`;
|
|
154
201
|
if ("object" == typeof err) error = `${prefix}:${JSON.stringify(err)}`;
|
|
155
202
|
__WEBPACK_EXTERNAL_MODULE_loglevel__["default"].error(error);
|
|
156
|
-
sentry.captureException(error);
|
|
203
|
+
this.sentry.captureException(error);
|
|
157
204
|
}
|
|
158
205
|
close() {
|
|
159
206
|
this.stream.end();
|
|
160
207
|
}
|
|
161
|
-
constructor(
|
|
208
|
+
constructor(taskParams, coreVersion){
|
|
162
209
|
logger_define_property(this, "stream", void 0);
|
|
163
|
-
|
|
164
|
-
|
|
210
|
+
logger_define_property(this, "sentry", void 0);
|
|
211
|
+
this.sentry = new SentryInstance(taskParams, coreVersion);
|
|
212
|
+
const logFile = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(taskParams.cachePath, "rpa.log");
|
|
165
213
|
(0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.ensureFileSync)(logFile);
|
|
166
214
|
this.stream = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createWriteStream(logFile, {
|
|
167
215
|
flags: "a"
|
|
@@ -180,44 +228,8 @@ class Logger {
|
|
|
180
228
|
logToFile(methodName, formattedMessage);
|
|
181
229
|
};
|
|
182
230
|
__WEBPACK_EXTERNAL_MODULE_loglevel__["default"].setLevel(__WEBPACK_EXTERNAL_MODULE_loglevel__["default"].getLevel());
|
|
183
|
-
Logger.instance = this;
|
|
184
231
|
}
|
|
185
232
|
}
|
|
186
|
-
logger_define_property(Logger, "instance", null);
|
|
187
|
-
const template = `
|
|
188
|
-
const { app } = require("electron");
|
|
189
|
-
|
|
190
|
-
app.whenReady().then(() => {});
|
|
191
|
-
|
|
192
|
-
app.on("window-all-closed", (e) => e.preventDefault());
|
|
193
|
-
`;
|
|
194
|
-
const generateFile = async (dir)=>{
|
|
195
|
-
const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, "main.js");
|
|
196
|
-
const isPathExists = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.pathExists)(filePath);
|
|
197
|
-
if (!isPathExists) {
|
|
198
|
-
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.ensureFile)(filePath);
|
|
199
|
-
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.writeFile)(filePath, template);
|
|
200
|
-
}
|
|
201
|
-
return filePath;
|
|
202
|
-
};
|
|
203
|
-
const launchElectronApp = async (cachePath, playwright, electronPath)=>{
|
|
204
|
-
const logger = Logger.getInstance(cachePath);
|
|
205
|
-
try {
|
|
206
|
-
const mainPath = await generateFile(cachePath);
|
|
207
|
-
const electronApp = await playwright._electron.launch({
|
|
208
|
-
executablePath: electronPath,
|
|
209
|
-
args: [
|
|
210
|
-
mainPath
|
|
211
|
-
],
|
|
212
|
-
cwd: cachePath
|
|
213
|
-
});
|
|
214
|
-
logger.info(`electron 启动成功:${electronPath} ${mainPath}`);
|
|
215
|
-
return electronApp;
|
|
216
|
-
} catch (error) {
|
|
217
|
-
logger.error("electron 启动失败:", error);
|
|
218
|
-
throw error;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
233
|
function packageManager_define_property(obj, key, value) {
|
|
222
234
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
223
235
|
value: value,
|
|
@@ -308,7 +320,7 @@ class Task {
|
|
|
308
320
|
this.playwrightPackage,
|
|
309
321
|
this.electronPackage
|
|
310
322
|
]);
|
|
311
|
-
this._electronApp = await launchElectronApp(this
|
|
323
|
+
this._electronApp = await launchElectronApp(this, playwright, electronPath);
|
|
312
324
|
}
|
|
313
325
|
return this._electronApp;
|
|
314
326
|
}
|
|
@@ -357,7 +369,10 @@ class Task {
|
|
|
357
369
|
]);
|
|
358
370
|
return page;
|
|
359
371
|
}
|
|
360
|
-
|
|
372
|
+
updateLogVersion(version) {
|
|
373
|
+
this.logger.updateCoreVersion(version);
|
|
374
|
+
}
|
|
375
|
+
constructor(taskParam, coreVersion){
|
|
361
376
|
task_define_property(this, "logger", void 0);
|
|
362
377
|
task_define_property(this, "cachePath", void 0);
|
|
363
378
|
task_define_property(this, "debug", void 0);
|
|
@@ -367,10 +382,10 @@ class Task {
|
|
|
367
382
|
task_define_property(this, "electronPackage", void 0);
|
|
368
383
|
task_define_property(this, "_electronApp", null);
|
|
369
384
|
task_define_property(this, "isClosed", false);
|
|
370
|
-
this.cachePath = cachePath;
|
|
371
|
-
this.packagesDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(cachePath, "packages");
|
|
372
|
-
this.debug = debug || false;
|
|
373
|
-
this.logger = Logger
|
|
385
|
+
this.cachePath = taskParam.cachePath;
|
|
386
|
+
this.packagesDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(taskParam.cachePath, "packages");
|
|
387
|
+
this.debug = taskParam.debug || false;
|
|
388
|
+
this.logger = new Logger(taskParam, coreVersion);
|
|
374
389
|
this.packageManager = new PackageManager(this);
|
|
375
390
|
this.playwrightPackage = this.installPlaywright();
|
|
376
391
|
this.electronPackage = this.installElectron();
|
|
@@ -389,16 +404,16 @@ function src_define_property(obj, key, value) {
|
|
|
389
404
|
class RpaTask extends Task {
|
|
390
405
|
async update() {
|
|
391
406
|
try {
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
|
|
407
|
+
const version = await this.packageManager.update(this.actionName);
|
|
408
|
+
const actionPackage = this.packageManager.require(`${this.actionName}@${version}`);
|
|
409
|
+
this.updateLogVersion(version);
|
|
395
410
|
(null == actionPackage ? void 0 : actionPackage.actions) && (this.actions = actionPackage.actions);
|
|
396
411
|
} catch (error) {
|
|
397
412
|
this.logger.error("更新依赖失败", error);
|
|
398
413
|
}
|
|
399
414
|
}
|
|
400
415
|
constructor(params){
|
|
401
|
-
super(params), src_define_property(this, "actions", void 0);
|
|
416
|
+
super(params, __WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.version), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions");
|
|
402
417
|
this.actions = new __WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.Action(this);
|
|
403
418
|
params.forceUpdate && this.update();
|
|
404
419
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iflyrpa/playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@electron/get": "^2.0.0",
|
|
27
|
-
"@sentry/node": "^
|
|
27
|
+
"@sentry/node": "^9.2.0",
|
|
28
28
|
"extract-zip": "^2.0.1",
|
|
29
29
|
"loglevel": "^1.9.2",
|
|
30
30
|
"@iflyrpa/pacote": "1.0.0",
|
|
31
|
-
"@iflyrpa/actions": "1.1.
|
|
31
|
+
"@iflyrpa/actions": "1.1.11",
|
|
32
32
|
"@iflyrpa/share": "0.0.3"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|