prozilla-os 1.0.11 → 1.0.13

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