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