@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.cjs CHANGED
@@ -439,6 +439,7 @@ function createInternalLogger(moduleName, explicitLogger) {
439
439
  },
440
440
  warning(message) {
441
441
  baseLogger.warning(message);
442
+ a;
442
443
  },
443
444
  info(message) {
444
445
  baseLogger.info(message);
@@ -685,9 +686,9 @@ var resolveResourceTypeMeta = (domain) => {
685
686
  if (!byType || byType.size === 0) {
686
687
  return { resourceType: "", resourceTypeCounts: void 0 };
687
688
  }
688
- const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a, b) => {
689
- if (Number(b[1]) !== Number(a[1])) return Number(b[1]) - Number(a[1]);
690
- return String(a[0]).localeCompare(String(b[0]));
689
+ const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a2, b) => {
690
+ if (Number(b[1]) !== Number(a2[1])) return Number(b[1]) - Number(a2[1]);
691
+ return String(a2[0]).localeCompare(String(b[0]));
691
692
  });
692
693
  if (entries.length === 0) {
693
694
  return { resourceType: "", resourceTypeCounts: void 0 };
@@ -777,10 +778,10 @@ var normalizeDomainRows = (hosts) => {
777
778
  resourceTypeCounts: resourceTypeMeta.resourceTypeCounts || void 0
778
779
  });
779
780
  }
780
- rows.sort((a, b) => {
781
- if (b.totalBytes !== a.totalBytes) return b.totalBytes - a.totalBytes;
782
- if (b.requests !== a.requests) return b.requests - a.requests;
783
- return String(a.domain).localeCompare(String(b.domain));
781
+ rows.sort((a2, b) => {
782
+ if (b.totalBytes !== a2.totalBytes) return b.totalBytes - a2.totalBytes;
783
+ if (b.requests !== a2.requests) return b.requests - a2.requests;
784
+ return String(a2.domain).localeCompare(String(b.domain));
784
785
  });
785
786
  return {
786
787
  topDomains: rows.slice(0, MAX_TOP_DOMAINS),
@@ -3001,9 +3002,17 @@ var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
3001
3002
  actionVisibleTimeoutMs: 1500,
3002
3003
  sourceImageVisibleTimeoutMs: 3e3,
3003
3004
  challengeReadyTimeoutMs: 15e3,
3005
+ challengeReadyRefreshTimeoutMs: 2e4,
3004
3006
  challengeReadyPollMs: 300,
3005
3007
  loadingIndicatorVisibleTimeoutMs: 200,
3006
3008
  loadingTexts: ["\u52A0\u8F7D\u4E2D", "\u52A0\u8F7D\u4E2D..."],
3009
+ errorTexts: [
3010
+ "\u68C0\u6D4B\u5230\u60A8\u7684\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
3011
+ "\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
3012
+ "\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u8005\u7A0D\u540E\u518D\u8BD5",
3013
+ "\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u7A0D\u540E\u518D\u8BD5",
3014
+ "\u7A0D\u540E\u518D\u8BD5"
3015
+ ],
3007
3016
  recognitionDelayMs: 2e3,
3008
3017
  refreshWaitMs: 3e3,
3009
3018
  submitWaitMs: 3e3,
@@ -3170,6 +3179,7 @@ var isAnyCaptchaTextVisible = async (frame, texts, timeout) => {
3170
3179
  };
3171
3180
  var waitForCaptchaChallengeReady = async (page, frame, options) => {
3172
3181
  const deadline = Date.now() + options.challengeReadyTimeoutMs;
3182
+ let refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3173
3183
  let hasSeenLoading = false;
3174
3184
  while (Date.now() < deadline) {
3175
3185
  const isLoadingVisible = await isAnyCaptchaTextVisible(
@@ -3177,6 +3187,11 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3177
3187
  options.loadingTexts,
3178
3188
  options.loadingIndicatorVisibleTimeoutMs
3179
3189
  );
3190
+ const hasErrorTextVisible = await isAnyCaptchaTextVisible(
3191
+ frame,
3192
+ options.errorTexts,
3193
+ options.loadingIndicatorVisibleTimeoutMs
3194
+ );
3180
3195
  hasSeenLoading = hasSeenLoading || isLoadingVisible;
3181
3196
  const sourceImages = frame.locator(options.sourceImageSelector);
3182
3197
  const imageCount = await sourceImages.count().catch(() => 0);
@@ -3185,6 +3200,20 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
3185
3200
  logger9.info(hasSeenLoading ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u52A0\u8F7D\u5B8C\u6210\u3002" : "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u5C31\u7EEA\u3002");
3186
3201
  return;
3187
3202
  }
3203
+ if (hasErrorTextVisible) {
3204
+ 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");
3205
+ await refreshCaptcha(page, frame, options);
3206
+ refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3207
+ hasSeenLoading = false;
3208
+ continue;
3209
+ }
3210
+ if (!hasVisibleSourceImage && Date.now() >= refreshDeadline) {
3211
+ logger9.warn(`\u9A8C\u8BC1\u7801\u56FE\u7247\u8D85\u8FC7 ${options.challengeReadyRefreshTimeoutMs}ms \u4ECD\u672A\u51FA\u73B0\uFF0C\u5C1D\u8BD5\u5237\u65B0\u9898\u76EE\u3002`);
3212
+ await refreshCaptcha(page, frame, options);
3213
+ refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
3214
+ hasSeenLoading = false;
3215
+ continue;
3216
+ }
3188
3217
  await page.waitForTimeout(options.challengeReadyPollMs);
3189
3218
  }
3190
3219
  throw new Error("Captcha challenge is still loading and did not become ready in time.");