@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.js
CHANGED
|
@@ -7214,6 +7214,38 @@ var ProviderForm = function ProviderForm(_ref) {
|
|
|
7214
7214
|
},
|
|
7215
7215
|
placeholder: "Enter ".concat(fieldConfig.displayName.toLowerCase()),
|
|
7216
7216
|
className: errors[fieldName] ? "border-red-500" : ""
|
|
7217
|
+
}), fieldConfig.type === "file" && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
7218
|
+
className: "flex gap-2",
|
|
7219
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
7220
|
+
className: "flex-1",
|
|
7221
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DashReact.InputText, {
|
|
7222
|
+
value: formData[fieldName] || "",
|
|
7223
|
+
onChange: function onChange(value) {
|
|
7224
|
+
return handleInputChange(fieldName, value);
|
|
7225
|
+
},
|
|
7226
|
+
placeholder: "Select a file...",
|
|
7227
|
+
className: errors[fieldName] ? "border-red-500" : ""
|
|
7228
|
+
})
|
|
7229
|
+
}), /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
7230
|
+
onClick: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
7231
|
+
var filepath;
|
|
7232
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
7233
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7234
|
+
case 0:
|
|
7235
|
+
_context.next = 1;
|
|
7236
|
+
return window.mainApi.dialog.chooseFile(true, ["json"]);
|
|
7237
|
+
case 1:
|
|
7238
|
+
filepath = _context.sent;
|
|
7239
|
+
if (filepath) handleInputChange(fieldName, filepath);
|
|
7240
|
+
case 2:
|
|
7241
|
+
case "end":
|
|
7242
|
+
return _context.stop();
|
|
7243
|
+
}
|
|
7244
|
+
}, _callee);
|
|
7245
|
+
})),
|
|
7246
|
+
className: "px-3 py-1.5 text-sm rounded bg-white/10 hover:bg-white/20 transition-colors",
|
|
7247
|
+
children: "Browse"
|
|
7248
|
+
})]
|
|
7217
7249
|
}), errors[fieldName] && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
7218
7250
|
className: "text-sm text-red-500 dark:text-red-400",
|
|
7219
7251
|
children: errors[fieldName]
|
|
@@ -19526,7 +19558,7 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19526
19558
|
* even when multiple hook instances call connect() simultaneously.
|
|
19527
19559
|
*/
|
|
19528
19560
|
var connect = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
19529
|
-
var cached, result, state, connectPromise, _result,
|
|
19561
|
+
var cached, statusResult, result, state, connectPromise, _result, _t2, _t3;
|
|
19530
19562
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
19531
19563
|
while (1) switch (_context.prev = _context.next) {
|
|
19532
19564
|
case 0:
|
|
@@ -19557,65 +19589,90 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19557
19589
|
setError("Provider \"".concat(selectedProviderName, "\" has no MCP configuration"));
|
|
19558
19590
|
return _context.abrupt("return");
|
|
19559
19591
|
case 4:
|
|
19560
|
-
// 1. Already connected at module level?
|
|
19592
|
+
// 1. Already connected at module level? Verify with main process before trusting cache.
|
|
19593
|
+
// The server may have been stopped externally (e.g., Test Connection in settings).
|
|
19561
19594
|
cached = serverStates.get(selectedProviderName);
|
|
19562
19595
|
if (!(cached && cached.status === "connected")) {
|
|
19563
|
-
_context.next =
|
|
19596
|
+
_context.next = 9;
|
|
19597
|
+
break;
|
|
19598
|
+
}
|
|
19599
|
+
_context.prev = 5;
|
|
19600
|
+
_context.next = 6;
|
|
19601
|
+
return new Promise(function (resolve, reject) {
|
|
19602
|
+
dashApi.mcpGetServerStatus(selectedProviderName, function (event, result) {
|
|
19603
|
+
return resolve(result);
|
|
19604
|
+
}, function (event, err) {
|
|
19605
|
+
return reject(err);
|
|
19606
|
+
});
|
|
19607
|
+
});
|
|
19608
|
+
case 6:
|
|
19609
|
+
statusResult = _context.sent;
|
|
19610
|
+
if (!((statusResult === null || statusResult === void 0 ? void 0 : statusResult.status) === "connected")) {
|
|
19611
|
+
_context.next = 7;
|
|
19564
19612
|
break;
|
|
19565
19613
|
}
|
|
19566
19614
|
cached.consumerCount++;
|
|
19567
19615
|
applyResult(cached);
|
|
19568
19616
|
return _context.abrupt("return");
|
|
19569
|
-
case
|
|
19617
|
+
case 7:
|
|
19618
|
+
// Server was stopped externally — clear stale cache and reconnect
|
|
19619
|
+
serverStates["delete"](selectedProviderName);
|
|
19620
|
+
_context.next = 9;
|
|
19621
|
+
break;
|
|
19622
|
+
case 8:
|
|
19623
|
+
_context.prev = 8;
|
|
19624
|
+
_context["catch"](5);
|
|
19625
|
+
serverStates["delete"](selectedProviderName);
|
|
19626
|
+
case 9:
|
|
19570
19627
|
setIsConnecting(true);
|
|
19571
19628
|
setError(null);
|
|
19572
19629
|
|
|
19573
19630
|
// 2. Another hook instance already connecting? Piggyback on its promise
|
|
19574
19631
|
if (!pendingConnects.has(selectedProviderName)) {
|
|
19575
|
-
_context.next =
|
|
19632
|
+
_context.next = 17;
|
|
19576
19633
|
break;
|
|
19577
19634
|
}
|
|
19578
|
-
_context.prev =
|
|
19579
|
-
_context.next =
|
|
19635
|
+
_context.prev = 10;
|
|
19636
|
+
_context.next = 11;
|
|
19580
19637
|
return pendingConnects.get(selectedProviderName);
|
|
19581
|
-
case
|
|
19638
|
+
case 11:
|
|
19582
19639
|
result = _context.sent;
|
|
19583
19640
|
if (mountedRef.current) {
|
|
19584
|
-
_context.next =
|
|
19641
|
+
_context.next = 12;
|
|
19585
19642
|
break;
|
|
19586
19643
|
}
|
|
19587
19644
|
return _context.abrupt("return");
|
|
19588
|
-
case
|
|
19645
|
+
case 12:
|
|
19589
19646
|
if (!result.error) {
|
|
19590
|
-
_context.next =
|
|
19647
|
+
_context.next = 13;
|
|
19591
19648
|
break;
|
|
19592
19649
|
}
|
|
19593
19650
|
setError(result.message);
|
|
19594
19651
|
setIsConnecting(false);
|
|
19595
19652
|
setStatus("error");
|
|
19596
19653
|
return _context.abrupt("return");
|
|
19597
|
-
case
|
|
19654
|
+
case 13:
|
|
19598
19655
|
// Increment consumer count and apply
|
|
19599
19656
|
state = serverStates.get(selectedProviderName);
|
|
19600
19657
|
if (state) state.consumerCount++;
|
|
19601
19658
|
applyResult(result);
|
|
19602
|
-
_context.next =
|
|
19659
|
+
_context.next = 16;
|
|
19603
19660
|
break;
|
|
19604
|
-
case
|
|
19605
|
-
_context.prev =
|
|
19606
|
-
|
|
19661
|
+
case 14:
|
|
19662
|
+
_context.prev = 14;
|
|
19663
|
+
_t2 = _context["catch"](10);
|
|
19607
19664
|
if (mountedRef.current) {
|
|
19608
|
-
_context.next =
|
|
19665
|
+
_context.next = 15;
|
|
19609
19666
|
break;
|
|
19610
19667
|
}
|
|
19611
19668
|
return _context.abrupt("return");
|
|
19612
|
-
case
|
|
19613
|
-
setError((
|
|
19669
|
+
case 15:
|
|
19670
|
+
setError((_t2 === null || _t2 === void 0 ? void 0 : _t2.message) || "Failed to connect to MCP server");
|
|
19614
19671
|
setIsConnecting(false);
|
|
19615
19672
|
setStatus("error");
|
|
19616
|
-
case
|
|
19673
|
+
case 16:
|
|
19617
19674
|
return _context.abrupt("return");
|
|
19618
|
-
case
|
|
19675
|
+
case 17:
|
|
19619
19676
|
// 3. First caller — fire the IPC call and share the promise
|
|
19620
19677
|
connectPromise = new Promise(function (resolve, reject) {
|
|
19621
19678
|
dashApi.mcpStartServer(selectedProviderName, provider.mcpConfig, provider.credentials, function (event, result) {
|
|
@@ -19651,46 +19708,46 @@ var useMcpProvider = function useMcpProvider(providerType) {
|
|
|
19651
19708
|
});
|
|
19652
19709
|
});
|
|
19653
19710
|
pendingConnects.set(selectedProviderName, connectPromise);
|
|
19654
|
-
_context.prev =
|
|
19655
|
-
_context.next =
|
|
19711
|
+
_context.prev = 18;
|
|
19712
|
+
_context.next = 19;
|
|
19656
19713
|
return connectPromise;
|
|
19657
|
-
case
|
|
19714
|
+
case 19:
|
|
19658
19715
|
_result = _context.sent;
|
|
19659
19716
|
if (mountedRef.current) {
|
|
19660
|
-
_context.next =
|
|
19717
|
+
_context.next = 20;
|
|
19661
19718
|
break;
|
|
19662
19719
|
}
|
|
19663
19720
|
return _context.abrupt("return");
|
|
19664
|
-
case
|
|
19721
|
+
case 20:
|
|
19665
19722
|
if (!_result.error) {
|
|
19666
|
-
_context.next =
|
|
19723
|
+
_context.next = 21;
|
|
19667
19724
|
break;
|
|
19668
19725
|
}
|
|
19669
19726
|
setError(_result.message);
|
|
19670
19727
|
setIsConnecting(false);
|
|
19671
19728
|
setStatus("error");
|
|
19672
19729
|
return _context.abrupt("return");
|
|
19673
|
-
case
|
|
19730
|
+
case 21:
|
|
19674
19731
|
applyResult(_result);
|
|
19675
|
-
_context.next =
|
|
19732
|
+
_context.next = 24;
|
|
19676
19733
|
break;
|
|
19677
|
-
case
|
|
19678
|
-
_context.prev =
|
|
19679
|
-
|
|
19734
|
+
case 22:
|
|
19735
|
+
_context.prev = 22;
|
|
19736
|
+
_t3 = _context["catch"](18);
|
|
19680
19737
|
if (mountedRef.current) {
|
|
19681
|
-
_context.next =
|
|
19738
|
+
_context.next = 23;
|
|
19682
19739
|
break;
|
|
19683
19740
|
}
|
|
19684
19741
|
return _context.abrupt("return");
|
|
19685
|
-
case
|
|
19686
|
-
setError((
|
|
19742
|
+
case 23:
|
|
19743
|
+
setError((_t3 === null || _t3 === void 0 ? void 0 : _t3.message) || "Failed to connect to MCP server");
|
|
19687
19744
|
setIsConnecting(false);
|
|
19688
19745
|
setStatus("error");
|
|
19689
|
-
case
|
|
19746
|
+
case 24:
|
|
19690
19747
|
case "end":
|
|
19691
19748
|
return _context.stop();
|
|
19692
19749
|
}
|
|
19693
|
-
}, _callee, null, [[
|
|
19750
|
+
}, _callee, null, [[5, 8], [10, 14], [18, 22]]);
|
|
19694
19751
|
})), [dashApi, provider, providerType, selectedProviderName, applyResult]);
|
|
19695
19752
|
|
|
19696
19753
|
/**
|