tauri-plugin-delta-update-api 0.0.0-stage → 1.0.0-rc.4
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 +21 -0
- package/README.md +100 -2
- package/dist/commands.d.ts +16 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +36 -0
- package/dist/commands.js.map +1 -0
- package/dist/controller.d.ts +24 -0
- package/dist/controller.d.ts.map +1 -0
- package/dist/controller.js +94 -0
- package/dist/controller.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +37 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +54 -0
- package/dist/react.js.map +1 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 delta-update-engine contributors
|
|
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
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tauri-plugin-delta-update-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Frontend types and `invoke` wrappers for `tauri-plugin-delta-update`.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add tauri-plugin-delta-update-api
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createUpdateController } from 'tauri-plugin-delta-update-api';
|
|
11
|
+
|
|
12
|
+
const updater = createUpdateController();
|
|
13
|
+
updater.subscribe((state) => {
|
|
14
|
+
if (state?.state === 'Prepared') {
|
|
15
|
+
console.log(`v${state.version} ready on next launch`);
|
|
16
|
+
}
|
|
17
|
+
if (state?.state === 'RolledBack') {
|
|
18
|
+
console.log(`rolled back to v${state.version}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await updater.start();
|
|
23
|
+
|
|
24
|
+
const result = await updater.check();
|
|
25
|
+
if (result.available) {
|
|
26
|
+
console.log(result.notes, result.mandatory);
|
|
27
|
+
await updater.prepare();
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
React 18+ can use the optional hook subpath:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { useUpdater } from 'tauri-plugin-delta-update-api/react';
|
|
35
|
+
|
|
36
|
+
function UpdateBanner() {
|
|
37
|
+
const { state, restart } = useUpdater();
|
|
38
|
+
return state?.state === 'Prepared'
|
|
39
|
+
? <button onClick={() => void restart()}>Restart into v{state.version}</button>
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`confirm()` is the post-restart health acknowledgement (state `Committed`). It is
|
|
45
|
+
**not** called automatically by default (`auto_confirm: false`); call it after
|
|
46
|
+
your app's core startup work succeeds. Set `auto_confirm: true` only if the
|
|
47
|
+
window being visible is a sufficient health signal for your app. When several
|
|
48
|
+
components share one controller, `start()`/`stop()` are reference counted and
|
|
49
|
+
the listener is only released by the last consumer. React is an optional peer
|
|
50
|
+
dependency: Vue/Svelte and vanilla apps use `createUpdateController` directly.
|
|
51
|
+
|
|
52
|
+
### Vue / Svelte
|
|
53
|
+
|
|
54
|
+
The controller already satisfies Svelte's store contract (`subscribe` emits the
|
|
55
|
+
current value immediately and returns an unsubscribe function), so `$updater`
|
|
56
|
+
works without an extra adapter:
|
|
57
|
+
|
|
58
|
+
```svelte
|
|
59
|
+
<script>
|
|
60
|
+
import { onDestroy, onMount } from 'svelte';
|
|
61
|
+
import { createUpdateController } from 'tauri-plugin-delta-update-api';
|
|
62
|
+
|
|
63
|
+
const updater = createUpdateController();
|
|
64
|
+
onMount(() => void updater.start());
|
|
65
|
+
onDestroy(() => updater.stop());
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
{#if $updater?.state === 'Prepared'}
|
|
69
|
+
<button on:click={() => updater.restart()}>Restart into v{$updater.version}</button>
|
|
70
|
+
{/if}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Vue 3 composition API:
|
|
74
|
+
|
|
75
|
+
```vue
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import { onScopeDispose, shallowRef } from 'vue';
|
|
78
|
+
import { createUpdateController } from 'tauri-plugin-delta-update-api';
|
|
79
|
+
|
|
80
|
+
const updater = createUpdateController();
|
|
81
|
+
const state = shallowRef(updater.getState());
|
|
82
|
+
const unsubscribe = updater.subscribe((next) => {
|
|
83
|
+
state.value = next;
|
|
84
|
+
});
|
|
85
|
+
void updater.start();
|
|
86
|
+
onScopeDispose(() => {
|
|
87
|
+
unsubscribe();
|
|
88
|
+
updater.stop();
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<button v-if="state?.state === 'Prepared'" @click="updater.restart()">
|
|
94
|
+
Restart into v{{ state.version }}
|
|
95
|
+
</button>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The low-level `check`, `prepare`, `STATE_EVENT` and typed payloads are still
|
|
100
|
+
exported. The package contains no update logic; verification, download and
|
|
101
|
+
replacement are performed by the Rust engine.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CancelResult, CheckResult, ClearSkipResult, ConfirmResult, DiagnosticsResult, PrepareResult, RestartResult, UpdateRecord, UpdateStatePayload } from './types';
|
|
2
|
+
export declare function check(): Promise<CheckResult>;
|
|
3
|
+
export declare function prepare(): Promise<PrepareResult>;
|
|
4
|
+
export declare function cancelPrepare(): Promise<CancelResult>;
|
|
5
|
+
export declare function status(): Promise<UpdateStatePayload>;
|
|
6
|
+
export declare function confirmHealthy(): Promise<ConfirmResult>;
|
|
7
|
+
export declare function restartToApply(): Promise<RestartResult>;
|
|
8
|
+
/** Write a support bundle next to the app logs and return its path. */
|
|
9
|
+
export declare function exportDiagnostics(): Promise<DiagnosticsResult>;
|
|
10
|
+
/** Open the app log directory so the user can attach the newest bundle. */
|
|
11
|
+
export declare function openDiagnosticsFolder(): Promise<void>;
|
|
12
|
+
/** Remove the rollback skip marker so the same version can be retried. */
|
|
13
|
+
export declare function clearSkippedVersion(): Promise<ClearSkipResult>;
|
|
14
|
+
/** Newest terminal update outcomes (completed / rolled_back / failed). */
|
|
15
|
+
export declare function getUpdateHistory(limit?: number): Promise<UpdateRecord[]>;
|
|
16
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC,CAE5C;AAED,wBAAgB,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAEhD;AAED,wBAAgB,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,CAErD;AAED,wBAAgB,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEpD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAEvD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAEvD;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAE9D;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,eAAe,CAAC,CAE9D;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEpE"}
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
export function check() {
|
|
3
|
+
return invoke('plugin:delta-update|check');
|
|
4
|
+
}
|
|
5
|
+
export function prepare() {
|
|
6
|
+
return invoke('plugin:delta-update|prepare');
|
|
7
|
+
}
|
|
8
|
+
export function cancelPrepare() {
|
|
9
|
+
return invoke('plugin:delta-update|cancel_prepare');
|
|
10
|
+
}
|
|
11
|
+
export function status() {
|
|
12
|
+
return invoke('plugin:delta-update|status');
|
|
13
|
+
}
|
|
14
|
+
export function confirmHealthy() {
|
|
15
|
+
return invoke('plugin:delta-update|confirm_healthy');
|
|
16
|
+
}
|
|
17
|
+
export function restartToApply() {
|
|
18
|
+
return invoke('plugin:delta-update|restart_to_apply');
|
|
19
|
+
}
|
|
20
|
+
/** Write a support bundle next to the app logs and return its path. */
|
|
21
|
+
export function exportDiagnostics() {
|
|
22
|
+
return invoke('plugin:delta-update|export_diagnostics');
|
|
23
|
+
}
|
|
24
|
+
/** Open the app log directory so the user can attach the newest bundle. */
|
|
25
|
+
export function openDiagnosticsFolder() {
|
|
26
|
+
return invoke('plugin:delta-update|open_diagnostics_folder');
|
|
27
|
+
}
|
|
28
|
+
/** Remove the rollback skip marker so the same version can be retried. */
|
|
29
|
+
export function clearSkippedVersion() {
|
|
30
|
+
return invoke('plugin:delta-update|clear_skipped_version');
|
|
31
|
+
}
|
|
32
|
+
/** Newest terminal update outcomes (completed / rolled_back / failed). */
|
|
33
|
+
export function getUpdateHistory(limit = 50) {
|
|
34
|
+
return invoke('plugin:delta-update|get_update_history', { limit });
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAc9C,MAAM,UAAU,KAAK;IACnB,OAAO,MAAM,CAAc,2BAA2B,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,MAAM,CAAgB,6BAA6B,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,MAAM,CAAe,oCAAoC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,MAAM;IACpB,OAAO,MAAM,CAAqB,4BAA4B,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAgB,qCAAqC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAgB,sCAAsC,CAAC,CAAC;AACvE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAoB,wCAAwC,CAAC,CAAC;AAC7E,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,qBAAqB;IACnC,OAAO,MAAM,CAAO,6CAA6C,CAAC,CAAC;AACrE,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IACjC,OAAO,MAAM,CAAkB,2CAA2C,CAAC,CAAC;AAC9E,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,KAAK,GAAG,EAAE;IACzC,OAAO,MAAM,CAAiB,wCAAwC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cancelPrepare, check, confirmHealthy, prepare, restartToApply } from './commands';
|
|
2
|
+
import { type UpdateStatePayload } from './types';
|
|
3
|
+
export type UpdateStateListener = (state: UpdateStatePayload | null) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Framework-agnostic update store. It keeps the latest state event, exposes a
|
|
6
|
+
* snapshot and wraps the six commands, so React/Vue/Svelte apps do not have to
|
|
7
|
+
* duplicate listener and error plumbing.
|
|
8
|
+
*
|
|
9
|
+
* `start`/`stop` are reference counted: several components can share one
|
|
10
|
+
* controller, and the event listener is only released when the last one stops.
|
|
11
|
+
*/
|
|
12
|
+
export interface UpdateController {
|
|
13
|
+
getState(): UpdateStatePayload | null;
|
|
14
|
+
subscribe(listener: UpdateStateListener): () => void;
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
stop(): void;
|
|
17
|
+
check: typeof check;
|
|
18
|
+
prepare: typeof prepare;
|
|
19
|
+
cancel: typeof cancelPrepare;
|
|
20
|
+
confirm: typeof confirmHealthy;
|
|
21
|
+
restart: typeof restartToApply;
|
|
22
|
+
}
|
|
23
|
+
export declare function createUpdateController(): UpdateController;
|
|
24
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,KAAK,EACL,cAAc,EACd,OAAO,EACP,cAAc,EAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,kBAAkB,GAAG,IAAI,CAAC;IACtC,SAAS,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI,CAAC;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,cAAc,CAAC;IAC/B,OAAO,EAAE,OAAO,cAAc,CAAC;CAChC;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CA0FzD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { listen } from '@tauri-apps/api/event';
|
|
2
|
+
import { cancelPrepare, check, confirmHealthy, prepare, restartToApply, status, } from './commands';
|
|
3
|
+
import { STATE_EVENT } from './types';
|
|
4
|
+
export function createUpdateController() {
|
|
5
|
+
let state = null;
|
|
6
|
+
let unlisten = null;
|
|
7
|
+
let starting = null;
|
|
8
|
+
let refs = 0;
|
|
9
|
+
let generation = 0;
|
|
10
|
+
const listeners = new Set();
|
|
11
|
+
const notify = (listener) => {
|
|
12
|
+
try {
|
|
13
|
+
listener(state);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
// One broken component must not starve the other subscribers.
|
|
17
|
+
console.error('[delta-update] state listener failed', error);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const update = (next) => {
|
|
21
|
+
state = next;
|
|
22
|
+
for (const listener of [...listeners])
|
|
23
|
+
notify(listener);
|
|
24
|
+
};
|
|
25
|
+
const start = () => {
|
|
26
|
+
refs += 1;
|
|
27
|
+
if (starting)
|
|
28
|
+
return starting;
|
|
29
|
+
const current = ++generation;
|
|
30
|
+
starting = (async () => {
|
|
31
|
+
// Subscribe before reading the snapshot: an update that lands in
|
|
32
|
+
// between would otherwise be overwritten by the stale snapshot.
|
|
33
|
+
let sawEvent = false;
|
|
34
|
+
const stopListening = await listen(STATE_EVENT, (event) => {
|
|
35
|
+
sawEvent = true;
|
|
36
|
+
update(event.payload);
|
|
37
|
+
});
|
|
38
|
+
if (current !== generation) {
|
|
39
|
+
stopListening();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
unlisten = stopListening;
|
|
43
|
+
let initial;
|
|
44
|
+
try {
|
|
45
|
+
initial = await status();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
stopListening();
|
|
49
|
+
if (unlisten === stopListening)
|
|
50
|
+
unlisten = null;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
if (current === generation && !sawEvent)
|
|
54
|
+
update(initial);
|
|
55
|
+
})().catch((error) => {
|
|
56
|
+
if (current === generation) {
|
|
57
|
+
starting = null;
|
|
58
|
+
refs = 0;
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
return starting;
|
|
63
|
+
};
|
|
64
|
+
const stop = () => {
|
|
65
|
+
refs = Math.max(0, refs - 1);
|
|
66
|
+
if (refs > 0)
|
|
67
|
+
return;
|
|
68
|
+
generation += 1;
|
|
69
|
+
unlisten?.();
|
|
70
|
+
unlisten = null;
|
|
71
|
+
starting = null;
|
|
72
|
+
// A stopped listener no longer guarantees the snapshot is current; drop it
|
|
73
|
+
// so a later subscriber does not render a stale Prepared/Committed state.
|
|
74
|
+
state = null;
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
getState: () => state,
|
|
78
|
+
subscribe(listener) {
|
|
79
|
+
listeners.add(listener);
|
|
80
|
+
notify(listener);
|
|
81
|
+
return () => {
|
|
82
|
+
listeners.delete(listener);
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
start,
|
|
86
|
+
stop,
|
|
87
|
+
check,
|
|
88
|
+
prepare,
|
|
89
|
+
cancel: cancelPrepare,
|
|
90
|
+
confirm: confirmHealthy,
|
|
91
|
+
restart: restartToApply,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EACL,aAAa,EACb,KAAK,EACL,cAAc,EACd,OAAO,EACP,cAAc,EACd,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAA2B,MAAM,SAAS,CAAC;AAwB/D,MAAM,UAAU,sBAAsB;IACpC,IAAI,KAAK,GAA8B,IAAI,CAAC;IAC5C,IAAI,QAAQ,GAAsB,IAAI,CAAC;IACvC,IAAI,QAAQ,GAAyB,IAAI,CAAC;IAC1C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEjD,MAAM,MAAM,GAAG,CAAC,QAA6B,EAAQ,EAAE;QACrD,IAAI,CAAC;YACH,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAA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7B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UpdateController } from './controller';
|
|
2
|
+
import { type CancelResult, type CheckResult, type ConfirmResult, type PrepareResult, type RestartResult, type UpdateStatePayload } from './types';
|
|
3
|
+
export interface UseUpdaterResult {
|
|
4
|
+
state: UpdateStatePayload | null;
|
|
5
|
+
controller: UpdateController;
|
|
6
|
+
check: () => Promise<CheckResult>;
|
|
7
|
+
prepare: () => Promise<PrepareResult>;
|
|
8
|
+
cancel: () => Promise<CancelResult>;
|
|
9
|
+
confirm: () => Promise<ConfirmResult>;
|
|
10
|
+
restart: () => Promise<RestartResult>;
|
|
11
|
+
/** Prepare unless already prepared or busy; resolves `null` when skipped. */
|
|
12
|
+
retryPrepare: () => Promise<PrepareResult | null>;
|
|
13
|
+
/** Restart only when an update is prepared; resolves `null` otherwise. */
|
|
14
|
+
retryRestart: () => Promise<RestartResult | null>;
|
|
15
|
+
/** Derived flags so callers do not hand-compare state strings. */
|
|
16
|
+
isChecking: boolean;
|
|
17
|
+
isDownloading: boolean;
|
|
18
|
+
isReady: boolean;
|
|
19
|
+
isCommitted: boolean;
|
|
20
|
+
isRolledBack: boolean;
|
|
21
|
+
isFailed: boolean;
|
|
22
|
+
isBusy: boolean;
|
|
23
|
+
/** The running version is below the publisher's `min_supported_version`. */
|
|
24
|
+
isUpdateRequired: boolean;
|
|
25
|
+
canPrepare: boolean;
|
|
26
|
+
canRestart: boolean;
|
|
27
|
+
error: UpdateStatePayload['error'];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* React hook around `createUpdateController`.
|
|
31
|
+
*
|
|
32
|
+
* Pass a shared controller when several components must observe the same
|
|
33
|
+
* state; the hook otherwise creates one per component. The controller is
|
|
34
|
+
* started on mount and stopped on unmount.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useUpdater(shared?: UpdateController): UseUpdaterResult;
|
|
37
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACtC,6EAA6E;IAC7E,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAClD,0EAA0E;IAC1E,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAClD,kEAAkE;IAClE,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CA+CtE"}
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useEffect, useMemo, useSyncExternalStore } from 'react';
|
|
2
|
+
import { createUpdateController } from './controller';
|
|
3
|
+
import { isBusy, isCommitted, isFailed, isPrepared, isRolledBack, isUpdateRequired, } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* React hook around `createUpdateController`.
|
|
6
|
+
*
|
|
7
|
+
* Pass a shared controller when several components must observe the same
|
|
8
|
+
* state; the hook otherwise creates one per component. The controller is
|
|
9
|
+
* started on mount and stopped on unmount.
|
|
10
|
+
*/
|
|
11
|
+
export function useUpdater(shared) {
|
|
12
|
+
const controller = useMemo(() => shared ?? createUpdateController(), [shared]);
|
|
13
|
+
const state = useSyncExternalStore(controller.subscribe, controller.getState, controller.getState);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
void controller.start().catch((error) => {
|
|
16
|
+
// The hook has no error channel; a failed start leaves `state` null.
|
|
17
|
+
console.warn('[delta-update] failed to start the update controller', error);
|
|
18
|
+
});
|
|
19
|
+
return () => controller.stop();
|
|
20
|
+
}, [controller]);
|
|
21
|
+
return {
|
|
22
|
+
state,
|
|
23
|
+
controller,
|
|
24
|
+
check: controller.check,
|
|
25
|
+
prepare: controller.prepare,
|
|
26
|
+
cancel: controller.cancel,
|
|
27
|
+
confirm: controller.confirm,
|
|
28
|
+
restart: controller.restart,
|
|
29
|
+
retryPrepare: async () => {
|
|
30
|
+
if (state !== null && (isPrepared(state) || isBusy(state)))
|
|
31
|
+
return null;
|
|
32
|
+
return controller.prepare();
|
|
33
|
+
},
|
|
34
|
+
retryRestart: async () => {
|
|
35
|
+
if (state === null || !isPrepared(state))
|
|
36
|
+
return null;
|
|
37
|
+
return controller.restart();
|
|
38
|
+
},
|
|
39
|
+
isChecking: state?.state === 'Checking',
|
|
40
|
+
isDownloading: state?.state === 'Downloading' || state?.state === 'Preparing',
|
|
41
|
+
isReady: state !== null && isPrepared(state),
|
|
42
|
+
isCommitted: isCommitted(state),
|
|
43
|
+
isRolledBack: isRolledBack(state),
|
|
44
|
+
isFailed: isFailed(state),
|
|
45
|
+
isBusy: isBusy(state),
|
|
46
|
+
isUpdateRequired: isUpdateRequired(state),
|
|
47
|
+
canPrepare: state?.state === 'Idle' ||
|
|
48
|
+
state?.state === 'UpdateRequired' ||
|
|
49
|
+
isFailed(state),
|
|
50
|
+
canRestart: state !== null && isPrepared(state),
|
|
51
|
+
error: state?.error ?? null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAyB,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,gBAAgB,GAOjB,MAAM,SAAS,CAAC;AA6BjB;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,MAAyB;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,IAAI,sBAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,oBAAoB,CAChC,UAAU,CAAC,SAAS,EACpB,UAAU,CAAC,QAAQ,EACnB,UAAU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C,KAAK,CAAC;QACjC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;QACrB,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC;QACzC,UAAU,EACR,KAAK,EAAE,KAAK,KAAK,MAAM;YACvB,KAAK,EAAE,KAAK,KAAK,gBAAgB;YACjC,QAAQ,CAAC,KAAK,CAAC;QACjB,UAAU,EAAE,KAAK,KAAK,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC;QAC/C,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export declare const STATE_EVENT = "delta-update://state";
|
|
2
|
+
export declare const STATE_NAMES: readonly ["Idle", "UpdateRequired", "Checking", "Downloading", "Preparing", "Prepared", "Cancelled", "Committing", "Committed", "RollingBack", "RolledBack", "Failed"];
|
|
3
|
+
export type UpdateStateName = (typeof STATE_NAMES)[number];
|
|
4
|
+
export interface UpdateProgress {
|
|
5
|
+
total: number;
|
|
6
|
+
completed: number;
|
|
7
|
+
/** Meaning of total/completed. `Prepared` payloads omit it. */
|
|
8
|
+
unit?: 'bytes' | 'files' | 'ops';
|
|
9
|
+
/** File currently being downloaded or verified, when the plugin reports one. */
|
|
10
|
+
file?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export type ErrorAction = 'retry' | 'wait' | 'check_update' | 'contact_support' | 'grant_permission' | 'free_space' | 'update_client' | 'report_security' | 'recover_backup' | 'fix_config' | 'unsupported' | 'restart';
|
|
13
|
+
export interface UpdateError {
|
|
14
|
+
code: string;
|
|
15
|
+
category: string;
|
|
16
|
+
message: string;
|
|
17
|
+
retryable: boolean;
|
|
18
|
+
action: ErrorAction;
|
|
19
|
+
user_action: string;
|
|
20
|
+
detail: string;
|
|
21
|
+
}
|
|
22
|
+
export interface UpdateStatePayload {
|
|
23
|
+
v: number;
|
|
24
|
+
state: UpdateStateName;
|
|
25
|
+
version: string | null;
|
|
26
|
+
progress: UpdateProgress | null;
|
|
27
|
+
error: UpdateError | null;
|
|
28
|
+
/** Set only in `UpdateRequired`: the oldest version the publisher supports. */
|
|
29
|
+
min_supported_version?: string | null;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CheckResult {
|
|
33
|
+
available: boolean;
|
|
34
|
+
version: string | null;
|
|
35
|
+
current_version: string;
|
|
36
|
+
files_changed: number;
|
|
37
|
+
files_staged: number;
|
|
38
|
+
download_bytes: number;
|
|
39
|
+
total_bytes: number;
|
|
40
|
+
notes: string | null;
|
|
41
|
+
mandatory: boolean;
|
|
42
|
+
/** The running version is below the publisher's `min_supported_version`. */
|
|
43
|
+
update_required?: boolean;
|
|
44
|
+
/** Oldest version the publisher still supports; absent when unset. */
|
|
45
|
+
min_supported_version?: string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Files skipped because they are cloud placeholders (OneDrive/Files
|
|
48
|
+
* On-Demand). If the manifest lists them, they are downloaded in full.
|
|
49
|
+
* Older plugin versions omit this field; treat a missing value as 0.
|
|
50
|
+
*/
|
|
51
|
+
cloud_placeholders_skipped?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface PrepareResult {
|
|
54
|
+
/** `"Prepared"` on completion; the current state name when a prepare is already running. */
|
|
55
|
+
state: UpdateStateName;
|
|
56
|
+
version: string;
|
|
57
|
+
}
|
|
58
|
+
export interface CancelResult {
|
|
59
|
+
state: 'Cancelled';
|
|
60
|
+
}
|
|
61
|
+
export interface ConfirmResult {
|
|
62
|
+
acknowledged: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface RestartResult {
|
|
65
|
+
state: 'Committing';
|
|
66
|
+
version: string;
|
|
67
|
+
}
|
|
68
|
+
export interface DiagnosticsResult {
|
|
69
|
+
/** Absolute path of the JSON support bundle written next to the app logs. */
|
|
70
|
+
path: string;
|
|
71
|
+
}
|
|
72
|
+
export interface ClearSkipResult {
|
|
73
|
+
/** Whether a rollback skip marker existed and was removed. */
|
|
74
|
+
cleared: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** One terminal update outcome from `get_update_history`. */
|
|
77
|
+
export interface UpdateRecord {
|
|
78
|
+
v: number;
|
|
79
|
+
version: string;
|
|
80
|
+
from_version?: string | null;
|
|
81
|
+
started_at_unix?: number | null;
|
|
82
|
+
finished_at_unix: number;
|
|
83
|
+
result: 'completed' | 'rolled_back' | 'failed';
|
|
84
|
+
duration_ms?: number | null;
|
|
85
|
+
reason?: string | null;
|
|
86
|
+
error_code?: string | null;
|
|
87
|
+
}
|
|
88
|
+
export declare function isPrepared(payload: UpdateStatePayload): payload is UpdateStatePayload & {
|
|
89
|
+
state: 'Prepared';
|
|
90
|
+
version: string;
|
|
91
|
+
};
|
|
92
|
+
export declare const isCommitted: (payload: UpdateStatePayload | null) => payload is UpdateStatePayload & {
|
|
93
|
+
state: "Committed";
|
|
94
|
+
version: string;
|
|
95
|
+
};
|
|
96
|
+
export declare const isRolledBack: (payload: UpdateStatePayload | null) => payload is UpdateStatePayload & {
|
|
97
|
+
state: "RolledBack";
|
|
98
|
+
};
|
|
99
|
+
export declare const isFailed: (payload: UpdateStatePayload | null) => payload is UpdateStatePayload & {
|
|
100
|
+
state: "Failed";
|
|
101
|
+
error: UpdateError;
|
|
102
|
+
};
|
|
103
|
+
export declare const isUpdateRequired: (payload: UpdateStatePayload | null) => payload is UpdateStatePayload & {
|
|
104
|
+
state: "UpdateRequired";
|
|
105
|
+
min_supported_version: string;
|
|
106
|
+
};
|
|
107
|
+
/** The plugin is doing work; commands that need the same gate will fail. */
|
|
108
|
+
export declare const isBusy: (payload: UpdateStatePayload | null) => boolean;
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,yB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M,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,IAAI,kBAAkB,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAExE;AAED,eAAO,MAAM,WAAW,GACtB,SAAS,kBAAkB,GAAG,IAAI,KACjC,OAAO,IAAI,kBAAkB,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CACZ,CAAC;AAE7D,eAAO,MAAM,YAAY,GACvB,SAAS,kBAAkB,GAAG,IAAI,KACjC,OAAO,IAAI,kBAAkB,GAAG;IAAE,KAAK,EAAE,YAAY,CAAA;CACvB,CAAC;AAElC,eAAO,MAAM,QAAQ,GACnB,SAAS,kBAAkB,GAAG,IAAI,KACjC,OAAO,IAAI,kBAAkB,GAAG;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CACjB,CAAC;AAExD,eAAO,MAAM,gBAAgB,GAC3B,SAAS,kBAAkB,GAAG,IAAI,KACjC,OAAO,IAAI,kBAAkB,GAAG;IACjC,KAAK,EAAE,gBAAgB,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;CAC2C,CAAC;AAU5E,4EAA4E;AAC5E,eAAO,MAAM,MAAM,GAAI,SAAS,kBAAkB,GAAG,IAAI,KAAG,OACR,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const STATE_EVENT = 'delta-update://state';
|
|
2
|
+
export const STATE_NAMES = [
|
|
3
|
+
'Idle',
|
|
4
|
+
'UpdateRequired',
|
|
5
|
+
'Checking',
|
|
6
|
+
'Downloading',
|
|
7
|
+
'Preparing',
|
|
8
|
+
'Prepared',
|
|
9
|
+
'Cancelled',
|
|
10
|
+
'Committing',
|
|
11
|
+
'Committed',
|
|
12
|
+
'RollingBack',
|
|
13
|
+
'RolledBack',
|
|
14
|
+
'Failed',
|
|
15
|
+
];
|
|
16
|
+
export function isPrepared(payload) {
|
|
17
|
+
return payload.state === 'Prepared' && payload.version !== null;
|
|
18
|
+
}
|
|
19
|
+
export const isCommitted = (payload) => payload?.state === 'Committed' && payload.version !== null;
|
|
20
|
+
export const isRolledBack = (payload) => payload?.state === 'RolledBack';
|
|
21
|
+
export const isFailed = (payload) => payload?.state === 'Failed' && payload.error !== null;
|
|
22
|
+
export const isUpdateRequired = (payload) => payload?.state === 'UpdateRequired' && !!payload.min_supported_version;
|
|
23
|
+
const BUSY_STATES = new Set([
|
|
24
|
+
'Checking',
|
|
25
|
+
'Downloading',
|
|
26
|
+
'Preparing',
|
|
27
|
+
'Committing',
|
|
28
|
+
'RollingBack',
|
|
29
|
+
]);
|
|
30
|
+
/** The plugin is doing work; commands that need the same gate will fail. */
|
|
31
|
+
export const isBusy = (payload) => payload !== null && BUSY_STATES.has(payload.state);
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM;IACN,gBAAgB;IAChB,UAAU;IACV,aAAa;IACb,WAAW;IACX,UAAU;IACV,WAAW;IACX,YAAY;IACZ,WAAW;IACX,aAAa;IACb,YAAY;IACZ,QAAQ;CACA,CAAC;AAgHX,MAAM,UAAU,UAAU,CACxB,OAA2B;IAE3B,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAkC,EACuC,EAAE,CAC3E,OAAO,EAAE,KAAK,KAAK,WAAW,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAkC,EACuB,EAAE,CAC3D,OAAO,EAAE,KAAK,KAAK,YAAY,CAAC;AAElC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAAkC,EACuC,EAAE,CAC3E,OAAO,EAAE,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAkC,EAIlC,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,gBAAgB,IAAI,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;AAE5E,MAAM,WAAW,GAAiC,IAAI,GAAG,CAAC;IACxD,UAAU;IACV,aAAa;IACb,WAAW;IACX,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAkC,EAAW,EAAE,CACpE,OAAO,KAAK,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-delta-update-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
|
+
"description": "Windows-only frontend API for the tauri-plugin-delta-update Tauri 2 plugin",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/zuoqiuning/delta-update-engine.git",
|
|
9
|
+
"directory": "packages/plugin-api"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/zuoqiuning/delta-update-engine/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/zuoqiuning/delta-update-engine#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"tauri",
|
|
17
|
+
"updater",
|
|
18
|
+
"delta",
|
|
19
|
+
"plugin"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./react": {
|
|
31
|
+
"types": "./dist/react.d.ts",
|
|
32
|
+
"import": "./dist/react.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"registry": "https://registry.npmjs.org",
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@tauri-apps/api": "^2.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=18"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"react": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/react": "18.3.12",
|
|
56
|
+
"react": "18.3.1",
|
|
57
|
+
"typescript": "^5.6.0",
|
|
58
|
+
"vitest": "^2.1.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc -p tsconfig.json",
|
|
62
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
63
|
+
"test": "vitest run"
|
|
64
|
+
}
|
|
6
65
|
}
|