fix: export request methods
This commit is contained in:
parent
9d0470ceb1
commit
37ac23c57a
@ -2,71 +2,63 @@ import { HTTPResponse } from 'puppeteer'
|
|||||||
import { HTTPRequest } from 'puppeteer'
|
import { HTTPRequest } from 'puppeteer'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _abort :: String -> Request -> Promise Unit`
|
|
||||||
* @type {(_0: import("puppeteer").ErrorCode) => (_1: HTTPRequest) => () => Promise<void>}
|
* @type {(_0: import("puppeteer").ErrorCode) => (_1: HTTPRequest) => () => Promise<void>}
|
||||||
*/
|
*/
|
||||||
export const _abort = e => r => () => r.abort(e)
|
export const _abort = e => r => () => r.abort(e)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _continue :: Foreign -> Request -> Promise Unit`
|
|
||||||
* @type {(_0: import("puppeteer").ContinueRequestOverrides) => (_1: HTTPRequest) => () => Promise<void>}
|
* @type {(_0: import("puppeteer").ContinueRequestOverrides) => (_1: HTTPRequest) => () => Promise<void>}
|
||||||
*/
|
*/
|
||||||
export const _continue = o => r => () => r.continue(o)
|
export const _continue = o => r => () => r.continue(o)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _respond :: RespondToRequest -> Request -> Promise Unit`
|
|
||||||
* @type {(_0: import("puppeteer").ResponseForRequest) => (_1: HTTPRequest) => () => Promise<void>}
|
* @type {(_0: import("puppeteer").ResponseForRequest) => (_1: HTTPRequest) => () => Promise<void>}
|
||||||
*/
|
*/
|
||||||
export const _respond = rep => req => () => req.respond(rep)
|
export const _respond = rep => req => () => req.respond(rep)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _failure :: Request -> Effect (Nullable {errorText :: String})`
|
|
||||||
* @type {(_1: HTTPRequest) => () => {errorText: string} | null}
|
* @type {(_1: HTTPRequest) => () => {errorText: string} | null}
|
||||||
*/
|
*/
|
||||||
export const _failure = r => () => r.failure()
|
export const _failure = r => () => r.failure()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import headers :: Request -> Effect (Map String String)`
|
* @type {(_1: HTTPRequest) => () => Array<{k: string, v: string}>}
|
||||||
* @type {(_1: HTTPRequest) => () => Map<string, string>}
|
|
||||||
*/
|
*/
|
||||||
export const headers = r => () =>
|
export const headers = r => () => {
|
||||||
Object.entries(r.headers()).reduce((map, [k, v]) => {
|
/** @type {Array<{k: string, v: string}>} */
|
||||||
map.set(k, v)
|
const init = []
|
||||||
return map
|
return Object.entries(r.headers()).reduce(
|
||||||
}, new Map())
|
(map, [k, v]) => [...map, { k, v }],
|
||||||
|
init,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _isNavigation :: Request -> Effect Boolean`
|
|
||||||
* @type {(_1: HTTPRequest) => () => boolean}
|
* @type {(_1: HTTPRequest) => () => boolean}
|
||||||
*/
|
*/
|
||||||
export const isNavigation = r => () => r.isNavigationRequest()
|
export const isNavigation = r => () => r.isNavigationRequest()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _method :: Request -> Effect String`
|
|
||||||
* @type {(_1: HTTPRequest) => () => string}
|
* @type {(_1: HTTPRequest) => () => string}
|
||||||
*/
|
*/
|
||||||
export const method = r => () => r.method()
|
export const method = r => () => r.method()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _postData :: Request -> Effect Foreign`
|
|
||||||
* @type {(_1: HTTPRequest) => () => string | undefined}
|
* @type {(_1: HTTPRequest) => () => string | undefined}
|
||||||
*/
|
*/
|
||||||
export const _postData = r => () => r.postData()
|
export const _postData = r => () => r.postData()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _resourceType :: Request -> Effect String`
|
|
||||||
* @type {(_1: HTTPRequest) => () => string}
|
* @type {(_1: HTTPRequest) => () => string}
|
||||||
*/
|
*/
|
||||||
export const resourceType = r => () => r.resourceType()
|
export const resourceType = r => () => r.resourceType()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _url :: Request -> Effect String`
|
|
||||||
* @type {(_1: HTTPRequest) => () => string}
|
* @type {(_1: HTTPRequest) => () => string}
|
||||||
*/
|
*/
|
||||||
export const url = r => () => r.url()
|
export const url = r => () => r.url()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `foreign import _response :: Request -> Effect (Nullable Response)`
|
|
||||||
* @type {(_1: HTTPRequest) => () => HTTPResponse | null}
|
* @type {(_1: HTTPRequest) => () => HTTPResponse | null}
|
||||||
*/
|
*/
|
||||||
export const _response = r => () => r.response()
|
export const _response = r => () => r.response()
|
||||||
|
@ -9,6 +9,11 @@ module Puppeteer.HTTP.Request
|
|||||||
, failure
|
, failure
|
||||||
, postData
|
, postData
|
||||||
, response
|
, response
|
||||||
|
, headers
|
||||||
|
, isNavigation
|
||||||
|
, method
|
||||||
|
, resourceType
|
||||||
|
, url
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
@ -67,7 +72,6 @@ prepareContinueRequestOverrides { headers: headers', method: method', postData:
|
|||||||
, url: FFI.maybeToUndefined url'
|
, url: FFI.maybeToUndefined url'
|
||||||
}
|
}
|
||||||
|
|
||||||
foreign import headers :: Request -> Effect (Map String String)
|
|
||||||
foreign import isNavigation :: Request -> Effect Boolean
|
foreign import isNavigation :: Request -> Effect Boolean
|
||||||
foreign import method :: Request -> Effect String
|
foreign import method :: Request -> Effect String
|
||||||
foreign import resourceType :: Request -> Effect String
|
foreign import resourceType :: Request -> Effect String
|
||||||
@ -77,10 +81,14 @@ foreign import _abort :: String -> Request -> Promise Unit
|
|||||||
foreign import _continue :: Foreign -> Request -> Promise Unit
|
foreign import _continue :: Foreign -> Request -> Promise Unit
|
||||||
foreign import _respond :: Foreign -> Request -> Promise Unit
|
foreign import _respond :: Foreign -> Request -> Promise Unit
|
||||||
|
|
||||||
|
foreign import _headers :: Request -> Effect (Array {k :: String, v :: String})
|
||||||
foreign import _failure :: Request -> Effect (Nullable { errorText :: String })
|
foreign import _failure :: Request -> Effect (Nullable { errorText :: String })
|
||||||
foreign import _postData :: Request -> Effect Foreign
|
foreign import _postData :: Request -> Effect Foreign
|
||||||
foreign import _response :: Request -> Effect (Nullable Response)
|
foreign import _response :: Request -> Effect (Nullable Response)
|
||||||
|
|
||||||
|
headers :: Request -> Effect (Map String String)
|
||||||
|
headers = map FFI.makeMap <<< _headers
|
||||||
|
|
||||||
abort :: Context InterceptRequestsHint -> ErrorCode -> Request -> Aff Unit
|
abort :: Context InterceptRequestsHint -> ErrorCode -> Request -> Aff Unit
|
||||||
abort _ e = Promise.toAff <<< _abort (errorCodeString e)
|
abort _ e = Promise.toAff <<< _abort (errorCodeString e)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user