@prozilla-os/core 1.3.2 → 1.3.4

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 CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="react" />
2
-
3
1
  import { FC } from 'react';
4
2
  import { HTMLAttributeAnchorTarget } from 'react';
5
3
  import { IconProp } from '@fortawesome/fontawesome-svg-core';
@@ -105,8 +103,17 @@ export declare class App<AppProps extends WindowProps = WindowProps> {
105
103
  * @default false
106
104
  */
107
105
  launchAtStartup: boolean;
106
+ /**
107
+ * The category the app belongs to
108
+ */
109
+ category: typeof APP_CATEGORIES[number] | null;
110
+ /**
111
+ * Metadata of the app's package
112
+ */
113
+ metadata: AppMetadata | null;
108
114
  isActive: boolean;
109
115
  isPinned?: boolean;
116
+ isInstalled: boolean;
110
117
  constructor(name: App["name"], id: App["id"], windowContent: App<AppProps>["windowContent"], windowOptions?: App["windowOptions"]);
111
118
  WindowContent: (props: AppProps) => JSX_2.Element | null;
112
119
  /**
@@ -137,20 +144,41 @@ export declare class App<AppProps extends WindowProps = WindowProps> {
137
144
  * Changes whether this application is launched at startup or not
138
145
  */
139
146
  setLaunchAtStartup(launchAtStartup: boolean): this;
147
+ /**
148
+ * Changes whether this application is installed by default or not
149
+ */
150
+ setInstalled(installed: boolean): this;
151
+ /**
152
+ * Changes the category this application belongs to
153
+ */
154
+ setCategory(category: typeof APP_CATEGORIES[number] | null): this;
155
+ setMetadata(metadata: AppMetadata | null): this;
156
+ }
157
+
158
+ 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"];
159
+
160
+ declare interface AppMetadata {
161
+ name: string;
162
+ version: `${number}.${number}.${number}`;
163
+ author: string;
140
164
  }
141
165
 
142
166
  export declare class AppsConfig {
143
167
  apps: AppsConfigOptions["apps"];
144
168
  static APP_ROLES: {
145
- FileExplorer: string;
146
- Terminal: string;
147
- TextEditor: string;
148
- Settings: string;
149
- MediaViewer: string;
150
- Browser: string;
169
+ fileExplorer: string;
170
+ terminal: string;
171
+ textEditor: string;
172
+ settings: string;
173
+ mediaViewer: string;
174
+ browser: string;
151
175
  };
152
176
  constructor(options?: OptionalInterface<AppsConfigOptions>);
153
- getAppById(id: string): App | null;
177
+ get installedApps(): App<any>[];
178
+ /**
179
+ * @param includeUninstalled Include apps that are not currently installed
180
+ */
181
+ getAppById(id: string, includeUninstalled?: boolean): App | null;
154
182
  /**
155
183
  * Get the app associated with a file extension
156
184
  */
@@ -159,6 +187,10 @@ export declare class AppsConfig {
159
187
  * Get the app with a specific role
160
188
  */
161
189
  getAppByRole(role: string): App | null;
190
+ /**
191
+ * Get all applications (including uninstalled apps) that belong to a category
192
+ */
193
+ getAppsByCategory(category: typeof APP_CATEGORIES[number]): App[];
162
194
  }
163
195
 
164
196
  declare interface AppsConfigOptions {
@@ -244,15 +276,13 @@ declare interface DropdownActionProps extends ActionProps {
244
276
  showOnHover?: boolean;
245
277
  }
246
278
 
247
- export declare function DropdownButton({ label, options, shortcuts }: {
279
+ export declare function DropdownButton({ label, options, shortcuts }: DropdownButtonProps): JSX_2.Element;
280
+
281
+ declare interface DropdownButtonProps {
248
282
  label: string;
249
- options: {
250
- [s: string]: Function;
251
- };
252
- shortcuts: {
253
- [s: string]: string[];
254
- };
255
- }): JSX_2.Element;
283
+ options: Record<string, () => void>;
284
+ shortcuts: Record<string, string[]>;
285
+ }
256
286
 
257
287
  declare class EventEmitter<EventMap extends EventNamesMap> {
258
288
  #private;
@@ -277,11 +307,16 @@ export declare type FileEventHandler = (event: Event, file: VirtualFile) => void
277
307
 
278
308
  export declare type FolderEventHandler = (event: Event, folder: VirtualFolder) => void;
279
309
 
310
+ /**
311
+ * Formats a shortcut (combination of keys) into a human-readable format.
312
+ *
313
+ * For a list of valid key values, refer to this page: <https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values>
314
+ */
280
315
  export declare function formatShortcut(shortcut: string[]): string;
281
316
 
282
- export declare function generateUrl(options: generateUrlOptions): string;
317
+ export declare function generateUrl(options: GenerateUrlOptions): string;
283
318
 
284
- declare interface generateUrlOptions {
319
+ declare interface GenerateUrlOptions {
285
320
  appId?: string;
286
321
  fullscreen?: boolean;
287
322
  standalone?: boolean;
@@ -301,7 +336,7 @@ export declare function ImagePreview({ source, className, onError, ...props }: I
301
336
  declare interface ImagePreviewProps {
302
337
  source: string;
303
338
  className?: string;
304
- onError?: Function;
339
+ onError?: () => void;
305
340
  }
306
341
 
307
342
  declare interface ImageProps {
@@ -313,8 +348,8 @@ declare interface ImageProps {
313
348
  export declare function Interactable({ onClick, onDoubleClick, children, ...props }: InteractableProps): JSX_2.Element;
314
349
 
315
350
  declare interface InteractableProps {
316
- onClick: Function;
317
- onDoubleClick: Function;
351
+ onClick?: (event: MouseEvent) => void;
352
+ onDoubleClick?: (event: MouseEvent) => void;
318
353
  children: ReactNode;
319
354
  [key: string]: unknown;
320
355
  }
@@ -342,7 +377,7 @@ declare class Modal {
342
377
  modalsManager: ModalsManager | null;
343
378
  element: FC<ModalProps> | null;
344
379
  props: object;
345
- callback: Function | null;
380
+ callback: ((...args: unknown[]) => void) | null;
346
381
  id: number | null;
347
382
  dismissible: boolean;
348
383
  lastInteraction?: number;
@@ -373,7 +408,7 @@ export declare interface ModalProps {
373
408
  [key: string]: unknown;
374
409
  };
375
410
  children?: ReactNode;
376
- onFinish?: Function;
411
+ onFinish?: () => void;
377
412
  [key: string]: unknown;
378
413
  }
379
414
 
@@ -381,7 +416,7 @@ export declare class ModalsConfig {
381
416
  defaultDialogSize: ModalsConfigOptions["defaultDialogSize"];
382
417
  defaultFileSelectorSize: ModalsConfigOptions["defaultFileSelectorSize"];
383
418
  static DIALOG_CONTENT_TYPES: {
384
- CloseButton: number;
419
+ closeButton: number;
385
420
  };
386
421
  constructor(options?: OptionalInterface<ModalsConfigOptions>);
387
422
  }
@@ -402,14 +437,14 @@ declare interface ModalsConfigOptions {
402
437
  export declare class ModalsManager {
403
438
  modals: Record<string, Modal>;
404
439
  containerRef?: MutableRefObject<HTMLElement>;
405
- updateModals: Function;
440
+ updateModals: (modals: ModalsManager["modals"]) => void;
406
441
  /**
407
442
  * @param single - Set to false to preserve other open modals
408
443
  */
409
444
  open(modal: Modal, single?: boolean): void;
410
445
  close(modalId: string | number, sendModalsUpdate?: boolean): void;
411
446
  focus(modalId: string): void;
412
- setUpdateModals(updateModals: Function): void;
447
+ setUpdateModals(updateModals: ModalsManager["updateModals"]): void;
413
448
  get modalIds(): string[];
414
449
  static getModalIconUrl(name: string): string;
415
450
  }
@@ -435,9 +470,9 @@ declare interface OpenWindowedModalParams {
435
470
  iconUrl?: string;
436
471
  title?: string;
437
472
  size: Vector2;
438
- Modal: Function;
473
+ Modal: FC<ModalProps>;
439
474
  single?: boolean;
440
- fullscreen?: boolean;
475
+ fullscreen?: WindowProps["fullscreen"];
441
476
  }
442
477
 
443
478
  export declare type OptionalInterface<Interface> = {
@@ -511,14 +546,17 @@ declare interface RadioActionProps extends ActionProps {
511
546
  */
512
547
  export declare function reloadViewport(): void;
513
548
 
549
+ export declare function removeBaseUrl(url: string): string;
550
+
514
551
  export declare function removeUrlProtocol(url: string): string;
515
552
 
516
- export declare function Router({ path, homePage, fallbackPage }: RouterProps): JSX_2.Element;
553
+ export declare function Router({ path, homePage, fallbackPage, children }: RouterProps): JSX_2.Element;
517
554
 
518
555
  declare interface RouterProps {
519
556
  path?: string;
520
557
  homePage?: JSX.Element;
521
558
  fallbackPage?: JSX.Element;
559
+ children?: ReactElement;
522
560
  }
523
561
 
524
562
  declare class Settings {
@@ -561,6 +599,7 @@ export declare function setViewportTitle(title: string): void;
561
599
  export declare function Share({ modal, params, ...props }: ModalProps): JSX_2.Element;
562
600
 
563
601
  declare class Skin {
602
+ systemIcon: SkinOptions["systemIcon"];
564
603
  appIcons: SkinOptions["appIcons"];
565
604
  appNames: SkinOptions["appNames"];
566
605
  wallpapers: SkinOptions["wallpapers"];
@@ -568,10 +607,17 @@ declare class Skin {
568
607
  fileIcons: SkinOptions["fileIcons"];
569
608
  folderIcons: SkinOptions["folderIcons"];
570
609
  loadStyleSheet: SkinOptions["loadStyleSheet"];
610
+ defaultTheme: SkinOptions["defaultTheme"];
571
611
  constructor(options?: OptionalInterface_2<SkinOptions>);
572
612
  }
573
613
 
574
614
  declare interface SkinOptions {
615
+ /**
616
+ * SVG icon for the system
617
+ * @default
618
+ * "https://os.prozilla.dev/icon.svg"
619
+ */
620
+ systemIcon: string;
575
621
  /**
576
622
  * Replacements for app icons based on app id
577
623
  */
@@ -602,6 +648,7 @@ declare interface SkinOptions {
602
648
  info?: string;
603
649
  text?: string;
604
650
  code?: string;
651
+ external?: string;
605
652
  };
606
653
  /**
607
654
  * URLs of icons for types of folders
@@ -616,6 +663,10 @@ declare interface SkinOptions {
616
663
  * Function that dynamically imports style sheet
617
664
  */
618
665
  loadStyleSheet?: () => void;
666
+ /**
667
+ * Default theme
668
+ */
669
+ defaultTheme?: Theme;
619
670
  }
620
671
 
621
672
  export declare function StandaloneRoute({ app }: StandaloneRouteProps): JSX_2.Element;
@@ -647,7 +698,7 @@ export declare class SystemManager {
647
698
  readonly trackingConfig: TrackingConfig;
648
699
  readonly windowsConfig: WindowsConfig;
649
700
  readonly virtualDriveConfig: VirtualDriveConfig;
650
- constructor({ systemName, tagLine, skin, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig }: SystemManagerParams);
701
+ constructor({ systemName, tagLine, skin, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig, }: SystemManagerParams);
651
702
  private loadSkin;
652
703
  getUptime(precision?: number): string;
653
704
  }
@@ -687,11 +738,24 @@ declare interface TextDisplayProps {
687
738
  children: ReactNode;
688
739
  }
689
740
 
690
- export declare const THEMES: Record<number, string | null>;
741
+ declare enum Theme {
742
+ Dark = 0,
743
+ Light = 1,
744
+ Cherry = 2,
745
+ Mango = 3,
746
+ Aqua = 4,
747
+ Grape = 5
748
+ }
691
749
 
692
750
  export declare class TimeManager {
693
- static startDate: Date;
751
+ static START_DATE: Date;
752
+ /**
753
+ * Resets the time
754
+ */
694
755
  static reset(): void;
756
+ /**
757
+ * Get the current uptime
758
+ */
695
759
  static getUptime(precision?: number): string;
696
760
  }
697
761
 
@@ -703,7 +767,7 @@ declare interface ToggleActionProps extends ActionProps {
703
767
 
704
768
  export declare class TrackingConfig {
705
769
  enabled: TrackingConfigOptions["enabled"];
706
- GAMeasurementId: TrackingConfigOptions["GAMeasurementId"];
770
+ googleAnalyticsMeasurementId: TrackingConfigOptions["GAMeasurementId"];
707
771
  constructor(options?: OptionalInterface<TrackingConfigOptions>);
708
772
  }
709
773
 
@@ -734,7 +798,7 @@ export declare function useAlert(): {
734
798
  export declare function useAppFolder(app?: App): VirtualFolder | null;
735
799
 
736
800
  /**
737
- * Combine clas names and an optional static class name
801
+ * Combine class names and an optional static class name
738
802
  */
739
803
  export declare function useClassNames(classNames: (string | undefined)[], block?: string, element?: string, modifier?: string | string[]): string;
740
804
 
@@ -750,9 +814,9 @@ declare interface UseContextMenuParams {
750
814
  export declare function useHistory<Type>(initialState: Type): {
751
815
  history: Type[];
752
816
  stateIndex: number;
753
- pushState: Function;
754
- undo: Function;
755
- redo: Function;
817
+ pushState: (state: Type) => void;
818
+ undo: () => void;
819
+ redo: () => void;
756
820
  undoAvailable: boolean;
757
821
  redoAvailable: boolean;
758
822
  };
@@ -819,7 +883,7 @@ export declare function useSettingsManager(): SettingsManagerState;
819
883
  export declare function useShortcuts({ options, shortcuts, useCategories }: UseShortcutsParams): void;
820
884
 
821
885
  declare interface UseShortcutsParams {
822
- options: Record<string, Record<string, Function>> | Record<string, Function>;
886
+ options: Record<string, Record<string, (event: KeyboardEvent) => void>> | Record<string, (event: KeyboardEvent) => void>;
823
887
  shortcuts?: Record<string, Record<string, string[]>> | Record<string, string[]>;
824
888
  useCategories?: boolean;
825
889
  }
@@ -893,7 +957,7 @@ declare class VirtualBase extends EventEmitter<EventNamesMap> {
893
957
  open(..._args: unknown[]): unknown;
894
958
  get path(): string;
895
959
  /**
896
- * Returns path without using alias
960
+ * Returns path without using this item's alias
897
961
  */
898
962
  get displayPath(): string;
899
963
  /**
@@ -917,10 +981,43 @@ declare interface VirtualBaseJson {
917
981
  }
918
982
 
919
983
  export declare class VirtualDriveConfig {
984
+ saveData: VirtualDriveConfigOptions["saveData"];
985
+ defaultData: VirtualDriveConfigOptions["defaultData"];
920
986
  constructor(options?: OptionalInterface<VirtualDriveConfigOptions>);
921
987
  }
922
988
 
923
989
  declare interface VirtualDriveConfigOptions {
990
+ /**
991
+ * Enables persistent storage of the virtual drive
992
+ * @default true
993
+ */
994
+ saveData: boolean;
995
+ /**
996
+ * Configure the data that is loaded initially when ProzillaOS is opened
997
+ */
998
+ defaultData: {
999
+ /**
1000
+ * Include pictures folder in default data
1001
+ * @default true
1002
+ */
1003
+ includePicturesFolder?: boolean;
1004
+ /**
1005
+ * Include documents folder in default data
1006
+ * @default true
1007
+ */
1008
+ includeDocumentsFolder?: boolean;
1009
+ /**
1010
+ * Include desktop folder in default data
1011
+ * @default true
1012
+ */
1013
+ includeDesktopFolder?: boolean;
1014
+ /**
1015
+ * Include source tree folder in default data
1016
+ * @default true
1017
+ */
1018
+ includeSourceTree?: boolean;
1019
+ loadData?: (virtualRoot: VirtualRoot) => void;
1020
+ };
924
1021
  }
925
1022
 
926
1023
  /**
@@ -932,9 +1029,9 @@ export declare class VirtualFile extends VirtualBase {
932
1029
  content: OptionalStringProperty;
933
1030
  static NON_TEXT_EXTENSIONS: string[];
934
1031
  static EVENT_NAMES: {
935
- CONTENT_CHANGE: string;
1032
+ contentChange: string;
936
1033
  };
937
- constructor(name: string, extension?: string | undefined);
1034
+ constructor(name: string, extension?: string);
938
1035
  setAlias(alias: string): this;
939
1036
  /**
940
1037
  * Sets the source of this file and removes the content
@@ -958,6 +1055,7 @@ export declare class VirtualFile extends VirtualBase {
958
1055
  getIconUrl(): string;
959
1056
  getType(): string;
960
1057
  toJSON(): VirtualFileJson | null;
1058
+ static removeFileScheme(source: string): string;
961
1059
  }
962
1060
 
963
1061
  declare interface VirtualFileJson extends VirtualBaseJson {
@@ -997,8 +1095,8 @@ export declare class VirtualFolder extends VirtualBase {
997
1095
  files: (VirtualFile | VirtualFileLink)[];
998
1096
  type: number | undefined;
999
1097
  static TYPE: {
1000
- GENERAL: number;
1001
- MEDIA: number;
1098
+ general: number;
1099
+ media: number;
1002
1100
  };
1003
1101
  constructor(name: string, type?: number);
1004
1102
  setAlias(alias: string): this;
@@ -1034,9 +1132,9 @@ export declare class VirtualFolder extends VirtualBase {
1034
1132
  */
1035
1133
  createFileLink(name: string, callback?: (newFileLink: VirtualFileLink | VirtualFile) => void): this;
1036
1134
  /**
1037
- * Creates files based on an array of objects with file names and extensions
1135
+ * Creates file links based on an array of objects with file names and extensions
1038
1136
  */
1039
- createFileLinks(files: {
1137
+ createFileLinks(fileLinks: {
1040
1138
  name: string;
1041
1139
  }[]): this;
1042
1140
  /**
@@ -1073,16 +1171,19 @@ export declare class VirtualFolder extends VirtualBase {
1073
1171
  delete(): void;
1074
1172
  /**
1075
1173
  * Returns all files inside this folder
1174
+ * @param showHidden Whether to include hidden files
1076
1175
  */
1077
1176
  getFiles(showHidden?: boolean): VirtualFile[];
1078
1177
  /**
1079
1178
  * Returns all sub-folders inside this folder
1179
+ * @param showHidden Whether to include hidden folders
1080
1180
  */
1081
1181
  getSubFolders(showHidden?: boolean): VirtualFolder[];
1082
1182
  /**
1083
- * Returns the amount of files and sub-folders inside this folder
1183
+ * Returns the amount of files and sub-folders inside this folder
1184
+ * @param includeHidden Whether to include hidden files and folders in the count
1084
1185
  */
1085
- getItemCount(showHidden?: boolean): number;
1186
+ getItemCount(includeHidden?: boolean): number;
1086
1187
  isFolder(): boolean;
1087
1188
  getIconUrl(): string;
1088
1189
  toJSON(): VirtualFolderJson | null;
@@ -1132,7 +1233,7 @@ export declare class VirtualRoot extends VirtualFolder {
1132
1233
  loadedDefaultData: boolean;
1133
1234
  systemManager: SystemManager;
1134
1235
  static EVENT_NAMES: {
1135
- ERROR: string;
1236
+ error: string;
1136
1237
  };
1137
1238
  constructor(systemManager: SystemManager);
1138
1239
  loadDefaultData(): void;
@@ -1192,14 +1293,14 @@ declare interface WindowOptions {
1192
1293
 
1193
1294
  export declare interface WindowProps extends WindowOptions {
1194
1295
  fullscreen?: boolean;
1195
- onInteract?: Function;
1296
+ onInteract?: () => void;
1196
1297
  setTitle?: React.Dispatch<React.SetStateAction<string>>;
1197
1298
  setIconUrl?: React.Dispatch<React.SetStateAction<string>>;
1198
1299
  close?: (event?: Event) => void;
1199
1300
  focus?: (event: Event, force?: boolean) => void;
1200
1301
  active?: boolean;
1201
1302
  minimized?: boolean;
1202
- toggleMinimized?: Function;
1303
+ toggleMinimized?: (event?: Event) => void;
1203
1304
  index?: number;
1204
1305
  standalone?: boolean;
1205
1306
  }
@@ -1232,24 +1333,53 @@ export declare class WindowsManager {
1232
1333
  windows: {
1233
1334
  [id: string]: WindowOptions;
1234
1335
  };
1235
- updateWindows: Function;
1336
+ updateWindows: (window: WindowsManager["windows"]) => void;
1236
1337
  startupComplete: boolean;
1237
1338
  constructor(systemManager: SystemManager, trackingManager: TrackingManager);
1339
+ /**
1340
+ * Open a window for an app
1341
+ */
1238
1342
  open(appId: string, options?: WindowOptions | null): object | null;
1343
+ /**
1344
+ * Opens a file with the associated app or by a method specified by the file scheme
1345
+ * @returns Opened window
1346
+ */
1239
1347
  openFile(file: VirtualFile, options?: object): object | null;
1348
+ /**
1349
+ * Close a window
1350
+ */
1240
1351
  close(windowId: string): void;
1352
+ /**
1353
+ * Focus on a specific window
1354
+ */
1241
1355
  focus(windowId: string): void;
1356
+ /**
1357
+ * Check whether a window is focused
1358
+ */
1242
1359
  isFocused(windowId: string): boolean | undefined;
1360
+ /**
1361
+ * Check if any window is focused
1362
+ */
1243
1363
  isAnyFocused(): boolean;
1244
1364
  /**
1365
+ * Change the minimized state of a window
1245
1366
  * @param minimized - Leave as undefined to toggle the window's minimization state
1246
1367
  */
1247
1368
  setMinimized(windowId: string, minimized?: boolean): void;
1369
+ /**
1370
+ * Minimize all windows
1371
+ */
1248
1372
  minimizeAll(): void;
1373
+ /**
1374
+ * Check if an app has an open window
1375
+ */
1249
1376
  isAppActive(appId: string): boolean;
1377
+ /**
1378
+ * Get an opened window of a certain app
1379
+ */
1250
1380
  getAppWindowId(appId: string): string | null;
1251
- setUpdateWindows(updateWindows: Function): void;
1252
- startup(appIds: string[], options: {}): void;
1381
+ setUpdateWindows(updateWindows: WindowsManager["updateWindows"]): void;
1382
+ startup(appIds: string[], options: Record<string, unknown>): void;
1253
1383
  get windowIds(): string[];
1254
1384
  }
1255
1385