diff --git a/eslint.config.js b/eslint.config.js index 4342e26..f159204 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -14,6 +14,7 @@ export default tseslint.config( project: ["./tsconfig.json", "./packages/*/tsconfig.json", "./packages/apps/*/tsconfig.json"], tsconfigRootDir: import.meta.dirname, allowAutomaticSingleRunInference: true, + EXPERIMENTAL_useProjectService: true }, }, ignores: [ diff --git a/packages/apps/file-explorer/CHANGELOG.md b/packages/apps/file-explorer/CHANGELOG.md index 59d7368..88dc146 100644 --- a/packages/apps/file-explorer/CHANGELOG.md +++ b/packages/apps/file-explorer/CHANGELOG.md @@ -1,5 +1,13 @@ # @prozilla-os/file-explorer +## 1.0.10 + +### Patch Changes + +- Added application roles +- Updated dependencies + - @prozilla-os/core@1.0.13 + ## 1.0.9 ### Patch Changes diff --git a/packages/apps/file-explorer/package.json b/packages/apps/file-explorer/package.json index 1d7db7a..299a54d 100644 --- a/packages/apps/file-explorer/package.json +++ b/packages/apps/file-explorer/package.json @@ -1,7 +1,7 @@ { "name": "@prozilla-os/file-explorer", "description": "A standard ProzillaOS application for browsing files.", - "version": "1.0.9", + "version": "1.0.10", "homepage": "https://os.prozilla.dev/file-explorer", "author": { "name": "Prozilla", @@ -12,7 +12,7 @@ "main": "dist/main.js", "types": "dist/main.d.ts", "scripts": { - "build": "tsc && vite build" + "build": "tsc --project tsconfig.build.json && vite build" }, "repository": { "type": "git", diff --git a/packages/apps/file-explorer/src/components/FileExplorer.tsx b/packages/apps/file-explorer/src/components/FileExplorer.tsx index 2a4b225..27cd1bd 100644 --- a/packages/apps/file-explorer/src/components/FileExplorer.tsx +++ b/packages/apps/file-explorer/src/components/FileExplorer.tsx @@ -4,9 +4,10 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faArrowUp, faCaretLeft, faCaretRight, faCircleInfo, faCog, faDesktop, faFileLines, faHouse, faImage, faPlus, faSearch, faTrash } from "@fortawesome/free-solid-svg-icons"; import { QuickAccessButton } from "./QuickAccessButton"; import { ImportButton } from "./ImportButton"; -import { Actions, ClickAction, CODE_EXTENSIONS, DIALOG_CONTENT_TYPES, DialogBox, DirectoryList, Divider, FileEventHandler, FolderEventHandler, OnSelectionChangeParams, useAlert, useContextMenu, useHistory, useSystemManager, useVirtualRoot, useWindowedModal, useWindowsManager, utilStyles, Vector2, VirtualFile, VirtualFolder, VirtualFolderLink, VirtualRoot, WindowProps } from "@prozilla-os/core"; +import { Actions, ClickAction, CODE_EXTENSIONS, DialogBox, DirectoryList, Divider, FileEventHandler, FolderEventHandler, ModalProps, ModalsConfig, OnSelectionChangeParams, useAlert, useContextMenu, useHistory, useSystemManager, useVirtualRoot, useWindowedModal, useWindowsManager, utilStyles, Vector2, VirtualFile, VirtualFolder, VirtualFolderLink, VirtualRoot, WindowProps } from "@prozilla-os/core"; import { SELECTOR_MODE } from "../constants/fileExplorer.const"; import { FileProperties } from "./modals/file-properties/FileProperties"; +import { JSX } from "react/jsx-runtime"; export interface FileExplorerProps extends WindowProps { path?: string; @@ -140,10 +141,10 @@ export function FileExplorer({ app, path: startPath, selectorMode, Footer, onSel title: "Error", iconUrl: app?.iconUrl as string | undefined, size: new Vector2(300, 150), - Modal: (props: {}) => + Modal: (props: JSX.IntrinsicAttributes & ModalProps) =>

Invalid path: "{value}"

- +
}); return; @@ -191,16 +192,16 @@ export function FileExplorer({ app, path: startPath, selectorMode, Footer, onSel tabIndex={0} className={styles.IconButton} onClick={() => { - // openWindowedModal({ - // title: "Error", - // iconUrl: AppsManager.getAppIconUrl(APPS.FILE_EXPLORER), - // size: new Vector2(300, 150), - // Modal: (props) => - // - //

This folder is protected.

- // - //
- // }); + openWindowedModal({ + title: "Error", + iconUrl: app?.iconUrl as string | undefined, + size: new Vector2(300, 150), + Modal: (props: JSX.IntrinsicAttributes & ModalProps) => + +

This folder is protected.

+ +
+ }); // if (currentDirectory.canBeEdited) { // onNew(event); diff --git a/packages/apps/file-explorer/src/main.ts b/packages/apps/file-explorer/src/main.ts index d97ee8f..611a579 100644 --- a/packages/apps/file-explorer/src/main.ts +++ b/packages/apps/file-explorer/src/main.ts @@ -1,8 +1,9 @@ -import { App } from "@prozilla-os/core"; +import { App, AppsConfig } from "@prozilla-os/core"; import { FileExplorer, FileExplorerProps } from "./components/FileExplorer"; const fileExplorer = new App("File Explorer", "file-explorer", FileExplorer) - .setIconUrl("https://os.prozilla.dev/assets/apps/icons/file-explorer.svg"); + .setIconUrl("https://os.prozilla.dev/assets/apps/icons/file-explorer.svg") + .setRole(AppsConfig.APP_ROLES.FileExplorer); export { fileExplorer }; export { FileSelectorMode } from "./types/utils"; \ No newline at end of file diff --git a/packages/apps/file-explorer/tsconfig.build.json b/packages/apps/file-explorer/tsconfig.build.json new file mode 100644 index 0000000..18fdbd9 --- /dev/null +++ b/packages/apps/file-explorer/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "paths": { + "@prozilla-os/core": ["packages/core/dist/main"] + } + } +} \ No newline at end of file diff --git a/packages/apps/file-explorer/tsconfig.json b/packages/apps/file-explorer/tsconfig.json index aa4a7f6..66cc328 100644 --- a/packages/apps/file-explorer/tsconfig.json +++ b/packages/apps/file-explorer/tsconfig.json @@ -8,9 +8,9 @@ "emitDeclarationOnly": true, "noEmit": false, "paths": { - "@prozilla-os/core": ["packages/core/dist/main"] + "@prozilla-os/core": ["./node_modules/@prozilla-os/core/src/main"] } }, "include": ["src", "vite.config.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules"], } \ No newline at end of file diff --git a/packages/apps/file-explorer/vite.config.ts b/packages/apps/file-explorer/vite.config.ts index d216a24..e30fa76 100644 --- a/packages/apps/file-explorer/vite.config.ts +++ b/packages/apps/file-explorer/vite.config.ts @@ -15,6 +15,7 @@ export default defineConfig({ rollupTypes: true, strictOutput: true, pathsToAliases: false, + tsconfigPath: "tsconfig.build.json" }) ], build: { diff --git a/packages/apps/terminal/CHANGELOG.md b/packages/apps/terminal/CHANGELOG.md index f3b37ef..f18d56a 100644 --- a/packages/apps/terminal/CHANGELOG.md +++ b/packages/apps/terminal/CHANGELOG.md @@ -1,5 +1,13 @@ # @prozilla-os/terminal +## 1.0.3 + +### Patch Changes + +- Added application roles +- Updated dependencies + - @prozilla-os/core@1.0.13 + ## 1.0.2 ### Patch Changes diff --git a/packages/apps/terminal/package.json b/packages/apps/terminal/package.json index a98dc3b..cf58f7a 100644 --- a/packages/apps/terminal/package.json +++ b/packages/apps/terminal/package.json @@ -1,7 +1,7 @@ { "name": "@prozilla-os/terminal", "description": "A terminal/shell application for ProzillaOS.", - "version": "1.0.2", + "version": "1.0.3", "homepage": "https://os.prozilla.dev/terminal", "author": { "name": "Prozilla", diff --git a/packages/apps/terminal/src/main.ts b/packages/apps/terminal/src/main.ts index 69bbe0b..f6d2089 100644 --- a/packages/apps/terminal/src/main.ts +++ b/packages/apps/terminal/src/main.ts @@ -1,7 +1,8 @@ -import { App } from "@prozilla-os/core"; +import { App, AppsConfig } from "@prozilla-os/core"; import { Terminal, TerminalProps } from "./components/Terminal"; const terminal = new App("Terminal", "terminal", Terminal) - .setIconUrl("https://os.prozilla.dev/assets/apps/icons/terminal.svg"); + .setIconUrl("https://os.prozilla.dev/assets/apps/icons/terminal.svg") + .setRole(AppsConfig.APP_ROLES.Terminal); export { terminal }; \ No newline at end of file diff --git a/packages/apps/terminal/tsconfig.build.json b/packages/apps/terminal/tsconfig.build.json new file mode 100644 index 0000000..18fdbd9 --- /dev/null +++ b/packages/apps/terminal/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "paths": { + "@prozilla-os/core": ["packages/core/dist/main"] + } + } +} \ No newline at end of file diff --git a/packages/apps/terminal/tsconfig.json b/packages/apps/terminal/tsconfig.json index aa4a7f6..66cc328 100644 --- a/packages/apps/terminal/tsconfig.json +++ b/packages/apps/terminal/tsconfig.json @@ -8,9 +8,9 @@ "emitDeclarationOnly": true, "noEmit": false, "paths": { - "@prozilla-os/core": ["packages/core/dist/main"] + "@prozilla-os/core": ["./node_modules/@prozilla-os/core/src/main"] } }, "include": ["src", "vite.config.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules"], } \ No newline at end of file diff --git a/packages/apps/text-editor/CHANGELOG.md b/packages/apps/text-editor/CHANGELOG.md index 7b247ec..8e0c491 100644 --- a/packages/apps/text-editor/CHANGELOG.md +++ b/packages/apps/text-editor/CHANGELOG.md @@ -1,5 +1,13 @@ # @prozilla-os/text-editor +## 1.0.3 + +### Patch Changes + +- Added application roles +- Updated dependencies + - @prozilla-os/core@1.0.13 + ## 1.0.2 ### Patch Changes diff --git a/packages/apps/text-editor/package.json b/packages/apps/text-editor/package.json index a7b6dab..a4b415b 100644 --- a/packages/apps/text-editor/package.json +++ b/packages/apps/text-editor/package.json @@ -1,7 +1,7 @@ { "name": "@prozilla-os/text-editor", "description": "A text editor application for ProzillaOS.", - "version": "1.0.2", + "version": "1.0.3", "homepage": "https://os.prozilla.dev/text-editor", "author": { "name": "Prozilla", diff --git a/packages/apps/text-editor/src/components/overrides/MarkdownLink.tsx b/packages/apps/text-editor/src/components/overrides/MarkdownLink.tsx index c9b6e05..2e571a8 100644 --- a/packages/apps/text-editor/src/components/overrides/MarkdownLink.tsx +++ b/packages/apps/text-editor/src/components/overrides/MarkdownLink.tsx @@ -2,7 +2,7 @@ import { MouseEventHandler, ReactNode, useMemo } from "react"; import { faClipboard, faExternalLink } from "@fortawesome/free-solid-svg-icons"; import { MarkdownProps } from "../TextEditor"; import styles from "../TextEditor.module.css"; -import { Actions, ClickAction, copyToClipboard, DIALOG_CONTENT_TYPES, DialogBox, ModalProps, removeUrlProtocol, TextDisplay, useContextMenu, useWindowedModal, Vector2 } from "@prozilla-os/core"; +import { Actions, ClickAction, copyToClipboard, DialogBox, ModalProps, ModalsConfig, removeUrlProtocol, TextDisplay, useContextMenu, useWindowedModal, Vector2 } from "@prozilla-os/core"; import { sanitizeProps } from "../../core/_utils/sanitizeProps"; interface MarkdownLinkProps extends MarkdownProps { @@ -32,7 +32,7 @@ export function MarkdownLink({ href, children, windowsManager, currentFile, setC Modal: (props: ModalProps) =>

Target not found: "{href}"

- +
}); } diff --git a/packages/apps/text-editor/src/main.ts b/packages/apps/text-editor/src/main.ts index 67b3bd7..598d96a 100644 --- a/packages/apps/text-editor/src/main.ts +++ b/packages/apps/text-editor/src/main.ts @@ -1,7 +1,8 @@ -import { App } from "@prozilla-os/core"; +import { App, AppsConfig } from "@prozilla-os/core"; import { TextEditor, TextEditorProps } from "./components/TextEditor"; const textEditor = new App("Text Editor", "text-editor", TextEditor) - .setIconUrl("https://os.prozilla.dev/assets/apps/icons/text-editor.svg"); + .setIconUrl("https://os.prozilla.dev/assets/apps/icons/text-editor.svg") + .setRole(AppsConfig.APP_ROLES.TextEditor); export { textEditor }; \ No newline at end of file diff --git a/packages/apps/text-editor/tsconfig.build.json b/packages/apps/text-editor/tsconfig.build.json new file mode 100644 index 0000000..18fdbd9 --- /dev/null +++ b/packages/apps/text-editor/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "paths": { + "@prozilla-os/core": ["packages/core/dist/main"] + } + } +} \ No newline at end of file diff --git a/packages/apps/text-editor/tsconfig.json b/packages/apps/text-editor/tsconfig.json index aa4a7f6..a550f60 100644 --- a/packages/apps/text-editor/tsconfig.json +++ b/packages/apps/text-editor/tsconfig.json @@ -8,7 +8,7 @@ "emitDeclarationOnly": true, "noEmit": false, "paths": { - "@prozilla-os/core": ["packages/core/dist/main"] + "@prozilla-os/core": ["./node_modules/@prozilla-os/core/src/main"] } }, "include": ["src", "vite.config.ts"], diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index ebd22d5..52ccc6c 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # @prozilla-os/core +## 1.0.13 + +### Patch Changes + +- Added application roles + ## 1.0.12 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 72fefea..7f753a4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@prozilla-os/core", "description": "A React component library written in TypeScript for building web-based operating systems, made by Prozilla.", - "version": "1.0.12", + "version": "1.0.13", "homepage": "https://os.prozilla.dev", "author": { "name": "Prozilla", diff --git a/packages/core/src/components/desktop/Desktop.tsx b/packages/core/src/components/desktop/Desktop.tsx index 852f5a1..3d97408 100644 --- a/packages/core/src/components/desktop/Desktop.tsx +++ b/packages/core/src/components/desktop/Desktop.tsx @@ -3,23 +3,22 @@ import styles from "./Desktop.module.css"; import { useEffect } from "react"; import { Actions } from "../actions/Actions"; import { ClickAction } from "../actions/actions/ClickAction"; -import { faArrowsRotate, faCompress, faExpand, faEye, faFolder, faPaintBrush, faTerminal, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { faArrowsRotate, faCompress, faExpand, faEye, faPaintBrush, faTrash } from "@fortawesome/free-solid-svg-icons"; import { ToggleAction } from "../actions/actions/ToggleAction"; import { DropdownAction } from "../actions/actions/DropdownAction"; import { RadioAction } from "../actions/actions/RadioAction"; import { Divider } from "../actions/actions/Divider"; import { Share } from "../modals/share/Share"; import { ModalProps } from "../modals/ModalView"; -import { SettingsManager, reloadViewport, ModalsManager, Vector2, isValidInteger } from "../../features"; +import { SettingsManager, reloadViewport, ModalsManager, Vector2, isValidInteger, AppsConfig } from "../../features"; import { VirtualFile } from "../../features/virtual-drive/file"; import { VirtualFolder, VirtualFolderLink } from "../../features/virtual-drive/folder"; import { useSettingsManager, useWindowsManager, useVirtualRoot, useWindowedModal, useContextMenu, useSystemManager } from "../../hooks"; import { DirectoryList } from "../_utils"; import { FileEventHandler, FolderEventHandler } from "../_utils/directory-list/DirectoryList"; -// import { fileExplorer } from "@prozilla-os/file-explorer"; export const Desktop = memo(() => { - const { desktopConfig } = useSystemManager(); + const { desktopConfig, appsConfig } = useSystemManager(); const settingsManager = useSettingsManager(); const windowsManager = useWindowsManager(); const virtualRoot = useVirtualRoot(); @@ -32,6 +31,9 @@ export const Desktop = memo(() => { const directory = virtualRoot?.navigate("~/Desktop"); + const fileExplorer = appsConfig.getAppByRole(AppsConfig.APP_ROLES.FileExplorer); + const terminal = appsConfig.getAppByRole(AppsConfig.APP_ROLES.Terminal); + const { onContextMenu, ShortcutsListener } = useContextMenu({ Actions: (props) => @@ -83,12 +85,16 @@ export const Desktop = memo(() => { windowsManager?.open("settings", { tab: 2 }); }}/> - {/* { - windowsManager?.open(fileExplorer.id, { path: directory?.path }); - }}/> */} - {/* { - windowsManager?.open(APPS.TERMINAL, { path: directory?.path }); - }}/> */} + {fileExplorer != null && + { + windowsManager?.open(fileExplorer.id, { path: directory?.path }); + }}/> + } + {terminal != null && + { + windowsManager?.open(terminal.id, { path: directory?.path }); + }}/> + } { openWindowedModal({ @@ -103,9 +109,11 @@ export const Desktop = memo(() => { { if (windowsManager != null) (file as VirtualFile).open(windowsManager); }}/> - {/* { - if (windowsManager != null) (file as VirtualFile).parent?.open(windowsManager); - }}/> */} + {fileExplorer != null && + { + if (windowsManager != null) (file as VirtualFile).parent?.open(windowsManager); + }}/> + } { (file as VirtualFile).delete(); }}/> @@ -116,12 +124,16 @@ export const Desktop = memo(() => { { if (windowsManager != null) (folder as VirtualFolder).open(windowsManager); }}/> - {/* { - windowsManager?.open(APPS.TERMINAL, { path: (folder as VirtualFolder).path }); - }}/> */} - {/* { - if (windowsManager != null) (folder as VirtualFolder).parent?.open(windowsManager); - }}/> */} + {fileExplorer != null && + { + windowsManager?.open(fileExplorer.id, { path: (folder as VirtualFolder).path }); + }}/> + } + {terminal != null && + { + if (windowsManager != null) (folder as VirtualFolder).parent?.open(windowsManager); + }}/> + } { (folder as VirtualFolder).delete(); @@ -183,9 +195,11 @@ export const Desktop = memo(() => { windowsManager?.openFile(file, options); }} onOpenFolder={(event, folder) => { - // windowsManager?.open(fileExplorer.id, { - // path: (folder as VirtualFolderLink).linkedPath ?? folder.path - // }); + if (fileExplorer != null) { + windowsManager?.open(fileExplorer.id, { + path: (folder as VirtualFolderLink).linkedPath ?? folder.path + }); + } }} onContextMenuFile={onContextMenuFile as unknown as FileEventHandler} onContextMenuFolder={onContextMenuFolder as unknown as FolderEventHandler} diff --git a/packages/core/src/components/modals/dialog-box/DialogBox.tsx b/packages/core/src/components/modals/dialog-box/DialogBox.tsx index fea1b30..5692162 100644 --- a/packages/core/src/components/modals/dialog-box/DialogBox.tsx +++ b/packages/core/src/components/modals/dialog-box/DialogBox.tsx @@ -1,4 +1,4 @@ -import { DIALOG_CONTENT_TYPES } from "../../../constants/modals.const"; +import { ModalsConfig } from "../../../features/system/configs"; import { WindowedModal } from "../_utils/WindowedModal"; import { ModalProps } from "../ModalView"; import styles from "./DialogBox.module.css"; @@ -12,7 +12,7 @@ export function DialogBox({ modal, params, children, ...props }: ModalProps) { const type = parseInt(attribute); switch (type) { - case DIALOG_CONTENT_TYPES.closeButton: + case ModalsConfig.DIALOG_CONTENT_TYPES.CloseButton: modal?.close(); break; } diff --git a/packages/core/src/components/taskbar/menus/HomeMenu.tsx b/packages/core/src/components/taskbar/menus/HomeMenu.tsx index 5e03014..b2f32b3 100644 --- a/packages/core/src/components/taskbar/menus/HomeMenu.tsx +++ b/packages/core/src/components/taskbar/menus/HomeMenu.tsx @@ -5,10 +5,9 @@ import taskbarStyles from "../Taskbar.module.css"; import { faCircleInfo, faFileLines, faGear, faImage, faPowerOff } from "@fortawesome/free-solid-svg-icons"; import { ReactSVG } from "react-svg"; import { useEffect, useState } from "react"; -import { closeViewport, Vector2 } from "../../../features"; +import { AppsConfig, closeViewport, Vector2 } from "../../../features"; import { useWindowsManager, useVirtualRoot, useKeyboardListener, useSystemManager } from "../../../hooks"; import { utilStyles } from "../../../styles"; -// import { fileExplorer } from "@prozilla-os/file-explorer"; interface HomeMenuProps { active: boolean; @@ -56,6 +55,8 @@ export function HomeMenu({ active, setActive, search }: HomeMenuProps) { useKeyboardListener({ onKeyDown, onKeyUp }); + const fileExplorer = appsConfig.getAppByRole(AppsConfig.APP_ROLES.FileExplorer); + return (
@@ -82,20 +83,22 @@ export function HomeMenu({ active, setActive, search }: HomeMenuProps) {

Info

- {/* - */} + {fileExplorer != null && <> + + + }
diff --git a/packages/core/src/constants/index.ts b/packages/core/src/constants/index.ts index 9a24704..2e36b84 100644 --- a/packages/core/src/constants/index.ts +++ b/packages/core/src/constants/index.ts @@ -1,4 +1,3 @@ -export { DIALOG_CONTENT_TYPES } from "./modals.const"; export { CODE_EXTENSIONS } from "./virtualDrive.const"; export { ANSI } from "./utils.const"; export { THEMES } from "./themes.const"; \ No newline at end of file diff --git a/packages/core/src/constants/modals.const.ts b/packages/core/src/constants/modals.const.ts deleted file mode 100644 index 749bcdc..0000000 --- a/packages/core/src/constants/modals.const.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const DIALOG_CONTENT_TYPES = { - closeButton: 0 -}; \ No newline at end of file diff --git a/packages/core/src/features/system/configs/app.tsx b/packages/core/src/features/system/configs/app.tsx index 5e6b381..12ace13 100644 --- a/packages/core/src/features/system/configs/app.tsx +++ b/packages/core/src/features/system/configs/app.tsx @@ -4,24 +4,57 @@ import { FC } from "react"; const validIdRegex = /^[a-zA-Z0-9-]+$/; +/** + * An application that can be ran by ProzillaOS + * Applications can be installed by adding them to the `apps` array in {@link AppsConfig} + */ export class App { + /** + * The display name of this application + */ name: string = "App"; + + /** + * The unique ID of this application + */ id: string = "app"; + + /** + * Main component that renders this app inside a window + */ windowContent: FC; + + /** + * Default options that get passed to the {@link this.windowContent} component + */ windowOptions?: { size: Vector2; [key: string]: unknown; }; + /** + * Description of this application + */ description: string | null = null; + + /** + * URL of the icon of this application + */ iconUrl: string | null = null; + /** + * Defines what the app can handle and how it can be used elsewhere in the system + */ + role: string | null = null; + + /** + * An array of file extensions that this application can interpret + */ + associatedExtensions: string[] = []; + isActive: boolean = false; isPinned?: boolean; - /** - * @param windowOptions - Default window options - */ constructor(name: App["name"], id: App["id"], windowContent: App["windowContent"], windowOptions?: App["windowOptions"]) { this.name = name; this.id = id; @@ -36,25 +69,49 @@ export class App { WindowContent = (props: AppProps) => { props = { ...props, ...this.windowOptions }; - if (this.windowContent == null) { + if (this.windowContent == null) return null; - } return ; }; + /** + * Set the display name of this application + */ + setName(name: string): this { + this.name = name; + return this; + } + + /** + * Set the description of this application + */ setDescription(description: App["description"]): this { this.description = description; return this; } + /** + * Set the URL of the icon of this application + */ setIconUrl(iconUrl: App["iconUrl"]): this { this.iconUrl = iconUrl; return this; } - setName(name: string): this { - this.name = name; + /** + * Set the role of this application + */ + setRole(role: string | null): this { + this.role = role; + return this; + } + + /** + * Set the associated extensions of this application + */ + setAssociatedExtensions(extensions: string[] | null): this { + this.associatedExtensions = extensions ?? []; return this; } } \ No newline at end of file diff --git a/packages/core/src/features/system/configs/appsConfig.ts b/packages/core/src/features/system/configs/appsConfig.ts index f2a2d0d..7d8852d 100644 --- a/packages/core/src/features/system/configs/appsConfig.ts +++ b/packages/core/src/features/system/configs/appsConfig.ts @@ -2,6 +2,9 @@ import { App } from "."; import { OptionalInterface } from "../../../types/utils"; export interface AppsConfigOptions { + /** + * An array of applications + */ // eslint-disable-next-line @typescript-eslint/no-explicit-any apps: App[]; } @@ -9,6 +12,12 @@ export interface AppsConfigOptions { export class AppsConfig { apps: AppsConfigOptions["apps"] = []; + static APP_ROLES = { + FileExplorer: "file-explorer", + Terminal: "terminal", + TextEditor: "text-editor", + }; + constructor(options: OptionalInterface = {}) { const { apps } = options as AppsConfigOptions; @@ -29,7 +38,7 @@ export class AppsConfig { let resultApp: App | null = null; this.apps.forEach((app) => { - if (app.id === id) { + if (resultApp == null && app.id === id) { resultApp = app; return; } @@ -42,19 +51,31 @@ export class AppsConfig { * Get the app associated with a file extension */ getAppByFileExtension(fileExtension: string): App | null { - return null; + let resultApp: App | null = null; - // let app: App | null = null; + this.apps.forEach((app) => { + if (resultApp == null && app.associatedExtensions?.includes(fileExtension)) { + resultApp = app; + return; + } + }); - // if (IMAGE_FORMATS.includes(fileExtension)) - // return this.getAppById(APPS.MEDIA_VIEWER); + return resultApp ?? this.getAppByRole(AppsConfig.APP_ROLES.TextEditor); + } - // switch (fileExtension) { - // default: - // app = this.getAppById(APPS.TEXT_EDITOR); - // break; - // } + /** + * Get the app with a specific role + */ + getAppByRole(role: string): App | null { + let resultApp: App | null = null; - // return app; + this.apps.forEach((app) => { + if (resultApp == null && app.role == role) { + resultApp = app; + return; + } + }); + + return resultApp; } } \ No newline at end of file diff --git a/packages/core/src/features/system/configs/index.ts b/packages/core/src/features/system/configs/index.ts index 92bb1e4..765b33b 100644 --- a/packages/core/src/features/system/configs/index.ts +++ b/packages/core/src/features/system/configs/index.ts @@ -6,4 +6,4 @@ export { ModalsConfig } from "./modalsConfig"; export { TaskbarConfig } from "./taskbarConfig"; export { TrackingConfig } from "./trackingConfig"; export { WindowsConfig } from "./windowsConfig"; -export { VirtualDriveConfig } from "./virtualDriveConfig"; \ No newline at end of file +export { VirtualDriveConfig } from "./virtualDriveConfig"; diff --git a/packages/core/src/features/system/configs/modalsConfig.ts b/packages/core/src/features/system/configs/modalsConfig.ts index e9d0e3d..93dd5eb 100644 --- a/packages/core/src/features/system/configs/modalsConfig.ts +++ b/packages/core/src/features/system/configs/modalsConfig.ts @@ -19,6 +19,10 @@ export class ModalsConfig { defaultDialogSize: ModalsConfigOptions["defaultDialogSize"]; defaultFileSelectorSize: ModalsConfigOptions["defaultFileSelectorSize"]; + static DIALOG_CONTENT_TYPES = { + CloseButton: 0 + }; + constructor(options: OptionalInterface = {}) { const { defaultDialogSize, defaultFileSelectorSize } = options as ModalsConfigOptions; diff --git a/packages/core/src/features/virtual-drive/folder/virtualFolder.ts b/packages/core/src/features/virtual-drive/folder/virtualFolder.ts index b4538c7..19e3122 100644 --- a/packages/core/src/features/virtual-drive/folder/virtualFolder.ts +++ b/packages/core/src/features/virtual-drive/folder/virtualFolder.ts @@ -4,7 +4,7 @@ import { VirtualFileJson } from "../file/virtualFile"; import { VirtualBase, VirtualBaseJson } from "../virtualBase"; import { VirtualFolderLink } from "."; import { VirtualFile, VirtualFileLink } from "../file"; -// import { fileExplorer } from "@prozilla-os/file-explorer"; +import { AppsConfig } from "../../system/configs"; export interface VirtualFolderJson extends VirtualBaseJson { fls?: VirtualFileJson[]; @@ -288,7 +288,10 @@ export class VirtualFolder extends VirtualBase { * Opens this folder in file explorer */ open(windowsManager: WindowsManager) { - return windowsManager.open("file-explorer", { path: this.path }); + const { appsConfig } = this.getRoot().systemManager; + const fileExplorer = appsConfig.getAppByRole(AppsConfig.APP_ROLES.FileExplorer); + if (fileExplorer != null) + return windowsManager.open(fileExplorer.id, { path: this.path }); } /** diff --git a/packages/core/src/features/virtual-drive/root/defaultData.ts b/packages/core/src/features/virtual-drive/root/defaultData.ts index 6de7840..5af8b66 100644 --- a/packages/core/src/features/virtual-drive/root/defaultData.ts +++ b/packages/core/src/features/virtual-drive/root/defaultData.ts @@ -7,7 +7,7 @@ import { VirtualRoot } from "./virtualRoot"; * Loads default data on the virtual root */ export function loadDefaultData(systemManager: SystemManager, virtualRoot: VirtualRoot) { - const { desktopConfig, virtualDriveConfig } = systemManager; + const { desktopConfig, virtualDriveConfig, appsConfig } = systemManager; const linkedPaths: Record = {}; virtualRoot.createFolder("home", (folder) => { @@ -15,13 +15,18 @@ export function loadDefaultData(systemManager: SystemManager, virtualRoot: Virtu folder.setAlias("~") .createFolder(".config", (folder) => { folder.createFile("desktop", "xml", (file) => { - file.setSource("/config/desktop.xml"); + file.setContent(` + ${desktopConfig.defaultWallpaper} + true + `); }).createFile("taskbar", "xml", (file) => { - file.setSource("/config/taskbar.xml"); + file.setContent(` + ${appsConfig.apps.map(({ id }) => id).join(",")} + `); }).createFile("apps", "xml", (file) => { - file.setSource("/config/apps.xml"); + file.setContent(""); }).createFile("theme", "xml", (file) => { - file.setSource("/config/theme.xml"); + file.setContent("0"); }); }) .createFolder("Pictures", (folder) => { diff --git a/packages/core/src/hooks/modals/alert.tsx b/packages/core/src/hooks/modals/alert.tsx index 96bc314..0279bac 100644 --- a/packages/core/src/hooks/modals/alert.tsx +++ b/packages/core/src/hooks/modals/alert.tsx @@ -1,9 +1,8 @@ import { useCallback } from "react"; import { DialogBox } from "../../components/modals/dialog-box/DialogBox"; -import { DIALOG_CONTENT_TYPES } from "../../constants/modals.const"; import { useWindowedModal } from "./windowedModal"; import { ModalProps } from "../../components/modals/ModalView"; -import { Vector2 } from "../../features"; +import { ModalsConfig, Vector2 } from "../../features"; interface AlertParams { title: string; @@ -25,7 +24,7 @@ export function useAlert() { Modal: (props: ModalProps) =>

{text}

- +
}); }, [openWindowedModal]); diff --git a/packages/prozilla-os/CHANGELOG.md b/packages/prozilla-os/CHANGELOG.md index 006a237..ebbeed2 100644 --- a/packages/prozilla-os/CHANGELOG.md +++ b/packages/prozilla-os/CHANGELOG.md @@ -1,5 +1,16 @@ # prozilla-os +## 1.0.13 + +### Patch Changes + +- Added application roles +- Updated dependencies + - @prozilla-os/file-explorer@1.0.10 + - @prozilla-os/text-editor@1.0.3 + - @prozilla-os/terminal@1.0.3 + - @prozilla-os/core@1.0.13 + ## 1.0.12 ### Patch Changes diff --git a/packages/prozilla-os/package.json b/packages/prozilla-os/package.json index fc54300..5db44d4 100644 --- a/packages/prozilla-os/package.json +++ b/packages/prozilla-os/package.json @@ -1,7 +1,7 @@ { "name": "prozilla-os", "description": "a React component library written in TypeScript for building web-based operating systems, made by Prozilla.", - "version": "1.0.12", + "version": "1.0.13", "homepage": "https://os.prozilla.dev", "author": { "name": "Prozilla", diff --git a/public/config/apps.xml b/public/config/apps.xml deleted file mode 100644 index b4d4b3b..0000000 --- a/public/config/apps.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/public/config/desktop.xml b/public/config/desktop.xml deleted file mode 100644 index 5a30d6c..0000000 --- a/public/config/desktop.xml +++ /dev/null @@ -1,4 +0,0 @@ - - /assets/wallpapers/vibrant-wallpaper-purple-yellow.png - true - \ No newline at end of file diff --git a/public/config/taskbar.xml b/public/config/taskbar.xml deleted file mode 100644 index a05e8d6..0000000 --- a/public/config/taskbar.xml +++ /dev/null @@ -1,3 +0,0 @@ - - file-explorer,terminal,settings,media-viewer,browser,text-editor,wordle,ball-maze,minesweeper - \ No newline at end of file diff --git a/public/config/theme.xml b/public/config/theme.xml deleted file mode 100644 index 0aad8e2..0000000 --- a/public/config/theme.xml +++ /dev/null @@ -1,3 +0,0 @@ - - 0 - \ No newline at end of file diff --git a/src/config/desktop.config.ts b/src/config/desktop.config.ts index 860462d..a64695d 100644 --- a/src/config/desktop.config.ts +++ b/src/config/desktop.config.ts @@ -12,5 +12,5 @@ export const desktopConfig = new DesktopConfig({ "/assets/wallpapers/flame-abstract-wallpaper-orange.png", "/assets/wallpapers/wave-abstract-wallpaper-teal.png", ], - defaultWallpaper: "/assets/wallpapers/colorful-mesh-gradient-red-green.png" + defaultWallpaper: "/assets/wallpapers/abstract-mesh-gradient-orange-red-purple.png" }); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 6216bb1..29f97f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,7 +30,7 @@ "baseUrl": "./", "paths": { "prozilla-os": ["packages/prozilla-os/dist/main"], - "@prozilla-os/*": ["packages/*/dist/main", "packages/apps/*/dist/main"], + "@prozilla-os/*": ["packages/*/dist/main", "packages/*/src/main", "packages/apps/*/dist/main"], } }, "include": [