Initial, working but only with viewport height adjusted a little bit

This commit is contained in:
2026-03-28 16:12:33 +01:00
commit 7d94dee26b
16 changed files with 857 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package bridge
import (
"encoding/json"
"maps"
"math/rand"
)
type CommandType string
const (
ContinueCommand CommandType = "continue"
BreakCommand CommandType = "break"
LocalsCommand CommandType = "locals"
)
func makeCommand(cmd CommandType, values map[string]any) (requestId string, request string) {
m := make(map[string]any, len(values)+2)
maps.Copy(m, values)
requestId = randString(8)
m["cmd"] = cmd
m["request_id"] = requestId
b, err := json.Marshal(m)
if err != nil {
panic("failed to marshal command " + err.Error())
}
return requestId, string(b)
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func randString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}