@trops/dash-core 0.1.56 → 0.1.58
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/dist/index.esm.js +94 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +94 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7195,6 +7195,38 @@ var ProviderForm = function ProviderForm(_ref) {
|
|
|
7195
7195
|
},
|
|
7196
7196
|
placeholder: "Enter ".concat(fieldConfig.displayName.toLowerCase()),
|
|
7197
7197
|
className: errors[fieldName] ? "border-red-500" : ""
|
|
7198
|
+
}), fieldConfig.type === "file" && /*#__PURE__*/jsxs("div", {
|
|
7199
|
+
className: "flex gap-2",
|
|
7200
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
7201
|
+
className: "flex-1",
|
|
7202
|
+
children: /*#__PURE__*/jsx(InputText, {
|
|
7203
|
+
value: formData[fieldName] || "",
|
|
7204
|
+
onChange: function onChange(value) {
|
|
7205
|
+
return handleInputChange(fieldName, value);
|
|
7206
|
+
},
|
|
7207
|
+
placeholder: "Select a file...",
|
|
7208
|
+
className: errors[fieldName] ? "border-red-500" : ""
|
|
7209
|
+
})
|
|
7210
|
+
}), /*#__PURE__*/jsx("button", {
|
|
7211
|
+
onClick: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
7212
|
+
var filepath;
|
|
7213
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
7214
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7215
|
+
case 0:
|
|
7216
|
+
_context.next = 1;
|
|
7217
|
+
return window.mainApi.dialog.chooseFile(true, ["json"]);
|
|
7218
|
+
case 1:
|
|
7219
|
+
filepath = _context.sent;
|
|
7220
|
+
if (filepath) handleInputChange(fieldName, filepath);
|
|
7221
|
+
case 2:
|
|
7222
|
+
case "end":
|
|
7223
|
+
return _context.stop();
|
|
7224
|
+
}
|
|
7225
|
+
}, _callee);
|
|
7226
|
+
})),
|
|
7227
|
+
className: "px-3 py-1.5 text-sm rounded bg-white/10 hover:bg-white/20 transition-colors",
|
|
7228
|
+
children: "Browse"
|
|
7229
|
+
})]
|
|
7198
7230
|
}), errors[fieldName] && /*#__PURE__*/jsx("p", {
|
|
7199
7231
|
className: "text-sm text-red-500 dark:text-red-400",
|
|
7200
7232
|
children: errors[fieldName]
|
|
@@ -19507,7 +19539,7 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19507
19539
|
* even when multiple hook instances call connect() simultaneously.
|
|
19508
19540
|
*/
|
|
19509
19541
|
var connect = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
19510
|
-
var cached, result, state, connectPromise, _result,
|
|
19542
|
+
var cached, statusResult, result, state, connectPromise, _result, _t2, _t3;
|
|
19511
19543
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
19512
19544
|
while (1) switch (_context.prev = _context.next) {
|
|
19513
19545
|
case 0:
|
|
@@ -19538,65 +19570,90 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19538
19570
|
setError("Provider \"".concat(selectedProviderName, "\" has no MCP configuration"));
|
|
19539
19571
|
return _context.abrupt("return");
|
|
19540
19572
|
case 4:
|
|
19541
|
-
// 1. Already connected at module level?
|
|
19573
|
+
// 1. Already connected at module level? Verify with main process before trusting cache.
|
|
19574
|
+
// The server may have been stopped externally (e.g., Test Connection in settings).
|
|
19542
19575
|
cached = serverStates.get(selectedProviderName);
|
|
19543
19576
|
if (!(cached && cached.status === "connected")) {
|
|
19544
|
-
_context.next =
|
|
19577
|
+
_context.next = 9;
|
|
19578
|
+
break;
|
|
19579
|
+
}
|
|
19580
|
+
_context.prev = 5;
|
|
19581
|
+
_context.next = 6;
|
|
19582
|
+
return new Promise(function (resolve, reject) {
|
|
19583
|
+
dashApi.mcpGetServerStatus(selectedProviderName, function (event, result) {
|
|
19584
|
+
return resolve(result);
|
|
19585
|
+
}, function (event, err) {
|
|
19586
|
+
return reject(err);
|
|
19587
|
+
});
|
|
19588
|
+
});
|
|
19589
|
+
case 6:
|
|
19590
|
+
statusResult = _context.sent;
|
|
19591
|
+
if (!((statusResult === null || statusResult === void 0 ? void 0 : statusResult.status) === "connected")) {
|
|
19592
|
+
_context.next = 7;
|
|
19545
19593
|
break;
|
|
19546
19594
|
}
|
|
19547
19595
|
cached.consumerCount++;
|
|
19548
19596
|
applyResult(cached);
|
|
19549
19597
|
return _context.abrupt("return");
|
|
19550
|
-
case
|
|
19598
|
+
case 7:
|
|
19599
|
+
// Server was stopped externally — clear stale cache and reconnect
|
|
19600
|
+
serverStates["delete"](selectedProviderName);
|
|
19601
|
+
_context.next = 9;
|
|
19602
|
+
break;
|
|
19603
|
+
case 8:
|
|
19604
|
+
_context.prev = 8;
|
|
19605
|
+
_context["catch"](5);
|
|
19606
|
+
serverStates["delete"](selectedProviderName);
|
|
19607
|
+
case 9:
|
|
19551
19608
|
setIsConnecting(true);
|
|
19552
19609
|
setError(null);
|
|
19553
19610
|
|
|
19554
19611
|
// 2. Another hook instance already connecting? Piggyback on its promise
|
|
19555
19612
|
if (!pendingConnects.has(selectedProviderName)) {
|
|
19556
|
-
_context.next =
|
|
19613
|
+
_context.next = 17;
|
|
19557
19614
|
break;
|
|
19558
19615
|
}
|
|
19559
|
-
_context.prev =
|
|
19560
|
-
_context.next =
|
|
19616
|
+
_context.prev = 10;
|
|
19617
|
+
_context.next = 11;
|
|
19561
19618
|
return pendingConnects.get(selectedProviderName);
|
|
19562
|
-
case
|
|
19619
|
+
case 11:
|
|
19563
19620
|
result = _context.sent;
|
|
19564
19621
|
if (mountedRef.current) {
|
|
19565
|
-
_context.next =
|
|
19622
|
+
_context.next = 12;
|
|
19566
19623
|
break;
|
|
19567
19624
|
}
|
|
19568
19625
|
return _context.abrupt("return");
|
|
19569
|
-
case
|
|
19626
|
+
case 12:
|
|
19570
19627
|
if (!result.error) {
|
|
19571
|
-
_context.next =
|
|
19628
|
+
_context.next = 13;
|
|
19572
19629
|
break;
|
|
19573
19630
|
}
|
|
19574
19631
|
setError(result.message);
|
|
19575
19632
|
setIsConnecting(false);
|
|
19576
19633
|
setStatus("error");
|
|
19577
19634
|
return _context.abrupt("return");
|
|
19578
|
-
case
|
|
19635
|
+
case 13:
|
|
19579
19636
|
// Increment consumer count and apply
|
|
19580
19637
|
state = serverStates.get(selectedProviderName);
|
|
19581
19638
|
if (state) state.consumerCount++;
|
|
19582
19639
|
applyResult(result);
|
|
19583
|
-
_context.next =
|
|
19640
|
+
_context.next = 16;
|
|
19584
19641
|
break;
|
|
19585
|
-
case
|
|
19586
|
-
_context.prev =
|
|
19587
|
-
|
|
19642
|
+
case 14:
|
|
19643
|
+
_context.prev = 14;
|
|
19644
|
+
_t2 = _context["catch"](10);
|
|
19588
19645
|
if (mountedRef.current) {
|
|
19589
|
-
_context.next =
|
|
19646
|
+
_context.next = 15;
|
|
19590
19647
|
break;
|
|
19591
19648
|
}
|
|
19592
19649
|
return _context.abrupt("return");
|
|
19593
|
-
case
|
|
19594
|
-
setError((
|
|
19650
|
+
case 15:
|
|
19651
|
+
setError((_t2 === null || _t2 === void 0 ? void 0 : _t2.message) || "Failed to connect to MCP server");
|
|
19595
19652
|
setIsConnecting(false);
|
|
19596
19653
|
setStatus("error");
|
|
19597
|
-
case
|
|
19654
|
+
case 16:
|
|
19598
19655
|
return _context.abrupt("return");
|
|
19599
|
-
case
|
|
19656
|
+
case 17:
|
|
19600
19657
|
// 3. First caller — fire the IPC call and share the promise
|
|
19601
19658
|
connectPromise = new Promise(function (resolve, reject) {
|
|
19602
19659
|
dashApi.mcpStartServer(selectedProviderName, provider.mcpConfig, provider.credentials, function (event, result) {
|
|
@@ -19632,46 +19689,46 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19632
19689
|
});
|
|
19633
19690
|
});
|
|
19634
19691
|
pendingConnects.set(selectedProviderName, connectPromise);
|
|
19635
|
-
_context.prev =
|
|
19636
|
-
_context.next =
|
|
19692
|
+
_context.prev = 18;
|
|
19693
|
+
_context.next = 19;
|
|
19637
19694
|
return connectPromise;
|
|
19638
|
-
case
|
|
19695
|
+
case 19:
|
|
19639
19696
|
_result = _context.sent;
|
|
19640
19697
|
if (mountedRef.current) {
|
|
19641
|
-
_context.next =
|
|
19698
|
+
_context.next = 20;
|
|
19642
19699
|
break;
|
|
19643
19700
|
}
|
|
19644
19701
|
return _context.abrupt("return");
|
|
19645
|
-
case
|
|
19702
|
+
case 20:
|
|
19646
19703
|
if (!_result.error) {
|
|
19647
|
-
_context.next =
|
|
19704
|
+
_context.next = 21;
|
|
19648
19705
|
break;
|
|
19649
19706
|
}
|
|
19650
19707
|
setError(_result.message);
|
|
19651
19708
|
setIsConnecting(false);
|
|
19652
19709
|
setStatus("error");
|
|
19653
19710
|
return _context.abrupt("return");
|
|
19654
|
-
case
|
|
19711
|
+
case 21:
|
|
19655
19712
|
applyResult(_result);
|
|
19656
|
-
_context.next =
|
|
19713
|
+
_context.next = 24;
|
|
19657
19714
|
break;
|
|
19658
|
-
case
|
|
19659
|
-
_context.prev =
|
|
19660
|
-
|
|
19715
|
+
case 22:
|
|
19716
|
+
_context.prev = 22;
|
|
19717
|
+
_t3 = _context["catch"](18);
|
|
19661
19718
|
if (mountedRef.current) {
|
|
19662
|
-
_context.next =
|
|
19719
|
+
_context.next = 23;
|
|
19663
19720
|
break;
|
|
19664
19721
|
}
|
|
19665
19722
|
return _context.abrupt("return");
|
|
19666
|
-
case
|
|
19667
|
-
setError((
|
|
19723
|
+
case 23:
|
|
19724
|
+
setError((_t3 === null || _t3 === void 0 ? void 0 : _t3.message) || "Failed to connect to MCP server");
|
|
19668
19725
|
setIsConnecting(false);
|
|
19669
19726
|
setStatus("error");
|
|
19670
|
-
case
|
|
19727
|
+
case 24:
|
|
19671
19728
|
case "end":
|
|
19672
19729
|
return _context.stop();
|
|
19673
19730
|
}
|
|
19674
|
-
}, _callee, null, [[
|
|
19731
|
+
}, _callee, null, [[5, 8], [10, 14], [18, 22]]);
|
|
19675
19732
|
})), [dashApi, provider, providerType, selectedProviderName, applyResult]);
|
|
19676
19733
|
|
|
19677
19734
|
/**
|