pinia-plugin-subscription 1.0.0-beta.11 → 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,10 +1,10 @@
1
- var $ = Object.defineProperty;
2
- var O = (s, e, t) => e in s ? $(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var u = (s, e, t) => O(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { T as C, g as w, s as T, i as j, h as I, p as S, a as z } 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 L, toRef as k } from "vue";
7
- class ce {
1
+ var O = Object.defineProperty;
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 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
9
  u(this, "_createInstance");
10
10
  u(this, "_name");
@@ -58,7 +58,7 @@ class ce {
58
58
  }), this._storeInstance ? (this._subscriptions = this._storeInstance.getSubscriptions(), this._storeMutationSubscription = this._storeInstance.storeSubscribe, this._storeOnActionSubscription = this._storeInstance.onAction, this.pluginCreated && this.pluginCreated(e), !0) : !1;
59
59
  }
60
60
  }
61
- class P extends C {
61
+ class M extends w {
62
62
  constructor(t, r) {
63
63
  super();
64
64
  u(this, "_className", "Store");
@@ -69,8 +69,8 @@ class P extends C {
69
69
  u(this, "_storeSubscribe");
70
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
- const o = w(this.store);
73
- o && (T(o, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
72
+ const o = T(this.store);
73
+ o && (j(o, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
74
74
  }
75
75
  }
76
76
  get onAction() {
@@ -109,7 +109,7 @@ class P extends C {
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 = L(r)), this.state[t] = r, this.store[t] = k(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 ?? {} };
@@ -127,14 +127,14 @@ class P extends C {
127
127
  return this.getValue(this.state[t]);
128
128
  }
129
129
  getSubscriptions() {
130
- if (!j(this._subscriptions))
130
+ if (!I(this._subscriptions))
131
131
  return this._subscriptions;
132
132
  }
133
133
  getValue(t) {
134
134
  return t?.__v_isRef ? t.value : t;
135
135
  }
136
136
  hasDeniedFirstChar(t) {
137
- return I(t);
137
+ return z(t);
138
138
  }
139
139
  static hasRequiredKeys(t) {
140
140
  return this._requiredKeys !== void 0 && this._requiredKeys?.every((r) => !!t[r]);
@@ -154,15 +154,15 @@ class P extends C {
154
154
  return Object.prototype.hasOwnProperty.call(this.store, t);
155
155
  }
156
156
  }
157
- u(P, "_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 M(s) {
165
+ function G(s) {
166
166
  if (typeof s != "function")
167
167
  return s;
168
168
  try {
@@ -191,11 +191,11 @@ class R {
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 = M(e);
198
+ const t = G(e);
199
199
  if (!this._redactor || t === void 0)
200
200
  return t;
201
201
  try {
@@ -205,148 +205,204 @@ class R {
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 (c) {
219
- console.error("Error in trace listener filter:", c);
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: c } = this._listeners.length === 0 ? { matched: [], metadata: void 0 } : this.matchListeners(e, t, r, l);
225
- if (!c || 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
- ...c,
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 i of a)
235
+ for (const a of c)
236
236
  try {
237
- i.handler(f);
238
- } catch (p) {
239
- console.error("Error in trace listener:", p);
237
+ a.handler(h);
238
+ } catch (n) {
239
+ console.error("Error in trace listener:", n);
240
240
  }
241
241
  }
242
242
  }
243
- const x = "#f86f63", G = (s, e = "white") => `background-color: ${s}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;
244
- function D(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 d(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: ${x}; padding: 1px; margin-right: 5px; font-size: 11px`,
254
- `[ ${e.name} ] ${e.message}`
255
- ), e.cause && console.log("cause:", e.cause);
256
- const c = 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
- c && c.forEach((f) => {
259
- const i = f.split("@");
260
- Array.isArray(i) && console.log(i[0], i[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: ${x}; 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
- if (t === "none" || o && typeof e[0] != "object") {
273
- console.log(
274
- "%c%s",
275
- "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
276
- `[ ${s} ]`,
277
- e
278
- );
279
- return;
280
- }
281
- const a = {
282
- options: "📚 ",
283
- store: "🏪 ",
353
+ const c = {
354
+ environment: "🍃 ",
355
+ options: "🧮 ",
356
+ store: "🏬 ",
284
357
  subscribers: "🧩 ",
285
358
  "hooks subscriptions": "🔗 "
286
359
  }[s] ?? "";
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.forEach((c) => {
302
- c.name ? d(c.name, c) : c._id ? d(c._id, c) : console.dir(c);
303
- });
360
+ let l = r ? [`${c}${s}`, r] : [`[ ${c}${s} ]`];
361
+ if (q(t, ...l), o)
362
+ K(e, t === "none" ? s : void 0, c);
304
363
  else {
305
- let c = [];
306
- Object.keys(e).forEach((f) => {
307
- if (f === "groupId")
364
+ let h = [];
365
+ Object.keys(e).forEach((a) => {
366
+ if (a === "groupId")
308
367
  return;
309
- const i = e[f];
310
- if (typeof i == "object")
311
- Array.isArray(i) ? typeof i[0] == "object" ? d(f, i, "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(
312
376
  "%c%s",
313
377
  "color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
314
- `[ ${f} ]`,
315
- b(i) ? i.value : i
316
- ) : i instanceof Error ? console.log(f, { name: i.name, message: i.message, stack: i.stack }) : d(f, Object.assign({}, i), "expanded");
317
- else if (!i)
318
- c.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);
319
388
  else {
320
- const p = typeof i;
389
+ const f = typeof n;
321
390
  console.log(
322
391
  "%c%s",
323
392
  "color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px",
324
- `[ ${f} ]`,
325
- p === "function" ? p : i
393
+ `[ ${a} ]`,
394
+ f === "function" ? f : n
326
395
  );
327
396
  }
328
- }), c.length && console.log(
397
+ }), h.length && console.log(
329
398
  "%c%s",
330
399
  "color: #f86f63; font-size: 9px",
331
400
  "[ Empty properties ]",
332
- c
401
+ h
333
402
  );
334
403
  }
335
404
  console.groupEnd();
336
405
  }
337
- function N(s) {
338
- const e = D(s);
339
- if (e && Object.keys(e).length > 0) {
340
- d(s.label, e, "collapsed", s.source);
341
- return;
342
- }
343
- console.log(
344
- "%c%s",
345
- "color: #f8f89f; padding: 1px; margin-right: 5px; font-size: 11px",
346
- s.label,
347
- s.source
348
- );
349
- }
350
406
  function _(s) {
351
407
  Object.keys(s).forEach((e) => {
352
408
  if (["groupId", "label", "namespace", "scope", "source"].includes(e))
@@ -387,6 +443,12 @@ function _(s) {
387
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), {})
388
444
  });
389
445
  break;
446
+ case "subscribers":
447
+ d(e, t.map(
448
+ (r, o) => `${o > 0 ? `\r
449
+ ` : " "}- ${r.name}`
450
+ ));
451
+ break;
390
452
  default:
391
453
  d(e, t);
392
454
  }
@@ -399,17 +461,7 @@ function _(s) {
399
461
  }
400
462
  });
401
463
  }
402
- function W(s, e) {
403
- if (!s)
404
- throw new Error("Style instructions are required");
405
- console.log(
406
- "%c%s",
407
- s,
408
- e.shift(),
409
- ...e
410
- );
411
- }
412
- function q(s, e, t) {
464
+ function F(s, e, t) {
413
465
  if (!s)
414
466
  throw new Error("Style instructions are required");
415
467
  const r = e.shift(), o = e[0];
@@ -428,73 +480,44 @@ function q(s, e, t) {
428
480
  `${r}
429
481
  `,
430
482
  o?.source
431
- ), e.forEach((l) => {
432
- switch (typeof l) {
483
+ ), e.forEach((p) => {
484
+ switch (typeof p) {
433
485
  case "string":
434
- console.info(l);
486
+ console.info(p);
435
487
  break;
436
488
  case "object":
437
- Array.isArray(l) ? console.table(l) : _(l);
489
+ Array.isArray(p) ? console.table(p) : _(p);
438
490
  break;
439
491
  case "function":
440
- console.dir(l);
492
+ console.dir(p);
441
493
  break;
442
494
  default:
443
- console.info(l);
495
+ console.info(p);
444
496
  }
445
497
  }), console.groupEnd();
446
498
  }
447
- class K {
448
- constructor() {
449
- u(this, "_bgColor", "transparent");
450
- u(this, "_color", "#f2f286");
451
- u(this, "_icon", "🍍⚡");
452
- u(this, "_errorBgColor", "#d24545");
453
- u(this, "_errorColor", "white");
454
- u(this, "_errorIcon", "🍍⚠️");
455
- u(this, "_pluginName");
456
- u(this, "_styles", {
457
- error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },
458
- info: { bgColor: this._bgColor, color: this._color, icon: this._icon }
459
- });
460
- }
461
- formatMessage(e, t) {
462
- return this._pluginName ? ` [${t} ${this._pluginName}]
463
- ${e}
464
- ` : e;
465
- }
466
- generateStyle(e) {
467
- return G(e.bgColor, e.color);
468
- }
469
- getStyleDefinition(e) {
470
- return this._styles[e ?? "info"];
471
- }
472
- log(...e) {
473
- this.useLog(
474
- this.getStyleDefinition(),
475
- e
476
- );
477
- }
478
- error(...e) {
479
- this.useLog(
480
- this.getStyleDefinition("error"),
481
- e
482
- );
483
- }
484
- rebuildArgs(e) {
485
- return typeof e == "string" ? [e] : Array.isArray(e) ? [e.shift(), ...e] : [e];
486
- }
487
- useLog(e, t) {
488
- W(
489
- this.generateStyle(e),
490
- this.rebuildArgs(t)
491
- );
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;
492
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
+ );
493
516
  }
494
- class V extends K {
517
+ class B extends W {
495
518
  constructor(t) {
496
519
  super();
497
- u(this, "_pluginName", S);
520
+ u(this, "_pluginName", E);
498
521
  t && (this._pluginName = t);
499
522
  }
500
523
  logGroup(t) {
@@ -508,109 +531,109 @@ class V extends K {
508
531
  "%c%s",
509
532
  "color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px",
510
533
  "[ ✨ traces ]"
511
- ), t.forEach((l) => N(l[1])), console.groupEnd(), console.groupEnd();
534
+ ), t.forEach((p) => v(p[1])), console.groupEnd(), console.groupEnd();
512
535
  }
513
536
  useLog(t, r) {
514
- q(
537
+ F(
515
538
  this.generateStyle(t),
516
539
  this.rebuildArgs(r),
517
540
  this._pluginName
518
541
  );
519
542
  }
520
543
  }
521
- function A(s) {
544
+ function $(s) {
522
545
  const e = Object.keys(s).reduce((t, r) => (r !== "level" && r !== "timestamp" && (t[r] = s[r]), t), {});
523
- return [F(s), e];
546
+ return [A(s), e];
524
547
  }
525
- function F(s) {
548
+ function A(s) {
526
549
  return s.scope ? `${s.label} [${s.scope}]` : `${s.label}`;
527
550
  }
528
- function H(s, e) {
551
+ function U(s, e) {
529
552
  const t = e.level === "error" ? "error" : "log";
530
- s[t](...A(e));
553
+ s[t](...$(e));
531
554
  }
532
- function B(s = "scope") {
533
- const e = new V(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
534
- function o(n) {
535
- t.has(n) || t.set(n, []), r.set(n, (r.get(n) ?? 0) + 1);
536
- }
537
- function l(n) {
538
- const a = t.get(n);
539
- if (!a) {
540
- 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}"`);
541
564
  return;
542
565
  }
543
- const c = (r.get(n) ?? 1) - 1;
544
- if (c > 0) {
545
- r.set(n, c);
566
+ const l = (r.get(i) ?? 1) - 1;
567
+ if (l > 0) {
568
+ r.set(i, l);
546
569
  return;
547
570
  }
548
- a.length && e.logGroup(a), t.delete(n), r.delete(n);
571
+ c.length && e.logGroup(c), t.delete(i), r.delete(i);
549
572
  }
550
573
  return {
551
574
  createGroup: o,
552
- logGroup: l,
553
- handler(n) {
554
- const a = n?.payload?.groupId ?? n[s];
555
- if (!t.has(a)) {
556
- 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);
557
580
  return;
558
581
  }
559
- t.get(a)?.push(A(n));
582
+ t.get(c)?.[0]?.[0] !== A(i) && t.get(c)?.push($(i));
560
583
  }
561
584
  };
562
585
  }
563
- function E(s, e = !0, t) {
564
- return (r) => s[t](({ comparator: o = "equals", target: l, value: n }) => {
565
- if (l === "namespace" && e && X(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))
566
589
  return !0;
567
- const a = r[l];
568
- if (typeof a != "string") return !1;
569
- let c = !1;
590
+ const c = r[p];
591
+ if (typeof c != "string") return !1;
592
+ let l = !1;
570
593
  switch (o) {
571
594
  case "equals":
572
- c = a === n;
595
+ l = c === i;
573
596
  break;
574
597
  case "contains":
575
- c = a.includes(n);
598
+ l = c.includes(i);
576
599
  break;
577
600
  case "startsWith":
578
- c = a.startsWith(n);
601
+ l = c.startsWith(i);
579
602
  break;
580
603
  case "endsWith":
581
- c = a.endsWith(n);
604
+ l = c.endsWith(i);
582
605
  break;
583
606
  default:
584
- c = !1;
607
+ l = !1;
585
608
  break;
586
609
  }
587
- return c;
610
+ return l;
588
611
  });
589
612
  }
590
- function U(s, e = !0, t = "every", r = "scope") {
613
+ function J(s, e = !0, t = "every", r = "scope") {
591
614
  return {
592
615
  groupBy: r,
593
- ...B(r),
594
- ...v(s, e, t)
616
+ ...X(r),
617
+ ...Q(s, e, t)
595
618
  };
596
619
  }
597
- function v(s, e = !0, t = "every") {
598
- 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) } : {
599
622
  ...s,
600
- 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
601
624
  };
602
625
  }
603
- function X(s) {
604
- return s?.source === S && (!s?.namespace || s.namespace.startsWith(z));
626
+ function Y(s) {
627
+ return s?.source === E && (!s?.namespace || s.namespace.startsWith(L));
605
628
  }
606
- function J() {
629
+ function Z() {
607
630
  try {
608
631
  return process.env.NODE_ENV === "production";
609
632
  } catch {
610
633
  return !1;
611
634
  }
612
635
  }
613
- const Q = "[REDACTED]", Y = [
636
+ const ee = "[REDACTED]", te = [
614
637
  /pass(word|wd|phrase|code)|^pwd/i,
615
638
  /secret/i,
616
639
  /token/i,
@@ -620,127 +643,127 @@ const Q = "[REDACTED]", Y = [
620
643
  /credential/i,
621
644
  /cookie/i,
622
645
  /cipher/i
623
- ], Z = 12;
624
- function ee(s) {
646
+ ], re = 12;
647
+ function se(s) {
625
648
  const e = /* @__PURE__ */ new Set(), t = [];
626
649
  for (const r of s)
627
650
  typeof r == "string" ? e.add(r.toLowerCase()) : t.push(new RegExp(r.source, r.flags.replace(/[gy]/g, "")));
628
651
  return (r) => e.has(r.toLowerCase()) || t.some((o) => o.test(r));
629
652
  }
630
- function te(s) {
653
+ function oe(s) {
631
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);
632
655
  }
633
- function re(s = !0) {
634
- const { includeDefaults: e = !0, keys: t = [], replacement: r = Q } = s === !0 ? {} : s, o = ee([...e ? Y : [], ...t]);
635
- function l(n, a, c) {
636
- if (!te(n))
637
- return n;
638
- const f = a.get(n);
639
- if (f !== void 0)
640
- return f;
641
- if (c >= 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)
642
665
  return "[MaxDepth]";
643
- if (n instanceof Map) {
644
- const p = /* @__PURE__ */ new Map();
645
- return a.set(n, p), n.forEach((h, g) => {
646
- p.set(g, typeof g == "string" && o(g) ? r : l(h, a, c + 1));
647
- }), p;
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;
648
671
  }
649
- if (n instanceof Set) {
650
- const p = /* @__PURE__ */ new Set();
651
- return a.set(n, p), n.forEach((h) => p.add(l(h, a, c + 1))), p;
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;
652
675
  }
653
- if (Array.isArray(n)) {
654
- const p = [];
655
- return a.set(n, p), n.forEach((h) => p.push(l(h, a, c + 1))), p;
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;
656
679
  }
657
- const i = {};
658
- a.set(n, i);
659
- for (const p of Object.keys(n)) {
660
- const h = o(p) ? r : l(n[p], a, c + 1);
661
- Object.defineProperty(i, p, {
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, {
662
685
  configurable: !0,
663
686
  enumerable: !0,
664
- value: h,
687
+ value: f,
665
688
  writable: !0
666
689
  });
667
690
  }
668
- return i;
691
+ return a;
669
692
  }
670
- return (n) => l(n, /* @__PURE__ */ new WeakMap(), 0);
693
+ return (i) => p(i, /* @__PURE__ */ new WeakMap(), 0);
671
694
  }
672
- const se = () => {
695
+ const ie = () => {
673
696
  };
674
- function ue({ enabled: s = !J(), redact: e = !1 } = {}) {
675
- const t = e ? re(e === !0 ? !0 : e) : void 0, r = [];
676
- function o(i, { context: p = !0, filterMode: h = "every", groupBy: g = "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" } = {}) {
677
700
  if (!s)
678
- return se;
679
- const m = U(
680
- i,
681
- !!p,
682
- h ?? "every",
701
+ return ie;
702
+ const m = J(
703
+ a,
704
+ !!n,
705
+ f ?? "every",
683
706
  g ?? "scope"
684
707
  );
685
708
  return r.push(m), () => {
686
- const y = r.indexOf(m);
687
- y !== -1 && r.splice(y, 1);
709
+ const x = r.indexOf(m);
710
+ x !== -1 && r.splice(x, 1);
688
711
  };
689
712
  }
690
- function l(i, p = !0) {
713
+ function p(a, n = !0) {
691
714
  return o(
692
- i.map((h) => ({ target: "scope", value: h })),
693
- { context: p, filterMode: "some", groupBy: "scope" }
715
+ a.map((f) => ({ target: "scope", value: f })),
716
+ { context: n, filterMode: "some", groupBy: "scope" }
694
717
  );
695
718
  }
696
- function n() {
719
+ function i() {
697
720
  r.length = 0;
698
721
  }
699
- function a(i) {
700
- const p = {
701
- groupId: i.groupId,
702
- label: i.label,
703
- level: i.level,
704
- namespace: i.namespace,
705
- scope: i.scope,
706
- source: i.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
707
730
  };
708
- return r.filter((h) => h.filter(p));
731
+ return r.filter((f) => f.filter(n));
709
732
  }
710
- function c() {
733
+ function l() {
711
734
  return r.length > 0;
712
735
  }
713
- function f(i, p) {
714
- r.length && a(p).forEach((h) => {
715
- const g = p.groupId ?? p[h.groupBy];
716
- typeof g == "string" && h[i](g);
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);
717
740
  });
718
741
  }
719
742
  return {
720
743
  addListener: o,
721
- addScopesListener: l,
722
- clearTraceListeners: n,
744
+ addScopesListener: p,
745
+ clearTraceListeners: i,
723
746
  tracerHandler: {
724
- closeGroup: (i) => f("logGroup", i),
725
- createTracer: (i, p = {}) => new R(i, r, { redactor: t, ...p }),
726
- hasTraceListeners: c,
727
- startGroup: (i) => f("createGroup", i)
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)
728
751
  },
729
- hasTraceListeners: c
752
+ hasTraceListeners: l
730
753
  };
731
754
  }
732
755
  export {
733
- ce as PluginSubscriber,
734
- fe as PluginSubscription,
735
- P as Store,
756
+ pe as PluginSubscriber,
757
+ de as PluginSubscription,
758
+ M as Store,
736
759
  R as Tracer,
737
- B as createConsoleGroupTraceListener,
738
- ae as createPluginSubscriber,
739
- ue as createTracerRegistry,
740
- Y as defaultRedactedKeys,
741
- w as getDefineAStoreSetupContext,
742
- j as isEmpty,
743
- T as setEnhancedStore,
744
- he as traceGroups
760
+ X as createConsoleGroupTraceListener,
761
+ le as createPluginSubscriber,
762
+ fe as createTracerRegistry,
763
+ te as defaultRedactedKeys,
764
+ T as getDefineAStoreSetupContext,
765
+ I as isEmpty,
766
+ j as setEnhancedStore,
767
+ be as traceGroups
745
768
  };
746
769
  //# sourceMappingURL=helpers.js.map