Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-io-core?versionSuffix=0.2.1)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-io-core/0.2.1)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![TeamCity build](https://img.shields.io/teamcity/build/s/KotlinTools_KotlinxIo_BuildAggregated.svg?server=http%3A%2F%2Fteamcity.jetbrains.com)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxIo_BuildAggregated&guest=1)
[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://fzhinkin.github.io/kotlinx-io-dokka-docs-preview/)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import kotlin.jvm.optionals.getOrNull

plugins {
Expand Down Expand Up @@ -36,6 +37,14 @@ kotlin {
}
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasm {
nodejs()
// Disabled because we can't exclude some tests: https://youtrack.jetbrains.com/issue/KT-58291
// browser()
binaries.executable()
}

sourceSets {
commonTest {
dependencies {
Expand Down Expand Up @@ -163,3 +172,7 @@ fun androidTargets() = listOf(
"androidNativeX64",
"androidNativeX86"
)

rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "20.4.0"
}
12 changes: 12 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ kotlin {
}
}

@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasm {
nodejs {
testTask(Action {
useMocha {
timeout = "300s"
}
filter.setExcludePatterns("*SmokeFileTest*")
})
}
}

sourceSets {
commonMain {
dependencies {
Expand Down
19 changes: 19 additions & 0 deletions core/wasm/src/-PlatformWasm.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package kotlinx.io

import kotlinx.io.internal.commonAsUtf8ToByteArray

internal actual fun String.asUtf8ToByteArray(): ByteArray = commonAsUtf8ToByteArray()

public actual open class IOException actual constructor(
message: String?,
cause: Throwable?
) : Exception(message, cause) {
public actual constructor(message: String?) : this(message, null)
}

public actual open class EOFException actual constructor(message: String?) : IOException(message)
15 changes: 15 additions & 0 deletions core/wasm/src/RawSink.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package kotlinx.io

@OptIn(ExperimentalStdlibApi::class)
public actual interface RawSink : AutoCloseableAlias {
public actual fun write(source: Buffer, byteCount: Long)

public actual fun flush()

actual override fun close()
}
17 changes: 17 additions & 0 deletions core/wasm/src/SegmentPool.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package kotlinx.io

internal actual object SegmentPool {
actual val MAX_SIZE: Int = 0

actual val byteCount: Int = 0

actual fun take(): Segment = Segment()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real pool in WASM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pooling is only supported for JVM target at the moment. I'm thinking of adding support for other targets later.


actual fun recycle(segment: Segment) {
}
}
27 changes: 27 additions & 0 deletions core/wasm/src/files/PathsWasm.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package kotlinx.io.files

import kotlinx.io.Sink
import kotlinx.io.Source


public actual class Path internal constructor(private val path: String,
@Suppress("UNUSED_PARAMETER") any: Any?) {
override fun toString(): String = path
}

public actual fun Path(path: String): Path {
return Path(path, null)
}

public actual fun Path.source(): Source {
TODO("Paths are not supported for Wasm target")
}

public actual fun Path.sink(): Sink {
TODO("Paths are not supported for Wasm target")
}
14 changes: 14 additions & 0 deletions core/wasm/test/utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package kotlinx.io

actual fun createTempFile(): String {
TODO("Paths are not supported for Wasm target")
}

actual fun deleteFile(path: String) {
TODO("Paths are not supported for Wasm target")
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.9.0"
kotlin = "1.9.10"
java = "8"
dokka = "1.8.20"
kover = "0.7.3"
Expand Down