Skip to content

Commit

Permalink
Added config for js
Browse files Browse the repository at this point in the history
  • Loading branch information
dragossusi committed Oct 20, 2024
1 parent a33f798 commit d675f54
Show file tree
Hide file tree
Showing 53 changed files with 240 additions and 102 deletions.
21 changes: 14 additions & 7 deletions backend/rpc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
// id("io.ktor.plugin")
// id("org.jetbrains.kotlinx.rpc.plugin")
id("org.jetbrains.kotlinx.rpc.plugin")
}

repositories {
mavenCentral()
}

kotlin {
jvm()
js(IR) {
browser()

if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
commonMain.dependencies {
api(Libs.Coroutines.core)
api(Libs.Serialization.core)
api(Libs.Serialization.json)

// implementation(Libs.Rpc.core)
// implementation(Libs.Rpc.serializationJson)
// implementation(Libs.datetime)
implementation(Libs.Rpc.core)
implementation(Libs.Rpc.serializationJson)
implementation(Libs.datetime)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ro.dragossusi.ktcnc.rpc

interface FileSystemService {
import kotlinx.rpc.RPC

interface FileSystemService : RPC {
suspend fun getRoot(): FileResponse

suspend fun getFile(path: String): FileResponse
Expand Down
1 change: 0 additions & 1 deletion backend/server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("org.jetbrains.kotlinx.rpc.plugin")
id("io.ktor.plugin")
}

Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ plugins {
id("androidx.room") version Versions.room apply false
// rpc
id("org.jetbrains.kotlinx.rpc.plugin") version Versions.Kotlinx.rpc apply false
id("org.jetbrains.kotlinx.rpc.platform") version Versions.Kotlinx.rpc apply false

id("io.ktor.plugin") version Versions.ktor
}
Expand Down
15 changes: 14 additions & 1 deletion buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,27 @@ object Libs {
}

object Serialization {
const val core =
"org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.Kotlinx.serialization}"
const val json =
"org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.Kotlinx.serialization}"
const val json_okio =
"org.jetbrains.kotlinx:kotlinx-serialization-json-okio:${Versions.Kotlinx.serialization}"
}

object Ktor {
object Client {
const val core = "io.ktor:ktor-client-core:${Versions.ktor}"
const val cio = "io.ktor:ktor-client-cio:${Versions.ktor}"
}

object Server {
const val core = "io.ktor:ktor-server-core-jvm:${Versions.ktor}"
}
}

object Rpc {
const val core = "org.jetbrains.kotlinx:kotlinx-rpc-core:${Versions.Kotlinx.rpc}"
const val core = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-core:${Versions.Kotlinx.rpc}"
const val client = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:${Versions.Kotlinx.rpc}"
const val server = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:${Versions.Kotlinx.rpc}"
const val ktorServer = "org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:${Versions.Kotlinx.rpc}"
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Platforms.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Platforms {
val jsEnabled = false
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object Versions {
const val kotlin = "2.0.10"
const val ksp = "2.0.10-1.0.24"
const val compose = "1.7.0"
const val material3adaptive = "1.0.0-alpha03"
const val material3adaptive = "1.0.0"
const val kodein = "7.21.1"

const val okio = "3.9.1"
Expand Down
6 changes: 4 additions & 2 deletions data/common/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/common/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/gcode/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/gcode/remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/lathehal/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/lathehal/remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
4 changes: 3 additions & 1 deletion data/lathetools/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ version = Versions.app

kotlin {
jvm()
js(IR) { browser() }
if (Platforms.jsEnabled) {
js(IR) { browser() }
}

sourceSets {
val commonMain by getting {
Expand Down
6 changes: 4 additions & 2 deletions data/lathetools/remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/linuxcnc/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
8 changes: 6 additions & 2 deletions data/linuxcnc/remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand All @@ -22,6 +24,8 @@ kotlin {
implementation(project(":model"))
implementation(Libs.okio)
implementation(Libs.Rpc.ktorClient)
implementation(Libs.Rpc.client)
implementation(Libs.Ktor.Client.core)

// logging
implementation(Libs.Log.logging)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
package com.mindovercnc.data.linuxcnc.remote

import com.mindovercnc.data.linuxcnc.FileSystemRepository
import io.ktor.client.*
import kotlinx.rpc.krpc.ktor.client.rpc
import kotlinx.rpc.krpc.ktor.client.rpcConfig
import kotlinx.rpc.withService
import mu.KotlinLogging
import ro.dragossusi.ktcnc.rpc.FileResponse
import ro.dragossusi.ktcnc.rpc.FileSystemService

class FileSystemRepositoryRemote(
private val fileSystemService: FileSystemService
private val httpClient: HttpClient
) : FileSystemRepository {

private suspend fun createService() = httpClient.rpc {
url {
host = "localhost"
port = 8080
}
rpcConfig {
serialization {
json()
}
}
}.withService<FileSystemService>()

override suspend fun getFile(path: String): FileResponse {
return fileSystemService.getFile(path)
return createService().getFile(path)
}

override suspend fun getNcRootAppFile(): FileResponse {
Expand Down
6 changes: 4 additions & 2 deletions data/settings/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions data/settings/remote/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions dispatcher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions editor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
6 changes: 4 additions & 2 deletions frontend/actor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ plugins {

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
24 changes: 14 additions & 10 deletions frontend/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
binaries.executable()
if (Platforms.jsEnabled) {
js(IR) {
browser()
binaries.executable()
}
}

sourceSets {
Expand Down Expand Up @@ -104,13 +106,15 @@ kotlin {
}
}

val jsMain by getting {
dependencies {
implementation(project(":data:gcode:remote"))
implementation(project(":data:linuxcnc:remote"))
implementation(project(":data:settings:remote"))
implementation(project(":data:lathetools:remote"))
implementation(project(":data:lathehal:remote"))
if (Platforms.jsEnabled) {
val jsMain by getting {
dependencies {
implementation(project(":data:gcode:remote"))
implementation(project(":data:linuxcnc:remote"))
implementation(project(":data:settings:remote"))
implementation(project(":data:lathetools:remote"))
implementation(project(":data:lathehal:remote"))
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions frontend/breadcrumb/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ version = Versions.app

kotlin {
jvm()
js(IR) {
browser()
if (Platforms.jsEnabled) {
js(IR) {
browser()
}
}

sourceSets {
Expand Down
Loading

0 comments on commit d675f54

Please sign in to comment.