@iflyrpa/playwright 4.0.9-beta.4 → 4.0.9

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.d.ts CHANGED
@@ -10,90 +10,6 @@ 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
-
41
- /**
42
- * 获取最新版本记录
43
- *
44
- * @returns 最新的版本记录,无历史记录时返回 null
45
- */
46
- export declare function getLatestVersionRecord(): VersionRecord | null;
47
-
48
- /**
49
- * 取一组版本记录中的最高价值等级
50
- *
51
- * 跨多个版本升级时,应按其中最严格的等级决定更新策略:
52
- * 只要期间有过一个 LEVEL_2 版本,就必须强制更新重启。
53
- *
54
- * @returns 最高等级,records 为空时返回 null
55
- */
56
- export declare function getMaxUpdateLevel(records: VersionRecord[]): UpdateLevel | null;
57
-
58
- /**
59
- * 获取版本历史信息
60
- *
61
- * 数据来自随包发布的 version-history.json,同步返回,不发起网络请求。
62
- *
63
- * @example
64
- * ```typescript
65
- * import { getVersionHistory } from "@iflyrpa/playwright";
66
- *
67
- * const history = getVersionHistory();
68
- * console.log("当前版本:", history.currentVersion);
69
- * ```
70
- */
71
- export declare function getVersionHistory(): VersionHistory;
72
-
73
- /**
74
- * 获取指定版本的详细信息
75
- *
76
- * @param version - 版本号,如 "4.1.0"
77
- * @returns 版本记录,版本不存在时返回 null
78
- */
79
- export declare function getVersionRecord(version: string): VersionRecord | null;
80
-
81
- /**
82
- * 获取从 fromVersion(不含)到最新版本(含)之间的所有版本记录
83
- *
84
- * 三方升级后可用它一次性展示期间累积的全部更新内容。
85
- * fromVersion 不在历史记录中时(跨度超过保留的 10 个版本),返回全部记录。
86
- *
87
- * @param fromVersion - 用户当前所在版本
88
- *
89
- * @example
90
- * ```typescript
91
- * const notes = getVersionRecordsSince("4.0.8");
92
- * // 展示 4.0.9 ~ 4.1.0 之间的所有更新说明
93
- * ```
94
- */
95
- export declare function getVersionRecordsSince(fromVersion: string): VersionRecord[];
96
-
97
13
  declare class Logger extends SentryInstance implements LoggerImplement {
98
14
  private stream;
99
15
  constructor(taskParams: TaskParams);
@@ -111,89 +27,15 @@ declare class PackageManager {
111
27
  private extract;
112
28
  require(module: string): any;
113
29
  install(name: string, version: string): Promise<void>;
114
- /**
115
- * 查询远端指定 dist-tag 的版本号(只读,不下载)
116
- *
117
- * distTag 缺失时(比如从未发过 beta)回退到 latest,不阻断更新。
118
- */
119
- getVersionByTag(name: string, distTag?: string): Promise<string>;
120
- /**
121
- * 查询远端应当使用的版本号(只读,不下载)
122
- *
123
- * beta 渠道取 beta 与 latest 的较大值:beta tag 可能落后于正式版
124
- * (正式版发布后 beta tag 不会自动前移),此时不应让灰度用户降级。
125
- */
126
- getLatestVersion(name: string, useBeta?: boolean): Promise<string>;
127
- update(name: string, useBeta?: boolean): Promise<string>;
30
+ update(name: string): Promise<string>;
128
31
  }
129
32
 
130
33
  export declare class RpaTask extends Task {
131
34
  actions: RpaAction.Action;
132
35
  private actionName;
133
- /** 内置版本,热更新失败时的回退基线 */
134
- private readonly bundledActionVersion;
135
- /** 内存中实际生效的版本 */
136
- private currentActionVersion;
137
- private latestActionVersion;
138
- private appliedUpdate;
139
- private updateChannel;
140
- private updateError?;
141
- /** 构造函数触发的更新任务,供 waitForUpdate 复用,避免重复请求 */
142
- private updateTask;
143
36
  constructor(params: TaskParams);
144
37
  private registerActions;
145
- /**
146
- * 获取当前运行的脚本包(@iflyrpa/actions)版本号
147
- *
148
- * 返回内存中实际生效的版本,热更新后会自动切换到新版本。
149
- * 适用于在脚本执行过程中记录或上报实际使用的脚本版本。
150
- */
151
- getActionVersion(): string;
152
- /**
153
- * 脚本包版本状态快照(同步,不发起网络请求)
154
- *
155
- * 第三方可用它与自己记录的版本比对,决定是否提示重启。
156
- * 注意:applied 为 true 时更新已在内存中生效,无需重启。
157
- */
158
- getActionVersionInfo(): ActionVersionInfo;
159
- /**
160
- * 当前用户是否走灰度渠道
161
- *
162
- * 取决于 GrowthBook 的 HuiwenCanary 开关,未初始化时返回 false(走正式渠道)。
163
- * 注意 GrowthBook 依赖 setUser 才会初始化,未调用 setUser 的场景恒为正式渠道。
164
- */
165
- private useBetaChannel;
166
- /**
167
- * 只查询远端最新版本号,不下载、不替换
168
- *
169
- * 适合"启动时静默检查有没有新版本"的场景。
170
- */
171
- checkActionUpdate(): Promise<ActionVersionInfo>;
172
- /**
173
- * 等待构造函数触发的更新流程结束,返回最终版本状态
174
- *
175
- * forceUpdate 为 false 时会主动执行一次更新。
176
- * 多次调用复用同一个任务,不会重复下载。
177
- */
178
- waitForActionUpdate(): Promise<ActionVersionInfo>;
179
38
  private update;
180
- /**
181
- * 【测试专用】验证脚本是否真的在内存中更新了
182
- *
183
- * 通过调用 actions 实例的版本标识方法,验证热更新后内存中的代码是否真的被替换。
184
- * 如果版本标识变化,说明热更新成功;如果标识不变,说明仍在使用旧版本。
185
- *
186
- * @returns 当前内存中 Action 实例的版本标识
187
- */
188
- verifyActionMemoryUpdate(): {
189
- version: string;
190
- shareVersion: string;
191
- marker: string;
192
- timestamp: string;
193
- } | {
194
- error: string;
195
- currentVersion: string;
196
- };
197
39
  }
198
40
 
199
41
  declare class SentryInstance {
@@ -285,49 +127,6 @@ declare interface TaskParams {
285
127
 
286
128
  declare type TimeConsuming = Record<string, number>;
287
129
 
288
- /**
289
- * 版本价值等级
290
- *
291
- * - 0 细微:修复小问题、文档更新、轻微优化,可选更新
292
- * - 1 一般:新功能、常规优化、非关键修复,建议更新
293
- * - 2 强烈:重大功能、安全修复、关键性能优化,强制更新并重启
294
- */
295
- export declare type UpdateLevel = 0 | 1 | 2;
296
-
297
130
  export declare const version: string;
298
131
 
299
- /**
300
- * 版本历史数据
301
- */
302
- export declare interface VersionHistory {
303
- /** 包名 */
304
- name: string;
305
- /** 当前版本 */
306
- currentVersion: string;
307
- /** 最后更新日期 */
308
- lastUpdate: string;
309
- /** 保留的最大版本数 */
310
- maxVersions: number;
311
- /** 版本记录列表(从新到旧) */
312
- versions: VersionRecord[];
313
- }
314
-
315
- /**
316
- * 单个版本记录
317
- */
318
- export declare interface VersionRecord {
319
- /** 版本号 */
320
- version: string;
321
- /** 发布日期 YYYY-MM-DD */
322
- releaseDate: string;
323
- /** 版本更新说明 */
324
- releaseNote: string[];
325
- /** 版本价值等级 0-细微 1-一般 2-强烈 */
326
- updateLevel: UpdateLevel;
327
- /** 更新策略建议 */
328
- updateStrategy: string;
329
- /** 变更类型 */
330
- changeType: "patch" | "minor" | "major";
331
- }
332
-
333
132
  export { }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
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]="92f20852-4bf4-5fbf-bdb2-412040c14232")}catch(e){}}();
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
3
  import * as __WEBPACK_EXTERNAL_MODULE_punycode__ from "punycode";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE_http__ from "http";
@@ -2552,7 +2552,9 @@ function __webpack_require__(moduleId) {
2552
2552
  });
2553
2553
  };
2554
2554
  })();
2555
- var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.4"}');
2555
+ var package_namespaceObject = {
2556
+ i8: "4.0.9"
2557
+ };
2556
2558
  function _define_property(obj, key, value) {
2557
2559
  if (key in obj) Object.defineProperty(obj, key, {
2558
2560
  value: value,
@@ -5361,45 +5363,10 @@ function packageManager_define_property(obj, key, value) {
5361
5363
  return obj;
5362
5364
  }
5363
5365
  const NPM_REGISTRY = "https://registry.npmmirror.com/";
5364
- const LATEST_TAG = "latest";
5365
- const BETA_TAG = "beta";
5366
- function compareVersion(a, b) {
5367
- const parse = (v)=>{
5368
- const [core, pre] = v.split("-");
5369
- const nums = core.split(".").map(Number);
5370
- return {
5371
- nums,
5372
- pre
5373
- };
5374
- };
5375
- const va = parse(a);
5376
- const vb = parse(b);
5377
- for(let i = 0; i < 3; i++){
5378
- const diff = (va.nums[i] ?? 0) - (vb.nums[i] ?? 0);
5379
- if (0 !== diff) return diff;
5380
- }
5381
- if (!va.pre && !vb.pre) return 0;
5382
- if (!va.pre) return 1;
5383
- if (!vb.pre) return -1;
5384
- const pa = va.pre.split(".");
5385
- const pb = vb.pre.split(".");
5386
- for(let i = 0; i < Math.max(pa.length, pb.length); i++){
5387
- const sa = pa[i];
5388
- const sb = pb[i];
5389
- if (void 0 === sa) return -1;
5390
- if (void 0 === sb) return 1;
5391
- const na = Number(sa);
5392
- const nb = Number(sb);
5393
- const bothNumeric = !Number.isNaN(na) && !Number.isNaN(nb);
5394
- const diff = bothNumeric ? na - nb : sa.localeCompare(sb);
5395
- if (0 !== diff) return diff;
5396
- }
5397
- return 0;
5398
- }
5399
5366
  class PackageManager {
5400
5367
  async getManifest(module) {
5401
5368
  try {
5402
- return await __WEBPACK_EXTERNAL_MODULE__iflyrpa_pacote_56da1cff__["default"].manifest(module, {
5369
+ return __WEBPACK_EXTERNAL_MODULE__iflyrpa_pacote_56da1cff__["default"].manifest(module, {
5403
5370
  registry: NPM_REGISTRY
5404
5371
  });
5405
5372
  } catch (error) {
@@ -5430,25 +5397,9 @@ class PackageManager {
5430
5397
  const plugin = this.require(packageName);
5431
5398
  if (!plugin) await this.extract(name, version);
5432
5399
  }
5433
- async getVersionByTag(name, distTag = LATEST_TAG) {
5434
- try {
5435
- const manifest = await this.getManifest(`${name}@${distTag}`);
5436
- return manifest.version;
5437
- } catch (error) {
5438
- if (distTag === LATEST_TAG) throw error;
5439
- this.task.logger.warn(`${name}@${distTag} 不存在,回退到 ${LATEST_TAG}`);
5440
- const manifest = await this.getManifest(`${name}@${LATEST_TAG}`);
5441
- return manifest.version;
5442
- }
5443
- }
5444
- async getLatestVersion(name, useBeta = false) {
5445
- const latest = await this.getVersionByTag(name, LATEST_TAG);
5446
- if (!useBeta) return latest;
5447
- const beta = await this.getVersionByTag(name, BETA_TAG);
5448
- return compareVersion(beta, latest) > 0 ? beta : latest;
5449
- }
5450
- async update(name, useBeta = false) {
5451
- const version = await this.getLatestVersion(name, useBeta);
5400
+ async update(name) {
5401
+ const manifest = await this.getManifest(`${name}@latest`);
5402
+ const version = manifest.version;
5452
5403
  const plugin = this.require(`${name}@${version}/package.json`);
5453
5404
  if (!plugin) await this.extract(name, version);
5454
5405
  return version;
@@ -5664,25 +5615,6 @@ class Task {
5664
5615
  this.electronPackage = this.installElectron();
5665
5616
  }
5666
5617
  }
5667
- var version_history_namespaceObject = JSON.parse('{"name":"@iflyrpa/playwright","currentVersion":"4.0.9-beta.4","lastUpdate":"2026-08-14","maxVersions":10,"versions":[{"version":"4.0.9-beta.4","releaseDate":"2026-08-14","releaseNote":["1. 版本更新优化"],"updateLevel":0,"updateStrategy":"可选更新","changeType":"patch"},{"version":"4.0.9-beta.3","releaseDate":"2026-08-14","releaseNote":["1. 测试更新","2. 重要修复,需要更新"],"updateLevel":2,"updateStrategy":"强制更新并重启","changeType":"patch"},{"version":"4.0.9-beta.2","releaseDate":"2026-08-13","releaseNote":["1.增加版本更新记录","2.优化错误提示"],"updateLevel":1,"updateStrategy":"建议更新","changeType":"patch"}]}');
5668
- function getVersionHistory() {
5669
- return version_history_namespaceObject;
5670
- }
5671
- function getLatestVersionRecord() {
5672
- return getVersionHistory().versions[0] ?? null;
5673
- }
5674
- function getVersionRecord(version) {
5675
- return getVersionHistory().versions.find((v)=>v.version === version) ?? null;
5676
- }
5677
- function getVersionRecordsSince(fromVersion) {
5678
- const { versions } = getVersionHistory();
5679
- const index = versions.findIndex((v)=>v.version === fromVersion);
5680
- return -1 === index ? versions : versions.slice(0, index);
5681
- }
5682
- function getMaxUpdateLevel(records) {
5683
- if (0 === records.length) return null;
5684
- return records.reduce((max, r)=>r.updateLevel > max ? r.updateLevel : max, 0);
5685
- }
5686
5618
  function src_define_property(obj, key, value) {
5687
5619
  if (key in obj) Object.defineProperty(obj, key, {
5688
5620
  value: value,
@@ -5696,84 +5628,25 @@ function src_define_property(obj, key, value) {
5696
5628
  class RpaTask extends Task {
5697
5629
  registerActions(rpaAction) {
5698
5630
  this.actions = new rpaAction.Action(this);
5699
- this.currentActionVersion = rpaAction.version;
5700
5631
  this.setActionVersion(rpaAction.version);
5701
5632
  }
5702
- getActionVersion() {
5703
- return this.currentActionVersion;
5704
- }
5705
- getActionVersionInfo() {
5706
- return {
5707
- current: this.currentActionVersion,
5708
- bundled: this.bundledActionVersion,
5709
- latest: this.latestActionVersion,
5710
- hasUpdate: !!this.latestActionVersion && this.latestActionVersion !== this.currentActionVersion,
5711
- applied: this.appliedUpdate,
5712
- channel: this.updateChannel,
5713
- error: this.updateError
5714
- };
5715
- }
5716
- useBetaChannel() {
5717
- const useBeta = this.isFeatOn(__WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__.BetaFlag);
5718
- this.updateChannel = useBeta ? "beta" : "latest";
5719
- return useBeta;
5720
- }
5721
- async checkActionUpdate() {
5722
- try {
5723
- this.latestActionVersion = await this.packageManager.getLatestVersion(this.actionName, this.useBetaChannel());
5724
- this.updateError = void 0;
5725
- } catch (error) {
5726
- this.updateError = error instanceof Error ? error.message : String(error);
5727
- this.logger.error("检查脚本版本失败", error);
5728
- }
5729
- return this.getActionVersionInfo();
5730
- }
5731
- waitForActionUpdate() {
5732
- if (!this.updateTask) this.updateTask = this.update();
5733
- return this.updateTask;
5734
- }
5735
5633
  async update() {
5736
5634
  try {
5737
- const version = await this.packageManager.update(this.actionName, this.useBetaChannel());
5738
- this.latestActionVersion = version;
5739
- if (version === this.currentActionVersion) {
5740
- this.appliedUpdate = false;
5741
- return this.getActionVersionInfo();
5742
- }
5635
+ const version = await this.packageManager.update(this.actionName);
5743
5636
  const rpaPackage = this.packageManager.require(`${this.actionName}@${version}/dist/bundle.js`);
5744
- if (null == rpaPackage ? void 0 : rpaPackage.Action) {
5745
- this.registerActions(rpaPackage);
5746
- this.appliedUpdate = true;
5747
- this.updateError = void 0;
5748
- this.logger.info(`脚本已热更新至 ${version}`);
5749
- } else {
5750
- this.appliedUpdate = false;
5751
- this.updateError = `加载 ${this.actionName}@${version} 失败`;
5752
- this.logger.warn(this.updateError);
5753
- }
5637
+ (null == rpaPackage ? void 0 : rpaPackage.Action) && this.registerActions(rpaPackage);
5754
5638
  } catch (error) {
5755
- this.appliedUpdate = false;
5756
- this.updateError = error instanceof Error ? error.message : String(error);
5757
5639
  this.logger.error("更新依赖失败", error);
5758
5640
  }
5759
- return this.getActionVersionInfo();
5760
- }
5761
- verifyActionMemoryUpdate() {
5762
- var _this_actions;
5763
- if (!(null === (_this_actions = this.actions) || void 0 === _this_actions ? void 0 : _this_actions.getActionVersionMarker)) return {
5764
- error: "getActionVersionMarker 方法不存在,可能是旧版本的 @iflyrpa/actions",
5765
- currentVersion: this.currentActionVersion
5766
- };
5767
- return this.actions.getActionVersionMarker();
5768
5641
  }
5769
5642
  constructor(params){
5770
- 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);
5643
+ super(params), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions");
5771
5644
  this.registerActions(__WEBPACK_EXTERNAL_MODULE__iflyrpa_actions_bd801d6f__);
5772
- if (params.forceUpdate) this.updateTask = this.update();
5645
+ params.forceUpdate && this.update();
5773
5646
  }
5774
5647
  }
5775
5648
  const src_version = package_namespaceObject.i8;
5776
- export { RpaTask, compareVersion, getLatestVersionRecord, getMaxUpdateLevel, getVersionHistory, getVersionRecord, getVersionRecordsSince, src_version as version };
5649
+ export { RpaTask, src_version as version };
5777
5650
 
5778
5651
  //# sourceMappingURL=index.js.map
5779
- //# debugId=92f20852-4bf4-5fbf-bdb2-412040c14232
5652
+ //# debugId=7135424a-8b43-5186-b3bf-add32278e972