@prozilla-os/core 2.0.2 → 2.1.2
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/README.md +105 -113
- package/dist/chunks/afire-DlRwSfiJ.js +68 -0
- package/dist/chunks/afire-DlRwSfiJ.js.map +1 -0
- package/dist/chunks/banner-jSvYkuqB.js +351 -0
- package/dist/chunks/banner-jSvYkuqB.js.map +1 -0
- package/dist/chunks/cat-B_KOgu80.js +37 -0
- package/dist/chunks/cat-B_KOgu80.js.map +1 -0
- package/dist/chunks/clear-C8xhqHmC.js +12 -0
- package/dist/chunks/clear-C8xhqHmC.js.map +1 -0
- package/dist/chunks/compgen-2kLzA1wV.js +11 -0
- package/dist/chunks/compgen-2kLzA1wV.js.map +1 -0
- package/dist/chunks/{cowsay-hTKzWScw.js → cowsay-CTLxUPtF.js} +13 -13
- package/dist/chunks/cowsay-CTLxUPtF.js.map +1 -0
- package/dist/chunks/date-CA1ub92R.js +33 -0
- package/dist/chunks/date-CA1ub92R.js.map +1 -0
- package/dist/chunks/dir-w2XNd6oI.js +11 -0
- package/dist/chunks/dir-w2XNd6oI.js.map +1 -0
- package/dist/chunks/doubleBracket-B5nqIccY.js +78 -0
- package/dist/chunks/doubleBracket-B5nqIccY.js.map +1 -0
- package/dist/chunks/{echo-Gmh-b8f5.js → echo-_hDVbupR.js} +5 -5
- package/dist/chunks/echo-_hDVbupR.js.map +1 -0
- package/dist/chunks/{eval-DINS_Vhl.js → eval-4uLqmhXl.js} +5 -5
- package/dist/chunks/eval-4uLqmhXl.js.map +1 -0
- package/dist/chunks/false-D6AWAlcU.js +12 -0
- package/dist/chunks/false-D6AWAlcU.js.map +1 -0
- package/dist/chunks/{fortune-DkIZpYa_.js → fortune-D8ZK6xtX.js} +7 -7
- package/dist/chunks/fortune-D8ZK6xtX.js.map +1 -0
- package/dist/chunks/grep-DZO92KaH.js +41 -0
- package/dist/chunks/grep-DZO92KaH.js.map +1 -0
- package/dist/chunks/head-C_bbNyUc.js +50 -0
- package/dist/chunks/head-C_bbNyUc.js.map +1 -0
- package/dist/chunks/help-OHTeCzgo.js +19 -0
- package/dist/chunks/help-OHTeCzgo.js.map +1 -0
- package/dist/chunks/history-DeQor0w1.js +17 -0
- package/dist/chunks/history-DeQor0w1.js.map +1 -0
- package/dist/chunks/hostname-B-lPyRps.js +10 -0
- package/dist/chunks/hostname-B-lPyRps.js.map +1 -0
- package/dist/chunks/install-9Dikj7i2.js +27 -0
- package/dist/chunks/install-9Dikj7i2.js.map +1 -0
- package/dist/chunks/less-wELkkcQx.js +98 -0
- package/dist/chunks/less-wELkkcQx.js.map +1 -0
- package/dist/chunks/{lolcat-Dyjbg15t.js → lolcat-xpDAXsIt.js} +20 -20
- package/dist/chunks/lolcat-xpDAXsIt.js.map +1 -0
- package/dist/chunks/{ls-DnmR50y0.js → ls-D2Ln7mue.js} +7 -7
- package/dist/chunks/ls-D2Ln7mue.js.map +1 -0
- package/dist/chunks/man-E9nMmKZ1.js +58 -0
- package/dist/chunks/man-E9nMmKZ1.js.map +1 -0
- package/dist/chunks/nano-DsRjsQ-k.js +79 -0
- package/dist/chunks/nano-DsRjsQ-k.js.map +1 -0
- package/dist/chunks/neofetch-Dyre2Ik0.js +46 -0
- package/dist/chunks/neofetch-Dyre2Ik0.js.map +1 -0
- package/dist/chunks/pipes-CQ-pK6Kv.js +89 -0
- package/dist/chunks/pipes-CQ-pK6Kv.js.map +1 -0
- package/dist/chunks/printenv-Cq-skM9d.js +22 -0
- package/dist/chunks/printenv-Cq-skM9d.js.map +1 -0
- package/dist/chunks/pwd-CZ9IWAfu.js +11 -0
- package/dist/chunks/pwd-CZ9IWAfu.js.map +1 -0
- package/dist/chunks/rain-DT-V01dD.js +63 -0
- package/dist/chunks/rain-DT-V01dD.js.map +1 -0
- package/dist/chunks/reload-CE3ZVq6O.js +10 -0
- package/dist/chunks/reload-CE3ZVq6O.js.map +1 -0
- package/dist/chunks/rev-C5m1qeoZ.js +15 -0
- package/dist/chunks/rev-C5m1qeoZ.js.map +1 -0
- package/dist/chunks/rm-Uxuv-dEz.js.map +1 -1
- package/dist/chunks/rmdir-BYWer3pb.js.map +1 -1
- package/dist/chunks/sh-CIyBHb8C.js +11 -0
- package/dist/chunks/sh-CIyBHb8C.js.map +1 -0
- package/dist/chunks/{sl-CLAmugya.js → sl-CVLteJLH.js} +10 -10
- package/dist/chunks/{sl-CLAmugya.js.map → sl-CVLteJLH.js.map} +1 -1
- package/dist/chunks/sleep-hEBW30R3.js +26 -0
- package/dist/chunks/sleep-hEBW30R3.js.map +1 -0
- package/dist/chunks/snow-DAlyPPxX.js +76 -0
- package/dist/chunks/snow-DAlyPPxX.js.map +1 -0
- package/dist/chunks/tail-BLlaoTxA.js +50 -0
- package/dist/chunks/tail-BLlaoTxA.js.map +1 -0
- package/dist/chunks/terminalUIApp-Bmiaqvd9.js +63 -0
- package/dist/chunks/terminalUIApp-Bmiaqvd9.js.map +1 -0
- package/dist/chunks/textEditorApp-BM3EiMoV.js +56 -0
- package/dist/chunks/textEditorApp-BM3EiMoV.js.map +1 -0
- package/dist/chunks/true-j1Uf2Nz9.js +12 -0
- package/dist/chunks/true-j1Uf2Nz9.js.map +1 -0
- package/dist/chunks/uniq-LncLpnFY.js +44 -0
- package/dist/chunks/uniq-LncLpnFY.js.map +1 -0
- package/dist/chunks/uptime-pYltXMOi.js +10 -0
- package/dist/chunks/uptime-pYltXMOi.js.map +1 -0
- package/dist/chunks/vi-Cgo3qLR9.js +121 -0
- package/dist/chunks/vi-Cgo3qLR9.js.map +1 -0
- package/dist/chunks/watch-B4Tgzgbn.js +53 -0
- package/dist/chunks/watch-B4Tgzgbn.js.map +1 -0
- package/dist/chunks/whatis-BPKA-MNF.js +17 -0
- package/dist/chunks/whatis-BPKA-MNF.js.map +1 -0
- package/dist/chunks/whoami-BS3xdQEI.js +10 -0
- package/dist/chunks/whoami-BS3xdQEI.js.map +1 -0
- package/dist/chunks/yes-ilM2l2xq.js +18 -0
- package/dist/chunks/yes-ilM2l2xq.js.map +1 -0
- package/dist/main.d.ts +803 -73
- package/dist/main.js +17714 -16034
- package/dist/main.js.map +1 -1
- package/package.json +19 -18
- package/dist/chunks/cat-DH-kPf08.js +0 -44
- package/dist/chunks/cat-DH-kPf08.js.map +0 -1
- package/dist/chunks/clear-DC-frUcf.js +0 -13
- package/dist/chunks/clear-DC-frUcf.js.map +0 -1
- package/dist/chunks/compgen-OhvISbst.js +0 -11
- package/dist/chunks/compgen-OhvISbst.js.map +0 -1
- package/dist/chunks/cowsay-hTKzWScw.js.map +0 -1
- package/dist/chunks/date-D8cnHZuY.js +0 -33
- package/dist/chunks/date-D8cnHZuY.js.map +0 -1
- package/dist/chunks/dir-BmNeEPzy.js +0 -11
- package/dist/chunks/dir-BmNeEPzy.js.map +0 -1
- package/dist/chunks/echo-Gmh-b8f5.js.map +0 -1
- package/dist/chunks/eval-DINS_Vhl.js.map +0 -1
- package/dist/chunks/fortune-DkIZpYa_.js.map +0 -1
- package/dist/chunks/grep-CR3FMStR.js +0 -41
- package/dist/chunks/grep-CR3FMStR.js.map +0 -1
- package/dist/chunks/help-Drx0UDCY.js +0 -19
- package/dist/chunks/help-Drx0UDCY.js.map +0 -1
- package/dist/chunks/history-BEJhnsrb.js +0 -17
- package/dist/chunks/history-BEJhnsrb.js.map +0 -1
- package/dist/chunks/hostname-D8sxyWIy.js +0 -10
- package/dist/chunks/hostname-D8sxyWIy.js.map +0 -1
- package/dist/chunks/lolcat-Dyjbg15t.js.map +0 -1
- package/dist/chunks/ls-DnmR50y0.js.map +0 -1
- package/dist/chunks/man-7W6T7lda.js +0 -60
- package/dist/chunks/man-7W6T7lda.js.map +0 -1
- package/dist/chunks/neofetch--vHMIS9v.js +0 -40
- package/dist/chunks/neofetch--vHMIS9v.js.map +0 -1
- package/dist/chunks/printenv-6OpJKd7g.js +0 -24
- package/dist/chunks/printenv-6OpJKd7g.js.map +0 -1
- package/dist/chunks/pwd-9JYDUbov.js +0 -11
- package/dist/chunks/pwd-9JYDUbov.js.map +0 -1
- package/dist/chunks/reload-CjTJVt5Z.js +0 -10
- package/dist/chunks/reload-CjTJVt5Z.js.map +0 -1
- package/dist/chunks/rev--2pyt1P8.js +0 -12
- package/dist/chunks/rev--2pyt1P8.js.map +0 -1
- package/dist/chunks/sh-B67OTc-j.js +0 -15
- package/dist/chunks/sh-B67OTc-j.js.map +0 -1
- package/dist/chunks/uniq-Dx_4r3B5.js +0 -44
- package/dist/chunks/uniq-Dx_4r3B5.js.map +0 -1
- package/dist/chunks/uptime-DjJ5V7hu.js +0 -10
- package/dist/chunks/uptime-DjJ5V7hu.js.map +0 -1
- package/dist/chunks/watch-BjJ8bCnP.js +0 -52
- package/dist/chunks/watch-BjJ8bCnP.js.map +0 -1
- package/dist/chunks/whatis-CFZWdHZ4.js +0 -17
- package/dist/chunks/whatis-CFZWdHZ4.js.map +0 -1
- package/dist/chunks/whoami-D-es0JvS.js +0 -10
- package/dist/chunks/whoami-D-es0JvS.js.map +0 -1
package/dist/main.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ForwardRefExoticComponent } from 'react';
|
|
|
5
5
|
import { HTMLAttributeAnchorTarget } from 'react';
|
|
6
6
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
7
7
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
8
|
+
import { KeyboardEvent as KeyboardEvent_2 } from 'react';
|
|
8
9
|
import { Listener } from '@prozilla-os/shared';
|
|
9
10
|
import { MemoExoticComponent } from 'react';
|
|
10
11
|
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
@@ -14,6 +15,7 @@ import { ReactElement } from 'react';
|
|
|
14
15
|
import { ReactNode } from 'react';
|
|
15
16
|
import { RefAttributes } from 'react';
|
|
16
17
|
import { RefObject } from 'react';
|
|
18
|
+
import { Result } from '@prozilla-os/shared';
|
|
17
19
|
import { Skin } from '@prozilla-os/skins';
|
|
18
20
|
import { Snapshot } from 'valtio';
|
|
19
21
|
import { UaEventOptions } from 'react-ga4/types/ga4';
|
|
@@ -83,9 +85,9 @@ export declare interface AlertParams {
|
|
|
83
85
|
single?: boolean;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
export declare const ANSI_ASCII_LOGO:
|
|
88
|
+
export declare const ANSI_ASCII_LOGO = "\n * \n **** \n **** ***** \n **: @@@@@@ @@@@@@@ \n ** @@@@@@@@@@@@ @@@@@@@@@%\n:**+@@@@@ +@@@@ @@@@ : \n : @@@* @@@ %@@@@@@@ \n ** @@@@ @@@ *@@@@@@@\n:***#@@@@ @@@@ @ @@@@\n **=@@@@@@@@@@% @@@@@@@@@@@\n **- :@@@@@@: :@@@@@@@: \n ";
|
|
87
89
|
|
|
88
|
-
export declare const ANSI_LOGO_COLOR:
|
|
90
|
+
export declare const ANSI_LOGO_COLOR: "\u001B[36m";
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* An application that can be ran by ProzillaOS.
|
|
@@ -210,13 +212,23 @@ export declare class App<AppProps extends WindowProps = WindowProps> {
|
|
|
210
212
|
export 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"];
|
|
211
213
|
|
|
212
214
|
export declare interface AppMetadata {
|
|
213
|
-
name
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
/** The display name of this application. */
|
|
216
|
+
name?: string;
|
|
217
|
+
/** The version of this application. */
|
|
218
|
+
version?: string;
|
|
219
|
+
/** The author of this application. */
|
|
220
|
+
author?: string;
|
|
221
|
+
/** Screenshots of this application. */
|
|
222
|
+
screenshots?: string[];
|
|
223
|
+
/** Website of this application or its developer. */
|
|
224
|
+
website?: string;
|
|
225
|
+
/** Release date of this application. */
|
|
226
|
+
releaseDate?: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export declare class AppsConfig extends EventEmitter<AppsConfigEvents> {
|
|
219
230
|
apps: AppsConfigOptions["apps"];
|
|
231
|
+
static readonly APPS_CHANGE_EVENT = "appsChange";
|
|
220
232
|
static APP_ROLES: {
|
|
221
233
|
fileExplorer: string;
|
|
222
234
|
terminal: string;
|
|
@@ -226,7 +238,22 @@ export declare class AppsConfig {
|
|
|
226
238
|
browser: string;
|
|
227
239
|
};
|
|
228
240
|
constructor(options?: Partial<AppsConfigOptions>);
|
|
241
|
+
/**
|
|
242
|
+
* Returns a list of all installed apps.
|
|
243
|
+
*/
|
|
229
244
|
get installedApps(): App<WindowProps>[];
|
|
245
|
+
onAppsChange(listener: () => void): () => void;
|
|
246
|
+
addApp(app: App<WindowProps>): void;
|
|
247
|
+
removeApp(id: string): boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Load an app from a URL or npm package and register it in the system.
|
|
250
|
+
* If an app with the same ID is already registered but uninstalled,
|
|
251
|
+
* it will be re-enabled instead of loaded again.
|
|
252
|
+
* @param target - The npm package name or URL to load the app from.
|
|
253
|
+
* @returns The loaded (or re-enabled) app.
|
|
254
|
+
*/
|
|
255
|
+
installApp(target: string, options?: LoadAppOptions): Promise<App<WindowProps>>;
|
|
256
|
+
uninstallApp(id: string): boolean;
|
|
230
257
|
/**
|
|
231
258
|
* @param id - The ID of the app.
|
|
232
259
|
* @param includeUninstalled - Include apps that are not currently installed.
|
|
@@ -246,6 +273,10 @@ export declare class AppsConfig {
|
|
|
246
273
|
getAppsByCategory(category: typeof APP_CATEGORIES[number]): App[];
|
|
247
274
|
}
|
|
248
275
|
|
|
276
|
+
export declare interface AppsConfigEvents {
|
|
277
|
+
appsChange: [];
|
|
278
|
+
}
|
|
279
|
+
|
|
249
280
|
export declare interface AppsConfigOptions {
|
|
250
281
|
/**
|
|
251
282
|
* An array of applications.
|
|
@@ -253,10 +284,114 @@ export declare interface AppsConfigOptions {
|
|
|
253
284
|
apps: App<WindowProps>[];
|
|
254
285
|
}
|
|
255
286
|
|
|
256
|
-
|
|
287
|
+
/**
|
|
288
|
+
* A sequence of strings and expansion nodes that form a single argument.
|
|
289
|
+
*/
|
|
290
|
+
declare type Argument = (string | ExpansionNode)[];
|
|
291
|
+
|
|
292
|
+
export declare interface ArithmeticEnvironment {
|
|
293
|
+
get(name: string): string | undefined;
|
|
294
|
+
set(name: string, value: string): void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Represents an arithmetic expansion (e.g., `$(( i++ ))`).
|
|
299
|
+
*/
|
|
300
|
+
declare interface ArithmeticExpansionNode extends BaseNode {
|
|
301
|
+
type: NodeType.ArithmeticExpansion;
|
|
302
|
+
content: ArithmeticNode;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare interface ArithmeticNode extends BaseNode {
|
|
306
|
+
type: NodeType.Arithmetic;
|
|
307
|
+
/** The math expression. */
|
|
308
|
+
expression: string;
|
|
309
|
+
/** Whether this node is used as a condition. */
|
|
310
|
+
isCondition: boolean;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare class ArithmeticParser {
|
|
314
|
+
private readonly env;
|
|
315
|
+
private tokens;
|
|
316
|
+
private position;
|
|
317
|
+
constructor(env: ArithmeticEnvironment);
|
|
318
|
+
evaluate(expression: string): ArithmeticParserResult;
|
|
319
|
+
private peek;
|
|
320
|
+
private pop;
|
|
321
|
+
private match;
|
|
322
|
+
private expect;
|
|
323
|
+
private consume;
|
|
324
|
+
private readVar;
|
|
325
|
+
private writeVar;
|
|
326
|
+
private parseAssignment;
|
|
327
|
+
private applyAssign;
|
|
328
|
+
private parseTernary;
|
|
329
|
+
private whileMatch;
|
|
330
|
+
private parseOr;
|
|
331
|
+
private parseAnd;
|
|
332
|
+
private parseBitOr;
|
|
333
|
+
private parseBitXor;
|
|
334
|
+
private parseBitAnd;
|
|
335
|
+
private parseEquality;
|
|
336
|
+
private parseCompare;
|
|
337
|
+
private parseShift;
|
|
338
|
+
private parseAdd;
|
|
339
|
+
private parseMultiplication;
|
|
340
|
+
private parseExponent;
|
|
341
|
+
private parseUnary;
|
|
342
|
+
private parsePrimary;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export declare type ArithmeticParserResult = Result<number, string>;
|
|
346
|
+
|
|
347
|
+
export declare const ASCII_LOGO = "\n * \n **** \n **** ***** \n **: @@@@@@ @@@@@@@ \n ** @@@@@@@@@@@@ @@@@@@@@@%\n:**+@@@@@ +@@@@ @@@@ : \n : @@@* @@@ %@@@@@@@ \n ** @@@@ @@@ *@@@@@@@\n:***#@@@@ @@@@ @ @@@@\n **=@@@@@@@@@@% @@@@@@@@@@@\n **- :@@@@@@: :@@@@@@@: \n ";
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Represents an assignment of an environment variable.
|
|
351
|
+
*/
|
|
352
|
+
declare interface AssignmentNode extends BaseNode {
|
|
353
|
+
type: NodeType.Assignment;
|
|
354
|
+
/** The name of the environment variable to assign. */
|
|
355
|
+
name: string;
|
|
356
|
+
/** The value to assign to the variable. */
|
|
357
|
+
value: Argument;
|
|
358
|
+
}
|
|
257
359
|
|
|
258
360
|
export declare const AUDIO_EXTENSIONS: string[];
|
|
259
361
|
|
|
362
|
+
/**
|
|
363
|
+
* An abstract node that uses a condition.
|
|
364
|
+
*/
|
|
365
|
+
declare interface BaseConditionNode extends BaseNode {
|
|
366
|
+
condition: ExecutableNode;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Represents a node that repeatedly executes a block of code.
|
|
371
|
+
*/
|
|
372
|
+
declare interface BaseLoopNode extends BaseRedirectionNode {
|
|
373
|
+
/** The block to execute for every iteration. */
|
|
374
|
+
body: Block;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare interface BaseNode {
|
|
378
|
+
/** The type of this node. */
|
|
379
|
+
type: NodeType;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* An abstract node that can handle I/O redirections.
|
|
384
|
+
*/
|
|
385
|
+
declare interface BaseRedirectionNode extends BaseNode {
|
|
386
|
+
/** An optional list of redirections to apply to this execution unit. */
|
|
387
|
+
redirections?: RedirectionNode[];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* A sequence of AST nodes representing a block of code.
|
|
392
|
+
*/
|
|
393
|
+
declare type Block = Node_2[];
|
|
394
|
+
|
|
260
395
|
export declare function Button({ className, href, children, icon, target, ...props }: ButtonProps): JSX_2.Element;
|
|
261
396
|
|
|
262
397
|
export declare interface ButtonProps {
|
|
@@ -268,9 +403,9 @@ export declare interface ButtonProps {
|
|
|
268
403
|
[key: string]: unknown;
|
|
269
404
|
}
|
|
270
405
|
|
|
271
|
-
declare type CategorizedOptions = Record<string, Record<string, ShortcutHandler>>;
|
|
406
|
+
export declare type CategorizedOptions = Record<string, Record<string, ShortcutHandler>>;
|
|
272
407
|
|
|
273
|
-
declare type CategorizedShortcuts = Record<string, Record<string, string[]>>;
|
|
408
|
+
export declare type CategorizedShortcuts = Record<string, Record<string, string[]>>;
|
|
274
409
|
|
|
275
410
|
export declare const ClickAction: MemoExoticComponent<({ actionId, label, shortcut, disabled, onTrigger, icon }: ClickActionProps) => JSX_2.Element>;
|
|
276
411
|
|
|
@@ -321,14 +456,34 @@ export declare class Command {
|
|
|
321
456
|
getOption(key: string): Option_2 | undefined;
|
|
322
457
|
}
|
|
323
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Represents a basic shell command to be executed.
|
|
461
|
+
*/
|
|
462
|
+
declare interface CommandNode extends BaseRedirectionNode {
|
|
463
|
+
type: NodeType.Command;
|
|
464
|
+
/** The individual arguments of the command, each potentially containing expansions. */
|
|
465
|
+
args: Argument[];
|
|
466
|
+
}
|
|
467
|
+
|
|
324
468
|
export declare type CommandOutput = number | undefined | void;
|
|
325
469
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
470
|
+
/**
|
|
471
|
+
* Represents a node that gets replaced with the output of a block of code.
|
|
472
|
+
*/
|
|
473
|
+
declare interface CommandSubstitutionNode extends BaseNode {
|
|
474
|
+
type: NodeType.CommandSubstitution;
|
|
475
|
+
/** The node to execute for substitution. */
|
|
476
|
+
content: Block;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Represents a pairing of a condition and a code block.
|
|
481
|
+
* Used for the primary IF branch and subsequent ELIF branches.
|
|
482
|
+
*/
|
|
483
|
+
declare interface ConditionalBlockNode extends BaseConditionNode {
|
|
484
|
+
type: NodeType.ConditionalBlock;
|
|
485
|
+
/** The block to execute if the condition returns {@link EXIT_CODE.success}. */
|
|
486
|
+
thenBranch: Block;
|
|
332
487
|
}
|
|
333
488
|
|
|
334
489
|
export declare type ContextMenuHandler = (event: MouseEvent_2<HTMLElement, MouseEvent_2>, params?: object) => Modal;
|
|
@@ -424,6 +579,62 @@ export declare interface DropdownButtonProps {
|
|
|
424
579
|
shortcuts: Record<string, string[]>;
|
|
425
580
|
}
|
|
426
581
|
|
|
582
|
+
/**
|
|
583
|
+
* An executable command or file.
|
|
584
|
+
*/
|
|
585
|
+
export declare type Executable = Command | VirtualFile;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Represents a node that acts as an executable unit capable of
|
|
589
|
+
* handling standard input and output streams and returning an exit code.
|
|
590
|
+
*/
|
|
591
|
+
declare type ExecutableNode = CommandNode | LogicalNode | PipelineNode | IfNode | WhileNode | ForInNode | ForExpressionNode | AssignmentNode | ArithmeticNode;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Represent the result of the resolution of an executable.
|
|
595
|
+
*/
|
|
596
|
+
export declare type ExecutableResolutionResult = Result<Executable, string>;
|
|
597
|
+
|
|
598
|
+
export declare class ExecutableResolver {
|
|
599
|
+
static builtins: Command[];
|
|
600
|
+
private static loadingTask;
|
|
601
|
+
static readonly NOT_FOUND_ERROR = "Command not found";
|
|
602
|
+
static readonly IS_DIRECTORY_ERROR = "Is a directory";
|
|
603
|
+
/**
|
|
604
|
+
* Finds the executable with the given name.
|
|
605
|
+
* @param name - The name of the executable.
|
|
606
|
+
* @param env - The environment to read the path variable from.
|
|
607
|
+
* @param workingDirectory - The directory to search in.
|
|
608
|
+
*/
|
|
609
|
+
static resolve(name: string, env: ShellEnvironment, workingDirectory: VirtualFolder): Promise<ExecutableResolutionResult>;
|
|
610
|
+
/**
|
|
611
|
+
* Resolves a specific path to a {@link VirtualFile}.
|
|
612
|
+
* @param path - The path to navigate to.
|
|
613
|
+
* @param workingDirectory - The directory to start the navigation from.
|
|
614
|
+
* @returns The resolved file or a failure if this is a directory or does not exist.
|
|
615
|
+
*/
|
|
616
|
+
private static resolvePath;
|
|
617
|
+
/**
|
|
618
|
+
* Attempts to resolve an executable by searching through the directories defined in the PATH variable.
|
|
619
|
+
* @param name - The name of the executable.
|
|
620
|
+
* @param env - The environment containing the PATH variable.
|
|
621
|
+
* @param workingDirectory - The directory to use for path resolution.
|
|
622
|
+
* @returns The first matching executable found in the PATH.
|
|
623
|
+
*/
|
|
624
|
+
private static resolveFromPathVariable;
|
|
625
|
+
/**
|
|
626
|
+
* Finds the builtin command with the given name.
|
|
627
|
+
* @param name - The name of the builtin.
|
|
628
|
+
* @returns The builtin with the given name, or `null` if there is none.
|
|
629
|
+
*/
|
|
630
|
+
static getBuiltin(name: string): Command | null;
|
|
631
|
+
/**
|
|
632
|
+
* Loads all builtins.
|
|
633
|
+
* @returns A promise that resolves when all builtins have finished loading.
|
|
634
|
+
*/
|
|
635
|
+
static loadBuiltins(): Promise<void>;
|
|
636
|
+
}
|
|
637
|
+
|
|
427
638
|
export declare type Execute = (args: string[], context: ShellContext) => Promise<CommandOutput> | CommandOutput;
|
|
428
639
|
|
|
429
640
|
export declare const EXIT_CODE: {
|
|
@@ -433,9 +644,11 @@ export declare const EXIT_CODE: {
|
|
|
433
644
|
readonly commandNotExecutable: 126;
|
|
434
645
|
readonly commandNotFound: 127;
|
|
435
646
|
readonly invalidExitArgument: 128;
|
|
436
|
-
readonly
|
|
647
|
+
readonly interrupted: 130;
|
|
437
648
|
};
|
|
438
649
|
|
|
650
|
+
declare type ExpansionNode = ParameterExpansionNode | ArithmeticExpansionNode | CommandSubstitutionNode;
|
|
651
|
+
|
|
439
652
|
export declare const FILE_SCHEMES: {
|
|
440
653
|
external: string;
|
|
441
654
|
app: string;
|
|
@@ -443,12 +656,73 @@ export declare const FILE_SCHEMES: {
|
|
|
443
656
|
|
|
444
657
|
export declare type FileEventHandler = (event: Event, file: VirtualFile) => void;
|
|
445
658
|
|
|
446
|
-
|
|
659
|
+
/**
|
|
660
|
+
* A stream that reads content from a {@link VirtualFile} and pushes it into the stream buffer.
|
|
661
|
+
*/
|
|
662
|
+
export declare class FileInputStream extends Stream {
|
|
663
|
+
private file;
|
|
664
|
+
constructor(file: VirtualFile);
|
|
665
|
+
private init;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* A stream that collects written data and saves it to a {@link VirtualFile} upon completion.
|
|
670
|
+
*/
|
|
671
|
+
export declare class FileOutputStream extends Stream {
|
|
672
|
+
private file;
|
|
673
|
+
private writeBuffer;
|
|
674
|
+
constructor(file: VirtualFile);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export declare type FlatOptions = Record<string, ShortcutHandler>;
|
|
447
678
|
|
|
448
|
-
declare type FlatShortcuts = Record<string, string[]>;
|
|
679
|
+
export declare type FlatShortcuts = Record<string, string[]>;
|
|
449
680
|
|
|
450
681
|
export declare type FolderEventHandler = (event: Event, folder: VirtualFolder) => void;
|
|
451
682
|
|
|
683
|
+
export declare interface FontMetrics {
|
|
684
|
+
/** The dimensions of a single character, in pixels. */
|
|
685
|
+
charSize: Vector2;
|
|
686
|
+
/** The dimensions of the container, in rows and columns. */
|
|
687
|
+
containerSize: Vector2;
|
|
688
|
+
/** The element to attach to the container, used for doing measurements. */
|
|
689
|
+
sentinel: ReactElement;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export declare interface FontMetricsParams {
|
|
693
|
+
/** A reactive reference to the container element. */
|
|
694
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
695
|
+
/**
|
|
696
|
+
* The string to use for character measurements.
|
|
697
|
+
* @default "M".repeat(100)
|
|
698
|
+
*/
|
|
699
|
+
testString?: string;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* A C-style `for` loop structure with a setup, condition and step.
|
|
704
|
+
*/
|
|
705
|
+
declare interface ForExpressionNode extends BaseLoopNode {
|
|
706
|
+
type: NodeType.ForExpression;
|
|
707
|
+
/** The node to execute before the loop. */
|
|
708
|
+
setup: ArithmeticNode;
|
|
709
|
+
/** The condition that determines whether the loop should continue. */
|
|
710
|
+
condition: ArithmeticNode;
|
|
711
|
+
/** The node to execute after each iteration of the loop. */
|
|
712
|
+
step: ArithmeticNode;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Represents a `for` loop structure for iterating over a list of items.
|
|
717
|
+
*/
|
|
718
|
+
declare interface ForInNode extends BaseLoopNode {
|
|
719
|
+
type: NodeType.ForIn;
|
|
720
|
+
/** The name of the environment variable assigned to the current item. */
|
|
721
|
+
variableName: string;
|
|
722
|
+
/** The list of raw strings or patterns to iterate over. */
|
|
723
|
+
items: Argument[];
|
|
724
|
+
}
|
|
725
|
+
|
|
452
726
|
/**
|
|
453
727
|
* Formats a shortcut (combination of keys) into a human-readable format.
|
|
454
728
|
*
|
|
@@ -475,18 +749,34 @@ export declare function HeaderMenu({ children, ...props }: ActionsProps): JSX_2.
|
|
|
475
749
|
* Represents a single entry in the shell's output history.
|
|
476
750
|
*/
|
|
477
751
|
export declare interface HistoryEntry {
|
|
478
|
-
/** The text content to display. */
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
752
|
+
/** The text content to display in the terminal. */
|
|
753
|
+
displayText?: string;
|
|
754
|
+
/** The raw input string of the command in this entry. */
|
|
755
|
+
input?: string;
|
|
756
|
+
flags: HistoryFlags;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
export declare enum HistoryFlags {
|
|
760
|
+
None = 0,
|
|
761
|
+
Command = 1,
|
|
762
|
+
Clear = 2
|
|
486
763
|
}
|
|
487
764
|
|
|
488
765
|
export declare const HOSTNAME = "prozilla-os";
|
|
489
766
|
|
|
767
|
+
/**
|
|
768
|
+
* Represents a conditional branching structure.
|
|
769
|
+
*/
|
|
770
|
+
declare interface IfNode extends BaseRedirectionNode {
|
|
771
|
+
type: NodeType.If;
|
|
772
|
+
/** The primary conditional branch. */
|
|
773
|
+
ifBranch: ConditionalBlockNode;
|
|
774
|
+
/** An array of additional conditional branches. */
|
|
775
|
+
elifBranches: ConditionalBlockNode[];
|
|
776
|
+
/** The block to execute if no conditions are met. */
|
|
777
|
+
elseBranch: Block;
|
|
778
|
+
}
|
|
779
|
+
|
|
490
780
|
declare function Image_2({ className, src, ...props }: ImageProps): JSX_2.Element;
|
|
491
781
|
export { Image_2 as Image }
|
|
492
782
|
|
|
@@ -506,6 +796,22 @@ export declare interface ImageProps {
|
|
|
506
796
|
[key: string]: unknown;
|
|
507
797
|
}
|
|
508
798
|
|
|
799
|
+
export declare interface InputStream<T = string> {
|
|
800
|
+
read(): Promise<Result<T | null, StreamError>>;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export declare interface InstalledAppsOptions {
|
|
804
|
+
/**
|
|
805
|
+
* Comparator function (defaults to alphabetical by name) or a boolean.
|
|
806
|
+
* If the value is `true`, the default sorting function is used, if it is `false`, the sorting step is skipped.
|
|
807
|
+
*/
|
|
808
|
+
sort?: ((a: App, b: App) => number) | boolean;
|
|
809
|
+
/**
|
|
810
|
+
* Optional predicate to narrow the list.
|
|
811
|
+
*/
|
|
812
|
+
filter?: (app: App) => boolean;
|
|
813
|
+
}
|
|
814
|
+
|
|
509
815
|
/**
|
|
510
816
|
* Button component that handles single and double clicks.
|
|
511
817
|
*/
|
|
@@ -522,6 +828,29 @@ export declare interface InteractableProps {
|
|
|
522
828
|
|
|
523
829
|
export declare function isValidUrl(string: string): boolean;
|
|
524
830
|
|
|
831
|
+
/**
|
|
832
|
+
* Load an app from either a URL or an npm package name (auto-detected).
|
|
833
|
+
*/
|
|
834
|
+
export declare function loadApp(appNameOrUrl: string, options?: LoadAppOptions): Promise<App<WindowProps>>;
|
|
835
|
+
|
|
836
|
+
export declare interface LoadAppOptions {
|
|
837
|
+
/**
|
|
838
|
+
* The name of the export that contains the App instance.
|
|
839
|
+
* If not specified, checks `app` first, then `default`.
|
|
840
|
+
*/
|
|
841
|
+
exportName?: string;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Represents logical execution flow (`&&` or `||`).
|
|
846
|
+
*/
|
|
847
|
+
declare interface LogicalNode extends BaseRedirectionNode {
|
|
848
|
+
type: NodeType.Logical;
|
|
849
|
+
left: ExecutableNode;
|
|
850
|
+
operator: "&&" | "||";
|
|
851
|
+
right: ExecutableNode;
|
|
852
|
+
}
|
|
853
|
+
|
|
525
854
|
/**
|
|
526
855
|
* Documentation metadata used by the `help` or `man` commands.
|
|
527
856
|
*/
|
|
@@ -693,6 +1022,28 @@ export declare type ModalsManagerState = ModalsManager | undefined;
|
|
|
693
1022
|
*/
|
|
694
1023
|
export declare const ModalsView: MemoExoticComponent<() => JSX_2.Element>;
|
|
695
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* Represents a node in the shell's Abstract Syntax Tree (AST).
|
|
1027
|
+
*/
|
|
1028
|
+
declare type Node_2 = ExecutableNode | ConditionalBlockNode | ExpansionNode;
|
|
1029
|
+
|
|
1030
|
+
declare enum NodeType {
|
|
1031
|
+
Command = "command",
|
|
1032
|
+
Logical = "logical",
|
|
1033
|
+
Pipeline = "pipeline",
|
|
1034
|
+
If = "if",
|
|
1035
|
+
ConditionalBlock = "conditionalBlock",
|
|
1036
|
+
While = "while",
|
|
1037
|
+
ForIn = "forIn",
|
|
1038
|
+
ForExpression = "forExpression",
|
|
1039
|
+
Assignment = "assignment",
|
|
1040
|
+
Arithmetic = "arithmetic",
|
|
1041
|
+
ParameterExpansion = "parameterExpansion",
|
|
1042
|
+
ArithmeticExpansion = "arithmeticExpansion",
|
|
1043
|
+
CommandSubstitution = "commandSubstitution",
|
|
1044
|
+
Redirection = "redirection"
|
|
1045
|
+
}
|
|
1046
|
+
|
|
696
1047
|
export declare function NoRoute(): JSX_2.Element;
|
|
697
1048
|
|
|
698
1049
|
export declare interface NoRouteProps {
|
|
@@ -746,6 +1097,10 @@ export { Option_2 as Option }
|
|
|
746
1097
|
|
|
747
1098
|
export declare type OptionalStringProperty = string | null | undefined;
|
|
748
1099
|
|
|
1100
|
+
export declare interface OutputStream<T = string> {
|
|
1101
|
+
write(data: T): Promise<Result<void, StreamError>>;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
749
1104
|
/**
|
|
750
1105
|
* Component that calls a function when the user clicks outside of it.
|
|
751
1106
|
*/
|
|
@@ -757,6 +1112,31 @@ export declare interface OutsideClickListenerProps {
|
|
|
757
1112
|
children: ReactNode;
|
|
758
1113
|
}
|
|
759
1114
|
|
|
1115
|
+
/**
|
|
1116
|
+
* Represents a parameter expansion (e.g., `${HOME}`).
|
|
1117
|
+
*/
|
|
1118
|
+
declare interface ParameterExpansionNode extends BaseNode {
|
|
1119
|
+
type: NodeType.ParameterExpansion;
|
|
1120
|
+
/** The name of the variable (e.g., `"HOME"` in `${HOME}`). */
|
|
1121
|
+
name: string;
|
|
1122
|
+
/** The expansion operator. */
|
|
1123
|
+
operator?: "-" | "=" | "+" | "?";
|
|
1124
|
+
/** The optional argument following the operator, which may contain further expansions. */
|
|
1125
|
+
argument?: Argument;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Represents a sequence of commands where the output of one is piped to the next.
|
|
1130
|
+
*/
|
|
1131
|
+
declare interface PipelineNode extends BaseRedirectionNode {
|
|
1132
|
+
type: NodeType.Pipeline;
|
|
1133
|
+
/**
|
|
1134
|
+
* A list of executable nodes where the `stdout` of one
|
|
1135
|
+
* is connected to the `stdin` of the next.
|
|
1136
|
+
*/
|
|
1137
|
+
commands: ExecutableNode[];
|
|
1138
|
+
}
|
|
1139
|
+
|
|
760
1140
|
/**
|
|
761
1141
|
* Represents an active or pending process within the shell.
|
|
762
1142
|
*/
|
|
@@ -777,6 +1157,8 @@ export declare interface ProcessIO {
|
|
|
777
1157
|
stdout: Stream;
|
|
778
1158
|
/** The stream used to output error messages. */
|
|
779
1159
|
stderr: Stream;
|
|
1160
|
+
/** The environment the process may read from or write to. */
|
|
1161
|
+
env: ShellEnvironment;
|
|
780
1162
|
}
|
|
781
1163
|
|
|
782
1164
|
/**
|
|
@@ -831,6 +1213,19 @@ export declare interface RadioActionProps extends ActionProps {
|
|
|
831
1213
|
initialIndex?: number;
|
|
832
1214
|
}
|
|
833
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Represents a file descriptor redirection.
|
|
1218
|
+
*/
|
|
1219
|
+
declare interface RedirectionNode extends BaseNode {
|
|
1220
|
+
type: NodeType.Redirection;
|
|
1221
|
+
/** The file descriptor to redirect (e.g., 0 for stdin, 1 for stdout, 2 for stderr). */
|
|
1222
|
+
fileDescriptor: number;
|
|
1223
|
+
/** The redirection operator. */
|
|
1224
|
+
operator: ">" | ">>" | "<" | "<&" | ">&";
|
|
1225
|
+
/** The target of the redirection, usually a file path or another file descriptor. */
|
|
1226
|
+
target: Argument;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
834
1229
|
/**
|
|
835
1230
|
* Reloads the viewport.
|
|
836
1231
|
*/
|
|
@@ -965,7 +1360,6 @@ export declare class Shell {
|
|
|
965
1360
|
env: ShellEnvironment;
|
|
966
1361
|
/** The logic handler for parsing and executing command strings. */
|
|
967
1362
|
interpreter: ShellInterpreter;
|
|
968
|
-
static readonly COMMAND_NOT_FOUND_ERROR = "Command not found";
|
|
969
1363
|
static readonly MISSING_ARGS_ERROR = "requires at least 1 argument";
|
|
970
1364
|
static readonly MISSING_OPTIONS_ERROR = "requires at least 1 option";
|
|
971
1365
|
static readonly COMMAND_FAILED_ERROR = "Command failed";
|
|
@@ -973,8 +1367,16 @@ export declare class Shell {
|
|
|
973
1367
|
static readonly INVALID_PATH_ERROR = "No such file or directory";
|
|
974
1368
|
static readonly SUDO_COMMAND = "sudo";
|
|
975
1369
|
/** Regex used to strip specific ANSI escape codes from the TTY buffer. */
|
|
976
|
-
static readonly STRIP_ANSI_REGEX
|
|
1370
|
+
private static readonly STRIP_ANSI_REGEX;
|
|
1371
|
+
private static readonly CURSOR_REGEX;
|
|
1372
|
+
private static readonly KEY_TO_ANSI;
|
|
977
1373
|
constructor(config: ShellConfig);
|
|
1374
|
+
handleKeyDown(event: Pick<KeyboardEvent_2, "key" | "preventDefault"> & Partial<Pick<KeyboardEvent_2, "ctrlKey" | "metaKey" | "shiftKey">>): Promise<void>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Toggles raw mode, which forwards all keystrokes directly to the active stream.
|
|
1377
|
+
* @param rawMode - Whether to enable raw mode.
|
|
1378
|
+
*/
|
|
1379
|
+
setRawMode(rawMode: boolean): void;
|
|
978
1380
|
/**
|
|
979
1381
|
* Sends a signal to the shell or the currently active foreground process.
|
|
980
1382
|
* @param signal - The signal to send. Defaults to `"SIGTERM"`.
|
|
@@ -991,9 +1393,9 @@ export declare class Shell {
|
|
|
991
1393
|
*/
|
|
992
1394
|
kill(): void;
|
|
993
1395
|
/**
|
|
994
|
-
*
|
|
1396
|
+
* Refreshes the prompt string based on the current user, hostname, and working directory.
|
|
995
1397
|
*/
|
|
996
|
-
updatePrompt(): void
|
|
1398
|
+
updatePrompt(): Promise<void>;
|
|
997
1399
|
/**
|
|
998
1400
|
* Updates the text in the current input line.
|
|
999
1401
|
* @param value - The new string value or a function that receives the previous value.
|
|
@@ -1010,7 +1412,7 @@ export declare class Shell {
|
|
|
1010
1412
|
*/
|
|
1011
1413
|
write(text: string): void;
|
|
1012
1414
|
/**
|
|
1013
|
-
*
|
|
1415
|
+
* Submits the current input line and executes the given command string.
|
|
1014
1416
|
* @param input - The command string to execute.
|
|
1015
1417
|
* @returns A promise that resolves with the final exit code of the execution.
|
|
1016
1418
|
*/
|
|
@@ -1039,6 +1441,27 @@ export declare class Shell {
|
|
|
1039
1441
|
* If multiple are found, it lists them in the history.
|
|
1040
1442
|
*/
|
|
1041
1443
|
autoComplete(): void;
|
|
1444
|
+
/**
|
|
1445
|
+
* Sets the shell to raw mode, listens for input on stdin.
|
|
1446
|
+
* @param stdin - The standard input stream.
|
|
1447
|
+
* @param onData - The callback to handle incoming data chunks.
|
|
1448
|
+
*/
|
|
1449
|
+
readRawInput(stdin: Stream, onData: (data: string) => void | Promise<void>): Promise<void>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Processes a list of paths, falling back to standard input if the list is empty or contains "-".
|
|
1452
|
+
* @param params.paths - The list of file paths or "-" for stdin.
|
|
1453
|
+
* @param params.workingDirectory - The directory to resolve paths against.
|
|
1454
|
+
* @param params.commandName - The name of the command invoking this utility.
|
|
1455
|
+
* @param params.onContent - Callback for file content.
|
|
1456
|
+
* @param params.onStdinData - Callback for standard input data.
|
|
1457
|
+
*/
|
|
1458
|
+
readFiles({ paths, workingDirectory, stdin, stderr, commandName, onContent, onStdinData, }: {
|
|
1459
|
+
paths: string[];
|
|
1460
|
+
workingDirectory: VirtualFolder;
|
|
1461
|
+
commandName: string;
|
|
1462
|
+
onContent: (content: string) => void | Promise<void>;
|
|
1463
|
+
onStdinData: (data: string) => void | Promise<void>;
|
|
1464
|
+
} & Pick<ProcessIO, "stdin" | "stderr">): Promise<number>;
|
|
1042
1465
|
/**
|
|
1043
1466
|
* Utility to write a formatted error message to a stream and return an exit code.
|
|
1044
1467
|
* @param stream - The stream to receive the error output.
|
|
@@ -1047,12 +1470,21 @@ export declare class Shell {
|
|
|
1047
1470
|
* @param exitCode - The numerical exit code to return.
|
|
1048
1471
|
* @returns `exitCode`.
|
|
1049
1472
|
*/
|
|
1050
|
-
static writeError(stream: Stream, commandName: string, error?: string | string[], exitCode?: number): number
|
|
1473
|
+
static writeError(stream: Stream, commandName: string, error?: string | string[], exitCode?: number): Promise<number>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Executes a task repeatedly and writes its output to `stdout`.
|
|
1476
|
+
* @returns A promise that resolves when the loop is finished.
|
|
1477
|
+
*/
|
|
1478
|
+
static loop({ stdout, stdin, task, delay, maxIterations }: Pick<ProcessIO, "stdout" | "stdin"> & {
|
|
1479
|
+
task: () => string;
|
|
1480
|
+
delay?: number;
|
|
1481
|
+
maxIterations?: number;
|
|
1482
|
+
}): Promise<0>;
|
|
1051
1483
|
/**
|
|
1052
1484
|
* Executes a frame-based animation in the terminal using the Alternate Screen Buffer.
|
|
1053
1485
|
* @returns A promise that resolves when the animation is stopped.
|
|
1054
1486
|
*/
|
|
1055
|
-
static animate({ stdout, stdin, render, delay, clear, stopOnBlank }: Pick<
|
|
1487
|
+
static animate({ stdout, stdin, render, delay, clear, stopOnBlank, useAltBuffer }: Pick<ProcessIO, "stdout" | "stdin"> & {
|
|
1056
1488
|
/** The function that renders each frame. */
|
|
1057
1489
|
render: (frame: number) => string;
|
|
1058
1490
|
/** The delay between each frame, in ms. */
|
|
@@ -1061,6 +1493,8 @@ export declare class Shell {
|
|
|
1061
1493
|
clear?: boolean;
|
|
1062
1494
|
/** Whether to stop the animation when the rendered frame is blank. */
|
|
1063
1495
|
stopOnBlank?: boolean;
|
|
1496
|
+
/** Whether to use the alt buffer while rendering this animation. */
|
|
1497
|
+
useAltBuffer?: boolean;
|
|
1064
1498
|
}): Promise<0>;
|
|
1065
1499
|
/**
|
|
1066
1500
|
* Reads input data. If `rawLine` is provided, it processes it immediately via the callback.
|
|
@@ -1069,7 +1503,42 @@ export declare class Shell {
|
|
|
1069
1503
|
* @param stdin - The input stream to fall back on.
|
|
1070
1504
|
* @param callback - Function to process the collected input data.
|
|
1071
1505
|
*/
|
|
1072
|
-
static readInput(rawLine: string, stdin: Stream, callback: (data: string) => CommandOutput): Promise<CommandOutput>;
|
|
1506
|
+
static readInput(rawLine: string, stdin: Stream, callback: (data: string) => Promise<CommandOutput> | CommandOutput): Promise<CommandOutput>;
|
|
1507
|
+
/**
|
|
1508
|
+
* Utility function that writes `text` followed by a newline (`"\n"`) to `stream`.
|
|
1509
|
+
* @param stream - The stream to write to.
|
|
1510
|
+
* @param text - The text to write.
|
|
1511
|
+
*/
|
|
1512
|
+
static printLn(stream: Stream, text?: string): Promise<void>;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
export declare namespace ShellAST {
|
|
1516
|
+
export {
|
|
1517
|
+
NodeType,
|
|
1518
|
+
BaseNode,
|
|
1519
|
+
BaseConditionNode,
|
|
1520
|
+
BaseRedirectionNode,
|
|
1521
|
+
ConditionalBlockNode,
|
|
1522
|
+
Argument,
|
|
1523
|
+
ParameterExpansionNode,
|
|
1524
|
+
ArithmeticExpansionNode,
|
|
1525
|
+
CommandSubstitutionNode,
|
|
1526
|
+
ExpansionNode,
|
|
1527
|
+
RedirectionNode,
|
|
1528
|
+
CommandNode,
|
|
1529
|
+
LogicalNode,
|
|
1530
|
+
PipelineNode,
|
|
1531
|
+
IfNode,
|
|
1532
|
+
BaseLoopNode,
|
|
1533
|
+
WhileNode,
|
|
1534
|
+
ForInNode,
|
|
1535
|
+
ForExpressionNode,
|
|
1536
|
+
AssignmentNode,
|
|
1537
|
+
ArithmeticNode,
|
|
1538
|
+
ExecutableNode,
|
|
1539
|
+
Node_2 as Node,
|
|
1540
|
+
Block
|
|
1541
|
+
}
|
|
1073
1542
|
}
|
|
1074
1543
|
|
|
1075
1544
|
/**
|
|
@@ -1136,16 +1605,18 @@ export declare interface ShellContext extends ProcessIO {
|
|
|
1136
1605
|
*/
|
|
1137
1606
|
export declare class ShellEnvironment {
|
|
1138
1607
|
store: Record<string, string>;
|
|
1139
|
-
parent
|
|
1140
|
-
exportedKeys
|
|
1608
|
+
private parent;
|
|
1609
|
+
private exportedKeys;
|
|
1141
1610
|
static readonly USER = "USER";
|
|
1142
1611
|
static readonly HOSTNAME = "HOSTNAME";
|
|
1143
1612
|
static readonly WORKING_DIRECTORY = "PWD";
|
|
1144
1613
|
static readonly PREVIOUS_WORKING_DIRECTORY = "OLDPWD";
|
|
1614
|
+
static readonly HOME = "HOME";
|
|
1615
|
+
static readonly PROMPT = "PS1";
|
|
1145
1616
|
static readonly EXIT_CODE = "?";
|
|
1146
1617
|
static readonly ARGUMENT_COUNT = "#";
|
|
1147
1618
|
static readonly PROCESS_ID = "$";
|
|
1148
|
-
/**
|
|
1619
|
+
/** Array of variables that should never be exported. */
|
|
1149
1620
|
static readonly INTERNAL_VARS: string[];
|
|
1150
1621
|
constructor(initialVars?: Record<string, string>, parent?: ShellEnvironment | null);
|
|
1151
1622
|
get(key: string): string | undefined;
|
|
@@ -1155,14 +1626,16 @@ export declare class ShellEnvironment {
|
|
|
1155
1626
|
*/
|
|
1156
1627
|
export(key: string): void;
|
|
1157
1628
|
/**
|
|
1158
|
-
* Replaces variable placeholders in a string with their corresponding values.
|
|
1629
|
+
* Replaces variable placeholders in a string with their corresponding values based on a pre-parsed node.
|
|
1630
|
+
* The expandedArgument must be pre-resolved by the interpreter to handle nested expansions.
|
|
1159
1631
|
*/
|
|
1160
|
-
expand(
|
|
1632
|
+
expand(node: ShellAST.ParameterExpansionNode, expandedArgument?: string): string;
|
|
1161
1633
|
/**
|
|
1162
1634
|
* Parses an assignment string (e.g., KEY=VALUE) and updates the environment.
|
|
1163
1635
|
* @returns `true` if the string was a valid assignment.
|
|
1164
1636
|
*/
|
|
1165
1637
|
parseAssignment(input: string): boolean;
|
|
1638
|
+
setCommandArguments(commandName: string, args: string[]): void;
|
|
1166
1639
|
/**
|
|
1167
1640
|
* Returns only variables that are marked for export.
|
|
1168
1641
|
*/
|
|
@@ -1184,6 +1657,7 @@ export declare class ShellEnvironment {
|
|
|
1184
1657
|
export declare class ShellInterpreter {
|
|
1185
1658
|
private shell;
|
|
1186
1659
|
pipeline: Process[];
|
|
1660
|
+
private static readonly PROMPT_ESCAPES;
|
|
1187
1661
|
constructor(shell: Shell);
|
|
1188
1662
|
/**
|
|
1189
1663
|
* Sends a termination signal to all processes currently in the pipeline.
|
|
@@ -1192,29 +1666,206 @@ export declare class ShellInterpreter {
|
|
|
1192
1666
|
terminatePipeline(signal: StreamSignal): void;
|
|
1193
1667
|
/**
|
|
1194
1668
|
* Parses and executes a shell script.
|
|
1195
|
-
* @param
|
|
1669
|
+
* @param input - The script content or a virtual file.
|
|
1670
|
+
* @param io - Optional output streams to override default TTY behavior.
|
|
1196
1671
|
* @returns The exit code of the last command executed in the script.
|
|
1197
1672
|
*/
|
|
1198
|
-
|
|
1673
|
+
execute(input: string | VirtualFile, io?: Partial<ProcessIO>): Promise<number>;
|
|
1199
1674
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1675
|
+
* Executes a block of nodes, passing along stream overrides.
|
|
1676
|
+
*/
|
|
1677
|
+
private executeBlock;
|
|
1678
|
+
/**
|
|
1679
|
+
* Dispatches an AST node to its specific execution logic.
|
|
1680
|
+
*/
|
|
1681
|
+
private executeNode;
|
|
1682
|
+
private executeLogicalNode;
|
|
1683
|
+
private executeAssignmentNode;
|
|
1684
|
+
private executeIfNode;
|
|
1685
|
+
private executeWhileNode;
|
|
1686
|
+
private executeForInNode;
|
|
1687
|
+
private executeForExpressionNode;
|
|
1688
|
+
/**
|
|
1689
|
+
* Handles the piping logic for any list of executable nodes.
|
|
1204
1690
|
*/
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1691
|
+
private executeCommands;
|
|
1692
|
+
private createPipeline;
|
|
1693
|
+
private linkStreams;
|
|
1694
|
+
private evaluateArgument;
|
|
1695
|
+
private captureCommandOutput;
|
|
1696
|
+
private removeQuotes;
|
|
1697
|
+
/**
|
|
1698
|
+
* Evaluates an arithmetic expression using an {@link ArithmeticParser} and returns an exit code.
|
|
1699
|
+
* @param node - The arithmetic operation.
|
|
1700
|
+
* @param env - The {@link ShellEnvironment} used for variable resolution within this instance.
|
|
1701
|
+
* @returns `EXIT_CODE.success` if the {@link ArithmeticParserResult} is successful and non-zero,
|
|
1702
|
+
* or `EXIT_CODE.generalError` otherwise.
|
|
1703
|
+
*/
|
|
1704
|
+
evaluateArithmetic(node: ShellAST.ArithmeticNode, env: ShellEnvironment): number;
|
|
1705
|
+
private executeRedirections;
|
|
1209
1706
|
/**
|
|
1210
1707
|
* Resolves a command, parses flags/options, and executes the command logic.
|
|
1211
1708
|
* @returns The resulting exit code from the command execution.
|
|
1212
1709
|
*/
|
|
1213
|
-
spawn
|
|
1710
|
+
private spawn;
|
|
1214
1711
|
/**
|
|
1215
|
-
*
|
|
1712
|
+
* Evaluates a prompt string by resolving escape sequences and shell expansions.
|
|
1216
1713
|
*/
|
|
1217
|
-
|
|
1714
|
+
evaluatePrompt(format: string, env?: ShellEnvironment): Promise<string>;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* A static utility class for parsing shell scripts into an Abstract Syntax Tree (AST).
|
|
1719
|
+
* Handles tokenization, control flow parsing (if, while, for), and shell-specific expansions.
|
|
1720
|
+
* @hideconstructor
|
|
1721
|
+
*/
|
|
1722
|
+
export declare class ShellParser {
|
|
1723
|
+
static readonly KEYWORD_IF = "if";
|
|
1724
|
+
static readonly KEYWORD_THEN = "then";
|
|
1725
|
+
static readonly KEYWORD_ELIF = "elif";
|
|
1726
|
+
static readonly KEYWORD_ELSE = "else";
|
|
1727
|
+
static readonly KEYWORD_FI = "fi";
|
|
1728
|
+
static readonly KEYWORD_WHILE = "while";
|
|
1729
|
+
static readonly KEYWORD_FOR = "for";
|
|
1730
|
+
static readonly KEYWORD_DO = "do";
|
|
1731
|
+
static readonly KEYWORD_DONE = "done";
|
|
1732
|
+
static readonly KEYWORD_IN = "in";
|
|
1733
|
+
static readonly ARITHMETIC_PREFIX_TOKEN = "((";
|
|
1734
|
+
static readonly ARITHMETIC_SUFFIX_TOKEN = "))";
|
|
1735
|
+
/**
|
|
1736
|
+
* High-level method to transform a raw script string into a structured AST.
|
|
1737
|
+
* @param script - The raw shell script string.
|
|
1738
|
+
* @returns An array of AST nodes representing the script execution flow.
|
|
1739
|
+
*/
|
|
1740
|
+
static parseScript(script: string): ShellAST.Block;
|
|
1741
|
+
private static tokenizeLine;
|
|
1742
|
+
/**
|
|
1743
|
+
* Splits an input string into tokens.
|
|
1744
|
+
* @param input - The raw string to tokenize.
|
|
1745
|
+
* @returns An array of trimmed, non-empty token strings.
|
|
1746
|
+
*/
|
|
1747
|
+
private static tokenize;
|
|
1748
|
+
/**
|
|
1749
|
+
* Iteratively parses lines into AST nodes until an end token is reached or lines run out.
|
|
1750
|
+
* @param lines - The array of tokenized lines.
|
|
1751
|
+
* @param startIndex - The index to start parsing from.
|
|
1752
|
+
* @param endTokens - Tokens that signal the end of a block (e.g., `fi`, `done`).
|
|
1753
|
+
* @returns An object containing the parsed nodes and the stopping context.
|
|
1754
|
+
*/
|
|
1755
|
+
private static parseStatements;
|
|
1756
|
+
/**
|
|
1757
|
+
* If `keyword` appears on `lines[index]` and has trailing content, rewrites the line to
|
|
1758
|
+
* start at that content and returns the same index (so it gets re-processed). Otherwise
|
|
1759
|
+
* advances past the keyword-only line and returns the incremented index.
|
|
1760
|
+
*/
|
|
1761
|
+
private static advancePastKeyword;
|
|
1762
|
+
/**
|
|
1763
|
+
* Parses `if`/`elif`/`else` blocks into an {@link ShellAST.IfNode}.
|
|
1764
|
+
* @param lines - The array of tokenized lines.
|
|
1765
|
+
* @param startIndex - The line index where the `if` starts.
|
|
1766
|
+
* @returns The generated {@link ShellAST.IfNode} and the index to resume parsing.
|
|
1767
|
+
*/
|
|
1768
|
+
private static parseIf;
|
|
1769
|
+
/**
|
|
1770
|
+
* Parses an `elif` branch, returning the branch data and the end token that stopped it.
|
|
1771
|
+
*/
|
|
1772
|
+
private static parseElifBranch;
|
|
1773
|
+
/**
|
|
1774
|
+
* Parses an `else` branch of an `if` block, returning its body and the end token (`fi`).
|
|
1775
|
+
*/
|
|
1776
|
+
private static parseElseBranch;
|
|
1777
|
+
/**
|
|
1778
|
+
* Parses a while-loop structure into a {@link ShellAST.WhileNode}.
|
|
1779
|
+
* @param lines - The tokenized lines.
|
|
1780
|
+
* @param startIndex - The line index where the `while` starts.
|
|
1781
|
+
* @returns The generated {@link ShellAST.WhileNode} and next index.
|
|
1782
|
+
*/
|
|
1783
|
+
private static parseWhile;
|
|
1784
|
+
/**
|
|
1785
|
+
* Parses a for-loop structure into a {@link ShellAST.ForNode}, extracting the iterator variable and items.
|
|
1786
|
+
* @param lines - The tokenized lines.
|
|
1787
|
+
* @param startIndex - The line index where the `for` starts.
|
|
1788
|
+
* @returns The generated {@link ShellAST.ForNode} and next index.
|
|
1789
|
+
*/
|
|
1790
|
+
private static parseFor;
|
|
1791
|
+
/**
|
|
1792
|
+
* Converts an array of lines into a {@link ShellAST.ForExpressionNode}.
|
|
1793
|
+
*/
|
|
1794
|
+
private static parseForExpression;
|
|
1795
|
+
/**
|
|
1796
|
+
* Converts an array of lines into a {@link ShellAST.ForInNode}.
|
|
1797
|
+
*/
|
|
1798
|
+
private static parseForIn;
|
|
1799
|
+
/**
|
|
1800
|
+
* Extracts redirection nodes from a sequence of tokens, returning the remaining
|
|
1801
|
+
* arguments and the extracted redirections.
|
|
1802
|
+
*/
|
|
1803
|
+
private static parseRedirections;
|
|
1804
|
+
/**
|
|
1805
|
+
* Converts a line into an {@link ShellAST.AssignmentNode}.
|
|
1806
|
+
*/
|
|
1807
|
+
private static parseAssignment;
|
|
1808
|
+
/**
|
|
1809
|
+
* Converts an expression string into an {@link ShellAST.ArithmeticNode}.
|
|
1810
|
+
*/
|
|
1811
|
+
private static parseArithmetic;
|
|
1812
|
+
/**
|
|
1813
|
+
* Converts a condition string into an {@link ShellAST.ExecutableNode}.
|
|
1814
|
+
*/
|
|
1815
|
+
private static resolveCondition;
|
|
1816
|
+
private static splitByOperators;
|
|
1817
|
+
/**
|
|
1818
|
+
* Converts an input string into a {@link ShellAST.ExecutableNode}.
|
|
1819
|
+
*/
|
|
1820
|
+
private static parseCommand;
|
|
1821
|
+
/**
|
|
1822
|
+
* Converts an input string into a {@link ShellAST.ExecutableNode},
|
|
1823
|
+
* that might contain logical operators.
|
|
1824
|
+
*/
|
|
1825
|
+
private static parseLogical;
|
|
1826
|
+
/**
|
|
1827
|
+
* Converts an input string into a {@link ShellAST.ExecutableNode},
|
|
1828
|
+
* that might contain pipes.
|
|
1829
|
+
*/
|
|
1830
|
+
private static parsePipeline;
|
|
1831
|
+
/**
|
|
1832
|
+
* Converts an input string into a {@link ShellAST.CommandNode}.
|
|
1833
|
+
*/
|
|
1834
|
+
private static parseSimpleCommand;
|
|
1835
|
+
/**
|
|
1836
|
+
* Converts an input string into a {@link ShellAST.ParameterExpansionNode}.
|
|
1837
|
+
*/
|
|
1838
|
+
private static parseParameterExpansion;
|
|
1839
|
+
/**
|
|
1840
|
+
* Converts an input string into an {@link ShellAST.ArithmeticExpansionNode}.
|
|
1841
|
+
*/
|
|
1842
|
+
private static parseArithmeticExpansion;
|
|
1843
|
+
/**
|
|
1844
|
+
* Converts an input string into a {@link ShellAST.CommandSubstitutionNode}.
|
|
1845
|
+
*/
|
|
1846
|
+
private static parseCommandSubstitution;
|
|
1847
|
+
/**
|
|
1848
|
+
* Converts an input string into an {@link ShellAST.Argument}.
|
|
1849
|
+
*/
|
|
1850
|
+
static parseArgument(input: string): ShellAST.Argument;
|
|
1851
|
+
/**
|
|
1852
|
+
* Expands braces in a shell argument (e.g., `"file{1..3}.txt"` or `"img.{jpg,png}"`).
|
|
1853
|
+
* Supports nested expansion and numeric sequences.
|
|
1854
|
+
* @param input - The raw string.
|
|
1855
|
+
* @returns An array of strings with all permutations expanded.
|
|
1856
|
+
*/
|
|
1857
|
+
static expandBraces(input: string): string[];
|
|
1858
|
+
/**
|
|
1859
|
+
* Parses flags and options out of a mutable args array, returning the collected options and
|
|
1860
|
+
* input values. Flag args are removed from `commandArgs` in place as a side-effect.
|
|
1861
|
+
* @param command - The command used to validate and look up option definitions.
|
|
1862
|
+
* @param commandArgs - The mutable argument list to parse from. Modified in place.
|
|
1863
|
+
* @returns An object containing the parsed option keys and any input values keyed by the option's short name.
|
|
1864
|
+
*/
|
|
1865
|
+
static parseOptions(command: Command, commandArgs: string[]): {
|
|
1866
|
+
options: string[];
|
|
1867
|
+
inputs: Record<string, string>;
|
|
1868
|
+
};
|
|
1218
1869
|
}
|
|
1219
1870
|
|
|
1220
1871
|
/**
|
|
@@ -1239,9 +1890,13 @@ export declare interface ShellState {
|
|
|
1239
1890
|
isUsingAltScreen: boolean;
|
|
1240
1891
|
/** A reactive view of the current environment variables. */
|
|
1241
1892
|
env: Record<string, string>;
|
|
1893
|
+
/** Indicates whether the shell is currently in raw mode, forwarding all keystrokes directly to the active stream. */
|
|
1894
|
+
isRawMode: boolean;
|
|
1895
|
+
/** The position of the cursor in raw mode. */
|
|
1896
|
+
cursorPosition: Vector2;
|
|
1242
1897
|
}
|
|
1243
1898
|
|
|
1244
|
-
declare type ShortcutHandler = (event: KeyboardEvent) => void;
|
|
1899
|
+
export declare type ShortcutHandler = (event: KeyboardEvent) => void;
|
|
1245
1900
|
|
|
1246
1901
|
export declare function StandaloneRoute({ app }: StandaloneRouteProps): JSX_2.Element;
|
|
1247
1902
|
|
|
@@ -1331,34 +1986,40 @@ export { StorageManager_2 as StorageManager }
|
|
|
1331
1986
|
* A communication channel for process I/O, supporting event-based data transmission,
|
|
1332
1987
|
* signaling, and piping between streams.
|
|
1333
1988
|
*/
|
|
1334
|
-
export declare class Stream<T = string> extends EventEmitter<StreamEvents<T>> {
|
|
1335
|
-
|
|
1989
|
+
export declare class Stream<T = string> extends EventEmitter<StreamEvents<T>> implements InputStream<T>, OutputStream<T> {
|
|
1990
|
+
private isClosed;
|
|
1991
|
+
private readonly buffer;
|
|
1992
|
+
private readonly pendingReads;
|
|
1993
|
+
private currentSignal;
|
|
1336
1994
|
static readonly DATA_EVENT = "data";
|
|
1337
|
-
static readonly
|
|
1338
|
-
static readonly STOP_EVENT = "stop";
|
|
1995
|
+
static readonly END_EVENT = "end";
|
|
1339
1996
|
static readonly SIGNAL_EVENT = "signal";
|
|
1997
|
+
static readonly ERROR_EVENT = "error";
|
|
1998
|
+
static readonly INTERRUPTED = "interrupted";
|
|
1999
|
+
static readonly CLOSED = "closed";
|
|
2000
|
+
private static readonly TERMINATING_SIGNALS;
|
|
1340
2001
|
/**
|
|
1341
|
-
*
|
|
2002
|
+
* Closes the stream (EOF). Subsequent calls to write will be rejected.
|
|
1342
2003
|
*/
|
|
1343
|
-
|
|
2004
|
+
end(): this;
|
|
1344
2005
|
/**
|
|
1345
|
-
*
|
|
2006
|
+
* Emits a control signal. Standard termination signals will automatically close the stream.
|
|
1346
2007
|
*/
|
|
1347
|
-
|
|
2008
|
+
signal(signal: StreamSignal): this;
|
|
1348
2009
|
/**
|
|
1349
|
-
*
|
|
2010
|
+
* Broadcasts data to all listeners if the stream is open.
|
|
1350
2011
|
*/
|
|
1351
|
-
|
|
2012
|
+
write(data: T): Promise<Result<void, StreamError>>;
|
|
1352
2013
|
/**
|
|
1353
|
-
*
|
|
2014
|
+
* Resolves with the next available chunk, or null if the stream is closed (EOF).
|
|
1354
2015
|
*/
|
|
1355
|
-
|
|
2016
|
+
read(): Promise<Result<T | null, StreamError>>;
|
|
1356
2017
|
/**
|
|
1357
|
-
* Forwards data,
|
|
2018
|
+
* Forwards data, end events, and signals from this stream to another.
|
|
1358
2019
|
* @param destination - The stream that will receive the forwarded data.
|
|
1359
2020
|
* @returns The destination stream to allow for chainable piping.
|
|
1360
2021
|
*/
|
|
1361
|
-
pipe(destination: Stream<T
|
|
2022
|
+
pipe(destination: Stream<T>, propagateEnd?: boolean): Stream<T>;
|
|
1362
2023
|
/**
|
|
1363
2024
|
* Returns a promise that resolves when the stream is stopped.
|
|
1364
2025
|
*/
|
|
@@ -1368,16 +2029,27 @@ export declare class Stream<T = string> extends EventEmitter<StreamEvents<T>> {
|
|
|
1368
2029
|
* @param value - Value to return when the promise resolves.
|
|
1369
2030
|
*/
|
|
1370
2031
|
wait<U>(value: U): Promise<U>;
|
|
2032
|
+
/**
|
|
2033
|
+
* Iterates over a readable string stream and yields each line.
|
|
2034
|
+
*/
|
|
2035
|
+
static readLines(stream: InputStream): AsyncGenerator<Result<string, StreamError>>;
|
|
1371
2036
|
}
|
|
1372
2037
|
|
|
2038
|
+
export declare type StreamError = {
|
|
2039
|
+
type: typeof Stream.INTERRUPTED;
|
|
2040
|
+
signal: StreamSignal;
|
|
2041
|
+
} | {
|
|
2042
|
+
type: typeof Stream.CLOSED;
|
|
2043
|
+
};
|
|
2044
|
+
|
|
1373
2045
|
export declare interface StreamEvents<T = string> {
|
|
1374
2046
|
data: [T];
|
|
1375
|
-
|
|
1376
|
-
stop: [];
|
|
2047
|
+
end: [];
|
|
1377
2048
|
signal: [StreamSignal];
|
|
2049
|
+
error: [StreamError];
|
|
1378
2050
|
}
|
|
1379
2051
|
|
|
1380
|
-
export declare type StreamSignal = "SIGINT" | "SIGKILL" | "SIGTERM" | "SIGINFO";
|
|
2052
|
+
export declare type StreamSignal = "SIGINT" | "SIGKILL" | "SIGTERM" | "SIGINFO" | "SIGHUP" | "SIGQUIT" | "SIGPIPE";
|
|
1381
2053
|
|
|
1382
2054
|
export declare class SystemManager {
|
|
1383
2055
|
#private;
|
|
@@ -1527,6 +2199,12 @@ export declare interface UseContextMenuParams {
|
|
|
1527
2199
|
Actions: FC<ActionsProps>;
|
|
1528
2200
|
}
|
|
1529
2201
|
|
|
2202
|
+
/**
|
|
2203
|
+
* Calculates the dimensions of a character and the dimensions
|
|
2204
|
+
* of its container in rows and columns.
|
|
2205
|
+
*/
|
|
2206
|
+
export declare function useFontMetrics({ containerRef, testString, }: FontMetricsParams): FontMetrics;
|
|
2207
|
+
|
|
1530
2208
|
/**
|
|
1531
2209
|
* Returns an object that handles stateful history with undo and redo methods.
|
|
1532
2210
|
*/
|
|
@@ -1545,6 +2223,28 @@ export declare function useHistory<Type>(initialState: Type): {
|
|
|
1545
2223
|
redoAvailable: boolean;
|
|
1546
2224
|
};
|
|
1547
2225
|
|
|
2226
|
+
/**
|
|
2227
|
+
* Returns a reactive list of all currently installed apps.
|
|
2228
|
+
*
|
|
2229
|
+
* The list stays in sync with `appsConfig.installedApps`, it updates
|
|
2230
|
+
* automatically when apps are installed, uninstalled, or added.
|
|
2231
|
+
*
|
|
2232
|
+
* **Note:** `sort` and `filter` must be stable references.
|
|
2233
|
+
* Passing inline functions will recreate them on every render,
|
|
2234
|
+
* causing an infinite render loop (`Maximum update depth exceeded`).
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```tsx
|
|
2237
|
+
* const installedApps = useInstalledApps();
|
|
2238
|
+
*
|
|
2239
|
+
* const filter = useCallback((app: App) => app.name.includes(query), [query]);
|
|
2240
|
+
* const searchResults = useInstalledApps({ filter });
|
|
2241
|
+
*
|
|
2242
|
+
* const sort = useCallback((a, b) => (a.metadata?.releaseDate ?? "").localeCompare(b.metadata?.releaseDate ?? ""), []);
|
|
2243
|
+
* const sortedByDate = useInstalledApps({ sort });
|
|
2244
|
+
* ```
|
|
2245
|
+
*/
|
|
2246
|
+
export declare function useInstalledApps(options?: InstalledAppsOptions): App<WindowProps>[];
|
|
2247
|
+
|
|
1548
2248
|
/**
|
|
1549
2249
|
* Returns the integer value of a setting and a function to update it.
|
|
1550
2250
|
* @param path - The path of the settings file.
|
|
@@ -1816,6 +2516,7 @@ export declare class VirtualBase<E extends VirtualBaseEvents = VirtualBaseEvents
|
|
|
1816
2516
|
getRoot(): VirtualRoot;
|
|
1817
2517
|
isFile(): this is VirtualFile;
|
|
1818
2518
|
isFolder(): this is VirtualFolder;
|
|
2519
|
+
isLink(): this is VirtualFileLink | VirtualFolderLink;
|
|
1819
2520
|
toJSON(): VirtualBaseJson | null;
|
|
1820
2521
|
toString(): string | null;
|
|
1821
2522
|
}
|
|
@@ -1869,6 +2570,16 @@ export declare interface VirtualDriveConfigOptions {
|
|
|
1869
2570
|
* @default true
|
|
1870
2571
|
*/
|
|
1871
2572
|
includePicturesFolder?: boolean;
|
|
2573
|
+
/**
|
|
2574
|
+
* Include audio folder in default data.
|
|
2575
|
+
* @default true
|
|
2576
|
+
*/
|
|
2577
|
+
includeAudioFolder?: boolean;
|
|
2578
|
+
/**
|
|
2579
|
+
* Include video folder in default data.
|
|
2580
|
+
* @default true
|
|
2581
|
+
*/
|
|
2582
|
+
includeVideoFolder?: boolean;
|
|
1872
2583
|
/**
|
|
1873
2584
|
* Include documents folder in default data.
|
|
1874
2585
|
* @default true
|
|
@@ -1889,6 +2600,11 @@ export declare interface VirtualDriveConfigOptions {
|
|
|
1889
2600
|
* @default true
|
|
1890
2601
|
*/
|
|
1891
2602
|
includeAppsFolder?: boolean;
|
|
2603
|
+
/**
|
|
2604
|
+
* Include scripts folder in default data.
|
|
2605
|
+
* @default true
|
|
2606
|
+
*/
|
|
2607
|
+
includeScriptsFolder?: boolean;
|
|
1892
2608
|
loadData?: (virtualRoot: VirtualRoot) => void;
|
|
1893
2609
|
};
|
|
1894
2610
|
}
|
|
@@ -1963,6 +2679,7 @@ export declare class VirtualFileLink extends VirtualFile {
|
|
|
1963
2679
|
setLinkedPath(path: string): VirtualFileLink;
|
|
1964
2680
|
isValid(): boolean;
|
|
1965
2681
|
toJSON(): VirtualFileLinkJson | null;
|
|
2682
|
+
isLink(): this is VirtualFileLink;
|
|
1966
2683
|
setAlias(...args: Parameters<VirtualFile["setAlias"]>): this;
|
|
1967
2684
|
setSource(...args: Parameters<VirtualFile["setSource"]>): this;
|
|
1968
2685
|
setContent(...args: Parameters<VirtualFile["setContent"]>): this;
|
|
@@ -2054,10 +2771,11 @@ export declare class VirtualFolder<E extends VirtualBaseEvents = VirtualBaseEven
|
|
|
2054
2771
|
* Removes a file or folder from this folder.
|
|
2055
2772
|
*/
|
|
2056
2773
|
remove(child: VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink): this;
|
|
2774
|
+
create(relativePath: string): VirtualFolder<VirtualBaseEvents> | VirtualFile | null;
|
|
2057
2775
|
/**
|
|
2058
2776
|
* Returns the file or folder at a relative path or null if it doesn't exist.
|
|
2059
2777
|
*/
|
|
2060
|
-
navigate(relativePath: string): VirtualFile | VirtualFolder | null;
|
|
2778
|
+
navigate(relativePath: string, createIfMissing?: boolean): VirtualFile | VirtualFolder | null;
|
|
2061
2779
|
navigateToFolder(relativePath: string): VirtualFolder | null;
|
|
2062
2780
|
navigateToFile(relativePath: string): VirtualFile | null;
|
|
2063
2781
|
/**
|
|
@@ -2104,6 +2822,7 @@ export declare class VirtualFolderLink extends VirtualFolder {
|
|
|
2104
2822
|
isValid(): boolean;
|
|
2105
2823
|
getIconUrl(): string;
|
|
2106
2824
|
toJSON(): VirtualFolderLinkJson | null;
|
|
2825
|
+
isLink(): this is VirtualFolderLink;
|
|
2107
2826
|
setAlias(...args: Parameters<VirtualFolder["setAlias"]>): this;
|
|
2108
2827
|
createFile(...args: Parameters<VirtualFolder["createFile"]>): this;
|
|
2109
2828
|
createFiles(...args: Parameters<VirtualFolder["createFiles"]>): this;
|
|
@@ -2189,6 +2908,13 @@ export declare interface WebViewProps extends WindowProps {
|
|
|
2189
2908
|
|
|
2190
2909
|
export declare const WELCOME_MESSAGE: string;
|
|
2191
2910
|
|
|
2911
|
+
/**
|
|
2912
|
+
* Represents a `while` loop structure.
|
|
2913
|
+
*/
|
|
2914
|
+
declare interface WhileNode extends BaseLoopNode, BaseConditionNode {
|
|
2915
|
+
type: NodeType.While;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2192
2918
|
export declare function WindowedModal({ modal, params, children, ...props }: ModalProps): JSX_2.Element;
|
|
2193
2919
|
|
|
2194
2920
|
export declare interface WindowOptions {
|
|
@@ -2288,6 +3014,10 @@ export declare class WindowsManager {
|
|
|
2288
3014
|
* Close a window.
|
|
2289
3015
|
*/
|
|
2290
3016
|
close(windowId: string): void;
|
|
3017
|
+
/**
|
|
3018
|
+
* Close all windows of a specific app.
|
|
3019
|
+
*/
|
|
3020
|
+
closeAppWindows(appId: string): void;
|
|
2291
3021
|
/**
|
|
2292
3022
|
* Focus on a specific window.
|
|
2293
3023
|
*/
|