pinia-plugin-subscription 1.0.0-beta.7 → 1.0.0-beta.8

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,23 +1,23 @@
1
- var E = Object.defineProperty;
2
- var S = (r, e, t) => e in r ? E(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var a = (r, e, t) => S(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { T as A, g as $, s as O, i as C, h as T, p as m, a as w } from "./chunks/PluginSubscription-DPu3ft-c.js";
5
- import { P as ut } from "./chunks/PluginSubscription-DPu3ft-c.js";
6
- import { isRef as k, ref as L, toRef as j } from "vue";
7
- class ot {
8
- constructor(e, t) {
9
- a(this, "_createInstance");
10
- a(this, "_name");
11
- a(this, "_pluginOptions");
12
- a(this, "_storeInstance");
13
- a(this, "_resetStoreCallback");
14
- a(this, "_storeOnActionSubscription");
15
- a(this, "_storeMutationSubscription");
16
- a(this, "_subscriptions");
17
- a(this, "pluginCreated");
18
- a(this, "execution");
19
- a(this, "hydrationScheduler");
20
- this._name = e, this._createInstance = t;
1
+ var A = Object.defineProperty;
2
+ var S = (r, t, e) => t in r ? A(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var p = (r, t, e) => S(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { T as $, g as C, s as O, i as T, h as w, p as x, a as k } from "./chunks/PluginSubscription-C_a6v8oi.js";
5
+ import { P as pt, t as lt } from "./chunks/PluginSubscription-C_a6v8oi.js";
6
+ import { isRef as z, ref as I, toRef as L } from "vue";
7
+ class it {
8
+ constructor(t, e) {
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");
20
+ this._name = t, this._createInstance = e;
21
21
  }
22
22
  get name() {
23
23
  return this._name;
@@ -28,8 +28,8 @@ class ot {
28
28
  get pluginOptions() {
29
29
  return this._pluginOptions;
30
30
  }
31
- set pluginOptions(e) {
32
- this._pluginOptions = e;
31
+ set pluginOptions(t) {
32
+ this._pluginOptions = t;
33
33
  }
34
34
  get resetStoreCallback() {
35
35
  return this._resetStoreCallback;
@@ -43,33 +43,33 @@ class ot {
43
43
  get subscriptions() {
44
44
  return this._subscriptions;
45
45
  }
46
- set subscriptions(e) {
47
- this._subscriptions = e;
46
+ set subscriptions(t) {
47
+ this._subscriptions = t;
48
48
  }
49
- afterHydration(e) {
49
+ afterHydration(t) {
50
50
  }
51
- hydrate(e) {
51
+ hydrate(t) {
52
52
  }
53
- invoke({ store: e, options: t }, s) {
54
- return this._storeInstance = this._createInstance(e, {
55
- ...t,
53
+ invoke({ store: t, options: e }, s) {
54
+ return this._storeInstance = this._createInstance(t, {
55
+ ...e,
56
56
  ...this.pluginOptions,
57
57
  createTracer: s ? () => s?.(this.name) : void 0
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;
58
+ }), this._storeInstance ? (this._subscriptions = this._storeInstance.getSubscriptions(), this._storeMutationSubscription = this._storeInstance.storeSubscribe, this._storeOnActionSubscription = this._storeInstance.onAction, this.pluginCreated && this.pluginCreated(t), !0) : !1;
59
59
  }
60
60
  }
61
- class z extends A {
62
- constructor(t, s) {
61
+ class j extends $ {
62
+ constructor(e, s) {
63
63
  super();
64
- a(this, "_className", "Store");
65
- a(this, "_createTracer");
66
- a(this, "_onAction");
67
- a(this, "_options");
68
- a(this, "_store");
69
- a(this, "_storeSubscribe");
70
- a(this, "_subscriptions", {});
71
- if (this._options = s.storeOptions, this._store = t, this.initializeTracer(s), this.trace("instance:created", t.$id), this._options?.enhancedStore) {
72
- const o = $(this.store);
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", {});
71
+ if (this._options = s.storeOptions, this._store = e, this.initializeTracer(s), this.trace("instance:created", e.$id), this._options?.enhancedStore) {
72
+ const o = C(this.store);
73
73
  o && (O(o, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
74
74
  }
75
75
  }
@@ -80,8 +80,8 @@ class z extends A {
80
80
  callback: this._onAction
81
81
  });
82
82
  }
83
- set onAction(t) {
84
- this._onAction = t;
83
+ set onAction(e) {
84
+ this._onAction = e;
85
85
  }
86
86
  get options() {
87
87
  return this._options;
@@ -89,8 +89,8 @@ class z extends A {
89
89
  get state() {
90
90
  return this._store.$state;
91
91
  }
92
- set state(t) {
93
- this._store.$state = t;
92
+ set state(e) {
93
+ this._store.$state = e;
94
94
  }
95
95
  get store() {
96
96
  return this._store;
@@ -102,64 +102,64 @@ class z extends A {
102
102
  callback: this._storeSubscribe
103
103
  });
104
104
  }
105
- set storeSubscribe(t) {
106
- this._storeSubscribe = t;
105
+ set storeSubscribe(e) {
106
+ this._storeSubscribe = e;
107
107
  }
108
108
  get tracer() {
109
109
  return !this._tracer && this._createTracer && (this._tracer = this._createTracer(), this._tracer.scope = this.store.$id), this._tracer;
110
110
  }
111
- addToState(t, s) {
112
- this.isOptionApi() || k(s) || (s = L(s)), this.state[t] = s, this.store[t] = j(this.state, t);
111
+ addToState(e, s) {
112
+ this.isOptionApi() || z(s) || (s = I(s)), this.state[e] = s, this.store[e] = L(this.state, e);
113
113
  }
114
- addSubscription(t, s, o) {
115
- this._subscriptions[t] = { subscription: s, ...o ?? {} };
114
+ addSubscription(e, s, o) {
115
+ this._subscriptions[e] = { subscription: s, ...o ?? {} };
116
116
  }
117
117
  afterHydration() {
118
118
  }
119
- static customizeStore(t, s) {
119
+ static customizeStore(e, s) {
120
120
  if (s.storeOptions && this.hasRequiredKeys(s.storeOptions))
121
- return new this(t, s);
121
+ return new this(e, s);
122
122
  }
123
- getOption(t) {
124
- return this.options && this.options[t];
123
+ getOption(e) {
124
+ return this.options && this.options[e];
125
125
  }
126
- getStatePropertyValue(t) {
127
- return this.getValue(this.state[t]);
126
+ getStatePropertyValue(e) {
127
+ return this.getValue(this.state[e]);
128
128
  }
129
129
  getSubscriptions() {
130
- if (!C(this._subscriptions))
130
+ if (!T(this._subscriptions))
131
131
  return this._subscriptions;
132
132
  }
133
- getValue(t) {
134
- return t?.__v_isRef ? t.value : t;
133
+ getValue(e) {
134
+ return e?.__v_isRef ? e.value : e;
135
135
  }
136
- hasDeniedFirstChar(t) {
137
- return T(t);
136
+ hasDeniedFirstChar(e) {
137
+ return w(e);
138
138
  }
139
- static hasRequiredKeys(t) {
140
- return this._requiredKeys !== void 0 && this._requiredKeys?.every((s) => !!t[s]);
139
+ static hasRequiredKeys(e) {
140
+ return this._requiredKeys !== void 0 && this._requiredKeys?.every((s) => !!e[s]);
141
141
  }
142
142
  hydrate() {
143
143
  }
144
- initializeTracer(t) {
145
- this._createTracer = t?.createTracer;
144
+ initializeTracer(e) {
145
+ this._createTracer = e?.createTracer;
146
146
  }
147
147
  isOptionApi() {
148
148
  return this.store._isOptionsAPI;
149
149
  }
150
- stateHas(t) {
151
- return Object.prototype.hasOwnProperty.call(this.state, t);
150
+ stateHas(e) {
151
+ return Object.prototype.hasOwnProperty.call(this.state, e);
152
152
  }
153
- storeHas(t) {
154
- return Object.prototype.hasOwnProperty.call(this.store, t);
153
+ storeHas(e) {
154
+ return Object.prototype.hasOwnProperty.call(this.store, e);
155
155
  }
156
156
  }
157
- a(z, "_requiredKeys");
158
- function it(r, e, t) {
157
+ p(j, "_requiredKeys");
158
+ function nt(r, t, e) {
159
159
  return {
160
160
  name: r,
161
- invoke: e,
162
- ...t
161
+ invoke: t,
162
+ ...e
163
163
  };
164
164
  }
165
165
  function R(r) {
@@ -167,89 +167,98 @@ function R(r) {
167
167
  return r;
168
168
  try {
169
169
  return r();
170
- } catch (e) {
171
- return { __tracePayloadError: e };
170
+ } catch (t) {
171
+ return { __tracePayloadError: t };
172
172
  }
173
173
  }
174
- class I {
175
- constructor(e, t, s = {}) {
176
- a(this, "_listeners", []);
177
- a(this, "_redactor");
178
- a(this, "_scope");
179
- a(this, "_source");
180
- this._redactor = s.redactor, this._scope = s.scope, this._source = e, this._listeners = t;
174
+ class M {
175
+ constructor(t, e, s = {}) {
176
+ p(this, "_listeners", []);
177
+ p(this, "_redactor");
178
+ p(this, "_scope");
179
+ p(this, "_source");
180
+ this._redactor = s.redactor, this._scope = s.scope, this._source = t, this._listeners = e;
181
181
  }
182
182
  get scope() {
183
183
  return this._scope;
184
184
  }
185
- set scope(e) {
186
- this._scope = e;
185
+ set scope(t) {
186
+ this._scope = t;
187
187
  }
188
188
  get source() {
189
189
  return this._source;
190
190
  }
191
- debug(e, t, s, o) {
192
- this.emit("debug", e, t, s, o);
191
+ debug(t, e, s, o) {
192
+ this.emit("debug", t, e, s, o);
193
193
  }
194
- error(e, t, s, o, n) {
195
- this.emit("error", e, t, o, n, s);
194
+ error(t, e, s, o, c) {
195
+ this.emit("error", t, e, o, c, s);
196
196
  }
197
- resolveAndRedact(e) {
198
- const t = R(e);
199
- if (!this._redactor || t === void 0)
200
- return t;
197
+ resolveAndRedact(t) {
198
+ const e = R(t);
199
+ if (!this._redactor || e === void 0)
200
+ return e;
201
201
  try {
202
- return this._redactor(t);
202
+ return this._redactor(e);
203
203
  } catch (s) {
204
204
  return { __traceRedactionError: s instanceof Error ? s.message : String(s) };
205
205
  }
206
206
  }
207
- matchListeners(e, t, s, o) {
208
- const n = {
209
- label: t,
210
- level: e,
207
+ matchListeners(t, e, s, o) {
208
+ const c = {
209
+ label: e,
210
+ level: t,
211
211
  namespace: s,
212
212
  scope: o ?? this._scope,
213
213
  source: this._source
214
214
  }, i = [];
215
- for (const c of this._listeners)
215
+ for (const n of this._listeners)
216
216
  try {
217
- c.filter(n) && i.push(c);
218
- } catch (u) {
219
- console.error("Error in trace listener filter:", u);
217
+ n.filter(c) && i.push(n);
218
+ } catch (a) {
219
+ console.error("Error in trace listener filter:", a);
220
220
  }
221
- return { matched: i, metadata: n };
221
+ return { matched: i, metadata: c };
222
222
  }
223
- emit(e, t, s, o, n, i) {
224
- const { matched: c, metadata: u } = this._listeners.length === 0 ? { matched: [], metadata: void 0 } : this.matchListeners(e, t, s, n);
225
- if (!u || c.length === 0) {
226
- e === "error" && console.error("Unhandled error trace event:", i);
223
+ emit(t, e, s, o, c, i) {
224
+ const { matched: n, metadata: a } = this._listeners.length === 0 ? { matched: [], metadata: void 0 } : this.matchListeners(t, e, s, c);
225
+ if (!a || n.length === 0) {
226
+ t === "error" && console.error("Unhandled error trace event:", i);
227
227
  return;
228
228
  }
229
- const p = {
230
- ...u,
229
+ const u = {
230
+ ...a,
231
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 f of c)
235
+ for (const f of n)
236
236
  try {
237
- f.handler(p);
237
+ f.handler(u);
238
238
  } catch (l) {
239
239
  console.error("Error in trace listener:", l);
240
240
  }
241
241
  }
242
242
  }
243
- const M = (r, e = "white") => `background-color: ${r}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;
244
- function g(r, e, t = !0) {
245
- if (e instanceof Error) {
246
- console.error(`[ ${r} ]`, e);
247
- return;
248
- }
249
- if (Array.isArray(e) ? e.length === 0 : Object.keys(e).length === 0) {
243
+ const y = "#f86f63", P = (r, t = "white") => `background-color: ${r}; color: ${t}; padding: 1px; margin-right: 5px; font-size: 12px`;
244
+ function g(r, t, e = !0) {
245
+ if (t instanceof Error) {
246
+ console.groupCollapsed(
247
+ "%c%s",
248
+ `color: ${y}; padding: 1px; margin-right: 5px; font-size: 11px`,
249
+ `[ ${t.name} ] ${t.message}`
250
+ ), t.cause && console.log("cause:", t.cause);
251
+ const n = t.stack?.split(`
252
+ `);
253
+ n && n.forEach((a) => {
254
+ const u = a.split("@");
255
+ Array.isArray(u) && console.log(u[0], u[1]);
256
+ }), console.groupEnd();
257
+ }
258
+ if (Array.isArray(t) ? t.length === 0 : Object.keys(t).length === 0) {
250
259
  console.log(
251
260
  "%c%s",
252
- "color: #f86f63; padding: 1px; margin-right: 5px; font-size: 10px",
261
+ `color: ${y}; padding: 1px; margin-right: 5px; font-size: 10px`,
253
262
  `[ ${r} ] Empty`
254
263
  );
255
264
  return;
@@ -259,7 +268,7 @@ function g(r, e, t = !0) {
259
268
  store: "🏪 ",
260
269
  subscribers: "🧩 "
261
270
  }[r] ?? "";
262
- if (t ? console.groupCollapsed(
271
+ if (e ? console.groupCollapsed(
263
272
  "%c%s",
264
273
  "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
265
274
  `[ ${i}${r} ]`
@@ -267,37 +276,39 @@ function g(r, e, t = !0) {
267
276
  "%c%s",
268
277
  "color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
269
278
  `[ ${i} ${r} ]`
270
- ), Array.isArray(e))
271
- typeof e[0] == "object" ? e.forEach((c) => {
272
- c.name ? g(c.name, c) : c._id ? g(c._id, c) : console.dir(c);
273
- }) : e.forEach((c, u) => {
279
+ ), Array.isArray(t))
280
+ typeof t[0] == "object" ? t.forEach((n) => {
281
+ n.name ? g(n.name, n) : n._id ? g(n._id, n) : console.dir(n);
282
+ }) : t.forEach((n, a) => {
274
283
  console.log(
275
284
  "%c%s",
276
285
  "color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
277
- `[ ${u} ]`,
278
- c
286
+ `[ ${a} ]`,
287
+ n
279
288
  );
280
289
  });
281
290
  else {
282
- let c = [];
283
- Object.keys(e).forEach((u) => {
284
- const p = e[u];
285
- typeof p == "object" ? Array.isArray(p) ? typeof p[0] == "object" ? g(u, p, !1) : (console.group(u), console.log(p), console.groupEnd()) : p instanceof Error ? console.log(u, p) : g(u, Object.assign({}, p), !1) : p ? console.log(
291
+ let n = [];
292
+ Object.keys(t).forEach((a) => {
293
+ if (a === "groupId")
294
+ return;
295
+ const u = t[a];
296
+ typeof u == "object" ? Array.isArray(u) ? typeof u[0] == "object" ? g(a, u, !1) : (console.group(a), console.log(u), console.groupEnd()) : u instanceof Error ? console.log(a, { name: u.name, message: u.message, stack: u.stack }) : g(a, Object.assign({}, u), !1) : u ? console.log(
286
297
  "%c%s",
287
298
  "color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px",
288
- `[ ${u} ]`,
289
- p
290
- ) : c.push(u);
291
- }), c.length && console.log(
299
+ `[ ${a} ]`,
300
+ u
301
+ ) : n.push(a);
302
+ }), n.length && console.log(
292
303
  "%c%s",
293
304
  "color: #f86f63; font-size: 9px",
294
305
  "[ Empty properties ]",
295
- c
306
+ n
296
307
  );
297
308
  }
298
309
  console.groupEnd();
299
310
  }
300
- function P(r) {
311
+ function G(r) {
301
312
  if (r.payload) {
302
313
  g(r.label, r.payload);
303
314
  return;
@@ -310,75 +321,75 @@ function P(r) {
310
321
  );
311
322
  }
312
323
  function _(r) {
313
- Object.keys(r).forEach((e) => {
314
- if (["label", "namespace", "scope", "source"].includes(e))
324
+ Object.keys(r).forEach((t) => {
325
+ if (["groupId", "label", "namespace", "scope", "source"].includes(t))
315
326
  return;
316
- const t = r[e];
317
- if (!t) {
327
+ const e = r[t];
328
+ if (!e) {
318
329
  console.log(
319
330
  "%c%s",
320
331
  "color: #f86f63; padding: 1px; margin-right: 5px; font-size: 10px",
321
- `[ ${e} ] ${t}`
332
+ `[ ${t} ] ${e}`
322
333
  );
323
334
  return;
324
335
  }
325
- switch (typeof t) {
336
+ switch (typeof e) {
326
337
  case "string":
327
338
  console.log(
328
339
  "%c%s",
329
340
  "color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px",
330
- `[ ${e} ]`,
331
- t
341
+ `[ ${t} ]`,
342
+ e
332
343
  );
333
344
  break;
334
345
  case "object":
335
- switch (e) {
346
+ switch (t) {
336
347
  case "mutation":
337
- console.groupCollapsed("[mutation]"), console.dir(t), console.groupEnd();
348
+ console.groupCollapsed("[mutation]"), console.dir(e), console.groupEnd();
338
349
  break;
339
350
  case "options":
340
- g(e, t?.storeOptions ?? t);
351
+ g(t, e?.storeOptions ?? e);
341
352
  break;
342
353
  case "payload":
343
- _(t);
354
+ _(e);
344
355
  break;
345
356
  case "store":
346
- g(e, {
347
- $state: t.$state,
348
- $actions: Object.keys(t).reduce((s, o) => (o.startsWith("$") && !["$id", "$state"].includes(o) || o.startsWith("_") || (s[o] = t[o]), s), {})
357
+ g(t, {
358
+ $state: e.$state,
359
+ $actions: Object.keys(e).reduce((s, o) => (o.startsWith("$") && !["$id", "$state"].includes(o) || o.startsWith("_") || (s[o] = e[o]), s), {})
349
360
  });
350
361
  break;
351
362
  default:
352
- g(e, t);
363
+ g(t, e);
353
364
  }
354
365
  break;
355
366
  case "function":
356
- console.dir(t);
367
+ console.dir(e);
357
368
  break;
358
369
  default:
359
- console.info(t);
370
+ console.info(e);
360
371
  }
361
372
  });
362
373
  }
363
- function G(r, e) {
374
+ function D(r, t) {
364
375
  if (!r)
365
376
  throw new Error("Style instructions are required");
366
377
  console.log(
367
378
  "%c%s",
368
379
  r,
369
- e.shift(),
370
- ...e
380
+ t.shift(),
381
+ ...t
371
382
  );
372
383
  }
373
- function D(r, e, t) {
384
+ function N(r, t, e) {
374
385
  if (!r)
375
386
  throw new Error("Style instructions are required");
376
- const s = e.shift(), o = e[0];
387
+ const s = t.shift(), o = t[0];
377
388
  if (!o?.payload || Object.keys(o.payload).length === 0) {
378
389
  console.log(
379
390
  "%c%s",
380
391
  r,
381
- `${o?.source === t ? o?.label ?? o?.namespace : s}`,
392
+ `${o?.source === e ? o?.label ?? o?.namespace : s}`,
382
393
  o?.source
383
394
  );
384
395
  return;
@@ -389,77 +400,77 @@ function D(r, e, t) {
389
400
  `${s}
390
401
  `,
391
402
  o?.source
392
- ), e.forEach((n) => {
393
- switch (typeof n) {
403
+ ), t.forEach((c) => {
404
+ switch (typeof c) {
394
405
  case "string":
395
- console.info(n);
406
+ console.info(c);
396
407
  break;
397
408
  case "object":
398
- Array.isArray(n) ? console.table(n) : _(n);
409
+ Array.isArray(c) ? console.table(c) : _(c);
399
410
  break;
400
411
  case "function":
401
- console.dir(n);
412
+ console.dir(c);
402
413
  break;
403
414
  default:
404
- console.info(n);
415
+ console.info(c);
405
416
  }
406
417
  }), console.groupEnd();
407
418
  }
408
- class N {
419
+ class W {
409
420
  constructor() {
410
- a(this, "_bgColor", "transparent");
411
- a(this, "_color", "#f2f286");
412
- a(this, "_icon", "🍍⚡");
413
- a(this, "_errorBgColor", "#d24545");
414
- a(this, "_errorColor", "white");
415
- a(this, "_errorIcon", "🍍⚠️");
416
- a(this, "_pluginName");
417
- a(this, "_styles", {
421
+ p(this, "_bgColor", "transparent");
422
+ p(this, "_color", "#f2f286");
423
+ p(this, "_icon", "🍍⚡");
424
+ p(this, "_errorBgColor", "#d24545");
425
+ p(this, "_errorColor", "white");
426
+ p(this, "_errorIcon", "🍍⚠️");
427
+ p(this, "_pluginName");
428
+ p(this, "_styles", {
418
429
  error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },
419
430
  info: { bgColor: this._bgColor, color: this._color, icon: this._icon }
420
431
  });
421
432
  }
422
- formatMessage(e, t) {
423
- return this._pluginName ? ` [${t} ${this._pluginName}]
424
- ${e}
425
- ` : e;
433
+ formatMessage(t, e) {
434
+ return this._pluginName ? ` [${e} ${this._pluginName}]
435
+ ${t}
436
+ ` : t;
426
437
  }
427
- generateStyle(e) {
428
- return M(e.bgColor, e.color);
438
+ generateStyle(t) {
439
+ return P(t.bgColor, t.color);
429
440
  }
430
- getStyleDefinition(e) {
431
- return this._styles[e ?? "info"];
441
+ getStyleDefinition(t) {
442
+ return this._styles[t ?? "info"];
432
443
  }
433
- log(...e) {
444
+ log(...t) {
434
445
  this.useLog(
435
446
  this.getStyleDefinition(),
436
- e
447
+ t
437
448
  );
438
449
  }
439
- error(...e) {
450
+ error(...t) {
440
451
  this.useLog(
441
452
  this.getStyleDefinition("error"),
442
- e
453
+ t
443
454
  );
444
455
  }
445
- rebuildArgs(e) {
446
- return typeof e == "string" ? [e] : Array.isArray(e) ? [e.shift(), ...e] : [e];
456
+ rebuildArgs(t) {
457
+ return typeof t == "string" ? [t] : Array.isArray(t) ? [t.shift(), ...t] : [t];
447
458
  }
448
- useLog(e, t) {
449
- G(
450
- this.generateStyle(e),
451
- this.rebuildArgs(t)
459
+ useLog(t, e) {
460
+ D(
461
+ this.generateStyle(t),
462
+ this.rebuildArgs(e)
452
463
  );
453
464
  }
454
465
  }
455
- class W extends N {
456
- constructor(t) {
466
+ class q extends W {
467
+ constructor(e) {
457
468
  super();
458
- a(this, "_pluginName", m);
459
- t && (this._pluginName = t);
469
+ p(this, "_pluginName", x);
470
+ e && (this._pluginName = e);
460
471
  }
461
- logGroup(t) {
462
- const o = t.shift()?.[1];
472
+ logGroup(e) {
473
+ const o = e.shift()?.[1];
463
474
  console.groupCollapsed(
464
475
  "%c%s",
465
476
  "color: #87e47f; padding: 1px; margin-right: 5px; font-size: 11px; font-family: arial",
@@ -469,104 +480,104 @@ class W extends N {
469
480
  "%c%s",
470
481
  "color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px",
471
482
  "[ ✨ traces ]"
472
- ), t.forEach((n) => P(n[1])), console.groupEnd(), console.groupEnd();
483
+ ), e.forEach((c) => G(c[1])), console.groupEnd(), console.groupEnd();
473
484
  }
474
- useLog(t, s) {
475
- D(
476
- this.generateStyle(t),
485
+ useLog(e, s) {
486
+ N(
487
+ this.generateStyle(e),
477
488
  this.rebuildArgs(s),
478
489
  this._pluginName
479
490
  );
480
491
  }
481
492
  }
482
- function x(r) {
483
- const e = Object.keys(r).reduce((t, s) => (s !== "level" && s !== "timestamp" && (t[s] = r[s]), t), {});
484
- return [q(r), e];
493
+ function E(r) {
494
+ const t = Object.keys(r).reduce((e, s) => (s !== "level" && s !== "timestamp" && (e[s] = r[s]), e), {});
495
+ return [K(r), t];
485
496
  }
486
- function q(r) {
497
+ function K(r) {
487
498
  return r.scope ? `${r.label} [${r.scope}]` : `${r.label}`;
488
499
  }
489
- function K(r, e) {
490
- const t = e.level === "error" ? "error" : "log";
491
- r[t](...x(e));
500
+ function F(r, t) {
501
+ const e = t.level === "error" ? "error" : "log";
502
+ r[e](...E(t));
492
503
  }
493
- function F(r = "scope") {
494
- const e = new W(), t = /* @__PURE__ */ new Map();
495
- function s(n) {
496
- t.set(n, []);
504
+ function H(r = "scope") {
505
+ const t = new q(), e = /* @__PURE__ */ new Map();
506
+ function s(c) {
507
+ e.set(c, []);
497
508
  }
498
- function o(n) {
499
- const i = t.get(n);
509
+ function o(c) {
510
+ const i = e.get(c);
500
511
  if (!i) {
501
- e.error(`No group found for key "${n}"`);
512
+ t.error(`No group found for key "${c}"`);
502
513
  return;
503
514
  }
504
- i.length && e.logGroup(i), t.delete(n);
515
+ i.length && t.logGroup(i), e.delete(c);
505
516
  }
506
517
  return {
507
518
  createGroup: s,
508
519
  logGroup: o,
509
- handler(n) {
510
- const i = n[r];
511
- if (!t.has(i)) {
512
- K(e, n);
520
+ handler(c) {
521
+ const i = c?.payload?.groupId ?? c[r];
522
+ if (!e.has(i)) {
523
+ F(t, c);
513
524
  return;
514
525
  }
515
- t.get(i)?.push(x(n));
526
+ e.get(i)?.push(E(c));
516
527
  }
517
528
  };
518
529
  }
519
- function y(r, e = !0, t) {
520
- return (s) => r[t](({ comparator: o = "equals", target: n, value: i }) => {
521
- if (n === "namespace" && e && U(s))
530
+ function m(r, t = !0, e) {
531
+ return (s) => r[e](({ comparator: o = "equals", target: c, value: i }) => {
532
+ if (c === "namespace" && t && B(s))
522
533
  return !0;
523
- const c = s[n];
524
- if (typeof c != "string") return !1;
525
- let u = !1;
534
+ const n = s[c];
535
+ if (typeof n != "string") return !1;
536
+ let a = !1;
526
537
  switch (o) {
527
538
  case "equals":
528
- u = c === i;
539
+ a = n === i;
529
540
  break;
530
541
  case "contains":
531
- u = c.includes(i);
542
+ a = n.includes(i);
532
543
  break;
533
544
  case "startsWith":
534
- u = c.startsWith(i);
545
+ a = n.startsWith(i);
535
546
  break;
536
547
  case "endsWith":
537
- u = c.endsWith(i);
548
+ a = n.endsWith(i);
538
549
  break;
539
550
  default:
540
- u = !1;
551
+ a = !1;
541
552
  break;
542
553
  }
543
- return u;
554
+ return a;
544
555
  });
545
556
  }
546
- function H(r, e = !0, t = "every", s = "scope") {
557
+ function V(r, t = !0, e = "every", s = "scope") {
547
558
  return {
548
559
  groupBy: s,
549
- ...F(s),
550
- ...V(r, e, t)
560
+ ...H(s),
561
+ ...U(r, t, e)
551
562
  };
552
563
  }
553
- function V(r, e = !0, t = "every") {
554
- return Array.isArray(r) ? { filter: y(r, e, t) } : {
564
+ function U(r, t = !0, e = "every") {
565
+ return Array.isArray(r) ? { filter: m(r, t, e) } : {
555
566
  ...r,
556
- filter: Array.isArray(r.filter) ? y(r.filter, e, t) : r.filter
567
+ filter: Array.isArray(r.filter) ? m(r.filter, t, e) : r.filter
557
568
  };
558
569
  }
559
- function U(r) {
560
- return r?.source === m && (!r?.namespace || r.namespace.startsWith(w));
570
+ function B(r) {
571
+ return r?.source === x && (!r?.namespace || r.namespace.startsWith(k));
561
572
  }
562
- function B() {
573
+ function X() {
563
574
  try {
564
575
  return process.env.NODE_ENV === "production";
565
576
  } catch {
566
577
  return !1;
567
578
  }
568
579
  }
569
- const X = "[REDACTED]", J = [
580
+ const J = "[REDACTED]", Q = [
570
581
  /pass(word|wd|phrase|code)|^pwd/i,
571
582
  /secret/i,
572
583
  /token/i,
@@ -576,57 +587,57 @@ const X = "[REDACTED]", J = [
576
587
  /credential/i,
577
588
  /cookie/i,
578
589
  /cipher/i
579
- ], Q = 12;
580
- function Y(r) {
581
- const e = /* @__PURE__ */ new Set(), t = [];
590
+ ], Y = 12;
591
+ function Z(r) {
592
+ const t = /* @__PURE__ */ new Set(), e = [];
582
593
  for (const s of r)
583
- typeof s == "string" ? e.add(s.toLowerCase()) : t.push(new RegExp(s.source, s.flags.replace(/[gy]/g, "")));
584
- return (s) => e.has(s.toLowerCase()) || t.some((o) => o.test(s));
594
+ typeof s == "string" ? t.add(s.toLowerCase()) : e.push(new RegExp(s.source, s.flags.replace(/[gy]/g, "")));
595
+ return (s) => t.has(s.toLowerCase()) || e.some((o) => o.test(s));
585
596
  }
586
- function Z(r) {
597
+ function v(r) {
587
598
  return r === null || typeof r != "object" ? !1 : !(r instanceof Date || r instanceof RegExp || r instanceof Error || r instanceof Promise || r instanceof WeakMap || r instanceof WeakSet);
588
599
  }
589
- function v(r = !0) {
590
- const { includeDefaults: e = !0, keys: t = [], replacement: s = X } = r === !0 ? {} : r, o = Y([...e ? J : [], ...t]);
591
- function n(i, c, u) {
592
- if (!Z(i))
600
+ function tt(r = !0) {
601
+ const { includeDefaults: t = !0, keys: e = [], replacement: s = J } = r === !0 ? {} : r, o = Z([...t ? Q : [], ...e]);
602
+ function c(i, n, a) {
603
+ if (!v(i))
593
604
  return i;
594
- const p = c.get(i);
595
- if (p !== void 0)
596
- return p;
597
- if (u >= Q)
605
+ const u = n.get(i);
606
+ if (u !== void 0)
607
+ return u;
608
+ if (a >= Y)
598
609
  return "[MaxDepth]";
599
610
  if (i instanceof Map) {
600
611
  const l = /* @__PURE__ */ new Map();
601
- return c.set(i, l), i.forEach((h, d) => {
602
- l.set(d, typeof d == "string" && o(d) ? s : n(h, c, u + 1));
612
+ return n.set(i, l), i.forEach((h, d) => {
613
+ l.set(d, typeof d == "string" && o(d) ? s : c(h, n, a + 1));
603
614
  }), l;
604
615
  }
605
616
  if (i instanceof Set) {
606
617
  const l = /* @__PURE__ */ new Set();
607
- return c.set(i, l), i.forEach((h) => l.add(n(h, c, u + 1))), l;
618
+ return n.set(i, l), i.forEach((h) => l.add(c(h, n, a + 1))), l;
608
619
  }
609
620
  if (Array.isArray(i)) {
610
621
  const l = [];
611
- return c.set(i, l), i.forEach((h) => l.push(n(h, c, u + 1))), l;
622
+ return n.set(i, l), i.forEach((h) => l.push(c(h, n, a + 1))), l;
612
623
  }
613
624
  const f = {};
614
- c.set(i, f);
625
+ n.set(i, f);
615
626
  for (const l of Object.keys(i))
616
- f[l] = o(l) ? s : n(i[l], c, u + 1);
627
+ f[l] = o(l) ? s : c(i[l], n, a + 1);
617
628
  return f;
618
629
  }
619
- return (i) => n(i, /* @__PURE__ */ new WeakMap(), 0);
630
+ return (i) => c(i, /* @__PURE__ */ new WeakMap(), 0);
620
631
  }
621
- const tt = () => {
632
+ const et = () => {
622
633
  };
623
- function nt({ enabled: r = !B(), redact: e = !1 } = {}) {
624
- const t = e ? v(e === !0 ? !0 : e) : void 0, s = [];
625
- function o(p, { context: f = !0, filterMode: l = "every", groupBy: h = "scope" } = {}) {
634
+ function ct({ enabled: r = !X(), redact: t = !1 } = {}) {
635
+ const e = t ? tt(t === !0 ? !0 : t) : void 0, s = [];
636
+ function o(u, { context: f = !0, filterMode: l = "every", groupBy: h = "scope" } = {}) {
626
637
  if (!r)
627
- return tt;
628
- const d = H(
629
- p,
638
+ return et;
639
+ const d = V(
640
+ u,
630
641
  !!f,
631
642
  l ?? "every",
632
643
  h ?? "scope"
@@ -636,43 +647,44 @@ function nt({ enabled: r = !B(), redact: e = !1 } = {}) {
636
647
  b !== -1 && s.splice(b, 1);
637
648
  };
638
649
  }
639
- function n() {
650
+ function c() {
640
651
  s.length = 0;
641
652
  }
642
- function i(p) {
643
- return s.filter((f) => f.filter(p));
653
+ function i(u) {
654
+ return s.filter((f) => f.filter(u));
644
655
  }
645
- function c() {
656
+ function n() {
646
657
  return s.length > 0;
647
658
  }
648
- function u(p, f) {
659
+ function a(u, f) {
649
660
  s.length && i(f).forEach((l) => {
650
- const h = f[l.groupBy];
651
- typeof h == "string" && l[p](h);
661
+ const h = f.groupId ?? f[l.groupBy];
662
+ typeof h == "string" && l[u](h);
652
663
  });
653
664
  }
654
665
  return {
655
666
  addListener: o,
656
- clearTraceListeners: n,
667
+ clearTraceListeners: c,
657
668
  tracerHandler: {
658
- closeGroup: (p) => u("logGroup", p),
659
- createTracer: (p, f = {}) => new I(p, s, { redactor: t, ...f }),
660
- startGroup: (p) => u("createGroup", p)
669
+ closeGroup: (u) => a("logGroup", u),
670
+ createTracer: (u, f = {}) => new M(u, s, { redactor: e, ...f }),
671
+ startGroup: (u) => a("createGroup", u)
661
672
  },
662
- hasTraceListeners: c
673
+ hasTraceListeners: n
663
674
  };
664
675
  }
665
676
  export {
666
- ot as PluginSubscriber,
667
- ut as PluginSubscription,
668
- z as Store,
669
- I as Tracer,
670
- F as createConsoleGroupTraceListener,
671
- it as createPluginSubscriber,
672
- nt as createTracerRegistry,
673
- J as defaultRedactedKeys,
674
- $ as getDefineAStoreSetupContext,
675
- C as isEmpty,
676
- O as setEnhancedStore
677
+ it as PluginSubscriber,
678
+ pt as PluginSubscription,
679
+ j as Store,
680
+ M as Tracer,
681
+ H as createConsoleGroupTraceListener,
682
+ nt as createPluginSubscriber,
683
+ ct as createTracerRegistry,
684
+ Q as defaultRedactedKeys,
685
+ C as getDefineAStoreSetupContext,
686
+ T as isEmpty,
687
+ O as setEnhancedStore,
688
+ lt as traceGroups
677
689
  };
678
690
  //# sourceMappingURL=helpers.js.map