fix: visibility

This commit is contained in:
orion 2023-11-06 16:51:05 -06:00
parent 33c0299bb8
commit 5db9c3e5b0
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -1,4 +1,15 @@
module Puppeteer.Mouse where module Puppeteer.Mouse
( MouseButton(..)
, scroll
, down
, up
, moveTo
, click
, MouseWheelOptions
, MouseMoveOptions
, MouseOptions
, MouseClickOptions
) where
import Prelude import Prelude
@ -30,16 +41,16 @@ type MouseMoveOptions r = (steps :: Number | r)
type MouseOptions r = (button :: MouseButton | r) type MouseOptions r = (button :: MouseButton | r)
type MouseClickOptions r = (count :: Int, delay :: Number | MouseOptions r) type MouseClickOptions r = (count :: Int, delay :: Number | MouseOptions r)
foreign import scrollImpl :: Mouse -> { deltaX :: Number, deltaY :: Number } -> Effect (Promise Unit) foreign import scrollImpl :: Mouse -> {deltaX :: Number, deltaY :: Number} -> Effect (Promise Unit)
foreign import clickImpl :: Mouse -> { x :: Number, y :: Number } -> { button :: String, count :: Int, delay :: Number } -> Effect (Promise Unit) foreign import clickImpl :: Mouse -> {x :: Number, y :: Number} -> {button :: String, count :: Int, delay :: Number} -> Effect (Promise Unit)
foreign import downImpl :: Mouse -> String -> Effect (Promise Unit) foreign import downImpl :: Mouse -> String -> Effect (Promise Unit)
foreign import upImpl :: Mouse -> String -> Effect (Promise Unit) foreign import upImpl :: Mouse -> String -> Effect (Promise Unit)
foreign import moveImpl :: Mouse -> { x :: Number, y :: Number } -> { steps :: Number } -> Effect (Promise Unit) foreign import moveImpl :: Mouse -> {x :: Number, y :: Number} -> {steps :: Number} -> Effect (Promise Unit)
scroll :: forall options missing. Union options missing (MouseWheelOptions ()) => Union options (MouseWheelOptions ()) (MouseWheelOptions ()) => Record options -> Mouse -> Aff Unit scroll :: forall options missing. Union options missing (MouseWheelOptions ()) => Union options (MouseWheelOptions ()) (MouseWheelOptions ()) => Record options -> Mouse -> Aff Unit
scroll options mouse = Promise.toAffE scroll options mouse = Promise.toAffE
$ scrollImpl mouse $ scrollImpl mouse
$ Record.merge options { deltaX: 0.0, deltaY: 0.0 } $ Record.merge options {deltaX: 0.0, deltaY: 0.0}
down :: MouseButton -> Mouse -> Aff Unit down :: MouseButton -> Mouse -> Aff Unit
down btn mouse = Promise.toAffE $ downImpl mouse (mouseButtonToString btn) down btn mouse = Promise.toAffE $ downImpl mouse (mouseButtonToString btn)
@ -47,29 +58,25 @@ down btn mouse = Promise.toAffE $ downImpl mouse (mouseButtonToString btn)
up :: MouseButton -> Mouse -> Aff Unit up :: MouseButton -> Mouse -> Aff Unit
up btn mouse = Promise.toAffE $ upImpl mouse (mouseButtonToString btn) up btn mouse = Promise.toAffE $ upImpl mouse (mouseButtonToString btn)
moveTo moveTo :: forall options missing fullU. Nub fullU (MouseMoveOptions ())
:: forall options missing fullU => Union options missing (MouseMoveOptions ())
. Nub fullU (MouseMoveOptions ()) => Union options (MouseMoveOptions ()) fullU
=> Union options missing (MouseMoveOptions ()) => Record options
=> Union options (MouseMoveOptions ()) fullU -> Mouse
=> Record options -> {x :: Number, y :: Number}
-> Mouse -> Aff Unit
-> { x :: Number, y :: Number }
-> Aff Unit
moveTo opts mouse xy = Promise.toAffE moveTo opts mouse xy = Promise.toAffE
$ moveImpl mouse xy $ moveImpl mouse xy
$ Record.merge opts { steps: 1.0 } $ Record.merge opts {steps: 1.0}
click click :: forall options missing fullU. Nub fullU (MouseClickOptions ())
:: forall options missing fullU => Union options missing (MouseClickOptions ())
. Nub fullU (MouseClickOptions ()) => Union options (MouseClickOptions ()) fullU
=> Union options missing (MouseClickOptions ()) => Record options
=> Union options (MouseClickOptions ()) fullU -> Mouse
=> Record options -> {x :: Number, y :: Number}
-> Mouse -> Aff Unit
-> { x :: Number, y :: Number }
-> Aff Unit
click opts mouse xy = Promise.toAffE click opts mouse xy = Promise.toAffE
$ clickImpl mouse xy $ clickImpl mouse xy
$ Record.modify (Proxy @"button") mouseButtonToString $ Record.modify (Proxy @"button") mouseButtonToString
$ Record.merge opts { button: MouseLeft, count: 1, delay: 0.0 } $ Record.merge opts {button: MouseLeft, count: 1, delay: 0.0}