@trops/dash-core 0.1.249 → 0.1.252

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
@@ -8315,7 +8315,7 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu
8315
8315
  var hasPropertyDescriptors_1 = hasPropertyDescriptors;
8316
8316
 
8317
8317
  var keys = objectKeys$2;
8318
- var hasSymbols$4 = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
8318
+ var hasSymbols$5 = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
8319
8319
 
8320
8320
  var toStr$4 = Object.prototype.toString;
8321
8321
  var concat = Array.prototype.concat;
@@ -8348,7 +8348,7 @@ var defineProperty$1 = function (object, name, value, predicate) {
8348
8348
  var defineProperties$1 = function (object, map) {
8349
8349
  var predicates = arguments.length > 2 ? arguments[2] : {};
8350
8350
  var props = keys(map);
8351
- if (hasSymbols$4) {
8351
+ if (hasSymbols$5) {
8352
8352
  props = concat.call(props, Object.getOwnPropertySymbols(map));
8353
8353
  }
8354
8354
  for (var i = 0; i < props.length; i += 1) {
@@ -8414,11 +8414,11 @@ var sign$1 = function sign(number) {
8414
8414
  };
8415
8415
 
8416
8416
  var shams$1;
8417
- var hasRequiredShams$1;
8417
+ var hasRequiredShams;
8418
8418
 
8419
- function requireShams$1 () {
8420
- if (hasRequiredShams$1) return shams$1;
8421
- hasRequiredShams$1 = 1;
8419
+ function requireShams () {
8420
+ if (hasRequiredShams) return shams$1;
8421
+ hasRequiredShams = 1;
8422
8422
 
8423
8423
  /** @type {import('./shams')} */
8424
8424
  /* eslint complexity: [2, 18], max-statements: [2, 33] */
@@ -8467,10 +8467,10 @@ function requireShams$1 () {
8467
8467
  }
8468
8468
 
8469
8469
  var origSymbol = typeof Symbol !== 'undefined' && Symbol;
8470
- var hasSymbolSham = requireShams$1();
8470
+ var hasSymbolSham = requireShams();
8471
8471
 
8472
8472
  /** @type {import('.')} */
8473
- var hasSymbols$3 = function hasNativeSymbols() {
8473
+ var hasSymbols$4 = function hasNativeSymbols() {
8474
8474
  if (typeof origSymbol !== 'function') { return false; }
8475
8475
  if (typeof Symbol !== 'function') { return false; }
8476
8476
  if (typeof origSymbol('foo') !== 'symbol') { return false; }
@@ -8774,7 +8774,7 @@ var ThrowTypeError = $gOPD$1
8774
8774
  }())
8775
8775
  : throwTypeError;
8776
8776
 
8777
- var hasSymbols$2 = hasSymbols$3();
8777
+ var hasSymbols$3 = hasSymbols$4();
8778
8778
 
8779
8779
  var getProto$2 = getProto$3;
8780
8780
  var $ObjectGPO = requireObject_getPrototypeOf();
@@ -8792,7 +8792,7 @@ var INTRINSICS = {
8792
8792
  '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
8793
8793
  '%Array%': Array,
8794
8794
  '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
8795
- '%ArrayIteratorPrototype%': hasSymbols$2 && getProto$2 ? getProto$2([][Symbol.iterator]()) : undefined$1,
8795
+ '%ArrayIteratorPrototype%': hasSymbols$3 && getProto$2 ? getProto$2([][Symbol.iterator]()) : undefined$1,
8796
8796
  '%AsyncFromSyncIteratorPrototype%': undefined$1,
8797
8797
  '%AsyncFunction%': needsEval,
8798
8798
  '%AsyncGenerator%': needsEval,
@@ -8823,10 +8823,10 @@ var INTRINSICS = {
8823
8823
  '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
8824
8824
  '%isFinite%': isFinite,
8825
8825
  '%isNaN%': isNaN,
8826
- '%IteratorPrototype%': hasSymbols$2 && getProto$2 ? getProto$2(getProto$2([][Symbol.iterator]())) : undefined$1,
8826
+ '%IteratorPrototype%': hasSymbols$3 && getProto$2 ? getProto$2(getProto$2([][Symbol.iterator]())) : undefined$1,
8827
8827
  '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
8828
8828
  '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
8829
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 || !getProto$2 ? undefined$1 : getProto$2(new Map()[Symbol.iterator]()),
8829
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$3 || !getProto$2 ? undefined$1 : getProto$2(new Map()[Symbol.iterator]()),
8830
8830
  '%Math%': Math,
8831
8831
  '%Number%': Number,
8832
8832
  '%Object%': $Object$2,
@@ -8840,11 +8840,11 @@ var INTRINSICS = {
8840
8840
  '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
8841
8841
  '%RegExp%': RegExp,
8842
8842
  '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
8843
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 || !getProto$2 ? undefined$1 : getProto$2(new Set()[Symbol.iterator]()),
8843
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$3 || !getProto$2 ? undefined$1 : getProto$2(new Set()[Symbol.iterator]()),
8844
8844
  '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
8845
8845
  '%String%': String,
8846
- '%StringIteratorPrototype%': hasSymbols$2 && getProto$2 ? getProto$2(''[Symbol.iterator]()) : undefined$1,
8847
- '%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
8846
+ '%StringIteratorPrototype%': hasSymbols$3 && getProto$2 ? getProto$2(''[Symbol.iterator]()) : undefined$1,
8847
+ '%Symbol%': hasSymbols$3 ? Symbol : undefined$1,
8848
8848
  '%SyntaxError%': $SyntaxError$1,
8849
8849
  '%ThrowTypeError%': ThrowTypeError,
8850
8850
  '%TypedArray%': TypedArray,
@@ -9197,12 +9197,12 @@ var callBound$i = function callBoundIntrinsic(name, allowMissing) {
9197
9197
 
9198
9198
  // modified from https://github.com/es-shims/es6-shim
9199
9199
  var objectKeys$1 = objectKeys$2;
9200
- var hasSymbols$1 = requireShams$1()();
9200
+ var hasSymbols$2 = requireShams()();
9201
9201
  var callBound$h = callBound$i;
9202
9202
  var $Object$1 = esObjectAtoms;
9203
9203
  var $push = callBound$h('Array.prototype.push');
9204
9204
  var $propIsEnumerable = callBound$h('Object.prototype.propertyIsEnumerable');
9205
- var originalGetSymbols = hasSymbols$1 ? $Object$1.getOwnPropertySymbols : null;
9205
+ var originalGetSymbols = hasSymbols$2 ? $Object$1.getOwnPropertySymbols : null;
9206
9206
 
9207
9207
  // eslint-disable-next-line no-unused-vars
9208
9208
  var implementation$8 = function assign(target, source1) {
@@ -9216,7 +9216,7 @@ var implementation$8 = function assign(target, source1) {
9216
9216
 
9217
9217
  // step 3.a.ii:
9218
9218
  var keys = objectKeys$1(from);
9219
- var getSymbols = hasSymbols$1 && ($Object$1.getOwnPropertySymbols || originalGetSymbols);
9219
+ var getSymbols = hasSymbols$2 && ($Object$1.getOwnPropertySymbols || originalGetSymbols);
9220
9220
  if (getSymbols) {
9221
9221
  var syms = getSymbols(from);
9222
9222
  for (var j = 0; j < syms.length; ++j) {
@@ -9513,23 +9513,14 @@ var regexp_prototype_flags = flagsBound;
9513
9513
 
9514
9514
  var esGetIterator = {exports: {}};
9515
9515
 
9516
- var shams;
9517
- var hasRequiredShams;
9518
-
9519
- function requireShams () {
9520
- if (hasRequiredShams) return shams;
9521
- hasRequiredShams = 1;
9522
-
9523
- var hasSymbols = requireShams$1();
9516
+ var hasSymbols$1 = requireShams();
9524
9517
 
9525
- /** @type {import('.')} */
9526
- shams = function hasToStringTagShams() {
9527
- return hasSymbols() && !!Symbol.toStringTag;
9528
- };
9529
- return shams;
9530
- }
9518
+ /** @type {import('.')} */
9519
+ var shams = function hasToStringTagShams() {
9520
+ return hasSymbols$1() && !!Symbol.toStringTag;
9521
+ };
9531
9522
 
9532
- var hasToStringTag$7 = requireShams()();
9523
+ var hasToStringTag$7 = shams();
9533
9524
  var callBound$f = callBound$i;
9534
9525
 
9535
9526
  var $toString$7 = callBound$f('Object.prototype.toString');
@@ -10566,7 +10557,7 @@ var tryStringObject = function tryStringObject(value) {
10566
10557
  /** @type {(receiver: ThisParameterType<typeof Object.prototype.toString>, ...args: Parameters<typeof Object.prototype.toString>) => ReturnType<typeof Object.prototype.toString>} */
10567
10558
  var $toString$6 = callBound$c('Object.prototype.toString');
10568
10559
  var strClass = '[object String]';
10569
- var hasToStringTag$6 = requireShams()();
10560
+ var hasToStringTag$6 = shams();
10570
10561
 
10571
10562
  /** @type {import('.')} */
10572
10563
  var isString$2 = function isString(value) {
@@ -10682,7 +10673,7 @@ var isSet$2 = exported$1 || function isSet(x) {
10682
10673
  var isArguments$1 = isArguments$2;
10683
10674
  var getStopIterationIterator = stopIterationIterator;
10684
10675
 
10685
- if (hasSymbols$3() || requireShams$1()()) {
10676
+ if (hasSymbols$4() || requireShams()()) {
10686
10677
  var $iterator = Symbol.iterator;
10687
10678
  // Symbol is available natively or shammed
10688
10679
  // natively:
@@ -10971,7 +10962,7 @@ var tryDateObject = function tryDateGetDayCall(value) {
10971
10962
  /** @type {(value: unknown) => string} */
10972
10963
  var toStr$2 = callBound$9('Object.prototype.toString');
10973
10964
  var dateClass = '[object Date]';
10974
- var hasToStringTag$5 = requireShams()();
10965
+ var hasToStringTag$5 = shams();
10975
10966
 
10976
10967
  /** @type {import('.')} */
10977
10968
  var isDateObject = function isDateObject(value) {
@@ -10982,7 +10973,7 @@ var isDateObject = function isDateObject(value) {
10982
10973
  };
10983
10974
 
10984
10975
  var callBound$8 = callBound$i;
10985
- var hasToStringTag$4 = requireShams()();
10976
+ var hasToStringTag$4 = shams();
10986
10977
  var hasOwn = hasown;
10987
10978
  var gOPD$1 = gopd$1;
10988
10979
 
@@ -11087,7 +11078,7 @@ var tryNumberObject = function tryNumberObject(value) {
11087
11078
  };
11088
11079
  var $toString$3 = callBound$6('Object.prototype.toString');
11089
11080
  var numClass = '[object Number]';
11090
- var hasToStringTag$3 = requireShams()();
11081
+ var hasToStringTag$3 = shams();
11091
11082
 
11092
11083
  /** @type {import('.')} */
11093
11084
  var isNumberObject = function isNumberObject(value) {
@@ -11114,7 +11105,7 @@ var tryBooleanObject = function booleanBrandCheck(value) {
11114
11105
  }
11115
11106
  };
11116
11107
  var boolClass = '[object Boolean]';
11117
- var hasToStringTag$2 = requireShams()();
11108
+ var hasToStringTag$2 = shams();
11118
11109
 
11119
11110
  /** @type {import('.')} */
11120
11111
  var isBooleanObject = function isBoolean(value) {
@@ -11156,7 +11147,7 @@ function requireSafeRegexTest () {
11156
11147
 
11157
11148
  var callBound$4 = callBound$i;
11158
11149
  var $toString$1 = callBound$4('Object.prototype.toString');
11159
- var hasSymbols = hasSymbols$3();
11150
+ var hasSymbols = hasSymbols$4();
11160
11151
  var safeRegexTest = requireSafeRegexTest();
11161
11152
 
11162
11153
  if (hasSymbols) {
@@ -11602,7 +11593,7 @@ var gOPD = gopd$1;
11602
11593
  var getProto = getProto$3;
11603
11594
 
11604
11595
  var $toString = callBound$2('Object.prototype.toString');
11605
- var hasToStringTag = requireShams()();
11596
+ var hasToStringTag = shams();
11606
11597
 
11607
11598
  var g = typeof globalThis === 'undefined' ? commonjsGlobal : globalThis;
11608
11599
  var typedArrays = availableTypedArrays();
@@ -23282,6 +23273,267 @@ var RegistryPackageDetail = function RegistryPackageDetail(_ref) {
23282
23273
  });
23283
23274
  };
23284
23275
 
23276
+ /**
23277
+ * useRegistryAuth — reusable hook for device-code OAuth against the Dash Registry.
23278
+ *
23279
+ * Encapsulates the full auth state machine: check status, initiate login,
23280
+ * poll for token, and cancel. Cleans up the poll interval on unmount.
23281
+ *
23282
+ * @returns {{
23283
+ * isAuthenticated: boolean,
23284
+ * isAuthenticating: boolean,
23285
+ * authFlow: { userCode: string, verificationUrlComplete: string } | null,
23286
+ * authError: string | null,
23287
+ * checkAuth: () => Promise<boolean>,
23288
+ * initiateAuth: () => Promise<void>,
23289
+ * cancelAuth: () => void,
23290
+ * }}
23291
+ */
23292
+ function useRegistryAuth() {
23293
+ var _useState = useState(false),
23294
+ _useState2 = _slicedToArray(_useState, 2),
23295
+ isAuthenticated = _useState2[0],
23296
+ setIsAuthenticated = _useState2[1];
23297
+ var _useState3 = useState(false),
23298
+ _useState4 = _slicedToArray(_useState3, 2),
23299
+ isAuthenticating = _useState4[0],
23300
+ setIsAuthenticating = _useState4[1];
23301
+ var _useState5 = useState(null),
23302
+ _useState6 = _slicedToArray(_useState5, 2),
23303
+ authFlow = _useState6[0],
23304
+ setAuthFlow = _useState6[1];
23305
+ var _useState7 = useState(null),
23306
+ _useState8 = _slicedToArray(_useState7, 2),
23307
+ authError = _useState8[0],
23308
+ setAuthError = _useState8[1];
23309
+ var pollIntervalRef = useRef(null);
23310
+ var onAuthorizedRef = useRef(null);
23311
+
23312
+ // Clean up polling on unmount
23313
+ useEffect(function () {
23314
+ return function () {
23315
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
23316
+ };
23317
+ }, []);
23318
+ var checkAuth = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
23319
+ var status, authed;
23320
+ return _regeneratorRuntime.wrap(function (_context) {
23321
+ while (1) switch (_context.prev = _context.next) {
23322
+ case 0:
23323
+ _context.prev = 0;
23324
+ _context.next = 1;
23325
+ return window.mainApi.registryAuth.getStatus();
23326
+ case 1:
23327
+ status = _context.sent;
23328
+ authed = !!(status !== null && status !== void 0 && status.authenticated);
23329
+ setIsAuthenticated(authed);
23330
+ return _context.abrupt("return", authed);
23331
+ case 2:
23332
+ _context.prev = 2;
23333
+ _context["catch"](0);
23334
+ return _context.abrupt("return", false);
23335
+ case 3:
23336
+ case "end":
23337
+ return _context.stop();
23338
+ }
23339
+ }, _callee, null, [[0, 2]]);
23340
+ })), []);
23341
+ var cancelAuth = useCallback(function () {
23342
+ if (pollIntervalRef.current) {
23343
+ clearInterval(pollIntervalRef.current);
23344
+ pollIntervalRef.current = null;
23345
+ }
23346
+ setIsAuthenticating(false);
23347
+ setAuthFlow(null);
23348
+ }, []);
23349
+ var initiateAuth = useCallback(/*#__PURE__*/function () {
23350
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(onAuthorized) {
23351
+ var flow, interval;
23352
+ return _regeneratorRuntime.wrap(function (_context3) {
23353
+ while (1) switch (_context3.prev = _context3.next) {
23354
+ case 0:
23355
+ setAuthError(null);
23356
+ onAuthorizedRef.current = onAuthorized || null;
23357
+ _context3.prev = 1;
23358
+ _context3.next = 2;
23359
+ return window.mainApi.registryAuth.initiateLogin();
23360
+ case 2:
23361
+ flow = _context3.sent;
23362
+ setAuthFlow(flow);
23363
+ if (flow.verificationUrlComplete) {
23364
+ window.mainApi.shell.openExternal(flow.verificationUrlComplete);
23365
+ }
23366
+ setIsAuthenticating(true);
23367
+ interval = (flow.interval || 5) * 1000;
23368
+ pollIntervalRef.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
23369
+ var pollResult;
23370
+ return _regeneratorRuntime.wrap(function (_context2) {
23371
+ while (1) switch (_context2.prev = _context2.next) {
23372
+ case 0:
23373
+ _context2.prev = 0;
23374
+ _context2.next = 1;
23375
+ return window.mainApi.registryAuth.pollToken(flow.deviceCode);
23376
+ case 1:
23377
+ pollResult = _context2.sent;
23378
+ if (pollResult.status === "authorized") {
23379
+ clearInterval(pollIntervalRef.current);
23380
+ pollIntervalRef.current = null;
23381
+ setIsAuthenticating(false);
23382
+ setAuthFlow(null);
23383
+ setIsAuthenticated(true);
23384
+ if (onAuthorizedRef.current) {
23385
+ onAuthorizedRef.current();
23386
+ }
23387
+ } else if (pollResult.status === "expired") {
23388
+ clearInterval(pollIntervalRef.current);
23389
+ pollIntervalRef.current = null;
23390
+ setIsAuthenticating(false);
23391
+ setAuthFlow(null);
23392
+ setAuthError("Authorization expired. Please try again.");
23393
+ }
23394
+ _context2.next = 3;
23395
+ break;
23396
+ case 2:
23397
+ _context2.prev = 2;
23398
+ _context2["catch"](0);
23399
+ clearInterval(pollIntervalRef.current);
23400
+ pollIntervalRef.current = null;
23401
+ setIsAuthenticating(false);
23402
+ case 3:
23403
+ case "end":
23404
+ return _context2.stop();
23405
+ }
23406
+ }, _callee2, null, [[0, 2]]);
23407
+ })), interval);
23408
+ _context3.next = 4;
23409
+ break;
23410
+ case 3:
23411
+ _context3.prev = 3;
23412
+ _context3["catch"](1);
23413
+ setAuthError("Could not reach the registry. Check your connection and try again.");
23414
+ case 4:
23415
+ case "end":
23416
+ return _context3.stop();
23417
+ }
23418
+ }, _callee3, null, [[1, 3]]);
23419
+ }));
23420
+ return function (_x) {
23421
+ return _ref2.apply(this, arguments);
23422
+ };
23423
+ }(), [cancelAuth]);
23424
+ return {
23425
+ isAuthenticated: isAuthenticated,
23426
+ isAuthenticating: isAuthenticating,
23427
+ authFlow: authFlow,
23428
+ authError: authError,
23429
+ checkAuth: checkAuth,
23430
+ initiateAuth: initiateAuth,
23431
+ cancelAuth: cancelAuth
23432
+ };
23433
+ }
23434
+
23435
+ var RegistryAuthPrompt = function RegistryAuthPrompt(_ref) {
23436
+ var onAuthenticated = _ref.onAuthenticated,
23437
+ _ref$onCancel = _ref.onCancel,
23438
+ onCancel = _ref$onCancel === void 0 ? null : _ref$onCancel,
23439
+ _ref$message = _ref.message,
23440
+ message = _ref$message === void 0 ? "Sign in to install from the Dash Registry." : _ref$message;
23441
+ var _useRegistryAuth = useRegistryAuth(),
23442
+ isAuthenticating = _useRegistryAuth.isAuthenticating,
23443
+ authFlow = _useRegistryAuth.authFlow,
23444
+ authError = _useRegistryAuth.authError,
23445
+ checkAuth = _useRegistryAuth.checkAuth,
23446
+ initiateAuth = _useRegistryAuth.initiateAuth,
23447
+ cancelAuth = _useRegistryAuth.cancelAuth;
23448
+ var checkedRef = useRef(false);
23449
+
23450
+ // Check auth on mount — if already authenticated, short-circuit
23451
+ useEffect(function () {
23452
+ if (checkedRef.current) return;
23453
+ checkedRef.current = true;
23454
+ checkAuth().then(function (authed) {
23455
+ if (authed && onAuthenticated) onAuthenticated();
23456
+ });
23457
+ }, [checkAuth, onAuthenticated]);
23458
+ function handleSignIn() {
23459
+ initiateAuth(function () {
23460
+ if (onAuthenticated) onAuthenticated();
23461
+ });
23462
+ }
23463
+ function handleCancel() {
23464
+ cancelAuth();
23465
+ if (onCancel) onCancel();
23466
+ }
23467
+
23468
+ // Polling state: show user code
23469
+ if (authFlow && isAuthenticating) {
23470
+ return /*#__PURE__*/jsxs("div", {
23471
+ className: "flex flex-col gap-3 p-4",
23472
+ children: [/*#__PURE__*/jsxs("div", {
23473
+ className: "bg-blue-500/10 border border-blue-500/20 rounded-lg p-4 space-y-3",
23474
+ children: [/*#__PURE__*/jsx("p", {
23475
+ className: "text-xs text-blue-300/90",
23476
+ children: "Enter this code in your browser:"
23477
+ }), /*#__PURE__*/jsx("div", {
23478
+ className: "text-center",
23479
+ children: /*#__PURE__*/jsx("span", {
23480
+ className: "text-2xl font-mono font-bold tracking-widest text-white",
23481
+ children: authFlow.userCode
23482
+ })
23483
+ }), /*#__PURE__*/jsx("p", {
23484
+ className: "text-xs text-blue-300/70 text-center",
23485
+ children: "Waiting for authorization \u2014 install will resume automatically..."
23486
+ })]
23487
+ }), onCancel && /*#__PURE__*/jsx("button", {
23488
+ type: "button",
23489
+ onClick: handleCancel,
23490
+ className: "self-center text-xs text-gray-500 hover:text-gray-300 transition-colors",
23491
+ children: "Cancel"
23492
+ })]
23493
+ });
23494
+ }
23495
+
23496
+ // Default: not-started / error state
23497
+ return /*#__PURE__*/jsxs("div", {
23498
+ className: "flex flex-col gap-3 p-4",
23499
+ children: [/*#__PURE__*/jsx("div", {
23500
+ className: "bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-3",
23501
+ children: /*#__PURE__*/jsxs("div", {
23502
+ className: "flex items-start gap-2",
23503
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
23504
+ icon: "lock",
23505
+ className: "h-3.5 w-3.5 text-yellow-400 mt-0.5 flex-shrink-0"
23506
+ }), /*#__PURE__*/jsx("span", {
23507
+ className: "text-sm text-yellow-300/90",
23508
+ children: message
23509
+ })]
23510
+ })
23511
+ }), /*#__PURE__*/jsx("button", {
23512
+ type: "button",
23513
+ onClick: handleSignIn,
23514
+ 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",
23515
+ children: "Sign in to Registry"
23516
+ }), authError && /*#__PURE__*/jsx("div", {
23517
+ className: "bg-red-500/10 border border-red-500/20 rounded-lg p-3",
23518
+ children: /*#__PURE__*/jsxs("div", {
23519
+ className: "flex items-start gap-2",
23520
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
23521
+ icon: "circle-xmark",
23522
+ className: "h-3.5 w-3.5 text-red-400 mt-0.5 flex-shrink-0"
23523
+ }), /*#__PURE__*/jsx("span", {
23524
+ className: "text-xs text-red-300/90",
23525
+ children: authError
23526
+ })]
23527
+ })
23528
+ }), onCancel && /*#__PURE__*/jsx("button", {
23529
+ type: "button",
23530
+ onClick: handleCancel,
23531
+ className: "self-center text-xs text-gray-500 hover:text-gray-300 transition-colors",
23532
+ children: "Cancel"
23533
+ })]
23534
+ });
23535
+ };
23536
+
23285
23537
  function getWidgetSearchQuery(componentKey) {
23286
23538
  var parts = componentKey.split(".");
23287
23539
  if (parts.length >= 3) {
@@ -23331,7 +23583,8 @@ function packageToFlatWidget(pkg) {
23331
23583
  *
23332
23584
  * Shows the existing "Widget Not Found" error display and adds a
23333
23585
  * "Find in Registry" button that does an exact registry lookup and
23334
- * opens an install modal.
23586
+ * opens an install modal. When install requires auth, shows an inline
23587
+ * RegistryAuthPrompt and auto-retries after successful sign-in.
23335
23588
  */
23336
23589
  var WidgetNotFound = function WidgetNotFound(_ref) {
23337
23590
  var component = _ref.component;
@@ -23359,6 +23612,12 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
23359
23612
  _useState10 = _slicedToArray(_useState1, 2),
23360
23613
  installError = _useState10[0],
23361
23614
  setInstallError = _useState10[1];
23615
+ var _useState11 = useState(false),
23616
+ _useState12 = _slicedToArray(_useState11, 2),
23617
+ needsAuth = _useState12[0],
23618
+ setNeedsAuth = _useState12[1];
23619
+ var _useRegistryAuth = useRegistryAuth(),
23620
+ checkAuth = _useRegistryAuth.checkAuth;
23362
23621
  var lookupWidget = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
23363
23622
  var _getWidgetSearchQuery, packageName, widgetName, pkg, result;
23364
23623
  return _regeneratorRuntime.wrap(function (_context) {
@@ -23369,6 +23628,7 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
23369
23628
  setNotFound(false);
23370
23629
  setRegistryWidget(null);
23371
23630
  setInstallError(null);
23631
+ setNeedsAuth(false);
23372
23632
  _getWidgetSearchQuery = getWidgetSearchQuery(component), packageName = _getWidgetSearchQuery.packageName, widgetName = _getWidgetSearchQuery.widgetName;
23373
23633
  _context.prev = 1;
23374
23634
  pkg = null; // Scoped ID — exact package lookup
@@ -23415,7 +23675,7 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
23415
23675
  }, _callee, null, [[1, 6]]);
23416
23676
  })), [component]);
23417
23677
  var handleInstall = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
23418
- var packageName, packageScope, downloadUrl, packageVersion, scopedId, resolvedUrl, _t2;
23678
+ var authed, packageName, packageScope, downloadUrl, packageVersion, scopedId, resolvedUrl, msg, _t2;
23419
23679
  return _regeneratorRuntime.wrap(function (_context2) {
23420
23680
  while (1) switch (_context2.prev = _context2.next) {
23421
23681
  case 0:
@@ -23427,28 +23687,53 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
23427
23687
  case 1:
23428
23688
  setIsInstalling(true);
23429
23689
  setInstallError(null);
23690
+ setNeedsAuth(false);
23430
23691
  _context2.prev = 2;
23692
+ _context2.next = 3;
23693
+ return checkAuth();
23694
+ case 3:
23695
+ authed = _context2.sent;
23696
+ if (authed) {
23697
+ _context2.next = 4;
23698
+ break;
23699
+ }
23700
+ setNeedsAuth(true);
23701
+ setIsInstalling(false);
23702
+ return _context2.abrupt("return");
23703
+ case 4:
23431
23704
  packageName = registryWidget.packageName, packageScope = registryWidget.packageScope, downloadUrl = registryWidget.downloadUrl, packageVersion = registryWidget.packageVersion;
23432
23705
  scopedId = packageScope ? "@".concat(packageScope.replace(/^@/, ""), "/").concat(packageName) : packageName;
23433
23706
  resolvedUrl = downloadUrl.replace(/\{version\}/g, packageVersion).replace(/\{name\}/g, packageName);
23434
- _context2.next = 3;
23707
+ _context2.next = 5;
23435
23708
  return window.mainApi.widgets.install(scopedId, resolvedUrl);
23436
- case 3:
23709
+ case 5:
23437
23710
  setShowModal(false);
23438
- _context2.next = 5;
23711
+ _context2.next = 7;
23439
23712
  break;
23440
- case 4:
23441
- _context2.prev = 4;
23713
+ case 6:
23714
+ _context2.prev = 6;
23442
23715
  _t2 = _context2["catch"](2);
23443
- setInstallError(_t2.message || "Failed to install package");
23444
- case 5:
23716
+ msg = _t2.message || "Failed to install package";
23717
+ if (msg.toLowerCase().includes("unauthorized")) {
23718
+ setNeedsAuth(true);
23719
+ } else {
23720
+ setInstallError(msg);
23721
+ }
23722
+ case 7:
23445
23723
  setIsInstalling(false);
23446
- case 6:
23724
+ case 8:
23447
23725
  case "end":
23448
23726
  return _context2.stop();
23449
23727
  }
23450
- }, _callee2, null, [[2, 4]]);
23451
- })), [registryWidget]);
23728
+ }, _callee2, null, [[2, 6]]);
23729
+ })), [registryWidget, checkAuth]);
23730
+ var handleAuthSuccess = useCallback(function () {
23731
+ setNeedsAuth(false);
23732
+ handleInstall();
23733
+ }, [handleInstall]);
23734
+ var handleClose = useCallback(function () {
23735
+ setShowModal(false);
23736
+ }, []);
23452
23737
  return /*#__PURE__*/jsxs(Fragment, {
23453
23738
  children: [/*#__PURE__*/jsxs("div", {
23454
23739
  className: "flex flex-col h-full justify-center items-center w-full z-10 gap-2 p-4 text-center",
@@ -23473,43 +23758,56 @@ var WidgetNotFound = function WidgetNotFound(_ref) {
23473
23758
  className: "h-3 w-3"
23474
23759
  }), "Find in Registry"]
23475
23760
  })]
23476
- }), showModal && /*#__PURE__*/jsxs(Modal, {
23477
- title: "Registry Package",
23761
+ }), /*#__PURE__*/jsx(Modal, {
23762
+ isOpen: showModal,
23763
+ setIsOpen: setShowModal,
23478
23764
  width: "w-1/3",
23479
- height: "h-auto",
23480
- onClose: function onClose() {
23481
- return setShowModal(false);
23482
- },
23483
- children: [isLoading && /*#__PURE__*/jsx("div", {
23484
- className: "flex items-center justify-center p-12",
23485
- children: /*#__PURE__*/jsx(FontAwesomeIcon, {
23486
- icon: "spinner",
23487
- className: "h-5 w-5 text-gray-400 animate-spin"
23488
- })
23489
- }), !isLoading && registryWidget && /*#__PURE__*/jsx(RegistryPackageDetail, {
23490
- widget: registryWidget,
23491
- onInstall: handleInstall,
23492
- isInstalling: isInstalling,
23493
- installError: installError
23494
- }), !isLoading && notFound && /*#__PURE__*/jsxs("div", {
23495
- className: "flex flex-col items-center justify-center gap-3 p-12 text-center",
23496
- children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
23497
- icon: "triangle-exclamation",
23498
- className: "h-6 w-6 text-amber-500"
23499
- }), /*#__PURE__*/jsx("div", {
23500
- className: "text-sm text-gray-400",
23501
- children: "This widget is not available in the registry."
23502
- }), /*#__PURE__*/jsx(Button, {
23503
- title: "Close",
23504
- bgColor: "bg-gray-600",
23505
- hoverBackgroundColor: "hover:bg-gray-700",
23506
- textSize: "text-sm",
23507
- padding: "py-1.5 px-4",
23508
- onClick: function onClick() {
23509
- return setShowModal(false);
23510
- }
23765
+ height: "auto",
23766
+ children: /*#__PURE__*/jsxs("div", {
23767
+ className: "relative",
23768
+ children: [/*#__PURE__*/jsx("button", {
23769
+ type: "button",
23770
+ className: "absolute top-3 right-3 z-10 text-gray-500 hover:text-gray-300 transition-colors",
23771
+ onClick: handleClose,
23772
+ children: /*#__PURE__*/jsx(FontAwesomeIcon, {
23773
+ icon: "xmark",
23774
+ className: "h-4 w-4"
23775
+ })
23776
+ }), isLoading && /*#__PURE__*/jsx("div", {
23777
+ className: "flex items-center justify-center p-12",
23778
+ children: /*#__PURE__*/jsx(FontAwesomeIcon, {
23779
+ icon: "spinner",
23780
+ className: "h-5 w-5 text-gray-400 animate-spin"
23781
+ })
23782
+ }), !isLoading && needsAuth && registryWidget && /*#__PURE__*/jsx(RegistryAuthPrompt, {
23783
+ onAuthenticated: handleAuthSuccess,
23784
+ onCancel: function onCancel() {
23785
+ return setNeedsAuth(false);
23786
+ },
23787
+ message: "Sign in to install this widget from the Dash Registry."
23788
+ }), !isLoading && !needsAuth && registryWidget && /*#__PURE__*/jsx(RegistryPackageDetail, {
23789
+ widget: registryWidget,
23790
+ onInstall: handleInstall,
23791
+ isInstalling: isInstalling,
23792
+ installError: installError
23793
+ }), !isLoading && notFound && /*#__PURE__*/jsxs("div", {
23794
+ className: "flex flex-col items-center justify-center gap-3 p-12 text-center",
23795
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
23796
+ icon: "triangle-exclamation",
23797
+ className: "h-6 w-6 text-amber-500"
23798
+ }), /*#__PURE__*/jsx("div", {
23799
+ className: "text-sm text-gray-400",
23800
+ children: "This widget is not available in the registry."
23801
+ }), /*#__PURE__*/jsx(Button, {
23802
+ title: "Close",
23803
+ bgColor: "bg-gray-600",
23804
+ hoverBackgroundColor: "hover:bg-gray-700",
23805
+ textSize: "text-sm",
23806
+ padding: "py-1.5 px-4",
23807
+ onClick: handleClose
23808
+ })]
23511
23809
  })]
23512
- })]
23810
+ })
23513
23811
  })]
23514
23812
  });
23515
23813
  };