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
4 changes: 3 additions & 1 deletion packages/Canvas/src/CanvasPattern.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
type domMatrix2DInit = WebApiDOM.Types.domMatrix2DInit

/**
Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasPattern/setTransform)
*/
@send
external setTransform: (Types.canvasPattern, ~transform: WebApiDOM.Types.domMatrix2DInit=?) => unit =
external setTransform: (Types.canvasPattern, ~transform: domMatrix2DInit=?) => unit =
"setTransform"

let isInstanceOf = (_: 't): bool => %raw(`param instanceof CanvasPattern`)
2 changes: 1 addition & 1 deletion packages/Canvas/src/OffscreenCanvas.res
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ The argument, if provided, is a dictionary that controls the encoding options of
external convertToBlob: (
Types.offscreenCanvas,
~options: Types.imageEncodeOptions=?,
) => promise<WebApiFile.Types.blob> = "convertToBlob"
) => promise<WebApiFile.Blob.t> = "convertToBlob"
4 changes: 3 additions & 1 deletion packages/Canvas/src/Path2D.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
type domMatrix2DInit = WebApiDOM.Types.domMatrix2DInit

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Path2D)
*/
Expand Down Expand Up @@ -145,5 +147,5 @@ Adds to the path the path given by the argument.
external addPath: (
Types.path2D,
~path: Types.path2D,
~transform: WebApiDOM.Types.domMatrix2DInit=?,
~transform: domMatrix2DInit=?,
) => unit = "addPath"
15 changes: 9 additions & 6 deletions packages/ChannelMessaging/src/MessagePort.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include WebApiEvent.EventTarget.Impl({type t = Types.messagePort})
type t = Types.messagePort
type structuredSerializeOptions = Types.structuredSerializeOptions

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

/**
Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
Expand All @@ -8,7 +11,7 @@ Throws a "DataCloneError" DOMException if transfer contains duplicate objects or
*/
@send
external postMessage: (
Types.messagePort,
t,
~message: JSON.t,
~transfer: array<Dict.t<string>>,
) => unit = "postMessage"
Expand All @@ -21,21 +24,21 @@ Throws a "DataCloneError" DOMException if transfer contains duplicate objects or
*/
@send
external postMessage2: (
Types.messagePort,
t,
~message: JSON.t,
~options: Types.structuredSerializeOptions=?,
~options: structuredSerializeOptions=?,
) => unit = "postMessage"

/**
Begins dispatching messages received on the port.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
*/
@send
external start: Types.messagePort => unit = "start"
external start: t => unit = "start"

/**
Disconnects the port, so that it is no longer active.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
*/
@send
external close: Types.messagePort => unit = "close"
external close: t => unit = "close"
6 changes: 4 additions & 2 deletions packages/DOM/src/HTMLElement.res
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
type t = Types.htmlElement

module Impl = (
T: {
type t
},
) => {
include Element.Impl({type t = T.t})

external asHTMLElement: T.t => Types.htmlElement = "%identity"
external asHTMLElement: T.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/attachInternals)
Expand Down Expand Up @@ -50,4 +52,4 @@ module Impl = (
external togglePopover: (T.t, ~force: bool=?) => bool = "togglePopover"
}

include Impl({type t = Types.htmlElement})
include Impl({type t = t})
14 changes: 8 additions & 6 deletions packages/DOM/src/HTMLFormElement.res
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
include HTMLElement.Impl({type t = Types.htmlFormElement})
type t = Types.htmlFormElement

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

/**
Fires when a FORM is about to be submitted.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/submit)
*/
@send
external submit: Types.htmlFormElement => unit = "submit"
external submit: t => unit = "submit"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/requestSubmit)
*/
@send
external requestSubmit: (Types.htmlFormElement, ~submitter: Types.htmlElement=?) => unit =
external requestSubmit: (t, ~submitter: WebApiDOM.HTMLElement.t=?) => unit =
"requestSubmit"

/**
Fires when the user resets a form.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reset)
*/
@send
external reset: Types.htmlFormElement => unit = "reset"
external reset: t => unit = "reset"

/**
Returns whether a form will validate when it is submitted, without having to submit it.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/checkValidity)
*/
@send
external checkValidity: Types.htmlFormElement => bool = "checkValidity"
external checkValidity: t => bool = "checkValidity"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reportValidity)
*/
@send
external reportValidity: Types.htmlFormElement => bool = "reportValidity"
external reportValidity: t => bool = "reportValidity"
39 changes: 35 additions & 4 deletions packages/DOM/src/Window.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include WebApiEvent.EventTarget.Impl({type t = Types.window})

external current: Types.window = "window"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
Expand Down Expand Up @@ -324,6 +326,16 @@ external setInterval: (Types.window, ~handler: string, ~timeout: int=?) => int =
external setInterval2: (Types.window, ~handler: unit => unit, ~timeout: int=?) => int =
"setInterval"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setInterval)
*/
@send
external setIntervalWithCallback: (
Types.window,
~handler: unit => unit,
~timeout: int=?,
) => int = "setInterval"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/clearInterval)
*/
Expand Down Expand Up @@ -400,7 +412,7 @@ external alert: Types.window => unit = "alert"
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/alert)
*/
@send
external alert2: (Types.window, string) => unit = "alert"
external alertWithMessage: (Types.window, string) => unit = "alert"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/confirm)
Expand Down Expand Up @@ -459,6 +471,25 @@ external postMessage2: (
~options: Types.windowPostMessageOptions=?,
) => unit = "postMessage"

/**
Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as WebApiFile Blob, FileList, and ArrayBuffer objects.

Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side.

A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only.

If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*".

Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/postMessage)
*/
@send
external postMessageWithOptions: (
Types.window,
~message: JSON.t,
~options: Types.windowPostMessageOptions=?,
) => unit = "postMessage"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/matchMedia)
*/
Expand Down Expand Up @@ -499,7 +530,7 @@ external scroll: (Types.window, ~options: Types.scrollToOptions=?) => unit = "sc
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scroll)
*/
@send
external scroll2: (Types.window, ~x: float, ~y: float) => unit = "scroll"
external scrollXY: (Types.window, ~x: float, ~y: float) => unit = "scroll"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollTo)
Expand All @@ -511,7 +542,7 @@ external scrollTo: (Types.window, ~options: Types.scrollToOptions=?) => unit = "
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollTo)
*/
@send
external scrollTo2: (Types.window, ~x: float, ~y: float) => unit = "scrollTo"
external scrollToXY: (Types.window, ~x: float, ~y: float) => unit = "scrollTo"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollBy)
Expand All @@ -523,7 +554,7 @@ external scrollBy: (Types.window, ~options: Types.scrollToOptions=?) => unit = "
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollBy)
*/
@send
external scrollBy2: (Types.window, ~x: float, ~y: float) => unit = "scrollBy"
external scrollByXY: (Types.window, ~x: float, ~y: float) => unit = "scrollBy"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/getComputedStyle)
Expand Down
20 changes: 11 additions & 9 deletions packages/Fetch/src/BodyInit.res
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
type t = Types.bodyInit

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromString: string => Types.bodyInit = "%identity"
external fromString: string => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromArrayBuffer: ArrayBuffer.t => Types.bodyInit = "%identity"
external fromArrayBuffer: ArrayBuffer.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromTypedArray: TypedArray.t<'t> => Types.bodyInit = "%identity"
external fromTypedArray: TypedArray.t<'t> => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromDataView: DataView.t => Types.bodyInit = "%identity"
external fromDataView: DataView.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromBlob: WebApiFile.Types.blob => Types.bodyInit = "%identity"
external fromBlob: WebApiFile.Blob.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromFile: WebApiFile.Types.file => Types.bodyInit = "%identity"
external fromFile: WebApiFile.File.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromURLSearchParams: WebApiURL.Types.urlSearchParams => Types.bodyInit = "%identity"
external fromURLSearchParams: WebApiURL.URLSearchParams.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromFormData: Types.formData => Types.bodyInit = "%identity"
external fromFormData: FormData.t => t = "%identity"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_a_body)
*/
external fromReadableStream: WebApiFile.Types.readableStream<'t> => Types.bodyInit = "%identity"
external fromReadableStream: WebApiFile.ReadableStream.t<'t> => t = "%identity"
32 changes: 19 additions & 13 deletions packages/Fetch/src/FormData.res
Original file line number Diff line number Diff line change
@@ -1,75 +1,81 @@
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData)
*/
type t = Types.formData
type formDataEntryValue = FormDataEntryValue.t

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData)
*/
@new
external make: (~form: 'form=?, ~submitter: 'submitter=?) => Types.formData = "FormData"
external make: (~form: 'form=?, ~submitter: 'submitter=?) => t = "FormData"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/append)
*/
@send
external append: (Types.formData, ~name: string, ~value: string) => unit = "append"
external append: (t, ~name: string, ~value: string) => unit = "append"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/append)
*/
@send
external appendBlob: (
Types.formData,
t,
~name: string,
~blobValue: WebApiFile.Types.blob,
~blobValue: WebApiFile.Blob.t,
~filename: string=?,
) => unit = "append"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/delete)
*/
@send
external delete: (Types.formData, string) => unit = "delete"
external delete: (t, string) => unit = "delete"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/get)
*/
@send
external get: (Types.formData, string) => null<Types.formDataEntryValue> = "get"
external get: (t, string) => null<formDataEntryValue> = "get"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
*/
@send
external getAll: (Types.formData, string) => array<Types.formDataEntryValue> = "getAll"
external getAll: (t, string) => array<formDataEntryValue> = "getAll"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/has)
*/
@send
external has: (Types.formData, string) => bool = "has"
external has: (t, string) => bool = "has"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/entries)
*/
@send
external entries: Types.formData => Iterator.t<(string, Types.formDataEntryValue)> = "entries"
external entries: t => Iterator.t<(string, formDataEntryValue)> = "entries"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/keys)
*/
@send
external keys: Types.formData => Iterator.t<string> = "keys"
external keys: t => Iterator.t<string> = "keys"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/set)
*/
@send
external set: (Types.formData, ~name: string, ~value: string) => unit = "set"
external set: (t, ~name: string, ~value: string) => unit = "set"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/set)
*/
@send
external setBlob: (
Types.formData,
t,
~name: string,
~blobValue: WebApiFile.Types.blob,
~blobValue: WebApiFile.Blob.t,
~filename: string=?,
) => unit = "set"
9 changes: 9 additions & 0 deletions packages/Fetch/src/FormDataEntryValue.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@unboxed
type t =
| String(string)
| File(WebApiFile.File.t)

external fromString: string => t = "%identity"
external fromFile: WebApiFile.File.t => t = "%identity"

let decode = (value: t): t => value
Loading