@trops/dash-core 0.1.287 → 0.1.289
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/electron/index.js +1095 -55
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +54 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +54 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -45459,7 +45459,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45459
45459
|
*
|
|
45460
45460
|
* @param {Array} installedWidgets - Widgets from useInstalledWidgets()
|
|
45461
45461
|
* @param {Function} onUpdated - Callback after a successful update (e.g. refresh)
|
|
45462
|
-
* @returns {{ updates: Map, isChecking: boolean, updateWidget: Function, isUpdating: string|null }}
|
|
45462
|
+
* @returns {{ updates: Map, isChecking: boolean, updateWidget: Function, isUpdating: string|null, needsAuth: boolean, clearNeedsAuth: Function, updateError: string|null }}
|
|
45463
45463
|
*/
|
|
45464
45464
|
function useWidgetUpdates() {
|
|
45465
45465
|
var installedWidgets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -45476,6 +45476,14 @@ function useWidgetUpdates() {
|
|
|
45476
45476
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
45477
45477
|
isUpdating = _useState6[0],
|
|
45478
45478
|
setIsUpdating = _useState6[1];
|
|
45479
|
+
var _useState7 = useState(false),
|
|
45480
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
45481
|
+
needsAuth = _useState8[0],
|
|
45482
|
+
setNeedsAuth = _useState8[1];
|
|
45483
|
+
var _useState9 = useState(null),
|
|
45484
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
45485
|
+
updateError = _useState0[0],
|
|
45486
|
+
setUpdateError = _useState0[1];
|
|
45479
45487
|
var checkedRef = useRef(false);
|
|
45480
45488
|
|
|
45481
45489
|
// Check for updates once when installed widgets are available
|
|
@@ -45526,7 +45534,7 @@ function useWidgetUpdates() {
|
|
|
45526
45534
|
// Update a single widget by downloading the latest version
|
|
45527
45535
|
var updateWidget = useCallback(/*#__PURE__*/function () {
|
|
45528
45536
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
|
|
45529
|
-
var info, widget, packageId, resolvedUrl;
|
|
45537
|
+
var info, widget, packageId, _window$mainApi2, status, resolvedUrl, _t;
|
|
45530
45538
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
45531
45539
|
while (1) switch (_context.prev = _context.next) {
|
|
45532
45540
|
case 0:
|
|
@@ -45543,11 +45551,23 @@ function useWidgetUpdates() {
|
|
|
45543
45551
|
});
|
|
45544
45552
|
packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || info.name || name;
|
|
45545
45553
|
setIsUpdating(name);
|
|
45554
|
+
setUpdateError(null);
|
|
45546
45555
|
_context.prev = 2;
|
|
45547
|
-
resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, packageId);
|
|
45548
45556
|
_context.next = 3;
|
|
45549
|
-
return window.mainApi.
|
|
45557
|
+
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();
|
|
45550
45558
|
case 3:
|
|
45559
|
+
status = _context.sent;
|
|
45560
|
+
if (status !== null && status !== void 0 && status.authenticated) {
|
|
45561
|
+
_context.next = 4;
|
|
45562
|
+
break;
|
|
45563
|
+
}
|
|
45564
|
+
setNeedsAuth(true);
|
|
45565
|
+
return _context.abrupt("return");
|
|
45566
|
+
case 4:
|
|
45567
|
+
resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, packageId);
|
|
45568
|
+
_context.next = 5;
|
|
45569
|
+
return window.mainApi.widgets.install(packageId, resolvedUrl);
|
|
45570
|
+
case 5:
|
|
45551
45571
|
// Remove from updates map on success
|
|
45552
45572
|
setUpdates(function (prev) {
|
|
45553
45573
|
var next = new Map(prev);
|
|
@@ -45555,30 +45575,37 @@ function useWidgetUpdates() {
|
|
|
45555
45575
|
return next;
|
|
45556
45576
|
});
|
|
45557
45577
|
if (onUpdated) onUpdated();
|
|
45558
|
-
_context.next =
|
|
45578
|
+
_context.next = 7;
|
|
45559
45579
|
break;
|
|
45560
|
-
case 4:
|
|
45561
|
-
_context.prev = 4;
|
|
45562
|
-
_context["catch"](2);
|
|
45563
|
-
case 5:
|
|
45564
|
-
_context.prev = 5;
|
|
45565
|
-
setIsUpdating(null);
|
|
45566
|
-
return _context.finish(5);
|
|
45567
45580
|
case 6:
|
|
45581
|
+
_context.prev = 6;
|
|
45582
|
+
_t = _context["catch"](2);
|
|
45583
|
+
setUpdateError(_t.message || "Update failed");
|
|
45584
|
+
case 7:
|
|
45585
|
+
_context.prev = 7;
|
|
45586
|
+
setIsUpdating(null);
|
|
45587
|
+
return _context.finish(7);
|
|
45588
|
+
case 8:
|
|
45568
45589
|
case "end":
|
|
45569
45590
|
return _context.stop();
|
|
45570
45591
|
}
|
|
45571
|
-
}, _callee, null, [[2,
|
|
45592
|
+
}, _callee, null, [[2, 6, 7, 8]]);
|
|
45572
45593
|
}));
|
|
45573
45594
|
return function (_x) {
|
|
45574
45595
|
return _ref.apply(this, arguments);
|
|
45575
45596
|
};
|
|
45576
45597
|
}(), [updates, onUpdated, installedWidgets]);
|
|
45598
|
+
var clearNeedsAuth = useCallback(function () {
|
|
45599
|
+
return setNeedsAuth(false);
|
|
45600
|
+
}, []);
|
|
45577
45601
|
return {
|
|
45578
45602
|
updates: updates,
|
|
45579
45603
|
isChecking: isChecking,
|
|
45580
45604
|
updateWidget: updateWidget,
|
|
45581
|
-
isUpdating: isUpdating
|
|
45605
|
+
isUpdating: isUpdating,
|
|
45606
|
+
needsAuth: needsAuth,
|
|
45607
|
+
clearNeedsAuth: clearNeedsAuth,
|
|
45608
|
+
updateError: updateError
|
|
45582
45609
|
};
|
|
45583
45610
|
}
|
|
45584
45611
|
|
|
@@ -45606,7 +45633,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
45606
45633
|
var _useWidgetUpdates = useWidgetUpdates(widgets, refresh),
|
|
45607
45634
|
updates = _useWidgetUpdates.updates,
|
|
45608
45635
|
updateWidget = _useWidgetUpdates.updateWidget,
|
|
45609
|
-
isUpdating = _useWidgetUpdates.isUpdating
|
|
45636
|
+
isUpdating = _useWidgetUpdates.isUpdating,
|
|
45637
|
+
needsAuth = _useWidgetUpdates.needsAuth,
|
|
45638
|
+
clearNeedsAuth = _useWidgetUpdates.clearNeedsAuth;
|
|
45610
45639
|
var _useState = useState(null),
|
|
45611
45640
|
_useState2 = _slicedToArray(_useState, 2),
|
|
45612
45641
|
selectedWidgetName = _useState2[0],
|
|
@@ -46330,7 +46359,16 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46330
46359
|
})]
|
|
46331
46360
|
})]
|
|
46332
46361
|
})
|
|
46333
|
-
}))
|
|
46362
|
+
})), /*#__PURE__*/jsx(RegistryAuthModal, {
|
|
46363
|
+
isOpen: needsAuth,
|
|
46364
|
+
setIsOpen: function setIsOpen(open) {
|
|
46365
|
+
if (!open) clearNeedsAuth();
|
|
46366
|
+
},
|
|
46367
|
+
onAuthenticated: function onAuthenticated() {
|
|
46368
|
+
clearNeedsAuth();
|
|
46369
|
+
if (selectedWidget !== null && selectedWidget !== void 0 && selectedWidget.name) updateWidget(selectedWidget.name);
|
|
46370
|
+
}
|
|
46371
|
+
})]
|
|
46334
46372
|
});
|
|
46335
46373
|
};
|
|
46336
46374
|
|