@inflatable-cookie/longhorn-tauri 0.6.0 → 0.7.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.
@@ -1,18 +0,0 @@
1
- import { listen } from "@tauri-apps/api/event";
2
- import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
3
-
4
- import type { EventTransport, Unlisten } from "@inflatable-cookie/longhorn/core";
5
- import { TRANSFER_CLIENT_CHANGED_EVENT } from "@inflatable-cookie/longhorn/transfer";
6
-
7
- import { TauriTransport } from "./index.ts";
8
-
9
- /// Optional raw Tauri invoke/listen edge.
10
- export class TauriEventTransport extends TauriTransport implements EventTransport {
11
- listen(event: string, listener: (payload: unknown) => void): Promise<Unlisten> {
12
- const options =
13
- event === TRANSFER_CLIENT_CHANGED_EVENT
14
- ? { target: getCurrentWebviewWindow().label }
15
- : undefined;
16
- return listen(event, ({ payload }) => listener(payload), options);
17
- }
18
- }
@@ -1,9 +0,0 @@
1
- import { invoke } from "@tauri-apps/api/core";
2
-
3
- import type { InvokeTransport } from "@inflatable-cookie/longhorn/core";
4
-
5
- export class TauriTransport implements InvokeTransport {
6
- invoke(command: string, arguments_: Record<string, unknown>): Promise<unknown> {
7
- return invoke(command, arguments_);
8
- }
9
- }
package/src/update.ts DELETED
@@ -1,74 +0,0 @@
1
- import { isEventTransport } from "@inflatable-cookie/longhorn/core";
2
- import type { EventTransport, InvokeTransport } from "@inflatable-cookie/longhorn/core";
3
- import type {
4
- UpdateApplyCommand,
5
- UpdateCancelCommand,
6
- UpdateCheckCommand,
7
- UpdateDeferCommand,
8
- UpdatePort,
9
- UpdatePrepareCommand,
10
- UpdateSelectChannelCommand,
11
- UpdateUnlisten,
12
- } from "@inflatable-cookie/longhorn/update";
13
- export const UPDATE_SNAPSHOT_COMMAND = "longhorn_update_snapshot";
14
- export const UPDATE_CHECK_COMMAND = "longhorn_update_check";
15
- export const UPDATE_SELECT_CHANNEL_COMMAND = "longhorn_update_select_channel";
16
- export const UPDATE_DEFER_COMMAND = "longhorn_update_defer";
17
- export const UPDATE_PREPARE_COMMAND = "longhorn_update_prepare";
18
- export const UPDATE_APPLY_COMMAND = "longhorn_update_apply";
19
- export const UPDATE_CANCEL_COMMAND = "longhorn_update_cancel";
20
- export const UPDATE_CHANGED_EVENT = "longhorn://update/changed";
21
- export const UPDATE_PROGRESS_EVENT = "longhorn://update/progress";
22
- /**
23
- * The update seam.
24
- *
25
- * Seven commands and two events, mirroring the staged `UpdateController`.
26
- * Each is its own invoke because each is its own capability on the host side:
27
- * reading state, reaching the network, changing what this install follows,
28
- * staging verified bytes, replacing the running application, and discarding
29
- * what was staged are six different grants.
30
- *
31
- * `UPDATE_PROGRESS_EVENT` carries a progress value rather than an invalidation
32
- * hint, because the host does not hold the authority lock across the transfer
33
- * and a snapshot read mid-transfer cannot show the bytes.
34
- *
35
- * Results are `unknown`, as every other raw port's are. What comes back over a
36
- * transport is untrusted until a validator says otherwise; `UpdateClient` is
37
- * what narrows them. Commands going *out* are typed, because those this side
38
- * constructs.
39
- */
40
- export function createTauriUpdatePort(options: {
41
- readonly transport: InvokeTransport;
42
- }): UpdatePort {
43
- const events = isEventTransport(options.transport) ? options.transport : undefined;
44
- return {
45
- snapshot: () => options.transport.invoke(UPDATE_SNAPSHOT_COMMAND, {}),
46
- check: (command: UpdateCheckCommand) =>
47
- options.transport.invoke(UPDATE_CHECK_COMMAND, { command }),
48
- selectChannel: (command: UpdateSelectChannelCommand) =>
49
- options.transport.invoke(UPDATE_SELECT_CHANNEL_COMMAND, { command }),
50
- defer: (command: UpdateDeferCommand) =>
51
- options.transport.invoke(UPDATE_DEFER_COMMAND, { command }),
52
- prepare: (command: UpdatePrepareCommand) =>
53
- options.transport.invoke(UPDATE_PREPARE_COMMAND, { command }),
54
- apply: (command: UpdateApplyCommand) =>
55
- options.transport.invoke(UPDATE_APPLY_COMMAND, { command }),
56
- cancel: (command: UpdateCancelCommand) =>
57
- options.transport.invoke(UPDATE_CANCEL_COMMAND, { command }),
58
- listen:
59
- events === undefined
60
- ? undefined
61
- : (listener) => listen(events, UPDATE_CHANGED_EVENT, listener),
62
- listenProgress:
63
- events === undefined
64
- ? undefined
65
- : (listener) => listen(events, UPDATE_PROGRESS_EVENT, listener),
66
- };
67
- }
68
- function listen(
69
- events: EventTransport,
70
- event: string,
71
- listener: (event: unknown) => void,
72
- ): Promise<UpdateUnlisten> {
73
- return events.listen(event, listener);
74
- }