com.jtransc.debugger.v8.node.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransc-debugger Show documentation
Show all versions of jtransc-debugger Show documentation
JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.
package com.jtransc.debugger.v8
import com.jtransc.async.Promise
import com.jtransc.debugger.JTranscDebugger
import com.jtransc.io.ProcessUtils
import com.jtransc.net.SocketUtils
import java.io.File
object NodeJS {
// node --debug-brk=9222 test.js
fun debugAsync(js: File, handler: ProcessUtils.ProcessHandler): Int {
val port = SocketUtils.getFreePort()
ProcessUtils.runAsync(js.parentFile, "node", listOf("--debug-brk=$port", js.absolutePath), handler)
return port
}
fun runAsync(js: File, handler: ProcessUtils.ProcessHandler): Unit {
ProcessUtils.runAsync(js.parentFile, "node", listOf(js.absolutePath), handler)
}
fun debug2Async(js: File, processHandler: ProcessUtils.ProcessHandler, debuggerHandler: JTranscDebugger.EventHandler): Promise {
val deferred = Promise.Deferred()
var done = false
var error = ""
var port = 0
port = NodeJS.debugAsync(js, object : ProcessUtils.ProcessHandler(processHandler) {
override fun onErrorData(data: String) {
super.onErrorData(data)
if (!done) {
error += data
if (error.contains("Debugger listening")) {
done = true
deferred.resolve(V8JTranscDebugger(port, "127.0.0.1", debuggerHandler))
}
}
}
})
return deferred.promise
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy