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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +29 -12
  2. package/CONTRIBUTING.md +10 -1
  3. package/README.md +11 -9
  4. package/SECURITY.md +2 -2
  5. package/dist/chunks/{PluginSubscription-Bkqj4uSK.js → PluginSubscription-GJDsym1O.js} +253 -247
  6. package/dist/core/PluginSubscriber.d.ts +1 -1
  7. package/dist/core/PluginSubscription.d.ts +13 -12
  8. package/dist/core/Store.d.ts +1 -1
  9. package/dist/helpers/index.d.ts +0 -4
  10. package/dist/helpers.js +56 -651
  11. package/dist/pinia-plugin-subscription.js +4 -5
  12. package/dist/system/TraceEmitter.d.ts +1 -2
  13. package/dist/types/index.d.ts +1 -2
  14. package/dist/types/plugin.d.ts +2 -3
  15. package/dist/types/trace.d.ts +30 -109
  16. package/dist/utils/traceGroups.d.ts +9 -7
  17. package/docs/authoring-plugins.md +13 -7
  18. package/docs/using-plugins.md +28 -19
  19. package/package.json +9 -4
  20. package/dist/chunks/PluginSubscription-Bkqj4uSK.js.map +0 -1
  21. package/dist/factories/console-trace-listener.d.ts +0 -7
  22. package/dist/factories/trace-listener.d.ts +0 -10
  23. package/dist/factories/trace-registry.d.ts +0 -2
  24. package/dist/helpers.js.map +0 -1
  25. package/dist/pinia-plugin-subscription.js.map +0 -1
  26. package/dist/system/Tracer.d.ts +0 -23
  27. package/dist/system/log/console-group.d.ts +0 -8
  28. package/dist/system/log/console.d.ts +0 -18
  29. package/dist/system/log/index.d.ts +0 -2
  30. package/dist/system/log/log-trace.d.ts +0 -8
  31. package/dist/system/log/print-array.d.ts +0 -7
  32. package/dist/system/log/print-error.d.ts +0 -6
  33. package/dist/system/log/print-object.d.ts +0 -1
  34. package/dist/system/log/print-trace-payload.d.ts +0 -1
  35. package/dist/system/log/print-trace.d.ts +0 -9
  36. package/dist/system/log/trace-console.d.ts +0 -9
  37. package/dist/tests/defineAStore.test-d.d.ts +0 -1
  38. package/dist/tests/storeOptionsExtensions.test-d.d.ts +0 -12
  39. package/dist/types/comparison.d.ts +0 -3
  40. package/dist/types/list.d.ts +0 -13
  41. package/dist/types/log.d.ts +0 -8
  42. package/dist/types/resourceId.d.ts +0 -4
  43. package/dist/utils/Performance.d.ts +0 -9
  44. package/dist/utils/environment.d.ts +0 -7
  45. package/dist/utils/object.d.ts +0 -4
  46. package/dist/utils/redact.d.ts +0 -15
  47. package/docs/tracing.md +0 -185
package/dist/helpers.js CHANGED
@@ -1,23 +1,23 @@
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
- constructor(e, t) {
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
- this._name = e, this._createInstance = t;
1
+ var o = Object.defineProperty;
2
+ var c = (i, s, t) => s in i ? o(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
+ var e = (i, s, t) => c(i, typeof s != "symbol" ? s + "" : s, t);
4
+ import { T as a, g as u, s as h, i as p, h as _ } from "./chunks/PluginSubscription-GJDsym1O.js";
5
+ import { P as T, t as C } from "./chunks/PluginSubscription-GJDsym1O.js";
6
+ import { isRef as b, ref as S, toRef as g } from "vue";
7
+ class y {
8
+ constructor(s, t) {
9
+ e(this, "_createInstance");
10
+ e(this, "_name");
11
+ e(this, "_pluginOptions");
12
+ e(this, "_storeInstance");
13
+ e(this, "_resetStoreCallback");
14
+ e(this, "_storeOnActionSubscription");
15
+ e(this, "_storeMutationSubscription");
16
+ e(this, "_subscriptions");
17
+ e(this, "pluginCreated");
18
+ e(this, "execution");
19
+ e(this, "hydrationScheduler");
20
+ this._name = s, this._createInstance = t;
21
21
  }
22
22
  get name() {
23
23
  return this._name;
@@ -28,8 +28,8 @@ class pe {
28
28
  get pluginOptions() {
29
29
  return this._pluginOptions;
30
30
  }
31
- set pluginOptions(e) {
32
- this._pluginOptions = e;
31
+ set pluginOptions(s) {
32
+ this._pluginOptions = s;
33
33
  }
34
34
  get resetStoreCallback() {
35
35
  return this._resetStoreCallback;
@@ -43,34 +43,34 @@ class pe {
43
43
  get subscriptions() {
44
44
  return this._subscriptions;
45
45
  }
46
- set subscriptions(e) {
47
- this._subscriptions = e;
46
+ set subscriptions(s) {
47
+ this._subscriptions = s;
48
48
  }
49
- afterHydration(e) {
49
+ afterHydration(s) {
50
50
  }
51
- hydrate(e) {
51
+ hydrate(s) {
52
52
  }
53
- invoke({ store: e, options: t }, r) {
54
- return this._storeInstance = this._createInstance(e, {
53
+ invoke({ store: s, options: t }, r) {
54
+ return this._storeInstance = this._createInstance(s, {
55
55
  ...t,
56
56
  ...this.pluginOptions,
57
57
  createTracer: r ? () => r?.(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(s), !0) : !1;
59
59
  }
60
60
  }
61
- class M extends w {
61
+ class l extends a {
62
62
  constructor(t, r) {
63
63
  super();
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", {});
64
+ e(this, "_className", "Store");
65
+ e(this, "_createTracer");
66
+ e(this, "_onAction");
67
+ e(this, "_options");
68
+ e(this, "_store");
69
+ e(this, "_storeSubscribe");
70
+ e(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 = T(this.store);
73
- o && (j(o, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
72
+ const n = u(this.store);
73
+ n && (h(n, this.store), this.trace("setup:enhancedStore:success", this.store.$id));
74
74
  }
75
75
  }
76
76
  get onAction() {
@@ -109,10 +109,10 @@ 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 = P(r)), this.state[t] = r, this.store[t] = k(this.state, t);
112
+ this.isOptionApi() || b(r) || (r = S(r)), this.state[t] = r, this.store[t] = g(this.state, t);
113
113
  }
114
- addSubscription(t, r, o) {
115
- this._subscriptions[t] = { subscription: r, ...o ?? {} };
114
+ addSubscription(t, r, n) {
115
+ this._subscriptions[t] = { subscription: r, ...n ?? {} };
116
116
  }
117
117
  afterHydration() {
118
118
  }
@@ -127,14 +127,14 @@ class M extends w {
127
127
  return this.getValue(this.state[t]);
128
128
  }
129
129
  getSubscriptions() {
130
- if (!I(this._subscriptions))
130
+ if (!p(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 z(t);
137
+ return _(t);
138
138
  }
139
139
  static hasRequiredKeys(t) {
140
140
  return this._requiredKeys !== void 0 && this._requiredKeys?.every((r) => !!t[r]);
@@ -154,616 +154,21 @@ class M extends w {
154
154
  return Object.prototype.hasOwnProperty.call(this.store, t);
155
155
  }
156
156
  }
157
- u(M, "_requiredKeys");
158
- function le(s, e, t) {
157
+ e(l, "_requiredKeys");
158
+ function A(i, s, t) {
159
159
  return {
160
- name: s,
161
- invoke: e,
160
+ name: i,
161
+ invoke: s,
162
162
  ...t
163
163
  };
164
164
  }
165
- function G(s) {
166
- if (typeof s != "function")
167
- return s;
168
- try {
169
- return s();
170
- } catch (e) {
171
- return { __tracePayloadError: e };
172
- }
173
- }
174
- class R {
175
- constructor(e, t, r = {}) {
176
- u(this, "_listeners", []);
177
- u(this, "_redactor");
178
- u(this, "_scope");
179
- u(this, "_source");
180
- this._redactor = r.redactor, this._scope = r.scope, this._source = e, this._listeners = t;
181
- }
182
- get scope() {
183
- return this._scope;
184
- }
185
- set scope(e) {
186
- this._scope = e;
187
- }
188
- get source() {
189
- return this._source;
190
- }
191
- debug(e, t, r, o) {
192
- this.emit("debug", e, t, r, o);
193
- }
194
- error(e, t, r, o, p) {
195
- this.emit("error", e, t, o, p, r);
196
- }
197
- resolveAndRedact(e) {
198
- const t = G(e);
199
- if (!this._redactor || t === void 0)
200
- return t;
201
- try {
202
- return this._redactor(t);
203
- } catch (r) {
204
- return { __traceRedactionError: r instanceof Error ? r.message : String(r) };
205
- }
206
- }
207
- matchListeners(e, t, r, o) {
208
- const p = {
209
- label: t,
210
- level: e,
211
- namespace: r,
212
- scope: o ?? this._scope,
213
- source: this._source
214
- }, i = [];
215
- for (const c of this._listeners)
216
- try {
217
- c.filter(p) && i.push(c);
218
- } catch (l) {
219
- console.error("Error in trace listener filter:", l);
220
- }
221
- return { matched: i, metadata: p };
222
- }
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
- return;
228
- }
229
- const h = {
230
- ...l,
231
- ...i !== void 0 && { error: i },
232
- ...o !== void 0 && { payload: this.resolveAndRedact(o) },
233
- timestamp: Date.now()
234
- };
235
- for (const a of c)
236
- try {
237
- a.handler(h);
238
- } catch (n) {
239
- console.error("Error in trace listener:", n);
240
- }
241
- }
242
- }
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
- );
252
- }
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(
316
- "%c%s",
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(`
336
- `);
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);
344
- const o = Array.isArray(e);
345
- if (o ? e.length === 0 : Object.keys(e).length === 0) {
346
- console.log(
347
- "%c%s",
348
- `color: ${S}; padding: 1px; margin-right: 5px; font-size: 10px`,
349
- `[ ${s} ] Empty`
350
- );
351
- return;
352
- }
353
- const c = {
354
- environment: "🍃 ",
355
- options: "🧮 ",
356
- store: "🏬 ",
357
- subscribers: "🧩 ",
358
- "hooks subscriptions": "🔗 "
359
- }[s] ?? "";
360
- let l = r ? [`${c}${s}`, r] : [`[ ${c}${s} ]`];
361
- if (q(t, ...l), o)
362
- K(e, t === "none" ? s : void 0, c);
363
- else {
364
- let h = [];
365
- Object.keys(e).forEach((a) => {
366
- if (a === "groupId")
367
- return;
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(
376
- "%c%s",
377
- "color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
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);
388
- else {
389
- const f = typeof n;
390
- console.log(
391
- "%c%s",
392
- "color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px",
393
- `[ ${a} ]`,
394
- f === "function" ? f : n
395
- );
396
- }
397
- }), h.length && console.log(
398
- "%c%s",
399
- "color: #f86f63; font-size: 9px",
400
- "[ Empty properties ]",
401
- h
402
- );
403
- }
404
- console.groupEnd();
405
- }
406
- function _(s) {
407
- Object.keys(s).forEach((e) => {
408
- if (["groupId", "label", "namespace", "scope", "source"].includes(e))
409
- return;
410
- const t = s[e];
411
- if (!t) {
412
- console.log(
413
- "%c%s",
414
- "color: #f86f63; padding: 1px; margin-right: 5px; font-size: 10px",
415
- `[ ${e} ] ${t}`
416
- );
417
- return;
418
- }
419
- switch (typeof t) {
420
- case "string":
421
- case "number":
422
- console.log(
423
- "%c%s",
424
- "color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px",
425
- `[ ${e} ]`,
426
- t
427
- );
428
- break;
429
- case "object":
430
- switch (e) {
431
- case "mutation":
432
- console.groupCollapsed("[mutation]"), console.dir(t), console.groupEnd();
433
- break;
434
- case "options":
435
- d(e, t?.storeOptions ?? t);
436
- break;
437
- case "payload":
438
- _(t);
439
- break;
440
- case "store":
441
- d(e, {
442
- $state: t.$state,
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), {})
444
- });
445
- break;
446
- case "subscribers":
447
- d(e, t.map(
448
- (r, o) => `${o > 0 ? `\r
449
- ` : " "}- ${r.name}`
450
- ));
451
- break;
452
- default:
453
- d(e, t);
454
- }
455
- break;
456
- case "function":
457
- console.dir(t);
458
- break;
459
- default:
460
- console.info(e, t);
461
- }
462
- });
463
- }
464
- function F(s, e, t) {
465
- if (!s)
466
- throw new Error("Style instructions are required");
467
- const r = e.shift(), o = e[0];
468
- if (!o?.payload || Object.keys(o.payload).length === 0) {
469
- console.log(
470
- "%c%s",
471
- s,
472
- `${o?.source === t ? o?.label ?? o?.namespace : r}`,
473
- o?.source
474
- );
475
- return;
476
- }
477
- console.groupCollapsed(
478
- "%c%s",
479
- s,
480
- `${r}
481
- `,
482
- o?.source
483
- ), e.forEach((p) => {
484
- switch (typeof p) {
485
- case "string":
486
- console.info(p);
487
- break;
488
- case "object":
489
- Array.isArray(p) ? console.table(p) : _(p);
490
- break;
491
- case "function":
492
- console.dir(p);
493
- break;
494
- default:
495
- console.info(p);
496
- }
497
- }), console.groupEnd();
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;
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
- );
516
- }
517
- class B extends W {
518
- constructor(t) {
519
- super();
520
- u(this, "_pluginName", E);
521
- t && (this._pluginName = t);
522
- }
523
- logGroup(t) {
524
- const o = t.shift()?.[1];
525
- console.groupCollapsed(
526
- "%c%s",
527
- "color: #87e47f; padding: 1px; margin-right: 5px; font-size: 11px; font-family: arial",
528
- `🍍 ${o?.label ?? o?.namespace}`,
529
- `[${o?.scope}]`
530
- ), o?.payload && _(o.payload), console.groupCollapsed(
531
- "%c%s",
532
- "color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px",
533
- "[ ✨ traces ]"
534
- ), t.forEach((p) => v(p[1])), console.groupEnd(), console.groupEnd();
535
- }
536
- useLog(t, r) {
537
- F(
538
- this.generateStyle(t),
539
- this.rebuildArgs(r),
540
- this._pluginName
541
- );
542
- }
543
- }
544
- function $(s) {
545
- const e = Object.keys(s).reduce((t, r) => (r !== "level" && r !== "timestamp" && (t[r] = s[r]), t), {});
546
- return [A(s), e];
547
- }
548
- function A(s) {
549
- return s.scope ? `${s.label} [${s.scope}]` : `${s.label}`;
550
- }
551
- function U(s, e) {
552
- const t = e.level === "error" ? "error" : "log";
553
- s[t](...$(e));
554
- }
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}"`);
564
- return;
565
- }
566
- const l = (r.get(i) ?? 1) - 1;
567
- if (l > 0) {
568
- r.set(i, l);
569
- return;
570
- }
571
- c.length && e.logGroup(c), t.delete(i), r.delete(i);
572
- }
573
- return {
574
- createGroup: o,
575
- logGroup: p,
576
- handler(i) {
577
- const c = i?.payload?.groupId ?? i[s];
578
- if (!t.has(c)) {
579
- U(e, i);
580
- return;
581
- }
582
- t.get(c)?.[0]?.[0] !== A(i) && t.get(c)?.push($(i));
583
- }
584
- };
585
- }
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))
589
- return !0;
590
- const c = r[p];
591
- if (typeof c != "string") return !1;
592
- let l = !1;
593
- switch (o) {
594
- case "equals":
595
- l = c === i;
596
- break;
597
- case "contains":
598
- l = c.includes(i);
599
- break;
600
- case "startsWith":
601
- l = c.startsWith(i);
602
- break;
603
- case "endsWith":
604
- l = c.endsWith(i);
605
- break;
606
- default:
607
- l = !1;
608
- break;
609
- }
610
- return l;
611
- });
612
- }
613
- function J(s, e = !0, t = "every", r = "scope") {
614
- return {
615
- groupBy: r,
616
- ...X(r),
617
- ...Q(s, e, t)
618
- };
619
- }
620
- function Q(s, e = !0, t = "every") {
621
- return Array.isArray(s) ? { filter: y(s, e, t) } : {
622
- ...s,
623
- filter: Array.isArray(s.filter) ? y(s.filter, e, t) : s.filter
624
- };
625
- }
626
- function Y(s) {
627
- return s?.source === E && (!s?.namespace || s.namespace.startsWith(L));
628
- }
629
- function Z() {
630
- try {
631
- return process.env.NODE_ENV === "production";
632
- } catch {
633
- return !1;
634
- }
635
- }
636
- const ee = "[REDACTED]", te = [
637
- /pass(word|wd|phrase|code)|^pwd/i,
638
- /secret/i,
639
- /token/i,
640
- /authorization/i,
641
- /api[-_]?key/i,
642
- /(private|encryption|signing|secret)[-_]?key/i,
643
- /credential/i,
644
- /cookie/i,
645
- /cipher/i
646
- ], re = 12;
647
- function se(s) {
648
- const e = /* @__PURE__ */ new Set(), t = [];
649
- for (const r of s)
650
- typeof r == "string" ? e.add(r.toLowerCase()) : t.push(new RegExp(r.source, r.flags.replace(/[gy]/g, "")));
651
- return (r) => e.has(r.toLowerCase()) || t.some((o) => o.test(r));
652
- }
653
- function oe(s) {
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);
655
- }
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)
665
- return "[MaxDepth]";
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;
671
- }
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;
675
- }
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;
679
- }
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, {
685
- configurable: !0,
686
- enumerable: !0,
687
- value: f,
688
- writable: !0
689
- });
690
- }
691
- return a;
692
- }
693
- return (i) => p(i, /* @__PURE__ */ new WeakMap(), 0);
694
- }
695
- const ie = () => {
696
- };
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" } = {}) {
700
- if (!s)
701
- return ie;
702
- const m = J(
703
- a,
704
- !!n,
705
- f ?? "every",
706
- g ?? "scope"
707
- );
708
- return r.push(m), () => {
709
- const x = r.indexOf(m);
710
- x !== -1 && r.splice(x, 1);
711
- };
712
- }
713
- function p(a, n = !0) {
714
- return o(
715
- a.map((f) => ({ target: "scope", value: f })),
716
- { context: n, filterMode: "some", groupBy: "scope" }
717
- );
718
- }
719
- function i() {
720
- r.length = 0;
721
- }
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
730
- };
731
- return r.filter((f) => f.filter(n));
732
- }
733
- function l() {
734
- return r.length > 0;
735
- }
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);
740
- });
741
- }
742
- return {
743
- addListener: o,
744
- addScopesListener: p,
745
- clearTraceListeners: i,
746
- tracerHandler: {
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)
751
- },
752
- hasTraceListeners: l
753
- };
754
- }
755
165
  export {
756
- pe as PluginSubscriber,
757
- de as PluginSubscription,
758
- M as Store,
759
- R as Tracer,
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
166
+ y as PluginSubscriber,
167
+ T as PluginSubscription,
168
+ l as Store,
169
+ A as createPluginSubscriber,
170
+ u as getDefineAStoreSetupContext,
171
+ p as isEmpty,
172
+ h as setEnhancedStore,
173
+ C as traceGroups
768
174
  };
769
- //# sourceMappingURL=helpers.js.map