@prozilla-os/core 1.3.1 → 1.3.3

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"];
@@ -572,6 +611,12 @@ declare class Skin {
572
611
  }
573
612
 
574
613
  declare interface SkinOptions {
614
+ /**
615
+ * SVG icon for the system
616
+ * @default
617
+ * "https://os.prozilla.dev/icon.svg"
618
+ */
619
+ systemIcon: string;
575
620
  /**
576
621
  * Replacements for app icons based on app id
577
622
  */
@@ -602,6 +647,7 @@ declare interface SkinOptions {
602
647
  info?: string;
603
648
  text?: string;
604
649
  code?: string;
650
+ external?: string;
605
651
  };
606
652
  /**
607
653
  * URLs of icons for types of folders
@@ -647,7 +693,7 @@ export declare class SystemManager {
647
693
  readonly trackingConfig: TrackingConfig;
648
694
  readonly windowsConfig: WindowsConfig;
649
695
  readonly virtualDriveConfig: VirtualDriveConfig;
650
- constructor({ systemName, tagLine, skin, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig }: SystemManagerParams);
696
+ constructor({ systemName, tagLine, skin, desktopConfig, appsConfig, miscConfig, modalsConfig, taskbarConfig, trackingConfig, windowsConfig, virtualDriveConfig, }: SystemManagerParams);
651
697
  private loadSkin;
652
698
  getUptime(precision?: number): string;
653
699
  }
@@ -690,8 +736,14 @@ declare interface TextDisplayProps {
690
736
  export declare const THEMES: Record<number, string | null>;
691
737
 
692
738
  export declare class TimeManager {
693
- static startDate: Date;
739
+ static START_DATE: Date;
740
+ /**
741
+ * Resets the time
742
+ */
694
743
  static reset(): void;
744
+ /**
745
+ * Get the current uptime
746
+ */
695
747
  static getUptime(precision?: number): string;
696
748
  }
697
749
 
@@ -703,7 +755,7 @@ declare interface ToggleActionProps extends ActionProps {
703
755
 
704
756
  export declare class TrackingConfig {
705
757
  enabled: TrackingConfigOptions["enabled"];
706
- GAMeasurementId: TrackingConfigOptions["GAMeasurementId"];
758
+ googleAnalyticsMeasurementId: TrackingConfigOptions["GAMeasurementId"];
707
759
  constructor(options?: OptionalInterface<TrackingConfigOptions>);
708
760
  }
709
761
 
@@ -750,9 +802,9 @@ declare interface UseContextMenuParams {
750
802
  export declare function useHistory<Type>(initialState: Type): {
751
803
  history: Type[];
752
804
  stateIndex: number;
753
- pushState: Function;
754
- undo: Function;
755
- redo: Function;
805
+ pushState: (state: Type) => void;
806
+ undo: () => void;
807
+ redo: () => void;
756
808
  undoAvailable: boolean;
757
809
  redoAvailable: boolean;
758
810
  };
@@ -819,7 +871,7 @@ export declare function useSettingsManager(): SettingsManagerState;
819
871
  export declare function useShortcuts({ options, shortcuts, useCategories }: UseShortcutsParams): void;
820
872
 
821
873
  declare interface UseShortcutsParams {
822
- options: Record<string, Record<string, Function>> | Record<string, Function>;
874
+ options: Record<string, Record<string, (event: KeyboardEvent) => void>> | Record<string, (event: KeyboardEvent) => void>;
823
875
  shortcuts?: Record<string, Record<string, string[]>> | Record<string, string[]>;
824
876
  useCategories?: boolean;
825
877
  }
@@ -917,10 +969,43 @@ declare interface VirtualBaseJson {
917
969
  }
918
970
 
919
971
  export declare class VirtualDriveConfig {
972
+ saveData: VirtualDriveConfigOptions["saveData"];
973
+ defaultData: VirtualDriveConfigOptions["defaultData"];
920
974
  constructor(options?: OptionalInterface<VirtualDriveConfigOptions>);
921
975
  }
922
976
 
923
977
  declare interface VirtualDriveConfigOptions {
978
+ /**
979
+ * Enables persistent storage of the virtual drive
980
+ * @default true
981
+ */
982
+ saveData: boolean;
983
+ /**
984
+ * Configure the data that is loaded initially when ProzillaOS is opened
985
+ */
986
+ defaultData: {
987
+ /**
988
+ * Include pictures folder in default data
989
+ * @default true
990
+ */
991
+ includePicturesFolder?: boolean;
992
+ /**
993
+ * Include documents folder in default data
994
+ * @default true
995
+ */
996
+ includeDocumentsFolder?: boolean;
997
+ /**
998
+ * Include desktop folder in default data
999
+ * @default true
1000
+ */
1001
+ includeDesktopFolder?: boolean;
1002
+ /**
1003
+ * Include source tree folder in default data
1004
+ * @default true
1005
+ */
1006
+ includeSourceTree?: boolean;
1007
+ loadData?: (virtualRoot: VirtualRoot) => void;
1008
+ };
924
1009
  }
925
1010
 
926
1011
  /**
@@ -932,9 +1017,9 @@ export declare class VirtualFile extends VirtualBase {
932
1017
  content: OptionalStringProperty;
933
1018
  static NON_TEXT_EXTENSIONS: string[];
934
1019
  static EVENT_NAMES: {
935
- CONTENT_CHANGE: string;
1020
+ contentChange: string;
936
1021
  };
937
- constructor(name: string, extension?: string | undefined);
1022
+ constructor(name: string, extension?: string);
938
1023
  setAlias(alias: string): this;
939
1024
  /**
940
1025
  * Sets the source of this file and removes the content
@@ -958,6 +1043,7 @@ export declare class VirtualFile extends VirtualBase {
958
1043
  getIconUrl(): string;
959
1044
  getType(): string;
960
1045
  toJSON(): VirtualFileJson | null;
1046
+ static removeFileScheme(source: string): string;
961
1047
  }
962
1048
 
963
1049
  declare interface VirtualFileJson extends VirtualBaseJson {
@@ -997,8 +1083,8 @@ export declare class VirtualFolder extends VirtualBase {
997
1083
  files: (VirtualFile | VirtualFileLink)[];
998
1084
  type: number | undefined;
999
1085
  static TYPE: {
1000
- GENERAL: number;
1001
- MEDIA: number;
1086
+ general: number;
1087
+ media: number;
1002
1088
  };
1003
1089
  constructor(name: string, type?: number);
1004
1090
  setAlias(alias: string): this;
@@ -1132,7 +1218,7 @@ export declare class VirtualRoot extends VirtualFolder {
1132
1218
  loadedDefaultData: boolean;
1133
1219
  systemManager: SystemManager;
1134
1220
  static EVENT_NAMES: {
1135
- ERROR: string;
1221
+ error: string;
1136
1222
  };
1137
1223
  constructor(systemManager: SystemManager);
1138
1224
  loadDefaultData(): void;
@@ -1192,14 +1278,14 @@ declare interface WindowOptions {
1192
1278
 
1193
1279
  export declare interface WindowProps extends WindowOptions {
1194
1280
  fullscreen?: boolean;
1195
- onInteract?: Function;
1281
+ onInteract?: () => void;
1196
1282
  setTitle?: React.Dispatch<React.SetStateAction<string>>;
1197
1283
  setIconUrl?: React.Dispatch<React.SetStateAction<string>>;
1198
1284
  close?: (event?: Event) => void;
1199
1285
  focus?: (event: Event, force?: boolean) => void;
1200
1286
  active?: boolean;
1201
1287
  minimized?: boolean;
1202
- toggleMinimized?: Function;
1288
+ toggleMinimized?: (event?: Event) => void;
1203
1289
  index?: number;
1204
1290
  standalone?: boolean;
1205
1291
  }
@@ -1232,24 +1318,53 @@ export declare class WindowsManager {
1232
1318
  windows: {
1233
1319
  [id: string]: WindowOptions;
1234
1320
  };
1235
- updateWindows: Function;
1321
+ updateWindows: (window: WindowsManager["windows"]) => void;
1236
1322
  startupComplete: boolean;
1237
1323
  constructor(systemManager: SystemManager, trackingManager: TrackingManager);
1324
+ /**
1325
+ * Open a window for an app
1326
+ */
1238
1327
  open(appId: string, options?: WindowOptions | null): object | null;
1328
+ /**
1329
+ * Opens a file with the associated app or by a method specified by the file scheme
1330
+ * @returns Opened window
1331
+ */
1239
1332
  openFile(file: VirtualFile, options?: object): object | null;
1333
+ /**
1334
+ * Close a window
1335
+ */
1240
1336
  close(windowId: string): void;
1337
+ /**
1338
+ * Focus on a specific window
1339
+ */
1241
1340
  focus(windowId: string): void;
1341
+ /**
1342
+ * Check whether a window is focused
1343
+ */
1242
1344
  isFocused(windowId: string): boolean | undefined;
1345
+ /**
1346
+ * Check if any window is focused
1347
+ */
1243
1348
  isAnyFocused(): boolean;
1244
1349
  /**
1350
+ * Change the minimized state of a window
1245
1351
  * @param minimized - Leave as undefined to toggle the window's minimization state
1246
1352
  */
1247
1353
  setMinimized(windowId: string, minimized?: boolean): void;
1354
+ /**
1355
+ * Minimize all windows
1356
+ */
1248
1357
  minimizeAll(): void;
1358
+ /**
1359
+ * Check if an app has an open window
1360
+ */
1249
1361
  isAppActive(appId: string): boolean;
1362
+ /**
1363
+ * Get an opened window of a certain app
1364
+ */
1250
1365
  getAppWindowId(appId: string): string | null;
1251
- setUpdateWindows(updateWindows: Function): void;
1252
- startup(appIds: string[], options: {}): void;
1366
+ setUpdateWindows(updateWindows: WindowsManager["updateWindows"]): void;
1367
+ startup(appIds: string[], options: Record<string, unknown>): void;
1253
1368
  get windowIds(): string[];
1254
1369
  }
1255
1370