@iflyrpa/playwright 1.0.15-beta.0 → 1.0.15-beta.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 +52 -17
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +52 -17
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const os = require('node:os');
|
|
|
8
8
|
const get = require('@electron/get');
|
|
9
9
|
const extract = require('extract-zip');
|
|
10
10
|
const log = require('loglevel');
|
|
11
|
+
const node = require('@sentry/node');
|
|
11
12
|
const livePluginManager = require('live-plugin-manager');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -22,7 +23,7 @@ const log__default = /*#__PURE__*/_interopDefaultCompat(log);
|
|
|
22
23
|
|
|
23
24
|
const name = "@iflyrpa/playwright";
|
|
24
25
|
const type = "module";
|
|
25
|
-
const version$1 = "1.0.15-beta.
|
|
26
|
+
const version$1 = "1.0.15-beta.1";
|
|
26
27
|
const main = "./dist/index.cjs";
|
|
27
28
|
const module$1 = "./dist/index.mjs";
|
|
28
29
|
const types = "./dist/index.d.ts";
|
|
@@ -38,6 +39,7 @@ const files = [
|
|
|
38
39
|
];
|
|
39
40
|
const dependencies = {
|
|
40
41
|
"@electron/get": "^2.0.0",
|
|
42
|
+
"@sentry/node": "^5.5.0",
|
|
41
43
|
"extract-zip": "^2.0.1",
|
|
42
44
|
"live-plugin-manager": "^1.0.0",
|
|
43
45
|
loglevel: "^1.9.2"
|
|
@@ -265,7 +267,7 @@ const xiaohongshuPublishAction = async (props) => {
|
|
|
265
267
|
await page.getByRole("textbox").click();
|
|
266
268
|
const fileChooser = await fileChooserPromise;
|
|
267
269
|
await fileChooser.setFiles(images);
|
|
268
|
-
const titleInstance = page.locator(".titleInput input");
|
|
270
|
+
const titleInstance = page.locator(".input.titleInput input");
|
|
269
271
|
await titleInstance.click();
|
|
270
272
|
await titleInstance.fill(params.title);
|
|
271
273
|
const descInstance = page.locator("#post-textarea");
|
|
@@ -348,19 +350,20 @@ const xiaohongshuPublishAction = async (props) => {
|
|
|
348
350
|
return response;
|
|
349
351
|
};
|
|
350
352
|
|
|
351
|
-
var __defProp$
|
|
352
|
-
var __defNormalProp$
|
|
353
|
-
var __publicField$
|
|
354
|
-
__defNormalProp$
|
|
353
|
+
var __defProp$4 = Object.defineProperty;
|
|
354
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
355
|
+
var __publicField$4 = (obj, key, value) => {
|
|
356
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
355
357
|
return value;
|
|
356
358
|
};
|
|
359
|
+
const ELECTRON_MIRROR = "http://npmmirror.com/mirrors/electron/";
|
|
357
360
|
class ElectronInstall {
|
|
358
361
|
constructor(rootDir, version, logger) {
|
|
359
362
|
this.rootDir = rootDir;
|
|
360
363
|
this.version = version;
|
|
361
364
|
this.logger = logger;
|
|
362
|
-
__publicField$
|
|
363
|
-
__publicField$
|
|
365
|
+
__publicField$4(this, "electronPath");
|
|
366
|
+
__publicField$4(this, "platformPath");
|
|
364
367
|
this.platformPath = this.getPlatformPath();
|
|
365
368
|
this.electronPath = path__default.join(rootDir, this.platformPath);
|
|
366
369
|
}
|
|
@@ -419,6 +422,8 @@ class ElectronInstall {
|
|
|
419
422
|
force: process.env.force_no_cache === "true",
|
|
420
423
|
cacheRoot: process.env.electron_config_cache,
|
|
421
424
|
checksums: void 0,
|
|
425
|
+
mirrorOptions: { mirror: ELECTRON_MIRROR },
|
|
426
|
+
// 使用国内镜像下载
|
|
422
427
|
platform,
|
|
423
428
|
arch
|
|
424
429
|
});
|
|
@@ -434,6 +439,28 @@ class ElectronInstall {
|
|
|
434
439
|
}
|
|
435
440
|
}
|
|
436
441
|
|
|
442
|
+
var __defProp$3 = Object.defineProperty;
|
|
443
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
444
|
+
var __publicField$3 = (obj, key, value) => {
|
|
445
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
446
|
+
return value;
|
|
447
|
+
};
|
|
448
|
+
class SentryInstance {
|
|
449
|
+
constructor(dsn) {
|
|
450
|
+
__publicField$3(this, "sentry");
|
|
451
|
+
if (!dsn)
|
|
452
|
+
return;
|
|
453
|
+
this.sentry = new node.NodeClient({
|
|
454
|
+
dsn,
|
|
455
|
+
defaultIntegrations: false
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
captureException(error) {
|
|
459
|
+
this.sentry?.captureException(error);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
const sentry = new SentryInstance(process.env.RPA_SENTRY_DSN);
|
|
463
|
+
|
|
437
464
|
var __defProp$2 = Object.defineProperty;
|
|
438
465
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
439
466
|
var __publicField$2 = (obj, key, value) => {
|
|
@@ -452,7 +479,7 @@ const _Logger = class _Logger {
|
|
|
452
479
|
log__default.methodFactory = (methodName) => {
|
|
453
480
|
return (message) => {
|
|
454
481
|
this.stream.write(
|
|
455
|
-
`[${( new Date()).
|
|
482
|
+
`[${( new Date()).toLocaleString()}] ${methodName.toUpperCase()}: ${message}
|
|
456
483
|
`
|
|
457
484
|
);
|
|
458
485
|
};
|
|
@@ -478,12 +505,14 @@ const _Logger = class _Logger {
|
|
|
478
505
|
warn(...msg) {
|
|
479
506
|
log__default.warn(...msg);
|
|
480
507
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
508
|
+
// error 级别的日志上报 sentry
|
|
509
|
+
error(prefix, err) {
|
|
510
|
+
const error = err || prefix;
|
|
511
|
+
if (err instanceof Error) {
|
|
512
|
+
err.message = `${prefix}\uFF1A${err.message}`;
|
|
486
513
|
}
|
|
514
|
+
log__default.error(error);
|
|
515
|
+
sentry.captureException(error);
|
|
487
516
|
}
|
|
488
517
|
close() {
|
|
489
518
|
this.stream.end();
|
|
@@ -638,6 +667,10 @@ class LocalAutomateTask {
|
|
|
638
667
|
__publicField(this, "playwrightPackage");
|
|
639
668
|
__publicField(this, "electronPackage");
|
|
640
669
|
__publicField(this, "_electronApp", null);
|
|
670
|
+
/**
|
|
671
|
+
* 应用是否已关闭
|
|
672
|
+
*/
|
|
673
|
+
__publicField(this, "isClosed", false);
|
|
641
674
|
this.cachePath = cachePath;
|
|
642
675
|
this.debug = debug || false;
|
|
643
676
|
this.logger = Logger.getInstance(cachePath);
|
|
@@ -712,10 +745,12 @@ class LocalAutomateTask {
|
|
|
712
745
|
* @returns
|
|
713
746
|
*/
|
|
714
747
|
async close() {
|
|
715
|
-
this.logger.
|
|
748
|
+
this.logger.info("\u5173\u95ED\u5E94\u7528");
|
|
716
749
|
this.clearTmpPath();
|
|
717
|
-
|
|
718
|
-
|
|
750
|
+
this.logger.close();
|
|
751
|
+
await this._electronApp?.close();
|
|
752
|
+
this.isClosed = true;
|
|
753
|
+
this._electronApp = null;
|
|
719
754
|
}
|
|
720
755
|
/**
|
|
721
756
|
* 小红书自动化发布
|
package/dist/index.d.cts
CHANGED
|
@@ -95,6 +95,10 @@ declare class LocalAutomateTask implements TaskParams {
|
|
|
95
95
|
private playwrightPackage;
|
|
96
96
|
private electronPackage;
|
|
97
97
|
private _electronApp;
|
|
98
|
+
/**
|
|
99
|
+
* 应用是否已关闭
|
|
100
|
+
*/
|
|
101
|
+
isClosed: boolean;
|
|
98
102
|
constructor({ cachePath, debug }: TaskParams);
|
|
99
103
|
/**
|
|
100
104
|
* 安装 playwright
|
package/dist/index.d.mts
CHANGED
|
@@ -95,6 +95,10 @@ declare class LocalAutomateTask implements TaskParams {
|
|
|
95
95
|
private playwrightPackage;
|
|
96
96
|
private electronPackage;
|
|
97
97
|
private _electronApp;
|
|
98
|
+
/**
|
|
99
|
+
* 应用是否已关闭
|
|
100
|
+
*/
|
|
101
|
+
isClosed: boolean;
|
|
98
102
|
constructor({ cachePath, debug }: TaskParams);
|
|
99
103
|
/**
|
|
100
104
|
* 安装 playwright
|
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,10 @@ declare class LocalAutomateTask implements TaskParams {
|
|
|
95
95
|
private playwrightPackage;
|
|
96
96
|
private electronPackage;
|
|
97
97
|
private _electronApp;
|
|
98
|
+
/**
|
|
99
|
+
* 应用是否已关闭
|
|
100
|
+
*/
|
|
101
|
+
isClosed: boolean;
|
|
98
102
|
constructor({ cachePath, debug }: TaskParams);
|
|
99
103
|
/**
|
|
100
104
|
* 安装 playwright
|
package/dist/index.mjs
CHANGED
|
@@ -6,11 +6,12 @@ import os from 'node:os';
|
|
|
6
6
|
import { downloadArtifact } from '@electron/get';
|
|
7
7
|
import extract from 'extract-zip';
|
|
8
8
|
import log from 'loglevel';
|
|
9
|
+
import { NodeClient } from '@sentry/node';
|
|
9
10
|
import { PluginManager } from 'live-plugin-manager';
|
|
10
11
|
|
|
11
12
|
const name = "@iflyrpa/playwright";
|
|
12
13
|
const type = "module";
|
|
13
|
-
const version$1 = "1.0.15-beta.
|
|
14
|
+
const version$1 = "1.0.15-beta.1";
|
|
14
15
|
const main = "./dist/index.cjs";
|
|
15
16
|
const module = "./dist/index.mjs";
|
|
16
17
|
const types = "./dist/index.d.ts";
|
|
@@ -26,6 +27,7 @@ const files = [
|
|
|
26
27
|
];
|
|
27
28
|
const dependencies = {
|
|
28
29
|
"@electron/get": "^2.0.0",
|
|
30
|
+
"@sentry/node": "^5.5.0",
|
|
29
31
|
"extract-zip": "^2.0.1",
|
|
30
32
|
"live-plugin-manager": "^1.0.0",
|
|
31
33
|
loglevel: "^1.9.2"
|
|
@@ -253,7 +255,7 @@ const xiaohongshuPublishAction = async (props) => {
|
|
|
253
255
|
await page.getByRole("textbox").click();
|
|
254
256
|
const fileChooser = await fileChooserPromise;
|
|
255
257
|
await fileChooser.setFiles(images);
|
|
256
|
-
const titleInstance = page.locator(".titleInput input");
|
|
258
|
+
const titleInstance = page.locator(".input.titleInput input");
|
|
257
259
|
await titleInstance.click();
|
|
258
260
|
await titleInstance.fill(params.title);
|
|
259
261
|
const descInstance = page.locator("#post-textarea");
|
|
@@ -336,19 +338,20 @@ const xiaohongshuPublishAction = async (props) => {
|
|
|
336
338
|
return response;
|
|
337
339
|
};
|
|
338
340
|
|
|
339
|
-
var __defProp$
|
|
340
|
-
var __defNormalProp$
|
|
341
|
-
var __publicField$
|
|
342
|
-
__defNormalProp$
|
|
341
|
+
var __defProp$4 = Object.defineProperty;
|
|
342
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
343
|
+
var __publicField$4 = (obj, key, value) => {
|
|
344
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
343
345
|
return value;
|
|
344
346
|
};
|
|
347
|
+
const ELECTRON_MIRROR = "http://npmmirror.com/mirrors/electron/";
|
|
345
348
|
class ElectronInstall {
|
|
346
349
|
constructor(rootDir, version, logger) {
|
|
347
350
|
this.rootDir = rootDir;
|
|
348
351
|
this.version = version;
|
|
349
352
|
this.logger = logger;
|
|
350
|
-
__publicField$
|
|
351
|
-
__publicField$
|
|
353
|
+
__publicField$4(this, "electronPath");
|
|
354
|
+
__publicField$4(this, "platformPath");
|
|
352
355
|
this.platformPath = this.getPlatformPath();
|
|
353
356
|
this.electronPath = path.join(rootDir, this.platformPath);
|
|
354
357
|
}
|
|
@@ -407,6 +410,8 @@ class ElectronInstall {
|
|
|
407
410
|
force: process.env.force_no_cache === "true",
|
|
408
411
|
cacheRoot: process.env.electron_config_cache,
|
|
409
412
|
checksums: void 0,
|
|
413
|
+
mirrorOptions: { mirror: ELECTRON_MIRROR },
|
|
414
|
+
// 使用国内镜像下载
|
|
410
415
|
platform,
|
|
411
416
|
arch
|
|
412
417
|
});
|
|
@@ -422,6 +427,28 @@ class ElectronInstall {
|
|
|
422
427
|
}
|
|
423
428
|
}
|
|
424
429
|
|
|
430
|
+
var __defProp$3 = Object.defineProperty;
|
|
431
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
432
|
+
var __publicField$3 = (obj, key, value) => {
|
|
433
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
434
|
+
return value;
|
|
435
|
+
};
|
|
436
|
+
class SentryInstance {
|
|
437
|
+
constructor(dsn) {
|
|
438
|
+
__publicField$3(this, "sentry");
|
|
439
|
+
if (!dsn)
|
|
440
|
+
return;
|
|
441
|
+
this.sentry = new NodeClient({
|
|
442
|
+
dsn,
|
|
443
|
+
defaultIntegrations: false
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
captureException(error) {
|
|
447
|
+
this.sentry?.captureException(error);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const sentry = new SentryInstance(process.env.RPA_SENTRY_DSN);
|
|
451
|
+
|
|
425
452
|
var __defProp$2 = Object.defineProperty;
|
|
426
453
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
427
454
|
var __publicField$2 = (obj, key, value) => {
|
|
@@ -440,7 +467,7 @@ const _Logger = class _Logger {
|
|
|
440
467
|
log.methodFactory = (methodName) => {
|
|
441
468
|
return (message) => {
|
|
442
469
|
this.stream.write(
|
|
443
|
-
`[${( new Date()).
|
|
470
|
+
`[${( new Date()).toLocaleString()}] ${methodName.toUpperCase()}: ${message}
|
|
444
471
|
`
|
|
445
472
|
);
|
|
446
473
|
};
|
|
@@ -466,12 +493,14 @@ const _Logger = class _Logger {
|
|
|
466
493
|
warn(...msg) {
|
|
467
494
|
log.warn(...msg);
|
|
468
495
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
496
|
+
// error 级别的日志上报 sentry
|
|
497
|
+
error(prefix, err) {
|
|
498
|
+
const error = err || prefix;
|
|
499
|
+
if (err instanceof Error) {
|
|
500
|
+
err.message = `${prefix}\uFF1A${err.message}`;
|
|
474
501
|
}
|
|
502
|
+
log.error(error);
|
|
503
|
+
sentry.captureException(error);
|
|
475
504
|
}
|
|
476
505
|
close() {
|
|
477
506
|
this.stream.end();
|
|
@@ -626,6 +655,10 @@ class LocalAutomateTask {
|
|
|
626
655
|
__publicField(this, "playwrightPackage");
|
|
627
656
|
__publicField(this, "electronPackage");
|
|
628
657
|
__publicField(this, "_electronApp", null);
|
|
658
|
+
/**
|
|
659
|
+
* 应用是否已关闭
|
|
660
|
+
*/
|
|
661
|
+
__publicField(this, "isClosed", false);
|
|
629
662
|
this.cachePath = cachePath;
|
|
630
663
|
this.debug = debug || false;
|
|
631
664
|
this.logger = Logger.getInstance(cachePath);
|
|
@@ -700,10 +733,12 @@ class LocalAutomateTask {
|
|
|
700
733
|
* @returns
|
|
701
734
|
*/
|
|
702
735
|
async close() {
|
|
703
|
-
this.logger.
|
|
736
|
+
this.logger.info("\u5173\u95ED\u5E94\u7528");
|
|
704
737
|
this.clearTmpPath();
|
|
705
|
-
|
|
706
|
-
|
|
738
|
+
this.logger.close();
|
|
739
|
+
await this._electronApp?.close();
|
|
740
|
+
this.isClosed = true;
|
|
741
|
+
this._electronApp = null;
|
|
707
742
|
}
|
|
708
743
|
/**
|
|
709
744
|
* 小红书自动化发布
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iflyrpa/playwright",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.15-beta.
|
|
4
|
+
"version": "1.0.15-beta.1",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"files": ["dist"],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@electron/get": "^2.0.0",
|
|
18
|
+
"@sentry/node": "^5.5.0",
|
|
18
19
|
"extract-zip": "^2.0.1",
|
|
19
20
|
"live-plugin-manager": "^1.0.0",
|
|
20
21
|
"loglevel": "^1.9.2"
|