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/CHANGELOG.md +17 -5
- package/README.md +2 -0
- package/dist/chunks/{PluginSubscription-BbN48iuP.js → PluginSubscription-Bkqj4uSK.js} +189 -163
- package/dist/chunks/PluginSubscription-Bkqj4uSK.js.map +1 -0
- package/dist/core/PluginSubscription.d.ts +8 -0
- package/dist/helpers.js +326 -303
- package/dist/helpers.js.map +1 -1
- package/dist/pinia-plugin-subscription.js +2 -2
- package/dist/system/log/console-group.d.ts +8 -0
- package/dist/system/{log.d.ts → log/console.d.ts} +1 -11
- package/dist/system/log/index.d.ts +2 -0
- package/dist/system/log/log-trace.d.ts +8 -0
- package/dist/system/log/print-array.d.ts +7 -0
- package/dist/system/log/print-error.d.ts +6 -0
- package/dist/system/log/print-object.d.ts +1 -0
- package/dist/system/log/print-trace-payload.d.ts +1 -0
- package/dist/system/log/print-trace.d.ts +9 -0
- package/dist/system/log/trace-console.d.ts +9 -0
- package/dist/types/plugin.d.ts +7 -0
- package/dist/utils/store.d.ts +4 -1
- package/docs/authoring-plugins.md +22 -5
- package/docs/tracing.md +2 -0
- package/docs/using-plugins.md +12 -0
- package/package.json +3 -1
- package/dist/chunks/PluginSubscription-BbN48iuP.js.map +0 -1
package/dist/helpers.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (s, e, t) =>
|
|
4
|
-
import { T as
|
|
5
|
-
import { P as
|
|
6
|
-
import { isRef as b, ref as
|
|
7
|
-
class
|
|
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
|
|
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 =
|
|
73
|
-
o && (
|
|
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 =
|
|
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 (!
|
|
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
|
|
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(
|
|
158
|
-
function
|
|
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
|
|
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,
|
|
195
|
-
this.emit("error", e, t, o,
|
|
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 =
|
|
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
|
|
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
|
-
},
|
|
215
|
-
for (const
|
|
214
|
+
}, i = [];
|
|
215
|
+
for (const c of this._listeners)
|
|
216
216
|
try {
|
|
217
|
-
|
|
218
|
-
} catch (
|
|
219
|
-
console.error("Error in trace listener filter:",
|
|
217
|
+
c.filter(p) && i.push(c);
|
|
218
|
+
} catch (l) {
|
|
219
|
+
console.error("Error in trace listener filter:", l);
|
|
220
220
|
}
|
|
221
|
-
return { matched:
|
|
221
|
+
return { matched: i, metadata: p };
|
|
222
222
|
}
|
|
223
|
-
emit(e, t, r, o,
|
|
224
|
-
const { matched:
|
|
225
|
-
if (!
|
|
226
|
-
e === "error" && console.error("Unhandled error trace event:",
|
|
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
|
|
230
|
-
...
|
|
231
|
-
...
|
|
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
|
|
235
|
+
for (const a of c)
|
|
236
236
|
try {
|
|
237
|
-
|
|
238
|
-
} catch (
|
|
239
|
-
console.error("Error in trace listener:",
|
|
237
|
+
a.handler(h);
|
|
238
|
+
} catch (n) {
|
|
239
|
+
console.error("Error in trace listener:", n);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
254
|
-
`[ ${
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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: ${
|
|
348
|
+
`color: ${S}; padding: 1px; margin-right: 5px; font-size: 10px`,
|
|
268
349
|
`[ ${s} ] Empty`
|
|
269
350
|
);
|
|
270
351
|
return;
|
|
271
352
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
|
306
|
-
Object.keys(e).forEach((
|
|
307
|
-
if (
|
|
364
|
+
let h = [];
|
|
365
|
+
Object.keys(e).forEach((a) => {
|
|
366
|
+
if (a === "groupId")
|
|
308
367
|
return;
|
|
309
|
-
const
|
|
310
|
-
if (typeof
|
|
311
|
-
Array.isArray(
|
|
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
|
-
`[ ${
|
|
315
|
-
b(
|
|
316
|
-
) :
|
|
317
|
-
|
|
318
|
-
|
|
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
|
|
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
|
-
`[ ${
|
|
325
|
-
|
|
393
|
+
`[ ${a} ]`,
|
|
394
|
+
f === "function" ? f : n
|
|
326
395
|
);
|
|
327
396
|
}
|
|
328
|
-
}),
|
|
397
|
+
}), h.length && console.log(
|
|
329
398
|
"%c%s",
|
|
330
399
|
"color: #f86f63; font-size: 9px",
|
|
331
400
|
"[ Empty properties ]",
|
|
332
|
-
|
|
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
|
|
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((
|
|
432
|
-
switch (typeof
|
|
483
|
+
), e.forEach((p) => {
|
|
484
|
+
switch (typeof p) {
|
|
433
485
|
case "string":
|
|
434
|
-
console.info(
|
|
486
|
+
console.info(p);
|
|
435
487
|
break;
|
|
436
488
|
case "object":
|
|
437
|
-
Array.isArray(
|
|
489
|
+
Array.isArray(p) ? console.table(p) : _(p);
|
|
438
490
|
break;
|
|
439
491
|
case "function":
|
|
440
|
-
console.dir(
|
|
492
|
+
console.dir(p);
|
|
441
493
|
break;
|
|
442
494
|
default:
|
|
443
|
-
console.info(
|
|
495
|
+
console.info(p);
|
|
444
496
|
}
|
|
445
497
|
}), console.groupEnd();
|
|
446
498
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
|
517
|
+
class B extends W {
|
|
495
518
|
constructor(t) {
|
|
496
519
|
super();
|
|
497
|
-
u(this, "_pluginName",
|
|
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((
|
|
534
|
+
), t.forEach((p) => v(p[1])), console.groupEnd(), console.groupEnd();
|
|
512
535
|
}
|
|
513
536
|
useLog(t, r) {
|
|
514
|
-
|
|
537
|
+
F(
|
|
515
538
|
this.generateStyle(t),
|
|
516
539
|
this.rebuildArgs(r),
|
|
517
540
|
this._pluginName
|
|
518
541
|
);
|
|
519
542
|
}
|
|
520
543
|
}
|
|
521
|
-
function
|
|
544
|
+
function $(s) {
|
|
522
545
|
const e = Object.keys(s).reduce((t, r) => (r !== "level" && r !== "timestamp" && (t[r] = s[r]), t), {});
|
|
523
|
-
return [
|
|
546
|
+
return [A(s), e];
|
|
524
547
|
}
|
|
525
|
-
function
|
|
548
|
+
function A(s) {
|
|
526
549
|
return s.scope ? `${s.label} [${s.scope}]` : `${s.label}`;
|
|
527
550
|
}
|
|
528
|
-
function
|
|
551
|
+
function U(s, e) {
|
|
529
552
|
const t = e.level === "error" ? "error" : "log";
|
|
530
|
-
s[t](
|
|
553
|
+
s[t](...$(e));
|
|
531
554
|
}
|
|
532
|
-
function
|
|
533
|
-
const e = new
|
|
534
|
-
function o(
|
|
535
|
-
t.has(
|
|
536
|
-
}
|
|
537
|
-
function
|
|
538
|
-
const
|
|
539
|
-
if (!
|
|
540
|
-
e.error(`No group found for key "${
|
|
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
|
|
544
|
-
if (
|
|
545
|
-
r.set(
|
|
566
|
+
const l = (r.get(i) ?? 1) - 1;
|
|
567
|
+
if (l > 0) {
|
|
568
|
+
r.set(i, l);
|
|
546
569
|
return;
|
|
547
570
|
}
|
|
548
|
-
|
|
571
|
+
c.length && e.logGroup(c), t.delete(i), r.delete(i);
|
|
549
572
|
}
|
|
550
573
|
return {
|
|
551
574
|
createGroup: o,
|
|
552
|
-
logGroup:
|
|
553
|
-
handler(
|
|
554
|
-
const
|
|
555
|
-
if (!t.has(
|
|
556
|
-
|
|
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(
|
|
582
|
+
t.get(c)?.[0]?.[0] !== A(i) && t.get(c)?.push($(i));
|
|
560
583
|
}
|
|
561
584
|
};
|
|
562
585
|
}
|
|
563
|
-
function
|
|
564
|
-
return (r) => s[t](({ comparator: o = "equals", target:
|
|
565
|
-
if (
|
|
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
|
|
568
|
-
if (typeof
|
|
569
|
-
let
|
|
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
|
-
|
|
595
|
+
l = c === i;
|
|
573
596
|
break;
|
|
574
597
|
case "contains":
|
|
575
|
-
|
|
598
|
+
l = c.includes(i);
|
|
576
599
|
break;
|
|
577
600
|
case "startsWith":
|
|
578
|
-
|
|
601
|
+
l = c.startsWith(i);
|
|
579
602
|
break;
|
|
580
603
|
case "endsWith":
|
|
581
|
-
|
|
604
|
+
l = c.endsWith(i);
|
|
582
605
|
break;
|
|
583
606
|
default:
|
|
584
|
-
|
|
607
|
+
l = !1;
|
|
585
608
|
break;
|
|
586
609
|
}
|
|
587
|
-
return
|
|
610
|
+
return l;
|
|
588
611
|
});
|
|
589
612
|
}
|
|
590
|
-
function
|
|
613
|
+
function J(s, e = !0, t = "every", r = "scope") {
|
|
591
614
|
return {
|
|
592
615
|
groupBy: r,
|
|
593
|
-
...
|
|
594
|
-
...
|
|
616
|
+
...X(r),
|
|
617
|
+
...Q(s, e, t)
|
|
595
618
|
};
|
|
596
619
|
}
|
|
597
|
-
function
|
|
598
|
-
return Array.isArray(s) ? { filter:
|
|
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) ?
|
|
623
|
+
filter: Array.isArray(s.filter) ? y(s.filter, e, t) : s.filter
|
|
601
624
|
};
|
|
602
625
|
}
|
|
603
|
-
function
|
|
604
|
-
return s?.source ===
|
|
626
|
+
function Y(s) {
|
|
627
|
+
return s?.source === E && (!s?.namespace || s.namespace.startsWith(L));
|
|
605
628
|
}
|
|
606
|
-
function
|
|
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
|
|
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
|
-
],
|
|
624
|
-
function
|
|
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
|
|
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
|
|
634
|
-
const { includeDefaults: e = !0, keys: t = [], replacement: r =
|
|
635
|
-
function
|
|
636
|
-
if (!
|
|
637
|
-
return
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
640
|
-
return
|
|
641
|
-
if (
|
|
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 (
|
|
644
|
-
const
|
|
645
|
-
return
|
|
646
|
-
|
|
647
|
-
}),
|
|
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 (
|
|
650
|
-
const
|
|
651
|
-
return
|
|
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(
|
|
654
|
-
const
|
|
655
|
-
return
|
|
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
|
|
658
|
-
|
|
659
|
-
for (const
|
|
660
|
-
const
|
|
661
|
-
Object.defineProperty(
|
|
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:
|
|
687
|
+
value: f,
|
|
665
688
|
writable: !0
|
|
666
689
|
});
|
|
667
690
|
}
|
|
668
|
-
return
|
|
691
|
+
return a;
|
|
669
692
|
}
|
|
670
|
-
return (
|
|
693
|
+
return (i) => p(i, /* @__PURE__ */ new WeakMap(), 0);
|
|
671
694
|
}
|
|
672
|
-
const
|
|
695
|
+
const ie = () => {
|
|
673
696
|
};
|
|
674
|
-
function
|
|
675
|
-
const t = e ?
|
|
676
|
-
function o(
|
|
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
|
|
679
|
-
const m =
|
|
680
|
-
|
|
681
|
-
!!
|
|
682
|
-
|
|
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
|
|
687
|
-
|
|
709
|
+
const x = r.indexOf(m);
|
|
710
|
+
x !== -1 && r.splice(x, 1);
|
|
688
711
|
};
|
|
689
712
|
}
|
|
690
|
-
function
|
|
713
|
+
function p(a, n = !0) {
|
|
691
714
|
return o(
|
|
692
|
-
|
|
693
|
-
{ context:
|
|
715
|
+
a.map((f) => ({ target: "scope", value: f })),
|
|
716
|
+
{ context: n, filterMode: "some", groupBy: "scope" }
|
|
694
717
|
);
|
|
695
718
|
}
|
|
696
|
-
function
|
|
719
|
+
function i() {
|
|
697
720
|
r.length = 0;
|
|
698
721
|
}
|
|
699
|
-
function a
|
|
700
|
-
const
|
|
701
|
-
groupId:
|
|
702
|
-
label:
|
|
703
|
-
level:
|
|
704
|
-
namespace:
|
|
705
|
-
scope:
|
|
706
|
-
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((
|
|
731
|
+
return r.filter((f) => f.filter(n));
|
|
709
732
|
}
|
|
710
|
-
function
|
|
733
|
+
function l() {
|
|
711
734
|
return r.length > 0;
|
|
712
735
|
}
|
|
713
|
-
function
|
|
714
|
-
r.length &&
|
|
715
|
-
const g =
|
|
716
|
-
typeof g == "string" &&
|
|
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:
|
|
722
|
-
clearTraceListeners:
|
|
744
|
+
addScopesListener: p,
|
|
745
|
+
clearTraceListeners: i,
|
|
723
746
|
tracerHandler: {
|
|
724
|
-
closeGroup: (
|
|
725
|
-
createTracer: (
|
|
726
|
-
hasTraceListeners:
|
|
727
|
-
startGroup: (
|
|
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:
|
|
752
|
+
hasTraceListeners: l
|
|
730
753
|
};
|
|
731
754
|
}
|
|
732
755
|
export {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
756
|
+
pe as PluginSubscriber,
|
|
757
|
+
de as PluginSubscription,
|
|
758
|
+
M as Store,
|
|
736
759
|
R as Tracer,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|