@lvce-editor/update-worker 1.5.0 → 1.7.0
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/updateWorkerMain.js +22 -7
- package/package.json +1 -1
package/dist/updateWorkerMain.js
CHANGED
|
@@ -837,6 +837,8 @@ const WebWorkerRpcClient = {
|
|
|
837
837
|
create: create$1
|
|
838
838
|
};
|
|
839
839
|
|
|
840
|
+
const Electron = 2;
|
|
841
|
+
|
|
840
842
|
const RendererWorker = 1;
|
|
841
843
|
|
|
842
844
|
const rpcs = Object.create(null);
|
|
@@ -903,11 +905,12 @@ const promptRestart = () => {
|
|
|
903
905
|
return i18nString(UiStrings.DoYouWantToRestart);
|
|
904
906
|
};
|
|
905
907
|
|
|
906
|
-
// TODO avoid js prompt in elctron, since it crashes electron
|
|
907
|
-
|
|
908
908
|
const confirmPrompt = async message => {
|
|
909
|
-
|
|
910
|
-
|
|
909
|
+
const result = await invoke('ConfirmPrompt.prompt', message, {
|
|
910
|
+
// @ts-ignore
|
|
911
|
+
platform: Electron
|
|
912
|
+
});
|
|
913
|
+
return result;
|
|
911
914
|
};
|
|
912
915
|
|
|
913
916
|
const downloadToDisk = async (diskPath, response) => {
|
|
@@ -984,7 +987,7 @@ const getDiskPath = async downloadUrl => {
|
|
|
984
987
|
// @ts-ignore
|
|
985
988
|
const cacheDir = await invoke('PlatformPaths.getCachePath');
|
|
986
989
|
const baseName = getBaseName(downloadUrl);
|
|
987
|
-
const diskPath = `${cacheDir}/${baseName}`;
|
|
990
|
+
const diskPath = `${cacheDir}/auto-updater/${baseName}`;
|
|
988
991
|
return diskPath;
|
|
989
992
|
};
|
|
990
993
|
|
|
@@ -1025,6 +1028,8 @@ const getUpdateUrl = (repository, version) => {
|
|
|
1025
1028
|
};
|
|
1026
1029
|
|
|
1027
1030
|
const exec = async (path, args, options) => {
|
|
1031
|
+
// @ts-ignore
|
|
1032
|
+
await invoke('Exec.exec', path, args, options);
|
|
1028
1033
|
// TODO
|
|
1029
1034
|
return {
|
|
1030
1035
|
type: 0,
|
|
@@ -1065,17 +1070,27 @@ const isCached = async (url, cache) => {
|
|
|
1065
1070
|
return false;
|
|
1066
1071
|
};
|
|
1067
1072
|
|
|
1073
|
+
const isOnline = () => {
|
|
1074
|
+
return navigator.onLine;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1068
1077
|
const shouldUpdate = async (updateSetting, version) => {
|
|
1069
1078
|
if (updateSetting && updateSetting !== 'none') {
|
|
1070
1079
|
return true;
|
|
1071
1080
|
}
|
|
1072
|
-
promptMessage(version);
|
|
1073
|
-
const shouldUpdate = await confirmPrompt();
|
|
1081
|
+
const message = promptMessage(version);
|
|
1082
|
+
const shouldUpdate = await confirmPrompt(message);
|
|
1074
1083
|
return shouldUpdate;
|
|
1075
1084
|
};
|
|
1076
1085
|
|
|
1077
1086
|
const checkForUpdates = async (updateSetting, repository) => {
|
|
1078
1087
|
try {
|
|
1088
|
+
if (!isOnline()) {
|
|
1089
|
+
return {
|
|
1090
|
+
updated: false,
|
|
1091
|
+
error: undefined
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1079
1094
|
const bucketName = 'electron-updates';
|
|
1080
1095
|
const cacheName = 'electron-updates';
|
|
1081
1096
|
const info = await getLatestReleaseVersion(repository);
|