@yoltra/devtools-ui 0.3.0 → 0.5.0
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/README.es.md +1 -1
- package/README.md +1 -1
- package/dist/devtools-ui.cjs +23 -0
- package/dist/devtools-ui.cjs.map +1 -0
- package/dist/devtools-ui.mjs +885 -0
- package/dist/devtools-ui.mjs.map +1 -0
- package/dist/types/context/HubContext.d.ts +1 -1
- package/dist/types/context/HubProvider.d.ts +2 -2
- package/dist/types/hooks/stateReplay.d.ts +53 -0
- package/dist/types/hooks/useEventLog.d.ts +1 -1
- package/dist/types/hooks/useEventReplay.d.ts +1 -1
- package/dist/types/hooks/useHubConnection.d.ts +1 -1
- package/dist/types/hooks/useStoreRegistry.d.ts +1 -1
- package/dist/types/hooks/useTimeTravel.d.ts +1 -1
- package/dist/types/index.d.ts +17 -17
- package/dist/types/types.d.ts +10 -0
- package/package.json +28 -15
- package/dist/devtools-ui.cjs.js +0 -7
- package/dist/devtools-ui.cjs.js.map +0 -1
- package/dist/devtools-ui.esm.js +0 -847
- package/dist/devtools-ui.esm.js.map +0 -1
package/dist/devtools-ui.esm.js
DELETED
|
@@ -1,847 +0,0 @@
|
|
|
1
|
-
import Re, { createContext as ve, useState as w, useRef as k, useCallback as b, useEffect as M, useContext as be, useMemo as Oe } from "react";
|
|
2
|
-
import { DevtoolsRole as v, PROTOCOL_VERSION as K } from "@yoltra/devtools-protocol";
|
|
3
|
-
const H = () => {
|
|
4
|
-
}, de = ve({
|
|
5
|
-
status: "disconnected",
|
|
6
|
-
send: H,
|
|
7
|
-
subscribe: () => H,
|
|
8
|
-
disconnect: H,
|
|
9
|
-
reconnect: H
|
|
10
|
-
});
|
|
11
|
-
var X = { exports: {} }, L = {};
|
|
12
|
-
var ie;
|
|
13
|
-
function _e() {
|
|
14
|
-
if (ie) return L;
|
|
15
|
-
ie = 1;
|
|
16
|
-
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
17
|
-
function n(o, r, c) {
|
|
18
|
-
var a = null;
|
|
19
|
-
if (c !== void 0 && (a = "" + c), r.key !== void 0 && (a = "" + r.key), "key" in r) {
|
|
20
|
-
c = {};
|
|
21
|
-
for (var i in r)
|
|
22
|
-
i !== "key" && (c[i] = r[i]);
|
|
23
|
-
} else c = r;
|
|
24
|
-
return r = c.ref, {
|
|
25
|
-
$$typeof: e,
|
|
26
|
-
type: o,
|
|
27
|
-
key: a,
|
|
28
|
-
ref: r !== void 0 ? r : null,
|
|
29
|
-
props: c
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return L.Fragment = s, L.jsx = n, L.jsxs = n, L;
|
|
33
|
-
}
|
|
34
|
-
var U = {};
|
|
35
|
-
var ae;
|
|
36
|
-
function ye() {
|
|
37
|
-
return ae || (ae = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
38
|
-
function e(t) {
|
|
39
|
-
if (t == null) return null;
|
|
40
|
-
if (typeof t == "function")
|
|
41
|
-
return t.$$typeof === Te ? null : t.displayName || t.name || null;
|
|
42
|
-
if (typeof t == "string") return t;
|
|
43
|
-
switch (t) {
|
|
44
|
-
case p:
|
|
45
|
-
return "Fragment";
|
|
46
|
-
case N:
|
|
47
|
-
return "Profiler";
|
|
48
|
-
case h:
|
|
49
|
-
return "StrictMode";
|
|
50
|
-
case A:
|
|
51
|
-
return "Suspense";
|
|
52
|
-
case P:
|
|
53
|
-
return "SuspenseList";
|
|
54
|
-
case Se:
|
|
55
|
-
return "Activity";
|
|
56
|
-
}
|
|
57
|
-
if (typeof t == "object")
|
|
58
|
-
switch (typeof t.tag == "number" && console.error(
|
|
59
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
60
|
-
), t.$$typeof) {
|
|
61
|
-
case I:
|
|
62
|
-
return "Portal";
|
|
63
|
-
case d:
|
|
64
|
-
return (t.displayName || "Context") + ".Provider";
|
|
65
|
-
case g:
|
|
66
|
-
return (t._context.displayName || "Context") + ".Consumer";
|
|
67
|
-
case R:
|
|
68
|
-
var u = t.render;
|
|
69
|
-
return t = t.displayName, t || (t = u.displayName || u.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
70
|
-
case x:
|
|
71
|
-
return u = t.displayName || null, u !== null ? u : e(t.type) || "Memo";
|
|
72
|
-
case V:
|
|
73
|
-
u = t._payload, t = t._init;
|
|
74
|
-
try {
|
|
75
|
-
return e(t(u));
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
function s(t) {
|
|
82
|
-
return "" + t;
|
|
83
|
-
}
|
|
84
|
-
function n(t) {
|
|
85
|
-
try {
|
|
86
|
-
s(t);
|
|
87
|
-
var u = !1;
|
|
88
|
-
} catch {
|
|
89
|
-
u = !0;
|
|
90
|
-
}
|
|
91
|
-
if (u) {
|
|
92
|
-
u = console;
|
|
93
|
-
var T = u.error, _ = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
94
|
-
return T.call(
|
|
95
|
-
u,
|
|
96
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
97
|
-
_
|
|
98
|
-
), s(t);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function o(t) {
|
|
102
|
-
if (t === p) return "<>";
|
|
103
|
-
if (typeof t == "object" && t !== null && t.$$typeof === V)
|
|
104
|
-
return "<...>";
|
|
105
|
-
try {
|
|
106
|
-
var u = e(t);
|
|
107
|
-
return u ? "<" + u + ">" : "<...>";
|
|
108
|
-
} catch {
|
|
109
|
-
return "<...>";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function r() {
|
|
113
|
-
var t = J.A;
|
|
114
|
-
return t === null ? null : t.getOwner();
|
|
115
|
-
}
|
|
116
|
-
function c() {
|
|
117
|
-
return Error("react-stack-top-frame");
|
|
118
|
-
}
|
|
119
|
-
function a(t) {
|
|
120
|
-
if (te.call(t, "key")) {
|
|
121
|
-
var u = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
122
|
-
if (u && u.isReactWarning) return !1;
|
|
123
|
-
}
|
|
124
|
-
return t.key !== void 0;
|
|
125
|
-
}
|
|
126
|
-
function i(t, u) {
|
|
127
|
-
function T() {
|
|
128
|
-
re || (re = !0, console.error(
|
|
129
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
130
|
-
u
|
|
131
|
-
));
|
|
132
|
-
}
|
|
133
|
-
T.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
134
|
-
get: T,
|
|
135
|
-
configurable: !0
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
function f() {
|
|
139
|
-
var t = e(this.type);
|
|
140
|
-
return ne[t] || (ne[t] = !0, console.error(
|
|
141
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
142
|
-
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
143
|
-
}
|
|
144
|
-
function l(t, u, T, _, D, C, W, G) {
|
|
145
|
-
return T = C.ref, t = {
|
|
146
|
-
$$typeof: O,
|
|
147
|
-
type: t,
|
|
148
|
-
key: u,
|
|
149
|
-
props: C,
|
|
150
|
-
_owner: D
|
|
151
|
-
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(t, "ref", {
|
|
152
|
-
enumerable: !1,
|
|
153
|
-
get: f
|
|
154
|
-
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
155
|
-
configurable: !1,
|
|
156
|
-
enumerable: !1,
|
|
157
|
-
writable: !0,
|
|
158
|
-
value: 0
|
|
159
|
-
}), Object.defineProperty(t, "_debugInfo", {
|
|
160
|
-
configurable: !1,
|
|
161
|
-
enumerable: !1,
|
|
162
|
-
writable: !0,
|
|
163
|
-
value: null
|
|
164
|
-
}), Object.defineProperty(t, "_debugStack", {
|
|
165
|
-
configurable: !1,
|
|
166
|
-
enumerable: !1,
|
|
167
|
-
writable: !0,
|
|
168
|
-
value: W
|
|
169
|
-
}), Object.defineProperty(t, "_debugTask", {
|
|
170
|
-
configurable: !1,
|
|
171
|
-
enumerable: !1,
|
|
172
|
-
writable: !0,
|
|
173
|
-
value: G
|
|
174
|
-
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
175
|
-
}
|
|
176
|
-
function E(t, u, T, _, D, C, W, G) {
|
|
177
|
-
var y = u.children;
|
|
178
|
-
if (y !== void 0)
|
|
179
|
-
if (_)
|
|
180
|
-
if (he(y)) {
|
|
181
|
-
for (_ = 0; _ < y.length; _++)
|
|
182
|
-
m(y[_]);
|
|
183
|
-
Object.freeze && Object.freeze(y);
|
|
184
|
-
} else
|
|
185
|
-
console.error(
|
|
186
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
187
|
-
);
|
|
188
|
-
else m(y);
|
|
189
|
-
if (te.call(u, "key")) {
|
|
190
|
-
y = e(t);
|
|
191
|
-
var Y = Object.keys(u).filter(function(me) {
|
|
192
|
-
return me !== "key";
|
|
193
|
-
});
|
|
194
|
-
_ = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ce[y + _] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
195
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
196
|
-
let props = %s;
|
|
197
|
-
<%s {...props} />
|
|
198
|
-
React keys must be passed directly to JSX without using spread:
|
|
199
|
-
let props = %s;
|
|
200
|
-
<%s key={someKey} {...props} />`,
|
|
201
|
-
_,
|
|
202
|
-
y,
|
|
203
|
-
Y,
|
|
204
|
-
y
|
|
205
|
-
), ce[y + _] = !0);
|
|
206
|
-
}
|
|
207
|
-
if (y = null, T !== void 0 && (n(T), y = "" + T), a(u) && (n(u.key), y = "" + u.key), "key" in u) {
|
|
208
|
-
T = {};
|
|
209
|
-
for (var B in u)
|
|
210
|
-
B !== "key" && (T[B] = u[B]);
|
|
211
|
-
} else T = u;
|
|
212
|
-
return y && i(
|
|
213
|
-
T,
|
|
214
|
-
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
215
|
-
), l(
|
|
216
|
-
t,
|
|
217
|
-
y,
|
|
218
|
-
C,
|
|
219
|
-
D,
|
|
220
|
-
r(),
|
|
221
|
-
T,
|
|
222
|
-
W,
|
|
223
|
-
G
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
function m(t) {
|
|
227
|
-
typeof t == "object" && t !== null && t.$$typeof === O && t._store && (t._store.validated = 1);
|
|
228
|
-
}
|
|
229
|
-
var S = Re, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), I = /* @__PURE__ */ Symbol.for("react.portal"), p = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), N = /* @__PURE__ */ Symbol.for("react.profiler"), g = /* @__PURE__ */ Symbol.for("react.consumer"), d = /* @__PURE__ */ Symbol.for("react.context"), R = /* @__PURE__ */ Symbol.for("react.forward_ref"), A = /* @__PURE__ */ Symbol.for("react.suspense"), P = /* @__PURE__ */ Symbol.for("react.suspense_list"), x = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), Se = /* @__PURE__ */ Symbol.for("react.activity"), Te = /* @__PURE__ */ Symbol.for("react.client.reference"), J = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, te = Object.prototype.hasOwnProperty, he = Array.isArray, q = console.createTask ? console.createTask : function() {
|
|
230
|
-
return null;
|
|
231
|
-
};
|
|
232
|
-
S = {
|
|
233
|
-
react_stack_bottom_frame: function(t) {
|
|
234
|
-
return t();
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
var re, ne = {}, se = S.react_stack_bottom_frame.bind(
|
|
238
|
-
S,
|
|
239
|
-
c
|
|
240
|
-
)(), oe = q(o(c)), ce = {};
|
|
241
|
-
U.Fragment = p, U.jsx = function(t, u, T, _, D) {
|
|
242
|
-
var C = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
243
|
-
return E(
|
|
244
|
-
t,
|
|
245
|
-
u,
|
|
246
|
-
T,
|
|
247
|
-
!1,
|
|
248
|
-
_,
|
|
249
|
-
D,
|
|
250
|
-
C ? Error("react-stack-top-frame") : se,
|
|
251
|
-
C ? q(o(t)) : oe
|
|
252
|
-
);
|
|
253
|
-
}, U.jsxs = function(t, u, T, _, D) {
|
|
254
|
-
var C = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
255
|
-
return E(
|
|
256
|
-
t,
|
|
257
|
-
u,
|
|
258
|
-
T,
|
|
259
|
-
!0,
|
|
260
|
-
_,
|
|
261
|
-
D,
|
|
262
|
-
C ? Error("react-stack-top-frame") : se,
|
|
263
|
-
C ? q(o(t)) : oe
|
|
264
|
-
);
|
|
265
|
-
};
|
|
266
|
-
})()), U;
|
|
267
|
-
}
|
|
268
|
-
var ue;
|
|
269
|
-
function Ne() {
|
|
270
|
-
return ue || (ue = 1, process.env.NODE_ENV === "production" ? X.exports = _e() : X.exports = ye()), X.exports;
|
|
271
|
-
}
|
|
272
|
-
var Ae = Ne();
|
|
273
|
-
const Ie = {
|
|
274
|
-
timeTravel: !0,
|
|
275
|
-
eventReplay: !0,
|
|
276
|
-
stateExplorer: !0,
|
|
277
|
-
eventEmit: !0,
|
|
278
|
-
performanceMetrics: !0
|
|
279
|
-
}, ke = 750, we = 3e4;
|
|
280
|
-
function Ye({
|
|
281
|
-
config: e,
|
|
282
|
-
children: s
|
|
283
|
-
}) {
|
|
284
|
-
const [n, o] = w("disconnected"), r = k(null), c = k(/* @__PURE__ */ new Set()), a = k(0), i = k(null), f = k(crypto.randomUUID()), l = k(e);
|
|
285
|
-
l.current = e;
|
|
286
|
-
const E = b(() => {
|
|
287
|
-
const h = l.current, g = `ws://${h.host ?? "localhost"}:${h.port}`, d = h.WebSocket ?? (typeof globalThis.WebSocket < "u" ? globalThis.WebSocket : void 0);
|
|
288
|
-
if (!d) {
|
|
289
|
-
console.error(
|
|
290
|
-
"[Yoltra DevTools] No WebSocket implementation available. In Node.js, pass { WebSocket } from 'ws' via config.WebSocket."
|
|
291
|
-
);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
o("connecting");
|
|
295
|
-
try {
|
|
296
|
-
const R = new d(g);
|
|
297
|
-
r.current = R, R.onopen = () => {
|
|
298
|
-
a.current = 0;
|
|
299
|
-
const A = JSON.stringify({
|
|
300
|
-
type: "HANDSHAKE_REQUEST",
|
|
301
|
-
protocolVersion: K,
|
|
302
|
-
role: v.EXTENSION,
|
|
303
|
-
extension: {
|
|
304
|
-
id: f.current,
|
|
305
|
-
name: h.extensionName ?? "DevTools UI",
|
|
306
|
-
capabilities: Ie
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
R.send(A);
|
|
310
|
-
}, R.onmessage = (A) => {
|
|
311
|
-
try {
|
|
312
|
-
const P = typeof A.data == "string" ? A.data : String(A.data), x = JSON.parse(P);
|
|
313
|
-
if (x.type === "HANDSHAKE_RESPONSE") {
|
|
314
|
-
x.success ? o("connected") : R.close();
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
c.current.forEach((V) => V(x));
|
|
318
|
-
} catch {
|
|
319
|
-
}
|
|
320
|
-
}, R.onclose = () => {
|
|
321
|
-
r.current = null, o("disconnected");
|
|
322
|
-
const A = h.autoReconnect ?? !0, P = h.maxReconnectAttempts ?? 1 / 0;
|
|
323
|
-
if (A && a.current < P) {
|
|
324
|
-
const x = a.current++, V = Math.min(
|
|
325
|
-
ke * Math.pow(2, x) + Math.random() * 500,
|
|
326
|
-
we
|
|
327
|
-
);
|
|
328
|
-
i.current = setTimeout(E, V);
|
|
329
|
-
}
|
|
330
|
-
}, R.onerror = () => {
|
|
331
|
-
};
|
|
332
|
-
} catch {
|
|
333
|
-
o("disconnected");
|
|
334
|
-
}
|
|
335
|
-
}, []), m = b(() => {
|
|
336
|
-
i.current && (clearTimeout(i.current), i.current = null), a.current = 1 / 0, r.current?.close(), r.current = null, o("disconnected");
|
|
337
|
-
}, []), S = b(() => {
|
|
338
|
-
a.current = 0, r.current?.close(), r.current = null, E();
|
|
339
|
-
}, [E]), O = b((h) => {
|
|
340
|
-
const N = r.current;
|
|
341
|
-
N && N.readyState === 1 && N.send(JSON.stringify(h));
|
|
342
|
-
}, []), I = b((h) => (c.current.add(h), () => {
|
|
343
|
-
c.current.delete(h);
|
|
344
|
-
}), []);
|
|
345
|
-
M(() => (E(), () => {
|
|
346
|
-
i.current && clearTimeout(i.current), a.current = 1 / 0, r.current?.close();
|
|
347
|
-
}), [E]);
|
|
348
|
-
const p = {
|
|
349
|
-
status: n,
|
|
350
|
-
send: O,
|
|
351
|
-
subscribe: I,
|
|
352
|
-
disconnect: m,
|
|
353
|
-
reconnect: S
|
|
354
|
-
};
|
|
355
|
-
return /* @__PURE__ */ Ae.jsx(de.Provider, { value: p, children: s });
|
|
356
|
-
}
|
|
357
|
-
function j() {
|
|
358
|
-
return be(de);
|
|
359
|
-
}
|
|
360
|
-
function Le(e) {
|
|
361
|
-
const { send: s } = j();
|
|
362
|
-
return { emit: b(
|
|
363
|
-
(o, r, c) => {
|
|
364
|
-
e && s({
|
|
365
|
-
type: "EMIT_TO_STORE",
|
|
366
|
-
storeId: e,
|
|
367
|
-
event: { channel: o, type: r, payload: c },
|
|
368
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
369
|
-
sourceId: "",
|
|
370
|
-
sourceRole: v.EXTENSION
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
[e, s]
|
|
374
|
-
) };
|
|
375
|
-
}
|
|
376
|
-
const xe = 2e3;
|
|
377
|
-
function Ue(e, s) {
|
|
378
|
-
const { subscribe: n } = j(), o = s?.maxEntries ?? xe, r = k(/* @__PURE__ */ new Map()), c = k(o);
|
|
379
|
-
c.current = o;
|
|
380
|
-
const [, a] = w(0);
|
|
381
|
-
M(() => n((E) => {
|
|
382
|
-
if (E.type !== "STORE_EVENT") return;
|
|
383
|
-
const m = E.storeId, S = {
|
|
384
|
-
event: E.event,
|
|
385
|
-
storeId: m,
|
|
386
|
-
patches: E.patches,
|
|
387
|
-
snapshotVersion: E.snapshotVersion,
|
|
388
|
-
committed: E.committed,
|
|
389
|
-
timestamp: E.timestamp
|
|
390
|
-
}, I = [...r.current.get(m) ?? [], S];
|
|
391
|
-
r.current.set(
|
|
392
|
-
m,
|
|
393
|
-
I.length > c.current ? I.slice(I.length - c.current) : I
|
|
394
|
-
), a((p) => p + 1);
|
|
395
|
-
}), [n]);
|
|
396
|
-
const i = b(() => {
|
|
397
|
-
e && (r.current.delete(e), a((l) => l + 1));
|
|
398
|
-
}, [e]);
|
|
399
|
-
return { entries: e ? r.current.get(e) ?? [] : [], clear: i };
|
|
400
|
-
}
|
|
401
|
-
function Fe(e) {
|
|
402
|
-
const { send: s } = j();
|
|
403
|
-
return { replay: b(
|
|
404
|
-
(o, r) => {
|
|
405
|
-
e && s({
|
|
406
|
-
type: "EVENT_REPLAY",
|
|
407
|
-
storeId: e,
|
|
408
|
-
snapshot: o,
|
|
409
|
-
events: r.map((c) => ({
|
|
410
|
-
id: c.event.id,
|
|
411
|
-
channel: c.event.channel,
|
|
412
|
-
type: c.event.type,
|
|
413
|
-
payload: c.event.payload
|
|
414
|
-
})),
|
|
415
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
416
|
-
sourceId: "",
|
|
417
|
-
sourceRole: v.EXTENSION
|
|
418
|
-
});
|
|
419
|
-
},
|
|
420
|
-
[e, s]
|
|
421
|
-
) };
|
|
422
|
-
}
|
|
423
|
-
function He(e, s) {
|
|
424
|
-
const { send: n, subscribe: o } = j(), [r, c] = w(null), [a, i] = w(!1), f = s?.refreshIntervalMs ?? 2e3, l = k(null), E = b(() => {
|
|
425
|
-
e && (i(!0), n({
|
|
426
|
-
type: "REQUEST_METRICS",
|
|
427
|
-
storeId: e,
|
|
428
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
429
|
-
sourceId: "",
|
|
430
|
-
sourceRole: v.EXTENSION
|
|
431
|
-
}));
|
|
432
|
-
}, [e, n]);
|
|
433
|
-
return M(() => {
|
|
434
|
-
if (!e) {
|
|
435
|
-
c(null);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
E();
|
|
439
|
-
const m = o((S) => {
|
|
440
|
-
S.type === "STORE_METRICS" && S.storeId === e && (c(S.metrics), i(!1));
|
|
441
|
-
});
|
|
442
|
-
return f > 0 && (l.current = setInterval(E, f)), () => {
|
|
443
|
-
m(), l.current && (clearInterval(l.current), l.current = null);
|
|
444
|
-
};
|
|
445
|
-
}, [e, o, E, f]), { metrics: r, loading: a, refresh: E };
|
|
446
|
-
}
|
|
447
|
-
function Xe() {
|
|
448
|
-
const { subscribe: e } = j(), [s, n] = w([]);
|
|
449
|
-
return M(() => e((r) => {
|
|
450
|
-
switch (r.type) {
|
|
451
|
-
case "STORE_REGISTRY":
|
|
452
|
-
n(r.stores);
|
|
453
|
-
break;
|
|
454
|
-
case "STORE_CONNECTED":
|
|
455
|
-
n((c) => c.some((i) => i.id === r.store.id) ? c.map(
|
|
456
|
-
(i) => i.id === r.store.id ? { ...i, status: "connected" } : i
|
|
457
|
-
) : [
|
|
458
|
-
...c,
|
|
459
|
-
{
|
|
460
|
-
id: r.store.id,
|
|
461
|
-
name: r.store.name,
|
|
462
|
-
status: "connected",
|
|
463
|
-
capabilities: r.store.capabilities,
|
|
464
|
-
connectedAt: r.timestamp
|
|
465
|
-
}
|
|
466
|
-
]);
|
|
467
|
-
break;
|
|
468
|
-
case "STORE_DISCONNECTED":
|
|
469
|
-
n(
|
|
470
|
-
(c) => c.map(
|
|
471
|
-
(a) => a.id === r.storeId ? { ...a, status: "disconnected" } : a
|
|
472
|
-
)
|
|
473
|
-
);
|
|
474
|
-
break;
|
|
475
|
-
}
|
|
476
|
-
}), [e]), s;
|
|
477
|
-
}
|
|
478
|
-
function Z(e, s) {
|
|
479
|
-
let n = structuredClone(e);
|
|
480
|
-
for (const o of s) {
|
|
481
|
-
const r = Ce(o.path);
|
|
482
|
-
switch (o.op) {
|
|
483
|
-
case "add":
|
|
484
|
-
n = ee(n, r, o.value, !0);
|
|
485
|
-
break;
|
|
486
|
-
case "replace":
|
|
487
|
-
n = ee(n, r, o.value, !1);
|
|
488
|
-
break;
|
|
489
|
-
case "remove":
|
|
490
|
-
n = pe(n, r);
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return n;
|
|
495
|
-
}
|
|
496
|
-
function Ce(e) {
|
|
497
|
-
return e === "" || e === "/" ? [] : e.slice(1).split("/").map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
498
|
-
}
|
|
499
|
-
const Ee = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
500
|
-
function ee(e, s, n, o) {
|
|
501
|
-
if (s.length === 0) return n;
|
|
502
|
-
const r = Array.isArray(e) ? [...e] : { ...e }, [c, ...a] = s;
|
|
503
|
-
if (Ee.has(c)) return r;
|
|
504
|
-
if (a.length === 0)
|
|
505
|
-
if (o && Array.isArray(r)) {
|
|
506
|
-
const i = c === "-" ? r.length : Number(c);
|
|
507
|
-
Number.isInteger(i) && i >= 0 && i <= r.length ? r.splice(i, 0, n) : r[c] = n;
|
|
508
|
-
} else
|
|
509
|
-
r[c] = n;
|
|
510
|
-
else
|
|
511
|
-
r[c] = ee(r[c] ?? {}, a, n, o);
|
|
512
|
-
return r;
|
|
513
|
-
}
|
|
514
|
-
function pe(e, s) {
|
|
515
|
-
if (s.length === 0) return;
|
|
516
|
-
const n = Array.isArray(e) ? [...e] : { ...e }, [o, ...r] = s;
|
|
517
|
-
return Ee.has(o) || (r.length === 0 ? Array.isArray(n) ? n.splice(Number(o), 1) : delete n[o] : n[o] = pe(n[o], r)), n;
|
|
518
|
-
}
|
|
519
|
-
function ge(e) {
|
|
520
|
-
const s = e.scheduler ?? {
|
|
521
|
-
setInterval: (r, c) => setInterval(r, c),
|
|
522
|
-
clearInterval: (r) => clearInterval(r)
|
|
523
|
-
};
|
|
524
|
-
let n = s.setInterval(() => {
|
|
525
|
-
if (e.isSettled()) {
|
|
526
|
-
o();
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
e.request();
|
|
530
|
-
}, e.intervalMs);
|
|
531
|
-
function o() {
|
|
532
|
-
n !== null && (s.clearInterval(n), n = null);
|
|
533
|
-
}
|
|
534
|
-
return o;
|
|
535
|
-
}
|
|
536
|
-
const Pe = 1500;
|
|
537
|
-
function $e(e) {
|
|
538
|
-
const { send: s, subscribe: n } = j(), [o, r] = w(null), [c, a] = w(0), [i, f] = w(!1), l = k(0), E = k([]), m = k(null), S = b(() => {
|
|
539
|
-
m.current?.(), m.current = null;
|
|
540
|
-
}, []), O = b(() => {
|
|
541
|
-
e && (f(!0), s({
|
|
542
|
-
type: "REQUEST_STATE",
|
|
543
|
-
storeId: e,
|
|
544
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
545
|
-
sourceId: "",
|
|
546
|
-
sourceRole: v.EXTENSION
|
|
547
|
-
}));
|
|
548
|
-
}, [e, s]);
|
|
549
|
-
return M(() => {
|
|
550
|
-
if (!e) {
|
|
551
|
-
r(null), a(0), l.current = 0;
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
O(), m.current = ge({
|
|
555
|
-
request: O,
|
|
556
|
-
isSettled: () => l.current !== 0,
|
|
557
|
-
intervalMs: Pe
|
|
558
|
-
});
|
|
559
|
-
const I = n((p) => {
|
|
560
|
-
if (p.type === "STATE_SNAPSHOT" && p.storeId === e) {
|
|
561
|
-
S(), r(p.state), a(p.version), l.current = p.version, f(!1);
|
|
562
|
-
const h = E.current.filter((N) => N.version > p.version).sort((N, g) => N.version - g.version);
|
|
563
|
-
if (E.current = [], h.length > 0) {
|
|
564
|
-
r((g) => {
|
|
565
|
-
let d = g;
|
|
566
|
-
for (const R of h)
|
|
567
|
-
d = Z(d, R.patches);
|
|
568
|
-
return d;
|
|
569
|
-
});
|
|
570
|
-
const N = h[h.length - 1].version;
|
|
571
|
-
a(N), l.current = N;
|
|
572
|
-
}
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
if (p.type === "STORE_EVENT" && p.storeId === e && p.committed) {
|
|
576
|
-
if (l.current === 0) {
|
|
577
|
-
E.current.push({
|
|
578
|
-
patches: p.patches,
|
|
579
|
-
version: p.snapshotVersion
|
|
580
|
-
});
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
if (p.snapshotVersion <= l.current)
|
|
584
|
-
return;
|
|
585
|
-
r((h) => Z(h, p.patches)), a(p.snapshotVersion), l.current = p.snapshotVersion;
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
return () => {
|
|
589
|
-
I(), S(), E.current = [];
|
|
590
|
-
};
|
|
591
|
-
}, [e, n, O, S]), { state: o, version: c, loading: i, refresh: O };
|
|
592
|
-
}
|
|
593
|
-
function Je(e) {
|
|
594
|
-
const { send: s, subscribe: n } = j(), [o, r] = w(null), [c, a] = w(!1), i = b(() => {
|
|
595
|
-
e && (a(!0), s({
|
|
596
|
-
type: "REQUEST_SUBSCRIPTIONS",
|
|
597
|
-
storeId: e,
|
|
598
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
599
|
-
sourceId: "",
|
|
600
|
-
sourceRole: v.EXTENSION
|
|
601
|
-
}));
|
|
602
|
-
}, [e, s]);
|
|
603
|
-
return M(() => {
|
|
604
|
-
if (!e) {
|
|
605
|
-
r(null);
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
return i(), n((l) => {
|
|
609
|
-
l.type === "STORE_SUBSCRIPTIONS" && l.storeId === e && (r({
|
|
610
|
-
atomic: l.atomic,
|
|
611
|
-
event: l.event,
|
|
612
|
-
coarse: l.coarse,
|
|
613
|
-
effects: l.effects,
|
|
614
|
-
middleware: l.middleware,
|
|
615
|
-
reducers: l.reducers
|
|
616
|
-
}), a(!1));
|
|
617
|
-
});
|
|
618
|
-
}, [e, n, i]), { data: o, loading: c, refresh: i };
|
|
619
|
-
}
|
|
620
|
-
function le(e, s) {
|
|
621
|
-
const { isTimeTraveling: n, currentIndex: o, entryCount: r } = s, c = r - 1;
|
|
622
|
-
if (e === "back") {
|
|
623
|
-
const f = (n ? o : c) - 1;
|
|
624
|
-
return f >= 0 ? { kind: "jump", index: f } : { kind: "none" };
|
|
625
|
-
}
|
|
626
|
-
if (!n) return { kind: "none" };
|
|
627
|
-
const a = o + 1;
|
|
628
|
-
return a > c ? { kind: "resume" } : { kind: "jump", index: a };
|
|
629
|
-
}
|
|
630
|
-
function qe(e, s, n = !0) {
|
|
631
|
-
const { send: o, subscribe: r } = j(), [c, a] = w(-1), [i, f] = w(!1), [l, E] = w(null), m = k(null);
|
|
632
|
-
M(() => {
|
|
633
|
-
if (m.current = null, E(null), !!e)
|
|
634
|
-
return r((d) => {
|
|
635
|
-
d.type === "STATE_SNAPSHOT" && d.storeId === e && m.current === null && (m.current = { state: d.state, version: d.version });
|
|
636
|
-
});
|
|
637
|
-
}, [e, r]);
|
|
638
|
-
const S = b(
|
|
639
|
-
(d) => {
|
|
640
|
-
const R = m.current;
|
|
641
|
-
if (!R) return null;
|
|
642
|
-
let A = R.state;
|
|
643
|
-
for (let P = 0; P <= d; P++) {
|
|
644
|
-
const x = s[P];
|
|
645
|
-
if (!x) break;
|
|
646
|
-
x.snapshotVersion <= R.version || (A = Z(A, x.patches));
|
|
647
|
-
}
|
|
648
|
-
return A;
|
|
649
|
-
},
|
|
650
|
-
[s]
|
|
651
|
-
), O = b(
|
|
652
|
-
(d) => {
|
|
653
|
-
if (!e || !n || d < 0 || d >= s.length) return;
|
|
654
|
-
E((A) => A ?? s.length), a(d), f(!0);
|
|
655
|
-
const R = s[d];
|
|
656
|
-
o({
|
|
657
|
-
type: "TIME_TRAVEL",
|
|
658
|
-
storeId: e,
|
|
659
|
-
state: S(d),
|
|
660
|
-
snapshotVersion: R.snapshotVersion,
|
|
661
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
662
|
-
sourceId: "",
|
|
663
|
-
sourceRole: v.EXTENSION
|
|
664
|
-
});
|
|
665
|
-
},
|
|
666
|
-
[e, s, o, S, n]
|
|
667
|
-
), I = b(() => {
|
|
668
|
-
if (f(!1), a(-1), E(null), n && e && s.length > 0) {
|
|
669
|
-
const d = s.length - 1, R = s[d];
|
|
670
|
-
o({
|
|
671
|
-
type: "TIME_TRAVEL",
|
|
672
|
-
storeId: e,
|
|
673
|
-
state: S(d),
|
|
674
|
-
snapshotVersion: R.snapshotVersion,
|
|
675
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
676
|
-
sourceId: "",
|
|
677
|
-
sourceRole: v.EXTENSION
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
}, [e, s, o, S, n]), p = l ?? s.length, h = b(() => {
|
|
681
|
-
const d = le("back", {
|
|
682
|
-
isTimeTraveling: i,
|
|
683
|
-
currentIndex: c,
|
|
684
|
-
entryCount: p
|
|
685
|
-
});
|
|
686
|
-
d.kind === "jump" && O(d.index);
|
|
687
|
-
}, [i, c, p, O]), N = b(() => {
|
|
688
|
-
const d = le("forward", {
|
|
689
|
-
isTimeTraveling: i,
|
|
690
|
-
currentIndex: c,
|
|
691
|
-
entryCount: p
|
|
692
|
-
});
|
|
693
|
-
d.kind === "jump" ? O(d.index) : d.kind === "resume" && I();
|
|
694
|
-
}, [i, c, p, O, I]), g = Oe(
|
|
695
|
-
() => S(i ? c : s.length - 1),
|
|
696
|
-
[S, i, c, s.length]
|
|
697
|
-
);
|
|
698
|
-
return {
|
|
699
|
-
currentIndex: c,
|
|
700
|
-
isTimeTraveling: i,
|
|
701
|
-
previewState: g,
|
|
702
|
-
frameCount: l,
|
|
703
|
-
jumpTo: O,
|
|
704
|
-
stepBack: h,
|
|
705
|
-
stepForward: N,
|
|
706
|
-
resume: I
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
const z = 0, Q = 1, De = 2, F = 3;
|
|
710
|
-
function $() {
|
|
711
|
-
return {
|
|
712
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
713
|
-
sourceId: "loopback-hub",
|
|
714
|
-
sourceRole: v.HUB
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
function fe(e) {
|
|
718
|
-
return e.split(".")[0] ?? "0";
|
|
719
|
-
}
|
|
720
|
-
class je {
|
|
721
|
-
constructor() {
|
|
722
|
-
this.peers = /* @__PURE__ */ new Set();
|
|
723
|
-
}
|
|
724
|
-
add(s) {
|
|
725
|
-
const n = { role: null, id: null, deliver: s, closed: !1 };
|
|
726
|
-
return this.peers.add(n), n;
|
|
727
|
-
}
|
|
728
|
-
remove(s) {
|
|
729
|
-
if (this.peers.delete(s) && (s.closed = !0, s.role === v.STORE && s.id)) {
|
|
730
|
-
const n = JSON.stringify({
|
|
731
|
-
type: "STORE_DISCONNECTED",
|
|
732
|
-
storeId: s.id,
|
|
733
|
-
reason: "disconnected",
|
|
734
|
-
...$()
|
|
735
|
-
});
|
|
736
|
-
this.eachExtension((o) => o.deliver(n));
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
receive(s, n) {
|
|
740
|
-
if (s.closed) return;
|
|
741
|
-
let o;
|
|
742
|
-
try {
|
|
743
|
-
o = JSON.parse(n);
|
|
744
|
-
} catch {
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
if (!(o === null || typeof o != "object" || typeof o.type != "string")) {
|
|
748
|
-
if (s.role === null) {
|
|
749
|
-
this.handshake(s, o);
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
if (s.role === v.STORE)
|
|
753
|
-
this.eachExtension((r) => r.deliver(n));
|
|
754
|
-
else if (typeof o.storeId == "string")
|
|
755
|
-
for (const r of this.peers)
|
|
756
|
-
r.role === v.STORE && r.id === o.storeId && r.deliver(n);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
handshake(s, n) {
|
|
760
|
-
if (n.type !== "HANDSHAKE_REQUEST") return;
|
|
761
|
-
const o = n.role, r = o === v.STORE ? n.store?.id : o === v.EXTENSION ? n.extension?.id : void 0, a = fe(String(n.protocolVersion ?? "")) === fe(K) && typeof r == "string";
|
|
762
|
-
if (s.deliver(
|
|
763
|
-
JSON.stringify({
|
|
764
|
-
type: "HANDSHAKE_RESPONSE",
|
|
765
|
-
success: a,
|
|
766
|
-
protocolVersion: K,
|
|
767
|
-
...$(),
|
|
768
|
-
...a ? {} : { error: "Loopback handshake rejected (version or id mismatch)" }
|
|
769
|
-
})
|
|
770
|
-
), !!a)
|
|
771
|
-
if (s.role = o, s.id = r, o === v.STORE) {
|
|
772
|
-
s.storeInfo = { name: n.store?.name ?? r, capabilities: n.store?.capabilities };
|
|
773
|
-
const i = JSON.stringify({
|
|
774
|
-
type: "STORE_CONNECTED",
|
|
775
|
-
store: { id: r, name: s.storeInfo.name, capabilities: s.storeInfo.capabilities },
|
|
776
|
-
...$()
|
|
777
|
-
});
|
|
778
|
-
this.eachExtension((f) => f.deliver(i));
|
|
779
|
-
} else {
|
|
780
|
-
const i = [...this.peers].filter((f) => f.role === v.STORE && f.storeInfo).map((f) => ({
|
|
781
|
-
id: f.id,
|
|
782
|
-
name: f.storeInfo.name,
|
|
783
|
-
status: "connected",
|
|
784
|
-
capabilities: f.storeInfo.capabilities,
|
|
785
|
-
connectedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
786
|
-
}));
|
|
787
|
-
s.deliver(JSON.stringify({ type: "STORE_REGISTRY", stores: i, ...$() }));
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
eachExtension(s) {
|
|
791
|
-
for (const n of this.peers) n.role === v.EXTENSION && s(n);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
function We() {
|
|
795
|
-
const e = new je(), s = (r, c) => {
|
|
796
|
-
let a = z;
|
|
797
|
-
const i = e.add((f) => c.onMessage(f));
|
|
798
|
-
return queueMicrotask(() => {
|
|
799
|
-
a = Q, c.onOpen();
|
|
800
|
-
}), {
|
|
801
|
-
get readyState() {
|
|
802
|
-
return a;
|
|
803
|
-
},
|
|
804
|
-
send: (f) => e.receive(i, f),
|
|
805
|
-
close: () => {
|
|
806
|
-
a !== F && (a = F, e.remove(i), c.onClose());
|
|
807
|
-
},
|
|
808
|
-
dispose: () => {
|
|
809
|
-
i.closed = !0;
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
}, o = class o {
|
|
813
|
-
constructor(c) {
|
|
814
|
-
this.onopen = null, this.onmessage = null, this.onclose = null, this.onerror = null, this.readyState = z, this.peer = e.add((a) => this.onmessage?.({ data: a })), queueMicrotask(() => {
|
|
815
|
-
this.readyState = Q, this.onopen?.();
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
send(c) {
|
|
819
|
-
e.receive(this.peer, c);
|
|
820
|
-
}
|
|
821
|
-
close() {
|
|
822
|
-
this.readyState !== F && (this.readyState = F, e.remove(this.peer), this.onclose?.());
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
o.CONNECTING = z, o.OPEN = Q, o.CLOSING = De, o.CLOSED = F;
|
|
826
|
-
let n = o;
|
|
827
|
-
return {
|
|
828
|
-
agentSocketFactory: s,
|
|
829
|
-
WebSocket: n
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
export {
|
|
833
|
-
de as HubContext,
|
|
834
|
-
Ye as HubProvider,
|
|
835
|
-
Z as applyPatches,
|
|
836
|
-
We as createLoopbackHub,
|
|
837
|
-
Le as useEventEmitter,
|
|
838
|
-
Ue as useEventLog,
|
|
839
|
-
Fe as useEventReplay,
|
|
840
|
-
j as useHubConnection,
|
|
841
|
-
He as useStoreMetrics,
|
|
842
|
-
Xe as useStoreRegistry,
|
|
843
|
-
$e as useStoreState,
|
|
844
|
-
Je as useStoreSubscriptions,
|
|
845
|
-
qe as useTimeTravel
|
|
846
|
-
};
|
|
847
|
-
//# sourceMappingURL=devtools-ui.esm.js.map
|