summaryrefslogtreecommitdiff
path: root/vendor/github.com/playwright-community/playwright-go/binding_call.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-31 16:09:12 -0600
committermo khan <mo@mokhan.ca>2025-07-31 16:09:12 -0600
commit311603d0c0b04d451e9fb8e5e8335dca8425e2c4 (patch)
treef38db8e10c4b55aef21c96c30fc71278c6e3d5c6 /vendor/github.com/playwright-community/playwright-go/binding_call.go
parentebb003ef2beaeee61104d6b88a342c5c9fa73b51 (diff)
Connect to postgresql
Diffstat (limited to 'vendor/github.com/playwright-community/playwright-go/binding_call.go')
-rw-r--r--vendor/github.com/playwright-community/playwright-go/binding_call.go87
1 files changed, 0 insertions, 87 deletions
diff --git a/vendor/github.com/playwright-community/playwright-go/binding_call.go b/vendor/github.com/playwright-community/playwright-go/binding_call.go
deleted file mode 100644
index 8468992..0000000
--- a/vendor/github.com/playwright-community/playwright-go/binding_call.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package playwright
-
-import (
- "fmt"
- "strings"
-
- "github.com/go-stack/stack"
-)
-
-type BindingCall interface {
- Call(f BindingCallFunction)
-}
-
-type bindingCallImpl struct {
- channelOwner
-}
-
-// BindingSource is the value passed to a binding call execution
-type BindingSource struct {
- Context BrowserContext
- Page Page
- Frame Frame
-}
-
-// ExposedFunction represents the func signature of an exposed function
-type ExposedFunction = func(args ...interface{}) interface{}
-
-// BindingCallFunction represents the func signature of an exposed binding call func
-type BindingCallFunction func(source *BindingSource, args ...interface{}) interface{}
-
-func (b *bindingCallImpl) Call(f BindingCallFunction) {
- defer func() {
- if r := recover(); r != nil {
- if _, err := b.channel.Send("reject", map[string]interface{}{
- "error": serializeError(r.(error)),
- }); err != nil {
- logger.Error("could not reject BindingCall", "error", err)
- }
- }
- }()
-
- frame := fromChannel(b.initializer["frame"]).(*frameImpl)
- source := &BindingSource{
- Context: frame.Page().Context(),
- Page: frame.Page(),
- Frame: frame,
- }
- var result interface{}
- if handle, ok := b.initializer["handle"]; ok {
- result = f(source, fromChannel(handle))
- } else {
- initializerArgs := b.initializer["args"].([]interface{})
- funcArgs := []interface{}{}
- for i := 0; i < len(initializerArgs); i++ {
- funcArgs = append(funcArgs, parseResult(initializerArgs[i]))
- }
- result = f(source, funcArgs...)
- }
- _, err := b.channel.Send("resolve", map[string]interface{}{
- "result": serializeArgument(result),
- })
- if err != nil {
- logger.Error("could not resolve BindingCall", "error", err)
- }
-}
-
-func serializeError(err error) map[string]interface{} {
- st := stack.Trace().TrimRuntime()
- if len(st) == 0 { // https://github.com/go-stack/stack/issues/27
- st = stack.Trace()
- }
- return map[string]interface{}{
- "error": &Error{
- Name: "Playwright for Go Error",
- Message: err.Error(),
- Stack: strings.ReplaceAll(strings.TrimFunc(fmt.Sprintf("%+v", st), func(r rune) bool {
- return r == '[' || r == ']'
- }), " ", "\n"),
- },
- }
-}
-
-func newBindingCall(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *bindingCallImpl {
- bt := &bindingCallImpl{}
- bt.createChannelOwner(bt, parent, objectType, guid, initializer)
- return bt
-}