Skip to content

Commit

Permalink
Merge pull request #26 from Cmdv/add-foreign-for-chrome-aws
Browse files Browse the repository at this point in the history
add the ability for user to use Chrome AWS's version of puppeteer
  • Loading branch information
justinwoo committed Mar 10, 2021
2 parents 37a8bd7 + 48ceeee commit f7512a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Toppoki.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ exports._launch = function(options) {
};
};

exports._launchChromeAWS = function(chromium, options) {
return function() {
return chromium.puppeteer.launch(options);
};
};

exports._newPage = function(browser) {
return function() {
return browser.newPage();
Expand Down
12 changes: 12 additions & 0 deletions src/Toppoki.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ foreign import data Browser :: Type
foreign import data Page :: Type
foreign import data ElementHandle :: Type

-- This is used when one wants to use chrome-aws-lambda version of puppeteer
foreign import data ChromeAWS :: Type

newtype URL = URL String
derive instance newtypeURL :: Newtype URL _

Expand Down Expand Up @@ -60,6 +63,14 @@ launch
-> Aff Browser
launch = runPromiseAffE1 _launch

launchChromeAWS
:: forall options trash
. Row.Union options trash LaunchOptions
=> ChromeAWS
-> { | options }
-> Aff Browser
launchChromeAWS = runPromiseAffE2 _launchChromeAWS

newPage :: Browser -> Aff Page
newPage = runPromiseAffE1 _newPage

Expand Down Expand Up @@ -298,6 +309,7 @@ bringToFront = runPromiseAffE1 _bringToFront

foreign import puppeteer :: Puppeteer
foreign import _launch :: forall options. FU.Fn1 options (Effect (Promise Browser))
foreign import _launchChromeAWS :: forall options. FU.Fn2 ChromeAWS options (Effect (Promise Browser))
foreign import _newPage :: FU.Fn1 Browser (Effect (Promise Page))
foreign import _goto :: FU.Fn2 URL Page (Effect (Promise Unit))
foreign import _close :: FU.Fn1 Browser (Effect (Promise Unit))
Expand Down

0 comments on commit f7512a8

Please sign in to comment.