1 |
|
2 |
|
3 |
|
4 |
|
5 | export namespace Chrome {
|
6 | export namespace DevTools {
|
7 | export interface EventSink<ListenerT extends(...args: any) => any> {
|
8 | addListener(listener: ListenerT): void;
|
9 | }
|
10 |
|
11 | export interface Resource {
|
12 | readonly url: string;
|
13 |
|
14 | getContent(callback: (content: string, encoding: string) => unknown): void;
|
15 | setContent(content: string, commit: boolean, callback?: (error?: Object) => unknown): void;
|
16 | }
|
17 |
|
18 | export interface InspectedWindow {
|
19 | tabId: number;
|
20 |
|
21 | onResourceAdded: EventSink<(resource: Resource) => unknown>;
|
22 | onResourceContentCommitted: EventSink<(resource: Resource, content: string) => unknown>;
|
23 |
|
24 | eval(
|
25 | expression: string,
|
26 | options?: {contextSecurityOrigin?: string, frameURL?: string, useContentScriptContext?: boolean},
|
27 | callback?: (result: unknown, exceptioninfo: {
|
28 | code: string,
|
29 | description: string,
|
30 | details: unknown[],
|
31 | isError: boolean,
|
32 | isException: boolean,
|
33 | value: string
|
34 | }) => unknown): void;
|
35 | getResources(callback: (resources: Resource[]) => unknown): void;
|
36 | reload(reloadOptions?: {ignoreCache?: boolean, injectedScript?: string, userAgent?: string}): void;
|
37 | }
|
38 |
|
39 | export interface Button {
|
40 | onClicked: EventSink<() => unknown>;
|
41 | update(iconPath?: string, tooltipText?: string, disabled?: boolean): void;
|
42 | }
|
43 |
|
44 | export interface ExtensionView {
|
45 | onHidden: EventSink<() => unknown>;
|
46 | onShown: EventSink<(window?: Window) => unknown>;
|
47 | }
|
48 |
|
49 | export interface ExtensionPanel extends ExtensionView {
|
50 | onSearch: EventSink<(action: string, queryString?: string) => unknown>;
|
51 | createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Button;
|
52 | }
|
53 |
|
54 | export interface ExtensionSidebarPane extends ExtensionView {
|
55 | setHeight(height: string): void;
|
56 | setObject(jsonObject: string, rootTitle?: string, callback?: () => unknown): void;
|
57 | setPage(path: string): void;
|
58 | }
|
59 |
|
60 | export interface PanelWithSidebar {
|
61 | createSidebarPane(title: string, callback?: (result: ExtensionSidebarPane) => unknown): void;
|
62 | onSelectionChanged: EventSink<() => unknown>;
|
63 | }
|
64 |
|
65 | export interface Panels {
|
66 | elements: PanelWithSidebar;
|
67 | sources: PanelWithSidebar;
|
68 | themeName: string;
|
69 |
|
70 | create(title: string, iconPath: string, pagePath: string, callback?: (panel: ExtensionPanel) => unknown): void;
|
71 | openResource(url: string, lineNumber: number, columnNumber?: number, callback?: () => unknown): void;
|
72 | }
|
73 |
|
74 | export interface Request {
|
75 | getContent(callback: (content: string, encoding: string) => unknown): void;
|
76 | }
|
77 |
|
78 | export interface Network {
|
79 | onNavigated: EventSink<(url: string) => unknown>;
|
80 | onRequestFinished: EventSink<(request: Request) => unknown>;
|
81 |
|
82 | getHAR(callback: (harLog: object) => unknown): void;
|
83 | }
|
84 |
|
85 | export interface DevToolsAPI {
|
86 | network: Network;
|
87 | panels: Panels;
|
88 | inspectedWindow: InspectedWindow;
|
89 | languageServices: LanguageExtensions;
|
90 | }
|
91 |
|
92 | export interface ExperimentalDevToolsAPI {
|
93 | inspectedWindow: InspectedWindow;
|
94 | }
|
95 |
|
96 | export interface RawModule {
|
97 | url: string;
|
98 | code?: ArrayBuffer;
|
99 | }
|
100 |
|
101 | export interface RawLocationRange {
|
102 | rawModuleId: string;
|
103 | startOffset: number;
|
104 | endOffset: number;
|
105 | }
|
106 |
|
107 | export interface RawLocation {
|
108 | rawModuleId: string;
|
109 | codeOffset: number;
|
110 | inlineFrameIndex: number;
|
111 | }
|
112 |
|
113 | export interface SourceLocation {
|
114 | rawModuleId: string;
|
115 | sourceFileURL: string;
|
116 | lineNumber: number;
|
117 | columnNumber: number;
|
118 | }
|
119 |
|
120 | export interface Variable {
|
121 | scope: string;
|
122 | name: string;
|
123 | type: string;
|
124 | nestedName?: string[];
|
125 | }
|
126 |
|
127 | export interface ScopeInfo {
|
128 | type: string;
|
129 | typeName: string;
|
130 | icon?: string;
|
131 | }
|
132 |
|
133 | export interface FunctionInfo {
|
134 | name: string;
|
135 | }
|
136 |
|
137 | export type Enumerator = {
|
138 | name: string,
|
139 | value: unknown,
|
140 | typeId: unknown,
|
141 | };
|
142 |
|
143 | export interface FieldInfo {
|
144 | name?: string;
|
145 | offset: number;
|
146 | typeId: unknown;
|
147 | }
|
148 |
|
149 | export interface TypeInfo {
|
150 | typeNames: string[];
|
151 | typeId: unknown;
|
152 | members: FieldInfo[];
|
153 | enumerators?: Enumerator[];
|
154 | alignment: number;
|
155 | arraySize: number;
|
156 | size: number;
|
157 | canExpand: boolean;
|
158 | hasValue: boolean;
|
159 | }
|
160 |
|
161 | export interface EvalBase {
|
162 | rootType: TypeInfo;
|
163 | payload: unknown;
|
164 | }
|
165 |
|
166 | export interface LanguageExtensionPlugin {
|
167 | |
168 |
|
169 |
|
170 |
|
171 | addRawModule(rawModuleId: string, symbolsURL: string|undefined, rawModule: RawModule): Promise<string[]>;
|
172 |
|
173 | |
174 |
|
175 |
|
176 | sourceLocationToRawLocation(sourceLocation: SourceLocation): Promise<RawLocationRange[]>;
|
177 |
|
178 | |
179 |
|
180 |
|
181 | rawLocationToSourceLocation(rawLocation: RawLocation): Promise<SourceLocation[]>;
|
182 |
|
183 | |
184 |
|
185 |
|
186 | getScopeInfo(type: string): Promise<ScopeInfo>;
|
187 |
|
188 | |
189 |
|
190 |
|
191 | listVariablesInScope(rawLocation: RawLocation): Promise<Variable[]>;
|
192 |
|
193 | |
194 |
|
195 |
|
196 | removeRawModule(rawModuleId: string): Promise<void>;
|
197 |
|
198 | |
199 |
|
200 |
|
201 |
|
202 | getTypeInfo(expression: string, context: RawLocation): Promise<{
|
203 | typeInfos: Array<TypeInfo>,
|
204 | base: EvalBase,
|
205 | }|null>;
|
206 |
|
207 | |
208 |
|
209 |
|
210 | getFormatter(
|
211 | expressionOrField: string|{
|
212 | base: EvalBase,
|
213 | field: Array<FieldInfo>,
|
214 | },
|
215 | context: RawLocation): Promise<{
|
216 | js: string,
|
217 | }|null>;
|
218 |
|
219 | |
220 |
|
221 |
|
222 | getInspectableAddress(field: {
|
223 | base: EvalBase,
|
224 | field: Array<FieldInfo>,
|
225 | }): Promise<{
|
226 | js: string,
|
227 | }>;
|
228 |
|
229 | |
230 |
|
231 |
|
232 | getFunctionInfo(rawLocation: RawLocation): Promise<{
|
233 | frames: Array<FunctionInfo>,
|
234 | }>;
|
235 |
|
236 | |
237 |
|
238 |
|
239 |
|
240 | getInlinedFunctionRanges(rawLocation: RawLocation): Promise<RawLocationRange[]>;
|
241 |
|
242 | |
243 |
|
244 |
|
245 |
|
246 |
|
247 | getInlinedCalleesRanges(rawLocation: RawLocation): Promise<RawLocationRange[]>;
|
248 |
|
249 | |
250 |
|
251 |
|
252 | getMappedLines(rawModuleId: string, sourceFileURL: string): Promise<number[]|undefined>;
|
253 | }
|
254 |
|
255 |
|
256 | export interface SupportedScriptTypes {
|
257 | language: string;
|
258 | symbol_types: string[];
|
259 | }
|
260 |
|
261 | export interface LanguageExtensions {
|
262 | registerLanguageExtensionPlugin(
|
263 | plugin: LanguageExtensionPlugin, pluginName: string,
|
264 | supportedScriptTypes: SupportedScriptTypes): Promise<void>;
|
265 | unregisterLanguageExtensionPlugin(plugin: LanguageExtensionPlugin): Promise<void>;
|
266 | }
|
267 |
|
268 | export interface Chrome {
|
269 | devtools: DevToolsAPI;
|
270 | experimental: {devtools: ExperimentalDevToolsAPI};
|
271 | }
|
272 | }
|
273 | }
|
274 |
|
275 | declare global {
|
276 | interface Window {
|
277 | chrome: Chrome.DevTools.Chrome;
|
278 | }
|
279 | }
|