@@ -1,38 +1,48 @@
11module Playwright
22 ( launch
3+ , close
34 , contexts
45 , isConnected
56 , version
6− , close
77 , newPage
8+ , goForward
9+ , goBack
810 , goto
11+ , addCookies
12+ , hover
13+ , innerHTML
14+ , innerText
15+ , isClosed
16+ , keyboard
17+ , mainFrame
18+ , name
919 , query
1020 , queryMany
1121 , screenshot
1222 , textContent
23+ , url
1324 , module Playwright.Data
1425 , module Playwright.Options
1526 )
1627where
1728
18−import Prelude
1929import Effect (Effect)
20−-- import Control.Promise (toAffE)
2130import Effect.Aff (Aff)
22−import Untagged.Coercible (class Coercible, coerce)
23−import Untagged.Union (type (|+|), UndefinedOr)
31+import Literals.Null (Null)
2432import Node.Buffer (Buffer)
2533import Playwright.Data
26−import Playwright.Options
2734import Playwright.Internal (effCall, effProp, affCall)
28−import Literals.Null (Null)
35+import Playwright.Options
36+import Prelude
37+import Untagged.Coercible (class Coercible)
38+import Untagged.Union (type (|+|), UndefinedOr)
2939
3040launch
3141 :: forall o
3242 . Coercible o LaunchOptions
3343 => BrowserType -> o -> Aff Browser
3444launch bt opts =
35− affCall "launch" typeInfo bt (coerce opts :: LaunchOptions)
45+ affCall "launch" typeInfo bt opts
3646 where
3747 typeInfo _ = launch
3848
@@ -62,14 +72,14 @@ newPage
6272 => x -> o -> Aff Page
6373newPage sth opts =
6474 affCall "newPage" typeInfo sth opts
65− where typeInfo _ = newPage :: x -> o -> Aff Page
75+ where typeInfo _ = newPage
6676
6777goForward
6878 :: forall o
6979 . Coercible o GoOptions
7080 => Page -> o -> Aff (Null |+| Response)
7181goForward page opts =
72− affCall "goForward" typeInfo page (coerce opts :: GoOptions)
82+ affCall "goForward" typeInfo page opts
7383 where typeInfo _ = goForward
7484
7585goBack
@@ -77,7 +87,7 @@ goBack
7787 . Coercible o GoOptions
7888 => Page -> o -> Aff (Null |+| Response)
7989goBack page opts =
80− affCall "goBack" typeInfo page (coerce opts :: GoOptions)
90+ affCall "goBack" typeInfo page opts
8191 where typeInfo _ = goBack
8292
8393goto
@@ -86,7 +96,7 @@ goto
8696 => Coercible o GotoOptions
8797 => x -> URL -> o -> Aff (Null |+| Response)
8898goto x url' opts =
89− affCall "goto" typeInfo x url' (coerce opts :: GotoOptions)
99+ affCall "goto" typeInfo x url' opts
90100 where typeInfo _ = goto
91101
92102type Cookie =
@@ -101,8 +111,7 @@ addCookies
101111 -> Aff Unit
102112addCookies bc cookies =
103113 affCall "addCookies" typeInfo bc cookies
104− where
105− typeInfo _ = addCookies
114+ where typeInfo _ = addCookies
106115
107116hover
108117 :: forall x o
@@ -118,8 +127,8 @@ innerHTML
118127 . Coercible x (Page |+| Frame |+| ElementHandle)
119128 => Coercible o InnerHTMLOptions
120129 => x -> Selector -> o -> Aff String
121−innerHTML x selector o =
122− affCall "innerHTML" typeInfo x selector (coerce o :: InnerHTMLOptions)
130+innerHTML x selector opts =
131+ affCall "innerHTML" typeInfo x selector opts
123132 where typeInfo _ = innerHTML
124133
125134innerText
@@ -130,10 +139,9 @@ innerText
130139 -> Selector
131140 -> o
132141 -> Aff String
133−innerText x sel o =
134− affCall "innerText" typeInfo x sel o
135− where typeInfo _ = innerText
136− :: x -> Selector -> o -> Aff String
142+innerText x sel opts =
143+ affCall "innerText" typeInfo x sel opts
144+ where typeInfo _ = innerText :: x -> Selector -> o -> Aff String
137145
138146isClosed :: Page -> Effect Boolean
139147isClosed = effCall "isClosed" \_ -> isClosed
@@ -141,6 +149,12 @@ isClosed = effCall "isClosed" \_ -> isClosed
141149keyboard :: Page -> Effect Keyboard
142150keyboard = effProp "keyboard"
143151
152+mainFrame :: Page -> Effect Frame
153+mainFrame = effCall "mainFrame" \_ -> mainFrame
154+
155+name :: Frame -> Effect String
156+name = effCall "name" \_ -> name
157+
144158-- | `sth.$(selector)`
145159query
146160 :: forall x
@@ -180,6 +194,6 @@ url
180194 :: forall x
181195 . Coercible x (Page |+| Frame |+| Download |+| Request |+| Response |+| Worker)
182196 => x
183− -> Effect String
184−url = effCall "url" typeInfo
185− where typeInfo _ = url :: x -> Effect String
197+ -> Effect URL
198+url x = effCall "url" typeInfo x
199+ where typeInfo _ = url