@flemist/simple-utils 2.1.4 → 2.1.6

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.
Files changed (51) hide show
  1. package/build/browser/index.cjs +1 -1
  2. package/build/browser/index.mjs +175 -146
  3. package/build/common/async/Locker.d.ts +28 -0
  4. package/build/common/async/index.d.ts +2 -0
  5. package/build/common/async/promise.d.ts +7 -0
  6. package/build/common/cache/Cache.d.ts +46 -0
  7. package/build/common/cache/CacheStats.d.ts +20 -0
  8. package/build/common/cache/MemoryStorage.d.ts +11 -0
  9. package/build/common/cache/getHashKey.d.ts +1 -0
  10. package/build/common/cache/getJsonKey.d.ts +1 -0
  11. package/build/common/cache/index.d.ts +6 -0
  12. package/build/common/cache/types.d.ts +28 -0
  13. package/build/common/converter/converterErrorToBuffer.d.ts +2 -0
  14. package/build/common/converter/converterJson.d.ts +2 -0
  15. package/build/common/converter/converterJsonBuffer.d.ts +2 -0
  16. package/build/common/converter/converterStringToBuffer.d.ts +2 -0
  17. package/build/common/converter/helpers.d.ts +13 -0
  18. package/build/common/converter/index.d.ts +8 -0
  19. package/build/common/converter/mapObjectConverter.d.ts +2 -0
  20. package/build/common/converter/setArrayConverter.d.ts +2 -0
  21. package/build/common/converter/types.d.ts +41 -0
  22. package/build/common/gzip/compressGzip.d.ts +35 -0
  23. package/build/common/gzip/decompressGzip.d.ts +2 -0
  24. package/build/common/gzip/index.d.ts +2 -0
  25. package/build/common/index.cjs +1 -1
  26. package/build/common/index.d.ts +3 -0
  27. package/build/common/index.mjs +175 -146
  28. package/build/common/string/index.d.ts +1 -1
  29. package/build/node/cache/FileStatStorage.d.ts +23 -0
  30. package/build/node/cache/FileStorage.d.ts +29 -0
  31. package/build/node/cache/createConverterSubPath.d.ts +12 -0
  32. package/build/node/cache/createFileCacheOptions.d.ts +15 -0
  33. package/build/node/cache/generateTempFileName.d.ts +1 -0
  34. package/build/node/cache/index.d.ts +6 -0
  35. package/build/node/cache/writeFileThroughTmp.d.ts +2 -0
  36. package/build/node/fs/index.d.ts +1 -0
  37. package/build/node/fs/readDirRecursive.d.ts +6 -0
  38. package/build/node/index.cjs +8 -8
  39. package/build/node/index.d.ts +1 -0
  40. package/build/node/index.mjs +1063 -606
  41. package/build/node/test/helpers/common.d.ts +2 -0
  42. package/build/node/test/helpers/createTestE2e.d.ts +30 -0
  43. package/build/node/test/helpers/index.d.ts +3 -0
  44. package/build/node/test/helpers/waitPageStable.d.ts +35 -0
  45. package/build/node/test/index.d.ts +1 -0
  46. package/build/urlGet-BoqnOos7.js +17 -0
  47. package/build/urlGet-OHY_Qdk-.mjs +2416 -0
  48. package/package.json +37 -38
  49. package/build/common/time/dateToString.d.ts +0 -2
  50. package/build/urlGet-CerQ1cKh.js +0 -17
  51. package/build/urlGet-DZEwtNXt.mjs +0 -2000
@@ -1,55 +1,75 @@
1
- import { V as mt, S as pt, F as yt } from "../urlGet-DZEwtNXt.mjs";
2
- import { ac as he, M as de, W as me, X as pe, P as ye, aj as we, a2 as be, a3 as ge, b5 as xe, b6 as Ee, b7 as Se, b8 as ke, b9 as Oe, ba as je, bb as Ce, bk as Pe, bc as Ae, bd as Le, be as Te, bf as Me, bg as De, bh as Fe, bi as Ie, bj as Re, R as _e, $ as Ne, a0 as We, U as $e, L as Be, H as ze, a6 as Je, ad as Ue, ae as ve, K as He, I as Ge, N as Ke, q as Ve, aa as Ye, a9 as qe, a8 as Xe, Z as Qe, l as Ze, o as tr, B as er, C as rr, D as nr, E as sr, z as ar, A as or, a5 as ir, ag as cr, af as lr, Q as ur, u as fr, v as hr, w as dr, J as mr, p as pr, x as yr, d as wr, g as br, a4 as gr, _ as xr, ab as Er, aH as Sr, aJ as kr, am as Or, ak as jr, b4 as Cr, al as Pr, ap as Ar, aL as Lr, aO as Tr, aD as Mr, aC as Dr, aq as Fr, aZ as Ir, ax as Rr, aY as _r, av as Nr, aX as Wr, aA as $r, au as Br, a_ as zr, as as Jr, ar as Ur, ao as vr, b1 as Hr, aF as Gr, aE as Kr, at as Vr, aw as Yr, aR as qr, aS as Xr, aT as Qr, aV as Zr, aP as tn, aW as en, ay as rn, aU as nn, aQ as sn, aN as an, aK as on, aG as cn, aI as ln, a$ as un, b0 as fn, an as hn, ah as dn, ai as mn, az as pn, aM as yn, aB as wn, b2 as bn, b3 as gn, b as xn, m as En, c as Sn, n as kn, f as On, k as jn, r as Cn, h as Pn, e as An, i as Ln, j as Tn, G as Mn, a as Dn, s as Fn, T as In, t as Rn, y as _n, bq as Nn, bs as Wn, br as $n, bl as Bn, bp as zn, bm as Jn, bo as Un, bn as vn, a7 as Hn, a1 as Gn, O as Kn, Y as Vn } from "../urlGet-DZEwtNXt.mjs";
3
- import { Locker as wt, useAbortController as bt, combineAbortSignals as st, delay as at } from "@flemist/async-utils";
4
- import { Pool as gt, poolRunWait as N } from "@flemist/time-limits";
5
- import xt from "node:os";
6
- import * as D from "path";
7
- import ot from "path";
8
- import { priorityCreate as z } from "@flemist/priority-queue";
9
- import * as F from "fs";
10
- import Et from "picomatch";
11
- import { spawn as v } from "child_process";
12
- import { AbortControllerFast as St } from "@flemist/abort-controller-fast";
13
- const Z = new gt(xt.cpus().length);
14
- function W(t) {
15
- return t.replace(/\\/g, "/");
1
+ import { aq as ut, an as St, r as xt, q as Ot, a as Tt, aj as _t, ah as kt, a5 as Ct } from "../urlGet-OHY_Qdk-.mjs";
2
+ import { C as Le, b as Fe, aF as Ie, ac as Re, ak as Ne, al as $e, am as We, af as ze, aM as Be, av as Ue, aw as Je, by as Ke, bz as Ge, bA as He, bB as Ve, bC as qe, bD as Ye, bE as Qe, bN as Xe, bF as Ze, bG as tr, bH as er, bI as rr, bJ as nr, bK as sr, bL as ar, bM as or, M as ir, R as cr, as as lr, at as ur, U as fr, ab as hr, a7 as dr, az as mr, aG as pr, aH as wr, y as yr, aa as br, a8 as gr, ad as Er, V as Sr, o as xr, p as Or, aD as Tr, aC as _r, aB as kr, ap as Cr, Q as Pr, S as Dr, A as vr, a1 as Ar, a2 as Mr, a3 as jr, a4 as Lr, W as Fr, X as Ir, ay as Rr, aJ as Nr, aI as $r, ag as Wr, Y as zr, Z as Br, _ as Ur, a9 as Jr, T as Kr, g as Gr, $ as Hr, H as Vr, G as qr, z as Yr, ax as Qr, ar as Xr, s as Zr, aE as tn, b8 as en, ba as rn, aP as nn, aN as sn, bx as an, aO as on, aS as cn, bc as ln, bf as un, b4 as fn, b3 as hn, aT as dn, bq as mn, a_ as pn, bp as wn, aY as yn, bo as bn, b1 as gn, aX as En, br as Sn, aV as xn, aU as On, aR as Tn, bu as _n, b6 as kn, b5 as Cn, aW as Pn, aZ as Dn, bi as vn, bj as An, bk as Mn, bm as jn, bg as Ln, bn as Fn, a$ as In, bl as Rn, bh as Nn, be as $n, bb as Wn, b7 as zn, b9 as Bn, bs as Un, bt as Jn, aQ as Kn, aK as Gn, aL as Hn, b0 as Vn, bd as qn, b2 as Yn, bv as Qn, bw as Xn, D as Zn, B as ts, E as es, F as rs, K as ns, P as ss, I as as, L as os, J as is, N as cs, O as ls, u as us, a6 as fs, w as hs, v as ds, ai as ms, k as ps, j as ws, e as ys, d as bs, n as gs, m as Es, l as Ss, i as xs, h as Os, f as Ts, c as _s, t as ks, x as Cs, a0 as Ps, bT as Ds, bV as vs, bU as As, bO as Ms, bS as js, bP as Ls, bR as Fs, bQ as Is, aA as Rs, au as Ns, ae as $s, ao as Ws } from "../urlGet-OHY_Qdk-.mjs";
3
+ import * as P from "path";
4
+ import I from "path";
5
+ import { Pool as Pt, poolRunWait as A } from "@flemist/time-limits";
6
+ import Dt from "node:os";
7
+ import * as v from "fs";
8
+ import $ from "fs";
9
+ import { priorityCreate as J } from "@flemist/priority-queue";
10
+ import { useAbortController as vt, combineAbortSignals as rt, delay as ft } from "@flemist/async-utils";
11
+ import At from "picomatch";
12
+ import { spawn as G } from "child_process";
13
+ import { AbortControllerFast as ht, AbortError as st } from "@flemist/abort-controller-fast";
14
+ import { createTestVariants as Mt } from "@flemist/test-variants";
15
+ const R = new Pt(Dt.cpus().length);
16
+ async function jt(t, e, n, s) {
17
+ t = I.resolve(t), e = I.resolve(e), await A({
18
+ pool: s ?? R,
19
+ count: 1,
20
+ func: async () => {
21
+ let r = !1;
22
+ try {
23
+ await ut([
24
+ $.promises.mkdir(I.dirname(t), { recursive: !0 }),
25
+ (async () => {
26
+ await $.promises.mkdir(I.dirname(e), { recursive: !0 }), await $.promises.writeFile(e, n), r = !0;
27
+ })()
28
+ ]), await $.promises.rename(e, t);
29
+ } catch (a) {
30
+ throw r && await $.promises.unlink(e).catch(() => {
31
+ }), a;
32
+ }
33
+ }
34
+ });
16
35
  }
17
- let U = null;
18
- function kt(t) {
19
- U == null && (U = /* @__PURE__ */ new Map());
20
- const e = W(t);
21
- let n = U.get(e);
22
- return n == null && (n = new wt(), U.set(e, n)), n;
36
+ function Lt() {
37
+ return `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}.tmp`;
23
38
  }
24
- function Qt(t) {
39
+ function F(t) {
40
+ return t.replace(/[\\/]+/g, "/");
41
+ }
42
+ const Ft = new St();
43
+ function be(t) {
25
44
  const { filePath: e, func: n } = t;
26
- return kt(e).lock(
27
- () => N({
28
- pool: Z,
45
+ return Ft.lock(
46
+ F(e),
47
+ () => A({
48
+ pool: R,
29
49
  count: 1,
30
50
  func: n
31
51
  })
32
52
  );
33
53
  }
34
- function Ot(t) {
54
+ function It(t) {
35
55
  return t.match(/^[/\\]?[^/\\]+/)[0];
36
56
  }
37
- function jt(t, e) {
38
- return Ot(t) + "|" + e.ino;
57
+ function Rt(t, e) {
58
+ return It(t) + "|" + e.ino;
39
59
  }
40
- function Ct(t) {
41
- return t.endsWith(":") && (t += "/"), D.resolve(t);
60
+ function Nt(t) {
61
+ return t.endsWith(":") && (t += "/"), P.resolve(t);
42
62
  }
43
- function et(t, e) {
63
+ function at(t, e) {
44
64
  t.totalSize += e.totalSize, t.maxFileDateModified = Math.max(
45
65
  t.maxFileDateModified,
46
66
  e.maxFileDateModified
47
67
  ), t.countFiles += e.countFiles, t.countDirs += e.countDirs, t.countLinks += e.countLinks;
48
68
  }
49
- const Pt = function(e) {
69
+ const $t = function(e) {
50
70
  return e.code === "ENOENT";
51
71
  };
52
- function it(t) {
72
+ function dt(t) {
53
73
  const e = t.paths;
54
74
  if (!e || e.length === 0)
55
75
  return Promise.resolve({
@@ -59,148 +79,148 @@ function it(t) {
59
79
  countDirs: 0,
60
80
  countLinks: 0
61
81
  });
62
- const n = t.level ?? 0, s = t.walkedIds ?? /* @__PURE__ */ new Set(), r = t.abortSignal, a = t.pool ?? Z, o = t.handleError, i = t.priority ?? z(0), u = t.walkLinks ?? !1, c = t.log, x = t.handlePath, f = t.matchPath;
63
- async function y(h) {
64
- if (!(o && await o(h)) && !Pt(h))
65
- throw h;
82
+ const n = t.level ?? 0, s = t.walkedIds ?? /* @__PURE__ */ new Set(), r = t.abortSignal, a = t.pool ?? R, o = t.handleError, i = t.priority ?? J(0), c = t.walkLinks ?? !1, l = t.log, g = t.handlePath, d = t.matchPath;
83
+ async function h(f) {
84
+ if (!(o && await o(f)) && !$t(f))
85
+ throw f;
66
86
  }
67
- function j(h) {
68
- return !(!c || c.minTotalContentSize != null && h < c.minTotalContentSize || c.maxNestedLevel != null && n > c.maxNestedLevel);
87
+ function x(f) {
88
+ return !(!l || l.minTotalContentSize != null && f < l.minTotalContentSize || l.maxNestedLevel != null && n > l.maxNestedLevel);
69
89
  }
70
- return bt(async (h) => {
71
- const w = st(r, h), m = {
90
+ return vt(async (f) => {
91
+ const m = rt(r, f), p = {
72
92
  totalSize: 0,
73
93
  maxFileDateModified: 0,
74
94
  countFiles: 0,
75
95
  countDirs: 0,
76
96
  countLinks: 0
77
97
  };
78
- function T(g, O) {
79
- if (j(O.totalSize)) {
80
- const b = `${O.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${g}`;
81
- c?.handleLog ? c.handleLog(b) : console.log(b);
98
+ function k(w, _) {
99
+ if (x(_.totalSize)) {
100
+ const O = `${_.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${w}`;
101
+ l?.handleLog ? l.handleLog(O) : console.log(O);
82
102
  }
83
103
  }
84
- async function l(g, O, p, b) {
85
- return x ? await N({
104
+ async function u(w, _, S, O) {
105
+ return g ? await A({
86
106
  pool: a,
87
107
  func: async () => {
88
108
  try {
89
- return await x({
109
+ return await g({
90
110
  level: n,
91
- path: g,
92
- stat: O,
93
- itemStat: p,
94
- totalStat: m,
95
- abortSignal: w
111
+ path: w,
112
+ stat: _,
113
+ itemStat: S,
114
+ totalStat: p,
115
+ abortSignal: m
96
116
  });
97
- } catch (k) {
98
- return await y(k), !1;
117
+ } catch (T) {
118
+ return await h(T), !1;
99
119
  }
100
120
  },
101
121
  count: 1,
102
- priority: b,
103
- abortSignal: w
122
+ priority: O,
123
+ abortSignal: m
104
124
  }) : !0;
105
125
  }
106
- async function E(g, O, p, b) {
107
- b || (b = g);
108
- const k = await N({
126
+ async function y(w, _, S, O) {
127
+ O || (O = w);
128
+ const T = await A({
109
129
  pool: a,
110
- func: () => F.promises.lstat(g).catch(y),
130
+ func: () => v.promises.lstat(w).catch(h),
111
131
  count: 1,
112
- priority: z(O, z(1, i)),
113
- abortSignal: w
132
+ priority: J(_, J(1, i)),
133
+ abortSignal: m
114
134
  });
115
- if (!k || !p && k.isFile())
135
+ if (!T || !S && T.isFile())
116
136
  return null;
117
- const P = jt(g, k);
118
- if (s.has(P))
137
+ const D = Rt(w, T);
138
+ if (s.has(D))
119
139
  return null;
120
- s.add(P);
121
- let d = {
122
- totalSize: k.size,
123
- maxFileDateModified: k.isDirectory() ? 0 : k.mtimeMs,
140
+ s.add(D);
141
+ let b = {
142
+ totalSize: T.size,
143
+ maxFileDateModified: T.isDirectory() ? 0 : T.mtimeMs,
124
144
  countFiles: 0,
125
145
  countDirs: 0,
126
146
  countLinks: 0
127
147
  };
128
- const A = z(
129
- O,
130
- z(k.isDirectory() ? 2 : 3, i)
148
+ const M = J(
149
+ _,
150
+ J(T.isDirectory() ? 2 : 3, i)
131
151
  );
132
- if (k.isSymbolicLink()) {
133
- if (u) {
134
- const C = await N({
152
+ if (T.isSymbolicLink()) {
153
+ if (c) {
154
+ const C = await A({
135
155
  pool: a,
136
- func: () => F.promises.readlink(g).catch(y).then((M) => M ?? null),
156
+ func: () => v.promises.readlink(w).catch(h).then((L) => L ?? null),
137
157
  count: 1,
138
- priority: A,
139
- abortSignal: w
158
+ priority: M,
159
+ abortSignal: m
140
160
  });
141
161
  if (C) {
142
- const M = D.isAbsolute(C) ? C : D.resolve(D.dirname(b), C), I = await E(
143
- M,
144
- O,
145
- p,
146
- b
162
+ const L = P.isAbsolute(C) ? C : P.resolve(P.dirname(O), C), N = await y(
163
+ L,
164
+ _,
165
+ S,
166
+ O
147
167
  );
148
- I && (d = I);
168
+ N && (b = N);
149
169
  }
150
170
  }
151
- return (p || d.countFiles + d.countDirs + d.countLinks >= 1) && (d.countLinks += 1, await l(
171
+ return (S || b.countFiles + b.countDirs + b.countLinks >= 1) && (b.countLinks += 1, await u(
172
+ O,
173
+ T,
152
174
  b,
153
- k,
154
- d,
155
- A
156
- ) && (et(m, d), T(b, d))), d;
157
- } else if (k.isDirectory()) {
158
- const C = await N({
175
+ M
176
+ ) && (at(p, b), k(O, b))), b;
177
+ } else if (T.isDirectory()) {
178
+ const C = await A({
159
179
  pool: a,
160
- func: () => F.promises.readdir(g).catch(y),
180
+ func: () => v.promises.readdir(w).catch(h),
161
181
  count: 1,
162
182
  priority: i,
163
- abortSignal: w
183
+ abortSignal: m
164
184
  });
165
185
  if (C) {
166
- for (let M = 0, I = C.length; M < I; M++)
167
- C[M] = D.join(b, C[M]);
168
- d = await it({
186
+ for (let L = 0, N = C.length; L < N; L++)
187
+ C[L] = P.join(O, C[L]);
188
+ b = await dt({
169
189
  ...t,
170
190
  paths: C,
171
- abortSignal: w,
172
- priority: A,
191
+ abortSignal: m,
192
+ priority: M,
173
193
  level: n + 1,
174
194
  walkedIds: s
175
195
  });
176
196
  }
177
197
  }
178
- return (p || d.countFiles + d.countDirs + d.countLinks >= 1) && (k.isDirectory() ? d.countDirs += 1 : k.isFile() && (d.countFiles += 1), await l(
198
+ return (S || b.countFiles + b.countDirs + b.countLinks >= 1) && (T.isDirectory() ? b.countDirs += 1 : T.isFile() && (b.countFiles += 1), await u(
199
+ O,
200
+ T,
179
201
  b,
180
- k,
181
- d,
182
- A
183
- ) && (et(m, d), T(b, d))), d;
202
+ M
203
+ ) && (at(p, b), k(O, b))), b;
184
204
  }
185
- const S = [];
186
- for (let g = 0, O = e.length; g < O; g++) {
187
- const p = Ct(e[g]), b = f ? f(p) : !0;
188
- b !== !1 && S.push(E(p, g, b));
205
+ const E = [];
206
+ for (let w = 0, _ = e.length; w < _; w++) {
207
+ const S = Nt(e[w]), O = d ? d(S) : !0;
208
+ O !== !1 && E.push(y(S, w, O));
189
209
  }
190
- return await Promise.all(S), m;
210
+ return await Promise.all(E), p;
191
211
  });
192
212
  }
193
- function Zt(t) {
194
- return it(t);
213
+ function ge(t) {
214
+ return dt(t);
195
215
  }
196
- function te({
216
+ function Ee({
197
217
  globs: t,
198
218
  rootDir: e,
199
219
  noCase: n
200
220
  }) {
201
221
  const s = [];
202
222
  return t.forEach((r) => {
203
- r = W(r).trim();
223
+ r = F(r).trim();
204
224
  const a = r.startsWith("^");
205
225
  a && (r = r.substring(1).trim());
206
226
  const o = r.startsWith("!");
@@ -209,85 +229,326 @@ function te({
209
229
  `Invalid glob pattern: "${r}". The syntax '${r.substring(0, 2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`
210
230
  );
211
231
  r.startsWith("/") && (r = "." + r);
212
- const i = W(e ? D.resolve(e, r) : r);
232
+ const i = F(e ? P.resolve(e, r) : r);
213
233
  if (!i)
214
234
  return;
215
- let u;
235
+ let c;
216
236
  try {
217
- u = Et(i, {
237
+ c = At(i, {
218
238
  nocase: n ?? !1,
219
239
  dot: !0,
220
240
  strictBrackets: !0
221
241
  // Validate bracket balance for patterns like "["
222
242
  });
223
- } catch (c) {
243
+ } catch (l) {
224
244
  throw new Error(
225
- `Invalid glob pattern: "${r}". ${c instanceof Error ? c.message : "Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`
245
+ `Invalid glob pattern: "${r}". ${l instanceof Error ? l.message : "Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`
226
246
  );
227
247
  }
228
248
  s.push({
229
249
  exclude: a,
230
250
  negative: o,
231
251
  debugInfo: i,
232
- match: u
252
+ match: c
233
253
  });
234
254
  }), function(a) {
235
- a = W(a);
255
+ a = F(a);
236
256
  let o = null, i = !1;
237
- for (let u = 0, c = s.length; u < c; u++) {
238
- const x = s[u];
239
- x.match(a) && (x.exclude ? i = !x.negative : (o = !x.negative, i = !1));
257
+ for (let c = 0, l = s.length; c < l; c++) {
258
+ const g = s[c];
259
+ g.match(a) && (g.exclude ? i = !g.negative : (o = !g.negative, i = !1));
240
260
  }
241
261
  return i ? !1 : o;
242
262
  };
243
263
  }
244
- function At(t) {
264
+ function Wt(t) {
245
265
  const e = t.startsWith("!");
246
266
  return e && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), e && (t = "!" + t), t;
247
267
  }
248
- function Lt(t, e) {
268
+ function zt(t, e) {
249
269
  if (!e || e === ".")
250
270
  return t;
251
271
  const n = t.startsWith("^");
252
272
  n && (t = t.substring(1));
253
273
  const s = t.startsWith("!");
254
- return s && (t = t.substring(1)), t.startsWith("/") ? (e.endsWith("/") && (e = e.substring(0, e.length - 1)), t = e + t) : (e.endsWith("/") || (e += "/"), t.startsWith("./") ? t = e + t.substring(2) : t.startsWith("../") ? t = e + t : (e.startsWith("..") && (e = ""), t.startsWith("**") ? t = e + t : t = e + "**/" + t)), t = W(D.normalize(t)), s && (t = "!" + t), n && (t = "^" + t), t;
274
+ return s && (t = t.substring(1)), t.startsWith("/") ? (e.endsWith("/") && (e = e.substring(0, e.length - 1)), t = e + t) : (e.endsWith("/") || (e += "/"), t.startsWith("./") ? t = e + t.substring(2) : t.startsWith("../") ? t = e + t : (e.startsWith("..") && (e = ""), t.startsWith("**") ? t = e + t : t = e + "**/" + t)), t = F(P.normalize(t)), s && (t = "!" + t), n && (t = "^" + t), t;
255
275
  }
256
- function rt(t) {
276
+ function ot(t) {
257
277
  return "^" + t;
258
278
  }
259
- async function Tt(t) {
260
- const n = (await F.promises.readFile(t, "utf-8")).split(`
279
+ async function Bt(t) {
280
+ const n = (await v.promises.readFile(t, "utf-8")).split(`
261
281
  `), s = [];
262
282
  return n.forEach((r) => {
263
283
  r = r.trim(), !(!r || r.startsWith("#")) && s.push(r);
264
284
  }), s;
265
285
  }
266
- async function ee(t) {
286
+ async function Se(t) {
267
287
  const e = t.rootDir ?? ".", n = [];
268
288
  if (!t.globs?.length)
269
289
  return n;
270
290
  const s = [];
271
291
  return t.globs.forEach((r) => {
272
- r.value && (r.valueType === "file-contains-patterns" ? s.push(r) : r.valueType === "pattern" && n.push(r.exclude ? rt(r.value) : r.value));
292
+ r.value && (r.valueType === "file-contains-patterns" ? s.push(r) : r.valueType === "pattern" && n.push(r.exclude ? ot(r.value) : r.value));
273
293
  }), s.length && await Promise.all(
274
294
  s.map(async (r) => {
275
- await N({
276
- pool: Z,
295
+ await A({
296
+ pool: R,
277
297
  count: 1,
278
298
  func: async () => {
279
- const a = D.resolve(e, r.value), o = await Tt(a), i = D.relative(e, D.dirname(a));
280
- o.forEach((u) => {
281
- u = At(u), u = Lt(u, i), n.push(r.exclude ? rt(u) : u);
299
+ const a = P.resolve(e, r.value), o = await Bt(a), i = P.relative(e, P.dirname(a));
300
+ o.forEach((c) => {
301
+ c = Wt(c), c = zt(c, i), n.push(r.exclude ? ot(c) : c);
282
302
  });
283
303
  }
284
304
  });
285
305
  })
286
306
  ), n;
287
307
  }
288
- function Mt(t, e = {}) {
308
+ function Ut(t, e) {
309
+ return A({
310
+ pool: e ?? R,
311
+ count: 1,
312
+ func: () => v.promises.readdir(t, { withFileTypes: !0 })
313
+ });
314
+ }
315
+ async function Jt(t, e) {
316
+ const n = [];
317
+ async function s(r, a) {
318
+ let o;
319
+ try {
320
+ o = await Ut(r, e);
321
+ } catch (c) {
322
+ if (a !== "" && c.code === "ENOENT")
323
+ return;
324
+ throw c;
325
+ }
326
+ let i = null;
327
+ o.forEach((c) => {
328
+ const l = P.join(a, c.name);
329
+ n.push([F(l), c]), c.isDirectory() && (i == null && (i = []), i.push(
330
+ s(P.join(r, c.name), l)
331
+ ));
332
+ }), i != null && await Promise.all(i);
333
+ }
334
+ return await s(t, ""), n;
335
+ }
336
+ class it {
337
+ _options;
338
+ constructor(e) {
339
+ this._options = e;
340
+ }
341
+ get options() {
342
+ return this._options;
343
+ }
344
+ async set(e, n) {
345
+ const s = this._options.converterSubPath.to(e), r = P.join(this._options.dir, s), a = this._options.getTempFileName ? this._options.getTempFileName(e) : Lt(), o = P.join(this._options.tmpDir, a);
346
+ await jt(r, o, n, this._options.pool);
347
+ }
348
+ async get(e) {
349
+ const n = this._options.converterSubPath.to(e), s = P.join(this._options.dir, n);
350
+ try {
351
+ const r = await A({
352
+ pool: this._options.pool ?? R,
353
+ count: 1,
354
+ func: () => v.promises.readFile(s)
355
+ });
356
+ return new Uint8Array(r);
357
+ } catch (r) {
358
+ if (r.code === "ENOENT")
359
+ return;
360
+ throw r;
361
+ }
362
+ }
363
+ async delete(e) {
364
+ const n = this._options.converterSubPath.to(e), s = P.join(this._options.dir, n);
365
+ try {
366
+ await A({
367
+ pool: this._options.pool ?? R,
368
+ count: 1,
369
+ func: () => v.promises.unlink(s)
370
+ });
371
+ } catch (r) {
372
+ if (r.code === "ENOENT")
373
+ return;
374
+ throw r;
375
+ }
376
+ }
377
+ async clear() {
378
+ const e = await this.getKeys();
379
+ await ut(e.map((n) => this.delete(n)));
380
+ }
381
+ async getKeys() {
382
+ try {
383
+ const e = await Jt(
384
+ this._options.dir,
385
+ this._options.pool
386
+ ), n = [];
387
+ return e.forEach(([s, r]) => {
388
+ if (!r.isFile())
389
+ return;
390
+ const a = this._options.converterSubPath.from(s);
391
+ a != null && n.push(a);
392
+ }), n;
393
+ } catch (e) {
394
+ if (e.code === "ENOENT")
395
+ return [];
396
+ throw e;
397
+ }
398
+ }
399
+ }
400
+ function ct(t) {
401
+ const e = t.prefix ? F(t.prefix) : "", n = t.suffix ? F(t.suffix) : "", s = t.splitKeyLetters ?? 0;
402
+ return {
403
+ to(r) {
404
+ if (s <= 0)
405
+ return F(e + r + n);
406
+ const a = Math.min(s, r.length);
407
+ let o = e;
408
+ for (let i = 0; i < a; i++)
409
+ o += (i === 0 ? "" : "/") + r[i];
410
+ return a < r.length && (o += (a === 0 ? "" : "/") + r.slice(a)), F(o + n);
411
+ },
412
+ from(r) {
413
+ return s <= 0 ? !r.startsWith(e) || !r.endsWith(n) ? null : r.slice(e.length, r.length - n.length) : !r.startsWith(e) || !r.endsWith(n) ? null : r.slice(e.length, r.length - n.length).replace(/\//g, "");
414
+ }
415
+ };
416
+ }
417
+ class Kt {
418
+ _options;
419
+ _entries = /* @__PURE__ */ new Map();
420
+ _entriesLoaded = !1;
421
+ constructor(e) {
422
+ this._options = e;
423
+ }
424
+ async set(e, n) {
425
+ const s = n.hasError ? this._options.storages.error : this._options.storages.value, r = s.options.converterSubPath.to(e), a = I.resolve(s.options.dir, r);
426
+ await A({
427
+ pool: this._options.pool ?? R,
428
+ count: 1,
429
+ func: async () => {
430
+ await $.promises.utimes(
431
+ a,
432
+ n.dateUsed / 1e3,
433
+ n.dateModified / 1e3
434
+ ), this._entries.set(e, n);
435
+ }
436
+ });
437
+ }
438
+ async get(e) {
439
+ const n = this._options.storages.value.options.converterSubPath.to(e), s = this._options.storages.error.options.converterSubPath.to(e), r = I.resolve(
440
+ this._options.storages.value.options.dir,
441
+ n
442
+ ), a = I.resolve(
443
+ this._options.storages.error.options.dir,
444
+ s
445
+ );
446
+ return await A({
447
+ pool: this._options.pool ?? R,
448
+ count: 1,
449
+ func: async () => {
450
+ const [o, i] = await Promise.all([
451
+ $.promises.stat(r).catch((c) => {
452
+ if (c.code === "ENOENT")
453
+ return null;
454
+ throw c;
455
+ }),
456
+ $.promises.stat(a).catch((c) => {
457
+ if (c.code === "ENOENT")
458
+ return null;
459
+ throw c;
460
+ })
461
+ ]);
462
+ if (o != null && i != null) {
463
+ const c = i.mtimeMs >= o.mtimeMs, l = c ? i : o;
464
+ return {
465
+ dateModified: l.mtimeMs,
466
+ dateUsed: l.atimeMs,
467
+ size: l.size,
468
+ hasError: c
469
+ };
470
+ } else return o != null ? {
471
+ dateModified: o.mtimeMs,
472
+ dateUsed: o.atimeMs,
473
+ size: o.size,
474
+ hasError: !1
475
+ } : i != null ? {
476
+ dateModified: i.mtimeMs,
477
+ dateUsed: i.atimeMs,
478
+ size: i.size,
479
+ hasError: !0
480
+ } : void 0;
481
+ }
482
+ });
483
+ }
484
+ async delete(e) {
485
+ this._entries.delete(e);
486
+ }
487
+ async clear() {
488
+ this._entries.clear();
489
+ }
490
+ async _getKeys() {
491
+ const [e, n] = await Promise.all([
492
+ this._options.storages.value.getKeys(),
493
+ this._options.storages.error.getKeys()
494
+ ]);
495
+ return [...e, ...n];
496
+ }
497
+ async getEntries() {
498
+ if (!this._entriesLoaded) {
499
+ const e = await this._getKeys();
500
+ await Promise.all(
501
+ e.map(async (n) => {
502
+ if (this._entries.has(n))
503
+ return;
504
+ const s = await this.get(n);
505
+ s != null && this._entries.set(n, s);
506
+ })
507
+ ), this._entriesLoaded = !0;
508
+ }
509
+ return this._entries;
510
+ }
511
+ async getKeys() {
512
+ const e = await this.getEntries();
513
+ return Array.from(e.keys());
514
+ }
515
+ }
516
+ function xe(t) {
517
+ const e = new it({
518
+ dir: t.dir,
519
+ tmpDir: t.tmpDir,
520
+ converterSubPath: ct({ suffix: ".value" })
521
+ }), n = new it({
522
+ dir: t.dir,
523
+ tmpDir: t.tmpDir,
524
+ converterSubPath: ct({ suffix: ".error" })
525
+ });
526
+ return {
527
+ converterInput: t.converterInput ?? Tt,
528
+ converterValue: t.converterValue ?? Ot,
529
+ converterError: xt,
530
+ totalSize: t.totalSize,
531
+ getSize: {
532
+ value: (s) => s.byteLength,
533
+ error: (s) => s.byteLength,
534
+ stat: () => 0
535
+ },
536
+ isExpired: t.isExpired,
537
+ storages: {
538
+ value: e,
539
+ error: n,
540
+ stat: new Kt({
541
+ storages: {
542
+ value: e,
543
+ error: n
544
+ }
545
+ })
546
+ }
547
+ };
548
+ }
549
+ function Gt(t, e = {}) {
289
550
  return new Promise((n, s) => {
290
- const r = v(t, {
551
+ const r = G(t, {
291
552
  shell: !0,
292
553
  ...e
293
554
  }), a = [];
@@ -305,19 +566,19 @@ function Mt(t, e = {}) {
305
566
  });
306
567
  });
307
568
  }
308
- async function re() {
569
+ async function Oe() {
309
570
  let t;
310
571
  switch (process.platform) {
311
572
  case "darwin":
312
- t = v("afplay", ["/System/Library/Sounds/Ping.aiff"], {
573
+ t = G("afplay", ["/System/Library/Sounds/Ping.aiff"], {
313
574
  stdio: "ignore"
314
575
  });
315
576
  break;
316
577
  case "linux":
317
- t = v("beep", [], { stdio: "ignore", shell: !0 });
578
+ t = G("beep", [], { stdio: "ignore", shell: !0 });
318
579
  break;
319
580
  case "win32":
320
- t = v("powershell", ["-c", "[console]::beep(1000,300)"], {
581
+ t = G("powershell", ["-c", "[console]::beep(1000,300)"], {
321
582
  stdio: "ignore"
322
583
  });
323
584
  break;
@@ -332,84 +593,84 @@ async function re() {
332
593
  });
333
594
  });
334
595
  }
335
- async function Dt({
596
+ async function Ht({
336
597
  page: t,
337
598
  urlFilters: e,
338
599
  timeouts: n
339
600
  }) {
340
- return n || (n = {}), n.downloadInternal || (n.downloadInternal = 10 * 1e3), n.downloadExternal || (n.downloadExternal = 60 * 1e3), n.total || (n.total = 300 * 1e3), await mt(
601
+ return n || (n = {}), n.downloadInternal || (n.downloadInternal = 10 * 1e3), n.downloadExternal || (n.downloadExternal = 60 * 1e3), n.total || (n.total = 300 * 1e3), await _t(
341
602
  () => t.evaluate(
342
603
  ({
343
604
  urlFilters: r,
344
605
  timeouts: a
345
606
  }) => {
346
- function o(c) {
347
- return function(f) {
348
- let y = !1;
349
- for (let j = 0, h = c.length; j < h; j++) {
350
- const w = c[j];
351
- w.pattern.test(f) && (y = w.value);
607
+ function o(l) {
608
+ return function(d) {
609
+ let h = !1;
610
+ for (let x = 0, f = l.length; x < f; x++) {
611
+ const m = l[x];
612
+ m.pattern.test(d) && (h = m.value);
352
613
  }
353
- return y;
614
+ return h;
354
615
  };
355
616
  }
356
617
  const i = r && o(r);
357
- let u = performance.getEntries && performance.getEntries();
358
- return u || (u = []), u.push({
618
+ let c = performance.getEntries && performance.getEntries();
619
+ return c || (c = []), c.push({
359
620
  name: location.href
360
621
  }), Promise.all(
361
- u.map(
362
- (c) => {
363
- if (c.entryType != null && c.entryType !== "resource" || i && !i(c.name))
622
+ c.map(
623
+ (l) => {
624
+ if (l.entryType != null && l.entryType !== "resource" || i && !i(l.name))
364
625
  return null;
365
- if (c.responseStatus != null)
366
- return c.responseStatus >= 400 ? Promise.resolve({
367
- url: c.name,
368
- error: c.responseStatus
626
+ if (l.responseStatus != null)
627
+ return l.responseStatus >= 400 ? Promise.resolve({
628
+ url: l.name,
629
+ error: l.responseStatus
369
630
  }) : null;
370
631
  if (navigator.userAgent.indexOf("Chrome") === -1)
371
632
  return null;
372
- const x = typeof AbortController < "u" ? new AbortController() : null, f = new URL(c.name).origin === location.origin, y = f ? a.downloadInternal : a.downloadExternal;
373
- let j;
374
- const h = new Promise((l, E) => {
375
- j = E;
376
- }), w = y && setTimeout(() => {
377
- x?.abort(), j(
633
+ const g = typeof AbortController < "u" ? new AbortController() : null, d = new URL(l.name).origin === location.origin, h = d ? a.downloadInternal : a.downloadExternal;
634
+ let x;
635
+ const f = new Promise((u, y) => {
636
+ x = y;
637
+ }), m = h && setTimeout(() => {
638
+ g?.abort(), x(
378
639
  new Error("[test][getPageHttpErrors] fetch timeout")
379
640
  );
380
- }, y);
381
- let m = fetch(c.name, {
382
- mode: f ? "same-origin" : "no-cors",
383
- signal: x?.signal,
384
- cache: f ? "force-cache" : void 0,
641
+ }, h);
642
+ let p = fetch(l.name, {
643
+ mode: d ? "same-origin" : "no-cors",
644
+ signal: g?.signal,
645
+ cache: d ? "force-cache" : void 0,
385
646
  method: "HEAD"
386
- }).then((l) => l.ok ? null : {
387
- url: c.name,
388
- error: l.status + " " + l.statusText
389
- }).catch((l) => ({
390
- url: c.name,
391
- error: l.message
647
+ }).then((u) => u.ok ? null : {
648
+ url: l.name,
649
+ error: u.status + " " + u.statusText
650
+ }).catch((u) => ({
651
+ url: l.name,
652
+ error: u.message
392
653
  }));
393
- x || (m = Promise.race([m, h]));
394
- function T() {
395
- w && clearTimeout(w);
654
+ g || (p = Promise.race([p, f]));
655
+ function k() {
656
+ m && clearTimeout(m);
396
657
  }
397
- return m.then(
398
- (l) => (T(), l),
399
- (l) => {
400
- throw T(), l;
658
+ return p.then(
659
+ (u) => (k(), u),
660
+ (u) => {
661
+ throw k(), u;
401
662
  }
402
663
  );
403
664
  }
404
665
  )
405
- ).then((c) => {
406
- const x = c.filter((f) => f).map(
407
- (f) => ({
408
- url: new URL(f.url),
409
- error: f.error
666
+ ).then((l) => {
667
+ const g = l.filter((d) => d).map(
668
+ (d) => ({
669
+ url: new URL(d.url),
670
+ error: d.error
410
671
  })
411
672
  );
412
- return x.length > 0 ? x : null;
673
+ return g.length > 0 ? g : null;
413
674
  });
414
675
  },
415
676
  {
@@ -420,12 +681,12 @@ async function Dt({
420
681
  { timeout: n.total }
421
682
  );
422
683
  }
423
- async function Ft({
684
+ async function Vt({
424
685
  page: t,
425
686
  urlFilters: e,
426
687
  errorFilter: n
427
688
  }) {
428
- let s = await Dt({
689
+ let s = await Ht({
429
690
  page: t,
430
691
  urlFilters: e
431
692
  });
@@ -434,12 +695,12 @@ async function Ft({
434
695
  `[test][checkPageHttpErrors] Page has http errors: ${JSON.stringify(s, null, 2)}`
435
696
  );
436
697
  }
437
- async function It({
698
+ async function qt({
438
699
  page: t,
439
700
  filter: e,
440
701
  onError: n
441
702
  }) {
442
- const s = "callback_191b355ea6f64499a6607ad571da5d4d", r = t.context().browser()?.browserType().name(), a = pt();
703
+ const s = "callback_191b355ea6f64499a6607ad571da5d4d", r = t.context().browser()?.browserType().name(), a = kt();
443
704
  function o(i) {
444
705
  try {
445
706
  if (e && !e({
@@ -447,73 +708,73 @@ async function It({
447
708
  error: i
448
709
  }))
449
710
  return;
450
- } catch (u) {
451
- i = String(u);
711
+ } catch (c) {
712
+ i = String(c);
452
713
  }
453
714
  try {
454
715
  console.error(
455
716
  `[test][subscribeJsErrors] BROWSER JS ERROR (${r}): ${i}`
456
717
  );
457
- const u = new Error(i);
458
- u.stack = a, n(u);
459
- } catch (u) {
460
- console.error("[test][subscribeJsErrors] error", u);
718
+ const c = new Error(i);
719
+ c.stack = a, n(c);
720
+ } catch (c) {
721
+ console.error("[test][subscribeJsErrors] error", c);
461
722
  }
462
723
  }
463
724
  await t.exposeFunction(s, o), await t.addInitScript((i) => {
464
- function u(f) {
465
- if (Array.isArray(f))
466
- return f.map(u).join(`\r
725
+ function c(d) {
726
+ if (Array.isArray(d))
727
+ return d.map(c).join(`\r
467
728
  \r
468
729
  `);
469
- if (f instanceof Error)
470
- return f.stack || f.toString();
471
- if (typeof f == "object" && f != null) {
472
- const y = /* @__PURE__ */ new Set();
730
+ if (d instanceof Error)
731
+ return d.stack || d.toString();
732
+ if (typeof d == "object" && d != null) {
733
+ const h = /* @__PURE__ */ new Set();
473
734
  return JSON.stringify(
474
- f,
475
- (j, h) => {
476
- if (typeof h == "object" && h != null) {
477
- if (y.has(h))
735
+ d,
736
+ (x, f) => {
737
+ if (typeof f == "object" && f != null) {
738
+ if (h.has(f))
478
739
  return "[Circular]";
479
- y.add(h);
740
+ h.add(f);
480
741
  }
481
- return h;
742
+ return f;
482
743
  },
483
744
  2
484
745
  );
485
746
  }
486
- return String(f);
747
+ return String(d);
487
748
  }
488
- function c(f) {
489
- window[i](f);
749
+ function l(d) {
750
+ window[i](d);
490
751
  }
491
- const x = {
752
+ const g = {
492
753
  warn: console.warn.bind(console),
493
754
  error: console.error.bind(console)
494
755
  };
495
- console.warn = function(...y) {
496
- return c("console.warn: " + u(y)), x.warn.apply(this, y);
497
- }, console.error = function(...y) {
498
- return c("console.error: " + u(y)), x.error.apply(this, y);
756
+ console.warn = function(...h) {
757
+ return l("console.warn: " + c(h)), g.warn.apply(this, h);
758
+ }, console.error = function(...h) {
759
+ return l("console.error: " + c(h)), g.error.apply(this, h);
499
760
  }, window.addEventListener(
500
761
  "error",
501
- function(f) {
502
- c("window error: " + (f.message || JSON.stringify(f)));
762
+ function(d) {
763
+ l("window error: " + (d.message || JSON.stringify(d)));
503
764
  },
504
765
  !0
505
766
  ), window.addEventListener(
506
767
  "unhandledrejection",
507
- function(f) {
508
- c("window unhandledrejection: " + u(f.reason));
768
+ function(d) {
769
+ l("window unhandledrejection: " + c(d.reason));
509
770
  },
510
771
  !0
511
772
  );
512
773
  }, s);
513
774
  }
514
- async function Rt() {
775
+ async function mt() {
515
776
  try {
516
- process.platform === "win32" && await Mt(
777
+ process.platform === "win32" && await Gt(
517
778
  `wmic process where "commandline like '%ms-playwright%' and not commandline like '%wmic.exe%' and priority != 4" CALL setpriority "idle"`
518
779
  );
519
780
  } catch (t) {
@@ -523,38 +784,38 @@ async function Rt() {
523
784
  console.warn("[test][setPlaywrightPriorityLow] error: " + e);
524
785
  }
525
786
  }
526
- let H = null, q = null;
527
- function ne(t) {
528
- q = t;
787
+ let H = null, Z = null;
788
+ function Te(t) {
789
+ Z = t;
529
790
  }
530
- function _t() {
791
+ function Yt() {
531
792
  if (H)
532
793
  return;
533
- const t = q || (process.env.DELAY_ON_ERROR ? parseInt(process.env.DELAY_ON_ERROR, 10) : 0);
534
- if (q)
535
- return console.log(`[test][delayOnError] Delay on error: ${t} ms`), H = at(t), H;
794
+ const t = Z || (process.env.DELAY_ON_ERROR ? parseInt(process.env.DELAY_ON_ERROR, 10) : 0);
795
+ if (Z)
796
+ return console.log(`[test][delayOnError] Delay on error: ${t} ms`), H = ft(t), H;
536
797
  }
537
- function se() {
798
+ function _e() {
538
799
  return H;
539
800
  }
540
- async function Nt(t) {
541
- const { page: e } = t, n = e.context().browser()?.browserType().name(), s = new St(), r = st(
801
+ async function Qt(t) {
802
+ const { page: e } = t, n = e.context().browser()?.browserType().name(), s = new ht(), r = rt(
542
803
  s.signal,
543
804
  t.abortSignal
544
805
  ), a = (i) => {
545
- let u = `Error in (${n}) ${e.url()}
806
+ let c = `Error in (${n}) ${e.url()}
546
807
  `;
547
- t.pageFilePath && (u += ` at _ (${ot.resolve(t.pageFilePath)}:0:0)
548
- `), i.stack = u + (i.stack || i.message), i.message = u + i.message, console.error("[test][initPage] error", i), s.abort(i);
808
+ t.pageFilePath && (c += ` at _ (${I.resolve(t.pageFilePath)}:0:0)
809
+ `), i.stack = c + (i.stack || i.message), i.message = c + i.message, console.error("[test][initPage] error", i), s.abort(i);
549
810
  };
550
- return await It({
811
+ return await qt({
551
812
  page: e,
552
813
  filter: t.filters?.js?.filter,
553
814
  onError: a
554
815
  }), {
555
816
  abortSignal: r,
556
817
  checkErrors: async () => {
557
- await Ft({
818
+ await Vt({
558
819
  page: e,
559
820
  urlFilters: t.filters?.http?.urlFilters,
560
821
  errorFilter: t.filters?.http?.errorFilter
@@ -562,7 +823,7 @@ async function Nt(t) {
562
823
  }
563
824
  };
564
825
  }
565
- async function ae({
826
+ async function Xt({
566
827
  page: t,
567
828
  abortSignal: e,
568
829
  filters: n,
@@ -571,7 +832,7 @@ async function ae({
571
832
  }) {
572
833
  const a = t.context().browser()?.browserType().name();
573
834
  try {
574
- const { abortSignal: o, checkErrors: i } = await Nt({
835
+ const { abortSignal: o, checkErrors: i } = await Qt({
575
836
  page: t,
576
837
  abortSignal: e,
577
838
  filters: n,
@@ -585,11 +846,11 @@ async function ae({
585
846
  } catch (o) {
586
847
  let i = `Error in (${a}) ${t.url()}
587
848
  `;
588
- throw r && (i += ` at _ (${ot.resolve(r)}:0:0)
849
+ throw r && (i += ` at _ (${I.resolve(r)}:0:0)
589
850
  `), o.stack = i + (o.stack || o.message), o.message = i + o.message, o;
590
851
  }
591
852
  }
592
- function oe({
853
+ function ke({
593
854
  browserType: t,
594
855
  options: e
595
856
  }) {
@@ -602,43 +863,199 @@ function oe({
602
863
  }
603
864
  };
604
865
  }
605
- function ie({
866
+ function Zt({
606
867
  browser: t,
607
868
  options: e
608
869
  }) {
609
870
  return async function(s) {
610
871
  const r = await t.newContext(e ?? void 0);
611
- await Rt();
872
+ await mt();
612
873
  try {
613
874
  const a = await s(r);
614
875
  return await r.close(), a;
615
876
  } catch (a) {
616
- const o = _t?.();
877
+ const o = Yt?.();
617
878
  throw o ? (console.error("[test][useBrowserContext] error", a), o.finally(() => r.close())) : await r.close(), a;
618
879
  }
619
880
  };
620
881
  }
621
- async function Y(t, e) {
622
- const n = D.dirname(t);
623
- await F.promises.stat(n).catch(() => null) || await F.promises.mkdir(n, { recursive: !0 }), await F.promises.writeFile(t, JSON.stringify(e, null, 4), {
882
+ async function Ce(t, e) {
883
+ const n = await t.$$(e);
884
+ for (const s of n)
885
+ await s.click();
886
+ }
887
+ const Q = new ht();
888
+ let te = 0;
889
+ function ee(t) {
890
+ return async function({
891
+ browser: n,
892
+ contextOptions: s,
893
+ name: r,
894
+ url: a,
895
+ pool: o,
896
+ priority: i,
897
+ filters: c,
898
+ ...l
899
+ }, g) {
900
+ const d = rt(
901
+ Q.signal,
902
+ g
903
+ );
904
+ try {
905
+ await A({
906
+ pool: o,
907
+ count: 1,
908
+ priority: i,
909
+ abortSignal: d,
910
+ func: async (h, x) => {
911
+ x.throwIfAborted(), await Zt({
912
+ browser: n,
913
+ options: s
914
+ })(async (f) => {
915
+ x.throwIfAborted();
916
+ const m = await f.newPage();
917
+ await mt();
918
+ const p = n.browserType().name(), k = x.subscribe(() => {
919
+ m.isClosed() || (m.close({
920
+ // reason: reason?.message,
921
+ runBeforeUnload: !1
922
+ }), f.close({
923
+ // reason: reason?.message,
924
+ }));
925
+ });
926
+ try {
927
+ console.log(`START ${r} (${p}): ${a}`), await Xt({
928
+ page: m,
929
+ abortSignal: x,
930
+ filters: c,
931
+ func: async ({ page: u, checkErrors: y, abortSignal: E }) => {
932
+ await t({
933
+ page: u,
934
+ url: a,
935
+ checkErrors: y,
936
+ abortSignal: E,
937
+ args: l
938
+ });
939
+ }
940
+ }), console.log(
941
+ `END [${te++}] ${r} (${p}): ${a}`
942
+ );
943
+ } catch (u) {
944
+ if (x.aborted || u instanceof st) {
945
+ console.log(`ABORTED ${r} (${p}): ${a}`);
946
+ return;
947
+ }
948
+ throw console.log(`ERROR ${r} (${p}): ${a}`), Q.signal.aborted || (console.log("unsubscribe on first error"), k()), Q.abort(), u;
949
+ }
950
+ });
951
+ }
952
+ });
953
+ } catch (h) {
954
+ if (h instanceof st)
955
+ return;
956
+ throw h;
957
+ }
958
+ };
959
+ }
960
+ function Pe(t) {
961
+ const e = ee(t);
962
+ return Mt(async (n) => await e(n));
963
+ }
964
+ function De(t, e) {
965
+ const n = e.stableTime, s = e.timeout, r = e.mutation ? {
966
+ childList: !!e.mutation.childList,
967
+ attributes: !!e.mutation.attributes,
968
+ characterData: !!e.mutation.characterData,
969
+ subtree: !!e.mutation.subtree,
970
+ selector: e.mutation.selector ?? null
971
+ } : null, a = e.resource ? {
972
+ resource: !!e.resource.resource,
973
+ navigation: !!e.resource.navigation,
974
+ paint: !!e.resource.paint,
975
+ longTask: !!e.resource.longTask
976
+ } : null;
977
+ return t.evaluate(
978
+ ({ stableTime: o, timeout: i, mutation: c, resource: l }) => {
979
+ return new Promise((h, x) => {
980
+ let f = Date.now(), m = null, p = null;
981
+ const k = [];
982
+ function u() {
983
+ f = Date.now();
984
+ }
985
+ function y() {
986
+ m != null && (clearTimeout(m), m = null), p != null && (clearTimeout(p), p = null);
987
+ for (let w = 0, _ = k.length; w < _; w++)
988
+ k[w]();
989
+ }
990
+ function E() {
991
+ const w = o - (Date.now() - f);
992
+ w <= 0 ? (y(), h()) : m = setTimeout(E, w);
993
+ }
994
+ if (c) {
995
+ const w = g(c, u);
996
+ k.push(w);
997
+ }
998
+ if (l) {
999
+ const w = d(l, u);
1000
+ k.push(w);
1001
+ }
1002
+ m = setTimeout(E, o), p = setTimeout(() => {
1003
+ y(), x(
1004
+ new Error(
1005
+ `[waitPageStable] timed out after ${i}ms waiting for page to stabilize`
1006
+ )
1007
+ );
1008
+ }, i);
1009
+ });
1010
+ function g(h, x) {
1011
+ const f = h.selector ? document.querySelector(h.selector) : document.documentElement;
1012
+ if (!f)
1013
+ throw new Error(
1014
+ `[waitPageStable] element not found: ${h.selector}`
1015
+ );
1016
+ const m = new MutationObserver(x);
1017
+ return m.observe(f, {
1018
+ childList: h.childList,
1019
+ attributes: h.attributes,
1020
+ characterData: h.characterData,
1021
+ subtree: h.subtree
1022
+ }), () => {
1023
+ m.disconnect();
1024
+ };
1025
+ }
1026
+ function d(h, x) {
1027
+ const f = [];
1028
+ h.resource && f.push("resource"), h.navigation && f.push("navigation"), h.paint && f.push("paint"), h.longTask && f.push("longtask");
1029
+ const m = new PerformanceObserver(x);
1030
+ return m.observe({ entryTypes: f }), () => {
1031
+ m.disconnect();
1032
+ };
1033
+ }
1034
+ },
1035
+ { stableTime: n, timeout: s, mutation: r, resource: a }
1036
+ );
1037
+ }
1038
+ async function X(t, e) {
1039
+ const n = P.dirname(t);
1040
+ await v.promises.stat(n).catch(() => null) || await v.promises.mkdir(n, { recursive: !0 }), await v.promises.writeFile(t, JSON.stringify(e, null, 4), {
624
1041
  encoding: "utf-8"
625
1042
  });
626
1043
  }
627
- async function Wt(t) {
628
- if (!await F.promises.stat(t).catch(() => null))
1044
+ async function re(t) {
1045
+ if (!await v.promises.stat(t).catch(() => null))
629
1046
  return null;
630
- const e = await F.promises.readFile(t, { encoding: "utf-8" });
1047
+ const e = await v.promises.readFile(t, { encoding: "utf-8" });
631
1048
  return JSON.parse(e);
632
1049
  }
633
- const X = "-", Q = "+";
634
- function G(t, e, n) {
1050
+ const tt = "-", et = "+";
1051
+ function V(t, e, n) {
635
1052
  if (t === e)
636
1053
  return null;
637
1054
  if (Array.isArray(t)) {
638
1055
  if (Array.isArray(e)) {
639
1056
  let r = null;
640
1057
  for (let a = 0, o = Math.max(e.length, e.length); a < o; a++) {
641
- const i = G(t[a], e[a], n);
1058
+ const i = V(t[a], e[a], n);
642
1059
  i != null && (r || (r = []), r.push(i));
643
1060
  }
644
1061
  return r != null && n && (r = n(t, e, r)), r;
@@ -647,159 +1064,159 @@ function G(t, e, n) {
647
1064
  let r = null;
648
1065
  for (const a in t)
649
1066
  if (Object.prototype.hasOwnProperty.call(t, a)) {
650
- const o = G(t[a], e[a], n);
1067
+ const o = V(t[a], e[a], n);
651
1068
  o != null && (r || (r = {}), r[a] = o);
652
1069
  }
653
1070
  for (const a in e)
654
1071
  if (Object.prototype.hasOwnProperty.call(e, a) && !Object.prototype.hasOwnProperty.call(t, a)) {
655
- const o = G(t[a], e[a], n);
1072
+ const o = V(t[a], e[a], n);
656
1073
  o != null && (r || (r = {}), r[a] = o);
657
1074
  }
658
1075
  return r != null && n && (r = n(t, e, r)), r;
659
1076
  }
660
1077
  let s = {
661
- [X]: t,
662
- [Q]: e
1078
+ [tt]: t,
1079
+ [et]: e
663
1080
  };
664
1081
  return n && (s = n(t, e, s)), s;
665
1082
  }
666
- function nt(t) {
667
- function e(l) {
668
- return l.sort((E, S) => E[0] > S[0] ? 1 : -1).reduce((E, S) => (E[S[0]] = S[1], E), {});
1083
+ function lt(t) {
1084
+ function e(u) {
1085
+ return u.sort((y, E) => y[0] > E[0] ? 1 : -1).reduce((y, E) => (y[E[0]] = E[1], y), {});
669
1086
  }
670
- function n(l) {
671
- return l.reduce((E, S) => (E[S] = !0, E), {});
1087
+ function n(u) {
1088
+ return u.reduce((y, E) => (y[E] = !0, y), {});
672
1089
  }
673
- const s = t.filters && t.filters.excludeAttrs && n(t.filters.excludeAttrs), r = t.filters && t.filters.fixAttrs, a = t.filters && t.filters.fixStyles, o = t.filters && t.filters.excludeStyles && n(t.filters.excludeStyles), i = t.filters && t.filters.fixTags, u = t.filters && t.filters.excludeClasses, c = t.filters && t.filters.excludeIds, x = t.filters && t.filters.excludeSelectorClasses, f = t.filters && t.filters.excludeSelectorIds;
674
- let y;
1090
+ const s = t.filters && t.filters.excludeAttrs && n(t.filters.excludeAttrs), r = t.filters && t.filters.fixAttrs, a = t.filters && t.filters.fixStyles, o = t.filters && t.filters.excludeStyles && n(t.filters.excludeStyles), i = t.filters && t.filters.fixTags, c = t.filters && t.filters.excludeClasses, l = t.filters && t.filters.excludeIds, g = t.filters && t.filters.excludeSelectorClasses, d = t.filters && t.filters.excludeSelectorIds;
1091
+ let h;
675
1092
  if (t.filters && t.filters.excludeSelectors && t.filters.excludeSelectors.length > 0) {
676
- const l = Array.from(
1093
+ const u = Array.from(
677
1094
  document.querySelectorAll(t.filters.excludeSelectors.join(","))
678
1095
  );
679
- l.length > 0 && (y = new Set(l));
1096
+ u.length > 0 && (h = new Set(u));
680
1097
  }
681
- function j(l, E, S, g) {
682
- const O = getComputedStyle(l, E), p = [];
683
- for (let b = 0, k = O.length; b < k; b++) {
684
- const P = O[b];
685
- if (o && o[P])
1098
+ function x(u, y, E, w) {
1099
+ const _ = getComputedStyle(u, y), S = [];
1100
+ for (let O = 0, T = _.length; O < T; O++) {
1101
+ const D = _[O];
1102
+ if (o && o[D])
686
1103
  continue;
687
- let d = O[P];
688
- if (d && a)
689
- for (let A = 0, C = a.length; A < C; A++)
690
- a[A].name.test(P) && (d = d.replace(a[A].search, a[A].replace));
691
- (!S || S[P] !== d) && (!g || g[P] === d) && p.push([P, d]);
1104
+ let b = _[D];
1105
+ if (b && a)
1106
+ for (let M = 0, C = a.length; M < C; M++)
1107
+ a[M].name.test(D) && (b = b.replace(a[M].search, a[M].replace));
1108
+ (!E || E[D] !== b) && (!w || w[D] === b) && S.push([D, b]);
692
1109
  }
693
- return e(p);
1110
+ return e(S);
694
1111
  }
695
- function h(l, E, S) {
1112
+ function f(u, y, E) {
696
1113
  return {
697
- _: j(
698
- l,
1114
+ _: x(
1115
+ u,
699
1116
  void 0,
700
- E && E._,
701
- S && S._
1117
+ y && y._,
1118
+ E && E._
702
1119
  ),
703
- before: j(
704
- l,
1120
+ before: x(
1121
+ u,
705
1122
  "before",
706
- E && E.before,
707
- S && S.before
1123
+ y && y.before,
1124
+ E && E.before
708
1125
  ),
709
- after: j(
710
- l,
1126
+ after: x(
1127
+ u,
711
1128
  "after",
712
- E && E.after,
713
- S && S.after
1129
+ y && y.after,
1130
+ E && E.after
714
1131
  )
715
1132
  };
716
1133
  }
717
- function w(l, E, S, g, O) {
718
- for (let p = 0, b = l.childNodes.length; p < b; p++) {
719
- const k = l.childNodes[p];
720
- if (!k)
1134
+ function m(u, y, E, w, _) {
1135
+ for (let S = 0, O = u.childNodes.length; S < O; S++) {
1136
+ const T = u.childNodes[S];
1137
+ if (!T)
721
1138
  throw new Error(
722
- `child is null; index=${p}; ${g}, ${l.className}\r
1139
+ `child is null; index=${S}; ${w}, ${u.className}\r
723
1140
  You should wait js executions before test`
724
1141
  );
725
- k instanceof Element && m(
726
- k,
1142
+ T instanceof Element && p(
1143
+ T,
1144
+ y,
727
1145
  E,
728
- S,
729
- g,
730
- O
1146
+ w,
1147
+ _
731
1148
  );
732
1149
  }
733
1150
  }
734
- function m(l, E, S, g, O) {
735
- const p = O && O[E.length];
736
- if (O && !p || y && y.has(l))
1151
+ function p(u, y, E, w, _) {
1152
+ const S = _ && _[y.length];
1153
+ if (_ && !S || h && h.has(u))
737
1154
  return;
738
- let b = l.tagName && l.tagName.toLowerCase();
739
- if (b === "head" && (S = !1), i)
740
- for (let L = 0, $ = i.length; L < $; L++)
741
- b = b.replace(i[L].search, i[L].replace);
742
- if (p && p.tag !== b)
1155
+ let O = u.tagName && u.tagName.toLowerCase();
1156
+ if (O === "head" && (E = !1), i)
1157
+ for (let j = 0, B = i.length; j < B; j++)
1158
+ O = O.replace(i[j].search, i[j].replace);
1159
+ if (S && S.tag !== O)
743
1160
  return;
744
- const k = [];
745
- for (let L = 0, $ = l.attributes.length; L < $; L++) {
746
- const R = l.attributes.item(L);
747
- let _ = R.name, J = R.value;
748
- if (_ = _.toLowerCase(), _ !== "class" && !(s && s[_])) {
1161
+ const T = [];
1162
+ for (let j = 0, B = u.attributes.length; j < B; j++) {
1163
+ const W = u.attributes.item(j);
1164
+ let z = W.name, K = W.value;
1165
+ if (z = z.toLowerCase(), z !== "class" && !(s && s[z])) {
749
1166
  if (r)
750
- for (let B = 0, dt = r.length; B < dt; B++)
751
- r[B].name.test(_) && (J = J.replace(r[B].search, r[B].replace));
752
- (!p || p.attrs && p.attrs[_] === J) && k.push([_, J]);
1167
+ for (let U = 0, Et = r.length; U < Et; U++)
1168
+ r[U].name.test(z) && (K = K.replace(r[U].search, r[U].replace));
1169
+ (!S || S.attrs && S.attrs[z] === K) && T.push([z, K]);
753
1170
  }
754
1171
  }
755
- const P = [], d = [];
756
- for (let L = 0, $ = l.classList.length; L < $; L++) {
757
- const R = l.classList.item(L);
758
- (!u || !u.test(R)) && P.push(R), (!x || !x.test(R)) && d.push(R);
1172
+ const D = [], b = [];
1173
+ for (let j = 0, B = u.classList.length; j < B; j++) {
1174
+ const W = u.classList.item(j);
1175
+ (!c || !c.test(W)) && D.push(W), (!g || !g.test(W)) && b.push(W);
759
1176
  }
760
- const A = S ? h(l, t.defaultStyle, p && p.style) : null, C = l.childElementCount ? [] : null;
761
- l.id && (!c || !c.test(l.id)) && l.id;
762
- const M = l.id && (!f || !f.test(l.id)) ? l.id : "", I = (b || "") + (M ? "#" + M : "") + (d.length > 0 ? "." + d.join(".") : ""), tt = I ? g ? g + " > " + I : I : g, ht = {
763
- tag: b,
764
- selector: tt,
765
- classes: P,
766
- attrs: k.length > 0 ? e(k) : null,
767
- style: A,
1177
+ const M = E ? f(u, t.defaultStyle, S && S.style) : null, C = u.childElementCount ? [] : null;
1178
+ u.id && (!l || !l.test(u.id)) && u.id;
1179
+ const L = u.id && (!d || !d.test(u.id)) ? u.id : "", N = (O || "") + (L ? "#" + L : "") + (b.length > 0 ? "." + b.join(".") : ""), nt = N ? w ? w + " > " + N : N : w, gt = {
1180
+ tag: O,
1181
+ selector: nt,
1182
+ classes: D,
1183
+ attrs: T.length > 0 ? e(T) : null,
1184
+ style: M,
768
1185
  childs: C
769
1186
  };
770
- E.push(ht), C && w(
771
- l,
1187
+ y.push(gt), C && m(
1188
+ u,
772
1189
  C,
773
- S,
774
- tt,
775
- p && p.childs
1190
+ E,
1191
+ nt,
1192
+ S && S.childs
776
1193
  );
777
1194
  }
778
- const T = [];
779
- return m(
1195
+ const k = [];
1196
+ return p(
780
1197
  document.documentElement,
781
- T,
1198
+ k,
782
1199
  !0,
783
1200
  "",
784
1201
  t.shouldEqualResult && [t.shouldEqualResult]
785
- ), T[0];
1202
+ ), k[0];
786
1203
  }
787
- async function ct(t) {
1204
+ async function pt(t) {
788
1205
  const e = await t.context().newCDPSession(t);
789
1206
  return await e.send("DOM.enable"), await e.send("CSS.enable"), e;
790
1207
  }
791
- async function lt(t) {
1208
+ async function wt(t) {
792
1209
  await t.send("CSS.disable"), await t.send("DOM.disable"), await t.detach();
793
1210
  }
794
- async function ce(t, e) {
795
- const n = await ct(t);
1211
+ async function ve(t, e) {
1212
+ const n = await pt(t);
796
1213
  try {
797
1214
  return await e(n);
798
1215
  } finally {
799
- await lt(n);
1216
+ await wt(n);
800
1217
  }
801
1218
  }
802
- async function $t(t, e) {
1219
+ async function ne(t, e) {
803
1220
  const { nodes: n } = await t.send("DOM.getFlattenedDocument", {
804
1221
  depth: -1,
805
1222
  pierce: !0
@@ -810,7 +1227,7 @@ async function $t(t, e) {
810
1227
  forcedPseudoClasses: e
811
1228
  });
812
1229
  }
813
- function K(t, e) {
1230
+ function q(t, e) {
814
1231
  if (!t || !e)
815
1232
  return e || null;
816
1233
  let n = null;
@@ -820,17 +1237,17 @@ function K(t, e) {
820
1237
  Object.prototype.hasOwnProperty.call(t, s) && !Object.prototype.hasOwnProperty.call(e, s) && (n || (n = {}), n[s] = "");
821
1238
  return n;
822
1239
  }
823
- function Bt(t, e) {
1240
+ function se(t, e) {
824
1241
  if (!t || !e)
825
1242
  return e || null;
826
- const n = K(t._, e._), s = K(t.before, e.before), r = K(t.after, e.after);
1243
+ const n = q(t._, e._), s = q(t.before, e.before), r = q(t.after, e.after);
827
1244
  return !n && !s && !r ? null : {
828
1245
  _: n || {},
829
1246
  before: s || {},
830
1247
  after: r || {}
831
1248
  };
832
1249
  }
833
- function zt(t, e) {
1250
+ function ae(t, e) {
834
1251
  if (!t || !e)
835
1252
  return e || null;
836
1253
  if (t.length !== e.length)
@@ -840,20 +1257,20 @@ function zt(t, e) {
840
1257
  return e;
841
1258
  return null;
842
1259
  }
843
- function ut(t, e) {
844
- const n = zt(t.classes, e.classes), s = K(t.attrs, e.attrs), r = Bt(t.style, e.style);
1260
+ function yt(t, e) {
1261
+ const n = ae(t.classes, e.classes), s = q(t.attrs, e.attrs), r = se(t.style, e.style);
845
1262
  let a = null;
846
1263
  if (t.childs && e.childs) {
847
1264
  const o = Math.min(t.childs.length, e.childs.length);
848
1265
  for (let i = 0; i < o; i++) {
849
- const u = ut(t.childs[i], e.childs[i]);
850
- if (u) {
1266
+ const c = yt(t.childs[i], e.childs[i]);
1267
+ if (c) {
851
1268
  if (!a) {
852
1269
  a = [];
853
- for (let c = 0; c < o; c++)
1270
+ for (let l = 0; l < o; l++)
854
1271
  a.push({});
855
1272
  }
856
- a[i] = u;
1273
+ a[i] = c;
857
1274
  }
858
1275
  }
859
1276
  }
@@ -866,23 +1283,23 @@ function ut(t, e) {
866
1283
  childs: a
867
1284
  };
868
1285
  }
869
- const V = (t, e, n, s) => {
1286
+ const Y = (t, e, n, s) => {
870
1287
  const r = s(t, e, n, s);
871
1288
  if (r == null)
872
1289
  return r;
873
1290
  if (Array.isArray(r))
874
1291
  return r.map(
875
- (a, o, i) => V(a, o, i, s)
1292
+ (a, o, i) => Y(a, o, i, s)
876
1293
  );
877
1294
  if (typeof r == "object") {
878
1295
  const a = {};
879
1296
  for (const o in r)
880
- Object.prototype.hasOwnProperty.call(r, o) && (a[o] = V(r[o], o, r, s));
1297
+ Object.prototype.hasOwnProperty.call(r, o) && (a[o] = Y(r[o], o, r, s));
881
1298
  return a;
882
1299
  }
883
1300
  return r;
884
1301
  };
885
- function ft(t, e) {
1302
+ function bt(t, e) {
886
1303
  if (t.attrs && e.excludeAttrs) {
887
1304
  for (let n = 0, s = e.excludeAttrs.length; n < s; n++)
888
1305
  delete t.attrs[e.excludeAttrs[n]];
@@ -899,9 +1316,9 @@ function ft(t, e) {
899
1316
  }
900
1317
  if (t.childs)
901
1318
  for (let n = 0, s = t.childs.length; n < s; n++)
902
- ft(t.childs[n], e);
1319
+ bt(t.childs[n], e);
903
1320
  }
904
- function Jt(t, e) {
1321
+ function oe(t, e) {
905
1322
  for (const n in t) {
906
1323
  if (!Object.prototype.hasOwnProperty.call(t, n)) continue;
907
1324
  const s = t[n];
@@ -909,11 +1326,11 @@ function Jt(t, e) {
909
1326
  if (!Object.prototype.hasOwnProperty.call(s, r)) continue;
910
1327
  const a = s[r];
911
1328
  for (const o in a)
912
- Object.prototype.hasOwnProperty.call(a, o) && ft(a[o], e);
1329
+ Object.prototype.hasOwnProperty.call(a, o) && bt(a[o], e);
913
1330
  }
914
1331
  }
915
1332
  }
916
- function le({
1333
+ function Ae({
917
1334
  actualResultFile: t,
918
1335
  expectedResultFile: e,
919
1336
  diffResultFile: n,
@@ -921,269 +1338,309 @@ function le({
921
1338
  transform: r,
922
1339
  pseudoStates: a
923
1340
  }) {
924
- let o, i, u, c = {};
1341
+ let o, i, c, l = {};
925
1342
  return {
926
- async init(x) {
927
- o = await Wt(e), r && (o = V(o, null, null, r)), o && s && Jt(o, s), await x.goto("about:blank"), i = await x.evaluate(nt, { filters: s }), u = i.style;
1343
+ async init(g) {
1344
+ o = await re(e), r && (o = Y(o, null, null, r)), o && s && oe(o, s), await g.goto("about:blank"), i = await g.evaluate(lt, { filters: s }), c = i.style;
928
1345
  },
929
1346
  async handlePage({
930
- page: x,
931
- testId: f,
932
- url: y,
933
- stateId: j,
934
- _filters: h
1347
+ page: g,
1348
+ testId: d,
1349
+ url: h,
1350
+ stateId: x,
1351
+ _filters: f
935
1352
  }) {
936
- let w = c[f];
937
- w || (w = {}, c[f] = w);
938
- let m = w[y.href];
939
- m || (m = {}, w[y.href] = m), await x.addStyleTag({
1353
+ let m = l[d];
1354
+ m || (m = {}, l[d] = m);
1355
+ let p = m[h.href];
1356
+ p || (p = {}, m[h.href] = p), await g.addStyleTag({
940
1357
  content: "*, *::before, *::after { animation-name: none!important; transition-duration: 0s !important; }"
941
1358
  });
942
- const T = a ?? [{ states: [] }];
943
- let l = null, E;
1359
+ const k = a ?? [{ states: [] }];
1360
+ let u = null, y;
944
1361
  try {
945
- for (let S = 0; S < T.length; S++) {
946
- const g = T[S], O = g.states.length > 0 ? j + ":" + g.states.join(":") : j;
947
- let p = null;
948
- if (g.states.length > 0) {
949
- l || (l = await ct(x));
950
- const d = performance.now();
951
- await $t(l, g.states), p = performance.now() - d;
1362
+ for (let E = 0; E < k.length; E++) {
1363
+ const w = k[E], _ = w.states.length > 0 ? x + ":" + w.states.join(":") : x;
1364
+ let S = null;
1365
+ if (w.states.length > 0) {
1366
+ u || (u = await pt(g));
1367
+ const b = performance.now();
1368
+ await ne(u, w.states), S = performance.now() - b;
952
1369
  }
953
- g.delay && await at(g.delay);
954
- const b = performance.now(), k = await x.evaluate(nt, {
955
- filters: h || s,
956
- defaultStyle: u,
957
- shouldEqualResult: m[O]
958
- }), P = performance.now() - b;
1370
+ w.delay && await ft(w.delay);
1371
+ const O = performance.now(), T = await g.evaluate(lt, {
1372
+ filters: f || s,
1373
+ defaultStyle: c,
1374
+ shouldEqualResult: p[_]
1375
+ }), D = performance.now() - O;
959
1376
  if (console.log(
960
- `SNAPSHOT ${O}:` + (p != null ? ` forcePseudoClasses ${p.toFixed(0)}ms,` : "") + ` getAllElements ${P.toFixed(0)}ms`
961
- ), !E)
962
- E = k, m[O] = k;
1377
+ `SNAPSHOT ${_}:` + (S != null ? ` forcePseudoClasses ${S.toFixed(0)}ms,` : "") + ` getAllElements ${D.toFixed(0)}ms`
1378
+ ), !y)
1379
+ y = T, p[_] = T;
963
1380
  else {
964
- const d = ut(E, k);
965
- d && (m[O] = d);
1381
+ const b = yt(y, T);
1382
+ b && (p[_] = b);
966
1383
  }
967
1384
  }
968
1385
  } finally {
969
- l && await lt(l);
1386
+ u && await wt(u);
970
1387
  }
971
1388
  },
972
- async end({ checkExistUrlsOnly: x }) {
973
- if (c = yt(c), r && (c = V(c, null, null, r)), o) {
974
- let f, y;
975
- if (!x)
976
- f = o, y = c;
1389
+ async end({ checkExistUrlsOnly: g }) {
1390
+ if (l = Ct(l), r && (l = Y(l, null, null, r)), o) {
1391
+ let d, h;
1392
+ if (!g)
1393
+ d = o, h = l;
977
1394
  else {
978
- f = {}, y = {};
979
- for (const h in o)
980
- if (Object.prototype.hasOwnProperty.call(o, h) && Object.prototype.hasOwnProperty.call(c, h)) {
981
- f[h] = {}, y[h] = {};
982
- for (const w in o[h])
983
- Object.prototype.hasOwnProperty.call(o[h], w) && Object.prototype.hasOwnProperty.call(c[h], w) && (f[h][w] = o[h][w], y[h][w] = c[h][w]);
1395
+ d = {}, h = {};
1396
+ for (const f in o)
1397
+ if (Object.prototype.hasOwnProperty.call(o, f) && Object.prototype.hasOwnProperty.call(l, f)) {
1398
+ d[f] = {}, h[f] = {};
1399
+ for (const m in o[f])
1400
+ Object.prototype.hasOwnProperty.call(o[f], m) && Object.prototype.hasOwnProperty.call(l[f], m) && (d[f][m] = o[f][m], h[f][m] = l[f][m]);
984
1401
  }
985
1402
  }
986
- const j = G(
987
- f,
988
- y,
989
- (h, w, m) => m.selector && (delete m.selector, Object.keys(m).length === 0) ? null : m.childs && m.childs.length === 1 ? m.childs[0] : (w && w.selector ? m[Q] ? m[Q] = w.selector : m = { selector: w.selector, ...m } : h && h.selector && (m[X] ? m[X] = h.selector : m = { selector: h.selector, ...m }), m)
1403
+ const x = V(
1404
+ d,
1405
+ h,
1406
+ (f, m, p) => p.selector && (delete p.selector, Object.keys(p).length === 0) ? null : p.childs && p.childs.length === 1 ? p.childs[0] : (m && m.selector ? p[et] ? p[et] = m.selector : p = { selector: m.selector, ...p } : f && f.selector && (p[tt] ? p[tt] = f.selector : p = { selector: f.selector, ...p }), p)
990
1407
  );
991
- if (n && await Y(n, j || {}), j)
992
- throw await Y(t, c), console.error(
993
- "Pages elements changes: " + JSON.stringify(j, null, 4).substring(0, 5e3)
1408
+ if (n && await X(n, x || {}), x)
1409
+ throw await X(t, l), console.error(
1410
+ "Pages elements changes: " + JSON.stringify(x, null, 4).substring(0, 5e3)
994
1411
  ), new Error("Pages elements changes detected");
995
- await F.promises.stat(t).catch(() => null) && await F.promises.unlink(t);
1412
+ await v.promises.stat(t).catch(() => null) && await v.promises.unlink(t);
996
1413
  } else
997
- await Y(e, c);
998
- return c;
1414
+ await X(e, l);
1415
+ return l;
999
1416
  }
1000
1417
  };
1001
1418
  }
1002
1419
  export {
1003
- he as CheckError,
1004
- de as ConsoleMessageLevel,
1005
- Q as DIFF_NEW,
1006
- X as DIFF_OLD,
1007
- me as Lazy,
1008
- pe as LazyWithId,
1009
- ye as LogLevel,
1010
- we as MAX_REPORT_ITEMS_DEFAULT,
1011
- be as MatchInternalError,
1012
- ge as Matcher,
1013
- xe as MatcherAny,
1014
- Ee as MatcherArray,
1015
- Se as MatcherArrayItem,
1016
- ke as MatcherConvert,
1017
- Oe as MatcherCustom,
1018
- je as MatcherFew,
1019
- Ce as MatcherIn,
1020
- Pe as MatcherInstanceOf,
1021
- Ae as MatcherIs,
1022
- Le as MatcherNever,
1023
- Te as MatcherNot,
1024
- Me as MatcherNumber,
1025
- De as MatcherObject,
1026
- Fe as MatcherObjectEntry,
1027
- Ie as MatcherRef,
1028
- Re as MatcherString,
1029
- _e as Random,
1030
- Ne as Subject,
1031
- We as SubjectWithId,
1032
- $e as UNIQUE_PSEUDO_RANDOM_MAX_COUNT,
1033
- Be as alertConsole,
1034
- ze as alertReplace,
1035
- Je as argsToString,
1036
- Ue as check,
1037
- ve as checkFunc,
1038
- Ft as checkPageHttpErrors,
1039
- He as consoleIntercept,
1040
- Ge as consoleMessageToString,
1041
- Ke as consoleReplace,
1042
- Ve as convertTimeZone,
1043
- ct as createCDPSession,
1044
- te as createMatchPath,
1045
- Ye as createMatchResult,
1046
- qe as createMatchResultBoolean,
1047
- Xe as createMatchResultError,
1048
- le as createPagesElementsChangesTest,
1049
- Qe as createTaskDelayRetry,
1050
- Ze as createUniquePseudoRandom,
1051
- tr as dateNowUnique,
1052
- er as deepCloneJsonLike,
1053
- rr as deepEqualJsonLike,
1054
- nr as deepEqualJsonLikeMap,
1055
- _t as delayOnErrorCall,
1056
- ne as delayOnErrorSet,
1057
- se as delayOnErrorWait,
1058
- lt as destroyCDPSession,
1059
- sr as equalArray,
1060
- ar as escapeHtml,
1061
- or as escapeRegExp,
1062
- Mt as exec,
1063
- ir as expectedToString,
1064
- Qt as fileLock,
1065
- cr as filterMatchResult,
1066
- lr as filterMatchResultNested,
1067
- ur as fixStackTrace,
1068
- $t as forcePseudoClasses,
1069
- fr as formatAny,
1070
- hr as formatDate,
1071
- dr as formatDateFileName,
1072
- nt as getAllElements,
1073
- mr as getConsoleMessages,
1074
- pr as getDateInet,
1075
- Ot as getDrive,
1076
- ut as getElementsStyleDiff,
1077
- jt as getFileId,
1078
- yt as getNormalizedObject,
1079
- yr as getObjectId,
1080
- G as getObjectsDiff,
1081
- Dt as getPageHttpErrors,
1082
- wr as getRandomFunc,
1083
- br as getRandomSeed,
1084
- pt as getStackTrace,
1085
- At as globGitIgnoreToPicomatch,
1086
- Lt as globToRelative,
1087
- Nt as initPage,
1088
- gr as isMatcher,
1089
- xr as isObservable,
1090
- ee as loadGlobs,
1091
- Tt as loadGlobsFromFile,
1092
- Wt as loadJson,
1093
- Er as match,
1094
- Sr as matchAnd,
1095
- kr as matchAndPipe,
1096
- Or as matchAny,
1097
- jr as matchArray,
1098
- Cr as matchArrayBuffer,
1099
- Pr as matchArrayIncludes,
1100
- Ar as matchArrayItem,
1101
- Lr as matchArrayLength,
1102
- Tr as matchArrayWith,
1103
- Mr as matchBoolean,
1104
- Dr as matchConstructor,
1105
- Fr as matchConvert,
1106
- Ir as matchCustom,
1107
- Rr as matchDeep,
1108
- _r as matchEnum,
1109
- Nr as matchFloat,
1110
- Wr as matchIn,
1111
- $r as matchInstanceOf,
1112
- Br as matchInt,
1113
- zr as matchIntDate,
1114
- Jr as matchIs,
1115
- Ur as matchIsNonStrict,
1116
- vr as matchNever,
1117
- Hr as matchNot,
1118
- Gr as matchNotNullish,
1119
- Kr as matchNullish,
1120
- Vr as matchNumber,
1121
- Yr as matchObject,
1122
- qr as matchObjectEntries,
1123
- Xr as matchObjectEntry,
1124
- Qr as matchObjectKey,
1125
- Zr as matchObjectKeyValue,
1126
- tn as matchObjectKeys,
1127
- en as matchObjectKeysNotNull,
1128
- rn as matchObjectPartial,
1129
- nn as matchObjectValue,
1130
- sn as matchObjectValues,
1131
- an as matchObjectWith,
1132
- on as matchOptional,
1133
- cn as matchOr,
1134
- ln as matchOrPipe,
1135
- un as matchRange,
1136
- fn as matchRangeDate,
1137
- hn as matchRef,
1138
- dn as matchResultNestedToString,
1139
- mn as matchResultToString,
1140
- pn as matchString,
1141
- yn as matchStringLength,
1142
- wn as matchTypeOf,
1143
- bn as matchUuid,
1144
- gn as matchValueState,
1145
- xn as max,
1146
- En as min,
1147
- Sn as minMax,
1148
- re as nodeBeep,
1149
- kn as numberMod,
1150
- V as objectTransform,
1151
- W as pathNormalize,
1152
- Ct as pathResolve,
1153
- Z as poolFs,
1154
- On as randomBoolean,
1155
- jn as randomEnum,
1156
- Cn as randomFloat,
1157
- Pn as randomIndexWeighted,
1158
- An as randomInt,
1159
- Ln as randomItem,
1160
- Tn as randomItems,
1161
- Y as saveJson,
1162
- Mn as setFuncName,
1163
- Rt as setPlaywrightPriorityLow,
1164
- Dn as sha256,
1165
- Fn as sha256Buffer,
1166
- It as subscribeJsErrors,
1167
- ae as testPage,
1168
- In as timeoutAbortController,
1169
- Rn as toHex,
1170
- _n as truncateString,
1171
- Nn as urlGetBoolean,
1172
- Wn as urlGetFloat,
1173
- $n as urlGetInt,
1174
- Bn as urlGetParams,
1175
- zn as urlGetString,
1176
- Jn as urlParamToBoolean,
1177
- Un as urlParamToFloat,
1178
- vn as urlParamToInt,
1179
- oe as useBrowser,
1180
- ie as useBrowserContext,
1181
- ce as usingCDPSession,
1182
- Hn as validateMatchResult,
1183
- Gn as waitObservable,
1184
- Pt as walkPathHandleErrorDefault,
1185
- Zt as walkPaths,
1186
- Kn as withConsoleReplace,
1187
- Vn as withRetry,
1188
- mt as withTimeout
1420
+ Le as Cache,
1421
+ Fe as CacheStats,
1422
+ Ie as CheckError,
1423
+ Re as ConsoleMessageLevel,
1424
+ et as DIFF_NEW,
1425
+ tt as DIFF_OLD,
1426
+ Kt as FileStatStorage,
1427
+ it as FileStorage,
1428
+ Ne as Lazy,
1429
+ $e as LazyWithId,
1430
+ We as Locker,
1431
+ St as LockerWithId,
1432
+ ze as LogLevel,
1433
+ Be as MAX_REPORT_ITEMS_DEFAULT,
1434
+ Ue as MatchInternalError,
1435
+ Je as Matcher,
1436
+ Ke as MatcherAny,
1437
+ Ge as MatcherArray,
1438
+ He as MatcherArrayItem,
1439
+ Ve as MatcherConvert,
1440
+ qe as MatcherCustom,
1441
+ Ye as MatcherFew,
1442
+ Qe as MatcherIn,
1443
+ Xe as MatcherInstanceOf,
1444
+ Ze as MatcherIs,
1445
+ tr as MatcherNever,
1446
+ er as MatcherNot,
1447
+ rr as MatcherNumber,
1448
+ nr as MatcherObject,
1449
+ sr as MatcherObjectEntry,
1450
+ ar as MatcherRef,
1451
+ or as MatcherString,
1452
+ ir as MemoryStorage,
1453
+ cr as Random,
1454
+ lr as Subject,
1455
+ ur as SubjectWithId,
1456
+ fr as UNIQUE_PSEUDO_RANDOM_MAX_COUNT,
1457
+ hr as alertConsole,
1458
+ dr as alertReplace,
1459
+ mr as argsToString,
1460
+ pr as check,
1461
+ wr as checkFunc,
1462
+ Vt as checkPageHttpErrors,
1463
+ Ce as clickAll,
1464
+ yr as compressGzip,
1465
+ br as consoleIntercept,
1466
+ gr as consoleMessageToString,
1467
+ Er as consoleReplace,
1468
+ Sr as convertTimeZone,
1469
+ xt as converterErrorToBuffer,
1470
+ xr as converterJson,
1471
+ Ot as converterJsonBuffer,
1472
+ Or as converterStringToBuffer,
1473
+ pt as createCDPSession,
1474
+ ct as createConverterSubPath,
1475
+ xe as createFileCacheOptions,
1476
+ Ee as createMatchPath,
1477
+ Tr as createMatchResult,
1478
+ _r as createMatchResultBoolean,
1479
+ kr as createMatchResultError,
1480
+ Ae as createPagesElementsChangesTest,
1481
+ Cr as createTaskDelayRetry,
1482
+ ee as createTestE2e,
1483
+ Pe as createTestE2eVariants,
1484
+ Pr as createUniquePseudoRandom,
1485
+ Dr as dateNowUnique,
1486
+ vr as decompressGzip,
1487
+ Ar as deepCloneJsonLike,
1488
+ Mr as deepEqualJsonLike,
1489
+ jr as deepEqualJsonLikeMap,
1490
+ Yt as delayOnErrorCall,
1491
+ Te as delayOnErrorSet,
1492
+ _e as delayOnErrorWait,
1493
+ wt as destroyCDPSession,
1494
+ Lr as equalArray,
1495
+ Fr as escapeHtml,
1496
+ Ir as escapeRegExp,
1497
+ Gt as exec,
1498
+ Rr as expectedToString,
1499
+ be as fileLock,
1500
+ Nr as filterMatchResult,
1501
+ $r as filterMatchResultNested,
1502
+ Wr as fixStackTrace,
1503
+ ne as forcePseudoClasses,
1504
+ zr as formatAny,
1505
+ Br as formatDate,
1506
+ Ur as formatDateFileName,
1507
+ Lt as generateTempFileName,
1508
+ lt as getAllElements,
1509
+ Jr as getConsoleMessages,
1510
+ Kr as getDateInet,
1511
+ It as getDrive,
1512
+ yt as getElementsStyleDiff,
1513
+ Rt as getFileId,
1514
+ Tt as getHashKey,
1515
+ Gr as getJsonKey,
1516
+ Ct as getNormalizedObject,
1517
+ Hr as getObjectId,
1518
+ V as getObjectsDiff,
1519
+ Ht as getPageHttpErrors,
1520
+ Vr as getRandomFunc,
1521
+ qr as getRandomSeed,
1522
+ kt as getStackTrace,
1523
+ Wt as globGitIgnoreToPicomatch,
1524
+ zt as globToRelative,
1525
+ Qt as initPage,
1526
+ Yr as isGzipCompressed,
1527
+ Qr as isMatcher,
1528
+ Xr as isObservable,
1529
+ Se as loadGlobs,
1530
+ Bt as loadGlobsFromFile,
1531
+ re as loadJson,
1532
+ Zr as mapObjectConverter,
1533
+ tn as match,
1534
+ en as matchAnd,
1535
+ rn as matchAndPipe,
1536
+ nn as matchAny,
1537
+ sn as matchArray,
1538
+ an as matchArrayBuffer,
1539
+ on as matchArrayIncludes,
1540
+ cn as matchArrayItem,
1541
+ ln as matchArrayLength,
1542
+ un as matchArrayWith,
1543
+ fn as matchBoolean,
1544
+ hn as matchConstructor,
1545
+ dn as matchConvert,
1546
+ mn as matchCustom,
1547
+ pn as matchDeep,
1548
+ wn as matchEnum,
1549
+ yn as matchFloat,
1550
+ bn as matchIn,
1551
+ gn as matchInstanceOf,
1552
+ En as matchInt,
1553
+ Sn as matchIntDate,
1554
+ xn as matchIs,
1555
+ On as matchIsNonStrict,
1556
+ Tn as matchNever,
1557
+ _n as matchNot,
1558
+ kn as matchNotNullish,
1559
+ Cn as matchNullish,
1560
+ Pn as matchNumber,
1561
+ Dn as matchObject,
1562
+ vn as matchObjectEntries,
1563
+ An as matchObjectEntry,
1564
+ Mn as matchObjectKey,
1565
+ jn as matchObjectKeyValue,
1566
+ Ln as matchObjectKeys,
1567
+ Fn as matchObjectKeysNotNull,
1568
+ In as matchObjectPartial,
1569
+ Rn as matchObjectValue,
1570
+ Nn as matchObjectValues,
1571
+ $n as matchObjectWith,
1572
+ Wn as matchOptional,
1573
+ zn as matchOr,
1574
+ Bn as matchOrPipe,
1575
+ Un as matchRange,
1576
+ Jn as matchRangeDate,
1577
+ Kn as matchRef,
1578
+ Gn as matchResultNestedToString,
1579
+ Hn as matchResultToString,
1580
+ Vn as matchString,
1581
+ qn as matchStringLength,
1582
+ Yn as matchTypeOf,
1583
+ Qn as matchUuid,
1584
+ Xn as matchValueState,
1585
+ Zn as max,
1586
+ ts as min,
1587
+ es as minMax,
1588
+ Oe as nodeBeep,
1589
+ rs as numberMod,
1590
+ Y as objectTransform,
1591
+ F as pathNormalize,
1592
+ Nt as pathResolve,
1593
+ R as poolFs,
1594
+ ut as promiseAllWait,
1595
+ ns as randomBoolean,
1596
+ ss as randomEnum,
1597
+ as as randomFloat,
1598
+ os as randomIndexWeighted,
1599
+ is as randomInt,
1600
+ cs as randomItem,
1601
+ ls as randomItems,
1602
+ Jt as readDirRecursive,
1603
+ X as saveJson,
1604
+ us as setArrayConverter,
1605
+ fs as setFuncName,
1606
+ mt as setPlaywrightPriorityLow,
1607
+ hs as sha256,
1608
+ ds as sha256Buffer,
1609
+ qt as subscribeJsErrors,
1610
+ Xt as testPage,
1611
+ ms as timeoutAbortController,
1612
+ ps as toConvertFrom,
1613
+ ws as toConvertTo,
1614
+ ys as toConvertWithDefaultFrom,
1615
+ bs as toConvertWithDefaultTo,
1616
+ gs as toConverter,
1617
+ Es as toConverterFrom,
1618
+ Ss as toConverterTo,
1619
+ xs as toConverterWithDefault,
1620
+ Os as toConverterWithDefaultFrom,
1621
+ Ts as toConverterWithDefaultTo,
1622
+ _s as toCorrect,
1623
+ ks as toCorrectWithDefault,
1624
+ Cs as toHex,
1625
+ Ps as truncateString,
1626
+ Ds as urlGetBoolean,
1627
+ vs as urlGetFloat,
1628
+ As as urlGetInt,
1629
+ Ms as urlGetParams,
1630
+ js as urlGetString,
1631
+ Ls as urlParamToBoolean,
1632
+ Fs as urlParamToFloat,
1633
+ Is as urlParamToInt,
1634
+ ke as useBrowser,
1635
+ Zt as useBrowserContext,
1636
+ ve as usingCDPSession,
1637
+ Rs as validateMatchResult,
1638
+ Ns as waitObservable,
1639
+ De as waitPageStable,
1640
+ $t as walkPathHandleErrorDefault,
1641
+ ge as walkPaths,
1642
+ $s as withConsoleReplace,
1643
+ Ws as withRetry,
1644
+ _t as withTimeout,
1645
+ jt as writeFileThroughTmp
1189
1646
  };