@@ -17,31 +17,31 @@ where
1717
1818import Prelude
1919import Effect (Effect)
20−import Control.Promise (toAffE)
20+-- import Control.Promise (toAffE)
2121import Effect.Aff (Aff)
2222import Untagged.Coercible (class Coercible, coerce)
23−import Untagged.Union (type (|+|))
23+import Untagged.Union (type (|+|), UndefinedOr)
2424import Node.Buffer (Buffer)
2525import Playwright.Data
2626import Playwright.Options
27−import Playwright.Internal (effCall, effProp)
27+import Playwright.Internal (effCall, effProp, affCall)
28+import Literals.Null (Null)
2829
2930launch
3031 :: forall o
3132 . Coercible o LaunchOptions
3233 => BrowserType -> o -> Aff Browser
3334launch bt opts =
34− toAffE $ effCall "launch" typeInfo bt (coerce opts :: LaunchOptions)
35+ affCall "launch" typeInfo bt (coerce opts :: LaunchOptions)
3536 where
36− typeInfo _ = launch :: BrowserType -> o -> Aff Browser
37+ typeInfo _ = launch
3738
3839close
3940 :: forall x
4041 . Coercible x (Browser |+| BrowserContext |+| Page)
4142 => x -> Aff Unit
4243close x =
43− toAffE $ effCall "close" typeInfo x
44− where typeInfo _ = close :: x -> Aff Unit
44+ affCall "close" (\_ -> close) x
4545
4646contexts :: Browser -> Effect (Array BrowserContext)
4747contexts =
@@ -61,7 +61,7 @@ newPage
6161 => Coercible o NewpageOptions
6262 => x -> o -> Aff Page
6363newPage sth opts =
64− toAffE $ effCall "newPage" typeInfo sth (coerce opts :: NewpageOptions)
64+ affCall "newPage" typeInfo sth opts
6565 where typeInfo _ = newPage :: x -> o -> Aff Page
6666
6767goForward
@@ -69,16 +69,16 @@ goForward
6969 . Coercible o GoOptions
7070 => Page -> o -> Aff (Null |+| Response)
7171goForward page opts =
72− toAffE $ effCall "goForward" typeInfo page (coerce opts :: GoOptions)
73− where typeInfo _ = goForward :: Page -> o -> Aff (Null |+| Response)
72+ affCall "goForward" typeInfo page (coerce opts :: GoOptions)
73+ where typeInfo _ = goForward
7474
7575goBack
7676 :: forall o
7777 . Coercible o GoOptions
7878 => Page -> o -> Aff (Null |+| Response)
7979goBack page opts =
80− toAffE $ effCall "goBack" typeInfo page (coerce opts :: GoOptions)
81− where typeInfo _ = goBack :: Page -> o -> Aff (Null |+| Response)
80+ affCall "goBack" typeInfo page (coerce opts :: GoOptions)
81+ where typeInfo _ = goBack
8282
8383goto
8484 :: forall x o
@@ -86,8 +86,23 @@ goto
8686 => Coercible o GotoOptions
8787 => x -> URL -> o -> Aff (Null |+| Response)
8888goto x url' opts =
89− toAffE $ effCall "goto" typeInfo x url' (coerce opts :: GotoOptions)
90− where typeInfo _ = goto :: x -> URL -> o -> Aff (Null |+| Response)
89+ affCall "goto" typeInfo x url' (coerce opts :: GotoOptions)
90+ where typeInfo _ = goto
91+
92+type Cookie =
93+ { name :: String
94+ , value :: String
95+ , url :: UndefinedOr String
96+ }
97+
98+addCookies
99+ :: BrowserContext
100+ -> Array Cookie
101+ -> Aff Unit
102+addCookies bc cookies =
103+ affCall "addCookies" typeInfo bc cookies
104+ where
105+ typeInfo _ = addCookies
91106
92107hover
93108 :: forall x o
@@ -95,7 +110,7 @@ hover
95110 => Coercible o HoverOptions
96111 => x -> o -> Aff Unit
97112hover sth opts =
98− toAffE $ effCall "hover" typeInfo sth (coerce opts :: HoverOptions)
113+ affCall "hover" typeInfo sth opts
99114 where typeInfo _ = hover :: x -> o -> Aff Unit
100115
101116innerHTML
@@ -104,12 +119,8 @@ innerHTML
104119 => Coercible o InnerHTMLOptions
105120 => x -> Selector -> o -> Aff String
106121innerHTML x selector o =
107− toAffE $ effCall "innerHTML" typeInfo x selector (coerce o :: InnerHTMLOptions)
122+ affCall "innerHTML" typeInfo x selector (coerce o :: InnerHTMLOptions)
108123 where typeInfo _ = innerHTML
109− :: x
110− -> Selector
111− -> o
112− -> Aff String
113124
114125innerText
115126 :: forall x o
@@ -120,7 +131,7 @@ innerText
120131 -> o
121132 -> Aff String
122133innerText x sel o =
123− toAffE $ effCall "innerText" typeInfo x sel o
134+ affCall "innerText" typeInfo x sel o
124135 where typeInfo _ = innerText
125136 :: x -> Selector -> o -> Aff String
126137
@@ -135,8 +146,8 @@ query
135146 :: forall x
136147 . Coercible x (ElementHandle |+| Page |+| Frame)
137148 => x -> Selector -> Aff ElementHandle
138−query x sel =
139− toAffE $ effCall "$" typeInfo x sel
149+query x =
150+ affCall "$" typeInfo x
140151 where typeInfo _ = query :: x -> Selector -> Aff ElementHandle
141152
142153-- | `sth.$$(selector)`
@@ -144,8 +155,8 @@ queryMany
144155 :: forall x
145156 . Coercible x (ElementHandle |+| Page |+| Frame)
146157 => x -> Selector -> Aff (Array ElementHandle)
147−queryMany sth sel =
148− toAffE $ effCall "$$" typeInfo sth sel
158+queryMany sth =
159+ affCall "$$" typeInfo sth
149160 where typeInfo _ = queryMany :: x -> Selector -> Aff (Array ElementHandle)
150161
151162screenshot
@@ -154,16 +165,16 @@ screenshot
154165 => Coercible o ScreenshotOptions
155166 => x -> o -> Aff Buffer
156167screenshot x o =
157− toAffE $ effCall "screenshot" typeInfo x (coerce o :: ScreenshotOptions)
158− where typeInfo _ = screenshot :: x -> o -> Aff Buffer
168+ affCall "screenshot" typeInfo x o
169+ where typeInfo _ = screenshot
159170
160171textContent
161172 :: forall x
162173 . Coercible x (Page |+| Frame |+| ElementHandle)
163174 => x -> Selector -> Aff (Null |+| String)
164−textContent x sel =
165− toAffE $ effCall "textContent" typeInfo x sel
166− where typeInfo _ = textContent :: x -> Selector -> Aff (Null |+| String)
175+textContent x =
176+ affCall "textContent" typeInfo x
177+ where typeInfo _ = textContent
167178
168179url
169180 :: forall x