Skip to content

Commit 913bd0a

Browse files
committed
Fix critical expect-actual suppress
1 parent f55bf94 commit 913bd0a

File tree

10 files changed

+77
-72
lines changed

10 files changed

+77
-72
lines changed

build.gradle.kts

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
}
1515

1616
group = "org.jetbrains.kotlinx"
17-
version = "0.7.3-SNAPSHOT"
17+
version = "0.7.5-SNAPSHOT"
1818

1919
buildscript {
2020
dependencies {
@@ -294,50 +294,6 @@ tasks.register<Copy>("jsPackagePrepare") {
294294
}
295295
}
296296

297-
tasks.register<Exec>("publishNpm") {
298-
dependsOn("jsPackagePrepare")
299-
dependsOn("kotlinNodeJsSetup")
300-
301-
group = "publishing"
302-
description = "Publishes ${project.name} NPM module to 'registry.npmjs.org'."
303-
304-
val kotlinNodeJsSetupTask = tasks["kotlinNodeJsSetup"] as NodeJsSetupTask
305-
306-
// For some unknown reason, the node distributive's structure is different on Windows and UNIX.
307-
val node = if (Os.isFamily(Os.FAMILY_WINDOWS)) {
308-
kotlinNodeJsSetupTask.destination
309-
.resolve("node.exe")
310-
} else {
311-
kotlinNodeJsSetupTask.destination
312-
.resolve("bin")
313-
.resolve("node")
314-
}
315-
316-
val npm = if (Os.isFamily(Os.FAMILY_WINDOWS)) {
317-
kotlinNodeJsSetupTask.destination
318-
.resolve("node_modules")
319-
.resolve("npm")
320-
.resolve("bin")
321-
.resolve("npm-cli.js")
322-
} else {
323-
kotlinNodeJsSetupTask.destination
324-
.resolve("lib")
325-
.resolve("node_modules")
326-
.resolve("npm")
327-
.resolve("bin")
328-
.resolve("npm-cli.js")
329-
}
330-
331-
commandLine(
332-
node,
333-
npm,
334-
"publish",
335-
"$buildDir/tmp/jsPackage",
336-
"--//registry.npmjs.org/:_authToken=${System.getenv("NPMJS_AUTH")}",
337-
"--access=public"
338-
)
339-
}
340-
341297
publishing {
342298
publications {
343299
configureEach {

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
kotlin("jvm") version "1.4.31"
2+
kotlin("jvm") version "1.6.10"
33
}
44

55
repositories {

buildSrc/src/main/kotlin/kotlinx/html/generate/humanizer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ private fun String.makeCamelCaseByDictionary() : String {
9595
var unprocessedStart = 0
9696
allRanges.forEachIndexed { i, mr ->
9797
if (mr.range.start >= unprocessedStart) {
98-
val startClash = allRanges.safeSubList(i + 1).asSequence().takeWhile { it.range.start == mr.range.start }.maxBy { it.value.length }
98+
val startClash = allRanges.safeSubList(i + 1).asSequence().takeWhile { it.range.start == mr.range.start }
99+
.maxByOrNull { it.value.length }
99100
if (startClash == null || startClash.value.length <= mr.value.length) {
100101
val possibleTail = when {
101102
mr.value.endsWith("ing") -> 3

buildSrc/src/main/kotlin/kotlinx/html/generate/tag-builders.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ fun Appendable.htmlTagBuilders(receiver : String, tag : TagInfo) {
3434
htmlTagBuilderMethod(receiver, tag, false)
3535
}
3636

37-
val someEnumAttribute = tag.attributes.filter { it.type == AttributeType.ENUM }.maxBy { it.enumValues.size } // ??
37+
val someEnumAttribute =
38+
tag.attributes.filter { it.type == AttributeType.ENUM }.maxByOrNull { it.enumValues.size } // ??
3839
if (someEnumAttribute != null && someEnumAttribute.enumValues.size < 25) {
3940
htmlTagEnumBuilderMethod(receiver, tag, true, someEnumAttribute, 0)
4041
if (probablyContentOnly) {

src/commonMain/kotlin/Event.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
package org.w3c.dom.events
22

3-
@Suppress("HEADER_WITHOUT_IMPLEMENTATION", "NO_ACTUAL_FOR_EXPECT")
43
expect interface Event {
54
fun stopPropagation()
65
fun preventDefault()
76

8-
fun initEvent(
9-
eventTypeArg: String,
10-
canBubbleArg: Boolean,
11-
cancelableArg: Boolean
12-
)
7+
fun initEvent(eventTypeArg: String, canBubbleArg: Boolean, cancelableArg: Boolean)
138
}

src/jsMain/kotlin/EventJs.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.w3c.dom.events // ktlint-disable filename
2+
3+
import org.w3c.dom.*
4+
5+
public actual external interface Event {
6+
val type: String
7+
val target: EventTarget?
8+
val currentTarget: EventTarget?
9+
val eventPhase: Short
10+
val bubbles: Boolean
11+
val cancelable: Boolean
12+
val defaultPrevented: Boolean
13+
val composed: Boolean
14+
val isTrusted: Boolean
15+
val timeStamp: Number
16+
17+
fun stopImmediatePropagation()
18+
fun composedPath(): Array<EventTarget>
19+
20+
actual fun stopPropagation()
21+
actual fun preventDefault()
22+
actual fun initEvent(eventTypeArg: String, canBubbleArg: Boolean, cancelableArg: Boolean)
23+
}

src/jsMain/kotlin/dom-js.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import kotlinx.html.consumers.*
55
import org.w3c.dom.*
66
import org.w3c.dom.events.*
77

8-
@Suppress("NOTHING_TO_INLINE")
98
private inline fun HTMLElement.setEvent(name: String, noinline callback : (Event) -> Unit) : Unit {
109
asDynamic()[name] = callback
1110
}

src/jsMain/kotlin/injector.kt

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,41 @@ import kotlinx.html.dom.*
55
import org.w3c.dom.*
66
import kotlin.reflect.*
77

8-
fun <F : Any, T : Any> F.injectTo(bean : T, field : KMutableProperty1<T, in F>) {
8+
fun <F : Any, T : Any> F.injectTo(bean: T, field: KMutableProperty1<T, in F>) {
99
field.set(bean, this)
1010
}
1111

12-
private fun <F : Any, T : Any> F.injectToUnsafe(bean : T, field : KMutableProperty1<T, out F>) {
12+
private fun <F : Any, T : Any> F.injectToUnsafe(bean: T, field: KMutableProperty1<T, out F>) {
1313
injectTo(bean, field.asDynamic())
1414
}
1515

1616
interface InjectCapture
17-
class InjectByClassName(val className : String) : InjectCapture
18-
class InjectByTagName(val tagName : String) : InjectCapture
17+
class InjectByClassName(val className: String) : InjectCapture
18+
class InjectByTagName(val tagName: String) : InjectCapture
1919
object InjectRoot : InjectCapture
2020
interface CustomCapture : InjectCapture {
21-
fun apply(element : HTMLElement) : Boolean
21+
fun apply(element: HTMLElement): Boolean
2222
}
2323

24-
class InjectorConsumer<out T: Any>(val downstream : TagConsumer<HTMLElement>, val bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>) : TagConsumer<HTMLElement> by downstream {
24+
class InjectorConsumer<out T : Any>(
25+
val downstream: TagConsumer<HTMLElement>,
26+
val bean: T,
27+
rules: List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>
28+
) : TagConsumer<HTMLElement> by downstream {
2529

2630
private val classesMap: Map<String, List<KMutableProperty1<T, out HTMLElement>>> = rules
27-
.filter { it.first is InjectByClassName }
28-
.map { it.first as InjectByClassName to it.second }
29-
.groupBy ({ it.first.className }, { it.second })
31+
.filter { it.first is InjectByClassName }
32+
.map { it.first as InjectByClassName to it.second }
33+
.groupBy({ it.first.className }, { it.second })
3034

3135
private val tagNamesMap = rules
32-
.filter { it.first is InjectByTagName }
33-
.map { it.first as InjectByTagName to it.second }
34-
.groupBy({ it.first.tagName.toLowerCase() }, { it.second })
36+
.filter { it.first is InjectByTagName }
37+
.map { it.first as InjectByTagName to it.second }
38+
.groupBy({ it.first.tagName.toLowerCase() }, { it.second })
3539

3640
private val rootCaptures = rules.filter { it.first == InjectRoot }.map { it.second }
37-
private val customCaptures = rules.filter {it.first is CustomCapture}.map {it.first as CustomCapture to it.second}
41+
private val customCaptures =
42+
rules.filter { it.first is CustomCapture }.map { it.first as CustomCapture to it.second }
3843

3944
override fun onTagEnd(tag: Tag) {
4045
downstream.onTagEnd(tag)
@@ -53,7 +58,7 @@ class InjectorConsumer<out T: Any>(val downstream : TagConsumer<HTMLElement>, va
5358
}
5459
}
5560

56-
customCaptures.filter { it.first.apply(node) }.map {it.second}.forEach { field ->
61+
customCaptures.filter { it.first.apply(node) }.map { it.second }.forEach { field ->
5762
node.injectToUnsafe(bean, field)
5863
}
5964
}
@@ -68,10 +73,16 @@ class InjectorConsumer<out T: Any>(val downstream : TagConsumer<HTMLElement>, va
6873
}
6974
}
7075

71-
fun <T: Any> TagConsumer<HTMLElement>.inject(bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>) : TagConsumer<HTMLElement> = InjectorConsumer(this, bean, rules)
76+
fun <T : Any> TagConsumer<HTMLElement>.inject(
77+
bean: T,
78+
rules: List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>
79+
): TagConsumer<HTMLElement> = InjectorConsumer(this, bean, rules)
7280

73-
fun <T: Any> HTMLElement.appendAndInject(bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>, block : TagConsumer<HTMLElement>.() -> Unit) : List<HTMLElement> = append {
81+
fun <T : Any> HTMLElement.appendAndInject(
82+
bean: T,
83+
rules: List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>,
84+
block: TagConsumer<HTMLElement>.() -> Unit
85+
): List<HTMLElement> = append {
7486
InjectorConsumer(this@append, bean, rules).block()
7587
Unit
7688
}
77-

src/jvmMain/kotlin/EventJvm.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.w3c.dom.events // ktlint-disable filename
2+
3+
actual interface Event {
4+
actual fun stopPropagation()
5+
actual fun preventDefault()
6+
actual fun initEvent(eventTypeArg: String, canBubbleArg: Boolean, cancelableArg: Boolean)
7+
}

src/nativeMain/kotlin/EventNative.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.w3c.dom.events // ktlint-disable filename
2+
3+
actual interface Event {
4+
actual fun stopPropagation()
5+
actual fun preventDefault()
6+
7+
actual fun initEvent(
8+
eventTypeArg: String,
9+
canBubbleArg: Boolean,
10+
cancelableArg: Boolean
11+
)
12+
}

0 commit comments

Comments
 (0)