This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathtypes.ts
138 lines (138 loc) · 3.07 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import type { DeviceModel, DeviceModelId } from "@ledgerhq/devices";
import type { Observable, Subject } from "rxjs";
import type { CryptoCurrency } from "../types/currencies";
import type { App, DeviceInfo, FinalFirmware } from "../types/manager";
export type Exec = (
appOp: AppOp,
targetId: string | number,
app: App
) => Observable<{
progress: number;
}>;
export type InstalledItem = {
name: string;
updated: boolean;
hash: string;
blocks: number;
version: string;
availableVersion: string;
};
export type ListAppsEvent =
| {
type: "device-permission-requested";
wording: string;
}
| {
type: "device-permission-granted";
}
| {
type: "result";
result: ListAppsResult;
};
export type ListAppsResult = {
appByName: Record<string, App>;
appsListNames: string[];
installedAvailable: boolean;
installed: InstalledItem[];
deviceInfo: DeviceInfo;
deviceModelId: DeviceModelId;
firmware: FinalFirmware | null | undefined;
};
export type State = {
deviceInfo: DeviceInfo;
deviceModel: DeviceModel;
firmware: FinalFirmware | null | undefined;
appByName: Record<string, App>;
apps: App[];
installedAvailable: boolean;
installed: InstalledItem[];
recentlyInstalledApps: string[];
installQueue: string[];
uninstallQueue: string[];
// queue saved at the time of a "updateAll" action
updateAllQueue: string[];
currentAppOp: AppOp | null | undefined;
currentProgressSubject: Subject<number> | null | undefined;
currentError:
| {
error: Error;
appOp: AppOp;
}
| null
| undefined;
};
export type AppOp =
| {
type: "install";
name: string;
}
| {
type: "uninstall";
name: string;
};
export type Action = // recover from an error
| {
type: "recover";
} // wipe will remove all apps of the device
| {
type: "wipe";
} // uninstall a specific app by name
| {
type: "uninstall";
name: string;
force?: boolean;
} // install or update a specific app by name
| {
type: "install";
name: string;
} // update all
| {
type: "updateAll";
} // action to run after an update was done on the device (uninstall/install)
| {
type: "onRunnerEvent";
event: RunnerEvent;
};
export type RunnerEvent =
| {
type: "runStart";
appOp: AppOp;
}
| {
type: "runProgress";
appOp: AppOp;
progress: number;
}
| {
type: "runError";
appOp: AppOp;
error: Error;
}
| {
type: "runSuccess";
appOp: AppOp;
};
export type AppData = {
currency: CryptoCurrency | null | undefined;
name: string;
blocks: number;
bytes: number;
};
export type UnrecognizedAppData = {
name: string;
hash: string;
};
export type AppsDistribution = {
totalBlocks: number;
totalBytes: number;
osBlocks: number;
osBytes: number;
apps: Array<AppData>;
appsSpaceBlocks: number;
appsSpaceBytes: number;
totalAppsBlocks: number;
totalAppsBytes: number;
freeSpaceBlocks: number;
freeSpaceBytes: number;
shouldWarnMemory: boolean;
};