Skip to content

Commit 709ebf4

Browse files
committed
fix generation of callback parameters
1 parent 5b48dd7 commit 709ebf4

File tree

9 files changed

+10
-29
lines changed

9 files changed

+10
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ and
2222
```groovy
2323
dependencies {
2424
// ...
25-
compile 'com.github.cypressious.kotlin-webextensions-declarations:webextensions-declarations:v0.1'
25+
compile 'com.github.cypressious.kotlin-webextensions-declarations:webextensions-declarations:v0.2'
2626
}
2727
```
2828

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
ext.kotlin_version = '1.2.0'
3-
ext.publish_version = 0.1
3+
ext.publish_version = '0.2'
44

55
repositories {
66
jcenter()

declarations/src/main/kotlin/alarms/alarms.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package alarms
22

3-
import webextensions.Event
43
import kotlin.js.Promise
4+
import webextensions.Event
55

66
class Alarm(
77
/**

declarations/src/main/kotlin/downloads/downloads.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package downloads
22

3-
import kotlin.js.Promise
43
import webextensions.Event
4+
import kotlin.js.Promise
55

66
typealias FilenameConflictAction = String
77

@@ -232,8 +232,6 @@ class Options2(/**
232232
*/
233233
var size: Int? = null)
234234

235-
typealias Callback = Any
236-
237235
class DownloadDelta(
238236
/**
239237
* The <code>id</code> of the <a href='#type-DownloadItem'>DownloadItem</a> that changed.

declarations/src/main/kotlin/menus/menus.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ class Icons() {
9191
}
9292
}
9393

94-
/**
95-
* A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for $(ref:contextMenus.onClicked). */
96-
typealias Onclick = Any
97-
9894
/**
9995
* The ID of a parent menu item; this makes the item a child of a previously added item. */
10096
typealias ParentId = Any
@@ -124,7 +120,7 @@ class CreateProperties(
124120
/**
125121
* A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for $(ref:contextMenus.onClicked).
126122
*/
127-
var onclick: Onclick? = null,
123+
var onclick: (() -> Unit)? = null,
128124
/**
129125
* The ID of a parent menu item; this makes the item a child of a previously added item.
130126
*/
@@ -147,10 +143,6 @@ class CreateProperties(
147143
var command: String? = null
148144
)
149145

150-
/**
151-
* Called when the item has been created in the browser. If there were any problems creating the item, details will be available in $(ref:runtime.lastError). */
152-
typealias Callback = Any
153-
154146
/**
155147
* The ID of the newly created item. */
156148
typealias CreateResult = Any
@@ -159,8 +151,6 @@ typealias CreateResult = Any
159151
* The ID of the item to update. */
160152
typealias Id = Any
161153

162-
typealias Onclick2 = Any
163-
164154
/**
165155
* Note: You cannot change an item to be a child of one of its own descendants. */
166156
typealias ParentId2 = Any
@@ -173,7 +163,7 @@ class UpdateProperties(
173163
var title: String? = null,
174164
var checked: Boolean? = null,
175165
var contexts: Array<ContextType>? = null,
176-
var onclick: Onclick2,
166+
var onclick: () -> Unit,
177167
/**
178168
* Note: You cannot change an item to be a child of one of its own descendants.
179169
*/
@@ -193,7 +183,7 @@ external class MenusNamespace {
193183
/**
194184
* Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in $(ref:runtime.lastError)).
195185
*/
196-
fun create(createProperties: CreateProperties, callback: Callback? = definedExternally): CreateResult
186+
fun create(createProperties: CreateProperties, callback: (() -> Unit)? = definedExternally): CreateResult
197187

198188
/**
199189
* Updates a previously created context menu item.

declarations/src/main/kotlin/omnibox/omnibox.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,10 @@ class DescriptionStyles2(
6363
*/
6464
class DescriptionStylesRaw2(var offset: Int, var type: Int)
6565

66-
/**
67-
* A callback passed to the onInputChanged event used for sending suggestions back to the browser. */
68-
typealias Suggest = Any
69-
7066
external class OmniboxNamespace {
7167
val onInputStarted: Event<() -> Unit>
7268

73-
val onInputChanged: Event<(text: String, suggest: Suggest) -> Unit>
69+
val onInputChanged: Event<(text: String, suggest: () -> Unit) -> Unit>
7470

7571
val onInputEntered: Event<(text: String, disposition: OnInputEnteredDisposition) -> Unit>
7672

declarations/src/main/kotlin/tabs/tabs.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ var name: String? = null, /**
239239
*/
240240
var frameId: Int? = null)
241241

242-
typealias ResponseCallback = Any
243-
244242
class Options(/**
245243
* Send a message to a specific $(topic:frame_ids)[frame] identified by <code>frameId</code> instead of all frames in the tab.
246244
*/

declarations/src/main/kotlin/webRequest/webRequest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,6 @@ class Details5(
393393
var statusCode: Int
394394
)
395395

396-
typealias Callback = Any
397-
398396
class Details6(
399397
/**
400398
* The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
@@ -640,7 +638,7 @@ external class WebRequestNamespace {
640638

641639
val onHeadersReceived: Event<(details: Details4) -> Unit>
642640

643-
val onAuthRequired: Event<(details: Details5, callback: Callback?) -> Unit>
641+
val onAuthRequired: Event<(details: Details5, callback: (() -> Unit)?) -> Unit>
644642

645643
val onResponseStarted: Event<(details: Details6) -> Unit>
646644

src/main/kotlin/de/rakhman/webextensions/merging.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private fun Parameter.resolve(
7777
actual: Boolean = false,
7878
isReturn: Boolean = false
7979
): Parameter {
80+
if (type == "function") return copy(parameters = parameters?.map { it.resolve(it.name ?: name, types) })
8081
if (type == "array") return copy(items = items?.resolve(name, types, actual))
8182
if (type != "object" &&
8283
choices == null &&

0 commit comments

Comments
 (0)