@tutti-os/desktop-update-admission 0.0.266
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/LICENSE +201 -0
- package/README.md +112 -0
- package/dist/chunk-GONYAEKF.js +139 -0
- package/dist/chunk-GONYAEKF.js.map +1 -0
- package/dist/chunk-LV67FBCG.js +112 -0
- package/dist/chunk-LV67FBCG.js.map +1 -0
- package/dist/chunk-TRALK3GT.js +33 -0
- package/dist/chunk-TRALK3GT.js.map +1 -0
- package/dist/chunk-X4U7GODT.js +134 -0
- package/dist/chunk-X4U7GODT.js.map +1 -0
- package/dist/chunk-ZQTIYDGZ.js +603 -0
- package/dist/chunk-ZQTIYDGZ.js.map +1 -0
- package/dist/contracts/index.d.ts +97 -0
- package/dist/contracts/index.js +15 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/development/index.d.ts +133 -0
- package/dist/development/index.js +289 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/mock-server-cli.d.ts +1 -0
- package/dist/development/mock-server-cli.js +67 -0
- package/dist/development/mock-server-cli.js.map +1 -0
- package/dist/electron-main/index.d.ts +38 -0
- package/dist/electron-main/index.js +498 -0
- package/dist/electron-main/index.js.map +1 -0
- package/dist/i18n/index.d.ts +64 -0
- package/dist/i18n/index.js +74 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/mandatory-updater/index.d.ts +23 -0
- package/dist/mandatory-updater/index.js +10 -0
- package/dist/mandatory-updater/index.js.map +1 -0
- package/dist/preload/index.d.ts +9 -0
- package/dist/preload/index.js +30 -0
- package/dist/preload/index.js.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +116 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// src/development/updaterDriver.ts
|
|
2
|
+
var DevelopmentInstallSuppressedError = class extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(
|
|
5
|
+
"development update simulation does not install or restart the application"
|
|
6
|
+
);
|
|
7
|
+
this.name = "DevelopmentInstallSuppressedError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var DevelopmentInstallError = class extends Error {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("development update installation failed");
|
|
13
|
+
this.name = "DevelopmentInstallError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function completeDevelopmentUpdateInstallation(scenario) {
|
|
17
|
+
if (scenario.updater.check === "available" || scenario.updater.check === "downloaded" || scenario.updater.check === "targetBelowMinimum") {
|
|
18
|
+
if (scenario.updater.install === "error") {
|
|
19
|
+
throw new DevelopmentInstallError();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
throw new DevelopmentInstallSuppressedError();
|
|
23
|
+
}
|
|
24
|
+
function createDevelopmentAppUpdateDriver(scenario) {
|
|
25
|
+
const updater = scenario.updater;
|
|
26
|
+
const checkingListeners = /* @__PURE__ */ new Set();
|
|
27
|
+
const progressListeners = /* @__PURE__ */ new Set();
|
|
28
|
+
const errorListeners = /* @__PURE__ */ new Set();
|
|
29
|
+
const availableListeners = /* @__PURE__ */ new Set();
|
|
30
|
+
const downloadedListeners = /* @__PURE__ */ new Set();
|
|
31
|
+
const notAvailableListeners = /* @__PURE__ */ new Set();
|
|
32
|
+
const latestVersion = updater.check === "available" || updater.check === "downloaded" || updater.check === "targetBelowMinimum" ? updater.latestVersion : scenario.currentVersion;
|
|
33
|
+
const updateInfo = () => ({
|
|
34
|
+
downloadedFile: "development-update-simulation",
|
|
35
|
+
files: [],
|
|
36
|
+
path: "",
|
|
37
|
+
releaseDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38
|
+
releaseName: latestVersion,
|
|
39
|
+
sha512: "",
|
|
40
|
+
version: latestVersion
|
|
41
|
+
});
|
|
42
|
+
const emitError = (message) => {
|
|
43
|
+
const error = new Error(message);
|
|
44
|
+
for (const listener of errorListeners) {
|
|
45
|
+
listener(error);
|
|
46
|
+
}
|
|
47
|
+
return error;
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
async checkForUpdates() {
|
|
51
|
+
for (const listener of checkingListeners) {
|
|
52
|
+
listener();
|
|
53
|
+
}
|
|
54
|
+
if (updater.check === "error") {
|
|
55
|
+
throw emitError("Development update check failed");
|
|
56
|
+
}
|
|
57
|
+
const info = updateInfo();
|
|
58
|
+
if (updater.check === "unavailable") {
|
|
59
|
+
for (const listener of notAvailableListeners) {
|
|
60
|
+
listener(info);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
for (const listener of availableListeners) {
|
|
65
|
+
listener(info);
|
|
66
|
+
}
|
|
67
|
+
if (updater.check === "downloaded") {
|
|
68
|
+
for (const listener of downloadedListeners) {
|
|
69
|
+
listener(info);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
configure() {
|
|
74
|
+
},
|
|
75
|
+
async downloadUpdate() {
|
|
76
|
+
if (!("download" in updater)) {
|
|
77
|
+
throw emitError("Development update is unavailable");
|
|
78
|
+
}
|
|
79
|
+
if (updater.download === "error") {
|
|
80
|
+
throw emitError("Development update download failed");
|
|
81
|
+
}
|
|
82
|
+
const info = updateInfo();
|
|
83
|
+
for (const listener of progressListeners) {
|
|
84
|
+
listener({
|
|
85
|
+
bytesPerSecond: 100,
|
|
86
|
+
delta: 100,
|
|
87
|
+
percent: 100,
|
|
88
|
+
total: 100,
|
|
89
|
+
transferred: 100
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const listener of downloadedListeners) {
|
|
93
|
+
listener(info);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
onCheckingForUpdate(listener) {
|
|
97
|
+
checkingListeners.add(listener);
|
|
98
|
+
return () => checkingListeners.delete(listener);
|
|
99
|
+
},
|
|
100
|
+
onDownloadProgress(listener) {
|
|
101
|
+
progressListeners.add(listener);
|
|
102
|
+
return () => progressListeners.delete(listener);
|
|
103
|
+
},
|
|
104
|
+
onError(listener) {
|
|
105
|
+
errorListeners.add(listener);
|
|
106
|
+
return () => errorListeners.delete(listener);
|
|
107
|
+
},
|
|
108
|
+
onUpdateAvailable(listener) {
|
|
109
|
+
availableListeners.add(listener);
|
|
110
|
+
return () => availableListeners.delete(listener);
|
|
111
|
+
},
|
|
112
|
+
onUpdateDownloaded(listener) {
|
|
113
|
+
downloadedListeners.add(listener);
|
|
114
|
+
return () => downloadedListeners.delete(listener);
|
|
115
|
+
},
|
|
116
|
+
onUpdateNotAvailable(listener) {
|
|
117
|
+
notAvailableListeners.add(listener);
|
|
118
|
+
return () => notAvailableListeners.delete(listener);
|
|
119
|
+
},
|
|
120
|
+
quitAndInstall() {
|
|
121
|
+
completeDevelopmentUpdateInstallation(scenario);
|
|
122
|
+
},
|
|
123
|
+
setFeedUrl() {
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
DevelopmentInstallSuppressedError,
|
|
130
|
+
DevelopmentInstallError,
|
|
131
|
+
completeDevelopmentUpdateInstallation,
|
|
132
|
+
createDevelopmentAppUpdateDriver
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=chunk-X4U7GODT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/development/updaterDriver.ts"],"sourcesContent":["import type { DesktopUpdateDevelopmentScenario } from \"./scenario.ts\";\n\ntype DriverDisposer = () => void;\n\nexport interface DevelopmentUpdateInfo {\n downloadedFile: string;\n files: never[];\n path: string;\n releaseDate: string;\n releaseName: string;\n sha512: string;\n version: string;\n}\n\nexport interface DevelopmentUpdateProgress {\n bytesPerSecond: number;\n delta: number;\n percent: number;\n total: number;\n transferred: number;\n}\n\nexport interface DevelopmentAppUpdateDriver {\n checkForUpdates(): Promise<void>;\n configure(...args: unknown[]): void;\n downloadUpdate(): Promise<void>;\n onCheckingForUpdate(listener: () => void): DriverDisposer;\n onDownloadProgress(\n listener: (progress: DevelopmentUpdateProgress) => void\n ): DriverDisposer;\n onError(listener: (error: Error) => void): DriverDisposer;\n onUpdateAvailable(\n listener: (info: DevelopmentUpdateInfo) => void\n ): DriverDisposer;\n onUpdateDownloaded(\n listener: (info: DevelopmentUpdateInfo) => void\n ): DriverDisposer;\n onUpdateNotAvailable(\n listener: (info: DevelopmentUpdateInfo) => void\n ): DriverDisposer;\n quitAndInstall(): void;\n setFeedUrl(_url: string): void;\n}\n\nexport class DevelopmentInstallSuppressedError extends Error {\n public constructor() {\n super(\n \"development update simulation does not install or restart the application\"\n );\n this.name = \"DevelopmentInstallSuppressedError\";\n }\n}\n\nexport class DevelopmentInstallError extends Error {\n public constructor() {\n super(\"development update installation failed\");\n this.name = \"DevelopmentInstallError\";\n }\n}\n\nexport function completeDevelopmentUpdateInstallation(\n scenario: DesktopUpdateDevelopmentScenario\n): never {\n if (\n scenario.updater.check === \"available\" ||\n scenario.updater.check === \"downloaded\" ||\n scenario.updater.check === \"targetBelowMinimum\"\n ) {\n if (scenario.updater.install === \"error\") {\n throw new DevelopmentInstallError();\n }\n }\n throw new DevelopmentInstallSuppressedError();\n}\n\nexport function createDevelopmentAppUpdateDriver(\n scenario: DesktopUpdateDevelopmentScenario\n): DevelopmentAppUpdateDriver {\n const updater = scenario.updater;\n const checkingListeners = new Set<() => void>();\n const progressListeners = new Set<\n (progress: DevelopmentUpdateProgress) => void\n >();\n const errorListeners = new Set<(error: Error) => void>();\n const availableListeners = new Set<(info: DevelopmentUpdateInfo) => void>();\n const downloadedListeners = new Set<(info: DevelopmentUpdateInfo) => void>();\n const notAvailableListeners = new Set<\n (info: DevelopmentUpdateInfo) => void\n >();\n const latestVersion =\n updater.check === \"available\" ||\n updater.check === \"downloaded\" ||\n updater.check === \"targetBelowMinimum\"\n ? updater.latestVersion\n : scenario.currentVersion;\n const updateInfo = (): DevelopmentUpdateInfo => ({\n downloadedFile: \"development-update-simulation\",\n files: [],\n path: \"\",\n releaseDate: new Date().toISOString(),\n releaseName: latestVersion,\n sha512: \"\",\n version: latestVersion\n });\n const emitError = (message: string): Error => {\n const error = new Error(message);\n for (const listener of errorListeners) {\n listener(error);\n }\n return error;\n };\n\n return {\n async checkForUpdates() {\n for (const listener of checkingListeners) {\n listener();\n }\n if (updater.check === \"error\") {\n throw emitError(\"Development update check failed\");\n }\n const info = updateInfo();\n if (updater.check === \"unavailable\") {\n for (const listener of notAvailableListeners) {\n listener(info);\n }\n return;\n }\n for (const listener of availableListeners) {\n listener(info);\n }\n if (updater.check === \"downloaded\") {\n for (const listener of downloadedListeners) {\n listener(info);\n }\n }\n },\n configure() {},\n async downloadUpdate() {\n if (!(\"download\" in updater)) {\n throw emitError(\"Development update is unavailable\");\n }\n if (updater.download === \"error\") {\n throw emitError(\"Development update download failed\");\n }\n const info = updateInfo();\n for (const listener of progressListeners) {\n listener({\n bytesPerSecond: 100,\n delta: 100,\n percent: 100,\n total: 100,\n transferred: 100\n });\n }\n for (const listener of downloadedListeners) {\n listener(info);\n }\n },\n onCheckingForUpdate(listener) {\n checkingListeners.add(listener);\n return () => checkingListeners.delete(listener);\n },\n onDownloadProgress(listener) {\n progressListeners.add(listener);\n return () => progressListeners.delete(listener);\n },\n onError(listener) {\n errorListeners.add(listener);\n return () => errorListeners.delete(listener);\n },\n onUpdateAvailable(listener) {\n availableListeners.add(listener);\n return () => availableListeners.delete(listener);\n },\n onUpdateDownloaded(listener) {\n downloadedListeners.add(listener);\n return () => downloadedListeners.delete(listener);\n },\n onUpdateNotAvailable(listener) {\n notAvailableListeners.add(listener);\n return () => notAvailableListeners.delete(listener);\n },\n quitAndInstall() {\n completeDevelopmentUpdateInstallation(scenario);\n },\n setFeedUrl() {}\n };\n}\n"],"mappings":";AA4CO,IAAM,oCAAN,cAAgD,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