import type { Nuxt } from '@nuxt/schema' import type { ShallowRef } from 'vue' import { useApplicationManager } from '../runtime/composables/useApplicationManager' declare module 'nuxt/schema' { interface PublicRuntimeConfig { owd: { tailwindPaths: [] } } } interface IApplicationManager { apps: Map get appsEntries(): Reactive get appsRunning(): Reactive get windowsOpened(): Reactive> get appCategories(): string[] get appsByCategory(): { [category: string]: IApplicationController[] } defineApp( id: string, config: ApplicationConfig, ): Promise closeApp(id: string): void launchAppEntry( id: string, entry: string, ): Promise execAppCommand( id: string, command: string, meta: undefined | any, ): Promise isAppDefined(id: string): boolean isAppRunning(id: string): boolean } type ApplicationCommand = (app: IApplicationController, args: any) => void interface ApplicationConfig { id: string title: string icon?: string category?: string version?: string description?: string provides?: ApplicationConfigProvide singleton?: boolean meta?: IApplicationMeta permissions?: ApplicationPermission[] windows?: { [key: string]: WindowConfig } entries: { [key: string]: ApplicationEntry } commands?: { [key: string]: ApplicationCommand } onReady?(app: IApplicationController): void | Promise onLaunch?(app: IApplicationController): void | Promise onRestore?(app: IApplicationController): void | Promise onClose?(app: IApplicationController): void | Promise } interface ApplicationConfigProvide { name: string command: string } type IApplicationMeta = { [key: string]: any } interface IApplicationController { id: string config: ApplicationConfig get meta(): { [key: string]: any } store: Pinia windows: Map openWindowCount: ShallowRef isRunning: boolean setRunning(value: boolean): void initApplication(): Promise restoreApplication(): Promise getWindowsByModel(model: string): IWindowController[] getFirstWindowByModel(model: string): IWindowController | undefined openWindow( model: string, windowStoredState?: WindowStoredState, options?: { isRestoring?: boolean }, ) closeWindow(windowId: string): void closeAllWindows(): void execCommand(command: string): Promise // deprecated get windowsOpened(): Reactive> } export interface IWindowController { application: IApplicationController instanced: boolean model: string config: WindowConfig override: WindowOverride get state(): WindowState // common get title(): string get icon(): string | undefined // sizes get size(): WindowSize get position(): WindowPosition | undefined // minimize get isMinimizable(): boolean // maximize get isMaximizable(): boolean get isMaximized(): boolean // destroy get isDestroyable(): boolean // draggable get isDraggable(): boolean // resizable get isResizable(): boolean get actions(): { // position setActive(value: boolean) setFocus(value: boolean) bringToFront() setPosition(data: WindowPosition) // size setSize(data: WindowSize) // minimize minimize(): boolean // maximize toggleMaximize(): boolean maximize(): boolean unmaximize(): boolean // destroy destroy(): boolean // workspace setWorkspace(workspaceId: string) // override setTitleOverride(title: string | undefined): void resetTitleOverride(): void } /** Payload restored with window state (e.g. explorer cwd in `path`). */ get meta(): { path?: string } & Record /** Chrome menu model (e.g. PrimeVue Menubar). */ menu: unknown[] setMenu(menu: unknown[]): void destroy(): boolean /** Set by module-fs when an explorer surface mounts on this window. */ fsExplorer?: any } export interface WindowContent { padded?: boolean centered?: boolean } export interface WindowConfig { title?: string category?: string icon?: string component?: Raw // position position?: WindowPosition // sizes size: WindowSize // minimize minimizable?: boolean // maximize maximized?: boolean maximizable?: boolean // destroy destroyable?: boolean // draggable draggable?: boolean // draggable resizable?: boolean overridable?: Partial< Record< | 'position' | 'size' | 'maximized' | 'draggable' | 'resizable' | 'destroyable' | 'minimizable', boolean > > } interface WindowStoredState { model: string state: WindowState meta: any } interface WindowOverride { title?: undefined | string icon?: undefined | string } interface WindowState { id: string createdAt: number category?: string workspace: string // position position?: WindowPosition // sizes size?: WindowSize // focused focused: boolean // minimize active?: boolean minimizable?: boolean // maximize maximized?: boolean maximizable?: boolean // destroy destroyable?: boolean // draggable draggable?: boolean // draggable resizable?: boolean } interface WindowSize { width?: WindowSizeValue height?: WindowSizeValue minWidth?: WindowSizeValue minHeight?: WindowSizeValue maxWidth?: WindowSizeValue maxHeight?: WindowSizeValue } interface WindowPosition { x?: number y?: number z?: number } type WindowSizeValue = number | string | undefined interface ApplicationEntry { title?: string icon?: string category?: string visibility?: ApplicationEntryVisibility command: string | any } interface ApplicationEntryWithInherited extends ApplicationEntry { application: IApplicationController visibility: ApplicationEntryVisibility } type ApplicationEntryVisibility = 'primary' | 'secondary' | 'hidden' // DESKTOP interface IDesktopManager { defaultApps: import('vue').ComputedRef> getDefaultApp(feature: string): DefaultAppConfig | undefined setDefaultApp( feature: string, application: IApplicationController, entry: string, ): void } interface DocsModuleUserSourceConfig { cwd: string prefix?: string include?: string exclude?: string[] } interface DocsModuleConfig { basePath?: string title?: string sources?: DocsModuleUserSourceConfig[] } interface DesktopConfig { theme?: string modules?: string[] apps?: string[] docs?: DocsModuleConfig name?: string defaultApps?: DefaultAppsConfig features?: string[] explorer?: DesktopExplorerConfig systemBar?: DesktopSystemBarConfig dockBar?: DesktopDockBarConfig workspaces?: DesktopWorkspacesConfig } interface DesktopExplorerFolderConfig { id: string label: string path: string icon?: string } interface DesktopExplorerConfig { quickAccess?: DesktopExplorerFolderConfig[] quickAccessExtra?: DesktopExplorerFolderConfig[] quickAccessOverride?: DesktopExplorerFolderConfig[] specialFolders?: DesktopExplorerFolderConfig[] specialFoldersExtra?: DesktopExplorerFolderConfig[] specialFoldersOverride?: DesktopExplorerFolderConfig[] /** Friendly labels for ZenFS mount points shown under “This PC” (paths → label). */ mountLabels?: Record } interface DesktopWindowsConfig { position: 'relative' | 'absolute' | 'fixed' } interface DesktopDockBarConfig { enabled?: boolean position?: 'top' | 'bottom' } interface DesktopSystemBarConfig { enabled?: boolean position?: 'top' | 'bottom' startButton?: boolean } interface DesktopWorkspacesConfig { enabled?: boolean } // TERMINAL type TerminalCommand = { name: string applicationId: string } interface CommandOutput { text: string isError?: boolean } // DEFAULT APP interface DefaultAppsConfig { terminal?: DefaultAppConfig browser?: DefaultAppConfig editor?: DefaultAppConfig [key: string]: DefaultAppConfig } /** Stored default for a feature: which app and which entry key to use. */ interface DefaultAppConfig { applicationId: string entry: string } export function defineDesktopApp(config: ApplicationConfig) export function defineDesktopConfig(config: DesktopConfig) export function registerTailwindPath(nuxt: Nuxt, path: string): void export {}