@mcp-fe/react-tools 0.1.1 → 0.1.3
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/index.mjs +126 -2276
- package/package.json +6 -7
package/index.mjs
CHANGED
|
@@ -1,2334 +1,184 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Ye = 1;
|
|
6
|
-
var v = /* @__PURE__ */ Symbol.for("react.transitional.element"), n = /* @__PURE__ */ Symbol.for("react.portal"), s = /* @__PURE__ */ Symbol.for("react.fragment"), a = /* @__PURE__ */ Symbol.for("react.strict_mode"), u = /* @__PURE__ */ Symbol.for("react.profiler"), d = /* @__PURE__ */ Symbol.for("react.consumer"), y = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), O = /* @__PURE__ */ Symbol.for("react.suspense"), I = /* @__PURE__ */ Symbol.for("react.memo"), m = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.activity"), L = Symbol.iterator;
|
|
7
|
-
function $(t) {
|
|
8
|
-
return t === null || typeof t != "object" ? null : (t = L && t[L] || t["@@iterator"], typeof t == "function" ? t : null);
|
|
9
|
-
}
|
|
10
|
-
var U = {
|
|
11
|
-
isMounted: function() {
|
|
12
|
-
return !1;
|
|
13
|
-
},
|
|
14
|
-
enqueueForceUpdate: function() {
|
|
15
|
-
},
|
|
16
|
-
enqueueReplaceState: function() {
|
|
17
|
-
},
|
|
18
|
-
enqueueSetState: function() {
|
|
19
|
-
}
|
|
20
|
-
}, D = Object.assign, F = {};
|
|
21
|
-
function H(t, o, l) {
|
|
22
|
-
this.props = t, this.context = o, this.refs = F, this.updater = l || U;
|
|
23
|
-
}
|
|
24
|
-
H.prototype.isReactComponent = {}, H.prototype.setState = function(t, o) {
|
|
25
|
-
if (typeof t != "object" && typeof t != "function" && t != null)
|
|
26
|
-
throw Error(
|
|
27
|
-
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
28
|
-
);
|
|
29
|
-
this.updater.enqueueSetState(this, t, o, "setState");
|
|
30
|
-
}, H.prototype.forceUpdate = function(t) {
|
|
31
|
-
this.updater.enqueueForceUpdate(this, t, "forceUpdate");
|
|
32
|
-
};
|
|
33
|
-
function N() {
|
|
34
|
-
}
|
|
35
|
-
N.prototype = H.prototype;
|
|
36
|
-
function G(t, o, l) {
|
|
37
|
-
this.props = t, this.context = o, this.refs = F, this.updater = l || U;
|
|
38
|
-
}
|
|
39
|
-
var X = G.prototype = new N();
|
|
40
|
-
X.constructor = G, D(X, H.prototype), X.isPureReactComponent = !0;
|
|
41
|
-
var x = Array.isArray;
|
|
42
|
-
function se() {
|
|
43
|
-
}
|
|
44
|
-
var W = { H: null, A: null, T: null, S: null }, ue = Object.prototype.hasOwnProperty;
|
|
45
|
-
function z(t, o, l) {
|
|
46
|
-
var f = l.ref;
|
|
47
|
-
return {
|
|
48
|
-
$$typeof: v,
|
|
49
|
-
type: t,
|
|
50
|
-
key: o,
|
|
51
|
-
ref: f !== void 0 ? f : null,
|
|
52
|
-
props: l
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function te(t, o) {
|
|
56
|
-
return z(t.type, o, t.props);
|
|
57
|
-
}
|
|
58
|
-
function ie(t) {
|
|
59
|
-
return typeof t == "object" && t !== null && t.$$typeof === v;
|
|
60
|
-
}
|
|
61
|
-
function A(t) {
|
|
62
|
-
var o = { "=": "=0", ":": "=2" };
|
|
63
|
-
return "$" + t.replace(/[=:]/g, function(l) {
|
|
64
|
-
return o[l];
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
var re = /\/+/g;
|
|
68
|
-
function V(t, o) {
|
|
69
|
-
return typeof t == "object" && t !== null && t.key != null ? A("" + t.key) : o.toString(36);
|
|
70
|
-
}
|
|
71
|
-
function Q(t) {
|
|
72
|
-
switch (t.status) {
|
|
73
|
-
case "fulfilled":
|
|
74
|
-
return t.value;
|
|
75
|
-
case "rejected":
|
|
76
|
-
throw t.reason;
|
|
77
|
-
default:
|
|
78
|
-
switch (typeof t.status == "string" ? t.then(se, se) : (t.status = "pending", t.then(
|
|
79
|
-
function(o) {
|
|
80
|
-
t.status === "pending" && (t.status = "fulfilled", t.value = o);
|
|
81
|
-
},
|
|
82
|
-
function(o) {
|
|
83
|
-
t.status === "pending" && (t.status = "rejected", t.reason = o);
|
|
84
|
-
}
|
|
85
|
-
)), t.status) {
|
|
86
|
-
case "fulfilled":
|
|
87
|
-
return t.value;
|
|
88
|
-
case "rejected":
|
|
89
|
-
throw t.reason;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
throw t;
|
|
93
|
-
}
|
|
94
|
-
function q(t, o, l, f, _) {
|
|
95
|
-
var S = typeof t;
|
|
96
|
-
(S === "undefined" || S === "boolean") && (t = null);
|
|
97
|
-
var p = !1;
|
|
98
|
-
if (t === null) p = !0;
|
|
99
|
-
else
|
|
100
|
-
switch (S) {
|
|
101
|
-
case "bigint":
|
|
102
|
-
case "string":
|
|
103
|
-
case "number":
|
|
104
|
-
p = !0;
|
|
105
|
-
break;
|
|
106
|
-
case "object":
|
|
107
|
-
switch (t.$$typeof) {
|
|
108
|
-
case v:
|
|
109
|
-
case n:
|
|
110
|
-
p = !0;
|
|
111
|
-
break;
|
|
112
|
-
case m:
|
|
113
|
-
return p = t._init, q(
|
|
114
|
-
p(t._payload),
|
|
115
|
-
o,
|
|
116
|
-
l,
|
|
117
|
-
f,
|
|
118
|
-
_
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (p)
|
|
123
|
-
return _ = _(t), p = f === "" ? "." + V(t, 0) : f, x(_) ? (l = "", p != null && (l = p.replace(re, "$&/") + "/"), q(_, o, l, "", function(ee) {
|
|
124
|
-
return ee;
|
|
125
|
-
})) : _ != null && (ie(_) && (_ = te(
|
|
126
|
-
_,
|
|
127
|
-
l + (_.key == null || t && t.key === _.key ? "" : ("" + _.key).replace(
|
|
128
|
-
re,
|
|
129
|
-
"$&/"
|
|
130
|
-
) + "/") + p
|
|
131
|
-
)), o.push(_)), 1;
|
|
132
|
-
p = 0;
|
|
133
|
-
var Y = f === "" ? "." : f + ":";
|
|
134
|
-
if (x(t))
|
|
135
|
-
for (var j = 0; j < t.length; j++)
|
|
136
|
-
f = t[j], S = Y + V(f, j), p += q(
|
|
137
|
-
f,
|
|
138
|
-
o,
|
|
139
|
-
l,
|
|
140
|
-
S,
|
|
141
|
-
_
|
|
142
|
-
);
|
|
143
|
-
else if (j = $(t), typeof j == "function")
|
|
144
|
-
for (t = j.call(t), j = 0; !(f = t.next()).done; )
|
|
145
|
-
f = f.value, S = Y + V(f, j++), p += q(
|
|
146
|
-
f,
|
|
147
|
-
o,
|
|
148
|
-
l,
|
|
149
|
-
S,
|
|
150
|
-
_
|
|
151
|
-
);
|
|
152
|
-
else if (S === "object") {
|
|
153
|
-
if (typeof t.then == "function")
|
|
154
|
-
return q(
|
|
155
|
-
Q(t),
|
|
156
|
-
o,
|
|
157
|
-
l,
|
|
158
|
-
f,
|
|
159
|
-
_
|
|
160
|
-
);
|
|
161
|
-
throw o = String(t), Error(
|
|
162
|
-
"Objects are not valid as a React child (found: " + (o === "[object Object]" ? "object with keys {" + Object.keys(t).join(", ") + "}" : o) + "). If you meant to render a collection of children, use an array instead."
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
return p;
|
|
166
|
-
}
|
|
167
|
-
function K(t, o, l) {
|
|
168
|
-
if (t == null) return t;
|
|
169
|
-
var f = [], _ = 0;
|
|
170
|
-
return q(t, f, "", "", function(S) {
|
|
171
|
-
return o.call(l, S, _++);
|
|
172
|
-
}), f;
|
|
173
|
-
}
|
|
174
|
-
function ne(t) {
|
|
175
|
-
if (t._status === -1) {
|
|
176
|
-
var o = t._result;
|
|
177
|
-
o = o(), o.then(
|
|
178
|
-
function(l) {
|
|
179
|
-
(t._status === 0 || t._status === -1) && (t._status = 1, t._result = l);
|
|
180
|
-
},
|
|
181
|
-
function(l) {
|
|
182
|
-
(t._status === 0 || t._status === -1) && (t._status = 2, t._result = l);
|
|
183
|
-
}
|
|
184
|
-
), t._status === -1 && (t._status = 0, t._result = o);
|
|
185
|
-
}
|
|
186
|
-
if (t._status === 1) return t._result.default;
|
|
187
|
-
throw t._result;
|
|
188
|
-
}
|
|
189
|
-
var Z = typeof reportError == "function" ? reportError : function(t) {
|
|
190
|
-
if (typeof window == "object" && typeof window.ErrorEvent == "function") {
|
|
191
|
-
var o = new window.ErrorEvent("error", {
|
|
192
|
-
bubbles: !0,
|
|
193
|
-
cancelable: !0,
|
|
194
|
-
message: typeof t == "object" && t !== null && typeof t.message == "string" ? String(t.message) : String(t),
|
|
195
|
-
error: t
|
|
196
|
-
});
|
|
197
|
-
if (!window.dispatchEvent(o)) return;
|
|
198
|
-
} else if (typeof process == "object" && typeof process.emit == "function") {
|
|
199
|
-
process.emit("uncaughtException", t);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
console.error(t);
|
|
203
|
-
}, ae = {
|
|
204
|
-
map: K,
|
|
205
|
-
forEach: function(t, o, l) {
|
|
206
|
-
K(
|
|
207
|
-
t,
|
|
208
|
-
function() {
|
|
209
|
-
o.apply(this, arguments);
|
|
210
|
-
},
|
|
211
|
-
l
|
|
212
|
-
);
|
|
213
|
-
},
|
|
214
|
-
count: function(t) {
|
|
215
|
-
var o = 0;
|
|
216
|
-
return K(t, function() {
|
|
217
|
-
o++;
|
|
218
|
-
}), o;
|
|
219
|
-
},
|
|
220
|
-
toArray: function(t) {
|
|
221
|
-
return K(t, function(o) {
|
|
222
|
-
return o;
|
|
223
|
-
}) || [];
|
|
224
|
-
},
|
|
225
|
-
only: function(t) {
|
|
226
|
-
if (!ie(t))
|
|
227
|
-
throw Error(
|
|
228
|
-
"React.Children.only expected to receive a single React element child."
|
|
229
|
-
);
|
|
230
|
-
return t;
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
return g.Activity = k, g.Children = ae, g.Component = H, g.Fragment = s, g.Profiler = u, g.PureComponent = G, g.StrictMode = a, g.Suspense = O, g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = W, g.__COMPILER_RUNTIME = {
|
|
234
|
-
__proto__: null,
|
|
235
|
-
c: function(t) {
|
|
236
|
-
return W.H.useMemoCache(t);
|
|
237
|
-
}
|
|
238
|
-
}, g.cache = function(t) {
|
|
239
|
-
return function() {
|
|
240
|
-
return t.apply(null, arguments);
|
|
241
|
-
};
|
|
242
|
-
}, g.cacheSignal = function() {
|
|
243
|
-
return null;
|
|
244
|
-
}, g.cloneElement = function(t, o, l) {
|
|
245
|
-
if (t == null)
|
|
246
|
-
throw Error(
|
|
247
|
-
"The argument must be a React element, but you passed " + t + "."
|
|
248
|
-
);
|
|
249
|
-
var f = D({}, t.props), _ = t.key;
|
|
250
|
-
if (o != null)
|
|
251
|
-
for (S in o.key !== void 0 && (_ = "" + o.key), o)
|
|
252
|
-
!ue.call(o, S) || S === "key" || S === "__self" || S === "__source" || S === "ref" && o.ref === void 0 || (f[S] = o[S]);
|
|
253
|
-
var S = arguments.length - 2;
|
|
254
|
-
if (S === 1) f.children = l;
|
|
255
|
-
else if (1 < S) {
|
|
256
|
-
for (var p = Array(S), Y = 0; Y < S; Y++)
|
|
257
|
-
p[Y] = arguments[Y + 2];
|
|
258
|
-
f.children = p;
|
|
259
|
-
}
|
|
260
|
-
return z(t.type, _, f);
|
|
261
|
-
}, g.createContext = function(t) {
|
|
262
|
-
return t = {
|
|
263
|
-
$$typeof: y,
|
|
264
|
-
_currentValue: t,
|
|
265
|
-
_currentValue2: t,
|
|
266
|
-
_threadCount: 0,
|
|
267
|
-
Provider: null,
|
|
268
|
-
Consumer: null
|
|
269
|
-
}, t.Provider = t, t.Consumer = {
|
|
270
|
-
$$typeof: d,
|
|
271
|
-
_context: t
|
|
272
|
-
}, t;
|
|
273
|
-
}, g.createElement = function(t, o, l) {
|
|
274
|
-
var f, _ = {}, S = null;
|
|
275
|
-
if (o != null)
|
|
276
|
-
for (f in o.key !== void 0 && (S = "" + o.key), o)
|
|
277
|
-
ue.call(o, f) && f !== "key" && f !== "__self" && f !== "__source" && (_[f] = o[f]);
|
|
278
|
-
var p = arguments.length - 2;
|
|
279
|
-
if (p === 1) _.children = l;
|
|
280
|
-
else if (1 < p) {
|
|
281
|
-
for (var Y = Array(p), j = 0; j < p; j++)
|
|
282
|
-
Y[j] = arguments[j + 2];
|
|
283
|
-
_.children = Y;
|
|
284
|
-
}
|
|
285
|
-
if (t && t.defaultProps)
|
|
286
|
-
for (f in p = t.defaultProps, p)
|
|
287
|
-
_[f] === void 0 && (_[f] = p[f]);
|
|
288
|
-
return z(t, S, _);
|
|
289
|
-
}, g.createRef = function() {
|
|
290
|
-
return { current: null };
|
|
291
|
-
}, g.forwardRef = function(t) {
|
|
292
|
-
return { $$typeof: b, render: t };
|
|
293
|
-
}, g.isValidElement = ie, g.lazy = function(t) {
|
|
294
|
-
return {
|
|
295
|
-
$$typeof: m,
|
|
296
|
-
_payload: { _status: -1, _result: t },
|
|
297
|
-
_init: ne
|
|
298
|
-
};
|
|
299
|
-
}, g.memo = function(t, o) {
|
|
300
|
-
return {
|
|
301
|
-
$$typeof: I,
|
|
302
|
-
type: t,
|
|
303
|
-
compare: o === void 0 ? null : o
|
|
304
|
-
};
|
|
305
|
-
}, g.startTransition = function(t) {
|
|
306
|
-
var o = W.T, l = {};
|
|
307
|
-
W.T = l;
|
|
308
|
-
try {
|
|
309
|
-
var f = t(), _ = W.S;
|
|
310
|
-
_ !== null && _(l, f), typeof f == "object" && f !== null && typeof f.then == "function" && f.then(se, Z);
|
|
311
|
-
} catch (S) {
|
|
312
|
-
Z(S);
|
|
313
|
-
} finally {
|
|
314
|
-
o !== null && l.types !== null && (o.types = l.types), W.T = o;
|
|
315
|
-
}
|
|
316
|
-
}, g.unstable_useCacheRefresh = function() {
|
|
317
|
-
return W.H.useCacheRefresh();
|
|
318
|
-
}, g.use = function(t) {
|
|
319
|
-
return W.H.use(t);
|
|
320
|
-
}, g.useActionState = function(t, o, l) {
|
|
321
|
-
return W.H.useActionState(t, o, l);
|
|
322
|
-
}, g.useCallback = function(t, o) {
|
|
323
|
-
return W.H.useCallback(t, o);
|
|
324
|
-
}, g.useContext = function(t) {
|
|
325
|
-
return W.H.useContext(t);
|
|
326
|
-
}, g.useDebugValue = function() {
|
|
327
|
-
}, g.useDeferredValue = function(t, o) {
|
|
328
|
-
return W.H.useDeferredValue(t, o);
|
|
329
|
-
}, g.useEffect = function(t, o) {
|
|
330
|
-
return W.H.useEffect(t, o);
|
|
331
|
-
}, g.useEffectEvent = function(t) {
|
|
332
|
-
return W.H.useEffectEvent(t);
|
|
333
|
-
}, g.useId = function() {
|
|
334
|
-
return W.H.useId();
|
|
335
|
-
}, g.useImperativeHandle = function(t, o, l) {
|
|
336
|
-
return W.H.useImperativeHandle(t, o, l);
|
|
337
|
-
}, g.useInsertionEffect = function(t, o) {
|
|
338
|
-
return W.H.useInsertionEffect(t, o);
|
|
339
|
-
}, g.useLayoutEffect = function(t, o) {
|
|
340
|
-
return W.H.useLayoutEffect(t, o);
|
|
341
|
-
}, g.useMemo = function(t, o) {
|
|
342
|
-
return W.H.useMemo(t, o);
|
|
343
|
-
}, g.useOptimistic = function(t, o) {
|
|
344
|
-
return W.H.useOptimistic(t, o);
|
|
345
|
-
}, g.useReducer = function(t, o, l) {
|
|
346
|
-
return W.H.useReducer(t, o, l);
|
|
347
|
-
}, g.useRef = function(t) {
|
|
348
|
-
return W.H.useRef(t);
|
|
349
|
-
}, g.useState = function(t) {
|
|
350
|
-
return W.H.useState(t);
|
|
351
|
-
}, g.useSyncExternalStore = function(t, o, l) {
|
|
352
|
-
return W.H.useSyncExternalStore(
|
|
353
|
-
t,
|
|
354
|
-
o,
|
|
355
|
-
l
|
|
356
|
-
);
|
|
357
|
-
}, g.useTransition = function() {
|
|
358
|
-
return W.H.useTransition();
|
|
359
|
-
}, g.version = "19.2.3", g;
|
|
360
|
-
}
|
|
361
|
-
var he = { exports: {} };
|
|
362
|
-
he.exports;
|
|
363
|
-
var He;
|
|
364
|
-
function et() {
|
|
365
|
-
return He || (He = 1, (function(v, n) {
|
|
366
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
367
|
-
function s(e, r) {
|
|
368
|
-
Object.defineProperty(d.prototype, e, {
|
|
369
|
-
get: function() {
|
|
370
|
-
console.warn(
|
|
371
|
-
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
372
|
-
r[0],
|
|
373
|
-
r[1]
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
function a(e) {
|
|
379
|
-
return e === null || typeof e != "object" ? null : (e = Ce && e[Ce] || e["@@iterator"], typeof e == "function" ? e : null);
|
|
380
|
-
}
|
|
381
|
-
function u(e, r) {
|
|
382
|
-
e = (e = e.constructor) && (e.displayName || e.name) || "ReactClass";
|
|
383
|
-
var i = e + "." + r;
|
|
384
|
-
Se[i] || (console.error(
|
|
385
|
-
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
386
|
-
r,
|
|
387
|
-
e
|
|
388
|
-
), Se[i] = !0);
|
|
389
|
-
}
|
|
390
|
-
function d(e, r, i) {
|
|
391
|
-
this.props = e, this.context = r, this.refs = me, this.updater = i || be;
|
|
392
|
-
}
|
|
393
|
-
function y() {
|
|
394
|
-
}
|
|
395
|
-
function b(e, r, i) {
|
|
396
|
-
this.props = e, this.context = r, this.refs = me, this.updater = i || be;
|
|
397
|
-
}
|
|
398
|
-
function O() {
|
|
399
|
-
}
|
|
400
|
-
function I(e) {
|
|
401
|
-
return "" + e;
|
|
402
|
-
}
|
|
403
|
-
function m(e) {
|
|
404
|
-
try {
|
|
405
|
-
I(e);
|
|
406
|
-
var r = !1;
|
|
407
|
-
} catch {
|
|
408
|
-
r = !0;
|
|
409
|
-
}
|
|
410
|
-
if (r) {
|
|
411
|
-
r = console;
|
|
412
|
-
var i = r.error, c = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
413
|
-
return i.call(
|
|
414
|
-
r,
|
|
415
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
416
|
-
c
|
|
417
|
-
), I(e);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
function k(e) {
|
|
421
|
-
if (e == null) return null;
|
|
422
|
-
if (typeof e == "function")
|
|
423
|
-
return e.$$typeof === Qe ? null : e.displayName || e.name || null;
|
|
424
|
-
if (typeof e == "string") return e;
|
|
425
|
-
switch (e) {
|
|
426
|
-
case t:
|
|
427
|
-
return "Fragment";
|
|
428
|
-
case l:
|
|
429
|
-
return "Profiler";
|
|
430
|
-
case o:
|
|
431
|
-
return "StrictMode";
|
|
432
|
-
case p:
|
|
433
|
-
return "Suspense";
|
|
434
|
-
case Y:
|
|
435
|
-
return "SuspenseList";
|
|
436
|
-
case Re:
|
|
437
|
-
return "Activity";
|
|
438
|
-
}
|
|
439
|
-
if (typeof e == "object")
|
|
440
|
-
switch (typeof e.tag == "number" && console.error(
|
|
441
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
442
|
-
), e.$$typeof) {
|
|
443
|
-
case ae:
|
|
444
|
-
return "Portal";
|
|
445
|
-
case _:
|
|
446
|
-
return e.displayName || "Context";
|
|
447
|
-
case f:
|
|
448
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
449
|
-
case S:
|
|
450
|
-
var r = e.render;
|
|
451
|
-
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
452
|
-
case j:
|
|
453
|
-
return r = e.displayName || null, r !== null ? r : k(e.type) || "Memo";
|
|
454
|
-
case ee:
|
|
455
|
-
r = e._payload, e = e._init;
|
|
456
|
-
try {
|
|
457
|
-
return k(e(r));
|
|
458
|
-
} catch {
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return null;
|
|
462
|
-
}
|
|
463
|
-
function L(e) {
|
|
464
|
-
if (e === t) return "<>";
|
|
465
|
-
if (typeof e == "object" && e !== null && e.$$typeof === ee)
|
|
466
|
-
return "<...>";
|
|
467
|
-
try {
|
|
468
|
-
var r = k(e);
|
|
469
|
-
return r ? "<" + r + ">" : "<...>";
|
|
470
|
-
} catch {
|
|
471
|
-
return "<...>";
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
function $() {
|
|
475
|
-
var e = w.A;
|
|
476
|
-
return e === null ? null : e.getOwner();
|
|
477
|
-
}
|
|
478
|
-
function U() {
|
|
479
|
-
return Error("react-stack-top-frame");
|
|
480
|
-
}
|
|
481
|
-
function D(e) {
|
|
482
|
-
if (pe.call(e, "key")) {
|
|
483
|
-
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
484
|
-
if (r && r.isReactWarning) return !1;
|
|
485
|
-
}
|
|
486
|
-
return e.key !== void 0;
|
|
487
|
-
}
|
|
488
|
-
function F(e, r) {
|
|
489
|
-
function i() {
|
|
490
|
-
Oe || (Oe = !0, console.error(
|
|
491
|
-
"%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)",
|
|
492
|
-
r
|
|
493
|
-
));
|
|
494
|
-
}
|
|
495
|
-
i.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
496
|
-
get: i,
|
|
497
|
-
configurable: !0
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
function H() {
|
|
501
|
-
var e = k(this.type);
|
|
502
|
-
return Ne[e] || (Ne[e] = !0, console.error(
|
|
503
|
-
"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."
|
|
504
|
-
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
505
|
-
}
|
|
506
|
-
function N(e, r, i, c, h, R) {
|
|
507
|
-
var T = i.ref;
|
|
508
|
-
return e = {
|
|
509
|
-
$$typeof: Z,
|
|
510
|
-
type: e,
|
|
511
|
-
key: r,
|
|
512
|
-
props: i,
|
|
513
|
-
_owner: c
|
|
514
|
-
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(e, "ref", {
|
|
515
|
-
enumerable: !1,
|
|
516
|
-
get: H
|
|
517
|
-
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
518
|
-
configurable: !1,
|
|
519
|
-
enumerable: !1,
|
|
520
|
-
writable: !0,
|
|
521
|
-
value: 0
|
|
522
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
523
|
-
configurable: !1,
|
|
524
|
-
enumerable: !1,
|
|
525
|
-
writable: !0,
|
|
526
|
-
value: null
|
|
527
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
528
|
-
configurable: !1,
|
|
529
|
-
enumerable: !1,
|
|
530
|
-
writable: !0,
|
|
531
|
-
value: h
|
|
532
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
533
|
-
configurable: !1,
|
|
534
|
-
enumerable: !1,
|
|
535
|
-
writable: !0,
|
|
536
|
-
value: R
|
|
537
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
538
|
-
}
|
|
539
|
-
function G(e, r) {
|
|
540
|
-
return r = N(
|
|
541
|
-
e.type,
|
|
542
|
-
r,
|
|
543
|
-
e.props,
|
|
544
|
-
e._owner,
|
|
545
|
-
e._debugStack,
|
|
546
|
-
e._debugTask
|
|
547
|
-
), e._store && (r._store.validated = e._store.validated), r;
|
|
548
|
-
}
|
|
549
|
-
function X(e) {
|
|
550
|
-
x(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === ee && (e._payload.status === "fulfilled" ? x(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
551
|
-
}
|
|
552
|
-
function x(e) {
|
|
553
|
-
return typeof e == "object" && e !== null && e.$$typeof === Z;
|
|
554
|
-
}
|
|
555
|
-
function se(e) {
|
|
556
|
-
var r = { "=": "=0", ":": "=2" };
|
|
557
|
-
return "$" + e.replace(/[=:]/g, function(i) {
|
|
558
|
-
return r[i];
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
function W(e, r) {
|
|
562
|
-
return typeof e == "object" && e !== null && e.key != null ? (m(e.key), se("" + e.key)) : r.toString(36);
|
|
563
|
-
}
|
|
564
|
-
function ue(e) {
|
|
565
|
-
switch (e.status) {
|
|
566
|
-
case "fulfilled":
|
|
567
|
-
return e.value;
|
|
568
|
-
case "rejected":
|
|
569
|
-
throw e.reason;
|
|
570
|
-
default:
|
|
571
|
-
switch (typeof e.status == "string" ? e.then(O, O) : (e.status = "pending", e.then(
|
|
572
|
-
function(r) {
|
|
573
|
-
e.status === "pending" && (e.status = "fulfilled", e.value = r);
|
|
574
|
-
},
|
|
575
|
-
function(r) {
|
|
576
|
-
e.status === "pending" && (e.status = "rejected", e.reason = r);
|
|
577
|
-
}
|
|
578
|
-
)), e.status) {
|
|
579
|
-
case "fulfilled":
|
|
580
|
-
return e.value;
|
|
581
|
-
case "rejected":
|
|
582
|
-
throw e.reason;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
throw e;
|
|
586
|
-
}
|
|
587
|
-
function z(e, r, i, c, h) {
|
|
588
|
-
var R = typeof e;
|
|
589
|
-
(R === "undefined" || R === "boolean") && (e = null);
|
|
590
|
-
var T = !1;
|
|
591
|
-
if (e === null) T = !0;
|
|
592
|
-
else
|
|
593
|
-
switch (R) {
|
|
594
|
-
case "bigint":
|
|
595
|
-
case "string":
|
|
596
|
-
case "number":
|
|
597
|
-
T = !0;
|
|
598
|
-
break;
|
|
599
|
-
case "object":
|
|
600
|
-
switch (e.$$typeof) {
|
|
601
|
-
case Z:
|
|
602
|
-
case ae:
|
|
603
|
-
T = !0;
|
|
604
|
-
break;
|
|
605
|
-
case ee:
|
|
606
|
-
return T = e._init, z(
|
|
607
|
-
T(e._payload),
|
|
608
|
-
r,
|
|
609
|
-
i,
|
|
610
|
-
c,
|
|
611
|
-
h
|
|
612
|
-
);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
if (T) {
|
|
616
|
-
T = e, h = h(T);
|
|
617
|
-
var P = c === "" ? "." + W(T, 0) : c;
|
|
618
|
-
return Ae(h) ? (i = "", P != null && (i = P.replace(Ie, "$&/") + "/"), z(h, r, i, "", function(oe) {
|
|
619
|
-
return oe;
|
|
620
|
-
})) : h != null && (x(h) && (h.key != null && (T && T.key === h.key || m(h.key)), i = G(
|
|
621
|
-
h,
|
|
622
|
-
i + (h.key == null || T && T.key === h.key ? "" : ("" + h.key).replace(
|
|
623
|
-
Ie,
|
|
624
|
-
"$&/"
|
|
625
|
-
) + "/") + P
|
|
626
|
-
), c !== "" && T != null && x(T) && T.key == null && T._store && !T._store.validated && (i._store.validated = 2), h = i), r.push(h)), 1;
|
|
627
|
-
}
|
|
628
|
-
if (T = 0, P = c === "" ? "." : c + ":", Ae(e))
|
|
629
|
-
for (var C = 0; C < e.length; C++)
|
|
630
|
-
c = e[C], R = P + W(c, C), T += z(
|
|
631
|
-
c,
|
|
632
|
-
r,
|
|
633
|
-
i,
|
|
634
|
-
R,
|
|
635
|
-
h
|
|
636
|
-
);
|
|
637
|
-
else if (C = a(e), typeof C == "function")
|
|
638
|
-
for (C === e.entries && (je || console.warn(
|
|
639
|
-
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
640
|
-
), je = !0), e = C.call(e), C = 0; !(c = e.next()).done; )
|
|
641
|
-
c = c.value, R = P + W(c, C++), T += z(
|
|
642
|
-
c,
|
|
643
|
-
r,
|
|
644
|
-
i,
|
|
645
|
-
R,
|
|
646
|
-
h
|
|
647
|
-
);
|
|
648
|
-
else if (R === "object") {
|
|
649
|
-
if (typeof e.then == "function")
|
|
650
|
-
return z(
|
|
651
|
-
ue(e),
|
|
652
|
-
r,
|
|
653
|
-
i,
|
|
654
|
-
c,
|
|
655
|
-
h
|
|
656
|
-
);
|
|
657
|
-
throw r = String(e), Error(
|
|
658
|
-
"Objects are not valid as a React child (found: " + (r === "[object Object]" ? "object with keys {" + Object.keys(e).join(", ") + "}" : r) + "). If you meant to render a collection of children, use an array instead."
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
return T;
|
|
662
|
-
}
|
|
663
|
-
function te(e, r, i) {
|
|
664
|
-
if (e == null) return e;
|
|
665
|
-
var c = [], h = 0;
|
|
666
|
-
return z(e, c, "", "", function(R) {
|
|
667
|
-
return r.call(i, R, h++);
|
|
668
|
-
}), c;
|
|
669
|
-
}
|
|
670
|
-
function ie(e) {
|
|
671
|
-
if (e._status === -1) {
|
|
672
|
-
var r = e._ioInfo;
|
|
673
|
-
r != null && (r.start = r.end = performance.now()), r = e._result;
|
|
674
|
-
var i = r();
|
|
675
|
-
if (i.then(
|
|
676
|
-
function(h) {
|
|
677
|
-
if (e._status === 0 || e._status === -1) {
|
|
678
|
-
e._status = 1, e._result = h;
|
|
679
|
-
var R = e._ioInfo;
|
|
680
|
-
R != null && (R.end = performance.now()), i.status === void 0 && (i.status = "fulfilled", i.value = h);
|
|
681
|
-
}
|
|
682
|
-
},
|
|
683
|
-
function(h) {
|
|
684
|
-
if (e._status === 0 || e._status === -1) {
|
|
685
|
-
e._status = 2, e._result = h;
|
|
686
|
-
var R = e._ioInfo;
|
|
687
|
-
R != null && (R.end = performance.now()), i.status === void 0 && (i.status = "rejected", i.reason = h);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
), r = e._ioInfo, r != null) {
|
|
691
|
-
r.value = i;
|
|
692
|
-
var c = i.displayName;
|
|
693
|
-
typeof c == "string" && (r.name = c);
|
|
694
|
-
}
|
|
695
|
-
e._status === -1 && (e._status = 0, e._result = i);
|
|
696
|
-
}
|
|
697
|
-
if (e._status === 1)
|
|
698
|
-
return r = e._result, r === void 0 && console.error(
|
|
699
|
-
`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
700
|
-
|
|
701
|
-
Your code should look like:
|
|
702
|
-
const MyComponent = lazy(() => import('./MyComponent'))
|
|
703
|
-
|
|
704
|
-
Did you accidentally put curly braces around the import?`,
|
|
705
|
-
r
|
|
706
|
-
), "default" in r || console.error(
|
|
707
|
-
`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
708
|
-
|
|
709
|
-
Your code should look like:
|
|
710
|
-
const MyComponent = lazy(() => import('./MyComponent'))`,
|
|
711
|
-
r
|
|
712
|
-
), r.default;
|
|
713
|
-
throw e._result;
|
|
714
|
-
}
|
|
715
|
-
function A() {
|
|
716
|
-
var e = w.H;
|
|
717
|
-
return e === null && console.error(
|
|
718
|
-
`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
719
|
-
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
720
|
-
2. You might be breaking the Rules of Hooks
|
|
721
|
-
3. You might have more than one copy of React in the same app
|
|
722
|
-
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`
|
|
723
|
-
), e;
|
|
724
|
-
}
|
|
725
|
-
function re() {
|
|
726
|
-
w.asyncTransitions--;
|
|
727
|
-
}
|
|
728
|
-
function V(e) {
|
|
729
|
-
if (ge === null)
|
|
730
|
-
try {
|
|
731
|
-
var r = ("require" + Math.random()).slice(0, 7);
|
|
732
|
-
ge = (v && v[r]).call(
|
|
733
|
-
v,
|
|
734
|
-
"timers"
|
|
735
|
-
).setImmediate;
|
|
736
|
-
} catch {
|
|
737
|
-
ge = function(c) {
|
|
738
|
-
Le === !1 && (Le = !0, typeof MessageChannel > "u" && console.error(
|
|
739
|
-
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
740
|
-
));
|
|
741
|
-
var h = new MessageChannel();
|
|
742
|
-
h.port1.onmessage = c, h.port2.postMessage(void 0);
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
return ge(e);
|
|
746
|
-
}
|
|
747
|
-
function Q(e) {
|
|
748
|
-
return 1 < e.length && typeof AggregateError == "function" ? new AggregateError(e) : e[0];
|
|
749
|
-
}
|
|
750
|
-
function q(e, r) {
|
|
751
|
-
r !== ve - 1 && console.error(
|
|
752
|
-
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
753
|
-
), ve = r;
|
|
754
|
-
}
|
|
755
|
-
function K(e, r, i) {
|
|
756
|
-
var c = w.actQueue;
|
|
757
|
-
if (c !== null)
|
|
758
|
-
if (c.length !== 0)
|
|
759
|
-
try {
|
|
760
|
-
ne(c), V(function() {
|
|
761
|
-
return K(e, r, i);
|
|
762
|
-
});
|
|
763
|
-
return;
|
|
764
|
-
} catch (h) {
|
|
765
|
-
w.thrownErrors.push(h);
|
|
766
|
-
}
|
|
767
|
-
else w.actQueue = null;
|
|
768
|
-
0 < w.thrownErrors.length ? (c = Q(w.thrownErrors), w.thrownErrors.length = 0, i(c)) : r(e);
|
|
769
|
-
}
|
|
770
|
-
function ne(e) {
|
|
771
|
-
if (!Te) {
|
|
772
|
-
Te = !0;
|
|
773
|
-
var r = 0;
|
|
774
|
-
try {
|
|
775
|
-
for (; r < e.length; r++) {
|
|
776
|
-
var i = e[r];
|
|
777
|
-
do {
|
|
778
|
-
w.didUsePromise = !1;
|
|
779
|
-
var c = i(!1);
|
|
780
|
-
if (c !== null) {
|
|
781
|
-
if (w.didUsePromise) {
|
|
782
|
-
e[r] = i, e.splice(0, r);
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
i = c;
|
|
786
|
-
} else break;
|
|
787
|
-
} while (!0);
|
|
788
|
-
}
|
|
789
|
-
e.length = 0;
|
|
790
|
-
} catch (h) {
|
|
791
|
-
e.splice(0, r + 1), w.thrownErrors.push(h);
|
|
792
|
-
} finally {
|
|
793
|
-
Te = !1;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
798
|
-
var Z = /* @__PURE__ */ Symbol.for("react.transitional.element"), ae = /* @__PURE__ */ Symbol.for("react.portal"), t = /* @__PURE__ */ Symbol.for("react.fragment"), o = /* @__PURE__ */ Symbol.for("react.strict_mode"), l = /* @__PURE__ */ Symbol.for("react.profiler"), f = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), S = /* @__PURE__ */ Symbol.for("react.forward_ref"), p = /* @__PURE__ */ Symbol.for("react.suspense"), Y = /* @__PURE__ */ Symbol.for("react.suspense_list"), j = /* @__PURE__ */ Symbol.for("react.memo"), ee = /* @__PURE__ */ Symbol.for("react.lazy"), Re = /* @__PURE__ */ Symbol.for("react.activity"), Ce = Symbol.iterator, Se = {}, be = {
|
|
799
|
-
isMounted: function() {
|
|
800
|
-
return !1;
|
|
801
|
-
},
|
|
802
|
-
enqueueForceUpdate: function(e) {
|
|
803
|
-
u(e, "forceUpdate");
|
|
804
|
-
},
|
|
805
|
-
enqueueReplaceState: function(e) {
|
|
806
|
-
u(e, "replaceState");
|
|
807
|
-
},
|
|
808
|
-
enqueueSetState: function(e) {
|
|
809
|
-
u(e, "setState");
|
|
810
|
-
}
|
|
811
|
-
}, We = Object.assign, me = {};
|
|
812
|
-
Object.freeze(me), d.prototype.isReactComponent = {}, d.prototype.setState = function(e, r) {
|
|
813
|
-
if (typeof e != "object" && typeof e != "function" && e != null)
|
|
814
|
-
throw Error(
|
|
815
|
-
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
816
|
-
);
|
|
817
|
-
this.updater.enqueueSetState(this, e, r, "setState");
|
|
818
|
-
}, d.prototype.forceUpdate = function(e) {
|
|
819
|
-
this.updater.enqueueForceUpdate(this, e, "forceUpdate");
|
|
820
|
-
};
|
|
821
|
-
var B = {
|
|
822
|
-
isMounted: [
|
|
823
|
-
"isMounted",
|
|
824
|
-
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
825
|
-
],
|
|
826
|
-
replaceState: [
|
|
827
|
-
"replaceState",
|
|
828
|
-
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
829
|
-
]
|
|
830
|
-
};
|
|
831
|
-
for (le in B)
|
|
832
|
-
B.hasOwnProperty(le) && s(le, B[le]);
|
|
833
|
-
y.prototype = d.prototype, B = b.prototype = new y(), B.constructor = b, We(B, d.prototype), B.isPureReactComponent = !0;
|
|
834
|
-
var Ae = Array.isArray, Qe = /* @__PURE__ */ Symbol.for("react.client.reference"), w = {
|
|
835
|
-
H: null,
|
|
836
|
-
A: null,
|
|
837
|
-
T: null,
|
|
838
|
-
S: null,
|
|
839
|
-
actQueue: null,
|
|
840
|
-
asyncTransitions: 0,
|
|
841
|
-
isBatchingLegacy: !1,
|
|
842
|
-
didScheduleLegacyUpdate: !1,
|
|
843
|
-
didUsePromise: !1,
|
|
844
|
-
thrownErrors: [],
|
|
845
|
-
getCurrentStack: null,
|
|
846
|
-
recentlyCreatedOwnerStacks: 0
|
|
847
|
-
}, pe = Object.prototype.hasOwnProperty, Pe = console.createTask ? console.createTask : function() {
|
|
848
|
-
return null;
|
|
849
|
-
};
|
|
850
|
-
B = {
|
|
851
|
-
react_stack_bottom_frame: function(e) {
|
|
852
|
-
return e();
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
var Oe, Me, Ne = {}, Ke = B.react_stack_bottom_frame.bind(
|
|
856
|
-
B,
|
|
857
|
-
U
|
|
858
|
-
)(), Xe = Pe(L(U)), je = !1, Ie = /\/+/g, Ue = typeof reportError == "function" ? reportError : function(e) {
|
|
859
|
-
if (typeof window == "object" && typeof window.ErrorEvent == "function") {
|
|
860
|
-
var r = new window.ErrorEvent("error", {
|
|
861
|
-
bubbles: !0,
|
|
862
|
-
cancelable: !0,
|
|
863
|
-
message: typeof e == "object" && e !== null && typeof e.message == "string" ? String(e.message) : String(e),
|
|
864
|
-
error: e
|
|
865
|
-
});
|
|
866
|
-
if (!window.dispatchEvent(r)) return;
|
|
867
|
-
} else if (typeof process == "object" && typeof process.emit == "function") {
|
|
868
|
-
process.emit("uncaughtException", e);
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
console.error(e);
|
|
872
|
-
}, Le = !1, ge = null, ve = 0, ye = !1, Te = !1, De = typeof queueMicrotask == "function" ? function(e) {
|
|
873
|
-
queueMicrotask(function() {
|
|
874
|
-
return queueMicrotask(e);
|
|
875
|
-
});
|
|
876
|
-
} : V;
|
|
877
|
-
B = Object.freeze({
|
|
878
|
-
__proto__: null,
|
|
879
|
-
c: function(e) {
|
|
880
|
-
return A().useMemoCache(e);
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
var le = {
|
|
884
|
-
map: te,
|
|
885
|
-
forEach: function(e, r, i) {
|
|
886
|
-
te(
|
|
887
|
-
e,
|
|
888
|
-
function() {
|
|
889
|
-
r.apply(this, arguments);
|
|
890
|
-
},
|
|
891
|
-
i
|
|
892
|
-
);
|
|
893
|
-
},
|
|
894
|
-
count: function(e) {
|
|
895
|
-
var r = 0;
|
|
896
|
-
return te(e, function() {
|
|
897
|
-
r++;
|
|
898
|
-
}), r;
|
|
899
|
-
},
|
|
900
|
-
toArray: function(e) {
|
|
901
|
-
return te(e, function(r) {
|
|
902
|
-
return r;
|
|
903
|
-
}) || [];
|
|
904
|
-
},
|
|
905
|
-
only: function(e) {
|
|
906
|
-
if (!x(e))
|
|
907
|
-
throw Error(
|
|
908
|
-
"React.Children.only expected to receive a single React element child."
|
|
909
|
-
);
|
|
910
|
-
return e;
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
n.Activity = Re, n.Children = le, n.Component = d, n.Fragment = t, n.Profiler = l, n.PureComponent = b, n.StrictMode = o, n.Suspense = p, n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = w, n.__COMPILER_RUNTIME = B, n.act = function(e) {
|
|
914
|
-
var r = w.actQueue, i = ve;
|
|
915
|
-
ve++;
|
|
916
|
-
var c = w.actQueue = r !== null ? r : [], h = !1;
|
|
917
|
-
try {
|
|
918
|
-
var R = e();
|
|
919
|
-
} catch (C) {
|
|
920
|
-
w.thrownErrors.push(C);
|
|
921
|
-
}
|
|
922
|
-
if (0 < w.thrownErrors.length)
|
|
923
|
-
throw q(r, i), e = Q(w.thrownErrors), w.thrownErrors.length = 0, e;
|
|
924
|
-
if (R !== null && typeof R == "object" && typeof R.then == "function") {
|
|
925
|
-
var T = R;
|
|
926
|
-
return De(function() {
|
|
927
|
-
h || ye || (ye = !0, console.error(
|
|
928
|
-
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
929
|
-
));
|
|
930
|
-
}), {
|
|
931
|
-
then: function(C, oe) {
|
|
932
|
-
h = !0, T.then(
|
|
933
|
-
function(ce) {
|
|
934
|
-
if (q(r, i), i === 0) {
|
|
935
|
-
try {
|
|
936
|
-
ne(c), V(function() {
|
|
937
|
-
return K(
|
|
938
|
-
ce,
|
|
939
|
-
C,
|
|
940
|
-
oe
|
|
941
|
-
);
|
|
942
|
-
});
|
|
943
|
-
} catch (Je) {
|
|
944
|
-
w.thrownErrors.push(Je);
|
|
945
|
-
}
|
|
946
|
-
if (0 < w.thrownErrors.length) {
|
|
947
|
-
var Ve = Q(
|
|
948
|
-
w.thrownErrors
|
|
949
|
-
);
|
|
950
|
-
w.thrownErrors.length = 0, oe(Ve);
|
|
951
|
-
}
|
|
952
|
-
} else C(ce);
|
|
953
|
-
},
|
|
954
|
-
function(ce) {
|
|
955
|
-
q(r, i), 0 < w.thrownErrors.length && (ce = Q(
|
|
956
|
-
w.thrownErrors
|
|
957
|
-
), w.thrownErrors.length = 0), oe(ce);
|
|
958
|
-
}
|
|
959
|
-
);
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
var P = R;
|
|
964
|
-
if (q(r, i), i === 0 && (ne(c), c.length !== 0 && De(function() {
|
|
965
|
-
h || ye || (ye = !0, console.error(
|
|
966
|
-
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
967
|
-
));
|
|
968
|
-
}), w.actQueue = null), 0 < w.thrownErrors.length)
|
|
969
|
-
throw e = Q(w.thrownErrors), w.thrownErrors.length = 0, e;
|
|
970
|
-
return {
|
|
971
|
-
then: function(C, oe) {
|
|
972
|
-
h = !0, i === 0 ? (w.actQueue = c, V(function() {
|
|
973
|
-
return K(
|
|
974
|
-
P,
|
|
975
|
-
C,
|
|
976
|
-
oe
|
|
977
|
-
);
|
|
978
|
-
})) : C(P);
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
}, n.cache = function(e) {
|
|
982
|
-
return function() {
|
|
983
|
-
return e.apply(null, arguments);
|
|
984
|
-
};
|
|
985
|
-
}, n.cacheSignal = function() {
|
|
986
|
-
return null;
|
|
987
|
-
}, n.captureOwnerStack = function() {
|
|
988
|
-
var e = w.getCurrentStack;
|
|
989
|
-
return e === null ? null : e();
|
|
990
|
-
}, n.cloneElement = function(e, r, i) {
|
|
991
|
-
if (e == null)
|
|
992
|
-
throw Error(
|
|
993
|
-
"The argument must be a React element, but you passed " + e + "."
|
|
994
|
-
);
|
|
995
|
-
var c = We({}, e.props), h = e.key, R = e._owner;
|
|
996
|
-
if (r != null) {
|
|
997
|
-
var T;
|
|
998
|
-
e: {
|
|
999
|
-
if (pe.call(r, "ref") && (T = Object.getOwnPropertyDescriptor(
|
|
1000
|
-
r,
|
|
1001
|
-
"ref"
|
|
1002
|
-
).get) && T.isReactWarning) {
|
|
1003
|
-
T = !1;
|
|
1004
|
-
break e;
|
|
1005
|
-
}
|
|
1006
|
-
T = r.ref !== void 0;
|
|
1007
|
-
}
|
|
1008
|
-
T && (R = $()), D(r) && (m(r.key), h = "" + r.key);
|
|
1009
|
-
for (P in r)
|
|
1010
|
-
!pe.call(r, P) || P === "key" || P === "__self" || P === "__source" || P === "ref" && r.ref === void 0 || (c[P] = r[P]);
|
|
1011
|
-
}
|
|
1012
|
-
var P = arguments.length - 2;
|
|
1013
|
-
if (P === 1) c.children = i;
|
|
1014
|
-
else if (1 < P) {
|
|
1015
|
-
T = Array(P);
|
|
1016
|
-
for (var C = 0; C < P; C++)
|
|
1017
|
-
T[C] = arguments[C + 2];
|
|
1018
|
-
c.children = T;
|
|
1019
|
-
}
|
|
1020
|
-
for (c = N(
|
|
1021
|
-
e.type,
|
|
1022
|
-
h,
|
|
1023
|
-
c,
|
|
1024
|
-
R,
|
|
1025
|
-
e._debugStack,
|
|
1026
|
-
e._debugTask
|
|
1027
|
-
), h = 2; h < arguments.length; h++)
|
|
1028
|
-
X(arguments[h]);
|
|
1029
|
-
return c;
|
|
1030
|
-
}, n.createContext = function(e) {
|
|
1031
|
-
return e = {
|
|
1032
|
-
$$typeof: _,
|
|
1033
|
-
_currentValue: e,
|
|
1034
|
-
_currentValue2: e,
|
|
1035
|
-
_threadCount: 0,
|
|
1036
|
-
Provider: null,
|
|
1037
|
-
Consumer: null
|
|
1038
|
-
}, e.Provider = e, e.Consumer = {
|
|
1039
|
-
$$typeof: f,
|
|
1040
|
-
_context: e
|
|
1041
|
-
}, e._currentRenderer = null, e._currentRenderer2 = null, e;
|
|
1042
|
-
}, n.createElement = function(e, r, i) {
|
|
1043
|
-
for (var c = 2; c < arguments.length; c++)
|
|
1044
|
-
X(arguments[c]);
|
|
1045
|
-
c = {};
|
|
1046
|
-
var h = null;
|
|
1047
|
-
if (r != null)
|
|
1048
|
-
for (C in Me || !("__self" in r) || "key" in r || (Me = !0, console.warn(
|
|
1049
|
-
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
1050
|
-
)), D(r) && (m(r.key), h = "" + r.key), r)
|
|
1051
|
-
pe.call(r, C) && C !== "key" && C !== "__self" && C !== "__source" && (c[C] = r[C]);
|
|
1052
|
-
var R = arguments.length - 2;
|
|
1053
|
-
if (R === 1) c.children = i;
|
|
1054
|
-
else if (1 < R) {
|
|
1055
|
-
for (var T = Array(R), P = 0; P < R; P++)
|
|
1056
|
-
T[P] = arguments[P + 2];
|
|
1057
|
-
Object.freeze && Object.freeze(T), c.children = T;
|
|
1058
|
-
}
|
|
1059
|
-
if (e && e.defaultProps)
|
|
1060
|
-
for (C in R = e.defaultProps, R)
|
|
1061
|
-
c[C] === void 0 && (c[C] = R[C]);
|
|
1062
|
-
h && F(
|
|
1063
|
-
c,
|
|
1064
|
-
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
1065
|
-
);
|
|
1066
|
-
var C = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
1067
|
-
return N(
|
|
1068
|
-
e,
|
|
1069
|
-
h,
|
|
1070
|
-
c,
|
|
1071
|
-
$(),
|
|
1072
|
-
C ? Error("react-stack-top-frame") : Ke,
|
|
1073
|
-
C ? Pe(L(e)) : Xe
|
|
1074
|
-
);
|
|
1075
|
-
}, n.createRef = function() {
|
|
1076
|
-
var e = { current: null };
|
|
1077
|
-
return Object.seal(e), e;
|
|
1078
|
-
}, n.forwardRef = function(e) {
|
|
1079
|
-
e != null && e.$$typeof === j ? console.error(
|
|
1080
|
-
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
1081
|
-
) : typeof e != "function" ? console.error(
|
|
1082
|
-
"forwardRef requires a render function but was given %s.",
|
|
1083
|
-
e === null ? "null" : typeof e
|
|
1084
|
-
) : e.length !== 0 && e.length !== 2 && console.error(
|
|
1085
|
-
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
1086
|
-
e.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
1087
|
-
), e != null && e.defaultProps != null && console.error(
|
|
1088
|
-
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
1089
|
-
);
|
|
1090
|
-
var r = { $$typeof: S, render: e }, i;
|
|
1091
|
-
return Object.defineProperty(r, "displayName", {
|
|
1092
|
-
enumerable: !1,
|
|
1093
|
-
configurable: !0,
|
|
1094
|
-
get: function() {
|
|
1095
|
-
return i;
|
|
1096
|
-
},
|
|
1097
|
-
set: function(c) {
|
|
1098
|
-
i = c, e.name || e.displayName || (Object.defineProperty(e, "name", { value: c }), e.displayName = c);
|
|
1099
|
-
}
|
|
1100
|
-
}), r;
|
|
1101
|
-
}, n.isValidElement = x, n.lazy = function(e) {
|
|
1102
|
-
e = { _status: -1, _result: e };
|
|
1103
|
-
var r = {
|
|
1104
|
-
$$typeof: ee,
|
|
1105
|
-
_payload: e,
|
|
1106
|
-
_init: ie
|
|
1107
|
-
}, i = {
|
|
1108
|
-
name: "lazy",
|
|
1109
|
-
start: -1,
|
|
1110
|
-
end: -1,
|
|
1111
|
-
value: null,
|
|
1112
|
-
owner: null,
|
|
1113
|
-
debugStack: Error("react-stack-top-frame"),
|
|
1114
|
-
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
1115
|
-
};
|
|
1116
|
-
return e._ioInfo = i, r._debugInfo = [{ awaited: i }], r;
|
|
1117
|
-
}, n.memo = function(e, r) {
|
|
1118
|
-
e == null && console.error(
|
|
1119
|
-
"memo: The first argument must be a component. Instead received: %s",
|
|
1120
|
-
e === null ? "null" : typeof e
|
|
1121
|
-
), r = {
|
|
1122
|
-
$$typeof: j,
|
|
1123
|
-
type: e,
|
|
1124
|
-
compare: r === void 0 ? null : r
|
|
1125
|
-
};
|
|
1126
|
-
var i;
|
|
1127
|
-
return Object.defineProperty(r, "displayName", {
|
|
1128
|
-
enumerable: !1,
|
|
1129
|
-
configurable: !0,
|
|
1130
|
-
get: function() {
|
|
1131
|
-
return i;
|
|
1132
|
-
},
|
|
1133
|
-
set: function(c) {
|
|
1134
|
-
i = c, e.name || e.displayName || (Object.defineProperty(e, "name", { value: c }), e.displayName = c);
|
|
1135
|
-
}
|
|
1136
|
-
}), r;
|
|
1137
|
-
}, n.startTransition = function(e) {
|
|
1138
|
-
var r = w.T, i = {};
|
|
1139
|
-
i._updatedFibers = /* @__PURE__ */ new Set(), w.T = i;
|
|
1140
|
-
try {
|
|
1141
|
-
var c = e(), h = w.S;
|
|
1142
|
-
h !== null && h(i, c), typeof c == "object" && c !== null && typeof c.then == "function" && (w.asyncTransitions++, c.then(re, re), c.then(O, Ue));
|
|
1143
|
-
} catch (R) {
|
|
1144
|
-
Ue(R);
|
|
1145
|
-
} finally {
|
|
1146
|
-
r === null && i._updatedFibers && (e = i._updatedFibers.size, i._updatedFibers.clear(), 10 < e && console.warn(
|
|
1147
|
-
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
1148
|
-
)), r !== null && i.types !== null && (r.types !== null && r.types !== i.types && console.error(
|
|
1149
|
-
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
1150
|
-
), r.types = i.types), w.T = r;
|
|
1151
|
-
}
|
|
1152
|
-
}, n.unstable_useCacheRefresh = function() {
|
|
1153
|
-
return A().useCacheRefresh();
|
|
1154
|
-
}, n.use = function(e) {
|
|
1155
|
-
return A().use(e);
|
|
1156
|
-
}, n.useActionState = function(e, r, i) {
|
|
1157
|
-
return A().useActionState(
|
|
1158
|
-
e,
|
|
1159
|
-
r,
|
|
1160
|
-
i
|
|
1161
|
-
);
|
|
1162
|
-
}, n.useCallback = function(e, r) {
|
|
1163
|
-
return A().useCallback(e, r);
|
|
1164
|
-
}, n.useContext = function(e) {
|
|
1165
|
-
var r = A();
|
|
1166
|
-
return e.$$typeof === f && console.error(
|
|
1167
|
-
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
1168
|
-
), r.useContext(e);
|
|
1169
|
-
}, n.useDebugValue = function(e, r) {
|
|
1170
|
-
return A().useDebugValue(e, r);
|
|
1171
|
-
}, n.useDeferredValue = function(e, r) {
|
|
1172
|
-
return A().useDeferredValue(e, r);
|
|
1173
|
-
}, n.useEffect = function(e, r) {
|
|
1174
|
-
return e == null && console.warn(
|
|
1175
|
-
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1176
|
-
), A().useEffect(e, r);
|
|
1177
|
-
}, n.useEffectEvent = function(e) {
|
|
1178
|
-
return A().useEffectEvent(e);
|
|
1179
|
-
}, n.useId = function() {
|
|
1180
|
-
return A().useId();
|
|
1181
|
-
}, n.useImperativeHandle = function(e, r, i) {
|
|
1182
|
-
return A().useImperativeHandle(e, r, i);
|
|
1183
|
-
}, n.useInsertionEffect = function(e, r) {
|
|
1184
|
-
return e == null && console.warn(
|
|
1185
|
-
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1186
|
-
), A().useInsertionEffect(e, r);
|
|
1187
|
-
}, n.useLayoutEffect = function(e, r) {
|
|
1188
|
-
return e == null && console.warn(
|
|
1189
|
-
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1190
|
-
), A().useLayoutEffect(e, r);
|
|
1191
|
-
}, n.useMemo = function(e, r) {
|
|
1192
|
-
return A().useMemo(e, r);
|
|
1193
|
-
}, n.useOptimistic = function(e, r) {
|
|
1194
|
-
return A().useOptimistic(e, r);
|
|
1195
|
-
}, n.useReducer = function(e, r, i) {
|
|
1196
|
-
return A().useReducer(e, r, i);
|
|
1197
|
-
}, n.useRef = function(e) {
|
|
1198
|
-
return A().useRef(e);
|
|
1199
|
-
}, n.useState = function(e) {
|
|
1200
|
-
return A().useState(e);
|
|
1201
|
-
}, n.useSyncExternalStore = function(e, r, i) {
|
|
1202
|
-
return A().useSyncExternalStore(
|
|
1203
|
-
e,
|
|
1204
|
-
r,
|
|
1205
|
-
i
|
|
1206
|
-
);
|
|
1207
|
-
}, n.useTransition = function() {
|
|
1208
|
-
return A().useTransition();
|
|
1209
|
-
}, n.version = "19.2.3", typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1210
|
-
})();
|
|
1211
|
-
})(he, he.exports)), he.exports;
|
|
1212
|
-
}
|
|
1213
|
-
var xe;
|
|
1214
|
-
function Ge() {
|
|
1215
|
-
return xe || (xe = 1, process.env.NODE_ENV === "production" ? ke.exports = Ze() : ke.exports = et()), ke.exports;
|
|
1216
|
-
}
|
|
1217
|
-
var M = Ge();
|
|
1218
|
-
const tt = typeof process < "u" && process.env?.NODE_ENV === "production", ze = typeof process < "u" && process.env?.MCP_DEBUG, _e = ze === "true" || !tt && ze !== "false", E = {
|
|
1219
|
-
log: (...v) => {
|
|
1220
|
-
_e && console.log(...v);
|
|
1221
|
-
},
|
|
1222
|
-
debug: (...v) => {
|
|
1223
|
-
_e && console.debug(...v);
|
|
1224
|
-
},
|
|
1225
|
-
info: (...v) => {
|
|
1226
|
-
console.info(...v);
|
|
1227
|
-
},
|
|
1228
|
-
error: (...v) => {
|
|
1229
|
-
console.error(...v);
|
|
1230
|
-
},
|
|
1231
|
-
warn: (...v) => {
|
|
1232
|
-
_e && console.warn(...v);
|
|
1233
|
-
}
|
|
1234
|
-
};
|
|
1235
|
-
class rt {
|
|
1236
|
-
// Configurable worker script URLs (defaults kept for backward compatibility)
|
|
1237
|
-
sharedWorkerUrl = "/mcp-shared-worker.js";
|
|
1238
|
-
serviceWorkerUrl = "/mcp-service-worker.js";
|
|
1239
|
-
// Backend websocket URL to pass into the worker(s)
|
|
1240
|
-
backendWsUrl = "ws://localhost:3001";
|
|
1241
|
-
serviceWorkerRegistration = null;
|
|
1242
|
-
sharedWorker = null;
|
|
1243
|
-
sharedWorkerPort = null;
|
|
1244
|
-
workerType = null;
|
|
1245
|
-
pendingAuthToken = null;
|
|
1246
|
-
// connection status subscribers
|
|
1247
|
-
connectionStatusCallbacks = /* @__PURE__ */ new Set();
|
|
1248
|
-
// Mutex/promise to prevent concurrent init runs
|
|
1249
|
-
initPromise = null;
|
|
1250
|
-
// Initialization state
|
|
1251
|
-
isInitialized = !1;
|
|
1252
|
-
initResolvers = [];
|
|
1253
|
-
// Queue for operations that need to wait for initialization
|
|
1254
|
-
pendingRegistrations = [];
|
|
1255
|
-
// Map to store tool handlers in main thread
|
|
1256
|
-
toolHandlers = /* @__PURE__ */ new Map();
|
|
1257
|
-
// Tool registry for tracking registrations and reference counting
|
|
1258
|
-
toolRegistry = /* @__PURE__ */ new Map();
|
|
1259
|
-
// Subscribers for tool changes (for React hooks reactivity)
|
|
1260
|
-
toolChangeListeners = /* @__PURE__ */ new Map();
|
|
1261
|
-
// Initialize and choose worker implementation (prefer SharedWorker)
|
|
1262
|
-
// Accept either a ServiceWorkerRegistration OR WorkerInitOptions to configure URLs
|
|
1263
|
-
async init(n) {
|
|
1264
|
-
E.log("[WorkerClient] init() called", {
|
|
1265
|
-
hasOptions: !!n,
|
|
1266
|
-
currentWorkerType: this.workerType,
|
|
1267
|
-
initInProgress: !!this.initPromise,
|
|
1268
|
-
timestamp: Date.now()
|
|
1269
|
-
});
|
|
1270
|
-
let s;
|
|
1271
|
-
const a = n;
|
|
1272
|
-
if (a && typeof a.scope == "string")
|
|
1273
|
-
s = n, E.log("[WorkerClient] Using explicit ServiceWorker registration");
|
|
1274
|
-
else if (n) {
|
|
1275
|
-
const u = n;
|
|
1276
|
-
E.log("[WorkerClient] Using WorkerClientInitOptions:", u), u.sharedWorkerUrl && (this.sharedWorkerUrl = u.sharedWorkerUrl), u.serviceWorkerUrl && (this.serviceWorkerUrl = u.serviceWorkerUrl), u.backendWsUrl && (this.backendWsUrl = u.backendWsUrl);
|
|
1277
|
-
}
|
|
1278
|
-
return this.initPromise ? this.initPromise.then(async () => {
|
|
1279
|
-
s && this.workerType !== "service" && await this.init(s);
|
|
1280
|
-
}) : (this.initPromise = (async () => {
|
|
1281
|
-
try {
|
|
1282
|
-
if (s) {
|
|
1283
|
-
this.serviceWorkerRegistration = s, this.workerType = "service", E.info(
|
|
1284
|
-
"[WorkerClient] Using ServiceWorker (explicit registration)"
|
|
1285
|
-
);
|
|
1286
|
-
try {
|
|
1287
|
-
const d = {
|
|
1288
|
-
type: "INIT",
|
|
1289
|
-
backendUrl: this.backendWsUrl
|
|
1290
|
-
};
|
|
1291
|
-
this.pendingAuthToken && (d.token = this.pendingAuthToken), this.serviceWorkerRegistration.active ? this.serviceWorkerRegistration.active.postMessage(d) : "serviceWorker" in navigator && navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage(d);
|
|
1292
|
-
} catch {
|
|
1293
|
-
}
|
|
1294
|
-
return;
|
|
1295
|
-
}
|
|
1296
|
-
if (await this.initSharedWorker()) {
|
|
1297
|
-
this.markAsInitialized();
|
|
1298
|
-
return;
|
|
1299
|
-
}
|
|
1300
|
-
await this.initServiceWorkerFallback(), this.markAsInitialized();
|
|
1301
|
-
} finally {
|
|
1302
|
-
this.initPromise = null;
|
|
1303
|
-
}
|
|
1304
|
-
})(), this.initPromise);
|
|
1305
|
-
}
|
|
1306
|
-
/**
|
|
1307
|
-
* Mark worker as initialized and process pending registrations
|
|
1308
|
-
* @private
|
|
1309
|
-
*/
|
|
1310
|
-
markAsInitialized() {
|
|
1311
|
-
this.isInitialized = !0, E.log(
|
|
1312
|
-
"[WorkerClient] Worker initialized, processing pending operations"
|
|
1313
|
-
), this.initResolvers.forEach((s) => s()), this.initResolvers = [];
|
|
1314
|
-
const n = [...this.pendingRegistrations];
|
|
1315
|
-
this.pendingRegistrations = [], n.forEach(
|
|
1316
|
-
async ({ name: s, description: a, inputSchema: u, handler: d, resolve: y, reject: b }) => {
|
|
1317
|
-
try {
|
|
1318
|
-
await this.registerToolInternal(
|
|
1319
|
-
s,
|
|
1320
|
-
a,
|
|
1321
|
-
u,
|
|
1322
|
-
d
|
|
1323
|
-
), y();
|
|
1324
|
-
} catch (O) {
|
|
1325
|
-
b(O instanceof Error ? O : new Error(String(O)));
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* Wait for worker initialization
|
|
1332
|
-
* @returns Promise that resolves when worker is initialized
|
|
1333
|
-
*/
|
|
1334
|
-
async waitForInit() {
|
|
1335
|
-
if (this.isInitialized)
|
|
1336
|
-
return Promise.resolve();
|
|
1337
|
-
if (this.initPromise) {
|
|
1338
|
-
await this.initPromise;
|
|
1339
|
-
return;
|
|
1340
|
-
}
|
|
1341
|
-
return new Promise((n) => {
|
|
1342
|
-
this.initResolvers.push(n);
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
/**
|
|
1346
|
-
* Check if worker is initialized
|
|
1347
|
-
*/
|
|
1348
|
-
get initialized() {
|
|
1349
|
-
return this.isInitialized;
|
|
1350
|
-
}
|
|
1351
|
-
async initSharedWorker() {
|
|
1352
|
-
if (typeof SharedWorker > "u")
|
|
1353
|
-
return Promise.resolve(!1);
|
|
1354
|
-
try {
|
|
1355
|
-
this.sharedWorker = new SharedWorker(this.sharedWorkerUrl, {
|
|
1356
|
-
type: "module"
|
|
1357
|
-
}), this.sharedWorkerPort = this.sharedWorker.port, this.sharedWorkerPort.start(), await new Promise((s, a) => {
|
|
1358
|
-
let u = !1;
|
|
1359
|
-
const d = setTimeout(() => {
|
|
1360
|
-
if (!u) {
|
|
1361
|
-
const b = this.sharedWorkerPort;
|
|
1362
|
-
b && (b.onmessage = null), a(new Error("SharedWorker initialization timeout"));
|
|
1363
|
-
}
|
|
1364
|
-
}, 2e3), y = this.sharedWorkerPort;
|
|
1365
|
-
if (!y)
|
|
1366
|
-
return clearTimeout(d), a(new Error("SharedWorker port not available"));
|
|
1367
|
-
y.onmessage = (b) => {
|
|
1368
|
-
try {
|
|
1369
|
-
const O = b.data;
|
|
1370
|
-
O && O.type === "CONNECTION_STATUS" && (clearTimeout(d), u = !0, this.workerType = "shared", y.onmessage = null, s(!0));
|
|
1371
|
-
} catch {
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
});
|
|
1375
|
-
const n = this.sharedWorkerPort;
|
|
1376
|
-
if (n) {
|
|
1377
|
-
try {
|
|
1378
|
-
const s = {
|
|
1379
|
-
type: "INIT",
|
|
1380
|
-
backendUrl: this.backendWsUrl
|
|
1381
|
-
};
|
|
1382
|
-
this.pendingAuthToken && (s.token = this.pendingAuthToken), n.postMessage(s), this.pendingAuthToken = null;
|
|
1383
|
-
} catch (s) {
|
|
1384
|
-
E.warn(
|
|
1385
|
-
"[WorkerClient] Failed to send INIT to SharedWorker port:",
|
|
1386
|
-
s
|
|
1387
|
-
);
|
|
1388
|
-
}
|
|
1389
|
-
n.onmessage = (s) => {
|
|
1390
|
-
try {
|
|
1391
|
-
const a = s.data;
|
|
1392
|
-
if (a && a.type === "CONNECTION_STATUS") {
|
|
1393
|
-
const u = !!a.connected;
|
|
1394
|
-
this.connectionStatusCallbacks.forEach((d) => {
|
|
1395
|
-
try {
|
|
1396
|
-
d(u);
|
|
1397
|
-
} catch {
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
} else a && a.type === "CALL_TOOL" && this.handleToolCall(a.toolName, a.args, a.callId).catch(
|
|
1401
|
-
(u) => {
|
|
1402
|
-
E.error(
|
|
1403
|
-
"[WorkerClient] Failed to handle tool call:",
|
|
1404
|
-
u
|
|
1405
|
-
);
|
|
1406
|
-
}
|
|
1407
|
-
);
|
|
1408
|
-
} catch {
|
|
1409
|
-
}
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
return E.info("[WorkerClient] Using SharedWorker"), !0;
|
|
1413
|
-
} catch (n) {
|
|
1414
|
-
return E.warn(
|
|
1415
|
-
"[WorkerClient] SharedWorker not available, falling back to ServiceWorker:",
|
|
1416
|
-
n
|
|
1417
|
-
), !1;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
async initServiceWorkerFallback() {
|
|
1421
|
-
if ("serviceWorker" in navigator)
|
|
1422
|
-
try {
|
|
1423
|
-
const n = await navigator.serviceWorker.getRegistration();
|
|
1424
|
-
if (n) {
|
|
1425
|
-
this.serviceWorkerRegistration = n, this.workerType = "service", E.info(
|
|
1426
|
-
"[WorkerClient] Using existing ServiceWorker registration"
|
|
1427
|
-
);
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
this.serviceWorkerRegistration = await navigator.serviceWorker.register(
|
|
1431
|
-
this.serviceWorkerUrl
|
|
1432
|
-
), this.workerType = "service", "serviceWorker" in navigator && navigator.serviceWorker.addEventListener(
|
|
1433
|
-
"message",
|
|
1434
|
-
(s) => {
|
|
1435
|
-
try {
|
|
1436
|
-
const a = s.data;
|
|
1437
|
-
a && a.type === "CALL_TOOL" && this.handleToolCall(
|
|
1438
|
-
a.toolName,
|
|
1439
|
-
a.args,
|
|
1440
|
-
a.callId
|
|
1441
|
-
).catch((u) => {
|
|
1442
|
-
E.error(
|
|
1443
|
-
"[WorkerClient] Failed to handle tool call:",
|
|
1444
|
-
u
|
|
1445
|
-
);
|
|
1446
|
-
});
|
|
1447
|
-
} catch (a) {
|
|
1448
|
-
E.error(
|
|
1449
|
-
"[WorkerClient] Error processing ServiceWorker message:",
|
|
1450
|
-
a
|
|
1451
|
-
);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
), E.info("[WorkerClient] Using MCP ServiceWorker (fallback)");
|
|
1455
|
-
try {
|
|
1456
|
-
const s = {
|
|
1457
|
-
type: "INIT",
|
|
1458
|
-
backendUrl: this.backendWsUrl
|
|
1459
|
-
};
|
|
1460
|
-
this.pendingAuthToken && (s.token = this.pendingAuthToken), this.serviceWorkerRegistration.active ? this.serviceWorkerRegistration.active.postMessage(s) : "serviceWorker" in navigator && navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage(s), this.pendingAuthToken = null;
|
|
1461
|
-
} catch {
|
|
1462
|
-
}
|
|
1463
|
-
} catch (n) {
|
|
1464
|
-
throw E.error("[WorkerClient] Failed to register ServiceWorker:", n), n;
|
|
1465
|
-
}
|
|
1466
|
-
else
|
|
1467
|
-
throw new Error("Neither SharedWorker nor ServiceWorker is supported");
|
|
1468
|
-
}
|
|
1469
|
-
// Low-level request that expects a reply via MessageChannel
|
|
1470
|
-
async request(n, s, a = 5e3) {
|
|
1471
|
-
if (E.log("[WorkerClient] Request started:", {
|
|
1472
|
-
type: n,
|
|
1473
|
-
payload: s,
|
|
1474
|
-
timeoutMs: a,
|
|
1475
|
-
workerType: this.workerType,
|
|
1476
|
-
hasSharedWorkerPort: !!this.sharedWorkerPort,
|
|
1477
|
-
hasServiceWorkerReg: !!this.serviceWorkerRegistration
|
|
1478
|
-
}), this.workerType === "shared" && this.sharedWorkerPort)
|
|
1479
|
-
return new Promise((u, d) => {
|
|
1480
|
-
const y = new MessageChannel(), b = Math.random().toString(36).substring(7), O = Date.now(), I = setTimeout(() => {
|
|
1481
|
-
const m = Date.now() - O;
|
|
1482
|
-
E.error("[WorkerClient] Request timeout:", {
|
|
1483
|
-
type: n,
|
|
1484
|
-
requestId: b,
|
|
1485
|
-
elapsed: m,
|
|
1486
|
-
timeoutMs: a
|
|
1487
|
-
}), y.port1.onmessage = null, d(new Error("Request timeout"));
|
|
1488
|
-
}, a);
|
|
1489
|
-
y.port1.onmessage = (m) => {
|
|
1490
|
-
try {
|
|
1491
|
-
const k = Date.now() - O;
|
|
1492
|
-
E.log("[WorkerClient] Request response received:", {
|
|
1493
|
-
type: n,
|
|
1494
|
-
requestId: b,
|
|
1495
|
-
elapsed: k,
|
|
1496
|
-
success: m.data?.success
|
|
1497
|
-
}), clearTimeout(I), m.data && m.data.success ? u(m.data) : m.data && m.data.success === !1 ? d(new Error(m.data.error || "Worker error")) : u(m.data);
|
|
1498
|
-
} catch (k) {
|
|
1499
|
-
clearTimeout(I), y.port1.onmessage = null, d(
|
|
1500
|
-
k instanceof Error ? k : new Error(String(k))
|
|
1501
|
-
);
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
try {
|
|
1505
|
-
const m = this.sharedWorkerPort;
|
|
1506
|
-
if (!m)
|
|
1507
|
-
return clearTimeout(I), E.error("[WorkerClient] SharedWorker port not available"), d(new Error("SharedWorker port not available"));
|
|
1508
|
-
E.log("[WorkerClient] Posting message to SharedWorker:", {
|
|
1509
|
-
type: n,
|
|
1510
|
-
requestId: b
|
|
1511
|
-
}), m.postMessage({ type: n, ...s || {} }, [y.port2]);
|
|
1512
|
-
} catch (m) {
|
|
1513
|
-
clearTimeout(I), E.error("[WorkerClient] Failed to post message:", m), d(m instanceof Error ? m : new Error(String(m)));
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1516
|
-
if (this.workerType === "service" && this.serviceWorkerRegistration) {
|
|
1517
|
-
const u = this.serviceWorkerRegistration;
|
|
1518
|
-
if (!u) throw new Error("Service worker registration missing");
|
|
1519
|
-
if (!u.active && (E.log("[WorkerClient] ServiceWorker not active, waiting..."), await navigator.serviceWorker.ready, !u.active))
|
|
1520
|
-
throw new Error("Service worker not active");
|
|
1521
|
-
return new Promise((d, y) => {
|
|
1522
|
-
const b = new MessageChannel(), O = Math.random().toString(36).substring(7), I = Date.now(), m = setTimeout(() => {
|
|
1523
|
-
const k = Date.now() - I;
|
|
1524
|
-
E.error("[WorkerClient] ServiceWorker request timeout:", {
|
|
1525
|
-
type: n,
|
|
1526
|
-
requestId: O,
|
|
1527
|
-
elapsed: k,
|
|
1528
|
-
timeoutMs: a
|
|
1529
|
-
}), b.port1.onmessage = null, y(new Error("Request timeout"));
|
|
1530
|
-
}, a);
|
|
1531
|
-
b.port1.onmessage = (k) => {
|
|
1532
|
-
try {
|
|
1533
|
-
const L = Date.now() - I;
|
|
1534
|
-
E.log("[WorkerClient] ServiceWorker response received:", {
|
|
1535
|
-
type: n,
|
|
1536
|
-
requestId: O,
|
|
1537
|
-
elapsed: L,
|
|
1538
|
-
success: k.data?.success
|
|
1539
|
-
}), clearTimeout(m), k.data && k.data.success ? d(k.data) : k.data && k.data.success === !1 ? y(new Error(k.data.error || "Worker error")) : d(k.data);
|
|
1540
|
-
} catch (L) {
|
|
1541
|
-
clearTimeout(m), b.port1.onmessage = null, y(
|
|
1542
|
-
L instanceof Error ? L : new Error(String(L))
|
|
1543
|
-
);
|
|
1544
|
-
}
|
|
1545
|
-
};
|
|
1546
|
-
try {
|
|
1547
|
-
const k = u.active;
|
|
1548
|
-
if (!k)
|
|
1549
|
-
return clearTimeout(m), E.error(
|
|
1550
|
-
"[WorkerClient] ServiceWorker active instance not available"
|
|
1551
|
-
), y(
|
|
1552
|
-
new Error("Service worker active instance not available")
|
|
1553
|
-
);
|
|
1554
|
-
E.log("[WorkerClient] Posting message to ServiceWorker:", {
|
|
1555
|
-
type: n,
|
|
1556
|
-
requestId: O
|
|
1557
|
-
}), k.postMessage({ type: n, ...s || {} }, [b.port2]);
|
|
1558
|
-
} catch (k) {
|
|
1559
|
-
clearTimeout(m), E.error(
|
|
1560
|
-
"[WorkerClient] Failed to post message to ServiceWorker:",
|
|
1561
|
-
k
|
|
1562
|
-
), y(k instanceof Error ? k : new Error(String(k)));
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
1566
|
-
throw new Error("No worker registered");
|
|
1567
|
-
}
|
|
1568
|
-
// Fire-and-forget postMessage (no response expected)
|
|
1569
|
-
async post(n, s) {
|
|
1570
|
-
if (this.workerType === "shared" && this.sharedWorkerPort) {
|
|
1571
|
-
try {
|
|
1572
|
-
this.sharedWorkerPort.postMessage({ type: n, ...s || {} });
|
|
1573
|
-
} catch (a) {
|
|
1574
|
-
E.error("[WorkerClient] Failed to post to SharedWorker:", a);
|
|
1575
|
-
}
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
if (this.workerType === "service" && this.serviceWorkerRegistration?.active) {
|
|
1579
|
-
try {
|
|
1580
|
-
this.serviceWorkerRegistration.active.postMessage({
|
|
1581
|
-
type: n,
|
|
1582
|
-
...s || {}
|
|
1583
|
-
});
|
|
1584
|
-
} catch (a) {
|
|
1585
|
-
E.error(
|
|
1586
|
-
"[WorkerClient] Failed to post to ServiceWorker (active):",
|
|
1587
|
-
a
|
|
1588
|
-
);
|
|
1589
|
-
}
|
|
1590
|
-
return;
|
|
1591
|
-
}
|
|
1592
|
-
if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
|
|
1593
|
-
try {
|
|
1594
|
-
navigator.serviceWorker.controller.postMessage({
|
|
1595
|
-
type: n,
|
|
1596
|
-
...s || {}
|
|
1597
|
-
});
|
|
1598
|
-
} catch (a) {
|
|
1599
|
-
E.error(
|
|
1600
|
-
"[WorkerClient] Failed to post to ServiceWorker.controller:",
|
|
1601
|
-
a
|
|
1602
|
-
);
|
|
1603
|
-
}
|
|
1604
|
-
return;
|
|
1605
|
-
}
|
|
1606
|
-
if (n === "SET_AUTH_TOKEN" && s) {
|
|
1607
|
-
const a = s.token;
|
|
1608
|
-
typeof a == "string" && (this.pendingAuthToken = a);
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
sendAuthTokenToServiceWorker(n) {
|
|
1612
|
-
if (this.serviceWorkerRegistration?.active)
|
|
1613
|
-
try {
|
|
1614
|
-
this.serviceWorkerRegistration.active.postMessage({
|
|
1615
|
-
type: "SET_AUTH_TOKEN",
|
|
1616
|
-
token: n
|
|
1617
|
-
});
|
|
1618
|
-
} catch (s) {
|
|
1619
|
-
console.error(
|
|
1620
|
-
"[WorkerClient] Failed to send auth token to ServiceWorker:",
|
|
1621
|
-
s
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
else if ("serviceWorker" in navigator && navigator.serviceWorker.controller)
|
|
1625
|
-
try {
|
|
1626
|
-
navigator.serviceWorker.controller.postMessage({
|
|
1627
|
-
type: "SET_AUTH_TOKEN",
|
|
1628
|
-
token: n
|
|
1629
|
-
});
|
|
1630
|
-
} catch (s) {
|
|
1631
|
-
console.error(
|
|
1632
|
-
"[WorkerClient] Failed to send auth token to ServiceWorker.controller:",
|
|
1633
|
-
s
|
|
1634
|
-
);
|
|
1635
|
-
}
|
|
1636
|
-
else
|
|
1637
|
-
this.pendingAuthToken = n;
|
|
1638
|
-
}
|
|
1639
|
-
// Subscription API for consumers to listen for connection status updates
|
|
1640
|
-
onConnectionStatus(n) {
|
|
1641
|
-
this.connectionStatusCallbacks.add(n);
|
|
1642
|
-
}
|
|
1643
|
-
offConnectionStatus(n) {
|
|
1644
|
-
this.connectionStatusCallbacks.delete(n);
|
|
1645
|
-
}
|
|
1646
|
-
async getConnectionStatus() {
|
|
1647
|
-
try {
|
|
1648
|
-
const n = await this.request(
|
|
1649
|
-
"GET_CONNECTION_STATUS",
|
|
1650
|
-
void 0,
|
|
1651
|
-
2e3
|
|
1652
|
-
);
|
|
1653
|
-
return n && typeof n == "object" && "connected" in n ? !!n.connected : !!n?.connected;
|
|
1654
|
-
} catch {
|
|
1655
|
-
return !1;
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
setAuthToken(n) {
|
|
1659
|
-
if (this.pendingAuthToken = n, this.workerType === "shared" && this.sharedWorkerPort)
|
|
1660
|
-
try {
|
|
1661
|
-
this.sharedWorkerPort.postMessage({ type: "SET_AUTH_TOKEN", token: n }), this.pendingAuthToken = null;
|
|
1662
|
-
} catch (s) {
|
|
1663
|
-
E.error(
|
|
1664
|
-
"[WorkerClient] Failed to set auth token on SharedWorker:",
|
|
1665
|
-
s
|
|
1666
|
-
);
|
|
1667
|
-
}
|
|
1668
|
-
else this.workerType === "service" && (this.sendAuthTokenToServiceWorker(n), this.pendingAuthToken = null);
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Register a custom MCP tool dynamically
|
|
1672
|
-
*
|
|
1673
|
-
* The handler function runs in the MAIN THREAD (browser context), not in the worker.
|
|
1674
|
-
* This means you have full access to:
|
|
1675
|
-
* - React context, hooks, Redux store
|
|
1676
|
-
* - DOM API, window, localStorage
|
|
1677
|
-
* - All your imports and dependencies
|
|
1678
|
-
* - Closures and external variables
|
|
1679
|
-
*
|
|
1680
|
-
* The worker acts as a proxy - it receives MCP tool calls and forwards them
|
|
1681
|
-
* to your handler via MessageChannel.
|
|
1682
|
-
*
|
|
1683
|
-
* @param name - Tool name
|
|
1684
|
-
* @param description - Tool description
|
|
1685
|
-
* @param inputSchema - JSON Schema for tool inputs
|
|
1686
|
-
* @param handler - Async function that handles the tool execution (runs in main thread)
|
|
1687
|
-
* @returns Promise that resolves when tool is registered
|
|
1688
|
-
*
|
|
1689
|
-
* @example With full access to imports and context:
|
|
1690
|
-
* ```typescript
|
|
1691
|
-
* import { z } from 'zod';
|
|
1692
|
-
* import { useMyStore } from './store';
|
|
1693
|
-
*
|
|
1694
|
-
* const store = useMyStore();
|
|
1695
|
-
*
|
|
1696
|
-
* await client.registerTool(
|
|
1697
|
-
* 'validate_user',
|
|
1698
|
-
* 'Validate user data',
|
|
1699
|
-
* { type: 'object', properties: { username: { type: 'string' } } },
|
|
1700
|
-
* async (args: any) => {
|
|
1701
|
-
* // Full access to everything!
|
|
1702
|
-
* const schema = z.object({ username: z.string().min(3) });
|
|
1703
|
-
* const validated = schema.parse(args);
|
|
1704
|
-
*
|
|
1705
|
-
* // Can access store, context, etc.
|
|
1706
|
-
* const currentUser = store.getState().user;
|
|
1707
|
-
*
|
|
1708
|
-
* return {
|
|
1709
|
-
* content: [{
|
|
1710
|
-
* type: 'text',
|
|
1711
|
-
* text: JSON.stringify({ validated, currentUser })
|
|
1712
|
-
* }]
|
|
1713
|
-
* };
|
|
1714
|
-
* }
|
|
1715
|
-
* );
|
|
1716
|
-
* ```
|
|
1717
|
-
*/
|
|
1718
|
-
async registerTool(n, s, a, u) {
|
|
1719
|
-
return this.isInitialized ? this.registerToolInternal(n, s, a, u) : (E.log(
|
|
1720
|
-
`[WorkerClient] Queueing tool registration '${n}' (worker not initialized yet)`
|
|
1721
|
-
), new Promise((d, y) => {
|
|
1722
|
-
this.pendingRegistrations.push({
|
|
1723
|
-
name: n,
|
|
1724
|
-
description: s,
|
|
1725
|
-
inputSchema: a,
|
|
1726
|
-
handler: u,
|
|
1727
|
-
resolve: d,
|
|
1728
|
-
reject: y
|
|
1729
|
-
});
|
|
1730
|
-
}));
|
|
1731
|
-
}
|
|
1732
|
-
/**
|
|
1733
|
-
* Internal method to register tool (assumes worker is initialized)
|
|
1734
|
-
* @private
|
|
1735
|
-
*/
|
|
1736
|
-
async registerToolInternal(n, s, a, u) {
|
|
1737
|
-
const d = this.toolRegistry.get(n);
|
|
1738
|
-
if (d) {
|
|
1739
|
-
d.refCount++, E.log(
|
|
1740
|
-
`[WorkerClient] Incremented ref count for '${n}': ${d.refCount}`
|
|
1741
|
-
), this.toolHandlers.set(n, u), this.notifyToolChange(n);
|
|
1742
|
-
return;
|
|
1743
|
-
}
|
|
1744
|
-
this.toolHandlers.set(n, u), await this.request("REGISTER_TOOL", {
|
|
1745
|
-
name: n,
|
|
1746
|
-
description: s,
|
|
1747
|
-
inputSchema: a,
|
|
1748
|
-
handlerType: "proxy"
|
|
1749
|
-
// Tell worker this is a proxy handler
|
|
1750
|
-
}), this.toolRegistry.set(n, {
|
|
1751
|
-
refCount: 1,
|
|
1752
|
-
description: s,
|
|
1753
|
-
inputSchema: a,
|
|
1754
|
-
isRegistered: !0
|
|
1755
|
-
}), E.log(
|
|
1756
|
-
`[WorkerClient] Registered tool '${n}' with main-thread handler`
|
|
1757
|
-
), this.notifyToolChange(n);
|
|
1758
|
-
}
|
|
1759
|
-
/**
|
|
1760
|
-
* Unregister a previously registered MCP tool
|
|
1761
|
-
* @param name - Tool name to unregister
|
|
1762
|
-
* @returns Promise that resolves to true if tool was found and removed
|
|
1763
|
-
*/
|
|
1764
|
-
async unregisterTool(n) {
|
|
1765
|
-
const s = this.toolRegistry.get(n);
|
|
1766
|
-
if (!s)
|
|
1767
|
-
return E.warn(`[WorkerClient] Cannot unregister '${n}': not found`), !1;
|
|
1768
|
-
if (s.refCount--, E.log(
|
|
1769
|
-
`[WorkerClient] Decremented ref count for '${n}': ${s.refCount}`
|
|
1770
|
-
), s.refCount <= 0) {
|
|
1771
|
-
this.toolHandlers.delete(n);
|
|
1772
|
-
const a = await this.request(
|
|
1773
|
-
"UNREGISTER_TOOL",
|
|
1774
|
-
{ name: n }
|
|
1775
|
-
);
|
|
1776
|
-
return this.toolRegistry.delete(n), E.log(`[WorkerClient] Unregistered tool '${n}'`), this.notifyToolChange(n), a?.success ?? !1;
|
|
1777
|
-
}
|
|
1778
|
-
return this.notifyToolChange(n), !0;
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Subscribe to tool changes for a specific tool
|
|
1782
|
-
* Returns unsubscribe function
|
|
1783
|
-
*/
|
|
1784
|
-
onToolChange(n, s) {
|
|
1785
|
-
this.toolChangeListeners.has(n) || this.toolChangeListeners.set(n, /* @__PURE__ */ new Set());
|
|
1786
|
-
const a = this.toolChangeListeners.get(n);
|
|
1787
|
-
a.add(s);
|
|
1788
|
-
const u = this.toolRegistry.get(n);
|
|
1789
|
-
return s(u ? {
|
|
1790
|
-
refCount: u.refCount,
|
|
1791
|
-
isRegistered: u.isRegistered
|
|
1792
|
-
} : null), () => {
|
|
1793
|
-
a.delete(s), a.size === 0 && this.toolChangeListeners.delete(n);
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* Notify all listeners about tool changes
|
|
1798
|
-
* @private
|
|
1799
|
-
*/
|
|
1800
|
-
notifyToolChange(n) {
|
|
1801
|
-
const s = this.toolChangeListeners.get(n);
|
|
1802
|
-
if (!s || s.size === 0) return;
|
|
1803
|
-
const a = this.toolRegistry.get(n), u = a ? {
|
|
1804
|
-
refCount: a.refCount,
|
|
1805
|
-
isRegistered: a.isRegistered
|
|
1806
|
-
} : null;
|
|
1807
|
-
s.forEach((d) => {
|
|
1808
|
-
try {
|
|
1809
|
-
d(u);
|
|
1810
|
-
} catch (y) {
|
|
1811
|
-
E.error("[WorkerClient] Error in tool change listener:", y);
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
/**
|
|
1816
|
-
* Get tool info from registry
|
|
1817
|
-
*/
|
|
1818
|
-
getToolInfo(n) {
|
|
1819
|
-
const s = this.toolRegistry.get(n);
|
|
1820
|
-
return s ? {
|
|
1821
|
-
refCount: s.refCount,
|
|
1822
|
-
isRegistered: s.isRegistered
|
|
1823
|
-
} : null;
|
|
1824
|
-
}
|
|
1825
|
-
/**
|
|
1826
|
-
* Get all registered tool names
|
|
1827
|
-
*/
|
|
1828
|
-
getRegisteredTools() {
|
|
1829
|
-
return Array.from(this.toolRegistry.keys()).filter(
|
|
1830
|
-
(n) => this.toolRegistry.get(n)?.isRegistered
|
|
1831
|
-
);
|
|
1832
|
-
}
|
|
1833
|
-
/**
|
|
1834
|
-
* Check if a tool is registered
|
|
1835
|
-
*/
|
|
1836
|
-
isToolRegistered(n) {
|
|
1837
|
-
return this.toolRegistry.get(n)?.isRegistered ?? !1;
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* Handle tool call from worker - execute handler in main thread and return result
|
|
1841
|
-
* @private
|
|
1842
|
-
*/
|
|
1843
|
-
async handleToolCall(n, s, a) {
|
|
1844
|
-
E.log(`[WorkerClient] Handling tool call: ${n}`, {
|
|
1845
|
-
callId: a,
|
|
1846
|
-
args: s
|
|
1847
|
-
});
|
|
1848
|
-
try {
|
|
1849
|
-
const u = this.toolHandlers.get(n);
|
|
1850
|
-
if (!u)
|
|
1851
|
-
throw new Error(`Tool handler not found: ${n}`);
|
|
1852
|
-
const d = await u(s);
|
|
1853
|
-
this.sendToolCallResult(a, { success: !0, result: d });
|
|
1854
|
-
} catch (u) {
|
|
1855
|
-
E.error(`[WorkerClient] Tool call failed: ${n}`, u), this.sendToolCallResult(a, {
|
|
1856
|
-
success: !1,
|
|
1857
|
-
error: u instanceof Error ? u.message : "Unknown error"
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* Send tool call result back to worker
|
|
1863
|
-
* @private
|
|
1864
|
-
*/
|
|
1865
|
-
sendToolCallResult(n, s) {
|
|
1866
|
-
const a = {
|
|
1867
|
-
type: "TOOL_CALL_RESULT",
|
|
1868
|
-
callId: n,
|
|
1869
|
-
success: s.success,
|
|
1870
|
-
result: s.result,
|
|
1871
|
-
error: s.error
|
|
1872
|
-
};
|
|
1873
|
-
if (this.workerType === "shared" && this.sharedWorkerPort)
|
|
1874
|
-
try {
|
|
1875
|
-
this.sharedWorkerPort.postMessage(a);
|
|
1876
|
-
} catch (u) {
|
|
1877
|
-
E.error(
|
|
1878
|
-
"[WorkerClient] Failed to send result to SharedWorker:",
|
|
1879
|
-
u
|
|
1880
|
-
);
|
|
1881
|
-
}
|
|
1882
|
-
else if (this.workerType === "service" && this.serviceWorkerRegistration?.active)
|
|
1883
|
-
try {
|
|
1884
|
-
this.serviceWorkerRegistration.active.postMessage(a);
|
|
1885
|
-
} catch (u) {
|
|
1886
|
-
E.error(
|
|
1887
|
-
"[WorkerClient] Failed to send result to ServiceWorker:",
|
|
1888
|
-
u
|
|
1889
|
-
);
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
const J = new rt();
|
|
1894
|
-
function Be(v) {
|
|
1
|
+
import { useState as m, useRef as P, useEffect as M, useCallback as f, createContext as $, useContext as I } from "react";
|
|
2
|
+
import { workerClient as u } from "@mcp-fe/mcp-worker";
|
|
3
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
4
|
+
function b(t) {
|
|
1895
5
|
const {
|
|
1896
|
-
name:
|
|
6
|
+
name: e,
|
|
1897
7
|
description: s,
|
|
1898
|
-
inputSchema:
|
|
1899
|
-
handler:
|
|
1900
|
-
autoRegister:
|
|
1901
|
-
autoUnregister:
|
|
1902
|
-
} =
|
|
1903
|
-
M
|
|
1904
|
-
|
|
1905
|
-
}, [
|
|
1906
|
-
const
|
|
1907
|
-
const
|
|
8
|
+
inputSchema: i,
|
|
9
|
+
handler: r,
|
|
10
|
+
autoRegister: a = !0,
|
|
11
|
+
autoUnregister: l = !0
|
|
12
|
+
} = t, [d, p] = m(null), g = P(r), T = P(e), C = P(s), w = P(i), v = P(!0), n = P(!1);
|
|
13
|
+
M(() => {
|
|
14
|
+
g.current = r, T.current = e, C.current = s, w.current = i;
|
|
15
|
+
}, [r, e, s, i]);
|
|
16
|
+
const c = f(async (o) => g.current(o), []), y = f(async () => {
|
|
17
|
+
const o = T.current, h = C.current, z = w.current;
|
|
1908
18
|
try {
|
|
1909
|
-
await
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
),
|
|
1915
|
-
} catch (
|
|
19
|
+
await u.registerTool(
|
|
20
|
+
o,
|
|
21
|
+
h,
|
|
22
|
+
z,
|
|
23
|
+
c
|
|
24
|
+
), n.current = !0, console.log(`[useMCPTool] Registered tool '${o}'`);
|
|
25
|
+
} catch (S) {
|
|
1916
26
|
throw console.error(
|
|
1917
|
-
`[useMCPTool] Failed to register tool '${
|
|
1918
|
-
|
|
1919
|
-
),
|
|
27
|
+
`[useMCPTool] Failed to register tool '${o}':`,
|
|
28
|
+
S
|
|
29
|
+
), S;
|
|
1920
30
|
}
|
|
1921
|
-
}, [
|
|
1922
|
-
const
|
|
31
|
+
}, [c]), R = f(async () => {
|
|
32
|
+
const o = T.current;
|
|
1923
33
|
try {
|
|
1924
|
-
await
|
|
1925
|
-
} catch (
|
|
34
|
+
await u.unregisterTool(o), n.current = !1, console.log(`[useMCPTool] Unregistered tool '${o}'`);
|
|
35
|
+
} catch (h) {
|
|
1926
36
|
console.error(
|
|
1927
|
-
`[useMCPTool] Failed to unregister tool '${
|
|
1928
|
-
|
|
37
|
+
`[useMCPTool] Failed to unregister tool '${o}':`,
|
|
38
|
+
h
|
|
1929
39
|
);
|
|
1930
40
|
}
|
|
1931
41
|
}, []);
|
|
1932
|
-
return M
|
|
1933
|
-
|
|
1934
|
-
}), [
|
|
42
|
+
return M(() => u.onToolChange(e, (h) => {
|
|
43
|
+
p(h);
|
|
44
|
+
}), [e]), M(() => (a && y().catch((o) => {
|
|
1935
45
|
console.error(
|
|
1936
|
-
`[useMCPTool] Auto-register failed for '${
|
|
1937
|
-
|
|
46
|
+
`[useMCPTool] Auto-register failed for '${e}':`,
|
|
47
|
+
o
|
|
1938
48
|
);
|
|
1939
49
|
}), () => {
|
|
1940
|
-
|
|
50
|
+
v.current = !1, l && n.current && R().catch((o) => {
|
|
1941
51
|
console.error(
|
|
1942
|
-
`[useMCPTool] Auto-unregister failed for '${
|
|
1943
|
-
|
|
52
|
+
`[useMCPTool] Auto-unregister failed for '${e}':`,
|
|
53
|
+
o
|
|
1944
54
|
);
|
|
1945
55
|
});
|
|
1946
|
-
}), [
|
|
1947
|
-
isRegistered:
|
|
1948
|
-
refCount:
|
|
1949
|
-
register:
|
|
1950
|
-
unregister:
|
|
56
|
+
}), [e]), {
|
|
57
|
+
isRegistered: d?.isRegistered ?? !1,
|
|
58
|
+
refCount: d?.refCount ?? 0,
|
|
59
|
+
register: y,
|
|
60
|
+
unregister: R
|
|
1951
61
|
};
|
|
1952
62
|
}
|
|
1953
|
-
function
|
|
1954
|
-
return
|
|
63
|
+
function k(t) {
|
|
64
|
+
return u.isToolRegistered(t);
|
|
1955
65
|
}
|
|
1956
|
-
function
|
|
1957
|
-
return
|
|
66
|
+
function q() {
|
|
67
|
+
return u.getRegisteredTools();
|
|
1958
68
|
}
|
|
1959
|
-
function
|
|
1960
|
-
return
|
|
69
|
+
function U(t) {
|
|
70
|
+
return u.getToolInfo(t);
|
|
1961
71
|
}
|
|
1962
|
-
function
|
|
1963
|
-
const
|
|
1964
|
-
const
|
|
72
|
+
function F(t, e, s, i) {
|
|
73
|
+
const r = f(async () => {
|
|
74
|
+
const a = await s();
|
|
1965
75
|
return {
|
|
1966
76
|
content: [
|
|
1967
77
|
{
|
|
1968
78
|
type: "text",
|
|
1969
|
-
text: JSON.stringify(
|
|
79
|
+
text: JSON.stringify(a, null, 2)
|
|
1970
80
|
}
|
|
1971
81
|
]
|
|
1972
82
|
};
|
|
1973
83
|
}, [s]);
|
|
1974
|
-
return
|
|
1975
|
-
name:
|
|
1976
|
-
description:
|
|
84
|
+
return b({
|
|
85
|
+
name: t,
|
|
86
|
+
description: e,
|
|
1977
87
|
inputSchema: {
|
|
1978
88
|
type: "object",
|
|
1979
89
|
properties: {}
|
|
1980
90
|
},
|
|
1981
|
-
handler:
|
|
1982
|
-
...
|
|
91
|
+
handler: r,
|
|
92
|
+
...i
|
|
1983
93
|
});
|
|
1984
94
|
}
|
|
1985
|
-
function
|
|
1986
|
-
const
|
|
1987
|
-
async (
|
|
1988
|
-
const
|
|
95
|
+
function H(t, e, s, i, r) {
|
|
96
|
+
const a = f(
|
|
97
|
+
async (l) => {
|
|
98
|
+
const d = await i(l);
|
|
1989
99
|
return {
|
|
1990
100
|
content: [
|
|
1991
101
|
{
|
|
1992
102
|
type: "text",
|
|
1993
|
-
text: JSON.stringify(
|
|
103
|
+
text: JSON.stringify(d, null, 2)
|
|
1994
104
|
}
|
|
1995
105
|
]
|
|
1996
106
|
};
|
|
1997
107
|
},
|
|
1998
|
-
[
|
|
108
|
+
[i]
|
|
1999
109
|
);
|
|
2000
|
-
return
|
|
2001
|
-
name:
|
|
2002
|
-
description:
|
|
110
|
+
return b({
|
|
111
|
+
name: t,
|
|
112
|
+
description: e,
|
|
2003
113
|
inputSchema: {
|
|
2004
114
|
type: "object",
|
|
2005
115
|
properties: s,
|
|
2006
|
-
...
|
|
116
|
+
...r?.required && { required: r.required }
|
|
2007
117
|
},
|
|
2008
|
-
handler:
|
|
2009
|
-
autoRegister:
|
|
2010
|
-
autoUnregister:
|
|
118
|
+
handler: a,
|
|
119
|
+
autoRegister: r?.autoRegister,
|
|
120
|
+
autoUnregister: r?.autoUnregister
|
|
2011
121
|
});
|
|
2012
122
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
qe = 1;
|
|
2018
|
-
var v = /* @__PURE__ */ Symbol.for("react.transitional.element"), n = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
2019
|
-
function s(a, u, d) {
|
|
2020
|
-
var y = null;
|
|
2021
|
-
if (d !== void 0 && (y = "" + d), u.key !== void 0 && (y = "" + u.key), "key" in u) {
|
|
2022
|
-
d = {};
|
|
2023
|
-
for (var b in u)
|
|
2024
|
-
b !== "key" && (d[b] = u[b]);
|
|
2025
|
-
} else d = u;
|
|
2026
|
-
return u = d.ref, {
|
|
2027
|
-
$$typeof: v,
|
|
2028
|
-
type: a,
|
|
2029
|
-
key: y,
|
|
2030
|
-
ref: u !== void 0 ? u : null,
|
|
2031
|
-
props: d
|
|
2032
|
-
};
|
|
2033
|
-
}
|
|
2034
|
-
return fe.Fragment = n, fe.jsx = s, fe.jsxs = s, fe;
|
|
2035
|
-
}
|
|
2036
|
-
var de = {};
|
|
2037
|
-
var $e;
|
|
2038
|
-
function ot() {
|
|
2039
|
-
return $e || ($e = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2040
|
-
function v(t) {
|
|
2041
|
-
if (t == null) return null;
|
|
2042
|
-
if (typeof t == "function")
|
|
2043
|
-
return t.$$typeof === ie ? null : t.displayName || t.name || null;
|
|
2044
|
-
if (typeof t == "string") return t;
|
|
2045
|
-
switch (t) {
|
|
2046
|
-
case F:
|
|
2047
|
-
return "Fragment";
|
|
2048
|
-
case N:
|
|
2049
|
-
return "Profiler";
|
|
2050
|
-
case H:
|
|
2051
|
-
return "StrictMode";
|
|
2052
|
-
case se:
|
|
2053
|
-
return "Suspense";
|
|
2054
|
-
case W:
|
|
2055
|
-
return "SuspenseList";
|
|
2056
|
-
case te:
|
|
2057
|
-
return "Activity";
|
|
2058
|
-
}
|
|
2059
|
-
if (typeof t == "object")
|
|
2060
|
-
switch (typeof t.tag == "number" && console.error(
|
|
2061
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
2062
|
-
), t.$$typeof) {
|
|
2063
|
-
case D:
|
|
2064
|
-
return "Portal";
|
|
2065
|
-
case X:
|
|
2066
|
-
return t.displayName || "Context";
|
|
2067
|
-
case G:
|
|
2068
|
-
return (t._context.displayName || "Context") + ".Consumer";
|
|
2069
|
-
case x:
|
|
2070
|
-
var o = t.render;
|
|
2071
|
-
return t = t.displayName, t || (t = o.displayName || o.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
2072
|
-
case ue:
|
|
2073
|
-
return o = t.displayName || null, o !== null ? o : v(t.type) || "Memo";
|
|
2074
|
-
case z:
|
|
2075
|
-
o = t._payload, t = t._init;
|
|
2076
|
-
try {
|
|
2077
|
-
return v(t(o));
|
|
2078
|
-
} catch {
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
return null;
|
|
2082
|
-
}
|
|
2083
|
-
function n(t) {
|
|
2084
|
-
return "" + t;
|
|
2085
|
-
}
|
|
2086
|
-
function s(t) {
|
|
2087
|
-
try {
|
|
2088
|
-
n(t);
|
|
2089
|
-
var o = !1;
|
|
2090
|
-
} catch {
|
|
2091
|
-
o = !0;
|
|
2092
|
-
}
|
|
2093
|
-
if (o) {
|
|
2094
|
-
o = console;
|
|
2095
|
-
var l = o.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
2096
|
-
return l.call(
|
|
2097
|
-
o,
|
|
2098
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
2099
|
-
f
|
|
2100
|
-
), n(t);
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
function a(t) {
|
|
2104
|
-
if (t === F) return "<>";
|
|
2105
|
-
if (typeof t == "object" && t !== null && t.$$typeof === z)
|
|
2106
|
-
return "<...>";
|
|
2107
|
-
try {
|
|
2108
|
-
var o = v(t);
|
|
2109
|
-
return o ? "<" + o + ">" : "<...>";
|
|
2110
|
-
} catch {
|
|
2111
|
-
return "<...>";
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
function u() {
|
|
2115
|
-
var t = A.A;
|
|
2116
|
-
return t === null ? null : t.getOwner();
|
|
2117
|
-
}
|
|
2118
|
-
function d() {
|
|
2119
|
-
return Error("react-stack-top-frame");
|
|
2120
|
-
}
|
|
2121
|
-
function y(t) {
|
|
2122
|
-
if (re.call(t, "key")) {
|
|
2123
|
-
var o = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
2124
|
-
if (o && o.isReactWarning) return !1;
|
|
2125
|
-
}
|
|
2126
|
-
return t.key !== void 0;
|
|
2127
|
-
}
|
|
2128
|
-
function b(t, o) {
|
|
2129
|
-
function l() {
|
|
2130
|
-
q || (q = !0, console.error(
|
|
2131
|
-
"%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)",
|
|
2132
|
-
o
|
|
2133
|
-
));
|
|
2134
|
-
}
|
|
2135
|
-
l.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
2136
|
-
get: l,
|
|
2137
|
-
configurable: !0
|
|
2138
|
-
});
|
|
2139
|
-
}
|
|
2140
|
-
function O() {
|
|
2141
|
-
var t = v(this.type);
|
|
2142
|
-
return K[t] || (K[t] = !0, console.error(
|
|
2143
|
-
"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."
|
|
2144
|
-
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
2145
|
-
}
|
|
2146
|
-
function I(t, o, l, f, _, S) {
|
|
2147
|
-
var p = l.ref;
|
|
2148
|
-
return t = {
|
|
2149
|
-
$$typeof: U,
|
|
2150
|
-
type: t,
|
|
2151
|
-
key: o,
|
|
2152
|
-
props: l,
|
|
2153
|
-
_owner: f
|
|
2154
|
-
}, (p !== void 0 ? p : null) !== null ? Object.defineProperty(t, "ref", {
|
|
2155
|
-
enumerable: !1,
|
|
2156
|
-
get: O
|
|
2157
|
-
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
2158
|
-
configurable: !1,
|
|
2159
|
-
enumerable: !1,
|
|
2160
|
-
writable: !0,
|
|
2161
|
-
value: 0
|
|
2162
|
-
}), Object.defineProperty(t, "_debugInfo", {
|
|
2163
|
-
configurable: !1,
|
|
2164
|
-
enumerable: !1,
|
|
2165
|
-
writable: !0,
|
|
2166
|
-
value: null
|
|
2167
|
-
}), Object.defineProperty(t, "_debugStack", {
|
|
2168
|
-
configurable: !1,
|
|
2169
|
-
enumerable: !1,
|
|
2170
|
-
writable: !0,
|
|
2171
|
-
value: _
|
|
2172
|
-
}), Object.defineProperty(t, "_debugTask", {
|
|
2173
|
-
configurable: !1,
|
|
2174
|
-
enumerable: !1,
|
|
2175
|
-
writable: !0,
|
|
2176
|
-
value: S
|
|
2177
|
-
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
2178
|
-
}
|
|
2179
|
-
function m(t, o, l, f, _, S) {
|
|
2180
|
-
var p = o.children;
|
|
2181
|
-
if (p !== void 0)
|
|
2182
|
-
if (f)
|
|
2183
|
-
if (V(p)) {
|
|
2184
|
-
for (f = 0; f < p.length; f++)
|
|
2185
|
-
k(p[f]);
|
|
2186
|
-
Object.freeze && Object.freeze(p);
|
|
2187
|
-
} else
|
|
2188
|
-
console.error(
|
|
2189
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
2190
|
-
);
|
|
2191
|
-
else k(p);
|
|
2192
|
-
if (re.call(o, "key")) {
|
|
2193
|
-
p = v(t);
|
|
2194
|
-
var Y = Object.keys(o).filter(function(ee) {
|
|
2195
|
-
return ee !== "key";
|
|
2196
|
-
});
|
|
2197
|
-
f = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ae[p + f] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
2198
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
2199
|
-
let props = %s;
|
|
2200
|
-
<%s {...props} />
|
|
2201
|
-
React keys must be passed directly to JSX without using spread:
|
|
2202
|
-
let props = %s;
|
|
2203
|
-
<%s key={someKey} {...props} />`,
|
|
2204
|
-
f,
|
|
2205
|
-
p,
|
|
2206
|
-
Y,
|
|
2207
|
-
p
|
|
2208
|
-
), ae[p + f] = !0);
|
|
2209
|
-
}
|
|
2210
|
-
if (p = null, l !== void 0 && (s(l), p = "" + l), y(o) && (s(o.key), p = "" + o.key), "key" in o) {
|
|
2211
|
-
l = {};
|
|
2212
|
-
for (var j in o)
|
|
2213
|
-
j !== "key" && (l[j] = o[j]);
|
|
2214
|
-
} else l = o;
|
|
2215
|
-
return p && b(
|
|
2216
|
-
l,
|
|
2217
|
-
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
2218
|
-
), I(
|
|
2219
|
-
t,
|
|
2220
|
-
p,
|
|
2221
|
-
l,
|
|
2222
|
-
u(),
|
|
2223
|
-
_,
|
|
2224
|
-
S
|
|
2225
|
-
);
|
|
2226
|
-
}
|
|
2227
|
-
function k(t) {
|
|
2228
|
-
L(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === z && (t._payload.status === "fulfilled" ? L(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
2229
|
-
}
|
|
2230
|
-
function L(t) {
|
|
2231
|
-
return typeof t == "object" && t !== null && t.$$typeof === U;
|
|
2232
|
-
}
|
|
2233
|
-
var $ = Ge(), U = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), F = /* @__PURE__ */ Symbol.for("react.fragment"), H = /* @__PURE__ */ Symbol.for("react.strict_mode"), N = /* @__PURE__ */ Symbol.for("react.profiler"), G = /* @__PURE__ */ Symbol.for("react.consumer"), X = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), se = /* @__PURE__ */ Symbol.for("react.suspense"), W = /* @__PURE__ */ Symbol.for("react.suspense_list"), ue = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), te = /* @__PURE__ */ Symbol.for("react.activity"), ie = /* @__PURE__ */ Symbol.for("react.client.reference"), A = $.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, re = Object.prototype.hasOwnProperty, V = Array.isArray, Q = console.createTask ? console.createTask : function() {
|
|
2234
|
-
return null;
|
|
2235
|
-
};
|
|
2236
|
-
$ = {
|
|
2237
|
-
react_stack_bottom_frame: function(t) {
|
|
2238
|
-
return t();
|
|
2239
|
-
}
|
|
2240
|
-
};
|
|
2241
|
-
var q, K = {}, ne = $.react_stack_bottom_frame.bind(
|
|
2242
|
-
$,
|
|
2243
|
-
d
|
|
2244
|
-
)(), Z = Q(a(d)), ae = {};
|
|
2245
|
-
de.Fragment = F, de.jsx = function(t, o, l) {
|
|
2246
|
-
var f = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
2247
|
-
return m(
|
|
2248
|
-
t,
|
|
2249
|
-
o,
|
|
2250
|
-
l,
|
|
2251
|
-
!1,
|
|
2252
|
-
f ? Error("react-stack-top-frame") : ne,
|
|
2253
|
-
f ? Q(a(t)) : Z
|
|
2254
|
-
);
|
|
2255
|
-
}, de.jsxs = function(t, o, l) {
|
|
2256
|
-
var f = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
2257
|
-
return m(
|
|
2258
|
-
t,
|
|
2259
|
-
o,
|
|
2260
|
-
l,
|
|
2261
|
-
!0,
|
|
2262
|
-
f ? Error("react-stack-top-frame") : ne,
|
|
2263
|
-
f ? Q(a(t)) : Z
|
|
2264
|
-
);
|
|
2265
|
-
};
|
|
2266
|
-
})()), de;
|
|
2267
|
-
}
|
|
2268
|
-
var Fe;
|
|
2269
|
-
function st() {
|
|
2270
|
-
return Fe || (Fe = 1, process.env.NODE_ENV === "production" ? Ee.exports = nt() : Ee.exports = ot()), Ee.exports;
|
|
2271
|
-
}
|
|
2272
|
-
var it = st();
|
|
2273
|
-
const we = M.createContext(null);
|
|
2274
|
-
function dt({
|
|
2275
|
-
children: v,
|
|
2276
|
-
autoInit: n = !0,
|
|
123
|
+
const x = $(null);
|
|
124
|
+
function J({
|
|
125
|
+
children: t,
|
|
126
|
+
autoInit: e = !0,
|
|
2277
127
|
backendWsUrl: s = "ws://localhost:3001",
|
|
2278
|
-
initOptions:
|
|
2279
|
-
onInitialized:
|
|
2280
|
-
onInitError:
|
|
128
|
+
initOptions: i,
|
|
129
|
+
onInitialized: r,
|
|
130
|
+
onInitError: a
|
|
2281
131
|
}) {
|
|
2282
|
-
const [
|
|
2283
|
-
async (
|
|
2284
|
-
if (
|
|
132
|
+
const [l, d] = m(!1), [p, g] = m(!1), [T] = m([]), C = f(
|
|
133
|
+
async (n) => {
|
|
134
|
+
if (l) {
|
|
2285
135
|
console.log("[MCPToolsProvider] Already initialized");
|
|
2286
136
|
return;
|
|
2287
137
|
}
|
|
2288
138
|
try {
|
|
2289
|
-
const
|
|
2290
|
-
console.log("[MCPToolsProvider] Initializing worker client...",
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
}), console.log("[MCPToolsProvider] Worker client initialized"),
|
|
2295
|
-
} catch (
|
|
2296
|
-
throw console.error("[MCPToolsProvider] Initialization failed:",
|
|
2297
|
-
|
|
2298
|
-
),
|
|
139
|
+
const c = n || i || { backendWsUrl: s };
|
|
140
|
+
console.log("[MCPToolsProvider] Initializing worker client...", c), await u.init(c), d(!0);
|
|
141
|
+
const y = await u.getConnectionStatus();
|
|
142
|
+
g(y), u.onConnectionStatus((R) => {
|
|
143
|
+
g(R);
|
|
144
|
+
}), console.log("[MCPToolsProvider] Worker client initialized"), r?.();
|
|
145
|
+
} catch (c) {
|
|
146
|
+
throw console.error("[MCPToolsProvider] Initialization failed:", c), a?.(
|
|
147
|
+
c instanceof Error ? c : new Error(String(c))
|
|
148
|
+
), c;
|
|
2299
149
|
}
|
|
2300
150
|
},
|
|
2301
|
-
[
|
|
2302
|
-
),
|
|
2303
|
-
const
|
|
2304
|
-
return
|
|
151
|
+
[l, i, s, r, a]
|
|
152
|
+
), w = f(async () => {
|
|
153
|
+
const n = await u.getConnectionStatus();
|
|
154
|
+
return g(n), n;
|
|
2305
155
|
}, []);
|
|
2306
|
-
M
|
|
2307
|
-
|
|
2308
|
-
console.error("[MCPToolsProvider] Auto-init failed:",
|
|
156
|
+
M(() => {
|
|
157
|
+
e && C().catch((n) => {
|
|
158
|
+
console.error("[MCPToolsProvider] Auto-init failed:", n);
|
|
2309
159
|
});
|
|
2310
|
-
}, [
|
|
2311
|
-
if (!
|
|
2312
|
-
const
|
|
160
|
+
}, [e, C]), M(() => {
|
|
161
|
+
if (!l) return;
|
|
162
|
+
const n = setInterval(() => {
|
|
2313
163
|
}, 5e3);
|
|
2314
|
-
return () => clearInterval(
|
|
2315
|
-
}, [
|
|
2316
|
-
const
|
|
2317
|
-
isInitialized:
|
|
2318
|
-
isConnected:
|
|
2319
|
-
registeredTools:
|
|
2320
|
-
initialize:
|
|
2321
|
-
getConnectionStatus:
|
|
164
|
+
return () => clearInterval(n);
|
|
165
|
+
}, [l]);
|
|
166
|
+
const v = {
|
|
167
|
+
isInitialized: l,
|
|
168
|
+
isConnected: p,
|
|
169
|
+
registeredTools: T,
|
|
170
|
+
initialize: C,
|
|
171
|
+
getConnectionStatus: w
|
|
2322
172
|
};
|
|
2323
|
-
return /* @__PURE__ */
|
|
173
|
+
return /* @__PURE__ */ A(x.Provider, { value: v, children: t });
|
|
2324
174
|
}
|
|
2325
|
-
function
|
|
2326
|
-
const
|
|
2327
|
-
if (!
|
|
175
|
+
function D(t = !1) {
|
|
176
|
+
const e = I(x);
|
|
177
|
+
if (!e && t)
|
|
2328
178
|
throw new Error(
|
|
2329
179
|
"useMCPToolsContext must be used within MCPToolsProvider. Either wrap your component tree with <MCPToolsProvider> or set strict=false."
|
|
2330
180
|
);
|
|
2331
|
-
return
|
|
181
|
+
return e || {
|
|
2332
182
|
isInitialized: !1,
|
|
2333
183
|
isConnected: !1,
|
|
2334
184
|
registeredTools: [],
|
|
@@ -2338,17 +188,17 @@ function ht(v = !1) {
|
|
|
2338
188
|
getConnectionStatus: async () => !1
|
|
2339
189
|
};
|
|
2340
190
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return
|
|
191
|
+
function G() {
|
|
192
|
+
return I(x) !== null;
|
|
2343
193
|
}
|
|
2344
194
|
export {
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
195
|
+
J as MCPToolsProvider,
|
|
196
|
+
q as getRegisteredTools,
|
|
197
|
+
U as getToolInfo,
|
|
198
|
+
k as isToolRegistered,
|
|
199
|
+
G as useHasMCPProvider,
|
|
200
|
+
H as useMCPAction,
|
|
201
|
+
F as useMCPGetter,
|
|
202
|
+
b as useMCPTool,
|
|
203
|
+
D as useMCPToolsContext
|
|
2354
204
|
};
|