diff --git a/Cargo.lock b/Cargo.lock index a9719f1a..d0042cd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2052,9 +2052,9 @@ checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" [[package]] name = "ts-rs" version = "9.0.1" -source = "git+https://github.com/Aleph-Alpha/ts-rs.git?branch=cli#7c9643e16038dd82e8ae2faf7914cdda6941b0a2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c" dependencies = [ - "lazy_static", "thiserror", "ts-rs-macros", ] @@ -2062,7 +2062,8 @@ dependencies = [ [[package]] name = "ts-rs-macros" version = "9.0.1" -source = "git+https://github.com/Aleph-Alpha/ts-rs.git?branch=cli#7c9643e16038dd82e8ae2faf7914cdda6941b0a2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c88cc88fd23b5a04528f3a8436024f20010a16ec18eb23c164b1242f65860130" dependencies = [ "proc-macro2", "quote", diff --git a/src/lib-node/crates/velopack_nodeffi/Cargo.toml b/src/lib-node/crates/velopack_nodeffi/Cargo.toml index 42999147..5b414c2f 100644 --- a/src/lib-node/crates/velopack_nodeffi/Cargo.toml +++ b/src/lib-node/crates/velopack_nodeffi/Cargo.toml @@ -4,14 +4,16 @@ version = "0.1.0" license = "MIT" edition = "2021" exclude = ["index.node"] +publish = false [lib] crate-type = ["cdylib"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] neon = "1" serde_json = "1" -ts-rs = { git = "https://github.com/Aleph-Alpha/ts-rs.git", branch = "cli" } velopack = { path = "../../../lib-rust" } + +[build-dependencies] +ts-rs = "9" +velopack = { path = "../../../lib-rust" } \ No newline at end of file diff --git a/src/lib-node/crates/velopack_nodeffi/build.rs b/src/lib-node/crates/velopack_nodeffi/build.rs new file mode 100644 index 00000000..48ec7655 --- /dev/null +++ b/src/lib-node/crates/velopack_nodeffi/build.rs @@ -0,0 +1,10 @@ +use std::{env, path::Path}; +use ts_rs::TS; +use velopack::*; + +fn main() { + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let bindings_dir = Path::new(&manifest_dir).join("..").join("..").join("src").join("bindings"); + UpdateInfo::export_all_to(&bindings_dir).unwrap(); + UpdateOptions::export_all_to(&bindings_dir).unwrap(); +} \ No newline at end of file diff --git a/src/lib-node/crates/velopack_nodeffi/src/lib.rs b/src/lib-node/crates/velopack_nodeffi/src/lib.rs index 4a3556c9..da8440ea 100644 --- a/src/lib-node/crates/velopack_nodeffi/src/lib.rs +++ b/src/lib-node/crates/velopack_nodeffi/src/lib.rs @@ -4,18 +4,6 @@ use std::thread; use velopack::sources::*; use velopack::*; -#[derive(ts_rs::TS)] -#[ts(as = "T")] -pub struct Wrapper(T); - -#[derive(ts_rs::TS)] -#[ts(export, export_to = "../../../bindings/")] -#[allow(dead_code)] -struct TsBindings { - pub t1: UpdateInfo, - pub t2: UpdateOptions, -} - struct UpdateManagerWrapper { manager: UpdateManager, } @@ -32,7 +20,7 @@ fn js_new_update_manager(mut cx: FunctionContext) -> JsResult(&arg_options).or_else(|e| cx.throw_error(e.to_string()))?; options = Some(new_opt); } - + let source = AutoSource::new(&arg_source); let manager = UpdateManager::new(source, options).or_else(|e| cx.throw_error(e.to_string()))?; let wrapper = UpdateManagerWrapper { manager }; diff --git a/src/lib-node/package-lock.json b/src/lib-node/package-lock.json new file mode 100644 index 00000000..baebf351 --- /dev/null +++ b/src/lib-node/package-lock.json @@ -0,0 +1,170 @@ +{ + "name": "veloz", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "veloz", + "version": "0.1.0", + "license": "ISC", + "dependencies": { + "@neon-rs/load": "^0.1.73" + }, + "devDependencies": { + "@neon-rs/cli": "^0.1.73", + "@tsconfig/node20": "^20.1.4", + "@types/node": "^20.11.16", + "typescript": "^5.3.3" + } + }, + "node_modules/@cargo-messages/android-arm-eabi": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/android-arm-eabi/-/android-arm-eabi-0.1.72.tgz", + "integrity": "sha512-gGZxIM1mj+Y5x+ULND6ZCNr7f70OJi9wDlycSK8hGONy9wrChN6JAIHryddC5cqcwlYAoQ6IDcDFElnhAYbybA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@cargo-messages/darwin-arm64": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/darwin-arm64/-/darwin-arm64-0.1.72.tgz", + "integrity": "sha512-EAzN5MLaXPljZKZDO5qR+aBs44eSq2ZbEnS7AI/FziE3MzeXbrGOS3fLba5+7yWPFXJyZolXzePm8N1EBv8ovg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@cargo-messages/darwin-x64": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/darwin-x64/-/darwin-x64-0.1.72.tgz", + "integrity": "sha512-RLo6j8s3nYbjdd1LDct4wamfChyRit7zokUuxtIYCu9XOlltkN5vnj1vwnrPvoqCMZ/7CbbuHFwSTn9A71de/w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@cargo-messages/linux-arm-gnueabihf": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/linux-arm-gnueabihf/-/linux-arm-gnueabihf-0.1.72.tgz", + "integrity": "sha512-tHsRshuzfjrX6SDW3jg6al8vMNLTMgczGnVYl5RuBZf/yrAUuwe30KxA9ge6w6mW6Ox797DyBchzAc9OLgTgmQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@cargo-messages/linux-x64-gnu": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/linux-x64-gnu/-/linux-x64-gnu-0.1.72.tgz", + "integrity": "sha512-VGtL6CCnUbhsP4aYuBNT5kfrAL7o0qjrxw97a+ax13t+nJd26tVEEIKHMu5drvvS/Nm/hn7sLT8zMnnCv0pvHg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@cargo-messages/win32-arm64-msvc": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/win32-arm64-msvc/-/win32-arm64-msvc-0.1.72.tgz", + "integrity": "sha512-V93Cgz39K+yqa3MveNbhh29pYCp8izK5uEavjPoxlNxAbsMCWH+s0verGDdUcfGxjR1H2V7oZ4FszPqR2SqMRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@cargo-messages/win32-x64-msvc": { + "version": "0.1.72", + "resolved": "https://registry.npmjs.org/@cargo-messages/win32-x64-msvc/-/win32-x64-msvc-0.1.72.tgz", + "integrity": "sha512-knz3uSrO0OSbq3U5VWfCY8FB4NsM43BOWLZ7x4sfaMOC1XWv+IyvDdkLe6DhJx8KUw46KIAimYs9YROrp6l46Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@neon-rs/cli": { + "version": "0.1.73", + "resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.1.73.tgz", + "integrity": "sha512-1kv8S/feB6UQWQQwsnGfkSkEBOtlFDNExnioL81E2BwvUWgjQPaseHgpi2EpWVgsPUgur5eBm4QowmlpWkD4/w==", + "dev": true, + "bin": { + "neon": "index.js" + }, + "optionalDependencies": { + "@cargo-messages/android-arm-eabi": "0.1.72", + "@cargo-messages/darwin-arm64": "0.1.72", + "@cargo-messages/darwin-x64": "0.1.72", + "@cargo-messages/linux-arm-gnueabihf": "0.1.72", + "@cargo-messages/linux-x64-gnu": "0.1.72", + "@cargo-messages/win32-arm64-msvc": "0.1.72", + "@cargo-messages/win32-x64-msvc": "0.1.72" + } + }, + "node_modules/@neon-rs/load": { + "version": "0.1.73", + "resolved": "https://registry.npmjs.org/@neon-rs/load/-/load-0.1.73.tgz", + "integrity": "sha512-iflBHUbPHBwlaltsS8O4ASE9nE3JCjGp8uvz0n+ItA1f6aBchW+WNU1AiwdQsh5BEBIKFjozZq/h+VmZsP/CsQ==" + }, + "node_modules/@tsconfig/node20": { + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz", + "integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.14.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.15.tgz", + "integrity": "sha512-Fz1xDMCF/B00/tYSVMlmK7hVeLh7jE5f3B7X1/hmV0MJBwE27KlS7EvD/Yp+z1lm8mVhwV5w+n8jOZG8AfTlKw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/src/lib-node/src/bindings/UpdateInfo.ts b/src/lib-node/src/bindings/UpdateInfo.ts new file mode 100644 index 00000000..3b5da50e --- /dev/null +++ b/src/lib-node/src/bindings/UpdateInfo.ts @@ -0,0 +1,17 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { VelopackAsset } from "./VelopackAsset"; + +/** + * Holds information about the current version and pending updates, such as how many there are, and access to release notes. + */ +export type UpdateInfo = { +/** + * The available version that we are updating to. + */ +TargetFullRelease: VelopackAsset, +/** + * True if the update is a version downgrade or lateral move (such as when switching channels to the same version number). + * In this case, only full updates are allowed, and any local packages on disk newer than the downloaded version will be + * deleted. + */ +IsDowngrade: boolean, }; diff --git a/src/lib-node/src/bindings/UpdateOptions.ts b/src/lib-node/src/bindings/UpdateOptions.ts new file mode 100644 index 00000000..a52ae232 --- /dev/null +++ b/src/lib-node/src/bindings/UpdateOptions.ts @@ -0,0 +1,23 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Options to customise the behaviour of UpdateManager. + */ +export type UpdateOptions = { +/** + * Allows UpdateManager to update to a version that's lower than the current version (i.e. downgrading). + * This could happen if a release has bugs and was retracted from the release feed, or if you're using + * ExplicitChannel to switch channels to another channel where the latest version on that + * channel is lower than the current version. + */ +AllowVersionDowngrade: boolean, +/** + * **This option should usually be left None**.
+ * Overrides the default channel used to fetch updates. + * The default channel will be whatever channel was specified on the command line when building this release. + * For example, if the current release was packaged with '--channel beta', then the default channel will be 'beta'. + * This allows users to automatically receive updates from the same channel they installed from. This options + * allows you to explicitly switch channels, for example if the user wished to switch back to the 'stable' channel + * without having to reinstall the application. + */ +ExplicitChannel: string | null, }; diff --git a/src/lib-node/src/bindings/VelopackAsset.ts b/src/lib-node/src/bindings/VelopackAsset.ts new file mode 100644 index 00000000..71336830 --- /dev/null +++ b/src/lib-node/src/bindings/VelopackAsset.ts @@ -0,0 +1,42 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * An individual Velopack asset, could refer to an asset on-disk or in a remote package feed. + */ +export type VelopackAsset = { +/** + * The name or Id of the package containing this release. + */ +PackageId: string, +/** + * The version of this release. + */ +Version: string, +/** + * The type of asset (eg. "Full" or "Delta"). + */ +Type: string, +/** + * The filename of the update package containing this release. + */ +FileName: string, +/** + * The SHA1 checksum of the update package containing this release. + */ +SHA1: string, +/** + * The SHA256 checksum of the update package containing this release. + */ +SHA256: string, +/** + * The size in bytes of the update package containing this release. + */ +Size: bigint, +/** + * The release notes in markdown format, as passed to Velopack when packaging the release. This may be an empty string. + */ +NotesMarkdown: string, +/** + * The release notes in HTML format, transformed from Markdown when packaging the release. This may be an empty string. + */ +NotesHtml: string, }; diff --git a/src/lib-node/src/index.cts b/src/lib-node/src/index.cts index 52d5943a..f790a5ee 100644 --- a/src/lib-node/src/index.cts +++ b/src/lib-node/src/index.cts @@ -1,4 +1,8 @@ import * as addon from './load.cjs'; +import { UpdateInfo } from './bindings/UpdateInfo'; +import { UpdateOptions } from './bindings/UpdateOptions'; + +export { UpdateInfo, UpdateOptions }; type UpdateManagerOpaque = {}; declare module "./load.cjs" { @@ -13,31 +17,6 @@ declare module "./load.cjs" { function js_wait_then_apply_update_async(um: UpdateManagerOpaque, update?: string): Promise; } -export type UpdateOptions = { - AllowVersionDowngrade: boolean; - ExplicitChannel: string; -} - -/** An individual Velopack asset, could refer to an asset on-disk or in a remote package feed. */ -export type VelopackAsset = { - FileName: string; - Version: string; - NotesHtml: string; - NotesMarkdown: string; - PackageId: string; - SHA1: string; - SHA256: string; - Size: number; - Type: "Full" | "Delta"; -} - -export type UpdateInfo = { - BaseRelease: VelopackAsset; - DeltasToTarget: VelopackAsset[]; - IsDowngrade: boolean; - TargetFullRelease: VelopackAsset; -} - export class UpdateManager { private opaque: UpdateManagerOpaque; diff --git a/src/lib-rust/Cargo.toml b/src/lib-rust/Cargo.toml index 51cd56d2..34ffb65e 100644 --- a/src/lib-rust/Cargo.toml +++ b/src/lib-rust/Cargo.toml @@ -31,7 +31,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } zip = { version = "2.1", default-features = false, features = ["deflate"] } thiserror = "1.0" -ts-rs = { git = "https://github.com/Aleph-Alpha/ts-rs.git", branch = "cli" } +ts-rs = "9" # delta packages zstd = { version = "0.13", optional = true }