mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(verifier): wire longPresses and scrolls generators
This commit is contained in:
1 parent
2397a65b9f
commit
dc0026ad37
3 files changed
+116
-50
No files matched your search
@@ -66,14 +66,16 @@ const (
|
||||
tagInternalKind = "__sanderlingKind"
|
||||
tagSelector = "__sanderlingSelector"
|
||||
|
||||
internalKindActions = "actions"
|
||||
internalKindWeighted = "weighted"
|
||||
internalKindBuiltinTaps = "taps"
|
||||
internalKindBuiltinDoubleTaps = "doubleTaps"
|
||||
internalKindBuiltinTyping = "typing"
|
||||
internalKindBuiltinSwipes = "swipes"
|
||||
internalKindBuiltinWaitOnce = "waitOnce"
|
||||
internalKindBuiltinPressKey = "pressKey"
|
||||
internalKindActions = "actions"
|
||||
internalKindWeighted = "weighted"
|
||||
internalKindBuiltinTaps = "taps"
|
||||
internalKindBuiltinDoubleTaps = "doubleTaps"
|
||||
internalKindBuiltinTyping = "typing"
|
||||
internalKindBuiltinSwipes = "swipes"
|
||||
internalKindBuiltinWaitOnce = "waitOnce"
|
||||
internalKindBuiltinPressKey = "pressKey"
|
||||
internalKindBuiltinLongPresses = "longPresses"
|
||||
internalKindBuiltinScrolls = "scrolls"
|
||||
)
|
||||
|
||||
// installRuntimeBindings exposes globalThis.__sanderling__ to the loaded spec.
|
||||
@@ -110,6 +112,12 @@ func (v *Verifier) installRuntimeBindings() error {
|
||||
if err := sanderling.Set("doubleTap", v.bindDoubleTap); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("longPress", v.bindLongPress); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("scroll", v.bindScroll); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("inputText", v.bindInputText); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -140,6 +148,12 @@ func (v *Verifier) installRuntimeBindings() error {
|
||||
if err := sanderling.Set("pressKeys", v.builtinGenerator(internalKindBuiltinPressKey)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("longPresses", v.builtinGenerator(internalKindBuiltinLongPresses)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sanderling.Set("scrolls", v.builtinGenerator(internalKindBuiltinScrolls)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return v.runtime.GlobalObject().Set("__sanderling__", sanderling)
|
||||
}
|
||||
@@ -425,6 +439,29 @@ func (v *Verifier) bindDoubleTap(call goja.FunctionCall) goja.Value {
|
||||
return handle
|
||||
}
|
||||
|
||||
func (v *Verifier) bindLongPress(call goja.FunctionCall) goja.Value {
|
||||
parameters := call.Argument(0).ToObject(v.runtime)
|
||||
if parameters == nil {
|
||||
panic(v.runtime.NewTypeError("LongPress requires {on}"))
|
||||
}
|
||||
handle := v.runtime.NewObject()
|
||||
_ = handle.Set("kind", "LongPress")
|
||||
_ = handle.Set("on", parameters.Get("on"))
|
||||
return handle
|
||||
}
|
||||
|
||||
func (v *Verifier) bindScroll(call goja.FunctionCall) goja.Value {
|
||||
parameters := call.Argument(0).ToObject(v.runtime)
|
||||
if parameters == nil {
|
||||
panic(v.runtime.NewTypeError("Scroll requires {direction}"))
|
||||
}
|
||||
handle := v.runtime.NewObject()
|
||||
_ = handle.Set("kind", "Scroll")
|
||||
_ = handle.Set("direction", parameters.Get("direction"))
|
||||
_ = handle.Set("in", parameters.Get("in"))
|
||||
return handle
|
||||
}
|
||||
|
||||
func (v *Verifier) bindInputText(call goja.FunctionCall) goja.Value {
|
||||
parameters := call.Argument(0).ToObject(v.runtime)
|
||||
if parameters == nil {
|
||||
|
||||
Reference in new issue
Block a user