@@ -4,13 +4,36 @@ import manifest.ExtensionURL
4
4
import webextensions.Event
5
5
import kotlin.js.Promise
6
6
7
+ /* *
8
+ * Set to undefined if the resource content was set successfully; describes error otherwise.
9
+ */
10
+ @Suppress(" NOTHING_TO_INLINE" , " UnsafeCastFromDynamic" )
11
+ class Error () {
12
+ inline operator fun get (key : String ): dynamic = asDynamic()[key]
13
+ inline operator fun set (key : String , value : dynamic ) {
14
+ asDynamic()[key] = value
15
+ }
16
+ }
17
+
7
18
/* *
8
19
* A resource within the inspected page, such as a document, a script, or an image.
9
- * @param url The URL of the resource.
10
20
*/
11
- class Resource (
21
+ external class Resource {
22
+ /* *
23
+ * The URL of the resource.
24
+ */
12
25
var url: String
13
- )
26
+
27
+ /* *
28
+ * Gets the content of the resource.
29
+ */
30
+ fun getContent (): Promise <String >
31
+
32
+ /* *
33
+ * Sets the content of the resource.
34
+ */
35
+ fun setContent (content : String , commit : Boolean ): Promise <Error ?>
36
+ }
14
37
15
38
/* *
16
39
* The options parameter can contain one or more options.
@@ -57,6 +80,11 @@ class ReloadOptions(
57
80
)
58
81
59
82
external class InspectedWindowNamespace {
83
+ /* *
84
+ * The ID of the tab being inspected. This ID may be used with chrome.tabs.* API.
85
+ */
86
+ var tabId: Int
87
+
60
88
/* *
61
89
* Evaluates a JavaScript expression in the context of the main frame of the inspected page. The
62
90
expression must evaluate to a JSON-compliant object, otherwise an exception is thrown.
@@ -78,8 +106,14 @@ external class InspectedWindowNamespace {
78
106
79
107
/* *
80
108
* Represents a network request for a document resource (script, image and so on). See HAR
81
- Specification for reference. */
82
- typealias Request = Any
109
+ Specification for reference.
110
+ */
111
+ external class Request {
112
+ /* *
113
+ * Returns content of the response body.
114
+ */
115
+ fun getContent (): Promise <String >
116
+ }
83
117
84
118
/* *
85
119
* A HAR log. See HAR specification for details.
@@ -113,24 +147,79 @@ external class NetworkNamespace {
113
147
}
114
148
115
149
/* *
116
- * Represents the Elements panel. */
117
- typealias ElementsPanel = Any
150
+ * Represents the Elements panel.
151
+ */
152
+ external class ElementsPanel {
153
+ /* *
154
+ * Creates a pane within panel's sidebar.
155
+ */
156
+ fun createSidebarPane (title : String ): Promise <ExtensionSidebarPane >
157
+ }
118
158
119
159
/* *
120
- * Represents the Sources panel. */
121
- typealias SourcesPanel = Any
160
+ * Represents the Sources panel.
161
+ */
162
+ external class SourcesPanel {
163
+ /* *
164
+ * Creates a pane within panel's sidebar.
165
+ */
166
+ fun createSidebarPane (title : String , callback : (() -> Unit )? = definedExternally)
167
+ }
122
168
123
169
/* *
124
- * Represents a panel created by extension. */
125
- typealias ExtensionPanel = Any
170
+ * Represents a panel created by extension.
171
+ */
172
+ external class ExtensionPanel {
173
+ /* *
174
+ * Appends a button to the status bar of the panel.
175
+ */
176
+ fun createStatusBarButton (
177
+ iconPath : String ,
178
+ tooltipText : String ,
179
+ disabled : Boolean
180
+ ): Button
181
+ }
126
182
127
183
/* *
128
- * A sidebar created by the extension. */
129
- typealias ExtensionSidebarPane = Any
184
+ * A sidebar created by the extension.
185
+ */
186
+ external class ExtensionSidebarPane {
187
+ /* *
188
+ * Sets the height of the sidebar.
189
+ */
190
+ fun setHeight (height : String )
191
+
192
+ /* *
193
+ * Sets an expression that is evaluated within the inspected page. The result is displayed in
194
+ the sidebar pane.
195
+ */
196
+ fun setExpression (expression : String , rootTitle : String? = definedExternally): Promise <Any >
197
+
198
+ /* *
199
+ * Sets a JSON-compliant object to be displayed in the sidebar pane.
200
+ */
201
+ fun setObject (jsonObject : String , rootTitle : String? = definedExternally): Promise <Any >
202
+
203
+ /* *
204
+ * Sets an HTML page to be displayed in the sidebar pane.
205
+ */
206
+ fun setPage (path : ExtensionURL ): Promise <Any >
207
+ }
130
208
131
209
/* *
132
- * A button created by the extension. */
133
- typealias Button = Any
210
+ * A button created by the extension.
211
+ */
212
+ external class Button {
213
+ /* *
214
+ * Updates the attributes of the button. If some of the arguments are omitted or
215
+ <code>null</code>, the corresponding attributes are not updated.
216
+ */
217
+ fun update (
218
+ iconPath : String? = definedExternally,
219
+ tooltipText : String? = definedExternally,
220
+ disabled : Boolean? = definedExternally
221
+ )
222
+ }
134
223
135
224
/* *
136
225
* Path of the panel's icon relative to the extension directory, or an empty string to use the
@@ -144,6 +233,21 @@ external class PanelsNamespace {
144
233
* @param themeName The name of the current devtools theme. */
145
234
val onThemeChanged: Event < (themeName: String ) -> Unit >
146
235
236
+ /* *
237
+ * Elements panel.
238
+ */
239
+ var elements: ElementsPanel
240
+
241
+ /* *
242
+ * Sources panel.
243
+ */
244
+ var sources: SourcesPanel
245
+
246
+ /* *
247
+ * The name of the current devtools theme.
248
+ */
249
+ var themeName: String
250
+
147
251
// /**
148
252
// * Creates an extension panel.
149
253
// */
0 commit comments