Update dependencies and add a text area to compile with my programming language compiler project

This commit is contained in:
Username404 2023-01-21 17:01:37 +01:00
parent 5a99a15ff3
commit 44da5cdacf
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
6 changed files with 109 additions and 33 deletions

View File

@ -1,9 +1,9 @@
plugins { plugins {
id("org.jetbrains.kotlin.js") version "1.6.0" id("org.jetbrains.kotlin.js") version "1.8.0"
} }
group = "fr.username404" group = "fr.username404"
version = "0.1" version = "1"
repositories { repositories {
mavenCentral() mavenCentral()
@ -12,7 +12,6 @@ repositories {
dependencies { dependencies {
implementation(kotlin("stdlib-js")) implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-html:${rootProject.property("kotlinx-html_version")}") implementation("org.jetbrains.kotlinx:kotlinx-html:${rootProject.property("kotlinx-html_version")}")
implementation("io.ktor:ktor-client-core:${rootProject.property("ktor_version")}")
} }
val outputDirectory = file("$rootDir/compiledOutput") val outputDirectory = file("$rootDir/compiledOutput")
@ -21,19 +20,17 @@ kotlin {
js(IR) { js(IR) {
moduleName = "Username404_Website" moduleName = "Username404_Website"
compilations.all { compilations.all {
with(languageSettings) { with(kotlinOptions) {
val secondDot = coreLibrariesVersion.let { it.indexOf('.', startIndex = it.indexOf('.') + 1) } val secondDot = coreLibrariesVersion.let { it.indexOf('.', startIndex = it.indexOf('.') + 1) }
apiVersion = coreLibrariesVersion.run { apiVersion = coreLibrariesVersion.run {
substring(0 until secondDot).also { println(it) } substring(0 until secondDot)
} }
languageVersion = apiVersion!!.substringBefore('.') + '.' + (apiVersion!!.substringAfter('.').toInt() + 1).toString() languageVersion = apiVersion!!.substringBefore('.') + '.' + (apiVersion!!.substringAfter('.').toInt() + 1).toString()
progressiveMode = true
}
with(kotlinOptions) {
moduleKind = "plain" moduleKind = "plain"
freeCompilerArgs = freeCompilerArgs + listOf( freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.js.ExperimentalJsExport", "-opt-in=kotlin.js.ExperimentalJsExport",
"-Xir-property-lazy-initialization" "-Xir-property-lazy-initialization"
) )
} }
@ -43,17 +40,17 @@ kotlin {
destinationDirectory = outputDirectory destinationDirectory = outputDirectory
output.library = "Web404" output.library = "Web404"
output.libraryTarget = "this" output.libraryTarget = "this"
cssSupport.enabled = true cssSupport { isEnabled = true }
} }
runTask { runTask {
cssSupport.enabled = true cssSupport { isEnabled = true }
} }
testTask { testTask {
useKarma { useKarma {
useFirefoxNightlyHeadless() useFirefoxNightlyHeadless()
webpackConfig.cssSupport.enabled = true webpackConfig.cssSupport { isEnabled = true }
} }
} }
} }

View File

@ -7,5 +7,4 @@ org.gradle.parallel=true
org.gradle.unsafe.configuration-cache=on org.gradle.unsafe.configuration-cache=on
org.gradle.vfs.watch=true org.gradle.vfs.watch=true
kotlinx-html_version=0.7.3 kotlinx-html_version=0.8.0+
ktor_version=1.6.5

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -1 +1,6 @@
rootProject.name = "Username404-Website" rootProject.name = "Username404-Website"
pluginManagement {
repositories {
gradlePluginPortal()
}
}

View File

@ -1,12 +1,92 @@
import kotlinx.browser.document import kotlinx.browser.document
import kotlinx.browser.window import kotlinx.browser.window
import kotlinx.html.*
import kotlinx.html.dom.append import kotlinx.html.dom.append
import kotlinx.html.js.div import kotlinx.html.js.div
import kotlinx.html.js.onClickFunction
import kotlinx.html.js.onKeyUpFunction
import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLTextAreaElement
import org.w3c.dom.get
external fun callMain(argument: Array<out String>)
fun ybcon(vararg argument: String) = callMain(argument)
val console get() = document.body!!.children["console"] as HTMLDivElement
private var typingTimer: Int = 0
const val typing_interval = 500
@JsExport @JsExport
fun makeBody() { fun makeConsole() {
document.body!!.append.div { with(document.body!!.append) {
// TODO Add elements to the body div {
id = "console"
style { unsafe { raw(
"""
#console {
position: relative;
display: none; filter: blur(0px);
transition: all 0.25s ease-in;
}
#console:hover { box-shadow: 0 0 50px #2f5361; }
#console, #input_box { border-bottom-left-radius: 10px; border-top-left-radius: 10px; }
#console, #output_box { border-bottom-right-radius: 10px; border-top-right-radius: 10px; }
textArea {
color: white;
border-color: #2f5361;
outline: none !important;
background: #2f5361;
font-family:"Noto Sans Mono SemiBold", Noto, mono;
width: 25vw; height: 50vh;
resize: none;
}
""".trimIndent()
) } }
script(src = "/ybcon.js") {} // Note: ybcon.js and ybcon.worker.js have to be available at this path on the server
textArea {
id = "input_box"
onKeyUpFunction = { event ->
window.clearTimeout(typingTimer)
ybcon("-t", (event.target!! as HTMLTextAreaElement).value)
typingTimer = window.setTimeout({
(console.children["output_box"] as HTMLTextAreaElement).value = js("yerbacon_output") as String
}, typing_interval)
}
}
textArea {
readonly = true
id = "output_box"
}
}
div {
style { unsafe {
raw("""
button {
position: fixed;
bottom: 10px;
right: 10px;
border: none;
background: inherit;
}
button:hover {
background: #2f5361;
}
""".trimIndent())
} }
button {
+ "Yerbacon programming language project"
onClickFunction = {
with(console.style) {
display = when (display) {
"none", "" -> "inline-block"
else -> "none"
}
}
}
}
}
} }
} }

View File

@ -9,12 +9,11 @@
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
<title>www.username404.fr</title> <title>www.username404.fr</title>
<style> <style>
html { html { scroll-behavior: smooth; }
scroll-behavior: smooth;
}
body { body {
text-align: center; text-align: center;
text-decoration-color: #868e96; text-decoration-color: #868e96;
color: #35b9ab;
font-family: 'Noto Sans', sans-serif; font-family: 'Noto Sans', sans-serif;
background: #173f4f; background: #173f4f;
} }
@ -22,13 +21,9 @@
position: fixed; position: fixed;
bottom: 10px; left: 10px; bottom: 10px; left: 10px;
} }
a { a, button { color: #21A4DF; }
color: #21A4DF; a { text-decoration: none; }
text-decoration: none; * { box-sizing: border-box; }
}
* {
box-sizing: border-box;
}
.mainBox { .mainBox {
font-size: xxx-large; font-size: xxx-large;
float: left; float: left;
@ -51,6 +46,6 @@
Source Source
</a> </a>
</div> </div>
<script>Web404.makeBody()</script> <script>Web404.makeConsole()</script>
</body> </body>
</html> </html>