@skrillex1224/playwright-toolkit 2.1.219 → 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,6 +412,7 @@ 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);
@@ -657,9 +658,9 @@ var resolveResourceTypeMeta = (domain) => {
657
658
  if (!byType || byType.size === 0) {
658
659
  return { resourceType: "", resourceTypeCounts: void 0 };
659
660
  }
660
- const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a, b) => {
661
- if (Number(b[1]) !== Number(a[1])) return Number(b[1]) - Number(a[1]);
662
- 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]));
663
664
  });
664
665
  if (entries.length === 0) {
665
666
  return { resourceType: "", resourceTypeCounts: void 0 };
@@ -749,10 +750,10 @@ var normalizeDomainRows = (hosts) => {
749
750
  resourceTypeCounts: resourceTypeMeta.resourceTypeCounts || void 0
750
751
  });
751
752
  }
752
- rows.sort((a, b) => {
753
- if (b.totalBytes !== a.totalBytes) return b.totalBytes - a.totalBytes;
754
- if (b.requests !== a.requests) return b.requests - a.requests;
755
- 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));
756
757
  });
757
758
  return {
758
759
  topDomains: rows.slice(0, MAX_TOP_DOMAINS),
@@ -2973,9 +2974,17 @@ var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
2973
2974
  actionVisibleTimeoutMs: 1500,
2974
2975
  sourceImageVisibleTimeoutMs: 3e3,
2975
2976
  challengeReadyTimeoutMs: 15e3,
2977
+ challengeReadyRefreshTimeoutMs: 2e4,
2976
2978
  challengeReadyPollMs: 300,
2977
2979
  loadingIndicatorVisibleTimeoutMs: 200,
2978
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
+ ],
2979
2988
  recognitionDelayMs: 2e3,
2980
2989
  refreshWaitMs: 3e3,
2981
2990
  submitWaitMs: 3e3,
@@ -3142,6 +3151,7 @@ var isAnyCaptchaTextVisible = async (frame, texts, timeout) => {
3142
3151
  };
3143
3152
  var waitForCaptchaChallengeReady = async (page, frame, options) => {
3144
3153
  const deadline = Date.now() + options.challengeReadyTimeoutMs;
3154
+ let refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3145
3155
  let hasSeenLoading = false;
3146
3156
  while (Date.now() < deadline) {
3147
3157
  const isLoadingVisible = await isAnyCaptchaTextVisible(
@@ -3149,6 +3159,11 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3149
3159
  options.loadingTexts,
3150
3160
  options.loadingIndicatorVisibleTimeoutMs
3151
3161
  );
3162
+ const hasErrorTextVisible = await isAnyCaptchaTextVisible(
3163
+ frame,
3164
+ options.errorTexts,
3165
+ options.loadingIndicatorVisibleTimeoutMs
3166
+ );
3152
3167
  hasSeenLoading = hasSeenLoading || isLoadingVisible;
3153
3168
  const sourceImages = frame.locator(options.sourceImageSelector);
3154
3169
  const imageCount = await sourceImages.count().catch(() => 0);
@@ -3157,6 +3172,20 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3157
3172
  logger9.info(hasSeenLoading ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u52A0\u8F7D\u5B8C\u6210\u3002" : "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u5C31\u7EEA\u3002");
3158
3173
  return;
3159
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
+ }
3160
3189
  await page.waitForTimeout(options.challengeReadyPollMs);
3161
3190
  }
3162
3191
  throw new Error("Captcha challenge is still loading and did not become ready in time.");