@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 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]="10485e63-d196-5082-84d7-9cdceb7a1130")}catch(e){}}();
3
1
  var __webpack_modules__ = {
4
2
  "../../node_modules/.pnpm/cross-fetch@4.1.0_encoding@0.1.13/node_modules/cross-fetch/dist/node-ponyfill.js": function(module, exports1, __webpack_require__) {
5
3
  const nodeFetch = __webpack_require__("../../node_modules/.pnpm/node-fetch@2.7.0_encoding@0.1.13/node_modules/node-fetch/lib/index.mjs");
@@ -2555,13 +2553,12 @@ var __webpack_exports__ = {};
2555
2553
  "use strict";
2556
2554
  __webpack_require__.r(__webpack_exports__);
2557
2555
  __webpack_require__.d(__webpack_exports__, {
2556
+ compareVersion: ()=>compareVersion,
2558
2557
  version: ()=>src_version,
2559
2558
  RpaTask: ()=>RpaTask
2560
2559
  });
2561
2560
  const actions_namespaceObject = require("@iflyrpa/actions");
2562
- var package_namespaceObject = {
2563
- i8: "4.0.8"
2564
- };
2561
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.1"}');
2565
2562
  const external_node_fs_namespaceObject = require("node:fs");
2566
2563
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
2567
2564
  const external_node_path_namespaceObject = require("node:path");
@@ -5387,10 +5384,45 @@ app.on("window-all-closed", (e) => e.preventDefault());
5387
5384
  return obj;
5388
5385
  }
5389
5386
  const NPM_REGISTRY = "https://registry.npmmirror.com/";
5387
+ const LATEST_TAG = "latest";
5388
+ const BETA_TAG = "beta";
5389
+ function compareVersion(a, b) {
5390
+ const parse = (v)=>{
5391
+ const [core, pre] = v.split("-");
5392
+ const nums = core.split(".").map(Number);
5393
+ return {
5394
+ nums,
5395
+ pre
5396
+ };
5397
+ };
5398
+ const va = parse(a);
5399
+ const vb = parse(b);
5400
+ for(let i = 0; i < 3; i++){
5401
+ const diff = (va.nums[i] ?? 0) - (vb.nums[i] ?? 0);
5402
+ if (0 !== diff) return diff;
5403
+ }
5404
+ if (!va.pre && !vb.pre) return 0;
5405
+ if (!va.pre) return 1;
5406
+ if (!vb.pre) return -1;
5407
+ const pa = va.pre.split(".");
5408
+ const pb = vb.pre.split(".");
5409
+ for(let i = 0; i < Math.max(pa.length, pb.length); i++){
5410
+ const sa = pa[i];
5411
+ const sb = pb[i];
5412
+ if (void 0 === sa) return -1;
5413
+ if (void 0 === sb) return 1;
5414
+ const na = Number(sa);
5415
+ const nb = Number(sb);
5416
+ const bothNumeric = !Number.isNaN(na) && !Number.isNaN(nb);
5417
+ const diff = bothNumeric ? na - nb : sa.localeCompare(sb);
5418
+ if (0 !== diff) return diff;
5419
+ }
5420
+ return 0;
5421
+ }
5390
5422
  class PackageManager {
5391
5423
  async getManifest(module) {
5392
5424
  try {
5393
- return pacote_default().manifest(module, {
5425
+ return await pacote_default().manifest(module, {
5394
5426
  registry: NPM_REGISTRY
5395
5427
  });
5396
5428
  } catch (error) {
@@ -5421,9 +5453,25 @@ app.on("window-all-closed", (e) => e.preventDefault());
5421
5453
  const plugin = this.require(packageName);
5422
5454
  if (!plugin) await this.extract(name, version);
5423
5455
  }
5424
- async update(name) {
5425
- const manifest = await this.getManifest(`${name}@latest`);
5426
- const version = manifest.version;
5456
+ async getVersionByTag(name, distTag = LATEST_TAG) {
5457
+ try {
5458
+ const manifest = await this.getManifest(`${name}@${distTag}`);
5459
+ return manifest.version;
5460
+ } catch (error) {
5461
+ if (distTag === LATEST_TAG) throw error;
5462
+ this.task.logger.warn(`${name}@${distTag} 不存在,回退到 ${LATEST_TAG}`);
5463
+ const manifest = await this.getManifest(`${name}@${LATEST_TAG}`);
5464
+ return manifest.version;
5465
+ }
5466
+ }
5467
+ async getLatestVersion(name, useBeta = false) {
5468
+ const latest = await this.getVersionByTag(name, LATEST_TAG);
5469
+ if (!useBeta) return latest;
5470
+ const beta = await this.getVersionByTag(name, BETA_TAG);
5471
+ return compareVersion(beta, latest) > 0 ? beta : latest;
5472
+ }
5473
+ async update(name, useBeta = false) {
5474
+ const version = await this.getLatestVersion(name, useBeta);
5427
5475
  const plugin = this.require(`${name}@${version}/package.json`);
5428
5476
  if (!plugin) await this.extract(name, version);
5429
5477
  return version;
@@ -5652,21 +5700,69 @@ app.on("window-all-closed", (e) => e.preventDefault());
5652
5700
  class RpaTask extends Task {
5653
5701
  registerActions(rpaAction) {
5654
5702
  this.actions = new rpaAction.Action(this);
5703
+ this.currentActionVersion = rpaAction.version;
5655
5704
  this.setActionVersion(rpaAction.version);
5656
5705
  }
5706
+ getActionVersionInfo() {
5707
+ return {
5708
+ current: this.currentActionVersion,
5709
+ bundled: this.bundledActionVersion,
5710
+ latest: this.latestActionVersion,
5711
+ hasUpdate: !!this.latestActionVersion && this.latestActionVersion !== this.currentActionVersion,
5712
+ applied: this.appliedUpdate,
5713
+ channel: this.updateChannel,
5714
+ error: this.updateError
5715
+ };
5716
+ }
5717
+ useBetaChannel() {
5718
+ const useBeta = this.isFeatOn(actions_namespaceObject.BetaFlag);
5719
+ this.updateChannel = useBeta ? "beta" : "latest";
5720
+ return useBeta;
5721
+ }
5722
+ async checkActionUpdate() {
5723
+ try {
5724
+ this.latestActionVersion = await this.packageManager.getLatestVersion(this.actionName, this.useBetaChannel());
5725
+ this.updateError = void 0;
5726
+ } catch (error) {
5727
+ this.updateError = error instanceof Error ? error.message : String(error);
5728
+ this.logger.error("检查脚本版本失败", error);
5729
+ }
5730
+ return this.getActionVersionInfo();
5731
+ }
5732
+ waitForActionUpdate() {
5733
+ if (!this.updateTask) this.updateTask = this.update();
5734
+ return this.updateTask;
5735
+ }
5657
5736
  async update() {
5658
5737
  try {
5659
- const version = await this.packageManager.update(this.actionName);
5738
+ const version = await this.packageManager.update(this.actionName, this.useBetaChannel());
5739
+ this.latestActionVersion = version;
5740
+ if (version === this.currentActionVersion) {
5741
+ this.appliedUpdate = false;
5742
+ return this.getActionVersionInfo();
5743
+ }
5660
5744
  const rpaPackage = this.packageManager.require(`${this.actionName}@${version}/dist/bundle.js`);
5661
- (null == rpaPackage ? void 0 : rpaPackage.Action) && this.registerActions(rpaPackage);
5745
+ if (null == rpaPackage ? void 0 : rpaPackage.Action) {
5746
+ this.registerActions(rpaPackage);
5747
+ this.appliedUpdate = true;
5748
+ this.updateError = void 0;
5749
+ this.logger.info(`脚本已热更新至 ${version}`);
5750
+ } else {
5751
+ this.appliedUpdate = false;
5752
+ this.updateError = `加载 ${this.actionName}@${version} 失败`;
5753
+ this.logger.warn(this.updateError);
5754
+ }
5662
5755
  } catch (error) {
5756
+ this.appliedUpdate = false;
5757
+ this.updateError = error instanceof Error ? error.message : String(error);
5663
5758
  this.logger.error("更新依赖失败", error);
5664
5759
  }
5760
+ return this.getActionVersionInfo();
5665
5761
  }
5666
5762
  constructor(params){
5667
- super(params), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions");
5763
+ super(params), src_define_property(this, "actions", void 0), src_define_property(this, "actionName", "@iflyrpa/actions"), src_define_property(this, "bundledActionVersion", actions_namespaceObject.version), src_define_property(this, "currentActionVersion", actions_namespaceObject.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);
5668
5764
  this.registerActions(actions_namespaceObject);
5669
- params.forceUpdate && this.update();
5765
+ if (params.forceUpdate) this.updateTask = this.update();
5670
5766
  }
5671
5767
  }
5672
5768
  const src_version = package_namespaceObject.i8;
@@ -5677,5 +5773,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
5677
5773
  value: true
5678
5774
  });
5679
5775
 
5680
- //# sourceMappingURL=index.cjs.map
5681
- //# debugId=10485e63-d196-5082-84d7-9cdceb7a1130
5776
+ //# sourceMappingURL=index.cjs.map