@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.js CHANGED
@@ -36890,7 +36890,7 @@ var PublishDashboardModal = function PublishDashboardModal(_ref) {
36890
36890
  }
36891
36891
  function _handlePublish() {
36892
36892
  _handlePublish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
36893
- var options, res, _t2;
36893
+ var configMap, componentConfigs, _i, _Object$entries, _Object$entries$_i, key, config, options, res, _t2;
36894
36894
  return _regeneratorRuntime.wrap(function (_context2) {
36895
36895
  while (1) switch (_context2.prev = _context2.next) {
36896
36896
  case 0:
@@ -36903,11 +36903,25 @@ var PublishDashboardModal = function PublishDashboardModal(_ref) {
36903
36903
  setIsPublishing(true);
36904
36904
  setResult(null);
36905
36905
  _context2.prev = 2;
36906
+ // Collect component configs from ComponentManager for scope resolution
36907
+ configMap = ComponentManager.componentMap();
36908
+ componentConfigs = {};
36909
+ for (_i = 0, _Object$entries = Object.entries(configMap); _i < _Object$entries.length; _i++) {
36910
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], config = _Object$entries$_i[1];
36911
+ if (config && (config.id || config.scope || config.packageName)) {
36912
+ componentConfigs[config.name || key] = {
36913
+ id: config.id || null,
36914
+ scope: config.scope || "",
36915
+ packageName: config.packageName || ""
36916
+ };
36917
+ }
36918
+ }
36906
36919
  options = {
36907
36920
  authorName: authorName.trim(),
36908
36921
  description: description.trim() || undefined,
36909
36922
  tags: selectedTags,
36910
- icon: icon || undefined
36923
+ icon: icon || undefined,
36924
+ componentConfigs: componentConfigs
36911
36925
  };
36912
36926
  _context2.next = 3;
36913
36927
  return window.mainApi.dashboardConfig.prepareDashboardForPublish(appId, workspaceId, options);
@@ -43264,7 +43278,12 @@ var GeneralSection = function GeneralSection() {
43264
43278
 
43265
43279
  var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43266
43280
  var widget = _ref.widget,
43267
- onDelete = _ref.onDelete;
43281
+ onDelete = _ref.onDelete,
43282
+ _ref$updateInfo = _ref.updateInfo,
43283
+ updateInfo = _ref$updateInfo === void 0 ? null : _ref$updateInfo,
43284
+ onUpdate = _ref.onUpdate,
43285
+ _ref$isUpdating = _ref.isUpdating,
43286
+ isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating;
43268
43287
  var _useContext = React.useContext(DashReact.ThemeContext),
43269
43288
  currentTheme = _useContext.currentTheme;
43270
43289
  var panelStyles = DashReact.getStylesForItem(DashReact.themeObjects.PANEL, currentTheme, {
@@ -43297,7 +43316,19 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43297
43316
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
43298
43317
  className: "text-xs font-semibold opacity-50",
43299
43318
  children: "VERSION"
43300
- }), /*#__PURE__*/jsxRuntime.jsxs("span", {
43319
+ }), updateInfo ? /*#__PURE__*/jsxRuntime.jsxs("span", {
43320
+ className: "flex items-center gap-2 text-xs",
43321
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
43322
+ className: "px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-50 w-fit"),
43323
+ children: ["v", widget.version]
43324
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
43325
+ className: "opacity-40",
43326
+ children: "\u2192"
43327
+ }), /*#__PURE__*/jsxRuntime.jsxs("span", {
43328
+ className: "px-2 py-0.5 rounded bg-blue-900/30 text-blue-400 w-fit",
43329
+ children: ["v", updateInfo.latestVersion]
43330
+ })]
43331
+ }) : /*#__PURE__*/jsxRuntime.jsxs("span", {
43301
43332
  className: "text-xs px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-70 w-fit"),
43302
43333
  children: ["v", widget.version]
43303
43334
  })]
@@ -43365,7 +43396,14 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
43365
43396
  })]
43366
43397
  }), widget.source !== "builtin" && /*#__PURE__*/jsxRuntime.jsxs("div", {
43367
43398
  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"),
43368
- children: [widget.path && /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
43399
+ children: [updateInfo && /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
43400
+ title: isUpdating ? "Updating..." : "Update to v".concat(updateInfo.latestVersion),
43401
+ onClick: function onClick() {
43402
+ return onUpdate(widget.name);
43403
+ },
43404
+ disabled: isUpdating,
43405
+ size: "sm"
43406
+ }), widget.path && /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
43369
43407
  title: "Open in Finder",
43370
43408
  onClick: handleOpenInFinder,
43371
43409
  size: "sm"
@@ -44228,6 +44266,115 @@ var useInstalledWidgets = function useInstalledWidgets() {
44228
44266
  };
44229
44267
  };
44230
44268
 
44269
+ /**
44270
+ * useWidgetUpdates — checks the registry for newer versions of installed widgets
44271
+ * and provides a one-click update function.
44272
+ *
44273
+ * @param {Array} installedWidgets - Widgets from useInstalledWidgets()
44274
+ * @param {Function} onUpdated - Callback after a successful update (e.g. refresh)
44275
+ * @returns {{ updates: Map, isChecking: boolean, updateWidget: Function, isUpdating: string|null }}
44276
+ */
44277
+ function useWidgetUpdates() {
44278
+ var installedWidgets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
44279
+ var onUpdated = arguments.length > 1 ? arguments[1] : undefined;
44280
+ var _useState = React.useState(new Map()),
44281
+ _useState2 = _slicedToArray(_useState, 2),
44282
+ updates = _useState2[0],
44283
+ setUpdates = _useState2[1];
44284
+ var _useState3 = React.useState(false),
44285
+ _useState4 = _slicedToArray(_useState3, 2),
44286
+ isChecking = _useState4[0],
44287
+ setIsChecking = _useState4[1];
44288
+ var _useState5 = React.useState(null),
44289
+ _useState6 = _slicedToArray(_useState5, 2),
44290
+ isUpdating = _useState6[0],
44291
+ setIsUpdating = _useState6[1];
44292
+ var checkedRef = React.useRef(false);
44293
+
44294
+ // Check for updates once when installed widgets are available
44295
+ React.useEffect(function () {
44296
+ var _window$mainApi;
44297
+ if (checkedRef.current) return;
44298
+ var installed = installedWidgets.filter(function (w) {
44299
+ return w.source === "installed" && w.version;
44300
+ });
44301
+ if (installed.length === 0) return;
44302
+ checkedRef.current = true;
44303
+ setIsChecking(true);
44304
+ var payload = installed.map(function (w) {
44305
+ return {
44306
+ name: w.name,
44307
+ version: w.version
44308
+ };
44309
+ });
44310
+ (_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) {
44311
+ if (Array.isArray(results) && results.length > 0) {
44312
+ var map = new Map();
44313
+ results.forEach(function (r) {
44314
+ return map.set(r.name, r);
44315
+ });
44316
+ setUpdates(map);
44317
+ }
44318
+ })["catch"](function (err) {
44319
+ })["finally"](function () {
44320
+ setIsChecking(false);
44321
+ });
44322
+ }, [installedWidgets]);
44323
+
44324
+ // Update a single widget by downloading the latest version
44325
+ var updateWidget = React.useCallback(/*#__PURE__*/function () {
44326
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
44327
+ var info, resolvedUrl;
44328
+ return _regeneratorRuntime.wrap(function (_context) {
44329
+ while (1) switch (_context.prev = _context.next) {
44330
+ case 0:
44331
+ info = updates.get(name);
44332
+ if (!(!info || !info.downloadUrl)) {
44333
+ _context.next = 1;
44334
+ break;
44335
+ }
44336
+ return _context.abrupt("return");
44337
+ case 1:
44338
+ setIsUpdating(name);
44339
+ _context.prev = 2;
44340
+ resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, name);
44341
+ _context.next = 3;
44342
+ return window.mainApi.widgets.install(name, resolvedUrl);
44343
+ case 3:
44344
+ // Remove from updates map on success
44345
+ setUpdates(function (prev) {
44346
+ var next = new Map(prev);
44347
+ next["delete"](name);
44348
+ return next;
44349
+ });
44350
+ if (onUpdated) onUpdated();
44351
+ _context.next = 5;
44352
+ break;
44353
+ case 4:
44354
+ _context.prev = 4;
44355
+ _context["catch"](2);
44356
+ case 5:
44357
+ _context.prev = 5;
44358
+ setIsUpdating(null);
44359
+ return _context.finish(5);
44360
+ case 6:
44361
+ case "end":
44362
+ return _context.stop();
44363
+ }
44364
+ }, _callee, null, [[2, 4, 5, 6]]);
44365
+ }));
44366
+ return function (_x) {
44367
+ return _ref.apply(this, arguments);
44368
+ };
44369
+ }(), [updates, onUpdated]);
44370
+ return {
44371
+ updates: updates,
44372
+ isChecking: isChecking,
44373
+ updateWidget: updateWidget,
44374
+ isUpdating: isUpdating
44375
+ };
44376
+ }
44377
+
44231
44378
  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; }
44232
44379
  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; }
44233
44380
  var WidgetsSection = function WidgetsSection(_ref) {
@@ -44249,6 +44396,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44249
44396
  error = _useInstalledWidgets.error,
44250
44397
  uninstallWidget = _useInstalledWidgets.uninstallWidget,
44251
44398
  refresh = _useInstalledWidgets.refresh;
44399
+ var _useWidgetUpdates = useWidgetUpdates(widgets, refresh),
44400
+ updates = _useWidgetUpdates.updates,
44401
+ updateWidget = _useWidgetUpdates.updateWidget,
44402
+ isUpdating = _useWidgetUpdates.isUpdating;
44252
44403
  var _useState = React.useState(null),
44253
44404
  _useState2 = _slicedToArray(_useState, 2),
44254
44405
  selectedWidgetName = _useState2[0],
@@ -44618,6 +44769,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44618
44769
  className: "flex items-center gap-2",
44619
44770
  children: [widget.displayName || widget.name, widget.source === "builtin" && /*#__PURE__*/jsxRuntime.jsx(DashReact.Tag3, {
44620
44771
  text: "Built-in"
44772
+ }), updates.has(widget.name) && /*#__PURE__*/jsxRuntime.jsx("span", {
44773
+ className: "text-[10px] text-blue-400 font-medium",
44774
+ children: "Update"
44621
44775
  })]
44622
44776
  })
44623
44777
  }, widget.name);
@@ -44712,9 +44866,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
44712
44866
  })]
44713
44867
  }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Content, {
44714
44868
  children: listBody
44715
- }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxRuntime.jsx("div", {
44869
+ }), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
44716
44870
  className: "px-3 py-2 text-[10px] opacity-40 flex-shrink-0 border-t border-white/10",
44717
- children: function () {
44871
+ children: [function () {
44718
44872
  var builtinCount = widgets.filter(function (w) {
44719
44873
  return w.source === "builtin";
44720
44874
  }).length;
@@ -44725,7 +44879,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44725
44879
  if (builtinCount > 0) parts.push("".concat(builtinCount, " built-in"));
44726
44880
  if (installedCount > 0) parts.push("".concat(installedCount, " installed"));
44727
44881
  return parts.join(", ");
44728
- }()
44882
+ }(), updates.size > 0 && /*#__PURE__*/jsxRuntime.jsxs("span", {
44883
+ className: "text-blue-400 ml-1",
44884
+ children: [" \xB7 ", updates.size, " update", updates.size !== 1 ? "s" : "", " available"]
44885
+ })]
44729
44886
  })]
44730
44887
  });
44731
44888
 
@@ -44789,7 +44946,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
44789
44946
  widget: selectedWidget,
44790
44947
  onDelete: function onDelete(w) {
44791
44948
  return handleDeleteRequest(w);
44792
- }
44949
+ },
44950
+ updateInfo: updates.get(selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name) || null,
44951
+ onUpdate: updateWidget,
44952
+ isUpdating: isUpdating === (selectedWidget === null || selectedWidget === void 0 ? void 0 : selectedWidget.name)
44793
44953
  });
44794
44954
  }
44795
44955