@skrillex1224/playwright-toolkit 2.1.218 → 2.1.220

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.js CHANGED
@@ -412,9 +412,13 @@ function createInternalLogger(moduleName, explicitLogger) {
412
412
  },
413
413
  warning(message) {
414
414
  baseLogger.warning(message);
415
+ a;
415
416
  },
416
417
  info(message) {
417
418
  baseLogger.info(message);
419
+ },
420
+ error(message) {
421
+ baseLogger.error(message);
418
422
  }
419
423
  };
420
424
  }
@@ -654,9 +658,9 @@ var resolveResourceTypeMeta = (domain) => {
654
658
  if (!byType || byType.size === 0) {
655
659
  return { resourceType: "", resourceTypeCounts: void 0 };
656
660
  }
657
- const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a, b) => {
658
- if (Number(b[1]) !== Number(a[1])) return Number(b[1]) - Number(a[1]);
659
- return String(a[0]).localeCompare(String(b[0]));
661
+ const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a2, b) => {
662
+ if (Number(b[1]) !== Number(a2[1])) return Number(b[1]) - Number(a2[1]);
663
+ return String(a2[0]).localeCompare(String(b[0]));
660
664
  });
661
665
  if (entries.length === 0) {
662
666
  return { resourceType: "", resourceTypeCounts: void 0 };
@@ -746,10 +750,10 @@ var normalizeDomainRows = (hosts) => {
746
750
  resourceTypeCounts: resourceTypeMeta.resourceTypeCounts || void 0
747
751
  });
748
752
  }
749
- rows.sort((a, b) => {
750
- if (b.totalBytes !== a.totalBytes) return b.totalBytes - a.totalBytes;
751
- if (b.requests !== a.requests) return b.requests - a.requests;
752
- return String(a.domain).localeCompare(String(b.domain));
753
+ rows.sort((a2, b) => {
754
+ if (b.totalBytes !== a2.totalBytes) return b.totalBytes - a2.totalBytes;
755
+ if (b.requests !== a2.requests) return b.requests - a2.requests;
756
+ return String(a2.domain).localeCompare(String(b.domain));
753
757
  });
754
758
  return {
755
759
  topDomains: rows.slice(0, MAX_TOP_DOMAINS),
@@ -2970,9 +2974,17 @@ var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
2970
2974
  actionVisibleTimeoutMs: 1500,
2971
2975
  sourceImageVisibleTimeoutMs: 3e3,
2972
2976
  challengeReadyTimeoutMs: 15e3,
2977
+ challengeReadyRefreshTimeoutMs: 2e4,
2973
2978
  challengeReadyPollMs: 300,
2974
2979
  loadingIndicatorVisibleTimeoutMs: 200,
2975
2980
  loadingTexts: ["\u52A0\u8F7D\u4E2D", "\u52A0\u8F7D\u4E2D..."],
2981
+ errorTexts: [
2982
+ "\u68C0\u6D4B\u5230\u60A8\u7684\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
2983
+ "\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
2984
+ "\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u8005\u7A0D\u540E\u518D\u8BD5",
2985
+ "\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u7A0D\u540E\u518D\u8BD5",
2986
+ "\u7A0D\u540E\u518D\u8BD5"
2987
+ ],
2976
2988
  recognitionDelayMs: 2e3,
2977
2989
  refreshWaitMs: 3e3,
2978
2990
  submitWaitMs: 3e3,
@@ -3139,6 +3151,7 @@ var isAnyCaptchaTextVisible = async (frame, texts, timeout) => {
3139
3151
  };
3140
3152
  var waitForCaptchaChallengeReady = async (page, frame, options) => {
3141
3153
  const deadline = Date.now() + options.challengeReadyTimeoutMs;
3154
+ let refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3142
3155
  let hasSeenLoading = false;
3143
3156
  while (Date.now() < deadline) {
3144
3157
  const isLoadingVisible = await isAnyCaptchaTextVisible(
@@ -3146,6 +3159,11 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3146
3159
  options.loadingTexts,
3147
3160
  options.loadingIndicatorVisibleTimeoutMs
3148
3161
  );
3162
+ const hasErrorTextVisible = await isAnyCaptchaTextVisible(
3163
+ frame,
3164
+ options.errorTexts,
3165
+ options.loadingIndicatorVisibleTimeoutMs
3166
+ );
3149
3167
  hasSeenLoading = hasSeenLoading || isLoadingVisible;
3150
3168
  const sourceImages = frame.locator(options.sourceImageSelector);
3151
3169
  const imageCount = await sourceImages.count().catch(() => 0);
@@ -3154,6 +3172,20 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3154
3172
  logger9.info(hasSeenLoading ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u52A0\u8F7D\u5B8C\u6210\u3002" : "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u5C31\u7EEA\u3002");
3155
3173
  return;
3156
3174
  }
3175
+ if (hasErrorTextVisible) {
3176
+ logger9.warn("\u9A8C\u8BC1\u7801\u9762\u677F\u51FA\u73B0\u7F51\u7EDC\u5F02\u5E38\u6587\u6848\uFF0C\u5C1D\u8BD5\u7ACB\u5373\u5237\u65B0\u9898\u76EE\u3002");
3177
+ await refreshCaptcha(page, frame, options);
3178
+ refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3179
+ hasSeenLoading = false;
3180
+ continue;
3181
+ }
3182
+ if (!hasVisibleSourceImage && Date.now() >= refreshDeadline) {
3183
+ logger9.warn(`\u9A8C\u8BC1\u7801\u56FE\u7247\u8D85\u8FC7 ${options.challengeReadyRefreshTimeoutMs}ms \u4ECD\u672A\u51FA\u73B0\uFF0C\u5C1D\u8BD5\u5237\u65B0\u9898\u76EE\u3002`);
3184
+ await refreshCaptcha(page, frame, options);
3185
+ refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3186
+ hasSeenLoading = false;
3187
+ continue;
3188
+ }
3157
3189
  await page.waitForTimeout(options.challengeReadyPollMs);
3158
3190
  }
3159
3191
  throw new Error("Captcha challenge is still loading and did not become ready in time.");