Skip to content

Commit

Permalink
reset to prior window state
Browse files Browse the repository at this point in the history
  • Loading branch information
YairLevi committed Jan 16, 2024
1 parent 7743c3f commit 193c0ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
10 changes: 2 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.9.22</kotlin.version>
<ktor_version>2.3.7</ktor_version>
<kotlin.version>1.8.21</kotlin.version>
</properties>

<repositories>
Expand All @@ -40,7 +39,7 @@
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
<descriptorRef>contained</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Expand Down Expand Up @@ -100,11 +99,6 @@
</build>

<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.9.3</version> <!-- Use the latest version -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
24 changes: 7 additions & 17 deletions src/main/kotlin/org/levi/coffee/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ package org.levi.coffee

import dev.webview.Webview
import org.levi.coffee.internal.CodeGenerator
import org.levi.coffee.internal.util.FileUtil
import org.levi.coffee.internal.MethodBinder
import org.levi.coffee.internal.util.FileUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import spark.Spark.staticFiles
import spark.Spark.init
import spark.Spark.stop
import java.util.Base64
import java.util.*
import java.util.function.Consumer
import kotlin.system.exitProcess

class Window (withDevTools: Boolean = true, val isDev: Boolean = false) {
class Window(dev: Boolean = true) {
private val log: Logger = LoggerFactory.getLogger(this::class.java)

private val _webview: Webview = Webview(withDevTools)
private val _webview: Webview = Webview(dev)
private val _beforeStartCallbacks: MutableList<Runnable> = ArrayList()
private val _onCloseCallbacks: MutableList<Runnable> = ArrayList()
private val _bindObjects: MutableList<Any> = ArrayList()
Expand Down Expand Up @@ -86,6 +83,7 @@ class Window (withDevTools: Boolean = true, val isDev: Boolean = false) {
_onCloseCallbacks.add(r)
}


fun run() {
CodeGenerator.generateEventsAPI()
CodeGenerator.generateTypes(*_bindObjects.toTypedArray())
Expand All @@ -95,17 +93,9 @@ class Window (withDevTools: Boolean = true, val isDev: Boolean = false) {
_beforeStartCallbacks.forEach(Consumer { it.run() })
Ipc.setWebview(_webview)

if (isDev) {
_webview.loadURL(_url)
}
else {
staticFiles.location("/dist")
_webview.loadURL("http://localhost:4567")
init()
}

_webview.loadURL(_url)
_webview.run()
stop()

_onCloseCallbacks.forEach(Consumer { it.run() })
_webview.close()
}
Expand Down

0 comments on commit 193c0ed

Please sign in to comment.