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