@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.js CHANGED
@@ -225,25 +225,24 @@ var ActorInfo = {
225
225
  path: "/",
226
226
  device: Device.Mobile,
227
227
  share: {
228
- mode: "custom",
229
- prefix: "",
230
- xurl: []
228
+ mode: "response",
229
+ prefix: "https://chat.baidu.com/csaitab/history/share?v=2&share_id=",
230
+ xurl: [
231
+ "/aichat/api/getShareToken",
232
+ "data",
233
+ "token"
234
+ ]
231
235
  }
232
236
  }),
233
237
  baidu: createActorInfo({
234
238
  key: "baidu",
235
239
  name: "\u767E\u5EA6AI\u641C",
236
240
  domain: "www.baidu.com",
237
- device: Device.Mobile,
238
241
  path: "/s",
239
242
  share: {
240
- mode: "response",
243
+ mode: "dom",
241
244
  prefix: "",
242
- xurl: [
243
- "/aichat/api/shortURL",
244
- "data",
245
- "short_url"
246
- ]
245
+ xurl: []
247
246
  }
248
247
  }),
249
248
  yuanbao: createActorInfo({
@@ -9042,6 +9041,13 @@ var Share = {
9042
9041
  const domMode = options.domMode ?? Mutation.Mode.All;
9043
9042
  const performActions = typeof options.performActions === "function" ? options.performActions : async () => {
9044
9043
  };
9044
+ const signal = options.signal;
9045
+ const isAborted = () => Boolean(signal?.aborted);
9046
+ const abortReason = () => {
9047
+ const reason = signal?.reason;
9048
+ if (reason instanceof Error) return reason.message;
9049
+ return reason ? String(reason) : "aborted";
9050
+ };
9045
9051
  if (share.prefix === void 0) {
9046
9052
  throw new Error("Share.captureLink requires options.share.prefix");
9047
9053
  }
@@ -9065,6 +9071,15 @@ var Share = {
9065
9071
  lastMatchedUrl: "",
9066
9072
  responseSampleUrls: []
9067
9073
  };
9074
+ if (isAborted()) {
9075
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9076
+ return {
9077
+ link: null,
9078
+ payloadText: "",
9079
+ payloadSnapshot: abortReason(),
9080
+ source: "none"
9081
+ };
9082
+ }
9068
9083
  const candidates = {
9069
9084
  dom: null,
9070
9085
  response: null,
@@ -9123,6 +9138,7 @@ var Share = {
9123
9138
  if (candidates.response?.link) return;
9124
9139
  stats.responseObserved += 1;
9125
9140
  try {
9141
+ if (isAborted()) return;
9126
9142
  const url = String(response.url() || "");
9127
9143
  if (url && stats.responseSampleUrls.length < 8 && !stats.responseSampleUrls.includes(url)) {
9128
9144
  stats.responseSampleUrls.push(url);
@@ -9177,7 +9193,7 @@ var Share = {
9177
9193
  const actionTimeout = getRemainingMs();
9178
9194
  logger15.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${actionTimeout}ms`);
9179
9195
  let actionValue;
9180
- if (actionTimeout > 0) {
9196
+ if (!isAborted() && actionTimeout > 0) {
9181
9197
  let timer = null;
9182
9198
  const actionPromise = Promise.resolve().then(() => performActions()).then((result) => ({ type: "done", result })).catch((error) => ({ type: "error", error }));
9183
9199
  const timeoutPromise = new Promise((resolve) => {
@@ -9208,6 +9224,15 @@ var Share = {
9208
9224
  }
9209
9225
  let nextProgressLogTs = Date.now() + 3e3;
9210
9226
  while (true) {
9227
+ if (isAborted()) {
9228
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9229
+ return {
9230
+ link: null,
9231
+ payloadText: "",
9232
+ payloadSnapshot: abortReason(),
9233
+ source: "none"
9234
+ };
9235
+ }
9211
9236
  const selected = candidates[share.mode];
9212
9237
  if (selected?.link) {
9213
9238
  logger15.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);