-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathdocks.ts
More file actions
99 lines (89 loc) · 2.86 KB
/
docks.ts
File metadata and controls
99 lines (89 loc) · 2.86 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import type { RpcFunctionsCollector } from '@vitejs/devtools-rpc'
import type { Raw } from 'vue'
import type { DevToolsDockEntriesGrouped } from '../../../core/src/client/webcomponents/state/dock-settings'
import type { DevToolsDockEntry, DevToolsDocksUserSettings, DevToolsDockUserEntry, DevToolsRpcClientFunctions, EventEmitter } from '../types'
import type { SharedState } from '../utils/shared-state'
import type { DevToolsRpcClient } from './rpc'
export interface DockPanelStorage {
width: number
height: number
top: number
left: number
position: 'left' | 'right' | 'bottom' | 'top'
open: boolean
inactiveTimeout: number
}
export type DockClientType = 'embedded' | 'standalone'
export interface DevToolsClientContext {
/**
* The RPC client to interact with the server
*/
readonly rpc: DevToolsRpcClient
}
export interface DocksContext extends DevToolsClientContext {
/**
* Type of the client environment
*
* 'embedded' - running inside an embedded floating panel
* 'standalone' - running inside a standalone window (no user app)
*/
readonly clientType: 'embedded' | 'standalone'
/**
* The panel context
*/
readonly panel: DocksPanelContext
/**
* The docks entries context
*/
readonly docks: DocksEntriesContext
}
export type DevToolsClientRpcHost = RpcFunctionsCollector<DevToolsRpcClientFunctions, DevToolsClientContext>
export interface DocksPanelContext {
store: DockPanelStorage
isDragging: boolean
isResizing: boolean
readonly isVertical: boolean
}
export interface DocksEntriesContext {
selectedId: string | null
readonly selected: DevToolsDockEntry | null
entries: DevToolsDockEntry[]
entryToStateMap: Map<string, DockEntryState>
groupedEntries: DevToolsDockEntriesGrouped
settings: SharedState<DevToolsDocksUserSettings>
/**
* Get the state of a dock entry by its ID
*/
getStateById: (id: string) => DockEntryState | undefined
/**
* Switch to the selected dock entry, pass `null` to clear the selection
*
* @returns Whether the selection was changed successfully
*/
switchEntry: (id?: string | null) => Promise<boolean>
/**
* Toggle the selected dock entry
*
* @returns Whether the selection was changed successfully
*/
toggleEntry: (id: string) => Promise<boolean>
}
export interface DockEntryState {
entryMeta: DevToolsDockEntry
readonly isActive: boolean
domElements: {
iframe?: HTMLIFrameElement | null
panel?: HTMLDivElement | null
}
events: Raw<EventEmitter<DockEntryStateEvents>>
}
export interface DockEntryStateEvents {
'entry:activated': () => void
'entry:deactivated': () => void
'entry:updated': (newMeta: DevToolsDockUserEntry) => void
'dom:panel:mounted': (panel: HTMLDivElement) => void
'dom:iframe:mounted': (iframe: HTMLIFrameElement) => void
}
export interface RpcClientEvents {
'rpc:is-trusted:updated': (isTrusted: boolean) => void
}