Added JavaScript node and browser targets
This commit is contained in:
parent
58107c70bb
commit
2a301c9975
|
@ -26,13 +26,32 @@ kotlin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// js(BOTH) {
|
js(IR) {
|
||||||
// browser {
|
binaries.executable()
|
||||||
// commonWebpackConfig {
|
browser {
|
||||||
// cssSupport.enabled = true
|
commonWebpackConfig {
|
||||||
// }
|
cssSupport.enabled = true
|
||||||
// }
|
}
|
||||||
// }
|
testTask {
|
||||||
|
useKarma {
|
||||||
|
// we cannot assume that Chrome and Firefox are installed on all systems
|
||||||
|
// useChromeHeadless()
|
||||||
|
// useFirefox()
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodejs {
|
||||||
|
testTask {
|
||||||
|
useMocha {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
testLogging {
|
||||||
|
events "failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ios {
|
ios {
|
||||||
binaries {
|
binaries {
|
||||||
|
@ -101,23 +120,11 @@ kotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// jsMain {
|
jsMain {
|
||||||
// dependencies {
|
dependencies {
|
||||||
// implementation npm("@js-joda/timezone", "2.3.0")
|
implementation "io.ktor:ktor-client-js:$ktorVersion"
|
||||||
// implementation "io.ktor:ktor-client-js:$ktorVersion"
|
}
|
||||||
// }
|
}
|
||||||
/* Plus:
|
|
||||||
@JsModule("@js-joda/timezone")
|
|
||||||
@JsNonModule
|
|
||||||
external object JsJodaTimeZoneModule
|
|
||||||
|
|
||||||
private val jsJodaTz = JsJodaTimeZoneModule
|
|
||||||
*/
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// jsTest {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
iosMain {
|
iosMain {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.dankito.banking.fints.extensions
|
package net.dankito.banking.fints.extensions
|
||||||
|
|
||||||
|
import net.dankito.utils.multiplatform.extensions.platformSpecificQualifiedName
|
||||||
import kotlin.contracts.ExperimentalContracts
|
import kotlin.contracts.ExperimentalContracts
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
@ -65,7 +66,7 @@ fun <T : Any?> assertContains(collection: Collection<T>, vararg items: T) {
|
||||||
inline fun <reified T : Throwable> assertThrows(action: () -> Unit) {
|
inline fun <reified T : Throwable> assertThrows(action: () -> Unit) {
|
||||||
try {
|
try {
|
||||||
action()
|
action()
|
||||||
fail("action() didn't throw any exception. Expected was ${T::class.qualifiedName}")
|
fail("action() didn't throw any exception. Expected was ${T::class.platformSpecificQualifiedName}")
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
assertTrue(throwable is T)
|
assertTrue(throwable is T)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class SepaMessageCreatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `containsOnlyAllowedCharacters colon is a legal character`() {
|
fun containsOnlyAllowedCharacters_ColonIsALegalCharacter() {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.containsOnlyAllowedCharacters(":")
|
val result = underTest.containsOnlyAllowedCharacters(":")
|
||||||
|
@ -41,7 +41,7 @@ class SepaMessageCreatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `containsOnlyAllowedCharacters ! is an illegal character`() {
|
fun containsOnlyAllowedCharacters_ExclamationMarkIsAnIllegalCharacter() {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.containsOnlyAllowedCharacters("!")
|
val result = underTest.containsOnlyAllowedCharacters("!")
|
||||||
|
@ -51,7 +51,7 @@ class SepaMessageCreatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `containsOnlyAllowedCharacters € is an illegal character`() {
|
fun containsOnlyAllowedCharacters_EuroSignIsAnIllegalCharacter() {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.containsOnlyAllowedCharacters("€")
|
val result = underTest.containsOnlyAllowedCharacters("€")
|
||||||
|
@ -61,7 +61,7 @@ class SepaMessageCreatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `containsOnlyAllowedCharacters at sign is an illegal character`() {
|
fun containsOnlyAllowedCharacters_AtSignIsAnIllegalCharacter() {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.containsOnlyAllowedCharacters("@")
|
val result = underTest.containsOnlyAllowedCharacters("@")
|
||||||
|
@ -71,7 +71,7 @@ class SepaMessageCreatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `containsOnlyAllowedCharacters ö is an illegal character`() {
|
fun containsOnlyAllowedCharacters_ÖIsAnIllegalCharacter() {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.containsOnlyAllowedCharacters("ö")
|
val result = underTest.containsOnlyAllowedCharacters("ö")
|
||||||
|
|
|
@ -69,7 +69,7 @@ class FlickerCodeDecoderTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `decode HHD 1_4 Get transactions`() {
|
fun decodeHHD1_4_GetTransactions() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val challenge = "0388A01239230124622DE26123456780987654321"
|
val challenge = "0388A01239230124622DE26123456780987654321"
|
||||||
|
@ -82,7 +82,7 @@ class FlickerCodeDecoderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `decode HHD 1_4 Money Transfer`() {
|
fun decodeHHD1_4_TransferMoney() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val challenge = "0438701109374422DE2612345678098765432106100,00"
|
val challenge = "0438701109374422DE2612345678098765432106100,00"
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Mt940ParserTest : FinTsTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Fix annual jump from booking date to value date`() {
|
fun fixAnnualJumpFromBookingDateToValueDate() {
|
||||||
|
|
||||||
val transactionsString = ":20:STARTUMSE\n" +
|
val transactionsString = ":20:STARTUMSE\n" +
|
||||||
":25:$BankCode/$CustomerId\n" +
|
":25:$BankCode/$CustomerId\n" +
|
||||||
|
@ -164,7 +164,7 @@ class Mt940ParserTest : FinTsTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Fix line starts with dash but is not a statement separator`() {
|
fun fixLineStartsWithDashButIsNotASstatementSeparator() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val transactionsString = "\n" +
|
val transactionsString = "\n" +
|
||||||
|
@ -227,7 +227,7 @@ class Mt940ParserTest : FinTsTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Fix that time got detected as field code`() {
|
fun fixThatTimeGotDetectedAsFieldCode() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val transactionsString = "\n" +
|
val transactionsString = "\n" +
|
||||||
|
@ -276,7 +276,7 @@ class Mt940ParserTest : FinTsTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Fix that questionmark, gets detected as field code`() {
|
fun fixThat_QuestionMarkComma_GetsDetectedAsFieldCode() {
|
||||||
val transactionsString = """
|
val transactionsString = """
|
||||||
:20:STARTUMS
|
:20:STARTUMS
|
||||||
:25:$BankCode/$CustomerId
|
:25:$BankCode/$CustomerId
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Base64Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testRandomStrings() {
|
fun testRandomStrings() {
|
||||||
val steps = 1000000
|
val steps = 10_000 // 1_000_000 have been too much for JavaScript
|
||||||
val random = randomWithSeed()
|
val random = randomWithSeed()
|
||||||
|
|
||||||
for (count in 0 until steps) {
|
for (count in 0 until steps) {
|
||||||
|
|
|
@ -18,13 +18,32 @@ kotlin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// js(BOTH) {
|
js(IR) {
|
||||||
// browser {
|
binaries.executable()
|
||||||
// commonWebpackConfig {
|
browser {
|
||||||
// cssSupport.enabled = true
|
commonWebpackConfig {
|
||||||
// }
|
cssSupport.enabled = true
|
||||||
// }
|
}
|
||||||
// }
|
testTask {
|
||||||
|
useKarma {
|
||||||
|
// we cannot assume that Chrome and Firefox are installed on all systems
|
||||||
|
// useChromeHeadless()
|
||||||
|
// useFirefox()
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodejs {
|
||||||
|
testTask {
|
||||||
|
useMocha {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
testLogging {
|
||||||
|
events "failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ios {
|
ios {
|
||||||
binaries {
|
binaries {
|
||||||
|
@ -80,19 +99,17 @@ kotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// jsMain {
|
jsMain {
|
||||||
// dependencies {
|
dependencies {
|
||||||
// implementation npm("@js-joda/timezone", "2.3.0")
|
implementation npm("@js-joda/timezone", "2.3.0")
|
||||||
// implementation "io.ktor:ktor-client-js:$ktorVersion"
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
/* Plus:
|
|
||||||
@JsModule("@js-joda/timezone")
|
|
||||||
@JsNonModule
|
|
||||||
external object JsJodaTimeZoneModule
|
|
||||||
|
|
||||||
private val jsJodaTz = JsJodaTimeZoneModule
|
jsTest {
|
||||||
*/
|
dependencies {
|
||||||
|
implementation kotlin("test-js") // don't know why this dependency is needed here, it's not needed e.g. in fints4k project
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
iosMain {
|
iosMain {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.dankito.utils.multiplatform.extensions
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On some platforms like JavaScript [KClass.qualifiedName] is not supported.
|
||||||
|
* On these [KClass.simpleName] is returned, on all others [KClass.qualifiedName].
|
||||||
|
*/
|
||||||
|
expect val KClass<*>.platformSpecificQualifiedName: String
|
|
@ -9,6 +9,8 @@ enum class OsType {
|
||||||
|
|
||||||
iOS,
|
iOS,
|
||||||
|
|
||||||
|
JavaScript, // TODO: differenciate between Browser and NodeJS
|
||||||
|
|
||||||
Native // TODO: get if running on Linux, Windows or macOs
|
Native // TODO: get if running on Linux, Windows or macOs
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
import net.dankito.utils.multiplatform.extensions.ensureMinStringLength
|
package net.dankito.utils.multiplatform.extensions
|
||||||
import net.dankito.utils.multiplatform.extensions.numberOfDigits
|
|
||||||
import net.dankito.utils.multiplatform.extensions.toStringWithMinDigits
|
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.dankito.utils.multiplatform.extensions
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On some platforms like JavaScript [KClass.qualifiedName] is not supported.
|
||||||
|
* On these [KClass.simpleName] is returned, on all others [KClass.qualifiedName].
|
||||||
|
*/
|
||||||
|
actual val KClass<*>.platformSpecificQualifiedName: String
|
||||||
|
get() = this.qualifiedName ?: this.simpleName ?: "ClassNameNotFound" // should actually never occur
|
|
@ -0,0 +1,26 @@
|
||||||
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
|
import kotlinx.datetime.LocalDate
|
||||||
|
import kotlinx.datetime.LocalDateTime
|
||||||
|
|
||||||
|
actual class DateFormatter actual constructor(pattern: String) {
|
||||||
|
|
||||||
|
actual constructor(dateStyle: DateFormatStyle) : this("")
|
||||||
|
|
||||||
|
actual constructor(dateStyle: DateFormatStyle, timeStyle: DateFormatStyle) : this("")
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: implement for Logger, get current time formatted as string
|
||||||
|
actual fun format(date: LocalDateTime): String {
|
||||||
|
return "" // is only used in rare cases, don't implement right now
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun parseDate(dateString: String): LocalDate? {
|
||||||
|
return null // is only used in rare cases, don't implement right now
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun parse(dateString: String): LocalDateTime? {
|
||||||
|
return null // is only used in rare cases, don't implement right now
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
|
// required so that Joda time zones get loaded, see:
|
||||||
|
// https://github.com/Kotlin/kotlinx-datetime#note-about-time-zones-in-js
|
||||||
|
// https://github.com/Kotlin/kotlinx-datetime/blob/master/core/js/test/JsJodaTimeZoneModule.kt
|
||||||
|
|
||||||
|
@JsModule("@js-joda/timezone")
|
||||||
|
@JsNonModule
|
||||||
|
external object JsJodaTimeZoneModule
|
||||||
|
|
||||||
|
private val jsJodaTz = JsJodaTimeZoneModule
|
|
@ -0,0 +1,23 @@
|
||||||
|
package net.dankito.utils.multiplatform
|
||||||
|
|
||||||
|
actual class Thread actual constructor() {
|
||||||
|
|
||||||
|
actual companion object {
|
||||||
|
|
||||||
|
actual val current: Thread
|
||||||
|
get() = Thread()
|
||||||
|
|
||||||
|
actual fun printCurrentThreadStackTrace() {
|
||||||
|
Thread.current.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
actual val threadName = "main"
|
||||||
|
|
||||||
|
actual fun printStackTrace() {
|
||||||
|
// TODO: find a better way
|
||||||
|
Exception("Nothing happened, just to print the stack trace").printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.dankito.utils.multiplatform.extensions
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On some platforms like JavaScript [KClass.qualifiedName] is not supported.
|
||||||
|
* On these [KClass.simpleName] is returned, on all others [KClass.qualifiedName].
|
||||||
|
*/
|
||||||
|
actual val KClass<*>.platformSpecificQualifiedName: String
|
||||||
|
get() = this.simpleName // on JavaScript qualifiedName is not supported
|
||||||
|
?: "ClassNameNotFound" // should actually never occur
|
|
@ -0,0 +1,9 @@
|
||||||
|
package net.dankito.utils.multiplatform.log
|
||||||
|
|
||||||
|
actual class DefaultLoggerFactory actual constructor() {
|
||||||
|
|
||||||
|
actual fun createDefaultLoggerFactory(): ILoggerFactory {
|
||||||
|
return LogToConsoleLoggerFactory()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package net.dankito.utils.multiplatform.os
|
||||||
|
|
||||||
|
actual class OsHelper actual constructor() {
|
||||||
|
|
||||||
|
actual val osType = OsType.JavaScript
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.dankito.utils.multiplatform.extensions
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On some platforms like JavaScript [KClass.qualifiedName] is not supported.
|
||||||
|
* On these [KClass.simpleName] is returned, on all others [KClass.qualifiedName].
|
||||||
|
*/
|
||||||
|
actual val KClass<*>.platformSpecificQualifiedName: String
|
||||||
|
get() = this.qualifiedName ?: this.simpleName ?: "ClassNameNotFound" // should actually never occur
|
|
@ -5,12 +5,9 @@ import kotlinx.datetime.*
|
||||||
|
|
||||||
actual class DateFormatter actual constructor(pattern: String) {
|
actual class DateFormatter actual constructor(pattern: String) {
|
||||||
|
|
||||||
|
actual constructor(dateStyle: DateFormatStyle) : this("")
|
||||||
|
|
||||||
actual constructor(dateStyle: DateFormatStyle)
|
actual constructor(dateStyle: DateFormatStyle, timeStyle: DateFormatStyle) : this("")
|
||||||
: this("")
|
|
||||||
|
|
||||||
actual constructor(dateStyle: DateFormatStyle, timeStyle: DateFormatStyle)
|
|
||||||
: this("")
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: implement for Logger, get current time formatted as string
|
// TODO: implement for Logger, get current time formatted as string
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.dankito.utils.multiplatform.extensions
|
||||||
|
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On some platforms like JavaScript [KClass.qualifiedName] is not supported.
|
||||||
|
* On these [KClass.simpleName] is returned, on all others [KClass.qualifiedName].
|
||||||
|
*/
|
||||||
|
actual val KClass<*>.platformSpecificQualifiedName: String
|
||||||
|
get() = this.qualifiedName ?: this.simpleName ?: "ClassNameNotFound" // should actually never occur
|
Loading…
Reference in New Issue