@meacore/tauri-easy-updater 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Keyler Tamayo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @meacore/tauri-easy-updater
2
+
3
+ Hassle-free auto-updates for Tauri apps. No signing keys required.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @meacore/tauri-easy-updater
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import {
15
+ useUpdateChecker,
16
+ UpdateBanner,
17
+ createGitHubProvider,
18
+ } from '@meacore/tauri-easy-updater';
19
+
20
+ function App() {
21
+ const { updateInfo, dismiss } = useUpdateChecker({
22
+ currentVersion: '1.0.0',
23
+ provider: createGitHubProvider({ owner: 'myuser', repo: 'myapp' }),
24
+ });
25
+
26
+ return (
27
+ <>
28
+ {updateInfo?.hasUpdate && (
29
+ <UpdateBanner updateInfo={updateInfo} onDismiss={dismiss} />
30
+ )}
31
+ </>
32
+ );
33
+ }
34
+ ```
35
+
36
+ ## Documentation
37
+
38
+ See the full documentation at https://github.com/keylertamayo/tauri-easy-updater
39
+
40
+ ## License
41
+
42
+ MIT
@@ -0,0 +1,154 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Manifest structure used by the updater.
5
+ */
6
+ interface UpdateManifest {
7
+ version: string;
8
+ pub_date: string;
9
+ notes: string;
10
+ platforms: {
11
+ [platform: string]: {
12
+ url: string;
13
+ };
14
+ };
15
+ }
16
+ /**
17
+ * Information about an available update exposed to the UI.
18
+ */
19
+ interface UpdateInfo {
20
+ hasUpdate: boolean;
21
+ currentVersion: string;
22
+ latestVersion: string;
23
+ downloadUrl: string;
24
+ releaseNotes: string;
25
+ pubDate: string;
26
+ }
27
+ /**
28
+ * Provider interface used by the updater hook.
29
+ */
30
+ interface UpdateProvider {
31
+ type: 'github' | 'http' | 's3';
32
+ fetchManifest(): Promise<UpdateManifest>;
33
+ }
34
+ /**
35
+ * Configuration options for the update checker hook.
36
+ */
37
+ interface UpdaterConfig {
38
+ currentVersion: string;
39
+ provider: UpdateProvider;
40
+ /**
41
+ * Whether to check for updates on startup.
42
+ * @default true
43
+ */
44
+ checkOnStartup?: boolean;
45
+ /**
46
+ * Interval in milliseconds between automatic checks.
47
+ * `0` means only check on startup or when `checkNow` is called.
48
+ * @default 0
49
+ */
50
+ checkIntervalMs?: number;
51
+ /**
52
+ * When true, suppresses UI-driven side effects from errors.
53
+ * Errors are still exposed via the hook return value.
54
+ * @default false
55
+ */
56
+ silent?: boolean;
57
+ }
58
+
59
+ /**
60
+ * Returns the current platform identifier used in update manifests.
61
+ *
62
+ * Values:
63
+ * - "windows-x86_64"
64
+ * - "darwin-x86_64"
65
+ * - "darwin-aarch64"
66
+ * - "linux-x86_64"
67
+ *
68
+ * If called outside a Tauri context (e.g. SSR), it resolves to an empty string.
69
+ */
70
+ declare function getCurrentPlatform(): Promise<string>;
71
+
72
+ /**
73
+ * Returns true if `latest` represents a strictly newer version than `current`.
74
+ *
75
+ * - Handles an optional `v` prefix (e.g. `v1.2.3`).
76
+ * - Supports prerelease segments (e.g. `1.2.3-beta.1`).
77
+ * - Falls back to `false` if parsing fails.
78
+ */
79
+ declare function isNewerVersion(latest: string, current: string): boolean;
80
+
81
+ interface GitHubProviderConfig {
82
+ owner: string;
83
+ repo: string;
84
+ manifestAssetName?: string;
85
+ /**
86
+ * If true, falls back to the GitHub Releases API when the manifest
87
+ * asset is not found.
88
+ * @default true
89
+ */
90
+ fallbackToReleaseApi?: boolean;
91
+ }
92
+ /**
93
+ * Creates an update provider backed by GitHub Releases.
94
+ *
95
+ * It tries to download a manifest asset first and, if not found,
96
+ * optionally falls back to the Releases API.
97
+ */
98
+ declare function createGitHubProvider(config: GitHubProviderConfig): UpdateProvider;
99
+
100
+ interface HttpProviderConfig {
101
+ manifestUrl: string;
102
+ headers?: Record<string, string>;
103
+ }
104
+ /**
105
+ * Creates a generic HTTP(S) update provider backed by a direct manifest URL.
106
+ */
107
+ declare function createHttpProvider(config: HttpProviderConfig): UpdateProvider;
108
+
109
+ interface S3ProviderConfig {
110
+ bucketUrl: string;
111
+ /**
112
+ * Path to the manifest inside the bucket.
113
+ * @default "latest/update-manifest.json"
114
+ */
115
+ manifestPath?: string;
116
+ }
117
+ /**
118
+ * Creates a provider that resolves a manifest served from S3-like storage.
119
+ */
120
+ declare function createS3Provider(config: S3ProviderConfig): UpdateProvider;
121
+
122
+ /**
123
+ * React hook that checks for updates using the configured provider and the Tauri plugin.
124
+ */
125
+ declare function useUpdateChecker(config: UpdaterConfig): {
126
+ updateInfo: UpdateInfo | null;
127
+ isChecking: boolean;
128
+ error: Error | null;
129
+ checkNow: () => Promise<void>;
130
+ dismiss: () => void;
131
+ isDismissed: boolean;
132
+ };
133
+
134
+ type Theme$1 = 'light' | 'dark' | 'auto';
135
+ interface UpdateBannerProps {
136
+ updateInfo: UpdateInfo;
137
+ onDismiss: () => void;
138
+ position?: 'top' | 'bottom';
139
+ theme?: Theme$1;
140
+ className?: string;
141
+ }
142
+ declare function UpdateBanner(props: UpdateBannerProps): react_jsx_runtime.JSX.Element;
143
+
144
+ type Theme = 'light' | 'dark' | 'auto';
145
+ interface UpdateModalProps {
146
+ updateInfo: UpdateInfo;
147
+ onDismiss: () => void;
148
+ appName?: string;
149
+ theme?: Theme;
150
+ className?: string;
151
+ }
152
+ declare function UpdateModal(props: UpdateModalProps): react_jsx_runtime.JSX.Element;
153
+
154
+ export { type GitHubProviderConfig, type HttpProviderConfig, type S3ProviderConfig, UpdateBanner, type UpdateBannerProps, type UpdateInfo, type UpdateManifest, UpdateModal, type UpdateModalProps, type UpdateProvider, type UpdaterConfig, createGitHubProvider, createHttpProvider, createS3Provider, getCurrentPlatform, isNewerVersion, useUpdateChecker };
@@ -0,0 +1,154 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Manifest structure used by the updater.
5
+ */
6
+ interface UpdateManifest {
7
+ version: string;
8
+ pub_date: string;
9
+ notes: string;
10
+ platforms: {
11
+ [platform: string]: {
12
+ url: string;
13
+ };
14
+ };
15
+ }
16
+ /**
17
+ * Information about an available update exposed to the UI.
18
+ */
19
+ interface UpdateInfo {
20
+ hasUpdate: boolean;
21
+ currentVersion: string;
22
+ latestVersion: string;
23
+ downloadUrl: string;
24
+ releaseNotes: string;
25
+ pubDate: string;
26
+ }
27
+ /**
28
+ * Provider interface used by the updater hook.
29
+ */
30
+ interface UpdateProvider {
31
+ type: 'github' | 'http' | 's3';
32
+ fetchManifest(): Promise<UpdateManifest>;
33
+ }
34
+ /**
35
+ * Configuration options for the update checker hook.
36
+ */
37
+ interface UpdaterConfig {
38
+ currentVersion: string;
39
+ provider: UpdateProvider;
40
+ /**
41
+ * Whether to check for updates on startup.
42
+ * @default true
43
+ */
44
+ checkOnStartup?: boolean;
45
+ /**
46
+ * Interval in milliseconds between automatic checks.
47
+ * `0` means only check on startup or when `checkNow` is called.
48
+ * @default 0
49
+ */
50
+ checkIntervalMs?: number;
51
+ /**
52
+ * When true, suppresses UI-driven side effects from errors.
53
+ * Errors are still exposed via the hook return value.
54
+ * @default false
55
+ */
56
+ silent?: boolean;
57
+ }
58
+
59
+ /**
60
+ * Returns the current platform identifier used in update manifests.
61
+ *
62
+ * Values:
63
+ * - "windows-x86_64"
64
+ * - "darwin-x86_64"
65
+ * - "darwin-aarch64"
66
+ * - "linux-x86_64"
67
+ *
68
+ * If called outside a Tauri context (e.g. SSR), it resolves to an empty string.
69
+ */
70
+ declare function getCurrentPlatform(): Promise<string>;
71
+
72
+ /**
73
+ * Returns true if `latest` represents a strictly newer version than `current`.
74
+ *
75
+ * - Handles an optional `v` prefix (e.g. `v1.2.3`).
76
+ * - Supports prerelease segments (e.g. `1.2.3-beta.1`).
77
+ * - Falls back to `false` if parsing fails.
78
+ */
79
+ declare function isNewerVersion(latest: string, current: string): boolean;
80
+
81
+ interface GitHubProviderConfig {
82
+ owner: string;
83
+ repo: string;
84
+ manifestAssetName?: string;
85
+ /**
86
+ * If true, falls back to the GitHub Releases API when the manifest
87
+ * asset is not found.
88
+ * @default true
89
+ */
90
+ fallbackToReleaseApi?: boolean;
91
+ }
92
+ /**
93
+ * Creates an update provider backed by GitHub Releases.
94
+ *
95
+ * It tries to download a manifest asset first and, if not found,
96
+ * optionally falls back to the Releases API.
97
+ */
98
+ declare function createGitHubProvider(config: GitHubProviderConfig): UpdateProvider;
99
+
100
+ interface HttpProviderConfig {
101
+ manifestUrl: string;
102
+ headers?: Record<string, string>;
103
+ }
104
+ /**
105
+ * Creates a generic HTTP(S) update provider backed by a direct manifest URL.
106
+ */
107
+ declare function createHttpProvider(config: HttpProviderConfig): UpdateProvider;
108
+
109
+ interface S3ProviderConfig {
110
+ bucketUrl: string;
111
+ /**
112
+ * Path to the manifest inside the bucket.
113
+ * @default "latest/update-manifest.json"
114
+ */
115
+ manifestPath?: string;
116
+ }
117
+ /**
118
+ * Creates a provider that resolves a manifest served from S3-like storage.
119
+ */
120
+ declare function createS3Provider(config: S3ProviderConfig): UpdateProvider;
121
+
122
+ /**
123
+ * React hook that checks for updates using the configured provider and the Tauri plugin.
124
+ */
125
+ declare function useUpdateChecker(config: UpdaterConfig): {
126
+ updateInfo: UpdateInfo | null;
127
+ isChecking: boolean;
128
+ error: Error | null;
129
+ checkNow: () => Promise<void>;
130
+ dismiss: () => void;
131
+ isDismissed: boolean;
132
+ };
133
+
134
+ type Theme$1 = 'light' | 'dark' | 'auto';
135
+ interface UpdateBannerProps {
136
+ updateInfo: UpdateInfo;
137
+ onDismiss: () => void;
138
+ position?: 'top' | 'bottom';
139
+ theme?: Theme$1;
140
+ className?: string;
141
+ }
142
+ declare function UpdateBanner(props: UpdateBannerProps): react_jsx_runtime.JSX.Element;
143
+
144
+ type Theme = 'light' | 'dark' | 'auto';
145
+ interface UpdateModalProps {
146
+ updateInfo: UpdateInfo;
147
+ onDismiss: () => void;
148
+ appName?: string;
149
+ theme?: Theme;
150
+ className?: string;
151
+ }
152
+ declare function UpdateModal(props: UpdateModalProps): react_jsx_runtime.JSX.Element;
153
+
154
+ export { type GitHubProviderConfig, type HttpProviderConfig, type S3ProviderConfig, UpdateBanner, type UpdateBannerProps, type UpdateInfo, type UpdateManifest, UpdateModal, type UpdateModalProps, type UpdateProvider, type UpdaterConfig, createGitHubProvider, createHttpProvider, createS3Provider, getCurrentPlatform, isNewerVersion, useUpdateChecker };