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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions .github/workflows/deploy_maven_central.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
#
#name: deploy maven central
#
#on:
# push:
# workflow_dispatch:
#
#jobs:
# test:
# if: github.ref != 'refs/heads/main'
# uses: ./.github/workflows/test.yml
# cd:
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
# - name: Import GPG key
# uses: crazy-max/ghaction-import-gpg@v5
# with:
# gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
# - name: Set up Java
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
# - name: Make gradlew executable
# run: chmod +x ./gradlew
# - name: Validate Gradle wrapper
# uses: gradle/wrapper-validation-action@v1
# - name: Publish package
# uses: gradle/gradle-build-action@v2
# with:
# arguments: |
# -PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }}
# -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }}
# -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }}
# -PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }}
# allTests publishAndReleaseToMavenCentral
# env:
# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
######

name: deploy maven central

on:
push:
workflow_dispatch:

jobs:
test:
if: github.ref != 'refs/heads/main'
uses: ./.github/workflows/test.yml
cd:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: |
-PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }}
-PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }}
-PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }}
-PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }}
allTests publishAndReleaseToMavenCentral
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
#####
128 changes: 128 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# hakate

## About

* A state managing library for kotlin
* It can manage state with dependency

### repository

* https://central.sonatype.com/artifact/net.kigawa/hakate

## Using

### Requirement

* kotlin
* jvm
* js

### Getting Started

#### 1. add to dependency

pom.xml

```pom.xml
<dependency>
<groupId>net.kigawa</groupId>
<artifactId>renlin</artifactId>
<version>{version}</version>
</dependency>
```

build.gradle.kts

```build.gradle.kts
implementation("net.kigawa:renlin:{version}")
```

#### 2. write the code

write a root component
```kotlin
class SampleComponent(
val name: String,
val sub: Sub,
) {
val root = div.component {
t("test root")

// call subcomponent
sub.display {
}

fragment {
div {
fragment {
p {
t("text")
}
}
}
}
sub.controller {
}
}
}

```

write a subcomponent
```kotlin
class Sub(
dispatcher: StateDispatcher,
) {
val state: MutableState<String> = dispatcher.newState("state")

val display = div.component {
t("display")
div {
val value = state.useValue()
t("display1")
div {
t("display1-1")
p {
t("display1-1-1 $value")
}
}
}
}
val controller = div.component {
t("controller")
}
// fragment component
val test = fragment<FlowContent>().component { }
val test1 = fragment<PhrasingContent>().component { }
val test2 = fragment<FlowPhrasingIntersection>().component { }
}
```

set state
```kotlin
state.set("new value")
```

init endpoint
```kotlin
val root = document.getElementById("root") ?: throw Exception("Root not found")
val sub = Sub()
val sample = SampleComponent("sample", sub)
val dispatcher = HakateInitializer().newStateDispatcher()
Entrypoint(root).render(sample.root, dispatcher)
```

## Author

* kigawa
* [email protected]

# Making

## Version

### Example: 9.1.2

* **9**: major, destructive
* **1**: miner, new function
* **2**: miner, bug fix
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kotlin-version = "2.1.0"
coroutines-version = "1.9.0"
coroutines-test-version = "1.10.1"
datetime-version = "0.6.1"
hakate-version = "3.3.0"
nexus-publish = "2.0.0-rc-1"
dokka = "1.9.20"
vanniktech-maven-publish = "0.29.0"
Expand All @@ -14,12 +15,11 @@ kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines-version" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines-test-version" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "datetime-version" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-version" }
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }
hakate = { module = "net.kigawa:hakate", version.ref = "hakate-version" }


[plugins]
sonatype-central-upload = { id = "cl.franciscosolis.sonatype-central-upload", version = "1.0.3" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-version" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-maven-publish" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
1 change: 1 addition & 0 deletions renlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ kotlin {
sourceSets["commonMain"].dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlin.stdlib)
implementation(libs.hakate)
}
sourceSets["commonTest"].dependencies {
implementation(kotlin("test-common"))
Expand Down
5 changes: 5 additions & 0 deletions renlin/src/commonMain/kotlin/net/kigawa/renlin/Noting.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.kigawa.renlin

import net.kigawa.renlin.category.ContentCategory

interface NotingContent: ContentCategory
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.kigawa.renlin.category

interface ContentCategory {
// fun newContentDsl(): DSL
// fun component(
// block: DSL.() -> Unit,
// ): Component1<Fragment<DSL>, EmptyDsl> {
// return object : FragmentComponent<DSL>() {
// override fun newDsl(): DSL {
// return newContentDsl()
// }
// }.component(block)
// }
}

interface AllContentCategory : ContentCategory, FlowContent, PhrasingContent, FlowPhrasingIntersection
interface DslContentCategory<CATEGORY_DSL : DslContentCategory<CATEGORY_DSL>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.kigawa.renlin.category

import net.kigawa.renlin.Html
import net.kigawa.renlin.dsl.Dsl


interface FlowContent : ContentCategory {
// override fun newContentDsl(): FlowContentDsl {
// return FragmentDsl()
// }
}

@Html
interface FlowContentDsl<CATEGORY_DSL : FlowContent> :
Dsl<CATEGORY_DSL> {

// fun fragment(block: FlowContentDsl.() -> Unit) {
// object : FragmentComponent<FlowContentDsl>() {
// override fun newDsl(): FlowContentDsl {
// return FragmentDsl()
// }
// }.render(this, block)
// }
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.kigawa.renlin.category

interface FlowPhrasingIntersection : FlowContent, PhrasingContent {}
interface FlowPhrasingDsl<CATEGORY_DSL : FlowPhrasingIntersection> :
FlowContentDsl<CATEGORY_DSL>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.kigawa.renlin.category

import net.kigawa.renlin.dsl.Dsl
import net.kigawa.renlin.tag.text


interface PhrasingContent : ContentCategory


fun <CONTENT_CATEGORY : PhrasingContent> Dsl<CONTENT_CATEGORY>.t(str: String, key: String? = null) {
text.render(this) {
[email protected] = key
[email protected] = str
}
}
23 changes: 20 additions & 3 deletions renlin/src/commonMain/kotlin/net/kigawa/renlin/dsl/Dsl.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
package net.kigawa.renlin.dsl

import net.kigawa.hakate.api.state.State
import net.kigawa.renlin.Html
import net.kigawa.renlin.element.TagElement
import net.kigawa.renlin.category.ContentCategory
import net.kigawa.renlin.dsl.state.DslState
import net.kigawa.renlin.element.TagNode
import net.kigawa.renlin.tag.Fragment
import net.kigawa.renlin.tag.Tag
import net.kigawa.renlin.tag.component.SubComponent

@Html
interface Dsl {
val element: TagElement
interface Dsl<CONTENT_CATEGORY : ContentCategory> {
var key: String?
var dslState: DslState?
fun subDsl(registeredDslData: RegisteredDslData)
fun mountDslState(state: DslState, registeredDslData: RegisteredDslData)
fun applyElement(element: TagNode)
val states: Set<State<*>>
operator fun <TAG : Tag<in CONTENT_CATEGORY>, DSL : Dsl<*>> SubComponent<TAG, DSL>.invoke(block: DSL.() -> Unit) =
this.render(this@Dsl, block)

val fragment: SubComponent<Tag<CONTENT_CATEGORY>, out Dsl<CONTENT_CATEGORY>>
get() = Fragment.create<CONTENT_CATEGORY>()

fun <T> State<T>.useValue(): T
}
Loading