@trops/dash-core 0.1.181 → 0.1.182

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 CHANGED
@@ -38594,6 +38594,16 @@ var WebSocketProviderForm = function WebSocketProviderForm(_ref) {
38594
38594
  _useState10 = _slicedToArray(_useState1, 2),
38595
38595
  errors = _useState10[0],
38596
38596
  setErrors = _useState10[1];
38597
+ var _useState11 = useState(false),
38598
+ _useState12 = _slicedToArray(_useState11, 2),
38599
+ isWsTesting = _useState12[0],
38600
+ setIsWsTesting = _useState12[1];
38601
+ var _useState13 = useState(null),
38602
+ _useState14 = _slicedToArray(_useState13, 2),
38603
+ wsTestResult = _useState14[0],
38604
+ setWsTestResult = _useState14[1];
38605
+ var appContext = useContext(AppContext);
38606
+ var dashApi = appContext === null || appContext === void 0 ? void 0 : appContext.dashApi;
38597
38607
  var nextRowIdRef = useRef(0);
38598
38608
  var nextRowId = function nextRowId() {
38599
38609
  return "ws_hdr_".concat(++nextRowIdRef.current);
@@ -38683,6 +38693,92 @@ var WebSocketProviderForm = function WebSocketProviderForm(_ref) {
38683
38693
  });
38684
38694
  });
38685
38695
  }
38696
+ function handleTestConnection() {
38697
+ return _handleTestConnection.apply(this, arguments);
38698
+ }
38699
+ function _handleTestConnection() {
38700
+ _handleTestConnection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38701
+ var headers, _iterator4, _step4, row, subprotoArray, testName, startTime, result, latency, _t;
38702
+ return _regeneratorRuntime.wrap(function (_context) {
38703
+ while (1) switch (_context.prev = _context.next) {
38704
+ case 0:
38705
+ if (!(!(dashApi !== null && dashApi !== void 0 && dashApi.webSocket) || !url.trim() || !isValidWsUrl(url))) {
38706
+ _context.next = 1;
38707
+ break;
38708
+ }
38709
+ return _context.abrupt("return");
38710
+ case 1:
38711
+ setIsWsTesting(true);
38712
+ setWsTestResult(null);
38713
+
38714
+ // Build config from current form state (same as handleSave)
38715
+ headers = {};
38716
+ _iterator4 = _createForOfIteratorHelper$4(headerRows);
38717
+ try {
38718
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
38719
+ row = _step4.value;
38720
+ if (row.key.trim()) {
38721
+ headers[row.key.trim()] = row.value;
38722
+ }
38723
+ }
38724
+ } catch (err) {
38725
+ _iterator4.e(err);
38726
+ } finally {
38727
+ _iterator4.f();
38728
+ }
38729
+ subprotoArray = subprotocols.split(",").map(function (s) {
38730
+ return s.trim();
38731
+ }).filter(Boolean);
38732
+ testName = name.trim() || "__ws_test__";
38733
+ startTime = Date.now();
38734
+ _context.prev = 2;
38735
+ _context.next = 3;
38736
+ return dashApi.webSocket.connect(testName, {
38737
+ url: url.trim(),
38738
+ headers: Object.keys(headers).length > 0 ? headers : null,
38739
+ subprotocols: subprotoArray.length > 0 ? subprotoArray : null,
38740
+ credentials: Object.keys(credentials).length > 0 ? credentials : null
38741
+ });
38742
+ case 3:
38743
+ result = _context.sent;
38744
+ latency = Date.now() - startTime;
38745
+ if (!result.error) {
38746
+ _context.next = 4;
38747
+ break;
38748
+ }
38749
+ setWsTestResult({
38750
+ success: false,
38751
+ message: result.message || "Connection failed"
38752
+ });
38753
+ _context.next = 5;
38754
+ break;
38755
+ case 4:
38756
+ setWsTestResult({
38757
+ success: true,
38758
+ message: "Connected in ".concat(latency, "ms")
38759
+ });
38760
+ _context.next = 5;
38761
+ return dashApi.webSocket.disconnect(testName)["catch"](function () {});
38762
+ case 5:
38763
+ _context.next = 7;
38764
+ break;
38765
+ case 6:
38766
+ _context.prev = 6;
38767
+ _t = _context["catch"](2);
38768
+ setWsTestResult({
38769
+ success: false,
38770
+ message: (_t === null || _t === void 0 ? void 0 : _t.message) || "Connection failed"
38771
+ });
38772
+ case 7:
38773
+ setIsWsTesting(false);
38774
+ case 8:
38775
+ case "end":
38776
+ return _context.stop();
38777
+ }
38778
+ }, _callee, null, [[2, 6]]);
38779
+ }));
38780
+ return _handleTestConnection.apply(this, arguments);
38781
+ }
38686
38782
  return /*#__PURE__*/jsxs("div", {
38687
38783
  className: "flex flex-col flex-1 min-h-0",
38688
38784
  children: [/*#__PURE__*/jsxs("div", {
@@ -38701,7 +38797,7 @@ var WebSocketProviderForm = function WebSocketProviderForm(_ref) {
38701
38797
  return setName(value);
38702
38798
  },
38703
38799
  placeholder: "e.g., crypto-ws, stock-feed",
38704
- error: !!errors.name
38800
+ inputClassName: errors.name ? "border-red-500" : ""
38705
38801
  }), errors.name && /*#__PURE__*/jsx("span", {
38706
38802
  className: "text-xs text-red-400",
38707
38803
  children: errors.name
@@ -38717,7 +38813,7 @@ var WebSocketProviderForm = function WebSocketProviderForm(_ref) {
38717
38813
  return setUrl(value);
38718
38814
  },
38719
38815
  placeholder: "wss://api.example.com/ws or ws://localhost:8080",
38720
- error: !!errors.url
38816
+ inputClassName: errors.url ? "border-red-500" : ""
38721
38817
  }), errors.url && /*#__PURE__*/jsx("span", {
38722
38818
  className: "text-xs text-red-400",
38723
38819
  children: errors.url
@@ -38825,17 +38921,32 @@ var WebSocketProviderForm = function WebSocketProviderForm(_ref) {
38825
38921
  });
38826
38922
  },
38827
38923
  placeholder: "Enter ".concat(field),
38828
- error: !!errors["cred_".concat(field)]
38924
+ inputClassName: errors["cred_".concat(field)] ? "border-red-500" : ""
38829
38925
  }), errors["cred_".concat(field)] && /*#__PURE__*/jsx("span", {
38830
38926
  className: "text-xs text-red-400",
38831
38927
  children: errors["cred_".concat(field)]
38832
38928
  })]
38833
38929
  }, field);
38834
38930
  })]
38931
+ }), wsTestResult && /*#__PURE__*/jsx("div", {
38932
+ className: "p-3 rounded-lg text-sm ".concat(wsTestResult.success ? "bg-green-900/30 border border-green-700 text-green-300" : "bg-red-900/30 border border-red-700 text-red-300"),
38933
+ children: /*#__PURE__*/jsxs("div", {
38934
+ className: "flex items-center gap-2",
38935
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
38936
+ icon: wsTestResult.success ? "circle-check" : "circle-exclamation"
38937
+ }), /*#__PURE__*/jsx("span", {
38938
+ children: wsTestResult.message
38939
+ })]
38940
+ })
38835
38941
  })]
38836
38942
  }), /*#__PURE__*/jsxs("div", {
38837
38943
  className: "flex-shrink-0 flex flex-row justify-end gap-2 px-6 py-4 border-t border-white/10",
38838
- children: [/*#__PURE__*/jsx(Button, {
38944
+ children: [(dashApi === null || dashApi === void 0 ? void 0 : dashApi.webSocket) && /*#__PURE__*/jsx(Button, {
38945
+ title: isWsTesting ? "Testing..." : "Test Connection",
38946
+ onClick: handleTestConnection,
38947
+ size: "sm",
38948
+ disabled: !url.trim() || !isValidWsUrl(url)
38949
+ }), /*#__PURE__*/jsx(Button, {
38839
38950
  title: "Cancel",
38840
38951
  onClick: onCancel,
38841
38952
  size: "sm"