-
Notifications
You must be signed in to change notification settings - Fork 73
Add bindings for Navigator
#194
base: master
Are you sure you want to change the base?
Changes from 1 commit
1524d72
498e63a
a0a1813
2ce11ea
9000d9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
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 buildID : t => string = ""; | ||
[@bs.get] external clipboard : t => clipboard = ""; | ||
[@bs.get] external connection : t => networkConnection = ""; | ||
[@bs.get] external cookieEnabled : t => bool = ""; | ||
[@bs.get] external credentials : t => credentialsContainer = ""; | ||
[@bs.get] external deviceMemory : t => float = ""; | ||
[@bs.get] external geolocation : t => geolocation = ""; | ||
[@bs.get] external language : t => string = ""; | ||
[@bs.get] external maxTouchPoints : t => int = ""; | ||
[@bs.get] external mediaDevices : t => mediaDevices = ""; | ||
[@bs.get] external mediaSession : t => mediaSession = ""; | ||
[@bs.get] external onLine : t => bool = ""; | ||
[@bs.get] external oscpu : t => string = ""; | ||
[@bs.get] external platform : t => string = ""; | ||
[@bs.get] external productSub : t => string = ""; | ||
[@bs.get] external serviceWorker : t => serviceWorkerContainer = ""; | ||
[@bs.get] external vendor : t => string = ""; | ||
[@bs.get] external vendorSub : t => string = ""; | ||
[@bs.get] external webdriver : t => bool = ""; | ||
[@bs.get] external xr : t => xr = ""; | ||
|
||
[@bs.send.pipe : t] external canShare : shareOptions => bool = ""; | ||
[@bs.send.pipe : t] external registerProtocolHandler : (string, string, string) => unit = ""; | ||
[@bs.send.pipe : t] external requestMediaKeySystemAccess : (string, list(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) = ""; | ||
[@bs.send.pipe : t] external vibrate : ( | ||
[@bs.unwrap] [ | ||
| `Int(int) | ||
| `IntList(list(int)) | ||
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. For |
||
]) => bool = ""; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ type frameList; /* array-like, WindowProxy? */ | |
type idleDeadline; /* Cooperative Scheduling of Background Tasks */ | ||
type locationbar; /* "bar object" */ | ||
type menubar; /* "bar object" */ | ||
type navigator; | ||
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. Deleting this type will break backward-compatibility, so instead can you alias it to the newly-introduced |
||
type personalbar; /* "bar object" */ | ||
type screen; | ||
type scrollbars; /* "bar object" */ | ||
|
@@ -39,7 +38,7 @@ module Impl = (T: {type t;}) => { | |
[@bs.get] external menubar : t_window => menubar = ""; | ||
[@bs.get] external name : t_window => string = ""; | ||
[@bs.set] external setName : (t_window, string) => unit = "name"; | ||
[@bs.get] external navigator : t_window => navigator = ""; | ||
[@bs.get] external navigator : t_window => Webapi__Dom__Navigator.t = ""; | ||
[@bs.get] [@bs.return nullable] external opener : t_window => option(Dom.window) = ""; | ||
[@bs.get] external outerWidth : t_window => int = ""; | ||
[@bs.get] external outerHeight : t_window => int = ""; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ module MouseEvent = Webapi__Dom__MouseEvent; | |
module MutationObserver = Webapi__Dom__MutationObserver; | ||
module MutationRecord = Webapi__Dom__MutationRecord; | ||
module NamedNodeMap = Webapi__Dom__NamedNodeMap; | ||
module Navigator = Webapi__Dom__Navigator; | ||
module Node = Webapi__Dom__Node; | ||
module NodeFilter = Webapi__Dom__NodeFilter; | ||
module NodeIterator = Webapi__Dom__NodeIterator; | ||
|
@@ -71,6 +72,7 @@ include Webapi__Dom__Types; | |
[@bs.val] external document : Dom.document = "document"; | ||
[@bs.val] [@bs.scope "window"] external history : Dom.history = "history"; | ||
[@bs.val] [@bs.scope "window"] external location : Dom.location = "location"; | ||
[@bs.val] [@bs.scope "window"] external navigator : Webapi__Dom__Navigator.t = "navigator"; | ||
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. I realize there are similar bindings above it, but I really don't think |
||
|
||
|
||
/* Unimplemented interfaces (aka. "The TODO list") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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:
|
||
open Navigator; | ||
|
||
let _ = buildID(navigator); | ||
let _ = clipboard(navigator); | ||
let _ = connection(navigator); | ||
let _ = cookieEnabled(navigator); | ||
let _ = credentials(navigator); | ||
let _ = deviceMemory(navigator); | ||
let _ = geolocation(navigator); | ||
let _ = language(navigator); | ||
let _ = maxTouchPoints(navigator); | ||
let _ = mediaDevices(navigator); | ||
let _ = mediaSession(navigator); | ||
let _ = onLine(navigator); | ||
let _ = oscpu(navigator); | ||
let _ = platform(navigator); | ||
let _ = productSub(navigator); | ||
let _ = serviceWorker(navigator); | ||
let _ = vendor(navigator); | ||
let _ = vendorSub(navigator); | ||
let _ = webdriver(navigator); | ||
let _ = xr(navigator); | ||
|
||
navigator |> registerProtocolHandler("web+burger", "https://burgers.example.com/?burger=%s", "Burger handler"); | ||
navigator |> sendBeacon("/log", `String("a whole lotta burgers")); | ||
navigator |> vibrate(`Int(200)); | ||
navigator |> vibrate(`IntList([100,30,100,30,100,30,200,30,200,30,200,30,100,30,100,30,100])); |
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.
Since there are only two types of allowed parameters here, can you use two different bindings i.e.
vibrate
andvibrateArray
? That's the typical style used inbs-webapi
, and I recommended the@bs.unwrap
style forsendBeacon
because it takes so many different types that it would have exploded the number of bindings.