mirror of
https://github.com/klntsky/purescript-playwright.git
synced 2024-11-22 13:23:01 +03:00
Add launch
.
This commit is contained in:
parent
edeed4c3ed
commit
e2de1671d1
17
bower.json
Normal file
17
bower.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "purescript-playwright",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"output"
|
||||
],
|
||||
"dependencies": {
|
||||
"purescript-prelude": "^4.1.1",
|
||||
"purescript-console": "^4.4.0",
|
||||
"purescript-effect": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"purescript-psci-support": "^4.0.0"
|
||||
}
|
||||
}
|
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "purescript-playwright",
|
||||
"version": "0.0.1",
|
||||
"description": "PureScript bindings for Playwright",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {
|
||||
"bower": "^1.8.8",
|
||||
"playwright": "^1.3.0",
|
||||
"pulp": "^15.0.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "pulp test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/klntsky/purescript-playwright.git"
|
||||
},
|
||||
"keywords": [
|
||||
"purescript",
|
||||
"playwright"
|
||||
],
|
||||
"author": "Vladimir Kalnitsky <klntsky@gmail.com>",
|
||||
"license": "BSD-3-Clause",
|
||||
"bugs": {
|
||||
"url": "https://github.com/klntsky/purescript-playwright/issues"
|
||||
},
|
||||
"homepage": "https://github.com/klntsky/purescript-playwright#readme"
|
||||
}
|
8
packages.dhall
Normal file
8
packages.dhall
Normal file
@ -0,0 +1,8 @@
|
||||
let upstream =
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200822/packages.dhall sha256:b4f151f1af4c5cb6bf5437489f4231fbdd92792deaf32971e6bcb0047b3dd1f8
|
||||
|
||||
let overrides = {=}
|
||||
|
||||
let additions = {=}
|
||||
|
||||
in upstream ⫽ overrides ⫽ additions
|
6
spago.dhall
Normal file
6
spago.dhall
Normal file
@ -0,0 +1,6 @@
|
||||
{ name = "playwright"
|
||||
, dependencies =
|
||||
[ "console", "effect", "prelude", "psci-support", "aff-promise", "options" ]
|
||||
, packages = ./packages.dhall
|
||||
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
|
||||
}
|
14
src/Playwright.js
Normal file
14
src/Playwright.js
Normal file
@ -0,0 +1,14 @@
|
||||
/* global require exports */
|
||||
|
||||
var P = require('playwright');
|
||||
|
||||
exports.chromium = P.chromium;
|
||||
exports.firefox = P.firefox;
|
||||
exports.webkit = P.webkit;
|
||||
exports._launch = function (browser) {
|
||||
return function (opts) {
|
||||
return function () {
|
||||
return browser.launch(opts);
|
||||
};
|
||||
};
|
||||
};
|
113
src/Playwright.purs
Normal file
113
src/Playwright.purs
Normal file
@ -0,0 +1,113 @@
|
||||
module Playwright
|
||||
( BrowserType
|
||||
, Browser
|
||||
|
||||
, firefox
|
||||
, chromium
|
||||
, webkit
|
||||
|
||||
, launch
|
||||
, LaunchOptions
|
||||
, headless
|
||||
, executablePath
|
||||
, args
|
||||
, ignoreDefaultArgs
|
||||
, ProxyOptions
|
||||
, server
|
||||
, bypass
|
||||
, username
|
||||
, password
|
||||
, proxy
|
||||
, downloadsPath
|
||||
, chromiumSandbox
|
||||
, firefoxUserPrefs
|
||||
, handleSIGINT
|
||||
, handleSIGTERM
|
||||
, handleSIGHUP
|
||||
, timeout
|
||||
, env
|
||||
, devtools
|
||||
, slowMo
|
||||
)
|
||||
where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Control.Promise (Promise, toAffE)
|
||||
import Data.Options (Option, Options, opt)
|
||||
import Effect.Aff (Aff)
|
||||
import Foreign (Foreign)
|
||||
import Foreign.Object (Object)
|
||||
|
||||
foreign import data BrowserType :: Type
|
||||
foreign import data Browser :: Type
|
||||
|
||||
foreign import firefox :: BrowserType
|
||||
foreign import chromium :: BrowserType
|
||||
foreign import webkit :: BrowserType
|
||||
|
||||
foreign import _launch :: BrowserType -> Options LaunchOptions -> Effect (Promise Browser)
|
||||
|
||||
launch :: BrowserType -> Options LaunchOptions -> Aff Browser
|
||||
launch bt = toAffE <<< _launch bt
|
||||
|
||||
foreign import data LaunchOptions :: Type
|
||||
|
||||
headless :: Option LaunchOptions Boolean
|
||||
headless = opt "headless"
|
||||
|
||||
executablePath :: Option LaunchOptions String
|
||||
executablePath = opt "executablePath"
|
||||
|
||||
args :: Option LaunchOptions String
|
||||
args = opt "args"
|
||||
|
||||
ignoreDefaultArgs :: Option LaunchOptions (Array String)
|
||||
ignoreDefaultArgs = opt "ignoreDefaultArgs"
|
||||
|
||||
foreign import data ProxyOptions :: Type
|
||||
|
||||
server :: Option ProxyOptions String
|
||||
server = opt "server"
|
||||
|
||||
bypass :: Option ProxyOptions String
|
||||
bypass = opt "bypass"
|
||||
|
||||
username :: Option ProxyOptions String
|
||||
username = opt "username"
|
||||
|
||||
password :: Option ProxyOptions String
|
||||
password = opt "password"
|
||||
|
||||
proxy :: Option LaunchOptions (Options ProxyOptions)
|
||||
proxy = opt "proxy"
|
||||
|
||||
downloadsPath :: Option LaunchOptions String
|
||||
downloadsPath = opt "downloadsPath"
|
||||
|
||||
chromiumSandbox :: Option LaunchOptions Boolean
|
||||
chromiumSandbox = opt "chromiumSandbox"
|
||||
|
||||
firefoxUserPrefs :: Option LaunchOptions Foreign
|
||||
firefoxUserPrefs = opt "firefoxUserPrefs"
|
||||
|
||||
handleSIGINT :: Option LaunchOptions Boolean
|
||||
handleSIGINT = opt "handleSIGINT"
|
||||
|
||||
handleSIGTERM :: Option LaunchOptions Boolean
|
||||
handleSIGTERM = opt "handleSIGTERM"
|
||||
|
||||
handleSIGHUP :: Option LaunchOptions Boolean
|
||||
handleSIGHUP = opt "handleSIGHUP"
|
||||
|
||||
timeout :: Option LaunchOptions Number
|
||||
timeout = opt "timeout"
|
||||
|
||||
env :: Option LaunchOptions (Object String)
|
||||
env = opt "env"
|
||||
|
||||
devtools :: Option LaunchOptions Boolean
|
||||
devtools = opt "devtools"
|
||||
|
||||
slowMo :: Option LaunchOptions Number
|
||||
slowMo = opt "slowMo"
|
9
test/Main.purs
Normal file
9
test/Main.purs
Normal file
@ -0,0 +1,9 @@
|
||||
module Test.Main where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Effect.Console (log)
|
||||
|
||||
main :: Effect Unit
|
||||
main = do
|
||||
log "You should add some tests."
|
Loading…
Reference in New Issue
Block a user