@skrillex1224/playwright-toolkit 2.1.255 → 2.1.257

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
@@ -252,25 +252,24 @@ var ActorInfo = {
252
252
  path: "/",
253
253
  device: Device.Mobile,
254
254
  share: {
255
- mode: "custom",
256
- prefix: "",
257
- xurl: []
255
+ mode: "response",
256
+ prefix: "https://chat.baidu.com/csaitab/history/share?v=2&share_id=",
257
+ xurl: [
258
+ "/aichat/api/getShareToken",
259
+ "data",
260
+ "token"
261
+ ]
258
262
  }
259
263
  }),
260
264
  baidu: createActorInfo({
261
265
  key: "baidu",
262
266
  name: "\u767E\u5EA6AI\u641C",
263
267
  domain: "www.baidu.com",
264
- device: Device.Mobile,
265
268
  path: "/s",
266
269
  share: {
267
- mode: "response",
270
+ mode: "dom",
268
271
  prefix: "",
269
- xurl: [
270
- "/aichat/api/shortURL",
271
- "data",
272
- "short_url"
273
- ]
272
+ xurl: []
274
273
  }
275
274
  }),
276
275
  yuanbao: createActorInfo({
@@ -9070,6 +9069,13 @@ var Share = {
9070
9069
  const domMode = options.domMode ?? Mutation.Mode.All;
9071
9070
  const performActions = typeof options.performActions === "function" ? options.performActions : async () => {
9072
9071
  };
9072
+ const signal = options.signal;
9073
+ const isAborted = () => Boolean(signal?.aborted);
9074
+ const abortReason = () => {
9075
+ const reason = signal?.reason;
9076
+ if (reason instanceof Error) return reason.message;
9077
+ return reason ? String(reason) : "aborted";
9078
+ };
9073
9079
  if (share.prefix === void 0) {
9074
9080
  throw new Error("Share.captureLink requires options.share.prefix");
9075
9081
  }
@@ -9093,6 +9099,15 @@ var Share = {
9093
9099
  lastMatchedUrl: "",
9094
9100
  responseSampleUrls: []
9095
9101
  };
9102
+ if (isAborted()) {
9103
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9104
+ return {
9105
+ link: null,
9106
+ payloadText: "",
9107
+ payloadSnapshot: abortReason(),
9108
+ source: "none"
9109
+ };
9110
+ }
9096
9111
  const candidates = {
9097
9112
  dom: null,
9098
9113
  response: null,
@@ -9151,6 +9166,7 @@ var Share = {
9151
9166
  if (candidates.response?.link) return;
9152
9167
  stats.responseObserved += 1;
9153
9168
  try {
9169
+ if (isAborted()) return;
9154
9170
  const url = String(response.url() || "");
9155
9171
  if (url && stats.responseSampleUrls.length < 8 && !stats.responseSampleUrls.includes(url)) {
9156
9172
  stats.responseSampleUrls.push(url);
@@ -9205,7 +9221,7 @@ var Share = {
9205
9221
  const actionTimeout = getRemainingMs();
9206
9222
  logger15.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${actionTimeout}ms`);
9207
9223
  let actionValue;
9208
- if (actionTimeout > 0) {
9224
+ if (!isAborted() && actionTimeout > 0) {
9209
9225
  let timer = null;
9210
9226
  const actionPromise = Promise.resolve().then(() => performActions()).then((result) => ({ type: "done", result })).catch((error) => ({ type: "error", error }));
9211
9227
  const timeoutPromise = new Promise((resolve) => {
@@ -9236,6 +9252,15 @@ var Share = {
9236
9252
  }
9237
9253
  let nextProgressLogTs = Date.now() + 3e3;
9238
9254
  while (true) {
9255
+ if (isAborted()) {
9256
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9257
+ return {
9258
+ link: null,
9259
+ payloadText: "",
9260
+ payloadSnapshot: abortReason(),
9261
+ source: "none"
9262
+ };
9263
+ }
9239
9264
  const selected = candidates[share.mode];
9240
9265
  if (selected?.link) {
9241
9266
  logger15.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);