@tauri-apps/plugin-updater 2.0.0-alpha.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/LICENSE.spdx ADDED
@@ -0,0 +1,20 @@
1
+ SPDXVersion: SPDX-2.1
2
+ DataLicense: CC0-1.0
3
+ PackageName: tauri
4
+ DataFormat: SPDXRef-1
5
+ PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
6
+ PackageHomePage: https://tauri.app
7
+ PackageLicenseDeclared: Apache-2.0
8
+ PackageLicenseDeclared: MIT
9
+ PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
10
+ PackageSummary: <text>Tauri is a rust project that enables developers to make secure
11
+ and small desktop applications using a web frontend.
12
+ </text>
13
+ PackageComment: <text>The package includes the following libraries; see
14
+ Relationship information.
15
+ </text>
16
+ Created: 2019-05-20T09:00:00Z
17
+ PackageDownloadLocation: git://github.com/tauri-apps/tauri
18
+ PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
19
+ PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
20
+ Creator: Person: Daniel Thompson-Yvetot
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Updater
2
+
3
+ In-app updates for Tauri applications.
4
+
5
+ - Supported platforms: Windows, Linux and macOS.
6
+
7
+ ## Install
8
+
9
+ _This plugin requires a Rust version of at least **1.65**_
10
+
11
+ There are three general methods of installation that we can recommend.
12
+
13
+ 1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
14
+ 2. Pull sources directly from Github using git tags / revision hashes (most secure)
15
+ 3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
16
+
17
+ Install the Core plugin by adding the following to your `Cargo.toml` file:
18
+
19
+ `src-tauri/Cargo.toml`
20
+
21
+ ```toml
22
+ # you can add the dependencies on the `[dependencies]` section if you do not target mobile
23
+ [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
24
+ tauri-plugin-updater = "2.0.0-alpha"
25
+ # alternatively with Git:
26
+ tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
27
+ ```
28
+
29
+ You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
30
+
31
+ > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
32
+
33
+ ```sh
34
+ pnpm add @tauri-apps/plugin-updater
35
+ # or
36
+ npm add @tauri-apps/plugin-updater
37
+ # or
38
+ yarn add @tauri-apps/plugin-updater
39
+
40
+ # alternatively with Git:
41
+ pnpm add https://github.com/tauri-apps/tauri-plugin-updater#v2
42
+ # or
43
+ npm add https://github.com/tauri-apps/tauri-plugin-updater#v2
44
+ # or
45
+ yarn add https://github.com/tauri-apps/tauri-plugin-updater#v2
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ First you need to register the core plugin with Tauri:
51
+
52
+ `src-tauri/src/main.rs`
53
+
54
+ ```rust
55
+ fn main() {
56
+ tauri::Builder::default()
57
+ .setup(|app| {
58
+ #[cfg(desktop)]
59
+ app.handle().plugin(tauri_plugin_updater::Builder::new().build())?;
60
+ Ok(())
61
+ })
62
+ .run(tauri::generate_context!())
63
+ .expect("error while running tauri application");
64
+ }
65
+ ```
66
+
67
+ Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
68
+
69
+ ```javascript
70
+ import { check } from "@tauri-apps/plugin-updater";
71
+ import { relaunch } from "@tauri-apps/plugin-process";
72
+ const update = await check();
73
+ if (update.response.available) {
74
+ await update.downloadAndInstall();
75
+ await relaunch();
76
+ }
77
+ ```
78
+
79
+ ## Contributing
80
+
81
+ PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
82
+
83
+ ## License
84
+
85
+ Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
86
+
87
+ MIT or MIT/Apache 2.0 where applicable.
@@ -0,0 +1,42 @@
1
+ interface CheckOptions {
2
+ /**
3
+ * Request headers
4
+ */
5
+ headers?: Record<string, unknown>;
6
+ /**
7
+ * Timeout in seconds
8
+ */
9
+ timeout?: number;
10
+ /**
11
+ * Target identifier for the running application. This is sent to the backend.
12
+ */
13
+ target?: string;
14
+ }
15
+ interface UpdateResponse {
16
+ available: boolean;
17
+ currentVersion: string;
18
+ latestVersion: string;
19
+ date?: string;
20
+ body?: string;
21
+ }
22
+ type DownloadEvent = {
23
+ event: "Started";
24
+ data: {
25
+ contentLength?: number;
26
+ };
27
+ } | {
28
+ event: "Progress";
29
+ data: {
30
+ chunkLength: number;
31
+ };
32
+ } | {
33
+ event: "Finished";
34
+ };
35
+ declare class Update {
36
+ response: UpdateResponse;
37
+ constructor(response: UpdateResponse);
38
+ downloadAndInstall(onEvent?: (progress: DownloadEvent) => void): Promise<void>;
39
+ }
40
+ declare function check(options?: CheckOptions): Promise<Update>;
41
+ export type { CheckOptions, UpdateResponse, DownloadEvent };
42
+ export { check, Update };
@@ -0,0 +1,25 @@
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);
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}`}
4
+
5
+ // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
+ class Update {
7
+ constructor(response) {
8
+ this.response = response;
9
+ }
10
+ async downloadAndInstall(onEvent) {
11
+ const channel = new a();
12
+ if (onEvent != null) {
13
+ channel.onmessage = onEvent;
14
+ }
15
+ return u("plugin:updater|download_and_install", {
16
+ onEvent: channel,
17
+ });
18
+ }
19
+ }
20
+ async function check(options) {
21
+ return u("plugin:updater|check", { ...options }).then((response) => new Update(response));
22
+ }
23
+
24
+ export { Update, check };
25
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1,23 @@
1
+ import { Channel, invoke } from '@tauri-apps/api/tauri';
2
+
3
+ // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
4
+ class Update {
5
+ constructor(response) {
6
+ this.response = response;
7
+ }
8
+ async downloadAndInstall(onEvent) {
9
+ const channel = new Channel();
10
+ if (onEvent != null) {
11
+ channel.onmessage = onEvent;
12
+ }
13
+ return invoke("plugin:updater|download_and_install", {
14
+ onEvent: channel,
15
+ });
16
+ }
17
+ }
18
+ async function check(options) {
19
+ return invoke("plugin:updater|check", { ...options }).then((response) => new Update(response));
20
+ }
21
+
22
+ export { Update, check };
23
+ //# sourceMappingURL=index.mjs.map
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@tauri-apps/plugin-updater",
3
+ "version": "2.0.0-alpha.0",
4
+ "license": "MIT or APACHE-2.0",
5
+ "authors": [
6
+ "Tauri Programme within The Commons Conservancy"
7
+ ],
8
+ "type": "module",
9
+ "browser": "dist-js/index.min.js",
10
+ "module": "dist-js/index.mjs",
11
+ "types": "dist-js/index.d.ts",
12
+ "exports": {
13
+ "import": "./dist-js/index.mjs",
14
+ "types": "./dist-js/index.d.ts",
15
+ "browser": "./dist-js/index.min.js"
16
+ },
17
+ "files": [
18
+ "dist-js",
19
+ "!dist-js/**/*.map",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "devDependencies": {
24
+ "tslib": "^2.5.0"
25
+ },
26
+ "dependencies": {
27
+ "@tauri-apps/api": "2.0.0-alpha.4"
28
+ },
29
+ "scripts": {
30
+ "build": "rollup -c"
31
+ }
32
+ }