@tauri-apps/plugin-updater 2.11.0 → 2.13.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/README.md CHANGED
@@ -12,7 +12,7 @@ In-app updates for Tauri applications.
12
12
 
13
13
  ## Install
14
14
 
15
- _This plugin requires a Rust version of at least **1.77.2**_
15
+ _This plugin requires a Rust version of at least **1.90**_
16
16
 
17
17
  There are three general methods of installation that we can recommend.
18
18
 
package/dist-js/index.cjs CHANGED
@@ -5,7 +5,34 @@ var core = require('@tauri-apps/api/core');
5
5
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
6
  // SPDX-License-Identifier: Apache-2.0
7
7
  // SPDX-License-Identifier: MIT
8
+ /**
9
+ * In-app updates for Tauri applications: check the configured endpoints for a new release,
10
+ * download it and install it.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * An update announced by the update server, as returned by {@linkcode check}.
16
+ *
17
+ * It holds a resource on the Rust side, so call {@linkcode Update.close} when you are done with it
18
+ * without installing it.
19
+ *
20
+ * @since 2.0.0
21
+ */
8
22
  class Update extends core.Resource {
23
+ /**
24
+ * Creates an update from the metadata returned by the backend.
25
+ * You should not need to call this yourself, use {@linkcode check} instead.
26
+ *
27
+ * @param metadata The update information returned by the backend, including the resource identifier of the update.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { check } from '@tauri-apps/plugin-updater';
32
+ * // the update instance is created for you by `check`
33
+ * const update = await check();
34
+ * ```
35
+ */
9
36
  constructor(metadata) {
10
37
  super(metadata.rid);
11
38
  this.available = true;
@@ -15,7 +42,29 @@ class Update extends core.Resource {
15
42
  this.body = metadata.body;
16
43
  this.rawJson = metadata.rawJson;
17
44
  }
18
- /** Download the updater package. Call {@linkcode install} later to install it */
45
+ /**
46
+ * Downloads the updater package. Call {@linkcode install} later to install it.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { check } from '@tauri-apps/plugin-updater';
51
+ *
52
+ * const update = await check();
53
+ * if (update) {
54
+ * let downloaded = 0;
55
+ * await update.download((event) => {
56
+ * if (event.event === 'Progress') {
57
+ * downloaded += event.data.chunkLength;
58
+ * console.log(`downloaded ${downloaded} bytes`);
59
+ * }
60
+ * });
61
+ * await update.install();
62
+ * }
63
+ * ```
64
+ *
65
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
66
+ * @param options The headers and the timeout to use for the download request.
67
+ */
19
68
  async download(onEvent, options) {
20
69
  convertToRustHeaders(options);
21
70
  const channel = new core.Channel();
@@ -36,6 +85,19 @@ class Update extends core.Resource {
36
85
  *
37
86
  * - **Windows:** This function exits the app after launching the updater installer successfully
38
87
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { check } from '@tauri-apps/plugin-updater';
92
+ *
93
+ * const update = await check();
94
+ * if (update) {
95
+ * await update.download();
96
+ * await update.install();
97
+ * }
98
+ * ```
99
+ *
100
+ * @param options Options for the installation, such as whether the Windows installer should restart the app afterwards.
39
101
  */
40
102
  async install(options) {
41
103
  if (!this.downloadedBytes) {
@@ -56,6 +118,21 @@ class Update extends core.Resource {
56
118
  *
57
119
  * - **Windows:** This function exits the app after launching the updater installer successfully
58
120
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { check } from '@tauri-apps/plugin-updater';
125
+ *
126
+ * const update = await check();
127
+ * if (update) {
128
+ * await update.downloadAndInstall((event) => {
129
+ * console.log(event.event);
130
+ * });
131
+ * }
132
+ * ```
133
+ *
134
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
135
+ * @param options The headers and the timeout to use for the download request, and the installation options.
59
136
  */
60
137
  async downloadAndInstall(onEvent, options) {
61
138
  convertToRustHeaders(options);
@@ -69,12 +146,44 @@ class Update extends core.Resource {
69
146
  ...options
70
147
  });
71
148
  }
149
+ /**
150
+ * Releases the update resource and the downloaded bytes held by the backend.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * import { check } from '@tauri-apps/plugin-updater';
155
+ *
156
+ * const update = await check();
157
+ * if (update) {
158
+ * await update.close();
159
+ * }
160
+ * ```
161
+ */
72
162
  async close() {
73
163
  await this.downloadedBytes?.close();
74
164
  await super.close();
75
165
  }
76
166
  }
77
- /** Check for updates, resolves to `null` if no updates are available */
167
+ /**
168
+ * Checks the configured endpoints for an available update.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * import { check } from '@tauri-apps/plugin-updater';
173
+ *
174
+ * const update = await check();
175
+ * if (update) {
176
+ * console.log(`update ${update.version} is available`);
177
+ * await update.downloadAndInstall();
178
+ * }
179
+ * ```
180
+ *
181
+ * @param options The headers, timeout, proxy and target to use for the update check request.
182
+ *
183
+ * @returns A promise resolving to the available {@linkcode Update}, or `null` when no update is available.
184
+ *
185
+ * @since 2.0.0
186
+ */
78
187
  async function check(options) {
79
188
  convertToRustHeaders(options);
80
189
  const metadata = await core.invoke('plugin:updater|check', {
@@ -1,8 +1,14 @@
1
+ /**
2
+ * In-app updates for Tauri applications: check the configured endpoints for a new release,
3
+ * download it and install it.
4
+ *
5
+ * @module
6
+ */
1
7
  import { Resource } from '@tauri-apps/api/core';
2
8
  /** Options used when checking for updates */
3
9
  interface CheckOptions {
4
10
  /**
5
- * Request headers
11
+ * The headers to send along with the update check request.
6
12
  */
7
13
  headers?: HeadersInit;
8
14
  /**
@@ -17,15 +23,11 @@ interface CheckOptions {
17
23
  * Target identifier for the running application. This is sent to the backend.
18
24
  */
19
25
  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;
24
26
  }
25
27
  /** Options used when downloading an update */
26
28
  interface DownloadOptions {
27
29
  /**
28
- * Request headers
30
+ * The headers to send along with the update download request.
29
31
  */
30
32
  headers?: HeadersInit;
31
33
  /**
@@ -62,17 +64,80 @@ type DownloadEvent = {
62
64
  } | {
63
65
  event: 'Finished';
64
66
  };
67
+ /**
68
+ * An update announced by the update server, as returned by {@linkcode check}.
69
+ *
70
+ * It holds a resource on the Rust side, so call {@linkcode Update.close} when you are done with it
71
+ * without installing it.
72
+ *
73
+ * @since 2.0.0
74
+ */
65
75
  declare class Update extends Resource {
66
- /** @deprecated This is always true, check if the return value is `null` instead when using {@linkcode check} */
76
+ /**
77
+ * Whether an update is available.
78
+ *
79
+ * @deprecated This is always true, check if the return value is `null` instead when using {@linkcode check}
80
+ */
67
81
  available: boolean;
82
+ /**
83
+ * The version of the application that is currently running.
84
+ */
68
85
  currentVersion: string;
86
+ /**
87
+ * The version announced by the update server.
88
+ */
69
89
  version: string;
90
+ /**
91
+ * The publish date of the update as an RFC 3339 string, when the server provided one.
92
+ */
70
93
  date?: string;
94
+ /**
95
+ * The release notes of the update, when the server provided them.
96
+ */
71
97
  body?: string;
98
+ /**
99
+ * The raw update manifest returned by the server, useful when it contains
100
+ * additional fields that the updater itself does not handle.
101
+ */
72
102
  rawJson: Record<string, unknown>;
73
103
  private downloadedBytes?;
104
+ /**
105
+ * Creates an update from the metadata returned by the backend.
106
+ * You should not need to call this yourself, use {@linkcode check} instead.
107
+ *
108
+ * @param metadata The update information returned by the backend, including the resource identifier of the update.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * import { check } from '@tauri-apps/plugin-updater';
113
+ * // the update instance is created for you by `check`
114
+ * const update = await check();
115
+ * ```
116
+ */
74
117
  constructor(metadata: UpdateMetadata);
75
- /** Download the updater package. Call {@linkcode install} later to install it */
118
+ /**
119
+ * Downloads the updater package. Call {@linkcode install} later to install it.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * import { check } from '@tauri-apps/plugin-updater';
124
+ *
125
+ * const update = await check();
126
+ * if (update) {
127
+ * let downloaded = 0;
128
+ * await update.download((event) => {
129
+ * if (event.event === 'Progress') {
130
+ * downloaded += event.data.chunkLength;
131
+ * console.log(`downloaded ${downloaded} bytes`);
132
+ * }
133
+ * });
134
+ * await update.install();
135
+ * }
136
+ * ```
137
+ *
138
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
139
+ * @param options The headers and the timeout to use for the download request.
140
+ */
76
141
  download(onEvent?: (progress: DownloadEvent) => void, options?: DownloadOptions): Promise<void>;
77
142
  /**
78
143
  * Install downloaded updater package. Must be called after {@linkcode download}.
@@ -81,6 +146,19 @@ declare class Update extends Resource {
81
146
  *
82
147
  * - **Windows:** This function exits the app after launching the updater installer successfully
83
148
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * import { check } from '@tauri-apps/plugin-updater';
153
+ *
154
+ * const update = await check();
155
+ * if (update) {
156
+ * await update.download();
157
+ * await update.install();
158
+ * }
159
+ * ```
160
+ *
161
+ * @param options Options for the installation, such as whether the Windows installer should restart the app afterwards.
84
162
  */
85
163
  install(options?: InstallOptions): Promise<void>;
86
164
  /**
@@ -90,11 +168,58 @@ declare class Update extends Resource {
90
168
  *
91
169
  * - **Windows:** This function exits the app after launching the updater installer successfully
92
170
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * import { check } from '@tauri-apps/plugin-updater';
175
+ *
176
+ * const update = await check();
177
+ * if (update) {
178
+ * await update.downloadAndInstall((event) => {
179
+ * console.log(event.event);
180
+ * });
181
+ * }
182
+ * ```
183
+ *
184
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
185
+ * @param options The headers and the timeout to use for the download request, and the installation options.
93
186
  */
94
187
  downloadAndInstall(onEvent?: (progress: DownloadEvent) => void, options?: DownloadOptions & InstallOptions): Promise<void>;
188
+ /**
189
+ * Releases the update resource and the downloaded bytes held by the backend.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * import { check } from '@tauri-apps/plugin-updater';
194
+ *
195
+ * const update = await check();
196
+ * if (update) {
197
+ * await update.close();
198
+ * }
199
+ * ```
200
+ */
95
201
  close(): Promise<void>;
96
202
  }
97
- /** Check for updates, resolves to `null` if no updates are available */
203
+ /**
204
+ * Checks the configured endpoints for an available update.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * import { check } from '@tauri-apps/plugin-updater';
209
+ *
210
+ * const update = await check();
211
+ * if (update) {
212
+ * console.log(`update ${update.version} is available`);
213
+ * await update.downloadAndInstall();
214
+ * }
215
+ * ```
216
+ *
217
+ * @param options The headers, timeout, proxy and target to use for the update check request.
218
+ *
219
+ * @returns A promise resolving to the available {@linkcode Update}, or `null` when no update is available.
220
+ *
221
+ * @since 2.0.0
222
+ */
98
223
  declare function check(options?: CheckOptions): Promise<Update | null>;
99
224
  export type { CheckOptions, DownloadOptions, DownloadEvent };
100
225
  export { check, Update };
package/dist-js/index.js CHANGED
@@ -3,7 +3,34 @@ import { Resource, Channel, invoke } from '@tauri-apps/api/core';
3
3
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  // SPDX-License-Identifier: MIT
6
+ /**
7
+ * In-app updates for Tauri applications: check the configured endpoints for a new release,
8
+ * download it and install it.
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * An update announced by the update server, as returned by {@linkcode check}.
14
+ *
15
+ * It holds a resource on the Rust side, so call {@linkcode Update.close} when you are done with it
16
+ * without installing it.
17
+ *
18
+ * @since 2.0.0
19
+ */
6
20
  class Update extends Resource {
21
+ /**
22
+ * Creates an update from the metadata returned by the backend.
23
+ * You should not need to call this yourself, use {@linkcode check} instead.
24
+ *
25
+ * @param metadata The update information returned by the backend, including the resource identifier of the update.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { check } from '@tauri-apps/plugin-updater';
30
+ * // the update instance is created for you by `check`
31
+ * const update = await check();
32
+ * ```
33
+ */
7
34
  constructor(metadata) {
8
35
  super(metadata.rid);
9
36
  this.available = true;
@@ -13,7 +40,29 @@ class Update extends Resource {
13
40
  this.body = metadata.body;
14
41
  this.rawJson = metadata.rawJson;
15
42
  }
16
- /** Download the updater package. Call {@linkcode install} later to install it */
43
+ /**
44
+ * Downloads the updater package. Call {@linkcode install} later to install it.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { check } from '@tauri-apps/plugin-updater';
49
+ *
50
+ * const update = await check();
51
+ * if (update) {
52
+ * let downloaded = 0;
53
+ * await update.download((event) => {
54
+ * if (event.event === 'Progress') {
55
+ * downloaded += event.data.chunkLength;
56
+ * console.log(`downloaded ${downloaded} bytes`);
57
+ * }
58
+ * });
59
+ * await update.install();
60
+ * }
61
+ * ```
62
+ *
63
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
64
+ * @param options The headers and the timeout to use for the download request.
65
+ */
17
66
  async download(onEvent, options) {
18
67
  convertToRustHeaders(options);
19
68
  const channel = new Channel();
@@ -34,6 +83,19 @@ class Update extends Resource {
34
83
  *
35
84
  * - **Windows:** This function exits the app after launching the updater installer successfully
36
85
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { check } from '@tauri-apps/plugin-updater';
90
+ *
91
+ * const update = await check();
92
+ * if (update) {
93
+ * await update.download();
94
+ * await update.install();
95
+ * }
96
+ * ```
97
+ *
98
+ * @param options Options for the installation, such as whether the Windows installer should restart the app afterwards.
37
99
  */
38
100
  async install(options) {
39
101
  if (!this.downloadedBytes) {
@@ -54,6 +116,21 @@ class Update extends Resource {
54
116
  *
55
117
  * - **Windows:** This function exits the app after launching the updater installer successfully
56
118
  * - **macOS / Linux:** You need to relaunch the app to run the newly install version
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { check } from '@tauri-apps/plugin-updater';
123
+ *
124
+ * const update = await check();
125
+ * if (update) {
126
+ * await update.downloadAndInstall((event) => {
127
+ * console.log(event.event);
128
+ * });
129
+ * }
130
+ * ```
131
+ *
132
+ * @param onEvent Callback invoked with a `Started` event when the first chunk is received, a `Progress` event for every downloaded chunk and a `Finished` event when the download completes.
133
+ * @param options The headers and the timeout to use for the download request, and the installation options.
57
134
  */
58
135
  async downloadAndInstall(onEvent, options) {
59
136
  convertToRustHeaders(options);
@@ -67,12 +144,44 @@ class Update extends Resource {
67
144
  ...options
68
145
  });
69
146
  }
147
+ /**
148
+ * Releases the update resource and the downloaded bytes held by the backend.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * import { check } from '@tauri-apps/plugin-updater';
153
+ *
154
+ * const update = await check();
155
+ * if (update) {
156
+ * await update.close();
157
+ * }
158
+ * ```
159
+ */
70
160
  async close() {
71
161
  await this.downloadedBytes?.close();
72
162
  await super.close();
73
163
  }
74
164
  }
75
- /** Check for updates, resolves to `null` if no updates are available */
165
+ /**
166
+ * Checks the configured endpoints for an available update.
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * import { check } from '@tauri-apps/plugin-updater';
171
+ *
172
+ * const update = await check();
173
+ * if (update) {
174
+ * console.log(`update ${update.version} is available`);
175
+ * await update.downloadAndInstall();
176
+ * }
177
+ * ```
178
+ *
179
+ * @param options The headers, timeout, proxy and target to use for the update check request.
180
+ *
181
+ * @returns A promise resolving to the available {@linkcode Update}, or `null` when no update is available.
182
+ *
183
+ * @since 2.0.0
184
+ */
76
185
  async function check(options) {
77
186
  convertToRustHeaders(options);
78
187
  const metadata = await invoke('plugin:updater|check', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-updater",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -24,6 +24,6 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@tauri-apps/api": "^2.11.0"
27
+ "@tauri-apps/api": "^2.12.0"
28
28
  }
29
29
  }