This repository was archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Add bindings for Navigator
#194
Open
forrest-akin
wants to merge
5
commits into
reasonml-community:master
Choose a base branch
from
forrest-akin:feature/navigator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1524d72
add bindings for `Navigator`
forrest-akin 498e63a
alias existing `navigator` type to `Navigator.t` for backwards compat
forrest-akin a0a1813
add `@since` jsdoc for Navigator and remove `Dom.navigator`
forrest-akin 2ce11ea
updating PR
forrest-akin 9000d9f
bump version and update changelog
forrest-akin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
|
||
var $$navigator = window.navigator; | ||
|
||
$$navigator.clipboard; | ||
|
||
$$navigator.cookieEnabled; | ||
|
||
$$navigator.geolocation; | ||
|
||
$$navigator.maxTouchPoints; | ||
|
||
$$navigator.mediaDevices; | ||
|
||
$$navigator.serviceWorker; | ||
|
||
$$navigator.vendor; | ||
|
||
$$navigator.registerProtocolHandler("web+burger", "https://burgers.example.com/?burger=%s", "Burger handler"); | ||
|
||
$$navigator.sendBeacon("/log", "a whole lotta burgers"); | ||
|
||
$$navigator.vibrate(200); | ||
|
||
$$navigator.vibrate([ | ||
100, | ||
30, | ||
100, | ||
30, | ||
100, | ||
30, | ||
200, | ||
30, | ||
200, | ||
30, | ||
200, | ||
30, | ||
100, | ||
30, | ||
100, | ||
30, | ||
100 | ||
]); | ||
|
||
exports.$$navigator = $$navigator; | ||
/* navigator Not a pure module */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
open Js.Typed_array; | ||
|
||
|
||
type t; | ||
|
||
type clipboard; | ||
type networkConnection; | ||
type credentialsContainer; | ||
type geolocation; | ||
type mediaDevices; | ||
type mediaSession; | ||
type serviceWorkerContainer; | ||
type xr; | ||
type mediaKeySystemAccess; | ||
type mediaKeySystemConfiguration; | ||
type shareOptions; | ||
|
||
[@bs.get] external clipboard : t => clipboard = ""; | ||
// [@bs.get] external connection : t => networkConnection = ""; /** experimental */ | ||
[@bs.get] external cookieEnabled : t => bool = ""; | ||
// [@bs.get] external credentials : t => credentialsContainer = ""; /** experimental */ | ||
// [@bs.get] external deviceMemory : t => float = ""; /** experimental */ | ||
// [@bs.get] external doNotTrack : t => string = ""; /** experimental */ | ||
[@bs.get] external geolocation : t => geolocation = ""; | ||
// [@bs.get] external keyboard : t => keyboard = ""; /** experimental */ | ||
// [@bs.get] external locks : t => lockManager = ""; /** experimental */ | ||
[@bs.get] external maxTouchPoints : t => int = ""; | ||
// [@bs.get] external mediaCapabilities : t => mediaCapabilities = ""; /** experimental */ | ||
[@bs.get] external mediaDevices : t => mediaDevices = ""; | ||
// [@bs.get] external mediaSession : t => mediaSession = ""; /** experimental */ | ||
// [@bs.get] external permissions : t => permissions = ""; /** experimental */ | ||
// [@bs.get] external presentation : t => presentation = ""; /** experimental */ | ||
[@bs.get] external serviceWorker : t => serviceWorkerContainer = ""; | ||
[@bs.get] external vendor : t => string = ""; | ||
// [@bs.get] external vendorSub : t => string = ""; /** non-standard */ | ||
// [@bs.get] external wakeLock : t => wakeLock = ""; /** experimental */ | ||
// [@bs.get] external webdriver : t => bool = ""; /** experimental */ | ||
// [@bs.get] external xr : t => xr = ""; /** experimental */ | ||
|
||
// [@bs.send.pipe : t] external canShare : shareOptions => bool = ""; /** experimental */ | ||
// [@bs.send.pipe : t] external getGamePads : unit => array(gamePad) = ""; /** experimental */ | ||
[@bs.send.pipe : t] external registerProtocolHandler : (string, string, string) => unit = ""; | ||
[@bs.send.pipe : t] external requestMediaKeySystemAccess : (string, array(mediaKeySystemConfiguration)) => Js.Promise.t(mediaKeySystemAccess) = ""; | ||
[@bs.send.pipe : t] external sendBeacon : ( | ||
string, | ||
[@bs.unwrap] [ | ||
| `ArrayBuffer(ArrayBuffer.t) | ||
| `Int8Array(Int8Array.t) | ||
| `Uint8Array(Uint8Array.t) | ||
| `Uint8ClampedArray(Uint8ClampedArray.t) | ||
| `Int16Array(Int16Array.t) | ||
| `Uint16Array(Uint16Array.t) | ||
| `Int32Array(Int32Array.t) | ||
| `Uint32Array(Uint32Array.t) | ||
| `Float32Array(Float32Array.t) | ||
| `Float64Array(Float64Array.t) | ||
| `DataView(DataView.t) | ||
| `Blob(Webapi__Blob.t) | ||
| `FormData(Fetch.FormData.t) | ||
| `URLSearchParams(Webapi__Url.URLSearchParams.t) | ||
| `String(string) | ||
]) => bool = ""; | ||
// [@bs.send.pipe : t] external share : shareOptions => Js.Promise.t(unit) = ""; /** experimental */ | ||
[@bs.send.pipe : t] external vibrate : int => bool = "vibrate"; | ||
[@bs.send.pipe : t] external vibrateArray : array(int) => bool = "vibrate"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
open Webapi.Dom; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for writing these tests. I know it's a bit annoying, but can you also check in the compiled test output? You'll need to do:
|
||
|
||
let navigator = Window.navigator(window); | ||
let _ = Navigator.clipboard(navigator); | ||
let _ = Navigator.cookieEnabled(navigator); | ||
let _ = Navigator.geolocation(navigator); | ||
let _ = Navigator.maxTouchPoints(navigator); | ||
let _ = Navigator.mediaDevices(navigator); | ||
let _ = Navigator.serviceWorker(navigator); | ||
let _ = Navigator.vendor(navigator); | ||
|
||
navigator |> Navigator.registerProtocolHandler("web+burger", "https://burgers.example.com/?burger=%s", "Burger handler"); | ||
navigator |> Navigator.sendBeacon("/log", `String("a whole lotta burgers")); | ||
navigator |> Navigator.vibrate(200); | ||
navigator |> Navigator.vibrateArray([|100,30,100,30,100,30,200,30,200,30,200,30,100,30,100,30,100|]); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting this type will break backward-compatibility, so instead can you alias it to the newly-introduced
Webapi__Dom__Navigator.t
type and deprecate the alias, thx