@trops/dash-core 0.1.241 → 0.1.243

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.js CHANGED
@@ -6309,11 +6309,37 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6309
6309
  createdDashboard = _useState12[0],
6310
6310
  setCreatedDashboard = _useState12[1];
6311
6311
 
6312
- // Sub-step state (DASH-188): 0 = Name, 1 = Folder, 2 = Theme
6313
- var _useState13 = React.useState(0),
6312
+ // Auth flow state (device-code auth for registry install)
6313
+ var _useState13 = React.useState(null),
6314
6314
  _useState14 = _slicedToArray(_useState13, 2),
6315
- subStep = _useState14[0],
6316
- setSubStep = _useState14[1];
6315
+ authNeeded = _useState14[0],
6316
+ setAuthNeeded = _useState14[1];
6317
+ var _useState15 = React.useState(null),
6318
+ _useState16 = _slicedToArray(_useState15, 2),
6319
+ authFlow = _useState16[0],
6320
+ setAuthFlow = _useState16[1];
6321
+ var _useState17 = React.useState(false),
6322
+ _useState18 = _slicedToArray(_useState17, 2),
6323
+ isPolling = _useState18[0],
6324
+ setIsPolling = _useState18[1];
6325
+ var _useState19 = React.useState(null),
6326
+ _useState20 = _slicedToArray(_useState19, 2),
6327
+ authError = _useState20[0],
6328
+ setAuthError = _useState20[1];
6329
+ var pollIntervalRef = React.useRef(null);
6330
+
6331
+ // Clean up polling on unmount
6332
+ React.useEffect(function () {
6333
+ return function () {
6334
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
6335
+ };
6336
+ }, []);
6337
+
6338
+ // Sub-step state (DASH-188): 0 = Name, 1 = Folder, 2 = Theme
6339
+ var _useState21 = React.useState(0),
6340
+ _useState22 = _slicedToArray(_useState21, 2),
6341
+ subStep = _useState22[0],
6342
+ setSubStep = _useState22[1];
6317
6343
  var isPrebuilt = state.path === "prebuilt";
6318
6344
 
6319
6345
  // Initialize customization defaults when stepping into this step
@@ -6355,6 +6381,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6355
6381
  case 0:
6356
6382
  setCreating(true);
6357
6383
  setError(null);
6384
+ setAuthNeeded(null);
6358
6385
  _context2.prev = 1;
6359
6386
  _state$customization = state.customization, name = _state$customization.name, menuId = _state$customization.menuId, theme = _state$customization.theme;
6360
6387
  if (!(isPrebuilt && state.selectedDashboard)) {
@@ -6390,7 +6417,9 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6390
6417
  _context2.next = 5;
6391
6418
  break;
6392
6419
  }
6393
- throw new Error(installResult.error || "Sign in to install this dashboard.");
6420
+ setAuthNeeded(installResult.error || "Sign in to install this dashboard.");
6421
+ setCreating(false);
6422
+ return _context2.abrupt("return");
6394
6423
  case 5:
6395
6424
  if (!(installResult !== null && installResult !== void 0 && installResult.workspace)) {
6396
6425
  _context2.next = 7;
@@ -6653,7 +6682,80 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6653
6682
  setNewFolderIcon(null);
6654
6683
  }
6655
6684
 
6656
- // --- Success state ---
6685
+ // --- Registry auth sign-in (device-code flow) ---
6686
+ function handleSignIn() {
6687
+ return _handleSignIn.apply(this, arguments);
6688
+ } // --- Success state ---
6689
+ function _handleSignIn() {
6690
+ _handleSignIn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
6691
+ var flow, interval;
6692
+ return _regeneratorRuntime.wrap(function (_context4) {
6693
+ while (1) switch (_context4.prev = _context4.next) {
6694
+ case 0:
6695
+ setAuthError(null);
6696
+ _context4.prev = 1;
6697
+ _context4.next = 2;
6698
+ return window.mainApi.registryAuth.initiateLogin();
6699
+ case 2:
6700
+ flow = _context4.sent;
6701
+ setAuthFlow(flow);
6702
+ if (flow.verificationUrlComplete) {
6703
+ window.mainApi.shell.openExternal(flow.verificationUrlComplete);
6704
+ }
6705
+ setIsPolling(true);
6706
+ interval = (flow.interval || 5) * 1000;
6707
+ pollIntervalRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
6708
+ var pollResult;
6709
+ return _regeneratorRuntime.wrap(function (_context3) {
6710
+ while (1) switch (_context3.prev = _context3.next) {
6711
+ case 0:
6712
+ _context3.prev = 0;
6713
+ _context3.next = 1;
6714
+ return window.mainApi.registryAuth.pollToken(flow.deviceCode);
6715
+ case 1:
6716
+ pollResult = _context3.sent;
6717
+ if (pollResult.status === "authorized") {
6718
+ clearInterval(pollIntervalRef.current);
6719
+ pollIntervalRef.current = null;
6720
+ setIsPolling(false);
6721
+ setAuthFlow(null);
6722
+ setAuthNeeded(null);
6723
+ handleCreate();
6724
+ } else if (pollResult.status === "expired") {
6725
+ clearInterval(pollIntervalRef.current);
6726
+ pollIntervalRef.current = null;
6727
+ setIsPolling(false);
6728
+ setAuthFlow(null);
6729
+ setAuthError("Authorization expired. Please try again.");
6730
+ }
6731
+ _context3.next = 3;
6732
+ break;
6733
+ case 2:
6734
+ _context3.prev = 2;
6735
+ _context3["catch"](0);
6736
+ clearInterval(pollIntervalRef.current);
6737
+ pollIntervalRef.current = null;
6738
+ setIsPolling(false);
6739
+ case 3:
6740
+ case "end":
6741
+ return _context3.stop();
6742
+ }
6743
+ }, _callee2, null, [[0, 2]]);
6744
+ })), interval);
6745
+ _context4.next = 4;
6746
+ break;
6747
+ case 3:
6748
+ _context4.prev = 3;
6749
+ _context4["catch"](1);
6750
+ setAuthError("Could not reach the registry. Check your connection and try again.");
6751
+ case 4:
6752
+ case "end":
6753
+ return _context4.stop();
6754
+ }
6755
+ }, _callee3, null, [[1, 3]]);
6756
+ }));
6757
+ return _handleSignIn.apply(this, arguments);
6758
+ }
6657
6759
  if (createdDashboard) {
6658
6760
  return /*#__PURE__*/jsxRuntime.jsx("div", {
6659
6761
  className: "flex flex-col gap-4",
@@ -7017,6 +7119,55 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
7017
7119
  children: isPrebuilt ? ((_state$selectedDashbo = state.selectedDashboard) === null || _state$selectedDashbo === void 0 ? void 0 : _state$selectedDashbo.displayName) || ((_state$selectedDashbo2 = state.selectedDashboard) === null || _state$selectedDashbo2 === void 0 ? void 0 : _state$selectedDashbo2.name) || "Pre-built dashboard" : "".concat(state.selectedWidgets.length, " widget").concat(state.selectedWidgets.length !== 1 ? "s" : "")
7018
7120
  })]
7019
7121
  })]
7122
+ }), authNeeded && /*#__PURE__*/jsxRuntime.jsxs("div", {
7123
+ className: "flex flex-col gap-3",
7124
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7125
+ className: "bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-3",
7126
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7127
+ className: "flex items-start gap-2",
7128
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
7129
+ icon: "lock",
7130
+ className: "h-3.5 w-3.5 text-yellow-400 mt-0.5 flex-shrink-0"
7131
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
7132
+ className: "text-sm text-yellow-300/90",
7133
+ children: authNeeded
7134
+ })]
7135
+ })
7136
+ }), !authFlow && !isPolling && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
7137
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
7138
+ type: "button",
7139
+ onClick: handleSignIn,
7140
+ 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",
7141
+ children: "Sign in to Registry"
7142
+ }), authError && /*#__PURE__*/jsxRuntime.jsx("div", {
7143
+ className: "bg-red-500/10 border border-red-500/20 rounded-lg p-3",
7144
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7145
+ className: "flex items-start gap-2",
7146
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
7147
+ icon: "circle-xmark",
7148
+ className: "h-3.5 w-3.5 text-red-400 mt-0.5 flex-shrink-0"
7149
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
7150
+ className: "text-xs text-red-300/90",
7151
+ children: authError
7152
+ })]
7153
+ })
7154
+ })]
7155
+ }), authFlow && isPolling && /*#__PURE__*/jsxRuntime.jsxs("div", {
7156
+ className: "bg-blue-500/10 border border-blue-500/20 rounded-lg p-4 space-y-3",
7157
+ children: [/*#__PURE__*/jsxRuntime.jsx("p", {
7158
+ className: "text-xs text-blue-300/90",
7159
+ children: "Enter this code in your browser:"
7160
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
7161
+ className: "text-center",
7162
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
7163
+ className: "text-2xl font-mono font-bold tracking-widest text-white",
7164
+ children: authFlow.userCode
7165
+ })
7166
+ }), /*#__PURE__*/jsxRuntime.jsx("p", {
7167
+ className: "text-xs text-blue-300/70 text-center",
7168
+ children: "Waiting for authorization \u2014 install will resume automatically..."
7169
+ })]
7170
+ })]
7020
7171
  }), error && /*#__PURE__*/jsxRuntime.jsxs("div", {
7021
7172
  className: "flex items-center gap-2 text-red-400 py-2",
7022
7173
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {