@flemist/simple-utils 2.1.0 → 2.1.1

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.
@@ -1,53 +1,55 @@
1
- import { T as ct, Q as lt, E as ut } from "../urlGet-BCW9jvAm.mjs";
2
- import { L as Yt, V as Zt, W as te, O as ee, R as ne, _ as re, $ as se, U as ae, K as oe, G as ie, a2 as ce, J as le, H as ue, M as fe, q as de, Y as he, l as me, o as pe, A as ye, B as we, C as ge, D as xe, y as Se, z as Ee, P as ke, u as Oe, v as be, w as je, I as Pe, p as Le, d as Ae, g as Ce, Z as De, a1 as Fe, aq as Te, as as Ie, a5 as We, a3 as _e, aP as Re, a4 as Me, a8 as Ne, au as ze, ax as $e, am as Je, al as Ue, a9 as He, aI as Be, ag as Ge, aH as Ke, ae as Ve, aG as qe, aj as ve, ad as Qe, aJ as Xe, ab as Ye, aa as Ze, a7 as tn, aM as en, ao as nn, an as rn, ac as sn, af as an, aA as on, aB as cn, aC as ln, aE as un, ay as fn, aF as dn, ah as hn, aD as mn, az as pn, aw as yn, at as wn, ap as gn, ar as xn, aK as Sn, aL as En, a6 as kn, ai as On, av as bn, ak as jn, aN as Pn, aO as Ln, b as An, m as Cn, c as Dn, n as Fn, f as Tn, k as In, r as Wn, h as _n, e as Rn, i as Mn, j as Nn, F as zn, a as $n, s as Jn, S as Un, t as Hn, x as Bn, aV as Gn, aX as Kn, aW as Vn, aQ as qn, aU as vn, aR as Qn, aT as Xn, aS as Yn, a0 as Zn, N as tr, X as er } from "../urlGet-BCW9jvAm.mjs";
3
- import { Locker as ft, useAbortController as dt, combineAbortSignals as ht, delay as mt } from "@flemist/async-utils";
4
- import { Pool as pt, poolRunWait as M } from "@flemist/time-limits";
5
- import yt from "node:os";
1
+ import { T as mt, Q as pt, E as yt } from "../urlGet-BCW9jvAm.mjs";
2
+ import { L as de, V as he, W as me, O as pe, R as ye, _ as we, $ as ge, U as xe, K as Ee, G as Se, a2 as be, J as ke, H as Oe, M as Pe, q as je, Y as Ce, l as Ae, o as Le, A as De, B as Fe, C as Te, D as Ie, y as _e, z as Re, P as We, u as Ne, v as $e, w as Me, I as Be, p as ze, d as Je, g as Ue, Z as He, a1 as Ge, aq as ve, as as Ke, a5 as Ve, a3 as Ye, aP as qe, a4 as Qe, a8 as Xe, au as Ze, ax as tn, am as en, al as nn, a9 as rn, aI as sn, ag as an, aH as on, ae as cn, aG as ln, aj as un, ad as fn, aJ as dn, ab as hn, aa as mn, a7 as pn, aM as yn, ao as wn, an as gn, ac as xn, af as En, aA as Sn, aB as bn, aC as kn, aE as On, ay as Pn, aF as jn, ah as Cn, aD as An, az as Ln, aw as Dn, at as Fn, ap as Tn, ar as In, aK as _n, aL as Rn, a6 as Wn, ai as Nn, av as $n, ak as Mn, aN as Bn, aO as zn, b as Jn, m as Un, c as Hn, n as Gn, f as vn, k as Kn, r as Vn, h as Yn, e as qn, i as Qn, j as Xn, F as Zn, a as tr, s as er, S as nr, t as rr, x as sr, aV as ar, aX as or, aW as ir, aQ as cr, aU as lr, aR as ur, aT as fr, aS as dr, a0 as hr, N as mr, X as pr } from "../urlGet-BCW9jvAm.mjs";
3
+ import { Locker as wt, useAbortController as gt, combineAbortSignals as st, delay as at } from "@flemist/async-utils";
4
+ import { Pool as xt, poolRunWait as N } from "@flemist/time-limits";
5
+ import Et from "node:os";
6
6
  import * as T from "path";
7
- import { priorityCreate as J } from "@flemist/priority-queue";
7
+ import ot from "path";
8
+ import { priorityCreate as z } from "@flemist/priority-queue";
8
9
  import * as I from "fs";
9
- import wt from "picomatch";
10
- import { spawn as gt } from "child_process";
11
- const Q = new pt(yt.cpus().length);
12
- function N(t) {
10
+ import St from "picomatch";
11
+ import { spawn as H } from "child_process";
12
+ import { AbortControllerFast as bt } from "@flemist/abort-controller-fast";
13
+ const Z = new xt(Et.cpus().length);
14
+ function $(t) {
13
15
  return t.replace(/\\/g, "/");
14
16
  }
15
- let H = null;
16
- function xt(t) {
17
- H == null && (H = /* @__PURE__ */ new Map());
18
- const e = N(t);
19
- let r = H.get(e);
20
- return r == null && (r = new ft(), H.set(e, r)), r;
17
+ let U = null;
18
+ function kt(t) {
19
+ U == null && (U = /* @__PURE__ */ new Map());
20
+ const e = $(t);
21
+ let r = U.get(e);
22
+ return r == null && (r = new wt(), U.set(e, r)), r;
21
23
  }
22
- function Jt(t) {
24
+ function Xt(t) {
23
25
  const { filePath: e, func: r } = t;
24
- return xt(e).lock(
25
- () => M({
26
- pool: Q,
26
+ return kt(e).lock(
27
+ () => N({
28
+ pool: Z,
27
29
  count: 1,
28
30
  func: r
29
31
  })
30
32
  );
31
33
  }
32
- function St(t) {
34
+ function Ot(t) {
33
35
  return t.match(/^[/\\]?[^/\\]+/)[0];
34
36
  }
35
- function Et(t, e) {
36
- return St(t) + "|" + e.ino;
37
+ function Pt(t, e) {
38
+ return Ot(t) + "|" + e.ino;
37
39
  }
38
- function kt(t) {
40
+ function jt(t) {
39
41
  return t.endsWith(":") && (t += "/"), T.resolve(t);
40
42
  }
41
- function Y(t, e) {
43
+ function et(t, e) {
42
44
  t.totalSize += e.totalSize, t.maxFileDateModified = Math.max(
43
45
  t.maxFileDateModified,
44
46
  e.maxFileDateModified
45
47
  ), t.countFiles += e.countFiles, t.countDirs += e.countDirs, t.countLinks += e.countLinks;
46
48
  }
47
- const Ot = function(e) {
49
+ const Ct = function(e) {
48
50
  return e.code === "ENOENT";
49
51
  };
50
- function et(t) {
52
+ function it(t) {
51
53
  const e = t.paths;
52
54
  if (!e || e.length === 0)
53
55
  return Promise.resolve({
@@ -57,43 +59,43 @@ function et(t) {
57
59
  countDirs: 0,
58
60
  countLinks: 0
59
61
  });
60
- const r = t.level ?? 0, s = t.walkedIds ?? /* @__PURE__ */ new Set(), n = t.abortSignal, a = t.pool ?? Q, o = t.handleError, u = t.priority ?? J(0), f = t.walkLinks ?? !1, i = t.log, S = t.handlePath, l = t.matchPath;
62
+ const r = t.level ?? 0, s = t.walkedIds ?? /* @__PURE__ */ new Set(), n = t.abortSignal, a = t.pool ?? Z, o = t.handleError, i = t.priority ?? z(0), u = t.walkLinks ?? !1, c = t.log, E = t.handlePath, f = t.matchPath;
61
63
  async function y(d) {
62
- if (!(o && await o(d)) && !Ot(d))
64
+ if (!(o && await o(d)) && !Ct(d))
63
65
  throw d;
64
66
  }
65
- function j(d) {
66
- return !(!i || i.minTotalContentSize != null && d < i.minTotalContentSize || i.maxNestedLevel != null && r > i.maxNestedLevel);
67
+ function P(d) {
68
+ return !(!c || c.minTotalContentSize != null && d < c.minTotalContentSize || c.maxNestedLevel != null && r > c.maxNestedLevel);
67
69
  }
68
- return dt(async (d) => {
69
- const w = ht(n, d), m = {
70
+ return gt(async (d) => {
71
+ const w = st(n, d), m = {
70
72
  totalSize: 0,
71
73
  maxFileDateModified: 0,
72
74
  countFiles: 0,
73
75
  countDirs: 0,
74
76
  countLinks: 0
75
77
  };
76
- function D(x, b) {
77
- if (j(b.totalSize)) {
78
- const g = `${b.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${x}`;
79
- i?.handleLog ? i.handleLog(g) : console.log(g);
78
+ function D(x, O) {
79
+ if (P(O.totalSize)) {
80
+ const g = `${O.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${x}`;
81
+ c?.handleLog ? c.handleLog(g) : console.log(g);
80
82
  }
81
83
  }
82
- async function c(x, b, p, g) {
83
- return S ? await M({
84
+ async function l(x, O, p, g) {
85
+ return E ? await N({
84
86
  pool: a,
85
87
  func: async () => {
86
88
  try {
87
- return await S({
89
+ return await E({
88
90
  level: r,
89
91
  path: x,
90
- stat: b,
92
+ stat: O,
91
93
  itemStat: p,
92
94
  totalStat: m,
93
95
  abortSignal: w
94
96
  });
95
- } catch (O) {
96
- return await y(O), !1;
97
+ } catch (k) {
98
+ return await y(k), !1;
97
99
  }
98
100
  },
99
101
  count: 1,
@@ -101,71 +103,71 @@ function et(t) {
101
103
  abortSignal: w
102
104
  }) : !0;
103
105
  }
104
- async function E(x, b, p, g) {
106
+ async function S(x, O, p, g) {
105
107
  g || (g = x);
106
- const O = await M({
108
+ const k = await N({
107
109
  pool: a,
108
110
  func: () => I.promises.lstat(x).catch(y),
109
111
  count: 1,
110
- priority: J(b, J(1, u)),
112
+ priority: z(O, z(1, i)),
111
113
  abortSignal: w
112
114
  });
113
- if (!O || !p && O.isFile())
115
+ if (!k || !p && k.isFile())
114
116
  return null;
115
- const L = Et(x, O);
116
- if (s.has(L))
117
+ const C = Pt(x, k);
118
+ if (s.has(C))
117
119
  return null;
118
- s.add(L);
120
+ s.add(C);
119
121
  let h = {
120
- totalSize: O.size,
121
- maxFileDateModified: O.isDirectory() ? 0 : O.mtimeMs,
122
+ totalSize: k.size,
123
+ maxFileDateModified: k.isDirectory() ? 0 : k.mtimeMs,
122
124
  countFiles: 0,
123
125
  countDirs: 0,
124
126
  countLinks: 0
125
127
  };
126
- const A = J(
127
- b,
128
- J(O.isDirectory() ? 2 : 3, u)
128
+ const A = z(
129
+ O,
130
+ z(k.isDirectory() ? 2 : 3, i)
129
131
  );
130
- if (O.isSymbolicLink()) {
131
- if (f) {
132
- const P = await M({
132
+ if (k.isSymbolicLink()) {
133
+ if (u) {
134
+ const j = await N({
133
135
  pool: a,
134
136
  func: () => I.promises.readlink(x).catch(y).then((F) => F ?? null),
135
137
  count: 1,
136
138
  priority: A,
137
139
  abortSignal: w
138
140
  });
139
- if (P) {
140
- const F = T.isAbsolute(P) ? P : T.resolve(T.dirname(g), P), W = await E(
141
+ if (j) {
142
+ const F = T.isAbsolute(j) ? j : T.resolve(T.dirname(g), j), _ = await S(
141
143
  F,
142
- b,
144
+ O,
143
145
  p,
144
146
  g
145
147
  );
146
- W && (h = W);
148
+ _ && (h = _);
147
149
  }
148
150
  }
149
- return (p || h.countFiles + h.countDirs + h.countLinks >= 1) && (h.countLinks += 1, await c(
151
+ return (p || h.countFiles + h.countDirs + h.countLinks >= 1) && (h.countLinks += 1, await l(
150
152
  g,
151
- O,
153
+ k,
152
154
  h,
153
155
  A
154
- ) && (Y(m, h), D(g, h))), h;
155
- } else if (O.isDirectory()) {
156
- const P = await M({
156
+ ) && (et(m, h), D(g, h))), h;
157
+ } else if (k.isDirectory()) {
158
+ const j = await N({
157
159
  pool: a,
158
160
  func: () => I.promises.readdir(x).catch(y),
159
161
  count: 1,
160
- priority: u,
162
+ priority: i,
161
163
  abortSignal: w
162
164
  });
163
- if (P) {
164
- for (let F = 0, W = P.length; F < W; F++)
165
- P[F] = T.join(g, P[F]);
166
- h = await et({
165
+ if (j) {
166
+ for (let F = 0, _ = j.length; F < _; F++)
167
+ j[F] = T.join(g, j[F]);
168
+ h = await it({
167
169
  ...t,
168
- paths: P,
170
+ paths: j,
169
171
  abortSignal: w,
170
172
  priority: A,
171
173
  level: r + 1,
@@ -173,32 +175,32 @@ function et(t) {
173
175
  });
174
176
  }
175
177
  }
176
- return (p || h.countFiles + h.countDirs + h.countLinks >= 1) && (O.isDirectory() ? h.countDirs += 1 : O.isFile() && (h.countFiles += 1), await c(
178
+ return (p || h.countFiles + h.countDirs + h.countLinks >= 1) && (k.isDirectory() ? h.countDirs += 1 : k.isFile() && (h.countFiles += 1), await l(
177
179
  g,
178
- O,
180
+ k,
179
181
  h,
180
182
  A
181
- ) && (Y(m, h), D(g, h))), h;
183
+ ) && (et(m, h), D(g, h))), h;
182
184
  }
183
- const k = [];
184
- for (let x = 0, b = e.length; x < b; x++) {
185
- const p = kt(e[x]), g = l ? l(p) : !0;
186
- g !== !1 && k.push(E(p, x, g));
185
+ const b = [];
186
+ for (let x = 0, O = e.length; x < O; x++) {
187
+ const p = jt(e[x]), g = f ? f(p) : !0;
188
+ g !== !1 && b.push(S(p, x, g));
187
189
  }
188
- return await Promise.all(k), m;
190
+ return await Promise.all(b), m;
189
191
  });
190
192
  }
191
- function Ut(t) {
192
- return et(t);
193
+ function Zt(t) {
194
+ return it(t);
193
195
  }
194
- function Ht({
196
+ function te({
195
197
  globs: t,
196
198
  rootDir: e,
197
199
  noCase: r
198
200
  }) {
199
201
  const s = [];
200
202
  return t.forEach((n) => {
201
- n = N(n).trim();
203
+ n = $(n).trim();
202
204
  const a = n.startsWith("^");
203
205
  a && (n = n.substring(1).trim());
204
206
  const o = n.startsWith("!");
@@ -207,85 +209,85 @@ function Ht({
207
209
  `Invalid glob pattern: "${n}". The syntax '${n.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.`
208
210
  );
209
211
  n.startsWith("/") && (n = "." + n);
210
- const u = N(e ? T.resolve(e, n) : n);
211
- if (!u)
212
+ const i = $(e ? T.resolve(e, n) : n);
213
+ if (!i)
212
214
  return;
213
- let f;
215
+ let u;
214
216
  try {
215
- f = wt(u, {
217
+ u = St(i, {
216
218
  nocase: r ?? !1,
217
219
  dot: !0,
218
220
  strictBrackets: !0
219
221
  // Validate bracket balance for patterns like "["
220
222
  });
221
- } catch (i) {
223
+ } catch (c) {
222
224
  throw new Error(
223
- `Invalid glob pattern: "${n}". ${i instanceof Error ? i.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.`
225
+ `Invalid glob pattern: "${n}". ${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.`
224
226
  );
225
227
  }
226
228
  s.push({
227
229
  exclude: a,
228
230
  negative: o,
229
- debugInfo: u,
230
- match: f
231
+ debugInfo: i,
232
+ match: u
231
233
  });
232
234
  }), function(a) {
233
- a = N(a);
234
- let o = null, u = !1;
235
- for (let f = 0, i = s.length; f < i; f++) {
236
- const S = s[f];
237
- S.match(a) && (S.exclude ? u = !S.negative : (o = !S.negative, u = !1));
235
+ a = $(a);
236
+ let o = null, i = !1;
237
+ for (let u = 0, c = s.length; u < c; u++) {
238
+ const E = s[u];
239
+ E.match(a) && (E.exclude ? i = !E.negative : (o = !E.negative, i = !1));
238
240
  }
239
- return u ? !1 : o;
241
+ return i ? !1 : o;
240
242
  };
241
243
  }
242
- function bt(t) {
244
+ function At(t) {
243
245
  const e = t.startsWith("!");
244
246
  return e && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), e && (t = "!" + t), t;
245
247
  }
246
- function jt(t, e) {
248
+ function Lt(t, e) {
247
249
  if (!e || e === ".")
248
250
  return t;
249
251
  const r = t.startsWith("^");
250
252
  r && (t = t.substring(1));
251
253
  const s = t.startsWith("!");
252
- 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 = N(T.normalize(t)), s && (t = "!" + t), r && (t = "^" + t), t;
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 = $(T.normalize(t)), s && (t = "!" + t), r && (t = "^" + t), t;
253
255
  }
254
- function Z(t) {
256
+ function nt(t) {
255
257
  return "^" + t;
256
258
  }
257
- async function Pt(t) {
259
+ async function Dt(t) {
258
260
  const r = (await I.promises.readFile(t, "utf-8")).split(`
259
261
  `), s = [];
260
262
  return r.forEach((n) => {
261
263
  n = n.trim(), !(!n || n.startsWith("#")) && s.push(n);
262
264
  }), s;
263
265
  }
264
- async function Bt(t) {
266
+ async function ee(t) {
265
267
  const e = t.rootDir ?? ".", r = [];
266
268
  if (!t.globs?.length)
267
269
  return r;
268
270
  const s = [];
269
271
  return t.globs.forEach((n) => {
270
- n.value && (n.valueType === "file-contains-patterns" ? s.push(n) : n.valueType === "pattern" && r.push(n.exclude ? Z(n.value) : n.value));
272
+ n.value && (n.valueType === "file-contains-patterns" ? s.push(n) : n.valueType === "pattern" && r.push(n.exclude ? nt(n.value) : n.value));
271
273
  }), s.length && await Promise.all(
272
274
  s.map(async (n) => {
273
- await M({
274
- pool: Q,
275
+ await N({
276
+ pool: Z,
275
277
  count: 1,
276
278
  func: async () => {
277
- const a = T.resolve(e, n.value), o = await Pt(a), u = T.relative(e, T.dirname(a));
278
- o.forEach((f) => {
279
- f = bt(f), f = jt(f, u), r.push(n.exclude ? Z(f) : f);
279
+ const a = T.resolve(e, n.value), o = await Dt(a), i = T.relative(e, T.dirname(a));
280
+ o.forEach((u) => {
281
+ u = At(u), u = Lt(u, i), r.push(n.exclude ? nt(u) : u);
280
282
  });
281
283
  }
282
284
  });
283
285
  })
284
286
  ), r;
285
287
  }
286
- function Lt(t, e = {}) {
288
+ function Ft(t, e = {}) {
287
289
  return new Promise((r, s) => {
288
- const n = gt(t, {
290
+ const n = H(t, {
289
291
  shell: !0,
290
292
  ...e
291
293
  }), a = [];
@@ -294,93 +296,120 @@ function Lt(t, e = {}) {
294
296
  }), n.on("error", (o) => {
295
297
  s(o);
296
298
  }), n.on("exit", (o) => {
297
- const u = Buffer.concat(a).toString("utf8");
299
+ const i = Buffer.concat(a).toString("utf8");
298
300
  if (o !== 0) {
299
301
  s(new Error(`[exec][exit] code: ${o}`));
300
302
  return;
301
303
  }
302
- r(u);
304
+ r(i);
303
305
  });
304
306
  });
305
307
  }
306
- async function At({
308
+ async function ne() {
309
+ let t;
310
+ switch (process.platform) {
311
+ case "darwin":
312
+ t = H("afplay", ["/System/Library/Sounds/Ping.aiff"], {
313
+ stdio: "ignore"
314
+ });
315
+ break;
316
+ case "linux":
317
+ t = H("beep", [], { stdio: "ignore", shell: !0 });
318
+ break;
319
+ case "win32":
320
+ t = H("powershell", ["-c", "[console]::beep(1000,300)"], {
321
+ stdio: "ignore"
322
+ });
323
+ break;
324
+ default:
325
+ throw new Error(
326
+ `[nodeBeep] Beep not supported on platform: ${process.platform}`
327
+ );
328
+ }
329
+ await new Promise((e, r) => {
330
+ t.on("error", r), t.on("close", (s) => {
331
+ s !== 0 ? r(new Error(`[nodeBeep] Beep process exited with code ${s}`)) : e();
332
+ });
333
+ });
334
+ }
335
+ async function Tt({
307
336
  page: t,
308
337
  urlFilters: e,
309
338
  timeouts: r
310
339
  }) {
311
- return r || (r = {}), r.downloadInternal || (r.downloadInternal = 10 * 1e3), r.downloadExternal || (r.downloadExternal = 60 * 1e3), r.total || (r.total = 300 * 1e3), await ct(
340
+ return r || (r = {}), r.downloadInternal || (r.downloadInternal = 10 * 1e3), r.downloadExternal || (r.downloadExternal = 60 * 1e3), r.total || (r.total = 300 * 1e3), await mt(
312
341
  () => t.evaluate(
313
342
  ({
314
343
  urlFilters: n,
315
344
  timeouts: a
316
345
  }) => {
317
- function o(i) {
318
- return function(l) {
346
+ function o(c) {
347
+ return function(f) {
319
348
  let y = !1;
320
- for (let j = 0, d = i.length; j < d; j++) {
321
- const w = i[j];
322
- w.pattern.test(l) && (y = w.value);
349
+ for (let P = 0, d = c.length; P < d; P++) {
350
+ const w = c[P];
351
+ w.pattern.test(f) && (y = w.value);
323
352
  }
324
353
  return y;
325
354
  };
326
355
  }
327
- const u = n && o(n);
328
- let f = performance.getEntries && performance.getEntries();
329
- return f || (f = []), f.push({
356
+ const i = n && o(n);
357
+ let u = performance.getEntries && performance.getEntries();
358
+ return u || (u = []), u.push({
330
359
  name: location.href
331
360
  }), Promise.all(
332
- f.map(
333
- (i) => {
334
- if (i.entryType != null && i.entryType !== "resource" || u && !u(i.name))
361
+ u.map(
362
+ (c) => {
363
+ if (c.entryType != null && c.entryType !== "resource" || i && !i(c.name))
335
364
  return null;
336
- if (i.responseStatus != null)
337
- return i.responseStatus >= 400 ? Promise.resolve({
338
- url: i.name,
339
- error: i.responseStatus
365
+ if (c.responseStatus != null)
366
+ return c.responseStatus >= 400 ? Promise.resolve({
367
+ url: c.name,
368
+ error: c.responseStatus
340
369
  }) : null;
341
370
  if (navigator.userAgent.indexOf("Chrome") === -1)
342
371
  return null;
343
- const S = typeof AbortController < "u" ? new AbortController() : null, l = new URL(i.name).origin === location.origin, y = l ? a.downloadInternal : a.downloadExternal;
344
- let j;
345
- const d = new Promise((c, E) => {
346
- j = E;
372
+ const E = typeof AbortController < "u" ? new AbortController() : null, f = new URL(c.name).origin === location.origin, y = f ? a.downloadInternal : a.downloadExternal;
373
+ let P;
374
+ const d = new Promise((l, S) => {
375
+ P = S;
347
376
  }), w = y && setTimeout(() => {
348
- S?.abort(), j(
377
+ E?.abort(), P(
349
378
  new Error("[test][getPageHttpErrors] fetch timeout")
350
379
  );
351
380
  }, y);
352
- let m = fetch(i.name, {
353
- mode: l ? "same-origin" : "no-cors",
354
- signal: S?.signal,
355
- cache: l ? "force-cache" : void 0,
381
+ let m = fetch(c.name, {
382
+ mode: f ? "same-origin" : "no-cors",
383
+ signal: E?.signal,
384
+ cache: f ? "force-cache" : void 0,
356
385
  method: "HEAD"
357
- }).then((c) => c.ok ? null : {
358
- url: i.name,
359
- error: c.status + " " + c.statusText
360
- }).catch((c) => ({
361
- url: i.name,
362
- error: c.message
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
363
392
  }));
364
- S || (m = Promise.race([m, d]));
393
+ E || (m = Promise.race([m, d]));
365
394
  function D() {
366
395
  w && clearTimeout(w);
367
396
  }
368
397
  return m.then(
369
- (c) => (D(), c),
370
- (c) => {
371
- throw D(), c;
398
+ (l) => (D(), l),
399
+ (l) => {
400
+ throw D(), l;
372
401
  }
373
402
  );
374
403
  }
375
404
  )
376
- ).then((i) => {
377
- const S = i.filter((l) => l).map(
378
- (l) => ({
379
- url: new URL(l.url),
380
- error: l.error
405
+ ).then((c) => {
406
+ const E = c.filter((f) => f).map(
407
+ (f) => ({
408
+ url: new URL(f.url),
409
+ error: f.error
381
410
  })
382
411
  );
383
- return S.length > 0 ? S : null;
412
+ return E.length > 0 ? E : null;
384
413
  });
385
414
  },
386
415
  {
@@ -391,12 +420,12 @@ async function At({
391
420
  { timeout: r.total }
392
421
  );
393
422
  }
394
- async function Gt({
423
+ async function It({
395
424
  page: t,
396
425
  urlFilters: e,
397
426
  errorFilter: r
398
427
  }) {
399
- let s = await At({
428
+ let s = await Tt({
400
429
  page: t,
401
430
  urlFilters: e
402
431
  });
@@ -405,45 +434,45 @@ async function Gt({
405
434
  `[test][checkPageHttpErrors] Page has http errors: ${JSON.stringify(s, null, 2)}`
406
435
  );
407
436
  }
408
- async function Kt({
437
+ async function _t({
409
438
  page: t,
410
439
  filter: e,
411
440
  onError: r
412
441
  }) {
413
- const s = "callback_191b355ea6f64499a6607ad571da5d4d", n = t.context().browser()?.browserType().name(), a = lt();
414
- function o(u) {
442
+ const s = "callback_191b355ea6f64499a6607ad571da5d4d", n = t.context().browser()?.browserType().name(), a = pt();
443
+ function o(i) {
415
444
  try {
416
445
  if (e && !e({
417
446
  url: new URL(t.url()),
418
- error: u
447
+ error: i
419
448
  }))
420
449
  return;
421
- } catch (f) {
422
- u = String(f);
450
+ } catch (u) {
451
+ i = String(u);
423
452
  }
424
453
  try {
425
454
  console.error(
426
- `[test][subscribeJsErrors] BROWSER JS ERROR (${n}): ${u}`
455
+ `[test][subscribeJsErrors] BROWSER JS ERROR (${n}): ${i}`
427
456
  );
428
- const f = new Error(u);
429
- f.stack = a, r(f);
430
- } catch (f) {
431
- console.error("[test][subscribeJsErrors] error", f);
457
+ const u = new Error(i);
458
+ u.stack = a, r(u);
459
+ } catch (u) {
460
+ console.error("[test][subscribeJsErrors] error", u);
432
461
  }
433
462
  }
434
- await t.exposeFunction(s, o), await t.addInitScript((u) => {
435
- function f(l) {
436
- if (Array.isArray(l))
437
- return l.map(f).join(`\r
463
+ 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
438
467
  \r
439
468
  `);
440
- if (l instanceof Error)
441
- return l.stack || l.toString();
442
- if (typeof l == "object" && l != null) {
469
+ if (f instanceof Error)
470
+ return f.stack || f.toString();
471
+ if (typeof f == "object" && f != null) {
443
472
  const y = /* @__PURE__ */ new Set();
444
473
  return JSON.stringify(
445
- l,
446
- (j, d) => {
474
+ f,
475
+ (P, d) => {
447
476
  if (typeof d == "object" && d != null) {
448
477
  if (y.has(d))
449
478
  return "[Circular]";
@@ -454,37 +483,37 @@ async function Kt({
454
483
  2
455
484
  );
456
485
  }
457
- return String(l);
486
+ return String(f);
458
487
  }
459
- function i(l) {
460
- window[u](l);
488
+ function c(f) {
489
+ window[i](f);
461
490
  }
462
- const S = {
491
+ const E = {
463
492
  warn: console.warn.bind(console),
464
493
  error: console.error.bind(console)
465
494
  };
466
495
  console.warn = function(...y) {
467
- return i("console.warn: " + f(y)), S.warn.apply(this, y);
496
+ return c("console.warn: " + u(y)), E.warn.apply(this, y);
468
497
  }, console.error = function(...y) {
469
- return i("console.error: " + f(y)), S.error.apply(this, y);
498
+ return c("console.error: " + u(y)), E.error.apply(this, y);
470
499
  }, window.addEventListener(
471
500
  "error",
472
- function(l) {
473
- i("window error: " + (l.message || JSON.stringify(l)));
501
+ function(f) {
502
+ c("window error: " + (f.message || JSON.stringify(f)));
474
503
  },
475
504
  !0
476
505
  ), window.addEventListener(
477
506
  "unhandledrejection",
478
- function(l) {
479
- i("window unhandledrejection: " + f(l.reason));
507
+ function(f) {
508
+ c("window unhandledrejection: " + u(f.reason));
480
509
  },
481
510
  !0
482
511
  );
483
512
  }, s);
484
513
  }
485
- async function Vt() {
514
+ async function Rt() {
486
515
  try {
487
- process.platform === "win32" && await Lt(
516
+ process.platform === "win32" && await Ft(
488
517
  `wmic process where "commandline like '%ms-playwright%' and not commandline like '%wmic.exe%' and priority != 4" CALL setpriority "idle"`
489
518
  );
490
519
  } catch (t) {
@@ -494,28 +523,123 @@ async function Vt() {
494
523
  console.warn("[test][setPlaywrightPriorityLow] error: " + e);
495
524
  }
496
525
  }
497
- async function V(t, e) {
526
+ let G = null, q = null;
527
+ function re(t) {
528
+ q = t;
529
+ }
530
+ function Wt() {
531
+ if (G)
532
+ 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`), G = at(t), G;
536
+ }
537
+ function se() {
538
+ return G;
539
+ }
540
+ async function Nt(t) {
541
+ const { page: e } = t, r = e.context().browser()?.browserType().name(), s = new bt(), n = st(
542
+ s.signal,
543
+ t.abortSignal
544
+ ), a = (i) => {
545
+ let u = `Error in (${r}) ${e.url()}
546
+ `;
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);
549
+ };
550
+ return await _t({
551
+ page: e,
552
+ filter: t.filters?.js?.filter,
553
+ onError: a
554
+ }), {
555
+ abortSignal: n,
556
+ checkErrors: async () => {
557
+ await It({
558
+ page: e,
559
+ urlFilters: t.filters?.http?.urlFilters,
560
+ errorFilter: t.filters?.http?.errorFilter
561
+ }), n.throwIfAborted();
562
+ }
563
+ };
564
+ }
565
+ async function ae({
566
+ page: t,
567
+ abortSignal: e,
568
+ filters: r,
569
+ func: s,
570
+ pageFilePath: n
571
+ }) {
572
+ const a = t.context().browser()?.browserType().name();
573
+ try {
574
+ const { abortSignal: o, checkErrors: i } = await Nt({
575
+ page: t,
576
+ abortSignal: e,
577
+ filters: r,
578
+ pageFilePath: n
579
+ });
580
+ await s({
581
+ page: t,
582
+ abortSignal: o,
583
+ checkErrors: i
584
+ }), await i();
585
+ } catch (o) {
586
+ let i = `Error in (${a}) ${t.url()}
587
+ `;
588
+ throw n && (i += ` at _ (${ot.resolve(n)}:0:0)
589
+ `), o.stack = i + (o.stack || o.message), o.message = i + o.message, o;
590
+ }
591
+ }
592
+ function oe({
593
+ browserType: t,
594
+ options: e
595
+ }) {
596
+ return async function(s) {
597
+ const n = await t.launch(e ?? void 0);
598
+ try {
599
+ return await s(n);
600
+ } finally {
601
+ await n.close();
602
+ }
603
+ };
604
+ }
605
+ function ie({
606
+ browser: t,
607
+ options: e
608
+ }) {
609
+ return async function(s) {
610
+ const n = await t.newContext(e ?? void 0);
611
+ await Rt();
612
+ try {
613
+ const a = await s(n);
614
+ return await n.close(), a;
615
+ } catch (a) {
616
+ const o = Wt?.();
617
+ throw o ? (console.error("[test][useBrowserContext] error", a), o.finally(() => n.close())) : await n.close(), a;
618
+ }
619
+ };
620
+ }
621
+ async function Y(t, e) {
498
622
  const r = T.dirname(t);
499
623
  await I.promises.stat(r).catch(() => null) || await I.promises.mkdir(r, { recursive: !0 }), await I.promises.writeFile(t, JSON.stringify(e, null, 4), {
500
624
  encoding: "utf-8"
501
625
  });
502
626
  }
503
- async function Ct(t) {
627
+ async function $t(t) {
504
628
  if (!await I.promises.stat(t).catch(() => null))
505
629
  return null;
506
630
  const e = await I.promises.readFile(t, { encoding: "utf-8" });
507
631
  return JSON.parse(e);
508
632
  }
509
- const q = "-", v = "+";
510
- function B(t, e, r) {
633
+ const Q = "-", X = "+";
634
+ function v(t, e, r) {
511
635
  if (t === e)
512
636
  return null;
513
637
  if (Array.isArray(t)) {
514
638
  if (Array.isArray(e)) {
515
639
  let n = null;
516
640
  for (let a = 0, o = Math.max(e.length, e.length); a < o; a++) {
517
- const u = B(t[a], e[a], r);
518
- u != null && (n || (n = []), n.push(u));
641
+ const i = v(t[a], e[a], r);
642
+ i != null && (n || (n = []), n.push(i));
519
643
  }
520
644
  return n != null && r && (n = r(t, e, n)), n;
521
645
  }
@@ -523,131 +647,131 @@ function B(t, e, r) {
523
647
  let n = null;
524
648
  for (const a in t)
525
649
  if (Object.prototype.hasOwnProperty.call(t, a)) {
526
- const o = B(t[a], e[a], r);
650
+ const o = v(t[a], e[a], r);
527
651
  o != null && (n || (n = {}), n[a] = o);
528
652
  }
529
653
  for (const a in e)
530
654
  if (Object.prototype.hasOwnProperty.call(e, a) && !Object.prototype.hasOwnProperty.call(t, a)) {
531
- const o = B(t[a], e[a], r);
655
+ const o = v(t[a], e[a], r);
532
656
  o != null && (n || (n = {}), n[a] = o);
533
657
  }
534
658
  return n != null && r && (n = r(t, e, n)), n;
535
659
  }
536
660
  let s = {
537
- [q]: t,
538
- [v]: e
661
+ [Q]: t,
662
+ [X]: e
539
663
  };
540
664
  return r && (s = r(t, e, s)), s;
541
665
  }
542
- function tt(t) {
543
- function e(c) {
544
- return c.sort((E, k) => E[0] > k[0] ? 1 : -1).reduce((E, k) => (E[k[0]] = k[1], E), {});
666
+ function rt(t) {
667
+ function e(l) {
668
+ return l.sort((S, b) => S[0] > b[0] ? 1 : -1).reduce((S, b) => (S[b[0]] = b[1], S), {});
545
669
  }
546
- function r(c) {
547
- return c.reduce((E, k) => (E[k] = !0, E), {});
670
+ function r(l) {
671
+ return l.reduce((S, b) => (S[b] = !0, S), {});
548
672
  }
549
- const s = t.filters && t.filters.excludeAttrs && r(t.filters.excludeAttrs), n = t.filters && t.filters.fixAttrs, a = t.filters && t.filters.fixStyles, o = t.filters && t.filters.excludeStyles && r(t.filters.excludeStyles), u = t.filters && t.filters.fixTags, f = t.filters && t.filters.excludeClasses, i = t.filters && t.filters.excludeIds, S = t.filters && t.filters.excludeSelectorClasses, l = t.filters && t.filters.excludeSelectorIds;
673
+ const s = t.filters && t.filters.excludeAttrs && r(t.filters.excludeAttrs), n = t.filters && t.filters.fixAttrs, a = t.filters && t.filters.fixStyles, o = t.filters && t.filters.excludeStyles && r(t.filters.excludeStyles), i = t.filters && t.filters.fixTags, u = t.filters && t.filters.excludeClasses, c = t.filters && t.filters.excludeIds, E = t.filters && t.filters.excludeSelectorClasses, f = t.filters && t.filters.excludeSelectorIds;
550
674
  let y;
551
675
  if (t.filters && t.filters.excludeSelectors && t.filters.excludeSelectors.length > 0) {
552
- const c = Array.from(
676
+ const l = Array.from(
553
677
  document.querySelectorAll(t.filters.excludeSelectors.join(","))
554
678
  );
555
- c.length > 0 && (y = new Set(c));
679
+ l.length > 0 && (y = new Set(l));
556
680
  }
557
- function j(c, E, k, x) {
558
- const b = getComputedStyle(c, E), p = [];
559
- for (let g = 0, O = b.length; g < O; g++) {
560
- const L = b[g];
561
- if (o && o[L])
681
+ function P(l, S, b, x) {
682
+ const O = getComputedStyle(l, S), p = [];
683
+ for (let g = 0, k = O.length; g < k; g++) {
684
+ const C = O[g];
685
+ if (o && o[C])
562
686
  continue;
563
- let h = b[L];
687
+ let h = O[C];
564
688
  if (h && a)
565
- for (let A = 0, P = a.length; A < P; A++)
566
- a[A].name.test(L) && (h = h.replace(a[A].search, a[A].replace));
567
- (!k || k[L] !== h) && (!x || x[L] === h) && p.push([L, h]);
689
+ for (let A = 0, j = a.length; A < j; A++)
690
+ a[A].name.test(C) && (h = h.replace(a[A].search, a[A].replace));
691
+ (!b || b[C] !== h) && (!x || x[C] === h) && p.push([C, h]);
568
692
  }
569
693
  return e(p);
570
694
  }
571
- function d(c, E, k) {
695
+ function d(l, S, b) {
572
696
  return {
573
- _: j(
574
- c,
697
+ _: P(
698
+ l,
575
699
  void 0,
576
- E && E._,
577
- k && k._
700
+ S && S._,
701
+ b && b._
578
702
  ),
579
- before: j(
580
- c,
703
+ before: P(
704
+ l,
581
705
  "before",
582
- E && E.before,
583
- k && k.before
706
+ S && S.before,
707
+ b && b.before
584
708
  ),
585
- after: j(
586
- c,
709
+ after: P(
710
+ l,
587
711
  "after",
588
- E && E.after,
589
- k && k.after
712
+ S && S.after,
713
+ b && b.after
590
714
  )
591
715
  };
592
716
  }
593
- function w(c, E, k, x, b) {
594
- for (let p = 0, g = c.childNodes.length; p < g; p++) {
595
- const O = c.childNodes[p];
596
- if (!O)
717
+ function w(l, S, b, x, O) {
718
+ for (let p = 0, g = l.childNodes.length; p < g; p++) {
719
+ const k = l.childNodes[p];
720
+ if (!k)
597
721
  throw new Error(
598
- `child is null; index=${p}; ${x}, ${c.className}\r
722
+ `child is null; index=${p}; ${x}, ${l.className}\r
599
723
  You should wait js executions before test`
600
724
  );
601
- O instanceof Element && m(
602
- O,
603
- E,
725
+ k instanceof Element && m(
604
726
  k,
727
+ S,
728
+ b,
605
729
  x,
606
- b
730
+ O
607
731
  );
608
732
  }
609
733
  }
610
- function m(c, E, k, x, b) {
611
- const p = b && b[E.length];
612
- if (b && !p || y && y.has(c))
734
+ function m(l, S, b, x, O) {
735
+ const p = O && O[S.length];
736
+ if (O && !p || y && y.has(l))
613
737
  return;
614
- let g = c.tagName && c.tagName.toLowerCase();
615
- if (g === "head" && (k = !1), u)
616
- for (let C = 0, z = u.length; C < z; C++)
617
- g = g.replace(u[C].search, u[C].replace);
738
+ let g = l.tagName && l.tagName.toLowerCase();
739
+ if (g === "head" && (b = !1), i)
740
+ for (let L = 0, M = i.length; L < M; L++)
741
+ g = g.replace(i[L].search, i[L].replace);
618
742
  if (p && p.tag !== g)
619
743
  return;
620
- const O = [];
621
- for (let C = 0, z = c.attributes.length; C < z; C++) {
622
- const _ = c.attributes.item(C);
623
- let R = _.name, U = _.value;
624
- if (R = R.toLowerCase(), R !== "class" && !(s && s[R])) {
744
+ const k = [];
745
+ for (let L = 0, M = l.attributes.length; L < M; L++) {
746
+ const R = l.attributes.item(L);
747
+ let W = R.name, J = R.value;
748
+ if (W = W.toLowerCase(), W !== "class" && !(s && s[W])) {
625
749
  if (n)
626
- for (let $ = 0, it = n.length; $ < it; $++)
627
- n[$].name.test(R) && (U = U.replace(n[$].search, n[$].replace));
628
- (!p || p.attrs && p.attrs[R] === U) && O.push([R, U]);
750
+ for (let B = 0, ht = n.length; B < ht; B++)
751
+ n[B].name.test(W) && (J = J.replace(n[B].search, n[B].replace));
752
+ (!p || p.attrs && p.attrs[W] === J) && k.push([W, J]);
629
753
  }
630
754
  }
631
- const L = [], h = [];
632
- for (let C = 0, z = c.classList.length; C < z; C++) {
633
- const _ = c.classList.item(C);
634
- (!f || !f.test(_)) && L.push(_), (!S || !S.test(_)) && h.push(_);
755
+ const C = [], h = [];
756
+ for (let L = 0, M = l.classList.length; L < M; L++) {
757
+ const R = l.classList.item(L);
758
+ (!u || !u.test(R)) && C.push(R), (!E || !E.test(R)) && h.push(R);
635
759
  }
636
- const A = k ? d(c, t.defaultStyle, p && p.style) : null, P = c.childElementCount ? [] : null;
637
- c.id && (!i || !i.test(c.id)) && c.id;
638
- const F = c.id && (!l || !l.test(c.id)) ? c.id : "", W = (g || "") + (F ? "#" + F : "") + (h.length > 0 ? "." + h.join(".") : ""), X = W ? x ? x + " > " + W : W : x, ot = {
760
+ const A = b ? d(l, t.defaultStyle, p && p.style) : null, j = l.childElementCount ? [] : null;
761
+ l.id && (!c || !c.test(l.id)) && l.id;
762
+ const F = l.id && (!f || !f.test(l.id)) ? l.id : "", _ = (g || "") + (F ? "#" + F : "") + (h.length > 0 ? "." + h.join(".") : ""), tt = _ ? x ? x + " > " + _ : _ : x, dt = {
639
763
  tag: g,
640
- selector: X,
641
- classes: L,
642
- attrs: O.length > 0 ? e(O) : null,
764
+ selector: tt,
765
+ classes: C,
766
+ attrs: k.length > 0 ? e(k) : null,
643
767
  style: A,
644
- childs: P
768
+ childs: j
645
769
  };
646
- E.push(ot), P && w(
647
- c,
648
- P,
649
- k,
650
- X,
770
+ S.push(dt), j && w(
771
+ l,
772
+ j,
773
+ b,
774
+ tt,
651
775
  p && p.childs
652
776
  );
653
777
  }
@@ -660,22 +784,22 @@ You should wait js executions before test`
660
784
  t.shouldEqualResult && [t.shouldEqualResult]
661
785
  ), D[0];
662
786
  }
663
- async function nt(t) {
787
+ async function ct(t) {
664
788
  const e = await t.context().newCDPSession(t);
665
789
  return await e.send("DOM.enable"), await e.send("CSS.enable"), e;
666
790
  }
667
- async function rt(t) {
791
+ async function lt(t) {
668
792
  await t.send("CSS.disable"), await t.send("DOM.disable"), await t.detach();
669
793
  }
670
- async function qt(t, e) {
671
- const r = await nt(t);
794
+ async function ce(t, e) {
795
+ const r = await ct(t);
672
796
  try {
673
797
  return await e(r);
674
798
  } finally {
675
- await rt(r);
799
+ await lt(r);
676
800
  }
677
801
  }
678
- async function Dt(t, e) {
802
+ async function Mt(t, e) {
679
803
  const { nodes: r } = await t.send("DOM.getFlattenedDocument", {
680
804
  depth: -1,
681
805
  pierce: !0
@@ -686,7 +810,7 @@ async function Dt(t, e) {
686
810
  forcedPseudoClasses: e
687
811
  });
688
812
  }
689
- function G(t, e) {
813
+ function K(t, e) {
690
814
  if (!t || !e)
691
815
  return e || null;
692
816
  let r = null;
@@ -696,17 +820,17 @@ function G(t, e) {
696
820
  Object.prototype.hasOwnProperty.call(t, s) && !Object.prototype.hasOwnProperty.call(e, s) && (r || (r = {}), r[s] = "");
697
821
  return r;
698
822
  }
699
- function Ft(t, e) {
823
+ function Bt(t, e) {
700
824
  if (!t || !e)
701
825
  return e || null;
702
- const r = G(t._, e._), s = G(t.before, e.before), n = G(t.after, e.after);
826
+ const r = K(t._, e._), s = K(t.before, e.before), n = K(t.after, e.after);
703
827
  return !r && !s && !n ? null : {
704
828
  _: r || {},
705
829
  before: s || {},
706
830
  after: n || {}
707
831
  };
708
832
  }
709
- function Tt(t, e) {
833
+ function zt(t, e) {
710
834
  if (!t || !e)
711
835
  return e || null;
712
836
  if (t.length !== e.length)
@@ -716,20 +840,20 @@ function Tt(t, e) {
716
840
  return e;
717
841
  return null;
718
842
  }
719
- function st(t, e) {
720
- const r = Tt(t.classes, e.classes), s = G(t.attrs, e.attrs), n = Ft(t.style, e.style);
843
+ function ut(t, e) {
844
+ const r = zt(t.classes, e.classes), s = K(t.attrs, e.attrs), n = Bt(t.style, e.style);
721
845
  let a = null;
722
846
  if (t.childs && e.childs) {
723
847
  const o = Math.min(t.childs.length, e.childs.length);
724
- for (let u = 0; u < o; u++) {
725
- const f = st(t.childs[u], e.childs[u]);
726
- if (f) {
848
+ for (let i = 0; i < o; i++) {
849
+ const u = ut(t.childs[i], e.childs[i]);
850
+ if (u) {
727
851
  if (!a) {
728
852
  a = [];
729
- for (let i = 0; i < o; i++)
853
+ for (let c = 0; c < o; c++)
730
854
  a.push({});
731
855
  }
732
- a[u] = f;
856
+ a[i] = u;
733
857
  }
734
858
  }
735
859
  }
@@ -742,23 +866,23 @@ function st(t, e) {
742
866
  childs: a
743
867
  };
744
868
  }
745
- const K = (t, e, r, s) => {
869
+ const V = (t, e, r, s) => {
746
870
  const n = s(t, e, r, s);
747
871
  if (n == null)
748
872
  return n;
749
873
  if (Array.isArray(n))
750
874
  return n.map(
751
- (a, o, u) => K(a, o, u, s)
875
+ (a, o, i) => V(a, o, i, s)
752
876
  );
753
877
  if (typeof n == "object") {
754
878
  const a = {};
755
879
  for (const o in n)
756
- Object.prototype.hasOwnProperty.call(n, o) && (a[o] = K(n[o], o, n, s));
880
+ Object.prototype.hasOwnProperty.call(n, o) && (a[o] = V(n[o], o, n, s));
757
881
  return a;
758
882
  }
759
883
  return n;
760
884
  };
761
- function at(t, e) {
885
+ function ft(t, e) {
762
886
  if (t.attrs && e.excludeAttrs) {
763
887
  for (let r = 0, s = e.excludeAttrs.length; r < s; r++)
764
888
  delete t.attrs[e.excludeAttrs[r]];
@@ -775,9 +899,9 @@ function at(t, e) {
775
899
  }
776
900
  if (t.childs)
777
901
  for (let r = 0, s = t.childs.length; r < s; r++)
778
- at(t.childs[r], e);
902
+ ft(t.childs[r], e);
779
903
  }
780
- function It(t, e) {
904
+ function Jt(t, e) {
781
905
  for (const r in t) {
782
906
  if (!Object.prototype.hasOwnProperty.call(t, r)) continue;
783
907
  const s = t[r];
@@ -785,11 +909,11 @@ function It(t, e) {
785
909
  if (!Object.prototype.hasOwnProperty.call(s, n)) continue;
786
910
  const a = s[n];
787
911
  for (const o in a)
788
- Object.prototype.hasOwnProperty.call(a, o) && at(a[o], e);
912
+ Object.prototype.hasOwnProperty.call(a, o) && ft(a[o], e);
789
913
  }
790
914
  }
791
915
  }
792
- function vt({
916
+ function le({
793
917
  actualResultFile: t,
794
918
  expectedResultFile: e,
795
919
  diffResultFile: r,
@@ -797,228 +921,236 @@ function vt({
797
921
  transform: n,
798
922
  pseudoStates: a
799
923
  }) {
800
- let o, u, f, i = {};
924
+ let o, i, u, c = {};
801
925
  return {
802
- async init(S) {
803
- o = await Ct(e), n && (o = K(o, null, null, n)), o && s && It(o, s), await S.goto("about:blank"), u = await S.evaluate(tt, { filters: s }), f = u.style;
926
+ async init(E) {
927
+ o = await $t(e), n && (o = V(o, null, null, n)), o && s && Jt(o, s), await E.goto("about:blank"), i = await E.evaluate(rt, { filters: s }), u = i.style;
804
928
  },
805
929
  async handlePage({
806
- page: S,
807
- testId: l,
930
+ page: E,
931
+ testId: f,
808
932
  url: y,
809
- stateId: j,
933
+ stateId: P,
810
934
  _filters: d
811
935
  }) {
812
- let w = i[l];
813
- w || (w = {}, i[l] = w);
936
+ let w = c[f];
937
+ w || (w = {}, c[f] = w);
814
938
  let m = w[y.href];
815
- m || (m = {}, w[y.href] = m), await S.addStyleTag({
939
+ m || (m = {}, w[y.href] = m), await E.addStyleTag({
816
940
  content: "*, *::before, *::after { animation-name: none!important; transition-duration: 0s !important; }"
817
941
  });
818
942
  const D = a ?? [{ states: [] }];
819
- let c = null, E;
943
+ let l = null, S;
820
944
  try {
821
- for (let k = 0; k < D.length; k++) {
822
- const x = D[k], b = x.states.length > 0 ? j + ":" + x.states.join(":") : j;
945
+ for (let b = 0; b < D.length; b++) {
946
+ const x = D[b], O = x.states.length > 0 ? P + ":" + x.states.join(":") : P;
823
947
  let p = null;
824
948
  if (x.states.length > 0) {
825
- c || (c = await nt(S));
949
+ l || (l = await ct(E));
826
950
  const h = performance.now();
827
- await Dt(c, x.states), p = performance.now() - h;
951
+ await Mt(l, x.states), p = performance.now() - h;
828
952
  }
829
- x.delay && await mt(x.delay);
830
- const g = performance.now(), O = await S.evaluate(tt, {
953
+ x.delay && await at(x.delay);
954
+ const g = performance.now(), k = await E.evaluate(rt, {
831
955
  filters: d || s,
832
- defaultStyle: f,
833
- shouldEqualResult: m[b]
834
- }), L = performance.now() - g;
956
+ defaultStyle: u,
957
+ shouldEqualResult: m[O]
958
+ }), C = performance.now() - g;
835
959
  if (console.log(
836
- `SNAPSHOT ${b}:` + (p != null ? ` forcePseudoClasses ${p.toFixed(0)}ms,` : "") + ` getAllElements ${L.toFixed(0)}ms`
837
- ), !E)
838
- E = O, m[b] = O;
960
+ `SNAPSHOT ${O}:` + (p != null ? ` forcePseudoClasses ${p.toFixed(0)}ms,` : "") + ` getAllElements ${C.toFixed(0)}ms`
961
+ ), !S)
962
+ S = k, m[O] = k;
839
963
  else {
840
- const h = st(E, O);
841
- h && (m[b] = h);
964
+ const h = ut(S, k);
965
+ h && (m[O] = h);
842
966
  }
843
967
  }
844
968
  } finally {
845
- c && await rt(c);
969
+ l && await lt(l);
846
970
  }
847
971
  },
848
- async end({ checkExistUrlsOnly: S }) {
849
- if (i = ut(i), n && (i = K(i, null, null, n)), o) {
850
- let l, y;
851
- if (!S)
852
- l = o, y = i;
972
+ async end({ checkExistUrlsOnly: E }) {
973
+ if (c = yt(c), n && (c = V(c, null, null, n)), o) {
974
+ let f, y;
975
+ if (!E)
976
+ f = o, y = c;
853
977
  else {
854
- l = {}, y = {};
978
+ f = {}, y = {};
855
979
  for (const d in o)
856
- if (Object.prototype.hasOwnProperty.call(o, d) && Object.prototype.hasOwnProperty.call(i, d)) {
857
- l[d] = {}, y[d] = {};
980
+ if (Object.prototype.hasOwnProperty.call(o, d) && Object.prototype.hasOwnProperty.call(c, d)) {
981
+ f[d] = {}, y[d] = {};
858
982
  for (const w in o[d])
859
- Object.prototype.hasOwnProperty.call(o[d], w) && Object.prototype.hasOwnProperty.call(i[d], w) && (l[d][w] = o[d][w], y[d][w] = i[d][w]);
983
+ Object.prototype.hasOwnProperty.call(o[d], w) && Object.prototype.hasOwnProperty.call(c[d], w) && (f[d][w] = o[d][w], y[d][w] = c[d][w]);
860
984
  }
861
985
  }
862
- const j = B(
863
- l,
986
+ const P = v(
987
+ f,
864
988
  y,
865
- (d, 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[v] ? m[v] = w.selector : m = { selector: w.selector, ...m } : d && d.selector && (m[q] ? m[q] = d.selector : m = { selector: d.selector, ...m }), m)
989
+ (d, 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[X] ? m[X] = w.selector : m = { selector: w.selector, ...m } : d && d.selector && (m[Q] ? m[Q] = d.selector : m = { selector: d.selector, ...m }), m)
866
990
  );
867
- if (r && await V(r, j || {}), j)
868
- throw await V(t, i), console.error(
869
- "Pages elements changes: " + JSON.stringify(j, null, 4).substring(0, 5e3)
991
+ if (r && await Y(r, P || {}), P)
992
+ throw await Y(t, c), console.error(
993
+ "Pages elements changes: " + JSON.stringify(P, null, 4).substring(0, 5e3)
870
994
  ), new Error("Pages elements changes detected");
871
995
  await I.promises.stat(t).catch(() => null) && await I.promises.unlink(t);
872
996
  } else
873
- await V(e, i);
874
- return i;
997
+ await Y(e, c);
998
+ return c;
875
999
  }
876
1000
  };
877
1001
  }
878
1002
  export {
879
- Yt as ConsoleMessageLevel,
880
- v as DIFF_NEW,
881
- q as DIFF_OLD,
882
- Zt as Lazy,
883
- te as LazyWithId,
884
- ee as LogLevel,
885
- ne as Random,
886
- re as Subject,
887
- se as SubjectWithId,
888
- ae as UNIQUE_PSEUDO_RANDOM_MAX_COUNT,
889
- oe as alertConsole,
890
- ie as alertReplace,
891
- ce as check,
892
- Gt as checkPageHttpErrors,
893
- le as consoleIntercept,
894
- ue as consoleMessageToString,
895
- fe as consoleReplace,
896
- de as convertTimeZone,
897
- nt as createCDPSession,
898
- Ht as createMatchPath,
899
- vt as createPagesElementsChangesTest,
900
- he as createTaskDelayRetry,
901
- me as createUniquePseudoRandom,
902
- pe as dateNowUnique,
903
- ye as deepCloneJsonLike,
904
- we as deepEqualJsonLike,
905
- ge as deepEqualJsonLikeMap,
906
- rt as destroyCDPSession,
907
- xe as equalArray,
908
- Se as escapeHtml,
909
- Ee as escapeRegExp,
910
- Lt as exec,
911
- Jt as fileLock,
912
- ke as fixStackTrace,
913
- Dt as forcePseudoClasses,
914
- Oe as formatAny,
915
- be as formatDate,
916
- je as formatDateFileName,
917
- tt as getAllElements,
918
- Pe as getConsoleMessages,
919
- Le as getDateInet,
920
- St as getDrive,
921
- st as getElementsStyleDiff,
922
- Et as getFileId,
923
- ut as getNormalizedObject,
924
- B as getObjectsDiff,
925
- At as getPageHttpErrors,
926
- Ae as getRandomFunc,
927
- Ce as getRandomSeed,
928
- lt as getStackTrace,
929
- bt as globGitIgnoreToPicomatch,
930
- jt as globToRelative,
931
- De as isObservable,
932
- Bt as loadGlobs,
933
- Pt as loadGlobsFromFile,
934
- Ct as loadJson,
935
- Fe as match,
936
- Te as matchAnd,
937
- Ie as matchAndPipe,
938
- We as matchAny,
939
- _e as matchArray,
940
- Re as matchArrayBuffer,
941
- Me as matchArrayIncludes,
942
- Ne as matchArrayItem,
943
- ze as matchArrayLength,
944
- $e as matchArrayWith,
945
- Je as matchBoolean,
946
- Ue as matchConstructor,
947
- He as matchConvert,
948
- Be as matchCustom,
949
- Ge as matchDeep,
950
- Ke as matchEnum,
951
- Ve as matchFloat,
952
- qe as matchIn,
953
- ve as matchInstanceOf,
954
- Qe as matchInt,
955
- Xe as matchIntDate,
956
- Ye as matchIs,
957
- Ze as matchIsNonStrict,
958
- tn as matchNever,
959
- en as matchNot,
960
- nn as matchNotNullish,
961
- rn as matchNullish,
962
- sn as matchNumber,
963
- an as matchObject,
964
- on as matchObjectEntries,
965
- cn as matchObjectEntry,
966
- ln as matchObjectKey,
967
- un as matchObjectKeyValue,
968
- fn as matchObjectKeys,
969
- dn as matchObjectKeysNotNull,
970
- hn as matchObjectPartial,
971
- mn as matchObjectValue,
972
- pn as matchObjectValues,
973
- yn as matchObjectWith,
974
- wn as matchOptional,
975
- gn as matchOr,
976
- xn as matchOrPipe,
977
- Sn as matchRange,
978
- En as matchRangeDate,
979
- kn as matchRef,
980
- On as matchString,
981
- bn as matchStringLength,
982
- jn as matchTypeOf,
983
- Pn as matchUuid,
984
- Ln as matchValueState,
985
- An as max,
986
- Cn as min,
987
- Dn as minMax,
988
- Fn as numberMod,
989
- K as objectTransform,
990
- N as pathNormalize,
991
- kt as pathResolve,
992
- Q as poolFs,
993
- Tn as randomBoolean,
994
- In as randomEnum,
995
- Wn as randomFloat,
996
- _n as randomIndexWeighted,
997
- Rn as randomInt,
998
- Mn as randomItem,
999
- Nn as randomItems,
1000
- V as saveJson,
1001
- zn as setFuncName,
1002
- Vt as setPlaywrightPriorityLow,
1003
- $n as sha256,
1004
- Jn as sha256Buffer,
1005
- Kt as subscribeJsErrors,
1006
- Un as timeoutAbortController,
1007
- Hn as toHex,
1008
- Bn as truncateString,
1009
- Gn as urlGetBoolean,
1010
- Kn as urlGetFloat,
1011
- Vn as urlGetInt,
1012
- qn as urlGetParams,
1013
- vn as urlGetString,
1014
- Qn as urlParamToBoolean,
1015
- Xn as urlParamToFloat,
1016
- Yn as urlParamToInt,
1017
- qt as usingCDPSession,
1018
- Zn as waitObservable,
1019
- Ot as walkPathHandleErrorDefault,
1020
- Ut as walkPaths,
1021
- tr as withConsoleReplace,
1022
- er as withRetry,
1023
- ct as withTimeout
1003
+ de as ConsoleMessageLevel,
1004
+ X as DIFF_NEW,
1005
+ Q as DIFF_OLD,
1006
+ he as Lazy,
1007
+ me as LazyWithId,
1008
+ pe as LogLevel,
1009
+ ye as Random,
1010
+ we as Subject,
1011
+ ge as SubjectWithId,
1012
+ xe as UNIQUE_PSEUDO_RANDOM_MAX_COUNT,
1013
+ Ee as alertConsole,
1014
+ Se as alertReplace,
1015
+ be as check,
1016
+ It as checkPageHttpErrors,
1017
+ ke as consoleIntercept,
1018
+ Oe as consoleMessageToString,
1019
+ Pe as consoleReplace,
1020
+ je as convertTimeZone,
1021
+ ct as createCDPSession,
1022
+ te as createMatchPath,
1023
+ le as createPagesElementsChangesTest,
1024
+ Ce as createTaskDelayRetry,
1025
+ Ae as createUniquePseudoRandom,
1026
+ Le as dateNowUnique,
1027
+ De as deepCloneJsonLike,
1028
+ Fe as deepEqualJsonLike,
1029
+ Te as deepEqualJsonLikeMap,
1030
+ Wt as delayOnErrorCall,
1031
+ re as delayOnErrorSet,
1032
+ se as delayOnErrorWait,
1033
+ lt as destroyCDPSession,
1034
+ Ie as equalArray,
1035
+ _e as escapeHtml,
1036
+ Re as escapeRegExp,
1037
+ Ft as exec,
1038
+ Xt as fileLock,
1039
+ We as fixStackTrace,
1040
+ Mt as forcePseudoClasses,
1041
+ Ne as formatAny,
1042
+ $e as formatDate,
1043
+ Me as formatDateFileName,
1044
+ rt as getAllElements,
1045
+ Be as getConsoleMessages,
1046
+ ze as getDateInet,
1047
+ Ot as getDrive,
1048
+ ut as getElementsStyleDiff,
1049
+ Pt as getFileId,
1050
+ yt as getNormalizedObject,
1051
+ v as getObjectsDiff,
1052
+ Tt as getPageHttpErrors,
1053
+ Je as getRandomFunc,
1054
+ Ue as getRandomSeed,
1055
+ pt as getStackTrace,
1056
+ At as globGitIgnoreToPicomatch,
1057
+ Lt as globToRelative,
1058
+ Nt as initPage,
1059
+ He as isObservable,
1060
+ ee as loadGlobs,
1061
+ Dt as loadGlobsFromFile,
1062
+ $t as loadJson,
1063
+ Ge as match,
1064
+ ve as matchAnd,
1065
+ Ke as matchAndPipe,
1066
+ Ve as matchAny,
1067
+ Ye as matchArray,
1068
+ qe as matchArrayBuffer,
1069
+ Qe as matchArrayIncludes,
1070
+ Xe as matchArrayItem,
1071
+ Ze as matchArrayLength,
1072
+ tn as matchArrayWith,
1073
+ en as matchBoolean,
1074
+ nn as matchConstructor,
1075
+ rn as matchConvert,
1076
+ sn as matchCustom,
1077
+ an as matchDeep,
1078
+ on as matchEnum,
1079
+ cn as matchFloat,
1080
+ ln as matchIn,
1081
+ un as matchInstanceOf,
1082
+ fn as matchInt,
1083
+ dn as matchIntDate,
1084
+ hn as matchIs,
1085
+ mn as matchIsNonStrict,
1086
+ pn as matchNever,
1087
+ yn as matchNot,
1088
+ wn as matchNotNullish,
1089
+ gn as matchNullish,
1090
+ xn as matchNumber,
1091
+ En as matchObject,
1092
+ Sn as matchObjectEntries,
1093
+ bn as matchObjectEntry,
1094
+ kn as matchObjectKey,
1095
+ On as matchObjectKeyValue,
1096
+ Pn as matchObjectKeys,
1097
+ jn as matchObjectKeysNotNull,
1098
+ Cn as matchObjectPartial,
1099
+ An as matchObjectValue,
1100
+ Ln as matchObjectValues,
1101
+ Dn as matchObjectWith,
1102
+ Fn as matchOptional,
1103
+ Tn as matchOr,
1104
+ In as matchOrPipe,
1105
+ _n as matchRange,
1106
+ Rn as matchRangeDate,
1107
+ Wn as matchRef,
1108
+ Nn as matchString,
1109
+ $n as matchStringLength,
1110
+ Mn as matchTypeOf,
1111
+ Bn as matchUuid,
1112
+ zn as matchValueState,
1113
+ Jn as max,
1114
+ Un as min,
1115
+ Hn as minMax,
1116
+ ne as nodeBeep,
1117
+ Gn as numberMod,
1118
+ V as objectTransform,
1119
+ $ as pathNormalize,
1120
+ jt as pathResolve,
1121
+ Z as poolFs,
1122
+ vn as randomBoolean,
1123
+ Kn as randomEnum,
1124
+ Vn as randomFloat,
1125
+ Yn as randomIndexWeighted,
1126
+ qn as randomInt,
1127
+ Qn as randomItem,
1128
+ Xn as randomItems,
1129
+ Y as saveJson,
1130
+ Zn as setFuncName,
1131
+ Rt as setPlaywrightPriorityLow,
1132
+ tr as sha256,
1133
+ er as sha256Buffer,
1134
+ _t as subscribeJsErrors,
1135
+ ae as testPage,
1136
+ nr as timeoutAbortController,
1137
+ rr as toHex,
1138
+ sr as truncateString,
1139
+ ar as urlGetBoolean,
1140
+ or as urlGetFloat,
1141
+ ir as urlGetInt,
1142
+ cr as urlGetParams,
1143
+ lr as urlGetString,
1144
+ ur as urlParamToBoolean,
1145
+ fr as urlParamToFloat,
1146
+ dr as urlParamToInt,
1147
+ oe as useBrowser,
1148
+ ie as useBrowserContext,
1149
+ ce as usingCDPSession,
1150
+ hr as waitObservable,
1151
+ Ct as walkPathHandleErrorDefault,
1152
+ Zt as walkPaths,
1153
+ mr as withConsoleReplace,
1154
+ pr as withRetry,
1155
+ mt as withTimeout
1024
1156
  };