Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/ClipboardAPI/Clipboard.res
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
open ClipboardTypes

include EventTarget.Impl({type t = clipboard})
type t = ClipboardTypes.clipboard = {...ClipboardTypes.clipboard}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should add a short comment just explaining this pattern for future ref

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on updating the readme and contributor docs to cover this once we're ready to finish tidying things up.


external current: t = "clipboard"

include EventTarget.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/read)
*/
@send
external read: clipboard => promise<array<clipboardItem>> = "read"
external read: t => promise<array<clipboardItem>> = "read"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/readText)
*/
@send
external readText: clipboard => promise<string> = "readText"
external readText: t => promise<string> = "readText"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/write)
*/
@send
external write: (clipboard, array<clipboardItem>) => promise<unit> = "write"
external write: (t, array<clipboardItem>) => promise<unit> = "write"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/writeText)
*/
@send
external writeText: (clipboard, string) => promise<unit> = "writeText"
external writeText: (t, string) => promise<unit> = "writeText"
18 changes: 10 additions & 8 deletions src/CredentialManagementAPI/CredentialsContainer.res
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
open CredentialManagementTypes

type t = CredentialManagementTypes.credentialsContainer = {
...CredentialManagementTypes.credentialsContainer,
}

external current: t = "credentials"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get)
*/
@send
external get: (credentialsContainer, ~options: credentialRequestOptions=?) => promise<credential> =
"get"
external get: (t, ~options: credentialRequestOptions=?) => promise<credential> = "get"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store)
*/
@send
external store: (credentialsContainer, credential) => promise<unit> = "store"
external store: (t, credential) => promise<unit> = "store"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/create)
*/
@send
external create: (
credentialsContainer,
~options: credentialCreationOptions=?,
) => promise<credential> = "create"
external create: (t, ~options: credentialCreationOptions=?) => promise<credential> = "create"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/preventSilentAccess)
*/
@send
external preventSilentAccess: credentialsContainer => promise<unit> = "preventSilentAccess"
external preventSilentAccess: t => promise<unit> = "preventSilentAccess"
10 changes: 0 additions & 10 deletions src/Global.res
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ open ChannelMessagingTypes
open FetchTypes
open EventTypes

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
external window: window = "window"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
Expand Down Expand Up @@ -124,11 +119,6 @@ external parent: window = "parent"
*/
external frameElement: element = "frameElement"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/navigator)
*/
external navigator: navigator = "navigator"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screen)
*/
Expand Down
15 changes: 9 additions & 6 deletions src/HistoryAPI/History.res
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
open HistoryTypes

type t = HistoryTypes.history = {...HistoryTypes.history}

external current: t = "history"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/go)
*/
@send
external go: (history, ~delta: int=?) => unit = "go"
external go: (t, ~delta: int=?) => unit = "go"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/back)
*/
@send
external back: history => unit = "back"
external back: t => unit = "back"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/forward)
*/
@send
external forward: history => unit = "forward"
external forward: t => unit = "forward"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/pushState)
*/
@send
external pushState: (history, ~data: JSON.t, ~unused: string, ~url: string=?) => unit = "pushState"
external pushState: (t, ~data: JSON.t, ~unused: string, ~url: string=?) => unit = "pushState"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/replaceState)
*/
@send
external replaceState: (history, ~data: JSON.t, ~unused: string, ~url: string=?) => unit =
"replaceState"
external replaceState: (t, ~data: JSON.t, ~unused: string, ~url: string=?) => unit = "replaceState"
12 changes: 8 additions & 4 deletions src/IndexedDBAPI/IDBFactory.res
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
open IndexedDBTypes

type t = IndexedDBTypes.idbFactory = {...IndexedDBTypes.idbFactory}

external current: t = "indexedDB"

/**
Attempts to open a connection to the named database with the current version, or 1 if it does not already exist. If the request is successful request's result will be the connection.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/open)
*/
@send
external open_: (idbFactory, ~name: string, ~version: int=?) => idbOpenDBRequest = "open"
external open_: (t, ~name: string, ~version: int=?) => idbOpenDBRequest = "open"

/**
Attempts to delete the named database. If the database already exists and there are open connections that don't close in response to a versionchange event, the request will be blocked until all they close. If the request is successful request's result will be null.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/deleteDatabase)
*/
@send
external deleteDatabase: (idbFactory, string) => idbOpenDBRequest = "deleteDatabase"
external deleteDatabase: (t, string) => idbOpenDBRequest = "deleteDatabase"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/databases)
*/
@send
external databases: idbFactory => promise<array<idbDatabaseInfo>> = "databases"
external databases: t => promise<array<idbDatabaseInfo>> = "databases"

/**
Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if the keys are equal.
Expand All @@ -27,4 +31,4 @@ Throws a "DataError" DOMException if either input is not a valid key.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/cmp)
*/
@send
external cmp: (idbFactory, ~first: JSON.t, ~second: JSON.t) => int = "cmp"
external cmp: (t, ~first: JSON.t, ~second: JSON.t) => int = "cmp"
35 changes: 18 additions & 17 deletions src/PerformanceAPI/Performance.res
Original file line number Diff line number Diff line change
@@ -1,72 +1,73 @@
open PerformanceTypes

include EventTarget.Impl({type t = performance})
type t = PerformanceTypes.performance = {...PerformanceTypes.performance}

external current: t = "performance"

include EventTarget.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/now)
*/
@send
external now: performance => float = "now"
external now: t => float = "now"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
*/
@send
external toJSON: performance => Dict.t<string> = "toJSON"
external toJSON: t => Dict.t<string> = "toJSON"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntries)
*/
@send
external getEntries: performance => performanceEntryList = "getEntries"
external getEntries: t => performanceEntryList = "getEntries"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType)
*/
@send
external getEntriesByType: (performance, string) => performanceEntryList = "getEntriesByType"
external getEntriesByType: (t, string) => performanceEntryList = "getEntriesByType"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName)
*/
@send
external getEntriesByName: (performance, ~name: string, ~type_: string=?) => performanceEntryList =
external getEntriesByName: (t, ~name: string, ~type_: string=?) => performanceEntryList =
"getEntriesByName"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings)
*/
@send
external clearResourceTimings: performance => unit = "clearResourceTimings"
external clearResourceTimings: t => unit = "clearResourceTimings"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize)
*/
@send
external setResourceTimingBufferSize: (performance, int) => unit = "setResourceTimingBufferSize"
external setResourceTimingBufferSize: (t, int) => unit = "setResourceTimingBufferSize"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/mark)
*/
@send
external mark: (
performance,
~markName: string,
~markOptions: performanceMarkOptions=?,
) => performanceMark = "mark"
external mark: (t, ~markName: string, ~markOptions: performanceMarkOptions=?) => performanceMark =
"mark"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks)
*/
@send
external clearMarks: (performance, ~markName: string=?) => unit = "clearMarks"
external clearMarks: (t, ~markName: string=?) => unit = "clearMarks"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/measure)
*/
@send
external measure: (
performance,
t,
~measureName: string,
~startOrMeasureOptions: string=?,
~endMark: string=?,
Expand All @@ -77,7 +78,7 @@ external measure: (
*/
@send
external measureWithOptions: (
performance,
t,
~measureName: string,
~startOrMeasureOptions: performanceMeasureOptions=?,
~endMark: string=?,
Expand All @@ -87,4 +88,4 @@ external measureWithOptions: (
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures)
*/
@send
external clearMeasures: (performance, ~measureName: string=?) => unit = "clearMeasures"
external clearMeasures: (t, ~measureName: string=?) => unit = "clearMeasures"
6 changes: 5 additions & 1 deletion src/PermissionsAPI/Permissions.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
open PermissionsTypes

type t = PermissionsTypes.permissions = {...PermissionsTypes.permissions}

external current: t = "permissions"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Permissions/query)
*/
@send
external query: (permissions, permissionDescriptor) => promise<permissionStatus> = "query"
external query: (t, permissionDescriptor) => promise<permissionStatus> = "query"
6 changes: 5 additions & 1 deletion src/ScreenWakeLockAPI/WakeLock.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
open ScreenWakeLockTypes

type t = ScreenWakeLockTypes.wakeLock = {...ScreenWakeLockTypes.wakeLock}

external current: t = "wakeLock"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WakeLock/request)
*/
@send
external request: (wakeLock, ~type_: wakeLockType=?) => promise<wakeLockSentinel> = "request"
external request: (t, ~type_: wakeLockType=?) => promise<wakeLockSentinel> = "request"
19 changes: 10 additions & 9 deletions src/ServiceWorkerAPI/ServiceWorkerContainer.res
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
open ServiceWorkerTypes

include EventTarget.Impl({type t = serviceWorkerContainer})
type t = ServiceWorkerTypes.serviceWorkerContainer = {...ServiceWorkerTypes.serviceWorkerContainer}

external current: t = "serviceWorker"

include EventTarget.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/register)
*/
@send
external register: (
serviceWorkerContainer,
t,
string,
~options: registrationOptions=?,
) => promise<serviceWorkerRegistration> = "register"
Expand All @@ -16,20 +20,17 @@ external register: (
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/getRegistration)
*/
@send
external getRegistration: (
serviceWorkerContainer,
~clientURL: string=?,
) => Nullable.t<serviceWorkerRegistration> = "getRegistration"
external getRegistration: (t, ~clientURL: string=?) => Nullable.t<serviceWorkerRegistration> =
"getRegistration"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/getRegistrations)
*/
@send
external getRegistrations: serviceWorkerContainer => promise<array<serviceWorkerRegistration>> =
"getRegistrations"
external getRegistrations: t => promise<array<serviceWorkerRegistration>> = "getRegistrations"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/startMessages)
*/
@send
external startMessages: serviceWorkerContainer => unit = "startMessages"
external startMessages: t => unit = "startMessages"
8 changes: 6 additions & 2 deletions src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
open ServiceWorkerTypes

include WorkerGlobalScope.Impl({type t = serviceWorkerGlobalScope})
type t = ServiceWorkerTypes.serviceWorkerGlobalScope = {
...ServiceWorkerTypes.serviceWorkerGlobalScope,
}

include WorkerGlobalScope.Impl({type t = t})

/**
Forces the waiting service worker to become the active service worker.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting)
*/
@send
external skipWaiting: serviceWorkerGlobalScope => promise<unit> = "skipWaiting"
external skipWaiting: t => promise<unit> = "skipWaiting"
Loading