Skip to content

Commit

Permalink
Multiplatform build
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Mashkov committed Jan 17, 2017
1 parent a304b1d commit 4ad3daf
Show file tree
Hide file tree
Showing 22 changed files with 305 additions and 356 deletions.
10 changes: 2 additions & 8 deletions js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx.html.shared</artifactId>
<version>${project.version}</version>
<classifier>js</classifier>

<exclusions>
<exclusion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand All @@ -47,6 +39,7 @@
<moduleKind>umd</moduleKind>
<sourceMap>true</sourceMap>
<outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
<multiPlatform>true</multiPlatform>
</configuration>
</execution>
<execution>
Expand All @@ -60,6 +53,7 @@
<metaInfo>true</metaInfo>
<sourceMap>true</sourceMap>
<moduleKind>umd</moduleKind>
<multiPlatform>true</multiPlatform>
</configuration>
</execution>
</executions>
Expand Down
4 changes: 2 additions & 2 deletions js/src/main/kotlin/dom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class JSDOMBuilder<out R : HTMLElement>(val document : Document) : TagConsumer<R
}


fun Document.createTree() : TagConsumer<HTMLElement> = JSDOMBuilder(this)
val Document.create : TagConsumer<HTMLElement>
fun Document.createTree() : TagConsumer<HTMLElement> = JSDOMBuilder(this)
val Document.create : TagConsumer<HTMLElement>
get() = JSDOMBuilder(this)

fun Node.append(block : TagConsumer<HTMLElement>.() -> Unit) : List<HTMLElement> =
Expand Down
3 changes: 2 additions & 1 deletion js/src/main/kotlin/injector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface CustomCapture : InjectCapture {

class InjectorConsumer<out T: Any>(val downstream : TagConsumer<HTMLElement>, val bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>) : TagConsumer<HTMLElement> by downstream {

private val classesMap = rules
private val classesMap: Map<String, List<KMutableProperty1<T, out HTMLElement>>> = rules
.filter { it.first is InjectByClassName }
.map { it.first as InjectByClassName to it.second }
.groupBy ({ it.first.className }, { it.second })
Expand Down Expand Up @@ -71,6 +71,7 @@ class InjectorConsumer<out T: Any>(val downstream : TagConsumer<HTMLElement>, va
}

fun <T: Any> TagConsumer<HTMLElement>.inject(bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>) : TagConsumer<HTMLElement> = InjectorConsumer(this, bean, rules)

fun <T: Any> HTMLElement.appendAndInject(bean : T, rules : List<Pair<InjectCapture, KMutableProperty1<T, out HTMLElement>>>, block : TagConsumer<HTMLElement>.() -> Unit) : List<HTMLElement> = append {
InjectorConsumer(this@append, bean, rules).block()
Unit
Expand Down
5 changes: 5 additions & 0 deletions js/src/main/kotlin/trace.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package kotlinx.html.consumers

import kotlinx.html.*

fun <R> TagConsumer<R>.trace() : TagConsumer<R> = trace(println = { console.info(it) })
3 changes: 3 additions & 0 deletions js/src/main/kotlin/utilsImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package kotlinx.html

impl fun currentTimeMillis(): Long = Date().getTime().toLong()
5 changes: 2 additions & 3 deletions js/src/test/karma/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ module.exports = function (config) {
reporters: ['progress', 'junit'],
files: [
'../../../target/test-js/kotlin.js',
'../../../../shared/target/js/*.js',
'../../../target/classes/*.js',
'../../../target/classes/*.js',
'../../../target/test-js/*.js'
],
exclude: [],
Expand All @@ -45,4 +44,4 @@ module.exports = function (config) {
}
}
)
};
};

0 comments on commit 4ad3daf

Please sign in to comment.