@skrillex1224/playwright-toolkit 2.1.214 → 2.1.215

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/browser.js CHANGED
@@ -2920,16 +2920,6 @@ var normalizeSessionStorage = (value) => {
2920
2920
  return acc;
2921
2921
  }, {});
2922
2922
  };
2923
- var normalizeAuth = (value) => {
2924
- const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
2925
- return Object.entries(source).reduce((acc, [key, item]) => {
2926
- const safeKey = String(key || "").trim();
2927
- const safeValue = String(item != null ? item : "").trim();
2928
- if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
2929
- acc[safeKey] = safeValue;
2930
- return acc;
2931
- }, {});
2932
- };
2933
2923
  var normalizeCookieSameSite = (value) => {
2934
2924
  const raw = String(value || "").trim().toLowerCase();
2935
2925
  if (!raw) return "";
@@ -3064,8 +3054,7 @@ var normalizeRawSnapshot = (value = {}) => {
3064
3054
  cookies: Array.isArray(source.cookies) ? deepClone(source.cookies) : [],
3065
3055
  local_storage: normalizeLocalStorage((_j = source.local_storage) != null ? _j : source.localStorage),
3066
3056
  session_storage: normalizeSessionStorage((_k = source.session_storage) != null ? _k : source.sessionStorage),
3067
- browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource),
3068
- auth: normalizeAuth(source.auth)
3057
+ browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource)
3069
3058
  };
3070
3059
  };
3071
3060
  var collectCookieUrlsFromSnapshot = (snapshot = {}) => {
@@ -3085,21 +3074,19 @@ var filterCookiesBySnapshot = (cookies = [], snapshot = {}) => {
3085
3074
  return normalizedCookies.filter((cookie) => cookieUrls.some((url) => doesCookieMatchUrl(cookie, url)));
3086
3075
  };
3087
3076
  var buildEnvPayloadFromSnapshot = (snapshot = {}, options = {}) => {
3088
- var _a, _b, _c, _d, _e;
3077
+ var _a, _b, _c, _d;
3089
3078
  const normalized = normalizeRawSnapshot(snapshot);
3090
3079
  const cookies = filterCookiesBySnapshot((snapshot == null ? void 0 : snapshot.cookies) || normalized.cookies, normalized);
3091
3080
  const localStorage = normalized.local_storage;
3092
3081
  const sessionStorage = normalized.session_storage;
3093
- const auth = normalizeAuth((_a = options.auth) != null ? _a : normalized.auth);
3094
3082
  const browserProfileCore = normalizeBrowserProfileCore(
3095
- (_e = (_c = options.browserProfileCore) != null ? _c : (_b = snapshot == null ? void 0 : snapshot.browser_profile) == null ? void 0 : _b.core) != null ? _e : (_d = snapshot == null ? void 0 : snapshot.browserProfile) == null ? void 0 : _d.core
3083
+ (_d = (_b = options.browserProfileCore) != null ? _b : (_a = snapshot == null ? void 0 : snapshot.browser_profile) == null ? void 0 : _a.core) != null ? _d : (_c = snapshot == null ? void 0 : snapshot.browserProfile) == null ? void 0 : _c.core
3096
3084
  );
3097
3085
  const browserProfile = buildBrowserProfilePayload(browserProfileCore, normalized.browser_profile_observed);
3098
3086
  const payload = {
3099
3087
  ...cookies.length > 0 ? { cookies } : {},
3100
3088
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
3101
3089
  ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
3102
- ...Object.keys(auth).length > 0 ? { auth } : {},
3103
3090
  ...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
3104
3091
  };
3105
3092
  return Object.keys(payload).length > 0 ? payload : null;
@@ -3363,7 +3350,6 @@ var RuntimeEnv = {
3363
3350
  normalizeCookies,
3364
3351
  normalizeLocalStorage,
3365
3352
  normalizeSessionStorage,
3366
- normalizeAuth,
3367
3353
  normalizeBrowserProfileCore,
3368
3354
  normalizeObservedBrowserProfile,
3369
3355
  normalizeSnapshot(snapshot = {}) {
@@ -3391,15 +3377,12 @@ var RuntimeEnv = {
3391
3377
  const cookieMap = buildCookieMap(cookies);
3392
3378
  const localStorage = normalizeLocalStorage(runtime == null ? void 0 : runtime.local_storage);
3393
3379
  const sessionStorage = normalizeSessionStorage(runtime == null ? void 0 : runtime.session_storage);
3394
- const auth = normalizeAuth(runtime == null ? void 0 : runtime.auth);
3395
3380
  const browserProfile = normalizeBrowserProfile(runtime == null ? void 0 : runtime.browser_profile);
3396
3381
  const envId = String((input == null ? void 0 : input.env_id) || "").trim();
3397
3382
  const normalizedRuntime = {
3398
- ...runtime,
3399
3383
  ...cookies.length > 0 ? { cookies } : {},
3400
3384
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
3401
- ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
3402
- ...Object.keys(auth).length > 0 ? { auth } : {}
3385
+ ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {}
3403
3386
  };
3404
3387
  if (Object.keys(browserProfile.payload).length > 0) {
3405
3388
  normalizedRuntime.browser_profile = browserProfile.payload;
@@ -3411,7 +3394,6 @@ var RuntimeEnv = {
3411
3394
  runtime: normalizedRuntime,
3412
3395
  envId,
3413
3396
  query,
3414
- auth,
3415
3397
  cookies,
3416
3398
  cookieMap,
3417
3399
  localStorage,
@@ -3428,7 +3410,6 @@ var RuntimeEnv = {
3428
3410
  const state = normalizeRuntimeState(source, actor);
3429
3411
  const browserProfile = buildBrowserProfilePayload(state.browserProfileCore, state.browserProfileObserved);
3430
3412
  const envPatch = {
3431
- ...Object.keys(state.auth || {}).length > 0 ? { auth: state.auth } : {},
3432
3413
  ...Array.isArray(state.cookies) && state.cookies.length > 0 ? { cookies: state.cookies } : {},
3433
3414
  ...Object.keys(state.localStorage || {}).length > 0 ? { local_storage: state.localStorage } : {},
3434
3415
  ...Object.keys(state.sessionStorage || {}).length > 0 ? { session_storage: state.sessionStorage } : {},
@@ -3436,17 +3417,10 @@ var RuntimeEnv = {
3436
3417
  };
3437
3418
  return Object.keys(envPatch).length > 0 ? envPatch : null;
3438
3419
  },
3439
- // hasLoginState 用来区分“必须鉴权的平台”和“可匿名运行的平台”。
3420
+ // hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
3440
3421
  hasLoginState(source = {}, actor = "") {
3441
3422
  const state = normalizeRuntimeState(source, actor);
3442
- return Array.isArray(state.cookies) && state.cookies.length > 0 || Object.keys(state.localStorage || {}).length > 0 || Object.keys(state.sessionStorage || {}).length > 0 || Object.keys(state.auth || {}).length > 0;
3443
- },
3444
- getAuthValue(source = {}, key = "", actor = "") {
3445
- var _a, _b;
3446
- const state = normalizeRuntimeState(source, actor);
3447
- const safeKey = String(key || "").trim();
3448
- if (!safeKey) return "";
3449
- return String((_b = (_a = state.auth) == null ? void 0 : _a[safeKey]) != null ? _b : "").trim();
3423
+ return isPlainObject(state.runtime) && Object.keys(state.runtime || {}).length > 0;
3450
3424
  },
3451
3425
  rememberState(source = {}) {
3452
3426
  const state = normalizeRuntimeState(source);
@@ -3545,7 +3519,6 @@ var RuntimeEnv = {
3545
3519
  cookies
3546
3520
  },
3547
3521
  {
3548
- auth: state.auth,
3549
3522
  browserProfileCore: state.browserProfileCore
3550
3523
  }
3551
3524
  );