@trops/dash-core 0.1.301 → 0.1.302

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
@@ -44510,7 +44510,9 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
44510
44510
  updateInfo = _ref$updateInfo === void 0 ? null : _ref$updateInfo,
44511
44511
  onUpdate = _ref.onUpdate,
44512
44512
  _ref$isUpdating = _ref.isUpdating,
44513
- isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating;
44513
+ isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
44514
+ _ref$updateError = _ref.updateError,
44515
+ updateError = _ref$updateError === void 0 ? null : _ref$updateError;
44514
44516
  var _useContext = React.useContext(DashReact.ThemeContext),
44515
44517
  currentTheme = _useContext.currentTheme;
44516
44518
  var panelStyles = DashReact.getStylesForItem(DashReact.themeObjects.PANEL, currentTheme, {
@@ -44621,6 +44623,12 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
44621
44623
  children: widget.path
44622
44624
  })]
44623
44625
  })]
44626
+ }), updateError && /*#__PURE__*/jsxRuntime.jsx("div", {
44627
+ className: "flex-shrink-0 px-6 py-2",
44628
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
44629
+ className: "p-2 rounded bg-red-900/30 border border-red-700 text-xs text-red-400",
44630
+ children: updateError
44631
+ })
44624
44632
  }), widget.source !== "builtin" && /*#__PURE__*/jsxRuntime.jsxs("div", {
44625
44633
  className: "flex-shrink-0 flex flex-row justify-end gap-2 px-6 py-4 border-t ".concat(currentTheme["border-primary-medium"] || "border-white/10"),
44626
44634
  children: [updateInfo && /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
@@ -45584,17 +45592,25 @@ function useWidgetUpdates() {
45584
45592
  // Update a single widget by downloading the latest version
45585
45593
  var updateWidget = React.useCallback(/*#__PURE__*/function () {
45586
45594
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
45587
- var info, widget, packageId, _window$mainApi2, status, resolvedUrl, _t;
45595
+ var info, widget, packageId, _window$mainApi2, profile, resolvedUrl, _t;
45588
45596
  return _regeneratorRuntime.wrap(function (_context) {
45589
45597
  while (1) switch (_context.prev = _context.next) {
45590
45598
  case 0:
45591
45599
  info = updates.get(name);
45592
- if (!(!info || !info.downloadUrl)) {
45600
+ if (info) {
45593
45601
  _context.next = 1;
45594
45602
  break;
45595
45603
  }
45604
+ setUpdateError("No update info found for \"".concat(name, "\"."));
45596
45605
  return _context.abrupt("return");
45597
45606
  case 1:
45607
+ if (info.downloadUrl) {
45608
+ _context.next = 2;
45609
+ break;
45610
+ }
45611
+ setUpdateError("Update for \"".concat(name, "\" has no download URL. The registry entry may be incomplete."));
45612
+ return _context.abrupt("return");
45613
+ case 2:
45598
45614
  // Use packageId for install — name may be a CM key (widget-level)
45599
45615
  widget = installedWidgets.find(function (w) {
45600
45616
  return w.name === name;
@@ -45602,22 +45618,23 @@ function useWidgetUpdates() {
45602
45618
  packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || info.name || name;
45603
45619
  setIsUpdating(name);
45604
45620
  setUpdateError(null);
45605
- _context.prev = 2;
45606
- _context.next = 3;
45607
- return (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.registryAuth) === null || _window$mainApi2 === void 0 ? void 0 : _window$mainApi2.getStatus();
45608
- case 3:
45609
- status = _context.sent;
45610
- if (status !== null && status !== void 0 && status.authenticated) {
45611
- _context.next = 4;
45621
+ _context.prev = 3;
45622
+ _context.next = 4;
45623
+ return (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.registryAuth) === null || _window$mainApi2 === void 0 ? void 0 : _window$mainApi2.getProfile();
45624
+ case 4:
45625
+ profile = _context.sent;
45626
+ if (profile) {
45627
+ _context.next = 5;
45612
45628
  break;
45613
45629
  }
45614
45630
  setNeedsAuth(true);
45615
45631
  return _context.abrupt("return");
45616
- case 4:
45632
+ case 5:
45617
45633
  resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, packageId);
45618
- _context.next = 5;
45634
+ _context.next = 6;
45619
45635
  return window.mainApi.widgets.install(packageId, resolvedUrl);
45620
- case 5:
45636
+ case 6:
45637
+
45621
45638
  // Remove ALL widgets in this package from updates map
45622
45639
  // (install replaces the entire package, not just one widget)
45623
45640
  setUpdates(function (prev) {
@@ -45639,21 +45656,21 @@ function useWidgetUpdates() {
45639
45656
  return next;
45640
45657
  });
45641
45658
  if (onUpdated) onUpdated();
45642
- _context.next = 7;
45659
+ _context.next = 8;
45643
45660
  break;
45644
- case 6:
45645
- _context.prev = 6;
45646
- _t = _context["catch"](2);
45647
- setUpdateError(_t.message || "Update failed");
45648
45661
  case 7:
45649
45662
  _context.prev = 7;
45650
- setIsUpdating(null);
45651
- return _context.finish(7);
45663
+ _t = _context["catch"](3);
45664
+ setUpdateError(_t.message || "Update failed");
45652
45665
  case 8:
45666
+ _context.prev = 8;
45667
+ setIsUpdating(null);
45668
+ return _context.finish(8);
45669
+ case 9:
45653
45670
  case "end":
45654
45671
  return _context.stop();
45655
45672
  }
45656
- }, _callee, null, [[2, 6, 7, 8]]);
45673
+ }, _callee, null, [[3, 7, 8, 9]]);
45657
45674
  }));
45658
45675
  return function (_x) {
45659
45676
  return _ref.apply(this, arguments);
@@ -45699,7 +45716,8 @@ var WidgetsSection = function WidgetsSection(_ref) {
45699
45716
  updateWidget = _useWidgetUpdates.updateWidget,
45700
45717
  isUpdating = _useWidgetUpdates.isUpdating,
45701
45718
  needsAuth = _useWidgetUpdates.needsAuth,
45702
- clearNeedsAuth = _useWidgetUpdates.clearNeedsAuth;
45719
+ clearNeedsAuth = _useWidgetUpdates.clearNeedsAuth,
45720
+ updateError = _useWidgetUpdates.updateError;
45703
45721
  var _useState = React.useState(null),
45704
45722
  _useState2 = _slicedToArray(_useState, 2),
45705
45723
  selectedWidgetName = _useState2[0],
@@ -46348,7 +46366,8 @@ var WidgetsSection = function WidgetsSection(_ref) {
46348
46366
  },
46349
46367
  updateInfo: updates.get(selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name) || null,
46350
46368
  onUpdate: updateWidget,
46351
- isUpdating: isUpdating === (selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name)
46369
+ isUpdating: isUpdating === (selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name),
46370
+ updateError: updateError
46352
46371
  });
46353
46372
  }
46354
46373