-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathui.ts
More file actions
80 lines (71 loc) · 2.19 KB
/
Copy pathui.ts
File metadata and controls
80 lines (71 loc) · 2.19 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
import { EventEmitter } from 'events'
import { ControllerInterface } from './controller'
export type IUiController = ControllerInterface<
InstanceType<typeof import('../controllers/ui//ui').UiController>
>
export type View = {
id: string
type: 'request-window' | 'tab' | 'popup' | 'side-panel' | 'mobile'
currentRoute?: string
previousRoute?: string
isReady?: boolean
searchParams?: { [key: string]: string }
}
export const isExtensionOverlayView = (view: Pick<View, 'type'>) =>
view.type === 'popup' || view.type === 'side-panel'
export const isSidePanelView = (view: Pick<View, 'type'>) => view.type === 'side-panel'
export type UiManager = {
window: {
event: EventEmitter
open: (options?: {
route?: string
customSize?: { width: number; height: number }
baseWindowId?: number
}) => Promise<WindowProps>
focus: (windowProps: WindowProps, params?: FocusWindowParams) => Promise<WindowProps>
remove: (winId: WindowId | 'popup') => Promise<void>
closePopupWithUrl: (url: string) => Promise<void> // remove window of type popup
}
notification: {
create: ({
title,
message,
icon
}: {
title: string
message: string
icon?: string
}) => Promise<void>
}
message: {
sendToastMessage: (
message: string,
options?: {
timeout?: number
type?: 'error' | 'success' | 'info' | 'warning'
sticky?: boolean
}
) => void
sendUiMessage: (params: {}) => void
sendNavigateMessage: (viewId: string, route: string, params: { [key: string]: any }) => void
}
// Extension-only: nudge a dapp tab after side-panel requests so React Query refetches.
dispatchDappTabFocus?: (targets: { tabId: number; windowId?: number }[]) => void
}
export type WindowId = number
export type WindowProps = {
id: WindowId
top: number
left: number
width: number
height: number
focused: boolean
createdFromWindowId?: number
} | null
export type FocusWindowParams = {
/**
* In some cases, the passed window cannot be focused (e.g., on Arc browser). If the window cannot be focused
* within 1 second, a new window is created and the old one is removed.
*/
reopenIfNeeded?: boolean
}