@prozilla-os/terminal 1.1.21 → 1.1.23
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/dist/main.d.ts +1602 -64
- package/dist/main.js +744 -7
- package/dist/main.js.map +1 -1
- package/package.json +10 -9
- package/dist/chunks/cat-DGK7wWrK.js +0 -16
- package/dist/chunks/cat-DGK7wWrK.js.map +0 -1
- package/dist/chunks/cd-DvjkW_6o.js +0 -15
- package/dist/chunks/cd-DvjkW_6o.js.map +0 -1
- package/dist/chunks/clear-BF9eb1Dq.js +0 -14
- package/dist/chunks/clear-BF9eb1Dq.js.map +0 -1
- package/dist/chunks/cmatrix-VYovsHQW.js +0 -59
- package/dist/chunks/cmatrix-VYovsHQW.js.map +0 -1
- package/dist/chunks/compgen-3TwdgHm_.js +0 -13
- package/dist/chunks/compgen-3TwdgHm_.js.map +0 -1
- package/dist/chunks/cowsay-IfArfPSJ.js +0 -49
- package/dist/chunks/cowsay-IfArfPSJ.js.map +0 -1
- package/dist/chunks/dir-B_Ipo5xb.js +0 -11
- package/dist/chunks/dir-B_Ipo5xb.js.map +0 -1
- package/dist/chunks/echo-DX-Ar2Ut.js +0 -11
- package/dist/chunks/echo-DX-Ar2Ut.js.map +0 -1
- package/dist/chunks/eval-C7InkmFY.js +0 -14
- package/dist/chunks/eval-C7InkmFY.js.map +0 -1
- package/dist/chunks/exit-D7PPqtiE.js +0 -11
- package/dist/chunks/exit-D7PPqtiE.js.map +0 -1
- package/dist/chunks/fortune-zyxpnYNP.js +0 -59
- package/dist/chunks/fortune-zyxpnYNP.js.map +0 -1
- package/dist/chunks/help-BEgNbwLL.js +0 -17
- package/dist/chunks/help-BEgNbwLL.js.map +0 -1
- package/dist/chunks/history-l0sNRNKZ.js +0 -2
- package/dist/chunks/history-l0sNRNKZ.js.map +0 -1
- package/dist/chunks/hostname-DU1lQde2.js +0 -11
- package/dist/chunks/hostname-DU1lQde2.js.map +0 -1
- package/dist/chunks/lolcat-5-mBWD9l.js +0 -35
- package/dist/chunks/lolcat-5-mBWD9l.js.map +0 -1
- package/dist/chunks/ls-DnkSPHVM.js +0 -18
- package/dist/chunks/ls-DnkSPHVM.js.map +0 -1
- package/dist/chunks/main-CXiltWT-.js +0 -957
- package/dist/chunks/main-CXiltWT-.js.map +0 -1
- package/dist/chunks/make-DqVQDThH.js +0 -9
- package/dist/chunks/make-DqVQDThH.js.map +0 -1
- package/dist/chunks/man-D_hBUTDt.js +0 -47
- package/dist/chunks/man-D_hBUTDt.js.map +0 -1
- package/dist/chunks/mkdir-BCvMrPTX.js +0 -11
- package/dist/chunks/mkdir-BCvMrPTX.js.map +0 -1
- package/dist/chunks/neofetch-BFHOITJj.js +0 -40
- package/dist/chunks/neofetch-BFHOITJj.js.map +0 -1
- package/dist/chunks/pwd-C21tQanw.js +0 -11
- package/dist/chunks/pwd-C21tQanw.js.map +0 -1
- package/dist/chunks/reboot-C2t7a3Av.js +0 -11
- package/dist/chunks/reboot-C2t7a3Av.js.map +0 -1
- package/dist/chunks/reload-C9o_dGZw.js +0 -10
- package/dist/chunks/reload-C9o_dGZw.js.map +0 -1
- package/dist/chunks/rev-CBibYebM.js +0 -11
- package/dist/chunks/rev-CBibYebM.js.map +0 -1
- package/dist/chunks/rm-ChTrwld4.js +0 -12
- package/dist/chunks/rm-ChTrwld4.js.map +0 -1
- package/dist/chunks/rmdir-CUM4xt2w.js +0 -11
- package/dist/chunks/rmdir-CUM4xt2w.js.map +0 -1
- package/dist/chunks/sl-DrATMkz6.js +0 -166
- package/dist/chunks/sl-DrATMkz6.js.map +0 -1
- package/dist/chunks/touch-CqBIAjMe.js +0 -19
- package/dist/chunks/touch-CqBIAjMe.js.map +0 -1
- package/dist/chunks/uptime-xM-0FRzA.js +0 -11
- package/dist/chunks/uptime-xM-0FRzA.js.map +0 -1
- package/dist/chunks/whatis-vXemLo9m.js +0 -13
- package/dist/chunks/whatis-vXemLo9m.js.map +0 -1
- package/dist/chunks/whoami-CnUR69yX.js +0 -11
- package/dist/chunks/whoami-CnUR69yX.js.map +0 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,99 +1,1008 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
|
+
import { UaEventOptions } from 'react-ga4/types/ga4';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An application that can be ran by ProzillaOS.
|
|
7
|
+
*
|
|
8
|
+
* Applications can be installed by adding them to {@link AppsConfig.apps}.
|
|
9
|
+
* @typeParam AppProps - The props of the {@link windowContent} of this app.
|
|
10
|
+
*/
|
|
11
|
+
declare class App<AppProps extends WindowProps = WindowProps> {
|
|
12
|
+
/**
|
|
13
|
+
* The display name of this application.
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The unique ID of this application.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Main component that renders this app inside a window.
|
|
22
|
+
*/
|
|
23
|
+
windowContent: FC<AppProps> | null;
|
|
24
|
+
/**
|
|
25
|
+
* Default options that get passed to the {@link App.windowContent} component.
|
|
26
|
+
*/
|
|
27
|
+
windowOptions?: Partial<AppProps> & DefaultWindowOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Description of this application.
|
|
30
|
+
*/
|
|
31
|
+
description: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* URL of the icon of this application.
|
|
34
|
+
*/
|
|
35
|
+
iconUrl: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Defines what the app can handle and how it can be used elsewhere in the system.
|
|
38
|
+
*/
|
|
39
|
+
role: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* An array of file extensions that this application can interpret.
|
|
42
|
+
*/
|
|
43
|
+
associatedExtensions: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Determines whether the app is pinned by default.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
pinnedByDefault: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Determines whether the app is launched at startup.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
launchAtStartup: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The category the app belongs to.
|
|
56
|
+
*/
|
|
57
|
+
category: typeof APP_CATEGORIES[number] | null;
|
|
58
|
+
/**
|
|
59
|
+
* Metadata of the app's package.
|
|
60
|
+
*/
|
|
61
|
+
metadata: AppMetadata | null;
|
|
62
|
+
/**
|
|
63
|
+
* Determines whether a desktop icon is added to the default data.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
showDesktopIcon: boolean;
|
|
67
|
+
isActive: boolean;
|
|
68
|
+
isPinned?: boolean;
|
|
69
|
+
isInstalled: boolean;
|
|
70
|
+
constructor(name: App["name"], id: App["id"], windowContent: App<AppProps>["windowContent"], windowOptions?: Partial<AppProps> & DefaultWindowOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Returns the component that renders the content of a window for this app.
|
|
73
|
+
*/
|
|
74
|
+
WindowContent: (props: AppProps) => JSX_2.Element | null;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the display name of this application.
|
|
77
|
+
*/
|
|
78
|
+
setName(name: string): this;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the description of this application.
|
|
81
|
+
*/
|
|
82
|
+
setDescription(description: App["description"]): this;
|
|
83
|
+
/**
|
|
84
|
+
* Sets the URL of the icon of this application.
|
|
85
|
+
*/
|
|
86
|
+
setIconUrl(iconUrl: App["iconUrl"]): this;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the role of this application.
|
|
89
|
+
*/
|
|
90
|
+
setRole(role: string | null): this;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the associated extensions of this application.
|
|
93
|
+
*/
|
|
94
|
+
setAssociatedExtensions(extensions: string[] | null): this;
|
|
95
|
+
/**
|
|
96
|
+
* Changes whether this application is pinned by default or not.
|
|
97
|
+
*/
|
|
98
|
+
setPinnedByDefault(pinnedByDefault: boolean): this;
|
|
99
|
+
/**
|
|
100
|
+
* Changes whether this application is launched at startup or not.
|
|
101
|
+
*/
|
|
102
|
+
setLaunchAtStartup(launchAtStartup: boolean): this;
|
|
103
|
+
/**
|
|
104
|
+
* Changes whether this application is installed by default or not.
|
|
105
|
+
*/
|
|
106
|
+
setInstalled(installed: boolean): this;
|
|
107
|
+
/**
|
|
108
|
+
* Sets the category this application belongs to.
|
|
109
|
+
*/
|
|
110
|
+
setCategory(category: typeof APP_CATEGORIES[number] | null): this;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the metadata for this application.
|
|
113
|
+
*/
|
|
114
|
+
setMetadata(metadata: AppMetadata | null): this;
|
|
115
|
+
/**
|
|
116
|
+
* Changes whether this application has a desktop icon in the default data.
|
|
117
|
+
*/
|
|
118
|
+
setShowDesktopIcon(showDesktopIcon: boolean): this;
|
|
119
|
+
/**
|
|
120
|
+
* Sets the default options for the {@link App.windowContent} component.
|
|
121
|
+
*/
|
|
122
|
+
setWindowOptions(windowOptions: Partial<AppProps> & DefaultWindowOptions): this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare const APP_CATEGORIES: readonly ["Business", "Developer tools", "Education", "Entertainment", "Food & dining", "Health & fitness", "Kids & family", "Lifestyle", "Media", "Medical", "Multimedia design", "Music", "Navigation & maps", "News & weather", "Personal finance", "Personalization", "Photo & video", "Productivity", "Security", "Shopping", "Social", "Sports", "Travel", "Utilities & tools"];
|
|
126
|
+
|
|
127
|
+
declare interface AppMetadata {
|
|
128
|
+
name: string;
|
|
129
|
+
version: `${number}.${number}.${number}`;
|
|
130
|
+
author: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare class AppsConfig {
|
|
134
|
+
apps: AppsConfigOptions["apps"];
|
|
135
|
+
static APP_ROLES: {
|
|
136
|
+
fileExplorer: string;
|
|
137
|
+
terminal: string;
|
|
138
|
+
textEditor: string;
|
|
139
|
+
settings: string;
|
|
140
|
+
mediaViewer: string;
|
|
141
|
+
browser: string;
|
|
142
|
+
};
|
|
143
|
+
constructor(options?: Partial<AppsConfigOptions>);
|
|
144
|
+
get installedApps(): App<WindowProps>[];
|
|
145
|
+
/**
|
|
146
|
+
* @param id - The ID of the app.
|
|
147
|
+
* @param includeUninstalled - Include apps that are not currently installed.
|
|
148
|
+
*/
|
|
149
|
+
getAppById(id: string, includeUninstalled?: boolean): App | null;
|
|
150
|
+
/**
|
|
151
|
+
* Get the app associated with a file extension.
|
|
152
|
+
*/
|
|
153
|
+
getAppByFileExtension(fileExtension: string): App | null;
|
|
154
|
+
/**
|
|
155
|
+
* Get the app with a specific role.
|
|
156
|
+
*/
|
|
157
|
+
getAppByRole(role: string): App | null;
|
|
158
|
+
/**
|
|
159
|
+
* Get all applications (including uninstalled apps) that belong to a category.
|
|
160
|
+
*/
|
|
161
|
+
getAppsByCategory(category: typeof APP_CATEGORIES[number]): App[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare interface AppsConfigOptions {
|
|
165
|
+
/**
|
|
166
|
+
* An array of applications.
|
|
167
|
+
*/
|
|
168
|
+
apps: App<WindowProps>[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A function that handles an event asynchronously.
|
|
173
|
+
* @typeParam T - A record of all events.
|
|
174
|
+
* @typeParam K - The event this function handles.
|
|
175
|
+
*/
|
|
176
|
+
declare type AsyncListener<T extends Record<keyof T, unknown[]>, K extends keyof T> = (...args: T[K]) => Promise<void>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Defines a shell command, including its execution logic, arguments requirements, and manual page.
|
|
180
|
+
*/
|
|
181
|
+
declare class Command {
|
|
12
182
|
#private;
|
|
13
183
|
options: Option_2[];
|
|
14
184
|
manual?: Manual;
|
|
15
185
|
requireArgs?: boolean;
|
|
16
186
|
requireOptions?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The core logic to run when the command is invoked.
|
|
189
|
+
*/
|
|
17
190
|
execute: Execute;
|
|
191
|
+
/**
|
|
192
|
+
* Sets the command name and initializes the default usage string if not already set.
|
|
193
|
+
*/
|
|
18
194
|
setName(name?: string): Command;
|
|
19
195
|
get name(): string;
|
|
20
196
|
setExecute(execute: Execute): Command;
|
|
21
197
|
setRequireArgs(value: boolean): Command;
|
|
22
198
|
setRequireOptions(value: boolean): Command;
|
|
23
199
|
setManual({ purpose, usage, description, options }: Manual): Command;
|
|
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
|
-
username?: string;
|
|
49
|
-
hostname?: string;
|
|
50
|
-
rawInputValue?: string;
|
|
51
|
-
options?: string[];
|
|
52
|
-
exit?: () => void;
|
|
53
|
-
inputs?: Record<string, string>;
|
|
54
|
-
timestamp: number;
|
|
55
|
-
settingsManager: SettingsManager;
|
|
56
|
-
systemManager: SystemManager;
|
|
57
|
-
app: App;
|
|
58
|
-
};
|
|
200
|
+
/**
|
|
201
|
+
* Registers a new option/flag for this command.
|
|
202
|
+
*/
|
|
203
|
+
addOption({ short, long, isInput }: Omit<Option_2, "isInput"> & {
|
|
204
|
+
isInput?: boolean;
|
|
205
|
+
}): Command;
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves an option definition by either its short or long name.
|
|
208
|
+
*/
|
|
209
|
+
getOption(key: string): Option_2 | undefined;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare type CommandOutput = number | undefined | void;
|
|
213
|
+
|
|
214
|
+
declare interface DefaultWindowOptions {
|
|
215
|
+
size?: Vector2;
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare class DesktopConfig {
|
|
220
|
+
defaultIconSize: DesktopConfigOptions["defaultIconSize"];
|
|
221
|
+
defaultIconDirection: DesktopConfigOptions["defaultIconDirection"];
|
|
222
|
+
constructor(options?: Partial<DesktopConfigOptions>);
|
|
223
|
+
}
|
|
59
224
|
|
|
225
|
+
declare interface DesktopConfigOptions {
|
|
226
|
+
/**
|
|
227
|
+
* The default size of the icons.
|
|
228
|
+
* @default 1
|
|
229
|
+
*/
|
|
230
|
+
defaultIconSize: 0 | 1 | 2;
|
|
231
|
+
/**
|
|
232
|
+
* The defailt direction of the icons
|
|
233
|
+
* 0: vertical, 1: horizontal.
|
|
234
|
+
* @default 0
|
|
235
|
+
* */
|
|
236
|
+
defaultIconDirection: 0 | 1;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A simple event emitter.
|
|
241
|
+
* @typeParam T - A record of all events.
|
|
242
|
+
*/
|
|
243
|
+
declare class EventEmitter<T extends Record<keyof T, unknown[]>> {
|
|
244
|
+
#private;
|
|
245
|
+
/**
|
|
246
|
+
* Starts listening to an event.
|
|
247
|
+
* @param event - The event to listen to.
|
|
248
|
+
* @param listener - The function to call when the event is emitted.
|
|
249
|
+
* @returns The listener.
|
|
250
|
+
*/
|
|
251
|
+
on<K extends keyof T>(event: K, listener: Listener<T, K>): Listener<T, K>;
|
|
252
|
+
/**
|
|
253
|
+
* Registers an event listener that is automatically removed when called.
|
|
254
|
+
* @param event - The event to listen to.
|
|
255
|
+
* @param listener - The function to call once the event is emitted.
|
|
256
|
+
* @returns The wrapped listener.
|
|
257
|
+
*/
|
|
258
|
+
once<K extends keyof T>(event: K, listener: Listener<T, K>): Listener<T, K>;
|
|
259
|
+
/**
|
|
260
|
+
* Starts listening to an event.
|
|
261
|
+
* @param event - The event to listen to.
|
|
262
|
+
* @param listener - The function to call when the event is emitted.
|
|
263
|
+
* @returns The wrapped listener.
|
|
264
|
+
*/
|
|
265
|
+
onAsync<K extends keyof T>(event: K, listener: AsyncListener<T, K>, onRejected?: Parameters<Promise<void>["catch"]>[0]): Listener<T, K>;
|
|
266
|
+
/**
|
|
267
|
+
* Removes an event listener.
|
|
268
|
+
* @param event - The event to remove the listener from.
|
|
269
|
+
* @param listener - The listener to remove.
|
|
270
|
+
*/
|
|
271
|
+
off<K extends keyof T>(event: K, listener: Listener<T, K>): void;
|
|
272
|
+
/**
|
|
273
|
+
* Emits an event to all its listeners.
|
|
274
|
+
* @param event - The event to emit.
|
|
275
|
+
* @param args - The arguments to pass to the listeners.
|
|
276
|
+
*/
|
|
277
|
+
emit<K extends keyof T>(event: K, ...args: T[K]): void;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare type Execute = (args: string[], context: ShellContext) => Promise<CommandOutput> | CommandOutput;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Represents a single entry in the shell's output history.
|
|
284
|
+
*/
|
|
60
285
|
declare interface HistoryEntry {
|
|
286
|
+
/** The text content to display. */
|
|
61
287
|
text?: string;
|
|
62
|
-
|
|
288
|
+
/** Whether this entry represents a user-inputted command. */
|
|
289
|
+
isCommand: boolean;
|
|
290
|
+
/** The raw string value of the command. */
|
|
63
291
|
value?: string;
|
|
292
|
+
/** If true, the terminal view should be cleared before rendering this entry. */
|
|
64
293
|
clear?: boolean;
|
|
65
294
|
}
|
|
66
295
|
|
|
67
|
-
|
|
296
|
+
/**
|
|
297
|
+
* A function that handles an event.
|
|
298
|
+
* @typeParam T - A record of all events.
|
|
299
|
+
* @typeParam K - The event this function handles.
|
|
300
|
+
*/
|
|
301
|
+
declare type Listener<T extends Record<keyof T, unknown[]>, K extends keyof T> = (...args: T[K]) => void;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Documentation metadata used by the `help` or `man` commands.
|
|
305
|
+
*/
|
|
306
|
+
declare interface Manual {
|
|
307
|
+
/** A brief one-line summary of what the command does. */
|
|
68
308
|
purpose?: string;
|
|
309
|
+
/** A string representing the syntax (e.g., "ls [OPTION]... [FILE]..."). */
|
|
69
310
|
usage?: string;
|
|
311
|
+
/** A detailed explanation of the command's behavior. */
|
|
70
312
|
description?: string;
|
|
313
|
+
/** A mapping of option names to their descriptions for the help output. */
|
|
71
314
|
options?: object;
|
|
72
|
-
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
declare class MiscConfig {
|
|
318
|
+
doubleClickDelay: MiscConfigOptions["doubleClickDelay"];
|
|
319
|
+
constructor(options?: Partial<MiscConfigOptions>);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
declare interface MiscConfigOptions {
|
|
323
|
+
/**
|
|
324
|
+
* The maximum time between two clicks to register as a double click (in ms).
|
|
325
|
+
* @default 250
|
|
326
|
+
* */
|
|
327
|
+
doubleClickDelay: number;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
declare class ModalsConfig {
|
|
331
|
+
defaultDialogSize: ModalsConfigOptions["defaultDialogSize"];
|
|
332
|
+
defaultFileSelectorSize: ModalsConfigOptions["defaultFileSelectorSize"];
|
|
333
|
+
static DIALOG_CONTENT_TYPES: {
|
|
334
|
+
closeButton: number;
|
|
335
|
+
};
|
|
336
|
+
constructor(options?: Partial<ModalsConfigOptions>);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare interface ModalsConfigOptions {
|
|
340
|
+
/**
|
|
341
|
+
* Default size of a dialog box.
|
|
342
|
+
* @default new Vector2(400, 200)
|
|
343
|
+
*/
|
|
344
|
+
defaultDialogSize: Vector2;
|
|
345
|
+
/**
|
|
346
|
+
* Default size of a file selector.
|
|
347
|
+
* @default new Vector2(700, 400)
|
|
348
|
+
*/
|
|
349
|
+
defaultFileSelectorSize: Vector2;
|
|
350
|
+
}
|
|
73
351
|
|
|
74
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Represents a command-line flag or parameter.
|
|
354
|
+
*/
|
|
355
|
+
declare interface Option_2 {
|
|
356
|
+
/** The full name of the option (e.g., "all" for --all). */
|
|
75
357
|
long: string;
|
|
358
|
+
/** The single-character alias (e.g., "a" for -a). */
|
|
76
359
|
short: string;
|
|
360
|
+
/** If true, the shell expects a value to follow this option (e.g., --file <name>). */
|
|
77
361
|
isInput: boolean;
|
|
78
|
-
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
declare type OptionalStringProperty = string | null | undefined;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Represents an active or pending process within the shell.
|
|
368
|
+
*/
|
|
369
|
+
declare interface Process extends ProcessIO {
|
|
370
|
+
/** The executable name or alias being invoked. */
|
|
371
|
+
commandName: string;
|
|
372
|
+
/** Array of string arguments passed to the command. */
|
|
373
|
+
args: string[];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Standard input, output, and error streams for a process.
|
|
378
|
+
*/
|
|
379
|
+
declare interface ProcessIO {
|
|
380
|
+
/** The stream used to receive input data. */
|
|
381
|
+
stdin: Stream;
|
|
382
|
+
/** The stream used to output standard data. */
|
|
383
|
+
stdout: Stream;
|
|
384
|
+
/** The stream used to output error messages. */
|
|
385
|
+
stderr: Stream;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare class Settings {
|
|
389
|
+
#private;
|
|
390
|
+
/**
|
|
391
|
+
* The virtual path of the settings file.
|
|
392
|
+
*/
|
|
393
|
+
path: string;
|
|
394
|
+
/**
|
|
395
|
+
* The settings file.
|
|
396
|
+
*/
|
|
397
|
+
file: VirtualFile | null;
|
|
398
|
+
xmlDoc?: Document;
|
|
399
|
+
/**
|
|
400
|
+
* Virtual path to the desktop settings.
|
|
401
|
+
*/
|
|
402
|
+
static readonly DESKTOP: string;
|
|
403
|
+
/**
|
|
404
|
+
* Virtual path to the taskbar settings.
|
|
405
|
+
*/
|
|
406
|
+
static readonly TASKBAR: string;
|
|
407
|
+
/**
|
|
408
|
+
* Virtual path to the apps settings.
|
|
409
|
+
*/
|
|
410
|
+
static readonly APPS: string;
|
|
411
|
+
/**
|
|
412
|
+
* Virtual path to the theme settings.
|
|
413
|
+
*/
|
|
414
|
+
static readonly THEME: string;
|
|
415
|
+
/**
|
|
416
|
+
* Virtual path to the virtual drive settings.
|
|
417
|
+
*/
|
|
418
|
+
static readonly VIRTUAL_DRIVE: string;
|
|
419
|
+
constructor(virtualRoot: VirtualRoot, path: string);
|
|
420
|
+
/**
|
|
421
|
+
* Reads the xml doc from the given path and assigns it to itself.
|
|
422
|
+
*/
|
|
423
|
+
read(): Promise<void>;
|
|
424
|
+
write(): void;
|
|
425
|
+
/**
|
|
426
|
+
* Checks if xml doc is missing.
|
|
427
|
+
*/
|
|
428
|
+
isMissingXmlDoc(): Promise<boolean>;
|
|
429
|
+
/**
|
|
430
|
+
* Gets a value by a given key if it exists and optionally calls a callback function whenever the value changes.
|
|
431
|
+
* @param key - The key of the setting.
|
|
432
|
+
* @param callback - The callback function to call whenever the value changes.
|
|
433
|
+
*/
|
|
434
|
+
get(key: string, callback?: (value: string) => void): Promise<{
|
|
435
|
+
value: string | null;
|
|
436
|
+
listener?: SettingsListener;
|
|
437
|
+
}>;
|
|
438
|
+
/**
|
|
439
|
+
* Gets a value by a given key as a boolean.
|
|
440
|
+
*/
|
|
441
|
+
getBool(key: string, callback?: (value: boolean) => void): Promise<{
|
|
442
|
+
value: boolean | null;
|
|
443
|
+
listener?: SettingsListener;
|
|
444
|
+
}>;
|
|
445
|
+
/**
|
|
446
|
+
* Gets a value by a given key as an integer.
|
|
447
|
+
*/
|
|
448
|
+
getInt(key: string, callback?: (value: number) => void): Promise<{
|
|
449
|
+
value: number | null;
|
|
450
|
+
listener?: SettingsListener;
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Sets the value associated with a given key.
|
|
454
|
+
* @param key - The key of the setting.
|
|
455
|
+
* @param value - The new value.
|
|
456
|
+
*/
|
|
457
|
+
set(key: string, value: string): Promise<void>;
|
|
458
|
+
/**
|
|
459
|
+
* Removes a listener from the settings file.
|
|
460
|
+
* @param listener - The listener to remove.
|
|
461
|
+
*/
|
|
462
|
+
removeListener(listener: SettingsListener): void;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
declare type SettingsListener = Listener<VirtualFileEvents, "contentChange">;
|
|
466
|
+
|
|
467
|
+
declare class SettingsManager {
|
|
468
|
+
#private;
|
|
469
|
+
/**
|
|
470
|
+
* @deprecated - Use constants from {@link Settings} instead.
|
|
471
|
+
*/
|
|
472
|
+
static VIRTUAL_PATHS: {
|
|
473
|
+
[s: string]: string;
|
|
474
|
+
};
|
|
475
|
+
constructor(virtualRoot: VirtualRoot);
|
|
476
|
+
getSettings(path: string): Settings;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* A Unix-like shell emulator that handles command parsing, environment management,
|
|
481
|
+
* autocompletion, and process I/O.
|
|
482
|
+
*/
|
|
483
|
+
declare class Shell {
|
|
484
|
+
/** The reactive state of this shell. */
|
|
485
|
+
state: ShellState;
|
|
486
|
+
/** The configuration used to initialize this shell. */
|
|
487
|
+
config: ShellConfig;
|
|
488
|
+
/** The environment variable manager for this shell. */
|
|
489
|
+
env: ShellEnvironment;
|
|
490
|
+
/** The logic handler for parsing and executing command strings. */
|
|
491
|
+
interpreter: ShellInterpreter;
|
|
492
|
+
static readonly COMMAND_NOT_FOUND_ERROR = "Command not found";
|
|
493
|
+
static readonly MISSING_ARGS_ERROR = "requires at least 1 argument";
|
|
494
|
+
static readonly MISSING_OPTIONS_ERROR = "requires at least 1 option";
|
|
495
|
+
static readonly COMMAND_FAILED_ERROR = "Command failed";
|
|
496
|
+
static readonly USAGE_ERROR = "Incorrect usage";
|
|
497
|
+
static readonly INVALID_PATH_ERROR = "No such file or directory";
|
|
498
|
+
static readonly SUDO_COMMAND = "sudo";
|
|
499
|
+
/** Regex used to strip specific ANSI escape codes from the TTY buffer. */
|
|
500
|
+
static readonly STRIP_ANSI_REGEX: RegExp;
|
|
501
|
+
constructor(config: ShellConfig);
|
|
502
|
+
/**
|
|
503
|
+
* Sends a signal to the shell or the currently active foreground process.
|
|
504
|
+
* @param signal - The signal to send. Defaults to `"SIGTERM"`.
|
|
505
|
+
*/
|
|
506
|
+
terminate(signal?: StreamSignal): void;
|
|
507
|
+
/**
|
|
508
|
+
* Convenience method to send the `SIGINT` (Interrupt) signal.
|
|
509
|
+
* @see {@link Shell.terminate}
|
|
510
|
+
*/
|
|
511
|
+
interrupt(): void;
|
|
512
|
+
/**
|
|
513
|
+
* Convenience method to send the `SIGKILL` (Kill) signal, closing the shell.
|
|
514
|
+
* @see {@link Shell.terminate}
|
|
515
|
+
*/
|
|
516
|
+
kill(): void;
|
|
517
|
+
/**
|
|
518
|
+
* Recalculates the prompt string based on the current user, hostname, and working directory.
|
|
519
|
+
*/
|
|
520
|
+
updatePrompt(): void;
|
|
521
|
+
/**
|
|
522
|
+
* Updates the text in the current input line.
|
|
523
|
+
* @param value - The new string value or a function that receives the previous value.
|
|
524
|
+
*/
|
|
525
|
+
setLine(value: string | ((prev: string) => string)): void;
|
|
526
|
+
/**
|
|
527
|
+
* Appends a new entry to the terminal history.
|
|
528
|
+
* @param entry - The history entry to add.
|
|
529
|
+
*/
|
|
530
|
+
pushHistory(entry: HistoryEntry): void;
|
|
531
|
+
/**
|
|
532
|
+
* Writes raw text to the shell, handling ANSI escape codes for screen clearing and alt buffers.
|
|
533
|
+
* @param text - The string data to write to the TTY.
|
|
534
|
+
*/
|
|
535
|
+
write(text: string): void;
|
|
536
|
+
/**
|
|
537
|
+
* Clears the current input line and executes the given command string.
|
|
538
|
+
* @param input - The command string to execute.
|
|
539
|
+
* @returns A promise that resolves with the final exit code of the execution.
|
|
540
|
+
*/
|
|
541
|
+
run(input: string): Promise<number>;
|
|
542
|
+
/**
|
|
543
|
+
* Clears the current input line and resets the history search offset.
|
|
544
|
+
*/
|
|
545
|
+
clearLine(): void;
|
|
546
|
+
/**
|
|
547
|
+
* Navigates through command history.
|
|
548
|
+
* @param direction - Positive to go back in time, negative to go forward.
|
|
549
|
+
*/
|
|
550
|
+
historySearch(direction: number): void;
|
|
551
|
+
/**
|
|
552
|
+
* Changes the current working directory and updates `PWD`/`OLDPWD` environment variables.
|
|
553
|
+
* @param directory - The virtual folder to switch to.
|
|
554
|
+
*/
|
|
555
|
+
setWorkingDirectory(directory: VirtualFolder): void;
|
|
556
|
+
/**
|
|
557
|
+
* Calculates possible completions for the current input based on commands and file paths.
|
|
558
|
+
* @returns An array of string suggestions.
|
|
559
|
+
*/
|
|
560
|
+
getCompletions(): string[];
|
|
561
|
+
/**
|
|
562
|
+
* Performs an auto-completion action. If one match is found, it completes the line.
|
|
563
|
+
* If multiple are found, it lists them in the history.
|
|
564
|
+
*/
|
|
565
|
+
autoComplete(): void;
|
|
566
|
+
/**
|
|
567
|
+
* Utility to write a formatted error message to a stream and return an exit code.
|
|
568
|
+
* @param stream - The stream to receive the error output.
|
|
569
|
+
* @param commandName - The name of the command reporting the error.
|
|
570
|
+
* @param error - A single string or array of strings representing the error message.
|
|
571
|
+
* @param exitCode - The numerical exit code to return.
|
|
572
|
+
* @returns `exitCode`.
|
|
573
|
+
*/
|
|
574
|
+
static writeError(stream: Stream, commandName: string, error?: string | string[], exitCode?: number): number;
|
|
575
|
+
/**
|
|
576
|
+
* Executes a frame-based animation in the terminal using the Alternate Screen Buffer.
|
|
577
|
+
* @returns A promise that resolves when the animation is stopped.
|
|
578
|
+
*/
|
|
579
|
+
static animate({ stdout, stdin, render, delay, clear, stopOnBlank }: Pick<ShellContext, "stdout" | "stdin"> & {
|
|
580
|
+
/** The function that renders each frame. */
|
|
581
|
+
render: (frame: number) => string;
|
|
582
|
+
/** The delay between each frame, in ms. */
|
|
583
|
+
delay: number;
|
|
584
|
+
/** Whether to clear the terminal before each frame. */
|
|
585
|
+
clear?: boolean;
|
|
586
|
+
/** Whether to stop the animation when the rendered frame is blank. */
|
|
587
|
+
stopOnBlank?: boolean;
|
|
588
|
+
}): Promise<0>;
|
|
589
|
+
/**
|
|
590
|
+
* Reads input data. If `rawLine` is provided, it processes it immediately via the callback.
|
|
591
|
+
* Otherwise, it waits for data from the `stdin` stream.
|
|
592
|
+
* @param rawLine - The pre-provided input string.
|
|
593
|
+
* @param stdin - The input stream to fall back on.
|
|
594
|
+
* @param callback - Function to process the collected input data.
|
|
595
|
+
*/
|
|
596
|
+
static readInput(rawLine: string, stdin: Stream, callback: (data: string) => CommandOutput): Promise<CommandOutput>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Configuration options for initializing a new Shell instance.
|
|
601
|
+
*/
|
|
602
|
+
declare interface ShellConfig {
|
|
603
|
+
/** The application instance that owns and manages this shell. */
|
|
604
|
+
app?: App;
|
|
605
|
+
/** The initial working directory path (e.g., "~" or "/bin"). */
|
|
606
|
+
path?: string;
|
|
607
|
+
/** A string to pre-fill the shell input with. */
|
|
608
|
+
input?: string;
|
|
609
|
+
virtualRoot: VirtualRoot;
|
|
610
|
+
systemManager: SystemManager;
|
|
611
|
+
settingsManager: SettingsManager;
|
|
612
|
+
/** Callback function to trigger when the shell process should be terminated. */
|
|
613
|
+
exit: () => void;
|
|
614
|
+
/** A reactive reference containing the current terminal dimensions in rows and columns. */
|
|
615
|
+
sizeRef: {
|
|
616
|
+
current: Vector2;
|
|
617
|
+
};
|
|
618
|
+
/** Optional initial environment variables to populate the shell with. */
|
|
619
|
+
env?: Record<string, string>;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* The context object provided to command execution functions.
|
|
624
|
+
*/
|
|
625
|
+
declare interface ShellContext extends ProcessIO {
|
|
626
|
+
/** Reference to the parent Shell instance. */
|
|
627
|
+
shell: Shell;
|
|
628
|
+
/** The directory where the command was executed. */
|
|
629
|
+
workingDirectory: VirtualFolder;
|
|
630
|
+
/** The name of the user executing the command. */
|
|
631
|
+
username: string;
|
|
632
|
+
/** The hostname of the virtual system. */
|
|
633
|
+
hostname: string;
|
|
634
|
+
/** The full, unparsed command line string (excluding pipes/redirects). */
|
|
635
|
+
rawLine: string;
|
|
636
|
+
/** Array of parsed flags in their short form (e.g., ["l", "a"]). */
|
|
637
|
+
options: string[];
|
|
638
|
+
/**
|
|
639
|
+
* Function to kill the shell session.
|
|
640
|
+
* @see {@link Shell.kill}
|
|
641
|
+
*/
|
|
642
|
+
exit: () => void;
|
|
643
|
+
/** Map of option keys in their short form to their provided values. */
|
|
644
|
+
inputs: Record<string, string>;
|
|
645
|
+
/** Millisecond timestamp of when the command was started. */
|
|
646
|
+
timestamp: number;
|
|
647
|
+
virtualRoot: VirtualRoot;
|
|
648
|
+
settingsManager: SettingsManager;
|
|
649
|
+
systemManager: SystemManager;
|
|
650
|
+
/** The owning application, if any. */
|
|
651
|
+
app?: App;
|
|
652
|
+
/** The current dimensions of the terminal window. */
|
|
653
|
+
readonly size: Vector2;
|
|
654
|
+
/** The scoped environment variables for this process. */
|
|
655
|
+
env: ShellEnvironment;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Manages environment variabels for {@link Shell}.
|
|
660
|
+
*/
|
|
661
|
+
declare class ShellEnvironment {
|
|
662
|
+
store: Record<string, string>;
|
|
663
|
+
parent: ShellEnvironment | null;
|
|
664
|
+
exportedKeys: Set<string>;
|
|
665
|
+
static readonly USER = "USER";
|
|
666
|
+
static readonly HOSTNAME = "HOSTNAME";
|
|
667
|
+
static readonly WORKING_DIRECTORY = "PWD";
|
|
668
|
+
static readonly PREVIOUS_WORKING_DIRECTORY = "OLDPWD";
|
|
669
|
+
static readonly EXIT_CODE = "?";
|
|
670
|
+
static readonly ARGUMENT_COUNT = "#";
|
|
671
|
+
static readonly PROCESS_ID = "$";
|
|
672
|
+
/** List of variables that should never be exported. */
|
|
673
|
+
static readonly INTERNAL_VARS: string[];
|
|
674
|
+
constructor(initialVars?: Record<string, string>, parent?: ShellEnvironment | null);
|
|
675
|
+
get(key: string): string | undefined;
|
|
676
|
+
set(key: string, value: string, isExported?: boolean): void;
|
|
677
|
+
/**
|
|
678
|
+
* Marks an existing variable as exported.
|
|
679
|
+
*/
|
|
680
|
+
export(key: string): void;
|
|
681
|
+
/**
|
|
682
|
+
* Replaces variable placeholders in a string with their corresponding values.
|
|
683
|
+
*/
|
|
684
|
+
expand(input: string): string;
|
|
685
|
+
/**
|
|
686
|
+
* Parses an assignment string (e.g., KEY=VALUE) and updates the environment.
|
|
687
|
+
* @returns `true` if the string was a valid assignment.
|
|
688
|
+
*/
|
|
689
|
+
parseAssignment(input: string): boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Returns only variables that are marked for export.
|
|
692
|
+
*/
|
|
693
|
+
get exportedVariables(): Record<string, string>;
|
|
694
|
+
/**
|
|
695
|
+
* Returns all variables visible to this scope (including internal).
|
|
696
|
+
*/
|
|
697
|
+
get variables(): Record<string, string>;
|
|
698
|
+
/**
|
|
699
|
+
* Creates a child scope for subshells or command execution.
|
|
700
|
+
*/
|
|
701
|
+
fork(): ShellEnvironment;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Handles the parsing, expansion, and execution of shell commands and scripts.
|
|
706
|
+
* Manages the process pipeline and stream redirection.
|
|
707
|
+
*/
|
|
708
|
+
declare class ShellInterpreter {
|
|
709
|
+
private shell;
|
|
710
|
+
pipeline: Process[];
|
|
711
|
+
constructor(shell: Shell);
|
|
712
|
+
/**
|
|
713
|
+
* Sends a termination signal to all processes currently in the pipeline.
|
|
714
|
+
* @param signal - The signal to send.
|
|
715
|
+
*/
|
|
716
|
+
terminatePipeline(signal: StreamSignal): void;
|
|
717
|
+
/**
|
|
718
|
+
* Parses and executes a shell script.
|
|
719
|
+
* @param script - The script content or a virtual file.
|
|
720
|
+
* @returns The exit code of the last command executed in the script.
|
|
721
|
+
*/
|
|
722
|
+
executeScript(script: string | VirtualFile): Promise<number>;
|
|
723
|
+
/**
|
|
724
|
+
* Parses and executes an input string, handling environment expansion and piping.
|
|
725
|
+
* @param input - The raw command line string.
|
|
726
|
+
* @param streams - Optional output streams to override default TTY behavior.
|
|
727
|
+
* @returns A promise that resolves with the final exit code of the execution.
|
|
728
|
+
*/
|
|
729
|
+
execute(input: string, streams?: {
|
|
730
|
+
stdout?: Stream;
|
|
731
|
+
stderr?: Stream;
|
|
732
|
+
}): Promise<number>;
|
|
733
|
+
/**
|
|
734
|
+
* Resolves a command, parses flags/options, and executes the command logic.
|
|
735
|
+
* @returns The resulting exit code from the command execution.
|
|
736
|
+
*/
|
|
737
|
+
spawn({ stdin, stdout, stderr, commandName, args }: Process): Promise<number>;
|
|
738
|
+
/**
|
|
739
|
+
* Splits a command string into an array of arguments, respecting single and double quotes.
|
|
740
|
+
*/
|
|
741
|
+
static parseCommand(input: string): string[];
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* The internal reactive state of the shell.
|
|
746
|
+
*/
|
|
747
|
+
declare interface ShellState {
|
|
748
|
+
/** An array of all past outputs and commands displayed in the terminal. */
|
|
749
|
+
history: HistoryEntry[];
|
|
750
|
+
/** The current, unsubmitted text in the input line. */
|
|
751
|
+
line: string;
|
|
752
|
+
/** Current position in the history search (0 is the current line). */
|
|
753
|
+
historyOffset: number;
|
|
754
|
+
/** The current directory the shell is operating within. */
|
|
755
|
+
workingDirectory: VirtualFolder;
|
|
756
|
+
/** The formatted prompt string (e.g., "user@host:~$ "). */
|
|
757
|
+
prompt: string;
|
|
758
|
+
/** The current active input stream for a running process. */
|
|
759
|
+
stream: Stream | null;
|
|
760
|
+
/** Temporary storage for data written to the terminal while a stream is active. */
|
|
761
|
+
ttyBuffer: string | null;
|
|
762
|
+
/** Indicates if a process has requested the Alternate Screen Buffer (e.g., a text editor). */
|
|
763
|
+
isUsingAltScreen: boolean;
|
|
764
|
+
/** A reactive view of the current environment variables. */
|
|
765
|
+
env: Record<string, string>;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
declare class Skin {
|
|
769
|
+
systemIcon: SkinOptions["systemIcon"];
|
|
770
|
+
appIcons: SkinOptions["appIcons"];
|
|
771
|
+
appNames: SkinOptions["appNames"];
|
|
772
|
+
wallpapers: SkinOptions["wallpapers"];
|
|
773
|
+
defaultWallpaper: SkinOptions["defaultWallpaper"];
|
|
774
|
+
fileIcons: SkinOptions["fileIcons"];
|
|
775
|
+
folderIcons: SkinOptions["folderIcons"];
|
|
776
|
+
loadStyleSheet: SkinOptions["loadStyleSheet"];
|
|
777
|
+
defaultTheme: SkinOptions["defaultTheme"];
|
|
778
|
+
constructor(options?: Partial<SkinOptions>);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
declare interface SkinOptions {
|
|
782
|
+
/**
|
|
783
|
+
* SVG icon for the system.
|
|
784
|
+
* @default
|
|
785
|
+
* "https://os.prozilla.dev/icon.svg"
|
|
786
|
+
*/
|
|
787
|
+
systemIcon: string;
|
|
788
|
+
/**
|
|
789
|
+
* Replacements for app icons based on app id.
|
|
790
|
+
*/
|
|
791
|
+
appIcons?: {
|
|
792
|
+
[key: string]: string;
|
|
793
|
+
};
|
|
794
|
+
/**
|
|
795
|
+
* Replacements for app names based on app id.
|
|
796
|
+
*/
|
|
797
|
+
appNames?: {
|
|
798
|
+
[key: string]: string;
|
|
799
|
+
};
|
|
800
|
+
/**
|
|
801
|
+
* Array of URLs of wallpaper images.
|
|
802
|
+
*/
|
|
803
|
+
wallpapers: string[];
|
|
804
|
+
/**
|
|
805
|
+
* URL of default wallpaper image.
|
|
806
|
+
* @default
|
|
807
|
+
* "https://os.prozilla.dev/assets/wallpapers/vibrant-wallpaper-blue-purple-red.png"
|
|
808
|
+
*/
|
|
809
|
+
defaultWallpaper: string;
|
|
810
|
+
/**
|
|
811
|
+
* URLs of icons for types of files.
|
|
812
|
+
*/
|
|
813
|
+
fileIcons: {
|
|
814
|
+
generic: string;
|
|
815
|
+
info?: string;
|
|
816
|
+
text?: string;
|
|
817
|
+
code?: string;
|
|
818
|
+
external?: string;
|
|
819
|
+
video?: string;
|
|
820
|
+
audio?: string;
|
|
821
|
+
};
|
|
822
|
+
/**
|
|
823
|
+
* URLs of icons for types of folders.
|
|
824
|
+
*/
|
|
825
|
+
folderIcons: {
|
|
826
|
+
generic: string;
|
|
827
|
+
images?: string;
|
|
828
|
+
text?: string;
|
|
829
|
+
link?: string;
|
|
830
|
+
video?: string;
|
|
831
|
+
audio?: string;
|
|
832
|
+
};
|
|
833
|
+
/**
|
|
834
|
+
* Function that dynamically imports style sheet.
|
|
835
|
+
*/
|
|
836
|
+
loadStyleSheet?: () => void;
|
|
837
|
+
/**
|
|
838
|
+
* Default theme.
|
|
839
|
+
*/
|
|
840
|
+
defaultTheme?: Theme;
|
|
841
|
+
}
|
|
79
842
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
843
|
+
/**
|
|
844
|
+
* A wrapper for {@link localStorage} with additional functionality like compression and a size limit.
|
|
845
|
+
*/
|
|
846
|
+
declare class Storage_2 {
|
|
847
|
+
/**
|
|
848
|
+
* Enables compression of values stored in this storage.
|
|
849
|
+
* @default false
|
|
850
|
+
*/
|
|
851
|
+
enableCompression: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* The prefix to prepend to keys.
|
|
854
|
+
* @default undefined
|
|
855
|
+
*/
|
|
856
|
+
prefix: string | undefined;
|
|
857
|
+
/**
|
|
858
|
+
* The maximum amount of bytes of a value in this storage.
|
|
859
|
+
*/
|
|
860
|
+
static readonly MAX_BYTES = 5000000;
|
|
861
|
+
static readonly COMPRESSED_PREFIX = "\uE000";
|
|
862
|
+
static readonly UNCOMPRESSED_PREFIX = "\uE001";
|
|
863
|
+
/**
|
|
864
|
+
* Stores a key and value pair in this storage.
|
|
865
|
+
* @param key - The key to store.
|
|
866
|
+
* @param value - The value to store.
|
|
867
|
+
*/
|
|
868
|
+
store(key: string, value: string): void;
|
|
869
|
+
/**
|
|
870
|
+
* Loads a value associated with the given key.
|
|
871
|
+
* @param key - The key of the item.
|
|
872
|
+
* @returns The value of the item.
|
|
873
|
+
*/
|
|
874
|
+
load(key: string): string | null;
|
|
875
|
+
/**
|
|
876
|
+
* Replaces the key of an item if it exists.
|
|
877
|
+
* @param oldKey - The key to replace.
|
|
878
|
+
* @param newKey - The new key.
|
|
879
|
+
*/
|
|
880
|
+
rename(oldKey: string, newKey: string): this;
|
|
881
|
+
/**
|
|
882
|
+
* Removes the item with the given key from this storage.
|
|
883
|
+
* @param key - The key of the item.
|
|
884
|
+
*/
|
|
885
|
+
remove(key: string): this;
|
|
886
|
+
/**
|
|
887
|
+
* Clears all items stored in this storage.
|
|
888
|
+
*/
|
|
889
|
+
clear(): this;
|
|
890
|
+
/**
|
|
891
|
+
* Returns the byte size of a key and value pair.
|
|
892
|
+
* @param key - The key of the item.
|
|
893
|
+
* @param value - The value of the item.
|
|
894
|
+
*/
|
|
895
|
+
getItemByteSize(key: string, value: string): number;
|
|
896
|
+
getEncodedByteSize(string: string | null): number;
|
|
897
|
+
encode(string: string): {
|
|
898
|
+
result: string;
|
|
899
|
+
size: number;
|
|
85
900
|
};
|
|
901
|
+
decode(string: string): string;
|
|
902
|
+
setPrefix(prefix?: string): this;
|
|
903
|
+
static getByteSize(string: string | null): number;
|
|
904
|
+
static byteToKilobyte(bytes: number): number;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* A communication channel for process I/O, supporting event-based data transmission,
|
|
909
|
+
* signaling, and piping between streams.
|
|
910
|
+
*/
|
|
911
|
+
declare class Stream<T = string> extends EventEmitter<StreamEvents<T>> {
|
|
86
912
|
enabled: boolean;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
913
|
+
static readonly DATA_EVENT = "data";
|
|
914
|
+
static readonly START_EVENT = "start";
|
|
915
|
+
static readonly STOP_EVENT = "stop";
|
|
916
|
+
static readonly SIGNAL_EVENT = "signal";
|
|
917
|
+
/**
|
|
918
|
+
* Activates the stream and notifies listeners.
|
|
919
|
+
*/
|
|
920
|
+
start(callback?: (stream: this) => void): this;
|
|
921
|
+
/**
|
|
922
|
+
* Deactivates the stream. Subsequent calls to {@link Stream.write} will be ignored.
|
|
923
|
+
*/
|
|
924
|
+
stop(): this;
|
|
925
|
+
/**
|
|
926
|
+
* Emits a control signal. Standard termination signals will automatically stop the stream.
|
|
927
|
+
*/
|
|
928
|
+
signal(signal: StreamSignal): this;
|
|
929
|
+
/**
|
|
930
|
+
* Broadcasts data to all listeners if the stream is enabled.
|
|
931
|
+
*/
|
|
932
|
+
write(data: T): this;
|
|
933
|
+
/**
|
|
934
|
+
* Forwards data, stop events, and signals from this stream to another.
|
|
935
|
+
* @param destination - The stream that will receive the forwarded data.
|
|
936
|
+
* @returns The destination stream to allow for chainable piping.
|
|
937
|
+
*/
|
|
938
|
+
pipe(destination: Stream<T>): Stream<T>;
|
|
939
|
+
/**
|
|
940
|
+
* Returns a promise that resolves when the stream is stopped.
|
|
941
|
+
*/
|
|
942
|
+
wait(): Promise<void>;
|
|
943
|
+
/**
|
|
944
|
+
* Returns a promise that resolves when the stream is stopped.
|
|
945
|
+
* @param value - Value to return when the promise resolves.
|
|
946
|
+
*/
|
|
947
|
+
wait<U>(value: U): Promise<U>;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
declare interface StreamEvents<T = string> {
|
|
951
|
+
data: [T];
|
|
952
|
+
start: [];
|
|
953
|
+
stop: [];
|
|
954
|
+
signal: [StreamSignal];
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
declare type StreamSignal = "SIGINT" | "SIGKILL" | "SIGTERM" | "SIGINFO";
|
|
958
|
+
|
|
959
|
+
declare class SystemManager {
|
|
960
|
+
#private;
|
|
961
|
+
/** The name of the system. */
|
|
962
|
+
readonly systemName: string;
|
|
963
|
+
/** The tagline/short description of the system. */
|
|
964
|
+
readonly tagLine: string;
|
|
965
|
+
readonly skin: Skin;
|
|
966
|
+
readonly appsConfig: AppsConfig;
|
|
967
|
+
readonly desktopConfig: DesktopConfig;
|
|
968
|
+
readonly miscConfig: MiscConfig;
|
|
969
|
+
readonly modalsConfig: ModalsConfig;
|
|
970
|
+
readonly taskbarConfig: TaskbarConfig;
|
|
971
|
+
readonly trackingConfig: TrackingConfig;
|
|
972
|
+
readonly windowsConfig: WindowsConfig;
|
|
973
|
+
readonly virtualDriveConfig: VirtualDriveConfig;
|
|
974
|
+
readonly storage: Storage_2;
|
|
975
|
+
constructor({ systemName, tagLine, skin, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig, }: SystemManagerParams);
|
|
976
|
+
private loadSkin;
|
|
977
|
+
getUptime(precision?: number): string;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
declare interface SystemManagerParams {
|
|
981
|
+
systemName: SystemManager["systemName"] | null;
|
|
982
|
+
tagLine: SystemManager["tagLine"] | null;
|
|
983
|
+
skin?: SystemManager["skin"];
|
|
984
|
+
desktopConfig: DesktopConfig;
|
|
985
|
+
appsConfig: AppsConfig;
|
|
986
|
+
miscConfig: MiscConfig;
|
|
987
|
+
modalsConfig: ModalsConfig;
|
|
988
|
+
taskbarConfig: TaskbarConfig;
|
|
989
|
+
trackingConfig: TrackingConfig;
|
|
990
|
+
windowsConfig: WindowsConfig;
|
|
991
|
+
virtualDriveConfig: VirtualDriveConfig;
|
|
90
992
|
}
|
|
91
993
|
|
|
92
|
-
declare
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
994
|
+
declare class TaskbarConfig {
|
|
995
|
+
height: TaskbarConfigOptions["height"];
|
|
996
|
+
constructor(options?: Partial<TaskbarConfigOptions>);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
declare interface TaskbarConfigOptions {
|
|
1000
|
+
/**
|
|
1001
|
+
* Height of the taskbar in CSS pixels.
|
|
1002
|
+
* @default 3 * 16
|
|
1003
|
+
*/
|
|
1004
|
+
height: number;
|
|
1005
|
+
}
|
|
97
1006
|
|
|
98
1007
|
export declare const terminal: TerminalApp;
|
|
99
1008
|
|
|
@@ -108,4 +1017,633 @@ declare interface TerminalProps extends WindowProps {
|
|
|
108
1017
|
input?: string;
|
|
109
1018
|
}
|
|
110
1019
|
|
|
1020
|
+
declare enum Theme {
|
|
1021
|
+
Dark = 0,
|
|
1022
|
+
Light = 1,
|
|
1023
|
+
Cherry = 2,
|
|
1024
|
+
Mango = 3,
|
|
1025
|
+
Aqua = 4,
|
|
1026
|
+
Grape = 5
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
declare class TrackingConfig {
|
|
1030
|
+
enabled: TrackingConfigOptions["enabled"];
|
|
1031
|
+
googleAnalyticsMeasurementId: TrackingConfigOptions["GAMeasurementId"];
|
|
1032
|
+
constructor(options?: Partial<TrackingConfigOptions>);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
declare interface TrackingConfigOptions {
|
|
1036
|
+
/**
|
|
1037
|
+
* Enable tracking.
|
|
1038
|
+
* @default true
|
|
1039
|
+
*/
|
|
1040
|
+
enabled: boolean;
|
|
1041
|
+
/** Google Analytics measurement ID. */
|
|
1042
|
+
GAMeasurementId: string;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
declare class TrackingManager {
|
|
1046
|
+
#private;
|
|
1047
|
+
measurementId?: string | null;
|
|
1048
|
+
constructor(systemManager: SystemManager);
|
|
1049
|
+
init(): this;
|
|
1050
|
+
event(options: UaEventOptions | string): void;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
declare class Vector2 {
|
|
1054
|
+
x: number;
|
|
1055
|
+
y: number;
|
|
1056
|
+
constructor(xy: number);
|
|
1057
|
+
constructor(x: number, y?: number);
|
|
1058
|
+
static get ZERO(): Vector2;
|
|
1059
|
+
get clone(): Vector2;
|
|
1060
|
+
get magnitude(): number;
|
|
1061
|
+
setX(x: number): this;
|
|
1062
|
+
setY(y: number): this;
|
|
1063
|
+
set(x: number, y: number): this;
|
|
1064
|
+
round(): this;
|
|
1065
|
+
normalize(): this;
|
|
1066
|
+
scale(scalar: number): this;
|
|
1067
|
+
getDistanceSquared(x: number, y?: number): number;
|
|
1068
|
+
getDistanceSquared(vector2: Vector2): number;
|
|
1069
|
+
getDistance(x: number, y?: number): number;
|
|
1070
|
+
getDistance(vector2: Vector2): number;
|
|
1071
|
+
add(x: number, y?: number): this;
|
|
1072
|
+
add(vector2: Vector2): this;
|
|
1073
|
+
subtract(x: number, y?: number): this;
|
|
1074
|
+
subtract(vector2: Vector2): this;
|
|
1075
|
+
multiply(x: number, y?: number): this;
|
|
1076
|
+
multiply(vector2: Vector2): this;
|
|
1077
|
+
divide(x: number, y?: number): this;
|
|
1078
|
+
divide(vector2: Vector2): this;
|
|
1079
|
+
lerp(vector2: Vector2, t: number): this;
|
|
1080
|
+
static sum(vector2A: Vector2, vector2B: Vector2): Vector2;
|
|
1081
|
+
static difference(vector2A: Vector2, vector2B: Vector2): Vector2;
|
|
1082
|
+
static product(vector2A: Vector2, vector2B: Vector2): Vector2;
|
|
1083
|
+
static division(vector2A: Vector2, vector2B: Vector2): Vector2;
|
|
1084
|
+
static scale(vector2: Vector2, scalar: number): Vector2;
|
|
1085
|
+
static normalize(vector2: Vector2): Vector2;
|
|
1086
|
+
static lerp(vector2A: Vector2, vector2B: Vector2, t: number): Vector2;
|
|
1087
|
+
static from({ x, y }: {
|
|
1088
|
+
x: number;
|
|
1089
|
+
y: number;
|
|
1090
|
+
}): Vector2;
|
|
1091
|
+
static parseVector(x: number | Vector2, y?: number): {
|
|
1092
|
+
x: number;
|
|
1093
|
+
y: number;
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
declare class VirtualBase<E extends VirtualBaseEvents = VirtualBaseEvents> extends EventEmitter<E & Record<keyof E, unknown[]>> {
|
|
1098
|
+
/** The name of this item. */
|
|
1099
|
+
name: string;
|
|
1100
|
+
/** The alias of this item. */
|
|
1101
|
+
alias: string | undefined | null;
|
|
1102
|
+
/** The folder this item is in. */
|
|
1103
|
+
parent: VirtualFolder | undefined | null;
|
|
1104
|
+
/** Whether this item is protected from changes. */
|
|
1105
|
+
isProtected: boolean | undefined | null;
|
|
1106
|
+
/** The URL of the icon of this item. */
|
|
1107
|
+
iconUrl: string | undefined | null;
|
|
1108
|
+
/** The file this item links to. */
|
|
1109
|
+
linkedFile: VirtualFile | undefined | null;
|
|
1110
|
+
/** The folder this item links to. */
|
|
1111
|
+
linkedFolder: VirtualFolder | undefined | null;
|
|
1112
|
+
/** Whether this item has been edited by the user. */
|
|
1113
|
+
editedByUser: boolean | undefined | null;
|
|
1114
|
+
/** Whether this item is the root folder. */
|
|
1115
|
+
isRoot: boolean | undefined | null;
|
|
1116
|
+
/** The root folder. */
|
|
1117
|
+
root: VirtualRoot | undefined | null;
|
|
1118
|
+
/** Whether this item has been deleted. */
|
|
1119
|
+
isDeleted: boolean;
|
|
1120
|
+
static readonly UPDATE_EVENT = "update";
|
|
1121
|
+
constructor(name: string);
|
|
1122
|
+
get id(): string;
|
|
1123
|
+
setName(name: string): this;
|
|
1124
|
+
setAlias(alias: string): this;
|
|
1125
|
+
setParent(parent: VirtualFolder): this;
|
|
1126
|
+
setProtected(value: boolean): this;
|
|
1127
|
+
setIconUrl(iconUrl: string | null): this;
|
|
1128
|
+
getIconUrl(): string;
|
|
1129
|
+
getType(): string;
|
|
1130
|
+
/**
|
|
1131
|
+
* Tries to delete this item.
|
|
1132
|
+
*/
|
|
1133
|
+
delete(): void;
|
|
1134
|
+
confirmChanges(root?: VirtualRoot): void;
|
|
1135
|
+
/**
|
|
1136
|
+
* Opens this item in the appropriate application.
|
|
1137
|
+
*/
|
|
1138
|
+
open(..._args: unknown[]): unknown;
|
|
1139
|
+
/**
|
|
1140
|
+
* Returns the path of this item.
|
|
1141
|
+
*/
|
|
1142
|
+
get path(): string;
|
|
1143
|
+
/**
|
|
1144
|
+
* Returns path without using this item's alias.
|
|
1145
|
+
*/
|
|
1146
|
+
get displayPath(): string;
|
|
1147
|
+
/**
|
|
1148
|
+
* Returns path without using any aliases.
|
|
1149
|
+
*/
|
|
1150
|
+
get absolutePath(): string;
|
|
1151
|
+
/**
|
|
1152
|
+
* Returns whether this can be edited in its current state.
|
|
1153
|
+
*/
|
|
1154
|
+
get canBeEdited(): boolean;
|
|
1155
|
+
/**
|
|
1156
|
+
* Returns the root folder.
|
|
1157
|
+
*/
|
|
1158
|
+
getRoot(): VirtualRoot;
|
|
1159
|
+
isFile(): this is VirtualFile;
|
|
1160
|
+
isFolder(): this is VirtualFolder;
|
|
1161
|
+
toJSON(): VirtualBaseJson | null;
|
|
1162
|
+
toString(): string | null;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
declare interface VirtualBaseEvents {
|
|
1166
|
+
update: [];
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
declare interface VirtualBaseJson {
|
|
1170
|
+
nam: string;
|
|
1171
|
+
ico?: string;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
declare class VirtualDriveConfig {
|
|
1175
|
+
saveData: VirtualDriveConfigOptions["saveData"];
|
|
1176
|
+
defaultData: VirtualDriveConfigOptions["defaultData"];
|
|
1177
|
+
constructor(options?: Partial<VirtualDriveConfigOptions>);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
declare interface VirtualDriveConfigOptions {
|
|
1181
|
+
/**
|
|
1182
|
+
* Enables persistent storage of the virtual drive.
|
|
1183
|
+
* @default {
|
|
1184
|
+
enableCompression: true,
|
|
1185
|
+
prefix: "pos-"
|
|
1186
|
+
}
|
|
1187
|
+
*/
|
|
1188
|
+
saveData: false | {
|
|
1189
|
+
/**
|
|
1190
|
+
* Enables compression of stored items.
|
|
1191
|
+
* @default false
|
|
1192
|
+
*/
|
|
1193
|
+
enableCompression: boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* The prefix to prepend to stored keys.
|
|
1196
|
+
* @default "pos-"
|
|
1197
|
+
*/
|
|
1198
|
+
prefix?: string;
|
|
1199
|
+
/**
|
|
1200
|
+
* An array of tuples of old and new keys to migrate.
|
|
1201
|
+
* @default [["data", VirtualDriveStorage.KEY]]
|
|
1202
|
+
*/
|
|
1203
|
+
migrations?: [string, string][];
|
|
1204
|
+
};
|
|
1205
|
+
/**
|
|
1206
|
+
* Configure the data that is loaded initially when ProzillaOS is opened.
|
|
1207
|
+
*/
|
|
1208
|
+
defaultData: {
|
|
1209
|
+
/**
|
|
1210
|
+
* Include pictures folder in default data.
|
|
1211
|
+
* @default true
|
|
1212
|
+
*/
|
|
1213
|
+
includePicturesFolder?: boolean;
|
|
1214
|
+
/**
|
|
1215
|
+
* Include documents folder in default data.
|
|
1216
|
+
* @default true
|
|
1217
|
+
*/
|
|
1218
|
+
includeDocumentsFolder?: boolean;
|
|
1219
|
+
/**
|
|
1220
|
+
* Include desktop folder in default data.
|
|
1221
|
+
* @default true
|
|
1222
|
+
*/
|
|
1223
|
+
includeDesktopFolder?: boolean;
|
|
1224
|
+
/**
|
|
1225
|
+
* Include source tree folder in default data.
|
|
1226
|
+
* @default true
|
|
1227
|
+
*/
|
|
1228
|
+
includeSourceTree?: boolean;
|
|
1229
|
+
/**
|
|
1230
|
+
* Include apps folder in default data.
|
|
1231
|
+
* @default true
|
|
1232
|
+
*/
|
|
1233
|
+
includeAppsFolder?: boolean;
|
|
1234
|
+
loadData?: (virtualRoot: VirtualRoot) => void;
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
declare class VirtualDriveStorage extends Storage_2 {
|
|
1239
|
+
virtualDriveConfig: VirtualDriveConfig;
|
|
1240
|
+
static readonly KEY = "drive";
|
|
1241
|
+
constructor(virtualDriveConfig: VirtualDriveConfig);
|
|
1242
|
+
load(key: string): string | null;
|
|
1243
|
+
store(key: string, value: string): void;
|
|
1244
|
+
synchronize(): void;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* A virtual file that can be stored inside a folder.
|
|
1249
|
+
*/
|
|
1250
|
+
declare class VirtualFile extends VirtualBase<VirtualFileEvents> {
|
|
1251
|
+
/** The extension of this file. */
|
|
1252
|
+
extension: OptionalStringProperty;
|
|
1253
|
+
/** The URL of the source of this file. */
|
|
1254
|
+
source: OptionalStringProperty;
|
|
1255
|
+
/** The content of this file. */
|
|
1256
|
+
content: OptionalStringProperty;
|
|
1257
|
+
static NON_TEXT_EXTENSIONS: string[];
|
|
1258
|
+
static readonly CONTENT_CHANGE_EVENT = "contentChange";
|
|
1259
|
+
constructor(name: string, extension?: string);
|
|
1260
|
+
setAlias(alias: string): this;
|
|
1261
|
+
/**
|
|
1262
|
+
* Sets the source of this file and removes the content.
|
|
1263
|
+
*/
|
|
1264
|
+
setSource(source: string): this;
|
|
1265
|
+
/**
|
|
1266
|
+
* Sets the content of this file and removes the source.
|
|
1267
|
+
*/
|
|
1268
|
+
setContent(content: string | string[]): this;
|
|
1269
|
+
get id(): string;
|
|
1270
|
+
static splitId(id: string): {
|
|
1271
|
+
name: string;
|
|
1272
|
+
extension: OptionalStringProperty;
|
|
1273
|
+
};
|
|
1274
|
+
/**
|
|
1275
|
+
* Opens this file in an app associated with its extension.
|
|
1276
|
+
*/
|
|
1277
|
+
open(windowsManager: WindowsManager): object | null;
|
|
1278
|
+
read(): Promise<OptionalStringProperty | undefined>;
|
|
1279
|
+
isFile(): this is VirtualFile;
|
|
1280
|
+
getIconUrl(): string;
|
|
1281
|
+
getType(): string;
|
|
1282
|
+
download(): void;
|
|
1283
|
+
isDownloadable(): boolean;
|
|
1284
|
+
toJSON(): VirtualFileJson | null;
|
|
1285
|
+
static removeFileScheme(source: string): string;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
declare interface VirtualFileEvents extends VirtualBaseEvents {
|
|
1289
|
+
contentChange: [VirtualFile];
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
declare interface VirtualFileJson extends VirtualBaseJson {
|
|
1293
|
+
ext?: string;
|
|
1294
|
+
cnt?: string;
|
|
1295
|
+
src?: string;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* A link that points to a virtual file.
|
|
1300
|
+
*/
|
|
1301
|
+
declare class VirtualFileLink extends VirtualFile {
|
|
1302
|
+
linkedPath?: string;
|
|
1303
|
+
constructor(name: string, linkedFile?: VirtualFile);
|
|
1304
|
+
setLinkedFile(file: VirtualFile | null): VirtualFileLink;
|
|
1305
|
+
setLinkedPath(path: string): VirtualFileLink;
|
|
1306
|
+
isValid(): boolean;
|
|
1307
|
+
toJSON(): VirtualFileLinkJson | null;
|
|
1308
|
+
setAlias(...args: Parameters<VirtualFile["setAlias"]>): this;
|
|
1309
|
+
setSource(...args: Parameters<VirtualFile["setSource"]>): this;
|
|
1310
|
+
setContent(...args: Parameters<VirtualFile["setContent"]>): this;
|
|
1311
|
+
get id(): string;
|
|
1312
|
+
open(...args: Parameters<VirtualFile["open"]>): ReturnType<VirtualFile["open"]>;
|
|
1313
|
+
read(...args: Parameters<VirtualFile["read"]>): Promise<string | null | undefined>;
|
|
1314
|
+
getIconUrl(...args: Parameters<VirtualFile["getIconUrl"]>): ReturnType<VirtualFile["getIconUrl"]>;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
declare interface VirtualFileLinkJson extends VirtualFileJson {
|
|
1318
|
+
lnk: string;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* A virtual folder that can contains files and sub-folders.
|
|
1323
|
+
*/
|
|
1324
|
+
declare class VirtualFolder<E extends VirtualBaseEvents = VirtualBaseEvents> extends VirtualBase<E> {
|
|
1325
|
+
/** The folders inside this folder. */
|
|
1326
|
+
subFolders: (VirtualFolder | VirtualFolderLink)[];
|
|
1327
|
+
/** The files inside this folder. */
|
|
1328
|
+
files: (VirtualFile | VirtualFileLink)[];
|
|
1329
|
+
/**
|
|
1330
|
+
* The type of this folder.
|
|
1331
|
+
* @default VirtualFolder.TYPE.general
|
|
1332
|
+
*/
|
|
1333
|
+
type: number | undefined;
|
|
1334
|
+
static TYPE: {
|
|
1335
|
+
general: number;
|
|
1336
|
+
media: number;
|
|
1337
|
+
};
|
|
1338
|
+
constructor(name: string, type?: number);
|
|
1339
|
+
setAlias(alias: string): this;
|
|
1340
|
+
/**
|
|
1341
|
+
* Returns true if this folder contains a file matching a name and extension.
|
|
1342
|
+
*/
|
|
1343
|
+
hasFile(name: string, extension?: string): boolean;
|
|
1344
|
+
/**
|
|
1345
|
+
* Returns true if this folder contains a folder matching a name.
|
|
1346
|
+
*/
|
|
1347
|
+
hasFolder(name: string): boolean;
|
|
1348
|
+
/**
|
|
1349
|
+
* Finds and returns a file inside this folder matching a name and extension.
|
|
1350
|
+
*/
|
|
1351
|
+
findFile(name: string, extension?: string | null): VirtualFile | VirtualFileLink | null;
|
|
1352
|
+
/**
|
|
1353
|
+
* Finds and returns a folder inside this folder matching a name.
|
|
1354
|
+
*/
|
|
1355
|
+
findSubFolder(name: string): VirtualFolder | VirtualFolderLink | null;
|
|
1356
|
+
addFile(file: VirtualFile, confirmChanges?: boolean): this;
|
|
1357
|
+
/**
|
|
1358
|
+
* Creates a file with a name and extension.
|
|
1359
|
+
*/
|
|
1360
|
+
createFile(name: string, extension?: string, callback?: (newFile: VirtualFile | VirtualFileLink) => void): this;
|
|
1361
|
+
/**
|
|
1362
|
+
* Creates files based on an array of objects with file names and extensions.
|
|
1363
|
+
*/
|
|
1364
|
+
createFiles(files: {
|
|
1365
|
+
name: string;
|
|
1366
|
+
extension: string;
|
|
1367
|
+
}[]): this;
|
|
1368
|
+
/**
|
|
1369
|
+
* Creates a file link with a name.
|
|
1370
|
+
*/
|
|
1371
|
+
createFileLink(name: string, callback?: (newFileLink: VirtualFileLink | VirtualFile) => void): this;
|
|
1372
|
+
/**
|
|
1373
|
+
* Creates file links based on an array of objects with file names and extensions.
|
|
1374
|
+
*/
|
|
1375
|
+
createFileLinks(fileLinks: {
|
|
1376
|
+
name: string;
|
|
1377
|
+
}[]): this;
|
|
1378
|
+
addFolder(folder: VirtualFolder, confirmChanges?: boolean): this;
|
|
1379
|
+
/**
|
|
1380
|
+
* Creates a folder with a name.
|
|
1381
|
+
*/
|
|
1382
|
+
createFolder(name: string, callback?: (newFolder: VirtualFolder) => void): this;
|
|
1383
|
+
/**
|
|
1384
|
+
* Creates folders based on an array of folder names.
|
|
1385
|
+
*/
|
|
1386
|
+
createFolders(names: string[]): this;
|
|
1387
|
+
/**
|
|
1388
|
+
* Creates a folder link with a name.
|
|
1389
|
+
*/
|
|
1390
|
+
createFolderLink(name: string, callback?: (newFolderLink: VirtualFolderLink | VirtualFolder) => void): this;
|
|
1391
|
+
/**
|
|
1392
|
+
* Creates folder links based on an array of folder names.
|
|
1393
|
+
*/
|
|
1394
|
+
createFolderLinks(names: string[]): this;
|
|
1395
|
+
/**
|
|
1396
|
+
* Removes a file or folder from this folder.
|
|
1397
|
+
*/
|
|
1398
|
+
remove(child: VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink): this;
|
|
1399
|
+
/**
|
|
1400
|
+
* Returns the file or folder at a relative path or null if it doesn't exist.
|
|
1401
|
+
*/
|
|
1402
|
+
navigate(relativePath: string): VirtualFile | VirtualFolder | null;
|
|
1403
|
+
navigateToFolder(relativePath: string): VirtualFolder | null;
|
|
1404
|
+
navigateToFile(relativePath: string): VirtualFile | null;
|
|
1405
|
+
/**
|
|
1406
|
+
* Opens this folder in file explorer.
|
|
1407
|
+
*/
|
|
1408
|
+
open(windowsManager: WindowsManager): object | null | undefined;
|
|
1409
|
+
/**
|
|
1410
|
+
* Deletes this folder and all its files and sub-folders recursively.
|
|
1411
|
+
*/
|
|
1412
|
+
delete(): void;
|
|
1413
|
+
/**
|
|
1414
|
+
* Returns all files inside this folder.
|
|
1415
|
+
* @param showHidden - Whether to include hidden files.
|
|
1416
|
+
*/
|
|
1417
|
+
getFiles(showHidden?: boolean): VirtualFile[];
|
|
1418
|
+
/**
|
|
1419
|
+
* Returns all sub-folders inside this folder.
|
|
1420
|
+
* @param showHidden - Whether to include hidden folders.
|
|
1421
|
+
*/
|
|
1422
|
+
getSubFolders(showHidden?: boolean): VirtualFolder[];
|
|
1423
|
+
/**
|
|
1424
|
+
* Returns the amount of files and sub-folders inside this folder.
|
|
1425
|
+
* @param includeHidden - Whether to include hidden files and folders in the count.
|
|
1426
|
+
*/
|
|
1427
|
+
getItemCount(includeHidden?: boolean): number;
|
|
1428
|
+
isFolder(): this is VirtualFolder;
|
|
1429
|
+
getIconUrl(): string;
|
|
1430
|
+
toJSON(): VirtualFolderJson | null;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
declare interface VirtualFolderJson extends VirtualBaseJson {
|
|
1434
|
+
fls?: VirtualFileJson[];
|
|
1435
|
+
fds?: VirtualFolderJson[];
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* A link that points to a virtual folder.
|
|
1440
|
+
*/
|
|
1441
|
+
declare class VirtualFolderLink extends VirtualFolder {
|
|
1442
|
+
linkedPath?: string;
|
|
1443
|
+
constructor(name: string, linkedFolder?: VirtualFolder);
|
|
1444
|
+
setLinkedFolder(folder: VirtualFolder | null): VirtualFolderLink;
|
|
1445
|
+
setLinkedPath(path: string): VirtualFolderLink;
|
|
1446
|
+
isValid(): boolean;
|
|
1447
|
+
getIconUrl(): string;
|
|
1448
|
+
toJSON(): VirtualFolderLinkJson | null;
|
|
1449
|
+
setAlias(...args: Parameters<VirtualFolder["setAlias"]>): this;
|
|
1450
|
+
createFile(...args: Parameters<VirtualFolder["createFile"]>): this;
|
|
1451
|
+
createFiles(...args: Parameters<VirtualFolder["createFiles"]>): this;
|
|
1452
|
+
createFolder(...args: Parameters<VirtualFolder["createFolder"]>): this;
|
|
1453
|
+
createFolders(...args: Parameters<VirtualFolder["createFolders"]>): this;
|
|
1454
|
+
hasFile(...args: Parameters<VirtualFolder["hasFile"]>): ReturnType<VirtualFolder["hasFile"]>;
|
|
1455
|
+
hasFolder(...args: Parameters<VirtualFolder["hasFolder"]>): ReturnType<VirtualFolder["hasFolder"]>;
|
|
1456
|
+
findFile(...args: Parameters<VirtualFolder["findFile"]>): ReturnType<VirtualFolder["findFile"]>;
|
|
1457
|
+
findSubFolder(...args: Parameters<VirtualFolder["findSubFolder"]>): ReturnType<VirtualFolder["findSubFolder"]>;
|
|
1458
|
+
getFiles(...args: Parameters<VirtualFolder["getFiles"]>): ReturnType<VirtualFolder["getFiles"]>;
|
|
1459
|
+
getSubFolders(...args: Parameters<VirtualFolder["getSubFolders"]>): ReturnType<VirtualFolder["getSubFolders"]>;
|
|
1460
|
+
open(...args: Parameters<VirtualFolder["open"]>): ReturnType<VirtualFolder["open"]>;
|
|
1461
|
+
getItemCount(...args: Parameters<VirtualFolder["getItemCount"]>): ReturnType<VirtualFolder["getItemCount"]>;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
declare interface VirtualFolderLinkJson extends VirtualFolderJson {
|
|
1465
|
+
lnk: string;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* A virtual folder that serves as the root folder.
|
|
1470
|
+
*/
|
|
1471
|
+
declare class VirtualRoot extends VirtualFolder<VirtualRootEvents> {
|
|
1472
|
+
/** Aliases for files and folders. */
|
|
1473
|
+
shortcuts: Record<string, VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink>;
|
|
1474
|
+
initiated: boolean;
|
|
1475
|
+
loadedDefaultData: boolean;
|
|
1476
|
+
systemManager: SystemManager;
|
|
1477
|
+
storage: VirtualDriveStorage;
|
|
1478
|
+
static readonly ERROR_EVENT = "error";
|
|
1479
|
+
constructor(systemManager: SystemManager);
|
|
1480
|
+
loadDefaultData(): void;
|
|
1481
|
+
loadData(): void;
|
|
1482
|
+
/**
|
|
1483
|
+
* Calls the storage manager's store function with this root's data as a string.
|
|
1484
|
+
*/
|
|
1485
|
+
saveData(): void;
|
|
1486
|
+
/**
|
|
1487
|
+
* Initializes this root by loading the default data and then the user's data on top.
|
|
1488
|
+
*/
|
|
1489
|
+
init(): VirtualRoot;
|
|
1490
|
+
/**
|
|
1491
|
+
* Adds a shortcut to a file or folder.
|
|
1492
|
+
*/
|
|
1493
|
+
addShortcut(name: string, destination: VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink): this;
|
|
1494
|
+
/**
|
|
1495
|
+
* Tells the storage manager to clear all data and reloads the window.
|
|
1496
|
+
*/
|
|
1497
|
+
reset(): void;
|
|
1498
|
+
static isValidName(_name: string): boolean;
|
|
1499
|
+
static isValidFileName(_name: string): boolean;
|
|
1500
|
+
static isValidFolderName(_name: string): boolean;
|
|
1501
|
+
get path(): string;
|
|
1502
|
+
get displayPath(): string;
|
|
1503
|
+
toJSON(): VirtualRootJson | null;
|
|
1504
|
+
toString(): string | null;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
declare interface VirtualRootEvents extends VirtualBaseEvents {
|
|
1508
|
+
error: [{
|
|
1509
|
+
message: string;
|
|
1510
|
+
}];
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
declare interface VirtualRootJson extends VirtualFolderJson {
|
|
1514
|
+
scs: Record<string, string>;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
declare interface WindowOptions {
|
|
1518
|
+
/** The ID of the window. */
|
|
1519
|
+
id?: string;
|
|
1520
|
+
/** The app associated with the window. */
|
|
1521
|
+
app?: App;
|
|
1522
|
+
/**
|
|
1523
|
+
* The size of the window.
|
|
1524
|
+
* @default new Vector2(700, 400)
|
|
1525
|
+
*/
|
|
1526
|
+
size?: Vector2;
|
|
1527
|
+
/** The position of the window. */
|
|
1528
|
+
position?: Vector2;
|
|
1529
|
+
fullscreen?: boolean | string;
|
|
1530
|
+
options?: object;
|
|
1531
|
+
isFocused?: boolean;
|
|
1532
|
+
lastInteraction?: number;
|
|
1533
|
+
minimized?: boolean;
|
|
1534
|
+
[key: string]: unknown;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
declare interface WindowProps extends WindowOptions {
|
|
1538
|
+
/**
|
|
1539
|
+
* Whether to start the window in fullscreen mode.
|
|
1540
|
+
* @default false
|
|
1541
|
+
*/
|
|
1542
|
+
fullscreen?: boolean;
|
|
1543
|
+
/** Function that sets the title of the window. */
|
|
1544
|
+
setTitle?: React.Dispatch<React.SetStateAction<string>>;
|
|
1545
|
+
/** Function that sets the icon URL of the window. */
|
|
1546
|
+
setIconUrl?: React.Dispatch<React.SetStateAction<string>>;
|
|
1547
|
+
/** Function that closes the window. */
|
|
1548
|
+
close?: (event?: Event | React.UIEvent<HTMLElement>) => void;
|
|
1549
|
+
/** Function that brings the window in focus. */
|
|
1550
|
+
focus?: (event?: Event | React.UIEvent<HTMLElement>, force?: boolean) => void;
|
|
1551
|
+
/** Whether the window is currently focused and should allow interactions. */
|
|
1552
|
+
active?: boolean;
|
|
1553
|
+
/** Whether to start the window in minimized mode. */
|
|
1554
|
+
minimized?: boolean;
|
|
1555
|
+
/** Function that toggles the minimized mode of the window. */
|
|
1556
|
+
toggleMinimized?: (event?: Event) => void;
|
|
1557
|
+
/** The depth value of the window. */
|
|
1558
|
+
index?: number;
|
|
1559
|
+
/** Whether the window is in standalone mode. */
|
|
1560
|
+
standalone?: boolean;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
declare class WindowsConfig {
|
|
1564
|
+
screenMargin: WindowsConfigOptions["screenMargin"];
|
|
1565
|
+
titleSeparator: WindowsConfigOptions["titleSeparator"];
|
|
1566
|
+
minScreenSize: WindowsConfigOptions["minScreenSize"];
|
|
1567
|
+
constructor(options?: Partial<WindowsConfigOptions>);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
declare interface WindowsConfigOptions {
|
|
1571
|
+
/**
|
|
1572
|
+
* The margin around windows that are not maximized, in pixels.
|
|
1573
|
+
* @default 32
|
|
1574
|
+
*/
|
|
1575
|
+
screenMargin: number;
|
|
1576
|
+
/**
|
|
1577
|
+
* The separator to use in window titles.
|
|
1578
|
+
* @default "-"
|
|
1579
|
+
*/
|
|
1580
|
+
titleSeparator: string;
|
|
1581
|
+
/**
|
|
1582
|
+
* If the user's screen is smaller than these values, windows will always be maximized.
|
|
1583
|
+
* @default new Vector2(350, 350)
|
|
1584
|
+
*/
|
|
1585
|
+
minScreenSize: Vector2;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Manages the states of windows.
|
|
1590
|
+
*/
|
|
1591
|
+
declare class WindowsManager {
|
|
1592
|
+
#private;
|
|
1593
|
+
windows: {
|
|
1594
|
+
[id: string]: WindowOptions;
|
|
1595
|
+
};
|
|
1596
|
+
/** Function that handles changes to the open windows. */
|
|
1597
|
+
updateWindows: (window: WindowsManager["windows"]) => void;
|
|
1598
|
+
startupComplete: boolean;
|
|
1599
|
+
constructor(systemManager: SystemManager, trackingManager: TrackingManager);
|
|
1600
|
+
/**
|
|
1601
|
+
* Opens a window for an application.
|
|
1602
|
+
* @param appId - The ID of the app.
|
|
1603
|
+
*/
|
|
1604
|
+
open(appId: string, options?: WindowOptions | null): object | null;
|
|
1605
|
+
/**
|
|
1606
|
+
* Opens a file with the associated app or by a method specified by the file scheme.
|
|
1607
|
+
* @returns Opened window.
|
|
1608
|
+
*/
|
|
1609
|
+
openFile(file: VirtualFile, options?: object): object | null;
|
|
1610
|
+
/**
|
|
1611
|
+
* Close a window.
|
|
1612
|
+
*/
|
|
1613
|
+
close(windowId: string): void;
|
|
1614
|
+
/**
|
|
1615
|
+
* Focus on a specific window.
|
|
1616
|
+
*/
|
|
1617
|
+
focus(windowId: string): void;
|
|
1618
|
+
/**
|
|
1619
|
+
* Check whether a window is focused.
|
|
1620
|
+
*/
|
|
1621
|
+
isFocused(windowId: string): boolean | undefined;
|
|
1622
|
+
/**
|
|
1623
|
+
* Check if any window is focused.
|
|
1624
|
+
*/
|
|
1625
|
+
isAnyFocused(): boolean;
|
|
1626
|
+
/**
|
|
1627
|
+
* Change the minimized state of a window.
|
|
1628
|
+
* @param windowId - The ID of the window.
|
|
1629
|
+
* @param minimized - Leave as undefined to toggle the window's minimization state.
|
|
1630
|
+
*/
|
|
1631
|
+
setMinimized(windowId: string, minimized?: boolean): void;
|
|
1632
|
+
/**
|
|
1633
|
+
* Minimize all windows.
|
|
1634
|
+
*/
|
|
1635
|
+
minimizeAll(): void;
|
|
1636
|
+
/**
|
|
1637
|
+
* Check if an app has an open window.
|
|
1638
|
+
*/
|
|
1639
|
+
isAppActive(appId: string): boolean;
|
|
1640
|
+
/**
|
|
1641
|
+
* Get an opened window of a certain app.
|
|
1642
|
+
*/
|
|
1643
|
+
getAppWindowId(appId: string): string | null;
|
|
1644
|
+
setUpdateWindows(updateWindows: WindowsManager["updateWindows"]): void;
|
|
1645
|
+
startup(appIds: string[], options: Record<string, unknown>): void;
|
|
1646
|
+
get windowIds(): string[];
|
|
1647
|
+
}
|
|
1648
|
+
|
|
111
1649
|
export { }
|