@tauri-apps/plugin-updater 2.7.0 → 2.8.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-js/index.cjs +11 -3
- package/dist-js/index.d.ts +4 -0
- package/dist-js/index.js +11 -3
- package/package.json +1 -1
package/dist-js/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ class Update extends core.Resource {
|
|
|
17
17
|
}
|
|
18
18
|
/** Download the updater package */
|
|
19
19
|
async download(onEvent, options) {
|
|
20
|
+
convertToRustHeaders(options);
|
|
20
21
|
const channel = new core.Channel();
|
|
21
22
|
if (onEvent) {
|
|
22
23
|
channel.onmessage = onEvent;
|
|
@@ -42,6 +43,7 @@ class Update extends core.Resource {
|
|
|
42
43
|
}
|
|
43
44
|
/** Downloads the updater package and installs it */
|
|
44
45
|
async downloadAndInstall(onEvent, options) {
|
|
46
|
+
convertToRustHeaders(options);
|
|
45
47
|
const channel = new core.Channel();
|
|
46
48
|
if (onEvent) {
|
|
47
49
|
channel.onmessage = onEvent;
|
|
@@ -59,14 +61,20 @@ class Update extends core.Resource {
|
|
|
59
61
|
}
|
|
60
62
|
/** Check for updates, resolves to `null` if no updates are available */
|
|
61
63
|
async function check(options) {
|
|
62
|
-
|
|
63
|
-
options.headers = Array.from(new Headers(options.headers).entries());
|
|
64
|
-
}
|
|
64
|
+
convertToRustHeaders(options);
|
|
65
65
|
const metadata = await core.invoke('plugin:updater|check', {
|
|
66
66
|
...options
|
|
67
67
|
});
|
|
68
68
|
return metadata ? new Update(metadata) : null;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Converts the headers in options to be an {@linkcode Array<[string, string]>} which is what the Rust side expects
|
|
72
|
+
*/
|
|
73
|
+
function convertToRustHeaders(options) {
|
|
74
|
+
if (options?.headers) {
|
|
75
|
+
options.headers = Array.from(new Headers(options.headers).entries());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
70
78
|
|
|
71
79
|
exports.Update = Update;
|
|
72
80
|
exports.check = check;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ interface CheckOptions {
|
|
|
17
17
|
* Target identifier for the running application. This is sent to the backend.
|
|
18
18
|
*/
|
|
19
19
|
target?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Allow downgrades to previous versions by not checking if the current version is greater than the available version.
|
|
22
|
+
*/
|
|
23
|
+
allowDowngrades?: boolean;
|
|
20
24
|
}
|
|
21
25
|
/** Options used when downloading an update */
|
|
22
26
|
interface DownloadOptions {
|
package/dist-js/index.js
CHANGED
|
@@ -15,6 +15,7 @@ class Update extends Resource {
|
|
|
15
15
|
}
|
|
16
16
|
/** Download the updater package */
|
|
17
17
|
async download(onEvent, options) {
|
|
18
|
+
convertToRustHeaders(options);
|
|
18
19
|
const channel = new Channel();
|
|
19
20
|
if (onEvent) {
|
|
20
21
|
channel.onmessage = onEvent;
|
|
@@ -40,6 +41,7 @@ class Update extends Resource {
|
|
|
40
41
|
}
|
|
41
42
|
/** Downloads the updater package and installs it */
|
|
42
43
|
async downloadAndInstall(onEvent, options) {
|
|
44
|
+
convertToRustHeaders(options);
|
|
43
45
|
const channel = new Channel();
|
|
44
46
|
if (onEvent) {
|
|
45
47
|
channel.onmessage = onEvent;
|
|
@@ -57,13 +59,19 @@ class Update extends Resource {
|
|
|
57
59
|
}
|
|
58
60
|
/** Check for updates, resolves to `null` if no updates are available */
|
|
59
61
|
async function check(options) {
|
|
60
|
-
|
|
61
|
-
options.headers = Array.from(new Headers(options.headers).entries());
|
|
62
|
-
}
|
|
62
|
+
convertToRustHeaders(options);
|
|
63
63
|
const metadata = await invoke('plugin:updater|check', {
|
|
64
64
|
...options
|
|
65
65
|
});
|
|
66
66
|
return metadata ? new Update(metadata) : null;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Converts the headers in options to be an {@linkcode Array<[string, string]>} which is what the Rust side expects
|
|
70
|
+
*/
|
|
71
|
+
function convertToRustHeaders(options) {
|
|
72
|
+
if (options?.headers) {
|
|
73
|
+
options.headers = Array.from(new Headers(options.headers).entries());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
68
76
|
|
|
69
77
|
export { Update, check };
|