@inflatable-cookie/longhorn-tauri 0.1.0 → 0.2.1
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/package.json +2 -2
- package/src/update.ts +25 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inflatable-cookie/longhorn-tauri",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"LICENSE"
|
|
75
75
|
],
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@inflatable-cookie/longhorn": "0.1
|
|
77
|
+
"@inflatable-cookie/longhorn": "0.2.1",
|
|
78
78
|
"@tauri-apps/api": "^2.10.1"
|
|
79
79
|
},
|
|
80
80
|
"sideEffects": false,
|
package/src/update.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isEventTransport, type EventTransport, type InvokeTransport } from "@inflatable-cookie/longhorn/core";
|
|
2
2
|
import type {
|
|
3
|
+
UpdateApplyCommand,
|
|
4
|
+
UpdateCancelCommand,
|
|
3
5
|
UpdateCheckCommand,
|
|
4
6
|
UpdateDeferCommand,
|
|
5
|
-
UpdateInstallCommand,
|
|
6
7
|
UpdatePort,
|
|
8
|
+
UpdatePrepareCommand,
|
|
7
9
|
UpdateSelectChannelCommand,
|
|
8
10
|
UpdateUnlisten,
|
|
9
11
|
} from "@inflatable-cookie/longhorn/update";
|
|
@@ -11,15 +13,23 @@ export const UPDATE_SNAPSHOT_COMMAND = "longhorn_update_snapshot";
|
|
|
11
13
|
export const UPDATE_CHECK_COMMAND = "longhorn_update_check";
|
|
12
14
|
export const UPDATE_SELECT_CHANNEL_COMMAND = "longhorn_update_select_channel";
|
|
13
15
|
export const UPDATE_DEFER_COMMAND = "longhorn_update_defer";
|
|
14
|
-
export const
|
|
16
|
+
export const UPDATE_PREPARE_COMMAND = "longhorn_update_prepare";
|
|
17
|
+
export const UPDATE_APPLY_COMMAND = "longhorn_update_apply";
|
|
18
|
+
export const UPDATE_CANCEL_COMMAND = "longhorn_update_cancel";
|
|
15
19
|
export const UPDATE_CHANGED_EVENT = "longhorn://update/changed";
|
|
20
|
+
export const UPDATE_PROGRESS_EVENT = "longhorn://update/progress";
|
|
16
21
|
/**
|
|
17
22
|
* The update seam.
|
|
18
23
|
*
|
|
19
|
-
*
|
|
20
|
-
* invoke because each is its own capability on the host side:
|
|
21
|
-
* reaching the network, changing what this install follows,
|
|
22
|
-
* running application
|
|
24
|
+
* Seven commands and two events, mirroring the staged `UpdateController`.
|
|
25
|
+
* Each is its own invoke because each is its own capability on the host side:
|
|
26
|
+
* reading state, reaching the network, changing what this install follows,
|
|
27
|
+
* staging verified bytes, replacing the running application, and discarding
|
|
28
|
+
* what was staged are six different grants.
|
|
29
|
+
*
|
|
30
|
+
* `UPDATE_PROGRESS_EVENT` carries a progress value rather than an invalidation
|
|
31
|
+
* hint, because the host does not hold the authority lock across the transfer
|
|
32
|
+
* and a snapshot read mid-transfer cannot show the bytes.
|
|
23
33
|
*
|
|
24
34
|
* Results are `unknown`, as every other raw port's are. What comes back over a
|
|
25
35
|
* transport is untrusted until a validator says otherwise; `UpdateClient` is
|
|
@@ -30,11 +40,14 @@ export function createTauriUpdatePort(options: { readonly transport: InvokeTrans
|
|
|
30
40
|
const events = isEventTransport(options.transport) ? options.transport : undefined;
|
|
31
41
|
return {
|
|
32
42
|
snapshot: () => options.transport.invoke(UPDATE_SNAPSHOT_COMMAND, {}),
|
|
33
|
-
check: (command) => options.transport.invoke(UPDATE_CHECK_COMMAND, { command }),
|
|
34
|
-
selectChannel: (command) => options.transport.invoke(UPDATE_SELECT_CHANNEL_COMMAND, { command }),
|
|
35
|
-
defer: (command) => options.transport.invoke(UPDATE_DEFER_COMMAND, { command }),
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
check: (command: UpdateCheckCommand) => options.transport.invoke(UPDATE_CHECK_COMMAND, { command }),
|
|
44
|
+
selectChannel: (command: UpdateSelectChannelCommand) => options.transport.invoke(UPDATE_SELECT_CHANNEL_COMMAND, { command }),
|
|
45
|
+
defer: (command: UpdateDeferCommand) => options.transport.invoke(UPDATE_DEFER_COMMAND, { command }),
|
|
46
|
+
prepare: (command: UpdatePrepareCommand) => options.transport.invoke(UPDATE_PREPARE_COMMAND, { command }),
|
|
47
|
+
apply: (command: UpdateApplyCommand) => options.transport.invoke(UPDATE_APPLY_COMMAND, { command }),
|
|
48
|
+
cancel: (command: UpdateCancelCommand) => options.transport.invoke(UPDATE_CANCEL_COMMAND, { command }),
|
|
49
|
+
listen: events === undefined ? undefined : (listener) => listen(events, UPDATE_CHANGED_EVENT, listener),
|
|
50
|
+
listenProgress: events === undefined ? undefined : (listener) => listen(events, UPDATE_PROGRESS_EVENT, listener),
|
|
38
51
|
};
|
|
39
52
|
}
|
|
40
|
-
function listen(events: EventTransport, listener: (event: unknown) => void): Promise<UpdateUnlisten> { return events.listen(
|
|
53
|
+
function listen(events: EventTransport, event: string, listener: (event: unknown) => void): Promise<UpdateUnlisten> { return events.listen(event, listener); }
|