diff --git a/.gitignore b/.gitignore index 4dc36cae..51dec909 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.iws out/ .gradle +.kotlin build/ data/ .kotlin/ diff --git a/.space.kts b/.space.kts deleted file mode 100644 index 45b2ed53..00000000 --- a/.space.kts +++ /dev/null @@ -1,4 +0,0 @@ -job("Build") { - gradlew("openjdk:11", "build") -} - diff --git a/CHANGELOG.md b/CHANGELOG.md index bf2c3478..2fa6c42d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,54 @@ # Changelog -## [Unreleased] +## Unreleased + ### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +## 0.4.1 - 2024-03-15 + +### Changed + +- VisionProperties `flowChanges()` -> `changes` + +### Fixed + +- Bug with ElementVisionRenderer having the same name +- Plotly update problem + +## 0.4.0 - 2024-02-16 + +### Added + +- Added compose-mpp rendering. + +### Changed + +- **Breaking API** Move vision cache to upper level for renderers to avoid re-creating visions for page reload. +- **Breaking API** Forms refactor. +- **Breaking API** Migrated from React to Compose-html. +- **Breaking API** changed js package for `visionforge-core` to `space.kscience.visionforge.html` to avoid mixing html and generic parts. + +## 0.3.0 - 2023-12-23 + +### Added + - Context receivers flag - MeshLine for thick lines - Custom client-side events and thier processing in VisionServer +- Control/input visions ### Changed + - Color accessor property is now `colorProperty`. Color uses non-nullable `invoke` instead of `set`. - API update for server and pages - Edges moved to solids module for easier construction @@ -17,17 +59,14 @@ - Naming of Canvas3D options. - Lights are added to the scene instead of 3D options. -### Deprecated - -### Removed - ### Fixed + - Jupyter integration for IDEA and Jupyter lab. -### Security +## 0.2.0 -## [0.2.0] ### Added + - Server module - Change collector - Customizable accessors for colors @@ -38,8 +77,8 @@ - Markdown module - Tables module - ### Changed + - Vision does not implement ItemProvider anymore. Property changes are done via `getProperty`/`setProperty` and `property` delegate. - Point3D and Point2D are made separate classes instead of expect/actual (to split up different engines. - JavaFX support moved to a separate module @@ -54,16 +93,10 @@ - Property listeners are not triggered if there are no changes. - Feedback websocket connection in the client. - -### Deprecated - ### Removed + - Primary modules dependencies on UI - ### Fixed + - Version conflicts - - -### Security - diff --git a/README.md b/README.md index eeeaab9e..b75dcb55 100644 --- a/README.md +++ b/README.md @@ -61,157 +61,96 @@ To learn more about DataForge, please consult the following URLs: ## Modules contained in this repository -
-* ### [cern-root-loader](cern-root-loader) -> +### [cern-root-loader](cern-root-loader) > > **Maturity**: EXPERIMENTAL -
-* ### [demo](demo) -> +### [demo](demo) > > **Maturity**: EXPERIMENTAL -
-* ### [jupyter](jupyter) -> +### [visionforge-compose-html](visionforge-compose-html) > > **Maturity**: EXPERIMENTAL -
-* ### [ui](ui) -> +### [visionforge-compose-multiplatform](visionforge-compose-multiplatform) > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-core](visionforge-core) -> +### [visionforge-core](visionforge-core) > > **Maturity**: DEVELOPMENT -
-* ### [visionforge-fx](visionforge-fx) -> -> -> **Maturity**: PROTOTYPE -
- -* ### [visionforge-gdml](visionforge-gdml) -> +### [visionforge-gdml](visionforge-gdml) > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-markdown](visionforge-markdown) -> +### [visionforge-jupyter](visionforge-jupyter) +> Common visionforge jupyter module > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-plotly](visionforge-plotly) -> +### [visionforge-markdown](visionforge-markdown) > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-server](visionforge-server) -> +### [visionforge-plotly](visionforge-plotly) > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-solid](visionforge-solid) -> +### [visionforge-server](visionforge-server) +> +> **Maturity**: EXPERIMENTAL + +### [visionforge-solid](visionforge-solid) > > **Maturity**: DEVELOPMENT -
-* ### [visionforge-tables](visionforge-tables) -> +### [visionforge-tables](visionforge-tables) > > **Maturity**: PROTOTYPE -
-* ### [visionforge-threejs](visionforge-threejs) -> +### [visionforge-threejs](visionforge-threejs) > > **Maturity**: EXPERIMENTAL -
-* ### [gdml](demo/gdml) -> +### [demo/compose-desktop-demo](demo/compose-desktop-demo) > > **Maturity**: EXPERIMENTAL -
-* ### [js-playground](demo/js-playground) -> +### [demo/gdml](demo/gdml) > > **Maturity**: EXPERIMENTAL -
-* ### [muon-monitor](demo/muon-monitor) -> +### [demo/js-playground](demo/js-playground) > > **Maturity**: EXPERIMENTAL -
-* ### [playground](demo/playground) -> +### [demo/muon-monitor](demo/muon-monitor) > > **Maturity**: EXPERIMENTAL -
-* ### [plotly-fx](demo/plotly-fx) -> +### [demo/playground](demo/playground) > > **Maturity**: EXPERIMENTAL -
-* ### [sat-demo](demo/sat-demo) -> +### [demo/sat-demo](demo/sat-demo) > > **Maturity**: EXPERIMENTAL -
-* ### [solid-showcase](demo/solid-showcase) -> +### [demo/solid-showcase](demo/solid-showcase) > > **Maturity**: EXPERIMENTAL -
-* ### [visionforge-jupyter-gdml](jupyter/visionforge-jupyter-gdml) -> +### [visionforge-jupyter/visionforge-jupyter-common](visionforge-jupyter/visionforge-jupyter-common) +> Jupyter api artifact including all common modules > > **Maturity**: EXPERIMENTAL -
-* ### [bootstrap](ui/bootstrap) -> +### [visionforge-threejs/visionforge-threejs-server](visionforge-threejs/visionforge-threejs-server) > > **Maturity**: EXPERIMENTAL -
- -* ### [react](ui/react) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [ring](ui/ring) -> -> -> **Maturity**: EXPERIMENTAL -
- -* ### [visionforge-threejs-server](visionforge-threejs/visionforge-threejs-server) -> -> -> **Maturity**: EXPERIMENTAL -
**Class diagram:** @@ -283,6 +222,21 @@ Visualization example for geometry defined as GDML file. ![](docs/images/gdml-demo.png) +## Stability and documentation + +VisionForge is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have the following levels: + +* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version. +* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked + with `@DFExperimental` or other stability warning annotations. +* **DEVELOPMENT**. API breaking generally follows semantic versioning ideology. There could be changes in minor + versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool. +* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases. + +Additionally, one should note that the VisionForge Json format impacts the reproducibility of stored vision fragments. There should not be any breaks of the format between major releases. All problems should be reported. + +The documentation for the project is a work in progress. Please report any issues with missing, vague or wrong information. The contributions into documentation are quite welcome. + ## Thanks and references The original three.js bindings were made by [Lars Ivar Hatledal](https://github.com/markaren), but the project is discontinued right now. diff --git a/build.gradle.kts b/build.gradle.kts index 2da86b96..eb7e4fe4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,18 +1,16 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile import space.kscience.gradle.useApache2Licence import space.kscience.gradle.useSPCTeam plugins { id("space.kscience.gradle.project") -// id("org.jetbrains.kotlinx.kover") version "0.5.0" + id("org.jetbrains.kotlinx.kover") version "0.5.0" } -val dataforgeVersion by extra("0.6.2") -val fxVersion by extra("11") +val dataforgeVersion by extra("0.8.0") allprojects { group = "space.kscience" - version = "0.3.0-dev-16" + version = "0.4.1" } subprojects { @@ -32,11 +30,11 @@ subprojects { } } - tasks.withType{ - kotlinOptions{ - useEsClasses = true - } - } +// tasks.withType{ +// kotlinOptions{ +// useEsClasses = true +// } +// } } ksciencePublish { diff --git a/cern-root-loader/api/cern-root-loader.api b/cern-root-loader/api/cern-root-loader.api index 2788976b..7150af55 100644 --- a/cern-root-loader/api/cern-root-loader.api +++ b/cern-root-loader/api/cern-root-loader.api @@ -1,3 +1,77 @@ +public final class ru/mipt/npm/root/BMN { + public static final field INSTANCE Lru/mipt/npm/root/BMN; + public final fun getJson ()Lkotlinx/serialization/json/Json; + public final fun readEventJson (Ljava/lang/String;)Lru/mipt/npm/root/BmnEventContainer; +} + +public final class ru/mipt/npm/root/BMNKt { + public static final fun toVector (Lru/mipt/npm/root/FairTrackParam;)Lspace/kscience/visionforge/solid/Float32Vector3D; +} + +public final class ru/mipt/npm/root/BmnEventContainer { + public fun (Ljava/util/List;Ljava/util/List;)V + public final fun getBmnGlobalTracks ()Ljava/util/List; + public final fun getCbmTracks ()Ljava/util/List; +} + +public final class ru/mipt/npm/root/BmnGlobalTrack { + public static final field Companion Lru/mipt/npm/root/BmnGlobalTrack$Companion; + public fun (Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;)V + public final fun component1 ()Lru/mipt/npm/root/FairTrackParam; + public final fun component2 ()Lru/mipt/npm/root/FairTrackParam; + public final fun copy (Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;)Lru/mipt/npm/root/BmnGlobalTrack; + public static synthetic fun copy$default (Lru/mipt/npm/root/BmnGlobalTrack;Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;ILjava/lang/Object;)Lru/mipt/npm/root/BmnGlobalTrack; + public fun equals (Ljava/lang/Object;)Z + public final fun getFParamFirst ()Lru/mipt/npm/root/FairTrackParam; + public final fun getFParamLast ()Lru/mipt/npm/root/FairTrackParam; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class ru/mipt/npm/root/BmnGlobalTrack$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lru/mipt/npm/root/BmnGlobalTrack$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/BmnGlobalTrack; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/BmnGlobalTrack;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class ru/mipt/npm/root/BmnGlobalTrack$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class ru/mipt/npm/root/CbmStsTrack { + public static final field Companion Lru/mipt/npm/root/CbmStsTrack$Companion; + public fun (Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;)V + public final fun component1 ()Lru/mipt/npm/root/FairTrackParam; + public final fun component2 ()Lru/mipt/npm/root/FairTrackParam; + public final fun copy (Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;)Lru/mipt/npm/root/CbmStsTrack; + public static synthetic fun copy$default (Lru/mipt/npm/root/CbmStsTrack;Lru/mipt/npm/root/FairTrackParam;Lru/mipt/npm/root/FairTrackParam;ILjava/lang/Object;)Lru/mipt/npm/root/CbmStsTrack; + public fun equals (Ljava/lang/Object;)Z + public final fun getFParamFirst ()Lru/mipt/npm/root/FairTrackParam; + public final fun getFParamLast ()Lru/mipt/npm/root/FairTrackParam; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class ru/mipt/npm/root/CbmStsTrack$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lru/mipt/npm/root/CbmStsTrack$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/CbmStsTrack; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/CbmStsTrack;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class ru/mipt/npm/root/CbmStsTrack$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class ru/mipt/npm/root/DGeoBoolNode : ru/mipt/npm/root/DObject { public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V public final fun getFLeft ()Lru/mipt/npm/root/DGeoShape; @@ -6,6 +80,28 @@ public final class ru/mipt/npm/root/DGeoBoolNode : ru/mipt/npm/root/DObject { public final fun getFRightMat ()Lru/mipt/npm/root/DGeoMatrix; } +public class ru/mipt/npm/root/DGeoCombiTrans : ru/mipt/npm/root/DGeoMatrix { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V + public final fun getFRotation ()Lru/mipt/npm/root/DGeoRotation; + public final fun getFTranslation ()[D +} + +public final class ru/mipt/npm/root/DGeoGenTrans : ru/mipt/npm/root/DGeoCombiTrans { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V + public final fun getFScale ()[D +} + +public final class ru/mipt/npm/root/DGeoHMatrix : ru/mipt/npm/root/DGeoMatrix { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V + public final fun getFRotation ()Lru/mipt/npm/root/DGeoRotation; + public final fun getFScale ()[D + public final fun getFTranslation ()[D +} + +public final class ru/mipt/npm/root/DGeoIdentity : ru/mipt/npm/root/DGeoMatrix { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V +} + public final class ru/mipt/npm/root/DGeoManager : ru/mipt/npm/root/DNamed { public static final field Companion Lru/mipt/npm/root/DGeoManager$Companion; public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V @@ -23,8 +119,8 @@ public final class ru/mipt/npm/root/DGeoMaterial : ru/mipt/npm/root/DNamed { public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V } -public class ru/mipt/npm/root/DGeoMatrix : ru/mipt/npm/root/DNamed { - public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V +public abstract class ru/mipt/npm/root/DGeoMatrix : ru/mipt/npm/root/DNamed { + public synthetic fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;Lkotlin/jvm/internal/DefaultConstructorMarker;)V } public final class ru/mipt/npm/root/DGeoMedium : ru/mipt/npm/root/DNamed { @@ -38,7 +134,12 @@ public final class ru/mipt/npm/root/DGeoNode : ru/mipt/npm/root/DNamed { public final fun getFVolume ()Lru/mipt/npm/root/DGeoVolume; } -public class ru/mipt/npm/root/DGeoScale : ru/mipt/npm/root/DGeoMatrix { +public final class ru/mipt/npm/root/DGeoRotation : ru/mipt/npm/root/DGeoMatrix { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V + public final fun getFRotationMatrix ()[D +} + +public final class ru/mipt/npm/root/DGeoScale : ru/mipt/npm/root/DGeoMatrix { public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V public final fun getFScale ()[D public final fun getX ()D @@ -53,6 +154,11 @@ public final class ru/mipt/npm/root/DGeoShape : ru/mipt/npm/root/DNamed { public final fun getFDZ ()D } +public final class ru/mipt/npm/root/DGeoTranslation : ru/mipt/npm/root/DGeoMatrix { + public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V + public final fun getFTranslation ()[D +} + public final class ru/mipt/npm/root/DGeoVolume : ru/mipt/npm/root/DNamed, space/kscience/dataforge/misc/Named { public fun (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V public final fun getFFillColor ()Ljava/lang/Integer; @@ -94,7 +200,45 @@ public final class ru/mipt/npm/root/DObjectKt { } public final class ru/mipt/npm/root/DRootToSolidKt { - public static final fun toSolid (Lru/mipt/npm/root/DGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun rootGeo (Lspace/kscience/visionforge/MutableVisionContainer;Lru/mipt/npm/root/DGeoManager;Ljava/lang/String;IZ)Lspace/kscience/visionforge/solid/SolidGroup; + public static synthetic fun rootGeo$default (Lspace/kscience/visionforge/MutableVisionContainer;Lru/mipt/npm/root/DGeoManager;Ljava/lang/String;IZILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; +} + +public final class ru/mipt/npm/root/FairTrackParam { + public static final field Companion Lru/mipt/npm/root/FairTrackParam$Companion; + public fun (DDDDDD)V + public final fun component1 ()D + public final fun component2 ()D + public final fun component3 ()D + public final fun component4 ()D + public final fun component5 ()D + public final fun component6 ()D + public final fun copy (DDDDDD)Lru/mipt/npm/root/FairTrackParam; + public static synthetic fun copy$default (Lru/mipt/npm/root/FairTrackParam;DDDDDDILjava/lang/Object;)Lru/mipt/npm/root/FairTrackParam; + public fun equals (Ljava/lang/Object;)Z + public final fun getFQp ()D + public final fun getFTx ()D + public final fun getFTy ()D + public final fun getFX ()D + public final fun getFY ()D + public final fun getFZ ()D + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class ru/mipt/npm/root/FairTrackParam$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lru/mipt/npm/root/FairTrackParam$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/FairTrackParam; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/FairTrackParam;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class ru/mipt/npm/root/FairTrackParam$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class ru/mipt/npm/root/RootColors { @@ -108,7 +252,7 @@ public final class ru/mipt/npm/root/serialization/JsonToRootKt { } public final class ru/mipt/npm/root/serialization/RootToSolidKt { - public static final fun toSolid (Lru/mipt/npm/root/serialization/TGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun rootGeo (Lspace/kscience/visionforge/MutableVisionContainer;Lru/mipt/npm/root/serialization/TGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup; } public class ru/mipt/npm/root/serialization/TGeoBBox : ru/mipt/npm/root/serialization/TGeoShape { @@ -119,12 +263,11 @@ public class ru/mipt/npm/root/serialization/TGeoBBox : ru/mipt/npm/root/serializ public final fun getFDY ()D public final fun getFDZ ()D public final fun getFOrigin ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBBox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoBBox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoBBox$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoBBox$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoBBox; @@ -145,7 +288,7 @@ public abstract class ru/mipt/npm/root/serialization/TGeoBoolNode : ru/mipt/npm/ public final fun getFLeftMat ()Lru/mipt/npm/root/serialization/TGeoMatrix; public abstract fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; public final fun getFRightMat ()Lru/mipt/npm/root/serialization/TGeoMatrix; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoBoolNode$Companion { @@ -154,17 +297,14 @@ public final class ru/mipt/npm/root/serialization/TGeoBoolNode$Companion { public final class ru/mipt/npm/root/serialization/TGeoCombiTrans : ru/mipt/npm/root/serialization/TGeoMatrix { public static final field Companion Lru/mipt/npm/root/serialization/TGeoCombiTrans$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun ([DLru/mipt/npm/root/serialization/TGeoRotation;)V public synthetic fun ([DLru/mipt/npm/root/serialization/TGeoRotation;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFRotation ()Lru/mipt/npm/root/serialization/TGeoRotation; public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCombiTrans;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCombiTrans; @@ -180,15 +320,12 @@ public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$Companion { public final class ru/mipt/npm/root/serialization/TGeoCompositeShape : ru/mipt/npm/root/serialization/TGeoBBox { public static final field Companion Lru/mipt/npm/root/serialization/TGeoCompositeShape$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lru/mipt/npm/root/serialization/TGeoBoolNode;)V public final fun getFNode ()Lru/mipt/npm/root/serialization/TGeoBoolNode; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCompositeShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCompositeShape; @@ -204,17 +341,14 @@ public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$Companion { public final class ru/mipt/npm/root/serialization/TGeoHMatrix : ru/mipt/npm/root/serialization/TGeoMatrix { public static final field Companion Lru/mipt/npm/root/serialization/TGeoHMatrix$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun ([D[D[D)V public final fun getFRotationMatrix ()[D public final fun getFScale ()[D public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoHMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoHMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoHMatrix$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoHMatrix; @@ -231,13 +365,10 @@ public final class ru/mipt/npm/root/serialization/TGeoHMatrix$Companion { public final class ru/mipt/npm/root/serialization/TGeoIdentity : ru/mipt/npm/root/serialization/TGeoMatrix { public static final field Companion Lru/mipt/npm/root/serialization/TGeoIdentity$Companion; public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIdentity;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoIdentity$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIdentity$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIdentity; @@ -253,16 +384,13 @@ public final class ru/mipt/npm/root/serialization/TGeoIdentity$Companion { public final class ru/mipt/npm/root/serialization/TGeoIntersection : ru/mipt/npm/root/serialization/TGeoBoolNode { public static final field Companion Lru/mipt/npm/root/serialization/TGeoIntersection$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIntersection;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoIntersection$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIntersection$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIntersection; @@ -279,17 +407,14 @@ public final class ru/mipt/npm/root/serialization/TGeoIntersection$Companion { public final class ru/mipt/npm/root/serialization/TGeoManager : ru/mipt/npm/root/serialization/TNamed { public static final field Companion Lru/mipt/npm/root/serialization/TGeoManager$Companion; public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFMatrices ()Lru/mipt/npm/root/serialization/TObjArray; public final fun getFNodes ()Lru/mipt/npm/root/serialization/TObjArray; public final fun getFShapes ()Lru/mipt/npm/root/serialization/TObjArray; public final fun getFVolumes ()Lru/mipt/npm/root/serialization/TObjArray; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoManager;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoManager$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoManager$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoManager; @@ -307,12 +432,11 @@ public class ru/mipt/npm/root/serialization/TGeoMaterial : ru/mipt/npm/root/seri public static final field Companion Lru/mipt/npm/root/serialization/TGeoMaterial$Companion; public fun ()V public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMaterial;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoMaterial;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoMaterial$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMaterial$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMaterial; @@ -329,7 +453,7 @@ public final class ru/mipt/npm/root/serialization/TGeoMaterial$Companion { public abstract class ru/mipt/npm/root/serialization/TGeoMatrix : ru/mipt/npm/root/serialization/TNamed { public static final field Companion Lru/mipt/npm/root/serialization/TGeoMatrix$Companion; public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoMatrix$Companion { @@ -338,17 +462,14 @@ public final class ru/mipt/npm/root/serialization/TGeoMatrix$Companion { public final class ru/mipt/npm/root/serialization/TGeoMedium : ru/mipt/npm/root/serialization/TNamed { public static final field Companion Lru/mipt/npm/root/serialization/TGeoMedium$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;ILru/mipt/npm/root/serialization/TGeoMaterial;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (ILru/mipt/npm/root/serialization/TGeoMaterial;[D)V public final fun getFId ()I public final fun getFMaterial ()Lru/mipt/npm/root/serialization/TGeoMaterial; public final fun getFParams ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMedium;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoMedium$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMedium$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMedium; @@ -365,13 +486,10 @@ public final class ru/mipt/npm/root/serialization/TGeoMedium$Companion { public final class ru/mipt/npm/root/serialization/TGeoMixture : ru/mipt/npm/root/serialization/TGeoMaterial { public static final field Companion Lru/mipt/npm/root/serialization/TGeoMixture$Companion; public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMixture;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoMixture$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMixture$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMixture; @@ -394,12 +512,11 @@ public class ru/mipt/npm/root/serialization/TGeoNode : ru/mipt/npm/root/serializ public final fun getFNumber ()I public final fun getFOverlaps ()[I public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolume; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoNode$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNode$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNode; @@ -416,14 +533,11 @@ public final class ru/mipt/npm/root/serialization/TGeoNode$Companion { public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix : ru/mipt/npm/root/serialization/TGeoNode { public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion; public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[ILru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFMatrix ()Lru/mipt/npm/root/serialization/TGeoMatrix; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeMatrix; @@ -440,14 +554,11 @@ public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion { public final class ru/mipt/npm/root/serialization/TGeoNodeOffset : ru/mipt/npm/root/serialization/TGeoNode { public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeOffset$Companion; public fun ()V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[IDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFOffset ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeOffset;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeOffset; @@ -471,12 +582,11 @@ public class ru/mipt/npm/root/serialization/TGeoPcon : ru/mipt/npm/root/serializ public final fun getFRmax ()[D public final fun getFRmin ()[D public final fun getFZ ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPcon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoPcon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoPcon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPcon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPcon; @@ -495,12 +605,11 @@ public class ru/mipt/npm/root/serialization/TGeoPgon : ru/mipt/npm/root/serializ public fun ()V public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIDD[D[D[DILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFNedges ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPgon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoPgon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoPgon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPgon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPgon; @@ -516,15 +625,12 @@ public final class ru/mipt/npm/root/serialization/TGeoPgon$Companion { public final class ru/mipt/npm/root/serialization/TGeoRotation : ru/mipt/npm/root/serialization/TGeoMatrix { public static final field Companion Lru/mipt/npm/root/serialization/TGeoRotation$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun ([D)V public final fun getFRotationMatrix ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoRotation$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoRotation$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoRotation; @@ -543,7 +649,7 @@ public abstract class ru/mipt/npm/root/serialization/TGeoShape : ru/mipt/npm/roo public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFShapeBits-pVg5ArA ()I public final fun getFShapeId ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoShape$Companion { @@ -552,17 +658,14 @@ public final class ru/mipt/npm/root/serialization/TGeoShape$Companion { public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly : ru/mipt/npm/root/serialization/TGeoBBox { public static final field Companion Lru/mipt/npm/root/serialization/TGeoShapeAssembly$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Z)V public synthetic fun (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFBBoxOK ()Z public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolumeAssembly; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShapeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoShapeAssembly; @@ -583,16 +686,13 @@ public final class ru/mipt/npm/root/serialization/TGeoShapeRef : ru/mipt/npm/roo public final class ru/mipt/npm/root/serialization/TGeoSubtraction : ru/mipt/npm/root/serialization/TGeoBoolNode { public static final field Companion Lru/mipt/npm/root/serialization/TGeoSubtraction$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoSubtraction;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoSubtraction$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoSubtraction$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoSubtraction; @@ -608,15 +708,12 @@ public final class ru/mipt/npm/root/serialization/TGeoSubtraction$Companion { public final class ru/mipt/npm/root/serialization/TGeoTranslation : ru/mipt/npm/root/serialization/TGeoMatrix { public static final field Companion Lru/mipt/npm/root/serialization/TGeoTranslation$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun ([D)V public final fun getFTranslation ()[D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTranslation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoTranslation$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTranslation$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTranslation; @@ -637,12 +734,11 @@ public class ru/mipt/npm/root/serialization/TGeoTube : ru/mipt/npm/root/serializ public final fun getFDz ()D public final fun getFRmax ()D public final fun getFRmin ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTube;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoTube;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoTube$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTube$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTube; @@ -659,7 +755,6 @@ public final class ru/mipt/npm/root/serialization/TGeoTube$Companion { public final class ru/mipt/npm/root/serialization/TGeoTubeSeg : ru/mipt/npm/root/serialization/TGeoTube { public static final field Companion Lru/mipt/npm/root/serialization/TGeoTubeSeg$Companion; public fun (DDDDDDDDD)V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DDDDDDDDDDDDDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFC1 ()D public final fun getFC2 ()D public final fun getFCdfi ()D @@ -669,12 +764,10 @@ public final class ru/mipt/npm/root/serialization/TGeoTubeSeg : ru/mipt/npm/root public final fun getFS1 ()D public final fun getFS2 ()D public final fun getFSm ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTubeSeg;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTubeSeg; @@ -690,16 +783,13 @@ public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$Companion { public final class ru/mipt/npm/root/serialization/TGeoUnion : ru/mipt/npm/root/serialization/TGeoBoolNode { public static final field Companion Lru/mipt/npm/root/serialization/TGeoUnion$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape; public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoUnion;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoUnion$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoUnion$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoUnion; @@ -729,12 +819,11 @@ public class ru/mipt/npm/root/serialization/TGeoVolume : ru/mipt/npm/root/serial public final fun getFNumber ()I public final fun getFRefCount ()I public final fun getFShape ()Lru/mipt/npm/root/serialization/TGeoShape; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolume;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolume;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoVolume$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolume$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolume; @@ -752,12 +841,11 @@ public class ru/mipt/npm/root/serialization/TGeoVolumeAssembly : ru/mipt/npm/roo public static final field Companion Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$Companion; public fun ()V public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILjava/lang/Integer;Lkotlin/UInt;Ljava/lang/Integer;Ljava/lang/Integer;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoMedium;IIILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolumeAssembly; @@ -784,7 +872,6 @@ public final class ru/mipt/npm/root/serialization/TGeoVolumeRef : ru/mipt/npm/ro public final class ru/mipt/npm/root/serialization/TGeoXtru : ru/mipt/npm/root/serialization/TGeoBBox { public static final field Companion Lru/mipt/npm/root/serialization/TGeoXtru$Companion; public fun (IID[D[D[D[D[D[D)V - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIID[D[D[D[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFNvert ()I public final fun getFNz ()I public final fun getFScale ()[D @@ -794,12 +881,10 @@ public final class ru/mipt/npm/root/serialization/TGeoXtru : ru/mipt/npm/root/se public final fun getFY0 ()[D public final fun getFZ ()[D public final fun getFZcurrent ()D - public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoXtru;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TGeoXtru$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoXtru$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoXtru; @@ -815,15 +900,12 @@ public final class ru/mipt/npm/root/serialization/TGeoXtru$Companion { public final class ru/mipt/npm/root/serialization/THashList : ru/mipt/npm/root/serialization/TObject { public static final field Companion Lru/mipt/npm/root/serialization/THashList$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Ljava/util/List;)V public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/THashList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/THashList$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/THashList$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/THashList; @@ -839,15 +921,12 @@ public final class ru/mipt/npm/root/serialization/THashList$Companion { public final class ru/mipt/npm/root/serialization/TList : ru/mipt/npm/root/serialization/TObject { public static final field Companion Lru/mipt/npm/root/serialization/TList$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Ljava/util/List;)V public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TList$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TList$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TList; @@ -867,12 +946,11 @@ public class ru/mipt/npm/root/serialization/TNamed : ru/mipt/npm/root/serializat public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFName ()Ljava/lang/String; public final fun getFTitle ()Ljava/lang/String; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TNamed;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TNamed;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TNamed$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lru/mipt/npm/root/serialization/TNamed$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TNamed; @@ -888,14 +966,11 @@ public final class ru/mipt/npm/root/serialization/TNamed$Companion { public final class ru/mipt/npm/root/serialization/TObjArray : ru/mipt/npm/root/serialization/TObject { public static final field Companion Lru/mipt/npm/root/serialization/TObjArray$Companion; - public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Ljava/util/List;)V public final fun getArr ()Ljava/util/List; - public static final fun write$Self (Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Lkotlinx/serialization/KSerializer;)V } public final class ru/mipt/npm/root/serialization/TObjArray$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public synthetic fun (Lkotlinx/serialization/KSerializer;)V public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; @@ -917,7 +992,7 @@ public abstract class ru/mipt/npm/root/serialization/TObject { public synthetic fun (ILkotlin/UInt;Lkotlin/UInt;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFBits-pVg5ArA ()I public final fun getFUniqueID-pVg5ArA ()I - public static final fun write$Self (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/root/serialization/TObject$Companion { diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt index 2c501fd7..e6536d6f 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt @@ -1,9 +1,6 @@ package ru.mipt.npm.root -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.double -import space.kscience.dataforge.meta.int -import space.kscience.dataforge.meta.set +import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.parseAsName import space.kscience.dataforge.names.plus @@ -365,7 +362,7 @@ private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? } return if (group.children.isEmpty()) { null - } else if (group.items.size == 1 && group.properties.own == null) { + } else if (group.items.size == 1 && group.properties.own.isEmpty()) { group.items.values.first().apply { parent = null } } else { group diff --git a/demo/compose-desktop-demo/README.md b/demo/compose-desktop-demo/README.md new file mode 100644 index 00000000..591acad6 --- /dev/null +++ b/demo/compose-desktop-demo/README.md @@ -0,0 +1,4 @@ +# Module compose-desktop-demo + + + diff --git a/demo/compose-desktop-demo/api/compose-desktop-demo.api b/demo/compose-desktop-demo/api/compose-desktop-demo.api new file mode 100644 index 00000000..7a968e47 --- /dev/null +++ b/demo/compose-desktop-demo/api/compose-desktop-demo.api @@ -0,0 +1,17 @@ +public final class ComposableSingletons$MainKt { + public static final field INSTANCE LComposableSingletons$MainKt; + public static field lambda-1 Lkotlin/jvm/functions/Function2; + public static field lambda-2 Lkotlin/jvm/functions/Function3; + public static field lambda-3 Lkotlin/jvm/functions/Function3; + public fun ()V + public final fun getLambda-1$compose_desktop_demo ()Lkotlin/jvm/functions/Function2; + public final fun getLambda-2$compose_desktop_demo ()Lkotlin/jvm/functions/Function3; + public final fun getLambda-3$compose_desktop_demo ()Lkotlin/jvm/functions/Function3; +} + +public final class MainKt { + public static final fun App (Landroidx/compose/runtime/Composer;I)V + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + diff --git a/demo/compose-desktop-demo/build.gradle.kts b/demo/compose-desktop-demo/build.gradle.kts new file mode 100644 index 00000000..ff6bc292 --- /dev/null +++ b/demo/compose-desktop-demo/build.gradle.kts @@ -0,0 +1,40 @@ +plugins { + id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) +} + +kscience { + jvm() + useCoroutines() + + commonMain{ + implementation(projects.visionforgeSolid) + } + + jvmMain { + implementation(projects.visionforgeComposeMultiplatform) + } +} + +kotlin{ + explicitApi = null + sourceSets{ + commonMain{ + dependencies { + implementation(compose.desktop.currentOs) + api(compose.preview) + } + } + } +} + + +compose{ + desktop{ + desktop { + application { + mainClass = "MainKt" + } + } + } +} \ No newline at end of file diff --git a/demo/compose-desktop-demo/src/jvmMain/kotlin/main.kt b/demo/compose-desktop-demo/src/jvmMain/kotlin/main.kt new file mode 100644 index 00000000..c9a1b8d6 --- /dev/null +++ b/demo/compose-desktop-demo/src/jvmMain/kotlin/main.kt @@ -0,0 +1,33 @@ +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import space.kscience.dataforge.meta.set +import space.kscience.visionforge.compose.PropertyEditor +import space.kscience.visionforge.solid.specifications.Canvas3DOptions + +@Composable +@Preview +fun App(){ + val options = remember { + Canvas3DOptions{ + meta["custom.field"] = 32 + } + } + PropertyEditor( + properties = options.meta, + descriptor = Canvas3DOptions.descriptor, + expanded = true + ) +} + + +fun main() = application { + Window(onCloseRequest = ::exitApplication) { + MaterialTheme { + App() + } + } +} diff --git a/demo/gdml/api/gdml.api b/demo/gdml/api/gdml.api index 480385c3..1dba1ad6 100644 --- a/demo/gdml/api/gdml.api +++ b/demo/gdml/api/gdml.api @@ -1,21 +1,3 @@ -public final class space/kscience/visionforge/gdml/demo/GDMLDemoApp : tornadofx/App { - public fun ()V -} - -public final class space/kscience/visionforge/gdml/demo/GDMLView : tornadofx/View { - public static final field Companion Lspace/kscience/visionforge/gdml/demo/GDMLView$Companion; - public fun ()V - public fun getRoot ()Ljavafx/scene/Parent; -} - -public final class space/kscience/visionforge/gdml/demo/GDMLView$Companion { -} - -public final class space/kscience/visionforge/gdml/demo/GdmlFxDemoAppKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - public final class space/kscience/visionforge/gdml/demo/ReadFileKt { public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/io/File;)Lspace/kscience/visionforge/Vision; public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; diff --git a/demo/gdml/build.gradle.kts b/demo/gdml/build.gradle.kts index 4cccf686..48a3298e 100644 --- a/demo/gdml/build.gradle.kts +++ b/demo/gdml/build.gradle.kts @@ -1,19 +1,23 @@ plugins { id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) } group = "demo" kscience { - jvm() +// jvm() js { - useCommonJs() browser { binaries.executable() - commonWebpackConfig { - cssSupport { - enabled.set(false) + commonWebpackConfig{ + cssSupport{ + enabled = true } + scssSupport{ + enabled = true + } + sourceMaps = true } } } @@ -21,14 +25,12 @@ kscience { implementation(projects.visionforgeSolid) implementation(projects.visionforgeGdml) } - jvmMain { -// implementation(project(":visionforge-fx")) - implementation(spclibs.logback.classic) - } +// jvmMain { +//// implementation(project(":visionforge-fx")) +// implementation(spclibs.logback.classic) +// } jsMain { - implementation(projects.ui.ring) implementation(projects.visionforgeThreejs) - implementation(npm("react-file-drop", "3.0.6")) } } @@ -36,30 +38,6 @@ kotlin { explicitApi = null } -//kotlin { -// -// sourceSets { -// commonMain { -// dependencies { -// implementation(project(":visionforge-solid")) -// implementation(project(":visionforge-gdml")) -// } -// } -// jvmMain { -// dependencies { -//// implementation(project(":visionforge-fx")) -// implementation("ch.qos.logback:logback-classic:1.2.11") -// } -// } -// jsMain { -// dependencies { -// implementation(project(":ui:ring")) -// implementation(project(":visionforge-threejs")) -// implementation(npm("react-file-drop", "3.0.6")) -// } -// } -// } -//} //val convertGdmlToJson by tasks.creating(JavaExec::class) { // group = "application" diff --git a/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt b/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt index ba9cb333..6ade4ec8 100644 --- a/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt +++ b/demo/gdml/src/commonTest/kotlin/space/kscience/visionforge/gdml/GDMLVisionTest.kt @@ -34,6 +34,6 @@ class GDMLVisionTest { val child = cubes[Name.of("composite-000","segment-0")] assertNotNull(child) child.properties.setValue(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue()) - assertEquals("red", child.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).string) + assertEquals("red", child.properties[SolidMaterial.MATERIAL_COLOR_KEY].string) } } \ No newline at end of file diff --git a/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt b/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt deleted file mode 100644 index 5116155b..00000000 --- a/demo/gdml/src/jsMain/kotlin/drop/FileDrop.kt +++ /dev/null @@ -1,50 +0,0 @@ -@file:JsModule("react-file-drop") -@file:JsNonModule - -package drop - -import org.w3c.dom.DragEvent -import org.w3c.files.FileList -import react.Component -import react.Props -import react.State - -sealed external class DropEffects { - @JsName("copy") - object Copy : DropEffects - - @JsName("move") - object Move : DropEffects - - @JsName("link") - object Link : DropEffects - - @JsName("none") - object None : DropEffects -} - -external interface FileDropProps : Props { - var className: String? - var targetClassName: String? - var draggingOverFrameClassName: String? - var draggingOverTargetClassName: String? - - // var frame?: Exclude | HTMLDocument; - var onFrameDragEnter: ((event: DragEvent) -> Unit)? - var onFrameDragLeave: ((event: DragEvent) -> Unit)? - var onFrameDrop: ((event: DragEvent) -> Unit)? - - // var onDragOver: ReactDragEventHandler? -// var onDragLeave: ReactDragEventHandler? - var onDrop: ((files: FileList?, event: dynamic) -> Unit)?//event:DragEvent) - var dropEffect: DropEffects? -} - -external interface FileDropState : State { - var draggingOverFrame: Boolean - var draggingOverTarget: Boolean -} - -external class FileDrop : Component { - override fun render(): dynamic -} \ No newline at end of file diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/FileDrop.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/FileDrop.kt new file mode 100644 index 00000000..3fdedb64 --- /dev/null +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/FileDrop.kt @@ -0,0 +1,86 @@ +@file:OptIn(ExperimentalComposeWebApi::class) + +package space.kscience.visionforge.gdml.demo + +import androidx.compose.runtime.* +import app.softwork.bootstrapcompose.Container +import app.softwork.bootstrapcompose.Icon +import org.jetbrains.compose.web.ExperimentalComposeWebApi +import org.jetbrains.compose.web.attributes.InputType +import org.jetbrains.compose.web.attributes.name +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.Input +import org.jetbrains.compose.web.dom.Text +import org.w3c.files.FileList + + +//https://codepen.io/zahedkamal87/pen/PobNNwE +@Composable +fun FileDrop( + title: String = "Drop files or Click here to select files to upload.", + onFileDrop: (FileList) -> Unit, +) { + var dragOver by remember { mutableStateOf(false) } + + Container(attrs = { + id("dropzone") + style { + border( + width = 0.2.cssRem, + style = LineStyle.Dashed, + color = Color("#6583fe") + ) + padding(2.cssRem) + borderRadius(0.25.cssRem) + backgroundColor(Color("#fff")) + textAlign("center") + fontSize(1.5.cssRem) + transitions { + all { + delay(0.25.s) + timingFunction(AnimationTimingFunction.EaseInOut) + properties("background-color") + } + } + cursor("pointer") + } + listOf("drag", "dragstart", "dragend", "dragenter").forEach { + addEventListener(it) { event -> + event.preventDefault() + event.stopPropagation() + } + } + onDragOver { event -> + event.preventDefault() + event.stopPropagation() + dragOver = true + } + onDragLeave { event -> + event.preventDefault() + event.stopPropagation() + dragOver = false + } + onDrop { event -> + event.preventDefault() + event.stopPropagation() + dragOver = false + event.dataTransfer?.files?.let { + onFileDrop(it) + } + } + }) { + Icon("cloud-upload"){ classes("dropzone-icon") } + Text(title) + Input(type = InputType.File, attrs = { + style { + display(DisplayStyle.None) + } + classes("dropzone-input") + name("files") + }) + } +} +// +//dropzone.addEventListener("click", function(e) { +// dropzone_input.click(); +//}); \ No newline at end of file diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt index 37c178f4..56c408e6 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt @@ -1,46 +1,35 @@ package space.kscience.visionforge.gdml.demo +import androidx.compose.runtime.* import kotlinx.browser.window -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.Deferred -import kotlinx.css.* +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.Div +import org.jetbrains.compose.web.dom.P +import org.jetbrains.compose.web.dom.Text import org.w3c.files.File import org.w3c.files.FileReader import org.w3c.files.get -import react.Props -import react.dom.h2 -import react.fc -import react.useState +import space.kscience.dataforge.context.Context import space.kscience.dataforge.names.Name import space.kscience.gdml.Gdml import space.kscience.gdml.decodeFromString import space.kscience.visionforge.Colors import space.kscience.visionforge.gdml.markLayers import space.kscience.visionforge.gdml.toVision -import space.kscience.visionforge.ring.ThreeCanvasWithControls -import space.kscience.visionforge.ring.tab import space.kscience.visionforge.setAsRoot import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.Solids import space.kscience.visionforge.solid.ambientLight import space.kscience.visionforge.solid.invoke -import styled.css -import styled.styledDiv +import space.kscience.visionforge.solid.three.compose.ThreeView +import space.kscience.visionforge.visionManager -external interface GDMLAppProps : Props { - var solids: Solids - var vision: Solid? - var selected: Name? -} -@JsExport -val GDMLApp = fc("GDMLApp") { props -> - var deferredVision: Deferred by useState { - CompletableDeferred(props.vision) - } +@Composable +fun GDMLApp(context: Context, initialVision: Solid?, selected: Name? = null) { + var vision: Solid? by remember { mutableStateOf(initialVision) } - fun readFileAsync(file: File): Deferred { - val deferred = CompletableDeferred() + fun readFileAsync(file: File) { + val visionManager = context.visionManager FileReader().apply { onload = { val data = result as String @@ -49,7 +38,7 @@ val GDMLApp = fc("GDMLApp") { props -> name.endsWith(".gdml") || name.endsWith(".xml") -> { val gdml = Gdml.decodeFromString(data) gdml.toVision().apply { - setAsRoot(props.solids.visionManager) + setAsRoot(visionManager) console.info("Marking layers for file $name") markLayers() ambientLight { @@ -57,43 +46,38 @@ val GDMLApp = fc("GDMLApp") { props -> } } } - name.endsWith(".json") -> props.solids.visionManager.decodeFromString(data) + + name.endsWith(".json") -> visionManager.decodeFromString(data) else -> { window.alert("File extension is not recognized: $name") error("File extension is not recognized: $name") } } - deferred.complete(parsedVision as? Solid ?: error("Parsed vision is not a solid")) + vision = parsedVision as? Solid ?: error("Parsed vision is not a solid") + Unit } readAsText(file) } - - return deferred } - styledDiv { - css { - height = 100.vh - 12.pt - width = 100.vw + Div({ + style { + height(100.vh - 12.pt) + width(100.vw) } - child(ThreeCanvasWithControls) { - attrs { - this.solids = props.solids - this.builderOfSolid = deferredVision - this.selected = props.selected - tab("Load") { - h2 { - +"Drag and drop .gdml or .json VisionForge files here" - } - fileDrop("(drag file here)") { files -> - val file = files?.get(0) - if (file != null) { - deferredVision = readFileAsync(file) - } + }) { + ThreeView(context, vision, selected) { + Tab("Load") { + P { + Text("Drag and drop .gdml or .json VisionForge files here") + } + FileDrop("(drag file here)") { files -> + val file = files[0] + if (file != null) { + readFileAsync(file) } } } - } } } diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt index 7c6514bf..3f4d775c 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt @@ -1,63 +1,57 @@ package space.kscience.visionforge.gdml.demo -import kotlinx.css.* +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.Style +import org.jetbrains.compose.web.renderComposable import org.w3c.dom.Document import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request import space.kscience.gdml.GdmlShowCase -import space.kscience.visionforge.Application import space.kscience.visionforge.Colors import space.kscience.visionforge.gdml.toVision -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render -import space.kscience.visionforge.solid.Solids +import space.kscience.visionforge.html.Application +import space.kscience.visionforge.html.VisionForgeStyles +import space.kscience.visionforge.html.startApplication import space.kscience.visionforge.solid.ambientLight import space.kscience.visionforge.solid.invoke import space.kscience.visionforge.solid.three.ThreePlugin -import space.kscience.visionforge.startApplication -import styled.injectGlobal private class GDMLDemoApp : Application { + val context = Context("gdml-demo") { + plugin(ThreePlugin) + } + override fun start(document: Document, state: Map) { - val context = Context("gdml-demo"){ - plugin(ThreePlugin) - } - - injectGlobal { - html{ - height = 100.pct - } - - body{ - height = 100.pct - display = Display.flex - alignItems = Align.stretch - } - - "#application"{ - width = 100.pct - display = Display.flex - alignItems = Align.stretch - } - } val element = document.getElementById("application") ?: error("Element with id 'application' not found on page") - createRoot(element).render { - child(GDMLApp) { - val vision = GdmlShowCase.cubes().toVision().apply { - ambientLight { - color(Colors.white) - } + val vision = GdmlShowCase.cubes().toVision().apply { + ambientLight { + color(Colors.white) + } + } + + renderComposable(element) { + Style(VisionForgeStyles) + Style { + "html" { + height(100.percent) } - //println(context.plugins.fetch(VisionManager).encodeToString(vision)) - attrs { - this.solids = context.request(Solids) - this.vision = vision + + "body" { + height(100.percent) + display(DisplayStyle.Flex) + alignItems(AlignItems.Stretch) + } + + "#application" { + width(100.percent) + display(DisplayStyle.Flex) + alignItems(AlignItems.Stretch) } } + GDMLApp(context, vision) } } } diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/fileDrop.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/fileDrop.kt deleted file mode 100644 index 2478c3af..00000000 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/fileDrop.kt +++ /dev/null @@ -1,30 +0,0 @@ -package space.kscience.visionforge.gdml.demo - -import drop.FileDrop -import kotlinx.css.* -import org.w3c.files.FileList -import react.RBuilder -import styled.css -import styled.styledDiv - -//TODO move styles to inline - -fun RBuilder.fileDrop(title: String, action: (files: FileList?) -> Unit) { - styledDiv { - css { - border = Border(style = BorderStyle.dashed, width = 1.px, color = Color.orange) - flexGrow = 0.0 - alignContent = Align.center - } - - child(FileDrop::class) { - attrs { - onDrop = { files, _ -> - console.info("loaded $files") - action(files) - } - } - +title - } - } -} \ No newline at end of file diff --git a/demo/gdml/webpack.config.d/01.ring.js b/demo/gdml/webpack.config.d/01.ring.js deleted file mode 100644 index 41da041c..00000000 --- a/demo/gdml/webpack.config.d/01.ring.js +++ /dev/null @@ -1,3 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/demo/js-playground/build.gradle.kts b/demo/js-playground/build.gradle.kts index eca736e4..86067e7a 100644 --- a/demo/js-playground/build.gradle.kts +++ b/demo/js-playground/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) } kscience { @@ -9,27 +10,26 @@ kscience { kotlin { explicitApi = null js { - useCommonJs() browser { binaries.executable() - commonWebpackConfig { - cssSupport { - enabled.set(false) + commonWebpackConfig{ + cssSupport{ + enabled = true } + scssSupport{ + enabled = true + } + sourceMaps = true } } } } kscience { - dependencies { implementation(projects.visionforge.visionforgeGdml) implementation(projects.visionforge.visionforgePlotly) implementation(projects.visionforge.visionforgeMarkdown) implementation(projects.visionforge.visionforgeThreejs) } - jsMain { - implementation(projects.ui.ring) - } } \ No newline at end of file diff --git a/demo/js-playground/src/jsMain/kotlin/JsPlaygroundApp.kt b/demo/js-playground/src/jsMain/kotlin/JsPlaygroundApp.kt index dd0d0b26..b544b17a 100644 --- a/demo/js-playground/src/jsMain/kotlin/JsPlaygroundApp.kt +++ b/demo/js-playground/src/jsMain/kotlin/JsPlaygroundApp.kt @@ -1,24 +1,20 @@ -import kotlinx.css.* +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.Div +import org.jetbrains.compose.web.renderComposable import org.w3c.dom.Document -import ringui.SmartTabs -import ringui.Tab import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request import space.kscience.plotly.models.Trace import space.kscience.plotly.scatter -import space.kscience.visionforge.Application import space.kscience.visionforge.Colors -import space.kscience.visionforge.JsVisionClient +import space.kscience.visionforge.html.Application +import space.kscience.visionforge.html.Tabs +import space.kscience.visionforge.html.VisionForgeStyles +import space.kscience.visionforge.html.startApplication +import space.kscience.visionforge.markup.MarkupPlugin import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render -import space.kscience.visionforge.ring.ThreeCanvasWithControls -import space.kscience.visionforge.ring.ThreeWithControlsPlugin -import space.kscience.visionforge.ring.solid import space.kscience.visionforge.solid.* -import space.kscience.visionforge.startApplication -import styled.css -import styled.styledDiv +import space.kscience.visionforge.solid.three.ThreePlugin +import space.kscience.visionforge.solid.three.compose.ThreeView import kotlin.random.Random fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number? = null, yErr: Number? = null) { @@ -30,31 +26,32 @@ fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number? private class JsPlaygroundApp : Application { + val playgroundContext = Context { + plugin(ThreePlugin) + plugin(PlotlyPlugin) + plugin(MarkupPlugin) + } + override fun start(document: Document, state: Map) { - val playgroundContext = Context { - plugin(ThreeWithControlsPlugin) - plugin(JsVisionClient) - plugin(PlotlyPlugin) - } +// val solids = playgroundContext.request(Solids) +// val client = playgroundContext.request(JsVisionClient) val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page") - createRoot(element).render { - styledDiv { - css { - padding = Padding(0.pt) - margin = Margin(0.pt) - height = 100.vh - width = 100.vw + renderComposable(element) { + Style(VisionForgeStyles) + Div({ + style { + padding(0.pt) + margin(0.pt) + height(100.vh) + width(100.vw) } - SmartTabs("gravity") { + }) { + Tabs("gravity") { Tab("gravity") { - GravityDemo { - attrs { - this.solids = playgroundContext.request(Solids) - } - } + GravityDemo(playgroundContext) } // Tab("D0") { @@ -66,43 +63,34 @@ private class JsPlaygroundApp : Application { // } // } Tab("spheres") { - styledDiv { - css { - height = 100.vh - 50.pt + Div({ + style { + height(100.vh - 50.pt) } - child(ThreeCanvasWithControls) { - val random = Random(112233) - attrs { - solids = playgroundContext.request(Solids) - solid { - ambientLight { - color(Colors.white) - } - repeat(100) { - sphere(5, name = "sphere[$it]") { - x = random.nextDouble(-300.0, 300.0) - y = random.nextDouble(-300.0, 300.0) - z = random.nextDouble(-300.0, 300.0) - material { - color(random.nextInt()) - } - detail = 16 - } + }) { + ThreeView(playgroundContext, SolidGroup { + ambientLight { + color(Colors.white) + } + repeat(100) { + sphere(5, name = "sphere[$it]") { + x = Random.nextDouble(-300.0, 300.0) + y = Random.nextDouble(-300.0, 300.0) + z = Random.nextDouble(-300.0, 300.0) + material { + color(Random.nextInt()) } + detail = 16 } } - } + }) } } Tab("plotly") { - Plotly { - attrs { - plot = space.kscience.plotly.Plotly.plot { - scatter { - x(1, 2, 3) - y(5, 8, 7) - } - } + Plot(playgroundContext) { + scatter { + x(1, 2, 3) + y(5, 8, 7) } } } @@ -110,6 +98,7 @@ private class JsPlaygroundApp : Application { } } } + } public fun main() { diff --git a/demo/js-playground/src/jsMain/kotlin/gravityDemo.kt b/demo/js-playground/src/jsMain/kotlin/gravityDemo.kt index a4bc9057..9a5089fa 100644 --- a/demo/js-playground/src/jsMain/kotlin/gravityDemo.kt +++ b/demo/js-playground/src/jsMain/kotlin/gravityDemo.kt @@ -1,110 +1,163 @@ +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import app.softwork.bootstrapcompose.Column +import app.softwork.bootstrapcompose.Row import kotlinx.coroutines.delay import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch -import kotlinx.css.* -import react.Props -import react.fc +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.AttrBuilderContext +import org.jetbrains.compose.web.dom.Div +import org.w3c.dom.HTMLDivElement +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.meta.Meta +import space.kscience.plotly.Plot import space.kscience.plotly.layout import space.kscience.plotly.models.Trace import space.kscience.visionforge.Colors +import space.kscience.visionforge.html.Vision +import space.kscience.visionforge.html.zIndex import space.kscience.visionforge.markup.VisionOfMarkup -import space.kscience.visionforge.react.flexRow -import space.kscience.visionforge.ring.ThreeCanvasWithControls -import space.kscience.visionforge.ring.solid +import space.kscience.visionforge.plotly.asVision import space.kscience.visionforge.solid.* -import styled.css -import styled.styledDiv +import space.kscience.visionforge.solid.three.compose.ThreeView import kotlin.math.sqrt -external interface DemoProps : Props { - var solids: Solids -} +@Composable +fun Plot( + context: Context, + meta: Meta = Meta.EMPTY, + attrs: AttrBuilderContext? = null, + block: Plot.() -> Unit, +) = Vision( + context = context, + attrs = attrs, + meta = meta, + vision = Plot().apply(block).asVision() +) -val GravityDemo = fc { props -> - val velocityTrace = Trace { - name = "velocity" - } - val energyTrace = Trace { - name = "energy" - } - val markup = VisionOfMarkup() +@Composable +fun Markup( + context: Context, + markup: VisionOfMarkup, + meta: Meta = Meta.EMPTY, + attrs: AttrBuilderContext? = null, +) = Vision( + context = context, + attrs = attrs, + meta = meta, + vision = markup +) - styledDiv { - css { - height = 100.vh - 50.pt + +private val h = 100.0 + +@Composable +fun GravityDemo(context: Context) { + val velocityTrace = remember { + Trace { + name = "velocity" } - styledDiv { - css { - height = 50.vh + } + + val energyTrace = remember { + Trace { + name = "energy" + } + } + + val markup = remember { VisionOfMarkup() } + + val solid = remember { + SolidGroup { + pointLight(200, 200, 200, name = "light") { + color(Colors.white) } - child(ThreeCanvasWithControls) { - attrs { - solids = props.solids - solid { - pointLight(200, 200, 200, name = "light"){ - color(Colors.white) - } - ambientLight() + ambientLight() - sphere(5.0, "ball") { - detail = 16 - color("red") - val h = 100.0 - y = h - solids.context.launch { - val g = 10.0 - val dt = 0.1 - var time = 0.0 - var velocity = 0.0 - while (isActive) { - delay(20) - time += dt - velocity -= g * dt - val energy = g * y.toDouble() + velocity * velocity / 2 - y = y.toDouble() + velocity * dt + sphere(5.0, "ball") { + detail = 16 + color("red") + y = h - velocityTrace.appendXYLatest(time, y) - energyTrace.appendXYLatest(time, energy) - if (y.toDouble() <= 2.5) { - //conservation of energy - velocity = sqrt(2 * g * h) - } + box(200, 5, 200, name = "floor") { + y = -2.5 + } + } + } + } - markup.content = """ - ## Bouncing sphere parameters - - **velocity** = $velocity - - **energy** = $energy - """.trimIndent() - } - } - } + LaunchedEffect(solid) { + val ball = solid["ball"]!! + val g = 10.0 + val dt = 0.1 + var time = 0.0 + var velocity = 0.0 + while (isActive) { + delay(20) + time += dt + velocity -= g * dt + val energy = g * ball.y.toDouble() + velocity * velocity / 2 + ball.y = ball.y.toDouble() + velocity * dt - box(200, 5, 200, name = "floor") { - y = -2.5 - } + velocityTrace.appendXYLatest(time, ball.y) + energyTrace.appendXYLatest(time, energy) + + if (ball.y.toDouble() <= 2.5) { + //conservation of energy + velocity = sqrt(2 * g * h) + } + + markup.content = """ + ## Bouncing sphere parameters + + **velocity** = $velocity + + **energy** = $energy + """.trimIndent() + } + } + + Div({ + style { + height(100.vh - 50.pt) + } + }) { + Div({ + style { + height(50.vh) + } + }) { + ThreeView(context, solid) + } + Row(attrs = { + style { + alignContent(AlignContent.Stretch) + alignItems(AlignItems.Stretch) + height(50.vh - 50.pt) + } + }) { + Column { + Plot(context) { + traces(velocityTrace, energyTrace) + layout { + xaxis.title = "time" } } } - } - flexRow { - css { - alignContent = Align.stretch - alignItems = Align.stretch - height = 50.vh - 50.pt - } - plotly { - traces(velocityTrace, energyTrace) - layout { - xaxis.title = "time" - } - } - Markup { - attrs { - this.markup = markup - } + Column { + Markup(context, markup, attrs = { + style { + width(100.percent) + height(100.percent) + border(2.pt, LineStyle.Solid, Color.blue) + paddingLeft(8.pt) + backgroundColor(Color.white) + flex(1) + zIndex(10000) + } + }) } } } diff --git a/demo/js-playground/src/jsMain/kotlin/markupComponent.kt b/demo/js-playground/src/jsMain/kotlin/markupComponent.kt deleted file mode 100644 index a47c28cf..00000000 --- a/demo/js-playground/src/jsMain/kotlin/markupComponent.kt +++ /dev/null @@ -1,55 +0,0 @@ -import kotlinx.css.* -import kotlinx.dom.clear -import kotlinx.html.dom.append -import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor -import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor -import org.w3c.dom.Element -import org.w3c.dom.HTMLElement -import react.Props -import react.fc -import react.useEffect -import react.useRef -import space.kscience.visionforge.markup.VisionOfMarkup -import space.kscience.visionforge.markup.markdown -import space.kscience.visionforge.useProperty -import styled.css -import styled.styledDiv - -external interface MarkupProps : Props { - var markup: VisionOfMarkup? -} - -val Markup = fc("Markup") { props -> - val elementRef = useRef(null) - - useEffect(props.markup, elementRef) { - val element = elementRef.current as? HTMLElement ?: error("Markup element not found") - props.markup?.let { vision -> - val flavour = when (vision.format) { - VisionOfMarkup.COMMONMARK_FORMAT -> CommonMarkFlavourDescriptor() - VisionOfMarkup.GFM_FORMAT -> GFMFlavourDescriptor() - //TODO add new formats via plugins - else -> error("Format ${vision.format} not recognized") - } - vision.useProperty(VisionOfMarkup::content) { content: String? -> - element.clear() - element.append { - markdown(flavour) { content ?: "" } - } - } - } - } - - styledDiv { - css { - width = 100.pct - height = 100.pct - border= Border(2.pt, BorderStyle.solid, Color.blue) - padding = Padding(left = 8.pt) - backgroundColor = Color.white - flex = Flex(1.0) - zIndex = 10000 - } - ref = elementRef - } -} \ No newline at end of file diff --git a/demo/js-playground/src/jsMain/kotlin/plotlyComponent.kt b/demo/js-playground/src/jsMain/kotlin/plotlyComponent.kt deleted file mode 100644 index 80417dde..00000000 --- a/demo/js-playground/src/jsMain/kotlin/plotlyComponent.kt +++ /dev/null @@ -1,43 +0,0 @@ -import kotlinx.css.* -import org.w3c.dom.Element -import org.w3c.dom.HTMLElement -import react.* -import space.kscience.plotly.Plot -import space.kscience.plotly.PlotlyConfig -import space.kscience.plotly.plot -import styled.css -import styled.styledDiv - -external interface PlotlyProps : Props { - var plot: Plot? -} - - -val Plotly = fc("Plotly") { props -> - val elementRef = useRef(null) - - useEffect(props.plot, elementRef) { - val element = elementRef.current as? HTMLElement ?: error("Plotly element not found") - props.plot?.let { - element.plot(PlotlyConfig { - responsive = true - }, it) - } - } - - styledDiv { - css { - width = 100.pct - height = 100.pct - border = Border(2.pt, BorderStyle.solid, Color.blue) - flex = Flex(1.0) - } - ref = elementRef - } -} - -fun RBuilder.plotly(plotbuilder: Plot.() -> Unit) = Plotly { - attrs { - this.plot = Plot().apply(plotbuilder) - } -} \ No newline at end of file diff --git a/demo/js-playground/webpack.config.d/01.ring.js b/demo/js-playground/webpack.config.d/01.ring.js deleted file mode 100644 index 41da041c..00000000 --- a/demo/js-playground/webpack.config.d/01.ring.js +++ /dev/null @@ -1,3 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/demo/muon-monitor/api/muon-monitor.api b/demo/muon-monitor/api/muon-monitor.api index da3a84ed..24b6218c 100644 --- a/demo/muon-monitor/api/muon-monitor.api +++ b/demo/muon-monitor/api/muon-monitor.api @@ -1,6 +1,6 @@ public final class ru/mipt/npm/muon/monitor/Event { + public static final field $stable I public static final field Companion Lru/mipt/npm/muon/monitor/Event$Companion; - public synthetic fun (IILjava/util/List;Ljava/util/Collection;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (ILjava/util/List;Ljava/util/Collection;)V public final fun component1 ()I public final fun component2 ()Ljava/util/List; @@ -13,12 +13,11 @@ public final class ru/mipt/npm/muon/monitor/Event { public final fun getTrack ()Ljava/util/List; public fun hashCode ()I public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lru/mipt/npm/muon/monitor/Event;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class ru/mipt/npm/muon/monitor/Event$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field $stable I public static final field INSTANCE Lru/mipt/npm/muon/monitor/Event$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/muon/monitor/Event; @@ -33,6 +32,7 @@ public final class ru/mipt/npm/muon/monitor/Event$Companion { } public final class ru/mipt/npm/muon/monitor/Model { + public static final field $stable I public fun (Lspace/kscience/visionforge/VisionManager;)V public final fun displayEvent (Lru/mipt/npm/muon/monitor/Event;)V public final fun encodeToString ()Ljava/lang/String; @@ -40,10 +40,10 @@ public final class ru/mipt/npm/muon/monitor/Model { public final fun getRoot ()Lspace/kscience/visionforge/solid/SolidGroup; public final fun getTracks ()Lspace/kscience/visionforge/solid/SolidGroup; public final fun reset ()V - public final fun setTracks (Lspace/kscience/visionforge/solid/SolidGroup;)V } public final class ru/mipt/npm/muon/monitor/Monitor { + public static final field $stable I public static final field CENTRAL_LAYER_Z F public static final field GEOMETRY_TOLERANCE D public static final field INSTANCE Lru/mipt/npm/muon/monitor/Monitor; @@ -61,9 +61,10 @@ public final class ru/mipt/npm/muon/monitor/ReadResourceKt { } public final class ru/mipt/npm/muon/monitor/SC1 { - public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFF)V - public synthetic fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D; + public static final field $stable I + public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Float32Vector3D;FFF)V + public synthetic fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Float32Vector3D;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getCenter ()Lspace/kscience/visionforge/solid/Float32Vector3D; public final fun getName ()Ljava/lang/String; public final fun getXSize ()F public final fun getYSize ()F @@ -71,8 +72,9 @@ public final class ru/mipt/npm/muon/monitor/SC1 { } public final class ru/mipt/npm/muon/monitor/SC16 { - public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;)V - public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D; + public static final field $stable I + public fun (Ljava/lang/String;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public final fun getCenter ()Lspace/kscience/visionforge/solid/Float32Vector3D; public final fun getName ()Ljava/lang/String; public final fun getPixels ()Ljava/util/Collection; } @@ -80,11 +82,12 @@ public final class ru/mipt/npm/muon/monitor/SC16 { public final class ru/mipt/npm/muon/monitor/server/MMServerKt { public static final fun main ()V public static synthetic fun main ([Ljava/lang/String;)V - public static final fun module (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;)V - public static synthetic fun module$default (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;ILjava/lang/Object;)V + public static final fun module (Lio/ktor/server/application/Application;Lspace/kscience/dataforge/context/Context;)V + public static synthetic fun module$default (Lio/ktor/server/application/Application;Lspace/kscience/dataforge/context/Context;ILjava/lang/Object;)V } public final class ru/mipt/npm/muon/monitor/sim/Cos2TrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { + public static final field $stable I public fun (Lorg/apache/commons/math3/random/RandomGenerator;DFF)V public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;DFFILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; @@ -95,6 +98,7 @@ public final class ru/mipt/npm/muon/monitor/sim/Cos2TrackGenerator : ru/mipt/npm } public final class ru/mipt/npm/muon/monitor/sim/FixedAngleGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { + public static final field $stable I public fun (Lorg/apache/commons/math3/random/RandomGenerator;DDFF)V public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;DDFFILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; @@ -112,8 +116,8 @@ public final class ru/mipt/npm/muon/monitor/sim/LineKt { public static final fun getY (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D public static final fun makeTrack (DDDD)Lorg/apache/commons/math3/geometry/euclidean/threed/Line; public static final fun makeTrack (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lorg/apache/commons/math3/geometry/euclidean/threed/Line; - public static final fun toPoint (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun toPoints (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Ljava/util/List; + public static final fun toKMathVector (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public static final fun toKMathVectors (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Ljava/util/List; } public final class ru/mipt/npm/muon/monitor/sim/MonitorKt { @@ -138,6 +142,7 @@ public abstract interface class ru/mipt/npm/muon/monitor/sim/TrackGenerator { } public final class ru/mipt/npm/muon/monitor/sim/UniformTrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator { + public static final field $stable I public fun (Lorg/apache/commons/math3/random/RandomGenerator;FF)V public synthetic fun (Lorg/apache/commons/math3/random/RandomGenerator;FFILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line; diff --git a/demo/muon-monitor/build.gradle.kts b/demo/muon-monitor/build.gradle.kts index d01b9dc9..3893e40e 100644 --- a/demo/muon-monitor/build.gradle.kts +++ b/demo/muon-monitor/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) application } @@ -14,17 +15,22 @@ kscience { fullStack( "muon-monitor.js", jvmConfig = { withJava() }, - jsConfig = { useCommonJs() } - ) { - commonWebpackConfig { - cssSupport { - enabled.set(false) +// jsConfig = { useCommonJs() }, + browserConfig = { + webpackTask{ + cssSupport{ + enabled = true + } + scssSupport{ + enabled = true + } } } - } + ) commonMain { implementation(projects.visionforgeSolid) + implementation(projects.visionforgeComposeHtml) } jvmMain { implementation("org.apache.commons:commons-math3:3.6.1") @@ -34,13 +40,14 @@ kscience { implementation("ch.qos.logback:logback-classic:1.2.11") } jsMain { - implementation(projects.ui.ring) implementation(projects.visionforgeThreejs) //implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) } } +kotlin{ + explicitApi = null +} -kotlin.explicitApi = null application { mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt") diff --git a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt index 7f7958b9..34b750e9 100644 --- a/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt +++ b/demo/muon-monitor/src/commonMain/kotlin/ru/mipt/npm/muon/monitor/Model.kt @@ -71,7 +71,7 @@ class Model(val manager: VisionManager) { fun reset() { map.values.forEach { - it.properties.setMeta(SolidMaterial.MATERIAL_COLOR_KEY, null) + it.properties[SolidMaterial.MATERIAL_COLOR_KEY] = null } tracks.children.clear() } diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt index 07dc7c7c..63924c42 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt @@ -1,281 +1,113 @@ package ru.mipt.npm.muon.monitor +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.remember +import app.softwork.bootstrapcompose.Button +import app.softwork.bootstrapcompose.ButtonGroup +import app.softwork.bootstrapcompose.Color.Secondary +import app.softwork.bootstrapcompose.Container +import app.softwork.bootstrapcompose.Layout.Width import kotlinx.browser.window -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.await import kotlinx.coroutines.launch -import kotlinx.css.* -import kotlinx.html.js.onClickFunction import kotlinx.serialization.json.Json +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.P +import org.jetbrains.compose.web.dom.Span +import org.jetbrains.compose.web.dom.Text import org.w3c.fetch.RequestInit -import react.Props -import react.dom.attrs -import react.dom.button -import react.dom.p -import react.fc -import react.useMemo -import react.useState +import space.kscience.dataforge.context.Context import space.kscience.dataforge.meta.invoke import space.kscience.dataforge.names.Name import space.kscience.visionforge.Colors -import space.kscience.visionforge.react.flexColumn -import space.kscience.visionforge.react.flexRow -import space.kscience.visionforge.ring.ThreeCanvasWithControls -import space.kscience.visionforge.ring.tab -import space.kscience.visionforge.solid.Solids import space.kscience.visionforge.solid.ambientLight import space.kscience.visionforge.solid.edges import space.kscience.visionforge.solid.invoke import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import styled.css -import styled.styledDiv -import styled.styledSpan +import space.kscience.visionforge.solid.three.compose.ThreeView import kotlin.math.PI -external interface MMAppProps : Props { - var model: Model - var solids: Solids - var selected: Name? -} +@Composable +fun MMApp(context: Context, model: Model, selected: Name? = null) { -@OptIn(DelicateCoroutinesApi::class) -@JsExport -val MMApp = fc("Muon monitor") { props -> - - val mmOptions = useMemo { + val mmOptions = remember { Canvas3DOptions { camera { distance = 2100.0 latitude = PI / 6 azimuth = PI + PI / 6 } - } } - val root = useMemo(props.model) { - props.model.root.apply { + val root = remember(model) { + model.root.apply { edges() - ambientLight{ + ambientLight { color(Colors.white) } } } - var events: Set by useState(emptySet()) + val events = remember { mutableStateListOf() } - styledDiv { - css { - height = 100.vh - 12.pt + Container(fluid = true, + attrs = { + style { + height(100.vh - 12.pt) + } } - child(ThreeCanvasWithControls) { - attrs { - this.solids = props.solids - this.builderOfSolid = CompletableDeferred(root) - this.selected = props.selected - this.options = mmOptions - tab("Events") { - flexColumn { - flexRow { - button { - +"Next" - attrs { - onClickFunction = { - solids.context.launch { - val event = window.fetch( - "http://localhost:8080/event", - RequestInit("GET") - ).then { response -> - if (response.ok) { - response.text() - } else { - error("Failed to get event") - } - }.then { body -> - Json.decodeFromString(Event.serializer(), body) - }.await() - events = events + event - props.model.displayEvent(event) - } + ) { + ThreeView( + context, + solid = root, + initialSelected = selected, + options = mmOptions, + sidebarTabs = { + Tab("Events") { + ButtonGroup({ Layout.width = Width.Full }) { + Button("Next") { + context.launch { + val event = window.fetch( + "http://localhost:8080/event", + RequestInit("GET") + ).then { response -> + if (response.ok) { + response.text() + } else { + error("Failed to get event") } - } - } - button { - +"Clear" - attrs { - onClickFunction = { - events = emptySet() - props.model.reset() - } - } + }.then { body -> + Json.decodeFromString(Event.serializer(), body) + }.await() + events.add(event) + model.displayEvent(event) } } + Button("Clear", color = Secondary) { + events.clear() + model.reset() + } } + events.forEach { event -> - p { - styledSpan { - +event.id.toString() + P { + Span { + Text(event.id.toString()) } - +" : " - styledSpan { - css { - color = Color.blue + Text(" : ") + Span({ + style { + color(Color.blue) } - +event.hits.toString() + }) { + Text(event.hits.toString()) } } } } } - - } + ) } - -// var selected by useState { props.selected } -// -// val onSelect: (Name?) -> Unit = { -// selected = it -// } -// - -// -// gridRow { -// flexColumn { -// css { -// +"col-lg-3" -// +"order-lg-1" -// +"order-2" -// padding(0.px) -// overflowY = Overflow.auto -// height = 100.vh -// } -// //tree -// card("Object tree") { -// css { -// flex(1.0, 1.0, FlexBasis.auto) -// } -// visionTree(root, selected, onSelect) -// } -// } -// flexColumn { -// css { -// +"col-lg-6" -// +"order-lg-2" -// +"order-1" -// height = 100.vh -// } -// h1("mx-auto page-header") { -// +"Muon monitor demo" -// } -// //canvas -// -// child(ThreeCanvasComponent) { -// attrs { -// this.context = props.context -// this.solid = root -// this.selected = selected -// this.options = mmOptions -// } -// } -// } -// flexColumn { -// css { -// +"col-lg-3" -// +"order-3" -// padding(0.px) -// height = 100.vh -// } -// styledDiv { -// css { -// flex(0.0, 1.0, FlexBasis.zero) -// } -// //settings -// card("Canvas configuration") { -// canvasControls(mmOptions, root) -// } -// -// card("Events") { -// button { -// +"Next" -// attrs { -// onClickFunction = { -// GlobalScope.launch { -// val event = props.connection.get("http://localhost:8080/event") -// props.model.displayEvent(event) -// } -// } -// } -// } -// button { -// +"Clear" -// attrs { -// onClickFunction = { -// props.model.reset() -// } -// } -// } -// } -// } -// styledDiv { -// css { -// padding(0.px) -// } -// nav { -// attrs { -// attributes["aria-label"] = "breadcrumb" -// } -// ol("breadcrumb") { -// li("breadcrumb-item") { -// button(classes = "btn btn-link p-0") { -// +"World" -// attrs { -// onClickFunction = { -// selected = Name.EMPTY -// } -// } -// } -// } -// if (selected != null) { -// val tokens = ArrayList(selected?.length ?: 1) -// selected?.tokens?.forEach { token -> -// tokens.add(token) -// val fullName = Name(tokens.toList()) -// li("breadcrumb-item") { -// button(classes = "btn btn-link p-0") { -// +token.toString() -// attrs { -// onClickFunction = { -// console.log("Selected = $fullName") -// selected = fullName -// } -// } -// } -// } -// } -// } -// } -// } -// } -// styledDiv { -// css { -// overflowY = Overflow.auto -// } -// //properties -// card("Properties") { -// selected.let { selected -> -// val selectedObject: Vision? = when { -// selected == null -> null -// selected.isEmpty() -> root -// else -> root[selected] -// } -// if (selectedObject != null) { -// visionPropertyEditor(selectedObject, key = selected) -// } -// } -// } -// } -// } -// -// } } \ No newline at end of file diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt index afc9ce80..bf985b4c 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt @@ -1,15 +1,15 @@ package ru.mipt.npm.muon.monitor +import org.jetbrains.compose.web.css.Style +import org.jetbrains.compose.web.renderComposable import org.w3c.dom.Document import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.request -import space.kscience.visionforge.Application import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.react.createRoot -import space.kscience.visionforge.react.render -import space.kscience.visionforge.solid.Solids +import space.kscience.visionforge.html.Application +import space.kscience.visionforge.html.VisionForgeStyles +import space.kscience.visionforge.html.startApplication import space.kscience.visionforge.solid.three.ThreePlugin -import space.kscience.visionforge.startApplication private class MMDemoApp : Application { @@ -23,14 +23,9 @@ private class MMDemoApp : Application { val model = Model(visionManager) - val element = document.getElementById("app") ?: error("Element with id 'app' not found on page") - createRoot(element).render { - child(MMApp) { - attrs { - this.model = model - this.solids = context.request(Solids) - } - } + renderComposable("app") { + Style(VisionForgeStyles) + MMApp(context, model) } } } diff --git a/demo/muon-monitor/webpack.config.d/01.ring.js b/demo/muon-monitor/webpack.config.d/01.ring.js deleted file mode 100644 index 41da041c..00000000 --- a/demo/muon-monitor/webpack.config.d/01.ring.js +++ /dev/null @@ -1,3 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/demo/playground/api/playground.api b/demo/playground/api/playground.api index 7a050caa..e133494f 100644 --- a/demo/playground/api/playground.api +++ b/demo/playground/api/playground.api @@ -3,6 +3,36 @@ public final class space/kscience/visionforge/examples/AllThingsDemoKt { public static synthetic fun main ([Ljava/lang/String;)V } +public final class space/kscience/visionforge/examples/AntennaKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/examples/AxesKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/examples/BmnDemoKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/examples/ControlVisionKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/examples/DynamicPlotlyVisionKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/examples/ExtrudedKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + public final class space/kscience/visionforge/examples/FormServerKt { public static final fun main ()V public static synthetic fun main ([Ljava/lang/String;)V @@ -28,6 +58,11 @@ public final class space/kscience/visionforge/examples/GenerateSchemaKt { public static synthetic fun main ([Ljava/lang/String;)V } +public final class space/kscience/visionforge/examples/MarkdownVisionKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + public final class space/kscience/visionforge/examples/PlotlyVisionKt { public static final fun main ()V public static synthetic fun main ([Ljava/lang/String;)V @@ -38,17 +73,24 @@ public final class space/kscience/visionforge/examples/RandomSpheresKt { public static synthetic fun main ([Ljava/lang/String;)V } -public final class space/kscience/visionforge/examples/RootParserKt { +public final class space/kscience/visionforge/examples/ServerExtensionsKt { + public static final fun makeVisionFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static synthetic fun makeVisionFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V + public static final fun serve (Ljava/lang/String;ZLspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static synthetic fun serve$default (Ljava/lang/String;ZLspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V +} + +public final class space/kscience/visionforge/examples/ShapesKt { public static final fun main ()V public static synthetic fun main ([Ljava/lang/String;)V } -public final class space/kscience/visionforge/examples/ServerExtensionsKt { - public static final fun makeVisionFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;)V - public static synthetic fun makeVisionFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V +public final class space/kscience/visionforge/examples/SimpleCubeKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V } -public final class space/kscience/visionforge/examples/SimpleCubeKt { +public final class space/kscience/visionforge/examples/SurfaceKt { public static final fun main ()V public static synthetic fun main ([Ljava/lang/String;)V } diff --git a/demo/playground/build.gradle.kts b/demo/playground/build.gradle.kts index c51f6691..71004852 100644 --- a/demo/playground/build.gradle.kts +++ b/demo/playground/build.gradle.kts @@ -14,16 +14,15 @@ repositories { kotlin { js(IR) { - useCommonJs() browser { webpackTask { - mainOutputFileName.set("js/visionforge-playground.js") - } - commonWebpackConfig { - sourceMaps = true cssSupport{ - enabled.set(false) + enabled = true } + scssSupport{ + enabled = true + } + mainOutputFileName.set("js/visionforge-playground.js") } } binaries.executable() @@ -57,7 +56,6 @@ kotlin { val jsMain by getting { dependencies { - implementation(projects.ui.ring) implementation(projects.visionforgeThreejs) compileOnly(npm("webpack-bundle-analyzer","4.5.0")) } diff --git a/demo/playground/notebooks/common-demo.ipynb b/demo/playground/notebooks/common-demo.ipynb index 78797545..caa7306f 100644 --- a/demo/playground/notebooks/common-demo.ipynb +++ b/demo/playground/notebooks/common-demo.ipynb @@ -54,9 +54,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "outputs_hidden": false - }, "tags": [] }, "outputs": [], @@ -83,9 +80,6 @@ "language": "kotlin", "name": "kotlin" }, - "ktnbPluginMetadata": { - "isAddProjectLibrariesToClasspath": false - }, "language_info": { "codemirror_mode": "text/x-kotlin", "file_extension": ".kt", @@ -94,6 +88,9 @@ "nbconvert_exporter": "", "pygments_lexer": "kotlin", "version": "1.8.20" + }, + "ktnbPluginMetadata": { + "projectLibraries": [] } }, "nbformat": 4, diff --git a/demo/playground/notebooks/controls.ipynb b/demo/playground/notebooks/controls.ipynb new file mode 100644 index 00000000..8552a178 --- /dev/null +++ b/demo/playground/notebooks/controls.ipynb @@ -0,0 +1,45 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "USE(JupyterCommonIntegration())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [], + "metadata": { + "collapsed": false + } + } + ], + "metadata": { + "kernelspec": { + "display_name": "Kotlin", + "language": "kotlin", + "name": "kotlin" + }, + "language_info": { + "name": "kotlin", + "version": "1.9.0", + "mimetype": "text/x-kotlin", + "file_extension": ".kt", + "pygments_lexer": "kotlin", + "codemirror_mode": "text/x-kotlin", + "nbconvert_exporter": "" + }, + "ktnbPluginMetadata": { + "projectDependencies": true + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/demo/playground/notebooks/dynamic-demo.ipynb b/demo/playground/notebooks/dynamic-demo.ipynb index ac70b4c2..3fcd31e3 100644 --- a/demo/playground/notebooks/dynamic-demo.ipynb +++ b/demo/playground/notebooks/dynamic-demo.ipynb @@ -25,10 +25,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": false, - "jupyter": { - "outputs_hidden": false - } + "collapsed": false }, "outputs": [], "source": [ @@ -84,7 +81,7 @@ "version": "1.8.0-dev-3517" }, "ktnbPluginMetadata": { - "isAddProjectLibrariesToClasspath": false + "projectLibraries": [] } }, "nbformat": 4, diff --git a/demo/playground/src/jsMain/kotlin/playgroundMain.kt b/demo/playground/src/jsMain/kotlin/playgroundMain.kt index feff4de1..1ae93b7f 100644 --- a/demo/playground/src/jsMain/kotlin/playgroundMain.kt +++ b/demo/playground/src/jsMain/kotlin/playgroundMain.kt @@ -1,14 +1,14 @@ import space.kscience.dataforge.misc.DFExperimental +import space.kscience.visionforge.html.runVisionClient import space.kscience.visionforge.jupyter.VFNotebookClient import space.kscience.visionforge.markup.MarkupPlugin import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.ring.ThreeWithControlsPlugin -import space.kscience.visionforge.runVisionClient +import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.tables.TableVisionJsPlugin @DFExperimental fun main() = runVisionClient { - plugin(ThreeWithControlsPlugin) + plugin(ThreePlugin) plugin(PlotlyPlugin) plugin(MarkupPlugin) plugin(TableVisionJsPlugin) diff --git a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt b/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt index 5b272b72..9227f014 100644 --- a/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt +++ b/demo/playground/src/jvmMain/kotlin/allThingsDemo.kt @@ -2,7 +2,6 @@ package space.kscience.visionforge.examples import kotlinx.html.h2 import space.kscience.dataforge.meta.ValueType -import space.kscience.dataforge.meta.invoke import space.kscience.plotly.layout import space.kscience.plotly.models.ScatterMode import space.kscience.plotly.models.TextPosition @@ -11,9 +10,9 @@ import space.kscience.tables.ColumnHeader import space.kscience.visionforge.html.ResourceLocation import space.kscience.visionforge.markup.markdown import space.kscience.visionforge.plotly.plotly +import space.kscience.visionforge.solid.axes import space.kscience.visionforge.solid.box import space.kscience.visionforge.solid.solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions import space.kscience.visionforge.solid.z import space.kscience.visionforge.tables.columnTable import kotlin.io.path.Path @@ -34,14 +33,8 @@ fun main() = makeVisionFile( h2 { +"3D visualization with Three-js" } vision("3D") { - solid( - Canvas3DOptions { - axes { - size = 200.0 - visible = true - } - } - ) { + solid { + axes(200) box(100, 100, 100, name = "aBox") { z = 50.0 } diff --git a/demo/playground/src/jvmMain/kotlin/controlVision.kt b/demo/playground/src/jvmMain/kotlin/controlVision.kt new file mode 100644 index 00000000..a0383ea2 --- /dev/null +++ b/demo/playground/src/jvmMain/kotlin/controlVision.kt @@ -0,0 +1,71 @@ +package space.kscience.visionforge.examples + +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.html.h2 +import kotlinx.html.p +import space.kscience.visionforge.VisionControlEvent +import space.kscience.visionforge.html.* +import space.kscience.visionforge.onSubmit +import kotlin.time.Duration.Companion.seconds + + +fun main() = serve { + + val events = ArrayDeque(10) + + val html = VisionOfPlainHtml() + + fun pushEvent(event: VisionControlEvent) { + events.addFirst(event) + if (events.size >= 10) { + events.removeLast() + } + html.content { + events.forEach { event -> + p { + text(event.toString()) + } + } + } + } + h2 { +"Control elements" } + + vision { + htmlCheckBox { + checked = true + onValueChange(context) { + pushEvent(this) + } + } + } + + vision { + htmlRangeField(1, 10) { + numberValue = 4 + onValueChange(context) { + pushEvent(this) + } + context.launch { + while (isActive) { + delay(1.seconds) + numberValue = ((numberValue?.toInt() ?: 0) + 1) % 10 + } + } + } + } + + + vision { + button("Click me") { + onSubmit(context) { + pushEvent(this) + } + } + } + + + + vision(html) +} \ No newline at end of file diff --git a/demo/playground/src/jvmMain/kotlin/dynamicPlotlyVision.kt b/demo/playground/src/jvmMain/kotlin/dynamicPlotlyVision.kt new file mode 100644 index 00000000..818e1ccf --- /dev/null +++ b/demo/playground/src/jvmMain/kotlin/dynamicPlotlyVision.kt @@ -0,0 +1,112 @@ +package space.kscience.visionforge.examples + +import io.ktor.server.cio.CIO +import io.ktor.server.engine.embeddedServer +import io.ktor.server.http.content.staticResources +import io.ktor.server.routing.routing +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.html.a +import kotlinx.html.h1 +import space.kscience.dataforge.context.Global +import space.kscience.dataforge.context.request +import space.kscience.plotly.layout +import space.kscience.plotly.models.Trace +import space.kscience.plotly.models.invoke +import space.kscience.visionforge.html.VisionPage +import space.kscience.visionforge.plotly.PlotlyPlugin +import space.kscience.visionforge.plotly.plotly +import space.kscience.visionforge.server.close +import space.kscience.visionforge.server.openInBrowser +import space.kscience.visionforge.server.visionPage +import kotlin.math.PI +import kotlin.math.cos +import kotlin.math.sin + +fun main() { + val plotlyPlugin = Global.request(PlotlyPlugin) + val visionManager = plotlyPlugin.visionManager + + val server = embeddedServer(CIO) { + + routing { + staticResources("/", null) + } + + + val freq = 1.0 / 1000 + val oscillationFreq = 1.0 / 10000 + + val x = (0..100).map { it.toDouble() / 100.0 } + val sinY = x.map { sin(2.0 * PI * it) } + val cosY = x.map { cos(2.0 * PI * it) } + + val sinTrace = Trace(x, sinY) { name = "sin" } + val cosTrace = Trace(x, cosY) { name = "cos" } + + visionPage( + visionManager, + VisionPage.scriptHeader("js/visionforge-playground.js"), + ) { + + h1 { +"This is the plot page" } + a("/other") { +"The other page" } + vision { + + + plotly { + traces(sinTrace, cosTrace) + layout { + title = "Other dynamic plot" + xaxis.title = "x axis name" + yaxis.title = "y axis name" + } + } + } + } + + visionPage( + visionManager, + VisionPage.scriptHeader("js/visionforge-playground.js"), + route = "other" + ) { + h1 { +"This is the other plot page" } + a("/") { +"Back to the main page" } + vision { + plotly { + traces(sinTrace) + layout { + title = "Dynamic plot" + xaxis.title = "x axis name" + yaxis.title = "y axis name" + } + } + } + } + + + //Start pushing updates + launch { + var time: Long = 0 + + while (isActive) { + delay(10) + time += 10 + sinTrace.y.numbers = x.map { sin(2.0 * PI * (it + time.toDouble() * freq)) } + val cosAmp = cos(2.0 * PI * oscillationFreq * time) + cosTrace.y.numbers = x.map { cos(2.0 * PI * (it + time.toDouble() * freq)) * cosAmp } + } + } + + }.start(false) + + + server.openInBrowser() + + while (readlnOrNull() != "exit") { + + } + + server.close() +} diff --git a/demo/playground/src/jvmMain/kotlin/formServer.kt b/demo/playground/src/jvmMain/kotlin/formServer.kt index d832d85a..c0539d0a 100644 --- a/demo/playground/src/jvmMain/kotlin/formServer.kt +++ b/demo/playground/src/jvmMain/kotlin/formServer.kt @@ -10,7 +10,7 @@ import space.kscience.dataforge.context.request import space.kscience.visionforge.VisionManager import space.kscience.visionforge.html.VisionOfHtmlForm import space.kscience.visionforge.html.VisionPage -import space.kscience.visionforge.html.bindForm +import space.kscience.visionforge.html.visionOfForm import space.kscience.visionforge.onPropertyChange import space.kscience.visionforge.server.close import space.kscience.visionforge.server.openInBrowser @@ -36,7 +36,7 @@ fun main() { visionManager, VisionPage.scriptHeader("js/visionforge-playground.js"), ) { - bindForm(form) { + visionOfForm(form) { label { htmlFor = "fname" +"First name:" @@ -67,15 +67,15 @@ fun main() { value = "Submit" } } - println(form.values) vision(form) + println(form.values) } }.start(false) server.openInBrowser() - while (readln() != "exit") { + while (readlnOrNull() != "exit") { } diff --git a/demo/playground/src/jvmMain/kotlin/markdownVision.kt b/demo/playground/src/jvmMain/kotlin/markdownVision.kt new file mode 100644 index 00000000..63edbcb6 --- /dev/null +++ b/demo/playground/src/jvmMain/kotlin/markdownVision.kt @@ -0,0 +1,19 @@ +package space.kscience.visionforge.examples + +import space.kscience.visionforge.html.ResourceLocation +import space.kscience.visionforge.markup.markdown + +fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { + vision { + markdown{ + content = """ + # h1 Heading 8-) + ## h2 Heading + ### h3 Heading + #### h4 Heading + ##### h5 Heading + ###### h6 Heading + """.trimIndent() + } + } +} \ No newline at end of file diff --git a/demo/playground/webpack.config.d/01.ring.js b/demo/playground/webpack.config.d/01.ring.js deleted file mode 100644 index b3cc4770..00000000 --- a/demo/playground/webpack.config.d/01.ring.js +++ /dev/null @@ -1,23 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; -const path = require('path'); - -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file diff --git a/demo/sat-demo/api/sat-demo.api b/demo/sat-demo/api/sat-demo.api index 00e5cedd..2fdc412b 100644 --- a/demo/sat-demo/api/sat-demo.api +++ b/demo/sat-demo/api/sat-demo.api @@ -3,3 +3,8 @@ public final class ru/mipt/npm/sat/SatServerKt { public static synthetic fun main ([Ljava/lang/String;)V } +public final class ru/mipt/npm/sat/StaticKt { + public static final fun main ()V + public static synthetic fun main ([Ljava/lang/String;)V +} + diff --git a/demo/sat-demo/build.gradle.kts b/demo/sat-demo/build.gradle.kts index 5e881b63..9b6f63b9 100644 --- a/demo/sat-demo/build.gradle.kts +++ b/demo/sat-demo/build.gradle.kts @@ -1,5 +1,9 @@ +import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode + + plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") + alias(spclibs.plugins.ktor) application } @@ -8,8 +12,10 @@ kscience { // useSerialization { // json() // } - useKtor() - dependencies{ + jvm{ + withJava() + } + jvmMain{ implementation("io.ktor:ktor-server-cio") implementation(projects.visionforgeThreejs.visionforgeThreejsServer) implementation(spclibs.logback.classic) @@ -18,6 +24,8 @@ kscience { group = "center.sciprog" +kotlin.explicitApi = ExplicitApiMode.Disabled + application { mainClass.set("ru.mipt.npm.sat.SatServerKt") } diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt b/demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/geometry.kt similarity index 100% rename from demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/geometry.kt rename to demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/geometry.kt diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt b/demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/satServer.kt similarity index 88% rename from demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt rename to demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/satServer.kt index 9f2f7e59..af4fbca4 100644 --- a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt +++ b/demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/satServer.kt @@ -14,10 +14,12 @@ import space.kscience.dataforge.meta.Null import space.kscience.dataforge.names.Name import space.kscience.visionforge.Colors import space.kscience.visionforge.html.VisionPage +import space.kscience.visionforge.html.meta import space.kscience.visionforge.server.close import space.kscience.visionforge.server.openInBrowser import space.kscience.visionforge.server.visionPage import space.kscience.visionforge.solid.* +import space.kscience.visionforge.solid.specifications.Canvas3DOptions import space.kscience.visionforge.three.threeJsHeader import kotlin.random.Random @@ -47,7 +49,12 @@ fun main() { ) { div("flex-column") { h1 { +"Satellite detector demo" } - vision { sat } + vision { + meta(Canvas3DOptions { + controls.enabled = false + }) + sat + } } } diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/static.kt b/demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/static.kt similarity index 100% rename from demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/static.kt rename to demo/sat-demo/src/jvmMain/kotlin/ru/mipt/npm/sat/static.kt diff --git a/demo/sat-demo/src/main/resources/css/styles.css b/demo/sat-demo/src/jvmMain/resources/css/styles.css similarity index 100% rename from demo/sat-demo/src/main/resources/css/styles.css rename to demo/sat-demo/src/jvmMain/resources/css/styles.css diff --git a/demo/solid-showcase/api/solid-showcase.api b/demo/solid-showcase/api/solid-showcase.api index 4cc47c7d..8b5b3a52 100644 --- a/demo/solid-showcase/api/solid-showcase.api +++ b/demo/solid-showcase/api/solid-showcase.api @@ -1,20 +1,3 @@ -public final class space/kscience/visionforge/demo/MetaEditorDemo : tornadofx/View { - public fun ()V - public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public synthetic fun getRoot ()Ljavafx/scene/Parent; - public fun getRoot ()Ljavafx/scene/control/SplitPane; -} - -public final class space/kscience/visionforge/demo/MetaEditorDemoApp : tornadofx/App { - public fun ()V -} - -public final class space/kscience/visionforge/demo/MetaEditorDemoKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - public final class space/kscience/visionforge/solid/demo/DemoKt { public static final fun demo (Lspace/kscience/visionforge/solid/demo/VisionLayout;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V public static synthetic fun demo$default (Lspace/kscience/visionforge/solid/demo/VisionLayout;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V @@ -23,25 +6,8 @@ public final class space/kscience/visionforge/solid/demo/DemoKt { public static final fun showcaseCSG (Lspace/kscience/visionforge/solid/demo/VisionLayout;)V } -public final class space/kscience/visionforge/solid/demo/FXDemoApp : tornadofx/App { - public fun ()V - public final fun getView ()Lspace/kscience/visionforge/solid/demo/FXDemoGrid; - public fun start (Ljavafx/stage/Stage;)V -} - -public final class space/kscience/visionforge/solid/demo/FXDemoAppKt { - public static final fun main ()V - public static synthetic fun main ([Ljava/lang/String;)V -} - -public final class space/kscience/visionforge/solid/demo/FXDemoGrid : tornadofx/View, space/kscience/visionforge/solid/demo/VisionLayout { - public fun ()V - public fun getRoot ()Ljavafx/scene/Parent; - public synthetic fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V - public fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/dataforge/meta/Meta;)V -} - public abstract interface class space/kscience/visionforge/solid/demo/VisionLayout { + public abstract fun getSolids ()Lspace/kscience/visionforge/solid/Solids; public abstract fun render (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V public static synthetic fun render$default (Lspace/kscience/visionforge/solid/demo/VisionLayout;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V } diff --git a/demo/solid-showcase/build.gradle.kts b/demo/solid-showcase/build.gradle.kts index 05a02260..f4a9820d 100644 --- a/demo/solid-showcase/build.gradle.kts +++ b/demo/solid-showcase/build.gradle.kts @@ -8,6 +8,16 @@ kscience { jvm() js{ binaries.executable() + browser{ + commonWebpackConfig{ + cssSupport{ + enabled = true + } + scssSupport{ + enabled = true + } + } + } } dependencies { implementation(projects.visionforgeSolid) diff --git a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt index 9e2ecedb..52a524e1 100644 --- a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt +++ b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt @@ -24,6 +24,11 @@ fun VisionLayout.demo(name: String, title: String = name, block: SolidGro block() ambientLight { color(Colors.white) + intensity = 0.5 + } + pointLight(0, 0, 1000) { + color(Colors.white) + intensity = 10.0 } } render(Name.parse(name), vision, meta) @@ -33,10 +38,6 @@ val canvasOptions = Canvas3DOptions { size { minSize = 400 } - axes { - size = 500.0 - visible = true - } camera { distance = 600.0 latitude = PI / 6 @@ -47,6 +48,8 @@ val canvasOptions = Canvas3DOptions { fun VisionLayout.showcase() { demo("shapes", "Basic shapes") { ambientLight() + axes(size = 500.0) + box(100.0, 100.0, 100.0) { z = -110.0 color("teal") @@ -111,7 +114,7 @@ fun VisionLayout.showcase() { GlobalScope.launch(Dispatchers.Main) { while (isActive) { delay(100) - rotate((PI/20).radians,Euclidean3DSpace.yAxis) + rotate((PI / 20).radians, Euclidean3DSpace.yAxis) } } color(Colors.red) @@ -122,13 +125,16 @@ fun VisionLayout.showcase() { demo("extrude", "extruded shape") { extruded { shape { - polygon(8, 50) + polygon(32, 50) } for (i in 0..100) { layer(i * 5, 20 * sin(2 * PI / 100 * i), 20 * cos(2 * PI / 100 * i)) } - color(Colors.teal) - rotationX = -PI / 2 + rotationY = -PI / 2 + material { + type = "lambert" + color(Colors.teal) + } } } @@ -161,7 +167,15 @@ fun VisionLayout.showcase() { } demo("STL", "STL loaded from URL") { - stl("https://ozeki.hu/attachments/116/Menger_sponge_sample.stl") + stl("Menger_sponge_sample.stl") { + scale(100f) + material { + type = "phong" + color("red") + specularColor("blue") + } + } + //stl("https://ozeki.hu/attachments/116/Menger_sponge_sample.stl") } } diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt index 5bdbcefe..5be57d31 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoApp.kt @@ -4,10 +4,10 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import org.w3c.dom.Document -import space.kscience.visionforge.Application +import space.kscience.visionforge.html.Application +import space.kscience.visionforge.html.startApplication import space.kscience.visionforge.solid.x import space.kscience.visionforge.solid.y -import space.kscience.visionforge.startApplication import kotlin.random.Random private class ThreeDemoApp : Application { diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt index 50e7f174..8715f75d 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt @@ -72,7 +72,7 @@ class ThreeDemoGrid(element: Element) : VisionLayout { } } val element = document.getElementById("output-$name") ?: error("Element not found") - three.getOrCreateCanvas(element, canvasOptions) + ThreeCanvas(three, element, canvasOptions) }.render(vision) } } diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt index 701df81b..5787b6b3 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/VariableBox.kt @@ -46,7 +46,7 @@ internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision mesh.scale.z = properties.getValue(VALUE)?.number?.toDouble() ?: 1.0 //add listener to object properties - onPropertyChange { name -> + onPropertyChange(three.context) { name -> when { name == VALUE -> { val value = properties.getValue(VALUE)?.int ?: 0 diff --git a/demo/solid-showcase/src/jsMain/resources/Menger_sponge_sample.stl b/demo/solid-showcase/src/jsMain/resources/Menger_sponge_sample.stl new file mode 100644 index 00000000..dfebb0a3 Binary files /dev/null and b/demo/solid-showcase/src/jsMain/resources/Menger_sponge_sample.stl differ diff --git a/docs/images/event-display-final.png b/docs/images/event-display-final.png new file mode 100644 index 00000000..d492e15b Binary files /dev/null and b/docs/images/event-display-final.png differ diff --git a/docs/images/event-display-selection.png b/docs/images/event-display-selection.png new file mode 100644 index 00000000..cb50a83e Binary files /dev/null and b/docs/images/event-display-selection.png differ diff --git a/docs/tutorials/tutorial-event-display.md b/docs/tutorials/tutorial-event-display.md new file mode 100644 index 00000000..e257178d --- /dev/null +++ b/docs/tutorials/tutorial-event-display.md @@ -0,0 +1,416 @@ +# Event Display Tutorial + +In this tutorial, we will explore properties of Visions and build a simple front-end application. You may find a complete project [here](https://git.sciprog.center/teldufalsari/visionforge-event-display-demo). + +__NOTE:__ You will need Kotlin Multiplatform 1.9.0 or higher to complete this tutorial! + +### Starting the Project + +We will use Idea's default project template for Kotlin Multiplatform. To initialize the project, go to *File -> New -> Project...*, Then choose *Full-Stack Web Application* project template and +*Kotlin Gradle* build system. Then select *Next -> Finish*. You will end up with a project with some sample code. + +To check that everything is working correctly, run *application -> run* Gradle target. You should see a greeting page when you open `http://localhost:8080` in a web browser. + +We will use Kotlin React as our main UI library and Ktor Netty both as a web server. Our event display frontend and server will reside in `jsMain` and `jvmMain` directories respectively. +Before we start, we have to load necessary dependencies: + +* Add SciProgCentre maven repo in `build.gradle.kts` file: +```kotlin +repositories { + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") + + // Add either the line below: + maven("https://repo.kotlin.link") + + // Or this line: + maven("https://maven.sciprog.center/kscience") + +} +``` + +* Add `visionforge-threejs-server` into the list of JS dependencies of your project: +```kotlin +kotlin { + sourceSets { + val jsMain by getting { + dependencies { + implementation("space.kscience:visionforge-threejs-server:0.3.0-dev-14") + } + } + } +} +``` + +Refresh build model in the Idea to make sure the dependencies are successfully resolved. + +__NOTE:__ In previous versions of VisionForge, some imports may be broken. If these dependencies fail to resolve, replace `space.kscience:visionforge-threejs-server:0.3.0-dev-14` with `space.kscience:visionforge-threejs:0.3.0-dev-14`. The resulting bundle will lack a React component used in the tutorial (see "Managing Visions"). You may copy and paste it directly from either [VisionForge](https://git.sciprog.center/kscience/visionforge/src/branch/master/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt) or the [tutorial repo](https://git.sciprog.center/teldufalsari/visionforge-event-display-demo/src/branch/main/src/jsMain/kotlin/canvas/ThreeCanvasComponent.kt), or even come up with a better implementation if your own. + +### Setting up Page Markup + +We need to create a page layout and set up Netty to serve our page to clients. There is nothing special related to VisionForge, so feel free to copy and paste the code below. + +File: `src/jvmMain/.../Server.kt` +```kotlin +// ... imports go here + +fun HTML.index() { + head { + // Compatibility headers + meta { charset = "UTF-8" } + meta { + name = "viewport" + content = "width=device-width, initial-scale=1.0" + } + meta { + httpEquiv = "X-UA-Compatible" + content = "IE=edge" + } + title("VF Demo") + } + // Link to our react script + body { + script(src = "/static/vf-demo.js") {} + } +} + +fun main() { + // Seting up Netty + embeddedServer(Netty, port = 8080, host = "127.0.0.1") { + routing { + get("/") { + call.respondHtml(HttpStatusCode.OK, HTML::index) + } + static("/static") { + resources() + } + } + }.start(wait = true) +} +``` + +File: `src/jsMain/.../Client.kt` +```kotlin + +fun main() { + val container = document.createElement("div") + document.body!!.appendChild(container) + + val eventDisplay = EventDisplay.create {} + createRoot(container).render(eventDisplay) +} +``` + +File: `src/jsMain/.../Display.kt` +```kotlin +// All markup goes here: +val EventDisplay = FC { + // Global CSS rules + Global { + styles { + "html,\n" + + "body" { + height = 100.vh + width = 100.vw + margin = 0.px + } + "body > div" { + height = 100.vh + width = 100.vw + display = Display.flex + flexDirection = FlexDirection.column + justifyContent = JustifyContent.start + alignItems = AlignItems.center + } + "*,\n" + + "*:before,\n" + + "*:after" { + boxSizing = BoxSizing.borderBox + } + } + } + + div { + css { + height = 100.pct + width = 100.pct + display = Display.flex + flexDirection = FlexDirection.column + alignItems = AlignItems.center + } + div { + css { + width = 100.pct + display = Display.flex + flexDirection = FlexDirection.row + alignItems = AlignItems.center + justifyContent = JustifyContent.center + + } + input { + css { + margin = 5.px + padding = 5.px + } + type = InputType.button + value = "Update Events" + } + input { + css { + margin = 5.px + padding = 5.px + } + type = InputType.button + value = "Update Geometry" + } + } + div { + css { + width = 98.pct + height = 1.pct + margin = 5.px + display = Display.flex + flexGrow = number(1.0) + justifyContent = JustifyContent.center + alignItems = AlignItems.center + backgroundColor = Color("#b3b3b3") + } + + } + } +} +``` + +After setting everything up, you should see a gray rectangle with two buttons above it when opening `localhost:8080`. + +### Managing Visions + +We are approaching the main part of the tutorial - the place where we will create a working demo. In particle accelerator experiments, event displays are employed to visualise particle collision events. Essentially, it requires drawing a detector setup and visual interpretation of events: tracks, detector hits etc. Usually, a number of events share a common detector setup (e.g. if these events occured in a single experiment run). It makes sense to update and re-render only event information, while keeping detector geometry constant between updates. + +Visions (namely, the `SolidGroup` class) allow us to create an object tree for our displayed event. `SolidGroup` can hold other Visions as its child nodes, access these nodes by names and update/delete them. We will use this property to update our event display efficiently. + +To display Visions as actual 3D object, we will use `ThreePlugin` that renders Visions using *three.js* library. The plugin allows us to create a Three.js representation of a vision that will observe changes of its correspondent Vision. This way we can update only Visions without diving deep into three.js stuff. Using observable Visions is also efficient: Three.js representations are not generated from scratch after each Vision update but are modified too. + +First, let's simulate data load operations: +* Add state variables to our `EventDisplay` React component. These variables will be treated as data loaded from a remote server. In real life, these may be JSON string with event data: +```kotlin +val EventDisplay = FC { + // ... + + var eventData: kotlin.Float? by useState(null) + var geometryData: kotlin.Float? by useState(null) + + // ... +} +``` +* Write two simple functions that will convert data to a Vision. In this case, we will simply parameters of solids like color of size; in real life, these functions will usually take raw data and convert it into Visions. +```kotlin +fun generateEvents(radius: Float): SolidGroup { + val count = Random.nextInt(10, 20) + return SolidGroup { + repeat(count) { + sphere(radius) { + x = 5.0 * (Random.nextFloat() - 0.5) + y = 2.0 * (Random.nextFloat() - 0.5) + z = 2.0 * (Random.nextFloat() - 0.5) + color(Colors.red) + } + } + } +} + +fun generateGeometry(distance: Float): SolidGroup { + return SolidGroup { + box(10, 3, 3) { + x = 0.0 + y = -distance + z = 0.0 + color(Colors.gray) + } + box(10, 3, 3) { + x = 0.0 + y = distance + z = 0.0 + color(Colors.gray) + } + } +} +``` +* Then, let's create our main Vision and add a static light source: +```kotlin +val EventDisplay = FC { + // ... + + val containedVision: SolidGroup by useState(SolidGroup { + ambientLight { + color(Colors.white) + } + }) + + // ... +} +``` + +* A `Context` object is required to hold plugins like `ThreePlugin`. It is also necessary to make Visions observable: we have to root our main Vision in the context. Declare a global `Context` in the same file with `EventDisplay` component: +```kotlin +val viewContext = Context { + plugin(Solids) + plugin(ThreePlugin) +} + +``` + +* Import `ThreeCanvasComponent` from VisionForge. This is a React component that handles all display work. It creates three.js canvas, attaches it to its own parent element and creates and draws `Object3D` on the canvas. We will attach this component to a +separate React component. Note order for Visions to update their Three.js representations, these Visions need to be rooted in a `Context`. This way Visions will be observed for changes, and any such change will trigger an update of the corresponding Three.js object. +```kotlin +external interface EventViewProps: Props { + var displayedVision: Solid? + var context: Context +} + +val EventView = FC { props -> + ThreeCanvasComponent { + solid = props.displayedVision + context = props.context + } + // Make displayedVision observed: + useEffect(props.displayedVision) { + props.displayedVision?.setAsRoot(props.context.visionManager) + } +} +``` + +__NOTE:__ If you had problems with dependency resolution, `ThreeCanvasComponent` may missing from your import scope. You may find a compatible implementation [here](https://git.sciprog.center/teldufalsari/visionforge-event-display-demo/src/branch/main/src/jsMain/kotlin/canvas/ThreeCanvasComponent.kt). + +* Finally, we need to attach EventView to our main component and connect raw data updates to Vision updates using React hooks: +```kotlin +// ... + +// Names used as keys to access and update Visions +// Refer to DataForge documentation for more details +val EVENTS_NAME = "DEMO_EVENTS".parseAsName(false) +val GEOMETRY_NAME = "DEMO_GEOMETRY".parseAsName(false) + +// ... + +val EventDisplay = FC { + // ... + + useEffect(eventData) { + eventData?.let { + containedVision.setChild(EVENTS_NAME, generateEvents(it)) + } + } + useEffect(geometryData) { + geometryData?.let { + containedVision.setChild(GEOMETRY_NAME, generateGeometry(it)) + } + } + // ... + + div { + // ... + + div { + css { + width = 98.pct + height = 1.pct + flexGrow = number(1.0) + margin = 5.px + display = Display.flex + justifyContent = JustifyContent.center + alignItems = AlignItems.center + } + // Replace the gray rectangle with an EventView: + EventView { + displayedVision = containedVision + context = viewContext + } + } + } +// ... +} +``` + +When we press either of the buttons, corresponding raw data changes. This update triggers `UseEffect` hook, which generates new event or geometry data and replaces the old data in the main Vision. Three.js representation is then updated to match our new Vision, so that changes are visible on the canvas. + +Recompile the project and go on `http://localhost:8080`. See how the displayed scene changes with each click: for example, when you update geometry, only the distance between "magnets" varies, but spheres remain intact. + +### Clearing the Scene + +We can erase children Visions from the scene completely. To do so, we cat pass `null` to the function `setChild` as `child` argument. Add these lines to the hooks that update Visions to remove the corresponding Vision from our diplayed `SolidGroup` when raw data changes to `null`: +```kotlin +useEffect(eventData) { + // ... + + if (eventData == null) { + containedVision.setChild(EVENT_NAME, null) + } +} +useEffect(geometryData) { + // ... + + if (geometryData == null) { + containedVision.setChild(GEOMETRY_NAME, null) + } +} +``` +To test how this works, let's create an erase button that will completely clear the scene: +```kotlin +val EventDisplay = FC { + // ... + + div { + // ... + + input { + css { + margin = 5.px + padding = 5.px + backgroundColor = NamedColor.lightcoral + color = NamedColor.white + } + type = InputType.button + value = "Clear Scene" + onClick = { + geometryData = null + eventData = null + } + } + } + + // ... +} +``` +![Picture of an event display with a red button with a caption "Clear Scene" added to the two previous buttons](../images/event-display-final.png "Scene clearing function") + +### Making Selection Fine-Grained + +You may feel annoyed by how selection works in our demo. That's right, selecting the whole detector or the entire event array is not that useful. This is due to the fact that VisionForge selects object based on names. We used names to distinguish SolidGroups, but in fact not only groups but every single Vision can have a name. But when we were randomly generating Vision, we did not use any names, did we? Right, Vision can be nameless, in which case they are treated as a monolithic object together with their parent. So it should be clear now that when we were selecting a single rectangle, we were in fact selecting the whole pair of rectangles and the other one went lit up as well. + +Fortunately, every `Solid` constructor takes a `name` parameter after essential parameters, so it should be easy to fix it. Go to the generator functions and add the change construction invocations to the following: +```kotlin +fun generateGeometry(distance: Float): SolidGroup { + return SolidGroup { + box(10, 3, 3, "Magnet1") { + // ... + } + box(10, 3, 3, "Magnet2") { + // ... + } + } +} +``` +For the events part, we will use the index in a loop as a name: +```kotlin +fun generateEvents(radius: Float): SolidGroup { + // ... + repeat(count) { + sphere(radius, it.toString()) { + // ... +} +``` + +After you update the build, it should be possible to select only one sphere or rectangle: + +![Picture of an event display with only one sphere between the magnets selected](../images/event-display-selection.png "Selection demonstration") \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e7b89633..b0efb732 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,6 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true kotlin.js.compiler=ir -#kotlin.incremental.js.ir=true org.gradle.parallel=true org.gradle.jvmargs=-Xmx4G diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586a..a5952066 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 31119a06..d8cf13ae 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -40,13 +40,9 @@ dependencyResolutionManagement { } include( -// ":ui", - ":ui:react", - ":ui:ring", -// ":ui:material", - ":ui:bootstrap", -// ":ui:compose", ":visionforge-core", + ":visionforge-compose-html", + ":visionforge-compose-multiplatform", ":visionforge-solid", // ":visionforge-fx", ":visionforge-threejs", @@ -64,6 +60,7 @@ include( ":demo:playground", // ":demo:plotly-fx", ":demo:js-playground", + ":demo:compose-desktop-demo", ":visionforge-jupyter", ":visionforge-jupyter:visionforge-jupyter-common" ) diff --git a/ui/README.md b/ui/README.md deleted file mode 100644 index ec08d176..00000000 --- a/ui/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module ui - - - diff --git a/ui/bootstrap/README.md b/ui/bootstrap/README.md deleted file mode 100644 index 0cc57002..00000000 --- a/ui/bootstrap/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module bootstrap - - - diff --git a/ui/bootstrap/build.gradle.kts b/ui/bootstrap/build.gradle.kts deleted file mode 100644 index f50ae119..00000000 --- a/ui/bootstrap/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -val dataforgeVersion: String by rootProject.extra - -kscience{ - js() - jsMain{ - dependencies { - api(project(":visionforge-solid")) - api(project(":ui:react")) - implementation(npm("file-saver", "2.0.2")) - implementation(npm("bootstrap","4.6.0")) - implementation(npm("jquery","3.5.1")) - implementation(npm("popper.js","1.16.1")) - } - } -} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/bootstrap.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/bootstrap.kt deleted file mode 100644 index c0171cb7..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/bootstrap.kt +++ /dev/null @@ -1,121 +0,0 @@ -package space.kscience.visionforge.bootstrap - -public fun useBootstrap(){ - kotlinext.js.require("bootstrap/dist/css/bootstrap.min.css") - kotlinext.js.require("bootstrap") -} - -//public inline fun TagConsumer.card(title: String, crossinline block: TagConsumer.() -> Unit) { -// div("card w-100") { -// div("card-body") { -// h3(classes = "card-title") { +title } -// block() -// } -// } -//} - -//public typealias SectionsBuilder = MutableList Unit>> -// -//public fun SectionsBuilder.entry(title: String, builder: DIV.() -> Unit) { -// add(title to builder) -//} - - -//public fun TagConsumer.accordion(id: String, elements: List Unit>>) { -// div("container-fluid") { -// div("accordion") { -// this.id = id -// elements.forEachIndexed { index, (title, builder) -> -// val headerID = "${id}-${index}-heading" -// val collapseID = "${id}-${index}-collapse" -// div("card") { -// div("card-header") { -// this.id = headerID -// h5("mb-0") { -// button(classes = "btn btn-link collapsed", type = ButtonType.button) { -// attributes["data-toggle"] = "collapse" -// attributes["data-target"] = "#$collapseID" -// attributes["aria-expanded"] = "false" -// attributes["aria-controls"] = collapseID -// +title -// } -// } -// } -// div("collapse") { -// this.id = collapseID -// attributes["aria-labelledby"] = headerID -// attributes["data-parent"] = "#$id" -// div("card-body", block = builder) -// } -// } -// } -// } -// } -//} - - -//public fun TagConsumer.accordion(id: String, builder: AccordionBuilder.() -> Unit) { -// val list = ArrayList Unit>>().apply(builder) -// accordion(id, list) -//} - -//public fun Element.displayCanvasControls(canvas: ThreeCanvas, block: TagConsumer.() -> Unit = {}) { -// clear() -// append { -// accordion("controls") { -// entry("Settings") { -// div("row") { -// div("col-2") { -// label("checkbox-inline") { -// input(type = InputType.checkBox) { -// checked = canvas.axes.visible -// onChangeFunction = { -// canvas.axes.visible = checked -// } -// } -// +"Axes" -// } -// } -// div("col-1") { -// button { -// +"Export" -// onClickFunction = { -// val json = (canvas.content as? SolidGroup)?.let { group -> -// val visionManager = canvas.context.plugins.fetch(SolidManager).visionManager -// visionManager.encodeToString(group) -// } -// if (json != null) { -// saveData(it, "object.json", "text/json") { -// json -// } -// } -// } -// } -// } -// } -// } -// entry("Layers") { -// div("row") { -// (0..11).forEach { layer -> -// div("col-1") { -// label { +layer.toString() } -// input(type = InputType.checkBox) { -// if (layer == 0) { -// checked = true -// } -// onChangeFunction = { -// if (checked) { -// canvas.camera.layers.enable(layer) -// } else { -// canvas.camera.layers.disable(layer) -// } -// } -// } -// } -// } -// } -// } -// } -// block() -// } -//} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt deleted file mode 100644 index f42235a8..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/outputConfig.kt +++ /dev/null @@ -1,77 +0,0 @@ -package space.kscience.visionforge.bootstrap - -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.css.* -import kotlinx.html.js.onClickFunction -import org.w3c.dom.events.Event -import org.w3c.files.Blob -import org.w3c.files.BlobPropertyBag -import react.FC -import react.Props -import react.RBuilder -import react.dom.attrs -import react.dom.button -import react.fc -import space.kscience.visionforge.Vision -import space.kscience.visionforge.encodeToString -import space.kscience.visionforge.react.flexColumn -import space.kscience.visionforge.react.flexRow -import space.kscience.visionforge.react.propertyEditor -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import styled.css - -private fun saveData(event: Event, fileName: String, mimeType: String = "text/plain", dataBuilder: () -> String) { - event.stopPropagation(); - event.preventDefault(); - - val fileSaver = kotlinext.js.require("file-saver") - val blob = Blob(arrayOf(dataBuilder()), BlobPropertyBag("$mimeType;charset=utf-8")) - fileSaver.saveAs(blob, fileName) -} - -public fun RBuilder.canvasControls(canvasOptions: Canvas3DOptions, vision: Vision?) { - child(CanvasControls) { - attrs { - this.canvasOptions = canvasOptions - this.vision = vision - } - } -} - -public external interface CanvasControlsProps : Props { - public var canvasOptions: Canvas3DOptions - public var vision: Vision? -} - - -public val CanvasControls: FC = fc("CanvasControls") { props -> - flexColumn { - flexRow { - css { - border = Border(1.px, BorderStyle.solid, Color.blue) - padding = Padding(4.px) - } - props.vision?.let { vision -> - button { - +"Export" - attrs { - onClickFunction = { - val json = vision.encodeToString() - saveData(it, "object.json", "text/json") { - json - } - } - } - } - } - } - @OptIn(DelicateCoroutinesApi::class) - propertyEditor( - scope = props.vision?.manager?.context ?: GlobalScope, - properties = props.canvasOptions.meta, - descriptor = Canvas3DOptions.descriptor, - expanded = false - ) - } -} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt deleted file mode 100644 index b37637fe..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/reactBootstrap.kt +++ /dev/null @@ -1,181 +0,0 @@ -package space.kscience.visionforge.bootstrap - -import kotlinx.html.ButtonType -import kotlinx.html.DIV -import kotlinx.html.id -import kotlinx.html.js.onClickFunction -import react.RBuilder -import react.dom.* -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.length -import styled.StyledDOMBuilder -import styled.css -import styled.styledDiv -import styled.styledNav - - -public inline fun RBuilder.card(title: String, crossinline block: StyledDOMBuilder
.() -> Unit): Unit = - styledDiv { - css { - +"card" - +"w-100" - } - styledDiv { - css { - +"card-body" - } - h3(classes = "card-title") { - +title - } - block() - } - } - -public fun RBuilder.accordion( - id: String, - elements: List.() -> Unit>>, -): Unit = styledDiv { - css { - +"accordion" - //+"p-1" - } - attrs { - this.id = id - } - elements.forEachIndexed { index, (title, builder) -> - val headerID = "${id}-${index}-heading" - val collapseID = "${id}-${index}-collapse" - div("card p-0 m-0") { - div("card-header") { - attrs { - this.id = headerID - } - h5("mb-0") { - button(classes = "btn btn-link collapsed", type = ButtonType.button) { - attrs { - attributes["data-toggle"] = "collapse" - attributes["data-target"] = "#$collapseID" - attributes["aria-expanded"] = "false" - attributes["aria-controls"] = collapseID - } - +title - } - } - } - div("collapse") { - attrs { - this.id = collapseID - attributes["aria-labelledby"] = headerID - attributes["data-parent"] = "#$id" - } - styledDiv { - css { - +"card-body" - } - builder() - } - } - } - } -} - - -public fun RBuilder.nameCrumbs(name: Name?, rootTitle: String, link: (Name) -> Unit): Unit = styledNav { - css { - +"p-0" - } - attrs { - attributes["aria-label"] = "breadcrumb" - } - ol("breadcrumb") { - li("breadcrumb-item") { - button(classes = "btn btn-link p-0") { - +rootTitle - attrs { - onClickFunction = { - link(Name.EMPTY) - } - } - } - } - if (name != null) { - val tokens = ArrayList(name.length) - name.tokens.forEach { token -> - tokens.add(token) - val fullName = Name(tokens.toList()) - li("breadcrumb-item") { - button(classes = "btn btn-link p-0") { - +token.toString() - attrs { - onClickFunction = { - console.log("Selected = $fullName") - link(fullName) - } - } - } - } - } - } - } -} - -public typealias RSectionsBuilder = MutableList.() -> Unit>> - -public fun RSectionsBuilder.entry(title: String, builder: StyledDOMBuilder
.() -> Unit) { - add(title to builder) -} - -public fun RBuilder.accordion(id: String, builder: RSectionsBuilder.() -> Unit): Unit { - val list = ArrayList.() -> Unit>>().apply(builder) - accordion(id, list) -} - -public enum class ContainerSize(public val suffix: String) { - DEFAULT(""), - SM("-sm"), - MD("-md"), - LG("-lg"), - XL("-xl"), - FLUID("-fluid") -} - -public inline fun RBuilder.container( - size: ContainerSize = ContainerSize.FLUID, - block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { - css { - classes.add("container${size.suffix}") - } - block() -} - - -public enum class GridMaxSize(public val suffix: String) { - NONE(""), - SM("-sm"), - MD("-md"), - LG("-lg"), - XL("-xl") -} - -public inline fun RBuilder.gridColumn( - weight: Int? = null, - maxSize: GridMaxSize = GridMaxSize.NONE, - block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { - val weightSuffix = weight?.let { "-$it" } ?: "" - css { - classes.add("col${maxSize.suffix}$weightSuffix") - } - block() -} - -public inline fun RBuilder.gridRow( - block: StyledDOMBuilder
.() -> Unit, -): Unit = styledDiv { - css { - classes.add("row") - } - block() -} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt deleted file mode 100644 index 23b5071b..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/tabComponent.kt +++ /dev/null @@ -1,86 +0,0 @@ -package space.kscience.visionforge.bootstrap - -import kotlinx.html.DIV -import kotlinx.html.classes -import kotlinx.html.js.onClickFunction -import react.* -import react.dom.attrs -import react.dom.button -import react.dom.li -import react.dom.ul -import space.kscience.visionforge.react.flexColumn -import styled.StyledDOMBuilder -import styled.styledDiv - -public external interface TabProps : PropsWithChildren { - public var id: String - public var title: String? -} - -@JsExport -public val Tab: FC = fc { props -> - props.children() -} - -public external interface TabPaneProps : PropsWithChildren { - public var activeTab: String? -} - -@JsExport -public val TabPane: FC = fc("TabPane") { props -> - var activeTab: String? by useState(props.activeTab) - - val children: Array?> = Children.map(props.children) { - it.asElementOrNull() - } ?: emptyArray() - - val childrenProps = children.mapNotNull { - it?.props?.unsafeCast() - } - - flexColumn { - ul("nav nav-tabs") { - childrenProps.forEach { cp -> - li("nav-item") { - button(classes = "nav-link") { - +(cp.title ?: cp.id) - attrs { - if (cp.id == activeTab) { - classes = classes + "active" - } - onClickFunction = { - activeTab = cp.id - } - } - } - } - } - } - children.find { (it?.props?.unsafeCast())?.id == activeTab }?.let { - child(it) - } - } -} - -public class TabBuilder(internal val parentBuilder: RBuilder) { - public fun tab(id: String, title: String? = null, builder: StyledDOMBuilder
.() -> Unit) { - parentBuilder.child(Tab) { - attrs { - this.id = id - this.title = title - } - styledDiv { - builder() - } - } - } -} - -public inline fun RBuilder.tabPane(activeTab: String? = null, crossinline builder: TabBuilder.() -> Unit) { - child(TabPane) { - attrs { - this.activeTab = activeTab - } - TabBuilder(this).builder() - } -} diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt deleted file mode 100644 index 0d5578a7..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/threeControls.kt +++ /dev/null @@ -1,80 +0,0 @@ -package space.kscience.visionforge.bootstrap - -import kotlinx.css.* -import react.FC -import react.PropsWithChildren -import react.RBuilder -import react.dom.h2 -import react.fc -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.isEmpty -import space.kscience.visionforge.Vision -import space.kscience.visionforge.react.visionTree -import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import styled.css -import styled.styledDiv - -public external interface ThreeControlsProps : PropsWithChildren { - public var canvasOptions: Canvas3DOptions - public var vision: Vision? - public var selected: Name? - public var onSelect: (Name) -> Unit -} - -@JsExport -public val ThreeControls: FC = fc { props -> - tabPane(if (props.selected != null) "Properties" else null) { - tab("Canvas") { - card("Canvas configuration") { - canvasControls(props.canvasOptions, props.vision) - } - } - tab("Tree") { - css { - border = Border(1.px, BorderStyle.solid, Color.lightGray) - padding = Padding(10.px) - } - h2 { +"Object tree" } - styledDiv { - css { - flex = Flex(1.0, 1.0, FlexBasis.inherit) - } - props.vision?.let { - visionTree(it, props.selected, props.onSelect) - } - } - } - tab("Properties") { - props.selected.let { selected -> - val selectedObject: Vision? = when { - selected == null -> null - selected.isEmpty() -> props.vision - else -> (props.vision as? SolidGroup)?.get(selected) - } - if (selectedObject != null) { - visionPropertyEditor(selectedObject, key = selected) - } - } - } - this.parentBuilder.run { - props.children() - } - } -} - -public fun RBuilder.threeControls( - canvasOptions: Canvas3DOptions, - vision: Vision?, - selected: Name?, - onSelect: (Name) -> Unit = {}, - builder: TabBuilder.() -> Unit = {}, -): Unit = child(ThreeControls) { - attrs { - this.canvasOptions = canvasOptions - this.vision = vision - this.selected = selected - this.onSelect = onSelect - } - TabBuilder(this).builder() -} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt b/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt deleted file mode 100644 index 8e7e1208..00000000 --- a/ui/bootstrap/src/jsMain/kotlin/space/kscience/visionforge/bootstrap/visionPropertyEditor.kt +++ /dev/null @@ -1,71 +0,0 @@ -package space.kscience.visionforge.bootstrap - -import org.w3c.dom.Element -import react.RBuilder -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.isEmpty -import space.kscience.visionforge.Vision -import space.kscience.visionforge.getStyle -import space.kscience.visionforge.react.EditorPropertyState -import space.kscience.visionforge.react.PropertyEditor -import space.kscience.visionforge.react.metaViewer -import space.kscience.visionforge.react.render -import space.kscience.visionforge.root -import space.kscience.visionforge.solid.SolidReference -import space.kscience.visionforge.styles - -public fun RBuilder.visionPropertyEditor( - vision: Vision, - descriptor: MetaDescriptor? = vision.descriptor, - key: Any? = null, -) { - - card("Properties") { - child(PropertyEditor) { - attrs { - this.key = key?.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - this.descriptor = descriptor - this.scope = vision.manager?.context ?: error("Orphan vision could not be observed") - this.getPropertyState = { name -> - val ownMeta = vision.properties.own?.getMeta(name) - if (ownMeta != null && !ownMeta.isEmpty()) { - EditorPropertyState.Defined - } else if (vision.properties.root().getValue(name) != null) { - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } - } - } - } - val styles = if (vision is SolidReference) { - (vision.styles + vision.prototype.styles).distinct() - } else { - vision.styles - } - if (styles.isNotEmpty()) { - card("Styles") { - accordion("styles") { - styles.forEach { styleName -> - val style = vision.getStyle(styleName) - if (style != null) { - entry(styleName) { - metaViewer(style) - } - } - } - } - } - } -} - -public fun Element.visionPropertyEditor( - item: Vision, - descriptor: MetaDescriptor? = item.descriptor, -): Unit = space.kscience.visionforge.react.createRoot(this).render { - visionPropertyEditor(item, descriptor = descriptor) -} \ No newline at end of file diff --git a/ui/bootstrap/src/jsMain/resources/css/custom-bootstrap.css b/ui/bootstrap/src/jsMain/resources/css/custom-bootstrap.css deleted file mode 100644 index ecb7ee5f..00000000 --- a/ui/bootstrap/src/jsMain/resources/css/custom-bootstrap.css +++ /dev/null @@ -1,56 +0,0 @@ -/*full height*/ -html, body { - height: 100%; - width: 100%; -} - -.container-fluid { height: inherit; } - -/* Remove default bullets */ -ul, .tree { - list-style-type: none; -} - -/* Style the caret/arrow */ -.tree-caret { - cursor: pointer; - user-select: none; /* Prevent text selection */ -} - -/* Create the caret/arrow with a unicode, and style it */ -.tree-caret::before { - content: "\25B6"; - color: black; - display: inline-block; - margin-right: 6px; -} - -.tree-leaf{ - user-select: none; - display: inline-block; -} - -.tree-leaf::before { - content: "\25C6"; - color: black; - display: inline-block; - margin-right: 6px; -} - - -/* Rotate the caret/arrow icon when clicked on (using JavaScript) */ -.tree-caret-down::before { - transform: rotate(90deg); -} - -.tree-label-inactive { - color: lightgrey; -} - -.tree-label-selected{ - background-color: lightblue; -} - -.no-padding{ - padding: 0; -} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/Tabs.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/Tabs.kt deleted file mode 100644 index cae4e797..00000000 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/Tabs.kt +++ /dev/null @@ -1,102 +0,0 @@ -package space.kscience.visionforge.compose - -import androidx.compose.runtime.* -import org.jetbrains.compose.web.dom.* -import org.w3c.dom.HTMLDivElement -import org.w3c.dom.HTMLLIElement - - -public class ComposeTab( - public val key: String, - public val title: String, - public val content: ContentBuilder, - public val disabled: Boolean, - public val titleExt: ContentBuilder, -) - -@Composable -public fun Tabs(tabs: List, activeKey: String) { - var active by remember(activeKey) { mutableStateOf(activeKey) } - - Div({ classes("card", "text-center") }) { - Div({ classes("card-header") }) { - - Ul({ classes("nav", "nav-tabs", "card-header-tabs") }) { - tabs.forEach { tab -> - Li({ - classes("nav-item") - }) { - A(attrs = { - classes("nav-link") - if (active == tab.key) { - classes("active") - } - if (tab.disabled) { - classes("disabled") - } - onClick { - active = tab.key - } - }) { - Text(tab.title) - } - tab.titleExt.invoke(this) - } - } - } - } - tabs.find { it.key == active }?.let { tab -> - Div({ classes("card-body") }) { - tab.content.invoke(this) - } - } - } - - -} - -public class TabBuilder internal constructor(public val key: String) { - private var title: String = key - public var disabled: Boolean = false - private var content: ContentBuilder = {} - private var titleExt: ContentBuilder = {} - - @Composable - public fun Content(content: ContentBuilder) { - this.content = content - } - - @Composable - public fun Title(title: String, titleExt: ContentBuilder = {}) { - this.title = title - this.titleExt = titleExt - } - - internal fun build(): ComposeTab = ComposeTab( - key, - title, - content, - disabled, - titleExt - ) -} - -public class TabsBuilder { - public var active: String = "" - internal val tabs: MutableList = mutableListOf() - - @Composable - public fun Tab(key: String, builder: @Composable TabBuilder.() -> Unit) { - tabs.add(TabBuilder(key).apply { builder() }.build()) - } - - public fun addTab(tab: ComposeTab) { - tabs.add(tab) - } -} - -@Composable -public fun Tabs(builder: @Composable TabsBuilder.() -> Unit) { - val result = TabsBuilder().apply { builder() } - Tabs(result.tabs, result.active) -} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeCanvas.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeCanvas.kt deleted file mode 100644 index 9816b5c2..00000000 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeCanvas.kt +++ /dev/null @@ -1,52 +0,0 @@ -package space.kscience.visionforge.compose - -import androidx.compose.runtime.* -import kotlinx.dom.clear -import org.jetbrains.compose.web.css.* -import org.jetbrains.compose.web.dom.Div -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import space.kscience.visionforge.solid.three.ThreeCanvas -import space.kscience.visionforge.solid.three.ThreePlugin - -@Composable -public fun ThreeCanvas( - context: Context, - options: Canvas3DOptions?, - solid: Solid?, - selected: Name?, -) { - - val three: ThreePlugin by derivedStateOf { context.request(ThreePlugin) } - - Div({ - style { - maxWidth(100.vw) - maxHeight(100.vh) - width(100.percent) - height(100.percent) - } - }) { - var canvas: ThreeCanvas? = null - DisposableEffect(options) { - canvas = ThreeCanvas(three, scopeElement, options ?: Canvas3DOptions()) - onDispose { - scopeElement.clear() - canvas = null - } - } - LaunchedEffect(solid) { - if (solid != null) { - canvas?.render(solid) - } else { - canvas?.clear() - } - } - LaunchedEffect(selected) { - canvas?.select(selected) - } - } -} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeControls.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeControls.kt deleted file mode 100644 index c559b946..00000000 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeControls.kt +++ /dev/null @@ -1,80 +0,0 @@ -package space.kscience.visionforge.compose - -import androidx.compose.runtime.Composable -import org.jetbrains.compose.web.css.* -import org.jetbrains.compose.web.dom.Button -import org.jetbrains.compose.web.dom.Text -import org.w3c.files.Blob -import org.w3c.files.BlobPropertyBag -import space.kscience.dataforge.context.Global -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision -import space.kscience.visionforge.encodeToString -import space.kscience.visionforge.solid.specifications.Canvas3DOptions - -@Composable -internal fun CanvasControls( - vision: Vision?, - options: Canvas3DOptions, -) { - FlexColumn { - FlexRow({ - style { - border { - width(1.px) - style(LineStyle.Solid) - color(Color("blue")) - } - padding(4.px) - } - }) { - vision?.let { vision -> - Button({ - onClick { event -> - val json = vision.encodeToString() - event.stopPropagation(); - event.preventDefault(); - - val fileSaver = kotlinext.js.require("file-saver") - val blob = Blob(arrayOf(json), BlobPropertyBag("text/json;charset=utf-8")) - fileSaver.saveAs(blob, "object.json") as Unit - } - }) { - Text("Export") - } - } - } - PropertyEditor( - scope = vision?.manager?.context ?: Global, - properties = options.meta, - descriptor = Canvas3DOptions.descriptor, - expanded = false - ) - - } -} - - -@Composable -public fun ThreeControls( - vision: Vision?, - canvasOptions: Canvas3DOptions, - selected: Name?, - onSelect: (Name?) -> Unit, - tabBuilder: @Composable TabsBuilder.() -> Unit = {}, -) { - Tabs { - active = "Tree" - vision?.let { vision -> - Tab("Tree") { - CardTitle("Vision tree") - VisionTree(vision, Name.EMPTY, selected, onSelect) - } - } - Tab("Settings") { - CardTitle("Canvas configuration") - CanvasControls(vision, canvasOptions) - } - tabBuilder() - } -} diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeViewWithControls.kt b/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeViewWithControls.kt deleted file mode 100644 index 7a347110..00000000 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/ThreeViewWithControls.kt +++ /dev/null @@ -1,169 +0,0 @@ -@file:OptIn(ExperimentalComposeWebApi::class) - -package space.kscience.visionforge.compose - -import androidx.compose.runtime.* -import app.softwork.bootstrapcompose.Card -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.launch -import org.jetbrains.compose.web.ExperimentalComposeWebApi -import org.jetbrains.compose.web.css.* -import org.jetbrains.compose.web.dom.* -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.isEmpty -import space.kscience.visionforge.* -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.specifications.Canvas3DOptions - -@Composable -public fun ThreeCanvasWithControls( - solids: Solids, - builderOfSolid: Deferred, - initialSelected: Name?, - options: Canvas3DOptions?, - tabBuilder: @Composable TabsBuilder.() -> Unit = {}, -) { - var selected: Name? by remember { mutableStateOf(initialSelected) } - var solid: Solid? by remember { mutableStateOf(null) } - - LaunchedEffect(builderOfSolid) { - solids.context.launch { - solid = builderOfSolid.await() - //ensure that the solid is properly rooted - if (solid?.parent == null) { - solid?.setAsRoot(solids.context.visionManager) - } - } - } - - val optionsWithSelector = remember(options) { - (options ?: Canvas3DOptions()).apply { - this.onSelect = { - selected = it - } - } - } - - val selectedVision: Vision? = remember(builderOfSolid, selected) { - selected?.let { - when { - it.isEmpty() -> solid - else -> (solid as? SolidGroup)?.get(it) - } - } - } - - - FlexRow({ - style { - height(100.percent) - width(100.percent) - flexWrap(FlexWrap.Wrap) - alignItems(AlignItems.Stretch) - alignContent(AlignContent.Stretch) - } - }) { - FlexColumn({ - style { - height(100.percent) - minWidth(600.px) - flex(10, 1, 600.px) - position(Position.Relative) - } - }) { - if (solid == null) { - Div({ - style { - position(Position.Fixed) - width(100.percent) - height(100.percent) - zIndex(1000) - top(40.percent) - left(0.px) - opacity(0.5) - filter { - opacity(50.percent) - } - } - }) { - Div({ classes("d-flex", " justify-content-center") }) { - Div({ - classes("spinner-grow", "text-primary") - style { - width(3.cssRem) - height(3.cssRem) - zIndex(20) - } - attr("role", "status") - }) { - Span({ classes("sr-only") }) { Text("Loading 3D vision") } - } - } - } - } else { - ThreeCanvas(solids.context, optionsWithSelector, solid, selected) - } - - selectedVision?.let { vision -> - Div({ - style { - position(Position.Absolute) - top(5.px) - right(5.px) - width(450.px) - } - }) { - Card( - headerAttrs = { - // border = true - }, - header = { - NameCrumbs(selected) { selected = it } - } - ) { - PropertyEditor( - scope = solids.context, - meta = vision.properties.root(), - getPropertyState = { name -> - if (vision.properties.own?.get(name) != null) { - EditorPropertyState.Defined - } else if (vision.properties.root()[name] != null) { - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - }, - updates = vision.properties.changes, - rootDescriptor = vision.descriptor - ) - - } - - vision.styles.takeIf { it.isNotEmpty() }?.let { styles -> - P { - B { Text("Styles: ") } - Text(styles.joinToString(separator = ", ")) - } - } - } - } - } - } - FlexColumn({ - style { - paddingAll(4.px) - minWidth(400.px) - height(100.percent) - overflowY("auto") - flex(1, 10, 300.px) - } - }) { - ThreeControls(solid, optionsWithSelector, selected, onSelect = { selected = it }, tabBuilder = tabBuilder) - } -} - - diff --git a/ui/react/README.md b/ui/react/README.md deleted file mode 100644 index 9f862213..00000000 --- a/ui/react/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module react - - - diff --git a/ui/react/build.gradle.kts b/ui/react/build.gradle.kts deleted file mode 100644 index 1770feeb..00000000 --- a/ui/react/build.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -kscience { - js() - jsMain { - dependencies { - api(projects.visionforgeSolid) - api("org.jetbrains.kotlin-wrappers:kotlin-styled") - api("org.jetbrains.kotlin-wrappers:kotlin-react-dom") -// implementation(npm("react-select","4.3.0")) - api(projects.visionforgeThreejs) - } - } -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MetaViewer.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MetaViewer.kt deleted file mode 100644 index 651c9d31..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MetaViewer.kt +++ /dev/null @@ -1,149 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.Align -import kotlinx.css.alignItems -import kotlinx.html.js.onClickFunction -import org.w3c.dom.events.Event -import react.* -import react.dom.a -import react.dom.attrs -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.isLeaf -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.lastOrNull -import space.kscience.dataforge.names.plus -import styled.css -import styled.styledDiv -import styled.styledSpan - -public external interface MetaViewerProps : Props { - /** - * Root meta - */ - public var root: Meta - - /** - * The title of root node - */ - public var rootName: String? - - /** - * Full path to the displayed node in [root]. Could be empty - */ - public var name: Name - - /** - * Root descriptor - */ - public var descriptor: MetaDescriptor? -} - -private val MetaViewerItem: FC = fc("MetaViewerItem") { props -> - metaViewerItem(props) -} - -private fun RBuilder.metaViewerItem(props: MetaViewerProps) { - var expanded: Boolean by useState { true } - val item = props.root[props.name] - val descriptorItem: MetaDescriptor? = props.descriptor?.get(props.name) - val actualValue = item?.value ?: descriptorItem?.defaultValue - val actualMeta = item ?: descriptorItem?.defaultNode - - val token = props.name.lastOrNull()?.toString() ?: props.rootName ?: "" - - val expanderClick: (Event) -> Unit = { - expanded = !expanded - } - - flexRow { - css { - alignItems = Align.center - } - if (actualMeta?.isLeaf == false) { - styledSpan { - css { - +TreeStyles.treeCaret - if (expanded) { - +TreeStyles.treeCaredDown - } - } - attrs { - onClickFunction = expanderClick - } - } - } - - styledSpan { - css { - +TreeStyles.treeLabel - if (item == null) { - +TreeStyles.treeLabelInactive - } - } - +token - } - styledDiv { - a { - +actualValue.toString() - } - } - } - if (expanded) { - flexColumn { - css { - +TreeStyles.tree - } - val keys = buildSet { - descriptorItem?.children?.keys?.forEach { - add(NameToken(it)) - } - actualMeta!!.items.keys.let { addAll(it) } - } - - keys.filter { !it.body.startsWith("@") }.forEach { token -> - styledDiv { - css { - +TreeStyles.treeItem - } - child(MetaViewerItem) { - attrs { - this.key = props.name.toString() - this.root = props.root - this.name = props.name + token - this.descriptor = props.descriptor - } - } - //configEditor(props.root, props.name + token, props.descriptor, props.default) - } - } - } - } - - -} - -@JsExport -public val MetaViewer: FC = fc("MetaViewer") { props -> - child(MetaViewerItem) { - attrs { - this.key = "" - this.root = props.root - this.name = Name.EMPTY - this.descriptor = props.descriptor - } - } -} - -public fun RBuilder.metaViewer(meta: Meta, descriptor: MetaDescriptor? = null, key: Any? = null) { - child(MetaViewer) { - attrs { - this.key = key?.toString() ?: "" - this.root = meta - this.descriptor = descriptor - } - } -} diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt deleted file mode 100644 index fc635d21..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/MultiSelectChooser.kt +++ /dev/null @@ -1,38 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.html.js.onChangeFunction -import org.w3c.dom.HTMLOptionElement -import org.w3c.dom.HTMLSelectElement -import org.w3c.dom.asList -import org.w3c.dom.events.Event -import react.FC -import react.dom.attrs -import react.dom.option -import react.dom.select -import react.fc -import space.kscience.dataforge.meta.asValue -import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.dataforge.meta.string - -@JsExport -public val MultiSelectChooser: FC = fc("MultiSelectChooser") { props -> - val onChange: (Event) -> Unit = { event: Event -> - val newSelected = (event.target as HTMLSelectElement).selectedOptions.asList() - .map { (it as HTMLOptionElement).value.asValue() } - props.onValueChange(newSelected.asValue()) - } - - select { - attrs { - multiple = true - values = (props.value?.list ?: emptyList()).mapTo(HashSet()) { it.string } - onChangeFunction = onChange - } - props.descriptor?.allowedValues?.forEach { optionValue -> - option { - +optionValue.string - } - } - - } -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt deleted file mode 100644 index 58986076..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/PropertyEditor.kt +++ /dev/null @@ -1,278 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.launch -import kotlinx.css.* -import kotlinx.css.properties.TextDecoration -import kotlinx.html.js.onClickFunction -import org.w3c.dom.events.Event -import react.* -import react.dom.attrs -import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.meta.ObservableMutableMeta -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement -import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.remove -import space.kscience.dataforge.names.* -import space.kscience.visionforge.hidden -import styled.css -import styled.styledButton -import styled.styledDiv -import styled.styledSpan - -/** - * The display state of a property - */ -public sealed class EditorPropertyState { - public object Defined : EditorPropertyState() - public class Default(public val source: String = "unknown") : EditorPropertyState() - - public object Undefined : EditorPropertyState() - -} - - -public external interface PropertyEditorProps : Props { - - /** - * Root config object - always non-null - */ - public var meta: MutableMeta - - public var getPropertyState: (Name) -> EditorPropertyState - - public var scope: CoroutineScope - - public var updates: Flow - - /** - * Full path to the displayed node in [meta]. Could be empty - */ - public var name: Name - - /** - * Root descriptor - */ - public var descriptor: MetaDescriptor? - - /** - * Initial expanded state - */ - public var expanded: Boolean? -} - -private val PropertyEditorItem: FC = fc("PropertyEditorItem") { props -> - propertyEditorItem(props) -} - -private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) { - var expanded: Boolean by useState { props.expanded ?: true } - val descriptor: MetaDescriptor? = useMemo(props.descriptor, props.name) { props.descriptor?.get(props.name) } - var property: MutableMeta by useState { props.meta.getOrCreate(props.name) } - var editorPropertyState: EditorPropertyState by useState { props.getPropertyState(props.name) } - - - val keys = useMemo(descriptor) { - buildSet { - descriptor?.children?.filterNot { - it.key.startsWith("@") || it.value.hidden - }?.forEach { - add(NameToken(it.key)) - } - //ownProperty?.items?.keys?.filterNot { it.body.startsWith("@") }?.let { addAll(it) } - } - } - - val token = props.name.lastOrNull()?.toString() ?: "Properties" - - fun update() { - property = props.meta.getOrCreate(props.name) - editorPropertyState = props.getPropertyState(props.name) - } - - useEffect(props.meta) { - val job = props.updates.onEach { updatedName -> - if (updatedName == props.name) { - update() - } - }.launchIn(props.scope) - - cleanup { - job.cancel() - } - } - - val expanderClick: (Event) -> Unit = { - expanded = !expanded - } - - val removeClick: (Event) -> Unit = { - props.meta.remove(props.name) - update() - } - - - - flexRow { - css { - alignItems = Align.center - } - if (keys.isNotEmpty()) { - styledSpan { - css { - +TreeStyles.treeCaret - if (expanded) { - +TreeStyles.treeCaredDown - } - } - attrs { - onClickFunction = expanderClick - } - } - } - styledSpan { - css { - +TreeStyles.treeLabel - if (editorPropertyState != EditorPropertyState.Defined) { - +TreeStyles.treeLabelInactive - } - } - +token - } - if (!props.name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) { - styledDiv { - css { - //+TreeStyles.resizeableInput - width = 160.px - margin = Margin(1.px, 5.px) - } - ValueChooser { - attrs { - this.descriptor = descriptor - this.state = editorPropertyState - this.value = property.value - this.onValueChange = { - property.value = it - editorPropertyState = props.getPropertyState(props.name) - } - } - } - } - - styledButton { - css { - width = 24.px - alignSelf = Align.stretch - margin = Margin(1.px, 5.px) - backgroundColor = Color.white - borderStyle = BorderStyle.solid - borderRadius = 2.px - textAlign = TextAlign.center - textDecoration = TextDecoration.none - cursor = Cursor.pointer - disabled { - cursor = Cursor.auto - borderStyle = BorderStyle.dashed - color = Color.lightGray - } - } - +"\u00D7" - attrs { - if (editorPropertyState!= EditorPropertyState.Defined) { - disabled = true - } else { - onClickFunction = removeClick - } - } - } - } - } - if (expanded) { - flexColumn { - css { - +TreeStyles.tree - } - keys.forEach { token -> - styledDiv { - css { - +TreeStyles.treeItem - } - child(PropertyEditorItem) { - attrs { - this.key = props.name.toString() - this.meta = props.meta - this.name = props.name + token - this.descriptor = props.descriptor - this.scope = props.scope - this.getPropertyState = { props.getPropertyState(props.name + token) } - this.updates = props.updates - } - } - //configEditor(props.root, props.name + token, props.descriptor, props.default) - } - } - } - } -} - -@JsExport -public val PropertyEditor: FC = fc("PropertyEditor") { props -> - child(PropertyEditorItem) { - attrs { - this.key = "" - this.meta = props.meta - this.name = Name.EMPTY - this.descriptor = props.descriptor - this.expanded = props.expanded - this.scope = props.scope - this.getPropertyState = props.getPropertyState - this.updates = props.updates - } - } -} - -@OptIn(ExperimentalCoroutinesApi::class) -public fun RBuilder.propertyEditor( - scope: CoroutineScope, - properties: ObservableMutableMeta, - descriptor: MetaDescriptor? = null, - key: Any? = null, - expanded: Boolean? = null, -) { - child(PropertyEditor) { - attrs { - this.meta = properties - this.descriptor = descriptor - this.key = key?.toString() ?: "" - this.expanded = expanded - this.scope = scope - this.getPropertyState = { name -> - if (properties[name] != null) { - EditorPropertyState.Defined - } else if (descriptor?.get(name)?.defaultValue != null) { - EditorPropertyState.Default("descriptor") - } else { - EditorPropertyState.Undefined - } - } - this.updates = callbackFlow { - properties.onChange(scope) { name -> - scope.launch { - send(name) - } - } - - invokeOnClose { - properties.removeListener(scope) - } - } - } - } -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt deleted file mode 100644 index 4a82a6e9..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/RangeValueChooser.kt +++ /dev/null @@ -1,78 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.pct -import kotlinx.css.width -import kotlinx.html.InputType -import kotlinx.html.js.onChangeFunction -import kotlinx.html.js.onInputFunction -import org.w3c.dom.HTMLInputElement -import org.w3c.dom.events.Event -import react.FC -import react.dom.attrs -import react.fc -import react.useState -import space.kscience.dataforge.meta.asValue -import space.kscience.dataforge.meta.descriptors.ValueRequirement -import space.kscience.dataforge.meta.double -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.string -import styled.css -import styled.styledInput - -@JsExport -public val RangeValueChooser: FC = fc("RangeValueChooser") { props -> - var innerValue by useState(props.value?.double) - var rangeDisabled: Boolean by useState(props.state != EditorPropertyState.Defined) - - val handleDisable: (Event) -> Unit = { - val checkBoxValue = (it.target as HTMLInputElement).checked - rangeDisabled = !checkBoxValue - props.onValueChange( - if (!checkBoxValue) { - null - } else { - innerValue?.asValue() - } - ) - } - - val handleChange: (Event) -> Unit = { - val newValue = (it.target as HTMLInputElement).value - props.onValueChange(newValue.toDoubleOrNull()?.asValue()) - innerValue = newValue.toDoubleOrNull() - } - - flexRow { - if (props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) { - styledInput(type = InputType.checkBox) { - attrs { - defaultChecked = rangeDisabled.not() - onChangeFunction = handleDisable - } - } - } - - styledInput(type = InputType.range) { - css { - width = 100.pct - } - attrs { - disabled = rangeDisabled - value = innerValue?.toString() ?: "" -// onChangeFunction = handleChange - onInputFunction = handleChange - val minValue = props.descriptor?.attributes?.get("min").string - minValue?.let { - min = it - } - val maxValue = props.descriptor?.attributes?.get("max").string - maxValue?.let { - max = it - } - props.descriptor?.attributes?.get("step").string?.let { - step = it - } - } - } - } -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt deleted file mode 100644 index 8cfa515d..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt +++ /dev/null @@ -1,55 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.* -import org.w3c.dom.Element -import react.* -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.request -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import space.kscience.visionforge.solid.three.ThreeCanvas -import space.kscience.visionforge.solid.three.ThreePlugin -import styled.css -import styled.styledDiv - -public external interface ThreeCanvasProps : Props { - public var context: Context - public var options: Canvas3DOptions? - public var solid: Solid? - public var selected: Name? -} - -public val ThreeCanvasComponent: FC = fc("ThreeCanvasComponent") { props -> - val elementRef = useRef(null) - var canvas by useState(null) - - val three: ThreePlugin = useMemo(props.context) { props.context.request(ThreePlugin) } - - useEffect(props.solid, props.options, elementRef) { - if (canvas == null) { - val element = elementRef.current ?: error("Canvas element not found") - canvas = ThreeCanvas(three, element, props.options ?: Canvas3DOptions()) - } - } - - useEffect(canvas, props.solid) { - props.solid?.let { obj -> - canvas?.render(obj) - } - } - - useEffect(canvas, props.selected) { - canvas?.select(props.selected) - } - - styledDiv { - css { - maxWidth = 100.vw - maxHeight = 100.vh - width = 100.pct - height = 100.pct - } - ref = elementRef - } -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/TreeStyles.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/TreeStyles.kt deleted file mode 100644 index 109d0256..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/TreeStyles.kt +++ /dev/null @@ -1,69 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.* -import kotlinx.css.properties.deg -import kotlinx.css.properties.rotate -import styled.StyleSheet - -public object TreeStyles : StyleSheet("treeStyles", true) { - /** - * Remove default bullets - */ - public val tree: RuleSet by css { - paddingLeft = 5.px - marginLeft = 0.px - listStyleType = ListStyleType.none - } - - /** - * Style the caret/arrow - */ - public val treeCaret: RuleSet by css { - cursor = Cursor.pointer - userSelect = UserSelect.none - /* Create the caret/arrow with a unicode, and style it */ - before { - content = "\u25B6".quoted - color = Color.black - display = Display.inlineBlock - marginRight = 6.px - } - } - - /** - * Rotate the caret/arrow icon when clicked on (using JavaScript) - */ - public val treeCaredDown:RuleSet by css { - before { - content = "\u25B6".quoted - color = Color.black - display = Display.inlineBlock - marginRight = 6.px - transform.rotate(90.deg) - } - } - - public val treeItem:RuleSet by css { - alignItems = Align.center - paddingLeft = 10.px - borderLeftStyle = BorderStyle.dashed - borderLeftWidth = 1.px - borderLeftColor = Color.lightGray - } - - public val treeLabel:RuleSet by css { - border = Border.none - padding = Padding(left = 4.pt, right = 4.pt, top = 0.pt, bottom = 0.pt) - textAlign = TextAlign.left - flex = Flex(1.0) - } - - public val treeLabelInactive: RuleSet by css { - color = Color.lightGray - } - - public val treeLabelSelected:RuleSet by css { - backgroundColor = Color.lightBlue - } - -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/VisionTree.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/VisionTree.kt deleted file mode 100644 index 6212a456..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/VisionTree.kt +++ /dev/null @@ -1,126 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.* -import kotlinx.css.properties.TextDecoration -import kotlinx.css.properties.TextDecorationLine -import kotlinx.html.js.onClickFunction -import org.w3c.dom.events.Event -import react.* -import react.dom.attrs -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.lastOrNull -import space.kscience.dataforge.names.plus -import space.kscience.dataforge.names.startsWith -import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionGroup -import space.kscience.visionforge.asSequence -import space.kscience.visionforge.isEmpty -import styled.css -import styled.styledDiv -import styled.styledSpan - -public external interface ObjectTreeProps : Props { - public var name: Name - public var selected: Name? - public var obj: Vision - public var clickCallback: (Name) -> Unit -} - -private val TreeLabel = fc { props -> - val token = useMemo(props.name) { props.name.lastOrNull()?.toString() ?: "World" } - styledSpan { - css { - +TreeStyles.treeLabel - color = Color("#069") - cursor = Cursor.pointer - hover { - textDecoration = TextDecoration(setOf(TextDecorationLine.underline)) - } - if (props.name == props.selected) { - +TreeStyles.treeLabelSelected - } - } - +token - attrs { - onClickFunction = { props.clickCallback(props.name) } - } - } -} - -private fun RBuilder.visionTree(props: ObjectTreeProps): Unit { - var expanded: Boolean by useState { props.selected?.startsWith(props.name) ?: false } - - val onClick: (Event) -> Unit = { - expanded = !expanded - } - - val obj = props.obj - - //display as node if any child is visible - if (obj is VisionGroup) { - flexRow { - if (obj.children.keys.any { !it.body.startsWith("@") }) { - styledSpan { - css { - +TreeStyles.treeCaret - if (expanded) { - +TreeStyles.treeCaredDown - } - } - attrs { - onClickFunction = onClick - } - } - } - child(TreeLabel, props = props) - } - if (expanded) { - flexColumn { - css { - +TreeStyles.tree - } - obj.children.asSequence() - .filter { !it.first.toString().startsWith("@") } // ignore statics and other hidden children - .sortedBy { (it.second as? VisionGroup)?.children?.isEmpty() ?: true } // ignore empty groups - .forEach { (childToken, child) -> - styledDiv { - css { - +TreeStyles.treeItem - } - child(ObjectTree) { - attrs { - this.name = props.name + childToken - this.obj = child - this.selected = props.selected - this.clickCallback = props.clickCallback - } - } - } - } - } - } - } else { - child(TreeLabel, props = props) - } -} - -@JsExport -public val ObjectTree: FC = fc("ObjectTree") { props -> - visionTree(props) -} - -public fun RBuilder.visionTree( - vision: Vision, - selected: Name? = null, - clickCallback: (Name) -> Unit = {}, -) { - child(ObjectTree) { - attrs { - this.name = Name.EMPTY - this.obj = vision - this.selected = selected - this.clickCallback = clickCallback - } - } -} - diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/createRoot.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/createRoot.kt deleted file mode 100644 index fec86770..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/createRoot.kt +++ /dev/null @@ -1,17 +0,0 @@ - -@file:JsModule("react-dom/client") -@file:JsNonModule - -package space.kscience.visionforge.react - -import org.w3c.dom.Element -import react.dom.client.Root -import react.dom.client.RootOptions - -/** - * Compatibility method to work with old browser API - */ -public external fun createRoot( - container: Element, - options: RootOptions = definedExternally, -): Root diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ext.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ext.kt deleted file mode 100644 index ae47fa65..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/ext.kt +++ /dev/null @@ -1,10 +0,0 @@ -package space.kscience.visionforge.react - -import react.Props -import react.RBuilder -import react.createElement -import react.dom.client.Root - -public fun Root.render(block: RBuilder.() -> Unit) { - render(createElement(block)) -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/layout.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/layout.kt deleted file mode 100644 index 11a13561..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/layout.kt +++ /dev/null @@ -1,31 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.Display -import kotlinx.css.FlexDirection -import kotlinx.css.display -import kotlinx.css.flexDirection -import kotlinx.html.DIV -import react.RBuilder -import styled.StyledDOMBuilder -import styled.css -import styled.styledDiv - -public inline fun RBuilder.flexColumn( - block: StyledDOMBuilder
.() -> Unit -): Unit = styledDiv { - css { - display = Display.flex - flexDirection = FlexDirection.column - } - block() -} - -public inline fun RBuilder.flexRow( - block: StyledDOMBuilder
.() -> Unit -): Unit = styledDiv { - css { - display = Display.flex - flexDirection = FlexDirection.row - } - block() -} \ No newline at end of file diff --git a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/valueChooser.kt b/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/valueChooser.kt deleted file mode 100644 index 5d0c7c3d..00000000 --- a/ui/react/src/jsMain/kotlin/space/kscience/visionforge/react/valueChooser.kt +++ /dev/null @@ -1,175 +0,0 @@ -package space.kscience.visionforge.react - -import kotlinx.css.* -import kotlinx.html.InputType -import kotlinx.html.js.onChangeFunction -import kotlinx.html.js.onKeyDownFunction -import org.w3c.dom.HTMLInputElement -import org.w3c.dom.HTMLSelectElement -import org.w3c.dom.events.Event -import react.FC -import react.Props -import react.dom.attrs -import react.dom.option -import react.fc -import react.useState -import space.kscience.dataforge.meta.* -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.allowedValues -import space.kscience.visionforge.Colors -import space.kscience.visionforge.widgetType -import styled.css -import styled.styledInput -import styled.styledSelect -import three.math.Color - -public external interface ValueChooserProps : Props { - public var descriptor: MetaDescriptor? - public var state: EditorPropertyState - public var value: Value? - public var onValueChange: (Value?) -> Unit -} - -@JsExport -public val StringValueChooser: FC = fc("StringValueChooser") { props -> - var value by useState(props.value?.string ?: "") - val keyDown: (Event) -> Unit = { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - value = (event.target as HTMLInputElement).value - props.onValueChange(value.asValue()) - } - } - val handleChange: (Event) -> Unit = { - value = (it.target as HTMLInputElement).value - } - styledInput(type = InputType.text) { - css { - width = 100.pct - } - attrs { - this.value = value - onKeyDownFunction = keyDown - onChangeFunction = handleChange - } - } -} - -@JsExport -public val BooleanValueChooser: FC = fc("BooleanValueChooser") { props -> - val handleChange: (Event) -> Unit = { - val newValue = (it.target as HTMLInputElement).checked - props.onValueChange(newValue.asValue()) - } - styledInput(type = InputType.checkBox) { - css { - width = 100.pct - } - attrs { - //this.attributes["indeterminate"] = (props.item == null).toString() - checked = props.value?.boolean ?: false - onChangeFunction = handleChange - } - } -} - -@JsExport -public val NumberValueChooser: FC = fc("NumberValueChooser") { props -> - var innerValue by useState(props.value?.string ?: "") - val keyDown: (Event) -> Unit = { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - innerValue = (event.target as HTMLInputElement).value - val number = innerValue.toDoubleOrNull() - if (number == null) { - console.error("The input value $innerValue is not a number") - } else { - props.onValueChange(number.asValue()) - } - } - } - val handleChange: (Event) -> Unit = { - innerValue = (it.target as HTMLInputElement).value - } - styledInput(type = InputType.number) { - css { - width = 100.pct - } - attrs { - value = innerValue - onKeyDownFunction = keyDown - onChangeFunction = handleChange - props.descriptor?.attributes?.get("step").string?.let { - step = it - } - props.descriptor?.attributes?.get("min").string?.let { - min = it - } - props.descriptor?.attributes?.get("max").string?.let { - max = it - } - } - } -} - -@JsExport -public val ComboValueChooser: FC = fc("ComboValueChooser") { props -> - var selected by useState(props.value?.string ?: "") - val handleChange: (Event) -> Unit = { - selected = (it.target as HTMLSelectElement).value - props.onValueChange(selected.asValue()) - } - styledSelect { - css { - width = 100.pct - } - props.descriptor?.allowedValues?.forEach { - option { - +it.string - } - } - attrs { - this.value = props.value?.string ?: "" - multiple = false - onChangeFunction = handleChange - } - } -} - -@JsExport -public val ColorValueChooser: FC = fc("ColorValueChooser") { props -> - val handleChange: (Event) -> Unit = { - props.onValueChange((it.target as HTMLInputElement).value.asValue()) - } - styledInput(type = InputType.color) { - css { - width = 100.pct - margin = Margin(0.px) - } - attrs { - this.value = props.value?.let { value -> - if (value.type == ValueType.NUMBER) Colors.rgbToString(value.int) - else "#" + Color(value.string).getHexString() - } ?: "#000000" - onChangeFunction = handleChange - } - } -} - -@JsExport -public val ValueChooser: FC = fc("ValueChooser") { props -> - val rawInput by useState(false) - - val descriptor = props.descriptor - val type = descriptor?.valueTypes?.firstOrNull() - - when { - rawInput -> child(StringValueChooser, props) - descriptor?.widgetType == "color" -> child(ColorValueChooser, props) - descriptor?.widgetType == "multiSelect" -> child(MultiSelectChooser, props) - descriptor?.widgetType == "range" -> child(RangeValueChooser, props) - type == ValueType.BOOLEAN -> child(BooleanValueChooser, props) - type == ValueType.NUMBER -> child(NumberValueChooser, props) - descriptor?.allowedValues?.isNotEmpty() ?: false -> child(ComboValueChooser, props) - //TODO handle lists - else -> child(StringValueChooser, props) - } -} diff --git a/ui/ring/README.md b/ui/ring/README.md deleted file mode 100644 index 6cdcbb60..00000000 --- a/ui/ring/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Module ring - - - diff --git a/ui/ring/build.gradle.kts b/ui/ring/build.gradle.kts deleted file mode 100644 index d1f2ff72..00000000 --- a/ui/ring/build.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -plugins { - id("space.kscience.gradle.mpp") -} - -val dataforgeVersion: String by rootProject.extra - -kscience{ - js{ - useCommonJs() - browser { - commonWebpackConfig { - cssSupport{ - enabled.set(false) - } - } - } - } - jsMain{ - api(projects.ui.react) - api("org.jetbrains.kotlin-wrappers:kotlin-ring-ui") - - implementation(npm("core-js","3.12.1")) - implementation(npm("file-saver", "2.0.2")) - } -} \ No newline at end of file diff --git a/ui/ring/src/jsMain/kotlin/ringui/Loader.kt b/ui/ring/src/jsMain/kotlin/ringui/Loader.kt deleted file mode 100644 index b7bc63a9..00000000 --- a/ui/ring/src/jsMain/kotlin/ringui/Loader.kt +++ /dev/null @@ -1,20 +0,0 @@ -@file:JsModule("@jetbrains/ring-ui/components/loader/loader") -@file:JsNonModule - -package ringui - -import react.ComponentClass -import react.PropsWithClassName - - -// https://github.com/JetBrains/ring-ui/blob/master/components/loader/loader.js -public external interface LoaderProps : PropsWithClassName { - public var size: Number - public var colors: Array - public var message: String - public var stop: Boolean - public var deterministic: Boolean -} - -@JsName("default") -public external val Loader: ComponentClass \ No newline at end of file diff --git a/ui/ring/src/jsMain/kotlin/ringui/LoaderScreen.kt b/ui/ring/src/jsMain/kotlin/ringui/LoaderScreen.kt deleted file mode 100644 index d662ee2b..00000000 --- a/ui/ring/src/jsMain/kotlin/ringui/LoaderScreen.kt +++ /dev/null @@ -1,16 +0,0 @@ -@file:JsModule("@jetbrains/ring-ui/components/loader-screen/loader-screen") -@file:JsNonModule - -package ringui - -import react.ComponentClass -import react.PropsWithClassName - -// https://github.com/JetBrains/ring-ui/blob/master/components/loader-screen/loader-screen.js -public external interface LoaderScreenProps : PropsWithClassName { - public var containerClassName: String - public var message: String -} - -@JsName("default") -public external val LoaderScreen: ComponentClass \ No newline at end of file diff --git a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt b/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt deleted file mode 100644 index 6ae2ec62..00000000 --- a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeViewWithControls.kt +++ /dev/null @@ -1,212 +0,0 @@ -package space.kscience.visionforge.ring - -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.async -import kotlinx.coroutines.launch -import kotlinx.css.* -import react.* -import react.dom.b -import react.dom.div -import react.dom.p -import react.dom.span -import ringui.* -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.NameToken -import space.kscience.dataforge.names.isEmpty -import space.kscience.dataforge.names.length -import space.kscience.visionforge.* -import space.kscience.visionforge.react.* -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.SolidGroup -import space.kscience.visionforge.solid.Solids -import space.kscience.visionforge.solid.solidGroup -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import styled.css -import styled.styledDiv - -public external interface ThreeCanvasWithControlsProps : Props { - public var solids: Solids - public var builderOfSolid: Deferred - public var selected: Name? - public var options: Canvas3DOptions? - public var additionalTabs: Map Unit>? -} - -private val ThreeCanvasWithControlsProps.context get() = solids.context - -public fun ThreeCanvasWithControlsProps.solid(block: SolidGroup.() -> Unit) { - builderOfSolid = context.async { - solids.solidGroup(null, block) - } -} - -public fun ThreeCanvasWithControlsProps.options(block: Canvas3DOptions.() -> Unit) { - options = Canvas3DOptions(block) -} - -public fun ThreeCanvasWithControlsProps.tab(title: String, block: RBuilder.() -> Unit) { - additionalTabs = (additionalTabs ?: emptyMap()) + (title to block) -} - - -public fun RBuilder.nameCrumbs(name: Name?, link: (Name) -> Unit): Unit = styledDiv { - div { - Link { - attrs { - onClick = { - link(Name.EMPTY) - } - } - +"\u2302" - } - - if (name != null) { - val tokens = ArrayList(name.length) - name.tokens.forEach { token -> - tokens.add(token) - val fullName = Name(tokens.toList()) - span { +"." } - Link { - +token.toString() - attrs { - onClick = { - console.log("Selected = $fullName") - link(fullName) - } - } - } - } - } - } - -} - -@JsExport -public val ThreeCanvasWithControls: FC = fc("ThreeViewWithControls") { props -> - var selected: Name? by useState { props.selected } - var solid: Solid? by useState(null) - - useEffect { - props.context.launch { - solid = props.builderOfSolid.await() - //ensure that the solid is properly rooted - if (solid?.parent == null) { - solid?.setAsRoot(props.context.visionManager) - } - } - } - - val onSelect: (Name?) -> Unit = { - selected = it - } - - val options = useMemo(props.options) { - (props.options ?: Canvas3DOptions()).apply { - this.onSelect = onSelect - } - } - - val selectedVision: Vision? = useMemo(props.builderOfSolid, selected) { - selected?.let { - when { - it.isEmpty() -> solid - else -> (solid as? SolidGroup)?.get(it) - } - } - } - - - flexRow { - css { - height = 100.pct - width = 100.pct - flexWrap = FlexWrap.wrap - alignItems = Align.stretch - alignContent = Align.stretch - } - - flexColumn { - css { - height = 100.pct - minWidth = 600.px - flex = Flex(10.0, 1.0, FlexBasis("600px")) - position = Position.relative - } - - if (solid == null) { - LoaderScreen { - attrs { - message = "Loading Three vision" - } - } - } else { - child(ThreeCanvasComponent) { - attrs { - this.context = props.context - this.solid = solid - this.selected = selected - this.options = options - } - } - } - - selectedVision?.let { vision -> - styledDiv { - css { - position = Position.absolute - top = 5.px - right = 5.px - width = 450.px - } - Island { - IslandHeader { - attrs { - border = true - } - nameCrumbs(selected) { selected = it } - } - IslandContent { - child(PropertyEditor) { - attrs { - this.key = selected.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - this.descriptor = vision.descriptor - this.scope = props.context - this.getPropertyState = { name -> - if (vision.properties.own?.get(name) != null) { - EditorPropertyState.Defined - } else if (vision.properties.root()[name] != null) { - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } - } - } - vision.styles.takeIf { it.isNotEmpty() }?.let { styles -> - p { - b { +"Styles: " } - +styles.joinToString(separator = ", ") - } - } - } - } - } - } - } - flexColumn { - css { - padding = Padding(4.px) - minWidth = 400.px - height = 100.pct - overflowY = Overflow.auto - flex = Flex(1.0, 10.0, FlexBasis("300px")) - } - ringThreeControls(options, solid, selected, onSelect, additionalTabs = props.additionalTabs) - } - } -} - diff --git a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt b/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt deleted file mode 100644 index 94259b2f..00000000 --- a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt +++ /dev/null @@ -1,57 +0,0 @@ -package space.kscience.visionforge.ring - -import kotlinx.coroutines.async -import org.w3c.dom.Element -import space.kscience.dataforge.context.AbstractPlugin -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.visionforge.ElementVisionRenderer -import space.kscience.visionforge.Vision -import space.kscience.visionforge.react.render -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import space.kscience.visionforge.solid.three.ThreePlugin - -public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { - public val three: ThreePlugin by require(ThreePlugin) - - override val tag: PluginTag get() = Companion.tag - - override fun rateVision(vision: Vision): Int = - if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING * 2 else ElementVisionRenderer.ZERO_RATING - - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { - if(meta["controls.enabled"].boolean == false){ - three.render(element, name, vision, meta) - } else { - space.kscience.visionforge.react.createRoot(element).render { - child(ThreeCanvasWithControls) { - attrs { - this.solids = three.solids - this.options = Canvas3DOptions.read(meta) - this.builderOfSolid = context.async { vision as Solid } - } - } - } - } - } - - override fun content(target: String): Map { - return when (target) { - ElementVisionRenderer.TYPE -> mapOf("three.withControls".asName() to this) - else -> super.content(target) - } - } - - public companion object : PluginFactory { - override val tag: PluginTag = PluginTag("vision.threejs.withControls", PluginTag.DATAFORGE_GROUP) - - override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin() - } -} \ No newline at end of file diff --git a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt b/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt deleted file mode 100644 index 83529d28..00000000 --- a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt +++ /dev/null @@ -1,88 +0,0 @@ -package space.kscience.visionforge.ring - -import org.w3c.dom.Element -import react.RBuilder -import react.dom.p -import ringui.Island -import ringui.SmartTabs -import ringui.Tab -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.get -import space.kscience.visionforge.Vision -import space.kscience.visionforge.getStyle -import space.kscience.visionforge.react.* -import space.kscience.visionforge.root -import space.kscience.visionforge.solid.SolidReference -import space.kscience.visionforge.styles - -public fun RBuilder.ringPropertyEditor( - vision: Vision, - descriptor: MetaDescriptor? = vision.descriptor, - key: Any? = null, -) { - val styles = if (vision is SolidReference) { - (vision.styles + vision.prototype.styles).distinct() - } else { - vision.styles - } - - flexColumn { - Island("Properties") { - child(PropertyEditor) { - attrs { - this.key = key?.toString() - this.meta = vision.properties.root() - this.updates = vision.properties.changes - this.descriptor = descriptor - this.scope = vision.manager?.context ?: error("Orphan vision could not be observed") - this.getPropertyState = {name-> - if(vision.properties.own?.get(name)!= null){ - EditorPropertyState.Defined - } else if(vision.properties.root()[name] != null){ - // TODO differentiate - EditorPropertyState.Default() - } else { - EditorPropertyState.Undefined - } - } - } - } - } - - if (styles.isNotEmpty()) { - Island("Styles") { - if (styles.size == 1) { - val styleName = styles.first() - p { - +styleName - } - val style = vision.getStyle(styleName) - if (style != null) { - Tab(styleName, id = styleName) { - metaViewer(style) - } - } - } else { - SmartTabs { - styles.forEach { styleName -> - val style = vision.getStyle(styleName) - if (style != null) { - Tab(styleName, id = styleName) { - metaViewer(style) - } - } - } - } - } - } - } - } -} - - -public fun Element.ringPropertyEditor( - item: Vision, - descriptor: MetaDescriptor? = item.descriptor, -): Unit = createRoot(this).render { - ringPropertyEditor(item, descriptor = descriptor) -} \ No newline at end of file diff --git a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt b/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt deleted file mode 100644 index 6cdc0707..00000000 --- a/ui/ring/src/jsMain/kotlin/space.kscience.visionforge.ring/ringThreeControls.kt +++ /dev/null @@ -1,131 +0,0 @@ -package space.kscience.visionforge.ring - -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.css.* -import kotlinx.html.js.onClickFunction -import org.w3c.dom.events.Event -import org.w3c.files.Blob -import org.w3c.files.BlobPropertyBag -import react.FC -import react.Props -import react.RBuilder -import react.dom.attrs -import react.dom.button -import react.fc -import ringui.Island -import ringui.SmartTabs -import ringui.Tab -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision -import space.kscience.visionforge.encodeToString -import space.kscience.visionforge.react.flexColumn -import space.kscience.visionforge.react.flexRow -import space.kscience.visionforge.react.propertyEditor -import space.kscience.visionforge.react.visionTree -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import styled.css - -internal fun saveData(event: Event, fileName: String, mimeType: String = "text/plain", dataBuilder: () -> String) { - event.stopPropagation(); - event.preventDefault(); - - val fileSaver = kotlinext.js.require("file-saver") - val blob = Blob(arrayOf(dataBuilder()), BlobPropertyBag("$mimeType;charset=utf-8")) - fileSaver.saveAs(blob, fileName) -} - -internal fun RBuilder.canvasControls(options: Canvas3DOptions, vision: Vision?): Unit { - child(CanvasControls) { - attrs { - this.options = options - this.vision = vision - } - } -} - -internal external interface CanvasControlsProps : Props { - public var options: Canvas3DOptions - public var vision: Vision? -} - -@OptIn(DelicateCoroutinesApi::class) -internal val CanvasControls: FC = fc("CanvasControls") { props -> - flexColumn { - flexRow { - css { - border = Border(1.px, BorderStyle.solid, Color.blue) - padding = Padding(4.px) - } - props.vision?.let { vision -> - button { - +"Export" - attrs { - onClickFunction = { - val json = vision.encodeToString() - saveData(it, "object.json", "text/json") { - json - } - - } - } - } - } - } - propertyEditor( - scope = props.vision?.manager?.context ?: GlobalScope, - properties = props.options.meta, - descriptor = Canvas3DOptions.descriptor, - expanded = false - ) - - } -} - - -public external interface ThreeControlsProps : Props { - public var canvasOptions: Canvas3DOptions - public var vision: Vision? - public var selected: Name? - public var onSelect: (Name?) -> Unit - public var additionalTabs: Map Unit> -} - -@JsExport -public val ThreeControls: FC = fc { props -> - SmartTabs("Tree") { - props.vision?.let { - Tab("Tree") { - Island("Vision tree") { - visionTree(it, props.selected, props.onSelect) - } - } - } - Tab("Settings") { - Island("Canvas configuration") { - canvasControls(props.canvasOptions, props.vision) - } - } - props.additionalTabs.forEach { (name, handler) -> - Tab(name) { - handler() - } - } - } -} - -public fun RBuilder.ringThreeControls( - canvasOptions: Canvas3DOptions, - vision: Vision?, - selected: Name?, - onSelect: (Name?) -> Unit = {}, - additionalTabs: Map Unit>? = null -): Unit = child(ThreeControls) { - attrs { - this.canvasOptions = canvasOptions - this.vision = vision - this.selected = selected - this.onSelect = onSelect - this.additionalTabs = additionalTabs ?: emptyMap() - } -} \ No newline at end of file diff --git a/ui/ring/webpack.config.d/01.ring.js b/ui/ring/webpack.config.d/01.ring.js deleted file mode 100644 index 41da041c..00000000 --- a/ui/ring/webpack.config.d/01.ring.js +++ /dev/null @@ -1,3 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -config.module.rules.push(...ringConfig.module.rules) \ No newline at end of file diff --git a/ui/compose/build.gradle.kts b/visionforge-compose-html/build.gradle.kts similarity index 54% rename from ui/compose/build.gradle.kts rename to visionforge-compose-html/build.gradle.kts index 77a8cfcf..89d7c329 100644 --- a/ui/compose/build.gradle.kts +++ b/visionforge-compose-html/build.gradle.kts @@ -1,40 +1,31 @@ - plugins { id("space.kscience.gradle.mpp") alias(spclibs.plugins.compose) -// id("com.android.library") } -kscience{ - jvm() +kscience { js() -// wasm() + jvm() } kotlin { // android() sourceSets { - val commonMain by getting { - dependencies { - - } - } - - val jvmMain by getting { + commonMain { dependencies { + api(projects.visionforgeCore) + //need this to placate compose compiler in MPP applications api(compose.runtime) - api(compose.foundation) - api(compose.material) - api(compose.preview) } } - val jsMain by getting{ + jsMain{ dependencies { - api(compose.html.core) api("app.softwork:bootstrap-compose:0.1.15") api("app.softwork:bootstrap-compose-icons:0.1.15") - api(projects.visionforge.visionforgeThreejs) + implementation(compose.html.svg) + + api(compose.html.core) } } } diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/ComposeHtmlVisionRenderer.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/ComposeHtmlVisionRenderer.kt new file mode 100644 index 00000000..5a54292d --- /dev/null +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/ComposeHtmlVisionRenderer.kt @@ -0,0 +1,28 @@ +package space.kscience.visionforge.html + +import androidx.compose.runtime.Composable +import org.jetbrains.compose.web.css.Style +import org.jetbrains.compose.web.dom.DOMScope +import org.jetbrains.compose.web.renderComposable +import org.w3c.dom.Element +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.names.Name +import space.kscience.visionforge.Vision + +/** + * An [ElementVisionRenderer] that could be used directly in Compose-html as well as a stand-alone renderer + */ +public interface ComposeHtmlVisionRenderer : ElementVisionRenderer { + + @Composable + public fun DOMScope.render(name: Name, vision: Vision, meta: Meta) + + override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { + renderComposable(element) { + Style(VisionForgeStyles) + render(name, vision, meta) + } + } + + public companion object +} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/MetaViewer.kt similarity index 94% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/MetaViewer.kt index 5aaf4140..3f85fd9f 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/MetaViewer.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.* import org.jetbrains.compose.web.css.AlignItems @@ -10,7 +10,6 @@ import org.jetbrains.compose.web.dom.Text import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.isLeaf import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken @@ -64,7 +63,7 @@ private fun MetaViewerItem(root: Meta, name: Name, rootDescriptor: MetaDescripto classes(TreeStyles.tree) }) { val keys = buildSet { - descriptorItem?.children?.keys?.forEach { + descriptorItem?.nodes?.keys?.forEach { add(NameToken(it)) } actualMeta!!.items.keys.let { addAll(it) } diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/NameCrumbs.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/NameCrumbs.kt similarity index 61% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/NameCrumbs.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/NameCrumbs.kt index 2becdbb6..787a45fa 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/NameCrumbs.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/NameCrumbs.kt @@ -1,26 +1,31 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.Composable -import org.jetbrains.compose.web.dom.Li -import org.jetbrains.compose.web.dom.Nav -import org.jetbrains.compose.web.dom.Ol -import org.jetbrains.compose.web.dom.Text +import org.jetbrains.compose.web.dom.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.length @Composable public fun NameCrumbs(name: Name?, link: (Name) -> Unit): Unit = Nav({ - attr("aria-label","breadcrumb") + attr("aria-label", "breadcrumb") }) { - Ol({classes("breadcrumb")}) { + Ol({ + classes("breadcrumb") + style { + property("--bs-breadcrumb-divider", "'.'") + property("--bs-breadcrumb-item-padding-x", ".1rem") + } + }) { Li({ classes("breadcrumb-item") onClick { link(Name.EMPTY) } }) { - Text("\u2302") + A("#") { + Text("\u2302") + } } if (name != null) { @@ -28,15 +33,16 @@ public fun NameCrumbs(name: Name?, link: (Name) -> Unit): Unit = Nav({ name.tokens.forEach { token -> tokens.add(token) val fullName = Name(tokens.toList()) - Text(".") Li({ classes("breadcrumb-item") - if(tokens.size == name.length) classes("active") + if (tokens.size == name.length) classes("active") onClick { link(fullName) } }) { - Text(token.toString()) + A("#") { + Text(token.toString()) + } } } } diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/PropertyEditor.kt similarity index 62% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/PropertyEditor.kt index d919cd77..04329625 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/PropertyEditor.kt @@ -1,25 +1,23 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.* -import kotlinx.coroutines.CoroutineScope +import app.softwork.bootstrapcompose.CloseButton +import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.launch -import org.jetbrains.compose.web.attributes.disabled import org.jetbrains.compose.web.css.AlignItems import org.jetbrains.compose.web.css.alignItems import org.jetbrains.compose.web.css.px import org.jetbrains.compose.web.css.width -import org.jetbrains.compose.web.dom.Button import org.jetbrains.compose.web.dom.Div import org.jetbrains.compose.web.dom.Span import org.jetbrains.compose.web.dom.Text import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.ObservableMutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.get -import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.remove import space.kscience.dataforge.names.* import space.kscience.visionforge.hidden @@ -29,35 +27,33 @@ import space.kscience.visionforge.hidden * The display state of a property */ public sealed class EditorPropertyState { - public object Defined : EditorPropertyState() - public class Default(public val source: String = "unknown") : EditorPropertyState() - public object Undefined : EditorPropertyState() - + public data object Defined : EditorPropertyState() + public data class Default(public val source: String = "unknown") : EditorPropertyState() + public data object Undefined : EditorPropertyState() } /** - * @param meta Root config object - always non-null - * @param rootDescriptor Full path to the displayed node in [meta]. Could be empty + * @param rootMeta Root config object - always non-null + * @param rootDescriptor Full path to the displayed node in [rootMeta]. Could be empty */ @Composable public fun PropertyEditor( - scope: CoroutineScope, - meta: MutableMeta, + rootMeta: MutableMeta, getPropertyState: (Name) -> EditorPropertyState, updates: Flow, - name: Name = Name.EMPTY, - rootDescriptor: MetaDescriptor? = null, + name: Name, + rootDescriptor: MetaDescriptor?, initialExpanded: Boolean? = null, ) { var expanded: Boolean by remember { mutableStateOf(initialExpanded ?: true) } - val descriptor: MetaDescriptor? = remember(rootDescriptor, name) { rootDescriptor?.get(name) } - var property: MutableMeta by remember { mutableStateOf(meta.getOrCreate(name)) } + val descriptor: MetaDescriptor? by derivedStateOf { rootDescriptor?.get(name) } + var displayedValue by remember { mutableStateOf(rootMeta.getValue(name)) } var editorPropertyState: EditorPropertyState by remember { mutableStateOf(getPropertyState(name)) } - val keys = remember(descriptor) { + val keys by derivedStateOf { buildSet { - descriptor?.children?.filterNot { + descriptor?.nodes?.filterNot { it.key.startsWith("@") || it.value.hidden }?.forEach { add(NameToken(it.key)) @@ -69,13 +65,13 @@ public fun PropertyEditor( val token = name.lastOrNull()?.toString() ?: "Properties" fun update() { - property = meta.getOrCreate(name) + displayedValue = rootMeta.getValue(name) editorPropertyState = getPropertyState(name) } - LaunchedEffect(meta) { + LaunchedEffect(rootMeta) { updates.collect { updatedName -> - if (updatedName == name) { + if (name.startsWith(updatedName)) { update() } } @@ -86,6 +82,7 @@ public fun PropertyEditor( alignItems(AlignItems.Center) } }) { + //if node has children if (keys.isNotEmpty()) { Span({ classes(TreeStyles.treeCaret) @@ -97,38 +94,35 @@ public fun PropertyEditor( } Span({ classes(TreeStyles.treeLabel) - if (editorPropertyState != EditorPropertyState.Defined) { - classes(TreeStyles.treeLabelInactive) + when (editorPropertyState) { + is EditorPropertyState.Default, EditorPropertyState.Undefined -> { + classes(TreeStyles.treeLabelInactive) + } + + EditorPropertyState.Defined -> {} } }) { Text(token) } - if (!name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) { + if (!name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) { Div({ style { width(160.px) marginAll(1.px, 5.px) } }) { - ValueChooser(descriptor, editorPropertyState, property.value) { - property.value = it - editorPropertyState = getPropertyState(name) + ValueChooser(descriptor, editorPropertyState, displayedValue) { + rootMeta.setValue(name, it) + update() } } - Button({ - classes(TreeStyles.propertyEditorButton) - if (editorPropertyState != EditorPropertyState.Defined) { - disabled() - } else { - onClick { - meta.remove(name) - update() - } - } - }) { - Text("\u00D7") + } + if (!name.isEmpty()) { + CloseButton(editorPropertyState != EditorPropertyState.Defined) { + rootMeta.remove(name) + update() } } } @@ -140,7 +134,7 @@ public fun PropertyEditor( Div({ classes(TreeStyles.treeItem) }) { - PropertyEditor(scope, meta, getPropertyState, updates, name + token, descriptor, expanded) + PropertyEditor(rootMeta, getPropertyState, updates, name + token, rootDescriptor, expanded) } } } @@ -149,14 +143,13 @@ public fun PropertyEditor( @Composable public fun PropertyEditor( - scope: CoroutineScope, properties: ObservableMutableMeta, descriptor: MetaDescriptor? = null, expanded: Boolean? = null, ) { + val scope = rememberCoroutineScope() PropertyEditor( - scope = scope, - meta = properties, + rootMeta = properties, getPropertyState = { name -> if (properties[name] != null) { EditorPropertyState.Defined @@ -173,9 +166,7 @@ public fun PropertyEditor( } } - invokeOnClose { - properties.removeListener(scope) - } + awaitClose { properties.removeListener(scope) } }, name = Name.EMPTY, rootDescriptor = descriptor, diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/Tabs.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/Tabs.kt new file mode 100644 index 00000000..36504cf4 --- /dev/null +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/Tabs.kt @@ -0,0 +1,94 @@ +package space.kscience.visionforge.html + +import androidx.compose.runtime.* +import app.softwork.bootstrapcompose.Card +import app.softwork.bootstrapcompose.NavbarLink +import app.softwork.bootstrapcompose.Styling +import org.jetbrains.compose.web.css.overflowY +import org.jetbrains.compose.web.dom.* +import org.w3c.dom.HTMLAnchorElement +import org.w3c.dom.HTMLDivElement + + +public class ComposeTab( + public val key: String, + public val title: ContentBuilder, + public val disabled: Boolean, + public val content: ContentBuilder, +) + +@Composable +public fun Tabs( + tabs: List, + activeKey: String, + styling: (Styling.() -> Unit)? = null, + attrs: AttrBuilderContext? = null, +) { + var active by remember(activeKey) { mutableStateOf(activeKey) } + + val activeTab by derivedStateOf { tabs.find { it.key == active } } + + Card( + styling, + attrs, + header = { + Ul({ classes("nav", "nav-tabs", "card-header-tabs") }) { + tabs.forEach { tab -> + Li({ + classes("nav-item") + }) { + NavbarLink( + active = active == tab.key, + disabled = tab.disabled, + attrs = { + onClick { event -> + event.preventDefault() + active = tab.key + } + } + ) { + tab.title.invoke(this) + } + } + } + } + }, + bodyAttrs = { + style { + overflowY("auto") + } + } + ) { + activeTab?.content?.invoke(this) + } +} + +public class TabsBuilder { + internal val tabs: MutableList = mutableListOf() + + @Composable + public fun Tab( + key: String, + label: ContentBuilder = { A("#") { Text(key) } }, + disabled: Boolean = false, + content: ContentBuilder, + ) { + tabs.add(ComposeTab(key, label, disabled, content)) + } + + public fun addTab(tab: ComposeTab) { + tabs.add(tab) + } +} + +@Composable +public fun Tabs( + activeKey: String? = null, + styling: (Styling.() -> Unit)? = null, + attrs: AttrBuilderContext? = null, + builder: @Composable TabsBuilder.() -> Unit, +) { + val result = TabsBuilder().apply { builder() } + + Tabs(result.tabs, activeKey ?: result.tabs.firstOrNull()?.key ?: "", styling, attrs) +} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/TreeStyles.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/TreeStyles.kt similarity index 65% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/TreeStyles.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/TreeStyles.kt index de9001ba..4d8406ad 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/TreeStyles.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/TreeStyles.kt @@ -1,16 +1,16 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import org.jetbrains.compose.web.ExperimentalComposeWebApi import org.jetbrains.compose.web.css.* @OptIn(ExperimentalComposeWebApi::class) -public object TreeStyles : StyleSheet() { +public object TreeStyles : StyleSheet(VisionForgeStyles) { /** * Remove default bullets */ public val tree: String by style { - paddingLeft(5.px) + paddingLeft(10.px) marginLeft(0.px) listStyleType("none") } @@ -22,7 +22,7 @@ public object TreeStyles : StyleSheet() { cursor("pointer") userSelect(UserSelect.none) /* Create the caret/arrow with a unicode, and style it */ - before { + (self + before) { content("\u25B6") color(Color.black) display(DisplayStyle.InlineBlock) @@ -34,7 +34,7 @@ public object TreeStyles : StyleSheet() { * Rotate the caret/arrow icon when clicked on (using JavaScript) */ public val treeCaretDown: String by style { - before { + (self + before) { content("\u25B6") color(Color.black) display(DisplayStyle.InlineBlock) @@ -46,13 +46,11 @@ public object TreeStyles : StyleSheet() { public val treeItem: String by style { alignItems(AlignItems.Center) paddingLeft(10.px) - border { - left { - width(1.px) - color(Color.lightgray) - style = LineStyle.Dashed - } - } + property("border-left", CSSBorder().apply{ + width(1.px) + color(Color.lightgray) + style = LineStyle.Dashed + }) } public val treeLabel: String by style { @@ -69,26 +67,4 @@ public object TreeStyles : StyleSheet() { public val treeLabelSelected: String by style { backgroundColor(Color.lightblue) } - - public val propertyEditorButton: String by style { - width(24.px) - alignSelf(AlignSelf.Stretch) - marginAll(1.px, 5.px) - backgroundColor(Color.white) - border{ - style(LineStyle.Solid) - } - borderRadius(2.px) - textAlign("center") - textDecoration("none") - cursor("pointer") - disabled { - cursor("auto") - border{ - style(LineStyle.Dashed) - } - color(Color.lightgray) - } - } - } \ No newline at end of file diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionForgeStyles.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionForgeStyles.kt new file mode 100644 index 00000000..311f41b2 --- /dev/null +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionForgeStyles.kt @@ -0,0 +1,28 @@ +package space.kscience.visionforge.html + +import org.jetbrains.compose.web.css.* + +public object VisionForgeStyles: StyleSheet() { + + public val propertyEditorButton: String by style { + width(24.px) + alignSelf(AlignSelf.Stretch) + marginAll(1.px, 5.px) + backgroundColor(Color.white) + border { + style(LineStyle.Solid) + } + borderRadius(2.px) + textAlign("center") + textDecoration("none") + cursor("pointer") + (self + disabled) { + cursor("auto") + border { + style(LineStyle.Dashed) + } + color(Color.lightgray) + } + } + +} \ No newline at end of file diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/VisionTree.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionTree.kt similarity index 90% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/VisionTree.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionTree.kt index 2de59f90..b714fb71 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/VisionTree.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/VisionTree.kt @@ -1,10 +1,9 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.* import org.jetbrains.compose.web.css.Color import org.jetbrains.compose.web.css.color import org.jetbrains.compose.web.css.cursor -import org.jetbrains.compose.web.css.textDecorationLine import org.jetbrains.compose.web.dom.Div import org.jetbrains.compose.web.dom.Span import org.jetbrains.compose.web.dom.Text @@ -15,8 +14,6 @@ import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionGroup import space.kscience.visionforge.asSequence -import space.kscience.visionforge.compose.TreeStyles.hover -import space.kscience.visionforge.compose.TreeStyles.invoke import space.kscience.visionforge.isEmpty @@ -35,10 +32,6 @@ private fun TreeLabel( style { color(Color("#069")) cursor("pointer") - hover.invoke { - textDecorationLine("underline") - } - } onClick { clickCallback(name) } }) { diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/bootstrap.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/bootstrap.kt similarity index 74% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/bootstrap.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/bootstrap.kt index 8b0ee5b5..ce27653b 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/bootstrap.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/bootstrap.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.Composable import org.jetbrains.compose.web.dom.H5 diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/composeHtmlVision.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/composeHtmlVision.kt new file mode 100644 index 00000000..9c8b6c8c --- /dev/null +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/composeHtmlVision.kt @@ -0,0 +1,56 @@ +package space.kscience.visionforge.html + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import kotlinx.dom.clear +import org.jetbrains.compose.web.dom.AttrBuilderContext +import org.jetbrains.compose.web.dom.Div +import org.w3c.dom.HTMLDivElement +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.gather +import space.kscience.dataforge.context.request +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName +import space.kscience.visionforge.* + + +/** + * Render an Element vision via injected vision renderer inside compose-html + */ +@Composable +public fun Vision( + context: Context, + vision: Vision, + name: Name = "@vision[${vision.hashCode().toString(16)}]".asName(), + meta: Meta = Meta.EMPTY, + attrs: AttrBuilderContext? = null, +): Unit = Div(attrs) { + + val client: VisionClient = context.request(JsVisionClient) + + // set vision root if necessary + if (vision.manager == null) { + vision.setAsRoot(client.visionManager) + } + + val renderer by derivedStateOf { + client.context.gather(ElementVisionRenderer.TYPE).values.mapNotNull { + val rating = it.rateVision(vision) + if (rating > 0) { + rating to it + } else { + null + } + }.maxBy { it.first }.second + } + + DisposableEffect(vision, name, renderer, meta) { + renderer.render(scopeElement, name, vision, meta) + onDispose { + scopeElement.clear() + } + } +} diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/css.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/css.kt similarity index 95% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/css.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/css.kt index 0bf8f7c2..9ae652cf 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/css.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/css.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import org.jetbrains.compose.web.css.* import org.jetbrains.compose.web.css.keywords.CSSAutoKeyword diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/layouts.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/layouts.kt similarity index 96% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/layouts.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/layouts.kt index 882f1f1c..ecdfbb1c 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/layouts.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/layouts.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.Composable import org.jetbrains.compose.web.css.DisplayStyle diff --git a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/valueChooser.kt similarity index 59% rename from ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt rename to visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/valueChooser.kt index 0be879ad..fdec8c3f 100644 --- a/ui/compose/src/jsMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/html/valueChooser.kt @@ -1,26 +1,19 @@ @file:Suppress("UNUSED_PARAMETER") -package space.kscience.visionforge.compose +package space.kscience.visionforge.html import androidx.compose.runtime.* +import kotlinx.uuid.UUID +import kotlinx.uuid.generateUUID import org.jetbrains.compose.web.attributes.* -import org.jetbrains.compose.web.css.percent -import org.jetbrains.compose.web.css.px -import org.jetbrains.compose.web.css.width -import org.jetbrains.compose.web.dom.Input -import org.jetbrains.compose.web.dom.Option -import org.jetbrains.compose.web.dom.Select -import org.jetbrains.compose.web.dom.Text -import org.w3c.dom.HTMLInputElement +import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLOptionElement import org.w3c.dom.asList import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.ValueRequirement import space.kscience.dataforge.meta.descriptors.allowedValues import space.kscience.visionforge.Colors import space.kscience.visionforge.widgetType -import three.math.Color @Composable @@ -30,20 +23,16 @@ public fun StringValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { - var stringValue by remember { mutableStateOf(value?.string ?: "") } + var stringValue by remember(value, descriptor) { mutableStateOf(value?.string ?: "") } Input(type = InputType.Text) { - style { - width(100.percent) - } + classes("w-100") value(stringValue) - onKeyDown { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - stringValue = (event.target as HTMLInputElement).value - onValueChange(stringValue.asValue()) - } + onChange { event -> + stringValue = event.value } - onChange { - stringValue = it.target.value + onInput { event -> + stringValue = event.value + onValueChange(event.value.asValue()) } } } @@ -56,16 +45,29 @@ public fun BooleanValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { - Input(type = InputType.Checkbox) { - style { - width(100.percent) - } - //this.attributes["indeterminate"] = (props.item == null).toString() - checked(value?.boolean ?: false) + val uid = remember { "checkbox[${UUID.generateUUID().toString(false)}]" } + var innerValue by remember(value, descriptor) { + mutableStateOf( + value?.boolean ?: descriptor?.defaultValue?.boolean + ) + } - onChange { - val newValue = it.target.checked - onValueChange(newValue.asValue()) + Input(type = InputType.Checkbox) { + classes("btn-check") + checked(innerValue ?: false) + autoComplete(AutoComplete.off) + id(uid) + + onInput { event -> + innerValue = event.value + onValueChange(event.value.asValue()) + } + } + Label(uid, attrs = { classes("btn", "btn-sm", "btn-outline-secondary", "w-100") }) { + if (innerValue == true) { + Text("On") + } else { + Text("Off") } } } @@ -77,25 +79,18 @@ public fun NumberValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { - var innerValue by remember { mutableStateOf(value?.string ?: "") } + var innerValue by remember(value, descriptor) { mutableStateOf(value?.number ?: descriptor?.defaultValue?.number) } Input(type = InputType.Number) { - style { - width(100.percent) + classes("w-100") + + value(innerValue ?: descriptor?.defaultValue?.number ?: 0.0) + + onChange { event -> + innerValue = event.value } - value(innerValue) - onKeyDown { event -> - if (event.type == "keydown" && event.asDynamic().key == "Enter") { - innerValue = (event.target as HTMLInputElement).value - val number = innerValue.toDoubleOrNull() - if (number == null) { - console.error("The input value $innerValue is not a number") - } else { - onValueChange(number.asValue()) - } - } - } - onChange { - innerValue = it.target.value + onInput { event -> + innerValue = event.value + onValueChange(event.value?.asValue()) } descriptor?.attributes?.get("step").number?.let { step(it) @@ -117,11 +112,10 @@ public fun ComboValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { - var selected by remember { mutableStateOf(value?.string ?: "") } + var selected by remember(value, descriptor) { mutableStateOf(value?.string ?: "") } Select({ - style { - width(100.percent) - } + classes("w-100") + onChange { selected = it.target.value onValueChange(selected.asValue()) @@ -143,19 +137,24 @@ public fun ColorValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { + var innerValue by remember { mutableStateOf(value?.string ?: descriptor?.defaultValue?.string) } + Input(type = InputType.Color) { - style { - width(100.percent) - marginAll(0.px) - } + classes("w-100") + value( value?.let { value -> if (value.type == ValueType.NUMBER) Colors.rgbToString(value.int) - else "#" + Color(value.string).getHexString() + else value.string + //else "#" + Color(value.string).getHexString() } ?: "#000000" ) - onChange { - onValueChange(it.target.value.asValue()) + onChange { event -> + innerValue = event.value + } + onInput { event -> + innerValue = event.value + onValueChange(event.value.asValue()) } } } @@ -169,6 +168,7 @@ public fun MultiSelectChooser( onValueChange: (Value?) -> Unit, ) { Select({ + classes("w-100","form-select") onChange { event -> val newSelected = event.target.selectedOptions.asList() .map { (it as HTMLOptionElement).value.asValue() } @@ -194,40 +194,18 @@ public fun RangeValueChooser( value: Value?, onValueChange: (Value?) -> Unit, ) { - var innerValue by remember { mutableStateOf(value?.double) } - var rangeDisabled: Boolean by remember { mutableStateOf(state != EditorPropertyState.Defined) } - - - FlexRow { - if (descriptor?.valueRequirement != ValueRequirement.REQUIRED) { - Input(type = InputType.Checkbox) { - if (!rangeDisabled) defaultChecked() - - onChange { - val checkBoxValue = it.target.checked - rangeDisabled = !checkBoxValue - onValueChange( - if (!checkBoxValue) { - null - } else { - innerValue?.asValue() - } - ) - } - } - } - } + var innerValue by remember(value, descriptor) { mutableStateOf(value?.number ?: descriptor?.defaultValue?.number) } Input(type = InputType.Range) { - style { - width(100.percent) - } - if (rangeDisabled) disabled() + classes("w-100", "form-range") + value(innerValue?.toString() ?: "") - onChange { - val newValue = it.target.value - onValueChange(newValue.toDoubleOrNull()?.asValue()) - innerValue = newValue.toDoubleOrNull() + onInput { event -> + innerValue = event.value + } + onChange { event -> + innerValue = event.value + onValueChange(innerValue?.asValue()) } descriptor?.attributes?.get("min").string?.let { min(it) diff --git a/visionforge-compose-multiplatform/README.md b/visionforge-compose-multiplatform/README.md new file mode 100644 index 00000000..aef4ef10 --- /dev/null +++ b/visionforge-compose-multiplatform/README.md @@ -0,0 +1,21 @@ +# Module visionforge-compose-multiplatform + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:visionforge-compose-multiplatform:0.4.1`. + +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:visionforge-compose-multiplatform:0.4.1") +} +``` diff --git a/visionforge-compose-multiplatform/build.gradle.kts b/visionforge-compose-multiplatform/build.gradle.kts new file mode 100644 index 00000000..b3175b38 --- /dev/null +++ b/visionforge-compose-multiplatform/build.gradle.kts @@ -0,0 +1,35 @@ +import space.kscience.gradle.Maturity + +plugins { + id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) +} + +kscience { + jvm() +// wasm() +} + +kotlin { +// android() + sourceSets { + commonMain { + dependencies { + api(projects.visionforgeCore) + api(compose.foundation) + api(compose.runtime) + api(compose.material) + api(compose.materialIconsExtended) + } + } + jvmMain { + dependencies { + implementation("com.eygraber:compose-color-picker:0.0.17") + } + } + } +} + +readme { + maturity = Maturity.EXPERIMENTAL +} \ No newline at end of file diff --git a/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionClient.kt b/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionClient.kt new file mode 100644 index 00000000..29bca480 --- /dev/null +++ b/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionClient.kt @@ -0,0 +1,134 @@ +package space.kscience.visionforge.compose + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.key +import androidx.compose.runtime.remember +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import space.kscience.dataforge.context.* +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.get +import space.kscience.dataforge.meta.int +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.NameToken +import space.kscience.dataforge.names.asName +import space.kscience.visionforge.* +import space.kscience.visionforge.html.VisionOutput +import space.kscience.visionforge.html.VisionTagConsumer + +/** + * A Kotlin-browser plugin that renders visions based on provided renderers and governs communication with the server. + */ +public class ComposeVisionClient : AbstractPlugin(), VisionClient { + override val tag: PluginTag get() = Companion.tag + override val visionManager: VisionManager by require(VisionManager) + + + private val renderers by lazy { context.gather(ComposeVisionRenderer.TYPE).values } + + private fun findRendererFor(vision: Vision): ComposeVisionRenderer? = renderers.mapNotNull { + val rating = it.rateVision(vision) + if (rating > 0) { + rating to it + } else { + null + } + }.maxByOrNull { it.first }?.second + + + private val mutex = Mutex() + + + private val rootChangeCollector = VisionChangeBuilder() + + /** + * Communicate vision property changed from rendering engine to model + */ + override fun notifyPropertyChanged(visionName: Name, propertyName: Name, item: Meta?) { + context.launch { + mutex.withLock { + rootChangeCollector.propertyChanged(visionName, propertyName, item) + } + } + } + + private val eventCollector = MutableSharedFlow>(meta["feedback.eventCache"].int ?: 100) + + /** + * Send a custom feedback event + */ + override suspend fun sendEvent(targetName: Name, event: VisionEvent) { + eventCollector.emit(targetName to event) + } + + @Composable + public fun renderVision(name: Name, vision: Vision, outputMeta: Meta) { + val renderer: ComposeVisionRenderer = remember(vision) { + findRendererFor(vision) ?: error("Could not find renderer for ${vision::class}") + } + + key(vision) { + vision.setAsRoot(visionManager) + } + //subscribe to a backwards events propagation for control visions + if (vision is ControlVision) { + LaunchedEffect(vision) { + vision.controlEventFlow.collect { + sendEvent(name, it) + } + } + } + + renderer.render(name, vision, outputMeta) + } + + +// override fun content(target: String): Map = if (target == ComposeVisionRenderer.TYPE) { +// listOf( +// htmlVisionRenderer, +// inputVisionRenderer, +// checkboxVisionRenderer, +// numberVisionRenderer, +// textVisionRenderer, +// rangeVisionRenderer, +// formVisionRenderer, +// buttonVisionRenderer +// ).associateBy { it.toString().asName() } +// } else super.content(target) + + public companion object : PluginFactory { + override fun build(context: Context, meta: Meta): ComposeVisionClient = ComposeVisionClient() + + override val tag: PluginTag = PluginTag(name = "vision.client.compose", group = PluginTag.DATAFORGE_GROUP) + } +} + +/** + * Render an Element vision via injected vision renderer inside compose-html + */ +@Composable +public fun Vision( + context: Context, + vision: Vision, + name: Name? = null, + meta: Meta = Meta.EMPTY, +) { + val actualName = name ?: NameToken(VisionTagConsumer.DEFAULT_VISION_NAME, vision.hashCode().toUInt().toString()).asName() + context.request(ComposeVisionClient).renderVision(actualName, vision, meta) +} + +@Composable +public fun Vision( + context: Context, + name: Name? = null, + meta: Meta = Meta.EMPTY, + buildOutput: VisionOutput.() -> Vision, +) { + val actualName = name ?: NameToken(VisionTagConsumer.DEFAULT_VISION_NAME, buildOutput.hashCode().toUInt().toString()).asName() + val output = VisionOutput(context, actualName) + val vision = output.buildOutput() + context.request(ComposeVisionClient).renderVision(actualName, vision, meta) +} \ No newline at end of file diff --git a/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionRenderer.kt b/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionRenderer.kt new file mode 100644 index 00000000..a7abee3f --- /dev/null +++ b/visionforge-compose-multiplatform/src/commonMain/kotlin/space/kscience/visionforge/compose/ComposeVisionRenderer.kt @@ -0,0 +1,47 @@ +package space.kscience.visionforge.compose + +import androidx.compose.runtime.Composable +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.misc.DfType +import space.kscience.dataforge.names.Name +import space.kscience.visionforge.Vision +import kotlin.reflect.KClass +import kotlin.reflect.cast + +@DfType(ComposeVisionRenderer.TYPE) +public interface ComposeVisionRenderer { + public fun rateVision(vision: Vision): Int + + @Composable + public fun render(name: Name, vision: Vision, meta: Meta) + + public companion object { + public const val TYPE: String = "composeVisionRenderer" + public const val ZERO_RATING: Int = 0 + public const val DEFAULT_RATING: Int = 10 + } +} + +public class SingleTypeComposeRenderer( + public val kClass: KClass, + private val acceptRating: Int = ComposeVisionRenderer.DEFAULT_RATING, + private val renderFunction: @Composable (name: Name, vision: T, meta: Meta) -> Unit, +) : ComposeVisionRenderer { + + override fun rateVision(vision: Vision): Int = + if (vision::class == kClass) acceptRating else ComposeVisionRenderer.ZERO_RATING + + @Composable + override fun render( + name: Name, + vision: Vision, + meta: Meta, + ) { + renderFunction(name, kClass.cast(vision), meta) + } +} + +public inline fun ComposeVisionRenderer( + acceptRating: Int = ComposeVisionRenderer.DEFAULT_RATING, + noinline renderFunction: @Composable (name: Name, vision: T, meta: Meta) -> Unit, +): ComposeVisionRenderer = SingleTypeComposeRenderer(T::class, acceptRating, renderFunction) diff --git a/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt new file mode 100644 index 00000000..d6578c73 --- /dev/null +++ b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/MetaViewer.kt @@ -0,0 +1,69 @@ +package space.kscience.visionforge.compose + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material.Icon +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ExpandLess +import androidx.compose.material.icons.filled.ExpandMore +import androidx.compose.runtime.* +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.get +import space.kscience.dataforge.meta.isLeaf +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.NameToken +import space.kscience.dataforge.names.lastOrNull +import space.kscience.dataforge.names.plus + + +@Composable +private fun MetaViewerItem(root: Meta, name: Name, rootDescriptor: MetaDescriptor? = null) { + var expanded: Boolean by remember { mutableStateOf(true) } + val item: Meta? = root[name] + val descriptorItem: MetaDescriptor? = rootDescriptor?.get(name) + val actualValue = item?.value ?: descriptorItem?.defaultValue + val actualMeta = item ?: descriptorItem?.defaultNode + + val token = name.lastOrNull()?.toString() ?: "" + + Row(modifier = Modifier.fillMaxWidth()) { + if (actualMeta?.isLeaf == false) { + TextButton({ expanded = !expanded }) { + if (expanded) { + Icon(Icons.Filled.ExpandLess, "collapse") + } else { + Icon(Icons.Filled.ExpandMore, "expand") + } + } + } + Text(token, color = if (item == null) Color.Gray else Color.Unspecified) + Spacer(Modifier.weight(1f)) + Text(actualValue.toString()) + } + if (expanded) { + Column { + val keys = buildSet { + descriptorItem?.nodes?.keys?.forEach { + add(NameToken(it)) + } + actualMeta!!.items.keys.let { addAll(it) } + } + + keys.filter { !it.body.startsWith("@") }.forEach { token -> + MetaViewerItem(root, name + token, rootDescriptor) + } + } + } +} + +@Composable +public fun MetaViewer(meta: Meta, descriptor: MetaDescriptor? = null) { + MetaViewerItem(meta, Name.EMPTY, descriptor) +} diff --git a/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt new file mode 100644 index 00000000..f2088c61 --- /dev/null +++ b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt @@ -0,0 +1,174 @@ +package space.kscience.visionforge.compose + +import androidx.compose.foundation.layout.* +import androidx.compose.material.Icon +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Clear +import androidx.compose.material.icons.filled.ExpandLess +import androidx.compose.material.icons.filled.ExpandMore +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.launch +import space.kscience.dataforge.meta.MutableMeta +import space.kscience.dataforge.meta.ObservableMutableMeta +import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.ValueRestriction +import space.kscience.dataforge.meta.descriptors.get +import space.kscience.dataforge.meta.remove +import space.kscience.dataforge.names.* +import space.kscience.visionforge.hidden + + +/** + * The display state of a property + */ +public sealed class EditorPropertyState { + public data object Defined : EditorPropertyState() + public data class Default(public val source: String = "unknown") : EditorPropertyState() + public data object Undefined : EditorPropertyState() +} + +/** + * @param rootMeta Root config object - always non-null + * @param rootDescriptor Full path to the displayed node in [rootMeta]. Could be empty + */ +@Composable +public fun PropertyEditor( + rootMeta: MutableMeta, + getPropertyState: (Name) -> EditorPropertyState, + updates: Flow, + name: Name, + rootDescriptor: MetaDescriptor?, + initialExpanded: Boolean? = null, +) { + var expanded: Boolean by remember { mutableStateOf(initialExpanded ?: true) } + val descriptor: MetaDescriptor? by derivedStateOf { rootDescriptor?.get(name) } + var displayedValue by remember { mutableStateOf(rootMeta.getValue(name)) } + var editorPropertyState: EditorPropertyState by remember { mutableStateOf(getPropertyState(name)) } + + fun buildKeys() = buildSet { + descriptor?.nodes?.filterNot { + it.key.startsWith("@") || it.value.hidden + }?.forEach { + add(NameToken(it.key)) + } + rootMeta[name]?.items?.keys?.filterNot { it.body.startsWith("@") }?.let { addAll(it) } + } + + var keys by remember { mutableStateOf(buildKeys()) } + + val token = name.lastOrNull()?.toString() ?: "Properties" + + fun update() { + displayedValue = rootMeta.getValue(name) + editorPropertyState = getPropertyState(name) + keys = buildKeys() + } + + LaunchedEffect(rootMeta) { + updates.collect { updatedName -> + if (name.startsWith(updatedName)) { + update() + } + } + } + Column(modifier = Modifier.fillMaxWidth().padding(start = 20.dp)) { + Row(modifier = Modifier.fillMaxWidth().padding(start = 20.dp)) { + //if node has children + if (keys.isNotEmpty()) { + TextButton( + { expanded = !expanded }, + modifier = Modifier.align(Alignment.CenterVertically).width(40.dp) + ) { + if (expanded) { + Icon(Icons.Filled.ExpandLess, "collapse") + } else { + Icon(Icons.Filled.ExpandMore, "expand") + } + } + } + Text( + token, + color = when (editorPropertyState) { + is EditorPropertyState.Default, EditorPropertyState.Undefined -> Color.Gray + else -> Color.Unspecified + }, + modifier = Modifier.align(Alignment.CenterVertically) + ) + Spacer(modifier = Modifier.weight(1f)) + + if (!name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) { + Box(modifier = Modifier.padding(1.dp, 5.dp).width(160.dp)) { + ValueChooser(descriptor, editorPropertyState, displayedValue) { + rootMeta.setValue(name, it) + update() + } + } + + } + if (!name.isEmpty()) { + TextButton( + onClick = { + rootMeta.remove(name) + update() + }, + enabled = editorPropertyState == EditorPropertyState.Defined, + modifier = Modifier.align(Alignment.CenterVertically).width(50.dp) + ) { + if (editorPropertyState == EditorPropertyState.Defined) { + Icon(Icons.Filled.Clear, "Reset") + } + } + } + } + if (expanded) { + Column(modifier = Modifier.fillMaxWidth()) { + keys.forEach { token -> + PropertyEditor(rootMeta, getPropertyState, updates, name + token, rootDescriptor, expanded) + } + } + } + } +} + + +@Composable +public fun PropertyEditor( + properties: ObservableMutableMeta, + descriptor: MetaDescriptor? = null, + expanded: Boolean? = null, +) { + val scope = rememberCoroutineScope() + PropertyEditor( + rootMeta = properties, + getPropertyState = { name -> + if (properties[name] != null) { + EditorPropertyState.Defined + } else if (descriptor?.get(name)?.defaultValue != null) { + EditorPropertyState.Default("descriptor") + } else { + EditorPropertyState.Undefined + } + }, + updates = callbackFlow { + properties.onChange(scope) { name -> + scope.launch { + send(name) + } + } + + awaitClose { properties.removeListener(scope) } + }, + name = Name.EMPTY, + rootDescriptor = descriptor, + initialExpanded = expanded, + ) +} \ No newline at end of file diff --git a/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt new file mode 100644 index 00000000..cfecc54e --- /dev/null +++ b/visionforge-compose-multiplatform/src/jvmMain/kotlin/space/kscience/visionforge/compose/valueChooser.kt @@ -0,0 +1,270 @@ +@file:Suppress("UNUSED_PARAMETER") + +package space.kscience.visionforge.compose + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.CheckBox +import androidx.compose.material.icons.filled.CheckBoxOutlineBlank +import androidx.compose.runtime.* +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.isSpecified +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.text.input.KeyboardType +import com.eygraber.compose.colorpicker.ColorPicker +import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.allowedValues +import space.kscience.visionforge.widgetType +import kotlin.math.roundToInt + + +@Composable +public fun StringValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var stringValue by remember(value, descriptor) { mutableStateOf(value?.string ?: "") } + TextField( + value = stringValue, + onValueChange = { + stringValue = it + onValueChange(it.asValue()) + }, + modifier = Modifier.fillMaxWidth() + ) +} + + +@Composable +public fun BooleanValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var innerValue by remember(value, descriptor) { + mutableStateOf( + value?.boolean ?: descriptor?.defaultValue?.boolean ?: false + ) + } + + Button( + onClick = { + innerValue = !innerValue + onValueChange(innerValue.asValue()) + }, + colors = if (innerValue) ButtonDefaults.buttonColors(Color.Green) else ButtonDefaults.buttonColors(Color.Gray) + ) { + if (innerValue) { + Text("On") + } else { + Text("Off") + } + } +} + +@Composable +public fun NumberValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var stringValue by remember(value, descriptor) { mutableStateOf(value?.string ?: descriptor?.defaultValue?.string) } + + TextField( + value = stringValue ?: "", + onValueChange = { newValue -> + stringValue = newValue + newValue.toDoubleOrNull()?.let { onValueChange(it.asValue()) } + }, + isError = stringValue?.toDoubleOrNull() != null, + modifier = Modifier.fillMaxWidth(), + keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number) + ) +} + + +@OptIn(ExperimentalMaterialApi::class) +@Composable +public fun ComboValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var expanded by remember { mutableStateOf(false) } + var selected by remember(value, descriptor) { mutableStateOf(value?.string ?: "") } + + ExposedDropdownMenuBox( + expanded = expanded, + onExpandedChange = { + expanded = !expanded + }, + modifier = Modifier.fillMaxWidth() + ) { + TextField( + value = selected, + onValueChange = {}, + readOnly = true, + trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) }, + ) + + ExposedDropdownMenu( + expanded = expanded, + onDismissRequest = { expanded = false } + ) { + descriptor?.allowedValues?.forEach { item: Value -> + DropdownMenuItem( + onClick = { + selected = item.string + expanded = false + onValueChange(selected.asValue()) + } + ) { + Text(item.string) + } + } + } + } +} + + +@Composable +public fun ColorValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + //var innerValue by remember { mutableStateOf(value ?: descriptor?.defaultValue) } + + Box(Modifier.fillMaxWidth()) { + ColorPicker(Modifier.fillMaxWidth()) { + if (it.isSpecified) { + onValueChange(it.toArgb().asValue()) + } + } + } +} + + +@OptIn(ExperimentalMaterialApi::class) +@Composable +public fun MultiSelectChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var expanded by remember { mutableStateOf(false) } + var selected: Set by remember(value) { + mutableStateOf(value?.list?.toSet() ?: emptySet()) + } + + ExposedDropdownMenuBox( + expanded = expanded, + onExpandedChange = { + expanded = !expanded + }, + modifier = Modifier.fillMaxWidth() + ) { + TextField( + value = selected.joinToString(prefix = "[", postfix = "]"), + onValueChange = {}, + readOnly = true, + trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) }, + ) + + ExposedDropdownMenu( + expanded = expanded, + onDismissRequest = { expanded = false } + ) { + descriptor?.allowedValues?.forEach { item: Value -> + val currentlySelected = item in selected + + DropdownMenuItem( + onClick = { + selected = if (currentlySelected) { + selected - item + } else { + selected + item + } + onValueChange(selected.asValue()) + } + ) { + if (currentlySelected) { + Icon(Icons.Default.CheckBox, "checked") + } else { + Icon(Icons.Default.CheckBoxOutlineBlank, "checked") + } + Text(item.string) + } + } + } + } +} + + +@Composable +public fun RangeValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + var innerValue by remember(value, descriptor) { mutableStateOf(value?.number ?: descriptor?.defaultValue?.number) } + val min by derivedStateOf { + descriptor?.attributes?.get("min").float ?: 0f + } + + val max by derivedStateOf { + descriptor?.attributes?.get("max").float ?: 0f + } + + val step by derivedStateOf { + descriptor?.attributes?.get("step").float ?: 0.1f + } + + Slider( + value = innerValue?.toFloat() ?: 0f, + onValueChange = { + innerValue = it + onValueChange(it.asValue()) + }, + valueRange = min..max, + steps = ((max - min) / step).roundToInt(), + modifier = Modifier.fillMaxWidth() + ) +} + +@Composable +public fun ValueChooser( + descriptor: MetaDescriptor?, + state: EditorPropertyState, + value: Value?, + onValueChange: (Value?) -> Unit, +) { + val rawInput by remember { mutableStateOf(false) } + + val type = descriptor?.valueTypes?.firstOrNull() + + when { + rawInput -> StringValueChooser(descriptor, state, value, onValueChange) + descriptor?.widgetType == "color" -> ColorValueChooser(descriptor, state, value, onValueChange) + descriptor?.widgetType == "multiSelect" -> MultiSelectChooser(descriptor, state, value, onValueChange) + descriptor?.widgetType == "range" -> RangeValueChooser(descriptor, state, value, onValueChange) + type == ValueType.BOOLEAN -> BooleanValueChooser(descriptor, state, value, onValueChange) + type == ValueType.NUMBER -> NumberValueChooser(descriptor, state, value, onValueChange) + descriptor?.allowedValues?.isNotEmpty() ?: false -> ComboValueChooser(descriptor, state, value, onValueChange) + //TODO handle lists + else -> StringValueChooser(descriptor, state, value, onValueChange) + } +} \ No newline at end of file diff --git a/visionforge-core/README.md b/visionforge-core/README.md index 2f9e6889..ebd092d8 100644 --- a/visionforge-core/README.md +++ b/visionforge-core/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-core:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-core:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-core:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-core:0.2.0") + implementation("space.kscience:visionforge-core:0.4.1") } ``` diff --git a/visionforge-core/api/visionforge-core.api b/visionforge-core/api/visionforge-core.api index f9099a99..9586823b 100644 --- a/visionforge-core/api/visionforge-core.api +++ b/visionforge-core/api/visionforge-core.api @@ -1,3 +1,66 @@ +public abstract class space/kscience/visionforge/AbstractControlVision : space/kscience/visionforge/AbstractVision, space/kscience/visionforge/ControlVision { + public static final field Companion Lspace/kscience/visionforge/AbstractControlVision$Companion; + public fun ()V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun dispatchControlEvent (Lspace/kscience/visionforge/VisionControlEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun getControlEventFlow ()Lkotlinx/coroutines/flow/SharedFlow; + public static final synthetic fun write$Self (Lspace/kscience/visionforge/AbstractControlVision;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +} + +public final class space/kscience/visionforge/AbstractControlVision$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public abstract class space/kscience/visionforge/AbstractVision : space/kscience/visionforge/Vision { + public static final field Companion Lspace/kscience/visionforge/AbstractVision$Companion; + public fun ()V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public fun getParent ()Lspace/kscience/visionforge/Vision; + public final fun getProperties ()Lspace/kscience/visionforge/MutableVisionProperties; + protected final fun getPropertiesInternal ()Lspace/kscience/dataforge/meta/MutableMeta; + public fun setParent (Lspace/kscience/visionforge/Vision;)V + protected final fun setPropertiesInternal (Lspace/kscience/dataforge/meta/MutableMeta;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/AbstractVision;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +} + +public final class space/kscience/visionforge/AbstractVision$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public abstract class space/kscience/visionforge/AbstractVisionGroup : space/kscience/visionforge/AbstractVision, space/kscience/visionforge/MutableVisionGroup { + public static final field Companion Lspace/kscience/visionforge/AbstractVisionGroup$Companion; + public fun ()V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public abstract fun createGroup ()Lspace/kscience/visionforge/AbstractVisionGroup; + public fun getChildren ()Lspace/kscience/visionforge/MutableVisionChildren; + public synthetic fun getChildren ()Lspace/kscience/visionforge/VisionChildren; + protected final fun getChildrenInternal ()Ljava/util/Map; + protected final fun setChildrenInternal (Ljava/util/Map;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/AbstractVisionGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +} + +public final class space/kscience/visionforge/AbstractVisionGroup$Companion { + public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun serializer ()Lkotlinx/serialization/KSerializer; + public final fun updateProperties (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/Name;)V + public static synthetic fun updateProperties$default (Lspace/kscience/visionforge/AbstractVisionGroup$Companion;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)V +} + +public class space/kscience/visionforge/AbstractVisionProperties : space/kscience/visionforge/MutableVisionProperties { + public fun (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/MutableMeta;)V + public fun getChanges ()Lkotlinx/coroutines/flow/Flow; + protected final fun getChangesInternal ()Lkotlinx/coroutines/flow/MutableSharedFlow; + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public synthetic fun getOwn ()Lspace/kscience/dataforge/meta/Meta; + public final fun getOwn ()Lspace/kscience/dataforge/meta/MutableMeta; + public fun getValue (Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/Value; + public final fun getVision ()Lspace/kscience/visionforge/Vision; + public fun invalidate (Lspace/kscience/dataforge/names/Name;)V + public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;Z)V + public fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Value;Z)V +} + public final class space/kscience/visionforge/Colors { public static final field BLUE_KEY Ljava/lang/String; public static final field GREEN_KEY Ljava/lang/String; @@ -156,68 +219,144 @@ public final class space/kscience/visionforge/Colors { public final fun rgbToString-8NGXxBw (BBB)Ljava/lang/String; } -public final class space/kscience/visionforge/ComputedVisionPropertiesKt { - public static final fun computeProperties (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static synthetic fun computeProperties$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; - public static final fun computeProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/values/Value; - public static synthetic fun computeProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; - public static final fun computePropertyNode (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/Meta; - public static synthetic fun computePropertyNode$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; - public static final fun computePropertyValues (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/values/MutableValueProvider; - public static synthetic fun computePropertyValues$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/values/MutableValueProvider; +public abstract interface class space/kscience/visionforge/ControlVision : space/kscience/visionforge/Vision { + public abstract fun dispatchControlEvent (Lspace/kscience/visionforge/VisionControlEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun getControlEventFlow ()Lkotlinx/coroutines/flow/SharedFlow; + public fun receiveEvent (Lspace/kscience/visionforge/VisionEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun receiveEvent$suspendImpl (Lspace/kscience/visionforge/ControlVision;Lspace/kscience/visionforge/VisionEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public final class space/kscience/visionforge/HtmlExportKt { - public static final fun makeFile (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;)Ljava/nio/file/Path; - public static synthetic fun makeFile$default (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/nio/file/Path; - public static final fun show (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;)V - public static synthetic fun show$default (Lspace/kscience/visionforge/html/Page;Ljava/nio/file/Path;ILjava/lang/Object;)V +public final class space/kscience/visionforge/ControlVisionKt { + public static final fun VisionInputEvent (Lspace/kscience/dataforge/meta/Value;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/VisionInputEvent; + public static synthetic fun VisionInputEvent$default (Lspace/kscience/dataforge/meta/Value;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionInputEvent; + public static final fun VisionSubmitEvent (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/VisionSubmitEvent; + public static synthetic fun VisionSubmitEvent$default (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionSubmitEvent; + public static final fun VisionValueChangeEvent (Lspace/kscience/dataforge/meta/Value;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/VisionValueChangeEvent; + public static synthetic fun VisionValueChangeEvent$default (Lspace/kscience/dataforge/meta/Value;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionValueChangeEvent; + public static final fun asyncControlEvent (Lspace/kscience/visionforge/ControlVision;Lspace/kscience/visionforge/VisionControlEvent;Lkotlinx/coroutines/CoroutineScope;)V + public static synthetic fun asyncControlEvent$default (Lspace/kscience/visionforge/ControlVision;Lspace/kscience/visionforge/VisionControlEvent;Lkotlinx/coroutines/CoroutineScope;ILjava/lang/Object;)V + public static final fun onSubmit (Lspace/kscience/visionforge/DataControl;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job; } -public abstract interface class space/kscience/visionforge/MutableVisionGroup : space/kscience/visionforge/VisionContainerBuilder, space/kscience/visionforge/VisionGroup { - public abstract fun onStructureChanged (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public abstract fun removeStructureListener (Ljava/lang/Object;)V +public abstract interface class space/kscience/visionforge/DataControl : space/kscience/visionforge/ControlVision { + public fun submit (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun submit$default (Lspace/kscience/visionforge/DataControl;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun submit$suspendImpl (Lspace/kscience/visionforge/DataControl;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public class space/kscience/visionforge/SimpleVisionPropertyContainer : space/kscience/dataforge/meta/Configurable, space/kscience/visionforge/VisionPropertyContainer { - public fun (Lspace/kscience/dataforge/meta/ObservableMutableMeta;)V - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; +public final class space/kscience/visionforge/FlowPropertyKt { + public static final fun flowProperty (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lkotlinx/coroutines/flow/Flow; + public static final fun flowProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun flowProperty$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun flowProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public static final fun flowPropertyValue (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lkotlinx/coroutines/flow/Flow; + public static final fun flowPropertyValue (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun flowPropertyValue$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun flowPropertyValue$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; +} + +public abstract interface class space/kscience/visionforge/MutableVisionChildren : space/kscience/visionforge/MutableVisionContainer, space/kscience/visionforge/VisionChildren { + public abstract fun clear ()V + public abstract fun getParent ()Lspace/kscience/visionforge/MutableVisionGroup; + public abstract fun set (Lspace/kscience/dataforge/names/NameToken;Lspace/kscience/visionforge/Vision;)V + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V +} + +public abstract interface class space/kscience/visionforge/MutableVisionContainer { + public abstract fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V +} + +public abstract interface class space/kscience/visionforge/MutableVisionGroup : space/kscience/visionforge/VisionGroup { + public abstract fun createGroup ()Lspace/kscience/visionforge/MutableVisionGroup; + public abstract fun getChildren ()Lspace/kscience/visionforge/MutableVisionChildren; + public fun update (Lspace/kscience/visionforge/VisionChange;)V +} + +public abstract interface class space/kscience/visionforge/MutableVisionProperties : space/kscience/dataforge/meta/MutableMetaProvider, space/kscience/visionforge/VisionProperties { + public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Meta; + public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MutableMeta; + public synthetic fun get (Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/Meta; + public fun get (Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/MutableMeta; + public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V + public abstract fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;Z)V + public fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Value;)V + public abstract fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Value;Z)V +} + +public final class space/kscience/visionforge/NullVision : space/kscience/visionforge/Vision { + public static final field INSTANCE Lspace/kscience/visionforge/NullVision; + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public fun getParent ()Lspace/kscience/visionforge/Vision; + public fun getProperties ()Lspace/kscience/visionforge/MutableVisionProperties; + public final fun serializer ()Lkotlinx/serialization/KSerializer; + public fun setParent (Lspace/kscience/visionforge/Vision;)V +} + +public final class space/kscience/visionforge/RootVision : space/kscience/visionforge/AbstractVisionGroup { + public fun (Lspace/kscience/visionforge/VisionManager;)V + public synthetic fun createGroup ()Lspace/kscience/visionforge/AbstractVisionGroup; + public synthetic fun createGroup ()Lspace/kscience/visionforge/MutableVisionGroup; + public fun createGroup ()Lspace/kscience/visionforge/SimpleVisionGroup; + public fun getManager ()Lspace/kscience/visionforge/VisionManager; +} + +public final class space/kscience/visionforge/SimpleVisionGroup : space/kscience/visionforge/AbstractVisionGroup, space/kscience/visionforge/MutableVisionContainer { + public static final field Companion Lspace/kscience/visionforge/SimpleVisionGroup$Companion; + public fun ()V + public synthetic fun createGroup ()Lspace/kscience/visionforge/AbstractVisionGroup; + public synthetic fun createGroup ()Lspace/kscience/visionforge/MutableVisionGroup; + public fun createGroup ()Lspace/kscience/visionforge/SimpleVisionGroup; + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V +} + +public final class space/kscience/visionforge/SimpleVisionGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/SimpleVisionGroup$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/SimpleVisionGroup; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/SimpleVisionGroup;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/SimpleVisionGroup$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/StyleReference { - public fun (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;)V + public fun (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)V public final fun getName ()Ljava/lang/String; - public final fun getOwner ()Lspace/kscience/visionforge/VisionGroup; + public final fun getOwner ()Lspace/kscience/visionforge/Vision; } public final class space/kscience/visionforge/StyleReferenceKt { - public static final fun style (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; - public static final fun style (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/Specification;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; - public static synthetic fun style$default (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; - public static synthetic fun style$default (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/Specification;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; - public static final fun useStyle (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/StyleReference;)V + public static final fun style (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; + public static final fun style (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/SchemeSpec;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadOnlyProperty; + public static synthetic fun style$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; + public static synthetic fun style$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/SchemeSpec;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; + public static final fun useStyle (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/StyleReference;Z)V + public static synthetic fun useStyle$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/StyleReference;ZILjava/lang/Object;)V } public final class space/kscience/visionforge/StyleSheet { public static final field Companion Lspace/kscience/visionforge/StyleSheet$Companion; - public static final synthetic fun box-impl (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/StyleSheet; - public static fun constructor-impl (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/VisionGroup; - public static final fun define-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V + public static final synthetic fun box-impl (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/StyleSheet; + public static fun constructor-impl (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/Vision; + public static final fun define-impl (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V public fun equals (Ljava/lang/Object;)Z - public static fun equals-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/Object;)Z - public static final fun equals-impl0 (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/visionforge/VisionGroup;)Z - public static final fun get-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; - public static final fun getItems-impl (Lspace/kscience/visionforge/VisionGroup;)Ljava/util/Map; + public static fun equals-impl (Lspace/kscience/visionforge/Vision;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/Vision;)Z + public static final fun get-impl (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; + public static final fun getItems-impl (Lspace/kscience/visionforge/Vision;)Ljava/util/Map; public fun hashCode ()I - public static fun hashCode-impl (Lspace/kscience/visionforge/VisionGroup;)I - public static final fun invoke-impl (Lspace/kscience/visionforge/VisionGroup;Lkotlin/jvm/functions/Function1;)V - public static final fun set-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public static final fun set-impl (Lspace/kscience/visionforge/VisionGroup;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V + public static fun hashCode-impl (Lspace/kscience/visionforge/Vision;)I + public static final fun invoke-impl (Lspace/kscience/visionforge/Vision;Lkotlin/jvm/functions/Function1;)V + public static final fun set-impl (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V public fun toString ()Ljava/lang/String; - public static fun toString-impl (Lspace/kscience/visionforge/VisionGroup;)Ljava/lang/String; - public final synthetic fun unbox-impl ()Lspace/kscience/visionforge/VisionGroup; + public static fun toString-impl (Lspace/kscience/visionforge/Vision;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lspace/kscience/visionforge/Vision; + public static final fun update-impl (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V } public final class space/kscience/visionforge/StyleSheet$Companion { @@ -227,99 +366,71 @@ public final class space/kscience/visionforge/StyleSheet$Companion { public final class space/kscience/visionforge/StyleSheetKt { public static final fun getStyle (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; public static final fun getStyleNodes (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Ljava/util/List; - public static final fun getStyleProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/values/Value; - public static final fun getStyleSheet (Lspace/kscience/visionforge/VisionGroup;)Lspace/kscience/visionforge/VisionGroup; + public static final fun getStyleProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Meta; + public static final fun getStyleSheet (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/Vision; public static final fun getStyles (Lspace/kscience/visionforge/Vision;)Ljava/util/List; public static final fun setStyles (Lspace/kscience/visionforge/Vision;Ljava/util/List;)V - public static final fun useStyle (Lspace/kscience/visionforge/Vision;Ljava/lang/String;)V + public static final fun useStyle (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Z)V + public static synthetic fun useStyle$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;ZILjava/lang/Object;)V } -public abstract interface class space/kscience/visionforge/Vision : space/kscience/dataforge/meta/Configurable, space/kscience/dataforge/meta/descriptors/Described { +public final class space/kscience/visionforge/UsePropertyKt { + public static final fun onPropertyChange (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; + public static final fun onPropertyChange (Lspace/kscience/visionforge/Vision;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job; + public static synthetic fun onPropertyChange$default (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static synthetic fun onPropertyChange$default (Lspace/kscience/visionforge/Vision;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static final fun useProperty (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/Job; + public static final fun useProperty (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job; + public static final fun useProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/Job; + public static synthetic fun useProperty$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static synthetic fun useProperty$default (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static synthetic fun useProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/Job; +} + +public abstract interface class space/kscience/visionforge/Vision : space/kscience/dataforge/meta/descriptors/Described { public static final field Companion Lspace/kscience/visionforge/Vision$Companion; + public static final field STYLE_TARGET Ljava/lang/String; public static final field TYPE Ljava/lang/String; public abstract fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; public fun getManager ()Lspace/kscience/visionforge/VisionManager; - public abstract fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - public abstract fun getParent ()Lspace/kscience/visionforge/VisionGroup; - public abstract fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; - public abstract fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public abstract fun setParent (Lspace/kscience/visionforge/VisionGroup;)V - public abstract fun update (Lspace/kscience/visionforge/VisionChange;)V + public abstract fun getParent ()Lspace/kscience/visionforge/Vision; + public abstract fun getProperties ()Lspace/kscience/visionforge/MutableVisionProperties; + public fun receiveEvent (Lspace/kscience/visionforge/VisionEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun receiveEvent$suspendImpl (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/VisionEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public abstract fun setParent (Lspace/kscience/visionforge/Vision;)V + public fun update (Lspace/kscience/visionforge/VisionChange;)V } public final class space/kscience/visionforge/Vision$Companion { + public static final field STYLE_TARGET Ljava/lang/String; public static final field TYPE Ljava/lang/String; public final fun getSTYLE_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getVISIBLE_KEY ()Lspace/kscience/dataforge/names/Name; } -public class space/kscience/visionforge/VisionBase : space/kscience/visionforge/Vision { - public static final field Companion Lspace/kscience/visionforge/VisionBase$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/MutableMeta;)V - public synthetic fun (Lspace/kscience/visionforge/VisionGroup;Lspace/kscience/dataforge/meta/MutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public final fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; - protected final fun getOrCreateProperties ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getParent ()Lspace/kscience/visionforge/VisionGroup; - protected final fun getProperties ()Lspace/kscience/dataforge/meta/MutableMeta; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public fun setParent (Lspace/kscience/visionforge/VisionGroup;)V - protected final fun setProperties (Lspace/kscience/dataforge/meta/MutableMeta;)V - public fun update (Lspace/kscience/visionforge/VisionChange;)V - public static final fun write$Self (Lspace/kscience/visionforge/VisionBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/VisionBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/VisionBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionBase; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionBase;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionBase$Companion { - public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public final fun serializer ()Lkotlinx/serialization/KSerializer; - public final fun updateProperties (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V -} - public abstract interface annotation class space/kscience/visionforge/VisionBuilder : java/lang/annotation/Annotation { } -public final class space/kscience/visionforge/VisionChange { +public final class space/kscience/visionforge/VisionChange : space/kscience/visionforge/VisionEvent { public static final field Companion Lspace/kscience/visionforge/VisionChange$Companion; public fun ()V - public synthetic fun (IZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)V - public synthetic fun (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Z - public final fun component2 ()Lspace/kscience/visionforge/Vision; - public final fun component3 ()Lspace/kscience/dataforge/meta/Meta; - public final fun component4 ()Ljava/util/Map; - public final fun copy (ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)Lspace/kscience/visionforge/VisionChange; - public static synthetic fun copy$default (Lspace/kscience/visionforge/VisionChange;ZLspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionChange; + public fun (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)V + public synthetic fun (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Lspace/kscience/visionforge/Vision; + public final fun component2 ()Lspace/kscience/dataforge/meta/Meta; + public final fun component3 ()Ljava/util/Map; + public final fun copy (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;)Lspace/kscience/visionforge/VisionChange; + public static synthetic fun copy$default (Lspace/kscience/visionforge/VisionChange;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;Ljava/util/Map;ILjava/lang/Object;)Lspace/kscience/visionforge/VisionChange; public fun equals (Ljava/lang/Object;)Z public final fun getChildren ()Ljava/util/Map; - public final fun getDelete ()Z public final fun getProperties ()Lspace/kscience/dataforge/meta/Meta; public final fun getVision ()Lspace/kscience/visionforge/Vision; public fun hashCode ()I public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/VisionChange;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/VisionChange$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/VisionChange$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionChange; @@ -333,36 +444,75 @@ public final class space/kscience/visionforge/VisionChange$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/VisionChangeBuilder : space/kscience/visionforge/VisionContainerBuilder { +public final class space/kscience/visionforge/VisionChangeBuilder : space/kscience/visionforge/MutableVisionContainer { public fun ()V - public final fun deepCopy ()Lspace/kscience/visionforge/VisionChange; + public final fun deepCopy (Lspace/kscience/visionforge/VisionManager;)Lspace/kscience/visionforge/VisionChange; + public final fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/VisionChangeBuilder; public final fun isEmpty ()Z public final fun propertyChanged (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V - public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V + public final fun toJsonString (Lspace/kscience/visionforge/VisionManager;)Ljava/lang/String; } public final class space/kscience/visionforge/VisionChangeKt { - public static final fun VisionChange (Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/VisionChange; - public static final fun flowChanges-HG0u8IE (Lspace/kscience/visionforge/Vision;J)Lkotlinx/coroutines/flow/Flow; + public static final fun VisionChange (Lspace/kscience/visionforge/VisionManager;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/VisionChange; + public static final fun flowChanges-8Mi8wO0 (Lspace/kscience/visionforge/Vision;JZ)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun flowChanges-8Mi8wO0$default (Lspace/kscience/visionforge/Vision;JZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; +} + +public abstract interface class space/kscience/visionforge/VisionChildren : space/kscience/visionforge/VisionContainer { + public static final field Companion Lspace/kscience/visionforge/VisionChildren$Companion; + public static final field STATIC_TOKEN_BODY Ljava/lang/String; + public abstract fun get (Lspace/kscience/dataforge/names/NameToken;)Lspace/kscience/visionforge/Vision; + public abstract fun getChanges ()Lkotlinx/coroutines/flow/Flow; + public fun getChild (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; + public abstract fun getKeys ()Ljava/util/Set; + public abstract fun getParent ()Lspace/kscience/visionforge/Vision; + public fun getValues ()Ljava/lang/Iterable; +} + +public final class space/kscience/visionforge/VisionChildren$Companion { + public static final field STATIC_TOKEN_BODY Ljava/lang/String; + public final fun empty (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/VisionChildren; +} + +public abstract interface class space/kscience/visionforge/VisionClient : space/kscience/dataforge/context/Plugin { + public abstract fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public abstract fun notifyPropertyChanged (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V + public abstract fun sendEvent (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionEvent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class space/kscience/visionforge/VisionClientKt { + public static final fun notifyPropertyChanged (Lspace/kscience/visionforge/VisionClient;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;Ljava/lang/Number;)V + public static final fun notifyPropertyChanged (Lspace/kscience/visionforge/VisionClient;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;Ljava/lang/String;)V + public static final fun notifyPropertyChanged (Lspace/kscience/visionforge/VisionClient;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;Lspace/kscience/dataforge/meta/Meta;)V + public static final fun notifyPropertyChanged (Lspace/kscience/visionforge/VisionClient;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;Z)V + public static final fun sendEventAsync (Lspace/kscience/visionforge/VisionClient;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionEvent;)Lkotlinx/coroutines/Job; } public abstract interface class space/kscience/visionforge/VisionContainer { - public abstract fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; + public abstract fun getChild (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; } -public abstract interface class space/kscience/visionforge/VisionContainerBuilder { - public abstract fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V +public final class space/kscience/visionforge/VisionContainerKt { + public static final fun asSequence (Lspace/kscience/visionforge/VisionChildren;)Lkotlin/sequences/Sequence; + public static final fun forEach (Lspace/kscience/visionforge/VisionChildren;Lkotlin/jvm/functions/Function2;)V + public static final fun get (Lspace/kscience/visionforge/VisionChildren;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; + public static final fun get (Lspace/kscience/visionforge/VisionChildren;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; + public static final fun getChild (Lspace/kscience/visionforge/VisionContainer;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; + public static final fun isEmpty (Lspace/kscience/visionforge/VisionChildren;)Z + public static final fun iterator (Lspace/kscience/visionforge/VisionChildren;)Ljava/util/Iterator; + public static final fun set (Lspace/kscience/visionforge/MutableVisionChildren;Ljava/lang/String;Lspace/kscience/visionforge/Vision;)V + public static final fun set (Lspace/kscience/visionforge/MutableVisionChildren;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V + public static final fun setChild (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lspace/kscience/visionforge/Vision;)V + public static final fun static (Lspace/kscience/visionforge/MutableVisionChildren;Lspace/kscience/visionforge/Vision;)V } -public final class space/kscience/visionforge/VisionDelegatesKt { - public static final fun numberProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZ)Lkotlin/properties/ReadWriteProperty; - public static final fun numberProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function0;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun numberProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun numberProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static final fun propertyValue (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZ)Lkotlin/properties/ReadWriteProperty; - public static final fun propertyValue (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun propertyValue$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; - public static synthetic fun propertyValue$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; +public abstract class space/kscience/visionforge/VisionControlEvent : space/kscience/dataforge/meta/MetaRepr, space/kscience/visionforge/VisionEvent { + public fun ()V + public abstract fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public fun toMeta ()Lspace/kscience/dataforge/meta/Meta; + public fun toString ()Ljava/lang/String; } public final class space/kscience/visionforge/VisionDescriptorKt { @@ -382,82 +532,57 @@ public final class space/kscience/visionforge/VisionDescriptorKt { public static final fun setWidgetType (Lspace/kscience/dataforge/meta/descriptors/MetaDescriptorBuilder;Ljava/lang/String;)V } -public abstract interface class space/kscience/visionforge/VisionGroup : space/kscience/dataforge/provider/Provider, space/kscience/visionforge/Vision, space/kscience/visionforge/VisionContainer { - public static final field Companion Lspace/kscience/visionforge/VisionGroup$Companion; - public static final field STYLE_TARGET Ljava/lang/String; - public fun content (Ljava/lang/String;)Ljava/util/Map; - public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/Vision; - public abstract fun getChildren ()Ljava/util/Map; - public fun getDefaultTarget ()Ljava/lang/String; +public abstract interface class space/kscience/visionforge/VisionEvent { + public static final field Companion Lspace/kscience/visionforge/VisionEvent$Companion; } -public final class space/kscience/visionforge/VisionGroup$Companion { - public static final field STYLE_TARGET Ljava/lang/String; +public final class space/kscience/visionforge/VisionEvent$Companion { + public final fun getCLICK_EVENT_KEY ()Lspace/kscience/dataforge/names/Name; } -public class space/kscience/visionforge/VisionGroupBase : space/kscience/visionforge/VisionBase, space/kscience/visionforge/MutableVisionGroup { - public static final field Companion Lspace/kscience/visionforge/VisionGroupBase$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/util/Map;)V - public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun addStatic (Lspace/kscience/visionforge/Vision;)V - protected final fun childrenChanged (Lspace/kscience/dataforge/names/Name;)V - protected fun createGroup ()Lspace/kscience/visionforge/VisionGroupBase; - public fun getChildren ()Ljava/util/Map; - protected final fun getChildrenInternal ()Ljava/util/Map; - public fun invalidateProperty (Lspace/kscience/dataforge/names/Name;)V - public fun onStructureChanged (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public fun removeStructureListener (Ljava/lang/Object;)V - public fun set (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V +public abstract interface class space/kscience/visionforge/VisionGroup : space/kscience/visionforge/Vision { + public abstract fun getChildren ()Lspace/kscience/visionforge/VisionChildren; public fun update (Lspace/kscience/visionforge/VisionChange;)V - public static final fun write$Self (Lspace/kscience/visionforge/VisionGroupBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V -} - -public final class space/kscience/visionforge/VisionGroupBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/VisionGroupBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionGroupBase; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionGroupBase;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionGroupBase$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/VisionGroupBaseKt { - public static final fun setAsRoot (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/VisionManager;)V } public final class space/kscience/visionforge/VisionGroupKt { - public static final fun get (Lspace/kscience/visionforge/VisionContainer;Ljava/lang/String;)Lspace/kscience/visionforge/Vision; - public static final fun getStructureChanges (Lspace/kscience/visionforge/MutableVisionGroup;)Lkotlinx/coroutines/flow/Flow; - public static final fun isEmpty (Lspace/kscience/visionforge/VisionGroup;)Z - public static final fun iterator (Lspace/kscience/visionforge/VisionGroup;)Ljava/util/Iterator; - public static final fun removeAll (Lspace/kscience/visionforge/MutableVisionGroup;)V - public static final fun set (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lspace/kscience/visionforge/Vision;)V - public static final fun set (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/NameToken;Lspace/kscience/visionforge/Vision;)V + public static final fun getChildren (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/VisionChildren; + public static final fun group (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/SimpleVisionGroup; + public static final fun group (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/SimpleVisionGroup; + public static synthetic fun group$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/SimpleVisionGroup; + public static synthetic fun group$default (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/SimpleVisionGroup; +} + +public final class space/kscience/visionforge/VisionInputEvent : space/kscience/visionforge/VisionControlEvent { + public static final field Companion Lspace/kscience/visionforge/VisionInputEvent$Companion; + public fun (Lspace/kscience/dataforge/meta/Meta;)V + public fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public final fun getName ()Lspace/kscience/dataforge/names/Name; + public final fun getValue ()Lspace/kscience/dataforge/meta/Value; + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/VisionInputEvent$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/VisionInputEvent$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionInputEvent; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionInputEvent;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/VisionInputEvent$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/VisionKt { - public static final fun getPropertyChanges (Lspace/kscience/visionforge/Vision;)Lkotlinx/coroutines/flow/Flow; - public static final fun getProperty (Lspace/kscience/visionforge/Vision;Ljava/lang/String;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/Vision;Ljava/lang/String;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; public static final fun getVisible (Lspace/kscience/visionforge/Vision;)Ljava/lang/Boolean; - public static final fun onPropertyChange (Lspace/kscience/visionforge/Vision;Lkotlin/jvm/functions/Function2;)V - public static final fun setProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Ljava/lang/Object;)V - public static final fun setPropertyNode (Lspace/kscience/visionforge/Vision;Ljava/lang/String;Ljava/lang/Object;)V public static final fun setVisible (Lspace/kscience/visionforge/Vision;Ljava/lang/Boolean;)V - public static final fun useProperty (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V - public static synthetic fun useProperty$default (Lspace/kscience/visionforge/Vision;Lkotlin/reflect/KProperty1;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V } -public final class space/kscience/visionforge/VisionManager : space/kscience/dataforge/context/AbstractPlugin { +public final class space/kscience/visionforge/VisionManager : space/kscience/dataforge/context/AbstractPlugin, space/kscience/visionforge/MutableVisionContainer { public static final field Companion Lspace/kscience/visionforge/VisionManager$Companion; public static final field VISION_SERIALIZER_MODULE_TARGET Ljava/lang/String; public fun (Lspace/kscience/dataforge/meta/Meta;)V @@ -473,19 +598,43 @@ public final class space/kscience/visionforge/VisionManager : space/kscience/dat public final fun getJsonFormat ()Lkotlinx/serialization/json/Json; public final fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V } public final class space/kscience/visionforge/VisionManager$Companion : space/kscience/dataforge/context/PluginFactory { + public synthetic fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object; + public fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/visionforge/VisionManager; public final fun getDefaultJson ()Lkotlinx/serialization/json/Json; public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/VisionManager; } public final class space/kscience/visionforge/VisionManagerKt { public static final fun encodeToString (Lspace/kscience/visionforge/Vision;)Ljava/lang/String; public static final fun getVisionManager (Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/VisionManager; + public static final fun setAsRoot (Lspace/kscience/visionforge/Vision;Lspace/kscience/visionforge/VisionManager;)V +} + +public final class space/kscience/visionforge/VisionMetaEvent : space/kscience/dataforge/meta/MetaRepr, space/kscience/visionforge/VisionEvent { + public static final field Companion Lspace/kscience/visionforge/VisionMetaEvent$Companion; + public fun (Lspace/kscience/dataforge/meta/Meta;)V + public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public fun toMeta ()Lspace/kscience/dataforge/meta/Meta; + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/VisionMetaEvent$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/VisionMetaEvent$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionMetaEvent; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionMetaEvent;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/VisionMetaEvent$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public abstract class space/kscience/visionforge/VisionPlugin : space/kscience/dataforge/context/AbstractPlugin { @@ -497,69 +646,148 @@ public abstract class space/kscience/visionforge/VisionPlugin : space/kscience/d protected abstract fun getVisionSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; } -public abstract interface class space/kscience/visionforge/VisionPropertyContainer { - public abstract fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; - public abstract fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public static synthetic fun getProperty$default (Lspace/kscience/visionforge/VisionPropertyContainer;Lspace/kscience/dataforge/names/Name;ZZZILjava/lang/Object;)Lspace/kscience/dataforge/values/Value; +public abstract interface class space/kscience/visionforge/VisionProperties : space/kscience/dataforge/meta/MetaProvider { + public fun flowChanges ()Lkotlinx/coroutines/flow/Flow; + public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Meta; + public abstract fun get (Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/Meta; + public static synthetic fun get$default (Lspace/kscience/visionforge/VisionProperties;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; + public abstract fun getChanges ()Lkotlinx/coroutines/flow/Flow; + public abstract fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public abstract fun getOwn ()Lspace/kscience/dataforge/meta/Meta; + public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Value; + public abstract fun getValue (Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/Value; + public static synthetic fun getValue$default (Lspace/kscience/visionforge/VisionProperties;Lspace/kscience/dataforge/names/Name;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Value; + public abstract fun invalidate (Lspace/kscience/dataforge/names/Name;)V } -public final class space/kscience/visionforge/html/HeadersKt { - public static final fun importScriptHeader (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;)Lkotlin/jvm/functions/Function1; - public static synthetic fun importScriptHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; +public final class space/kscience/visionforge/VisionPropertiesKt { + public static final fun get (Lspace/kscience/visionforge/MutableVisionProperties;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/MutableMeta; + public static final fun get (Lspace/kscience/visionforge/VisionProperties;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/Meta; + public static synthetic fun get$default (Lspace/kscience/visionforge/MutableVisionProperties;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MutableMeta; + public static synthetic fun get$default (Lspace/kscience/visionforge/VisionProperties;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; + public static final fun getValue (Lspace/kscience/visionforge/VisionProperties;Ljava/lang/String;ZLjava/lang/Boolean;)Lspace/kscience/dataforge/meta/Value; + public static synthetic fun getValue$default (Lspace/kscience/visionforge/VisionProperties;Ljava/lang/String;ZLjava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/Value; + public static final fun invoke (Lspace/kscience/visionforge/MutableVisionProperties;Lkotlin/jvm/functions/Function1;)V + public static final fun remove (Lspace/kscience/visionforge/MutableVisionProperties;Ljava/lang/String;)V + public static final fun remove (Lspace/kscience/visionforge/MutableVisionProperties;Lspace/kscience/dataforge/names/Name;)V + public static final fun root (Lspace/kscience/visionforge/MutableVisionProperties;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lspace/kscience/dataforge/meta/MutableMeta; + public static synthetic fun root$default (Lspace/kscience/visionforge/MutableVisionProperties;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MutableMeta; } -public final class space/kscience/visionforge/html/HtmlFormFragment { - public final fun get (Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; - public final fun getFormBody ()Lkotlin/jvm/functions/Function1; - public final fun getValues ()Lspace/kscience/dataforge/meta/Meta; - public final fun getVision ()Lspace/kscience/visionforge/html/VisionOfHtmlForm; -} - -public final class space/kscience/visionforge/html/HtmlFragmentKt { - public static final fun fragment (Lkotlinx/html/FlowContent;Lkotlin/jvm/functions/Function1;)V - public static final fun fragment (Lkotlinx/html/TagConsumer;Lkotlin/jvm/functions/Function1;)V - public static final fun plus (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static final fun renderToString (Lkotlin/jvm/functions/Function1;)Ljava/lang/String; -} - -public final class space/kscience/visionforge/html/HtmlVisionRendererKt { - public static final fun HtmlVisionFragment (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static final fun visionFragment (Lkotlinx/html/FlowContent;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ljava/util/Map; - public static final fun visionFragment (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ljava/util/Map; - public static synthetic fun visionFragment$default (Lkotlinx/html/FlowContent;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/Map; - public static synthetic fun visionFragment$default (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/Map; -} - -public final class space/kscience/visionforge/html/Page { - public static final field Companion Lspace/kscience/visionforge/html/Page$Companion; - public fun (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)V - public synthetic fun (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Lspace/kscience/dataforge/context/Context; - public final fun component2 ()Ljava/util/Map; - public final fun component3 ()Lkotlin/jvm/functions/Function1; - public final fun copy (Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/Page; - public static synthetic fun copy$default (Lspace/kscience/visionforge/html/Page;Lspace/kscience/dataforge/context/Context;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/Page; - public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Lkotlin/jvm/functions/Function1; - public final fun getContext ()Lspace/kscience/dataforge/context/Context; - public final fun getHeaders ()Ljava/util/Map; - public fun hashCode ()I - public final fun render (Lkotlinx/html/TagConsumer;)Ljava/lang/Object; +public final class space/kscience/visionforge/VisionSubmitEvent : space/kscience/visionforge/VisionControlEvent { + public static final field Companion Lspace/kscience/visionforge/VisionSubmitEvent$Companion; + public fun (Lspace/kscience/dataforge/meta/Meta;)V + public fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public final fun getName ()Lspace/kscience/dataforge/names/Name; + public final fun getPayload ()Lspace/kscience/dataforge/meta/Meta; public fun toString ()Ljava/lang/String; } -public final class space/kscience/visionforge/html/Page$Companion { - public final fun scriptHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static synthetic fun scriptHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; - public final fun styleSheetHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1; - public static synthetic fun styleSheetHeader$default (Lspace/kscience/visionforge/html/Page$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/jvm/functions/Function1; - public final fun title (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +public final class space/kscience/visionforge/VisionSubmitEvent$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/VisionSubmitEvent$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionSubmitEvent; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionSubmitEvent;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/VisionSubmitEvent$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/VisionValueChangeEvent : space/kscience/visionforge/VisionControlEvent { + public static final field Companion Lspace/kscience/visionforge/VisionValueChangeEvent$Companion; + public fun (Lspace/kscience/dataforge/meta/Meta;)V + public fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public final fun getName ()Lspace/kscience/dataforge/names/Name; + public final fun getValue ()Lspace/kscience/dataforge/meta/Value; + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/VisionValueChangeEvent$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/VisionValueChangeEvent$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/VisionValueChangeEvent; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/VisionValueChangeEvent;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/VisionValueChangeEvent$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/html/HeadersKt { + public static final fun importScriptHeader (Lspace/kscience/visionforge/html/VisionPage$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/ClassLoader;)Lspace/kscience/visionforge/html/HtmlFragment; + public static synthetic fun importScriptHeader$default (Lspace/kscience/visionforge/html/VisionPage$Companion;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;Ljava/nio/file/Path;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lspace/kscience/visionforge/html/HtmlFragment; +} + +public final class space/kscience/visionforge/html/HtmlExportKt { + public static final fun makeFile (Lspace/kscience/visionforge/html/VisionPage;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;)Ljava/nio/file/Path; + public static synthetic fun makeFile$default (Lspace/kscience/visionforge/html/VisionPage;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/nio/file/Path; + public static final fun show (Lspace/kscience/visionforge/html/VisionPage;Ljava/nio/file/Path;)V + public static synthetic fun show$default (Lspace/kscience/visionforge/html/VisionPage;Ljava/nio/file/Path;ILjava/lang/Object;)V +} + +public abstract interface class space/kscience/visionforge/html/HtmlFragment { + public abstract fun append (Lkotlinx/html/TagConsumer;)V +} + +public final class space/kscience/visionforge/html/HtmlFragmentKt { + public static final fun appendFragment (Lkotlinx/html/FlowContent;Lspace/kscience/visionforge/html/HtmlFragment;)V + public static final fun appendFragment (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/html/HtmlFragment;)V + public static final fun appendTo (Lspace/kscience/visionforge/html/HtmlFragment;Lkotlinx/html/TagConsumer;)V + public static final fun plus (Lspace/kscience/visionforge/html/HtmlFragment;Lspace/kscience/visionforge/html/HtmlFragment;)Lspace/kscience/visionforge/html/HtmlFragment; + public static final fun renderToString (Lspace/kscience/visionforge/html/HtmlFragment;)Ljava/lang/String; +} + +public abstract interface class space/kscience/visionforge/html/HtmlVisionContext : space/kscience/dataforge/context/ContextAware { + public fun generateId (Lspace/kscience/dataforge/names/Name;)Ljava/lang/String; + public abstract fun renderVision (Lkotlinx/html/DIV;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V +} + +public final class space/kscience/visionforge/html/HtmlVisionContextKt { + public static final fun vision (Lspace/kscience/visionforge/html/HtmlVisionContext;Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun vision (Lspace/kscience/visionforge/html/HtmlVisionContext;Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun vision$default (Lspace/kscience/visionforge/html/HtmlVisionContext;Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class space/kscience/visionforge/html/HtmlVisionFragment { + public abstract fun append (Lspace/kscience/visionforge/html/VisionTagConsumer;)V +} + +public final class space/kscience/visionforge/html/HtmlVisionRendererKt { + public static final fun appendTo (Lspace/kscience/visionforge/html/HtmlVisionFragment;Lspace/kscience/visionforge/html/VisionTagConsumer;)V + public static final fun visionFragment (Lkotlinx/html/FlowContent;Lspace/kscience/visionforge/VisionManager;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static final fun visionFragment (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/VisionManager;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static synthetic fun visionFragment$default (Lkotlinx/html/FlowContent;Lspace/kscience/visionforge/VisionManager;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V + public static synthetic fun visionFragment$default (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/VisionManager;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V +} + +public final class space/kscience/visionforge/html/InputFeedbackMode : java/lang/Enum { + public static final field Companion Lspace/kscience/visionforge/html/InputFeedbackMode$Companion; + public static final field NONE Lspace/kscience/visionforge/html/InputFeedbackMode; + public static final field ONCHANGE Lspace/kscience/visionforge/html/InputFeedbackMode; + public static final field ONINPUT Lspace/kscience/visionforge/html/InputFeedbackMode; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/html/InputFeedbackMode; + public static fun values ()[Lspace/kscience/visionforge/html/InputFeedbackMode; +} + +public final class space/kscience/visionforge/html/InputFeedbackMode$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/html/ResourceLocation : java/lang/Enum { public static final field EMBED Lspace/kscience/visionforge/html/ResourceLocation; public static final field LOCAL Lspace/kscience/visionforge/html/ResourceLocation; public static final field SYSTEM Lspace/kscience/visionforge/html/ResourceLocation; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/html/ResourceLocation; public static fun values ()[Lspace/kscience/visionforge/html/ResourceLocation; } @@ -567,22 +795,30 @@ public final class space/kscience/visionforge/html/ResourceLocation : java/lang/ public abstract interface annotation class space/kscience/visionforge/html/VisionDSL : java/lang/annotation/Annotation { } +public final class space/kscience/visionforge/html/VisionDisplay { + public fun (Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V + public final fun component1 ()Lspace/kscience/visionforge/VisionManager; + public final fun component2 ()Lspace/kscience/visionforge/Vision; + public final fun component3 ()Lspace/kscience/dataforge/meta/Meta; + public final fun copy (Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/visionforge/html/VisionDisplay; + public static synthetic fun copy$default (Lspace/kscience/visionforge/html/VisionDisplay;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionDisplay; + public fun equals (Ljava/lang/Object;)Z + public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta; + public final fun getVision ()Lspace/kscience/visionforge/Vision; + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class space/kscience/visionforge/html/VisionOfCheckbox : space/kscience/visionforge/html/VisionOfHtmlInput { public static final field Companion Lspace/kscience/visionforge/html/VisionOfCheckbox$Companion; public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getChecked ()Ljava/lang/Boolean; - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; public final fun setChecked (Ljava/lang/Boolean;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfCheckbox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/html/VisionOfCheckbox$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfCheckbox$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfCheckbox; @@ -596,19 +832,45 @@ public final class space/kscience/visionforge/html/VisionOfCheckbox$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/html/VisionOfHtmlForm : space/kscience/visionforge/html/VisionOfHtmlInput { +public abstract interface class space/kscience/visionforge/html/VisionOfHtml : space/kscience/visionforge/Vision { + public fun getClasses ()Ljava/util/Set; + public fun getStyleString ()Ljava/lang/String; + public fun setClasses (Ljava/util/Set;)V + public fun setStyleString (Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/html/VisionOfHtmlButton : space/kscience/visionforge/AbstractControlVision, space/kscience/visionforge/DataControl, space/kscience/visionforge/html/VisionOfHtml { + public static final field Companion Lspace/kscience/visionforge/html/VisionOfHtmlButton$Companion; + public fun ()V + public final fun getLabel ()Ljava/lang/String; + public final fun setLabel (Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/html/VisionOfHtmlButton$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfHtmlButton$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfHtmlButton; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfHtmlButton;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/html/VisionOfHtmlButton$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/html/VisionOfHtmlForm : space/kscience/visionforge/AbstractControlVision, space/kscience/visionforge/DataControl, space/kscience/visionforge/html/VisionOfHtml { public static final field Companion Lspace/kscience/visionforge/html/VisionOfHtmlForm$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/lang/String;)V public final fun getFormId ()Ljava/lang/String; public final fun getValues ()Lspace/kscience/dataforge/meta/Meta; public final fun setValues (Lspace/kscience/dataforge/meta/Meta;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfHtmlForm;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/html/VisionOfHtmlForm$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfHtmlForm$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; @@ -623,41 +885,70 @@ public final class space/kscience/visionforge/html/VisionOfHtmlForm$Companion { } public final class space/kscience/visionforge/html/VisionOfHtmlFormKt { - public static final fun HtmlFormFragment (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/HtmlFormFragment; - public static synthetic fun HtmlFormFragment$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/HtmlFormFragment; - public static final fun formFragment (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; - public static synthetic fun formFragment$default (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfHtmlForm; + public static final fun button (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfHtmlButton; + public static synthetic fun button$default (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfHtmlButton; + public static final fun onFormSubmit (Lspace/kscience/visionforge/html/VisionOfHtmlForm;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/Job; + public static final fun visionOfForm (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/html/VisionOfHtmlForm;Ljava/lang/String;Lkotlinx/html/FormEncType;Lkotlinx/html/FormMethod;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun visionOfForm$default (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/html/VisionOfHtmlForm;Ljava/lang/String;Lkotlinx/html/FormEncType;Lkotlinx/html/FormMethod;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; } -public abstract class space/kscience/visionforge/html/VisionOfHtmlInput : space/kscience/visionforge/VisionBase { +public class space/kscience/visionforge/html/VisionOfHtmlInput : space/kscience/visionforge/AbstractControlVision, space/kscience/visionforge/html/VisionOfHtml { public static final field Companion Lspace/kscience/visionforge/html/VisionOfHtmlInput$Companion; - public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public fun (Ljava/lang/String;)V public final fun getDisabled ()Z + public final fun getFieldName ()Ljava/lang/String; + public final fun getInputType ()Ljava/lang/String; + public final fun getValue ()Lspace/kscience/dataforge/meta/Value; public final fun setDisabled (Z)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public final fun setFieldName (Ljava/lang/String;)V + public final fun setValue (Lspace/kscience/dataforge/meta/Value;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +} + +public final class space/kscience/visionforge/html/VisionOfHtmlInput$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfHtmlInput$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfHtmlInput; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfHtmlInput;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/html/VisionOfHtmlInput$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class space/kscience/visionforge/html/VisionOfHtmlKt { + public static final fun content (Lspace/kscience/visionforge/html/VisionOfPlainHtml;Lkotlin/jvm/functions/Function1;)V + public static final fun html (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfPlainHtml; + public static final fun htmlCheckBox (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfCheckbox; + public static synthetic fun htmlCheckBox$default (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfCheckbox; + public static final fun htmlInput (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfHtmlInput; + public static synthetic fun htmlInput$default (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfHtmlInput; + public static final fun htmlNumberField (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfNumberField; + public static synthetic fun htmlNumberField$default (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfNumberField; + public static final fun htmlRangeField (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfRangeField; + public static synthetic fun htmlRangeField$default (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfRangeField; + public static final fun htmlTextField (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionOfTextField; + public static synthetic fun htmlTextField$default (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionOfTextField; + public static final fun onInput (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job; + public static synthetic fun onInput$default (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static final fun onValueChange (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job; + public static synthetic fun onValueChange$default (Lspace/kscience/visionforge/html/VisionOfHtmlInput;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job; +} + public final class space/kscience/visionforge/html/VisionOfNumberField : space/kscience/visionforge/html/VisionOfHtmlInput { public static final field Companion Lspace/kscience/visionforge/html/VisionOfNumberField$Companion; public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; - public final fun getValue ()Ljava/lang/Number; - public final fun setValue (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfNumberField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public final fun getNumberValue ()Ljava/lang/Number; + public final fun setNumberValue (Ljava/lang/Number;)V } public final class space/kscience/visionforge/html/VisionOfNumberField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfNumberField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfNumberField; @@ -671,24 +962,41 @@ public final class space/kscience/visionforge/html/VisionOfNumberField$Companion public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class space/kscience/visionforge/html/VisionOfPlainHtml : space/kscience/visionforge/AbstractVision, space/kscience/visionforge/html/VisionOfHtml { + public static final field Companion Lspace/kscience/visionforge/html/VisionOfPlainHtml$Companion; + public fun ()V + public final fun getContent ()Ljava/lang/String; + public final fun setContent (Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/html/VisionOfPlainHtml$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfPlainHtml$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfPlainHtml; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/html/VisionOfPlainHtml;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/html/VisionOfPlainHtml$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class space/kscience/visionforge/html/VisionOfRangeField : space/kscience/visionforge/html/VisionOfHtmlInput { public static final field Companion Lspace/kscience/visionforge/html/VisionOfRangeField$Companion; - public fun (DDDLjava/lang/String;Ljava/lang/String;)V - public synthetic fun (DDDLjava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;DDDLjava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; + public fun (DDD)V + public synthetic fun (DDDILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getMax ()D public final fun getMin ()D - public final fun getName ()Ljava/lang/String; + public final fun getNumberValue ()Ljava/lang/Number; public final fun getStep ()D - public final fun getValue ()Ljava/lang/Number; - public final fun setValue (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfRangeField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public final fun setNumberValue (Ljava/lang/Number;)V } public final class space/kscience/visionforge/html/VisionOfRangeField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfRangeField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfRangeField; @@ -705,19 +1013,12 @@ public final class space/kscience/visionforge/html/VisionOfRangeField$Companion public final class space/kscience/visionforge/html/VisionOfTextField : space/kscience/visionforge/html/VisionOfHtmlInput { public static final field Companion Lspace/kscience/visionforge/html/VisionOfTextField$Companion; public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLabel ()Ljava/lang/String; - public final fun getName ()Ljava/lang/String; public final fun getText ()Ljava/lang/String; public final fun setText (Ljava/lang/String;)V - public static final fun write$Self (Lspace/kscience/visionforge/html/VisionOfTextField;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/html/VisionOfTextField$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/html/VisionOfTextField$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/html/VisionOfTextField; @@ -731,17 +1032,42 @@ public final class space/kscience/visionforge/html/VisionOfTextField$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/html/VisionOutput { +public final class space/kscience/visionforge/html/VisionOutput : space/kscience/dataforge/context/ContextAware { public fun (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/names/Name;)V - public final fun getContext ()Lspace/kscience/dataforge/context/Context; + public fun getContext ()Lspace/kscience/dataforge/context/Context; public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta; public final fun getName ()Lspace/kscience/dataforge/names/Name; - public final fun meta (Lkotlin/jvm/functions/Function1;)V + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; public final fun requirePlugin (Lspace/kscience/dataforge/context/PluginFactory;)V public final fun setMeta (Lspace/kscience/dataforge/meta/Meta;)V } -public abstract class space/kscience/visionforge/html/VisionTagConsumer : kotlinx/html/TagConsumer { +public final class space/kscience/visionforge/html/VisionPage { + public static final field Companion Lspace/kscience/visionforge/html/VisionPage$Companion; + public fun (Lspace/kscience/visionforge/VisionManager;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;)V + public synthetic fun (Lspace/kscience/visionforge/VisionManager;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Lspace/kscience/visionforge/VisionManager; + public final fun component2 ()Ljava/util/Map; + public final fun component3 ()Lspace/kscience/visionforge/html/HtmlVisionFragment; + public final fun copy (Lspace/kscience/visionforge/VisionManager;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;)Lspace/kscience/visionforge/html/VisionPage; + public static synthetic fun copy$default (Lspace/kscience/visionforge/html/VisionPage;Lspace/kscience/visionforge/VisionManager;Ljava/util/Map;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionPage; + public fun equals (Ljava/lang/Object;)Z + public final fun getContent ()Lspace/kscience/visionforge/html/HtmlVisionFragment; + public final fun getPageHeaders ()Ljava/util/Map; + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/html/VisionPage$Companion { + public final fun scriptHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/HtmlFragment; + public static synthetic fun scriptHeader$default (Lspace/kscience/visionforge/html/VisionPage$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/HtmlFragment; + public final fun styleSheetHeader (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/HtmlFragment; + public static synthetic fun styleSheetHeader$default (Lspace/kscience/visionforge/html/VisionPage$Companion;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/HtmlFragment; + public final fun title (Ljava/lang/String;)Lspace/kscience/visionforge/html/HtmlFragment; +} + +public abstract class space/kscience/visionforge/html/VisionTagConsumer : kotlinx/html/TagConsumer, space/kscience/dataforge/context/ContextAware { public static final field AUTO_DATA_ATTRIBUTE Ljava/lang/String; public static final field Companion Lspace/kscience/visionforge/html/VisionTagConsumer$Companion; public static final field DEFAULT_ENDPOINT Ljava/lang/String; @@ -754,30 +1080,39 @@ public abstract class space/kscience/visionforge/html/VisionTagConsumer : kotlin public static final field OUTPUT_META_CLASS Ljava/lang/String; public static final field OUTPUT_NAME_ATTRIBUTE Ljava/lang/String; public static final field OUTPUT_RENDERED Ljava/lang/String; - public fun (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;Ljava/lang/String;)V - public synthetic fun (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/context/Context;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;)V + public synthetic fun (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + protected final fun addVision (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object; + public static synthetic fun addVision$default (Lspace/kscience/visionforge/html/VisionTagConsumer;Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)Ljava/lang/Object; public fun finalize ()Ljava/lang/Object; - public final fun getContext ()Lspace/kscience/dataforge/context/Context; + public fun getContext ()Lspace/kscience/dataforge/context/Context; + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; public fun onTagAttributeChange (Lkotlinx/html/Tag;Ljava/lang/String;Ljava/lang/String;)V public fun onTagComment (Ljava/lang/CharSequence;)V public fun onTagContent (Ljava/lang/CharSequence;)V public fun onTagContentEntity (Lkotlinx/html/Entities;)V public fun onTagContentUnsafe (Lkotlin/jvm/functions/Function1;)V public fun onTagEnd (Lkotlinx/html/Tag;)V - public fun onTagError (Lkotlinx/html/Tag;Ljava/lang/Throwable;)V public fun onTagEvent (Lkotlinx/html/Tag;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V public fun onTagStart (Lkotlinx/html/Tag;)V protected fun processResult (Ljava/lang/Object;)V protected abstract fun renderVision (Lkotlinx/html/DIV;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/meta/Meta;)V public fun resolveId (Lspace/kscience/dataforge/names/Name;)Ljava/lang/String; public final fun vision (Lkotlinx/html/TagConsumer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public final fun vision (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public fun vision (Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public fun vision (Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;)V public static synthetic fun vision$default (Lspace/kscience/visionforge/html/VisionTagConsumer;Lkotlinx/html/TagConsumer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun vision$default (Lspace/kscience/visionforge/html/VisionTagConsumer;Lkotlinx/html/TagConsumer;Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V } public final class space/kscience/visionforge/html/VisionTagConsumer$Companion { } +public final class space/kscience/visionforge/html/VisionTagConsumerKt { + public static final fun meta (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)V + public static final fun meta (Lspace/kscience/visionforge/html/VisionOutput;Lspace/kscience/dataforge/meta/MetaRepr;)V +} + public final class space/kscience/visionforge/visitor/CountDistinctKt { public static final fun countDistinct (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun countDistinctBy (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -806,7 +1141,8 @@ public abstract interface class space/kscience/visionforge/visitor/VisionVisitor public static final field Companion Lspace/kscience/visionforge/visitor/VisionVisitor$Companion; public fun skip (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)Z public abstract fun visit (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun visitChildren (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/VisionGroup;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun visitChildren (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun visitChildren$suspendImpl (Lspace/kscience/visionforge/visitor/VisionVisitor;Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class space/kscience/visionforge/visitor/VisionVisitor$Companion { diff --git a/visionforge-core/build.gradle.kts b/visionforge-core/build.gradle.kts index ad73b93d..554ac33c 100644 --- a/visionforge-core/build.gradle.kts +++ b/visionforge-core/build.gradle.kts @@ -8,12 +8,11 @@ kscience { jvm() js() native() + wasm() useCoroutines() - dependencies { + commonMain { api("space.kscience:dataforge-context:$dataforgeVersion") api(spclibs.kotlinx.html) - api(spclibs.atomicfu) -// api("org.jetbrains.kotlin-wrappers:kotlin-css") } jsMain { api("org.jetbrains.kotlin-wrappers:kotlin-extensions") diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt index 0cba6a37..655a7684 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/AbstractVision.kt @@ -1,8 +1,6 @@ package space.kscience.visionforge -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient +import kotlinx.serialization.* import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.descriptors.MetaDescriptor @@ -14,16 +12,12 @@ public abstract class AbstractVision : Vision { override var parent: Vision? = null @SerialName("properties") - protected var propertiesInternal: MutableMeta? = null + @OptIn(ExperimentalSerializationApi::class) + @EncodeDefault(EncodeDefault.Mode.NEVER) + protected var propertiesInternal: MutableMeta = MutableMeta() final override val properties: MutableVisionProperties by lazy { - object : AbstractVisionProperties(this) { - override var properties: MutableMeta? - get() = propertiesInternal - set(value) { - propertiesInternal = value - } - } + AbstractVisionProperties(this, propertiesInternal) } override val descriptor: MetaDescriptor? get() = null diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ControlVision.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ControlVision.kt new file mode 100644 index 00000000..f9ced040 --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/ControlVision.kt @@ -0,0 +1,139 @@ +package space.kscience.visionforge + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.* +import kotlinx.coroutines.launch +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient +import space.kscience.dataforge.meta.* +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.parseAsName + +public abstract class VisionControlEvent : VisionEvent, MetaRepr { + public abstract val meta: Meta + + override fun toMeta(): Meta = meta + + override fun toString(): String = toMeta().toString() +} + +public interface ControlVision : Vision { + public val controlEventFlow: SharedFlow + + /** + * Fire a [VisionControlEvent] on this [ControlVision] + */ + public suspend fun dispatchControlEvent(event: VisionControlEvent) + + override suspend fun receiveEvent(event: VisionEvent) { + if (event is VisionControlEvent) { + dispatchControlEvent(event) + } else super.receiveEvent(event) + } +} + +public fun ControlVision.asyncControlEvent( + event: VisionControlEvent, + scope: CoroutineScope = manager?.context ?: error("Can't fire asynchronous event for an orphan vision. Provide a scope."), +) { + scope.launch { dispatchControlEvent(event) } +} + + +@Serializable +public abstract class AbstractControlVision : AbstractVision(), ControlVision { + + @Transient + private val mutableControlEventFlow = MutableSharedFlow() + + override val controlEventFlow: SharedFlow + get() = mutableControlEventFlow + + override suspend fun dispatchControlEvent(event: VisionControlEvent) { + mutableControlEventFlow.emit(event) + } +} + + +/** + * An event for submitting changes + */ +@Serializable +@SerialName("control.submit") +public class VisionSubmitEvent(override val meta: Meta) : VisionControlEvent() { + public val payload: Meta get() = meta[::payload.name] ?: Meta.EMPTY + + public val name: Name? get() = meta["name"].string?.parseAsName() + + override fun toString(): String = meta.toString() +} + +public fun VisionSubmitEvent(payload: Meta = Meta.EMPTY, name: Name? = null): VisionSubmitEvent = VisionSubmitEvent( + Meta { + VisionSubmitEvent::payload.name put payload + VisionSubmitEvent::name.name put name.toString() + } +) + + +public interface DataControl : ControlVision { + /** + * Create and dispatch submit event + */ + public suspend fun submit(builder: MutableMeta.() -> Unit = {}) { + dispatchControlEvent(VisionSubmitEvent(Meta(builder))) + } +} + +/** + * Register listener + */ +public fun DataControl.onSubmit(scope: CoroutineScope, block: suspend VisionSubmitEvent.() -> Unit): Job = + controlEventFlow.filterIsInstance().onEach(block).launchIn(scope) + + +@Serializable +@SerialName("control.valueChange") +public class VisionValueChangeEvent(override val meta: Meta) : VisionControlEvent() { + + public val value: Value? get() = meta.value + + /** + * The name of a control that fired the event + */ + public val name: Name? get() = meta["name"]?.string?.parseAsName() + + override fun toString(): String = meta.toString() +} + + +public fun VisionValueChangeEvent(value: Value?, name: Name? = null): VisionValueChangeEvent = VisionValueChangeEvent( + Meta { + this.value = value + name?.let { set("name", it.toString()) } + } +) + + +@Serializable +@SerialName("control.input") +public class VisionInputEvent(override val meta: Meta) : VisionControlEvent() { + + public val value: Value? get() = meta.value + + /** + * The name of a control that fired the event + */ + public val name: Name? get() = meta["name"]?.string?.parseAsName() + + override fun toString(): String = meta.toString() +} + +public fun VisionInputEvent(value: Value?, name: Name? = null): VisionInputEvent = VisionInputEvent( + Meta { + this.value = value + name?.let { set("name", it.toString()) } + } +) diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt index 62d898b8..b26e3a36 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleReference.kt @@ -3,7 +3,7 @@ package space.kscience.visionforge import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.Scheme -import space.kscience.dataforge.meta.Specification +import space.kscience.dataforge.meta.SchemeSpec import kotlin.properties.ReadOnlyProperty /** @@ -36,7 +36,7 @@ public fun Vision.style( @VisionBuilder public fun Vision.style( - spec: Specification, + spec: SchemeSpec, styleKey: String? = null, builder: T.() -> Unit, ): ReadOnlyProperty = ReadOnlyProperty { _, property -> diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt index 00213644..85fea7f4 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/StyleSheet.kt @@ -13,7 +13,7 @@ import kotlin.jvm.JvmInline @JvmInline public value class StyleSheet(private val owner: Vision) { - private val styleNode: Meta get() = owner.properties.getMeta(STYLESHEET_KEY) + private val styleNode: Meta get() = owner.properties[STYLESHEET_KEY] public val items: Map get() = styleNode.items @@ -23,7 +23,7 @@ public value class StyleSheet(private val owner: Vision) { * Define a style without notifying owner */ public fun define(key: String, style: Meta?) { - owner.properties.setMeta(STYLESHEET_KEY + key, style) + owner.properties[STYLESHEET_KEY + key] = style } /** @@ -64,10 +64,10 @@ internal fun Vision.styleChanged(key: String, oldStyle: Meta?, newStyle: Meta?) } /** - * List of names of styles applied to this object. Order matters. Not inherited. + * List of style names applied to this object. Order matters. Not inherited. */ public var Vision.styles: List - get() = properties.own?.getValue(Vision.STYLE_KEY)?.stringList ?: emptyList() + get() = properties.own[Vision.STYLE_KEY]?.stringList ?: emptyList() set(value) { properties.setValue(Vision.STYLE_KEY, value.map { it.asValue() }.asValue()) } @@ -83,7 +83,7 @@ public val Vision.styleSheet: StyleSheet get() = StyleSheet(this) * The style with given name does not necessary exist at the moment. */ public fun Vision.useStyle(name: String, notify: Boolean = true) { - val newStyle = properties.own?.get(Vision.STYLE_KEY)?.value?.list?.plus(name.asValue()) ?: listOf(name.asValue()) + val newStyle = properties.own[Vision.STYLE_KEY]?.value?.list?.plus(name.asValue()) ?: listOf(name.asValue()) properties.setValue(Vision.STYLE_KEY, newStyle.asValue(), notify) } @@ -92,7 +92,7 @@ public fun Vision.useStyle(name: String, notify: Boolean = true) { * Resolve a style with given name for given [Vision]. The style is not necessarily applied to this [Vision]. */ public fun Vision.getStyle(name: String): Meta? = - properties.own?.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name) + properties.own[StyleSheet.STYLESHEET_KEY + name] ?: parent?.getStyle(name) /** * Resolve a property from all styles diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt index b4e6cba7..4062b356 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/Vision.kt @@ -1,15 +1,12 @@ package space.kscience.visionforge -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.context.logger +import space.kscience.dataforge.context.warn import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.boolean import space.kscience.dataforge.meta.descriptors.Described import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.misc.Type +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties @@ -18,7 +15,7 @@ import space.kscience.visionforge.Vision.Companion.TYPE /** * A root type for display hierarchy */ -@Type(TYPE) +@DfType(TYPE) public interface Vision : Described { /** @@ -37,7 +34,7 @@ public interface Vision : Described { /** * Update this vision using a dif represented by [VisionChange]. */ - public fun receiveChange(change: VisionChange) { + public fun update(change: VisionChange) { if (change.children?.isNotEmpty() == true) { error("Vision is not a group") } @@ -46,18 +43,12 @@ public interface Vision : Described { } } - public fun onMetaEvent(meta: Meta){ - //Do nothing by default - } - /** * Receive and process a generic [VisionEvent]. */ - public fun receiveEvent(event: VisionEvent) { - when (event) { - is VisionChange -> receiveChange(event) - is VisionMetaEvent -> onMetaEvent(event.meta) - } + public suspend fun receiveEvent(event: VisionEvent) { + if(event is VisionChange) update(event) + else manager?.logger?.warn { "Undispatched event: $event" } } override val descriptor: MetaDescriptor? @@ -78,14 +69,4 @@ public var Vision.visible: Boolean? get() = properties.getValue(Vision.VISIBLE_KEY)?.boolean set(value) { properties.setValue(Vision.VISIBLE_KEY, value?.asValue()) - } - -/** - * Subscribe on property updates. The subscription is bound to the given scope and canceled when the scope is canceled - */ -public fun Vision.onPropertyChange( - scope: CoroutineScope? = manager?.context, - callback: suspend (Name) -> Unit, -): Job = properties.changes.onEach { - callback(it) -}.launchIn(scope ?: error("Orphan Vision can't observe properties")) \ No newline at end of file + } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt index 87bff794..eb800111 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionChange.kt @@ -148,7 +148,7 @@ private fun CoroutineScope.collectChange( //Collect properties change source.properties.changes.onEach { propertyName -> - val newItem = source.properties.own?.get(propertyName) + val newItem = source.properties.own[propertyName] collector.propertyChanged(name, propertyName, newItem) }.launchIn(this) diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionClient.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionClient.kt index 76d8aa80..2d77dfd0 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionClient.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionClient.kt @@ -1,9 +1,9 @@ package space.kscience.visionforge +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import space.kscience.dataforge.context.Plugin import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MetaRepr import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.parseAsName @@ -18,6 +18,9 @@ public interface VisionClient: Plugin { public fun notifyPropertyChanged(visionName: Name, propertyName: Name, item: Meta?) } +public fun VisionClient.sendEventAsync(targetName: Name, event: VisionEvent): Job = context.launch { + sendEvent(targetName, event) +} public fun VisionClient.notifyPropertyChanged(visionName: Name, propertyName: String, item: Meta?) { notifyPropertyChanged(visionName, propertyName.parseAsName(true), item) @@ -33,10 +36,4 @@ public fun VisionClient.notifyPropertyChanged(visionName: Name, propertyName: St public fun VisionClient.notifyPropertyChanged(visionName: Name, propertyName: String, item: Boolean) { notifyPropertyChanged(visionName, propertyName.parseAsName(true), Meta(item)) -} - -public fun VisionClient.sendEvent(targetName: Name, payload: MetaRepr): Unit { - context.launch { - sendEvent(targetName, VisionMetaEvent(payload.toMeta())) - } } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt index c74f027d..09edf4c1 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt @@ -10,10 +10,17 @@ import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY @DslMarker public annotation class VisionBuilder +/** + * A container interface with read access to its content + * using DataForge [Name] objects as keys. + */ public interface VisionContainer { public fun getChild(name: Name): V? } +/** + * A container interface with write/replace/delete access to its content. + */ public interface MutableVisionContainer { //TODO add documentation public fun setChild(name: Name?, child: V?) @@ -61,12 +68,22 @@ public inline fun VisionChildren.forEach(block: (NameToken, Vision) -> Unit) { keys.forEach { block(it, get(it)!!) } } +/** + * A serializable representation of [Vision] children container + * with the ability to modify the container content. + */ public interface MutableVisionChildren : VisionChildren, MutableVisionContainer { public override val parent: MutableVisionGroup public operator fun set(token: NameToken, value: Vision?) + /** + * Set child [Vision] by name. + * @param name child name. Pass null to add a static child. Note that static children cannot + * be removed, replaced or accessed by name by other means. + * @param child new child value. Pass null to delete the child. + */ override fun setChild(name: Name?, child: Vision?) { when { name == null -> { diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionEvent.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionEvent.kt index 84d36217..e0f5beca 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionEvent.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionEvent.kt @@ -3,15 +3,13 @@ package space.kscience.visionforge import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.meta.set +import space.kscience.dataforge.meta.MetaRepr import space.kscience.dataforge.names.Name /** * An event propagated from client to a server */ -@Serializable -public sealed interface VisionEvent { +public interface VisionEvent { public companion object { public val CLICK_EVENT_KEY: Name get() = Name.of("events", "click", "payload") } @@ -22,14 +20,9 @@ public sealed interface VisionEvent { */ @Serializable @SerialName("meta") -public class VisionMetaEvent(public val meta: Meta) : VisionEvent +public class VisionMetaEvent(public val meta: Meta) : VisionEvent, MetaRepr { + override fun toMeta(): Meta = meta + override fun toString(): String = toMeta().toString() -public val Vision.Companion.CLICK_EVENT_KEY: Name get() = Name.of("events", "click", "payload") - -/** - * Set the payload to be sent to server on click - */ -public fun Vision.onClickPayload(payloadBuilder: MutableMeta.() -> Unit) { - properties[VisionEvent.CLICK_EVENT_KEY] = Meta(payloadBuilder) } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt index 1edfa40a..fd8aaa16 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroup.kt @@ -17,12 +17,12 @@ import space.kscience.visionforge.Vision.Companion.STYLE_KEY public interface VisionGroup : Vision { public val children: VisionChildren - override fun receiveChange(change: VisionChange) { + override fun update(change: VisionChange) { change.children?.forEach { (name, change) -> if (change.vision != null || change.vision == NullVision) { error("VisionGroup is read-only") } else { - children.getChild(name)?.receiveChange(change) + children.getChild(name)?.update(change) } } change.properties?.let { @@ -37,12 +37,12 @@ public interface MutableVisionGroup : VisionGroup { public fun createGroup(): MutableVisionGroup - override fun receiveChange(change: VisionChange) { + override fun update(change: VisionChange) { change.children?.forEach { (name, change) -> when { change.vision == NullVision -> children.setChild(name, null) change.vision != null -> children.setChild(name, change.vision) - else -> children.getChild(name)?.receiveChange(change) + else -> children.getChild(name)?.update(change) } } change.properties?.let { diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt index e4ca1cdb..406dfeba 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt @@ -13,10 +13,7 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.toJson import space.kscience.dataforge.meta.toMeta import space.kscience.dataforge.names.Name -import space.kscience.visionforge.html.VisionOfCheckbox -import space.kscience.visionforge.html.VisionOfHtmlForm -import space.kscience.visionforge.html.VisionOfNumberField -import space.kscience.visionforge.html.VisionOfTextField +import space.kscience.visionforge.html.* public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionContainer { override val tag: PluginTag get() = Companion.tag @@ -33,10 +30,11 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont } } - public val jsonFormat: Json - get() = Json(defaultJson) { + public val jsonFormat: Json by lazy { + Json(defaultJson) { serializersModule = this@VisionManager.serializersModule } + } public fun decodeFromString(string: String): Vision = jsonFormat.decodeFromString(visionSerializer, string) @@ -72,10 +70,22 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont defaultDeserializer { SimpleVisionGroup.serializer() } subclass(NullVision.serializer()) subclass(SimpleVisionGroup.serializer()) + subclass(VisionOfPlainHtml.serializer()) + subclass(VisionOfHtmlInput.serializer()) subclass(VisionOfNumberField.serializer()) subclass(VisionOfTextField.serializer()) subclass(VisionOfCheckbox.serializer()) + subclass(VisionOfRangeField.serializer()) subclass(VisionOfHtmlForm.serializer()) + subclass(VisionOfHtmlButton.serializer()) + } + + polymorphic(VisionEvent::class) { + subclass(VisionChange.serializer()) + subclass(VisionMetaEvent.serializer()) + subclass(VisionSubmitEvent.serializer()) + subclass(VisionValueChangeEvent.serializer()) + subclass(VisionInputEvent.serializer()) } } @@ -106,7 +116,7 @@ public abstract class VisionPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(met /** * Fetch a [VisionManager] from this plugin or create a child plugin with a [VisionManager] */ -public val Context.visionManager: VisionManager get() = request(VisionManager ) +public val Context.visionManager: VisionManager get() = request(VisionManager) public fun Vision.encodeToString(): String = manager?.encodeToString(this) ?: error("Orphan vision could not be encoded") @@ -122,6 +132,8 @@ public class RootVision(override val manager: VisionManager) : AbstractVisionGro * Designate this [Vision] as a root and assign a [VisionManager] as its parent */ public fun Vision.setAsRoot(manager: VisionManager) { + //do nothing if vision is already rooted + if(this.manager == manager) return if (parent != null) error("Vision $this already has a parent. It could not be set as root") parent = RootVision(manager) } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt index dfb06b50..9201d0bf 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionProperties.kt @@ -1,10 +1,7 @@ package space.kscience.visionforge -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.launch import kotlinx.serialization.Transient import space.kscience.dataforge.meta.* @@ -17,7 +14,7 @@ public interface VisionProperties : MetaProvider { /** * Raw Visions own properties without styles, defaults, etc. */ - public val own: Meta? + public val own: Meta public val descriptor: MetaDescriptor? @@ -34,17 +31,21 @@ public interface VisionProperties : MetaProvider { * @param inherit toggles parent node property lookup. Null means inference from descriptor. * @param includeStyles toggles inclusion of properties from styles. */ - public fun getMeta( + public fun get( name: Name, inherit: Boolean?, includeStyles: Boolean? = null, ): Meta - override fun getMeta(name: Name): Meta? = getMeta(name, null, null) + override fun get(name: Name): Meta? = get(name, null, null) public val changes: Flow + @Deprecated("Replace with property", ReplaceWith("changes")) + public fun flowChanges(): Flow = changes + + /** * Notify all listeners that a property has been changed and should be invalidated. * This method does not check that the property has actually changed. @@ -54,7 +55,7 @@ public interface VisionProperties : MetaProvider { public interface MutableVisionProperties : VisionProperties, MutableMetaProvider { - override fun getMeta( + override fun get( name: Name, inherit: Boolean?, includeStyles: Boolean?, @@ -65,9 +66,9 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider includeStyles, ) - public fun setMeta( + public fun set( name: Name, - node: Meta?, + item: Meta?, notify: Boolean, ) @@ -77,10 +78,10 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider notify: Boolean, ) - override fun getMeta(name: Name): MutableMeta = getMeta(name, null, null) + override fun get(name: Name): MutableMeta = get(name, null, null) - override fun setMeta(name: Name, node: Meta?) { - setMeta(name, node, true) + override fun set(name: Name, node: Meta?) { + set(name, node, true) } override fun setValue(name: Name, value: Value?) { @@ -89,7 +90,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider } public fun MutableVisionProperties.remove(name: Name) { - setMeta(name, null) + set(name, null) } public fun MutableVisionProperties.remove(name: String) { @@ -114,8 +115,8 @@ private class VisionPropertiesItem( override val items: Map get() { - val metaKeys = properties.own?.getMeta(nodeName)?.items?.keys ?: emptySet() - val descriptorKeys = descriptor?.children?.map { NameToken(it.key) } ?: emptySet() + val metaKeys = properties.own[nodeName]?.items?.keys ?: emptySet() + val descriptorKeys = descriptor?.nodes?.map { NameToken(it.key) } ?: emptySet() val defaultKeys = default?.get(nodeName)?.items?.keys ?: emptySet() val inheritFlag = descriptor?.inherited ?: inherit val stylesFlag = descriptor?.usesStyles ?: useStyles @@ -148,8 +149,8 @@ private class VisionPropertiesItem( default ) - override fun setMeta(name: Name, node: Meta?) { - properties.setMeta(nodeName + name, node) + override fun set(name: Name, node: Meta?) { + properties[nodeName + name] = node } override fun toString(): String = Meta.toString(this) @@ -160,25 +161,12 @@ private class VisionPropertiesItem( /** * A base implementation of [MutableVisionProperties] */ -public abstract class AbstractVisionProperties( +public open class AbstractVisionProperties( public val vision: Vision, + final override val own: MutableMeta, ) : MutableVisionProperties { override val descriptor: MetaDescriptor? get() = vision.descriptor - protected abstract var properties: MutableMeta? - - override val own: Meta? get() = properties - - @JvmSynchronized - protected fun getOrCreateProperties(): MutableMeta { - if (properties == null) { - //TODO check performance issues - val newProperties = MutableMeta() - properties = newProperties - } - return properties!! - } - private val descriptorCache = HashMap() override fun getValue( @@ -186,7 +174,7 @@ public abstract class AbstractVisionProperties( inherit: Boolean?, includeStyles: Boolean?, ): Value? { - own?.get(name)?.value?.let { return it } + own[name]?.value?.let { return it } val descriptor = descriptor?.let { descriptor -> descriptorCache.getOrPut(name) { descriptor[name] } } val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true @@ -202,16 +190,28 @@ public abstract class AbstractVisionProperties( return descriptor?.defaultValue } - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { + override fun set(name: Name, item: Meta?, notify: Boolean) { //ignore if the value is the same as existing - if (own?.getMeta(name) == node) return + if (own[name] == item) return if (name.isEmpty()) { - properties = node?.asMutableMeta() - } else if (node == null) { - properties?.setMeta(name, node) + if (item == null) { + own.items.keys.forEach { + remove(it.asName()) + } + } else { + (own.items.keys - item.items.keys).forEach { + remove(it.asName()) + } + item.items.forEach { (token, item) -> + set(token, item) + } + } + + } else if (item == null) { + own[name] = item } else { - getOrCreateProperties().setMeta(name, node) + own[name] = item } if (notify) { invalidate(name) @@ -220,12 +220,12 @@ public abstract class AbstractVisionProperties( override fun setValue(name: Name, value: Value?, notify: Boolean) { //ignore if the value is the same as existing - if (own?.getValue(name) == value) return + if (own.getValue(name) == value) return if (value == null) { - properties?.getMeta(name)?.value = null + own[name]?.value = null } else { - getOrCreateProperties().setValue(name, value) + own.setValue(name, value) } if (notify) { invalidate(name) @@ -233,14 +233,20 @@ public abstract class AbstractVisionProperties( } @Transient - protected val changesInternal: MutableSharedFlow = MutableSharedFlow() - override val changes: SharedFlow get() = changesInternal + protected val changesInternal: MutableSharedFlow = MutableSharedFlow() + + override val changes: Flow + get() = changesInternal override fun invalidate(propertyName: Name) { //send update signal - @OptIn(DelicateCoroutinesApi::class) - (vision.manager?.context ?: GlobalScope).launch { - changesInternal.emit(propertyName) + val manager = vision.manager + if (manager != null) { + manager.context.launch { + changesInternal.emit(propertyName) + } + } else { + changesInternal.tryEmit(propertyName) } //notify children if there are any @@ -265,54 +271,35 @@ public abstract class AbstractVisionProperties( public fun VisionProperties.getValue( name: String, - inherit: Boolean? = null, + inherit: Boolean, includeStyles: Boolean? = null, ): Value? = getValue(name.parseAsName(), inherit, includeStyles) /** * Get [Vision] property using key as a String */ -public fun VisionProperties.getMeta( +public operator fun VisionProperties.get( name: String, inherit: Boolean? = null, includeStyles: Boolean? = null, -): Meta = getMeta(name.parseAsName(), inherit, includeStyles) +): Meta = get(name.parseAsName(), inherit, includeStyles) /** * The root property node with given inheritance and style flags - * @param inherit - inherit properties from the [Vision] parent. If null, infer from descriptor - * @param includeStyles - include style information. If null, infer from descriptor + * @param inherit inherit properties from the [Vision] parent. If null, infer from descriptor + * @param includeStyles include style information. If null, infer from descriptor */ public fun MutableVisionProperties.root( inherit: Boolean? = null, includeStyles: Boolean? = null, -): MutableMeta = getMeta(Name.EMPTY, inherit, includeStyles) +): MutableMeta = get(Name.EMPTY, inherit, includeStyles) /** * Get [Vision] property using key as a String */ -public fun MutableVisionProperties.getMeta( +public operator fun MutableVisionProperties.get( name: String, inherit: Boolean? = null, includeStyles: Boolean? = null, -): MutableMeta = getMeta(name.parseAsName(), inherit, includeStyles) - -// -//public operator fun MutableVisionProperties.set(name: Name, value: Number): Unit = -// setValue(name, value.asValue()) -// -//public operator fun MutableVisionProperties.set(name: String, value: Number): Unit = -// set(name.parseAsName(), value) -// -//public operator fun MutableVisionProperties.set(name: Name, value: Boolean): Unit = -// setValue(name, value.asValue()) -// -//public operator fun MutableVisionProperties.set(name: String, value: Boolean): Unit = -// set(name.parseAsName(), value) -// -//public operator fun MutableVisionProperties.set(name: Name, value: String): Unit = -// setValue(name, value.asValue()) -// -//public operator fun MutableVisionProperties.set(name: String, value: String): Unit = -// set(name.parseAsName(), value) \ No newline at end of file +): MutableMeta = get(name.parseAsName(), inherit, includeStyles) diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt index f8d128e1..60c39c20 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/flowProperty.kt @@ -17,10 +17,10 @@ public fun Vision.flowProperty( includeStyles: Boolean? = null, ): Flow = flow { //Pass initial value. - emit(properties.getMeta(propertyName, inherit, includeStyles)) + emit(properties.get(propertyName, inherit, includeStyles)) properties.changes.collect { name -> if (name.startsWith(propertyName)) { - emit(properties.getMeta(propertyName, inherit, includeStyles)) + emit(properties.get(propertyName, inherit, includeStyles)) } } } diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt index d71e848a..801d23aa 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/HtmlVisionRenderer.kt @@ -8,19 +8,23 @@ import space.kscience.dataforge.names.asName import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager -public fun interface HtmlVisionFragment{ +public fun interface HtmlVisionFragment { public fun VisionTagConsumer<*>.append() } public fun HtmlVisionFragment.appendTo(consumer: VisionTagConsumer<*>): Unit = consumer.append() +public data class VisionDisplay(val visionManager: VisionManager, val vision: Vision, val meta: Meta) + /** * Render a fragment in the given consumer and return a map of extracted visions - * @param context a context used to create a vision fragment + * @param visionManager a context plugin used to create a vision fragment * @param embedData embed Vision initial state in the HTML * @param fetchDataUrl fetch data after first render from given url * @param updatesUrl receive push updates from the server at given url * @param idPrefix a prefix to be used before vision ids + * @param displayCache external cache for Vision displays. It is required to avoid re-creating visions on page update + * @param fragment the fragment to render */ public fun TagConsumer<*>.visionFragment( visionManager: VisionManager, @@ -28,39 +32,31 @@ public fun TagConsumer<*>.visionFragment( fetchDataUrl: String? = null, updatesUrl: String? = null, idPrefix: String? = null, - onVisionRendered: (Name, Vision) -> Unit = { _, _ -> }, + displayCache: MutableMap = mutableMapOf(), fragment: HtmlVisionFragment, ) { - val collector: MutableMap> = mutableMapOf() - val consumer = object : VisionTagConsumer(this@visionFragment, visionManager, idPrefix) { override fun TagConsumer.vision(name: Name?, buildOutput: VisionOutput.() -> Vision): T { //Avoid re-creating cached visions val actualName = name ?: NameToken( DEFAULT_VISION_NAME, - buildOutput.hashCode().toUInt().toString() + buildOutput.hashCode().toString(16) ).asName() - val (output, vision) = collector.getOrPut(actualName) { + val display = displayCache.getOrPut(actualName) { val output = VisionOutput(context, actualName) val vision = output.buildOutput() - onVisionRendered(actualName, vision) - output to vision + VisionDisplay(output.visionManager, vision, output.meta) } - return addVision(actualName, output.visionManager, vision, output.meta) + return addVision(actualName, display.visionManager, display.vision, display.meta) } override fun DIV.renderVision(manager: VisionManager, name: Name, vision: Vision, outputMeta: Meta) { - val (_, actualVision) = collector.getOrPut(name) { - val output = VisionOutput(context, name) - onVisionRendered(name, vision) - output to vision - } - + displayCache[name] = VisionDisplay(manager, vision, outputMeta) // Toggle update mode updatesUrl?.let { @@ -76,7 +72,7 @@ public fun TagConsumer<*>.visionFragment( type = "text/json" attributes["class"] = OUTPUT_DATA_CLASS unsafe { - +"\n${manager.encodeToString(actualVision)}\n" + +"\n${manager.encodeToString(vision)}\n" } } } @@ -91,8 +87,8 @@ public fun FlowContent.visionFragment( embedData: Boolean = true, fetchDataUrl: String? = null, updatesUrl: String? = null, - onVisionRendered: (Name, Vision) -> Unit = { _, _ -> }, idPrefix: String? = null, + displayCache: MutableMap = mutableMapOf(), fragment: HtmlVisionFragment, ): Unit = consumer.visionFragment( visionManager = visionManager, @@ -100,6 +96,6 @@ public fun FlowContent.visionFragment( fetchDataUrl = fetchDataUrl, updatesUrl = updatesUrl, idPrefix = idPrefix, - onVisionRendered = onVisionRendered, + displayCache = displayCache, fragment = fragment ) \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtml.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtml.kt new file mode 100644 index 00000000..050e88ae --- /dev/null +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtml.kt @@ -0,0 +1,155 @@ +package space.kscience.visionforge.html + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.html.DIV +import kotlinx.html.InputType +import kotlinx.html.div +import kotlinx.html.stream.createHTML +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.* +import space.kscience.dataforge.names.asName +import space.kscience.visionforge.* + + +public interface VisionOfHtml : Vision { + + /** + * Html class strings for this instance. Does not use vision inheritance, but uses styles + */ + public var classes: Set + get() = properties[::classes.name, false, true].stringList?.toSet() ?: emptySet() + set(value) { + properties[::classes.name] = value.map { it.asValue() } + } + + /** + * A custom style string + */ + public var styleString: String? + get() = properties[::styleString.name,false,true].string + set(value){ + properties[::styleString.name] = value?.asValue() + } +} + +@Serializable +@SerialName("html.plain") +public class VisionOfPlainHtml : AbstractVision(), VisionOfHtml { + public var content: String? by properties.string() +} + +public fun VisionOfPlainHtml.content(block: DIV.() -> Unit) { + content = createHTML().apply { + div(block = block) + }.finalize() +} + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.html( + block: VisionOfPlainHtml.() -> Unit, +): VisionOfPlainHtml = VisionOfPlainHtml().apply(block) + +@Serializable +public enum class InputFeedbackMode { + /** + * Fire feedback event on `onchange` event + */ + ONCHANGE, + + /** + * Fire feedback event on `oninput` event + */ + ONINPUT, + + /** + * provide only manual feedback + */ + NONE +} + +@Serializable +@SerialName("html.input") +public open class VisionOfHtmlInput( + public val inputType: String, +) : AbstractControlVision(), VisionOfHtml { + public var value: Value? by properties.value() + public var disabled: Boolean by properties.boolean { false } + public var fieldName: String? by properties.string() +} + +/** + * Trigger [callback] on each value change + */ +public fun VisionOfHtmlInput.onValueChange( + scope: CoroutineScope = manager?.context ?: error("Coroutine context is not resolved for $this"), + callback: suspend VisionValueChangeEvent.() -> Unit, +): Job = controlEventFlow.filterIsInstance().onEach(callback).launchIn(scope) + +public fun VisionOfHtmlInput.onInput( + scope: CoroutineScope = manager?.context ?: error("Coroutine context is not resolved for $this"), + callback: suspend VisionInputEvent.() -> Unit, +): Job = controlEventFlow.filterIsInstance().onEach(callback).launchIn(scope) + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.htmlInput( + inputType: String, + block: VisionOfHtmlInput.() -> Unit = {}, +): VisionOfHtmlInput = VisionOfHtmlInput(inputType).apply(block) + +@Serializable +@SerialName("html.text") +public class VisionOfTextField : VisionOfHtmlInput(InputType.text.realValue) { + public var text: String? by properties.string(key = VisionOfHtmlInput::value.name.asName()) +} + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.htmlTextField( + block: VisionOfTextField.() -> Unit = {}, +): VisionOfTextField = VisionOfTextField().apply(block) + + +@Serializable +@SerialName("html.checkbox") +public class VisionOfCheckbox : VisionOfHtmlInput(InputType.checkBox.realValue) { + public var checked: Boolean? by properties.boolean(key = VisionOfHtmlInput::value.name.asName()) +} + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.htmlCheckBox( + block: VisionOfCheckbox.() -> Unit = {}, +): VisionOfCheckbox = VisionOfCheckbox().apply(block) + +@Serializable +@SerialName("html.number") +public class VisionOfNumberField : VisionOfHtmlInput(InputType.number.realValue) { + public var numberValue: Number? by properties.number(key = VisionOfHtmlInput::value.name.asName()) +} + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.htmlNumberField( + block: VisionOfNumberField.() -> Unit = {}, +): VisionOfNumberField = VisionOfNumberField().apply(block) + +@Serializable +@SerialName("html.range") +public class VisionOfRangeField( + public val min: Double, + public val max: Double, + public val step: Double = 1.0, +) : VisionOfHtmlInput(InputType.range.realValue) { + public var numberValue: Number? by properties.number(key = VisionOfHtmlInput::value.name.asName()) +} + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.htmlRangeField( + min: Number, + max: Number, + step: Number = 1.0, + block: VisionOfRangeField.() -> Unit = {}, +): VisionOfRangeField = VisionOfRangeField(min.toDouble(), max.toDouble(), step.toDouble()).apply(block) + diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt index d9c0347d..994a1d3a 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlForm.kt @@ -1,26 +1,61 @@ package space.kscience.visionforge.html -import kotlinx.html.FORM -import kotlinx.html.TagConsumer -import kotlinx.html.form -import kotlinx.html.id +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.html.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.node +import space.kscience.dataforge.meta.string +import space.kscience.visionforge.AbstractControlVision +import space.kscience.visionforge.DataControl +import space.kscience.visionforge.onSubmit +/** + * @param formId an id of the element in rendered DOM, this form is bound to + */ @Serializable @SerialName("html.form") public class VisionOfHtmlForm( public val formId: String, -) : VisionOfHtmlInput() { - public var values: Meta? by mutableProperties.node() +) : AbstractControlVision(), DataControl, VisionOfHtml { + public var values: Meta? by properties.node() } -public fun TagConsumer.bindForm( - visionOfForm: VisionOfHtmlForm, - builder: FORM.() -> Unit, -): R = form { - this.id = visionOfForm.formId - builder() + +/** + * Create a [VisionOfHtmlForm] and bind this form to the id + */ +@HtmlTagMarker +public inline fun > C.visionOfForm( + vision: VisionOfHtmlForm, + action: String? = null, + encType: FormEncType? = null, + method: FormMethod? = null, + classes: String? = null, + crossinline block: FORM.() -> Unit = {}, +) : T = form(action, encType, method, classes){ + this.id = vision.formId + block() +} + + +public fun VisionOfHtmlForm.onFormSubmit(scope: CoroutineScope, block: (Meta?) -> Unit): Job = onSubmit(scope) { block(payload) } + + +@Serializable +@SerialName("html.button") +public class VisionOfHtmlButton : AbstractControlVision(), DataControl, VisionOfHtml { + public var label: String? by properties.string() +} + + +@Suppress("UnusedReceiverParameter") +public inline fun VisionOutput.button( + text: String, + block: VisionOfHtmlButton.() -> Unit = {}, +): VisionOfHtmlButton = VisionOfHtmlButton().apply { + label = text + block() } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt deleted file mode 100644 index d2bb2c52..00000000 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionOfHtmlInput.kt +++ /dev/null @@ -1,58 +0,0 @@ -package space.kscience.visionforge.html - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.meta.number -import space.kscience.dataforge.meta.string -import space.kscience.dataforge.names.Name -import space.kscience.visionforge.AbstractVision -import space.kscience.visionforge.Vision - -//TODO replace by something -internal val Vision.mutableProperties get() = properties.getMeta(Name.EMPTY, false, false) - -@Serializable -public abstract class VisionOfHtmlInput : AbstractVision() { - public var disabled: Boolean by mutableProperties.boolean { false } -} - -@Serializable -@SerialName("html.text") -public class VisionOfTextField( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var text: String? by mutableProperties.string() -} - -@Serializable -@SerialName("html.checkbox") -public class VisionOfCheckbox( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var checked: Boolean? by mutableProperties.boolean() -} - -@Serializable -@SerialName("html.number") -public class VisionOfNumberField( - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var value: Number? by mutableProperties.number() -} - -@Serializable -@SerialName("html.range") -public class VisionOfRangeField( - public val min: Double, - public val max: Double, - public val step: Double = 1.0, - public val label: String? = null, - public val name: String? = null, -) : VisionOfHtmlInput() { - public var value: Number? by mutableProperties.number() -} - diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt index 99a8ea0d..ccf9892e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt @@ -4,10 +4,7 @@ import kotlinx.html.* import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.ContextAware import space.kscience.dataforge.context.PluginFactory -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MetaSerializer -import space.kscience.dataforge.meta.MutableMeta -import space.kscience.dataforge.meta.isEmpty +import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.asName @@ -26,7 +23,7 @@ public annotation class VisionDSL * A placeholder object to attach inline vision builders. */ @VisionDSL -public class VisionOutput @PublishedApi internal constructor(override val context: Context, public val name: Name): ContextAware { +public class VisionOutput(override val context: Context, public val name: Name): ContextAware { public var meta: Meta = Meta.EMPTY private val requirements: MutableSet> = HashSet() @@ -46,9 +43,14 @@ public class VisionOutput @PublishedApi internal constructor(override val contex newContext.visionManager } - public inline fun meta(block: MutableMeta.() -> Unit) { - this.meta = Meta(block) - } +} + +public inline fun VisionOutput.meta(block: MutableMeta.() -> Unit) { + this.meta = Meta(block) +} + +public fun VisionOutput.meta(metaRepr: MetaRepr) { + this.meta = metaRepr.toMeta() } /** diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt index f6f95a6f..fcdea6d3 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/useProperty.kt @@ -2,6 +2,7 @@ package space.kscience.visionforge import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import space.kscience.dataforge.meta.Meta @@ -19,29 +20,29 @@ public fun Vision.useProperty( propertyName: Name, inherit: Boolean? = null, includeStyles: Boolean? = null, - scope: CoroutineScope? = manager?.context, + scope: CoroutineScope = manager?.context ?: error("Orphan Vision can't observe properties. Use explicit scope."), callback: (Meta) -> Unit, ): Job { //Pass initial value. - callback(properties.getMeta(propertyName, inherit, includeStyles)) + callback(properties.get(propertyName, inherit, includeStyles)) return properties.changes.onEach { name -> if (name.startsWith(propertyName)) { - callback(properties.getMeta(propertyName, inherit, includeStyles)) + callback(properties.get(propertyName, inherit, includeStyles)) } - }.launchIn(scope ?: error("Orphan Vision can't observe properties")) + }.launchIn(scope) } public fun Vision.useProperty( propertyName: String, inherit: Boolean? = null, includeStyles: Boolean? = null, - scope: CoroutineScope? = manager?.context, + scope: CoroutineScope = manager?.context ?: error("Orphan Vision can't observe properties. Use explicit scope."), callback: (Meta) -> Unit, ): Job = useProperty(propertyName.parseAsName(), inherit, includeStyles, scope, callback) public fun V.useProperty( property: KProperty1, - scope: CoroutineScope? = manager?.context, + scope: CoroutineScope = manager?.context ?: error("Orphan Vision can't observe properties. Use explicit scope."), callback: V.(T) -> Unit, ): Job { //Pass initial value. @@ -50,5 +51,26 @@ public fun V.useProperty( if (name.startsWith(property.name.asName())) { callback(property.get(this@useProperty)) } - }.launchIn(scope ?: error("Orphan Vision can't observe properties")) -} \ No newline at end of file + }.launchIn(scope) +} + +/** + * Subscribe on property updates. The subscription is bound to the given scope and canceled when the scope is canceled + */ +public fun Vision.onPropertyChange( + scope: CoroutineScope = manager?.context ?: error("Orphan Vision can't observe properties. Use explicit scope."), + callback: suspend (Name) -> Unit, +): Job = properties.changes.onEach { + callback(it) +}.launchIn(scope) + +/** + * Observe changes to the specific property without passing the initial value. + */ +public fun V.onPropertyChange( + property: KProperty1, + scope: CoroutineScope = manager?.context ?: error("Orphan Vision can't observe properties. Use explicit scope."), + callback: suspend V.(T) -> Unit, +): Job = properties.changes.filter { it.startsWith(property.name.asName()) }.onEach { + callback(property.get(this)) +}.launchIn(scope) \ No newline at end of file diff --git a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt index 20868b96..b4cb115d 100644 --- a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt +++ b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/html/HtmlTagTest.kt @@ -55,7 +55,7 @@ class HtmlTagTest { div { h2 { +"Properties" } ul { - vision.properties.own?.items?.forEach { + vision.properties.own.items.forEach { li { a { +it.key.toString() } p { +it.value.toString() } diff --git a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt index a6ea86a2..71b3109c 100644 --- a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt +++ b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt @@ -1,17 +1,16 @@ package space.kscience.visionforge.meta import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.take -import kotlinx.coroutines.flow.toList -import kotlinx.coroutines.launch +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.test.runTest import space.kscience.dataforge.context.Global import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.* import space.kscience.visionforge.* +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals @@ -24,7 +23,6 @@ private class TestScheme : Scheme() { companion object : SchemeSpec(::TestScheme) } -@OptIn(ExperimentalCoroutinesApi::class) internal class VisionPropertyTest { private val manager = Global.request(VisionManager) @@ -42,7 +40,7 @@ internal class VisionPropertyTest { @Test fun testPropertyEdit() { val vision = manager.group() - vision.properties.getMeta("fff.ddd").apply { + vision.properties["fff.ddd"].apply { value = 2.asValue() } assertEquals(2, vision.properties.getValue("fff.ddd")?.int) @@ -52,7 +50,7 @@ internal class VisionPropertyTest { @Test fun testPropertyUpdate() { val vision = manager.group() - vision.properties.getMeta("fff").updateWith(TestScheme) { + vision.properties["fff"].updateWith(TestScheme) { ddd = 2 } assertEquals(2, vision.properties.getValue("fff.ddd")?.int) @@ -87,14 +85,15 @@ internal class VisionPropertyTest { child.properties.remove("test") - assertEquals(11, child.properties.getMeta("test", inherit = true).int) + assertEquals(11, child.properties.get("test", inherit = true).int) // assertEquals(11, deferred.await()?.int) // assertEquals(2, callCounter) subscription.cancel() } @Test - fun testChildrenPropertyFlow() = runTest(timeout = 200.milliseconds) { + @Ignore + fun testChildrenPropertyFlow() = runTest(timeout = 500.milliseconds) { val group = Global.request(VisionManager).group { properties { @@ -111,17 +110,32 @@ internal class VisionPropertyTest { val child = group.children["child"]!! - launch { - val list = child.flowPropertyValue("test", inherit = true).take(3).map { it?.int }.toList() - assertEquals(22, list.first()) - //assertEquals(11, list[1]) //a race - assertEquals(33, list.last()) + val semaphore = Semaphore(1, 1) + + val changesFlow = child.flowPropertyValue("test", inherit = true).map { + semaphore.release() + it!!.int } - //wait for subscription to be created - delay(5) + val collectedValues = ArrayList(5) + val collectorJob = changesFlow.onEach { + collectedValues.add(it) + }.launchIn(this) + + assertEquals(22, child.properties["test", true].int) + + semaphore.acquire() child.properties.remove("test") + + assertEquals(11, child.properties["test", true].int) + + semaphore.acquire() group.properties["test"] = 33 + assertEquals(33, child.properties["test", true].int) + + semaphore.acquire() + collectorJob.cancel() + assertEquals(listOf(22, 11, 33), collectedValues) } } \ No newline at end of file diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/Application.kt similarity index 94% rename from visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt rename to visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/Application.kt index 85ead127..1e00d529 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/Application.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/Application.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge +package space.kscience.visionforge.html import kotlinx.browser.document import kotlinx.coroutines.CoroutineScope @@ -46,7 +46,7 @@ public interface Application: CoroutineScope { } public fun startApplication(builder: () -> Application) { - fun start(document: Document, state: dynamic): Application{ + fun start(document: Document, state: dynamic): Application { val application = builder() @Suppress("UnsafeCastFromDynamic") diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/ElementVisionRenderer.kt similarity index 68% rename from visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt rename to visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/ElementVisionRenderer.kt index 75ec785a..57d3e4e1 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/ElementVisionRenderer.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/ElementVisionRenderer.kt @@ -1,32 +1,27 @@ -package space.kscience.visionforge +package space.kscience.visionforge.html import kotlinx.dom.clear import kotlinx.html.TagConsumer import kotlinx.html.dom.append -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.InternalSerializationApi -import kotlinx.serialization.serializerOrNull import org.w3c.dom.Element import org.w3c.dom.HTMLElement import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.misc.Named -import space.kscience.dataforge.misc.Type +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.names.Name -import space.kscience.dataforge.names.asName -import space.kscience.dataforge.names.parseAsName +import space.kscience.visionforge.Vision import kotlin.reflect.KClass import kotlin.reflect.cast /** * A browser renderer for a [Vision]. */ -@Type(ElementVisionRenderer.TYPE) -public interface ElementVisionRenderer : Named { +@DfType(ElementVisionRenderer.TYPE) +public interface ElementVisionRenderer { /** * Give a [vision] integer rating based on this renderer capabilities. [ZERO_RATING] or negative values means that this renderer * can't process a vision. The value of [DEFAULT_RATING] used for default renderer. Specialized renderers could specify - * higher value in order to "steal" rendering job + * higher value to "steal" rendering job */ public fun rateVision(vision: Vision): Int @@ -34,7 +29,14 @@ public interface ElementVisionRenderer : Named { * Display the [vision] inside a given [element] replacing its current content. * @param meta additional parameters for rendering container */ - public fun render(element: Element, name: Name, vision: Vision, meta: Meta = Meta.EMPTY) + public fun render( + element: Element, + name: Name, + vision: Vision, + meta: Meta = Meta.EMPTY, + ) + + override fun toString(): String public companion object { public const val TYPE: String = "elementVisionRenderer" @@ -52,20 +54,22 @@ public class SingleTypeVisionRenderer( private val renderFunction: TagConsumer.(name: Name, vision: T, meta: Meta) -> Unit, ) : ElementVisionRenderer { - @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class) - override val name: Name - get() = kClass.serializerOrNull()?.descriptor?.serialName?.parseAsName() - ?: kClass.toString().asName() - override fun rateVision(vision: Vision): Int = if (vision::class == kClass) acceptRating else ElementVisionRenderer.ZERO_RATING - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { + override fun render( + element: Element, + name: Name, + vision: Vision, + meta: Meta, + ) { element.clear() element.append { renderFunction(name, kClass.cast(vision), meta) } } + + override fun toString(): String = "ElementVisionRender(${kClass.simpleName})" } public inline fun ElementVisionRenderer( diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/JsVisionClient.kt similarity index 81% rename from visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt rename to visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/JsVisionClient.kt index b9e0ef93..c69e1e91 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/JsVisionClient.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/JsVisionClient.kt @@ -1,4 +1,4 @@ -package space.kscience.visionforge +package space.kscience.visionforge.html import kotlinx.browser.document import kotlinx.browser.window @@ -12,6 +12,7 @@ import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.serialization.encodeToString import org.w3c.dom.* import org.w3c.dom.url.URL import space.kscience.dataforge.context.* @@ -20,8 +21,9 @@ import space.kscience.dataforge.meta.MetaSerializer import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.int import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.parseAsName -import space.kscience.visionforge.html.VisionTagConsumer +import space.kscience.visionforge.* import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_CONNECT_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_ENDPOINT_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_FETCH_ATTRIBUTE @@ -67,7 +69,8 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { private val mutex = Mutex() - private val changeCollector = VisionChangeBuilder() + + private val rootChangeCollector = VisionChangeBuilder() /** * Communicate vision property changed from rendering engine to model @@ -75,14 +78,12 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { override fun notifyPropertyChanged(visionName: Name, propertyName: Name, item: Meta?) { context.launch { mutex.withLock { - changeCollector.propertyChanged(visionName, propertyName, item) + rootChangeCollector.propertyChanged(visionName, propertyName, item) } } } - private val eventCollector by lazy { - MutableSharedFlow>(meta["feedback.eventCache"].int ?: 100) - } + private val eventCollector = MutableSharedFlow>(meta["feedback.eventCache"].int ?: 100) /** * Send a custom feedback event @@ -91,13 +92,7 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { eventCollector.emit(targetName to event) } - private fun renderVision(element: Element, name: Name, vision: Vision, outputMeta: Meta) { - vision.setAsRoot(visionManager) - val renderer = findRendererFor(vision) ?: error("Could not find renderer for ${vision::class}") - renderer.render(element, name, vision, outputMeta) - } - - private fun startVisionUpdate(element: Element, name: Name, vision: Vision?, outputMeta: Meta) { + private fun startVisionUpdate(element: Element, visionName: Name, vision: Vision, outputMeta: Meta) { element.attributes[OUTPUT_CONNECT_ATTRIBUTE]?.let { attr -> val wsUrl = if (attr.value.isBlank() || attr.value == VisionTagConsumer.AUTO_DATA_ATTRIBUTE) { val endpoint = resolveEndpoint(element) @@ -109,9 +104,10 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { URL(attr.value) }.apply { protocol = "ws" - searchParams.append("name", name.toString()) + searchParams.append("name", visionName.toString()) } + logger.info { "Updating vision data from $wsUrl" } //Individual websocket for this vision @@ -119,27 +115,24 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { onmessage = { messageEvent -> val stringData: String? = messageEvent.data as? String if (stringData != null) { - val event: VisionEvent = visionManager.jsonFormat.decodeFromString( - VisionEvent.serializer(), - stringData - ) + val event: VisionEvent = visionManager.jsonFormat.decodeFromString(stringData) // If change contains root vision replacement, do it - if(event is VisionChange) { + if (event is VisionChange) { event.vision?.let { vision -> - renderVision(element, name, vision, outputMeta) + renderVision(element, visionName, vision, outputMeta) } } - logger.debug { "Got $event for output with name $name" } - if (vision == null) error("Can't update vision because it is not loaded.") - vision.receiveEvent(event) + logger.debug { "Got $event for output with name $visionName" } + context.launch { + vision.receiveEvent(event) + } } else { logger.error { "WebSocket message data is not a string" } } } - //Backward change propagation var feedbackJob: Job? = null @@ -147,37 +140,58 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { val feedbackAggregationTime = meta["feedback.aggregationTime"]?.int ?: 300 onopen = { + feedbackJob = visionManager.context.launch { - eventCollector.filter { it.first == name }.onEach { - send(visionManager.jsonFormat.encodeToString(VisionEvent.serializer(), it.second)) + //launch a separate coroutine to send events to the backend + eventCollector.filter { it.first == visionName }.onEach { + send(visionManager.jsonFormat.encodeToString(it.second)) }.launchIn(this) + //aggregate atomic changes while (isActive) { delay(feedbackAggregationTime.milliseconds) - val change = changeCollector[name] ?: continue - if (!change.isEmpty()) { + val visionChangeCollector = rootChangeCollector[name] + if (visionChangeCollector?.isEmpty() == false) { mutex.withLock { - eventCollector.emit(name to change.deepCopy(visionManager)) - change.reset() + eventCollector.emit(visionName to visionChangeCollector.deepCopy(visionManager)) + rootChangeCollector.reset() } } } } - logger.info { "WebSocket feedback channel established for output '$name'" } + logger.info { "WebSocket feedback channel established for output '$visionName'" } } onclose = { feedbackJob?.cancel() - logger.info { "WebSocket feedback channel closed for output '$name'" } + logger.info { "WebSocket feedback channel closed for output '$visionName'" } } onerror = { feedbackJob?.cancel() - logger.error { "WebSocket feedback channel error for output '$name'" } + logger.error { "WebSocket feedback channel error for output '$visionName'" } } } } } + + private fun renderVision(element: Element, name: Name, vision: Vision, outputMeta: Meta) { + vision.setAsRoot(visionManager) + val renderer: ElementVisionRenderer = + findRendererFor(vision) ?: error("Could not find renderer for ${vision::class}") + //render vision + renderer.render(element, name, vision, outputMeta) + //start vision update from backend model + startVisionUpdate(element, name, vision, outputMeta) + //subscribe to a backwards events propagation for control visions + if(vision is ControlVision){ + vision.controlEventFlow.onEach { + sendEvent(name,it) + }.launchIn(context) + } + + } + /** * Fetch from server and render a vision, described in a given with [VisionTagConsumer.OUTPUT_CLASS] class. */ @@ -221,7 +235,6 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { response.text().then { text -> val vision = visionManager.decodeFromString(text) renderVision(element, name, vision, outputMeta) - startVisionUpdate(element, name, vision, outputMeta) } } else { logger.error { "Failed to fetch initial vision state from $fetchUrl" } @@ -237,13 +250,12 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { } logger.info { "Found embedded vision for output with name $name" } renderVision(element, name, embeddedVision, outputMeta) - startVisionUpdate(element, name, embeddedVision, outputMeta) } //Try to load vision via websocket - element.attributes[OUTPUT_CONNECT_ATTRIBUTE] != null -> { - startVisionUpdate(element, name, null, outputMeta) - } +// element.attributes[OUTPUT_CONNECT_ATTRIBUTE] != null -> { +// startVisionUpdate(element, name, null, outputMeta) +// } else -> error("No embedded vision data / fetch url for $name") } @@ -252,10 +264,15 @@ public class JsVisionClient : AbstractPlugin(), VisionClient { override fun content(target: String): Map = if (target == ElementVisionRenderer.TYPE) { listOf( - numberVisionRenderer(this), - textVisionRenderer(this), - formVisionRenderer(this) - ).associateByName() + htmlVisionRenderer, + inputVisionRenderer, + checkboxVisionRenderer, + numberVisionRenderer, + textVisionRenderer, + rangeVisionRenderer, + formVisionRenderer, + buttonVisionRenderer + ).associateBy { it.toString().asName() } } else super.content(target) public companion object : PluginFactory { @@ -314,7 +331,7 @@ public class VisionClientApplication(public val context: Context) : Application client.renderers.joinToString( prefix = "\n\t", separator = "\n\t" - ) { it.name.toString() } + ) { it.toString() } }" } val element = document.body ?: error("Document does not have a body") diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/formRenderers.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/formRenderers.kt new file mode 100644 index 00000000..a8c693d6 --- /dev/null +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/formRenderers.kt @@ -0,0 +1,89 @@ +package space.kscience.visionforge.html + +import kotlinx.browser.document +import kotlinx.coroutines.launch +import kotlinx.html.ButtonType +import kotlinx.html.js.button +import org.w3c.dom.HTMLFormElement +import org.w3c.dom.HTMLInputElement +import org.w3c.dom.get +import org.w3c.xhr.FormData +import space.kscience.dataforge.context.debug +import space.kscience.dataforge.context.logger +import space.kscience.dataforge.meta.* +import space.kscience.dataforge.names.Name +import space.kscience.visionforge.* + +/** + * Convert form data to Meta + */ +public fun FormData.toMeta(): Meta { + @Suppress("UNUSED_VARIABLE") val formData = this + //val res = js("Object.fromEntries(formData);") + val `object` = js("{}") + //language=JavaScript + js( + """ + formData.forEach(function(value, key){ + // Reflect.has in favor of: object.hasOwnProperty(key) + if(!Reflect.has(object, key)){ + object[key] = value; + return; + } + if(!Array.isArray(object[key])){ + object[key] = [object[key]]; + } + object[key].push(value); + }); + """ + ) + return DynamicMeta(`object`) +} + + +public fun VisionClient.sendMetaEvent(targetName: Name, payload: MetaRepr): Unit { + context.launch { + sendEvent(targetName, VisionMetaEvent(payload.toMeta())) + } +} + +internal val formVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + + val form = document.getElementById(vision.formId) as? HTMLFormElement + ?: error("An element with id = '${vision.formId} is not a form") + + form.subscribeToVision(vision) + + vision.manager?.logger?.debug { "Adding hooks to form with id = '$vision.formId'" } + + vision.useProperty(VisionOfHtmlForm::values) { values -> + vision.manager?.logger?.debug { "Updating form '${vision.formId}' with values $values" } + val inputs = form.getElementsByTagName("input") + values?.valueSequence()?.forEach { (token, value) -> + (inputs[token.toString()] as? HTMLInputElement)?.value = value.toString() + } + } + + form.onsubmit = { event -> + event.preventDefault() + val formData = FormData(form).toMeta() + vision.asyncControlEvent(VisionSubmitEvent(name = name, payload = formData)) + console.info("Sent form data: ${formData.toMap()}") + false + } + } + +internal val buttonVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + button(type = ButtonType.button).also { button -> + button.subscribeToVision(vision) + button.onclick = { + vision.asyncControlEvent(VisionSubmitEvent(name = name)) + } + vision.useProperty(VisionOfHtmlButton::label) { + button.innerHTML = it ?: "" + } + + } + } diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/inputRenderers.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/inputRenderers.kt new file mode 100644 index 00000000..3615c24a --- /dev/null +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/html/inputRenderers.kt @@ -0,0 +1,172 @@ +package space.kscience.visionforge.html + +import kotlinx.dom.clear +import kotlinx.html.InputType +import kotlinx.html.div +import kotlinx.html.js.input +import org.w3c.dom.HTMLElement +import org.w3c.dom.HTMLInputElement +import space.kscience.dataforge.meta.asValue +import space.kscience.dataforge.meta.double +import space.kscience.dataforge.meta.string +import space.kscience.visionforge.VisionInputEvent +import space.kscience.visionforge.VisionValueChangeEvent +import space.kscience.visionforge.asyncControlEvent +import space.kscience.visionforge.useProperty + +/** + * Subscribes the HTML element to a given vision. + * + * @param vision The vision to subscribe to. + */ +internal fun HTMLElement.subscribeToVision(vision: VisionOfHtml) { + vision.useProperty(VisionOfHtml::classes) { + classList.value = classes.joinToString(separator = " ") + } + + vision.useProperty(VisionOfHtml::styleString) { + style.cssText = it ?: "" + } +} + +/** + * Subscribes the HTML input element to a given vision. + * + * @param inputVision The input vision to subscribe to. + */ +private fun HTMLInputElement.subscribeToInput(inputVision: VisionOfHtmlInput) { + subscribeToVision(inputVision) + inputVision.useProperty(VisionOfHtmlInput::disabled) { + disabled = it + } +} + +internal val htmlVisionRenderer: ElementVisionRenderer = ElementVisionRenderer { _, vision, _ -> + div().also { div -> + div.subscribeToVision(vision) + vision.useProperty(VisionOfPlainHtml::content) { + div.clear() + if (it != null) div.innerHTML = it + } + } +} + +internal val inputVisionRenderer: ElementVisionRenderer = ElementVisionRenderer( + acceptRating = ElementVisionRenderer.DEFAULT_RATING - 1 +) { name, vision, _ -> + + input { + type = InputType.text + }.also { htmlInputElement -> + + htmlInputElement.onchange = { + vision.asyncControlEvent(VisionValueChangeEvent(htmlInputElement.value.asValue(), name)) + } + + htmlInputElement.oninput = { + vision.asyncControlEvent(VisionInputEvent(htmlInputElement.value.asValue(), name)) + } + + htmlInputElement.subscribeToInput(vision) + vision.useProperty(VisionOfHtmlInput::value) { + htmlInputElement.value = it?.string ?: "" + } + } +} + +internal val checkboxVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + input { + type = InputType.checkBox + }.also { htmlInputElement -> + + htmlInputElement.onchange = { + vision.asyncControlEvent(VisionValueChangeEvent(htmlInputElement.value.asValue(), name)) + } + + htmlInputElement.oninput = { + vision.asyncControlEvent(VisionInputEvent(htmlInputElement.value.asValue(), name)) + } + + + htmlInputElement.subscribeToInput(vision) + vision.useProperty(VisionOfCheckbox::checked) { + htmlInputElement.checked = it ?: false + } + } + } + +internal val textVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + input { + type = InputType.text + }.also { htmlInputElement -> + + htmlInputElement.onchange = { + vision.asyncControlEvent(VisionValueChangeEvent(htmlInputElement.value.asValue(), name)) + } + + htmlInputElement.oninput = { + vision.asyncControlEvent(VisionInputEvent(htmlInputElement.value.asValue(), name)) + } + + htmlInputElement.subscribeToInput(vision) + vision.useProperty(VisionOfTextField::text) { + htmlInputElement.value = it ?: "" + } + } + } + +internal val numberVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + input { + type = InputType.number + }.also { htmlInputElement -> + + htmlInputElement.onchange = { + htmlInputElement.value.toDoubleOrNull()?.let { + vision.asyncControlEvent(VisionValueChangeEvent(it.asValue(), name)) + } + } + + htmlInputElement.oninput = { + htmlInputElement.value.toDoubleOrNull()?.let { + vision.asyncControlEvent(VisionInputEvent(it.asValue(), name)) + } + } + + + htmlInputElement.subscribeToInput(vision) + vision.useProperty(VisionOfNumberField::value) { + htmlInputElement.valueAsNumber = it?.double ?: 0.0 + } + } + } + +internal val rangeVisionRenderer: ElementVisionRenderer = + ElementVisionRenderer { name, vision, _ -> + input { + type = InputType.range + min = vision.min.toString() + max = vision.max.toString() + step = vision.step.toString() + }.also { htmlInputElement -> + + htmlInputElement.onchange = { + htmlInputElement.value.toDoubleOrNull()?.let { + vision.asyncControlEvent(VisionValueChangeEvent(it.asValue(), name)) + } + } + + htmlInputElement.oninput = { + htmlInputElement.value.toDoubleOrNull()?.let { + vision.asyncControlEvent(VisionInputEvent(it.asValue(), name)) + } + } + + htmlInputElement.subscribeToInput(vision) + vision.useProperty(VisionOfRangeField::value) { + htmlInputElement.valueAsNumber = it?.double ?: 0.0 + } + } + } diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt deleted file mode 100644 index ff84c403..00000000 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/inputRenderers.kt +++ /dev/null @@ -1,113 +0,0 @@ -package space.kscience.visionforge - -import kotlinx.browser.document -import kotlinx.html.InputType -import kotlinx.html.js.input -import kotlinx.html.js.label -import kotlinx.html.js.onChangeFunction -import org.w3c.dom.HTMLFormElement -import org.w3c.dom.HTMLInputElement -import org.w3c.dom.get -import org.w3c.xhr.FormData -import space.kscience.dataforge.context.debug -import space.kscience.dataforge.context.logger -import space.kscience.dataforge.meta.DynamicMeta -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.toMap -import space.kscience.dataforge.meta.valueSequence -import space.kscience.visionforge.html.VisionOfHtmlForm -import space.kscience.visionforge.html.VisionOfNumberField -import space.kscience.visionforge.html.VisionOfTextField - -internal fun textVisionRenderer( - client: JsVisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - val fieldName = vision.name ?: "input[${vision.hashCode().toUInt()}]" - vision.label?.let { - label { - htmlFor = fieldName - +it - } - } - input { - type = InputType.text - this.name = fieldName - vision.useProperty(VisionOfTextField::text) { - value = it ?: "" - } - onChangeFunction = { - client.notifyPropertyChanged(name, VisionOfTextField::text.name, value) - } - } -} - -internal fun numberVisionRenderer( - client: JsVisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - val fieldName = vision.name ?: "input[${vision.hashCode().toUInt()}]" - vision.label?.let { - label { - htmlFor = fieldName - +it - } - } - input { - type = InputType.text - this.name = fieldName - vision.useProperty(VisionOfNumberField::value) { - value = it?.toDouble() ?: 0.0 - } - onChangeFunction = { - client.notifyPropertyChanged(name, VisionOfNumberField::value.name, value) - } - } -} - -internal fun FormData.toMeta(): Meta { - @Suppress("UNUSED_VARIABLE") val formData = this - //val res = js("Object.fromEntries(formData);") - val `object` = js("{}") - //language=JavaScript - js( - """ - formData.forEach(function(value, key){ - // Reflect.has in favor of: object.hasOwnProperty(key) - if(!Reflect.has(object, key)){ - object[key] = value; - return; - } - if(!Array.isArray(object[key])){ - object[key] = [object[key]]; - } - object[key].push(value); - }); - """ - ) - return DynamicMeta(`object`) -} - -internal fun formVisionRenderer( - client: JsVisionClient, -): ElementVisionRenderer = ElementVisionRenderer { name, vision, _ -> - - val form = document.getElementById(vision.formId) as? HTMLFormElement - ?: error("An element with id = '${vision.formId} is not a form") - - client.logger.debug{"Adding hooks to form with id = '$vision.formId'"} - - vision.useProperty(VisionOfHtmlForm::values) { values -> - client.logger.debug{"Updating form '${vision.formId}' with values $values"} - val inputs = form.getElementsByTagName("input") - values?.valueSequence()?.forEach { (token, value) -> - (inputs[token.toString()] as? HTMLInputElement)?.value = value.toString() - } - } - - form.onsubmit = { event -> - event.preventDefault() - val formData = FormData(form).toMeta() - client.notifyPropertyChanged(name, VisionOfHtmlForm::values.name, formData) - console.info("Sent: ${formData.toMap()}") - false - } -} \ No newline at end of file diff --git a/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt b/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt index 58bd2b09..75b5c188 100644 --- a/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt +++ b/visionforge-core/src/jsTest/kotlin/space/kscience/visionforge/FormTest.kt @@ -4,6 +4,7 @@ import org.w3c.xhr.FormData import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.int import space.kscience.dataforge.meta.stringList +import space.kscience.visionforge.html.toMeta import kotlin.test.Test import kotlin.test.assertEquals diff --git a/visionforge-core/src/jvmTest/kotlin/space/kscience/visionforge/meta/PropertyFlowTest.kt b/visionforge-core/src/jvmTest/kotlin/space/kscience/visionforge/meta/PropertyFlowTest.kt new file mode 100644 index 00000000..3c5834a5 --- /dev/null +++ b/visionforge-core/src/jvmTest/kotlin/space/kscience/visionforge/meta/PropertyFlowTest.kt @@ -0,0 +1,65 @@ +package space.kscience.visionforge.meta + +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.Timeout +import space.kscience.dataforge.context.Global +import space.kscience.dataforge.context.request +import space.kscience.dataforge.meta.* +import space.kscience.visionforge.* +import kotlin.test.Test +import kotlin.test.assertEquals + +internal class PropertyFlowTest { + + private val manager = Global.request(VisionManager) + + @Test + @Timeout(200) + fun testChildrenPropertyFlow() = runBlocking{ + val group = Global.request(VisionManager).group { + + properties { + "test" put 11 + } + + group("child") { + properties { + "test" put 22 + } + } + + } + + val child = group.children["child"]!! + + val changesFlow = child.flowPropertyValue("test", inherit = true).map { + it!!.int + } + + val collectedValues = ArrayList(5) + + val collectorJob = changesFlow.onEach { + collectedValues.add(it) + }.launchIn(this) + + + delay(2) + assertEquals(22, child.properties["test", true].int) + + child.properties.remove("test") + delay(2) + + assertEquals(11, child.properties["test", true].int) + group.properties["test"] = 33 + delay(2) + + assertEquals(33, child.properties["test", true].int) + + collectorJob.cancel() + assertEquals(listOf(22, 11, 33), collectedValues) + } +} \ No newline at end of file diff --git a/visionforge-gdml/README.md b/visionforge-gdml/README.md index 135a369e..e26717d4 100644 --- a/visionforge-gdml/README.md +++ b/visionforge-gdml/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-gdml:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-gdml:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-gdml:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-gdml:0.2.0") + implementation("space.kscience:visionforge-gdml:0.4.1") } ``` diff --git a/visionforge-gdml/api/visionforge-gdml.api b/visionforge-gdml/api/visionforge-gdml.api index 1a73d170..6922b868 100644 --- a/visionforge-gdml/api/visionforge-gdml.api +++ b/visionforge-gdml/api/visionforge-gdml.api @@ -14,19 +14,21 @@ public final class space/kscience/visionforge/gdml/GdmlLoaderKt { public final class space/kscience/visionforge/gdml/GdmlLoaderOptions { public static final field Companion Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Companion; public fun ()V - public final fun configure (Lkotlin/jvm/functions/Function4;)V public final fun getAUnit ()Lspace/kscience/gdml/AUnit; public final fun getConfigurePaint ()Lkotlin/jvm/functions/Function3; public final fun getConfigureSolid ()Lkotlin/jvm/functions/Function4; public final fun getLUnit ()Lspace/kscience/gdml/LUnit; + public final fun getLight ()Lspace/kscience/visionforge/solid/LightSource; public final fun getSolidAction ()Lkotlin/jvm/functions/Function1; public final fun getVolumeAction ()Lkotlin/jvm/functions/Function1; public final fun paint (Lkotlin/jvm/functions/Function3;)V public final fun registerAndUseStyle (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V public final fun setAUnit (Lspace/kscience/gdml/AUnit;)V public final fun setLUnit (Lspace/kscience/gdml/LUnit;)V + public final fun setLight (Lspace/kscience/visionforge/solid/LightSource;)V public final fun setSolidAction (Lkotlin/jvm/functions/Function1;)V public final fun setVolumeAction (Lkotlin/jvm/functions/Function1;)V + public final fun solids (Lkotlin/jvm/functions/Function4;)V public final fun transparent (Lspace/kscience/visionforge/solid/Solid;)V } @@ -34,6 +36,7 @@ public final class space/kscience/visionforge/gdml/GdmlLoaderOptions$Action : ja public static final field ADD Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; public static final field PROTOTYPE Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; public static final field REJECT Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; public static fun values ()[Lspace/kscience/visionforge/gdml/GdmlLoaderOptions$Action; } diff --git a/visionforge-jupyter/README.md b/visionforge-jupyter/README.md index 433d3042..b5794ea5 100644 --- a/visionforge-jupyter/README.md +++ b/visionforge-jupyter/README.md @@ -1,4 +1,21 @@ -# Module jupyter +# Module visionforge-jupyter Common visionforge jupyter module +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:visionforge-jupyter:0.4.1`. + +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:visionforge-jupyter:0.4.1") +} +``` diff --git a/visionforge-jupyter/api/visionforge-jupyter.api b/visionforge-jupyter/api/visionforge-jupyter.api new file mode 100644 index 00000000..019c5d4a --- /dev/null +++ b/visionforge-jupyter/api/visionforge-jupyter.api @@ -0,0 +1,54 @@ +public final class space/kscience/visionforge/jupyter/FormsKt { + public static final fun HtmlFormFragment (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/jupyter/HtmlFormFragment; + public static synthetic fun HtmlFormFragment$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/jupyter/HtmlFormFragment; + public static final fun form (Lspace/kscience/visionforge/jupyter/VisionForge;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/jupyter/HtmlFormFragment; + public static synthetic fun form$default (Lspace/kscience/visionforge/jupyter/VisionForge;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/jupyter/HtmlFormFragment; +} + +public final class space/kscience/visionforge/jupyter/HtmlFormFragment { + public final fun get (Ljava/lang/String;)Lspace/kscience/dataforge/meta/Meta; + public final fun getFormBody ()Lspace/kscience/visionforge/html/HtmlFragment; + public final fun getValues ()Lspace/kscience/dataforge/meta/Meta; + public final fun getVision ()Lspace/kscience/visionforge/html/VisionOfHtmlForm; +} + +public final class space/kscience/visionforge/jupyter/VisionForge : kotlinx/coroutines/CoroutineScope, space/kscience/dataforge/context/ContextAware { + public fun (Lspace/kscience/visionforge/VisionManager;Lorg/jetbrains/kotlinx/jupyter/api/Notebook;Lspace/kscience/dataforge/meta/Meta;)V + public synthetic fun (Lspace/kscience/visionforge/VisionManager;Lorg/jetbrains/kotlinx/jupyter/api/Notebook;Lspace/kscience/dataforge/meta/Meta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun form (Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/jupyter/HtmlFormFragment; + public final fun getConfiguration ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; + public fun getContext ()Lspace/kscience/dataforge/context/Context; + public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext; + public final fun getNotebook ()Lorg/jetbrains/kotlinx/jupyter/api/Notebook; + public final fun getProperty (Ljava/lang/String;)Lspace/kscience/dataforge/meta/TypedMeta; + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public final fun isServerRunning ()Z + public final fun produceHtml (Ljava/lang/Boolean;Lspace/kscience/visionforge/html/HtmlVisionFragment;)Lorg/jetbrains/kotlinx/jupyter/api/MimeTypedResult; + public static synthetic fun produceHtml$default (Lspace/kscience/visionforge/jupyter/VisionForge;Ljava/lang/Boolean;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/jupyter/api/MimeTypedResult; +} + +public final class space/kscience/visionforge/jupyter/VisionForgeCompatibility : java/lang/Enum { + public static final field DATALORE Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; + public static final field IDEA Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; + public static final field JUPYTER Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; + public static final field JUPYTER_LAB Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; + public static fun values ()[Lspace/kscience/visionforge/jupyter/VisionForgeCompatibility; +} + +public abstract class space/kscience/visionforge/jupyter/VisionForgeIntegration : org/jetbrains/kotlinx/jupyter/api/libraries/JupyterIntegration, space/kscience/dataforge/context/ContextAware { + public fun (Lspace/kscience/visionforge/VisionManager;)V + protected abstract fun afterLoaded (Lorg/jetbrains/kotlinx/jupyter/api/libraries/JupyterIntegration$Builder;Lspace/kscience/visionforge/jupyter/VisionForge;)V + public fun getContext ()Lspace/kscience/dataforge/context/Context; + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public final fun onLoaded (Lorg/jetbrains/kotlinx/jupyter/api/libraries/JupyterIntegration$Builder;)V +} + +public final class space/kscience/visionforge/jupyter/VisionForgeIntegrationKt { + public static final fun fragment (Lspace/kscience/visionforge/jupyter/VisionForge;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlinx/jupyter/api/MimeTypedResult; + public static final fun html (Lspace/kscience/visionforge/jupyter/VisionForge;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlinx/jupyter/api/MimeTypedResult; + public static final fun page (Lspace/kscience/visionforge/jupyter/VisionForge;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/html/VisionPage; + public static synthetic fun page$default (Lspace/kscience/visionforge/jupyter/VisionForge;Ljava/util/Map;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/html/VisionPage; +} + diff --git a/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt b/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt index e095485c..2b78f450 100644 --- a/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt +++ b/visionforge-jupyter/src/jsMain/kotlin/VFNotebookClient.kt @@ -8,10 +8,10 @@ import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta -import space.kscience.visionforge.JsVisionClient -import space.kscience.visionforge.renderAllVisions -import space.kscience.visionforge.renderAllVisionsById -import space.kscience.visionforge.renderAllVisionsIn +import space.kscience.visionforge.html.JsVisionClient +import space.kscience.visionforge.html.renderAllVisions +import space.kscience.visionforge.html.renderAllVisionsById +import space.kscience.visionforge.html.renderAllVisionsIn @JsExport public class VFNotebookClient : AbstractPlugin() { diff --git a/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt b/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt index 49d5fe23..5ac2c37b 100644 --- a/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt +++ b/visionforge-jupyter/src/jvmMain/kotlin/VisionForge.kt @@ -17,9 +17,9 @@ import space.kscience.dataforge.context.info import space.kscience.dataforge.context.logger import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name -import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager import space.kscience.visionforge.html.HtmlVisionFragment +import space.kscience.visionforge.html.VisionDisplay import space.kscience.visionforge.html.visionFragment import space.kscience.visionforge.server.VisionRoute import space.kscience.visionforge.server.serveVisionData @@ -55,7 +55,7 @@ public class VisionForge( override val context: Context get() = visionManager.context - public val configuration: ObservableMutableMeta = meta.toMutableMeta() + public val configuration: ObservableMutableMeta = meta.toMutableMeta().asObservable() private var counter = 0 @@ -142,7 +142,7 @@ public class VisionForge( //server.serveVisionsFromFragment(consumer, "content-${counter++}", fragment) val cellRoute = "content-${counter++}" - val collector: MutableMap = mutableMapOf() + val cache: MutableMap = mutableMapOf() val url = engine.environment.connectors.first().let { url { @@ -153,13 +153,13 @@ public class VisionForge( } } - engine.application.serveVisionData(VisionRoute(cellRoute, visionManager), collector) + engine.application.serveVisionData(VisionRoute(cellRoute, visionManager), cache) visionFragment( visionManager, embedData = true, updatesUrl = url, - onVisionRendered = { name, vision -> collector[name] = vision }, + displayCache = cache, fragment = fragment ) } else { diff --git a/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt b/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt index afc2ecc2..935f183c 100644 --- a/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt +++ b/visionforge-jupyter/src/jvmMain/kotlin/VisionForgeIntegration.kt @@ -7,7 +7,6 @@ import org.jetbrains.kotlinx.jupyter.api.declare import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager import space.kscience.visionforge.html.* @@ -17,7 +16,6 @@ import kotlin.random.nextUInt /** * A base class for different Jupyter VF integrations */ -@DFExperimental public abstract class VisionForgeIntegration( public val visionManager: VisionManager, ) : JupyterIntegration(), ContextAware { diff --git a/visionforge-jupyter/visionforge-jupyter-common/api/visionforge-jupyter-common.api b/visionforge-jupyter/visionforge-jupyter-common/api/visionforge-jupyter-common.api new file mode 100644 index 00000000..7e1cbb84 --- /dev/null +++ b/visionforge-jupyter/visionforge-jupyter-common/api/visionforge-jupyter-common.api @@ -0,0 +1,8 @@ +public final class space/kscience/visionforge/jupyter/JupyterCommonIntegration : space/kscience/visionforge/jupyter/VisionForgeIntegration { + public static final field Companion Lspace/kscience/visionforge/jupyter/JupyterCommonIntegration$Companion; + public fun ()V +} + +public final class space/kscience/visionforge/jupyter/JupyterCommonIntegration$Companion { +} + diff --git a/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts b/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts index e6fd162b..14984d77 100644 --- a/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts +++ b/visionforge-jupyter/visionforge-jupyter-common/build.gradle.kts @@ -7,16 +7,17 @@ description = "Jupyter api artifact including all common modules" kscience { fullStack( "js/visionforge-jupyter-common.js", - jsConfig = { useCommonJs() } - ) { - commonWebpackConfig { - sourceMaps = false - cssSupport { - enabled.set(false) + browserConfig = { + webpackTask { + cssSupport{ + enabled = true + } + scssSupport { + enabled = true + } } } - } - + ) dependencies { api(projects.visionforgeSolid) api(projects.visionforgePlotly) @@ -30,7 +31,6 @@ kscience { } jsMain { - implementation(projects.ui.ring) implementation(projects.visionforgeThreejs) } diff --git a/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt b/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt index e5fb4edd..10138701 100644 --- a/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt +++ b/visionforge-jupyter/visionforge-jupyter-common/src/jsMain/kotlin/commonJupyter.kt @@ -1,14 +1,14 @@ package space.kscience.visionforge.gdml.jupyter +import space.kscience.visionforge.html.runVisionClient import space.kscience.visionforge.jupyter.VFNotebookClient import space.kscience.visionforge.markup.MarkupPlugin import space.kscience.visionforge.plotly.PlotlyPlugin -import space.kscience.visionforge.ring.ThreeWithControlsPlugin -import space.kscience.visionforge.runVisionClient +import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.tables.TableVisionJsPlugin public fun main(): Unit = runVisionClient { - plugin(ThreeWithControlsPlugin) + plugin(ThreePlugin) plugin(PlotlyPlugin) plugin(MarkupPlugin) plugin(TableVisionJsPlugin) diff --git a/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt b/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt index 6200bd5d..2f7988f8 100644 --- a/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt +++ b/visionforge-jupyter/visionforge-jupyter-common/src/jvmMain/kotlin/JupyterCommonIntegration.kt @@ -1,14 +1,14 @@ package space.kscience.visionforge.jupyter -import kotlinx.html.* +import kotlinx.html.div +import kotlinx.html.p import org.jetbrains.kotlinx.jupyter.api.libraries.resources import space.kscience.dataforge.context.Context -import space.kscience.dataforge.misc.DFExperimental import space.kscience.gdml.Gdml import space.kscience.plotly.Plot import space.kscience.plotly.PlotlyPage import space.kscience.plotly.StaticPlotlyRenderer -import space.kscience.tables.* +import space.kscience.tables.Table import space.kscience.visionforge.gdml.toVision import space.kscience.visionforge.html.HtmlFragment import space.kscience.visionforge.html.VisionPage @@ -21,7 +21,6 @@ import space.kscience.visionforge.tables.toVision import space.kscience.visionforge.visionManager -@DFExperimental public class JupyterCommonIntegration : VisionForgeIntegration(CONTEXT.visionManager) { override fun Builder.afterLoaded(vf: VisionForge) { diff --git a/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js b/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js deleted file mode 100644 index cfb15cb8..00000000 --- a/visionforge-jupyter/visionforge-jupyter-common/webpack.config.d/01.ring.js +++ /dev/null @@ -1,24 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; - -const path = require('path'); - -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file diff --git a/visionforge-markdown/README.md b/visionforge-markdown/README.md index f43c742b..5aa2def9 100644 --- a/visionforge-markdown/README.md +++ b/visionforge-markdown/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-markdown:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-markdown:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-markdown:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-markdown:0.2.0") + implementation("space.kscience:visionforge-markdown:0.4.1") } ``` diff --git a/visionforge-markdown/api/visionforge-markdown.api b/visionforge-markdown/api/visionforge-markdown.api index 08028532..f8e472cf 100644 --- a/visionforge-markdown/api/visionforge-markdown.api +++ b/visionforge-markdown/api/visionforge-markdown.api @@ -3,23 +3,36 @@ public final class space/kscience/visionforge/markup/MarkdownKt { public static synthetic fun markdown$default (Lkotlinx/html/TagConsumer;Lorg/intellij/markdown/flavours/MarkdownFlavourDescriptor;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Ljava/lang/Object; } -public final class space/kscience/visionforge/markup/VisionOfMarkup : space/kscience/visionforge/VisionBase { +public final class space/kscience/visionforge/markup/MarkupPlugin : space/kscience/visionforge/VisionPlugin { + public static final field Companion Lspace/kscience/visionforge/markup/MarkupPlugin$Companion; + public fun ()V + public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; +} + +public final class space/kscience/visionforge/markup/MarkupPlugin$Companion : space/kscience/dataforge/context/PluginFactory { + public synthetic fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object; + public fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/visionforge/markup/MarkupPlugin; + public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; +} + +public final class space/kscience/visionforge/markup/MarkupPluginKt { + public static final fun content (Lspace/kscience/visionforge/markup/VisionOfMarkup;Ljava/lang/String;)V +} + +public final class space/kscience/visionforge/markup/VisionOfMarkup : space/kscience/visionforge/AbstractVision { public static final field COMMONMARK_FORMAT Ljava/lang/String; public static final field Companion Lspace/kscience/visionforge/markup/VisionOfMarkup$Companion; public static final field GFM_FORMAT Ljava/lang/String; public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/lang/String;)V public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getContent ()Ljava/lang/String; public final fun getFormat ()Ljava/lang/String; public final fun setContent (Ljava/lang/String;)V - public static final fun write$Self (Lspace/kscience/visionforge/markup/VisionOfMarkup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/markup/VisionOfMarkup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/markup/VisionOfMarkup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/markup/VisionOfMarkup; @@ -36,5 +49,7 @@ public final class space/kscience/visionforge/markup/VisionOfMarkup$Companion { public final class space/kscience/visionforge/markup/VisionOfMarkupKt { public static final fun content (Lspace/kscience/visionforge/markup/VisionOfMarkup;Lkotlin/jvm/functions/Function0;)V + public static final fun markdown (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/markup/VisionOfMarkup; + public static synthetic fun markdown$default (Lspace/kscience/visionforge/html/VisionOutput;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/markup/VisionOfMarkup; } diff --git a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt index 06470e4b..7ec33c80 100644 --- a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt @@ -13,14 +13,18 @@ import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.visionforge.* +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionPlugin +import space.kscience.visionforge.html.ElementVisionRenderer +import space.kscience.visionforge.html.JsVisionClient import space.kscience.visionforge.markup.VisionOfMarkup.Companion.COMMONMARK_FORMAT import space.kscience.visionforge.markup.VisionOfMarkup.Companion.GFM_FORMAT +import space.kscience.visionforge.useProperty public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: JsVisionClient by require(JsVisionClient) - actual override val tag: PluginTag get() = Companion.tag - actual override val visionSerializersModule: SerializersModule get() = markupSerializersModule + override val tag: PluginTag get() = Companion.tag + override val visionSerializersModule: SerializersModule get() = markupSerializersModule override fun rateVision(vision: Vision): Int = when (vision) { is VisionOfMarkup -> ElementVisionRenderer.DEFAULT_RATING @@ -34,7 +38,7 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { COMMONMARK_FORMAT -> CommonMarkFlavourDescriptor() GFM_FORMAT -> GFMFlavourDescriptor() //TODO add new formats via plugins - else-> error("Format ${vision.format} not recognized") + else -> error("Format ${vision.format} not recognized") } vision.useProperty(VisionOfMarkup::content) { div.clear() @@ -45,15 +49,17 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { element.append(div) } + override fun toString(): String = "Markup" + override fun content(target: String): Map = when (target) { ElementVisionRenderer.TYPE -> mapOf("markup".asName() to this) else -> super.content(target) } public actual companion object : PluginFactory { - actual override val tag: PluginTag = PluginTag("vision.markup.js", PluginTag.DATAFORGE_GROUP) + override val tag: PluginTag = PluginTag("vision.markup.js", PluginTag.DATAFORGE_GROUP) - actual override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() + override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() } } \ No newline at end of file diff --git a/visionforge-plotly/README.md b/visionforge-plotly/README.md index f8a03891..1b5c3678 100644 --- a/visionforge-plotly/README.md +++ b/visionforge-plotly/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-plotly:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-plotly:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-plotly:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-plotly:0.2.0") + implementation("space.kscience:visionforge-plotly:0.4.1") } ``` diff --git a/visionforge-plotly/api/visionforge-plotly.api b/visionforge-plotly/api/visionforge-plotly.api index 273f3123..349fe8d5 100644 --- a/visionforge-plotly/api/visionforge-plotly.api +++ b/visionforge-plotly/api/visionforge-plotly.api @@ -5,23 +5,24 @@ public final class space/kscience/visionforge/plotly/PlotlyPlugin : space/kscien } public final class space/kscience/visionforge/plotly/PlotlyPlugin$Companion : space/kscience/dataforge/context/PluginFactory { + public synthetic fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object; + public fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/visionforge/plotly/PlotlyPlugin; public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/plotly/PlotlyPlugin; } -public final class space/kscience/visionforge/plotly/VisionOfPlotly : space/kscience/visionforge/VisionBase { +public final class space/kscience/visionforge/plotly/VisionOfPlotly : space/kscience/visionforge/Vision { public static final field Companion Lspace/kscience/visionforge/plotly/VisionOfPlotly$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Lspace/kscience/plotly/Plot;)V + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; + public fun getParent ()Lspace/kscience/visionforge/Vision; public final fun getPlot ()Lspace/kscience/plotly/Plot; - public static final fun write$Self (Lspace/kscience/visionforge/plotly/VisionOfPlotly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getProperties ()Lspace/kscience/visionforge/MutableVisionProperties; + public fun setParent (Lspace/kscience/visionforge/Vision;)V } public final class space/kscience/visionforge/plotly/VisionOfPlotly$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/plotly/VisionOfPlotly$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; @@ -37,6 +38,7 @@ public final class space/kscience/visionforge/plotly/VisionOfPlotly$Companion { public final class space/kscience/visionforge/plotly/VisionOfPlotlyKt { public static final fun asVision (Lspace/kscience/plotly/Plot;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; - public static final fun plotly (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; + public static final fun plotly (Lspace/kscience/visionforge/html/VisionOutput;Lspace/kscience/plotly/PlotlyConfig;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; + public static synthetic fun plotly$default (Lspace/kscience/visionforge/html/VisionOutput;Lspace/kscience/plotly/PlotlyConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/plotly/VisionOfPlotly; } diff --git a/visionforge-plotly/build.gradle.kts b/visionforge-plotly/build.gradle.kts index 9d313266..81e5f60a 100644 --- a/visionforge-plotly/build.gradle.kts +++ b/visionforge-plotly/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("space.kscience.gradle.mpp") } -val plotlyVersion = "0.6.0" +val plotlyVersion = "0.7.0" kscience { jvm() diff --git a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt index d5333dda..444bcb9c 100644 --- a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt +++ b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt @@ -1,9 +1,7 @@ package space.kscience.visionforge.plotly import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.launch import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -26,59 +24,51 @@ public class VisionOfPlotly private constructor( ) : Vision { public constructor(plot: Plot) : this(plot.meta) - public val plot: Plot get() = Plot(meta.asObservable()) + @Transient + public val plot: Plot = Plot(meta.asObservable()) @Transient override var parent: Vision? = null @Transient override val properties: MutableVisionProperties = object : MutableVisionProperties { - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { - meta.setMeta(name, node) + override val own: Meta get() = plot.meta + + override val changes = callbackFlow { + plot.meta.onChange(this) { + launch { + send(it) + } + } + awaitClose { + plot.meta.removeListener(this) + } + } + + override fun invalidate(propertyName: Name) { + //do nothing, updates to source already counted +// manager?.context?.launch { +// changes.emit(propertyName) +// } + } + + override fun getValue(name: Name, inherit: Boolean?, includeStyles: Boolean?): Value? = plot.meta[name]?.value + + override fun set(name: Name, item: Meta?, notify: Boolean) { + plot.meta[name] = item + if (notify) invalidate(name) } override fun setValue(name: Name, value: Value?, notify: Boolean) { - meta.setValue(name, value) - } - - override val own: Meta get() = meta - - override val descriptor: MetaDescriptor? get() = this@VisionOfPlotly.descriptor - - override fun getMeta( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): MutableMeta = meta.getMeta(name) ?: MutableMeta() - - override fun getValue( - name: Name, - inherit: Boolean?, - includeStyles: Boolean?, - ): Value? = meta.getValue(name) - - override val changes: Flow = if (meta is ObservableMeta) { - callbackFlow { - meta.onChange(this) { - launch { - send(it) - } - } - awaitClose { - meta.removeListener(this) - } - } - } else emptyFlow() - - - override fun invalidate(propertyName: Name) { - // Do nothing + plot.meta[name] = value + if (notify) invalidate(name) } + override val descriptor: MetaDescriptor get() = plot.descriptor } - override val descriptor: MetaDescriptor? = null // TODO add descriptor for Plot + override val descriptor: MetaDescriptor = Plot.descriptor } public fun Plot.asVision(): VisionOfPlotly = VisionOfPlotly(this) diff --git a/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt b/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt index 7634e73d..2b2d4328 100644 --- a/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt +++ b/visionforge-plotly/src/commonTest/kotlin/space/kscience/visionforge/plotly/VisionOfPlotlyTest.kt @@ -1,22 +1,110 @@ package space.kscience.visionforge.plotly +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.meta.Value import space.kscience.plotly.Plotly -import space.kscience.plotly.scatter +import space.kscience.plotly.layout +import space.kscience.plotly.models.* +import space.kscience.visionforge.visionManager import kotlin.test.Test -import kotlin.test.assertTrue +import kotlin.test.assertEquals class VisionOfPlotlyTest { @Test - fun conversion(){ + fun conversion() { + val trace1 = Violin { + text("sample length: 32") + marker { + line { + width = 2 + color("#bebada") + } + symbol = Symbol.valueOf("line-ns") + } + orientation = Orientation.h + hoveron = ViolinHoveron.`points+kde` + meanline { + visible = true + } + legendgroup = "F" + scalegroup = "F" + points = ViolinPoints.all + pointpos = 1.2 + jitter = 0 + box { + visible = true + } + scalemode = ViolinScaleMode.count + showlegend = false + side = ViolinSide.positive + y0 = Value.of(0) + line { + color("#bebada") + } + name = "F" + + x(10.07, 34.83, 10.65, 12.43, 24.08, 13.42, 12.48, 29.8, 14.52, 11.38, + 20.27, 11.17, 12.26, 18.26, 8.51, 10.33, 14.15, 13.16, 17.47, 27.05, 16.43, + 8.35, 18.64, 11.87, 19.81, 43.11, 13.0, 12.74, 13.0, 16.4, 16.47, 18.78) + } + + val trace2 = Violin { + text("sample length: 30") + marker { + line { + width = 2 + color("#8dd3c7") + } + symbol = Symbol.valueOf("line-ns") + } + orientation = Orientation.h + hoveron = ViolinHoveron.`points+kde` + meanline { + visible = true + } + legendgroup = "M" + scalegroup = "M" + points = ViolinPoints.all + pointpos = -1.2 + jitter = 0 + box { + visible = true + } + scalemode = ViolinScaleMode.count + showlegend = false + side = ViolinSide.negative + y0 = Value.of(0) + + line { + color("#8dd3c7") + } + name = "M" + + x(27.2, 22.76, 17.29, 19.44, 16.66, 32.68, 15.98, 13.03, 18.28, 24.71, + 21.16, 11.69, 14.26, 15.95, 8.52, 22.82, 19.08, 16.0, 34.3, 41.19, 9.78, + 7.51, 28.44, 15.48, 16.58, 7.56, 10.34, 13.51, 18.71, 20.53) + } + val plot = Plotly.plot { - scatter { - x(1,2,3) - y(1,2,3) + traces(trace1, trace2) + layout { + width = 800 + height = 800 + title = "Advanced Violin Plot" } } val vision = VisionOfPlotly(plot) -// println(vision.plot.toJsonString()) -// println(vision.plot.data.toJsonString()) - assertTrue { vision.plot.data.first().x.doubles.size == 3} + val context = Context { + plugin(PlotlyPlugin) + } + val serialized = context.visionManager.encodeToString(vision) + + val deserialized: VisionOfPlotly = context.visionManager.decodeFromString(serialized) as VisionOfPlotly + + println(deserialized.plot.meta) + + assertEquals(62, deserialized.plot.data.sumOf { it.x.doubles.size}) + + assertEquals("Advanced Violin Plot", deserialized.plot.layout.title) } } \ No newline at end of file diff --git a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt index d7e5aaf6..167cf3e1 100644 --- a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt +++ b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt @@ -10,10 +10,10 @@ import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.plotly.PlotlyConfig import space.kscience.plotly.plot -import space.kscience.visionforge.ElementVisionRenderer -import space.kscience.visionforge.JsVisionClient import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionPlugin +import space.kscience.visionforge.html.ElementVisionRenderer +import space.kscience.visionforge.html.JsVisionClient public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: JsVisionClient by require(JsVisionClient) @@ -33,6 +33,8 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { element.plot(config, plot) } + override fun toString(): String = "Plotly" + override fun content(target: String): Map = when (target) { ElementVisionRenderer.TYPE -> mapOf("plotly".asName() to this) else -> super.content(target) diff --git a/visionforge-server/README.md b/visionforge-server/README.md index 0ac4c198..b7fa4411 100644 --- a/visionforge-server/README.md +++ b/visionforge-server/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-server:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-server:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-server:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-server:0.2.0") + implementation("space.kscience:visionforge-server:0.4.1") } ``` diff --git a/visionforge-server/api/visionforge-server.api b/visionforge-server/api/visionforge-server.api index 3446765b..5d52283f 100644 --- a/visionforge-server/api/visionforge-server.api +++ b/visionforge-server/api/visionforge-server.api @@ -1,36 +1,48 @@ -public final class space/kscience/visionforge/server/VisionServer : space/kscience/dataforge/meta/Configurable { - public static final field Companion Lspace/kscience/visionforge/server/VisionServer$Companion; +public final class space/kscience/visionforge/server/ApplicationExtensionsKt { + public static final fun EngineConnectorConfig (Ljava/lang/String;I)Lio/ktor/server/engine/EngineConnectorConfig; + public static final fun close (Lio/ktor/server/engine/ApplicationEngine;)V + public static final fun openInBrowser (Lio/ktor/server/engine/ApplicationEngine;)V + public static final fun require (Lio/ktor/util/pipeline/Pipeline;Lio/ktor/server/application/Plugin;)Ljava/lang/Object; +} + +public final class space/kscience/visionforge/server/VisionRoute : space/kscience/dataforge/context/ContextAware, space/kscience/dataforge/meta/Configurable { + public static final field Companion Lspace/kscience/visionforge/server/VisionRoute$Companion; public static final field DEFAULT_PAGE Ljava/lang/String; public static final field DEFAULT_PORT I - public final fun getApplication ()Lio/ktor/application/Application; - public final fun getCacheFragments ()Z - public final fun getDataEmbed ()Z - public final fun getDataFetch ()Z - public final fun getDataUpdate ()Z + public fun (Ljava/lang/String;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/dataforge/meta/ObservableMutableMeta;)V + public synthetic fun (Ljava/lang/String;Lspace/kscience/visionforge/VisionManager;Lspace/kscience/dataforge/meta/ObservableMutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun getContext ()Lspace/kscience/dataforge/context/Context; + public final fun getDataMode ()Lspace/kscience/visionforge/server/VisionRoute$Mode; public synthetic fun getMeta ()Lspace/kscience/dataforge/meta/MutableMeta; public fun getMeta ()Lspace/kscience/dataforge/meta/ObservableMutableMeta; + public final fun getRoute ()Ljava/lang/String; public final fun getUpdateInterval ()J - public final fun page (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V - public static synthetic fun page$default (Lspace/kscience/visionforge/server/VisionServer;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public final fun serveVisions (Ljava/lang/String;Ljava/util/Map;)V - public final fun serveVisionsFromFragment (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String; - public final fun setCacheFragments (Z)V - public final fun setDataEmbed (Z)V - public final fun setDataFetch (Z)V - public final fun setDataUpdate (Z)V + public final fun getVisionManager ()Lspace/kscience/visionforge/VisionManager; + public final fun setDataMode (Lspace/kscience/visionforge/server/VisionRoute$Mode;)V public final fun setUpdateInterval (J)V } -public final class space/kscience/visionforge/server/VisionServer$Companion { +public final class space/kscience/visionforge/server/VisionRoute$Companion { public final fun getUPDATE_INTERVAL_KEY ()Lspace/kscience/dataforge/names/Name; } -public final class space/kscience/visionforge/server/VisionServerKt { - public static final fun close (Lio/ktor/server/engine/ApplicationEngine;)V - public static final fun openInBrowser (Lio/ktor/server/engine/ApplicationEngine;)V - public static final fun serve (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;ILkotlin/jvm/functions/Function1;)Lio/ktor/server/engine/ApplicationEngine; - public static synthetic fun serve$default (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/ktor/server/engine/ApplicationEngine; - public static final fun visionServer (Lio/ktor/application/Application;Lspace/kscience/visionforge/VisionManager;Lio/ktor/http/Url;Ljava/lang/String;)Lspace/kscience/visionforge/server/VisionServer; - public static synthetic fun visionServer$default (Lio/ktor/application/Application;Lspace/kscience/visionforge/VisionManager;Lio/ktor/http/Url;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/server/VisionServer; +public final class space/kscience/visionforge/server/VisionRoute$Mode : java/lang/Enum { + public static final field EMBED Lspace/kscience/visionforge/server/VisionRoute$Mode; + public static final field FETCH Lspace/kscience/visionforge/server/VisionRoute$Mode; + public static final field UPDATE Lspace/kscience/visionforge/server/VisionRoute$Mode; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/server/VisionRoute$Mode; + public static fun values ()[Lspace/kscience/visionforge/server/VisionRoute$Mode; +} + +public final class space/kscience/visionforge/server/VisionServerKt { + public static final fun serveVisionData (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/server/VisionRoute;Ljava/util/Map;)V + public static final fun serveVisionData (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/server/VisionRoute;Lkotlin/jvm/functions/Function1;)V + public static final fun visionPage (Lio/ktor/server/application/Application;Ljava/lang/String;Lspace/kscience/visionforge/server/VisionRoute;Ljava/util/Collection;Lio/ktor/server/engine/EngineConnectorConfig;Lspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static final fun visionPage (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/VisionManager;[Lspace/kscience/visionforge/html/HtmlFragment;Ljava/lang/String;Lio/ktor/server/engine/EngineConnectorConfig;Lkotlin/jvm/functions/Function1;Lspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static final fun visionPage (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/html/VisionPage;Ljava/lang/String;Lio/ktor/server/engine/EngineConnectorConfig;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun visionPage$default (Lio/ktor/server/application/Application;Ljava/lang/String;Lspace/kscience/visionforge/server/VisionRoute;Ljava/util/Collection;Lio/ktor/server/engine/EngineConnectorConfig;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V + public static synthetic fun visionPage$default (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/VisionManager;[Lspace/kscience/visionforge/html/HtmlFragment;Ljava/lang/String;Lio/ktor/server/engine/EngineConnectorConfig;Lkotlin/jvm/functions/Function1;Lspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V + public static synthetic fun visionPage$default (Lio/ktor/server/application/Application;Lspace/kscience/visionforge/html/VisionPage;Ljava/lang/String;Lio/ktor/server/engine/EngineConnectorConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V } diff --git a/visionforge-server/build.gradle.kts b/visionforge-server/build.gradle.kts index 59034dd1..650b942a 100644 --- a/visionforge-server/build.gradle.kts +++ b/visionforge-server/build.gradle.kts @@ -1,10 +1,11 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } kscience{ + jvm() useKtor() - dependencies { + jvmMain { api(projects.visionforgeCore) api("io.ktor:ktor-server-host-common") api("io.ktor:ktor-server-html-builder") diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt b/visionforge-server/src/jvmMain/kotlin/space/kscience/visionforge/server/VisionServer.kt similarity index 78% rename from visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt rename to visionforge-server/src/jvmMain/kotlin/space/kscience/visionforge/server/VisionServer.kt index 4c5e093a..bb14b39a 100644 --- a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/VisionServer.kt +++ b/visionforge-server/src/jvmMain/kotlin/space/kscience/visionforge/server/VisionServer.kt @@ -1,30 +1,50 @@ package space.kscience.visionforge.server -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.engine.* -import io.ktor.server.html.* -import io.ktor.server.http.content.* -import io.ktor.server.plugins.* -import io.ktor.server.plugins.cors.routing.* -import io.ktor.server.request.* -import io.ktor.server.response.* +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.http.URLProtocol +import io.ktor.http.path +import io.ktor.server.application.Application +import io.ktor.server.application.call +import io.ktor.server.application.install +import io.ktor.server.application.log +import io.ktor.server.engine.EngineConnectorConfig +import io.ktor.server.html.respondHtml +import io.ktor.server.plugins.cors.routing.CORS +import io.ktor.server.request.header +import io.ktor.server.request.host +import io.ktor.server.request.port +import io.ktor.server.response.header +import io.ktor.server.response.respond +import io.ktor.server.response.respondText import io.ktor.server.routing.* -import io.ktor.server.util.* -import io.ktor.server.websocket.* -import io.ktor.util.pipeline.* -import io.ktor.websocket.* +import io.ktor.server.util.getOrFail +import io.ktor.server.util.url +import io.ktor.server.websocket.WebSockets +import io.ktor.server.websocket.application +import io.ktor.server.websocket.webSocket +import io.ktor.websocket.Frame import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import kotlinx.html.* +import kotlinx.html.body +import kotlinx.html.head +import kotlinx.html.header +import kotlinx.html.meta +import kotlinx.serialization.encodeToString import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.ContextAware -import space.kscience.dataforge.meta.* +import space.kscience.dataforge.meta.Configurable +import space.kscience.dataforge.meta.ObservableMutableMeta +import space.kscience.dataforge.meta.enum +import space.kscience.dataforge.meta.long import space.kscience.dataforge.names.Name -import space.kscience.visionforge.* +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionEvent +import space.kscience.visionforge.VisionManager +import space.kscience.visionforge.flowChanges import space.kscience.visionforge.html.* import kotlin.time.Duration.Companion.milliseconds @@ -32,7 +52,7 @@ import kotlin.time.Duration.Companion.milliseconds public class VisionRoute( public val route: String, public val visionManager: VisionManager, - override val meta: ObservableMutableMeta = MutableMeta(), + override val meta: ObservableMutableMeta = ObservableMutableMeta(), ) : Configurable, ContextAware { public enum class Mode { @@ -71,7 +91,6 @@ public class VisionRoute( /** * Serve visions in a given [route] without providing a page template. - * [visions] could be changed during the service. * * @return a [Flow] of backward events, including vision change events */ @@ -97,9 +116,7 @@ public fun Application.serveVisionData( for (frame in incoming) { val data = frame.data.decodeToString() application.log.debug("Received event for $name: \n$data") - val event = configuration.visionManager.jsonFormat.decodeFromString( - VisionEvent.serializer(), data - ) + val event: VisionEvent = configuration.visionManager.jsonFormat.decodeFromString(data) vision.receiveEvent(event) } @@ -108,10 +125,7 @@ public fun Application.serveVisionData( try { withContext(configuration.context.coroutineContext) { vision.flowChanges(configuration.updateInterval.milliseconds).onEach { event -> - val json = configuration.visionManager.jsonFormat.encodeToString( - VisionEvent.serializer(), - event - ) + val json = configuration.visionManager.jsonFormat.encodeToString(event) application.log.debug("Sending update for $name: \n$json") outgoing.send(Frame.Text(json)) }.collect() @@ -141,8 +155,8 @@ public fun Application.serveVisionData( public fun Application.serveVisionData( configuration: VisionRoute, - data: Map, -): Unit = serveVisionData(configuration) { data[it] } + data: Map, +): Unit = serveVisionData(configuration) { data[it]?.vision } /** * Serve a page, potentially containing any number of visions at a given [route] with given [header]. @@ -155,13 +169,13 @@ public fun Application.visionPage( headers: Collection, connector: EngineConnectorConfig? = null, visionFragment: HtmlVisionFragment, -){ +) { require(WebSockets) - val collector: MutableMap = mutableMapOf() + val cache: MutableMap = mutableMapOf() //serve data - serveVisionData(configuration, collector) + serveVisionData(configuration, cache) //filled pages routing { @@ -197,7 +211,7 @@ public fun Application.visionPage( path(route, "ws") } } else null, - onVisionRendered = { name, vision -> collector[name] = vision }, + displayCache = cache, fragment = visionFragment ) } diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/server/applicationExtensions.kt b/visionforge-server/src/jvmMain/kotlin/space/kscience/visionforge/server/applicationExtensions.kt similarity index 100% rename from visionforge-server/src/main/kotlin/space/kscience/visionforge/server/applicationExtensions.kt rename to visionforge-server/src/jvmMain/kotlin/space/kscience/visionforge/server/applicationExtensions.kt diff --git a/visionforge-solid/README.md b/visionforge-solid/README.md index cbf4073b..e0a6e29b 100644 --- a/visionforge-solid/README.md +++ b/visionforge-solid/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-solid:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-solid:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-solid:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-solid:0.2.0") + implementation("space.kscience:visionforge-solid:0.4.1") } ``` diff --git a/visionforge-solid/api/visionforge-solid.api b/visionforge-solid/api/visionforge-solid.api index c763e3c8..b8fc8211 100644 --- a/visionforge-solid/api/visionforge-solid.api +++ b/visionforge-solid/api/visionforge-solid.api @@ -1,24 +1,63 @@ +public final class space/kscience/visionforge/solid/AmbientLightSource : space/kscience/visionforge/solid/LightSource { + public static final field Companion Lspace/kscience/visionforge/solid/AmbientLightSource$Companion; + public fun ()V +} + +public final class space/kscience/visionforge/solid/AmbientLightSource$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/AmbientLightSource$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/AmbientLightSource; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/AmbientLightSource;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/AmbientLightSource$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/AxesSolid : space/kscience/visionforge/solid/MiscSolid { + public static final field AXES_NAME Ljava/lang/String; + public static final field Companion Lspace/kscience/visionforge/solid/AxesSolid$Companion; + public fun (D)V + public final fun getSize ()D +} + +public final class space/kscience/visionforge/solid/AxesSolid$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/AxesSolid$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/AxesSolid; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/AxesSolid;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/AxesSolid$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class space/kscience/visionforge/solid/Box : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/Hexagon { public static final field Companion Lspace/kscience/visionforge/solid/Box$Companion; public fun (FFF)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; + public fun getNode1 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode2 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode3 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode4 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode5 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode6 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode7 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode8 ()Lspace/kscience/visionforge/solid/Float32Vector3D; public final fun getXSize ()F public final fun getYSize ()F public final fun getZSize ()F - public static final fun write$Self (Lspace/kscience/visionforge/solid/Box;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Box$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Box$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Box; @@ -32,16 +71,18 @@ public final class space/kscience/visionforge/solid/Box$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/solid/ColorAccessor : space/kscience/dataforge/values/MutableValueProvider { - public fun (Lspace/kscience/dataforge/values/MutableValueProvider;Lspace/kscience/dataforge/names/Name;)V - public final fun getValue ()Lspace/kscience/dataforge/values/Value; - public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/values/Value; - public fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/values/Value;)V - public final fun setValue (Lspace/kscience/dataforge/values/Value;)V +public final class space/kscience/visionforge/solid/ColorAccessor : space/kscience/dataforge/meta/MutableValueProvider { + public fun (Lspace/kscience/dataforge/meta/MutableValueProvider;Lspace/kscience/dataforge/names/Name;)V + public final fun getValue ()Lspace/kscience/dataforge/meta/Value; + public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Value; + public final fun setValue (Lspace/kscience/dataforge/meta/Value;)V + public fun setValue (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/Value;)V } public final class space/kscience/visionforge/solid/ColorAccessorKt { public static final fun clear (Lspace/kscience/visionforge/solid/ColorAccessor;)V + public static final fun colorProperty (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;)Lkotlin/properties/ReadOnlyProperty; + public static synthetic fun colorProperty$default (Lspace/kscience/visionforge/Vision;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; public static final fun getString (Lspace/kscience/visionforge/solid/ColorAccessor;)Ljava/lang/String; public static final fun invoke (Lspace/kscience/visionforge/solid/ColorAccessor;I)V public static final fun invoke (Lspace/kscience/visionforge/solid/ColorAccessor;Ljava/lang/String;)V @@ -49,19 +90,16 @@ public final class space/kscience/visionforge/solid/ColorAccessorKt { public static final fun setString (Lspace/kscience/visionforge/solid/ColorAccessor;Ljava/lang/String;)V } -public final class space/kscience/visionforge/solid/Composite : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { +public final class space/kscience/visionforge/solid/Composite : space/kscience/visionforge/solid/SolidBase { public static final field Companion Lspace/kscience/visionforge/solid/Composite$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/visionforge/solid/CompositeType;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Solid;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Lspace/kscience/visionforge/solid/CompositeType;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Solid;)V public final fun getCompositeType ()Lspace/kscience/visionforge/solid/CompositeType; public final fun getFirst ()Lspace/kscience/visionforge/solid/Solid; public final fun getSecond ()Lspace/kscience/visionforge/solid/Solid; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Composite;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Composite$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Composite$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Composite; @@ -76,16 +114,16 @@ public final class space/kscience/visionforge/solid/Composite$Companion { } public final class space/kscience/visionforge/solid/CompositeKt { - public static final fun composite (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun composite$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; - public static final fun intersect (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun intersect$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; + public static final fun composite (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; + public static synthetic fun composite$default (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; + public static final fun intersect (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; + public static synthetic fun intersect$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; public static final fun smartComposite (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Solid; public static synthetic fun smartComposite$default (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/visionforge/solid/CompositeType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Solid; - public static final fun subtract (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun subtract$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; - public static final fun union (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; - public static synthetic fun union$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; + public static final fun subtract (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; + public static synthetic fun subtract$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; + public static final fun union (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Composite; + public static synthetic fun union$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Composite; } public final class space/kscience/visionforge/solid/CompositeType : java/lang/Enum { @@ -93,6 +131,7 @@ public final class space/kscience/visionforge/solid/CompositeType : java/lang/En public static final field INTERSECT Lspace/kscience/visionforge/solid/CompositeType; public static final field SUBTRACT Lspace/kscience/visionforge/solid/CompositeType; public static final field UNION Lspace/kscience/visionforge/solid/CompositeType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/solid/CompositeType; public static fun values ()[Lspace/kscience/visionforge/solid/CompositeType; } @@ -101,19 +140,16 @@ public final class space/kscience/visionforge/solid/ConeSegment : space/kscience public static final field Companion Lspace/kscience/visionforge/solid/ConeSegment$Companion; public fun (FFFFF)V public synthetic fun (FFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getAngle ()F public final fun getBottomRadius ()F public final fun getHeight ()F - public final fun getStartAngle ()F + public final fun getPhi ()F + public final fun getPhiStart ()F public final fun getTopRadius ()F public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/ConeSegment;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/ConeSegment$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/ConeSegment$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/ConeSegment; @@ -128,31 +164,28 @@ public final class space/kscience/visionforge/solid/ConeSegment$Companion { } public final class space/kscience/visionforge/solid/ConeSegmentKt { - public static final fun cone (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; - public static synthetic fun cone$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; - public static final fun cylinder (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; - public static synthetic fun cylinder$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; + public static final fun cone (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; + public static synthetic fun cone$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; + public static final fun cylinder (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSegment; + public static synthetic fun cylinder$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSegment; } -public final class space/kscience/visionforge/solid/ConeSurface : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { +public final class space/kscience/visionforge/solid/ConeSurface : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { public static final field Companion Lspace/kscience/visionforge/solid/ConeSurface$Companion; public fun (FFFFFFF)V public synthetic fun (FFFFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun getAngle ()F public final fun getBottomInnerRadius ()F public final fun getBottomRadius ()F public final fun getHeight ()F - public final fun getStartAngle ()F + public final fun getPhi ()F + public final fun getPhiStart ()F public final fun getTopInnerRadius ()F public final fun getTopRadius ()F public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/ConeSurface;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/ConeSurface$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/ConeSurface$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/ConeSurface; @@ -167,23 +200,20 @@ public final class space/kscience/visionforge/solid/ConeSurface$Companion { } public final class space/kscience/visionforge/solid/ConeSurfaceKt { - public static final fun coneSurface (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; - public static synthetic fun coneSurface$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; - public static final fun tube (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; - public static synthetic fun tube$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; + public static final fun coneSurface (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; + public static synthetic fun coneSurface$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; + public static final fun tube (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/ConeSurface; + public static synthetic fun tube$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/ConeSurface; } -public final class space/kscience/visionforge/solid/Convex : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { +public final class space/kscience/visionforge/solid/Convex : space/kscience/visionforge/solid/SolidBase { public static final field Companion Lspace/kscience/visionforge/solid/Convex$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/util/List;)V public final fun getPoints ()Ljava/util/List; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Convex;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Convex$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Convex$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Convex; @@ -204,37 +234,55 @@ public final class space/kscience/visionforge/solid/ConvexBuilder { } public final class space/kscience/visionforge/solid/ConvexKt { - public static final fun convex (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Convex; - public static synthetic fun convex$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Convex; + public static final fun convex (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Convex; + public static synthetic fun convex$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Convex; } -public final class space/kscience/visionforge/solid/ExtrudeBuilder : space/kscience/visionforge/SimpleVisionPropertyContainer { - public fun ()V - public fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/ObservableMutableMeta;)V - public synthetic fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/ObservableMutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getLayers ()Ljava/util/List; - public final fun getShape ()Ljava/util/List; - public final fun layer (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)V - public static synthetic fun layer$default (Lspace/kscience/visionforge/solid/ExtrudeBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Object;)V - public final fun setLayers (Ljava/util/List;)V - public final fun setShape (Ljava/util/List;)V - public final fun shape (Lkotlin/jvm/functions/Function1;)V +public final class space/kscience/visionforge/solid/CutTube : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { + public static final field Companion Lspace/kscience/visionforge/solid/CutTube$Companion; + public fun (FFFFFLspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public synthetic fun (FFFFFLspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getHeight ()F + public final fun getInnerRadius ()F + public final fun getNBottom ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun getNTop ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun getOuterRadius ()F + public final fun getPhi ()F + public final fun getPhiStart ()F + public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V } -public final class space/kscience/visionforge/solid/Extruded : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { +public final class space/kscience/visionforge/solid/CutTube$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/CutTube$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/CutTube; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/CutTube;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/CutTube$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/CutTubeKt { + public static final fun cutTube (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/CutTube; + public static synthetic fun cutTube$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/CutTube; +} + +public final class space/kscience/visionforge/solid/Extruded : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { public static final field Companion Lspace/kscience/visionforge/solid/Extruded$Companion; public static final field TYPE Ljava/lang/String; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/util/List;Ljava/util/List;)V public final fun getLayers ()Ljava/util/List; public final fun getShape ()Ljava/util/List; public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Extruded;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Extruded$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Extruded$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Extruded; @@ -244,34 +292,172 @@ public final class space/kscience/visionforge/solid/Extruded$$serializer : kotli public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; } +public final class space/kscience/visionforge/solid/Extruded$Builder { + public fun ()V + public fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/MutableMeta;)V + public synthetic fun (Ljava/util/List;Ljava/util/List;Lspace/kscience/dataforge/meta/MutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getLayers ()Ljava/util/List; + public final fun getProperties ()Lspace/kscience/dataforge/meta/MutableMeta; + public final fun getShape ()Ljava/util/List; + public final fun layer (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)V + public static synthetic fun layer$default (Lspace/kscience/visionforge/solid/Extruded$Builder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Object;)V + public final fun setLayers (Ljava/util/List;)V + public final fun setShape (Ljava/util/List;)V + public final fun shape (Lkotlin/jvm/functions/Function1;)V +} + public final class space/kscience/visionforge/solid/Extruded$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class space/kscience/visionforge/solid/Extruded$Layer { + public static final field Companion Lspace/kscience/visionforge/solid/Extruded$Layer$Companion; + public fun (FFFF)V + public final fun component1 ()F + public final fun component2 ()F + public final fun component3 ()F + public final fun component4 ()F + public final fun copy (FFFF)Lspace/kscience/visionforge/solid/Extruded$Layer; + public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Extruded$Layer;FFFFILjava/lang/Object;)Lspace/kscience/visionforge/solid/Extruded$Layer; + public fun equals (Ljava/lang/Object;)Z + public final fun getScale ()F + public final fun getX ()F + public final fun getY ()F + public final fun getZ ()F + public fun hashCode ()I + public final fun setScale (F)V + public final fun setX (F)V + public final fun setY (F)V + public final fun setZ (F)V + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/solid/Extruded$Layer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Extruded$Layer$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Extruded$Layer; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Extruded$Layer;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/Extruded$Layer$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class space/kscience/visionforge/solid/ExtrudedKt { - public static final fun extruded (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Extruded; - public static synthetic fun extruded$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Extruded; - public static final fun polygon (Lspace/kscience/visionforge/solid/Shape2DBuilder;ILjava/lang/Number;)V + public static final fun extruded (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Extruded; + public static synthetic fun extruded$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Extruded; +} + +public final class space/kscience/visionforge/solid/Float32Euclidean2DSpace : space/kscience/kmath/geometry/GeometrySpace, space/kscience/kmath/operations/ScaleOperations { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Float32Euclidean2DSpace; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lspace/kscience/visionforge/solid/Float32Vector2D;Lspace/kscience/visionforge/solid/Float32Vector2D;)Lspace/kscience/visionforge/solid/Float32Vector2D; + public synthetic fun distanceTo (Lspace/kscience/kmath/geometry/Vector;Lspace/kscience/kmath/geometry/Vector;)D + public fun distanceTo (Lspace/kscience/visionforge/solid/Float32Vector2D;Lspace/kscience/visionforge/solid/Float32Vector2D;)D + public synthetic fun dot (Lspace/kscience/kmath/geometry/Vector;Lspace/kscience/kmath/geometry/Vector;)D + public fun dot (Lspace/kscience/visionforge/solid/Float32Vector2D;Lspace/kscience/visionforge/solid/Float32Vector2D;)D + public final fun getXAxis ()Lspace/kscience/visionforge/solid/Float32Vector2D; + public final fun getYAxis ()Lspace/kscience/visionforge/solid/Float32Vector2D; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lspace/kscience/visionforge/solid/Float32Vector2D; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public final fun norm (Lspace/kscience/visionforge/solid/Float32Vector2D;)D + public fun norm (Lspace/kscience/visionforge/solid/Float32Vector2D;)Ljava/lang/Double; + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale (Lspace/kscience/visionforge/solid/Float32Vector2D;D)Lspace/kscience/visionforge/solid/Float32Vector2D; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lspace/kscience/visionforge/solid/Float32Vector2D;)Lspace/kscience/visionforge/solid/Float32Vector2D; + public final fun vector (FF)Lspace/kscience/visionforge/solid/Float32Vector2D; + public final fun vector (Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Float32Vector2D; +} + +public final class space/kscience/visionforge/solid/Float32Euclidean2DSpace$VectorSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Float32Euclidean2DSpace$VectorSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Float32Vector2D; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Float32Vector2D;)V +} + +public final class space/kscience/visionforge/solid/Float32Euclidean2DSpaceKt { + public static final fun Float32Vector2D (Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Float32Vector2D; +} + +public final class space/kscience/visionforge/solid/Float32Euclidean3DSpace : space/kscience/kmath/geometry/GeometrySpace, space/kscience/kmath/operations/ScaleOperations { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Float32Euclidean3DSpace; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun cross (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public synthetic fun distanceTo (Lspace/kscience/kmath/geometry/Vector;Lspace/kscience/kmath/geometry/Vector;)D + public fun distanceTo (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)D + public synthetic fun dot (Lspace/kscience/kmath/geometry/Vector;Lspace/kscience/kmath/geometry/Vector;)D + public fun dot (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)D + public final fun getXAxis ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun getYAxis ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun getZAxis ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public final fun norm (Lspace/kscience/visionforge/solid/Float32Vector3D;)D + public fun norm (Lspace/kscience/visionforge/solid/Float32Vector3D;)Ljava/lang/Double; + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale (Lspace/kscience/visionforge/solid/Float32Vector3D;D)Lspace/kscience/visionforge/solid/Float32Vector3D; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lspace/kscience/visionforge/solid/Float32Vector3D;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun vector (FFF)Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun vector (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun vectorProduct (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)Lspace/kscience/visionforge/solid/Float32Vector3D; +} + +public final class space/kscience/visionforge/solid/Float32Euclidean3DSpace$VectorSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Float32Euclidean3DSpace$VectorSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Float32Vector3D;)V +} + +public final class space/kscience/visionforge/solid/Float32Euclidean3DSpaceKt { + public static final fun Float32Vector3D (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Float32Vector3D; +} + +public abstract interface class space/kscience/visionforge/solid/Float32Vector2D : space/kscience/kmath/geometry/Vector2D { + public static final field Companion Lspace/kscience/visionforge/solid/Float32Vector2D$Companion; +} + +public final class space/kscience/visionforge/solid/Float32Vector2D$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public abstract interface class space/kscience/visionforge/solid/Float32Vector3D : space/kscience/kmath/geometry/Vector3D { + public static final field Companion Lspace/kscience/visionforge/solid/Float32Vector3D$Companion; +} + +public final class space/kscience/visionforge/solid/Float32Vector3D$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/solid/GenericHexagon : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/Hexagon { public static final field Companion Lspace/kscience/visionforge/solid/GenericHexagon$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public fun (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)V - public fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; - public static final fun write$Self (Lspace/kscience/visionforge/solid/GenericHexagon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public fun getNode1 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode2 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode3 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode4 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode5 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode6 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode7 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public fun getNode8 ()Lspace/kscience/visionforge/solid/Float32Vector3D; } public final class space/kscience/visionforge/solid/GenericHexagon$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/GenericHexagon$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/GenericHexagon; @@ -287,28 +473,21 @@ public final class space/kscience/visionforge/solid/GenericHexagon$Companion { public abstract interface class space/kscience/visionforge/solid/GeometryBuilder { public abstract fun build ()Ljava/lang/Object; - public abstract fun face (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;)V - public static synthetic fun face$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V + public abstract fun face (Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/dataforge/meta/Meta;)V + public static synthetic fun face$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V } public final class space/kscience/visionforge/solid/GeometryBuilderKt { - public static final fun cap (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Point3D;)V - public static synthetic fun cap$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Point3D;ILjava/lang/Object;)V - public static final fun face4 (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;)V - public static synthetic fun face4$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V + public static final fun cap (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public static synthetic fun cap$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Ljava/util/List;Lspace/kscience/visionforge/solid/Float32Vector3D;ILjava/lang/Object;)V + public static final fun face4 (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/dataforge/meta/Meta;)V + public static synthetic fun face4$default (Lspace/kscience/visionforge/solid/GeometryBuilder;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/dataforge/meta/Meta;ILjava/lang/Object;)V } public final class space/kscience/visionforge/solid/GeometryKt { public static final field PI2 F - public static final fun Point2D (Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Point2D; - public static final fun Point3D (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun cross (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun minus (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun normalizeInPlace (Lspace/kscience/visionforge/solid/MutablePoint3D;)V - public static final fun plus (Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun toMeta (Lspace/kscience/visionforge/solid/Point2D;)Lspace/kscience/dataforge/meta/Meta; - public static final fun toMeta (Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/dataforge/meta/Meta; - public static final fun unaryMinus (Lspace/kscience/visionforge/solid/Point3D;)Lspace/kscience/visionforge/solid/Point3D; + public static final fun toMeta (Lspace/kscience/visionforge/solid/Float32Vector2D;)Lspace/kscience/dataforge/meta/Meta; + public static final fun toMeta (Lspace/kscience/visionforge/solid/Float32Vector3D;)Lspace/kscience/dataforge/meta/Meta; } public abstract interface class space/kscience/visionforge/solid/GeometrySolid : space/kscience/visionforge/solid/Solid { @@ -316,132 +495,95 @@ public abstract interface class space/kscience/visionforge/solid/GeometrySolid : } public abstract interface class space/kscience/visionforge/solid/Hexagon : space/kscience/visionforge/solid/GeometrySolid { - public abstract fun getNode1 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode2 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode3 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode4 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode5 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode6 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode7 ()Lspace/kscience/visionforge/solid/Point3D; - public abstract fun getNode8 ()Lspace/kscience/visionforge/solid/Point3D; + public abstract fun getNode1 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode2 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode3 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode4 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode5 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode6 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode7 ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public abstract fun getNode8 ()Lspace/kscience/visionforge/solid/Float32Vector3D; public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V } public final class space/kscience/visionforge/solid/HexagonKt { - public static final fun box (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Box; - public static synthetic fun box$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Box; - public static final fun hexagon (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Hexagon; - public static synthetic fun hexagon$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Hexagon; + public static final fun box (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Box; + public static synthetic fun box$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Box; + public static final fun hexagon (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Hexagon; + public static synthetic fun hexagon$default (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Hexagon; } -public final class space/kscience/visionforge/solid/Layer { - public static final field Companion Lspace/kscience/visionforge/solid/Layer$Companion; - public fun (FFFF)V - public synthetic fun (IFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun component1 ()F - public final fun component2 ()F - public final fun component3 ()F - public final fun component4 ()F - public final fun copy (FFFF)Lspace/kscience/visionforge/solid/Layer; - public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Layer;FFFFILjava/lang/Object;)Lspace/kscience/visionforge/solid/Layer; - public fun equals (Ljava/lang/Object;)Z - public final fun getScale ()F - public final fun getX ()F - public final fun getY ()F - public final fun getZ ()F - public fun hashCode ()I - public final fun setScale (F)V - public final fun setX (F)V - public final fun setY (F)V - public final fun setZ (F)V - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Layer;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +public abstract class space/kscience/visionforge/solid/LightSource : space/kscience/visionforge/solid/MiscSolid { + public static final field Companion Lspace/kscience/visionforge/solid/LightSource$Companion; + public fun ()V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public final fun getColor ()Lspace/kscience/visionforge/solid/ColorAccessor; + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun getIntensity ()Ljava/lang/Number; + public final fun setIntensity (Ljava/lang/Number;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/solid/LightSource;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } -public final class space/kscience/visionforge/solid/Layer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Layer$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Layer; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Layer;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Layer$Companion { +public final class space/kscience/visionforge/solid/LightSource$Companion { + public final fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun getINTENSITY_KEY ()Lspace/kscience/dataforge/names/Name; public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public abstract interface class space/kscience/visionforge/solid/MutablePoint3D : space/kscience/visionforge/solid/Point3D { - public abstract fun getX ()F - public abstract fun getY ()F - public abstract fun getZ ()F - public abstract fun setX (F)V - public abstract fun setY (F)V - public abstract fun setZ (F)V +public final class space/kscience/visionforge/solid/LightSourceKt { + public static final fun ambientLight (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/AmbientLightSource; + public static synthetic fun ambientLight$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/AmbientLightSource; + public static final fun pointLight (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/PointLightSource; + public static synthetic fun pointLight$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/PointLightSource; } -public final class space/kscience/visionforge/solid/Point2D { - public static final field Companion Lspace/kscience/visionforge/solid/Point2D$Companion; - public fun (FF)V - public synthetic fun (IFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V - public final fun component1 ()F - public final fun component2 ()F - public final fun copy (FF)Lspace/kscience/visionforge/solid/Point2D; - public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Point2D;FFILjava/lang/Object;)Lspace/kscience/visionforge/solid/Point2D; - public fun equals (Ljava/lang/Object;)Z - public final fun getX ()F - public final fun getY ()F - public fun hashCode ()I - public final fun setX (F)V - public final fun setY (F)V - public fun toString ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/Point2D;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V +public abstract class space/kscience/visionforge/solid/MiscSolid : space/kscience/visionforge/solid/SolidBase { + public static final field Companion Lspace/kscience/visionforge/solid/MiscSolid$Companion; + public fun ()V + public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/solid/MiscSolid;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } -public final class space/kscience/visionforge/solid/Point2D$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/Point2D$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; - public fun childSerializers ()[Lkotlinx/serialization/KSerializer; - public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Point2D; - public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; - public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Point2D;)V - public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; -} - -public final class space/kscience/visionforge/solid/Point2D$Companion { +public final class space/kscience/visionforge/solid/MiscSolid$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public abstract interface class space/kscience/visionforge/solid/Point3D { - public static final field Companion Lspace/kscience/visionforge/solid/Point3D$Companion; - public abstract fun getX ()F - public abstract fun getY ()F - public abstract fun getZ ()F +public final class space/kscience/visionforge/solid/MiscSolidKt { + public static final fun axes (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/AxesSolid; + public static synthetic fun axes$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/AxesSolid; } -public final class space/kscience/visionforge/solid/Point3D$Companion { - public final fun getONE ()Lspace/kscience/visionforge/solid/Point3D; - public final fun getZERO ()Lspace/kscience/visionforge/solid/Point3D; +public final class space/kscience/visionforge/solid/PointLightSource : space/kscience/visionforge/solid/LightSource { + public static final field Companion Lspace/kscience/visionforge/solid/PointLightSource$Companion; + public fun ()V } -public final class space/kscience/visionforge/solid/PolyLine : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { +public final class space/kscience/visionforge/solid/PointLightSource$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/PointLightSource$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/PointLightSource; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/PointLightSource;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/PointLightSource$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/PolyLine : space/kscience/visionforge/solid/SolidBase { public static final field Companion Lspace/kscience/visionforge/solid/PolyLine$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V + public static final field DEFAULT_THICKNESS D public fun (Ljava/util/List;)V public final fun getPoints ()Ljava/util/List; public final fun getThickness ()Ljava/lang/Number; public final fun setThickness (Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/PolyLine;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/PolyLine$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/PolyLine$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/PolyLine; @@ -452,13 +594,12 @@ public final class space/kscience/visionforge/solid/PolyLine$$serializer : kotli } public final class space/kscience/visionforge/solid/PolyLine$Companion { - public final fun getTHICKNESS_KEY ()Lspace/kscience/dataforge/names/Name; public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/solid/PolyLineKt { - public static final fun polyline (Lspace/kscience/visionforge/VisionContainerBuilder;[Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/PolyLine; - public static synthetic fun polyline$default (Lspace/kscience/visionforge/VisionContainerBuilder;[Lspace/kscience/visionforge/solid/Point3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/PolyLine; + public static final fun polyline (Lspace/kscience/visionforge/MutableVisionContainer;[Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/PolyLine; + public static synthetic fun polyline$default (Lspace/kscience/visionforge/MutableVisionContainer;[Lspace/kscience/visionforge/solid/Float32Vector3D;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/PolyLine; } public abstract interface class space/kscience/visionforge/solid/PrototypeHolder { @@ -466,53 +607,17 @@ public abstract interface class space/kscience/visionforge/solid/PrototypeHolder public abstract fun prototypes (Lkotlin/jvm/functions/Function1;)V } -public final class space/kscience/visionforge/solid/Quaternion { - public static final synthetic fun box-impl ([D)Lspace/kscience/visionforge/solid/Quaternion; - public static fun constructor-impl ([D)[D - public fun equals (Ljava/lang/Object;)Z - public static fun equals-impl ([DLjava/lang/Object;)Z - public static final fun equals-impl0 ([D[D)Z - public final fun getValues ()[D - public fun hashCode ()I - public static fun hashCode-impl ([D)I - public fun toString ()Ljava/lang/String; - public static fun toString-impl ([D)Ljava/lang/String; - public final synthetic fun unbox-impl ()[D -} - -public final class space/kscience/visionforge/solid/QuaternionKt { - public static final fun component1-VMqeIco ([D)D - public static final fun component2-VMqeIco ([D)D - public static final fun component3-VMqeIco ([D)D - public static final fun component4-VMqeIco ([D)D -} - -public final class space/kscience/visionforge/solid/RotationOrder : java/lang/Enum { - public static final field XYZ Lspace/kscience/visionforge/solid/RotationOrder; - public static final field XZY Lspace/kscience/visionforge/solid/RotationOrder; - public static final field YXZ Lspace/kscience/visionforge/solid/RotationOrder; - public static final field YZX Lspace/kscience/visionforge/solid/RotationOrder; - public static final field ZXY Lspace/kscience/visionforge/solid/RotationOrder; - public static final field ZYX Lspace/kscience/visionforge/solid/RotationOrder; - public static fun valueOf (Ljava/lang/String;)Lspace/kscience/visionforge/solid/RotationOrder; - public static fun values ()[Lspace/kscience/visionforge/solid/RotationOrder; -} - public final class space/kscience/visionforge/solid/Shape2DBuilder { public static final field Companion Lspace/kscience/visionforge/solid/Shape2DBuilder$Companion; public fun ()V - public synthetic fun (ILjava/util/ArrayList;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/util/ArrayList;)V public synthetic fun (Ljava/util/ArrayList;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun build ()Ljava/util/List; public final fun point (Ljava/lang/Number;Ljava/lang/Number;)V - public final fun to (Ljava/lang/Number;Ljava/lang/Number;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Shape2DBuilder;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Shape2DBuilder$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Shape2DBuilder$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Shape2DBuilder; @@ -526,6 +631,10 @@ public final class space/kscience/visionforge/solid/Shape2DBuilder$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class space/kscience/visionforge/solid/Shape2DKt { + public static final fun polygon (Lspace/kscience/visionforge/solid/Shape2DBuilder;ILjava/lang/Number;)V +} + public abstract interface class space/kscience/visionforge/solid/Solid : space/kscience/visionforge/Vision { public static final field Companion Lspace/kscience/visionforge/solid/Solid$Companion; public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; @@ -555,17 +664,16 @@ public final class space/kscience/visionforge/solid/Solid$Companion { public final fun getZ_SCALE_KEY ()Lspace/kscience/dataforge/names/Name; } -public class space/kscience/visionforge/solid/SolidBase : space/kscience/visionforge/VisionBase, space/kscience/visionforge/solid/Solid { +public class space/kscience/visionforge/solid/SolidBase : space/kscience/visionforge/AbstractVision, space/kscience/visionforge/solid/Solid { public static final field Companion Lspace/kscience/visionforge/solid/SolidBase$Companion; public fun ()V public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public static final synthetic fun write$Self (Lspace/kscience/visionforge/solid/SolidBase;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Lkotlinx/serialization/KSerializer;)V } public final class space/kscience/visionforge/solid/SolidBase$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidBase$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun (Lkotlinx/serialization/KSerializer;)V public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidBase; @@ -576,24 +684,26 @@ public final class space/kscience/visionforge/solid/SolidBase$$serializer : kotl } public final class space/kscience/visionforge/solid/SolidBase$Companion { - public final fun serializer ()Lkotlinx/serialization/KSerializer; + public final fun serializer (Lkotlinx/serialization/KSerializer;)Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/solid/SolidGroup : space/kscience/visionforge/VisionGroupBase, space/kscience/visionforge/solid/PrototypeHolder, space/kscience/visionforge/solid/Solid { +public final class space/kscience/visionforge/solid/SolidGroup : space/kscience/visionforge/AbstractVisionGroup, space/kscience/visionforge/MutableVisionContainer, space/kscience/visionforge/MutableVisionGroup, space/kscience/visionforge/solid/PrototypeHolder, space/kscience/visionforge/solid/Solid { public static final field Companion Lspace/kscience/visionforge/solid/SolidGroup$Companion; public fun ()V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V - public synthetic fun createGroup ()Lspace/kscience/visionforge/VisionGroupBase; - public fun getChildren ()Ljava/util/Map; + public synthetic fun createGroup ()Lspace/kscience/visionforge/AbstractVisionGroup; + public synthetic fun createGroup ()Lspace/kscience/visionforge/MutableVisionGroup; + public fun createGroup ()Lspace/kscience/visionforge/solid/SolidGroup; + public final fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/Solid; public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun getItems ()Ljava/util/Map; public fun getPrototype (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/Solid; public fun prototypes (Lkotlin/jvm/functions/Function1;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public synthetic fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/solid/Solid;)V } public final class space/kscience/visionforge/solid/SolidGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidGroup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidGroup; @@ -610,39 +720,46 @@ public final class space/kscience/visionforge/solid/SolidGroup$Companion { public final class space/kscience/visionforge/solid/SolidGroupKt { public static final fun SolidGroup (Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static final fun group (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static final fun group (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; - public static synthetic fun group$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; - public static synthetic fun group$default (Lspace/kscience/visionforge/VisionContainerBuilder;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun get (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;)Lspace/kscience/visionforge/solid/Solid; + public static final fun solidGroup (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun solidGroup (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; + public static synthetic fun solidGroup$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; + public static synthetic fun solidGroup$default (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; } public final class space/kscience/visionforge/solid/SolidKt { public static final fun getDetail (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Integer; public static final fun getIgnore (Lspace/kscience/visionforge/Vision;)Ljava/lang/Boolean; public static final fun getLayer (Lspace/kscience/visionforge/solid/Solid;)I - public static final fun getPosition (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun getRotation (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; - public static final fun getRotationOrder (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/RotationOrder; + public static final fun getPosition (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public static final fun getQuaternion (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/kmath/complex/Quaternion; + public static final fun getQuaternionOrNull (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/kmath/complex/Quaternion; + public static final fun getRotation (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Float32Vector3D; + public static final fun getRotationOrder (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/kmath/geometry/RotationOrder; public static final fun getRotationX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getRotationY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getRotationZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; - public static final fun getScale (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Point3D; + public static final fun getScale (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/Float32Vector3D; public static final fun getScaleX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getScaleY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getScaleZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getX (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getY (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; public static final fun getZ (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; + public static final fun rotate (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/kmath/geometry/Angle;Lspace/kscience/kmath/geometry/Vector3D;)V + public static final fun scale (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V public static final fun setDetail (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Integer;)V public static final fun setIgnore (Lspace/kscience/visionforge/Vision;Ljava/lang/Boolean;)V public static final fun setLayer (Lspace/kscience/visionforge/solid/Solid;I)V - public static final fun setPosition (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V - public static final fun setRotation (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V - public static final fun setRotationOrder (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/RotationOrder;)V + public static final fun setPosition (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public static final fun setQuaternion (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/kmath/complex/Quaternion;)V + public static final fun setQuaternionOrNull (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/kmath/complex/Quaternion;)V + public static final fun setRotation (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Float32Vector3D;)V + public static final fun setRotationOrder (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/kmath/geometry/RotationOrder;)V public static final fun setRotationX (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V public static final fun setRotationY (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V public static final fun setRotationZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V - public static final fun setScale (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Point3D;)V + public static final fun setScale (Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/Float32Vector3D;)V public static final fun setScaleX (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V public static final fun setScaleY (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V public static final fun setScaleZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V @@ -651,19 +768,16 @@ public final class space/kscience/visionforge/solid/SolidKt { public static final fun setZ (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V } -public final class space/kscience/visionforge/solid/SolidLabel : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer { +public final class space/kscience/visionforge/solid/SolidLabel : space/kscience/visionforge/solid/SolidBase { public static final field Companion Lspace/kscience/visionforge/solid/SolidLabel$Companion; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Ljava/lang/String;DLjava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Ljava/lang/String;DLjava/lang/String;)V public final fun getFontFamily ()Ljava/lang/String; public final fun getFontSize ()D public final fun getText ()Ljava/lang/String; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidLabel;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/SolidLabel$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidLabel$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidLabel; @@ -678,8 +792,8 @@ public final class space/kscience/visionforge/solid/SolidLabel$Companion { } public final class space/kscience/visionforge/solid/SolidLabelKt { - public static final fun label (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidLabel; - public static synthetic fun label$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidLabel; + public static final fun label (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidLabel; + public static synthetic fun label$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidLabel; } public final class space/kscience/visionforge/solid/SolidMaterial : space/kscience/dataforge/meta/Scheme { @@ -689,25 +803,36 @@ public final class space/kscience/visionforge/solid/SolidMaterial : space/kscien public final fun getEmissiveColor ()Lspace/kscience/visionforge/solid/ColorAccessor; public final fun getOpacity ()F public final fun getSpecularColor ()Lspace/kscience/visionforge/solid/ColorAccessor; + public final fun getType ()Ljava/lang/String; public final fun getWireframe ()Z public final fun setOpacity (F)V + public final fun setType (Ljava/lang/String;)V public final fun setWireframe (Z)V } public final class space/kscience/visionforge/solid/SolidMaterial$Companion : space/kscience/dataforge/meta/SchemeSpec { public final fun getCOLOR_KEY ()Lspace/kscience/dataforge/names/Name; public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; + public final fun getEDGES_ENABLED_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getEDGES_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getEDGES_MATERIAL_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getEMISSIVE_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getENABLED_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getMATERIAL_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getMATERIAL_EMISSIVE_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getMATERIAL_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getMATERIAL_OPACITY_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getMATERIAL_SPECULAR_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getMATERIAL_WIREFRAME_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getOPACITY_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getSPECULAR_COLOR_KEY ()Lspace/kscience/dataforge/names/Name; + public final fun getTYPE_KEY ()Lspace/kscience/dataforge/names/Name; public final fun getWIREFRAME_KEY ()Lspace/kscience/dataforge/names/Name; } public final class space/kscience/visionforge/solid/SolidMaterialKt { + public static final fun edges (Lspace/kscience/visionforge/solid/Solid;ZLkotlin/jvm/functions/Function1;)V + public static synthetic fun edges$default (Lspace/kscience/visionforge/solid/Solid;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public static final fun getColor (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/ColorAccessor; public static final fun getMaterial (Lspace/kscience/visionforge/solid/Solid;)Lspace/kscience/visionforge/solid/SolidMaterial; public static final fun getOpacity (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/Number; @@ -716,87 +841,80 @@ public final class space/kscience/visionforge/solid/SolidMaterialKt { public static final fun setOpacity (Lspace/kscience/visionforge/solid/Solid;Ljava/lang/Number;)V } -public abstract interface class space/kscience/visionforge/solid/SolidReference : space/kscience/visionforge/VisionGroup { - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public abstract fun getPrototype ()Lspace/kscience/visionforge/solid/Solid; -} - -public final class space/kscience/visionforge/solid/SolidReferenceGroup : space/kscience/visionforge/VisionBase, space/kscience/visionforge/VisionGroup, space/kscience/visionforge/solid/Solid, space/kscience/visionforge/solid/SolidReference { - public static final field Companion Lspace/kscience/visionforge/solid/SolidReferenceGroup$Companion; +public final class space/kscience/visionforge/solid/SolidReference : space/kscience/visionforge/VisionGroup, space/kscience/visionforge/solid/Solid { + public static final field Companion Lspace/kscience/visionforge/solid/SolidReference$Companion; public static final field REFERENCE_CHILD_PROPERTY_PREFIX Ljava/lang/String; - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;Lspace/kscience/dataforge/names/Name;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V public fun (Lspace/kscience/dataforge/names/Name;)V - public fun getChildren ()Ljava/util/Map; + public fun getChildren ()Lspace/kscience/visionforge/VisionChildren; public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; - public fun getProperty (Lspace/kscience/dataforge/names/Name;ZZZ)Lspace/kscience/dataforge/values/Value; - public fun getPrototype ()Lspace/kscience/visionforge/solid/Solid; - public final fun getRefName ()Lspace/kscience/dataforge/names/Name; - public static final fun write$Self (Lspace/kscience/visionforge/solid/SolidReferenceGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getParent ()Lspace/kscience/visionforge/Vision; + public fun getProperties ()Lspace/kscience/visionforge/MutableVisionProperties; + public final fun getPrototype ()Lspace/kscience/visionforge/solid/Solid; + public final fun getPrototypeName ()Lspace/kscience/dataforge/names/Name; + public fun setParent (Lspace/kscience/visionforge/Vision;)V } -public final class space/kscience/visionforge/solid/SolidReferenceGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer { - public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidReferenceGroup$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; +public final class space/kscience/visionforge/solid/SolidReference$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/SolidReference$$serializer; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; - public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SolidReference; public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V - public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidReferenceGroup;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/SolidReference;)V public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/solid/SolidReferenceGroup$Companion { +public final class space/kscience/visionforge/solid/SolidReference$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class space/kscience/visionforge/solid/SolidReferenceKt { - public static final fun getUnref (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/solid/Solid; - public static final fun newRef (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/PrototypeHolder;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun newRef$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/PrototypeHolder;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static final fun ref (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Ljava/lang/String;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static final fun ref (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun ref$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; - public static synthetic fun ref$default (Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReferenceGroup; + public static final fun getPrototype (Lspace/kscience/visionforge/Vision;)Lspace/kscience/visionforge/solid/Solid; + public static final fun newRef (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/SolidReference; + public static synthetic fun newRef$default (Lspace/kscience/visionforge/solid/SolidGroup;Ljava/lang/String;Lspace/kscience/visionforge/solid/Solid;Lspace/kscience/visionforge/solid/SolidGroup;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReference; + public static final fun ref (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Ljava/lang/String;)Lspace/kscience/visionforge/solid/SolidReference; + public static final fun ref (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/visionforge/solid/SolidReference; + public static synthetic fun ref$default (Lspace/kscience/visionforge/MutableVisionContainer;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidReference; } -public final class space/kscience/visionforge/solid/Solids : space/kscience/visionforge/VisionPlugin { +public final class space/kscience/visionforge/solid/Solids : space/kscience/visionforge/VisionPlugin, space/kscience/visionforge/MutableVisionContainer { public static final field Companion Lspace/kscience/visionforge/solid/Solids$Companion; public fun (Lspace/kscience/dataforge/meta/Meta;)V public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; + public synthetic fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/Vision;)V + public fun setChild (Lspace/kscience/dataforge/names/Name;Lspace/kscience/visionforge/solid/Solid;)V } public final class space/kscience/visionforge/solid/Solids$Companion : space/kscience/dataforge/context/PluginFactory { + public synthetic fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object; + public fun build (Lspace/kscience/dataforge/context/Context;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/visionforge/solid/Solids; public final fun decodeFromString (Ljava/lang/String;)Lspace/kscience/visionforge/solid/Solid; public final fun encodeToString (Lspace/kscience/visionforge/solid/Solid;)Ljava/lang/String; public final fun getSerializersModuleForSolids ()Lkotlinx/serialization/modules/SerializersModule; public fun getTag ()Lspace/kscience/dataforge/context/PluginTag; - public fun getType ()Lkotlin/reflect/KClass; - public synthetic fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Ljava/lang/Object; - public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/visionforge/solid/Solids; } public final class space/kscience/visionforge/solid/SolidsKt { - public static final fun solid (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun solid (Lspace/kscience/visionforge/html/VisionOutput;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; + public static final fun solid (Lspace/kscience/visionforge/html/VisionOutput;Lspace/kscience/visionforge/solid/specifications/Canvas3DOptions;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SolidGroup; + public static synthetic fun solid$default (Lspace/kscience/visionforge/html/VisionOutput;Lspace/kscience/visionforge/solid/specifications/Canvas3DOptions;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SolidGroup; } -public final class space/kscience/visionforge/solid/Sphere : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/VisionPropertyContainer, space/kscience/visionforge/solid/GeometrySolid { +public final class space/kscience/visionforge/solid/Sphere : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { public static final field Companion Lspace/kscience/visionforge/solid/Sphere$Companion; public fun (FFFFF)V public synthetic fun (FFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V public final fun getPhi ()F public final fun getPhiStart ()F public final fun getRadius ()F public final fun getTheta ()F public final fun getThetaStart ()F public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/Sphere;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/Sphere$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/Sphere$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Sphere; @@ -811,15 +929,14 @@ public final class space/kscience/visionforge/solid/Sphere$Companion { } public final class space/kscience/visionforge/solid/SphereKt { - public static final fun sphere (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Sphere; - public static synthetic fun sphere$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Sphere; + public static final fun sphere (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Sphere; + public static synthetic fun sphere$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Sphere; } public final class space/kscience/visionforge/solid/SphereLayer : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { public static final field Companion Lspace/kscience/visionforge/solid/SphereLayer$Companion; public fun (FFFFFF)V public synthetic fun (FFFFFFILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (ILspace/kscience/dataforge/meta/MutableMeta;FFFFFFLkotlinx/serialization/internal/SerializationConstructorMarker;)V public final fun getInnerRadius ()F public final fun getOuterRadius ()F public final fun getPhi ()F @@ -827,12 +944,10 @@ public final class space/kscience/visionforge/solid/SphereLayer : space/kscience public final fun getTheta ()F public final fun getThetaStart ()F public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V - public static final fun write$Self (Lspace/kscience/visionforge/solid/SphereLayer;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V } public final class space/kscience/visionforge/solid/SphereLayer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public static final field INSTANCE Lspace/kscience/visionforge/solid/SphereLayer$$serializer; - public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor; public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/SphereLayer; @@ -847,29 +962,136 @@ public final class space/kscience/visionforge/solid/SphereLayer$Companion { } public final class space/kscience/visionforge/solid/SphereLayerKt { - public static final fun sphereLayer (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SphereLayer; - public static synthetic fun sphereLayer$default (Lspace/kscience/visionforge/VisionContainerBuilder;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SphereLayer; + public static final fun sphereLayer (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/SphereLayer; + public static synthetic fun sphereLayer$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/SphereLayer; } -public final class space/kscience/visionforge/solid/specifications/Axes : space/kscience/dataforge/meta/Scheme { - public static final field AXIS_SIZE D - public static final field AXIS_WIDTH D - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Axes$Companion; +public final class space/kscience/visionforge/solid/StlBinarySolid : space/kscience/visionforge/solid/StlSolid { + public static final field Companion Lspace/kscience/visionforge/solid/StlBinarySolid$Companion; + public fun ([B)V + public final fun getData ()[B +} + +public final class space/kscience/visionforge/solid/StlBinarySolid$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/StlBinarySolid$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/StlBinarySolid; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/StlBinarySolid;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/StlBinarySolid$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public abstract class space/kscience/visionforge/solid/StlSolid : space/kscience/visionforge/solid/SolidBase { +} + +public final class space/kscience/visionforge/solid/StlSolidKt { + public static final fun stl (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/StlSolid; + public static synthetic fun stl$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/StlSolid; +} + +public final class space/kscience/visionforge/solid/StlUrlSolid : space/kscience/visionforge/solid/StlSolid { + public static final field Companion Lspace/kscience/visionforge/solid/StlUrlSolid$Companion; + public fun (Ljava/lang/String;)V + public final fun getUrl ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/solid/StlUrlSolid$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/StlUrlSolid$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/StlUrlSolid; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/StlUrlSolid;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/StlUrlSolid$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/Surface : space/kscience/visionforge/solid/SolidBase, space/kscience/visionforge/solid/GeometrySolid { + public static final field Companion Lspace/kscience/visionforge/solid/Surface$Companion; + public static final field TYPE Ljava/lang/String; + public fun (Ljava/util/List;)V + public final fun getLayers ()Ljava/util/List; + public fun toGeometry (Lspace/kscience/visionforge/solid/GeometryBuilder;)V +} + +public final class space/kscience/visionforge/solid/Surface$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Surface$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Surface; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Surface;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/Surface$Builder { public fun ()V - public final fun getSize ()D - public final fun getVisible ()Z - public final fun getWidth ()D - public final fun setSize (D)V - public final fun setVisible (Z)V - public final fun setWidth (D)V + public fun (Ljava/util/List;Lspace/kscience/dataforge/meta/MutableMeta;)V + public synthetic fun (Ljava/util/List;Lspace/kscience/dataforge/meta/MutableMeta;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getLayers ()Ljava/util/List; + public final fun getProperties ()Lspace/kscience/dataforge/meta/MutableMeta; + public final fun layer (Ljava/lang/Number;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun layer$default (Lspace/kscience/visionforge/solid/Surface$Builder;Ljava/lang/Number;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public final fun setLayers (Ljava/util/List;)V } -public final class space/kscience/visionforge/solid/specifications/Axes$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; +public final class space/kscience/visionforge/solid/Surface$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class space/kscience/visionforge/solid/specifications/Camera : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Camera$Companion; +public final class space/kscience/visionforge/solid/Surface$Layer { + public static final field Companion Lspace/kscience/visionforge/solid/Surface$Layer$Companion; + public fun (FLjava/util/List;Ljava/util/List;)V + public final fun component1 ()F + public final fun component2 ()Ljava/util/List; + public final fun component3 ()Ljava/util/List; + public final fun copy (FLjava/util/List;Ljava/util/List;)Lspace/kscience/visionforge/solid/Surface$Layer; + public static synthetic fun copy$default (Lspace/kscience/visionforge/solid/Surface$Layer;FLjava/util/List;Ljava/util/List;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Surface$Layer; + public fun equals (Ljava/lang/Object;)Z + public final fun getCenter ()Lspace/kscience/visionforge/solid/Float32Vector3D; + public final fun getInner ()Ljava/util/List; + public final fun getOuter ()Ljava/util/List; + public final fun getSize ()I + public final fun getZ ()F + public fun hashCode ()I + public final fun innerPoints ()Ljava/util/List; + public final fun outerPoints ()Ljava/util/List; + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/visionforge/solid/Surface$Layer$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Lspace/kscience/visionforge/solid/Surface$Layer$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/visionforge/solid/Surface$Layer; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/visionforge/solid/Surface$Layer;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/Surface$Layer$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class space/kscience/visionforge/solid/SurfaceKt { + public static final fun surface (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/visionforge/solid/Surface; + public static synthetic fun surface$default (Lspace/kscience/visionforge/MutableVisionContainer;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/visionforge/solid/Surface; +} + +public final class space/kscience/visionforge/solid/specifications/CameraScheme : space/kscience/dataforge/meta/Scheme { + public static final field Companion Lspace/kscience/visionforge/solid/specifications/CameraScheme$Companion; public static final field FAR_CLIP D public static final field FIELD_OF_VIEW I public static final field INITIAL_AZIMUTH D @@ -891,31 +1113,29 @@ public final class space/kscience/visionforge/solid/specifications/Camera : spac public final fun setNearClip (D)V } -public final class space/kscience/visionforge/solid/specifications/Camera$Companion : space/kscience/dataforge/meta/SchemeSpec { +public final class space/kscience/visionforge/solid/specifications/CameraScheme$Companion : space/kscience/dataforge/meta/SchemeSpec { public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; } -public final class space/kscience/visionforge/solid/specifications/CameraKt { - public static final fun getZenith (Lspace/kscience/visionforge/solid/specifications/Camera;)D +public final class space/kscience/visionforge/solid/specifications/CameraSchemeKt { + public static final fun getZenith (Lspace/kscience/visionforge/solid/specifications/CameraScheme;)D } public final class space/kscience/visionforge/solid/specifications/Canvas3DOptions : space/kscience/dataforge/meta/Scheme { public static final field Companion Lspace/kscience/visionforge/solid/specifications/Canvas3DOptions$Companion; public fun ()V - public final fun getAxes ()Lspace/kscience/visionforge/solid/specifications/Axes; - public final fun getCamera ()Lspace/kscience/visionforge/solid/specifications/Camera; - public final fun getClipping ()Lspace/kscience/visionforge/solid/specifications/Clipping; - public final fun getControls ()Lspace/kscience/visionforge/solid/specifications/Controls; + public final fun getCamera ()Lspace/kscience/visionforge/solid/specifications/CameraScheme; + public final fun getCanvasName ()Ljava/lang/String; + public final fun getClipping ()Lspace/kscience/visionforge/solid/specifications/PointScheme; + public final fun getControls ()Lspace/kscience/visionforge/solid/specifications/Canvas3DUIScheme; public final fun getLayers ()Ljava/util/List; - public final fun getLight ()Lspace/kscience/visionforge/solid/specifications/Light; public final fun getOnSelect ()Lkotlin/jvm/functions/Function1; public final fun getSize ()Lspace/kscience/visionforge/solid/specifications/CanvasSize; - public final fun setAxes (Lspace/kscience/visionforge/solid/specifications/Axes;)V - public final fun setCamera (Lspace/kscience/visionforge/solid/specifications/Camera;)V - public final fun setClipping (Lspace/kscience/visionforge/solid/specifications/Clipping;)V - public final fun setControls (Lspace/kscience/visionforge/solid/specifications/Controls;)V + public final fun setCamera (Lspace/kscience/visionforge/solid/specifications/CameraScheme;)V + public final fun setCanvasName (Ljava/lang/String;)V + public final fun setClipping (Lspace/kscience/visionforge/solid/specifications/PointScheme;)V + public final fun setControls (Lspace/kscience/visionforge/solid/specifications/Canvas3DUIScheme;)V public final fun setLayers (Ljava/util/List;)V - public final fun setLight (Lspace/kscience/visionforge/solid/specifications/Light;)V public final fun setOnSelect (Lkotlin/jvm/functions/Function1;)V public final fun setSize (Lspace/kscience/visionforge/solid/specifications/CanvasSize;)V } @@ -929,6 +1149,17 @@ public final class space/kscience/visionforge/solid/specifications/Canvas3DOptio public static final fun computeWidth (Lspace/kscience/visionforge/solid/specifications/CanvasSize;Ljava/lang/Number;)I } +public final class space/kscience/visionforge/solid/specifications/Canvas3DUIScheme : space/kscience/dataforge/meta/Scheme { + public static final field Companion Lspace/kscience/visionforge/solid/specifications/Canvas3DUIScheme$Companion; + public fun ()V + public final fun getEnabled ()Z + public final fun setEnabled (Z)V +} + +public final class space/kscience/visionforge/solid/specifications/Canvas3DUIScheme$Companion : space/kscience/dataforge/meta/SchemeSpec { + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; +} + public final class space/kscience/visionforge/solid/specifications/CanvasSize : space/kscience/dataforge/meta/Scheme { public static final field Companion Lspace/kscience/visionforge/solid/specifications/CanvasSize$Companion; public fun ()V @@ -950,8 +1181,13 @@ public final class space/kscience/visionforge/solid/specifications/CanvasSize$Co public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; } -public final class space/kscience/visionforge/solid/specifications/Clipping : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Clipping$Companion; +public final class space/kscience/visionforge/solid/specifications/Clipping : space/kscience/dataforge/meta/SchemeSpec { + public static final field INSTANCE Lspace/kscience/visionforge/solid/specifications/Clipping; + public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; +} + +public final class space/kscience/visionforge/solid/specifications/PointScheme : space/kscience/dataforge/meta/Scheme { + public static final field Companion Lspace/kscience/visionforge/solid/specifications/PointScheme$Companion; public fun ()V public final fun getX ()Ljava/lang/Double; public final fun getY ()Ljava/lang/Double; @@ -961,24 +1197,11 @@ public final class space/kscience/visionforge/solid/specifications/Clipping : sp public final fun setZ (Ljava/lang/Double;)V } -public final class space/kscience/visionforge/solid/specifications/Clipping$Companion : space/kscience/dataforge/meta/SchemeSpec { - public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; +public final class space/kscience/visionforge/solid/specifications/PointScheme$Companion : space/kscience/dataforge/meta/SchemeSpec { } -public final class space/kscience/visionforge/solid/specifications/Controls : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Controls$Companion; - public fun ()V -} - -public final class space/kscience/visionforge/solid/specifications/Controls$Companion : space/kscience/dataforge/meta/SchemeSpec { -} - -public final class space/kscience/visionforge/solid/specifications/Light : space/kscience/dataforge/meta/Scheme { - public static final field Companion Lspace/kscience/visionforge/solid/specifications/Light$Companion; - public fun ()V -} - -public final class space/kscience/visionforge/solid/specifications/Light$Companion : space/kscience/dataforge/meta/SchemeSpec { +public final class space/kscience/visionforge/solid/specifications/PointSchemeKt { + public static final fun invoke (Lspace/kscience/visionforge/solid/specifications/PointScheme;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;)V } public abstract class space/kscience/visionforge/solid/transform/VisualTreeTransform { diff --git a/visionforge-solid/build.gradle.kts b/visionforge-solid/build.gradle.kts index f87cef77..f6ee0ab4 100644 --- a/visionforge-solid/build.gradle.kts +++ b/visionforge-solid/build.gradle.kts @@ -8,6 +8,7 @@ kscience { jvm() js() native() +// wasm() useSerialization { json() } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt index 3cc6ff61..76556860 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Composite.kt @@ -2,6 +2,7 @@ package space.kscience.visionforge.solid import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.isEmpty import space.kscience.dataforge.names.Name import space.kscience.visionforge.MutableVisionContainer import space.kscience.visionforge.VisionBuilder @@ -39,7 +40,7 @@ public inline fun MutableVisionContainer.composite( } val res = Composite(type, children[0], children[1]) - res.properties.setMeta(Name.EMPTY, group.properties.own) + res.properties[Name.EMPTY] = group.properties.own setChild(name, res) return res @@ -55,7 +56,7 @@ public fun SolidGroup.smartComposite( @VisionBuilder builder: SolidGroup.() -> Unit, ): Solid = if (type == CompositeType.GROUP) { val group = SolidGroup().apply(builder) - if (name == null && group.properties.own == null) { + if (name == null && group.properties.own.isEmpty()) { //append directly to group if no properties are defined group.items.forEach { (_, value) -> value.parent = null diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt index 8276722e..c2157480 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Extruded.kt @@ -92,7 +92,7 @@ public class Extruded( } internal fun build(): Extruded = Extruded(shape, layers).apply { - this.properties.setMeta(Name.EMPTY, this@Builder.properties) + this.properties[Name.EMPTY] = this@Builder.properties } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt index a42427da..c1e16daa 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt @@ -177,7 +177,7 @@ internal fun float32Vector( ): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Solid, property: KProperty<*>): Float32Vector3D? { - val item = thisRef.properties.own?.get(name) ?: return null + val item = thisRef.properties.own[name] ?: return null //using dynamic property accessor because values could change return object : Float32Vector3D { override val x: Float get() = item[X_KEY]?.float ?: defaultX @@ -190,7 +190,7 @@ internal fun float32Vector( override fun setValue(thisRef: Solid, property: KProperty<*>, value: Float32Vector3D?) { if (value == null) { - thisRef.properties.setMeta(name, null) + thisRef.properties[name] = null } else { thisRef.properties[name + X_KEY] = value.x thisRef.properties[name + Y_KEY] = value.y @@ -203,6 +203,10 @@ public var Solid.position: Float32Vector3D? by float32Vector(POSITION_KEY, 0f) public var Solid.rotation: Float32Vector3D? by float32Vector(ROTATION_KEY, 0f) public var Solid.scale: Float32Vector3D? by float32Vector(SCALE_KEY, 1f) +public fun Solid.scale(scaleFactor: Number) { + scale = Float32Vector3D(scaleFactor, scaleFactor, scaleFactor) +} + public var Solid.x: Number by float32(X_POSITION_KEY, 0f) public var Solid.y: Number by float32(Y_POSITION_KEY, 0f) public var Solid.z: Number by float32(Z_POSITION_KEY, 0f) @@ -255,5 +259,5 @@ public var Solid.scaleZ: Number by float32(Z_SCALE_KEY, 1f) * Add rotation with given [angle] relative to given [axis] */ public fun Solid.rotate(angle: Angle, axis: DoubleVector3D): Unit = with(QuaternionField) { - quaternion = Quaternion.fromRotation(angle, axis)*quaternion + quaternion = Quaternion.fromRotation(angle, axis) * quaternion } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt index 40857b14..6e336110 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidMaterial.kt @@ -2,6 +2,7 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.value import space.kscience.dataforge.meta.set import space.kscience.dataforge.names.Name @@ -18,6 +19,8 @@ import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_OPACITY @VisionBuilder public class SolidMaterial : Scheme() { + public var type: String by string("default", key = TYPE_KEY) + /** * Primary web-color for the material */ @@ -64,10 +67,11 @@ public class SolidMaterial : Scheme() { //must be lazy to avoid initialization bug MetaDescriptor { inherited = true + valueRestriction = ValueRestriction.ABSENT - value(TYPE_KEY, ValueType.STRING){ + value(TYPE_KEY, ValueType.STRING) { inherited = true - allowedValues = listOf("default".asValue(), "simple".asValue()) + allowedValues = listOf("default", "basic", "lambert", "phong").map { it.asValue() } default("default") } @@ -110,12 +114,12 @@ public val Solid.color: ColorAccessor get() = ColorAccessor(properties.root(true), MATERIAL_COLOR_KEY) public var Solid.material: SolidMaterial? - get() = SolidMaterial.read(properties.getMeta(MATERIAL_KEY)) - set(value) = properties.setMeta(MATERIAL_KEY, value?.meta) + get() = SolidMaterial.read(properties[MATERIAL_KEY]) + set(value) = properties.set(MATERIAL_KEY, value?.meta) @VisionBuilder public fun Solid.material(builder: SolidMaterial.() -> Unit) { - properties.getMeta(MATERIAL_KEY).updateWith(SolidMaterial, builder) + properties[MATERIAL_KEY].updateWith(SolidMaterial, builder) } public var Solid.opacity: Number? @@ -128,5 +132,5 @@ public var Solid.opacity: Number? @VisionBuilder public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) { properties[SolidMaterial.EDGES_ENABLED_KEY] = enabled - SolidMaterial.write(properties.getMeta(SolidMaterial.EDGES_MATERIAL_KEY)).apply(block) + SolidMaterial.write(properties[SolidMaterial.EDGES_MATERIAL_KEY]).apply(block) } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt index 32e69520..b98bd4cb 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/SolidReference.kt @@ -6,9 +6,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.launch -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient +import kotlinx.serialization.* import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.get @@ -51,21 +49,19 @@ public class SolidReference( } override val descriptor: MetaDescriptor get() = prototype.descriptor + @SerialName("properties") - private var propertiesInternal: MutableMeta? = null + @OptIn(ExperimentalSerializationApi::class) + @EncodeDefault(EncodeDefault.Mode.NEVER) + private val propertiesInternal: MutableMeta = MutableMeta() override val properties: MutableVisionProperties by lazy { - object : AbstractVisionProperties(this) { - override var properties: MutableMeta? - get() = propertiesInternal - set(value) { - propertiesInternal = value - } + object : AbstractVisionProperties(this, propertiesInternal) { override fun getValue(name: Name, inherit: Boolean?, includeStyles: Boolean?): Value? { if (name == Vision.STYLE_KEY) { return buildList { - properties?.getValue(Vision.STYLE_KEY)?.list?.forEach { + own.getValue(Vision.STYLE_KEY)?.list?.forEach { add(it) } prototype.styles.forEach { @@ -74,18 +70,18 @@ public class SolidReference( }.distinct().asValue() } //1. resolve own properties - properties?.getValue(name)?.let { return it } + own.getValue(name)?.let { return it } val descriptor = descriptor?.get(name) val inheritFlag = inherit ?: descriptor?.inherited ?: false val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true //2. Resolve prototype onw properties - prototype.properties.own?.getValue(name)?.let { return it } + prototype.properties.own.getValue(name)?.let { return it } if (stylesFlag) { //3. own styles - own?.getValue(Vision.STYLE_KEY)?.list?.forEach { styleName -> + own.getValue(Vision.STYLE_KEY)?.list?.forEach { styleName -> getStyle(styleName.string)?.getValue(name)?.let { return it } } //4. prototype styles @@ -162,7 +158,7 @@ internal class SolidReferenceChild( override val properties: MutableVisionProperties = object : MutableVisionProperties { override val descriptor: MetaDescriptor get() = this@SolidReferenceChild.descriptor - override val own: MutableMeta by lazy { owner.properties.getMeta(childToken(childName).asName()) } + override val own: MutableMeta by lazy { owner.properties[childToken(childName).asName()] } override fun getValue( name: Name, @@ -170,15 +166,16 @@ internal class SolidReferenceChild( includeStyles: Boolean?, ): Value? = own.getValue(name) ?: prototype.properties.getValue(name, inherit, includeStyles) - override fun setMeta(name: Name, node: Meta?, notify: Boolean) { - own.setMeta(name, node) + override fun set(name: Name, item: Meta?, notify: Boolean) { + own[name] = item } override fun setValue(name: Name, value: Value?, notify: Boolean) { own.setValue(name, value) } - override val changes: Flow get() = owner.properties.changes.filter { it.startsWith(childToken(childName)) } + override val changes: Flow + get() = owner.properties.changes.filter { it.startsWith(childToken(childName)) } override fun invalidate(propertyName: Name) { owner.properties.invalidate(childPropertyName(childName, propertyName)) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt index 35f9b75f..cf442c62 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Surface.kt @@ -155,7 +155,7 @@ public class Surface( } internal fun build(): Surface = Surface(layers).apply { - properties.setMeta(Name.EMPTY, this@Builder.properties) + properties[Name.EMPTY] = this@Builder.properties } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt index 58c3021d..8f799f2e 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/geometry.kt @@ -36,9 +36,9 @@ internal fun Meta.toVector2D(): Float32Vector2D = //} internal fun MetaProvider.point3D(default: Float = 0f) = Float32Euclidean3DSpace.vector( - getMeta(X_KEY).float ?: default, - getMeta(Y_KEY).float ?: default, - getMeta(Z_KEY).float ?: default + get(X_KEY).float ?: default, + get(Y_KEY).float ?: default, + get(Z_KEY).float ?: default ) diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt deleted file mode 100644 index 0ed9126e..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/AxesScheme.kt +++ /dev/null @@ -1,35 +0,0 @@ -package space.kscience.visionforge.solid.specifications - -import space.kscience.dataforge.meta.Scheme -import space.kscience.dataforge.meta.SchemeSpec -import space.kscience.dataforge.meta.boolean -import space.kscience.dataforge.meta.descriptors.MetaDescriptor -import space.kscience.dataforge.meta.descriptors.value -import space.kscience.dataforge.meta.double - -@Deprecated("Use separate axes object instead") -public class AxesScheme : Scheme() { - public var visible: Boolean by boolean(false) - public var size: Double by double(AXIS_SIZE) - public var width: Double by double(AXIS_WIDTH) - - @Suppress("DEPRECATION") - public companion object : SchemeSpec(::AxesScheme) { - public const val AXIS_SIZE: Double = 1000.0 - public const val AXIS_WIDTH: Double = 3.0 - - override val descriptor: MetaDescriptor by lazy { - MetaDescriptor { - value(AxesScheme::visible){ - default(false) - } - value(AxesScheme::size){ - default(AXIS_SIZE) - } - value(AxesScheme::width){ - default(AXIS_WIDTH) - } - } - } - } -} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt index b24c9b75..a67532ce 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DOptions.kt @@ -1,10 +1,14 @@ +@file:OptIn(DFExperimental::class) + package space.kscience.visionforge.solid.specifications import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.ValueRestriction import space.kscience.dataforge.meta.descriptors.scheme import space.kscience.dataforge.meta.descriptors.value import space.kscience.dataforge.meta.set +import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name import space.kscience.visionforge.hide import space.kscience.visionforge.widgetType @@ -12,6 +16,7 @@ import space.kscience.visionforge.widgetType public object Clipping : SchemeSpec(::PointScheme) { override val descriptor: MetaDescriptor = MetaDescriptor { + valueRestriction = ValueRestriction.ABSENT value(PointScheme::x) { widgetType = "range" attributes["min"] = 0.0 @@ -59,16 +64,16 @@ public class CanvasSize : Scheme() { } public class Canvas3DOptions : Scheme() { - @Suppress("DEPRECATION") - public var axes: AxesScheme by spec(AxesScheme) - public var camera: CameraScheme by spec(CameraScheme) - public var controls: ControlsScheme by spec(ControlsScheme) + public var canvasName: String by string("vision") - public var size: CanvasSize by spec(CanvasSize) + public var camera: CameraScheme by scheme(CameraScheme) + public var controls: Canvas3DUIScheme by scheme(Canvas3DUIScheme) + + public var size: CanvasSize by scheme(CanvasSize) public var layers: List by numberList(0) - public var clipping: PointScheme by spec(Clipping) + public var clipping: PointScheme by scheme(Clipping) public var onSelect: ((Name?) -> Unit)? = null @@ -76,9 +81,6 @@ public class Canvas3DOptions : Scheme() { public companion object : SchemeSpec(::Canvas3DOptions) { override val descriptor: MetaDescriptor by lazy { MetaDescriptor { - @Suppress("DEPRECATION") - scheme(Canvas3DOptions::axes, AxesScheme) - value(Canvas3DOptions::layers) { multiple = true default(listOf(0)) @@ -92,7 +94,7 @@ public class Canvas3DOptions : Scheme() { hide() } - scheme(Canvas3DOptions::controls, ControlsScheme) { + scheme(Canvas3DOptions::controls, Canvas3DUIScheme) { hide() } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DUIScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DUIScheme.kt new file mode 100644 index 00000000..46665a56 --- /dev/null +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/Canvas3DUIScheme.kt @@ -0,0 +1,19 @@ +package space.kscience.visionforge.solid.specifications + +import space.kscience.dataforge.meta.Scheme +import space.kscience.dataforge.meta.SchemeSpec +import space.kscience.dataforge.meta.boolean +import space.kscience.dataforge.meta.descriptors.MetaDescriptor +import space.kscience.dataforge.meta.descriptors.ValueRestriction + + +public class Canvas3DUIScheme : Scheme() { + + public var enabled: Boolean by boolean { true } + + public companion object : SchemeSpec(::Canvas3DUIScheme) { + override val descriptor: MetaDescriptor = MetaDescriptor { + valueRestriction = ValueRestriction.ABSENT + } + } +} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt deleted file mode 100644 index 5e68f37c..00000000 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/specifications/ControlsScheme.kt +++ /dev/null @@ -1,9 +0,0 @@ -package space.kscience.visionforge.solid.specifications - -import space.kscience.dataforge.meta.Scheme -import space.kscience.dataforge.meta.SchemeSpec - - -public class ControlsScheme : Scheme() { - public companion object : SchemeSpec(::ControlsScheme) -} \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt index cdc9caaf..bcf3baa9 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/transform/RemoveSingleChild.kt @@ -19,7 +19,7 @@ internal fun Solid.updateFrom(other: Solid): Solid { scaleX *= other.scaleX scaleY *= other.scaleY scaleZ *= other.scaleZ - properties.setMeta(Name.EMPTY, other.properties.root()) + properties[Name.EMPTY] = other.properties.root() return this } diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt deleted file mode 100644 index 87527802..00000000 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/DescriptorTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package space.kscience.visionforge.solid - -import space.kscience.dataforge.meta.ValueType -import space.kscience.dataforge.meta.descriptors.get -import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import kotlin.test.Test -import kotlin.test.assertNotNull -import kotlin.test.assertTrue - -class DescriptorTest { - @Test - fun canvasDescriptor() { - val descriptor = Canvas3DOptions.descriptor - //println(descriptor.config) - val axesSize = descriptor["axes.size"] - assertNotNull(axesSize) - assertTrue { - ValueType.NUMBER in axesSize.valueTypes!! - } - } -} \ No newline at end of file diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt index 4991c12d..a68e7daf 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPropertyTest.kt @@ -1,17 +1,17 @@ package space.kscience.visionforge.solid -import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay -import kotlinx.coroutines.test.runTest +import space.kscience.dataforge.meta.getValue import space.kscience.dataforge.meta.int import space.kscience.dataforge.meta.set import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.asName -import space.kscience.visionforge.* +import space.kscience.visionforge.getValue +import space.kscience.visionforge.styleSheet +import space.kscience.visionforge.styles +import space.kscience.visionforge.useStyle import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.time.Duration.Companion.milliseconds @OptIn(ExperimentalCoroutinesApi::class) @Suppress("UNUSED_VARIABLE") @@ -28,25 +28,14 @@ class SolidPropertyTest { } @Test - fun testColorUpdate() = runTest(timeout = 200.milliseconds) { + fun testColorUpdate() { val box = Box(10.0f, 10.0f, 10.0f) - val c = CompletableDeferred() - - - val subscription = box.onPropertyChange(this) { key -> - if (key == SolidMaterial.MATERIAL_COLOR_KEY) { - c.complete(box.color.string) - } - } - delay(5) - box.material { color("pink") } - assertEquals("pink", c.await()) - subscription.cancel() + assertEquals("pink", box.properties[SolidMaterial.MATERIAL_COLOR_KEY].string) } @Test diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt index 898fae11..0e495aaa 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt @@ -28,7 +28,7 @@ internal class VisionUpdateTest { propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("origin".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) } - targetVision.receiveChange(dif) + targetVision.update(dif) assertTrue { targetVision.children.getChild("top") is SolidGroup } assertEquals("red", (targetVision.children.getChild("origin") as Solid).color.string) // Should work assertEquals( diff --git a/visionforge-tables/README.md b/visionforge-tables/README.md index 6cdbd356..dab2ad0b 100644 --- a/visionforge-tables/README.md +++ b/visionforge-tables/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-tables:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-tables:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-tables:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-tables:0.2.0") + implementation("space.kscience:visionforge-tables:0.4.1") } ``` diff --git a/visionforge-tables/build.gradle.kts b/visionforge-tables/build.gradle.kts index 33988cf0..ccc0341a 100644 --- a/visionforge-tables/build.gradle.kts +++ b/visionforge-tables/build.gradle.kts @@ -2,30 +2,30 @@ plugins { id("space.kscience.gradle.mpp") } -val tablesVersion = "0.2.1" +val tablesVersion = "0.4.0" kscience { jvm() js { - useCommonJs() binaries.library() browser { - commonWebpackConfig { - cssSupport { - enabled.set(true) + webpackTask{ + scssSupport { + enabled = true } } } } - dependencies { + + useSerialization() + commonMain { api(projects.visionforgeCore) api("space.kscience:tables-kt:${tablesVersion}") } - dependencies(jsMain) { - implementation(npm("tabulator-tables", "5.5.2")) - implementation(npm("@types/tabulator-tables", "5.5.3")) + jsMain { + api(npm("tabulator-tables", "5.5.2")) + api(npm("@types/tabulator-tables", "5.5.3")) } - useSerialization() } readme { diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt index d6bc9b1d..4a8a06d1 100644 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt +++ b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt @@ -13,12 +13,11 @@ import space.kscience.visionforge.VisionPlugin public class TableVisionPlugin : VisionPlugin() { override val tag: PluginTag get() = Companion.tag - override val visionSerializersModule: SerializersModule - get() = SerializersModule { - polymorphic(Vision::class) { - subclass(VisionOfTable.serializer()) - } + override val visionSerializersModule: SerializersModule = SerializersModule { + polymorphic(Vision::class) { + subclass(VisionOfTable.serializer()) } + } public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.table", PluginTag.DATAFORGE_GROUP) diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt index 3e4f9da8..a691bd85 100644 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt +++ b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt @@ -70,7 +70,7 @@ public fun Table.toVision( } else { Meta { headers.forEach { - it.name put converter(row[it.name]) + it.name put converter(row.getOrNull(it.name)) } } } diff --git a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt index e1210ffa..def7017b 100644 --- a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt +++ b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt @@ -6,6 +6,7 @@ import space.kscience.dataforge.meta.double import space.kscience.dataforge.meta.int import space.kscience.tables.ColumnHeader import space.kscience.tables.ColumnTable +import space.kscience.tables.fill import space.kscience.tables.get import kotlin.math.pow import kotlin.test.Test @@ -18,7 +19,7 @@ internal class VisionOfTableTest { val y by ColumnHeader.typed() val table = ColumnTable(100) { - x.fill { it.asValue() } + fill(x, null) { it.asValue() } y.values = x.values.map { it?.double?.pow(2)?.asValue() } } diff --git a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt b/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt index 75977d79..1b7ba961 100644 --- a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt +++ b/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt @@ -1,6 +1,6 @@ package space.kscience.visionforge.tables -import js.core.jso +import js.objects.jso import org.w3c.dom.Element import org.w3c.dom.HTMLElement import space.kscience.dataforge.context.AbstractPlugin @@ -11,9 +11,9 @@ import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.toDynamic import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName -import space.kscience.visionforge.ElementVisionRenderer -import space.kscience.visionforge.JsVisionClient import space.kscience.visionforge.Vision +import space.kscience.visionforge.html.ElementVisionRenderer +import space.kscience.visionforge.html.JsVisionClient import tabulator.Tabulator import tabulator.TabulatorFull @@ -81,6 +81,8 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { TabulatorFull(element as HTMLElement, tableOptions) } + override fun toString(): String = "Table" + override fun content(target: String): Map = when (target) { ElementVisionRenderer.TYPE -> mapOf("table".asName() to this) else -> super.content(target) diff --git a/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt b/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt index f6efd32a..8908ee89 100644 --- a/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt +++ b/visionforge-tables/src/jsMain/kotlin/tabulator/Tabulator.kt @@ -5,6 +5,7 @@ "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING") @file:JsModule("tabulator-tables") +@file:JsNonModule package tabulator diff --git a/visionforge-threejs/README.md b/visionforge-threejs/README.md index 98c13b7a..0ac15cc6 100644 --- a/visionforge-threejs/README.md +++ b/visionforge-threejs/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-threejs:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-threejs:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-threejs:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-threejs:0.2.0") + implementation("space.kscience:visionforge-threejs:0.4.1") } ``` diff --git a/visionforge-threejs/build.gradle.kts b/visionforge-threejs/build.gradle.kts index 41714618..b066887c 100644 --- a/visionforge-threejs/build.gradle.kts +++ b/visionforge-threejs/build.gradle.kts @@ -1,22 +1,26 @@ plugins { id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) } -kotlin{ +kotlin { explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Disabled } -kscience{ - js{ +kscience { + js { binaries.library() } - jsMain{ - dependencies { - api(projects.visionforgeSolid) - implementation(npm("three", "0.143.0")) - implementation(npm("three-csg-ts", "3.1.10")) - implementation(npm("three.meshline","1.4.0")) - } + + commonMain { + api(projects.visionforgeSolid) + } + + jsMain { + api(projects.visionforgeComposeHtml) + implementation(npm("three", "0.143.0")) + implementation(npm("three-csg-ts", "3.1.13")) + implementation(npm("three.meshline", "1.4.0")) } } diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt index b65d1fce..786a0cc1 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt @@ -20,7 +20,6 @@ import three.core.Raycaster import three.external.controls.OrbitControls import three.external.controls.TrackballControls import three.geometries.EdgesGeometry -import three.helpers.AxesHelper import three.materials.Material import three.math.* import three.meshline.MeshLine @@ -50,14 +49,7 @@ public class ThreeCanvas( private val raycaster = Raycaster() private val mousePosition: Vector2 = Vector2() - private val scene: Scene = Scene().apply { - options.useProperty(Canvas3DOptions::axes, this) { - getObjectByName(AXES_NAME)?.let { remove(it) } - val axesObject = AxesHelper(axes.size.toInt()).apply { visible = axes.visible } - axesObject.name = AXES_NAME - add(axesObject) - } - } + private val scene: Scene = Scene() private fun buildCamera(spec: CameraScheme) = PerspectiveCamera( @@ -155,9 +147,10 @@ public class ThreeCanvas( } //Clipping planes - options.useProperty(Canvas3DOptions::clipping) { clipping -> - if (!clipping.meta.isEmpty()) { - renderer.localClippingEnabled = true + options.useProperty(Canvas3DOptions::clipping) { clipping: PointScheme -> + if (clipping.meta.isEmpty()) { + renderer.clippingPlanes = emptyArray() + } else { boundingBox?.let { boundingBox -> val xClippingPlane = clipping.x?.let { val absoluteValue = boundingBox.min.x + (boundingBox.max.x - boundingBox.min.x) * it @@ -175,8 +168,6 @@ public class ThreeCanvas( renderer.clippingPlanes = listOfNotNull(xClippingPlane, yClippingPlane, zClippingPlane).toTypedArray() } - } else { - renderer.localClippingEnabled = false } } @@ -236,7 +227,7 @@ public class ThreeCanvas( // } // } - private fun addControls(element: Node, controls: ControlsScheme) { + private fun addControls(element: Node, controls: Canvas3DUIScheme) { when (controls.meta["type"].string) { "trackball" -> TrackballControls(camera, element) else -> OrbitControls(camera, element) diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt index e6e9641c..1117ba37 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCompositeFactory.kt @@ -52,7 +52,7 @@ public class ThreeCompositeFactory(public val three: ThreePlugin) : ThreeFactory applyProperties(vision) if (observe) { - vision.onPropertyChange { name -> + vision.onPropertyChange(three.context) { name -> when { //name.startsWith(WIREFRAME_KEY) -> mesh.applyWireFrame(obj) name.startsWith(EDGES_KEY) -> applyEdges(vision) diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt index 122a2c30..09b81053 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeFactory.kt @@ -1,6 +1,6 @@ package space.kscience.visionforge.solid.three -import space.kscience.dataforge.misc.Type +import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.startsWith import space.kscience.visionforge.Vision @@ -17,7 +17,7 @@ import kotlin.reflect.KClass /** * Builder and updater for three.js object */ -@Type(TYPE) +@DfType(TYPE) public interface ThreeFactory { public val type: KClass diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt index 45068a3a..3ca87d48 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.solid.three -import js.core.jso +import js.objects.jso import space.kscience.dataforge.context.logger import space.kscience.dataforge.context.warn import space.kscience.visionforge.onPropertyChange @@ -27,7 +27,7 @@ public object ThreeLabelFactory : ThreeFactory { return Mesh(textGeo, ThreeMaterials.DEFAULT).apply { setMaterial(vision) updatePosition(vision) - if(observe) { + if (observe) { vision.onPropertyChange(three.context) { //TODO three.logger.warn { "Label parameter change not implemented" } diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt index 42722254..68bfd7b2 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeLineFactory.kt @@ -24,7 +24,7 @@ public object ThreeLineFactory : ThreeFactory { } val material = ThreeMaterials.getLineMaterial( - vision.properties.getMeta(SolidMaterial.MATERIAL_KEY), + vision.properties[SolidMaterial.MATERIAL_KEY], false ) diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt index 49667c8e..3c860111 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMaterials.kt @@ -10,10 +10,7 @@ import space.kscience.visionforge.getStyleNodes import space.kscience.visionforge.solid.ColorAccessor import space.kscience.visionforge.solid.SolidMaterial import space.kscience.visionforge.solid.SolidReference -import three.materials.LineBasicMaterial -import three.materials.Material -import three.materials.MeshBasicMaterial -import three.materials.MeshStandardMaterial +import three.materials.* import three.math.Color import three.objects.Mesh @@ -56,11 +53,23 @@ public object ThreeMaterials { } internal fun buildMaterial(meta: Meta): Material = when (meta[SolidMaterial.TYPE_KEY]?.string) { - "simple" -> MeshBasicMaterial().apply { + "basic" -> MeshBasicMaterial().apply { color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false } + "lambert" -> MeshLambertMaterial().apply { + color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR + emissive = meta[SolidMaterial.EMISSIVE_COLOR_KEY]?.threeColor() ?: DEFAULT_EMISSIVE_COLOR + wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false + } + + "phong" -> MeshPhongMaterial().apply { + color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR + emissive = meta[SolidMaterial.EMISSIVE_COLOR_KEY]?.threeColor() ?: DEFAULT_EMISSIVE_COLOR + wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false + } + else -> MeshStandardMaterial().apply { color = meta[SolidMaterial.COLOR_KEY]?.threeColor() ?: DEFAULT_COLOR emissive = meta[SolidMaterial.EMISSIVE_COLOR_KEY]?.threeColor() ?: DEFAULT_EMISSIVE_COLOR @@ -83,7 +92,7 @@ public object ThreeMaterials { private val visionMaterialCache = HashMap() internal fun cacheMaterial(vision: Vision): Material = visionMaterialCache.getOrPut(vision) { - buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY)).apply { + buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]).apply { cached = true } } @@ -124,7 +133,7 @@ internal var Material.cached: Boolean public fun Mesh.setMaterial(vision: Vision) { if ( - vision.properties.own?.get(SolidMaterial.MATERIAL_KEY) == null + vision.properties.own[SolidMaterial.MATERIAL_KEY] == null && vision.getStyleNodes(SolidMaterial.MATERIAL_KEY).isEmpty() ) { //if this is a reference, use material of the prototype @@ -133,11 +142,11 @@ public fun Mesh.setMaterial(vision: Vision) { } else { material = vision.parent?.let { parent -> //TODO cache parent material - ThreeMaterials.buildMaterial(parent.properties.getMeta(SolidMaterial.MATERIAL_KEY)) + ThreeMaterials.buildMaterial(parent.properties[SolidMaterial.MATERIAL_KEY]) } ?: ThreeMaterials.cacheMaterial(vision) } } else { - material = ThreeMaterials.buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY)) + material = ThreeMaterials.buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]) } } @@ -153,18 +162,18 @@ public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) { when (propertyName) { SolidMaterial.MATERIAL_COLOR_KEY -> { material.asDynamic().color = - vision.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).threeColor() + vision.properties[SolidMaterial.MATERIAL_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.SPECULAR_COLOR_KEY -> { material.asDynamic().specular = - vision.properties.getMeta(SolidMaterial.SPECULAR_COLOR_KEY).threeColor() + vision.properties[SolidMaterial.SPECULAR_COLOR_KEY].threeColor() ?: ThreeMaterials.DEFAULT_COLOR } SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY -> { - material.asDynamic().emissive = vision.properties.getMeta(SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY) + material.asDynamic().emissive = vision.properties[SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY] .threeColor() ?: ThreeMaterials.BLACK_COLOR } diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt index 4ba19998..2e5fc0ca 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeMeshFactory.kt @@ -76,7 +76,7 @@ public fun Mesh.applyEdges(vision: Solid) { val edges = children.find { it.name == EDGES_OBJECT_NAME } as? LineSegments //inherited edges definition, enabled by default if (vision.properties.getValue(EDGES_ENABLED_KEY, inherit = false)?.boolean != false) { - val material = ThreeMaterials.getLineMaterial(vision.properties.getMeta(EDGES_MATERIAL_KEY), true) + val material = ThreeMaterials.getLineMaterial(vision.properties[EDGES_MATERIAL_KEY], true) if (edges == null) { add( LineSegments( diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt index 7051f887..c943668a 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt @@ -1,27 +1,38 @@ package space.kscience.visionforge.solid.three +import androidx.compose.runtime.Composable import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import org.jetbrains.compose.web.dom.DOMScope import org.w3c.dom.Element import org.w3c.dom.HTMLElement import space.kscience.dataforge.context.* import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.names.* -import space.kscience.visionforge.* +import space.kscience.visionforge.Vision +import space.kscience.visionforge.VisionChildren +import space.kscience.visionforge.VisionClient +import space.kscience.visionforge.html.ComposeHtmlVisionRenderer +import space.kscience.visionforge.html.ElementVisionRenderer +import space.kscience.visionforge.html.JsVisionClient import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.specifications.Canvas3DOptions -import space.kscience.visionforge.solid.three.set +import space.kscience.visionforge.solid.three.compose.ThreeView +import space.kscience.visionforge.visible import three.core.Object3D import kotlin.collections.set import kotlin.reflect.KClass import three.objects.Group as ThreeGroup -public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { +/** + * A plugin that handles Three Object3D representation of Visions. + */ +public class ThreePlugin : AbstractPlugin(), ComposeHtmlVisionRenderer { override val tag: PluginTag get() = Companion.tag public val solids: Solids by require(Solids) - public val client: VisionClient? get() = context.plugins.get() + public val client: VisionClient by require(JsVisionClient) private val objectFactories = HashMap, ThreeFactory<*>>() private val compositeFactory = ThreeCompositeFactory(this) @@ -37,17 +48,23 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { objectFactories[SolidLabel::class] = ThreeCanvasLabelFactory objectFactories[AmbientLightSource::class] = ThreeAmbientLightFactory objectFactories[PointLightSource::class] = ThreePointLightFactory - objectFactories[StlSolid::class] = ThreeStlFactory + objectFactories[StlUrlSolid::class] = ThreeStlFactory + objectFactories[StlBinarySolid::class] = ThreeStlFactory objectFactories[AxesSolid::class] = ThreeAxesFactory } @Suppress("UNCHECKED_CAST") - private fun findObjectFactory(type: KClass): ThreeFactory? { - return (objectFactories[type] - ?: context.gather>(ThreeFactory.TYPE).values.find { it.type == type }) + private fun findObjectFactory(type: KClass): ThreeFactory? = + (objectFactories[type] ?: context.gather>(ThreeFactory.TYPE).values.find { it.type == type }) as ThreeFactory? - } + /** + * Build an Object3D representation of the given [Solid]. + * + * @param vision [Solid] object to build a representation of; + * @param observe whether the constructed Object3D should be changed when the + * original [Vision] changes. + */ public suspend fun buildObject3D(vision: Solid, observe: Boolean = true): Object3D = when (vision) { is ThreeJsVision -> vision.render(this) is SolidReference -> ThreeReferenceFactory.build(this, vision, observe) @@ -63,7 +80,7 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { // disable tracking changes for statics group[token] = object3D } catch (ex: Throwable) { - logger.error(ex) { "Failed to render $child" } + logger.error(ex) { "Failed to render vision with token $token and type ${child::class}" } } } } @@ -103,7 +120,7 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { val object3D = buildObject3D(child) set(childName, object3D) } catch (ex: Throwable) { - logger.error(ex) { "Failed to render $child" } + logger.error(ex) { "Failed to render vision with name $childName" } } } }.launchIn(context) @@ -125,6 +142,16 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { private val canvasCache = HashMap() + /** + * Return a [ThreeCanvas] object attached to the given [Element]. + * If there is no canvas bound, a new canvas object is created + * and returned. + * + * @param element HTML element to which the canvas is + * (or should be if it is created by this call) attached; + * @param options canvas options that are applied to a newly + * created [ThreeCanvas] in case it does not exist. + */ public fun getOrCreateCanvas( element: Element, options: Canvas3DOptions, @@ -142,6 +169,21 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { override fun rateVision(vision: Vision): Int = if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING else ElementVisionRenderer.ZERO_RATING + override fun toString(): String = "ThreeJS" + + /** + * Render the given [Solid] Vision in a [ThreeCanvas] attached + * to the [element]. Canvas objects are cached, so subsequent calls + * with the same [element] value do not create new canvas objects, + * but they replace existing content, so multiple Visions cannot be + * displayed in a single [ThreeCanvas]. + * + * @param element HTML element [ThreeCanvas] should be + * attached to; + * @param vision Vision to render; + * @param options options that are applied to a canvas + * in case it is not in the cache and should be created. + */ internal fun renderSolid( element: Element, vision: Solid, @@ -150,12 +192,10 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { render(vision) } - override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { - renderSolid( - element, - vision as? Solid ?: error("Solid expected but ${vision::class} found"), - Canvas3DOptions.read(meta) - ) + @Composable + override fun DOMScope.render(name: Name, vision: Vision, meta: Meta) { + require(vision is Solid) { "Expected Solid but found ${vision::class}" } + ThreeView(context, vision, null, Canvas3DOptions.read(meta)) } public companion object : PluginFactory { @@ -165,6 +205,19 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { } } +/** + * Render the given [Solid] Vision in a [ThreeCanvas] attached + * to the [element]. Canvas objects are cached, so subsequent calls + * with the same [element] value do not create new canvas objects, + * but they replace existing content, so multiple Visions cannot be + * displayed in a single [ThreeCanvas]. + * + * @param element HTML element [ThreeCanvas] should be + * attached to; + * @param obj Vision to render; + * @param optionsBuilder option builder that is applied to a canvas + * in case it is not in the cache and should be created. + */ public fun ThreePlugin.render( element: HTMLElement, obj: Solid, @@ -207,4 +260,4 @@ internal fun Object3D.findChild(name: Name): Object3D? { name.length == 1 -> this.children.find { it.name == name.tokens.first().toString() } else -> findChild(name.tokens.first().asName())?.findChild(name.cutFirst()) } -} \ No newline at end of file +} diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt index e3fb676f..d8ba0a3a 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeStlFactory.kt @@ -16,7 +16,9 @@ fun ArrayBuffer.toByteArray(): ByteArray = Int8Array(this).unsafeCast public object ThreeStlFactory : ThreeMeshFactory(StlSolid::class) { private val loader = STLLoader().apply { - requestHeader = listOf("Access-Control-Allow-Origin: *") + requestHeader = listOf( + "Access-Control-Allow-Origin: *", + ) } override suspend fun buildGeometry(obj: StlSolid): BufferGeometry = when (obj) { @@ -25,6 +27,7 @@ public object ThreeStlFactory : ThreeMeshFactory(StlSolid::class) { loader.load( url = obj.url, onLoad = { + console.info("Loaded STL from ${obj.url}") continuation.resume(it) }, onError = { diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeControls.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeControls.kt new file mode 100644 index 00000000..a0211a1e --- /dev/null +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeControls.kt @@ -0,0 +1,69 @@ +package space.kscience.visionforge.solid.three.compose + +import androidx.compose.runtime.Composable +import app.softwork.bootstrapcompose.Button +import app.softwork.bootstrapcompose.Color.Info +import app.softwork.bootstrapcompose.Column +import app.softwork.bootstrapcompose.Layout.Height +import app.softwork.bootstrapcompose.Layout.Width +import org.jetbrains.compose.web.dom.Hr +import org.w3c.files.Blob +import org.w3c.files.BlobPropertyBag +import space.kscience.dataforge.names.Name +import space.kscience.visionforge.Vision +import space.kscience.visionforge.encodeToString +import space.kscience.visionforge.html.* +import space.kscience.visionforge.solid.specifications.Canvas3DOptions + +@Composable +internal fun CanvasControls( + vision: Vision?, + options: Canvas3DOptions, +) { + Column { + vision?.let { vision -> + Button("Export", color = Info, styling = { Layout.width = Width.Full }) { + val json = vision.encodeToString() + + val fileSaver = kotlinext.js.require("file-saver") + val blob = Blob(arrayOf(json), BlobPropertyBag("text/json;charset=utf-8")) + fileSaver.saveAs(blob, "${options.canvasName}.json") as Unit + } + } + Hr() + PropertyEditor( + properties = options.meta, + descriptor = Canvas3DOptions.descriptor, + expanded = false + ) + + } +} + + +@Composable +public fun ThreeControls( + vision: Vision?, + canvasOptions: Canvas3DOptions, + selected: Name?, + onSelect: (Name?) -> Unit, + tabBuilder: @Composable TabsBuilder.() -> Unit = {}, +) { + Tabs( + styling = { + Layout.height = Height.Full + } + ) { + vision?.let { vision -> + Tab("Tree") { + CardTitle("Vision tree") + VisionTree(vision, Name.EMPTY, selected, onSelect) + } + } + Tab("Settings") { + CardTitle("Canvas configuration") + CanvasControls(vision, canvasOptions) + } + tabBuilder() + } +} diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt new file mode 100644 index 00000000..2dbd1f48 --- /dev/null +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt @@ -0,0 +1,192 @@ +package space.kscience.visionforge.solid.three.compose + +import androidx.compose.runtime.* +import app.softwork.bootstrapcompose.Card +import app.softwork.bootstrapcompose.Column +import app.softwork.bootstrapcompose.Layout.Height +import app.softwork.bootstrapcompose.Layout.Width +import app.softwork.bootstrapcompose.Row +import kotlinx.dom.clear +import org.jetbrains.compose.web.css.* +import org.jetbrains.compose.web.dom.* +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.request +import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.isEmpty +import space.kscience.visionforge.html.* +import space.kscience.visionforge.root +import space.kscience.visionforge.solid.Solid +import space.kscience.visionforge.solid.SolidGroup +import space.kscience.visionforge.solid.specifications.Canvas3DOptions +import space.kscience.visionforge.solid.three.ThreeCanvas +import space.kscience.visionforge.solid.three.ThreePlugin +import space.kscience.visionforge.styles + +@Composable +private fun SimpleThreeView( + context: Context, + options: Canvas3DOptions?, + solid: Solid?, + selected: Name?, +) { + + Div({ + style { + maxWidth(100.vw) + maxHeight(100.vh) + width(100.percent) + height(100.percent) + } + }) { + var canvas: ThreeCanvas? by remember { mutableStateOf(null) } + DisposableEffect(options) { + canvas = ThreeCanvas(context.request(ThreePlugin), scopeElement, options ?: Canvas3DOptions()) + onDispose { + scopeElement.clear() + canvas = null + } + } + LaunchedEffect(solid) { + if (solid != null) { + canvas?.render(solid) + } else { + canvas?.clear() + } + } + LaunchedEffect(selected) { + canvas?.select(selected) + } + } +} + + +@Composable +public fun ThreeView( + context: Context, + solid: Solid?, + initialSelected: Name? = null, + options: Canvas3DOptions? = null, + sidebarTabs: @Composable TabsBuilder.() -> Unit = {}, +) { + var selected: Name? by remember { mutableStateOf(initialSelected) } + + val optionsSnapshot by derivedStateOf { + (options ?: Canvas3DOptions()).apply { + this.onSelect = { + selected = it + } + } + } + + if (optionsSnapshot.controls.enabled) { + + Row( + styling = { + Layout { + width = Width.Full + height = Height.Full + } + } + ) { + Column( + styling = { + Layout { + height = Height.Full + } + }, + attrs = { + style { + position(Position.Relative) + minWidth(600.px) + } + } + ) { + if (solid == null) { + Div({ classes("d-flex", "justify-content-center") }) { + Div({ + classes("spinner-border") + attr("role", "status") + }) { + Span({ classes("visually-hidden") }) { + Text("Loading...") + } + } + } + } else { + SimpleThreeView(context, optionsSnapshot, solid, selected) + } + + key(selected) { + selected?.let { + when { + it.isEmpty() -> solid + else -> (solid as? SolidGroup)?.get(it) + } + }?.let { vision -> + Card(attrs = { + style { + position(Position.Absolute) + top(10.px) + right(10.px) + width(450.px) + overflowY("auto") + } + }) { + NameCrumbs(selected) { selected = it } + Hr() + PropertyEditor( + rootMeta = vision.properties.root(), + getPropertyState = { name -> + if (vision.properties.own[name] != null) { + EditorPropertyState.Defined + } else if (vision.properties.root()[name] != null) { + // TODO differentiate + EditorPropertyState.Default() + } else { + EditorPropertyState.Undefined + } + }, + name = Name.EMPTY, + updates = vision.properties.changes, + rootDescriptor = vision.descriptor + ) + vision.styles.takeIf { it.isNotEmpty() }?.let { styles -> + Hr() + P { + B { Text("Styles: ") } + Text(styles.joinToString(separator = ", ")) + } + } + } + } + } + } + + Column( + auto = true, + styling = { + Layout { + height = Height.Full + } + }, + attrs = { + style { + paddingAll(4.px) + minWidth(400.px) + height(100.percent) + } + } + ) { + ThreeControls( + solid, + optionsSnapshot, + selected, + onSelect = { selected = it }, + tabBuilder = sidebarTabs + ) + } + } + } else { + SimpleThreeView(context, optionsSnapshot, solid, selected) + } +} \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/README.md b/visionforge-threejs/visionforge-threejs-server/README.md index 0b9d9e4e..3190b351 100644 --- a/visionforge-threejs/visionforge-threejs-server/README.md +++ b/visionforge-threejs/visionforge-threejs-server/README.md @@ -6,19 +6,8 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:visionforge-threejs-server:0.2.0`. +The Maven coordinates of this project are `space.kscience:visionforge-threejs-server:0.4.1`. -**Gradle Groovy:** -```groovy -repositories { - maven { url 'https://repo.kotlin.link' } - mavenCentral() -} - -dependencies { - implementation 'space.kscience:visionforge-threejs-server:0.2.0' -} -``` **Gradle Kotlin DSL:** ```kotlin repositories { @@ -27,6 +16,6 @@ repositories { } dependencies { - implementation("space.kscience:visionforge-threejs-server:0.2.0") + implementation("space.kscience:visionforge-threejs-server:0.4.1") } ``` diff --git a/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api b/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api index d2d708d9..8d46c793 100644 --- a/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api +++ b/visionforge-threejs/visionforge-threejs-server/api/visionforge-threejs-server.api @@ -1,6 +1,6 @@ public final class space/kscience/visionforge/three/ServerExtensionsKt { - public static final fun getThreeJsHeader (Lspace/kscience/visionforge/html/Page$Companion;)Lkotlin/jvm/functions/Function1; - public static final fun makeThreeJsFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;)V - public static synthetic fun makeThreeJsFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public static final fun getThreeJsHeader (Lspace/kscience/visionforge/html/VisionPage$Companion;)Lspace/kscience/visionforge/html/HtmlFragment; + public static final fun makeThreeJsFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLspace/kscience/visionforge/html/HtmlVisionFragment;)V + public static synthetic fun makeThreeJsFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLspace/kscience/visionforge/html/HtmlVisionFragment;ILjava/lang/Object;)V } diff --git a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts index 059f3784..3dbfacf4 100644 --- a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts +++ b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts @@ -1,29 +1,39 @@ + plugins { id("space.kscience.gradle.mpp") + alias(spclibs.plugins.compose) } val ktorVersion: String by rootProject.extra kscience { - fullStack("js/visionforge-three.js") { - commonWebpackConfig { - cssSupport { - enabled.set(false) + fullStack( + bundleName = "js/visionforge-three.js", + browserConfig = { + webpackTask { + cssSupport { + enabled = true + } + scssSupport { + enabled = true + } } } - } + ) - dependencies { + commonMain { api(projects.visionforgeSolid) + api(projects.visionforgeComposeHtml) } - dependencies(jvmMain) { + jvmMain { api(projects.visionforgeServer) } - dependencies(jsMain) { + jsMain { api(projects.visionforgeThreejs) - api(projects.ui.ring) - compileOnly(npm("webpack-bundle-analyzer","4.5.0")) + api(npm("file-saver", "2.0.5")) + api(npm("@types/file-saver", "2.0.7")) + compileOnly(npm("webpack-bundle-analyzer", "4.5.0")) } } \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt b/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt index d1635ddf..c0169f81 100644 --- a/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt +++ b/visionforge-threejs/visionforge-threejs-server/src/jsMain/kotlin/space/kscience/visionforge/three/jsMain.kt @@ -1,11 +1,11 @@ package space.kscience.visionforge.three import space.kscience.dataforge.misc.DFExperimental -import space.kscience.visionforge.ring.ThreeWithControlsPlugin -import space.kscience.visionforge.runVisionClient +import space.kscience.visionforge.html.runVisionClient +import space.kscience.visionforge.solid.three.ThreePlugin @DFExperimental public fun main(): Unit = runVisionClient { - plugin(ThreeWithControlsPlugin) + plugin(ThreePlugin) } \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js b/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js deleted file mode 100644 index b3cc4770..00000000 --- a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/01.ring.js +++ /dev/null @@ -1,23 +0,0 @@ -const ringConfig = require('@jetbrains/ring-ui/webpack.config').config; -const path = require('path'); - -config.module.rules.push(...ringConfig.module.rules) - -config.module.rules.push( - { - test: /\.css$/, - exclude: [ - path.resolve(__dirname, "../../node_modules/@jetbrains/ring-ui") - ], - use: [ - { - loader: 'style-loader', - options: {} - }, - { - loader: 'css-loader', - options: {} - } - ] - } -) \ No newline at end of file diff --git a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js b/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js deleted file mode 100644 index 947253ca..00000000 --- a/visionforge-threejs/visionforge-threejs-server/webpack.config.d/02.bundle.js +++ /dev/null @@ -1,10 +0,0 @@ -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -module.exports = { - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: "static", - reportFilename: "bundle-report.html" - }) - ] -} \ No newline at end of file