Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jvm, js and wasmJs targets #3

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## Integration

### Android
### Gradle (JVM, Android, KMP)

Add this to your dependencies:

`implementation 'io.stepuplabs.spaydkmp:spayd-kmp-android:<latest-version>'`
`implementation 'io.stepuplabs.spaydkmp:spayd-kmp:<latest-version>'`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about changing the artifact name. Is it because the code doesn't have any Android-specific dependencies and it's pure JVM code?

Copy link
Author

Choose a reason for hiding this comment

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

Exactly, there is nothing Android-specific right now. The whole Android-specific implementation can be removed, with the removal of minSdk limitation as a positive side effect.

Several generated modules for different platforms should be resolved correctly when using root spayd-kmp.

spayd-kmp
spayd-kmp-iosarm64
spayd-kmp-iossimulatorarm64
spayd-kmp-iosx64
spayd-kmp-js
spayd-kmp-jvm
spayd-kmp-wasm-js

For some reason, it doesn't work this way when using the deployer publishing, but works with publishToMavenLocal task and default shared-* artifacts.

I will investigate it further.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I agree with removing Android specific implementation and changing the artifactId.

We are using MavenDeployer plugin for deploying to Central. It also support local deploy, so please try to deploy locally and see what artifacts in generated.

When it will be published to Central, there will be just one artifact or multiple?

Also, I'm not sure how it works in Javascript world with the KMP & dependencies - should we deploy to some JS specific repository like NPM?


### iOS

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kotlinx-datetime = "0.6.1"
ktor = "3.0.0"
okio = "3.9.1"
skie = "0.9.3"
urlencoder = "1.4.0"
urlencoder = "1.6.0"
maven-deployer = "0.16.0"

[plugins]
Expand Down
18 changes: 16 additions & 2 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import co.touchlab.skie.configuration.SealedInterop
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kotlinMultiplatform)
Expand Down Expand Up @@ -33,6 +34,20 @@ kotlin {
}
}

jvm()

js {
browser()
nodejs()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
d8()
}

sourceSets {
commonMain.dependencies {
implementation(libs.kotlinx.datetime)
Expand Down Expand Up @@ -73,8 +88,7 @@ skie {

deployer {
content {
androidComponents("release") {
kotlinSources()
kotlinComponents {
emptyDocs()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,10 @@ abstract class Buffer internal constructor(capacity: Int) {
this.capacity = limit
}

fun capacity(): Int {
return capacity
}

fun hasRemaining(): Boolean {
return position < limit
}

fun limit(): Int {
return limit
}

fun limit(newLimit: Int): Buffer {
require(!(newLimit < 0 || newLimit > capacity))
limit = newLimit
Expand All @@ -51,10 +43,6 @@ abstract class Buffer internal constructor(capacity: Int) {
return this
}

fun position(): Int {
return position
}

fun position(newPosition: Int): Buffer {
require(!(newPosition < 0 || newPosition > limit))
position = newPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class CharArrayBuffer : Buffer {
}

private fun copy(other: CharArrayBuffer, markOfOther: Int): CharArrayBuffer {
val buf = CharArrayBuffer(other.capacity(), other.backingArray, other.offset)
buf.limit = other.limit()
buf.position = other.position()
val buf = CharArrayBuffer(other.capacity, other.backingArray, other.offset)
buf.limit = other.limit
buf.position = other.position
buf.mark = markOfOther

return buf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ParserStateMachine(
val nextFormatToken: FormatToken
get() {
token = FormatToken()
token!!.formatStringStartIndex = format.position()
token!!.formatStringStartIndex = format.position

while (true) {
if (EXIT_STATE != state) {
Expand Down Expand Up @@ -82,7 +82,7 @@ class ParserStateMachine(
}
private val formatString: String
get() {
val end: Int = format.position()
val end: Int = format.position
format.rewind()
val formatString: String = format.subSequence(
token!!.formatStringStartIndex, end
Expand All @@ -108,7 +108,7 @@ class ParserStateMachine(

private fun processStartConversionState() {
if (currentChar.isDigit()) {
val position: Int = format.position() - 1
val position: Int = format.position - 1
val number = parseInt(format)
var nextChar = 0.toChar()
if (format.hasRemaining()) {
Expand All @@ -130,7 +130,7 @@ class ParserStateMachine(
} else { // the digital sequence stands for the width.
state = WIDTH_STATE
// do not get the next char.
format.position(format.position() - 1)
format.position(format.position - 1)
token!!.width = number
}
}
Expand All @@ -140,7 +140,7 @@ class ParserStateMachine(
token!!.argIndex = FormatToken.LAST_ARGUMENT_INDEX
} else {
state = FLAGS_STATE
format.position(format.position() - 1)
format.position(format.position - 1)
}
}

Expand All @@ -154,7 +154,7 @@ class ParserStateMachine(
state = PRECISION_STATE
} else {
state = CONVERSION_TYPE_STATE
format.position(format.position() - 1)
format.position(format.position - 1)
}
}

Expand All @@ -164,7 +164,7 @@ class ParserStateMachine(
} else {
state = CONVERSION_TYPE_STATE
// do not get the next char.
format.position(format.position() - 1)
format.position(format.position - 1)
}
}

Expand Down Expand Up @@ -196,12 +196,12 @@ class ParserStateMachine(
}

private fun parseInt(buffer: CharArrayBuffer): Int {
val start: Int = buffer.position() - 1
var end: Int = buffer.limit()
val start: Int = buffer.position - 1
var end: Int = buffer.limit

while (buffer.hasRemaining()) {
if (!buffer.get().isDigit()) {
end = buffer.position() - 1
end = buffer.position - 1
break
}
}
Expand Down
Loading