@trops/dash-core 0.1.235 → 0.1.237

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
@@ -43260,7 +43260,12 @@ var GeneralSection = function GeneralSection() {
43260
43260
 
43261
43261
  var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43262
43262
  var widget = _ref.widget,
43263
- onDelete = _ref.onDelete;
43263
+ onDelete = _ref.onDelete,
43264
+ _ref$updateInfo = _ref.updateInfo,
43265
+ updateInfo = _ref$updateInfo === void 0 ? null : _ref$updateInfo,
43266
+ onUpdate = _ref.onUpdate,
43267
+ _ref$isUpdating = _ref.isUpdating,
43268
+ isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating;
43264
43269
  var _useContext = useContext(ThemeContext),
43265
43270
  currentTheme = _useContext.currentTheme;
43266
43271
  var panelStyles = getStylesForItem(themeObjects.PANEL, currentTheme, {
@@ -43293,7 +43298,19 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43293
43298
  children: [/*#__PURE__*/jsx("span", {
43294
43299
  className: "text-xs font-semibold opacity-50",
43295
43300
  children: "VERSION"
43296
- }), /*#__PURE__*/jsxs("span", {
43301
+ }), updateInfo ? /*#__PURE__*/jsxs("span", {
43302
+ className: "flex items-center gap-2 text-xs",
43303
+ children: [/*#__PURE__*/jsxs("span", {
43304
+ className: "px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-50 w-fit"),
43305
+ children: ["v", widget.version]
43306
+ }), /*#__PURE__*/jsx("span", {
43307
+ className: "opacity-40",
43308
+ children: "\u2192"
43309
+ }), /*#__PURE__*/jsxs("span", {
43310
+ className: "px-2 py-0.5 rounded bg-blue-900/30 text-blue-400 w-fit",
43311
+ children: ["v", updateInfo.latestVersion]
43312
+ })]
43313
+ }) : /*#__PURE__*/jsxs("span", {
43297
43314
  className: "text-xs px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-70 w-fit"),
43298
43315
  children: ["v", widget.version]
43299
43316
  })]
@@ -43361,7 +43378,14 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43361
43378
  })]
43362
43379
  }), widget.source !== "builtin" && /*#__PURE__*/jsxs("div", {
43363
43380
  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"),
43364
- children: [widget.path && /*#__PURE__*/jsx(Button, {
43381
+ children: [updateInfo && /*#__PURE__*/jsx(Button, {
43382
+ title: isUpdating ? "Updating..." : "Update to v".concat(updateInfo.latestVersion),
43383
+ onClick: function onClick() {
43384
+ return onUpdate(widget.name);
43385
+ },
43386
+ disabled: isUpdating,
43387
+ size: "sm"
43388
+ }), widget.path && /*#__PURE__*/jsx(Button, {
43365
43389
  title: "Open in Finder",
43366
43390
  onClick: handleOpenInFinder,
43367
43391
  size: "sm"
@@ -44224,6 +44248,115 @@ var useInstalledWidgets = function useInstalledWidgets() {
44224
44248
  };
44225
44249
  };
44226
44250
 
44251
+ /**
44252
+ * useWidgetUpdates — checks the registry for newer versions of installed widgets
44253
+ * and provides a one-click update function.
44254
+ *
44255
+ * @param {Array} installedWidgets - Widgets from useInstalledWidgets()
44256
+ * @param {Function} onUpdated - Callback after a successful update (e.g. refresh)
44257
+ * @returns {{ updates: Map, isChecking: boolean, updateWidget: Function, isUpdating: string|null }}
44258
+ */
44259
+ function useWidgetUpdates() {
44260
+ var installedWidgets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
44261
+ var onUpdated = arguments.length > 1 ? arguments[1] : undefined;
44262
+ var _useState = useState(new Map()),
44263
+ _useState2 = _slicedToArray(_useState, 2),
44264
+ updates = _useState2[0],
44265
+ setUpdates = _useState2[1];
44266
+ var _useState3 = useState(false),
44267
+ _useState4 = _slicedToArray(_useState3, 2),
44268
+ isChecking = _useState4[0],
44269
+ setIsChecking = _useState4[1];
44270
+ var _useState5 = useState(null),
44271
+ _useState6 = _slicedToArray(_useState5, 2),
44272
+ isUpdating = _useState6[0],
44273
+ setIsUpdating = _useState6[1];
44274
+ var checkedRef = useRef(false);
44275
+
44276
+ // Check for updates once when installed widgets are available
44277
+ useEffect(function () {
44278
+ var _window$mainApi;
44279
+ if (checkedRef.current) return;
44280
+ var installed = installedWidgets.filter(function (w) {
44281
+ return w.source === "installed" && w.version;
44282
+ });
44283
+ if (installed.length === 0) return;
44284
+ checkedRef.current = true;
44285
+ setIsChecking(true);
44286
+ var payload = installed.map(function (w) {
44287
+ return {
44288
+ name: w.name,
44289
+ version: w.version
44290
+ };
44291
+ });
44292
+ (_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 || (_window$mainApi = _window$mainApi.registry) === null || _window$mainApi === void 0 || _window$mainApi.checkUpdates(payload).then(function (results) {
44293
+ if (Array.isArray(results) && results.length > 0) {
44294
+ var map = new Map();
44295
+ results.forEach(function (r) {
44296
+ return map.set(r.name, r);
44297
+ });
44298
+ setUpdates(map);
44299
+ }
44300
+ })["catch"](function (err) {
44301
+ })["finally"](function () {
44302
+ setIsChecking(false);
44303
+ });
44304
+ }, [installedWidgets]);
44305
+
44306
+ // Update a single widget by downloading the latest version
44307
+ var updateWidget = useCallback(/*#__PURE__*/function () {
44308
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
44309
+ var info, resolvedUrl;
44310
+ return _regeneratorRuntime.wrap(function (_context) {
44311
+ while (1) switch (_context.prev = _context.next) {
44312
+ case 0:
44313
+ info = updates.get(name);
44314
+ if (!(!info || !info.downloadUrl)) {
44315
+ _context.next = 1;
44316
+ break;
44317
+ }
44318
+ return _context.abrupt("return");
44319
+ case 1:
44320
+ setIsUpdating(name);
44321
+ _context.prev = 2;
44322
+ resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, name);
44323
+ _context.next = 3;
44324
+ return window.mainApi.widgets.install(name, resolvedUrl);
44325
+ case 3:
44326
+ // Remove from updates map on success
44327
+ setUpdates(function (prev) {
44328
+ var next = new Map(prev);
44329
+ next["delete"](name);
44330
+ return next;
44331
+ });
44332
+ if (onUpdated) onUpdated();
44333
+ _context.next = 5;
44334
+ break;
44335
+ case 4:
44336
+ _context.prev = 4;
44337
+ _context["catch"](2);
44338
+ case 5:
44339
+ _context.prev = 5;
44340
+ setIsUpdating(null);
44341
+ return _context.finish(5);
44342
+ case 6:
44343
+ case "end":
44344
+ return _context.stop();
44345
+ }
44346
+ }, _callee, null, [[2, 4, 5, 6]]);
44347
+ }));
44348
+ return function (_x) {
44349
+ return _ref.apply(this, arguments);
44350
+ };
44351
+ }(), [updates, onUpdated]);
44352
+ return {
44353
+ updates: updates,
44354
+ isChecking: isChecking,
44355
+ updateWidget: updateWidget,
44356
+ isUpdating: isUpdating
44357
+ };
44358
+ }
44359
+
44227
44360
  function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
44228
44361
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
44229
44362
  var WidgetsSection = function WidgetsSection(_ref) {
@@ -44245,6 +44378,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44245
44378
  error = _useInstalledWidgets.error,
44246
44379
  uninstallWidget = _useInstalledWidgets.uninstallWidget,
44247
44380
  refresh = _useInstalledWidgets.refresh;
44381
+ var _useWidgetUpdates = useWidgetUpdates(widgets, refresh),
44382
+ updates = _useWidgetUpdates.updates,
44383
+ updateWidget = _useWidgetUpdates.updateWidget,
44384
+ isUpdating = _useWidgetUpdates.isUpdating;
44248
44385
  var _useState = useState(null),
44249
44386
  _useState2 = _slicedToArray(_useState, 2),
44250
44387
  selectedWidgetName = _useState2[0],
@@ -44614,6 +44751,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44614
44751
  className: "flex items-center gap-2",
44615
44752
  children: [widget.displayName || widget.name, widget.source === "builtin" && /*#__PURE__*/jsx(Tag3, {
44616
44753
  text: "Built-in"
44754
+ }), updates.has(widget.name) && /*#__PURE__*/jsx("span", {
44755
+ className: "text-[10px] text-blue-400 font-medium",
44756
+ children: "Update"
44617
44757
  })]
44618
44758
  })
44619
44759
  }, widget.name);
@@ -44708,9 +44848,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44708
44848
  })]
44709
44849
  }), /*#__PURE__*/jsx(Sidebar.Content, {
44710
44850
  children: listBody
44711
- }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsx("div", {
44851
+ }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxs("div", {
44712
44852
  className: "px-3 py-2 text-[10px] opacity-40 flex-shrink-0 border-t border-white/10",
44713
- children: function () {
44853
+ children: [function () {
44714
44854
  var builtinCount = widgets.filter(function (w) {
44715
44855
  return w.source === "builtin";
44716
44856
  }).length;
@@ -44721,7 +44861,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44721
44861
  if (builtinCount > 0) parts.push("".concat(builtinCount, " built-in"));
44722
44862
  if (installedCount > 0) parts.push("".concat(installedCount, " installed"));
44723
44863
  return parts.join(", ");
44724
- }()
44864
+ }(), updates.size > 0 && /*#__PURE__*/jsxs("span", {
44865
+ className: "text-blue-400 ml-1",
44866
+ children: [" \xB7 ", updates.size, " update", updates.size !== 1 ? "s" : "", " available"]
44867
+ })]
44725
44868
  })]
44726
44869
  });
44727
44870
 
@@ -44785,7 +44928,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44785
44928
  widget: selectedWidget,
44786
44929
  onDelete: function onDelete(w) {
44787
44930
  return handleDeleteRequest(w);
44788
- }
44931
+ },
44932
+ updateInfo: updates.get(selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name) || null,
44933
+ onUpdate: updateWidget,
44934
+ isUpdating: isUpdating === (selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name)
44789
44935
  });
44790
44936
  }
44791
44937