forked from nuxt/devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.ts
65 lines (56 loc) · 2.97 KB
/
rpc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import type { Component, NuxtApp, NuxtLayout, NuxtOptions, NuxtPage } from 'nuxt/schema'
import type { StorageMounts } from 'nitropack'
import type { StorageValue } from 'unstorage'
import type { ModuleCustomTab } from './custom-tabs'
import type { AssetInfo, AutoImportsWithMetadata, ComponentRelationship, HookInfo, ImageMeta, NpmCommandOptions, NpmCommandType, PackageManagerName, PackageUpdateInfo, ServerRouteInfo } from './integrations'
import type { TerminalAction, TerminalInfo } from './terminals'
import type { GetWizardArgs, WizardActions } from './wizard'
import type { InstallModuleReturn } from './server-ctx'
export interface ServerFunctions {
// Static RPCs (can be provide on production build in the future)
getServerConfig(): NuxtOptions
getComponents(): Component[]
getComponentsRelationships(): Promise<ComponentRelationship[]>
getAutoImports(): AutoImportsWithMetadata
getServerPages(): NuxtPage[]
getCustomTabs(): ModuleCustomTab[]
getServerHooks(): HookInfo[]
getServerLayouts(): NuxtLayout[]
getStaticAssets(): Promise<AssetInfo[]>
getServerRoutes(): Promise<ServerRouteInfo[]>
getServerApp(): NuxtApp | undefined
// Updates
checkForUpdateFor(name: string): Promise<PackageUpdateInfo | undefined>
getPackageManager(): Promise<PackageManagerName>
getNpmCommand(command: NpmCommandType, packageName: string, options?: NpmCommandOptions): Promise<string[] | undefined>
runNpmCommand(command: NpmCommandType, packageName: string, options?: NpmCommandOptions): Promise<{ processId: string } | undefined>
// Terminal
getTerminals(): TerminalInfo[]
getTerminalDetail(id: string): TerminalInfo | undefined
runTerminalAction(id: string, action: TerminalAction): Promise<boolean>
// Storage
getStorageMounts(): Promise<StorageMounts>
getStorageKeys(base?: string): Promise<string[]>
getStorageItem(key: string): Promise<StorageValue>
setStorageItem(key: string, value: StorageValue): Promise<void>
removeStorageItem(key: string): Promise<void>
// Queries
getImageMeta(filepath: string): Promise<ImageMeta | undefined>
getTextAssetContent(filepath: string, limit?: number): Promise<string | undefined>
writeStaticAssets(file: { name: string; data: string }[], path: string): Promise<string[]>
// Actions
customTabAction(name: string, action: number): Promise<boolean>
runWizard<T extends WizardActions>(name: T, ...args: GetWizardArgs<T>): Promise<void>
openInEditor(filepath: string): Promise<boolean>
restartNuxt(hard?: boolean): Promise<void>
installNuxtModule(name: string, dry?: boolean): Promise<InstallModuleReturn>
unInstallNuxtModule(name: string, dry?: boolean): Promise<InstallModuleReturn>
}
export interface ClientFunctions {
refresh(event: ClientUpdateEvent): void
callHook(hook: string, ...args: any[]): Promise<void>
navigateTo(path: string): void
onTerminalData(_: { id: string; data: string }): void
onTerminalExit(_: { id: string; code?: number }): void
}
export type ClientUpdateEvent = keyof ServerFunctions