add version call

This commit is contained in:
Alexander Wang 2024-09-04 12:20:16 -06:00 committed by Maricaya
parent 7dea1db40b
commit b3e79f7aa2
No known key found for this signature in database
GPG key ID: 91DA6031E30DE02F

View file

@ -17,6 +17,7 @@ import (
"oss.terrastruct.com/d2/d2oracle"
"oss.terrastruct.com/d2/d2parser"
"oss.terrastruct.com/d2/lib/urlenc"
"oss.terrastruct.com/d2/lib/version"
)
func main() {
@ -27,6 +28,7 @@ func main() {
js.Global().Set("d2Parse", js.FuncOf(jsParse))
js.Global().Set("d2Encode", js.FuncOf(jsEncode))
js.Global().Set("d2Decode", js.FuncOf(jsDecode))
js.Global().Set("d2Version", js.FuncOf(jsVersion))
initCallback := js.Global().Get("onWasmInitialized")
if !initCallback.IsUndefined() {
initCallback.Invoke()
@ -310,3 +312,7 @@ func jsDecode(this js.Value, args []js.Value) interface{} {
str, _ := json.Marshal(ret)
return string(str)
}
func jsVersion(this js.Value, args []js.Value) interface{} {
return version.Version
}