@skrillex1224/playwright-toolkit 2.1.211 → 2.1.212
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/README.md +1 -1
- package/dist/index.cjs +90 -51
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +90 -51
- package/dist/index.js.map +3 -3
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -223,7 +223,7 @@ const image3 = await Share.captureScreen(page, {
|
|
|
223
223
|
watermarkify: {
|
|
224
224
|
query: '你好',
|
|
225
225
|
timezoneOffsetHours: 8,
|
|
226
|
-
// 默认会在同一浏览器上下文里访问
|
|
226
|
+
// 默认会在同一浏览器上下文里访问 https://myip.ipip.net/json 补充 IP / Loc,超时默认 10000ms
|
|
227
227
|
},
|
|
228
228
|
});
|
|
229
229
|
|
package/dist/index.cjs
CHANGED
|
@@ -350,18 +350,18 @@ var fallbackLog = {
|
|
|
350
350
|
error: (...args) => console.error(...args),
|
|
351
351
|
debug: (...args) => console.debug ? console.debug(...args) : console.log(...args)
|
|
352
352
|
};
|
|
353
|
-
var resolveLogMethod = (
|
|
354
|
-
if (
|
|
355
|
-
return
|
|
353
|
+
var resolveLogMethod = (logger13, name) => {
|
|
354
|
+
if (logger13 && typeof logger13[name] === "function") {
|
|
355
|
+
return logger13[name].bind(logger13);
|
|
356
356
|
}
|
|
357
|
-
if (name === "warning" &&
|
|
358
|
-
return
|
|
357
|
+
if (name === "warning" && logger13 && typeof logger13.warn === "function") {
|
|
358
|
+
return logger13.warn.bind(logger13);
|
|
359
359
|
}
|
|
360
360
|
return fallbackLog[name];
|
|
361
361
|
};
|
|
362
362
|
var defaultLogger = null;
|
|
363
|
-
var setDefaultLogger = (
|
|
364
|
-
defaultLogger =
|
|
363
|
+
var setDefaultLogger = (logger13) => {
|
|
364
|
+
defaultLogger = logger13;
|
|
365
365
|
};
|
|
366
366
|
var resolveLogger = (explicitLogger) => {
|
|
367
367
|
if (explicitLogger && typeof explicitLogger.info === "function") {
|
|
@@ -388,8 +388,8 @@ var colorize = (text, color) => {
|
|
|
388
388
|
var createBaseLogger = (prefix = "", explicitLogger) => {
|
|
389
389
|
const name = prefix ? String(prefix) : "";
|
|
390
390
|
const dispatch = (methodName, icon, message, color) => {
|
|
391
|
-
const
|
|
392
|
-
const logFn = resolveLogMethod(
|
|
391
|
+
const logger13 = resolveLogger(explicitLogger);
|
|
392
|
+
const logFn = resolveLogMethod(logger13, methodName);
|
|
393
393
|
const timestamp = colorize(`[${formatTimestamp()}]`, ANSI.gray);
|
|
394
394
|
const line = formatLine(name, icon, message);
|
|
395
395
|
const coloredLine = colorize(line, color);
|
|
@@ -4569,7 +4569,7 @@ var createTemplateLogger = (baseLogger = createBaseLogger()) => {
|
|
|
4569
4569
|
};
|
|
4570
4570
|
var getDefaultBaseLogger = () => createBaseLogger("");
|
|
4571
4571
|
var Logger = {
|
|
4572
|
-
setLogger: (
|
|
4572
|
+
setLogger: (logger13) => setDefaultLogger(logger13),
|
|
4573
4573
|
info: (message) => getDefaultBaseLogger().info(message),
|
|
4574
4574
|
success: (message) => getDefaultBaseLogger().success(message),
|
|
4575
4575
|
warning: (message) => getDefaultBaseLogger().warning(message),
|
|
@@ -4577,8 +4577,8 @@ var Logger = {
|
|
|
4577
4577
|
error: (message) => getDefaultBaseLogger().error(message),
|
|
4578
4578
|
debug: (message) => getDefaultBaseLogger().debug(message),
|
|
4579
4579
|
start: (message) => getDefaultBaseLogger().start(message),
|
|
4580
|
-
useTemplate: (
|
|
4581
|
-
if (
|
|
4580
|
+
useTemplate: (logger13) => {
|
|
4581
|
+
if (logger13) return createTemplateLogger(createBaseLogger("", logger13));
|
|
4582
4582
|
return createTemplateLogger();
|
|
4583
4583
|
}
|
|
4584
4584
|
};
|
|
@@ -4596,7 +4596,7 @@ var DEFAULT_WATERMARK_ROTATE_DEG = -16;
|
|
|
4596
4596
|
var DEFAULT_WATERMARK_CELL_WIDTH = 860;
|
|
4597
4597
|
var DEFAULT_WATERMARK_CELL_HEIGHT = 330;
|
|
4598
4598
|
var DEFAULT_STRIP_LOGO_URL = "https://static.heartbitai.com/geo/icon/favicon.png";
|
|
4599
|
-
var DEFAULT_IP_LOOKUP_URL = "
|
|
4599
|
+
var DEFAULT_IP_LOOKUP_URL = "https://myip.ipip.net/json";
|
|
4600
4600
|
var DEFAULT_LOGO_FETCH_TIMEOUT_MS = 2500;
|
|
4601
4601
|
var DEFAULT_STRIP_ONE_LINE_HEIGHT = 78;
|
|
4602
4602
|
var DEFAULT_STRIP_WRAPPED_MIN_HEIGHT = 108;
|
|
@@ -4643,6 +4643,7 @@ var LOCATION_NETWORK_SUFFIX_PATTERNS = [
|
|
|
4643
4643
|
];
|
|
4644
4644
|
var cachedStripLogoSrcPromise = null;
|
|
4645
4645
|
var cachedEnrichmentByContext = /* @__PURE__ */ new WeakMap();
|
|
4646
|
+
var logger11 = createInternalLogger("Watermarkify");
|
|
4646
4647
|
var normalizeText = (value) => String(value || "").trim();
|
|
4647
4648
|
var toInline = (value, maxLen = 200) => {
|
|
4648
4649
|
const text = normalizeText(value);
|
|
@@ -4710,18 +4711,26 @@ var pickHeaderValue = async (response, names = []) => {
|
|
|
4710
4711
|
}
|
|
4711
4712
|
return "";
|
|
4712
4713
|
};
|
|
4713
|
-
var
|
|
4714
|
+
var parseIpIpJsonResponse = (rawText) => {
|
|
4714
4715
|
const text = normalizeWhitespace(rawText);
|
|
4715
|
-
if (!text)
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4716
|
+
if (!text || !text.startsWith("{") && !text.startsWith("[")) {
|
|
4717
|
+
return null;
|
|
4718
|
+
}
|
|
4719
|
+
try {
|
|
4720
|
+
const payload = JSON.parse(text);
|
|
4721
|
+
const ip = toInline(payload?.data?.ip || payload?.ip, 80);
|
|
4722
|
+
const locationParts = Array.isArray(payload?.data?.location) ? payload.data.location.map((item) => normalizeWhitespace(item)).filter(Boolean) : [];
|
|
4723
|
+
const location = toInline(
|
|
4724
|
+
stripLocationNetworkSuffix(locationParts.join(" ")),
|
|
4725
|
+
80
|
|
4726
|
+
);
|
|
4727
|
+
if (!ip && !location) {
|
|
4728
|
+
return null;
|
|
4729
|
+
}
|
|
4730
|
+
return { ip, location };
|
|
4731
|
+
} catch {
|
|
4722
4732
|
return null;
|
|
4723
4733
|
}
|
|
4724
|
-
return { ip, location };
|
|
4725
4734
|
};
|
|
4726
4735
|
var fillEnrichment = (target, source) => {
|
|
4727
4736
|
if (!target || !source || typeof source !== "object") {
|
|
@@ -4871,10 +4880,16 @@ var resolveWithCustomResolver = async (page, baseMeta, options = {}) => {
|
|
|
4871
4880
|
if (!resolved || typeof resolved !== "object") {
|
|
4872
4881
|
return null;
|
|
4873
4882
|
}
|
|
4874
|
-
|
|
4883
|
+
const enrichment = {
|
|
4875
4884
|
ip: toInline(resolved.ip, 80),
|
|
4876
4885
|
location: toInline(resolved.location, 80)
|
|
4877
4886
|
};
|
|
4887
|
+
if (enrichment.ip || enrichment.location) {
|
|
4888
|
+
logger11.info(`\u81EA\u5B9A\u4E49 resolver \u547D\u4E2D: ip=${enrichment.ip || "-"}, loc=${enrichment.location || "-"}`);
|
|
4889
|
+
} else {
|
|
4890
|
+
logger11.warning("\u81EA\u5B9A\u4E49 resolver \u5DF2\u6267\u884C\uFF0C\u4F46\u672A\u8FD4\u56DE IP/Loc");
|
|
4891
|
+
}
|
|
4892
|
+
return enrichment;
|
|
4878
4893
|
} finally {
|
|
4879
4894
|
controller?.abort();
|
|
4880
4895
|
}
|
|
@@ -4931,6 +4946,7 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
4931
4946
|
}
|
|
4932
4947
|
const probeScope = await openProbePage(page);
|
|
4933
4948
|
if (!probeScope?.page) {
|
|
4949
|
+
logger11.warning("ipLookup \u8DF3\u8FC7: \u65E0\u6CD5\u521B\u5EFA probe page");
|
|
4934
4950
|
return null;
|
|
4935
4951
|
}
|
|
4936
4952
|
const timeoutMs = Math.max(
|
|
@@ -4939,10 +4955,16 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
4939
4955
|
);
|
|
4940
4956
|
try {
|
|
4941
4957
|
const probePage = probeScope.page;
|
|
4958
|
+
logger11.info(`ipLookup \u5C1D\u8BD5: url=${DEFAULT_IP_LOOKUP_URL}, timeoutMs=${timeoutMs}`);
|
|
4942
4959
|
const response = await probePage.goto(DEFAULT_IP_LOOKUP_URL, {
|
|
4943
4960
|
waitUntil: "commit",
|
|
4944
4961
|
timeout: timeoutMs
|
|
4945
|
-
}).catch(() =>
|
|
4962
|
+
}).catch((error) => {
|
|
4963
|
+
logger11.warning(`ipLookup \u8BF7\u6C42\u5931\u8D25: url=${DEFAULT_IP_LOOKUP_URL}, error=${error instanceof Error ? error.message : String(error)}`);
|
|
4964
|
+
return null;
|
|
4965
|
+
});
|
|
4966
|
+
const status = response && typeof response.status === "function" ? response.status() : 0;
|
|
4967
|
+
const contentType = normalizeText(await pickHeaderValue(response, ["content-type"]));
|
|
4946
4968
|
let rawText = "";
|
|
4947
4969
|
if (response && typeof response.text === "function") {
|
|
4948
4970
|
rawText = String(await withTimeout(
|
|
@@ -4958,8 +4980,15 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
4958
4980
|
Math.min(timeoutMs, 500)
|
|
4959
4981
|
) || "");
|
|
4960
4982
|
}
|
|
4961
|
-
|
|
4962
|
-
|
|
4983
|
+
const parsed = parseIpIpJsonResponse(rawText);
|
|
4984
|
+
if (parsed?.ip || parsed?.location) {
|
|
4985
|
+
logger11.info(`ipLookup \u6210\u529F: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, ip=${parsed.ip || "-"}, loc=${parsed.location || "-"}`);
|
|
4986
|
+
return parsed;
|
|
4987
|
+
}
|
|
4988
|
+
logger11.warning(`ipLookup \u672A\u89E3\u6790\u51FA IP/Loc: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, preview=${shortenTail(rawText, 120) || "[empty]"}`);
|
|
4989
|
+
return null;
|
|
4990
|
+
} catch (error) {
|
|
4991
|
+
logger11.warning(`ipLookup \u6267\u884C\u5F02\u5E38\uFF0C\u672A\u83B7\u5F97 IP/Loc: ${error instanceof Error ? error.message : String(error)}`);
|
|
4963
4992
|
return null;
|
|
4964
4993
|
} finally {
|
|
4965
4994
|
await probeScope.close().catch(() => {
|
|
@@ -4973,7 +5002,11 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
4973
5002
|
ip: toInline(options.ip, 80),
|
|
4974
5003
|
location: toInline(options.location, 80)
|
|
4975
5004
|
};
|
|
5005
|
+
logger11.info(`enrichment \u5F00\u59CB: host=${baseMeta.hostname || "-"}, hasPresetIp=${Boolean(merged.ip)}, hasPresetLoc=${Boolean(merged.location)}, ipLookup=${options.ipLookup !== false}`);
|
|
4976
5006
|
if (!merged.ip || !merged.location) {
|
|
5007
|
+
if (cached?.ip || cached?.location) {
|
|
5008
|
+
logger11.info(`enrichment \u547D\u4E2D\u4E0A\u4E0B\u6587\u7F13\u5B58: ip=${cached.ip || "-"}, loc=${cached.location || "-"}`);
|
|
5009
|
+
}
|
|
4977
5010
|
fillEnrichment(merged, cached);
|
|
4978
5011
|
}
|
|
4979
5012
|
if (!merged.ip || !merged.location) {
|
|
@@ -4996,10 +5029,16 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
4996
5029
|
"x-geo-country"
|
|
4997
5030
|
]), 80);
|
|
4998
5031
|
if (!merged.location || isWeakLocationValue(merged.location) && headerLocation) {
|
|
5032
|
+
logger11.info(`enrichment \u4F7F\u7528\u54CD\u5E94\u5934\u8865\u5145 Loc: ${headerLocation || "-"}`);
|
|
4999
5033
|
merged.location = headerLocation || merged.location;
|
|
5000
5034
|
}
|
|
5001
5035
|
}
|
|
5002
5036
|
writeCachedEnrichment(page, merged);
|
|
5037
|
+
if (merged.ip || merged.location) {
|
|
5038
|
+
logger11.info(`enrichment \u5B8C\u6210: ip=${merged.ip || "-"}, loc=${merged.location || "-"}`);
|
|
5039
|
+
} else {
|
|
5040
|
+
logger11.warning("enrichment \u5B8C\u6210: \u672A\u83B7\u5F97 IP/Loc");
|
|
5041
|
+
}
|
|
5003
5042
|
return merged;
|
|
5004
5043
|
};
|
|
5005
5044
|
var buildWatermarkStamp = ({ prompt, captureTime, ip, location }) => {
|
|
@@ -5678,7 +5717,7 @@ var watermarkifyScreenshotBuffer = async (buffer, meta) => {
|
|
|
5678
5717
|
};
|
|
5679
5718
|
|
|
5680
5719
|
// src/share.js
|
|
5681
|
-
var
|
|
5720
|
+
var logger12 = createInternalLogger("Share");
|
|
5682
5721
|
var DEFAULT_TIMEOUT_MS2 = 50 * 1e3;
|
|
5683
5722
|
var DEFAULT_PAYLOAD_SNAPSHOT_MAX_LEN = 500;
|
|
5684
5723
|
var DEFAULT_POLL_INTERVAL_MS = 120;
|
|
@@ -5815,7 +5854,7 @@ var createDomShareMonitor = async (page, options = {}) => {
|
|
|
5815
5854
|
const onMatch = typeof options.onMatch === "function" ? options.onMatch : null;
|
|
5816
5855
|
const onTelemetry = typeof options.onTelemetry === "function" ? options.onTelemetry : null;
|
|
5817
5856
|
let matched = false;
|
|
5818
|
-
|
|
5857
|
+
logger12.info(`DOM \u76D1\u542C\u51C6\u5907\u6302\u8F7D: selectors=${toJsonInline(selectors, 120)}, mode=${mode}`);
|
|
5819
5858
|
const monitor = await Mutation.useMonitor(page, selectors, {
|
|
5820
5859
|
mode,
|
|
5821
5860
|
onMutation: (context = {}) => {
|
|
@@ -5833,12 +5872,12 @@ ${text}`;
|
|
|
5833
5872
|
});
|
|
5834
5873
|
}
|
|
5835
5874
|
if (mutationCount <= 5 || mutationCount % 50 === 0) {
|
|
5836
|
-
|
|
5875
|
+
logger12.info(`DOM \u53D8\u5316\u5DF2\u6355\u83B7: mutationCount=${mutationCount}, mutationNodes=${mutationNodes.length}`);
|
|
5837
5876
|
}
|
|
5838
5877
|
const [candidate] = Utils.parseLinks(rawDom, { prefix }) || [];
|
|
5839
5878
|
if (!candidate) return;
|
|
5840
5879
|
matched = true;
|
|
5841
|
-
|
|
5880
|
+
logger12.success("captureLink.domHit", `DOM \u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: mutationCount=${mutationCount}, link=${candidate}`);
|
|
5842
5881
|
if (onMatch) {
|
|
5843
5882
|
onMatch({
|
|
5844
5883
|
link: candidate,
|
|
@@ -5854,7 +5893,7 @@ ${text}`;
|
|
|
5854
5893
|
return {
|
|
5855
5894
|
stop: async () => {
|
|
5856
5895
|
const result = await monitor.stop();
|
|
5857
|
-
|
|
5896
|
+
logger12.info(`DOM \u76D1\u542C\u5DF2\u505C\u6B62: totalMutations=${result?.totalMutations || 0}`);
|
|
5858
5897
|
return result;
|
|
5859
5898
|
}
|
|
5860
5899
|
};
|
|
@@ -5894,8 +5933,8 @@ var Share = {
|
|
|
5894
5933
|
if (share.mode === "response" && apiMatchers.length === 0) {
|
|
5895
5934
|
throw new Error("Share.captureLink requires share.xurl[0] api matcher when mode=response");
|
|
5896
5935
|
}
|
|
5897
|
-
|
|
5898
|
-
|
|
5936
|
+
logger12.start("captureLink", `mode=${share.mode}, timeoutMs=${timeoutMs}, prefix=${share.prefix}`);
|
|
5937
|
+
logger12.info(`captureLink \u914D\u7F6E: xurl=${toJsonInline(share.xurl)}, domMode=${domMode}, domSelectors=${toJsonInline(domSelectors, 120)}`);
|
|
5899
5938
|
const stats = {
|
|
5900
5939
|
actionTimedOut: false,
|
|
5901
5940
|
domMutationCount: 0,
|
|
@@ -5920,7 +5959,7 @@ var Share = {
|
|
|
5920
5959
|
link: validated,
|
|
5921
5960
|
payloadText: String(payloadText || "")
|
|
5922
5961
|
};
|
|
5923
|
-
|
|
5962
|
+
logger12.info(`\u5019\u9009\u94FE\u63A5\u5DF2\u786E\u8BA4: source=${source}, link=${validated}`);
|
|
5924
5963
|
return true;
|
|
5925
5964
|
};
|
|
5926
5965
|
const resolveResponseCandidate = (responseText) => {
|
|
@@ -5955,7 +5994,7 @@ var Share = {
|
|
|
5955
5994
|
try {
|
|
5956
5995
|
await monitor.stop();
|
|
5957
5996
|
} catch (error) {
|
|
5958
|
-
|
|
5997
|
+
logger12.warning(`\u505C\u6B62 DOM \u76D1\u542C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
5959
5998
|
}
|
|
5960
5999
|
};
|
|
5961
6000
|
const onResponse = async (response) => {
|
|
@@ -5968,29 +6007,29 @@ var Share = {
|
|
|
5968
6007
|
stats.responseSampleUrls.push(url);
|
|
5969
6008
|
}
|
|
5970
6009
|
if (stats.responseObserved <= 5) {
|
|
5971
|
-
|
|
6010
|
+
logger12.info(`\u63A5\u53E3\u54CD\u5E94\u91C7\u6837(${stats.responseObserved}): ${url}`);
|
|
5972
6011
|
}
|
|
5973
6012
|
if (!apiMatchers.some((matcher) => url.includes(matcher))) return;
|
|
5974
6013
|
stats.responseMatched += 1;
|
|
5975
6014
|
stats.lastMatchedUrl = url;
|
|
5976
|
-
|
|
6015
|
+
logger12.info(`\u63A5\u53E3\u547D\u4E2D\u5339\u914D(${stats.responseMatched}): ${url}`);
|
|
5977
6016
|
const text = await response.text();
|
|
5978
6017
|
const hit = resolveResponseCandidate(text);
|
|
5979
6018
|
if (!hit?.link) {
|
|
5980
6019
|
if (stats.responseMatched <= 3) {
|
|
5981
|
-
|
|
6020
|
+
logger12.info(`\u63A5\u53E3\u89E3\u6790\u5B8C\u6210\u4F46\u672A\u63D0\u53D6\u5230\u5206\u4EAB\u94FE\u63A5: payloadSize=${text.length}`);
|
|
5982
6021
|
}
|
|
5983
6022
|
return;
|
|
5984
6023
|
}
|
|
5985
6024
|
stats.responseResolved += 1;
|
|
5986
|
-
|
|
6025
|
+
logger12.success("captureLink.responseHit", `\u63A5\u53E3\u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: url=${url}, link=${hit.link}`);
|
|
5987
6026
|
setCandidate("response", hit.link, hit.payloadText);
|
|
5988
6027
|
} catch (error) {
|
|
5989
|
-
|
|
6028
|
+
logger12.warning(`\u63A5\u53E3\u54CD\u5E94\u5904\u7406\u5F02\u5E38: ${error instanceof Error ? error.message : String(error)}`);
|
|
5990
6029
|
}
|
|
5991
6030
|
};
|
|
5992
6031
|
if (share.mode === "dom") {
|
|
5993
|
-
|
|
6032
|
+
logger12.info("\u5F53\u524D\u4E3A DOM \u6A21\u5F0F\uFF0C\u4EC5\u542F\u7528 DOM \u76D1\u542C");
|
|
5994
6033
|
domMonitor = await createDomShareMonitor(page, {
|
|
5995
6034
|
prefix: share.prefix,
|
|
5996
6035
|
selectors: domSelectors,
|
|
@@ -6005,14 +6044,14 @@ var Share = {
|
|
|
6005
6044
|
});
|
|
6006
6045
|
}
|
|
6007
6046
|
if (share.mode === "response") {
|
|
6008
|
-
|
|
6047
|
+
logger12.info(`\u5F53\u524D\u4E3A\u63A5\u53E3\u6A21\u5F0F\uFF0C\u6302\u8F7D response \u76D1\u542C: apiMatchers=${toJsonInline(apiMatchers, 160)}`);
|
|
6009
6048
|
page.on("response", onResponse);
|
|
6010
6049
|
}
|
|
6011
6050
|
const deadline = Date.now() + timeoutMs;
|
|
6012
6051
|
const getRemainingMs = () => Math.max(0, deadline - Date.now());
|
|
6013
6052
|
try {
|
|
6014
6053
|
const actionTimeout = getRemainingMs();
|
|
6015
|
-
|
|
6054
|
+
logger12.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${actionTimeout}ms`);
|
|
6016
6055
|
if (actionTimeout > 0) {
|
|
6017
6056
|
let timer = null;
|
|
6018
6057
|
let actionError = null;
|
|
@@ -6026,21 +6065,21 @@ var Share = {
|
|
|
6026
6065
|
const actionResult = await Promise.race([actionPromise, timeoutPromise]);
|
|
6027
6066
|
if (timer) clearTimeout(timer);
|
|
6028
6067
|
if (actionResult === "__ACTION_ERROR__") {
|
|
6029
|
-
|
|
6068
|
+
logger12.fail("captureLink.performActions", actionError);
|
|
6030
6069
|
throw actionError;
|
|
6031
6070
|
}
|
|
6032
6071
|
if (actionResult === "__ACTION_TIMEOUT__") {
|
|
6033
6072
|
stats.actionTimedOut = true;
|
|
6034
|
-
|
|
6073
|
+
logger12.warning(`performActions \u5DF2\u8D85\u65F6 (${actionTimeout}ms)\uFF0C\u52A8\u4F5C\u53EF\u80FD\u4ECD\u5728\u5F02\u6B65\u6267\u884C`);
|
|
6035
6074
|
} else {
|
|
6036
|
-
|
|
6075
|
+
logger12.success("captureLink.performActions", "\u6267\u884C\u52A8\u4F5C\u5B8C\u6210");
|
|
6037
6076
|
}
|
|
6038
6077
|
}
|
|
6039
6078
|
let nextProgressLogTs = Date.now() + 3e3;
|
|
6040
6079
|
while (true) {
|
|
6041
6080
|
const selected = share.mode === "dom" ? candidates.dom : candidates.response;
|
|
6042
6081
|
if (selected?.link) {
|
|
6043
|
-
|
|
6082
|
+
logger12.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);
|
|
6044
6083
|
return {
|
|
6045
6084
|
link: selected.link,
|
|
6046
6085
|
payloadText: selected.payloadText,
|
|
@@ -6052,7 +6091,7 @@ var Share = {
|
|
|
6052
6091
|
if (remaining <= 0) break;
|
|
6053
6092
|
const now = Date.now();
|
|
6054
6093
|
if (now >= nextProgressLogTs) {
|
|
6055
|
-
|
|
6094
|
+
logger12.info(
|
|
6056
6095
|
`captureLink \u7B49\u5F85\u4E2D: remaining=${remaining}ms, domMutationCount=${stats.domMutationCount}, responseMatched=${stats.responseMatched}`
|
|
6057
6096
|
);
|
|
6058
6097
|
nextProgressLogTs = now + 5e3;
|
|
@@ -6060,11 +6099,11 @@ var Share = {
|
|
|
6060
6099
|
await (0, import_delay2.default)(Math.max(0, Math.min(DEFAULT_POLL_INTERVAL_MS, remaining)));
|
|
6061
6100
|
}
|
|
6062
6101
|
if (share.mode === "response" && stats.responseMatched === 0) {
|
|
6063
|
-
|
|
6102
|
+
logger12.warning(
|
|
6064
6103
|
`\u63A5\u53E3\u76D1\u542C\u672A\u547D\u4E2D: apiMatchers=${toJsonInline(apiMatchers, 220)}, \u54CD\u5E94\u6837\u672CURLs=${toJsonInline(stats.responseSampleUrls, 420)}`
|
|
6065
6104
|
);
|
|
6066
6105
|
}
|
|
6067
|
-
|
|
6106
|
+
logger12.warning(
|
|
6068
6107
|
`captureLink \u8D85\u65F6\u672A\u62FF\u5230\u94FE\u63A5: mode=${share.mode}, actionTimedOut=${stats.actionTimedOut}, domMutationCount=${stats.domMutationCount}, responseObserved=${stats.responseObserved}, responseMatched=${stats.responseMatched}, lastMatchedUrl=${stats.lastMatchedUrl || "none"}`
|
|
6069
6108
|
);
|
|
6070
6109
|
return {
|
|
@@ -6076,7 +6115,7 @@ var Share = {
|
|
|
6076
6115
|
} finally {
|
|
6077
6116
|
if (share.mode === "response") {
|
|
6078
6117
|
page.off("response", onResponse);
|
|
6079
|
-
|
|
6118
|
+
logger12.info("response \u76D1\u542C\u5DF2\u5378\u8F7D");
|
|
6080
6119
|
}
|
|
6081
6120
|
await stopDomMonitor();
|
|
6082
6121
|
}
|