diff --git a/build.gradle.kts b/build.gradle.kts index 19b1901b..6b08110b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,11 +10,11 @@ val plotlyVersion by extra("2.29.0") allprojects { group = "space.kscience" - version = "0.7.0-dev-1" + version = "0.7.0" } apiValidation { - ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo")) + ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo", "compose-demo")) } ksciencePublish{ diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 0a468e17..57483cb5 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -29,8 +29,8 @@ tasks.withType { val copyPlotlyResources by tasks.creating(Copy::class){ dependsOn(":plotlykt-core:jvmProcessResources") mustRunAfter(":plotlykt-core:jvmTestProcessResources") - from(project(":plotlykt-core").buildDir.resolve("processedResources/jvm")) - into(buildDir.resolve("resources")) + from(project(":plotlykt-core").layout.buildDirectory.file("processedResources/jvm")) + into(layout.buildDirectory.file("resources")) } tasks.getByName("classes").dependsOn(copyPlotlyResources) diff --git a/examples/compose-demo/build.gradle.kts b/examples/compose-demo/build.gradle.kts index 407d7fd3..d1d6f55a 100644 --- a/examples/compose-demo/build.gradle.kts +++ b/examples/compose-demo/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("multiplatform") - id("org.jetbrains.compose") version "1.5.12" + alias(spclibs.plugins.compose) } repositories { diff --git a/examples/js-demo/build.gradle.kts b/examples/js-demo/build.gradle.kts index dbef5c0e..a16944c3 100644 --- a/examples/js-demo/build.gradle.kts +++ b/examples/js-demo/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("js") + kotlin("multiplatform") } repositories { @@ -12,13 +12,16 @@ kotlin { browser() binaries.executable() } -} - -dependencies { - implementation(projects.plotlyktCore) - implementation(spclibs.kotlinx.coroutines.core) + sourceSets{ + jsMain{ + dependencies{ + implementation(projects.plotlyktCore) + implementation(spclibs.kotlinx.coroutines.core) + } + } + } } tasks.withType { - kotlinOptions.freeCompilerArgs = kotlinOptions.freeCompilerArgs +"-Xopt-in=kotlin.RequiresOptIn" + kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } \ No newline at end of file diff --git a/examples/src/main/kotlin/tabPageLayout.kt b/examples/src/main/kotlin/tabPageLayout.kt index 47d51782..75cc6d9c 100644 --- a/examples/src/main/kotlin/tabPageLayout.kt +++ b/examples/src/main/kotlin/tabPageLayout.kt @@ -1,3 +1,4 @@ +import kotlinx.html.* import space.kscience.plotly.* import space.kscience.plotly.models.Trace import space.kscience.plotly.models.invoke @@ -6,6 +7,60 @@ import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin + +public class PlotTabs { + public data class Tab(val title: String, val id: String, val content: PlotlyFragment) + + private val _tabs = ArrayList() + public val tabs: List get() = _tabs + + public fun tab(title: String, id: String = title, block: FlowContent.(renderer: PlotlyRenderer) -> Unit) { + _tabs.add(Tab(title, id, PlotlyFragment(block))) + } +} + +public fun Plotly.tabs(tabsID: String = "tabs", block: PlotTabs.() -> Unit): PlotlyPage { + val grid = PlotTabs().apply(block) + + return page(cdnBootstrap, cdnPlotlyHeader) { container -> + ul("nav nav-tabs") { + role = "tablist" + id = tabsID + grid.tabs.forEachIndexed { index, tab -> + li("nav-item") { + a(classes = "nav-link") { + if (index == 0) { + classes = classes + "active" + } + id = "${tab.id}-tab" + attributes["data-toggle"] = "tab" + href = "#${tab.id}" + role = "tab" + attributes["aria-controls"] = tab.id + attributes["aria-selected"] = "true" + +tab.title + } + } + } + } + div("tab-content") { + id = "$tabsID-content" + grid.tabs.forEachIndexed { index, tab -> + div("tab-pane fade") { + if (index == 0) { + classes = classes + setOf("show", "active") + } + id = tab.id + role = "tabpanel" + attributes["aria-labelledby"] = "${tab.id}-tab" + tab.content.render(this, container) + } + } + } + } +} + + @Suppress("DEPRECATION") @UnstablePlotlyAPI fun main() { @@ -26,14 +81,14 @@ fun main() { } - val responsive = PlotlyConfig{ + val responsive = PlotlyConfig { responsive = true } val plot = Plotly.tabs { - tab("First"){ - plot (config = responsive){ + tab("First") { + plot(config = responsive) { traces(trace1) layout { title = "First graph" @@ -42,7 +97,7 @@ fun main() { } } } - tab("Second"){ + tab("Second") { plot(config = responsive) { traces(trace2) layout { diff --git a/gradle.properties b/gradle.properties index a419f812..71eafd00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.mpp.stability.nowarn=true kotlin.jupyter.add.scanner=false kotlin.incremental.js.ir=true -toolsVersion=0.15.2-kotlin-1.9.21 \ No newline at end of file +toolsVersion=0.15.2-kotlin-1.9.22 \ No newline at end of file diff --git a/plotlykt-core/api/plotlykt-core.api b/plotlykt-core/api/plotlykt-core.api index 14fb4c5e..c36b0b65 100644 --- a/plotlykt-core/api/plotlykt-core.api +++ b/plotlykt-core/api/plotlykt-core.api @@ -79,40 +79,6 @@ public final class space/kscience/plotly/PlotExtensionsKt { public static final fun violin (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/models/Violin; } -public final class space/kscience/plotly/PlotGrid { - public fun ()V - public final fun get (Ljava/lang/String;)Lspace/kscience/plotly/PlotGrid$PlotCell; - public final fun getGrid ()Ljava/util/List; - public final fun plot (Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/Plot; - public final fun plot (Lspace/kscience/plotly/Plot;Ljava/lang/String;ILjava/lang/Integer;Ljava/lang/Integer;)Lspace/kscience/plotly/Plot; - public static synthetic fun plot$default (Lspace/kscience/plotly/PlotGrid;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/plotly/Plot; - public static synthetic fun plot$default (Lspace/kscience/plotly/PlotGrid;Lspace/kscience/plotly/Plot;Ljava/lang/String;ILjava/lang/Integer;Ljava/lang/Integer;ILjava/lang/Object;)Lspace/kscience/plotly/Plot; -} - -public final class space/kscience/plotly/PlotGrid$PlotCell { - public fun (Ljava/lang/String;Lspace/kscience/plotly/Plot;III)V - public synthetic fun (Ljava/lang/String;Lspace/kscience/plotly/Plot;IIIILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Lspace/kscience/plotly/Plot; - public final fun component3 ()I - public final fun component4 ()I - public final fun component5 ()I - public final fun copy (Ljava/lang/String;Lspace/kscience/plotly/Plot;III)Lspace/kscience/plotly/PlotGrid$PlotCell; - public static synthetic fun copy$default (Lspace/kscience/plotly/PlotGrid$PlotCell;Ljava/lang/String;Lspace/kscience/plotly/Plot;IIIILjava/lang/Object;)Lspace/kscience/plotly/PlotGrid$PlotCell; - public fun equals (Ljava/lang/Object;)Z - public final fun getCol ()I - public final fun getId ()Ljava/lang/String; - public final fun getPlot ()Lspace/kscience/plotly/Plot; - public final fun getRow ()I - public final fun getWidth ()I - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/plotly/PlotGridKt { - public static final fun grid (Lspace/kscience/plotly/Plotly;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/PlotlyPage; -} - public final class space/kscience/plotly/PlotKt { public static final fun Plot (Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/plotly/Plot; public static final fun layout (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)V @@ -120,33 +86,6 @@ public final class space/kscience/plotly/PlotKt { public static final fun trace (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/models/Trace; } -public final class space/kscience/plotly/PlotTabs { - public fun ()V - public final fun getTabs ()Ljava/util/List; - public final fun tab (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V - public static synthetic fun tab$default (Lspace/kscience/plotly/PlotTabs;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V -} - -public final class space/kscience/plotly/PlotTabs$Tab { - public fun (Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Ljava/lang/String; - public final fun component3 ()Lspace/kscience/plotly/PlotlyFragment; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;)Lspace/kscience/plotly/PlotTabs$Tab; - public static synthetic fun copy$default (Lspace/kscience/plotly/PlotTabs$Tab;Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;ILjava/lang/Object;)Lspace/kscience/plotly/PlotTabs$Tab; - public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Lspace/kscience/plotly/PlotlyFragment; - public final fun getId ()Ljava/lang/String; - public final fun getTitle ()Ljava/lang/String; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/plotly/PlotTabsKt { - public static final fun tabs (Lspace/kscience/plotly/Plotly;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/PlotlyPage; - public static synthetic fun tabs$default (Lspace/kscience/plotly/Plotly;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/plotly/PlotlyPage; -} - public final class space/kscience/plotly/Plotly { public static final field INSTANCE Lspace/kscience/plotly/Plotly; public static final field PLOTLY_CDN Ljava/lang/String; diff --git a/plotlykt-core/build.gradle.kts b/plotlykt-core/build.gradle.kts index e2c78c90..fb953ab5 100644 --- a/plotlykt-core/build.gradle.kts +++ b/plotlykt-core/build.gradle.kts @@ -18,8 +18,8 @@ kscience { dependencies { api("space.kscience:dataforge-meta:$dataforgeVersion") - //api(spclibs.kotlinx.html) - api("org.jetbrains.kotlinx:kotlinx-html:0.11.0") + api(spclibs.kotlinx.html) +// api("org.jetbrains.kotlinx:kotlinx-html:0.11.0") } jsMain{ diff --git a/plotlykt-core/src/jvmMain/kotlin/space/kscience/plotly/PlotTabs.kt b/plotlykt-core/src/jvmMain/kotlin/space/kscience/plotly/PlotTabs.kt deleted file mode 100644 index 25ec8173..00000000 --- a/plotlykt-core/src/jvmMain/kotlin/space/kscience/plotly/PlotTabs.kt +++ /dev/null @@ -1,59 +0,0 @@ -package space.kscience.plotly - -import kotlinx.html.* - -@UnstablePlotlyAPI -@Deprecated("Discontinued in favor of VisionForge layouts") -public class PlotTabs { - public data class Tab(val title: String, val id: String, val content: PlotlyFragment) - - private val _tabs = ArrayList() - public val tabs: List get() = _tabs - - public fun tab(title: String, id: String = title, block: FlowContent.(renderer: PlotlyRenderer) -> Unit) { - _tabs.add(Tab(title, id, PlotlyFragment(block))) - } -} - -@UnstablePlotlyAPI -@Deprecated("Discontinued in favor of VisionForge layouts") -public fun Plotly.tabs(tabsID: String = "tabs", block: PlotTabs.() -> Unit): PlotlyPage { - val grid = PlotTabs().apply(block) - - return page(cdnBootstrap, cdnPlotlyHeader) { container -> - ul("nav nav-tabs") { - role = "tablist" - id = tabsID - grid.tabs.forEachIndexed { index, tab-> - li("nav-item") { - a(classes = "nav-link") { - if(index == 0){ - classes = classes + "active" - } - id = "${tab.id}-tab" - attributes["data-toggle"] = "tab" - href = "#${tab.id}" - role = "tab" - attributes["aria-controls"] = tab.id - attributes["aria-selected"] = "true" - +tab.title - } - } - } - } - div("tab-content") { - id = "$tabsID-content" - grid.tabs.forEachIndexed {index, tab-> - div("tab-pane fade") { - if(index == 0){ - classes = classes + setOf("show", "active") - } - id = tab.id - role = "tabpanel" - attributes["aria-labelledby"] = "${tab.id}-tab" - tab.content.render(this, container) - } - } - } - } -} \ No newline at end of file diff --git a/plotlykt-jupyter/build.gradle.kts b/plotlykt-jupyter/build.gradle.kts index 7bfcfd41..847e7f93 100644 --- a/plotlykt-jupyter/build.gradle.kts +++ b/plotlykt-jupyter/build.gradle.kts @@ -1,13 +1,16 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") kotlin("jupyter.api") `maven-publish` } val dataforgeVersion: String by rootProject.extra -dependencies { - api(projects.plotlyktCore) +kscience{ + jvm() + jvmMain{ + api(projects.plotlyktCore) + } } tasks.processJupyterApiResources{ diff --git a/plotlykt-jupyter/src/main/kotlin/space/kscience/plotly/PlotlyIntegration.kt b/plotlykt-jupyter/src/jvmMain/kotlin/space/kscience/plotly/PlotlyIntegration.kt similarity index 100% rename from plotlykt-jupyter/src/main/kotlin/space/kscience/plotly/PlotlyIntegration.kt rename to plotlykt-jupyter/src/jvmMain/kotlin/space/kscience/plotly/PlotlyIntegration.kt diff --git a/plotlykt-script/build.gradle.kts b/plotlykt-script/build.gradle.kts index 048d230f..09ee0a87 100644 --- a/plotlykt-script/build.gradle.kts +++ b/plotlykt-script/build.gradle.kts @@ -1,26 +1,28 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") application `maven-publish` } -repositories { - maven("https://dl.bintray.com/kotlin/ktor/") -} - val ktorVersion: String by rootProject.extra val dataforgeVersion: String by rootProject.extra -dependencies { - api(projects.plotlyktCore) - api(spclibs.kotlinx.html) - api(kotlin("scripting-jvm-host")) - api(kotlin("scripting-jvm")) - api("io.github.microutils:kotlin-logging:3.0.5") - implementation(spclibs.logback.classic) - implementation(spclibs.kotlinx.cli) +kscience{ + jvm{ + withJava() + } + jvmMain{ + api(projects.plotlyktCore) + api(spclibs.kotlinx.html) + api(kotlin("scripting-jvm-host")) + api(kotlin("scripting-jvm")) + api("io.github.microutils:kotlin-logging:3.0.5") + implementation(spclibs.logback.classic) + implementation(spclibs.kotlinx.cli) + } } + application{ mainClass.set("space.kscience.plotly.script.CliKt") } \ No newline at end of file diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt similarity index 89% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt index e84aaaa8..8a6b051d 100644 --- a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt +++ b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt @@ -11,10 +11,10 @@ import kotlin.script.experimental.jvm.jvm fileExtension = "plotly.kts", compilationConfiguration = PlotlyScriptCompilationConfiguration::class ) -abstract class PlotlyScript +public abstract class PlotlyScript -class PlotlyScriptCompilationConfiguration: ScriptCompilationConfiguration({ +public class PlotlyScriptCompilationConfiguration: ScriptCompilationConfiguration({ baseClass(PlotlyScript::class) implicitReceivers(FlowContent::class) defaultImports( diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/builder.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/builder.kt similarity index 100% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/builder.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/builder.kt diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt similarity index 95% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt index 5794ab62..1c188f46 100644 --- a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt +++ b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt @@ -10,7 +10,7 @@ import java.io.File import java.nio.file.Path @OptIn(UnstablePlotlyAPI::class) -fun main(args: Array) { +public fun main(args: Array) { val parser = ArgParser("plotlykt-script") val input by parser.argument(ArgType.String, description ="Input file path") val output by parser.argument(ArgType.String, description = "Output file path").optional() diff --git a/plotlykt-script/src/main/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname b/plotlykt-script/src/jvmMain/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname similarity index 100% rename from plotlykt-script/src/main/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname rename to plotlykt-script/src/jvmMain/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname diff --git a/plotlykt-script/src/test/kotlin/space/kscience/plotly/script/BuilderTest.kt b/plotlykt-script/src/jvmTest/kotlin/space/kscience/plotly/script/BuilderTest.kt similarity index 100% rename from plotlykt-script/src/test/kotlin/space/kscience/plotly/script/BuilderTest.kt rename to plotlykt-script/src/jvmTest/kotlin/space/kscience/plotly/script/BuilderTest.kt diff --git a/plotlykt-script/src/test/resources/customPage.plotly.kts b/plotlykt-script/src/jvmTest/resources/customPage.plotly.kts similarity index 100% rename from plotlykt-script/src/test/resources/customPage.plotly.kts rename to plotlykt-script/src/jvmTest/resources/customPage.plotly.kts diff --git a/plotlykt-server/build.gradle.kts b/plotlykt-server/build.gradle.kts index 2409750d..57063afd 100644 --- a/plotlykt-server/build.gradle.kts +++ b/plotlykt-server/build.gradle.kts @@ -1,7 +1,7 @@ import space.kscience.gradle.KScienceVersions plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") kotlin("jupyter.api") `maven-publish` } @@ -9,13 +9,16 @@ plugins { val dataforgeVersion: String by rootProject.extra val ktorVersion = KScienceVersions.ktorVersion -dependencies { - api(projects.plotlyktCore) - api("io.ktor:ktor-server-cio:$ktorVersion") - api("io.ktor:ktor-server-html-builder:$ktorVersion") - api("io.ktor:ktor-server-websockets:$ktorVersion") - api("io.ktor:ktor-server-cors:$ktorVersion") - api("space.kscience:dataforge-context:$dataforgeVersion") +kscience{ + jvm() + commonMain{ + api(projects.plotlyktCore) + api("io.ktor:ktor-server-cio:$ktorVersion") + api("io.ktor:ktor-server-html-builder:$ktorVersion") + api("io.ktor:ktor-server-websockets:$ktorVersion") + api("io.ktor:ktor-server-cors:$ktorVersion") + api("space.kscience:dataforge-context:$dataforgeVersion") + } } tasks.processJupyterApiResources{ diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServer.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServer.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServer.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServer.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/Update.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/Update.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/Update.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/Update.kt