@iflyrpa/playwright 4.0.8-beta.0 → 4.0.9-beta.0

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