@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 +153 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +153 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43278,7 +43278,12 @@ var GeneralSection = function GeneralSection() {
|
|
|
43278
43278
|
|
|
43279
43279
|
var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
|
|
43280
43280
|
var widget = _ref.widget,
|
|
43281
|
-
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;
|
|
43282
43287
|
var _useContext = React.useContext(DashReact.ThemeContext),
|
|
43283
43288
|
currentTheme = _useContext.currentTheme;
|
|
43284
43289
|
var panelStyles = DashReact.getStylesForItem(DashReact.themeObjects.PANEL, currentTheme, {
|
|
@@ -43311,7 +43316,19 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
|
|
|
43311
43316
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
43312
43317
|
className: "text-xs font-semibold opacity-50",
|
|
43313
43318
|
children: "VERSION"
|
|
43314
|
-
}), /*#__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", {
|
|
43315
43332
|
className: "text-xs px-2 py-0.5 rounded ".concat(currentTheme["bg-primary-medium"], " opacity-70 w-fit"),
|
|
43316
43333
|
children: ["v", widget.version]
|
|
43317
43334
|
})]
|
|
@@ -43379,7 +43396,14 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
|
|
|
43379
43396
|
})]
|
|
43380
43397
|
}), widget.source !== "builtin" && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
43381
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"),
|
|
43382
|
-
children: [
|
|
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, {
|
|
43383
43407
|
title: "Open in Finder",
|
|
43384
43408
|
onClick: handleOpenInFinder,
|
|
43385
43409
|
size: "sm"
|
|
@@ -44242,6 +44266,115 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
44242
44266
|
};
|
|
44243
44267
|
};
|
|
44244
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
|
+
|
|
44245
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; }
|
|
44246
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; }
|
|
44247
44380
|
var WidgetsSection = function WidgetsSection(_ref) {
|
|
@@ -44263,6 +44396,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
44263
44396
|
error = _useInstalledWidgets.error,
|
|
44264
44397
|
uninstallWidget = _useInstalledWidgets.uninstallWidget,
|
|
44265
44398
|
refresh = _useInstalledWidgets.refresh;
|
|
44399
|
+
var _useWidgetUpdates = useWidgetUpdates(widgets, refresh),
|
|
44400
|
+
updates = _useWidgetUpdates.updates,
|
|
44401
|
+
updateWidget = _useWidgetUpdates.updateWidget,
|
|
44402
|
+
isUpdating = _useWidgetUpdates.isUpdating;
|
|
44266
44403
|
var _useState = React.useState(null),
|
|
44267
44404
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44268
44405
|
selectedWidgetName = _useState2[0],
|
|
@@ -44632,6 +44769,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
44632
44769
|
className: "flex items-center gap-2",
|
|
44633
44770
|
children: [widget.displayName || widget.name, widget.source === "builtin" && /*#__PURE__*/jsxRuntime.jsx(DashReact.Tag3, {
|
|
44634
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"
|
|
44635
44775
|
})]
|
|
44636
44776
|
})
|
|
44637
44777
|
}, widget.name);
|
|
@@ -44726,9 +44866,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
44726
44866
|
})]
|
|
44727
44867
|
}), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Content, {
|
|
44728
44868
|
children: listBody
|
|
44729
|
-
}), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxRuntime.
|
|
44869
|
+
}), !isLoading && !error && widgets.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
44730
44870
|
className: "px-3 py-2 text-[10px] opacity-40 flex-shrink-0 border-t border-white/10",
|
|
44731
|
-
children: function () {
|
|
44871
|
+
children: [function () {
|
|
44732
44872
|
var builtinCount = widgets.filter(function (w) {
|
|
44733
44873
|
return w.source === "builtin";
|
|
44734
44874
|
}).length;
|
|
@@ -44739,7 +44879,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
44739
44879
|
if (builtinCount > 0) parts.push("".concat(builtinCount, " built-in"));
|
|
44740
44880
|
if (installedCount > 0) parts.push("".concat(installedCount, " installed"));
|
|
44741
44881
|
return parts.join(", ");
|
|
44742
|
-
}()
|
|
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
|
+
})]
|
|
44743
44886
|
})]
|
|
44744
44887
|
});
|
|
44745
44888
|
|
|
@@ -44803,7 +44946,10 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
44803
44946
|
widget: selectedWidget,
|
|
44804
44947
|
onDelete: function onDelete(w) {
|
|
44805
44948
|
return handleDeleteRequest(w);
|
|
44806
|
-
}
|
|
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)
|
|
44807
44953
|
});
|
|
44808
44954
|
}
|
|
44809
44955
|
|