Fix nodejs support.

This commit is contained in:
2023-09-05 15:55:05 -07:00
parent 24e8267449
commit ff1c275589
20 changed files with 250 additions and 35 deletions

View File

@ -6,18 +6,16 @@ enum class JsPlatformType {
Unknown;
companion object {
fun current(): JsPlatformType {
val isWindowAvailable = js("typeof window") != undefined
val isProcessAvailable = js("typeof process") != undefined
val current: JsPlatformType
get() {
val isWindowAvailable = js("typeof window") != undefined
val isProcessAvailable = js("typeof process") != undefined
if (isProcessAvailable) {
return Nodejs
return when {
isProcessAvailable -> Nodejs
isWindowAvailable -> Browser
else -> Unknown
}
}
if (isWindowAvailable) {
return Browser
}
return Unknown
}
}
}

View File

@ -2,8 +2,9 @@ package gay.pizza.dough.core
import gay.pizza.dough.core.time.ClockProvider
import gay.pizza.dough.core.time.UnixTime
import kotlin.js.Date
object StandardClockProvider : ClockProvider {
override fun now(): UnixTime =
UnixTime(js("(new Date()).getTime()") as Long)
UnixTime(Date().getTime().toLong())
}