@iflyrpa/playwright 4.0.8 → 4.0.9-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 +110 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +110 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,34 @@ import { User } from '@sentry/node';
|
|
|
10
10
|
|
|
11
11
|
export { ActionMethodParams }
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* 脚本包(@iflyrpa/actions)的版本状态
|
|
15
|
+
*/
|
|
16
|
+
export declare interface ActionVersionInfo {
|
|
17
|
+
/** 当前内存中实际生效的版本 */
|
|
18
|
+
current: string;
|
|
19
|
+
/** 随 @iflyrpa/playwright 一起打包的内置版本 */
|
|
20
|
+
bundled: string;
|
|
21
|
+
/** 远端 registry 上对应渠道的最新版本,未查询成功时为 null */
|
|
22
|
+
latest: string | null;
|
|
23
|
+
/** 远端存在更新且尚未生效(current !== latest) */
|
|
24
|
+
hasUpdate: boolean;
|
|
25
|
+
/** 更新已下载并热替换成功,无需重启 */
|
|
26
|
+
applied: boolean;
|
|
27
|
+
/** 本次查询使用的渠道:beta 由 GrowthBook 灰度开关决定 */
|
|
28
|
+
channel: "latest" | "beta";
|
|
29
|
+
/** 更新流程失败时的原因 */
|
|
30
|
+
error?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 比较两个 semver 版本,a 比 b 新返回正数
|
|
35
|
+
*
|
|
36
|
+
* 只覆盖本仓库用到的 `x.y.z` 和 `x.y.z-beta.n` 两种形态,
|
|
37
|
+
* 按 semver 规则 prerelease 小于同版本号的正式版。
|
|
38
|
+
*/
|
|
39
|
+
export declare function compareVersion(a: string, b: string): number;
|
|
40
|
+
|
|
13
41
|
declare class Logger extends SentryInstance implements LoggerImplement {
|
|
14
42
|
private stream;
|
|
15
43
|
constructor(taskParams: TaskParams);
|
|
@@ -27,14 +55,64 @@ declare class PackageManager {
|
|
|
27
55
|
private extract;
|
|
28
56
|
require(module: string): any;
|
|
29
57
|
install(name: string, version: string): Promise<void>;
|
|
30
|
-
|
|
58
|
+
/**
|
|
59
|
+
* 查询远端指定 dist-tag 的版本号(只读,不下载)
|
|
60
|
+
*
|
|
61
|
+
* distTag 缺失时(比如从未发过 beta)回退到 latest,不阻断更新。
|
|
62
|
+
*/
|
|
63
|
+
getVersionByTag(name: string, distTag?: string): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* 查询远端应当使用的版本号(只读,不下载)
|
|
66
|
+
*
|
|
67
|
+
* beta 渠道取 beta 与 latest 的较大值:beta tag 可能落后于正式版
|
|
68
|
+
* (正式版发布后 beta tag 不会自动前移),此时不应让灰度用户降级。
|
|
69
|
+
*/
|
|
70
|
+
getLatestVersion(name: string, useBeta?: boolean): Promise<string>;
|
|
71
|
+
update(name: string, useBeta?: boolean): Promise<string>;
|
|
31
72
|
}
|
|
32
73
|
|
|
33
74
|
export declare class RpaTask extends Task {
|
|
34
75
|
actions: RpaAction.Action;
|
|
35
76
|
private actionName;
|
|
77
|
+
/** 内置版本,热更新失败时的回退基线 */
|
|
78
|
+
private readonly bundledActionVersion;
|
|
79
|
+
/** 内存中实际生效的版本 */
|
|
80
|
+
private currentActionVersion;
|
|
81
|
+
private latestActionVersion;
|
|
82
|
+
private appliedUpdate;
|
|
83
|
+
private updateChannel;
|
|
84
|
+
private updateError?;
|
|
85
|
+
/** 构造函数触发的更新任务,供 waitForUpdate 复用,避免重复请求 */
|
|
86
|
+
private updateTask;
|
|
36
87
|
constructor(params: TaskParams);
|
|
37
88
|
private registerActions;
|
|
89
|
+
/**
|
|
90
|
+
* 脚本包版本状态快照(同步,不发起网络请求)
|
|
91
|
+
*
|
|
92
|
+
* 第三方可用它与自己记录的版本比对,决定是否提示重启。
|
|
93
|
+
* 注意:applied 为 true 时更新已在内存中生效,无需重启。
|
|
94
|
+
*/
|
|
95
|
+
getActionVersionInfo(): ActionVersionInfo;
|
|
96
|
+
/**
|
|
97
|
+
* 当前用户是否走灰度渠道
|
|
98
|
+
*
|
|
99
|
+
* 取决于 GrowthBook 的 HuiwenCanary 开关,未初始化时返回 false(走正式渠道)。
|
|
100
|
+
* 注意 GrowthBook 依赖 setUser 才会初始化,未调用 setUser 的场景恒为正式渠道。
|
|
101
|
+
*/
|
|
102
|
+
private useBetaChannel;
|
|
103
|
+
/**
|
|
104
|
+
* 只查询远端最新版本号,不下载、不替换
|
|
105
|
+
*
|
|
106
|
+
* 适合"启动时静默检查有没有新版本"的场景。
|
|
107
|
+
*/
|
|
108
|
+
checkActionUpdate(): Promise<ActionVersionInfo>;
|
|
109
|
+
/**
|
|
110
|
+
* 等待构造函数触发的更新流程结束,返回最终版本状态
|
|
111
|
+
*
|
|
112
|
+
* forceUpdate 为 false 时会主动执行一次更新。
|
|
113
|
+
* 多次调用复用同一个任务,不会重复下载。
|
|
114
|
+
*/
|
|
115
|
+
waitForActionUpdate(): Promise<ActionVersionInfo>;
|
|
38
116
|
private update;
|
|
39
117
|
}
|
|
40
118
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7135424a-8b43-5186-b3bf-add32278e972")}catch(e){}}();
|
|
3
1
|
import * as __WEBPACK_EXTERNAL_MODULE_punycode__ from "punycode";
|
|
4
2
|
import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
|
|
5
3
|
import * as __WEBPACK_EXTERNAL_MODULE_http__ from "http";
|
|
@@ -2552,9 +2550,7 @@ function __webpack_require__(moduleId) {
|
|
|
2552
2550
|
});
|
|
2553
2551
|
};
|
|
2554
2552
|
})();
|
|
2555
|
-
var package_namespaceObject = {
|
|
2556
|
-
i8: "4.0.8"
|
|
2557
|
-
};
|
|
2553
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.1"}');
|
|
2558
2554
|
function _define_property(obj, key, value) {
|
|
2559
2555
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
2560
2556
|
value: value,
|
|
@@ -5363,10 +5359,45 @@ function packageManager_define_property(obj, key, value) {
|
|
|
5363
5359
|
return obj;
|
|
5364
5360
|
}
|
|
5365
5361
|
const NPM_REGISTRY = "https://registry.npmmirror.com/";
|
|
5362
|
+
const LATEST_TAG = "latest";
|
|
5363
|
+
const BETA_TAG = "beta";
|
|
5364
|
+
function compareVersion(a, b) {
|
|
5365
|
+
const parse = (v)=>{
|
|
5366
|
+
const [core, pre] = v.split("-");
|
|
5367
|
+
const nums = core.split(".").map(Number);
|
|
5368
|
+
return {
|
|
5369
|
+
nums,
|
|
5370
|
+
pre
|
|
5371
|
+
};
|
|
5372
|
+
};
|
|
5373
|
+
const va = parse(a);
|
|
5374
|
+
const vb = parse(b);
|
|
5375
|
+
for(let i = 0; i < 3; i++){
|
|
5376
|
+
const diff = (va.nums[i] ?? 0) - (vb.nums[i] ?? 0);
|
|
5377
|
+
if (0 !== diff) return diff;
|
|
5378
|
+
}
|
|
5379
|
+
if (!va.pre && !vb.pre) return 0;
|
|
5380
|
+
if (!va.pre) return 1;
|
|
5381
|
+
if (!vb.pre) return -1;
|
|
5382
|
+
const pa = va.pre.split(".");
|
|
5383
|
+
const pb = vb.pre.split(".");
|
|
5384
|
+
for(let i = 0; i < Math.max(pa.length, pb.length); i++){
|
|
5385
|
+
const sa = pa[i];
|
|
5386
|
+
const sb = pb[i];
|
|
5387
|
+
if (void 0 === sa) return -1;
|
|
5388
|
+
if (void 0 === sb) return 1;
|
|
5389
|
+
const na = Number(sa);
|
|
5390
|
+
const nb = Number(sb);
|
|
5391
|
+
const bothNumeric = !Number.isNaN(na) && !Number.isNaN(nb);
|
|
5392
|
+
const diff = bothNumeric ? na - nb : sa.localeCompare(sb);
|
|
5393
|
+
if (0 !== diff) return diff;
|
|
5394
|
+
}
|
|
5395
|
+
return 0;
|
|
5396
|
+
}
|
|
5366
5397
|
class PackageManager {
|
|
5367
5398
|
async getManifest(module) {
|
|
5368
5399
|
try {
|
|
5369
|
-
return __WEBPACK_EXTERNAL_MODULE__iflyrpa_pacote_56da1cff__["default"].manifest(module, {
|
|
5400
|
+
return await __WEBPACK_EXTERNAL_MODULE__iflyrpa_pacote_56da1cff__["default"].manifest(module, {
|
|
5370
5401
|
registry: NPM_REGISTRY
|
|
5371
5402
|
});
|
|
5372
5403
|
} catch (error) {
|
|
@@ -5397,9 +5428,25 @@ class PackageManager {
|
|
|
5397
5428
|
const plugin = this.require(packageName);
|
|
5398
5429
|
if (!plugin) await this.extract(name, version);
|
|
5399
5430
|
}
|
|
5400
|
-
async
|
|
5401
|
-
|
|
5402
|
-
|
|
5431
|
+
async getVersionByTag(name, distTag = LATEST_TAG) {
|
|
5432
|
+
try {
|
|
5433
|
+
const manifest = await this.getManifest(`${name}@${distTag}`);
|
|
5434
|
+
return manifest.version;
|
|
5435
|
+
} catch (error) {
|
|
5436
|
+
if (distTag === LATEST_TAG) throw error;
|
|
5437
|
+
this.task.logger.warn(`${name}@${distTag} 不存在,回退到 ${LATEST_TAG}`);
|
|
5438
|
+
const manifest = await this.getManifest(`${name}@${LATEST_TAG}`);
|
|
5439
|
+
return manifest.version;
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
async getLatestVersion(name, useBeta = false) {
|
|
5443
|
+
const latest = await this.getVersionByTag(name, LATEST_TAG);
|
|
5444
|
+
if (!useBeta) return latest;
|
|
5445
|
+
const beta = await this.getVersionByTag(name, BETA_TAG);
|
|
5446
|
+
return compareVersion(beta, latest) > 0 ? beta : latest;
|
|
5447
|
+
}
|
|
5448
|
+
async update(name, useBeta = false) {
|
|
5449
|
+
const version = await this.getLatestVersion(name, useBeta);
|
|
5403
5450
|
const plugin = this.require(`${name}@${version}/package.json`);
|
|
5404
5451
|
if (!plugin) await this.extract(name, version);
|
|
5405
5452
|
return version;
|
|
@@ -5628,25 +5675,72 @@ function src_define_property(obj, key, value) {
|
|
|
5628
5675
|
class RpaTask extends Task {
|
|
5629
5676
|
registerActions(rpaAction) {
|
|
5630
5677
|
this.actions = new rpaAction.Action(this);
|
|
5678
|
+
this.currentActionVersion = rpaAction.version;
|
|
5631
5679
|
this.setActionVersion(rpaAction.version);
|
|
5632
5680
|
}
|
|
5681
|
+
getActionVersionInfo() {
|
|
5682
|
+
return {
|
|
5683
|
+
current: this.currentActionVersion,
|
|
5684
|
+
bundled: this.bundledActionVersion,
|
|
5685
|
+
latest: this.latestActionVersion,
|
|
5686
|
+
hasUpdate: !!this.latestActionVersion && this.latestActionVersion !== this.currentActionVersion,
|
|
5687
|
+
applied: this.appliedUpdate,
|
|
5688
|
+
channel: this.updateChannel,
|
|
5689
|
+
error: this.updateError
|
|
5690
|
+
};
|
|
5691
|
+
}
|
|
5692
|
+
useBetaChannel() {
|
|
5693
|
+
const useBeta = this.isFeatOn(__WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.BetaFlag);
|
|
5694
|
+
this.updateChannel = useBeta ? "beta" : "latest";
|
|
5695
|
+
return useBeta;
|
|
5696
|
+
}
|
|
5697
|
+
async checkActionUpdate() {
|
|
5698
|
+
try {
|
|
5699
|
+
this.latestActionVersion = await this.packageManager.getLatestVersion(this.actionName, this.useBetaChannel());
|
|
5700
|
+
this.updateError = void 0;
|
|
5701
|
+
} catch (error) {
|
|
5702
|
+
this.updateError = error instanceof Error ? error.message : String(error);
|
|
5703
|
+
this.logger.error("检查脚本版本失败", error);
|
|
5704
|
+
}
|
|
5705
|
+
return this.getActionVersionInfo();
|
|
5706
|
+
}
|
|
5707
|
+
waitForActionUpdate() {
|
|
5708
|
+
if (!this.updateTask) this.updateTask = this.update();
|
|
5709
|
+
return this.updateTask;
|
|
5710
|
+
}
|
|
5633
5711
|
async update() {
|
|
5634
5712
|
try {
|
|
5635
|
-
const version = await this.packageManager.update(this.actionName);
|
|
5713
|
+
const version = await this.packageManager.update(this.actionName, this.useBetaChannel());
|
|
5714
|
+
this.latestActionVersion = version;
|
|
5715
|
+
if (version === this.currentActionVersion) {
|
|
5716
|
+
this.appliedUpdate = false;
|
|
5717
|
+
return this.getActionVersionInfo();
|
|
5718
|
+
}
|
|
5636
5719
|
const rpaPackage = this.packageManager.require(`${this.actionName}@${version}/dist/bundle.js`);
|
|
5637
|
-
(null == rpaPackage ? void 0 : rpaPackage.Action)
|
|
5720
|
+
if (null == rpaPackage ? void 0 : rpaPackage.Action) {
|
|
5721
|
+
this.registerActions(rpaPackage);
|
|
5722
|
+
this.appliedUpdate = true;
|
|
5723
|
+
this.updateError = void 0;
|
|
5724
|
+
this.logger.info(`脚本已热更新至 ${version}`);
|
|
5725
|
+
} else {
|
|
5726
|
+
this.appliedUpdate = false;
|
|
5727
|
+
this.updateError = `加载 ${this.actionName}@${version} 失败`;
|
|
5728
|
+
this.logger.warn(this.updateError);
|
|
5729
|
+
}
|
|
5638
5730
|
} catch (error) {
|
|
5731
|
+
this.appliedUpdate = false;
|
|
5732
|
+
this.updateError = error instanceof Error ? error.message : String(error);
|
|
5639
5733
|
this.logger.error("更新依赖失败", error);
|
|
5640
5734
|
}
|
|
5735
|
+
return this.getActionVersionInfo();
|
|
5641
5736
|
}
|
|
5642
5737
|
constructor(params){
|
|
5643
|
-
super(params), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions");
|
|
5738
|
+
super(params), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions"), src_define_property(this, "bundledActionVersion", __WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.version), src_define_property(this, "currentActionVersion", __WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.version), src_define_property(this, "latestActionVersion", null), src_define_property(this, "appliedUpdate", false), src_define_property(this, "updateChannel", "latest"), src_define_property(this, "updateError", void 0), src_define_property(this, "updateTask", null);
|
|
5644
5739
|
this.registerActions(__WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__);
|
|
5645
|
-
params.forceUpdate
|
|
5740
|
+
if (params.forceUpdate) this.updateTask = this.update();
|
|
5646
5741
|
}
|
|
5647
5742
|
}
|
|
5648
5743
|
const src_version = package_namespaceObject.i8;
|
|
5649
|
-
export { RpaTask, src_version as version };
|
|
5744
|
+
export { RpaTask, compareVersion, src_version as version };
|
|
5650
5745
|
|
|
5651
|
-
//# sourceMappingURL=index.js.map
|
|
5652
|
-
//# debugId=7135424a-8b43-5186-b3bf-add32278e972
|
|
5746
|
+
//# sourceMappingURL=index.js.map
|