prozilla-os 1.0.11 → 1.0.12

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 ADDED
@@ -0,0 +1,1209 @@
1
+ /// <reference types="react" />
2
+
3
+ import { FC } from 'react';
4
+ import { HTMLAttributeAnchorTarget } from 'react';
5
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
6
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
7
+ import { MemoExoticComponent } from 'react';
8
+ import { MouseEvent as MouseEvent_2 } from 'react';
9
+ import { MutableRefObject } from 'react';
10
+ import { NamedExoticComponent } from 'react';
11
+ import { ReactElement } from 'react';
12
+ import { ReactNode } from 'react';
13
+ import { Ref } from 'react';
14
+ import { UaEventOptions } from 'react-ga4/types/ga4';
15
+ import { default as utilStyles } from './utils.module.css';
16
+
17
+ declare interface ActionProps {
18
+ actionId?: string;
19
+ label?: string;
20
+ icon?: string | object;
21
+ shortcut?: string[];
22
+ onTrigger?: (event?: Event, triggerParams?: unknown, ...args: unknown[]) => void;
23
+ children?: ReactNode;
24
+ disabled?: boolean;
25
+ }
26
+
27
+ /**
28
+ * @example
29
+ * <ClickAction
30
+ * label="Reload"
31
+ * shortcut={["Control", "r"]}
32
+ * icon={faArrowsRotate}
33
+ * onTrigger={() => {
34
+ * reloadViewport();
35
+ * }}
36
+ * />
37
+ */
38
+ export declare function Actions({ children, mode, className, onAnyTrigger, triggerParams, avoidTaskbar }: ActionsProps): ReactElement;
39
+
40
+ declare interface ActionsProps {
41
+ mode?: string;
42
+ className?: string;
43
+ onAnyTrigger?: (event: Event, triggerParams: unknown, ...args: unknown[]) => void;
44
+ children?: ReactNode;
45
+ triggerParams?: unknown;
46
+ avoidTaskbar?: boolean;
47
+ [key: string]: unknown;
48
+ }
49
+
50
+ declare interface AlertParams {
51
+ title: string;
52
+ text: string;
53
+ iconUrl?: string;
54
+ size?: Vector2;
55
+ single?: boolean;
56
+ }
57
+
58
+ export declare const ANSI: {
59
+ fg: {
60
+ black: string;
61
+ red: string;
62
+ green: string;
63
+ yellow: string;
64
+ blue: string;
65
+ magenta: string;
66
+ cyan: string;
67
+ white: string;
68
+ };
69
+ bg: {};
70
+ decoration: {
71
+ dim: string;
72
+ };
73
+ reset: string;
74
+ };
75
+
76
+ export declare class App<AppProps extends WindowProps = WindowProps> {
77
+ name: string;
78
+ id: string;
79
+ windowContent: FC<AppProps>;
80
+ windowOptions?: {
81
+ size: Vector2;
82
+ [key: string]: unknown;
83
+ };
84
+ description: string | null;
85
+ iconUrl: string | null;
86
+ isActive: boolean;
87
+ isPinned?: boolean;
88
+ /**
89
+ * @param windowOptions - Default window options
90
+ */
91
+ constructor(name: App["name"], id: App["id"], windowContent: App<AppProps>["windowContent"], windowOptions?: App["windowOptions"]);
92
+ WindowContent: (props: AppProps) => JSX_2.Element | null;
93
+ setDescription(description: App["description"]): this;
94
+ setIconUrl(iconUrl: App["iconUrl"]): this;
95
+ setName(name: string): this;
96
+ }
97
+
98
+ export declare class AppsConfig {
99
+ apps: AppsConfigOptions["apps"];
100
+ constructor(options?: OptionalInterface<AppsConfigOptions>);
101
+ getAppById(id: string): App | null;
102
+ /**
103
+ * Get the app associated with a file extension
104
+ */
105
+ getAppByFileExtension(fileExtension: string): App | null;
106
+ }
107
+
108
+ declare interface AppsConfigOptions {
109
+ apps: App<any>[];
110
+ }
111
+
112
+ export declare function Button({ className, href, children, icon, target, ...props }: ButtonProps): JSX_2.Element;
113
+
114
+ declare interface ButtonProps {
115
+ className?: string;
116
+ href?: string;
117
+ icon?: IconProp;
118
+ target?: HTMLAttributeAnchorTarget;
119
+ children?: ReactNode;
120
+ [key: string]: unknown;
121
+ }
122
+
123
+ export declare function clamp(value: number, min: number, max: number): number;
124
+
125
+ export declare const ClickAction: MemoExoticComponent<({ actionId, label, shortcut, disabled, onTrigger, icon }: ClickActionProps) => JSX_2.Element>;
126
+
127
+ declare interface ClickActionProps extends ActionProps {
128
+ icon?: string | object;
129
+ }
130
+
131
+ /**
132
+ * Simulates closing the viewport by opening a blank page
133
+ * @param name - Name of the app
134
+ */
135
+ export declare function closeViewport(requireConfirmation: boolean | undefined, name: string): void;
136
+
137
+ export declare const CODE_EXTENSIONS: string[];
138
+
139
+ export declare function copyToClipboard(string: string, onSuccess?: (value: void) => void, onFail?: (value: void) => void): void;
140
+
141
+ export declare const Desktop: MemoExoticComponent<() => JSX_2.Element>;
142
+
143
+ export declare class DesktopConfig {
144
+ wallpapers: DesktopConfigOptions["wallpapers"];
145
+ defaultWallpaper: DesktopConfigOptions["defaultWallpaper"];
146
+ defaultIconSize: DesktopConfigOptions["defaultIconSize"];
147
+ defaultIconDirection: DesktopConfigOptions["defaultIconDirection"];
148
+ constructor(options?: OptionalInterface<DesktopConfigOptions>);
149
+ }
150
+
151
+ declare interface DesktopConfigOptions {
152
+ /** Array of URLs of wallpaper images */
153
+ wallpapers: string[];
154
+ /** URL of default wallpaper image */
155
+ defaultWallpaper: string;
156
+ /**
157
+ * @default 1
158
+ */
159
+ defaultIconSize: 0 | 1 | 2;
160
+ /**
161
+ * 0: vertical, 1: horizontal
162
+ * @default 0
163
+ * */
164
+ defaultIconDirection: 0 | 1;
165
+ }
166
+
167
+ export declare const DIALOG_CONTENT_TYPES: {
168
+ closeButton: number;
169
+ };
170
+
171
+ export declare function DialogBox({ modal, params, children, ...props }: ModalProps): JSX_2.Element;
172
+
173
+ export declare function DirectoryList({ directory, showHidden, folderClassName, fileClassName, className, onContextMenuFile, onContextMenuFolder, onOpenFile, onOpenFolder, allowMultiSelect, onSelectionChange, ...props }: DirectoryListProps): ReactElement | null;
174
+
175
+ declare interface DirectoryListProps {
176
+ directory: VirtualFolder;
177
+ showHidden?: boolean;
178
+ folderClassName?: string;
179
+ fileClassName?: string;
180
+ className?: string;
181
+ onContextMenuFile?: FileEventHandler;
182
+ onContextMenuFolder?: FolderEventHandler;
183
+ onOpenFile?: FileEventHandler;
184
+ onOpenFolder?: FolderEventHandler;
185
+ allowMultiSelect?: boolean;
186
+ onSelectionChange?: (params: OnSelectionChangeParams) => void;
187
+ [key: string]: unknown;
188
+ }
189
+
190
+ export declare function Divider(): JSX_2.Element;
191
+
192
+ export declare function DropdownAction({ label, icon, children, showOnHover }: DropdownActionProps): ReactElement;
193
+
194
+ declare interface DropdownActionProps extends ActionProps {
195
+ showOnHover?: boolean;
196
+ }
197
+
198
+ export declare function DropdownButton({ label, options, shortcuts }: {
199
+ label: string;
200
+ options: {
201
+ [s: string]: Function;
202
+ };
203
+ shortcuts: {
204
+ [s: string]: string[];
205
+ };
206
+ }): JSX_2.Element;
207
+
208
+ export declare class EventEmitter<EventMap extends EventNamesMap> {
209
+ #private;
210
+ static EVENT_NAMES: EventNamesMap;
211
+ /**
212
+ * Add event listener for an event
213
+ */
214
+ on<Key extends keyof EventMap>(eventName: Key, callback: (data: unknown) => void): void;
215
+ /**
216
+ * Remove event listener for an event
217
+ */
218
+ off<Key extends keyof EventMap>(eventName: Key, callback: (data: unknown) => void): void;
219
+ /**
220
+ * Dispatch event
221
+ */
222
+ emit<Key extends keyof EventMap>(eventName: Key, data?: unknown): void;
223
+ }
224
+
225
+ export declare type EventNamesMap = Record<string, string>;
226
+
227
+ export declare type FileEventHandler = (event: Event, file: VirtualFile) => void;
228
+
229
+ export declare const fileExplorer: App<FileExplorerProps>;
230
+
231
+ declare interface FileExplorerProps extends WindowProps {
232
+ path?: string;
233
+ selectorMode?: number;
234
+ Footer: FC;
235
+ onSelectionChange: (params: OnSelectionChangeParams) => void;
236
+ onSelectionFinish: Function;
237
+ }
238
+
239
+ export declare enum FileSelectorMode {
240
+ None = 0,
241
+ Single = 1,
242
+ Multi = 2
243
+ }
244
+
245
+ export declare type FolderEventHandler = (event: Event, folder: VirtualFolder) => void;
246
+
247
+ /**
248
+ * Format a time relative to now
249
+ * @param date - The date
250
+ * @param maxLength - The maximum amount of units, e.g.: 3 => years, months, days
251
+ */
252
+ export declare function formatRelativeTime(date: Date, maxLength: number | undefined, allowAffixes: boolean): string;
253
+
254
+ export declare function formatShortcut(shortcut: string[]): string;
255
+
256
+ /**
257
+ * Format a time
258
+ * @param time - Time in milliseconds
259
+ * @param maxLength - The maximum amount of units, e.g.: 3 => years, months, days
260
+ */
261
+ export declare function formatTime(time: number, maxLength: number | undefined, allowAffixes: boolean): string;
262
+
263
+ export declare function generateUrl(options: generateUrlOptions): string;
264
+
265
+ declare interface generateUrlOptions {
266
+ appId?: string;
267
+ fullscreen?: boolean;
268
+ standalone?: boolean;
269
+ }
270
+
271
+ export declare function getViewportParams(): Record<string, string>;
272
+
273
+ export declare function HeaderMenu({ children, ...props }: ActionsProps): JSX_2.Element;
274
+
275
+ export declare function ImagePreview({ source, className, onError, ...props }: ImagePreviewProps): JSX_2.Element;
276
+
277
+ declare interface ImagePreviewProps {
278
+ source: string;
279
+ className?: string;
280
+ onError?: Function;
281
+ }
282
+
283
+ export declare function Interactable({ onClick, onDoubleClick, children, ...props }: InteractableProps): JSX_2.Element;
284
+
285
+ declare interface InteractableProps {
286
+ onClick: Function;
287
+ onDoubleClick: Function;
288
+ children: ReactNode;
289
+ [key: string]: unknown;
290
+ }
291
+
292
+ export declare function isValidInteger(number: number | string): number | boolean;
293
+
294
+ export declare function isValidUrl(string: string): boolean;
295
+
296
+ export declare class MiscConfig {
297
+ doubleClickDelay: MiscConfigOptions["doubleClickDelay"];
298
+ constructor(options?: OptionalInterface<MiscConfigOptions>);
299
+ }
300
+
301
+ declare interface MiscConfigOptions {
302
+ /**
303
+ * The maximum time between two clicks to register as a double click (in ms)
304
+ * @default 250
305
+ * */
306
+ doubleClickDelay: number;
307
+ }
308
+
309
+ declare class Modal {
310
+ size: Vector2;
311
+ position: Vector2;
312
+ icon: string | null;
313
+ title: string | null;
314
+ modalsManager: ModalsManager | null;
315
+ element: FC<ModalProps> | null;
316
+ props: object;
317
+ callback: Function | null;
318
+ id: number | null;
319
+ dismissible: boolean;
320
+ lastInteraction?: number;
321
+ constructor(element: Modal["element"], callback?: Modal["callback"]);
322
+ setIcon(icon: string): Modal;
323
+ setTitle(title: string): Modal;
324
+ setPosition(position: Vector2): Modal;
325
+ setSize(size: Vector2): Modal;
326
+ setProps(props: object): Modal;
327
+ /**
328
+ * @param {boolean} dismissible
329
+ * @returns {Modal}
330
+ */
331
+ setDismissible(dismissible: boolean): Modal;
332
+ focus(): void;
333
+ finish(...args: unknown[]): void;
334
+ close(): void;
335
+ }
336
+
337
+ export declare interface ModalProps {
338
+ modal?: Modal;
339
+ params?: {
340
+ appId?: string;
341
+ fullscreen?: boolean;
342
+ iconUrl?: string;
343
+ title?: string;
344
+ standalone?: boolean;
345
+ [key: string]: unknown;
346
+ };
347
+ children?: ReactNode;
348
+ onFinish?: Function;
349
+ [key: string]: unknown;
350
+ }
351
+
352
+ export declare class ModalsConfig {
353
+ defaultDialogSize: ModalsConfigOptions["defaultDialogSize"];
354
+ defaultFileSelectorSize: ModalsConfigOptions["defaultFileSelectorSize"];
355
+ constructor(options?: OptionalInterface<ModalsConfigOptions>);
356
+ }
357
+
358
+ declare interface ModalsConfigOptions {
359
+ /**
360
+ * Default size of a dialog box
361
+ * @default new Vector2(400, 200)
362
+ */
363
+ defaultDialogSize: Vector2;
364
+ /**
365
+ * Default size of a file selector
366
+ * @default new Vector2(700, 400)
367
+ */
368
+ defaultFileSelectorSize: Vector2;
369
+ }
370
+
371
+ export declare class ModalsManager {
372
+ modals: Record<string, Modal>;
373
+ containerRef?: MutableRefObject<HTMLElement>;
374
+ updateModals: Function;
375
+ /**
376
+ * @param single - Set to false to preserve other open modals
377
+ */
378
+ open(modal: Modal, single?: boolean): void;
379
+ close(modalId: string | number, sendModalsUpdate?: boolean): void;
380
+ focus(modalId: string): void;
381
+ setUpdateModals(updateModals: Function): void;
382
+ get modalIds(): string[];
383
+ static getModalIconUrl(name: string): string;
384
+ }
385
+
386
+ declare type ModalsManagerState = ModalsManager | undefined;
387
+
388
+ export declare const ModalsView: MemoExoticComponent<() => JSX_2.Element>;
389
+
390
+ export declare interface OnSelectionChangeParams {
391
+ files?: string[];
392
+ folders?: string[];
393
+ directory?: VirtualFolder;
394
+ }
395
+
396
+ export declare function openUrl(url: string, target?: HTMLAttributeAnchorTarget): void;
397
+
398
+ declare type OpenWindowedModal = (params: OpenWindowedModalParams) => Modal;
399
+
400
+ declare interface OpenWindowedModalParams {
401
+ appId?: string;
402
+ iconUrl?: string;
403
+ title?: string;
404
+ size: Vector2;
405
+ Modal: Function;
406
+ single?: boolean;
407
+ fullscreen?: boolean;
408
+ }
409
+
410
+ export declare type OptionalInterface<Interface> = {
411
+ [Property in keyof Interface]?: Interface[Property];
412
+ };
413
+
414
+ declare type OptionalStringProperty = string | null | undefined;
415
+
416
+ export declare const OutsideClickListener: MemoExoticComponent<({ onOutsideClick, children }: OutsideClickListenerProps) => JSX_2.Element>;
417
+
418
+ declare interface OutsideClickListenerProps {
419
+ onOutsideClick: (event: Event) => void;
420
+ children: ReactNode;
421
+ }
422
+
423
+ export declare function ProgressBar({ fillPercentage, fillColor, backgroundColor, align, className }: ProgressBarProps): JSX_2.Element;
424
+
425
+ declare interface ProgressBarProps {
426
+ fillPercentage: number;
427
+ fillColor?: string;
428
+ backgroundColor?: string;
429
+ align?: "left";
430
+ className?: string;
431
+ }
432
+
433
+ export declare const ProzillaOS: NamedExoticComponent<ProzillaOSProps>;
434
+
435
+ declare interface ProzillaOSProps {
436
+ systemName?: string;
437
+ tagLine?: string;
438
+ config?: {
439
+ apps?: OptionalInterface<AppsConfigOptions>;
440
+ desktop?: OptionalInterface<DesktopConfigOptions>;
441
+ misc?: OptionalInterface<MiscConfigOptions>;
442
+ modals?: OptionalInterface<ModalsConfigOptions>;
443
+ taskbar?: OptionalInterface<TaskbarConfigOptions>;
444
+ tracking?: OptionalInterface<TrackingConfigOptions>;
445
+ windows?: OptionalInterface<WindowsConfigOptions>;
446
+ virtualDrive?: OptionalInterface<VirtualDriveConfigOptions>;
447
+ };
448
+ children?: ReactNode;
449
+ }
450
+
451
+ export declare function RadioAction({ actionId, options, initialIndex, onTrigger }: RadioActionProps): ReactElement;
452
+
453
+ /**
454
+ * @param {object} props
455
+ * @param {string} props.actionId
456
+ * @param {{
457
+ * label: string,
458
+ * shortcut: string[]
459
+ * }[]} props.options
460
+ * @param {number} props.initialIndex
461
+ * @param {Function} props.onTrigger
462
+ */
463
+ declare interface RadioActionProps extends ActionProps {
464
+ options: {
465
+ label: string;
466
+ shortcut?: string[];
467
+ }[];
468
+ initialIndex: number;
469
+ }
470
+
471
+ export declare function randomFromArray<Type>(array: Type[]): Type;
472
+
473
+ export declare function randomRange(min: number, max: number): number;
474
+
475
+ /**
476
+ * Reloads the viewport
477
+ */
478
+ export declare function reloadViewport(): void;
479
+
480
+ export declare function removeDuplicatesFromArray<Type>(array: Type[]): Type[];
481
+
482
+ export declare function removeFromArray<Type>(item: Type, array: Type[]): void;
483
+
484
+ export declare function removeUrlProtocol(url: string): string;
485
+
486
+ export declare function round(value: number, precision: number): number;
487
+
488
+ declare class Settings {
489
+ #private;
490
+ path: string;
491
+ file: VirtualFile;
492
+ xmlDoc?: Document;
493
+ constructor(virtualRoot: VirtualRoot, path: string);
494
+ /**
495
+ * Reads the xml doc from the given path and assigns it to itself
496
+ */
497
+ read(): Promise<void>;
498
+ write(): void;
499
+ /**
500
+ * Checks if xml doc is missing
501
+ */
502
+ isMissingXmlDoc(): Promise<boolean>;
503
+ /**
504
+ * Gets a value by a given key if it exists or calls a callback function whenever the value changes
505
+ */
506
+ get(key: string, callback?: (value: string) => void): Promise<string | null>;
507
+ set(key: string, value: string): Promise<void>;
508
+ }
509
+
510
+ export declare class SettingsManager {
511
+ #private;
512
+ static VIRTUAL_PATHS: {
513
+ [s: string]: string;
514
+ };
515
+ constructor(virtualRoot: VirtualRoot);
516
+ getSettings(path: string): Settings;
517
+ }
518
+
519
+ declare type SettingsManagerState = SettingsManager | undefined;
520
+
521
+ export declare function setViewportIcon(url: string): void;
522
+
523
+ export declare function setViewportTitle(title: string): void;
524
+
525
+ export declare function Share({ modal, params, ...props }: ModalProps): JSX_2.Element;
526
+
527
+ declare class StorageManager_2 {
528
+ static MAX_BYTES: number;
529
+ static store(key: string, value: string): void;
530
+ static load(key: string): string | null;
531
+ static clear(): void;
532
+ static getByteSize(string: string | null): number;
533
+ static byteToKilobyte(bytes: number): number;
534
+ }
535
+ export { StorageManager_2 as StorageManager }
536
+
537
+ export declare class SystemManager {
538
+ #private;
539
+ systemName: string;
540
+ tagLine: string;
541
+ appsConfig: AppsConfig;
542
+ desktopConfig: DesktopConfig;
543
+ miscConfig: MiscConfig;
544
+ modalsConfig: ModalsConfig;
545
+ taskbarConfig: TaskbarConfig;
546
+ trackingConfig: TrackingConfig;
547
+ windowsConfig: WindowsConfig;
548
+ virtualDriveConfig: VirtualDriveConfig;
549
+ constructor({ systemName, tagLine, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig }: SystemManagerParams);
550
+ getUptime(precision?: number): string;
551
+ }
552
+
553
+ declare interface SystemManagerParams {
554
+ systemName: SystemManager["systemName"] | null;
555
+ tagLine: SystemManager["tagLine"] | null;
556
+ desktopConfig: DesktopConfig;
557
+ appsConfig: AppsConfig;
558
+ miscConfig: MiscConfig;
559
+ modalsConfig: ModalsConfig;
560
+ taskbarConfig: TaskbarConfig;
561
+ trackingConfig: TrackingConfig;
562
+ windowsConfig: WindowsConfig;
563
+ virtualDriveConfig: VirtualDriveConfig;
564
+ }
565
+
566
+ export declare const Taskbar: MemoExoticComponent<() => JSX_2.Element>;
567
+
568
+ export declare class TaskbarConfig {
569
+ height: TaskbarConfigOptions["height"];
570
+ constructor(options?: OptionalInterface<TaskbarConfigOptions>);
571
+ }
572
+
573
+ declare interface TaskbarConfigOptions {
574
+ /**
575
+ * Height of the taskbar in CSS pixels
576
+ * @default 3 * 16
577
+ */
578
+ height: number;
579
+ }
580
+
581
+ export declare const terminal: App<TerminalProps>;
582
+
583
+ declare interface TerminalProps extends WindowProps {
584
+ path: string;
585
+ input: string;
586
+ }
587
+
588
+ export declare function TextDisplay({ children }: TextDisplayProps): JSX_2.Element;
589
+
590
+ declare interface TextDisplayProps {
591
+ children: ReactNode;
592
+ }
593
+
594
+ export declare const textEditor: App<TextEditorProps>;
595
+
596
+ declare interface TextEditorProps extends WindowProps {
597
+ file?: VirtualFile;
598
+ mode?: "view" | "edit";
599
+ path?: string;
600
+ }
601
+
602
+ export declare const THEMES: Record<number, string | null>;
603
+
604
+ export declare class TimeManager {
605
+ static startDate: Date;
606
+ static reset(): void;
607
+ static getUptime(precision?: number): string;
608
+ }
609
+
610
+ export declare function ToggleAction({ actionId, label, shortcut, initialValue, onTrigger }: ToggleActionProps): ReactElement;
611
+
612
+ declare interface ToggleActionProps extends ActionProps {
613
+ initialValue: boolean;
614
+ }
615
+
616
+ export declare class TrackingConfig {
617
+ enabled: TrackingConfigOptions["enabled"];
618
+ GAMeasurementId: TrackingConfigOptions["GAMeasurementId"];
619
+ constructor(options?: OptionalInterface<TrackingConfigOptions>);
620
+ }
621
+
622
+ declare interface TrackingConfigOptions {
623
+ /**
624
+ * Enable tracking
625
+ * @default true
626
+ */
627
+ enabled: boolean;
628
+ /** Google Analytics measurement ID */
629
+ GAMeasurementId: string;
630
+ }
631
+
632
+ export declare class TrackingManager {
633
+ #private;
634
+ measurementId?: string | null;
635
+ constructor(systemManager: SystemManager);
636
+ init(): this;
637
+ event(options: UaEventOptions | string): void;
638
+ }
639
+
640
+ declare type TrackingManagerState = TrackingManager | undefined;
641
+
642
+ export declare function useAlert(): {
643
+ alert: ({ title, text, iconUrl, size, single }: AlertParams) => void;
644
+ };
645
+
646
+ export declare function useAppFolder(app?: App): VirtualFolder | null;
647
+
648
+ export declare function useContextMenu({ Actions }: UseContextMenuParams): {
649
+ onContextMenu: (event: MouseEvent_2<HTMLElement, MouseEvent_2>, params?: object) => Modal;
650
+ ShortcutsListener: () => JSX_2.Element;
651
+ };
652
+
653
+ declare interface UseContextMenuParams {
654
+ Actions: FC<ActionsProps>;
655
+ }
656
+
657
+ export declare function useHistory<Type>(initialState: Type): {
658
+ history: Type[];
659
+ stateIndex: number;
660
+ pushState: Function;
661
+ undo: Function;
662
+ redo: Function;
663
+ undoAvailable: boolean;
664
+ redoAvailable: boolean;
665
+ };
666
+
667
+ export declare function useKeyboardListener({ onKeyDown, onKeyUp }: UseKeyboardListenerParams): void;
668
+
669
+ declare interface UseKeyboardListenerParams {
670
+ onKeyDown?: (event: KeyboardEvent) => void;
671
+ onKeyUp?: (event: KeyboardEvent) => void;
672
+ }
673
+
674
+ export declare function useModalsManager(): ModalsManagerState;
675
+
676
+ export declare function useMouseListener({ onMouseDown, onMouseUp, onClick, onContextMenu }: UseMouseListenerParams): void;
677
+
678
+ declare interface UseMouseListenerParams {
679
+ onMouseDown: EventListener;
680
+ onMouseUp: EventListener;
681
+ onClick: EventListener;
682
+ onContextMenu: EventListener;
683
+ }
684
+
685
+ export declare function useScreenBounds({ avoidTaskbar }: {
686
+ avoidTaskbar: boolean;
687
+ }): {
688
+ ref: Ref<HTMLElement>;
689
+ initiated: boolean;
690
+ alignLeft: boolean;
691
+ alignTop: boolean;
692
+ };
693
+
694
+ export declare function useScreenDimensions(): [screenWidth: number | null, screenHeight: number | null];
695
+
696
+ export declare function useScrollWithShadow(params: UseScrollWithShadowParams): {
697
+ boxShadow: string;
698
+ onUpdate: (event: Event | {
699
+ target: HTMLElement;
700
+ }) => void;
701
+ };
702
+
703
+ declare interface UseScrollWithShadowParams {
704
+ ref?: MutableRefObject<HTMLElement>;
705
+ horizontal?: boolean;
706
+ dynamicOffset?: boolean;
707
+ dynamicOffsetFactor?: number;
708
+ shadow?: {
709
+ offset?: number;
710
+ blurRadius?: number;
711
+ spreadRadius?: number;
712
+ color?: {
713
+ r?: number;
714
+ g?: number;
715
+ b?: number;
716
+ a?: number;
717
+ };
718
+ };
719
+ }
720
+
721
+ export declare function useSettingsManager(): SettingsManagerState;
722
+
723
+ /**
724
+ * TO DO: rewrite to use a global shortcuts manager instead, to allow certain shortcuts to be prioritized and prevent conflicts
725
+ */
726
+ export declare function useShortcuts({ options, shortcuts, useCategories }: UseShortcutsParams): void;
727
+
728
+ declare interface UseShortcutsParams {
729
+ options: Record<string, Record<string, Function>> | Record<string, Function>;
730
+ shortcuts?: Record<string, Record<string, string[]>> | Record<string, string[]>;
731
+ useCategories?: boolean;
732
+ }
733
+
734
+ export declare function useSystemManager(): SystemManager;
735
+
736
+ export declare function useTrackingManager(): TrackingManagerState;
737
+
738
+ export declare function useVirtualRoot(): VirtualRootState;
739
+
740
+ export declare function useWindowedModal(): {
741
+ openWindowedModal: OpenWindowedModal;
742
+ };
743
+
744
+ export declare function useWindowsManager(): WindowsManagerState;
745
+
746
+ export declare function useZIndex({ groupIndex, index }: UseZIndexParams): number;
747
+
748
+ declare interface UseZIndexParams {
749
+ groupIndex: number;
750
+ index: number;
751
+ }
752
+
753
+ export { utilStyles }
754
+
755
+ export declare class Vector2 {
756
+ x: number;
757
+ y: number;
758
+ static get ZERO(): Vector2;
759
+ get clone(): Vector2;
760
+ constructor(x: number, y?: number);
761
+ round(): Vector2;
762
+ getDistance(x: number, y?: number): number;
763
+ getDistance(vector2: Vector2): number;
764
+ static add(vector2A: Vector2, vector2B: Vector2): Vector2;
765
+ static subtract(vector2A: Vector2, vector2B: Vector2): Vector2;
766
+ static scale(vector2: Vector2, scalar: number): Vector2;
767
+ static magnitude(vector2: Vector2): number;
768
+ static normalize(vector2: Vector2): Vector2;
769
+ static sqrDistance(vector2A: Vector2, vector2B: Vector2): number;
770
+ static lerp(vector2A: Vector2, vector2B: Vector2, t: number): Vector2;
771
+ }
772
+
773
+ declare class VirtualBase extends EventEmitter<EventNamesMap> {
774
+ name: string;
775
+ alias: string | undefined | null;
776
+ parent: VirtualFolder | undefined | null;
777
+ isProtected: boolean | undefined | null;
778
+ iconUrl: string | undefined | null;
779
+ linkedFile: VirtualFile | undefined | null;
780
+ linkedFolder: VirtualFolder | undefined | null;
781
+ editedByUser: boolean | undefined | null;
782
+ isRoot: boolean | undefined | null;
783
+ root: VirtualRoot | undefined | null;
784
+ constructor(name: string);
785
+ get id(): string;
786
+ setName(name: string): this;
787
+ setAlias(alias: string): this;
788
+ setParent(parent: VirtualFolder): this;
789
+ setProtected(value: boolean): this;
790
+ setIconUrl(iconUrl: string | null): this;
791
+ getIconUrl(): string;
792
+ getType(): string;
793
+ delete(): void;
794
+ confirmChanges(root?: VirtualRoot): void;
795
+ open(..._args: unknown[]): unknown;
796
+ get path(): string;
797
+ /**
798
+ * Returns path without using alias
799
+ */
800
+ get displayPath(): string;
801
+ /**
802
+ * Returns path without using any aliases
803
+ */
804
+ get absolutePath(): string;
805
+ /**
806
+ * Returns whether this can be edited in its current state
807
+ */
808
+ get canBeEdited(): boolean;
809
+ getRoot(): VirtualRoot;
810
+ isFile(): boolean;
811
+ isFolder(): boolean;
812
+ toJSON(): VirtualBaseJson | null;
813
+ toString(): string | null;
814
+ }
815
+
816
+ declare interface VirtualBaseJson {
817
+ nam: string;
818
+ ico?: string;
819
+ }
820
+
821
+ export declare class VirtualDriveConfig {
822
+ fileIcon: VirtualDriveConfigOptions["fileIcon"];
823
+ infoFileIcon: VirtualDriveConfigOptions["infoFileIcon"];
824
+ textFileIcon: VirtualDriveConfigOptions["textFileIcon"];
825
+ codeFileIcon: VirtualDriveConfigOptions["codeFileIcon"];
826
+ folderIcon: VirtualDriveConfigOptions["folderIcon"];
827
+ imagesFolderIcon: VirtualDriveConfigOptions["imagesFolderIcon"];
828
+ textFolderIcon: VirtualDriveConfigOptions["textFolderIcon"];
829
+ folderLinkIcon: VirtualDriveConfigOptions["folderLinkIcon"];
830
+ constructor(options?: OptionalInterface<VirtualDriveConfigOptions>);
831
+ }
832
+
833
+ declare interface VirtualDriveConfigOptions {
834
+ fileIcon: string;
835
+ infoFileIcon: string;
836
+ textFileIcon: string;
837
+ codeFileIcon: string;
838
+ folderIcon: string;
839
+ imagesFolderIcon: string;
840
+ textFolderIcon: string;
841
+ folderLinkIcon: string;
842
+ }
843
+
844
+ /**
845
+ * A virtual file that can be stored inside a folder
846
+ */
847
+ export declare class VirtualFile extends VirtualBase {
848
+ extension: OptionalStringProperty;
849
+ source: OptionalStringProperty;
850
+ content: OptionalStringProperty;
851
+ static NON_TEXT_EXTENSIONS: string[];
852
+ static EVENT_NAMES: {
853
+ CONTENT_CHANGE: string;
854
+ };
855
+ constructor(name: string, extension?: string | undefined);
856
+ setAlias(alias: string): this;
857
+ /**
858
+ * Sets the source of this file and removes the content
859
+ */
860
+ setSource(source: string): this;
861
+ /**
862
+ * Sets the content of this file and removes the source
863
+ */
864
+ setContent(content: string): this;
865
+ get id(): string;
866
+ static splitId(id: string): {
867
+ name: string;
868
+ extension: OptionalStringProperty;
869
+ };
870
+ /**
871
+ * Opens this file in an app associated with its extension
872
+ */
873
+ open(windowsManager: WindowsManager): object | null;
874
+ read(): Promise<OptionalStringProperty | undefined>;
875
+ isFile(): boolean;
876
+ getIconUrl(): string;
877
+ getType(): string;
878
+ toJSON(): VirtualFileJson | null;
879
+ }
880
+
881
+ declare interface VirtualFileJson extends VirtualBaseJson {
882
+ ext?: string;
883
+ cnt?: string;
884
+ src?: string;
885
+ }
886
+
887
+ /**
888
+ * A link that points to a virtual file
889
+ */
890
+ export declare class VirtualFileLink extends VirtualFile {
891
+ linkedPath?: string;
892
+ constructor(name: string, linkedFile?: VirtualFile);
893
+ setLinkedFile(file: VirtualFile): VirtualFileLink;
894
+ setLinkedPath(path: string): VirtualFileLink;
895
+ isValid(): boolean;
896
+ toJSON(): VirtualFileLinkJson | null;
897
+ setAlias(...args: Parameters<VirtualFile["setAlias"]>): this;
898
+ setSource(...args: Parameters<VirtualFile["setSource"]>): this;
899
+ setContent(...args: Parameters<VirtualFile["setContent"]>): this;
900
+ get id(): string;
901
+ open(...args: Parameters<VirtualFile["open"]>): ReturnType<VirtualFile["open"]>;
902
+ read(...args: Parameters<VirtualFile["read"]>): Promise<string | null | undefined>;
903
+ getIconUrl(...args: Parameters<VirtualFile["getIconUrl"]>): ReturnType<VirtualFile["getIconUrl"]>;
904
+ }
905
+
906
+ declare interface VirtualFileLinkJson extends VirtualFileJson {
907
+ lnk: string;
908
+ }
909
+
910
+ /**
911
+ * A virtual folder that can contains files and sub-folders
912
+ */
913
+ export declare class VirtualFolder extends VirtualBase {
914
+ subFolders: (VirtualFolder | VirtualFolderLink)[];
915
+ files: (VirtualFile | VirtualFileLink)[];
916
+ type: number | undefined;
917
+ static TYPE: {
918
+ GENERAL: number;
919
+ MEDIA: number;
920
+ };
921
+ constructor(name: string, type?: number);
922
+ setAlias(alias: string): this;
923
+ /**
924
+ * Returns true if this folder contains a file matching a name and extension
925
+ */
926
+ hasFile(name: string, extension?: string): boolean;
927
+ /**
928
+ * Returns true if this folder contains a folder matching a name
929
+ */
930
+ hasFolder(name: string): boolean;
931
+ /**
932
+ * Finds and returns a file inside this folder matching a name and extension
933
+ */
934
+ findFile(name: string, extension?: string | null): VirtualFile | VirtualFileLink | null;
935
+ /**
936
+ * Finds and returns a folder inside this folder matching a name
937
+ */
938
+ findSubFolder(name: string): VirtualFolder | VirtualFolderLink | null;
939
+ /**
940
+ * Creates a file with a name and extension
941
+ */
942
+ createFile(name: string, extension?: string, callback?: (newFile: VirtualFile | VirtualFileLink) => void): this;
943
+ /**
944
+ * Creates files based on an array of objects with file names and extensions
945
+ */
946
+ createFiles(files: {
947
+ name: string;
948
+ extension: string;
949
+ }[]): this;
950
+ /**
951
+ * Creates a file link with a name
952
+ */
953
+ createFileLink(name: string, callback?: (newFileLink: VirtualFileLink | VirtualFile) => void): this;
954
+ /**
955
+ * Creates files based on an array of objects with file names and extensions
956
+ */
957
+ createFileLinks(files: {
958
+ name: string;
959
+ }[]): this;
960
+ /**
961
+ * Creates a folder with a name
962
+ */
963
+ createFolder(name: string, callback?: (newFolder: VirtualFolder) => void): this;
964
+ /**
965
+ * Creates folders based on an array of folder names
966
+ */
967
+ createFolders(names: string[]): this;
968
+ /**
969
+ * Creates a folder link with a name
970
+ */
971
+ createFolderLink(name: string, callback?: (newFolderLink: VirtualFolderLink | VirtualFolder) => void): this;
972
+ /**
973
+ * Creates folder links based on an array of folder names
974
+ */
975
+ createFolderLinks(names: string[]): this;
976
+ /**
977
+ * Removes a file or folder from this folder
978
+ */
979
+ remove(child: VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink): this;
980
+ /**
981
+ * Returns the file or folder at a relative path or null if it doesn't exist
982
+ */
983
+ navigate(relativePath: string): VirtualFile | VirtualFolder | null;
984
+ /**
985
+ * Opens this folder in file explorer
986
+ */
987
+ open(windowsManager: WindowsManager): object | null;
988
+ /**
989
+ * Deletes this folder and all its files and sub-folders recursively
990
+ */
991
+ delete(): void;
992
+ /**
993
+ * Returns all files inside this folder
994
+ */
995
+ getFiles(showHidden?: boolean): VirtualFile[];
996
+ /**
997
+ * Returns all sub-folders inside this folder
998
+ */
999
+ getSubFolders(showHidden?: boolean): VirtualFolder[];
1000
+ /**
1001
+ * Returns the amount of files and sub-folders inside this folder
1002
+ */
1003
+ getItemCount(showHidden?: boolean): number;
1004
+ isFolder(): boolean;
1005
+ getIconUrl(): string;
1006
+ toJSON(): VirtualFolderJson | null;
1007
+ }
1008
+
1009
+ declare interface VirtualFolderJson extends VirtualBaseJson {
1010
+ fls?: VirtualFileJson[];
1011
+ fds?: VirtualFolderJson[];
1012
+ }
1013
+
1014
+ /**
1015
+ * A link that points to a virtual folder
1016
+ */
1017
+ export declare class VirtualFolderLink extends VirtualFolder {
1018
+ linkedPath?: string;
1019
+ constructor(name: string, linkedFolder?: VirtualFolder);
1020
+ setLinkedFolder(folder: VirtualFolder): VirtualFolderLink;
1021
+ setLinkedPath(path: string): VirtualFolderLink;
1022
+ isValid(): boolean;
1023
+ getIconUrl(): string;
1024
+ toJSON(): VirtualFolderLinkJson | null;
1025
+ setAlias(...args: Parameters<VirtualFolder["setAlias"]>): this;
1026
+ createFile(...args: Parameters<VirtualFolder["createFile"]>): this;
1027
+ createFiles(...args: Parameters<VirtualFolder["createFiles"]>): this;
1028
+ createFolder(...args: Parameters<VirtualFolder["createFolder"]>): this;
1029
+ createFolders(...args: Parameters<VirtualFolder["createFolders"]>): this;
1030
+ hasFile(...args: Parameters<VirtualFolder["hasFile"]>): ReturnType<VirtualFolder["hasFile"]>;
1031
+ hasFolder(...args: Parameters<VirtualFolder["hasFolder"]>): ReturnType<VirtualFolder["hasFolder"]>;
1032
+ findFile(...args: Parameters<VirtualFolder["findFile"]>): ReturnType<VirtualFolder["findFile"]>;
1033
+ findSubFolder(...args: Parameters<VirtualFolder["findSubFolder"]>): ReturnType<VirtualFolder["findSubFolder"]>;
1034
+ getFiles(...args: Parameters<VirtualFolder["getFiles"]>): ReturnType<VirtualFolder["getFiles"]>;
1035
+ getSubFolders(...args: Parameters<VirtualFolder["getSubFolders"]>): ReturnType<VirtualFolder["getSubFolders"]>;
1036
+ open(...args: Parameters<VirtualFolder["open"]>): ReturnType<VirtualFolder["open"]>;
1037
+ getItemCount(...args: Parameters<VirtualFolder["getItemCount"]>): ReturnType<VirtualFolder["getItemCount"]>;
1038
+ }
1039
+
1040
+ declare interface VirtualFolderLinkJson extends VirtualFolderJson {
1041
+ lnk: string;
1042
+ }
1043
+
1044
+ /**
1045
+ * A virtual folder that serves as the root folder
1046
+ */
1047
+ export declare class VirtualRoot extends VirtualFolder {
1048
+ shortcuts: Record<string, VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink>;
1049
+ initiated: boolean;
1050
+ loadedDefaultData: boolean;
1051
+ systemManager: SystemManager;
1052
+ static EVENT_NAMES: {
1053
+ ERROR: string;
1054
+ };
1055
+ constructor(systemManager: SystemManager);
1056
+ loadDefaultData(): void;
1057
+ loadData(): void;
1058
+ /**
1059
+ * Calls the storage manager's store function with this root's data as a string
1060
+ */
1061
+ saveData(): void;
1062
+ /**
1063
+ * Initiates this root by loading the default data and then the user's data on top
1064
+ */
1065
+ init(): VirtualRoot;
1066
+ /**
1067
+ * Adds a shortcut to a file or folder
1068
+ */
1069
+ addShortcut(name: string, destination: VirtualFile | VirtualFileLink | VirtualFolder | VirtualFolderLink): this;
1070
+ /**
1071
+ * Tells the storage manager to clear all data and reloads the window
1072
+ */
1073
+ reset(): void;
1074
+ static isValidName(_name: string): void;
1075
+ static isValidFileName(_name: string): void;
1076
+ static isValidFolderName(_name: string): void;
1077
+ get path(): string;
1078
+ get displayPath(): string;
1079
+ toJSON(): VirtualRootJson | null;
1080
+ toString(): string | null;
1081
+ }
1082
+
1083
+ declare interface VirtualRootJson extends VirtualFolderJson {
1084
+ scs: Record<string, string>;
1085
+ }
1086
+
1087
+ declare type VirtualRootState = VirtualRoot | undefined;
1088
+
1089
+ export declare const WebView: FC<WebViewProps>;
1090
+
1091
+ declare interface WebViewProps extends WindowProps {
1092
+ source?: string;
1093
+ title?: string;
1094
+ }
1095
+
1096
+ export declare function WindowedModal({ modal, params, children, ...props }: ModalProps): JSX_2.Element;
1097
+
1098
+ declare interface WindowOptions {
1099
+ id?: string;
1100
+ app?: App;
1101
+ size?: Vector2;
1102
+ position?: Vector2;
1103
+ fullscreen?: boolean | string;
1104
+ options?: object;
1105
+ isFocused?: boolean;
1106
+ lastInteraction?: number;
1107
+ minimized?: boolean;
1108
+ [key: string]: unknown;
1109
+ }
1110
+
1111
+ export declare interface WindowProps extends WindowOptions {
1112
+ fullscreen?: boolean;
1113
+ onInteract?: Function;
1114
+ setTitle?: React.Dispatch<React.SetStateAction<string>>;
1115
+ setIconUrl?: React.Dispatch<React.SetStateAction<string>>;
1116
+ close?: (event?: Event) => void;
1117
+ focus?: (event: Event, force?: boolean) => void;
1118
+ active?: boolean;
1119
+ minimized?: boolean;
1120
+ toggleMinimized?: Function;
1121
+ index?: number;
1122
+ standalone?: boolean;
1123
+ }
1124
+
1125
+ export declare class WindowsConfig {
1126
+ screenMargin: WindowsConfigOptions["screenMargin"];
1127
+ titleSeparator: WindowsConfigOptions["titleSeparator"];
1128
+ minScreenSize: WindowsConfigOptions["minScreenSize"];
1129
+ constructor(options?: OptionalInterface<WindowsConfigOptions>);
1130
+ }
1131
+
1132
+ declare interface WindowsConfigOptions {
1133
+ /**
1134
+ * @default 32
1135
+ */
1136
+ screenMargin: number;
1137
+ /**
1138
+ * @default "-"
1139
+ */
1140
+ titleSeparator: string;
1141
+ /**
1142
+ * If the user's screen is smaller than these values, windows will always be maximized
1143
+ * @default new Vector2(350, 350)
1144
+ */
1145
+ minScreenSize: Vector2;
1146
+ }
1147
+
1148
+ export declare class WindowsManager {
1149
+ #private;
1150
+ windows: {
1151
+ [id: string]: WindowOptions;
1152
+ };
1153
+ updateWindows: Function;
1154
+ startupComplete: boolean;
1155
+ constructor(systemManager: SystemManager, trackingManager: TrackingManager);
1156
+ open(appId: string, options?: WindowOptions | null): object | null;
1157
+ openFile(file: VirtualFile, options?: object): object | null;
1158
+ close(windowId: string): void;
1159
+ focus(windowId: string): void;
1160
+ isFocused(windowId: string): boolean | undefined;
1161
+ isAnyFocused(): boolean;
1162
+ /**
1163
+ * @param minimized - Leave as undefined to toggle the window's minimization state
1164
+ */
1165
+ setMinimized(windowId: string, minimized?: boolean): void;
1166
+ minimizeAll(): void;
1167
+ isAppActive(appId: string): boolean;
1168
+ getAppWindowId(appId: string): string | null;
1169
+ setUpdateWindows(updateWindows: Function): void;
1170
+ startup(appIds: string[], options: {}): void;
1171
+ get windowIds(): string[];
1172
+ }
1173
+
1174
+ declare type WindowsManagerState = WindowsManager | undefined;
1175
+
1176
+ export declare const WindowsView: FC;
1177
+
1178
+ declare class ZIndexGroup {
1179
+ length: number;
1180
+ offset: number;
1181
+ groupIndex: number;
1182
+ zIndexManager: ZIndexManager | null;
1183
+ constructor(zIndexManager: ZIndexManager, initialLength?: number);
1184
+ setManager(zIndexManager: ZIndexManager): ZIndexGroup;
1185
+ setOffset(offset: number): ZIndexGroup;
1186
+ setLength(length: number): ZIndexGroup;
1187
+ getIndex(index: number): number;
1188
+ }
1189
+
1190
+ export declare class ZIndexManager extends EventEmitter<typeof ZIndexManagerEvents> {
1191
+ static GROUPS: {
1192
+ WINDOWS: number;
1193
+ TASKBAR: number;
1194
+ MODALS: number;
1195
+ };
1196
+ static EVENT_NAMES: {
1197
+ readonly indexChange: "indexChange";
1198
+ };
1199
+ groups: ZIndexGroup[];
1200
+ constructor();
1201
+ update(): void;
1202
+ getIndex(groupIndex: number, index: number): number;
1203
+ }
1204
+
1205
+ declare const ZIndexManagerEvents: {
1206
+ readonly indexChange: "indexChange";
1207
+ };
1208
+
1209
+ export { }