@skrillex1224/playwright-toolkit 3.0.42 → 3.0.44

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
@@ -98,6 +98,12 @@ var createActorInfo = (info) => {
98
98
  if (!raw) return "/";
99
99
  return raw.startsWith("/") ? raw : `/${raw}`;
100
100
  };
101
+ const normalizePaths = (value) => {
102
+ const raw = value && typeof value === "object" && !Array.isArray(value) ? value : {};
103
+ return Object.fromEntries(
104
+ Object.entries(raw).map(([key, item]) => [String(key || "").trim(), normalizePath(item)]).filter(([key]) => Boolean(key))
105
+ );
106
+ };
101
107
  const normalizeShare2 = (value) => {
102
108
  const raw = value && typeof value === "object" ? value : {};
103
109
  const modeRaw = String(raw.mode || "dom").trim().toLowerCase();
@@ -164,6 +170,7 @@ var createActorInfo = (info) => {
164
170
  const protocol = info.protocol || "https";
165
171
  const domain = normalizeDomain(info.domain);
166
172
  const path3 = normalizePath(info.path);
173
+ const paths = Object.freeze(normalizePaths(info.paths));
167
174
  const share = normalizeShare2(info.share);
168
175
  const device = normalizeDevice(info.device);
169
176
  return {
@@ -173,6 +180,9 @@ var createActorInfo = (info) => {
173
180
  path: path3,
174
181
  share,
175
182
  device,
183
+ get paths() {
184
+ return paths;
185
+ },
176
186
  get icon() {
177
187
  if (info.icon) return info.icon;
178
188
  return buildIcon(this);
@@ -210,6 +220,11 @@ var ActorInfo = {
210
220
  name: "\u7075\u5149",
211
221
  domain: "www.lingguang.com",
212
222
  path: "/",
223
+ paths: {
224
+ settings: "/settings/personal",
225
+ personalization: "/settings/personal",
226
+ memory: "/settings/personal"
227
+ },
213
228
  share: {
214
229
  mode: "response",
215
230
  prefix: "https://www.lingguang.com/share/",
@@ -224,6 +239,11 @@ var ActorInfo = {
224
239
  name: "\u8C46\u5305",
225
240
  domain: "www.doubao.com",
226
241
  path: "/",
242
+ paths: {
243
+ settings: "/settings/memory",
244
+ privacy: "/settings/memory",
245
+ memory: "/settings/memory"
246
+ },
227
247
  device: Device.Desktop,
228
248
  share: {
229
249
  mode: "response",
@@ -240,6 +260,10 @@ var ActorInfo = {
240
260
  name: "DeepSeek",
241
261
  domain: "chat.deepseek.com",
242
262
  path: "/",
263
+ paths: {
264
+ settings: "/",
265
+ personalization: "/"
266
+ },
243
267
  share: {
244
268
  mode: "response",
245
269
  prefix: "https://chat.deepseek.com/share/",
@@ -294,6 +318,11 @@ var ActorInfo = {
294
318
  name: "\u5143\u5B9D",
295
319
  domain: "yuanbao.tencent.com",
296
320
  path: "/chat/",
321
+ paths: {
322
+ settings: "/setting",
323
+ personalization: "/setting",
324
+ memory: "/setting"
325
+ },
297
326
  device: Device.Mobile,
298
327
  share: {
299
328
  mode: "response",
@@ -309,6 +338,10 @@ var ActorInfo = {
309
338
  name: "Kimi",
310
339
  domain: "www.kimi.com",
311
340
  path: "/",
341
+ paths: {
342
+ settings: "/settings?toOpenItem=memory",
343
+ memory: "/settings?toOpenItem=memory"
344
+ },
312
345
  device: Device.Mobile,
313
346
  share: {
314
347
  mode: "response",
@@ -325,6 +358,10 @@ var ActorInfo = {
325
358
  name: "\u901A\u4E49\u5343\u95EE",
326
359
  domain: "www.qianwen.com",
327
360
  path: "/chat",
361
+ paths: {
362
+ settings: "/chat",
363
+ memory: "/chat"
364
+ },
328
365
  device: Device.Mobile,
329
366
  share: {
330
367
  mode: "response",
@@ -341,6 +378,10 @@ var ActorInfo = {
341
378
  name: "\u7EB3\u7C73",
342
379
  domain: "www.n.cn",
343
380
  path: "/",
381
+ paths: {
382
+ settings: "/",
383
+ memory: "/"
384
+ },
344
385
  share: {
345
386
  mode: "response",
346
387
  prefix: "https://www.n.cn/share/mcp?id=",
@@ -1631,6 +1672,7 @@ var PageRuntimeStateKey = "__playwright_toolkit_runtime_state__";
1631
1672
  var BROWSER_PROFILE_SCHEMA_VERSION = 1;
1632
1673
  var SUPPORTED_CLOAK_FINGERPRINT_PLATFORMS = /* @__PURE__ */ new Set(["linux", "macos", "windows"]);
1633
1674
  var logger3 = createInternalLogger("RuntimeEnv");
1675
+ var MAX_RUNTIME_STORAGE_VALUE_CHARS = 256 * 1024;
1634
1676
  var rememberedRuntimeState = null;
1635
1677
  var isPlainObject = (value) => value && typeof value === "object" && !Array.isArray(value);
1636
1678
  var normalizeKnownDevice = (value) => {
@@ -1674,25 +1716,23 @@ var tryParseJSON = (value) => {
1674
1716
  return null;
1675
1717
  }
1676
1718
  };
1677
- var normalizeLocalStorage = (value) => {
1719
+ var normalizeStorageString = (value) => String(value ?? "").replace(/\u0000/g, "").trim();
1720
+ var normalizeStorageEntries = (value) => {
1678
1721
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1679
1722
  return Object.entries(source).reduce((acc, [key, item]) => {
1680
- const safeKey = String(key || "").trim();
1681
- const safeValue = String(item ?? "").trim();
1723
+ const safeKey = normalizeStorageString(key);
1724
+ const safeValue = normalizeStorageString(item);
1682
1725
  if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
1726
+ if (safeValue.length > MAX_RUNTIME_STORAGE_VALUE_CHARS) return acc;
1683
1727
  acc[safeKey] = safeValue;
1684
1728
  return acc;
1685
1729
  }, {});
1686
1730
  };
1731
+ var normalizeLocalStorage = (value) => {
1732
+ return normalizeStorageEntries(value);
1733
+ };
1687
1734
  var normalizeSessionStorage = (value) => {
1688
- const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1689
- return Object.entries(source).reduce((acc, [key, item]) => {
1690
- const safeKey = String(key || "").trim();
1691
- const safeValue = String(item ?? "").trim();
1692
- if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
1693
- acc[safeKey] = safeValue;
1694
- return acc;
1695
- }, {});
1735
+ return normalizeStorageEntries(value);
1696
1736
  };
1697
1737
  var normalizeCookieSameSite = (value) => {
1698
1738
  const raw = String(value || "").trim().toLowerCase();
@@ -1882,29 +1922,28 @@ var captureRawSnapshotFromPage = async (page) => {
1882
1922
  return "";
1883
1923
  }
1884
1924
  }) : [];
1885
- const snapshot = await page.evaluate(() => {
1886
- const localStorage = {};
1887
- const sessionStorage = {};
1925
+ const snapshot = await page.evaluate((maxStorageValueChars) => {
1926
+ const normalizeStorageStringInPage = (value) => String(value ?? "").replace(/\u0000/g, "").trim();
1927
+ const readStorageArea = (storage) => {
1928
+ const result = {};
1929
+ try {
1930
+ for (let i = 0; i < storage.length; i += 1) {
1931
+ const rawKey = storage.key(i);
1932
+ const key = normalizeStorageStringInPage(rawKey);
1933
+ if (!key) continue;
1934
+ const value = normalizeStorageStringInPage(storage.getItem(rawKey));
1935
+ if (!value || value === "<nil>") continue;
1936
+ if (value.length > maxStorageValueChars) continue;
1937
+ result[key] = value;
1938
+ }
1939
+ } catch {
1940
+ }
1941
+ return result;
1942
+ };
1943
+ const localStorage = readStorageArea(window.localStorage);
1944
+ const sessionStorage = readStorageArea(window.sessionStorage);
1888
1945
  const resourceUrls = [];
1889
1946
  const frameUrls2 = [];
1890
- try {
1891
- for (let i = 0; i < window.localStorage.length; i += 1) {
1892
- const key = window.localStorage.key(i);
1893
- if (!key) continue;
1894
- const value = window.localStorage.getItem(key);
1895
- if (value !== null) localStorage[key] = value;
1896
- }
1897
- } catch {
1898
- }
1899
- try {
1900
- for (let i = 0; i < window.sessionStorage.length; i += 1) {
1901
- const key = window.sessionStorage.key(i);
1902
- if (!key) continue;
1903
- const value = window.sessionStorage.getItem(key);
1904
- if (value !== null) sessionStorage[key] = value;
1905
- }
1906
- } catch {
1907
- }
1908
1947
  try {
1909
1948
  const perfEntries = performance.getEntriesByType("resource") || [];
1910
1949
  perfEntries.forEach((entry) => {
@@ -1951,7 +1990,7 @@ var captureRawSnapshotFromPage = async (page) => {
1951
1990
  }
1952
1991
  }
1953
1992
  };
1954
- });
1993
+ }, MAX_RUNTIME_STORAGE_VALUE_CHARS);
1955
1994
  return normalizeRawSnapshot({
1956
1995
  ...snapshot,
1957
1996
  frame_urls: [...frameUrls, ...snapshot?.frame_urls || []]
@@ -9887,11 +9926,11 @@ var watermarkifyScreenshotBuffer = async (buffer, meta, page = null, options = {
9887
9926
  // src/internals/compression.js
9888
9927
  var import_jimp2 = require("jimp");
9889
9928
  var logger16 = createInternalLogger("Compression");
9890
- var DEFAULT_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
9929
+ var DEFAULT_SCREENSHOT_MAX_BYTES = 500 * 1024;
9891
9930
  var DEFAULT_SCREENSHOT_OUTPUT_TYPE = "jpeg";
9892
- var DEFAULT_SCREENSHOT_QUALITY = 0.72;
9893
- var DEFAULT_SCREENSHOT_MIN_QUALITY = 0.38;
9894
- var DEFAULT_SCREENSHOT_MIN_SCALE = 0.25;
9931
+ var DEFAULT_SCREENSHOT_QUALITY = 0.32;
9932
+ var DEFAULT_SCREENSHOT_MIN_QUALITY = 0.32;
9933
+ var DEFAULT_SCREENSHOT_MIN_SCALE = 0.2;
9895
9934
  var SUPPORTED_SCREENSHOT_OUTPUT_TYPES = /* @__PURE__ */ new Set(["jpeg"]);
9896
9935
  var toPositiveInteger2 = (value, fallback = 0) => {
9897
9936
  const number = Math.floor(Number(value) || 0);
@@ -10476,7 +10515,7 @@ var Share = {
10476
10515
  * @param {Object} [options]
10477
10516
  * @param {boolean} [options.restore]
10478
10517
  * @param {number} [options.maxHeight]
10479
- * @param {number} [options.maxBytes] 默认 5MiB,返回 base64 超过后会压缩
10518
+ * @param {number} [options.maxBytes] 默认 500KiB,返回 base64 超过后会压缩
10480
10519
  * @param {'jpeg'|'jpg'} [options.type] 压缩输出格式,默认 jpeg
10481
10520
  * @param {boolean|Object} [options.compression] 传 false 可关闭压缩
10482
10521
  * @param {'default'|'cloak'} [options.mode] 截图水印合成模式,默认取当前 toolkit mode