@trops/dash-core 0.1.234 → 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
@@ -36872,7 +36872,7 @@ var PublishDashboardModal = function PublishDashboardModal(_ref) {
36872
36872
  }
36873
36873
  function _handlePublish() {
36874
36874
  _handlePublish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
36875
- var options, res, _t2;
36875
+ var configMap, componentConfigs, _i, _Object$entries, _Object$entries$_i, key, config, options, res, _t2;
36876
36876
  return _regeneratorRuntime.wrap(function (_context2) {
36877
36877
  while (1) switch (_context2.prev = _context2.next) {
36878
36878
  case 0:
@@ -36885,11 +36885,25 @@ var PublishDashboardModal = function PublishDashboardModal(_ref) {
36885
36885
  setIsPublishing(true);
36886
36886
  setResult(null);
36887
36887
  _context2.prev = 2;
36888
+ // Collect component configs from ComponentManager for scope resolution
36889
+ configMap = ComponentManager.componentMap();
36890
+ componentConfigs = {};
36891
+ for (_i = 0, _Object$entries = Object.entries(configMap); _i < _Object$entries.length; _i++) {
36892
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], config = _Object$entries$_i[1];
36893
+ if (config && (config.id || config.scope || config.packageName)) {
36894
+ componentConfigs[config.name || key] = {
36895
+ id: config.id || null,
36896
+ scope: config.scope || "",
36897
+ packageName: config.packageName || ""
36898
+ };
36899
+ }
36900
+ }
36888
36901
  options = {
36889
36902
  authorName: authorName.trim(),
36890
36903
  description: description.trim() || undefined,
36891
36904
  tags: selectedTags,
36892
- icon: icon || undefined
36905
+ icon: icon || undefined,
36906
+ componentConfigs: componentConfigs
36893
36907
  };
36894
36908
  _context2.next = 3;
36895
36909
  return window.mainApi.dashboardConfig.prepareDashboardForPublish(appId, workspaceId, options);
@@ -43246,7 +43260,12 @@ var GeneralSection = function GeneralSection() {
43246
43260
 
43247
43261
  var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43248
43262
  var widget = _ref.widget,
43249
- 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;
43250
43269
  var _useContext = useContext(ThemeContext),
43251
43270
  currentTheme = _useContext.currentTheme;
43252
43271
  var panelStyles = getStylesForItem(themeObjects.PANEL, currentTheme, {
@@ -43279,7 +43298,19 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43279
43298
  children: [/*#__PURE__*/jsx("span", {
43280
43299
  className: "text-xs font-semibold opacity-50",
43281
43300
  children: "VERSION"
43282
- }), /*#__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", {
43283
43314
  className: "text-xs px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-70 w-fit"),
43284
43315
  children: ["v", widget.version]
43285
43316
  })]
@@ -43347,7 +43378,14 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43347
43378
  })]
43348
43379
  }), widget.source !== "builtin" && /*#__PURE__*/jsxs("div", {
43349
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"),
43350
- 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, {
43351
43389
  title: "Open in Finder",
43352
43390
  onClick: handleOpenInFinder,
43353
43391
  size: "sm"
@@ -44210,6 +44248,115 @@ var useInstalledWidgets = function useInstalledWidgets() {
44210
44248
  };
44211
44249
  };
44212
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
+
44213
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; }
44214
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; }
44215
44362
  var WidgetsSection = function WidgetsSection(_ref) {
@@ -44231,6 +44378,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44231
44378
  error = _useInstalledWidgets.error,
44232
44379
  uninstallWidget = _useInstalledWidgets.uninstallWidget,
44233
44380
  refresh = _useInstalledWidgets.refresh;
44381
+ var _useWidgetUpdates = useWidgetUpdates(widgets, refresh),
44382
+ updates = _useWidgetUpdates.updates,
44383
+ updateWidget = _useWidgetUpdates.updateWidget,
44384
+ isUpdating = _useWidgetUpdates.isUpdating;
44234
44385
  var _useState = useState(null),
44235
44386
  _useState2 = _slicedToArray(_useState, 2),
44236
44387
  selectedWidgetName = _useState2[0],
@@ -44600,6 +44751,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44600
44751
  className: "flex items-center gap-2",
44601
44752
  children: [widget.displayName || widget.name, widget.source === "builtin" && /*#__PURE__*/jsx(Tag3, {
44602
44753
  text: "Built-in"
44754
+ }), updates.has(widget.name) && /*#__PURE__*/jsx("span", {
44755
+ className: "text-[10px] text-blue-400 font-medium",
44756
+ children: "Update"
44603
44757
  })]
44604
44758
  })
44605
44759
  }, widget.name);
@@ -44694,9 +44848,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44694
44848
  })]
44695
44849
  }), /*#__PURE__*/jsx(Sidebar.Content, {
44696
44850
  children: listBody
44697
- }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsx("div", {
44851
+ }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxs("div", {
44698
44852
  className: "px-3 py-2 text-[10px] opacity-40 flex-shrink-0 border-t border-white/10",
44699
- children: function () {
44853
+ children: [function () {
44700
44854
  var builtinCount = widgets.filter(function (w) {
44701
44855
  return w.source === "builtin";
44702
44856
  }).length;
@@ -44707,7 +44861,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44707
44861
  if (builtinCount > 0) parts.push("".concat(builtinCount, " built-in"));
44708
44862
  if (installedCount > 0) parts.push("".concat(installedCount, " installed"));
44709
44863
  return parts.join(", ");
44710
- }()
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
+ })]
44711
44868
  })]
44712
44869
  });
44713
44870
 
@@ -44771,7 +44928,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44771
44928
  widget: selectedWidget,
44772
44929
  onDelete: function onDelete(w) {
44773
44930
  return handleDeleteRequest(w);
44774
- }
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)
44775
44935
  });
44776
44936
  }
44777
44937