add version call

This commit is contained in:
Alexander Wang 2024-09-04 12:20:16 -06:00
parent 6016c7e6d9
commit 4550117025
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927

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
}