pinia-plugin-subscription 1.0.0-beta.12 → 1.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers.js CHANGED
@@ -1,22 +1,22 @@
1
1
  var O = Object.defineProperty;
2
2
  var C = (s, e, t) => e in s ? O(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var p = (s, e, t) => C(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { T as w, g as T, s as j, i as I, h as z, p as S, a as L } from "./chunks/PluginSubscription-BbN48iuP.js";
5
- import { P as fe, t as he } from "./chunks/PluginSubscription-BbN48iuP.js";
6
- import { isRef as b, ref as k, toRef as P } from "vue";
7
- class ce {
3
+ var u = (s, e, t) => C(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { T as w, g as T, s as j, i as I, h as z, p as E, a as L } from "./chunks/PluginSubscription-Bkqj4uSK.js";
5
+ import { P as de, t as be } from "./chunks/PluginSubscription-Bkqj4uSK.js";
6
+ import { isRef as b, ref as P, toRef as k } from "vue";
7
+ class pe {
8
8
  constructor(e, t) {
9
- p(this, "_createInstance");
10
- p(this, "_name");
11
- p(this, "_pluginOptions");
12
- p(this, "_storeInstance");
13
- p(this, "_resetStoreCallback");
14
- p(this, "_storeOnActionSubscription");
15
- p(this, "_storeMutationSubscription");
16
- p(this, "_subscriptions");
17
- p(this, "pluginCreated");
18
- p(this, "execution");
19
- p(this, "hydrationScheduler");
9
+ u(this, "_createInstance");
10
+ u(this, "_name");
11
+ u(this, "_pluginOptions");
12
+ u(this, "_storeInstance");
13
+ u(this, "_resetStoreCallback");
14
+ u(this, "_storeOnActionSubscription");
15
+ u(this, "_storeMutationSubscription");
16
+ u(this, "_subscriptions");
17
+ u(this, "pluginCreated");
18
+ u(this, "execution");
19
+ u(this, "hydrationScheduler");
20
20
  this._name = e, this._createInstance = t;
21
21
  }
22
22
  get name() {
@@ -61,13 +61,13 @@ class ce {
61
61
  class M extends w {
62
62
  constructor(t, r) {
63
63
  super();
64
- p(this, "_className", "Store");
65
- p(this, "_createTracer");
66
- p(this, "_onAction");
67
- p(this, "_options");
68
- p(this, "_store");
69
- p(this, "_storeSubscribe");
70
- p(this, "_subscriptions", {});
64
+ u(this, "_className", "Store");
65
+ u(this, "_createTracer");
66
+ u(this, "_onAction");
67
+ u(this, "_options");
68
+ u(this, "_store");
69
+ u(this, "_storeSubscribe");
70
+ u(this, "_subscriptions", {});
71
71
  if (this._options = r.storeOptions, this._store = t, this.initializeTracer(r), this.trace("instance:created", t.$id), this._options?.enhancedStore) {
72
72
  const o = T(this.store);
73
73
  o && (j(o, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
@@ -109,7 +109,7 @@ class M extends w {
109
109
  return !this._tracer && this._createTracer && (this._tracer = this._createTracer(), this._tracer.scope = this.store.$id), this._tracer;
110
110
  }
111
111
  addToState(t, r) {
112
- this.isOptionApi() || b(r) || (r = k(r)), this.state[t] = r, this.store[t] = P(this.state, t);
112
+ this.isOptionApi() || b(r) || (r = P(r)), this.state[t] = r, this.store[t] = k(this.state, t);
113
113
  }
114
114
  addSubscription(t, r, o) {
115
115
  this._subscriptions[t] = { subscription: r, ...o ?? {} };
@@ -154,15 +154,15 @@ class M extends w {
154
154
  return Object.prototype.hasOwnProperty.call(this.store, t);
155
155
  }
156
156
  }
157
- p(M, "_requiredKeys");
158
- function ae(s, e, t) {
157
+ u(M, "_requiredKeys");
158
+ function le(s, e, t) {
159
159
  return {
160
160
  name: s,
161
161
  invoke: e,
162
162
  ...t
163
163
  };
164
164
  }
165
- function R(s) {
165
+ function G(s) {
166
166
  if (typeof s != "function")
167
167
  return s;
168
168
  try {
@@ -171,12 +171,12 @@ function R(s) {
171
171
  return { __tracePayloadError: e };
172
172
  }
173
173
  }
174
- class G {
174
+ class R {
175
175
  constructor(e, t, r = {}) {
176
- p(this, "_listeners", []);
177
- p(this, "_redactor");
178
- p(this, "_scope");
179
- p(this, "_source");
176
+ u(this, "_listeners", []);
177
+ u(this, "_redactor");
178
+ u(this, "_scope");
179
+ u(this, "_source");
180
180
  this._redactor = r.redactor, this._scope = r.scope, this._source = e, this._listeners = t;
181
181
  }
182
182
  get scope() {
@@ -191,11 +191,11 @@ class G {
191
191
  debug(e, t, r, o) {
192
192
  this.emit("debug", e, t, r, o);
193
193
  }
194
- error(e, t, r, o, l) {
195
- this.emit("error", e, t, o, l, r);
194
+ error(e, t, r, o, p) {
195
+ this.emit("error", e, t, o, p, r);
196
196
  }
197
197
  resolveAndRedact(e) {
198
- const t = R(e);
198
+ const t = G(e);
199
199
  if (!this._redactor || t === void 0)
200
200
  return t;
201
201
  try {
@@ -205,151 +205,204 @@ class G {
205
205
  }
206
206
  }
207
207
  matchListeners(e, t, r, o) {
208
- const l = {
208
+ const p = {
209
209
  label: t,
210
210
  level: e,
211
211
  namespace: r,
212
212
  scope: o ?? this._scope,
213
213
  source: this._source
214
- }, n = [];
215
- for (const a of this._listeners)
214
+ }, i = [];
215
+ for (const c of this._listeners)
216
216
  try {
217
- a.filter(l) && n.push(a);
218
- } catch (i) {
219
- console.error("Error in trace listener filter:", i);
217
+ c.filter(p) && i.push(c);
218
+ } catch (l) {
219
+ console.error("Error in trace listener filter:", l);
220
220
  }
221
- return { matched: n, metadata: l };
221
+ return { matched: i, metadata: p };
222
222
  }
223
- emit(e, t, r, o, l, n) {
224
- const { matched: a, metadata: i } = this._listeners.length === 0 ? { matched: [], metadata: void 0 } : this.matchListeners(e, t, r, l);
225
- if (!i || a.length === 0) {
226
- e === "error" && console.error("Unhandled error trace event:", n);
223
+ emit(e, t, r, o, p, i) {
224
+ const { matched: c, metadata: l } = this._listeners.length === 0 ? { matched: [], metadata: void 0 } : this.matchListeners(e, t, r, p);
225
+ if (!l || c.length === 0) {
226
+ e === "error" && console.error("Unhandled error trace event:", i);
227
227
  return;
228
228
  }
229
- const f = {
230
- ...i,
231
- ...n !== void 0 && { error: n },
229
+ const h = {
230
+ ...l,
231
+ ...i !== void 0 && { error: i },
232
232
  ...o !== void 0 && { payload: this.resolveAndRedact(o) },
233
233
  timestamp: Date.now()
234
234
  };
235
- for (const c of a)
235
+ for (const a of c)
236
236
  try {
237
- c.handler(f);
238
- } catch (u) {
239
- console.error("Error in trace listener:", u);
237
+ a.handler(h);
238
+ } catch (n) {
239
+ console.error("Error in trace listener:", n);
240
240
  }
241
241
  }
242
242
  }
243
- const y = "#f86f63", D = (s, e = "white") => `background-color: ${s}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;
244
- function N(s) {
245
- const { payload: e } = s;
246
- if (e && Object.keys(e).length > 0)
247
- return Object.keys(e).reduce((t, r) => (["groupId", "label", "namespace", "scope", "source"].includes(r) || (t[r] = b(e[r]) ? e[r].value : e[r]), t), {});
243
+ function D(s, e) {
244
+ if (!s)
245
+ throw new Error("Style instructions are required");
246
+ console.log(
247
+ "%c%s",
248
+ s,
249
+ e.shift(),
250
+ ...e
251
+ );
248
252
  }
249
- function g(s, e, t = "collapsed", r) {
250
- if (e instanceof Error) {
251
- console.groupCollapsed(
253
+ const N = (s, e = "white") => `background-color: ${s}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;
254
+ class W {
255
+ constructor() {
256
+ u(this, "_bgColor", "transparent");
257
+ u(this, "_color", "#f2f286");
258
+ u(this, "_icon", "🍍⚡");
259
+ u(this, "_errorBgColor", "#d24545");
260
+ u(this, "_errorColor", "white");
261
+ u(this, "_errorIcon", "🍍⚠️");
262
+ u(this, "_pluginName");
263
+ u(this, "_styles", {
264
+ error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },
265
+ info: { bgColor: this._bgColor, color: this._color, icon: this._icon }
266
+ });
267
+ }
268
+ formatMessage(e, t) {
269
+ return this._pluginName ? ` [${t} ${this._pluginName}]
270
+ ${e}
271
+ ` : e;
272
+ }
273
+ generateStyle(e) {
274
+ return N(e.bgColor, e.color);
275
+ }
276
+ getStyleDefinition(e) {
277
+ return this._styles[e ?? "info"];
278
+ }
279
+ log(...e) {
280
+ this.useLog(
281
+ this.getStyleDefinition(),
282
+ e
283
+ );
284
+ }
285
+ error(...e) {
286
+ this.useLog(
287
+ this.getStyleDefinition("error"),
288
+ e
289
+ );
290
+ }
291
+ rebuildArgs(e) {
292
+ return typeof e == "string" ? [e] : Array.isArray(e) ? [e.shift(), ...e] : [e];
293
+ }
294
+ useLog(e, t) {
295
+ D(
296
+ this.generateStyle(e),
297
+ this.rebuildArgs(t)
298
+ );
299
+ }
300
+ }
301
+ function q(s = "none", ...e) {
302
+ s === "collapsed" ? console.groupCollapsed(
303
+ "%c%s",
304
+ "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
305
+ ...e
306
+ ) : s === "expanded" && console.group(
307
+ "%c%s",
308
+ "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
309
+ ...e
310
+ );
311
+ }
312
+ function K(s, e, t = "") {
313
+ if (typeof s[0] != "object") {
314
+ const r = typeof s[0] == "string" ? s.join(", ") : s;
315
+ e ? console.log(
252
316
  "%c%s",
253
- `color: ${y}; padding: 1px; margin-right: 5px; font-size: 11px`,
254
- `[ ${e.name} ] ${e.message}`
255
- ), e.cause && console.log("cause:", e.cause);
256
- const i = e.stack?.split(`
317
+ "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
318
+ `[ ${t}${e} ]`,
319
+ r
320
+ ) : console.log(r);
321
+ }
322
+ typeof s[0] == "object" && (s[0]?.name ? console.log(s.reduce((r, o) => (r && (r += `\r
323
+ `), r += `- ${o.name}`, r), "")) : s[0]?._id ? console.log(s.reduce((r, o) => (r && (r += `\r
324
+ `), r += `- ${o._id}`, r), "")) : s.forEach((r) => {
325
+ console.dir(r);
326
+ }));
327
+ }
328
+ const S = "#f86f63";
329
+ function V(s) {
330
+ console.groupCollapsed(
331
+ "%c%s",
332
+ `color: ${S}; padding: 1px; margin-right: 5px; font-size: 11px`,
333
+ `[ ${s.name} ] ${s.message}`
334
+ ), s.cause && console.log("cause:", s.cause);
335
+ const e = s.stack?.split(`
257
336
  `);
258
- i && i.forEach((f) => {
259
- const c = f.split("@");
260
- Array.isArray(c) && console.log(c[0], c[1]);
261
- }), console.groupEnd();
262
- }
337
+ e && e.forEach((t) => {
338
+ const r = t.split("@");
339
+ Array.isArray(r) && console.log(r[0], r[1]);
340
+ }), console.groupEnd();
341
+ }
342
+ function d(s, e, t = "collapsed", r) {
343
+ e instanceof Error && V(e);
263
344
  const o = Array.isArray(e);
264
345
  if (o ? e.length === 0 : Object.keys(e).length === 0) {
265
346
  console.log(
266
347
  "%c%s",
267
- `color: ${y}; padding: 1px; margin-right: 5px; font-size: 10px`,
348
+ `color: ${S}; padding: 1px; margin-right: 5px; font-size: 10px`,
268
349
  `[ ${s} ] Empty`
269
350
  );
270
351
  return;
271
352
  }
272
- const a = {
273
- options: "📚 ",
274
- store: "🏪 ",
353
+ const c = {
354
+ environment: "🍃 ",
355
+ options: "🧮 ",
356
+ store: "🏬 ",
275
357
  subscribers: "🧩 ",
276
358
  "hooks subscriptions": "🔗 "
277
359
  }[s] ?? "";
278
- if (t === "none" || o && typeof e[0] != "object") {
279
- console.log(
280
- "%c%s",
281
- "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
282
- `[ ${a}${s} ]`,
283
- o && typeof e[0] == "string" ? e.join(", ") : e
284
- );
285
- return;
286
- }
287
- if (t === "collapsed" ? r ? console.groupCollapsed(
288
- "%c%s",
289
- "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
290
- `${a}${s}`,
291
- r
292
- ) : console.groupCollapsed(
293
- "%c%s",
294
- "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
295
- `[ ${a}${s} ]`
296
- ) : t === "expanded" && console.group(
297
- "%c%s",
298
- "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
299
- `[ ${a} ${s} ]`
300
- ), o && typeof e[0] == "object")
301
- e[0]?.name ? console.log(e.reduce((i, f) => (i && (i += `\r
302
- `), i += `- ${f.name}`, i), "")) : e[0]?._id ? console.log(e.reduce((i, f) => (i && (i += `\r
303
- `), i += `- ${f._id}`, i), "")) : e.forEach((i) => {
304
- i.name ? g(i.name, i) : i._id ? g(i._id, i) : console.dir(i);
305
- });
360
+ let l = r ? [`${c}${s}`, r] : [`[ ${c}${s} ]`];
361
+ if (q(t, ...l), o)
362
+ K(e, t === "none" ? s : void 0, c);
306
363
  else {
307
- let i = [];
308
- Object.keys(e).forEach((f) => {
309
- if (f === "groupId")
364
+ let h = [];
365
+ Object.keys(e).forEach((a) => {
366
+ if (a === "groupId")
310
367
  return;
311
- const c = e[f];
312
- if (typeof c == "object")
313
- Array.isArray(c) ? typeof c[0] == "object" ? g(f, c, "expanded") : typeof c[0] == "string" ? g(f, c.map((u) => `\r
314
- - ${u}`), "expanded") : console.log(
368
+ const n = e[a];
369
+ if (typeof n == "object")
370
+ Array.isArray(n) ? typeof n[0] == "object" ? d(a, n, "expanded") : typeof n[0] == "string" ? d(
371
+ a,
372
+ n.map((f, g) => `${g > 0 ? `\r
373
+ ` : " "}- ${f}`),
374
+ "expanded"
375
+ ) : console.log(
315
376
  "%c%s",
316
377
  "color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
317
- `[ ${f} ]`,
318
- b(c) ? c.value : c
319
- ) : c instanceof Error ? console.log(f, { name: c.name, message: c.message, stack: c.stack }) : g(f, Object.assign({}, c), "expanded");
320
- else if (!c)
321
- i.push(f);
378
+ `[ ${a} ]`,
379
+ b(n) ? n.value : n
380
+ ) : n instanceof Error ? console.log(a, { name: n.name, message: n.message, stack: n.stack }) : (b(n) && console.log(
381
+ "%c%s",
382
+ "color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
383
+ `[ ${a} ]`,
384
+ b(n) ? n.value : n
385
+ ), d(a, Object.assign({}, n), "expanded"));
386
+ else if (!n)
387
+ h.push(a);
322
388
  else {
323
- const u = typeof c;
389
+ const f = typeof n;
324
390
  console.log(
325
391
  "%c%s",
326
392
  "color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px",
327
- `[ ${f} ]`,
328
- u === "function" ? u : c
393
+ `[ ${a} ]`,
394
+ f === "function" ? f : n
329
395
  );
330
396
  }
331
- }), i.length && console.log(
397
+ }), h.length && console.log(
332
398
  "%c%s",
333
399
  "color: #f86f63; font-size: 9px",
334
400
  "[ Empty properties ]",
335
- i
401
+ h
336
402
  );
337
403
  }
338
404
  console.groupEnd();
339
405
  }
340
- function W(s) {
341
- const e = N(s);
342
- if (e && Object.keys(e).length > 0) {
343
- g(s.label, e, "collapsed", s.source);
344
- return;
345
- }
346
- console.log(
347
- "%c%s",
348
- "color: #f8f89f; padding: 1px; margin-right: 5px; font-size: 11px",
349
- s.label,
350
- s.source
351
- );
352
- }
353
406
  function _(s) {
354
407
  Object.keys(s).forEach((e) => {
355
408
  if (["groupId", "label", "namespace", "scope", "source"].includes(e))
@@ -379,23 +432,25 @@ function _(s) {
379
432
  console.groupCollapsed("[mutation]"), console.dir(t), console.groupEnd();
380
433
  break;
381
434
  case "options":
382
- g(e, t?.storeOptions ?? t);
435
+ d(e, t?.storeOptions ?? t);
383
436
  break;
384
437
  case "payload":
385
438
  _(t);
386
439
  break;
387
440
  case "store":
388
- g(e, {
441
+ d(e, {
389
442
  $state: t.$state,
390
443
  $actions: Object.keys(t).reduce((r, o) => (o.startsWith("$") && !["$id", "$state"].includes(o) || o.startsWith("_") || (typeof t[o] != "function" ? (r.computed || (r.computed = []), r.computed.push(o)) : r[o] = t[o]), r), {})
391
444
  });
392
445
  break;
393
446
  case "subscribers":
394
- g(e, t.map((r) => `\r
395
- - ${r.name}`));
447
+ d(e, t.map(
448
+ (r, o) => `${o > 0 ? `\r
449
+ ` : " "}- ${r.name}`
450
+ ));
396
451
  break;
397
452
  default:
398
- g(e, t);
453
+ d(e, t);
399
454
  }
400
455
  break;
401
456
  case "function":
@@ -406,17 +461,7 @@ function _(s) {
406
461
  }
407
462
  });
408
463
  }
409
- function q(s, e) {
410
- if (!s)
411
- throw new Error("Style instructions are required");
412
- console.log(
413
- "%c%s",
414
- s,
415
- e.shift(),
416
- ...e
417
- );
418
- }
419
- function K(s, e, t) {
464
+ function F(s, e, t) {
420
465
  if (!s)
421
466
  throw new Error("Style instructions are required");
422
467
  const r = e.shift(), o = e[0];
@@ -435,73 +480,44 @@ function K(s, e, t) {
435
480
  `${r}
436
481
  `,
437
482
  o?.source
438
- ), e.forEach((l) => {
439
- switch (typeof l) {
483
+ ), e.forEach((p) => {
484
+ switch (typeof p) {
440
485
  case "string":
441
- console.info(l);
486
+ console.info(p);
442
487
  break;
443
488
  case "object":
444
- Array.isArray(l) ? console.table(l) : _(l);
489
+ Array.isArray(p) ? console.table(p) : _(p);
445
490
  break;
446
491
  case "function":
447
- console.dir(l);
492
+ console.dir(p);
448
493
  break;
449
494
  default:
450
- console.info(l);
495
+ console.info(p);
451
496
  }
452
497
  }), console.groupEnd();
453
498
  }
454
- class V {
455
- constructor() {
456
- p(this, "_bgColor", "transparent");
457
- p(this, "_color", "#f2f286");
458
- p(this, "_icon", "🍍⚡");
459
- p(this, "_errorBgColor", "#d24545");
460
- p(this, "_errorColor", "white");
461
- p(this, "_errorIcon", "🍍⚠️");
462
- p(this, "_pluginName");
463
- p(this, "_styles", {
464
- error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },
465
- info: { bgColor: this._bgColor, color: this._color, icon: this._icon }
466
- });
467
- }
468
- formatMessage(e, t) {
469
- return this._pluginName ? ` [${t} ${this._pluginName}]
470
- ${e}
471
- ` : e;
472
- }
473
- generateStyle(e) {
474
- return D(e.bgColor, e.color);
475
- }
476
- getStyleDefinition(e) {
477
- return this._styles[e ?? "info"];
478
- }
479
- log(...e) {
480
- this.useLog(
481
- this.getStyleDefinition(),
482
- e
483
- );
484
- }
485
- error(...e) {
486
- this.useLog(
487
- this.getStyleDefinition("error"),
488
- e
489
- );
490
- }
491
- rebuildArgs(e) {
492
- return typeof e == "string" ? [e] : Array.isArray(e) ? [e.shift(), ...e] : [e];
493
- }
494
- useLog(e, t) {
495
- q(
496
- this.generateStyle(e),
497
- this.rebuildArgs(t)
498
- );
499
+ function H(s) {
500
+ const { payload: e } = s;
501
+ if (e && Object.keys(e).length > 0)
502
+ return Object.keys(e).reduce((t, r) => (["groupId", "label", "namespace", "scope", "source"].includes(r) || (t[r] = b(e[r]) ? e[r].value : e[r]), t), {});
503
+ }
504
+ function v(s) {
505
+ const e = H(s);
506
+ if (e && Object.keys(e).length > 0) {
507
+ d(s.label, e, "collapsed", s.source);
508
+ return;
499
509
  }
510
+ console.log(
511
+ "%c%s",
512
+ "color: #f8f89f; padding: 1px; margin-right: 5px; font-size: 11px",
513
+ s.label,
514
+ s.source
515
+ );
500
516
  }
501
- class F extends V {
517
+ class B extends W {
502
518
  constructor(t) {
503
519
  super();
504
- p(this, "_pluginName", S);
520
+ u(this, "_pluginName", E);
505
521
  t && (this._pluginName = t);
506
522
  }
507
523
  logGroup(t) {
@@ -515,10 +531,10 @@ class F extends V {
515
531
  "%c%s",
516
532
  "color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px",
517
533
  "[ ✨ traces ]"
518
- ), t.forEach((l) => W(l[1])), console.groupEnd(), console.groupEnd();
534
+ ), t.forEach((p) => v(p[1])), console.groupEnd(), console.groupEnd();
519
535
  }
520
536
  useLog(t, r) {
521
- K(
537
+ F(
522
538
  this.generateStyle(t),
523
539
  this.rebuildArgs(r),
524
540
  this._pluginName
@@ -532,92 +548,92 @@ function $(s) {
532
548
  function A(s) {
533
549
  return s.scope ? `${s.label} [${s.scope}]` : `${s.label}`;
534
550
  }
535
- function H(s, e) {
551
+ function U(s, e) {
536
552
  const t = e.level === "error" ? "error" : "log";
537
553
  s[t](...$(e));
538
554
  }
539
- function B(s = "scope") {
540
- const e = new F(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
541
- function o(n) {
542
- t.has(n) || t.set(n, []), r.set(n, (r.get(n) ?? 0) + 1);
543
- }
544
- function l(n) {
545
- const a = t.get(n);
546
- if (!a) {
547
- e.error(`No group found for key "${n}"`);
555
+ function X(s = "scope") {
556
+ const e = new B(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
557
+ function o(i) {
558
+ t.has(i) || t.set(i, []), r.set(i, (r.get(i) ?? 0) + 1);
559
+ }
560
+ function p(i) {
561
+ const c = t.get(i);
562
+ if (!c) {
563
+ e.error(`No group found for key "${i}"`);
548
564
  return;
549
565
  }
550
- const i = (r.get(n) ?? 1) - 1;
551
- if (i > 0) {
552
- r.set(n, i);
566
+ const l = (r.get(i) ?? 1) - 1;
567
+ if (l > 0) {
568
+ r.set(i, l);
553
569
  return;
554
570
  }
555
- a.length && e.logGroup(a), t.delete(n), r.delete(n);
571
+ c.length && e.logGroup(c), t.delete(i), r.delete(i);
556
572
  }
557
573
  return {
558
574
  createGroup: o,
559
- logGroup: l,
560
- handler(n) {
561
- const a = n?.payload?.groupId ?? n[s];
562
- if (!t.has(a)) {
563
- H(e, n);
575
+ logGroup: p,
576
+ handler(i) {
577
+ const c = i?.payload?.groupId ?? i[s];
578
+ if (!t.has(c)) {
579
+ U(e, i);
564
580
  return;
565
581
  }
566
- t.get(a)?.[0]?.[0] !== A(n) && t.get(a)?.push($(n));
582
+ t.get(c)?.[0]?.[0] !== A(i) && t.get(c)?.push($(i));
567
583
  }
568
584
  };
569
585
  }
570
- function E(s, e = !0, t) {
571
- return (r) => s[t](({ comparator: o = "equals", target: l, value: n }) => {
572
- if (l === "namespace" && e && v(r))
586
+ function y(s, e = !0, t) {
587
+ return (r) => s[t](({ comparator: o = "equals", target: p, value: i }) => {
588
+ if (p === "namespace" && e && Y(r))
573
589
  return !0;
574
- const a = r[l];
575
- if (typeof a != "string") return !1;
576
- let i = !1;
590
+ const c = r[p];
591
+ if (typeof c != "string") return !1;
592
+ let l = !1;
577
593
  switch (o) {
578
594
  case "equals":
579
- i = a === n;
595
+ l = c === i;
580
596
  break;
581
597
  case "contains":
582
- i = a.includes(n);
598
+ l = c.includes(i);
583
599
  break;
584
600
  case "startsWith":
585
- i = a.startsWith(n);
601
+ l = c.startsWith(i);
586
602
  break;
587
603
  case "endsWith":
588
- i = a.endsWith(n);
604
+ l = c.endsWith(i);
589
605
  break;
590
606
  default:
591
- i = !1;
607
+ l = !1;
592
608
  break;
593
609
  }
594
- return i;
610
+ return l;
595
611
  });
596
612
  }
597
- function U(s, e = !0, t = "every", r = "scope") {
613
+ function J(s, e = !0, t = "every", r = "scope") {
598
614
  return {
599
615
  groupBy: r,
600
- ...B(r),
601
- ...X(s, e, t)
616
+ ...X(r),
617
+ ...Q(s, e, t)
602
618
  };
603
619
  }
604
- function X(s, e = !0, t = "every") {
605
- return Array.isArray(s) ? { filter: E(s, e, t) } : {
620
+ function Q(s, e = !0, t = "every") {
621
+ return Array.isArray(s) ? { filter: y(s, e, t) } : {
606
622
  ...s,
607
- filter: Array.isArray(s.filter) ? E(s.filter, e, t) : s.filter
623
+ filter: Array.isArray(s.filter) ? y(s.filter, e, t) : s.filter
608
624
  };
609
625
  }
610
- function v(s) {
611
- return s?.source === S && (!s?.namespace || s.namespace.startsWith(L));
626
+ function Y(s) {
627
+ return s?.source === E && (!s?.namespace || s.namespace.startsWith(L));
612
628
  }
613
- function J() {
629
+ function Z() {
614
630
  try {
615
631
  return process.env.NODE_ENV === "production";
616
632
  } catch {
617
633
  return !1;
618
634
  }
619
635
  }
620
- const Q = "[REDACTED]", Y = [
636
+ const ee = "[REDACTED]", te = [
621
637
  /pass(word|wd|phrase|code)|^pwd/i,
622
638
  /secret/i,
623
639
  /token/i,
@@ -627,127 +643,127 @@ const Q = "[REDACTED]", Y = [
627
643
  /credential/i,
628
644
  /cookie/i,
629
645
  /cipher/i
630
- ], Z = 12;
631
- function ee(s) {
646
+ ], re = 12;
647
+ function se(s) {
632
648
  const e = /* @__PURE__ */ new Set(), t = [];
633
649
  for (const r of s)
634
650
  typeof r == "string" ? e.add(r.toLowerCase()) : t.push(new RegExp(r.source, r.flags.replace(/[gy]/g, "")));
635
651
  return (r) => e.has(r.toLowerCase()) || t.some((o) => o.test(r));
636
652
  }
637
- function te(s) {
653
+ function oe(s) {
638
654
  return s === null || typeof s != "object" ? !1 : !(s instanceof Date || s instanceof RegExp || s instanceof Error || s instanceof Promise || s instanceof WeakMap || s instanceof WeakSet);
639
655
  }
640
- function re(s = !0) {
641
- const { includeDefaults: e = !0, keys: t = [], replacement: r = Q } = s === !0 ? {} : s, o = ee([...e ? Y : [], ...t]);
642
- function l(n, a, i) {
643
- if (!te(n))
644
- return n;
645
- const f = a.get(n);
646
- if (f !== void 0)
647
- return f;
648
- if (i >= Z)
656
+ function ne(s = !0) {
657
+ const { includeDefaults: e = !0, keys: t = [], replacement: r = ee } = s === !0 ? {} : s, o = se([...e ? te : [], ...t]);
658
+ function p(i, c, l) {
659
+ if (!oe(i))
660
+ return i;
661
+ const h = c.get(i);
662
+ if (h !== void 0)
663
+ return h;
664
+ if (l >= re)
649
665
  return "[MaxDepth]";
650
- if (n instanceof Map) {
651
- const u = /* @__PURE__ */ new Map();
652
- return a.set(n, u), n.forEach((h, d) => {
653
- u.set(d, typeof d == "string" && o(d) ? r : l(h, a, i + 1));
654
- }), u;
666
+ if (i instanceof Map) {
667
+ const n = /* @__PURE__ */ new Map();
668
+ return c.set(i, n), i.forEach((f, g) => {
669
+ n.set(g, typeof g == "string" && o(g) ? r : p(f, c, l + 1));
670
+ }), n;
655
671
  }
656
- if (n instanceof Set) {
657
- const u = /* @__PURE__ */ new Set();
658
- return a.set(n, u), n.forEach((h) => u.add(l(h, a, i + 1))), u;
672
+ if (i instanceof Set) {
673
+ const n = /* @__PURE__ */ new Set();
674
+ return c.set(i, n), i.forEach((f) => n.add(p(f, c, l + 1))), n;
659
675
  }
660
- if (Array.isArray(n)) {
661
- const u = [];
662
- return a.set(n, u), n.forEach((h) => u.push(l(h, a, i + 1))), u;
676
+ if (Array.isArray(i)) {
677
+ const n = [];
678
+ return c.set(i, n), i.forEach((f) => n.push(p(f, c, l + 1))), n;
663
679
  }
664
- const c = {};
665
- a.set(n, c);
666
- for (const u of Object.keys(n)) {
667
- const h = o(u) ? r : l(n[u], a, i + 1);
668
- Object.defineProperty(c, u, {
680
+ const a = {};
681
+ c.set(i, a);
682
+ for (const n of Object.keys(i)) {
683
+ const f = o(n) ? r : p(i[n], c, l + 1);
684
+ Object.defineProperty(a, n, {
669
685
  configurable: !0,
670
686
  enumerable: !0,
671
- value: h,
687
+ value: f,
672
688
  writable: !0
673
689
  });
674
690
  }
675
- return c;
691
+ return a;
676
692
  }
677
- return (n) => l(n, /* @__PURE__ */ new WeakMap(), 0);
693
+ return (i) => p(i, /* @__PURE__ */ new WeakMap(), 0);
678
694
  }
679
- const se = () => {
695
+ const ie = () => {
680
696
  };
681
- function ue({ enabled: s = !J(), redact: e = !1 } = {}) {
682
- const t = e ? re(e === !0 ? !0 : e) : void 0, r = [];
683
- function o(c, { context: u = !0, filterMode: h = "every", groupBy: d = "scope" } = {}) {
697
+ function fe({ enabled: s = !Z(), redact: e = !1 } = {}) {
698
+ const t = e ? ne(e === !0 ? !0 : e) : void 0, r = [];
699
+ function o(a, { context: n = !0, filterMode: f = "every", groupBy: g = "scope" } = {}) {
684
700
  if (!s)
685
- return se;
686
- const m = U(
687
- c,
688
- !!u,
689
- h ?? "every",
690
- d ?? "scope"
701
+ return ie;
702
+ const m = J(
703
+ a,
704
+ !!n,
705
+ f ?? "every",
706
+ g ?? "scope"
691
707
  );
692
708
  return r.push(m), () => {
693
709
  const x = r.indexOf(m);
694
710
  x !== -1 && r.splice(x, 1);
695
711
  };
696
712
  }
697
- function l(c, u = !0) {
713
+ function p(a, n = !0) {
698
714
  return o(
699
- c.map((h) => ({ target: "scope", value: h })),
700
- { context: u, filterMode: "some", groupBy: "scope" }
715
+ a.map((f) => ({ target: "scope", value: f })),
716
+ { context: n, filterMode: "some", groupBy: "scope" }
701
717
  );
702
718
  }
703
- function n() {
719
+ function i() {
704
720
  r.length = 0;
705
721
  }
706
- function a(c) {
707
- const u = {
708
- groupId: c.groupId,
709
- label: c.label,
710
- level: c.level,
711
- namespace: c.namespace,
712
- scope: c.scope,
713
- source: c.source
722
+ function c(a) {
723
+ const n = {
724
+ groupId: a.groupId,
725
+ label: a.label,
726
+ level: a.level,
727
+ namespace: a.namespace,
728
+ scope: a.scope,
729
+ source: a.source
714
730
  };
715
- return r.filter((h) => h.filter(u));
731
+ return r.filter((f) => f.filter(n));
716
732
  }
717
- function i() {
733
+ function l() {
718
734
  return r.length > 0;
719
735
  }
720
- function f(c, u) {
721
- r.length && a(u).forEach((h) => {
722
- const d = u.groupId ?? u[h.groupBy];
723
- typeof d == "string" && h[c](d);
736
+ function h(a, n) {
737
+ r.length && c(n).forEach((f) => {
738
+ const g = n.groupId ?? n[f.groupBy];
739
+ typeof g == "string" && f[a](g);
724
740
  });
725
741
  }
726
742
  return {
727
743
  addListener: o,
728
- addScopesListener: l,
729
- clearTraceListeners: n,
744
+ addScopesListener: p,
745
+ clearTraceListeners: i,
730
746
  tracerHandler: {
731
- closeGroup: (c) => f("logGroup", c),
732
- createTracer: (c, u = {}) => new G(c, r, { redactor: t, ...u }),
733
- hasTraceListeners: i,
734
- startGroup: (c) => f("createGroup", c)
747
+ closeGroup: (a) => h("logGroup", a),
748
+ createTracer: (a, n = {}) => new R(a, r, { redactor: t, ...n }),
749
+ hasTraceListeners: l,
750
+ startGroup: (a) => h("createGroup", a)
735
751
  },
736
- hasTraceListeners: i
752
+ hasTraceListeners: l
737
753
  };
738
754
  }
739
755
  export {
740
- ce as PluginSubscriber,
741
- fe as PluginSubscription,
756
+ pe as PluginSubscriber,
757
+ de as PluginSubscription,
742
758
  M as Store,
743
- G as Tracer,
744
- B as createConsoleGroupTraceListener,
745
- ae as createPluginSubscriber,
746
- ue as createTracerRegistry,
747
- Y as defaultRedactedKeys,
759
+ R as Tracer,
760
+ X as createConsoleGroupTraceListener,
761
+ le as createPluginSubscriber,
762
+ fe as createTracerRegistry,
763
+ te as defaultRedactedKeys,
748
764
  T as getDefineAStoreSetupContext,
749
765
  I as isEmpty,
750
766
  j as setEnhancedStore,
751
- he as traceGroups
767
+ be as traceGroups
752
768
  };
753
769
  //# sourceMappingURL=helpers.js.map