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/CHANGELOG.md +1 -0
- package/dist/chunks/{PluginSubscription-DPu3ft-c.js → PluginSubscription-C_a6v8oi.js} +93 -77
- package/dist/chunks/PluginSubscription-C_a6v8oi.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers.js +308 -296
- package/dist/helpers.js.map +1 -1
- package/dist/pinia-plugin-subscription.js +2 -2
- package/dist/types/trace.d.ts +4 -0
- package/dist/utils/traceGroups.d.ts +7 -0
- package/docs/tracing.md +17 -0
- package/package.json +1 -1
- package/dist/chunks/PluginSubscription-DPu3ft-c.js.map +0 -1
package/dist/helpers.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var S = (r,
|
|
3
|
-
var
|
|
4
|
-
import { T as
|
|
5
|
-
import { P as
|
|
6
|
-
import { isRef as
|
|
7
|
-
class
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this._name =
|
|
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(
|
|
32
|
-
this._pluginOptions =
|
|
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(
|
|
47
|
-
this._subscriptions =
|
|
46
|
+
set subscriptions(t) {
|
|
47
|
+
this._subscriptions = t;
|
|
48
48
|
}
|
|
49
|
-
afterHydration(
|
|
49
|
+
afterHydration(t) {
|
|
50
50
|
}
|
|
51
|
-
hydrate(
|
|
51
|
+
hydrate(t) {
|
|
52
52
|
}
|
|
53
|
-
invoke({ store:
|
|
54
|
-
return this._storeInstance = this._createInstance(
|
|
55
|
-
...
|
|
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(
|
|
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
|
|
62
|
-
constructor(
|
|
61
|
+
class j extends $ {
|
|
62
|
+
constructor(e, s) {
|
|
63
63
|
super();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (this._options = s.storeOptions, this._store =
|
|
72
|
-
const o =
|
|
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(
|
|
84
|
-
this._onAction =
|
|
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(
|
|
93
|
-
this._store.$state =
|
|
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(
|
|
106
|
-
this._storeSubscribe =
|
|
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(
|
|
112
|
-
this.isOptionApi() ||
|
|
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(
|
|
115
|
-
this._subscriptions[
|
|
114
|
+
addSubscription(e, s, o) {
|
|
115
|
+
this._subscriptions[e] = { subscription: s, ...o ?? {} };
|
|
116
116
|
}
|
|
117
117
|
afterHydration() {
|
|
118
118
|
}
|
|
119
|
-
static customizeStore(
|
|
119
|
+
static customizeStore(e, s) {
|
|
120
120
|
if (s.storeOptions && this.hasRequiredKeys(s.storeOptions))
|
|
121
|
-
return new this(
|
|
121
|
+
return new this(e, s);
|
|
122
122
|
}
|
|
123
|
-
getOption(
|
|
124
|
-
return this.options && this.options[
|
|
123
|
+
getOption(e) {
|
|
124
|
+
return this.options && this.options[e];
|
|
125
125
|
}
|
|
126
|
-
getStatePropertyValue(
|
|
127
|
-
return this.getValue(this.state[
|
|
126
|
+
getStatePropertyValue(e) {
|
|
127
|
+
return this.getValue(this.state[e]);
|
|
128
128
|
}
|
|
129
129
|
getSubscriptions() {
|
|
130
|
-
if (!
|
|
130
|
+
if (!T(this._subscriptions))
|
|
131
131
|
return this._subscriptions;
|
|
132
132
|
}
|
|
133
|
-
getValue(
|
|
134
|
-
return
|
|
133
|
+
getValue(e) {
|
|
134
|
+
return e?.__v_isRef ? e.value : e;
|
|
135
135
|
}
|
|
136
|
-
hasDeniedFirstChar(
|
|
137
|
-
return
|
|
136
|
+
hasDeniedFirstChar(e) {
|
|
137
|
+
return w(e);
|
|
138
138
|
}
|
|
139
|
-
static hasRequiredKeys(
|
|
140
|
-
return this._requiredKeys !== void 0 && this._requiredKeys?.every((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(
|
|
145
|
-
this._createTracer =
|
|
144
|
+
initializeTracer(e) {
|
|
145
|
+
this._createTracer = e?.createTracer;
|
|
146
146
|
}
|
|
147
147
|
isOptionApi() {
|
|
148
148
|
return this.store._isOptionsAPI;
|
|
149
149
|
}
|
|
150
|
-
stateHas(
|
|
151
|
-
return Object.prototype.hasOwnProperty.call(this.state,
|
|
150
|
+
stateHas(e) {
|
|
151
|
+
return Object.prototype.hasOwnProperty.call(this.state, e);
|
|
152
152
|
}
|
|
153
|
-
storeHas(
|
|
154
|
-
return Object.prototype.hasOwnProperty.call(this.store,
|
|
153
|
+
storeHas(e) {
|
|
154
|
+
return Object.prototype.hasOwnProperty.call(this.store, e);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
function
|
|
157
|
+
p(j, "_requiredKeys");
|
|
158
|
+
function nt(r, t, e) {
|
|
159
159
|
return {
|
|
160
160
|
name: r,
|
|
161
|
-
invoke:
|
|
162
|
-
...
|
|
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 (
|
|
171
|
-
return { __tracePayloadError:
|
|
170
|
+
} catch (t) {
|
|
171
|
+
return { __tracePayloadError: t };
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
class
|
|
175
|
-
constructor(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
this._redactor = s.redactor, this._scope = s.scope, this._source =
|
|
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(
|
|
186
|
-
this._scope =
|
|
185
|
+
set scope(t) {
|
|
186
|
+
this._scope = t;
|
|
187
187
|
}
|
|
188
188
|
get source() {
|
|
189
189
|
return this._source;
|
|
190
190
|
}
|
|
191
|
-
debug(
|
|
192
|
-
this.emit("debug",
|
|
191
|
+
debug(t, e, s, o) {
|
|
192
|
+
this.emit("debug", t, e, s, o);
|
|
193
193
|
}
|
|
194
|
-
error(
|
|
195
|
-
this.emit("error",
|
|
194
|
+
error(t, e, s, o, c) {
|
|
195
|
+
this.emit("error", t, e, o, c, s);
|
|
196
196
|
}
|
|
197
|
-
resolveAndRedact(
|
|
198
|
-
const
|
|
199
|
-
if (!this._redactor ||
|
|
200
|
-
return
|
|
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(
|
|
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(
|
|
208
|
-
const
|
|
209
|
-
label:
|
|
210
|
-
level:
|
|
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
|
|
215
|
+
for (const n of this._listeners)
|
|
216
216
|
try {
|
|
217
|
-
|
|
218
|
-
} catch (
|
|
219
|
-
console.error("Error in trace listener filter:",
|
|
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:
|
|
221
|
+
return { matched: i, metadata: c };
|
|
222
222
|
}
|
|
223
|
-
emit(
|
|
224
|
-
const { matched:
|
|
225
|
-
if (!
|
|
226
|
-
|
|
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
|
|
230
|
-
...
|
|
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
|
|
235
|
+
for (const f of n)
|
|
236
236
|
try {
|
|
237
|
-
f.handler(
|
|
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
|
|
244
|
-
function g(r,
|
|
245
|
-
if (
|
|
246
|
-
console.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
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 (
|
|
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(
|
|
271
|
-
typeof
|
|
272
|
-
|
|
273
|
-
}) :
|
|
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
|
-
`[ ${
|
|
278
|
-
|
|
286
|
+
`[ ${a} ]`,
|
|
287
|
+
n
|
|
279
288
|
);
|
|
280
289
|
});
|
|
281
290
|
else {
|
|
282
|
-
let
|
|
283
|
-
Object.keys(
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
`[ ${
|
|
289
|
-
|
|
290
|
-
) :
|
|
291
|
-
}),
|
|
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
|
-
|
|
306
|
+
n
|
|
296
307
|
);
|
|
297
308
|
}
|
|
298
309
|
console.groupEnd();
|
|
299
310
|
}
|
|
300
|
-
function
|
|
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((
|
|
314
|
-
if (["label", "namespace", "scope", "source"].includes(
|
|
324
|
+
Object.keys(r).forEach((t) => {
|
|
325
|
+
if (["groupId", "label", "namespace", "scope", "source"].includes(t))
|
|
315
326
|
return;
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
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
|
-
`[ ${
|
|
332
|
+
`[ ${t} ] ${e}`
|
|
322
333
|
);
|
|
323
334
|
return;
|
|
324
335
|
}
|
|
325
|
-
switch (typeof
|
|
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
|
-
`[ ${
|
|
331
|
-
|
|
341
|
+
`[ ${t} ]`,
|
|
342
|
+
e
|
|
332
343
|
);
|
|
333
344
|
break;
|
|
334
345
|
case "object":
|
|
335
|
-
switch (
|
|
346
|
+
switch (t) {
|
|
336
347
|
case "mutation":
|
|
337
|
-
console.groupCollapsed("[mutation]"), console.dir(
|
|
348
|
+
console.groupCollapsed("[mutation]"), console.dir(e), console.groupEnd();
|
|
338
349
|
break;
|
|
339
350
|
case "options":
|
|
340
|
-
g(
|
|
351
|
+
g(t, e?.storeOptions ?? e);
|
|
341
352
|
break;
|
|
342
353
|
case "payload":
|
|
343
|
-
_(
|
|
354
|
+
_(e);
|
|
344
355
|
break;
|
|
345
356
|
case "store":
|
|
346
|
-
g(
|
|
347
|
-
$state:
|
|
348
|
-
$actions: Object.keys(
|
|
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(
|
|
363
|
+
g(t, e);
|
|
353
364
|
}
|
|
354
365
|
break;
|
|
355
366
|
case "function":
|
|
356
|
-
console.dir(
|
|
367
|
+
console.dir(e);
|
|
357
368
|
break;
|
|
358
369
|
default:
|
|
359
|
-
console.info(
|
|
370
|
+
console.info(e);
|
|
360
371
|
}
|
|
361
372
|
});
|
|
362
373
|
}
|
|
363
|
-
function
|
|
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
|
-
|
|
370
|
-
...
|
|
380
|
+
t.shift(),
|
|
381
|
+
...t
|
|
371
382
|
);
|
|
372
383
|
}
|
|
373
|
-
function
|
|
384
|
+
function N(r, t, e) {
|
|
374
385
|
if (!r)
|
|
375
386
|
throw new Error("Style instructions are required");
|
|
376
|
-
const s =
|
|
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 ===
|
|
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
|
-
),
|
|
393
|
-
switch (typeof
|
|
403
|
+
), t.forEach((c) => {
|
|
404
|
+
switch (typeof c) {
|
|
394
405
|
case "string":
|
|
395
|
-
console.info(
|
|
406
|
+
console.info(c);
|
|
396
407
|
break;
|
|
397
408
|
case "object":
|
|
398
|
-
Array.isArray(
|
|
409
|
+
Array.isArray(c) ? console.table(c) : _(c);
|
|
399
410
|
break;
|
|
400
411
|
case "function":
|
|
401
|
-
console.dir(
|
|
412
|
+
console.dir(c);
|
|
402
413
|
break;
|
|
403
414
|
default:
|
|
404
|
-
console.info(
|
|
415
|
+
console.info(c);
|
|
405
416
|
}
|
|
406
417
|
}), console.groupEnd();
|
|
407
418
|
}
|
|
408
|
-
class
|
|
419
|
+
class W {
|
|
409
420
|
constructor() {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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(
|
|
423
|
-
return this._pluginName ? ` [${
|
|
424
|
-
${
|
|
425
|
-
` :
|
|
433
|
+
formatMessage(t, e) {
|
|
434
|
+
return this._pluginName ? ` [${e} ${this._pluginName}]
|
|
435
|
+
${t}
|
|
436
|
+
` : t;
|
|
426
437
|
}
|
|
427
|
-
generateStyle(
|
|
428
|
-
return
|
|
438
|
+
generateStyle(t) {
|
|
439
|
+
return P(t.bgColor, t.color);
|
|
429
440
|
}
|
|
430
|
-
getStyleDefinition(
|
|
431
|
-
return this._styles[
|
|
441
|
+
getStyleDefinition(t) {
|
|
442
|
+
return this._styles[t ?? "info"];
|
|
432
443
|
}
|
|
433
|
-
log(...
|
|
444
|
+
log(...t) {
|
|
434
445
|
this.useLog(
|
|
435
446
|
this.getStyleDefinition(),
|
|
436
|
-
|
|
447
|
+
t
|
|
437
448
|
);
|
|
438
449
|
}
|
|
439
|
-
error(...
|
|
450
|
+
error(...t) {
|
|
440
451
|
this.useLog(
|
|
441
452
|
this.getStyleDefinition("error"),
|
|
442
|
-
|
|
453
|
+
t
|
|
443
454
|
);
|
|
444
455
|
}
|
|
445
|
-
rebuildArgs(
|
|
446
|
-
return typeof
|
|
456
|
+
rebuildArgs(t) {
|
|
457
|
+
return typeof t == "string" ? [t] : Array.isArray(t) ? [t.shift(), ...t] : [t];
|
|
447
458
|
}
|
|
448
|
-
useLog(
|
|
449
|
-
|
|
450
|
-
this.generateStyle(
|
|
451
|
-
this.rebuildArgs(
|
|
459
|
+
useLog(t, e) {
|
|
460
|
+
D(
|
|
461
|
+
this.generateStyle(t),
|
|
462
|
+
this.rebuildArgs(e)
|
|
452
463
|
);
|
|
453
464
|
}
|
|
454
465
|
}
|
|
455
|
-
class
|
|
456
|
-
constructor(
|
|
466
|
+
class q extends W {
|
|
467
|
+
constructor(e) {
|
|
457
468
|
super();
|
|
458
|
-
|
|
459
|
-
|
|
469
|
+
p(this, "_pluginName", x);
|
|
470
|
+
e && (this._pluginName = e);
|
|
460
471
|
}
|
|
461
|
-
logGroup(
|
|
462
|
-
const o =
|
|
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
|
-
),
|
|
483
|
+
), e.forEach((c) => G(c[1])), console.groupEnd(), console.groupEnd();
|
|
473
484
|
}
|
|
474
|
-
useLog(
|
|
475
|
-
|
|
476
|
-
this.generateStyle(
|
|
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
|
|
483
|
-
const
|
|
484
|
-
return [
|
|
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
|
|
497
|
+
function K(r) {
|
|
487
498
|
return r.scope ? `${r.label} [${r.scope}]` : `${r.label}`;
|
|
488
499
|
}
|
|
489
|
-
function
|
|
490
|
-
const
|
|
491
|
-
r[
|
|
500
|
+
function F(r, t) {
|
|
501
|
+
const e = t.level === "error" ? "error" : "log";
|
|
502
|
+
r[e](...E(t));
|
|
492
503
|
}
|
|
493
|
-
function
|
|
494
|
-
const
|
|
495
|
-
function s(
|
|
496
|
-
|
|
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(
|
|
499
|
-
const i =
|
|
509
|
+
function o(c) {
|
|
510
|
+
const i = e.get(c);
|
|
500
511
|
if (!i) {
|
|
501
|
-
|
|
512
|
+
t.error(`No group found for key "${c}"`);
|
|
502
513
|
return;
|
|
503
514
|
}
|
|
504
|
-
i.length &&
|
|
515
|
+
i.length && t.logGroup(i), e.delete(c);
|
|
505
516
|
}
|
|
506
517
|
return {
|
|
507
518
|
createGroup: s,
|
|
508
519
|
logGroup: o,
|
|
509
|
-
handler(
|
|
510
|
-
const i =
|
|
511
|
-
if (!
|
|
512
|
-
|
|
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
|
-
|
|
526
|
+
e.get(i)?.push(E(c));
|
|
516
527
|
}
|
|
517
528
|
};
|
|
518
529
|
}
|
|
519
|
-
function
|
|
520
|
-
return (s) => r[
|
|
521
|
-
if (
|
|
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
|
|
524
|
-
if (typeof
|
|
525
|
-
let
|
|
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
|
-
|
|
539
|
+
a = n === i;
|
|
529
540
|
break;
|
|
530
541
|
case "contains":
|
|
531
|
-
|
|
542
|
+
a = n.includes(i);
|
|
532
543
|
break;
|
|
533
544
|
case "startsWith":
|
|
534
|
-
|
|
545
|
+
a = n.startsWith(i);
|
|
535
546
|
break;
|
|
536
547
|
case "endsWith":
|
|
537
|
-
|
|
548
|
+
a = n.endsWith(i);
|
|
538
549
|
break;
|
|
539
550
|
default:
|
|
540
|
-
|
|
551
|
+
a = !1;
|
|
541
552
|
break;
|
|
542
553
|
}
|
|
543
|
-
return
|
|
554
|
+
return a;
|
|
544
555
|
});
|
|
545
556
|
}
|
|
546
|
-
function
|
|
557
|
+
function V(r, t = !0, e = "every", s = "scope") {
|
|
547
558
|
return {
|
|
548
559
|
groupBy: s,
|
|
549
|
-
...
|
|
550
|
-
...
|
|
560
|
+
...H(s),
|
|
561
|
+
...U(r, t, e)
|
|
551
562
|
};
|
|
552
563
|
}
|
|
553
|
-
function
|
|
554
|
-
return Array.isArray(r) ? { filter:
|
|
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) ?
|
|
567
|
+
filter: Array.isArray(r.filter) ? m(r.filter, t, e) : r.filter
|
|
557
568
|
};
|
|
558
569
|
}
|
|
559
|
-
function
|
|
560
|
-
return r?.source ===
|
|
570
|
+
function B(r) {
|
|
571
|
+
return r?.source === x && (!r?.namespace || r.namespace.startsWith(k));
|
|
561
572
|
}
|
|
562
|
-
function
|
|
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
|
|
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
|
-
],
|
|
580
|
-
function
|
|
581
|
-
const
|
|
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" ?
|
|
584
|
-
return (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
|
|
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
|
|
590
|
-
const { includeDefaults:
|
|
591
|
-
function
|
|
592
|
-
if (!
|
|
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
|
|
595
|
-
if (
|
|
596
|
-
return
|
|
597
|
-
if (
|
|
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
|
|
602
|
-
l.set(d, typeof d == "string" && o(d) ? s :
|
|
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
|
|
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
|
|
622
|
+
return n.set(i, l), i.forEach((h) => l.push(c(h, n, a + 1))), l;
|
|
612
623
|
}
|
|
613
624
|
const f = {};
|
|
614
|
-
|
|
625
|
+
n.set(i, f);
|
|
615
626
|
for (const l of Object.keys(i))
|
|
616
|
-
f[l] = o(l) ? s :
|
|
627
|
+
f[l] = o(l) ? s : c(i[l], n, a + 1);
|
|
617
628
|
return f;
|
|
618
629
|
}
|
|
619
|
-
return (i) =>
|
|
630
|
+
return (i) => c(i, /* @__PURE__ */ new WeakMap(), 0);
|
|
620
631
|
}
|
|
621
|
-
const
|
|
632
|
+
const et = () => {
|
|
622
633
|
};
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
function o(
|
|
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
|
|
628
|
-
const d =
|
|
629
|
-
|
|
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
|
|
650
|
+
function c() {
|
|
640
651
|
s.length = 0;
|
|
641
652
|
}
|
|
642
|
-
function i(
|
|
643
|
-
return s.filter((f) => f.filter(
|
|
653
|
+
function i(u) {
|
|
654
|
+
return s.filter((f) => f.filter(u));
|
|
644
655
|
}
|
|
645
|
-
function
|
|
656
|
+
function n() {
|
|
646
657
|
return s.length > 0;
|
|
647
658
|
}
|
|
648
|
-
function u
|
|
659
|
+
function a(u, f) {
|
|
649
660
|
s.length && i(f).forEach((l) => {
|
|
650
|
-
const h = f[l.groupBy];
|
|
651
|
-
typeof h == "string" && l[
|
|
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:
|
|
667
|
+
clearTraceListeners: c,
|
|
657
668
|
tracerHandler: {
|
|
658
|
-
closeGroup: (
|
|
659
|
-
createTracer: (
|
|
660
|
-
startGroup: (
|
|
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:
|
|
673
|
+
hasTraceListeners: n
|
|
663
674
|
};
|
|
664
675
|
}
|
|
665
676
|
export {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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
|