@trops/dash-core 0.1.207 → 0.1.208

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
@@ -7,7 +7,7 @@ import _typeof from '@babel/runtime/helpers/typeof';
7
7
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
8
8
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
9
9
  import * as React from 'react';
10
- import React__default, { createContext, useContext, useState, useEffect, useMemo, useCallback, Fragment as Fragment$1, useReducer, useRef, Component, memo, Profiler } from 'react';
10
+ import React__default, { createContext, useContext, useState, useEffect, useMemo, useCallback, useRef, Fragment as Fragment$1, useReducer, Component, memo, Profiler } from 'react';
11
11
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
12
12
  import _createClass from '@babel/runtime/helpers/createClass';
13
13
  import * as jsxRuntime from 'react/jsx-runtime';
@@ -3581,9 +3581,30 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3581
3581
  _useState8 = _slicedToArray(_useState7, 2),
3582
3582
  installResult = _useState8[0],
3583
3583
  setInstallResult = _useState8[1];
3584
+ var _useState9 = useState(null),
3585
+ _useState0 = _slicedToArray(_useState9, 2),
3586
+ authFlow = _useState0[0],
3587
+ setAuthFlow = _useState0[1];
3588
+ var _useState1 = useState(false),
3589
+ _useState10 = _slicedToArray(_useState1, 2),
3590
+ isPolling = _useState10[0],
3591
+ setIsPolling = _useState10[1];
3592
+ var _useState11 = useState(null),
3593
+ _useState12 = _slicedToArray(_useState11, 2),
3594
+ authError = _useState12[0],
3595
+ setAuthError = _useState12[1];
3596
+ var pollIntervalRef = useRef(null);
3584
3597
  var pkg = dashboardPackage;
3585
3598
  if (!pkg) return null;
3586
3599
 
3600
+ // Clean up polling on unmount
3601
+ // eslint-disable-next-line react-hooks/rules-of-hooks
3602
+ useEffect(function () {
3603
+ return function () {
3604
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
3605
+ };
3606
+ }, []);
3607
+
3587
3608
  // Load preview data on mount
3588
3609
  // eslint-disable-next-line react-hooks/rules-of-hooks
3589
3610
  useEffect(function () {
@@ -3593,6 +3614,10 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3593
3614
  setPreviewLoading(true);
3594
3615
  setPreview(null);
3595
3616
  setInstallResult(null);
3617
+ setAuthFlow(null);
3618
+ setIsPolling(false);
3619
+ setAuthError(null);
3620
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
3596
3621
  (_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 || (_window$mainApi = _window$mainApi.dashboardConfig) === null || _window$mainApi === void 0 || _window$mainApi.getDashboardPreview(pkg.name).then(function (result) {
3597
3622
  if (!cancelled) setPreview(result);
3598
3623
  })["catch"](function (err) {
@@ -3620,11 +3645,25 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3620
3645
  case 1:
3621
3646
  setIsInstalling(true);
3622
3647
  setInstallResult(null);
3648
+ setAuthFlow(null);
3649
+ setAuthError(null);
3623
3650
  _context.prev = 2;
3624
3651
  _context.next = 3;
3625
3652
  return window.mainApi.dashboardConfig.installDashboardFromRegistry(appId, pkg.name);
3626
3653
  case 3:
3627
3654
  result = _context.sent;
3655
+ if (!(result !== null && result !== void 0 && result.authRequired)) {
3656
+ _context.next = 4;
3657
+ break;
3658
+ }
3659
+ // Auth needed — show inline auth prompt (DASH-135)
3660
+ setIsInstalling(false);
3661
+ setInstallResult({
3662
+ status: "auth",
3663
+ message: result.error || "Sign in to install this dashboard."
3664
+ });
3665
+ return _context.abrupt("return");
3666
+ case 4:
3628
3667
  setInstallResult({
3629
3668
  status: result !== null && result !== void 0 && result.success ? "success" : "error",
3630
3669
  message: result !== null && result !== void 0 && result.success ? "Dashboard \"".concat(((_result$workspace = result.workspace) === null || _result$workspace === void 0 ? void 0 : _result$workspace.name) || pkg.name, "\" installed successfully.") : (result === null || result === void 0 ? void 0 : result.error) || "Installation failed."
@@ -3632,27 +3671,104 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3632
3671
  if (result !== null && result !== void 0 && result.success && onInstallComplete) {
3633
3672
  onInstallComplete(result);
3634
3673
  }
3635
- _context.next = 5;
3674
+ _context.next = 6;
3636
3675
  break;
3637
- case 4:
3638
- _context.prev = 4;
3676
+ case 5:
3677
+ _context.prev = 5;
3639
3678
  _t = _context["catch"](2);
3640
3679
  setInstallResult({
3641
3680
  status: "error",
3642
3681
  message: _t.message || "Failed to install dashboard."
3643
3682
  });
3644
- case 5:
3645
- _context.prev = 5;
3646
- setIsInstalling(false);
3647
- return _context.finish(5);
3648
3683
  case 6:
3684
+ _context.prev = 6;
3685
+ setIsInstalling(false);
3686
+ return _context.finish(6);
3687
+ case 7:
3649
3688
  case "end":
3650
3689
  return _context.stop();
3651
3690
  }
3652
- }, _callee, null, [[2, 4, 5, 6]]);
3691
+ }, _callee, null, [[2, 5, 6, 7]]);
3653
3692
  }));
3654
3693
  return _handleInstall.apply(this, arguments);
3655
3694
  }
3695
+ function handleSignIn() {
3696
+ return _handleSignIn.apply(this, arguments);
3697
+ }
3698
+ function _handleSignIn() {
3699
+ _handleSignIn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
3700
+ var flow, interval;
3701
+ return _regeneratorRuntime.wrap(function (_context3) {
3702
+ while (1) switch (_context3.prev = _context3.next) {
3703
+ case 0:
3704
+ setAuthError(null);
3705
+ _context3.prev = 1;
3706
+ _context3.next = 2;
3707
+ return window.mainApi.registryAuth.initiateLogin();
3708
+ case 2:
3709
+ flow = _context3.sent;
3710
+ setAuthFlow(flow);
3711
+
3712
+ // Open verification URL in browser
3713
+ if (flow.verificationUrlComplete) {
3714
+ window.mainApi.shell.openExternal(flow.verificationUrlComplete);
3715
+ }
3716
+
3717
+ // Start polling for token
3718
+ setIsPolling(true);
3719
+ interval = (flow.interval || 5) * 1000;
3720
+ pollIntervalRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
3721
+ var pollResult;
3722
+ return _regeneratorRuntime.wrap(function (_context2) {
3723
+ while (1) switch (_context2.prev = _context2.next) {
3724
+ case 0:
3725
+ _context2.prev = 0;
3726
+ _context2.next = 1;
3727
+ return window.mainApi.registryAuth.pollToken(flow.deviceCode);
3728
+ case 1:
3729
+ pollResult = _context2.sent;
3730
+ if (pollResult.status === "authorized") {
3731
+ clearInterval(pollIntervalRef.current);
3732
+ pollIntervalRef.current = null;
3733
+ setIsPolling(false);
3734
+ setAuthFlow(null);
3735
+ // DASH-136: Auto-retry install after successful auth
3736
+ handleInstall();
3737
+ } else if (pollResult.status === "expired") {
3738
+ clearInterval(pollIntervalRef.current);
3739
+ pollIntervalRef.current = null;
3740
+ setIsPolling(false);
3741
+ setAuthFlow(null);
3742
+ setAuthError("Authorization expired. Please try again.");
3743
+ }
3744
+ _context2.next = 3;
3745
+ break;
3746
+ case 2:
3747
+ _context2.prev = 2;
3748
+ _context2["catch"](0);
3749
+ clearInterval(pollIntervalRef.current);
3750
+ pollIntervalRef.current = null;
3751
+ setIsPolling(false);
3752
+ case 3:
3753
+ case "end":
3754
+ return _context2.stop();
3755
+ }
3756
+ }, _callee2, null, [[0, 2]]);
3757
+ })), interval);
3758
+ _context3.next = 4;
3759
+ break;
3760
+ case 3:
3761
+ _context3.prev = 3;
3762
+ _context3["catch"](1);
3763
+ setAuthError("Could not reach the registry. Check your connection and try again.");
3764
+ case 4:
3765
+ case "end":
3766
+ return _context3.stop();
3767
+ }
3768
+ }, _callee3, null, [[1, 3]]);
3769
+ }));
3770
+ return _handleSignIn.apply(this, arguments);
3771
+ }
3656
3772
  var compatibility = preview === null || preview === void 0 ? void 0 : preview.compatibility;
3657
3773
  var widgetDeps = (preview === null || preview === void 0 ? void 0 : preview.widgets) || pkg.widgets || [];
3658
3774
  var providers = (preview === null || preview === void 0 ? void 0 : preview.providers) || [];
@@ -3822,7 +3938,7 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3822
3938
  }, idx);
3823
3939
  })
3824
3940
  })]
3825
- }), installResult && /*#__PURE__*/jsx("div", {
3941
+ }), installResult && installResult.status !== "auth" && /*#__PURE__*/jsx("div", {
3826
3942
  className: "p-2 rounded border ".concat(installResult.status === "success" ? "bg-green-900/20 border-green-700" : "bg-red-900/30 border-red-700"),
3827
3943
  children: /*#__PURE__*/jsxs("div", {
3828
3944
  className: "flex items-center gap-2",
@@ -3834,8 +3950,57 @@ var RegistryDashboardDetail = function RegistryDashboardDetail(_ref) {
3834
3950
  children: installResult.message
3835
3951
  })]
3836
3952
  })
3953
+ }), (installResult === null || installResult === void 0 ? void 0 : installResult.status) === "auth" && /*#__PURE__*/jsxs("div", {
3954
+ className: "space-y-3",
3955
+ children: [/*#__PURE__*/jsx("div", {
3956
+ className: "bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-3",
3957
+ children: /*#__PURE__*/jsxs("div", {
3958
+ className: "flex items-start gap-2",
3959
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
3960
+ icon: "lock",
3961
+ className: "h-3.5 w-3.5 text-yellow-400 mt-0.5 flex-shrink-0"
3962
+ }), /*#__PURE__*/jsx("span", {
3963
+ className: "text-sm text-yellow-300/90",
3964
+ children: installResult.message
3965
+ })]
3966
+ })
3967
+ }), !authFlow && !isPolling && /*#__PURE__*/jsxs(Fragment, {
3968
+ children: [/*#__PURE__*/jsx("button", {
3969
+ type: "button",
3970
+ onClick: handleSignIn,
3971
+ className: "px-4 py-2 rounded-lg text-sm bg-blue-500/20 border border-blue-500/30 text-blue-300 hover:bg-blue-500/30 transition-colors cursor-pointer",
3972
+ children: "Sign in to Registry"
3973
+ }), authError && /*#__PURE__*/jsx("div", {
3974
+ className: "bg-red-500/10 border border-red-500/20 rounded-lg p-3",
3975
+ children: /*#__PURE__*/jsxs("div", {
3976
+ className: "flex items-start gap-2",
3977
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
3978
+ icon: "circle-xmark",
3979
+ className: "h-3.5 w-3.5 text-red-400 mt-0.5 flex-shrink-0"
3980
+ }), /*#__PURE__*/jsx("span", {
3981
+ className: "text-xs text-red-300/90",
3982
+ children: authError
3983
+ })]
3984
+ })
3985
+ })]
3986
+ }), authFlow && isPolling && /*#__PURE__*/jsxs("div", {
3987
+ className: "bg-blue-500/10 border border-blue-500/20 rounded-lg p-4 space-y-3",
3988
+ children: [/*#__PURE__*/jsx("p", {
3989
+ className: "text-xs text-blue-300/90",
3990
+ children: "Enter this code in your browser:"
3991
+ }), /*#__PURE__*/jsx("div", {
3992
+ className: "text-center",
3993
+ children: /*#__PURE__*/jsx("span", {
3994
+ className: "text-2xl font-mono font-bold tracking-widest text-white",
3995
+ children: authFlow.userCode
3996
+ })
3997
+ }), /*#__PURE__*/jsx("p", {
3998
+ className: "text-xs text-blue-300/70 text-center",
3999
+ children: "Waiting for authorization \u2014 install will resume automatically..."
4000
+ })]
4001
+ })]
3837
4002
  })]
3838
- }), (installResult === null || installResult === void 0 ? void 0 : installResult.status) !== "success" && /*#__PURE__*/jsx("div", {
4003
+ }), (installResult === null || installResult === void 0 ? void 0 : installResult.status) !== "success" && (installResult === null || installResult === void 0 ? void 0 : installResult.status) !== "auth" && /*#__PURE__*/jsx("div", {
3839
4004
  className: "flex items-center justify-end px-6 py-3 border-t ".concat(currentTheme["border-primary-medium"]),
3840
4005
  children: /*#__PURE__*/jsx(Button, {
3841
4006
  title: isInstalling ? "Installing..." : "Install Dashboard",