@tauri-apps/plugin-updater 2.0.0-alpha.0 → 2.0.0-alpha.1

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
@@ -1,4 +1,4 @@
1
- # Updater
1
+ ![plugin-updater](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/updater/banner.png)
2
2
 
3
3
  In-app updates for Tauri applications.
4
4
 
@@ -1,8 +1,9 @@
1
+ /** Options used to check for updates */
1
2
  interface CheckOptions {
2
3
  /**
3
4
  * Request headers
4
5
  */
5
- headers?: Record<string, unknown>;
6
+ headers?: HeadersInit;
6
7
  /**
7
8
  * Timeout in seconds
8
9
  */
@@ -12,13 +13,14 @@ interface CheckOptions {
12
13
  */
13
14
  target?: string;
14
15
  }
15
- interface UpdateResponse {
16
+ interface UpdateMetadata {
16
17
  available: boolean;
17
18
  currentVersion: string;
18
- latestVersion: string;
19
+ version: string;
19
20
  date?: string;
20
21
  body?: string;
21
22
  }
23
+ /** Updater download event */
22
24
  type DownloadEvent = {
23
25
  event: "Started";
24
26
  data: {
@@ -33,10 +35,15 @@ type DownloadEvent = {
33
35
  event: "Finished";
34
36
  };
35
37
  declare class Update {
36
- response: UpdateResponse;
37
- constructor(response: UpdateResponse);
38
+ currentVersion: string;
39
+ version: string;
40
+ date?: string;
41
+ body?: string;
42
+ constructor(metadata: UpdateMetadata);
43
+ /** Downloads the updater package and installs it */
38
44
  downloadAndInstall(onEvent?: (progress: DownloadEvent) => void): Promise<void>;
39
45
  }
40
- declare function check(options?: CheckOptions): Promise<Update>;
41
- export type { CheckOptions, UpdateResponse, DownloadEvent };
46
+ /** Check for updates, resolves to `null` if no updates are available */
47
+ declare function check(options?: CheckOptions): Promise<Update | null>;
48
+ export type { CheckOptions, DownloadEvent };
42
49
  export { check, Update };
@@ -1,14 +1,20 @@
1
- var f$1=Object.defineProperty;var g=(a,b)=>{for(var c in b)f$1(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$1=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
1
+ var f$1=Object.defineProperty;var g=(a,b)=>{for(var c in b)f$1(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$1=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
2
2
 
3
- var f={};g(f,{Channel:()=>a,PluginListener:()=>c,addPluginListener:()=>v,convertFileSrc:()=>m,invoke:()=>u,transformCallback:()=>o});function h(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function o(t,e=!1){let n=h(),r=`_${n}`;return Object.defineProperty(window,r,{value:i=>(e&&Reflect.deleteProperty(window,r),t?.(i)),writable:!1,configurable:!0}),n}var s,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i(this,s,()=>{});this.id=o(e=>{h$1(this,s).call(this,e);});}set onmessage(e){j(this,s,e);}get onmessage(){return h$1(this,s)}toJSON(){return `__CHANNEL__:${this.id}`}};s=new WeakMap;var c=class{constructor(e,n,r){this.plugin=e,this.event=n,this.channelId=r;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function v(t,e,n){let r=new a;return r.onmessage=n,u(`plugin:${t}|register_listener`,{event:e,handler:r}).then(()=>new c(t,e,r.id))}async function u(t,e={}){return new Promise((n,r)=>{let i=o(d=>{n(d),Reflect.deleteProperty(window,`_${g}`);},!0),g=o(d=>{r(d),Reflect.deleteProperty(window,`_${i}`);},!0);window.__TAURI_IPC__({cmd:t,callback:i,error:g,...e});})}function m(t,e="asset"){let n=encodeURIComponent(t);return navigator.userAgent.includes("Windows")?`https://${e}.localhost/${n}`:`${e}://localhost/${n}`}
3
+ var h={};g(h,{Channel:()=>o,PluginListener:()=>a,addPluginListener:()=>m,convertFileSrc:()=>y,invoke:()=>u,transformCallback:()=>s});function f(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(n,e=!1){let t=f(),r=`_${t}`;return Object.defineProperty(window,r,{value:c=>(e&&Reflect.deleteProperty(window,r),n?.(c)),writable:!1,configurable:!0}),t}var i,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,i,()=>{});this.id=s(e=>{h$1(this,i).call(this,e);});}set onmessage(e){j(this,i,e);}get onmessage(){return h$1(this,i)}toJSON(){return `__CHANNEL__:${this.id}`}};i=new WeakMap;var a=class{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function m(n,e,t){let r=new o;return r.onmessage=t,u(`plugin:${n}|register_listener`,{event:e,handler:r}).then(()=>new a(n,e,r.id))}async function u(n,e={},t){return new Promise((r,c)=>{let g=s(d=>{r(d),Reflect.deleteProperty(window,`_${_}`);},!0),_=s(d=>{c(d),Reflect.deleteProperty(window,`_${g}`);},!0);window.__TAURI_IPC__({cmd:n,callback:g,error:_,payload:e,options:t});})}function y(n,e="asset"){return window.__TAURI__.convertFileSrc(n,e)}
4
4
 
5
5
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ // SPDX-License-Identifier: MIT
6
8
  class Update {
7
- constructor(response) {
8
- this.response = response;
9
+ constructor(metadata) {
10
+ this.currentVersion = metadata.currentVersion;
11
+ this.version = metadata.version;
12
+ this.date = metadata.date;
13
+ this.body = metadata.body;
9
14
  }
15
+ /** Downloads the updater package and installs it */
10
16
  async downloadAndInstall(onEvent) {
11
- const channel = new a();
17
+ const channel = new o();
12
18
  if (onEvent != null) {
13
19
  channel.onmessage = onEvent;
14
20
  }
@@ -17,8 +23,12 @@ class Update {
17
23
  });
18
24
  }
19
25
  }
26
+ /** Check for updates, resolves to `null` if no updates are available */
20
27
  async function check(options) {
21
- return u("plugin:updater|check", { ...options }).then((response) => new Update(response));
28
+ if (options === null || options === void 0 ? void 0 : options.headers) {
29
+ options.headers = Array.from(new Headers(options.headers).entries());
30
+ }
31
+ return u("plugin:updater|check", { ...options }).then((meta) => (meta.available ? new Update(meta) : null));
22
32
  }
23
33
 
24
34
  export { Update, check };
package/dist-js/index.mjs CHANGED
@@ -1,10 +1,16 @@
1
1
  import { Channel, invoke } from '@tauri-apps/api/tauri';
2
2
 
3
3
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ // SPDX-License-Identifier: MIT
4
6
  class Update {
5
- constructor(response) {
6
- this.response = response;
7
+ constructor(metadata) {
8
+ this.currentVersion = metadata.currentVersion;
9
+ this.version = metadata.version;
10
+ this.date = metadata.date;
11
+ this.body = metadata.body;
7
12
  }
13
+ /** Downloads the updater package and installs it */
8
14
  async downloadAndInstall(onEvent) {
9
15
  const channel = new Channel();
10
16
  if (onEvent != null) {
@@ -15,8 +21,12 @@ class Update {
15
21
  });
16
22
  }
17
23
  }
24
+ /** Check for updates, resolves to `null` if no updates are available */
18
25
  async function check(options) {
19
- return invoke("plugin:updater|check", { ...options }).then((response) => new Update(response));
26
+ if (options === null || options === void 0 ? void 0 : options.headers) {
27
+ options.headers = Array.from(new Headers(options.headers).entries());
28
+ }
29
+ return invoke("plugin:updater|check", { ...options }).then((meta) => (meta.available ? new Update(meta) : null));
20
30
  }
21
31
 
22
32
  export { Update, check };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-updater",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "license": "MIT or APACHE-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -24,7 +24,7 @@
24
24
  "tslib": "^2.5.0"
25
25
  },
26
26
  "dependencies": {
27
- "@tauri-apps/api": "2.0.0-alpha.4"
27
+ "@tauri-apps/api": "2.0.0-alpha.6"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "rollup -c"