summaryrefslogtreecommitdiff
path: root/vendor/github.com/playwright-community/playwright-go/channel_owner.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/channel_owner.go
parentebb003ef2beaeee61104d6b88a342c5c9fa73b51 (diff)
Connect to postgresql
Diffstat (limited to 'vendor/github.com/playwright-community/playwright-go/channel_owner.go')
-rw-r--r--vendor/github.com/playwright-community/playwright-go/channel_owner.go122
1 files changed, 0 insertions, 122 deletions
diff --git a/vendor/github.com/playwright-community/playwright-go/channel_owner.go b/vendor/github.com/playwright-community/playwright-go/channel_owner.go
deleted file mode 100644
index 5159eb2..0000000
--- a/vendor/github.com/playwright-community/playwright-go/channel_owner.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package playwright
-
-import (
- "sync"
-)
-
-type channelOwner struct {
- sync.RWMutex
- eventEmitter
- objectType string
- guid string
- channel *channel
- objects map[string]*channelOwner
- eventToSubscriptionMapping map[string]string
- connection *connection
- initializer map[string]interface{}
- parent *channelOwner
- wasCollected bool
- isInternalType bool
-}
-
-func (c *channelOwner) dispose(reason ...string) {
- // Clean up from parent and connection.
- if c.parent != nil {
- delete(c.parent.objects, c.guid)
- }
- c.connection.objects.Delete(c.guid)
- if len(reason) > 0 {
- c.wasCollected = reason[0] == "gc"
- }
-
- // Dispose all children.
- for _, object := range c.objects {
- object.dispose(reason...)
- }
- c.objects = make(map[string]*channelOwner)
-}
-
-func (c *channelOwner) adopt(child *channelOwner) {
- delete(child.parent.objects, child.guid)
- c.objects[child.guid] = child
- child.parent = c
-}
-
-func (c *channelOwner) setEventSubscriptionMapping(mapping map[string]string) {
- c.eventToSubscriptionMapping = mapping
-}
-
-func (c *channelOwner) updateSubscription(event string, enabled bool) {
- protocolEvent, ok := c.eventToSubscriptionMapping[event]
- if ok {
- c.channel.SendNoReplyInternal("updateSubscription", map[string]interface{}{
- "event": protocolEvent,
- "enabled": enabled,
- })
- }
-}
-
-func (c *channelOwner) Once(name string, handler interface{}) {
- c.addEvent(name, handler, true)
-}
-
-func (c *channelOwner) On(name string, handler interface{}) {
- c.addEvent(name, handler, false)
-}
-
-func (c *channelOwner) addEvent(name string, handler interface{}, once bool) {
- if c.ListenerCount(name) == 0 {
- c.updateSubscription(name, true)
- }
- c.eventEmitter.addEvent(name, handler, once)
-}
-
-func (c *channelOwner) RemoveListener(name string, handler interface{}) {
- c.eventEmitter.RemoveListener(name, handler)
- if c.ListenerCount(name) == 0 {
- c.updateSubscription(name, false)
- }
-}
-
-func (c *channelOwner) createChannelOwner(self interface{}, parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) {
- c.objectType = objectType
- c.guid = guid
- c.wasCollected = false
- c.parent = parent
- c.objects = make(map[string]*channelOwner)
- c.initializer = initializer
- if c.parent != nil {
- c.connection = parent.connection
- c.parent.objects[guid] = c
- }
- if c.connection != nil {
- c.connection.objects.Store(guid, c)
- }
- c.channel = newChannel(c, self)
- c.eventToSubscriptionMapping = map[string]string{}
-}
-
-func (c *channelOwner) markAsInternalType() {
- c.isInternalType = true
-}
-
-type rootChannelOwner struct {
- channelOwner
-}
-
-func (r *rootChannelOwner) initialize() (*Playwright, error) {
- ret, err := r.channel.SendReturnAsDict("initialize", map[string]interface{}{
- "sdkLanguage": "javascript",
- })
- if err != nil {
- return nil, err
- }
- return fromChannel(ret["playwright"]).(*Playwright), nil
-}
-
-func newRootChannelOwner(connection *connection) *rootChannelOwner {
- c := &rootChannelOwner{}
- c.connection = connection
- c.createChannelOwner(c, nil, "Root", "", make(map[string]interface{}))
- return c
-}