feat(updater): add `download` and `install` js binding
I think it's better to store downloaded bytes inside of Update instead of returning the bytes, that'll be a breaking change though
I'm using this to test it, sharing it for anyone who wants to test it
diff --git a/examples/api/package.json b/examples/api/package.json
index 3312494e..e3c6432f 100644
--- a/examples/api/package.json
+++ b/examples/api/package.json
@@ -23,7 +23,7 @@
"@tauri-apps/plugin-os": "2.0.0-beta.3",
"@tauri-apps/plugin-process": "2.0.0-beta.3",
"@tauri-apps/plugin-shell": "2.0.0-beta.4",
- "@tauri-apps/plugin-updater": "2.0.0-beta.3",
+ "@tauri-apps/plugin-updater": "file:../../plugins/updater",
"@zerodevx/svelte-json-view": "1.0.9"
},
"devDependencies": {
diff --git a/examples/api/src/views/Updater.svelte b/examples/api/src/views/Updater.svelte
index 819c65e0..7f3fc898 100644
--- a/examples/api/src/views/Updater.svelte
+++ b/examples/api/src/views/Updater.svelte
@@ -27,7 +27,7 @@
isInstalling = true;
downloadedSize = 0;
try {
- await newUpdate.downloadAndInstall((downloadProgress) => {
+ const bytes = await newUpdate.download((downloadProgress) => {
switch (downloadProgress.event) {
case "Started":
totalSize = downloadProgress.data.contentLength;
@@ -39,6 +39,7 @@
break;
}
});
+ await bytes.install()
onMessage("Installation complete, restarting...");
await new Promise((resolve) => setTimeout(resolve, 2000));
await relaunch();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 17cde4df..27eadec0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -109,8 +109,8 @@ importers:
specifier: 2.0.0-beta.4
version: 2.0.0-beta.4
'@tauri-apps/plugin-updater':
- specifier: 2.0.0-beta.3
- version: 2.0.0-beta.3
+ specifier: file:../../plugins/updater
+ version: link:../../plugins/updater
'@zerodevx/svelte-json-view':
specifier: 1.0.9
version: 1.0.9([email protected])
@@ -1026,9 +1026,6 @@ packages:
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-y9APB3ZLtkY4IM6syE+dn/R4XR2UTHBcAI/n9L5PgnvOjJAuuEzVYURn10G51nKnLw+sFbxO7LW4VW66Uoaa9g==}
- '@tauri-apps/[email protected]':
- resolution: {integrity: sha512-bD1ikPz80uK9YJKNYpYlA6StSp9lr0Ob1kGLG2XdmOgspv7SZLLNVzMORtKeqgepxwG99qdYGDDegT3Ll6+UlA==}
-
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-NJV/pdgJObDlDWi5+MTHZ2qyNvdL0dlHqQ72nzQYXWbW1LHMPXgCJYl0pLqL1XxxLtxtInYbtVCGVAcwhGxdkw==}
@@ -3517,10 +3514,6 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.0.0-beta.11
- '@tauri-apps/[email protected]':
- dependencies:
- '@tauri-apps/api': 2.0.0-beta.11
-
'@tauri-apps/[email protected]': {}
'@types/[email protected]': {}
I think it's better to store downloaded bytes inside of Update instead of returning the bytes, that'll be a breaking change though
Not sure what exactly you mean tbh but now's the time for breaking changes.
What I mean is instead of returning the bytes from Update::download, stores it inside Update and those bytes are always associated with that Update so that we don't need another resource, not sure if it's better though
Thank you