From 26ca62804ac3592b092f0e83c6a9c7f94ab6525c Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Thu, 29 Jun 2023 10:07:22 +0200 Subject: [PATCH] Rollback previous webapi --- packages/melange-fetch/src/Fetch.ml | 2 + packages/melange-runtime/dom_storage.ml | 6 +- packages/melange-runtime/dom_storage2.ml | 6 +- packages/melange-webapi/src/{dune => _dune} | 0 packages/webapi/Fetch.ml | 476 ++++ packages/webapi/Fetch__Iterator.ml | 20 + packages/webapi/{src => }/Webapi.re | 13 +- packages/webapi/Webapi__Base64.re | 2 + packages/webapi/Webapi__Blob.re | 29 + packages/webapi/Webapi__Canvas.re | 15 + packages/webapi/Webapi__Canvas__Canvas2d.re | 288 +++ packages/webapi/Webapi__Canvas__WebGl.re | 124 + packages/webapi/Webapi__Dom.re | 336 +++ .../webapi/Webapi__Dom__AnimationEvent.re | 13 + packages/webapi/Webapi__Dom__Attr.re | 17 + .../webapi/Webapi__Dom__BeforeUnloadEvent.re | 11 + packages/webapi/Webapi__Dom__CdataSection.re | 20 + packages/webapi/Webapi__Dom__CharacterData.re | 31 + packages/webapi/Webapi__Dom__ChildNode.re | 4 + .../webapi/Webapi__Dom__ClipboardEvent.re | 11 + packages/webapi/Webapi__Dom__CloseEvent.re | 12 + packages/webapi/Webapi__Dom__Comment.re | 20 + .../webapi/Webapi__Dom__CompositionEvent.re | 14 + .../Webapi__Dom__CssStyleDeclaration.re | 138 + packages/webapi/Webapi__Dom__CustomEvent.re | 8 + packages/webapi/Webapi__Dom__Document.re | 147 ++ .../webapi/Webapi__Dom__DocumentFragment.re | 14 + .../Webapi__Dom__DocumentOrShadowRoot.re | 6 + packages/webapi/Webapi__Dom__DocumentType.re | 15 + .../webapi/Webapi__Dom__DomImplementation.re | 25 + packages/webapi/Webapi__Dom__DomRect.re | 14 + packages/webapi/Webapi__Dom__DomStringMap.re | 12 + packages/webapi/Webapi__Dom__DomTokenList.re | 26 + packages/webapi/Webapi__Dom__DragEvent.re | 16 + packages/webapi/Webapi__Dom__Element.re | 213 ++ packages/webapi/Webapi__Dom__ErrorEvent.re | 14 + packages/webapi/Webapi__Dom__Event.re | 58 + packages/webapi/Webapi__Dom__EventTarget.re | 2275 +++++++++++++++++ packages/webapi/Webapi__Dom__FocusEvent.re | 14 + .../Webapi__Dom__GlobalEventHandlers.re | 56 + packages/webapi/Webapi__Dom__History.re | 14 + .../webapi/Webapi__Dom__HtmlCollection.re | 10 + packages/webapi/Webapi__Dom__HtmlDocument.re | 90 + packages/webapi/Webapi__Dom__HtmlElement.re | 118 + .../webapi/Webapi__Dom__HtmlFormElement.re | 63 + .../webapi/Webapi__Dom__HtmlImageElement.re | 49 + .../webapi/Webapi__Dom__HtmlInputElement.re | 238 ++ .../Webapi__Dom__IdbVersionChangeEvent.re | 12 + packages/webapi/Webapi__Dom__Image.re | 17 + packages/webapi/Webapi__Dom__InputEvent.re | 14 + packages/webapi/Webapi__Dom__KeyboardEvent.re | 29 + packages/webapi/Webapi__Dom__Location.re | 31 + packages/webapi/Webapi__Dom__MouseEvent.re | 43 + .../webapi/Webapi__Dom__MutationObserver.re | 9 + .../webapi/Webapi__Dom__MutationRecord.re | 12 + packages/webapi/Webapi__Dom__NamedNodeMap.re | 17 + packages/webapi/Webapi__Dom__Node.re | 83 + packages/webapi/Webapi__Dom__NodeFilter.re | 3 + packages/webapi/Webapi__Dom__NodeIterator.re | 12 + packages/webapi/Webapi__Dom__NodeList.re | 11 + .../Webapi__Dom__NonDocumentTypeChildNode.re | 7 + .../Webapi__Dom__NonElementParentNode.re | 5 + .../Webapi__Dom__PageTransitionEvent.re | 11 + packages/webapi/Webapi__Dom__ParentNode.re | 12 + packages/webapi/Webapi__Dom__PointerEvent.re | 27 + packages/webapi/Webapi__Dom__PopStateEvent.re | 11 + .../Webapi__Dom__ProcessingInstruction.re | 16 + packages/webapi/Webapi__Dom__ProgressEvent.re | 13 + packages/webapi/Webapi__Dom__Range.re | 56 + packages/webapi/Webapi__Dom__RelatedEvent.re | 12 + packages/webapi/Webapi__Dom__Selection.re | 30 + packages/webapi/Webapi__Dom__ShadowRoot.re | 22 + packages/webapi/Webapi__Dom__Slotable.re | 5 + packages/webapi/Webapi__Dom__StorageEvent.re | 15 + packages/webapi/Webapi__Dom__SvgZoomEvent.re | 18 + packages/webapi/Webapi__Dom__Text.re | 34 + packages/webapi/Webapi__Dom__TimeEvent.re | 11 + packages/webapi/Webapi__Dom__TouchEvent.re | 26 + packages/webapi/Webapi__Dom__TrackEvent.re | 11 + .../webapi/Webapi__Dom__TransitionEvent.re | 13 + packages/webapi/Webapi__Dom__TreeWalker.re | 20 + packages/webapi/Webapi__Dom__Types.re | 309 +++ packages/webapi/Webapi__Dom__UiEvent.re | 16 + packages/webapi/Webapi__Dom__ValidityState.re | 13 + .../webapi/Webapi__Dom__WebGlContextEvent.re | 11 + packages/webapi/Webapi__Dom__WheelEvent.re | 21 + packages/webapi/Webapi__Dom__Window.re | 135 + packages/webapi/Webapi__File.re | 17 + packages/webapi/Webapi__Performance.re | 3 + packages/webapi/Webapi__ReadableStream.re | 34 + packages/webapi/Webapi__ResizeObserver.re | 13 + ...pi__ResizeObserver__ResizeObserverEntry.re | 4 + packages/webapi/Webapi__Url.re | 61 + packages/webapi/dom.ml | 339 +++ packages/webapi/dune | 6 + packages/webapi/src/dune | 12 - 96 files changed, 6740 insertions(+), 25 deletions(-) rename packages/melange-webapi/src/{dune => _dune} (100%) create mode 100644 packages/webapi/Fetch.ml create mode 100644 packages/webapi/Fetch__Iterator.ml rename packages/webapi/{src => }/Webapi.re (76%) create mode 100644 packages/webapi/Webapi__Base64.re create mode 100644 packages/webapi/Webapi__Blob.re create mode 100644 packages/webapi/Webapi__Canvas.re create mode 100644 packages/webapi/Webapi__Canvas__Canvas2d.re create mode 100644 packages/webapi/Webapi__Canvas__WebGl.re create mode 100644 packages/webapi/Webapi__Dom.re create mode 100644 packages/webapi/Webapi__Dom__AnimationEvent.re create mode 100644 packages/webapi/Webapi__Dom__Attr.re create mode 100644 packages/webapi/Webapi__Dom__BeforeUnloadEvent.re create mode 100644 packages/webapi/Webapi__Dom__CdataSection.re create mode 100644 packages/webapi/Webapi__Dom__CharacterData.re create mode 100644 packages/webapi/Webapi__Dom__ChildNode.re create mode 100644 packages/webapi/Webapi__Dom__ClipboardEvent.re create mode 100644 packages/webapi/Webapi__Dom__CloseEvent.re create mode 100644 packages/webapi/Webapi__Dom__Comment.re create mode 100644 packages/webapi/Webapi__Dom__CompositionEvent.re create mode 100644 packages/webapi/Webapi__Dom__CssStyleDeclaration.re create mode 100644 packages/webapi/Webapi__Dom__CustomEvent.re create mode 100644 packages/webapi/Webapi__Dom__Document.re create mode 100644 packages/webapi/Webapi__Dom__DocumentFragment.re create mode 100644 packages/webapi/Webapi__Dom__DocumentOrShadowRoot.re create mode 100644 packages/webapi/Webapi__Dom__DocumentType.re create mode 100644 packages/webapi/Webapi__Dom__DomImplementation.re create mode 100644 packages/webapi/Webapi__Dom__DomRect.re create mode 100644 packages/webapi/Webapi__Dom__DomStringMap.re create mode 100644 packages/webapi/Webapi__Dom__DomTokenList.re create mode 100644 packages/webapi/Webapi__Dom__DragEvent.re create mode 100644 packages/webapi/Webapi__Dom__Element.re create mode 100644 packages/webapi/Webapi__Dom__ErrorEvent.re create mode 100644 packages/webapi/Webapi__Dom__Event.re create mode 100644 packages/webapi/Webapi__Dom__EventTarget.re create mode 100644 packages/webapi/Webapi__Dom__FocusEvent.re create mode 100644 packages/webapi/Webapi__Dom__GlobalEventHandlers.re create mode 100644 packages/webapi/Webapi__Dom__History.re create mode 100644 packages/webapi/Webapi__Dom__HtmlCollection.re create mode 100644 packages/webapi/Webapi__Dom__HtmlDocument.re create mode 100644 packages/webapi/Webapi__Dom__HtmlElement.re create mode 100644 packages/webapi/Webapi__Dom__HtmlFormElement.re create mode 100644 packages/webapi/Webapi__Dom__HtmlImageElement.re create mode 100644 packages/webapi/Webapi__Dom__HtmlInputElement.re create mode 100644 packages/webapi/Webapi__Dom__IdbVersionChangeEvent.re create mode 100644 packages/webapi/Webapi__Dom__Image.re create mode 100644 packages/webapi/Webapi__Dom__InputEvent.re create mode 100644 packages/webapi/Webapi__Dom__KeyboardEvent.re create mode 100644 packages/webapi/Webapi__Dom__Location.re create mode 100644 packages/webapi/Webapi__Dom__MouseEvent.re create mode 100644 packages/webapi/Webapi__Dom__MutationObserver.re create mode 100644 packages/webapi/Webapi__Dom__MutationRecord.re create mode 100644 packages/webapi/Webapi__Dom__NamedNodeMap.re create mode 100644 packages/webapi/Webapi__Dom__Node.re create mode 100644 packages/webapi/Webapi__Dom__NodeFilter.re create mode 100644 packages/webapi/Webapi__Dom__NodeIterator.re create mode 100644 packages/webapi/Webapi__Dom__NodeList.re create mode 100644 packages/webapi/Webapi__Dom__NonDocumentTypeChildNode.re create mode 100644 packages/webapi/Webapi__Dom__NonElementParentNode.re create mode 100644 packages/webapi/Webapi__Dom__PageTransitionEvent.re create mode 100644 packages/webapi/Webapi__Dom__ParentNode.re create mode 100644 packages/webapi/Webapi__Dom__PointerEvent.re create mode 100644 packages/webapi/Webapi__Dom__PopStateEvent.re create mode 100644 packages/webapi/Webapi__Dom__ProcessingInstruction.re create mode 100644 packages/webapi/Webapi__Dom__ProgressEvent.re create mode 100644 packages/webapi/Webapi__Dom__Range.re create mode 100644 packages/webapi/Webapi__Dom__RelatedEvent.re create mode 100644 packages/webapi/Webapi__Dom__Selection.re create mode 100644 packages/webapi/Webapi__Dom__ShadowRoot.re create mode 100644 packages/webapi/Webapi__Dom__Slotable.re create mode 100644 packages/webapi/Webapi__Dom__StorageEvent.re create mode 100644 packages/webapi/Webapi__Dom__SvgZoomEvent.re create mode 100644 packages/webapi/Webapi__Dom__Text.re create mode 100644 packages/webapi/Webapi__Dom__TimeEvent.re create mode 100644 packages/webapi/Webapi__Dom__TouchEvent.re create mode 100644 packages/webapi/Webapi__Dom__TrackEvent.re create mode 100644 packages/webapi/Webapi__Dom__TransitionEvent.re create mode 100644 packages/webapi/Webapi__Dom__TreeWalker.re create mode 100644 packages/webapi/Webapi__Dom__Types.re create mode 100644 packages/webapi/Webapi__Dom__UiEvent.re create mode 100644 packages/webapi/Webapi__Dom__ValidityState.re create mode 100644 packages/webapi/Webapi__Dom__WebGlContextEvent.re create mode 100644 packages/webapi/Webapi__Dom__WheelEvent.re create mode 100644 packages/webapi/Webapi__Dom__Window.re create mode 100644 packages/webapi/Webapi__File.re create mode 100644 packages/webapi/Webapi__Performance.re create mode 100644 packages/webapi/Webapi__ReadableStream.re create mode 100644 packages/webapi/Webapi__ResizeObserver.re create mode 100644 packages/webapi/Webapi__ResizeObserver__ResizeObserverEntry.re create mode 100644 packages/webapi/Webapi__Url.re create mode 100644 packages/webapi/dom.ml create mode 100644 packages/webapi/dune delete mode 100644 packages/webapi/src/dune diff --git a/packages/melange-fetch/src/Fetch.ml b/packages/melange-fetch/src/Fetch.ml index fc5c93158..e027e1066 100644 --- a/packages/melange-fetch/src/Fetch.ml +++ b/packages/melange-fetch/src/Fetch.ml @@ -22,8 +22,10 @@ module AbortController = struct (* external signal : t -> signal = "signal" [@@bs.get] *) let signal _ = assert false + (* external abort : unit = "abort" [@@bs.send.pipe: t] *) let abort _ = () + (* external make : unit -> t = "AbortController" [@@bs.new] *) let make () = assert false end diff --git a/packages/melange-runtime/dom_storage.ml b/packages/melange-runtime/dom_storage.ml index a7cf08b2d..f9c7adffb 100644 --- a/packages/melange-runtime/dom_storage.ml +++ b/packages/melange-runtime/dom_storage.ml @@ -1,18 +1,20 @@ type t = Dom_storage2.t (* external getItem : string -> string option = "getItem" - [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) + [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) let getItem _k = None (* external setItem : string -> string -> unit = "setItem" [@@bs.send.pipe: t] *) let setItem _k _v = () + (* external removeItem : string -> unit = "removeItem" [@@bs.send.pipe: t] *) let removeItem _k = () + (* external clear : unit -> unit = "clear" [@@bs.send.pipe: t] *) let clear _ = () (* external key : int -> string option = "key" - [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) + [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) let key _ = None (* external length : t -> int = "length" [@@bs.get] *) diff --git a/packages/melange-runtime/dom_storage2.ml b/packages/melange-runtime/dom_storage2.ml index 36659525f..2d726fb5c 100644 --- a/packages/melange-runtime/dom_storage2.ml +++ b/packages/melange-runtime/dom_storage2.ml @@ -1,18 +1,20 @@ type t (* external getItem : string -> string option = "getItem" - [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) + [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) let getItem _k = None (* external setItem : string -> string -> unit = "setItem" [@@bs.send.pipe: t] *) let setItem _k _v = () + (* external removeItem : string -> unit = "removeItem" [@@bs.send.pipe: t] *) let removeItem _k = () + (* external clear : unit -> unit = "clear" [@@bs.send.pipe: t] *) let clear _ = () (* external key : int -> string option = "key" - [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) + [@@bs.send.pipe: t] [@@bs.return null_to_opt] *) let key _ = None (* external length : t -> int = "length" [@@bs.get] *) diff --git a/packages/melange-webapi/src/dune b/packages/melange-webapi/src/_dune similarity index 100% rename from packages/melange-webapi/src/dune rename to packages/melange-webapi/src/_dune diff --git a/packages/webapi/Fetch.ml b/packages/webapi/Fetch.ml new file mode 100644 index 000000000..88c15d441 --- /dev/null +++ b/packages/webapi/Fetch.ml @@ -0,0 +1,476 @@ +type body +type bodyInit +type headers +type headersInit +type response +type request +type requestInit +type abortController +type signal + +(* external *) +type arrayBuffer (* TypedArray *) +type bufferSource (* Web IDL, either an arrayBuffer or arrayBufferView *) +type formData (* XMLHttpRequest *) +type readableStream (* Streams *) +type urlSearchParams (* URL *) +type blob +type file + +module AbortController = struct + type t = abortController + + external signal : t -> signal = "signal" [@@bs.get] + external abort : unit = "abort" [@@bs.send.pipe: t] + external make : unit -> t = "AbortController" [@@bs.new] +end + +type requestMethod = + | Get + | Head + | Post + | Put + | Delete + | Connect + | Options + | Trace + | Patch + | Other of string + +let encodeRequestMethod = (* internal *) + function + | Get -> "GET" + | Head -> "HEAD" + | Post -> "POST" + | Put -> "PUT" + | Delete -> "DELETE" + | Connect -> "CONNECT" + | Options -> "OPTIONS" + | Trace -> "TRACE" + | Patch -> "PATCH" + | Other method_ -> method_ + +let decodeRequestMethod = (* internal *) + function + | "GET" -> Get + | "HEAD" -> Head + | "POST" -> Post + | "PUT" -> Put + | "DELETE" -> Delete + | "CONNECT" -> Connect + | "OPTIONS" -> Options + | "TRACE" -> Trace + | "PATCH" -> Patch + | method_ -> Other method_ + +type referrerPolicy = + | None + | NoReferrer + | NoReferrerWhenDowngrade + | SameOrigin + | Origin + | StrictOrigin + | OriginWhenCrossOrigin + | StrictOriginWhenCrossOrigin + | UnsafeUrl + +let encodeReferrerPolicy = (* internal *) + function + | NoReferrer -> "no-referrer" + | None -> "" + | NoReferrerWhenDowngrade -> "no-referrer-when-downgrade" + | SameOrigin -> "same-origin" + | Origin -> "origin" + | StrictOrigin -> "strict-origin" + | OriginWhenCrossOrigin -> "origin-when-cross-origin" + | StrictOriginWhenCrossOrigin -> "strict-origin-when-cross-origin" + | UnsafeUrl -> "unsafe-url" + +let decodeReferrerPolicy = (* internal *) + function + | "no-referrer" -> NoReferrer + | "" -> None + | "no-referrer-when-downgrade" -> NoReferrerWhenDowngrade + | "same-origin" -> SameOrigin + | "origin" -> Origin + | "strict-origin" -> StrictOrigin + | "origin-when-cross-origin" -> OriginWhenCrossOrigin + | "strict-origin-when-cross-origin" -> StrictOriginWhenCrossOrigin + | "unsafe-url" -> UnsafeUrl + | e -> raise (Failure ("Unknown referrerPolicy: " ^ e)) + +type requestType = + | None (* default? unknown? just empty string in spec *) + | Audio + | Font + | Image + | Script + | Style + | Track + | Video + +let decodeRequestType = (* internal *) + function + | "audio" -> Audio + | "" -> None + | "font" -> Font + | "image" -> Image + | "script" -> Script + | "style" -> Style + | "track" -> Track + | "video" -> Video + | e -> raise (Failure ("Unknown requestType: " ^ e)) + +type requestDestination = + | None (* default? unknown? just empty string in spec *) + | Document + | Embed + | Font + | Image + | Manifest + | Media + | Object + | Report + | Script + | ServiceWorker + | SharedWorker + | Style + | Worker + | Xslt + +let decodeRequestDestination = (* internal *) + function + | "document" -> Document + | "" -> None + | "embed" -> Embed + | "font" -> Font + | "image" -> Image + | "manifest" -> Manifest + | "media" -> Media + | "object" -> Object + | "report" -> Report + | "script" -> Script + | "serviceworker" -> ServiceWorker + | "sharedworder" -> SharedWorker + | "style" -> Style + | "worker" -> Worker + | "xslt" -> Xslt + | e -> raise (Failure ("Unknown requestDestination: " ^ e)) + +type requestMode = Navigate | SameOrigin | NoCORS | CORS + +let encodeRequestMode = (* internal *) + function + | Navigate -> "navigate" + | SameOrigin -> "same-origin" + | NoCORS -> "no-cors" + | CORS -> "cors" + +let decodeRequestMode = (* internal *) + function + | "navigate" -> Navigate + | "same-origin" -> SameOrigin + | "no-cors" -> NoCORS + | "cors" -> CORS + | e -> raise (Failure ("Unknown requestMode: " ^ e)) + +type requestCredentials = Omit | SameOrigin | Include + +let encodeRequestCredentials = (* internal *) + function + | Omit -> "omit" + | SameOrigin -> "same-origin" + | Include -> "include" + +let decodeRequestCredentials = (* internal *) + function + | "omit" -> Omit + | "same-origin" -> SameOrigin + | "include" -> Include + | e -> raise (Failure ("Unknown requestCredentials: " ^ e)) + +type requestCache = + | Default + | NoStore + | Reload + | NoCache + | ForceCache + | OnlyIfCached + +let encodeRequestCache = (* internal *) + function + | Default -> "default" + | NoStore -> "no-store" + | Reload -> "reload" + | NoCache -> "no-cache" + | ForceCache -> "force-cache" + | OnlyIfCached -> "only-if-cached" + +let decodeRequestCache = (* internal *) + function + | "default" -> Default + | "no-store" -> NoStore + | "reload" -> Reload + | "no-cache" -> NoCache + | "force-cache" -> ForceCache + | "only-if-cached" -> OnlyIfCached + | e -> raise (Failure ("Unknown requestCache: " ^ e)) + +type requestRedirect = Follow | Error | Manual + +let encodeRequestRedirect = (* internal *) + function + | Follow -> "follow" + | Error -> "error" + | Manual -> "manual" + +let decodeRequestRedirect = (* internal *) + function + | "follow" -> Follow + | "error" -> Error + | "manual" -> Manual + | e -> raise (Failure ("Unknown requestRedirect: " ^ e)) + +module HeadersInit = struct + type t = headersInit + + external make : < .. > Js.t -> t = "%identity" + external makeWithDict : string Js.Dict.t -> t = "%identity" + external makeWithArray : (string * string) array -> t = "%identity" +end + +module Headers = struct + type t = headers + + (* external make : t = "Headers" [@@bs.new] *) + external makeWithInit : headersInit -> t = "Headers" [@@bs.new] + external append : string -> string -> unit = "append" [@@bs.send.pipe: t] + external delete : string -> unit = "delete" [@@bs.send.pipe: t] + (* entries *) + (* very experimental *) + + external get : string -> string option = "get" + [@@bs.send.pipe: t] [@@bs.return { null_to_opt }] + + external has : string -> bool = "has" [@@bs.send.pipe: t] + (* keys *) + (* very experimental *) + + external set : string -> string -> unit = "set" [@@bs.send.pipe: t] + (* values *) + (* very experimental *) +end + +module BodyInit = struct + type t = bodyInit + + external make : string -> t = "%identity" + external makeWithBlob : blob -> t = "%identity" + external makeWithBufferSource : bufferSource -> t = "%identity" + external makeWithFormData : formData -> t = "%identity" + external makeWithUrlSearchParams : urlSearchParams -> t = "%identity" +end + +module Body = struct + module Impl (T : sig + type t + end) = + struct + external body : T.t -> readableStream = "body" [@@bs.get] + external bodyUsed : T.t -> bool = "bodyUsed" [@@bs.get] + + (* external arrayBuffer : arrayBuffer Js.Promise.t = "arrayBuffer" + [@@bs.send.pipe: T.t] *) + + (* external blob : blob Js.Promise.t = "blob" [@@bs.send.pipe: T.t] *) + (* external formData : formData Js.Promise.t = "formData" [@@bs.send.pipe: T.t] *) + (* external json : Js.Json.t Js.Promise.t = "json" [@@bs.send.pipe: T.t] *) + (* external text : string Js.Promise.t = "text" [@@bs.send.pipe: T.t] *) + end + + type t = body + + include Impl (struct + type nonrec t = t + end) +end + +module RequestInit = struct + type t = requestInit + + let map f = function (* internal *) + | Some v -> Some (f v) | None -> None + + external make : + ?_method:string -> + ?headers:headersInit -> + ?body:bodyInit -> + ?referrer:string -> + ?referrerPolicy:string -> + ?mode:string -> + ?credentials:string -> + ?cache:string -> + ?redirect:string -> + ?integrity:string -> + ?keepalive:bool -> + ?signal:signal -> + unit -> + requestInit = "" + [@@bs.obj] + + let make ?(method_ : requestMethod option) ?(headers : headersInit option) + ?(body : bodyInit option) ?(referrer : string option) + ?(referrerPolicy : referrerPolicy = None) ?(mode : requestMode option) + ?(credentials : requestCredentials option) ?(cache : requestCache option) + ?(redirect : requestRedirect option) ?(integrity : string = "") + ?(keepalive : bool option) ?(signal : signal option) = + make + ?_method:(map encodeRequestMethod method_) + ?headers ?body ?referrer + ~referrerPolicy:(encodeReferrerPolicy referrerPolicy) + ?mode:(map encodeRequestMode mode) + ?credentials:(map encodeRequestCredentials credentials) + ?cache:(map encodeRequestCache cache) + ?redirect:(map encodeRequestRedirect redirect) + ~integrity ?keepalive ?signal +end + +module Request = struct + type t = request + + include Body.Impl (struct + type nonrec t = t + end) + + external make : string -> t = "Request" [@@bs.new] + external makeWithInit : string -> requestInit -> t = "Request" [@@bs.new] + external makeWithRequest : t -> t = "Request" [@@bs.new] + external makeWithRequestInit : t -> requestInit -> t = "Request" [@@bs.new] + external method_ : t -> string = "method" [@@bs.get] + + let method_ : t -> requestMethod = + fun self -> decodeRequestMethod (method_ self) + + external url : t -> string = "url" [@@bs.get] + external headers : t -> headers = "headers" [@@bs.get] + external type_ : t -> string = "type" [@@bs.get] + + let type_ : t -> requestType = fun self -> decodeRequestType (type_ self) + + external destination : t -> string = "destination" [@@bs.get] + + let destination : t -> requestDestination = + fun self -> decodeRequestDestination (destination self) + + external referrer : t -> string = "referrer" [@@bs.get] + external referrerPolicy : t -> string = "referrerPolicy" [@@bs.get] + + let referrerPolicy : t -> referrerPolicy = + fun self -> decodeReferrerPolicy (referrerPolicy self) + + external mode : t -> string = "mode" [@@bs.get] + + let mode : t -> requestMode = fun self -> decodeRequestMode (mode self) + + external credentials : t -> string = "credentials" [@@bs.get] + + let credentials : t -> requestCredentials = + fun self -> decodeRequestCredentials (credentials self) + + external cache : t -> string = "cache" [@@bs.get] + + let cache : t -> requestCache = fun self -> decodeRequestCache (cache self) + + external redirect : t -> string = "redirect" [@@bs.get] + + let redirect : t -> requestRedirect = + fun self -> decodeRequestRedirect (redirect self) + + external integrity : t -> string = "integrity" [@@bs.get] + external keepalive : t -> bool = "keepalive" [@@bs.get] + external signal : t -> signal = "signal" [@@bs.get] +end + +module Response = struct + type t = response + + include Body.Impl (struct + type nonrec t = t + end) + + external error : unit -> t = "error" [@@bs.val] + external redirect : string -> t = "redirect" [@@bs.val] + + external redirectWithStatus : string -> int (* enum-ish *) -> t = "redirect" + [@@bs.val] + + external headers : t -> headers = "headers" [@@bs.get] + external ok : t -> bool = "ok" [@@bs.get] + external redirected : t -> bool = "redirected" [@@bs.get] + external status : t -> int = "status" [@@bs.get] + external statusText : t -> string = "statusText" [@@bs.get] + external type_ : t -> string = "type" [@@bs.get] + external url : t -> string = "url" [@@bs.get] + external clone : t = "clone" [@@bs.send.pipe: t] +end + +module FormData = struct + module EntryValue = struct + type t + + let classify : t -> [> `String of string | `File of file ] = + fun t -> + if Js.typeof t = "string" then `String (Obj.magic t) + else `File (Obj.magic t) + end + + module Iterator = Fetch__Iterator + + type t = formData + + external make : unit -> t = "FormData" [@@bs.new] + external append : string -> string -> unit = "append" [@@bs.send.pipe: t] + external delete : string -> unit = "delete" [@@bs.send.pipe: t] + external get : string -> EntryValue.t option = "get" [@@bs.send.pipe: t] + external getAll : string -> EntryValue.t array = "getAll" [@@bs.send.pipe: t] + external set : string -> string -> unit = "set" [@@bs.send.pipe: t] + external has : string -> bool = "has" [@@bs.send.pipe: t] + external keys : t -> string Fetch__Iterator.t = "keys" [@@bs.send] + external values : t -> EntryValue.t Fetch__Iterator.t = "values" [@@bs.send] + + external appendObject : string -> < .. > Js.t -> ?filename:string -> unit + = "append" + [@@bs.send.pipe: t] + + external appendBlob : string -> blob -> ?filename:string -> unit = "append" + [@@bs.send.pipe: t] + + external appendFile : string -> file -> ?filename:string -> unit = "append" + [@@bs.send.pipe: t] + + external setObject : string -> < .. > Js.t -> ?filename:string -> unit = "set" + [@@bs.send.pipe: t] + + external setBlob : string -> blob -> ?filename:string -> unit = "set" + [@@bs.send.pipe: t] + + external setFile : string -> file -> ?filename:string -> unit = "set" + [@@bs.send.pipe: t] + + external entries : t -> (string * EntryValue.t) Fetch__Iterator.t = "entries" + [@@bs.send] +end + +(* external fetch : string -> response Js.Promise.t = "fetch" [@@bs.val] *) + +(* external fetchWithInit : string -> requestInit -> response Js.Promise.t + = "fetch" + [@@bs.val] *) + +(* external fetchWithRequest : request -> response Js.Promise.t = "fetch" + [@@bs.val] *) + +(* external fetchWithRequestInit : request -> requestInit -> response Js.Promise.t + = "fetch" + [@@bs.val] +*) diff --git a/packages/webapi/Fetch__Iterator.ml b/packages/webapi/Fetch__Iterator.ml new file mode 100644 index 000000000..c8a10e7b8 --- /dev/null +++ b/packages/webapi/Fetch__Iterator.ml @@ -0,0 +1,20 @@ +module Next = struct + type 'a t + + let done_ _ = None + let value _ = None +end + +type 'a t + +let next t = t + +let rec forEach ~f t = + let item = next t in + match Next.(done_ item, value item) with + | Some true, Some value -> f value + | Some true, None -> () + | (Some false | None), Some value -> + f value; + forEach ~f t + | (Some false | None), None -> forEach ~f t diff --git a/packages/webapi/src/Webapi.re b/packages/webapi/Webapi.re similarity index 76% rename from packages/webapi/src/Webapi.re rename to packages/webapi/Webapi.re index bfe17462d..6e225ad48 100644 --- a/packages/webapi/src/Webapi.re +++ b/packages/webapi/Webapi.re @@ -13,14 +13,12 @@ module File = Webapi__File; [Webapi.Dom.HtmlFormElement.data]. @since 0.18.0 */ -module FormData = Fetch.FormData; - +/* module FormData = Fetch.FormData; */ /** Re-export from [bs-fetch] for convenience. See also {!module:FormData}. @since 0.18.0 */ -module Iterator = FormData.Iterator; - +/* module Iterator = FormData.Iterator; */ module Performance = Webapi__Performance; /** @since 0.19.0 */ @@ -31,11 +29,8 @@ module Url = Webapi__Url; type rafId; -[@bs.val] -external requestAnimationFrame: (float => unit) => unit = - "requestAnimationFrame"; +[@bs.val] external requestAnimationFrame: (float => unit) => unit; [@bs.val] external requestCancellableAnimationFrame: (float => unit) => rafId = "requestAnimationFrame"; -[@bs.val] -external cancelAnimationFrame: rafId => unit = "cancelAnimationFrame"; +[@bs.val] external cancelAnimationFrame: rafId => unit; diff --git a/packages/webapi/Webapi__Base64.re b/packages/webapi/Webapi__Base64.re new file mode 100644 index 000000000..b173f510e --- /dev/null +++ b/packages/webapi/Webapi__Base64.re @@ -0,0 +1,2 @@ +[@bs.val] external btoa: (string, string) => int; +[@bs.val] external atob: (string, string) => int; diff --git a/packages/webapi/Webapi__Blob.re b/packages/webapi/Webapi__Blob.re new file mode 100644 index 000000000..1fddb56f9 --- /dev/null +++ b/packages/webapi/Webapi__Blob.re @@ -0,0 +1,29 @@ +module Impl = (T: {type t;}) => { + /* [@bs.send] + external arrayBuffer: T.t => Js.Promise.t(Js.Typed_array.ArrayBuffer.t); */ + + [@bs.get] external size: T.t => float; + + [@bs.send.pipe: T.t] + external slice: (~start: int=?, ~end_: int=?, ~contentType: string=?) => T.t; + + /** @since 0.19.0 */ + [@bs.send] + external stream: T.t => Webapi__ReadableStream.t; + + /* [@bs.send] external text: T.t => Js.Promise.t(string); */ + + [@bs.get] external type_: T.t => string = "type"; + + /** Deprecated, use [type_] instead. */ + [@deprecated "Use [type_] instead"] [@bs.get] + external _type: T.t => string = "type"; +}; + +type t = Fetch.blob; + +include Impl({ + type nonrec t = t; +}); + +// [@bs.new] external make: ... = "Blob"; diff --git a/packages/webapi/Webapi__Canvas.re b/packages/webapi/Webapi__Canvas.re new file mode 100644 index 000000000..acb1da705 --- /dev/null +++ b/packages/webapi/Webapi__Canvas.re @@ -0,0 +1,15 @@ +module Canvas2d = Webapi__Canvas__Canvas2d; +module WebGl = Webapi__Canvas__WebGl; + +module CanvasElement = { + [@bs.send] + external getContext2d: (Dom.element, [@bs.as "2d"] _) => Canvas2d.t = + "getContext"; + [@bs.send] + external getContextWebGl: (Dom.element, [@bs.as "webgl"] _) => WebGl.glT = + "getContext"; + [@bs.get] external height: Dom.element => int = "height"; + [@bs.set] external setHeight: (Dom.element, int) => unit = "height"; + [@bs.get] external width: Dom.element => int = "width"; + [@bs.set] external setWidth: (Dom.element, int) => unit = "width"; +}; diff --git a/packages/webapi/Webapi__Canvas__Canvas2d.re b/packages/webapi/Webapi__Canvas__Canvas2d.re new file mode 100644 index 000000000..cee570623 --- /dev/null +++ b/packages/webapi/Webapi__Canvas__Canvas2d.re @@ -0,0 +1,288 @@ +type t; /* Main type, representing the 2d canvas rendering context object */ +type gradient; +type pattern; +type measureText; + +/* Sub-modules (and their interfaces) for string enum arguments: */ +module type CompositeType = { + type t = pri string; + + let sourceOver: t; + let sourceIn: t; + let sourceOut: t; + let sourceAtop: t; + let destinationOver: t; + let destinationIn: t; + let destinationOut: t; + let destinationAtop: t; + let lighter: t; + let copy: t; + let xor: t; +}; + +module Composite: CompositeType = { + type t = string; + + let sourceOver: t = "source-over"; + let sourceIn: t = "source-in"; + let sourceOut: t = "source-out"; + let sourceAtop: t = "source-atop"; + let destinationOver: t = "destination-over"; + let destinationIn: t = "destination-in"; + let destinationOut: t = "destination-out"; + let destinationAtop: t = "destination-atop"; + let lighter: t = "lighter"; + let copy: t = "copy"; + let xor: t = "xor"; +}; + +module type LineCapType = { + type t = pri string; + + let butt: t; + let round: t; + let square: t; +}; + +module LineCap: LineCapType = { + type t = string; + + let butt: t = "butt"; + let round: t = "round"; + let square: t = "square"; +}; + +module type LineJoinType = { + type t = pri string; + + let round: t; + let bevel: t; + let miter: t; +}; + +module LineJoin: LineJoinType = { + type t = string; + + let round: t = "round"; + let bevel: t = "bevel"; + let miter: t = "miter"; +}; + +type image('a) = + | Number: image(float) + | ImageData: image(Webapi__Dom__Image.t); + +type style(_) = + | String: style(string) + | Gradient: style(gradient) + | Pattern: style(pattern); + +/* 2d Canvas API, following https://simon.html5.org/dump/html5-canvas-cheat-sheet.html */ +[@bs.send.pipe: t] external save: unit; +[@bs.send.pipe: t] external restore: unit; + +/* Transformation */ +[@bs.send.pipe: t] external scale: (~x: float, ~y: float) => unit; +[@bs.send.pipe: t] external rotate: float => unit; +[@bs.send.pipe: t] external translate: (~x: float, ~y: float) => unit; +[@bs.send.pipe: t] +external transform: + ( + ~m11: float, + ~m12: float, + ~m21: float, + ~m22: float, + ~dx: float, + ~dy: float + ) => + unit; +[@bs.send.pipe: t] +external setTransform: + ( + ~m11: float, + ~m12: float, + ~m21: float, + ~m22: float, + ~dx: float, + ~dy: float + ) => + unit; + +/* Compositing */ +[@bs.set] external globalAlpha: (t, float) => unit; +[@bs.set] external globalCompositeOperation: (t, Composite.t) => unit; + +/* Line Styles */ +[@bs.set] external lineWidth: (t, float) => unit; +[@bs.set] external lineCap: (t, LineCap.t) => unit; +[@bs.set] external lineJoin: (t, LineJoin.t) => unit; +[@bs.set] external miterLimit: (t, float) => unit; + +/* Colors, Styles, and Shadows */ +[@bs.set] external setFillStyle: (t, 'a) => unit = "fillStyle"; +[@bs.set] external setStrokeStyle: (t, 'a) => unit = "strokeStyle"; + +/* in re unused warnings + awaiting release of https://github.com/bloomberg/bucklescript/issues/1656 + to just use [@@bs.set] directly with an ignored (style a) */ +let setStrokeStyle = (type a, ctx: t, _: style(a), v: a) => + setStrokeStyle(ctx, v); + +let setFillStyle = (type a, ctx: t, _: style(a), v: a) => + setFillStyle(ctx, v); + +let reifyStyle = (type a, x: 'a): (style(a), a) => { + let isCanvasGradient: 'a => bool = [%raw + {| + function(x) { return x instanceof CanvasGradient; } + |} + ]; + + let isCanvasPattern: 'a => bool = [%raw + {| + function(x) { return x instanceof CanvasPattern; } + |} + ]; + + ( + if (Js.typeof(x) == "string") { + Obj.magic(String); + } else if (isCanvasGradient(x)) { + Obj.magic(Gradient); + } else if (isCanvasPattern(x)) { + Obj.magic(Pattern); + } else { + invalid_arg( + "Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern", + ); + }, + Obj.magic(x), + ); +}; + +[@bs.get] external fillStyle: t => 'a; +[@bs.get] external strokeStyle: t => 'a; + +let fillStyle = (ctx: t) => ctx |> fillStyle |> reifyStyle; + +let strokeStyle = (ctx: t) => ctx |> strokeStyle |> reifyStyle; + +[@bs.set] external shadowOffsetX: (t, float) => unit; +[@bs.set] external shadowOffsetY: (t, float) => unit; +[@bs.set] external shadowBlur: (t, float) => unit; +[@bs.set] external shadowColor: (t, string) => unit; + +/* Gradients */ +[@bs.send.pipe: t] +external createLinearGradient: + (~x0: float, ~y0: float, ~x1: float, ~y1: float) => gradient; +[@bs.send.pipe: t] +external createRadialGradient: + (~x0: float, ~y0: float, ~x1: float, ~y1: float, ~r0: float, ~r1: float) => + gradient; +[@bs.send.pipe: gradient] external addColorStop: (float, string) => unit; +[@bs.val] +external createPattern: + ( + t, + Dom.element, + [@bs.string] [ + | `repeat + | [@bs.as "repeat-x"] `repeatX + | [@bs.as "repeat-y"] `repeatY + | [@bs.as "no-repeat"] `noRepeat + ] + ) => + pattern; + +/* Paths */ +[@bs.send.pipe: t] external beginPath: unit; +[@bs.send.pipe: t] external closePath: unit; +[@bs.send.pipe: t] external fill: unit; +[@bs.send.pipe: t] external stroke: unit; +[@bs.send.pipe: t] external clip: unit; +[@bs.send.pipe: t] external moveTo: (~x: float, ~y: float) => unit; +[@bs.send.pipe: t] external lineTo: (~x: float, ~y: float) => unit; +[@bs.send.pipe: t] +external quadraticCurveTo: + (~cp1x: float, ~cp1y: float, ~x: float, ~y: float) => unit; +[@bs.send.pipe: t] +external bezierCurveTo: + ( + ~cp1x: float, + ~cp1y: float, + ~cp2x: float, + ~cp2y: float, + ~x: float, + ~y: float + ) => + unit; +[@bs.send.pipe: t] +external arcTo: + (~x1: float, ~y1: float, ~x2: float, ~y2: float, ~r: float) => unit; +[@bs.send.pipe: t] +external arc: + ( + ~x: float, + ~y: float, + ~r: float, + ~startAngle: float, + ~endAngle: float, + ~anticw: bool + ) => + unit; +[@bs.send.pipe: t] +external rect: (~x: float, ~y: float, ~w: float, ~h: float) => unit; +[@bs.send.pipe: t] external isPointInPath: (~x: float, ~y: float) => bool; + +/* Text */ +[@bs.set] external font: (t, string) => unit; +[@bs.set] external textAlign: (t, string) => unit; +[@bs.set] external textBaseline: (t, string) => unit; +[@bs.send.pipe: t] +external fillText: (string, ~x: float, ~y: float, ~maxWidth: float=?) => unit; +[@bs.send.pipe: t] +external strokeText: + (string, ~x: float, ~y: float, ~maxWidth: float=?) => unit; +[@bs.send.pipe: t] external measureText: string => measureText; +[@bs.get] external width: measureText => float; + +/* Rectangles */ +[@bs.send.pipe: t] +external fillRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit; +[@bs.send.pipe: t] +external strokeRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit; +[@bs.send.pipe: t] +external clearRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit; + +[@bs.send] +external createImageDataCoords: + (t, ~width: float, ~height: float) => Webapi__Dom__Image.t = + "createImageData"; +[@bs.send] +external createImageDataFromImage: + (t, Webapi__Dom__Image.t) => Webapi__Dom__Image.t = + "createImageData"; + +[@bs.send] +external getImageData: + (t, ~sx: float, ~sy: float, ~sw: float, ~sh: float) => Webapi__Dom__Image.t; + +[@bs.send] +external putImageData: + (t, ~imageData: Webapi__Dom__Image.t, ~dx: float, ~dy: float) => unit; + +[@bs.send] +external putImageDataWithDirtyRect: + ( + t, + ~imageData: Webapi__Dom__Image.t, + ~dx: float, + ~dy: float, + ~dirtyX: float, + ~dirtyY: float, + ~dirtyWidth: float, + ~dirtyHeight: float + ) => + unit = + "putImageData"; diff --git a/packages/webapi/Webapi__Canvas__WebGl.re b/packages/webapi/Webapi__Canvas__WebGl.re new file mode 100644 index 000000000..ad7142ccb --- /dev/null +++ b/packages/webapi/Webapi__Canvas__WebGl.re @@ -0,0 +1,124 @@ +type glT; +type programT; +type shaderT; +type bufferT; + +/* ClearBufferMask */ +let _DEPTH_BUFFER_BIT: int = 256; +let _STENCIL_BUFFER_BIT: int = 1024; +let _COLOR_BUFFER_BIT: int = 16384; + +/* BeginMode */ +let _POINTS: int = 0; +let _LINES: int = 1; +let _LINE_LOOP: int = 2; +let _LINE_STRIP: int = 3; +let _TRIANGLES: int = 4; +let _TRIANGLE_STRIP: int = 5; +let _TRIANGLE_FAN: int = 6; + +/* TEXTURE_2D */ +let _CULL_FACE: int = 2884; +let _BLEND: int = 3042; +let _DITHER: int = 3024; +let _STENCIL_TEST: int = 2960; +let _DEPTH_TEST: int = 2929; +let _SCISSOR_TEST: int = 3089; +let _POLYGON_OFFSET_FILL: int = 32823; +let _SAMPLE_ALPHA_TO_COVERAGE: int = 32926; +let _SAMPLE_COVERAGE: int = 32928; + +/* BlendingFactorDest */ +let _ZERO: int = 0; +let _ONE: int = 1; +let _SRC_COLOR: int = 768; +let _ONE_MINUS_SRC_COLOR: int = 769; +let _SRC_ALPHA: int = 770; +let _ONE_MINUS_SRC_ALPHA: int = 771; +let _DST_ALPHA: int = 772; +let _ONE_MINUS_DST_ALPHA: int = 773; + +/* DataType */ +let _BYTE: int = 5120; +let _UNSIGNED_BYTE: int = 5121; +let _SHORT: int = 5122; +let _UNSIGNED_SHORT: int = 5123; +let _INT: int = 5124; +let _UNSIGNED_INT: int = 5125; +let _FLOAT: int = 5126; + +/* CullFaceMode */ +let _FRONT: int = 1028; +let _BACK: int = 1029; +let _FRONT_AND_BACK: int = 1032; + +/* Shaders */ +let _FRAGMENT_SHADER: int = 35632; +let _VERTEX_SHADER: int = 35633; + +/* Buffer Objects */ +let _ARRAY_BUFFER: int = 34962; +let _ELEMENT_ARRAY_BUFFER: int = 34963; +let _ARRAY_BUFFER_BINDING: int = 34964; +let _ELEMENT_ARRAY_BUFFER_BINDING: int = 34965; +let _STREAM_DRAW: int = 35040; +let _STATIC_DRAW: int = 35044; +let _DYNAMIC_DRAW: int = 35048; + +/* void clear(GLbitfield mask); */ +[@bs.send] external clear: (glT, int) => unit = "clear"; +/* void clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); */ +[@bs.send] +external clearColor: (glT, float, float, float, float) => unit = "clearColor"; +/* void enable(GLenum cap); */ +[@bs.send] external enable: (glT, int) => unit = "enable"; +/* void disable(GLenum cap); */ +[@bs.send] external disable: (glT, int) => unit = "disable"; +/* void blendFunc(GLenum sfactor, GLenum dfactor); */ +[@bs.send] external blendFunc: (glT, int, int) => unit = "blendFunc"; +/* void cullFace(GLenum mode); */ +[@bs.send] external cullFace: (glT, int) => unit = "cullFace"; +[@bs.send] external createBuffer: glT => bufferT = "createBuffer"; +[@bs.send] external deleteBuffer: (glT, bufferT) => unit = "deleteBuffer"; +[@bs.send] external bindBuffer: (glT, int, bufferT) => unit = "bindBuffer"; +/* [@bs.send] + external bufferData: (glT, int, Js.Typed_array.Uint16Array.t, int) => unit = + "bufferData"; */ +/* [@bs.send] + external bufferFloatData: + (glT, int, Js.Typed_array.Float32Array.t, int) => unit = + "bufferData"; */ +[@bs.send] external createProgram: glT => programT = "createProgram"; +[@bs.send] external linkProgram: (glT, programT) => unit = "linkProgram"; +[@bs.send] external useProgram: (glT, programT) => unit = "useProgram"; +[@bs.send] +external getProgramInfoLog: (glT, programT) => string = "getProgramInfoLog"; +[@bs.send] +external bindAttribLocation: (glT, programT, int, string) => unit = + "bindAttribLocation"; +[@bs.send] external createShader: (glT, int) => shaderT = "createShader"; +[@bs.send] +external shaderSource: (glT, shaderT, string) => unit = "shaderSource"; +[@bs.send] external compileShader: (glT, shaderT) => unit = "compileShader"; +[@bs.send] +external attachShader: (glT, programT, shaderT) => unit = "attachShader"; +[@bs.send] +external getShaderInfoLog: (glT, shaderT) => string = "getShaderInfoLog"; +/* void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset); */ +[@bs.send] +external drawElements: (glT, int, int, int, int) => unit = "drawElements"; +/* void enableVertexAttribArray(GLuint index); */ +[@bs.send] +external enableVertexAttribArray: (glT, int) => unit = + "enableVertexAttribArray"; +/* void vertexAttribPointer(GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, GLintptr offset); */ +[@bs.send] +external vertexAttribPointer: (glT, int, int, int, bool, int, int) => unit = + "vertexAttribPointer"; +/* GLint gl.getAttribLocation(program, name); */ +[@bs.send] +external getAttribLocation: (glT, programT, string) => int = + "getAttribLocation"; +/* void gl.drawArrays(mode, first, count); */ +[@bs.send] external drawArrays: (glT, int, int, int) => unit = "drawArrays"; diff --git a/packages/webapi/Webapi__Dom.re b/packages/webapi/Webapi__Dom.re new file mode 100644 index 000000000..ab41ed2b7 --- /dev/null +++ b/packages/webapi/Webapi__Dom.re @@ -0,0 +1,336 @@ +module AnimationEvent = Webapi__Dom__AnimationEvent; +module Attr = Webapi__Dom__Attr; +module BeforeUnloadEvent = Webapi__Dom__BeforeUnloadEvent; +module CdataSection = Webapi__Dom__CdataSection; +module CharacterData = Webapi__Dom__CharacterData; +module Comment = Webapi__Dom__Comment; +module CssStyleDeclaration = Webapi__Dom__CssStyleDeclaration; +module ClipboardEvent = Webapi__Dom__ClipboardEvent; +module CloseEvent = Webapi__Dom__CloseEvent; +module CompositionEvent = Webapi__Dom__CompositionEvent; +module CustomEvent = Webapi__Dom__CustomEvent; +module Document = Webapi__Dom__Document; +module DocumentFragment = Webapi__Dom__DocumentFragment; +module DocumentType = Webapi__Dom__DocumentType; +module DomImplementation = Webapi__Dom__DomImplementation; +module DomRect = Webapi__Dom__DomRect; +module DomStringMap = Webapi__Dom__DomStringMap; +module DomTokenList = Webapi__Dom__DomTokenList; +module DragEvent = Webapi__Dom__DragEvent; +module Element = Webapi__Dom__Element; +module ErrorEvent = Webapi__Dom__ErrorEvent; +module Event = Webapi__Dom__Event; +module EventTarget = Webapi__Dom__EventTarget; +module FocusEvent = Webapi__Dom__FocusEvent; +module History = Webapi__Dom__History; +module HtmlCollection = Webapi__Dom__HtmlCollection; +module HtmlDocument = Webapi__Dom__HtmlDocument; +module HtmlElement = Webapi__Dom__HtmlElement; +module HtmlFormElement = Webapi__Dom__HtmlFormElement; +module HtmlImageElement = Webapi__Dom__HtmlImageElement; +module HtmlInputElement = Webapi__Dom__HtmlInputElement; +module IdbVersionChangeEvent = Webapi__Dom__IdbVersionChangeEvent; +module Image = Webapi__Dom__Image; +module InputEvent = Webapi__Dom__InputEvent; +module KeyboardEvent = Webapi__Dom__KeyboardEvent; +module Location = Webapi__Dom__Location; +module MouseEvent = Webapi__Dom__MouseEvent; +module MutationObserver = Webapi__Dom__MutationObserver; +module MutationRecord = Webapi__Dom__MutationRecord; +module NamedNodeMap = Webapi__Dom__NamedNodeMap; +module Node = Webapi__Dom__Node; +module NodeFilter = Webapi__Dom__NodeFilter; +module NodeIterator = Webapi__Dom__NodeIterator; +module NodeList = Webapi__Dom__NodeList; +module PageTransitionEvent = Webapi__Dom__PageTransitionEvent; +module PointerEvent = Webapi__Dom__PointerEvent; +module PopStateEvent = Webapi__Dom__PopStateEvent; +module ProcessingInstruction = Webapi__Dom__ProcessingInstruction; +module ProgressEvent = Webapi__Dom__ProgressEvent; +module Range = Webapi__Dom__Range; +module RelatedEvent = Webapi__Dom__RelatedEvent; +module Selection = Webapi__Dom__Selection; +module ShadowRoot = Webapi__Dom__ShadowRoot; +module StorageEvent = Webapi__Dom__StorageEvent; +module SvgZoomEvent = Webapi__Dom__SvgZoomEvent; +module Text = Webapi__Dom__Text; +module TimeEvent = Webapi__Dom__TimeEvent; +module TouchEvent = Webapi__Dom__TouchEvent; +module TrackEvent = Webapi__Dom__TrackEvent; +module TransitionEvent = Webapi__Dom__TransitionEvent; +module TreeWalker = Webapi__Dom__TreeWalker; +module UiEvent = Webapi__Dom__UiEvent; +module ValidityState = Webapi__Dom__ValidityState; +module WebGlContextEvent = Webapi__Dom__WebGlContextEvent; +module WheelEvent = Webapi__Dom__WheelEvent; +module Window = Webapi__Dom__Window; + +include Webapi__Dom__Types; + +/* [@bs.val] external window: Dom.window = "window"; */ +let window = assert(false); +/* [@bs.val] external document: Dom.document = "document"; */ +let document = assert(false); +/* [@bs.val] [@bs.scope "window"] external history: Dom.history = "history"; */ +let history = assert(false); +/* [@bs.val] [@bs.scope "window"] external location: Dom.location = "location"; */ +let location = assert(false); + +/* Unimplemented interfaces (aka. "The TODO list") + + Attr + CharacterData + ChildNode /* experimental */ + Comment + DocumentFragment + DocumentType + DOMError + DOMException + DOMImplementation + DOMTimeStamp + DOMSettableTokenList /* deprecated, merged with DOMTokenList */ + DOMStringList + MutationObserver + MutationRecord + NodeIterator + ParentNode /* experimental */ + ProcessingInstruction + Text + TreeWalker + URL + Worker + XMLDocument /* experimental */ + + /* HTML Elements */ + HTMLAnchorElement + HTMLAppletElement + HTMLAreaElement + HTMLAudioElement + HTMLBaseElement + HTMLBodyElement + HTMLBRElement + HTMLButtonELement + HTMLCanvasElement + HTMLDataElement + HTMLDataListElement + HTMLDialogElement + HTMLDirectoryElement + HTMLDivElement + HTMLDListElement + HTMLEmbedElement + HTMLFieldSetElement + HTMLFontElement + HTMLFrameElement + HTMLFrameSetElement + HTMLHeadElement + HTMLHeadingElement + HTMLHtmlElement + HTMLHRElement + HTMLIFrameElement + HTMLKeygenElement + HTMLLabelElement + HTMLLegendElement + HTMLLIElement + HTMLLinkElement + HTMLMapElement + HTMLMediaElement + HTMLMenuElement + HTMLMetaElement + HTMLMeterElement + HTMLModElement + HTMLObjectElement + HTMLOListElement + HTMLOptGroupElement + HTMLOptionElement + HTMLOutputElement + HTMLParagraphElement + HTMLParamElement + HTMLPreElement + HTMLProgressElement + HTMLQuoteElement + HTMLScriptElement + HTMLSelectElement + HTMLSourceElement + HTMLSpanElement + HTMLStyleElement + HTMLTableElement + HTMLTableCaptionElement + HTMLTableCellElement + HTMLTableDataCellElement + HTMLTableHeaderCellElement + HTMLTableColElement + HTMLTableRowElement + HTMLTableSectionElement + HTMLTextAreaElement + HTMLTimeElement + HTMLTitleElement + HTMLTrackElement + HTMLUListElement + HTMLUnknownElement + HTMLVideoElement + + /* Other interfaces */ + CanvasRenderingContext2D + CanvasGradient + CanvasPattern + TextMetrics + ImageData + CanvasPixelArray + NotifyAudioAvailableEvent + HTMLAllCollection + HTMLFormControlsCollection + HTMLOptionsCollection + HTMLPropertiesCollection + DOMStringMap + RadioNodeList + MediaError + + /* SVG Element interfaces */ + SVGAElement + SVGAltGlyphElement + SVGAltGlyphDefElement + SVGAltGlyphItemElement + SVGAnimationElement + SVGAnimateElement + SVGAnimateColorElement + SVGAnimateMotionElement + SVGAnimateTransformElement + SVGCircleElement + SVGClipPathElement + SVGColorProfileElement + SVGComponentTransferFunctionElement + SVGCursorElement + SVGDefsElement + SVGDescElement + SVGElement + SVGEllipseElement + SVGFEBlendElement + SVGFEColorMatrixElement + SVGFEComponentTransferElement + SVGFECompositeElement + SVGFEConvolveMatrixElement + SVGFEDiffuseLightingElement + SVGFEDisplacementMapElement + SVGFEDistantLightElement + SVGFEFloodElement + SVGFEGaussianBlurElement + SVGFEImageElement + SVGFEMergeElement + SVGFEMergeNodeElement + SVGFEMorphologyElement + SVGFEOffsetElement + SVGFEPointLightElement + SVGFESpecularLightingElement + SVGFESpotLightElement + SVGFETileElement + SVGFETurbulenceElement + SVGFEFuncRElement + SVGFEFuncGElement + SVGFEFuncBElement + SVGFEFuncAElement + SVGFilterElement + SVGFilterPrimitiveStandardAttributes + SVGFontElement + SVGFontFaceElement + SVGFontFaceFormatElement + SVGFontFaceNameElement + SVGFontFaceSrcElement + SVGFontFaceUriElement + SVGForeignObjectElement + SVGGElement + SVGGlyphElement + SVGGlyphRefElement + SVGGradientElement + SVGHKernElement + SVGImageElement + SVGLinearGradientElement + SVGLineElement + SVGMarkerElement + SVGMaskElement + SVGMetadataElement + SVGMissingGlyphElement + SVGMPathElement + SVGPathElement + SVGPatternElement + SVGPolylineElement + SVGPolygonElement + SVGRadialGradientElement + SVGRectElement + SVGScriptElement + SVGSetElement + SVGStopElement + SVGStyleElement + SVGSVGElement + SVGSwitchElement + SVGSymbolElement + SVGTextElement + SVGTextPathElement + SVGTitleElement + SVGTRefElement + SVGTSpanElement + SVGUseElement + SVGViewElement + SVGVKernElement + + /* SVG data type interfaces */ + + /* Static type */ + SVGAngle + SVGColor + SVGICCColor + SVGElementInstance + SVGElementInstanceList + SVGLength + SVGLengthList + SVGMatrix + SVGNumber + SVGNumberList + SVGPaint + SVGPoint + SVGPointList + SVGPreserveAspectRatio + SVGRect + SVGStringList + SVGTransform + SVGTransformList + + /* Animated type */ + SVGAnimatedAngle + SVGAnimatedBoolean + SVGAnimatedEnumeration + SVGAnimatedInteger + SVGAnimatedLength + SVGAnimatedLengthList + SVGAnimatedNumber + SVGAnimatedNumberList + SVGAnimatedPreserveAspectRatio + SVGAnimatedRect + SVGAnimatedString + SVGAnimatedTransformList + + /* SIML related interfaces */ + ElementTimeControl + TimeEvent + + /* Other SVG interfaces */ + SVGAnimatedPathData + SVGAnimatedPoints + SVGColorProfileRule + SVGCSSRule + SVGExternalResourcesRequired + SVGFitToViewBox + SVGLangSpace + SVGLocatable + SVGRenderingIntent + SVGStylable + SVGTests + SVGTextContentElement + SVGTextPositioningElement + SVGTransformable + SVGUnitTypes + SVGURIReference + SVGViewSpec + SVGZoomAndPan + + /* obsolete interfaces skipped */ + */ diff --git a/packages/webapi/Webapi__Dom__AnimationEvent.re b/packages/webapi/Webapi__Dom__AnimationEvent.re new file mode 100644 index 000000000..174d3ed7d --- /dev/null +++ b/packages/webapi/Webapi__Dom__AnimationEvent.re @@ -0,0 +1,13 @@ +type t = Dom.animationEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "AnimationEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "AnimationEvent"; + +[@bs.get] external animationName: t => string; +[@bs.get] external elapsedTime: t => float; +[@bs.get] external pseudoElement: t => string /* enum-ish */; diff --git a/packages/webapi/Webapi__Dom__Attr.re b/packages/webapi/Webapi__Dom__Attr.re new file mode 100644 index 000000000..aec191e62 --- /dev/null +++ b/packages/webapi/Webapi__Dom__Attr.re @@ -0,0 +1,17 @@ +type t = Dom.attr; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); + +[@bs.get] external namespaceURI: t => string; +[@bs.get] external prefix: t => string; +[@bs.get] external localName: t => string; +[@bs.get] external name: t => string; +[@bs.get] external value: t => string; +[@bs.get] [@bs.return nullable] +external ownerElement: t => option(Dom.element); +[@bs.get] external specified: t => bool; /* useless; always returns true (exact wording from spec) */ diff --git a/packages/webapi/Webapi__Dom__BeforeUnloadEvent.re b/packages/webapi/Webapi__Dom__BeforeUnloadEvent.re new file mode 100644 index 000000000..2eaa052d3 --- /dev/null +++ b/packages/webapi/Webapi__Dom__BeforeUnloadEvent.re @@ -0,0 +1,11 @@ +type t = Dom.beforeUnloadEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "BeforeUnloadEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "BeforeUnloadEvent"; + +[@bs.get] external returnValue: t => string; diff --git a/packages/webapi/Webapi__Dom__CdataSection.re b/packages/webapi/Webapi__Dom__CdataSection.re new file mode 100644 index 000000000..991358227 --- /dev/null +++ b/packages/webapi/Webapi__Dom__CdataSection.re @@ -0,0 +1,20 @@ +type t = Dom.cdataSection; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__CharacterData.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Slotable.Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__CharacterData.re b/packages/webapi/Webapi__Dom__CharacterData.re new file mode 100644 index 000000000..0bb889fe8 --- /dev/null +++ b/packages/webapi/Webapi__Dom__CharacterData.re @@ -0,0 +1,31 @@ +module Impl = (T: {type t;}) => { + [@bs.get] external data: T.t => string; + [@bs.get] external length: T.t => int; + + [@bs.send.pipe: T.t] + external substringData: (~offset: int, ~count: int) => string; + [@bs.send.pipe: T.t] external appendData: string => unit; + [@bs.send.pipe: T.t] external insertData: (~offset: int, string) => unit; + [@bs.send.pipe: T.t] + external deleteData: (~offset: int, ~count: int) => unit; + [@bs.send.pipe: T.t] + external replaceData: (~offset: int, ~count: int, string) => unit; +}; + +type t = Dom.characterData; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__ChildNode.re b/packages/webapi/Webapi__Dom__ChildNode.re new file mode 100644 index 000000000..070a0b74d --- /dev/null +++ b/packages/webapi/Webapi__Dom__ChildNode.re @@ -0,0 +1,4 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.send.pipe: T.t] external remove: unit; +}; diff --git a/packages/webapi/Webapi__Dom__ClipboardEvent.re b/packages/webapi/Webapi__Dom__ClipboardEvent.re new file mode 100644 index 000000000..3720feff7 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ClipboardEvent.re @@ -0,0 +1,11 @@ +type t = Dom.clipboardEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "ClipboardEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "ClipboardEvent"; + +[@bs.get] external clipboardData: t => Dom.dataTransfer; diff --git a/packages/webapi/Webapi__Dom__CloseEvent.re b/packages/webapi/Webapi__Dom__CloseEvent.re new file mode 100644 index 000000000..3fdf00409 --- /dev/null +++ b/packages/webapi/Webapi__Dom__CloseEvent.re @@ -0,0 +1,12 @@ +type t = Dom.closeEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "CloseEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "CloseEvent"; + +[@bs.get] external wasClean: t => bool; +[@bs.get] external code: t => int; +[@bs.get] external reason: t => string; diff --git a/packages/webapi/Webapi__Dom__Comment.re b/packages/webapi/Webapi__Dom__Comment.re new file mode 100644 index 000000000..2a7e337f6 --- /dev/null +++ b/packages/webapi/Webapi__Dom__Comment.re @@ -0,0 +1,20 @@ +type t = Dom.comment; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__CharacterData.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Slotable.Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__CompositionEvent.re b/packages/webapi/Webapi__Dom__CompositionEvent.re new file mode 100644 index 000000000..3ac4643df --- /dev/null +++ b/packages/webapi/Webapi__Dom__CompositionEvent.re @@ -0,0 +1,14 @@ +type t = Dom.compositionEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "CompositionEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "CompositionEvent"; + +[@bs.get] external data: t => string; diff --git a/packages/webapi/Webapi__Dom__CssStyleDeclaration.re b/packages/webapi/Webapi__Dom__CssStyleDeclaration.re new file mode 100644 index 000000000..d283d8c5a --- /dev/null +++ b/packages/webapi/Webapi__Dom__CssStyleDeclaration.re @@ -0,0 +1,138 @@ +type t = Dom.cssStyleDeclaration; +type cssRule; /* TODO: Move to Webapi__Dom */ + +[@bs.get] external cssText: t => string; +[@bs.set] external setCssText: (t, string) => unit = "cssText"; +[@bs.get] external length: t => int; +[@bs.get] external parentRule: t => cssRule; + +[@bs.send.pipe: t] external getPropertyPriority: string => string; +[@bs.send.pipe: t] external getPropertyValue: string => string; +[@bs.send.pipe: t] external item: int => string; +[@bs.send.pipe: t] external removeProperty: string => string; +[@bs.send.pipe: t] +external setProperty: + (string, string, string) => unit /*[@@bs.send.pipe : t] external setPropertyValue : (string, string) => unit = "";*/; /* not mentioned by MDN and not implemented by chrome, but in the CSSOM spec: https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface */ +/* CSS2Properties */ +[@bs.get] external azimuth: t => string; +[@bs.get] external background: t => string; +[@bs.get] external backgroundAttachment: t => string; +[@bs.get] external backgroundColor: t => string; +[@bs.get] external backgroundImage: t => string; +[@bs.get] external backgroundPosition: t => string; +[@bs.get] external backgroundRepeat: t => string; +[@bs.get] external border: t => string; +[@bs.get] external borderCollapse: t => string; +[@bs.get] external borderColor: t => string; +[@bs.get] external borderSpacing: t => string; +[@bs.get] external borderStyle: t => string; +[@bs.get] external borderTop: t => string; +[@bs.get] external borderRight: t => string; +[@bs.get] external borderBottom: t => string; +[@bs.get] external borderLeft: t => string; +[@bs.get] external borderTopColor: t => string; +[@bs.get] external borderRightColor: t => string; +[@bs.get] external borderBottomColor: t => string; +[@bs.get] external borderLeftColor: t => string; +[@bs.get] external borderTopStyle: t => string; +[@bs.get] external borderRightStyle: t => string; +[@bs.get] external borderBottomStyle: t => string; +[@bs.get] external borderLeftStyle: t => string; +[@bs.get] external borderTopWidth: t => string; +[@bs.get] external borderRightWidth: t => string; +[@bs.get] external borderBottomWidth: t => string; +[@bs.get] external borderLeftWidth: t => string; +[@bs.get] external borderWidth: t => string; +[@bs.get] external bottom: t => string; +[@bs.get] external captionSide: t => string; +[@bs.get] external clear: t => string; +[@bs.get] external clip: t => string; +[@bs.get] external color: t => string; +[@bs.get] external content: t => string; +[@bs.get] external counterIncrement: t => string; +[@bs.get] external counterReset: t => string; +[@bs.get] external cue: t => string; +[@bs.get] external cueAfter: t => string; +[@bs.get] external cueBefore: t => string; +[@bs.get] external cursor: t => string; +[@bs.get] external direction: t => string; +[@bs.get] external display: t => string; +[@bs.get] external elevation: t => string; +[@bs.get] external emptyCells: t => string; +[@bs.get] external cssFloat: t => string; +[@bs.get] external font: t => string; +[@bs.get] external fontFamily: t => string; +[@bs.get] external fontSize: t => string; +[@bs.get] external fontSizeAdjust: t => string; +[@bs.get] external fontStretch: t => string; +[@bs.get] external fontStyle: t => string; +[@bs.get] external fontVariant: t => string; +[@bs.get] external fontWeight: t => string; +[@bs.get] external height: t => string; +[@bs.get] external left: t => string; +[@bs.get] external letterSpacing: t => string; +[@bs.get] external lineHeight: t => string; +[@bs.get] external listStyle: t => string; +[@bs.get] external listStyleImage: t => string; +[@bs.get] external listStylePosition: t => string; +[@bs.get] external listStyleType: t => string; +[@bs.get] external margin: t => string; +[@bs.get] external marginTop: t => string; +[@bs.get] external marginRight: t => string; +[@bs.get] external marginBottom: t => string; +[@bs.get] external marginLeft: t => string; +[@bs.get] external markerOffset: t => string; +[@bs.get] external marks: t => string; +[@bs.get] external maxHeight: t => string; +[@bs.get] external maxWidth: t => string; +[@bs.get] external minHeight: t => string; +[@bs.get] external minWidth: t => string; +[@bs.get] external orphans: t => string; +[@bs.get] external outline: t => string; +[@bs.get] external outlineColor: t => string; +[@bs.get] external outlineStyle: t => string; +[@bs.get] external outlineWidth: t => string; +[@bs.get] external overflow: t => string; +[@bs.get] external padding: t => string; +[@bs.get] external paddingTop: t => string; +[@bs.get] external paddingRight: t => string; +[@bs.get] external paddingBottom: t => string; +[@bs.get] external paddingLeft: t => string; +[@bs.get] external page: t => string; +[@bs.get] external pageBreakAfter: t => string; +[@bs.get] external pageBreakBefore: t => string; +[@bs.get] external pageBreakInside: t => string; +[@bs.get] external pause: t => string; +[@bs.get] external pauseAfter: t => string; +[@bs.get] external pauseBefore: t => string; +[@bs.get] external pitch: t => string; +[@bs.get] external pitchRange: t => string; +[@bs.get] external playDuring: t => string; +[@bs.get] external position: t => string; +[@bs.get] external quotes: t => string; +[@bs.get] external richness: t => string; +[@bs.get] external right: t => string; +[@bs.get] external size: t => string; +[@bs.get] external speak: t => string; +[@bs.get] external speakHeader: t => string; +[@bs.get] external speakNumeral: t => string; +[@bs.get] external speakPunctuation: t => string; +[@bs.get] external speechRate: t => string; +[@bs.get] external stress: t => string; +[@bs.get] external tableLayout: t => string; +[@bs.get] external textAlign: t => string; +[@bs.get] external textDecoration: t => string; +[@bs.get] external textIndent: t => string; +[@bs.get] external textShadow: t => string; +[@bs.get] external textTransform: t => string; +[@bs.get] external top: t => string; +[@bs.get] external unicodeBidi: t => string; +[@bs.get] external verticalAlign: t => string; +[@bs.get] external visibility: t => string; +[@bs.get] external voiceFamily: t => string; +[@bs.get] external volume: t => string; +[@bs.get] external whiteSpace: t => string; +[@bs.get] external widows: t => string; +[@bs.get] external width: t => string; +[@bs.get] external wordSpacing: t => string; +[@bs.get] external zIndex: t => string; diff --git a/packages/webapi/Webapi__Dom__CustomEvent.re b/packages/webapi/Webapi__Dom__CustomEvent.re new file mode 100644 index 000000000..fe71ffdbc --- /dev/null +++ b/packages/webapi/Webapi__Dom__CustomEvent.re @@ -0,0 +1,8 @@ +type t = Dom.customEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "CustomEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "CustomEvent"; diff --git a/packages/webapi/Webapi__Dom__Document.re b/packages/webapi/Webapi__Dom__Document.re new file mode 100644 index 000000000..5f2c5db36 --- /dev/null +++ b/packages/webapi/Webapi__Dom__Document.re @@ -0,0 +1,147 @@ +module Impl = (T: {type t;}) => { + external asDocument: T.t => Dom.document = "%identity"; + + let asHtmlDocument: T.t => option(Dom.htmlDocument) = [%raw + {| + function(document) { + var defaultView = document.defaultView; + + if (defaultView != null) { + var HTMLDocument = defaultView.HTMLDocument; + + if (HTMLDocument != null && document instanceof HTMLDocument) { + return document; + } + } + } + |} + ]; + + /** Unsafe cast, use [ashtmlDocument] instead */ + external unsafeAsHtmlDocument: T.t => Dom.htmlDocument = "%identity"; + + let ofNode = (node: Dom.node): option(T.t) => + Webapi__Dom__Node.nodeType(node) == Webapi__Dom__Types.Document + ? Some(Obj.magic(node)) : None; + + [@bs.get] external characterSet: T.t => string; + [@bs.get] external compatMode: T.t => string /* compatMode enum */; /* experimental */ + let compatMode: T.t => Webapi__Dom__Types.compatMode = + self => Webapi__Dom__Types.decodeCompatMode(compatMode(self)); + [@bs.get] external doctype: T.t => Dom.documentType; + [@bs.get] external documentElement: T.t => Dom.element; + [@bs.get] external documentURI: T.t => string; + [@bs.get] external hidden: T.t => bool; + [@bs.get] external implementation: T.t => Dom.domImplementation; + [@bs.get] external lastStyleSheetSet: T.t => string; + [@bs.get] [@bs.return nullable] + external pointerLockElement: T.t => option(Dom.element); /* experimental */ + + [@bs.get] external preferredStyleSheetSet: T.t => string; + [@bs.get] [@bs.return nullable] + external scrollingElement: T.t => option(Dom.element); + [@bs.get] external selectedStyleSheetSet: T.t => string; + [@bs.set] + external setSelectedStyleSheetSet: (T.t, string) => unit = + "selectedStyleSheetSet"; + [@bs.get] external styleSheets: T.t => array(Dom.cssStyleSheet); /* return StyleSheetList, not array */ + [@bs.get] external styleSheetSets: T.t => array(string); + [@bs.get] external visibilityState: T.t => string /* visibilityState enum */; + let visibilityState: T.t => Webapi__Dom__Types.visibilityState = + self => Webapi__Dom__Types.decodeVisibilityState(visibilityState(self)); + + [@bs.send.pipe: T.t] + external adoptNode: Dom.element_like('a) => Dom.element_like('a); + [@bs.send.pipe: T.t] external createAttribute: string => Dom.attr; + [@bs.send.pipe: T.t] + external createAttributeNS: (string, string) => Dom.attr; + [@bs.send.pipe: T.t] external createComment: string => Dom.comment; + [@bs.send.pipe: T.t] external createDocumentFragment: Dom.documentFragment; + [@bs.send.pipe: T.t] external createElement: string => Dom.element; + [@bs.send.pipe: T.t] + external createElementWithOptions: (string, Js.t({..})) => Dom.element = + "createElement"; /* not widely supported */ + [@bs.send.pipe: T.t] + external createElementNS: (string, string) => Dom.element; + [@bs.send.pipe: T.t] + external createElementNSWithOptions: + (string, string, Js.t({..})) => Dom.element = + "createElementNS"; /* not widely supported */ + [@bs.send.pipe: T.t] + external createEvent: string /* large enum */ => Dom.event; /* discouraged (but not deprecated) in favor of Event constructors */ + [@bs.send.pipe: T.t] + external createNodeIterator: Dom.node_like('a) => Dom.nodeIterator; + [@bs.send.pipe: T.t] + external createNodeIteratorWithWhatToShow: + (Dom.node_like('a), Webapi__Dom__Types.WhatToShow.t) => Dom.nodeIterator = + "createNodeIterator"; + [@bs.send.pipe: T.t] + external createNodeIteratorWithWhatToShowFilter: + (Dom.node_like('a), Webapi__Dom__Types.WhatToShow.t, Dom.nodeFilter) => + Dom.nodeIterator = + "createNodeIterator"; /* createProcessingInstruction */ + [@bs.send.pipe: T.t] external createRange: Dom.range; + [@bs.send.pipe: T.t] external createTextNode: string => Dom.text; + [@bs.send.pipe: T.t] + external createTreeWalker: Dom.element_like('a) => Dom.treeWalker; + [@bs.send.pipe: T.t] + external createTreeWalkerWithWhatToShow: + (Dom.element_like('a), Webapi__Dom__Types.WhatToShow.t) => Dom.treeWalker = + "createTreeWalker"; + [@bs.send.pipe: T.t] + external createTreeWalkerWithWhatToShowFilter: + (Dom.element_like('a), Webapi__Dom__Types.WhatToShow.t, Dom.nodeFilter) => + Dom.treeWalker = + "createTreeWalker"; + [@bs.send.pipe: T.t] external elementFromPoint: (int, int) => Dom.element; /* experimental, but widely supported */ + [@bs.send.pipe: T.t] + external elementsFromPoint: (int, int) => array(Dom.element); /* experimental */ + [@bs.send.pipe: T.t] external enableStyleSheetsForSet: string => unit; + [@bs.send.pipe: T.t] external exitPointerLock: unit; /* experimental */ + [@bs.send.pipe: T.t] external getAnimations: array(Dom.animation); /* experimental */ + [@bs.send.pipe: T.t] + external getElementsByClassName: string => Dom.htmlCollection; + [@bs.send.pipe: T.t] + external getElementsByTagName: string => Dom.htmlCollection; + [@bs.send.pipe: T.t] + external getElementsByTagNameNS: (string, string) => Dom.htmlCollection; + [@bs.send.pipe: T.t] + external importNode: Dom.element_like('a) => Dom.element_like('a); + [@bs.send.pipe: T.t] + external importNodeDeep: + (Dom.element_like('a), [@bs.as {json|true|json}] _) => + Dom.element_like('a) = + "importNode"; + [@bs.send.pipe: T.t] external registerElement: (string, unit) => Dom.element; /* experimental and deprecated in favor of customElements.define() */ + [@bs.send.pipe: T.t] + external registerElementWithOptions: + (string, Js.t({..}), unit) => Dom.element = + "registerElement"; /* experimental and deprecated in favor of customElements.define() */ + + /** XPath stuff */; + /* createExpression */ + /* createNSResolver */ + /* evaluate */ + /* GlobalEventHandlers interface */ +}; + +type t = Dom.document; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonElementParentNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__DocumentOrShadowRoot.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ParentNode.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__DocumentFragment.re b/packages/webapi/Webapi__Dom__DocumentFragment.re new file mode 100644 index 000000000..2222ec678 --- /dev/null +++ b/packages/webapi/Webapi__Dom__DocumentFragment.re @@ -0,0 +1,14 @@ +type t = Dom.documentFragment; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonElementParentNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ParentNode.Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__DocumentOrShadowRoot.re b/packages/webapi/Webapi__Dom__DocumentOrShadowRoot.re new file mode 100644 index 000000000..d8c121f84 --- /dev/null +++ b/packages/webapi/Webapi__Dom__DocumentOrShadowRoot.re @@ -0,0 +1,6 @@ +/* Unused type t */ +[@warning "-34"] +/* Mixin */ +module Impl = (T: {type t;}) => { + /* TODO: Implemented in Shadow DOM spec */ +}; diff --git a/packages/webapi/Webapi__Dom__DocumentType.re b/packages/webapi/Webapi__Dom__DocumentType.re new file mode 100644 index 000000000..a36607ed6 --- /dev/null +++ b/packages/webapi/Webapi__Dom__DocumentType.re @@ -0,0 +1,15 @@ +type t = Dom.documentType; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); + +[@bs.get] external name: t => string; +[@bs.get] external publicId: t => string; +[@bs.get] external systemId: t => string; diff --git a/packages/webapi/Webapi__Dom__DomImplementation.re b/packages/webapi/Webapi__Dom__DomImplementation.re new file mode 100644 index 000000000..fd9fdb6bc --- /dev/null +++ b/packages/webapi/Webapi__Dom__DomImplementation.re @@ -0,0 +1,25 @@ +type t = Dom.domImplementation; + +[@bs.send.pipe: t] +external createDocumentType: + (~qualifiedName: string, ~publicId: string, ~systemId: string) => + Dom.documentType; +[@bs.send.pipe: t] +external createDocument: + (Js.null(string), string, Js.null(Dom.documentType)) => Dom.xmlDocument; +let createDocument = + ( + ~namespace: option(string)=?, + ~qualifiedName: string, + ~docType: option(Dom.documentType)=?, + ) => + createDocument( + Js.Null.fromOption(namespace), + qualifiedName, + Js.Null.fromOption(docType), + ); +[@bs.send.pipe: t] external createHTMLDocument: Dom.htmlDocument; +[@bs.send.pipe: t] +external createHTMLDocumentWithTitle: string => Dom.htmlDocument = + "createHTMLDocument"; +[@bs.send.pipe: t] external hasFeature: bool; /* useless; always returns true (this is exact wording from the actual spec) */ diff --git a/packages/webapi/Webapi__Dom__DomRect.re b/packages/webapi/Webapi__Dom__DomRect.re new file mode 100644 index 000000000..d846255f0 --- /dev/null +++ b/packages/webapi/Webapi__Dom__DomRect.re @@ -0,0 +1,14 @@ +type t = Dom.domRect; + +[@bs.new] +external make: (~x: float, ~y: float, ~width: float, ~height: float) => t = + "DOMRect"; /* experimental */ + +[@bs.get] external top: t => float; +[@bs.get] external bottom: t => float; +[@bs.get] external left: t => float; +[@bs.get] external right: t => float; +[@bs.get] external height: t => float; +[@bs.get] external width: t => float; +[@bs.get] external x: t => float; +[@bs.get] external y: t => float; diff --git a/packages/webapi/Webapi__Dom__DomStringMap.re b/packages/webapi/Webapi__Dom__DomStringMap.re new file mode 100644 index 000000000..55aa88d9c --- /dev/null +++ b/packages/webapi/Webapi__Dom__DomStringMap.re @@ -0,0 +1,12 @@ +type t = Dom.domStringMap; + +type key = string; + +[@bs.get_index] [@bs.return nullable] +external get: (t, key) => option(string); +let get = (key, map) => get(map, key); +[@bs.set_index] external set: (t, key, string) => unit; +let set = (key, value, map) => set(map, key, value); +let unsafeDeleteKey: (key, t) => unit = [%raw + "function(key, map) { delete map[key] }" +]; diff --git a/packages/webapi/Webapi__Dom__DomTokenList.re b/packages/webapi/Webapi__Dom__DomTokenList.re new file mode 100644 index 000000000..6083979dd --- /dev/null +++ b/packages/webapi/Webapi__Dom__DomTokenList.re @@ -0,0 +1,26 @@ +type t = Dom.domTokenList; + +[@bs.get] external length: t => int; + +[@bs.send.pipe: t] [@bs.return nullable] external item: int => option(string); +[@bs.send.pipe: t] external add: string => unit; +[@bs.send.pipe: t] [@bs.splice] +external addMany: array(string) => unit = "add"; +[@bs.send.pipe: t] external contains: string => bool = "contains"; +/* entries: iterator API, should have language support */ +[@bs.send.pipe: t] external forEach: ((string, int) => unit) => unit; +/* keys: iterator API, should have language support */ +[@bs.send.pipe: t] external remove: string => unit; +[@bs.send.pipe: t] [@bs.splice] +external removeMany: array(string) => unit = "remove"; +[@bs.send.pipe: t] external replace: (string, string) => unit; /* experimental */ +[@bs.send.pipe: t] external supports: string => bool; /* experimental, Content Management Level 1 */ +[@bs.send.pipe: t] external toggle: string => bool; +[@bs.send.pipe: t] +external toggleForced: (string, [@bs.as {json|true|json}] _) => bool = + "toggle"; +[@bs.send.pipe: t] external toString: string; +/* values: iterator API, should have language support */ + +[@bs.get] external value: t => string; /* experimental, from being merged with domSettableTokenList */ +[@bs.set] external setValue: (t, string) => unit = "value"; /* experimental, from being merged with domSettableTokenList */ diff --git a/packages/webapi/Webapi__Dom__DragEvent.re b/packages/webapi/Webapi__Dom__DragEvent.re new file mode 100644 index 000000000..146581da0 --- /dev/null +++ b/packages/webapi/Webapi__Dom__DragEvent.re @@ -0,0 +1,16 @@ +type t = Dom.dragEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__MouseEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "DragEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "DragEvent"; + +[@bs.get] external dataTransfer: t => Dom.dataTransfer; diff --git a/packages/webapi/Webapi__Dom__Element.re b/packages/webapi/Webapi__Dom__Element.re new file mode 100644 index 000000000..0e9d80812 --- /dev/null +++ b/packages/webapi/Webapi__Dom__Element.re @@ -0,0 +1,213 @@ +/* internal, moved out of Impl to reduce unnecessary code duplication */ +let ofNode = (node: Dom.node): option('a) => + Webapi__Dom__Node.nodeType(node) == Webapi__Dom__Types.Element + ? Some(Obj.magic(node)) : None; + +module Impl = (T: {type t;}) => { + let asHtmlElement: T.t => option(Dom.htmlElement) = [%raw + {| + function(element) { + var ownerDocument = element.ownerDocument; + + if (ownerDocument != null) { + var defaultView = ownerDocument.defaultView; + + if (defaultView != null) { + var HTMLElement = defaultView.HTMLElement; + + if (HTMLElement != null && element instanceof HTMLElement) { + return element; + } + } + } + } + |} + ]; + + /** Unsafe cast, use [asHtmlElement] instead */ + external unsafeAsHtmlElement: T.t => Dom.htmlElement = "%identity"; + + let ofNode: Dom.node => option(T.t) = ofNode; + + [@bs.get] external attributes: T.t => Dom.namedNodeMap; + [@bs.get] external classList: T.t => Dom.domTokenList; + [@bs.get] external className: T.t => string; + [@bs.set] external setClassName: (T.t, string) => unit = "className"; + [@bs.get] external clientHeight: T.t => int; /* experimental */ + [@bs.get] external clientLeft: T.t => int; /* experimental */ + [@bs.get] external clientTop: T.t => int; /* experimental */ + [@bs.get] external clientWidth: T.t => int; /* experimental */ + [@bs.get] external id: T.t => string; + [@bs.set] external setId: (T.t, string) => unit = "id"; + [@bs.get] external innerHTML: T.t => string; + [@bs.set] external setInnerHTML: (T.t, string) => unit = "innerHTML"; + [@bs.get] external localName: T.t => string; + [@bs.get] [@bs.return nullable] + external namespaceURI: T.t => option(string); + [@bs.get] external outerHTML: T.t => string; /* experimental, but widely supported */ + [@bs.set] external setOuterHTML: (T.t, string) => unit = "outerHTML"; /* experimental, but widely supported */ + [@bs.get] [@bs.return nullable] external prefix: T.t => option(string); + [@bs.get] external scrollHeight: T.t => int; /* experimental, but widely supported */ + [@bs.get] external scrollLeft: T.t => float; /* experimental */ + [@bs.set] external setScrollLeft: (T.t, float) => unit = "scrollLeft"; /* experimental */ + [@bs.get] external scrollTop: T.t => float; /* experimental, but widely supported */ + [@bs.set] external setScrollTop: (T.t, float) => unit = "scrollTop"; /* experimental, but widely supported */ + [@bs.get] external scrollWidth: T.t => int; /* experimental */ + [@bs.get] external shadowRoot: T.t => Dom.element; /* experimental */ + [@bs.get] external slot: T.t => string; /* experimental */ + [@bs.set] external setSlot: (T.t, string) => unit = "slot"; /* experimental */ + [@bs.get] external tagName: T.t => string; + + [@bs.send.pipe: T.t] + external attachShadow: {. "mode": string} => Dom.shadowRoot; /* experimental */ + [@bs.send.pipe: T.t] + external attachShadowOpen: + ([@bs.as {json|{ "mode": "open" }|json}] _) => Dom.shadowRoot = + "attachShadow"; /* experimental */ + [@bs.send.pipe: T.t] + external attachShadowClosed: + ([@bs.as {json|{ "mode": "closed" }|json}] _) => Dom.shadowRoot = + "attachShadow"; /* experimental */ + [@bs.send.pipe: T.t] + external animate: (Js.t({..}), Js.t({..})) => Dom.animation; /* experimental */ + [@bs.send.pipe: T.t] [@bs.return nullable] + external closest: string => option(Dom.element); /* experimental */ + [@bs.send.pipe: T.t] external createShadowRoot: Dom.shadowRoot; /* experimental AND deprecated (?!) */ + [@bs.send.pipe: T.t] [@bs.return nullable] + external getAttribute: string => option(string); + [@bs.send.pipe: T.t] [@bs.return nullable] + external getAttributeNS: (string, string) => option(string); + [@bs.send.pipe: T.t] external getBoundingClientRect: Dom.domRect; + [@bs.send.pipe: T.t] external getClientRects: array(Dom.domRect); + [@bs.send.pipe: T.t] + external getElementsByClassName: string => Dom.htmlCollection; + [@bs.send.pipe: T.t] + external getElementsByTagName: string => Dom.htmlCollection; + [@bs.send.pipe: T.t] + external getElementsByTagNameNS: (string, string) => Dom.htmlCollection; + [@bs.send.pipe: T.t] external hasAttribute: string => bool; + [@bs.send.pipe: T.t] external hasAttributeNS: (string, string) => bool; + [@bs.send.pipe: T.t] external hasAttributes: bool; + [@bs.send.pipe: T.t] + external insertAdjacentElement: + (string /* insertPosition enum */, Dom.element_like('a)) => unit; /* experimental, but widely supported */ + let insertAdjacentElement: + (Webapi__Dom__Types.insertPosition, Dom.element_like('a), T.t) => unit = + (position, element, self) => + insertAdjacentElement( + Webapi__Dom__Types.encodeInsertPosition(position), + element, + self, + ); + [@bs.send.pipe: T.t] + external insertAdjacentHTML: + (string /* insertPosition enum */, string) => unit; /* experimental, but widely supported */ + let insertAdjacentHTML: + (Webapi__Dom__Types.insertPosition, string, T.t) => unit = + (position, text, self) => + insertAdjacentHTML( + Webapi__Dom__Types.encodeInsertPosition(position), + text, + self, + ); + [@bs.send.pipe: T.t] + external insertAdjacentText: + (string /* insertPosition enum */, string) => unit; /* experimental, but widely supported */ + let insertAdjacentText: + (Webapi__Dom__Types.insertPosition, string, T.t) => unit = + (position, text, self) => + insertAdjacentText( + Webapi__Dom__Types.encodeInsertPosition(position), + text, + self, + ); + [@bs.send.pipe: T.t] external matches: string => bool; /* experimental, but widely supported */ + [@bs.send.pipe: T.t] + external releasePointerCapture: Dom.eventPointerId => unit; + [@bs.send.pipe: T.t] external removeAttribute: string => unit; + [@bs.send.pipe: T.t] external removeAttributeNS: (string, string) => unit; + [@bs.send.pipe: T.t] external requestFullscreen: unit; /* experimental */ + [@bs.send.pipe: T.t] external requestPointerLock: unit; /* experimental */ + [@bs.send.pipe: T.t] external scrollIntoView: unit; /* experimental, but widely supported */ + [@bs.send.pipe: T.t] + external scrollIntoViewNoAlignToTop: ([@bs.as {json|true|json}] _) => unit = + "scrollIntoView"; /* experimental, but widely supported */ + [@bs.send.pipe: T.t] + external scrollIntoViewWithOptions: + { + . + "behavior": string, + "block": string, + } => + unit = + "scrollIntoView"; /* experimental */ + [@bs.send.pipe: T.t] external scrollBy: (float, float) => unit; + [@bs.send.pipe: T.t] + external scrollByWithOptions: + { + . + "top": float, + "left": float, + "behavior": string, + } => + unit = + "scrollBy"; + [@bs.send.pipe: T.t] external scrollTo: (float, float) => unit; + [@bs.send.pipe: T.t] + external scrollToWithOptions: + { + . + "top": float, + "left": float, + "behavior": string, + } => + unit = + "scrollTo"; + [@bs.send.pipe: T.t] external setAttribute: (string, string) => unit; + [@bs.send.pipe: T.t] + external setAttributeNS: (string, string, string) => unit; + [@bs.send.pipe: T.t] external setPointerCapture: Dom.eventPointerId => unit; + + /* GlobalEventHandlers interface */ + /* Not sure this should be exposed, since EventTarget seems like a better API */ + + [@bs.set] + external setOnClick: (T.t, Dom.mouseEvent => unit) => unit = "onclick"; +}; + +/* TODO: This doesn't work. Why? + module Tree (T: { type t; }) => { + include NodeRe.Impl { type t = Type }; + include EventTargetRe.Impl { type t = Type }; + include Impl { type t = Type }; + }; + + include Tree { type t = Dom.element }; + */ + +type t = Dom.element; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__GlobalEventHandlers.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ParentNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Slotable.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__ErrorEvent.re b/packages/webapi/Webapi__Dom__ErrorEvent.re new file mode 100644 index 000000000..74d9c3a04 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ErrorEvent.re @@ -0,0 +1,14 @@ +type t = Dom.errorEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "ErrorEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "ErrorEvent"; + +[@bs.get] external message: t => string; +[@bs.get] external filename: t => string; +[@bs.get] external lineno: t => int; +[@bs.get] external colno: t => int; +[@bs.get] external error: t => Js.t({..}); diff --git a/packages/webapi/Webapi__Dom__Event.re b/packages/webapi/Webapi__Dom__Event.re new file mode 100644 index 000000000..ecd2b1e3f --- /dev/null +++ b/packages/webapi/Webapi__Dom__Event.re @@ -0,0 +1,58 @@ +module Impl = (T: {type t;}) => { + [@bs.get] external bubbles: T.t => bool; + [@bs.get] external cancelable: T.t => bool; + [@bs.get] external composed: T.t => bool; + [@bs.get] external currentTarget: T.t => Dom.eventTarget; + [@bs.get] external defaultPrevented: T.t => bool; + [@bs.get] external eventPhase: T.t => int /* eventPhase enum */; + + let eventPhase: T.t => Webapi__Dom__Types.EventPhase.t = + self => Webapi__Dom__Types.EventPhase.decode(eventPhase(self)); + + [@bs.get] external target: T.t => Dom.eventTarget; + [@bs.get] external timeStamp: T.t => float; + [@bs.get] external type_: T.t => string = "type"; + [@bs.get] external isTrusted: T.t => bool; + + [@bs.send.pipe: T.t] external preventDefault: unit; + [@bs.send.pipe: T.t] external stopImmediatePropagation: unit; + [@bs.send.pipe: T.t] external stopPropagation: unit; +}; + +type t = Dom.event; + +include Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "Event"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "Event"; + +/* + Unimplemented Event interfaces + + AudioProcessingEvent /* deprecated */ + BeforeInputEvent /* experimental? Looks like it might just be an InputEvent */ + BlobEvent /* experimental, MediaStream recording */ + CSSFontFaceLoadEvent /* experimental - https://www.w3.org/TR/css-font-loading-3/#dom-cssfontfaceloadevent */ + DeviceLightEvent /* experimenta, Ambient Light */ + DeviceMotionEvent /* experimental, Device Orientation */ + DeviceOrientationEvent /* experimental, Device Orientation */ + DeviceProximityEvent /* experimental, Device Orientation */ + DOMTransactionEvent /* very experimental - https://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html#the-domtransactionevent-interface */ + EditingBeforeInputEvent /* deprecated? - https://dvcs.w3.org/hg/editing/raw-file/57abe6d3cb60/editing.html#editingbeforeinputevent */ + FetchEvent /* experimental, Service Workers */ + GamepadEvent /* experimental, Gamepad */ + HashChangeEvent /* https://www.w3.org/TR/html51/browsers.html#the-hashchangeevent-interface */ + MediaStreamEvent /* experimental, WebRTC */ + MessageEvent /* experimental, Websocket/WebRTC */ + MutationEvent /* deprecated */ + OfflineAudioCompletionEvent /* experimental, Web Audio */ + RTCDataChannelEvent /* experimental, WebRTC */ + RTCIdentityErrorEventA /* experimental, WebRTC */ + RTCIdentityEvent /* experimental, WebRTC */ + RTCPeerConnectionIceEvent /* experimental, WebRTC */ + SensorEvent /* deprecated? */ + SVGEvent /* deprecated */ + UserProximityEvent /* experimental, Proximity Events */ + */ diff --git a/packages/webapi/Webapi__Dom__EventTarget.re b/packages/webapi/Webapi__Dom__EventTarget.re new file mode 100644 index 000000000..b9d992eb3 --- /dev/null +++ b/packages/webapi/Webapi__Dom__EventTarget.re @@ -0,0 +1,2275 @@ +module Impl = (T: {type t;}) => { + external asEventTarget: T.t => Dom.eventTarget = "%identity"; + + [@bs.send.pipe: T.t] + external addEventListener: (string, Dom.event => unit) => unit; + [@bs.send.pipe: T.t] + external addEventListenerWithOptions: + ( + string, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addEventListenerUseCapture: + (string, Dom.event => unit, [@bs.as {json|true|json}] _) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeEventListener: (string, Dom.event => unit) => unit; + [@bs.send.pipe: T.t] + external removeEventListenerWithOptions: + ( + string, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeEventListenerUseCapture: + (string, Dom.event => unit, [@bs.as {json|true|json}] _) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] external dispatchEvent: Dom.event_like('a) => bool; + + /** + * non-standard event-specific functions + */ + /* UI */ + [@bs.send.pipe: T.t] + external addLoadEventListener: ([@bs.as "load"] _, Dom.event => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addLoadEventListenerWithOptions: + ( + [@bs.as "load"] _, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addLoadEventListenerUseCapture: + ([@bs.as "load"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeLoadEventListener: + ([@bs.as "load"] _, Dom.event => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeLoadEventListenerWithOptions: + ( + [@bs.as "load"] _, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeLoadEventListenerUseCapture: + ([@bs.as "load"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addUnloadEventListener: + ([@bs.as "unload"] _, Dom.event => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addUnloadEventListenerWithOptions: + ( + [@bs.as "unload"] _, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addUnloadEventListenerUseCapture: + ([@bs.as "unload"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeUnloadEventListener: + ([@bs.as "unload"] _, Dom.event => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeUnloadEventListenerWithOptions: + ( + [@bs.as "unload"] _, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeUnloadEventListenerUseCapture: + ([@bs.as "unload"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addAbortEventListener: + ([@bs.as "abort"] _, Dom.event => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addAbortEventListenerWithOptions: + ( + [@bs.as "abort"] _, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addAbortEventListenerUseCapture: + ([@bs.as "abort"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeAbortEventListener: + ([@bs.as "abort"] _, Dom.event => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeAbortEventListenerWithOptions: + ( + [@bs.as "abort"] _, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeAbortEventListenerUseCapture: + ([@bs.as "abort"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addErrorEventListener: + ([@bs.as "error"] _, Dom.event => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addErrorEventListenerWithOptions: + ( + [@bs.as "error"] _, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addErrorEventListenerUseCapture: + ([@bs.as "error"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeErrorEventListener: + ([@bs.as "error"] _, Dom.event => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeErrorEventListenerWithOptions: + ( + [@bs.as "error"] _, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeErrorEventListenerUseCapture: + ([@bs.as "error"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addSelectEventListener: + ([@bs.as "select"] _, Dom.event => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addSelectEventListenerWithOptions: + ( + [@bs.as "select"] _, + Dom.event => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addSelectEventListenerUseCapture: + ([@bs.as "select"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeSelectEventListener: + ([@bs.as "select"] _, Dom.event => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeSelectEventListenerWithOptions: + ( + [@bs.as "select"] _, + Dom.event => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeSelectEventListenerUseCapture: + ([@bs.as "select"] _, Dom.event => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + /* Focus */ + + [@bs.send.pipe: T.t] + external addBlurEventListener: + ([@bs.as "blur"] _, Dom.focusEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addBlurEventListenerWithOptions: + ( + [@bs.as "blur"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addBlurEventListenerUseCapture: + ([@bs.as "blur"] _, Dom.focusEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeBlurEventListener: + ([@bs.as "blur"] _, Dom.focusEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeBlurEventListenerWithOptions: + ( + [@bs.as "blur"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeBlurEventListenerUseCapture: + ([@bs.as "blur"] _, Dom.focusEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addFocusEventListener: + ([@bs.as "focus"] _, Dom.focusEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addFocusEventListenerWithOptions: + ( + [@bs.as "focus"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addFocusEventListenerUseCapture: + ( + [@bs.as "focus"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeFocusEventListener: + ([@bs.as "focus"] _, Dom.focusEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeFocusEventListenerWithOptions: + ( + [@bs.as "focus"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeFocusEventListenerUseCapture: + ( + [@bs.as "focus"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addFocusInEventListener: + ([@bs.as "focusin"] _, Dom.focusEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addFocusInEventListenerWithOptions: + ( + [@bs.as "focusin"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addFocusInEventListenerUseCapture: + ( + [@bs.as "focusin"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeFocusInEventListener: + ([@bs.as "focusin"] _, Dom.focusEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeFocusInEventListenerWithOptions: + ( + [@bs.as "focusin"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeFocusInEventListenerUseCapture: + ( + [@bs.as "focusin"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addFocusOutEventListener: + ([@bs.as "focusout"] _, Dom.focusEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addFocusOutEventListenerWithOptions: + ( + [@bs.as "focusout"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addFocusOutEventListenerUseCapture: + ( + [@bs.as "focusout"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeFocusOutEventListener: + ([@bs.as "focusout"] _, Dom.focusEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeFocusOutEventListenerWithOptions: + ( + [@bs.as "focusout"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeFocusOutEventListenerUseCapture: + ( + [@bs.as "focusout"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Mouse */ + + [@bs.send.pipe: T.t] + external addClickEventListener: + ([@bs.as "click"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addClickEventListenerWithOptions: + ( + [@bs.as "click"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addClickEventListenerUseCapture: + ( + [@bs.as "click"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeClickEventListener: + ([@bs.as "click"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeClickEventListenerWithOptions: + ( + [@bs.as "click"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeClickEventListenerUseCapture: + ( + [@bs.as "click"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDblClickEventListener: + ([@bs.as "dblclick"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDblClickEventListenerWithOptions: + ( + [@bs.as "dblclick"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDblClickEventListenerUseCapture: + ( + [@bs.as "dblclick"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDblClickEventListener: + ([@bs.as "dblclick"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDblClickEventListenerWithOptions: + ( + [@bs.as "dblclick"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDblClickEventListenerUseCapture: + ( + [@bs.as "dblclick"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseDownEventListener: + ([@bs.as "mousedown"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseDownEventListenerWithOptions: + ( + [@bs.as "mousedown"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseDownEventListenerUseCapture: + ( + [@bs.as "mousedown"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseDownEventListener: + ([@bs.as "mousedown"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseDownEventListenerWithOptions: + ( + [@bs.as "mousedown"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseDownEventListenerUseCapture: + ( + [@bs.as "mousedown"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseEnterEventListener: + ([@bs.as "mouseenter"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseEnterEventListenerWithOptions: + ( + [@bs.as "mouseenter"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseEnterEventListenerUseCapture: + ( + [@bs.as "mouseenter"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseEnterEventListener: + ([@bs.as "mouseenter"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseEnterEventListenerWithOptions: + ( + [@bs.as "mouseenter"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseEnterEventListenerUseCapture: + ( + [@bs.as "mouseenter"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseMoveEventListener: + ([@bs.as "mousemove"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseMoveEventListenerWithOptions: + ( + [@bs.as "mousemove"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseMoveEventListenerUseCapture: + ( + [@bs.as "mousemove"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseMoveEventListener: + ([@bs.as "mousemove"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseMoveEventListenerWithOptions: + ( + [@bs.as "mousemove"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseMoveEventListenerUseCapture: + ( + [@bs.as "mousemove"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseOutEventListener: + ([@bs.as "mouseout"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseOutEventListenerWithOptions: + ( + [@bs.as "mouseout"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseOutEventListenerUseCapture: + ( + [@bs.as "mouseout"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseOutEventListener: + ([@bs.as "mouseout"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseOutEventListenerWithOptions: + ( + [@bs.as "mouseout"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseOutEventListenerUseCapture: + ( + [@bs.as "mouseout"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseOverEventListener: + ([@bs.as "mouseover"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseOverEventListenerWithOptions: + ( + [@bs.as "mouseover"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseOverEventListenerUseCapture: + ( + [@bs.as "mouseover"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseOverEventListener: + ([@bs.as "mouseover"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseOverEventListenerWithOptions: + ( + [@bs.as "mouseover"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseOverEventListenerUseCapture: + ( + [@bs.as "mouseover"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addMouseUpEventListener: + ([@bs.as "mouseup"] _, Dom.mouseEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addMouseUpEventListenerWithOptions: + ( + [@bs.as "mouseup"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addMouseUpEventListenerUseCapture: + ( + [@bs.as "mouseup"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeMouseUpEventListener: + ([@bs.as "mouseup"] _, Dom.mouseEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeMouseUpEventListenerWithOptions: + ( + [@bs.as "mouseup"] _, + Dom.mouseEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeMouseUpEventListenerUseCapture: + ( + [@bs.as "mouseup"] _, + Dom.mouseEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Wheel */ + + [@bs.send.pipe: T.t] + external addWheelEventListener: + ([@bs.as "wheel"] _, Dom.wheelEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addWheelEventListenerWithOptions: + ( + [@bs.as "wheel"] _, + Dom.wheelEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addWheelEventListenerUseCapture: + ( + [@bs.as "wheel"] _, + Dom.wheelEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeWheelEventListener: + ([@bs.as "wheel"] _, Dom.wheelEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeWheelEventListenerWithOptions: + ( + [@bs.as "wheel"] _, + Dom.wheelEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeWheelEventListenerUseCapture: + ( + [@bs.as "wheel"] _, + Dom.wheelEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Input */ + + [@bs.send.pipe: T.t] + external addBeforeInputEventListener: + ([@bs.as "beforeinput"] _, Dom.inputEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addBeforeInputEventListenerWithOptions: + ( + [@bs.as "beforeinput"] _, + Dom.inputEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addBeforeInputEventListenerUseCapture: + ( + [@bs.as "beforeinput"] _, + Dom.inputEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeBeforeInputEventListener: + ([@bs.as "beforeinput"] _, Dom.inputEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeBeforeInputEventListenerWithOptions: + ( + [@bs.as "beforeinput"] _, + Dom.inputEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeBeforeInputEventListenerUseCapture: + ( + [@bs.as "beforeinput"] _, + Dom.inputEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addInputEventListener: + ([@bs.as "input"] _, Dom.inputEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addInputEventListenerWithOptions: + ( + [@bs.as "input"] _, + Dom.inputEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addInputEventListenerUseCapture: + ( + [@bs.as "input"] _, + Dom.inputEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeInputEventListener: + ([@bs.as "input"] _, Dom.inputEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeInputEventListenerWithOptions: + ( + [@bs.as "input"] _, + Dom.inputEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeInputEventListenerUseCapture: + ( + [@bs.as "input"] _, + Dom.inputEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Keyboard */ + + [@bs.send.pipe: T.t] + external addKeyDownEventListener: + ([@bs.as "keydown"] _, Dom.keyboardEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addKeyDownEventListenerWithOptions: + ( + [@bs.as "keydown"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addKeyDownEventListenerUseCapture: + ( + [@bs.as "keydown"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeKeyDownEventListener: + ([@bs.as "keydown"] _, Dom.keyboardEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeKeyDownEventListenerWithOptions: + ( + [@bs.as "keydown"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeKeyDownEventListenerUseCapture: + ( + [@bs.as "keydown"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addKeyUpEventListener: + ([@bs.as "keyup"] _, Dom.keyboardEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addKeyUpEventListenerWithOptions: + ( + [@bs.as "keyup"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addKeyUpEventListenerUseCapture: + ( + [@bs.as "keyup"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeKeyUpEventListener: + ([@bs.as "keyup"] _, Dom.keyboardEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeKeyUpEventListenerWithOptions: + ( + [@bs.as "keyup"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeKeyUpEventListenerUseCapture: + ( + [@bs.as "keyup"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addKeyPressEventListener: + ([@bs.as "keypress"] _, Dom.keyboardEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addKeyPressEventListenerWithOptions: + ( + [@bs.as "keypress"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addKeyPressEventListenerUseCapture: + ( + [@bs.as "keypress"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeKeyPressEventListener: + ([@bs.as "keypress"] _, Dom.keyboardEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeKeyPressEventListenerWithOptions: + ( + [@bs.as "keypress"] _, + Dom.keyboardEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeKeyPressEventListenerUseCapture: + ( + [@bs.as "keypress"] _, + Dom.keyboardEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Composition */ + + [@bs.send.pipe: T.t] + external addCompositionStartEventListener: + ([@bs.as "compositionstart"] _, Dom.compositionEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addCompositionStartEventListenerWithOptions: + ( + [@bs.as "compositionstart"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addCompositionStartEventListenerUseCapture: + ( + [@bs.as "compositionstart"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionStartEventListener: + ([@bs.as "compositionstart"] _, Dom.compositionEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionStartEventListenerWithOptions: + ( + [@bs.as "compositionstart"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeCompositionStartEventListenerUseCapture: + ( + [@bs.as "compositionstart"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addCompositionUpdateEventListener: + ([@bs.as "compositionupdate"] _, Dom.compositionEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addCompositionUpdateEventListenerWithOptions: + ( + [@bs.as "compositionupdate"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addCompositionUpdateEventListenerUseCapture: + ( + [@bs.as "compositionupdate"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionUpdateEventListener: + ([@bs.as "compositionupdate"] _, Dom.compositionEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionUpdateEventListenerWithOptions: + ( + [@bs.as "compositionupdate"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeCompositionUpdateEventListenerUseCapture: + ( + [@bs.as "compositionupdate"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addCompositionEndEventListener: + ([@bs.as "compositionend"] _, Dom.compositionEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addCompositionEndEventListenerWithOptions: + ( + [@bs.as "compositionend"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addCompositionEndEventListenerUseCapture: + ( + [@bs.as "compositionend"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionEndEventListener: + ([@bs.as "compositionend"] _, Dom.compositionEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeCompositionEndEventListenerWithOptions: + ( + [@bs.as "compositionend"] _, + Dom.compositionEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeCompositionEndEventListenerUseCapture: + ( + [@bs.as "compositionend"] _, + Dom.compositionEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Drag */ + + [@bs.send.pipe: T.t] + external addDragEventListener: + ([@bs.as "drag"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragEventListenerWithOptions: + ( + [@bs.as "drag"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragEventListenerUseCapture: + ([@bs.as "drag"] _, Dom.dragEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragEventListener: + ([@bs.as "drag"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragEventListenerWithOptions: + ( + [@bs.as "drag"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragEventListenerUseCapture: + ([@bs.as "drag"] _, Dom.dragEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragEndEventListener: + ([@bs.as "dragend"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragEndEventListenerWithOptions: + ( + [@bs.as "dragend"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragEndEventListenerUseCapture: + ( + [@bs.as "dragend"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragEndEventListener: + ([@bs.as "dragend"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragEndEventListenerWithOptions: + ( + [@bs.as "dragend"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragEndEventListenerUseCapture: + ( + [@bs.as "dragend"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragEnterEventListener: + ([@bs.as "dragenter"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragEnterEventListenerWithOptions: + ( + [@bs.as "dragenter"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragEnterEventListenerUseCapture: + ( + [@bs.as "dragenter"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragEnterEventListener: + ([@bs.as "dragenter"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragEnterEventListenerWithOptions: + ( + [@bs.as "dragenter"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragEnterEventListenerUseCapture: + ( + [@bs.as "dragenter"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragExitEventListener: + ([@bs.as "dragexit"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragExitEventListenerWithOptions: + ( + [@bs.as "dragexit"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragExitEventListenerUseCapture: + ( + [@bs.as "dragexit"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragExitEventListener: + ([@bs.as "dragexit"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragExitEventListenerWithOptions: + ( + [@bs.as "dragexit"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragExitEventListenerUseCapture: + ( + [@bs.as "dragexit"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragLeaveEventListener: + ([@bs.as "dragleave"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragLeaveEventListenerWithOptions: + ( + [@bs.as "dragleave"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragLeaveEventListenerUseCapture: + ( + [@bs.as "dragleave"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragLeaveEventListener: + ([@bs.as "dragleave"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragLeaveEventListenerWithOptions: + ( + [@bs.as "dragleave"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragLeaveEventListenerUseCapture: + ( + [@bs.as "dragleave"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragOverEventListener: + ([@bs.as "dragover"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragOverEventListenerWithOptions: + ( + [@bs.as "dragover"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragOverEventListenerUseCapture: + ( + [@bs.as "dragover"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragOverEventListener: + ([@bs.as "dragover"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragOverEventListenerWithOptions: + ( + [@bs.as "dragover"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragOverEventListenerUseCapture: + ( + [@bs.as "dragover"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDragStartEventListener: + ([@bs.as "dragstart"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDragStartEventListenerWithOptions: + ( + [@bs.as "dragstart"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDragStartEventListenerUseCapture: + ( + [@bs.as "dragstart"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDragStartEventListener: + ([@bs.as "dragstart"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDragStartEventListenerWithOptions: + ( + [@bs.as "dragstart"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDragStartEventListenerUseCapture: + ( + [@bs.as "dragstart"] _, + Dom.dragEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addDropEventListener: + ([@bs.as "drop"] _, Dom.dragEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addDropEventListenerWithOptions: + ( + [@bs.as "drop"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addDropEventListenerUseCapture: + ([@bs.as "drop"] _, Dom.dragEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeDropEventListener: + ([@bs.as "drop"] _, Dom.dragEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeDropEventListenerWithOptions: + ( + [@bs.as "drop"] _, + Dom.dragEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeDropEventListenerUseCapture: + ([@bs.as "drop"] _, Dom.dragEvent => unit, [@bs.as {json|true|json}] _) => + unit = + "removeEventListener"; + + /* Touch */ + + [@bs.send.pipe: T.t] + external addTouchCancelEventListener: + ([@bs.as "touchcancel"] _, Dom.touchEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addTouchCancelEventListenerWithOptions: + ( + [@bs.as "touchcancel"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addTouchCancelEventListenerUseCapture: + ( + [@bs.as "touchcancel"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeTouchCancelEventListener: + ([@bs.as "touchcancel"] _, Dom.touchEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeTouchCancelEventListenerWithOptions: + ( + [@bs.as "touchcancel"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeTouchCancelEventListenerUseCapture: + ( + [@bs.as "touchcancel"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addTouchEndEventListener: + ([@bs.as "touchend"] _, Dom.touchEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addTouchEndEventListenerWithOptions: + ( + [@bs.as "touchend"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addTouchEndEventListenerUseCapture: + ( + [@bs.as "touchend"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeTouchEndEventListener: + ([@bs.as "touchend"] _, Dom.touchEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeTouchEndEventListenerWithOptions: + ( + [@bs.as "touchend"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeTouchEndEventListenerUseCapture: + ( + [@bs.as "touchend"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addTouchMoveEventListener: + ([@bs.as "touchmove"] _, Dom.touchEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addTouchMoveEventListenerWithOptions: + ( + [@bs.as "touchmove"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addTouchMoveEventListenerUseCapture: + ( + [@bs.as "touchmove"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeTouchMoveEventListener: + ([@bs.as "touchmove"] _, Dom.touchEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeTouchMoveEventListenerWithOptions: + ( + [@bs.as "touchmove"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeTouchMoveEventListenerUseCapture: + ( + [@bs.as "touchmove"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addTouchStartEventListener: + ([@bs.as "touchstart"] _, Dom.touchEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addTouchStartEventListenerWithOptions: + ( + [@bs.as "touchstart"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addTouchStartEventListenerUseCapture: + ( + [@bs.as "touchstart"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeTouchStartEventListener: + ([@bs.as "touchstart"] _, Dom.touchEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeTouchStartEventListenerWithOptions: + ( + [@bs.as "touchstart"] _, + Dom.touchEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeTouchStartEventListenerUseCapture: + ( + [@bs.as "touchstart"] _, + Dom.touchEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + /* Animation */ + + [@bs.send.pipe: T.t] + external addAnimationCancelEventListener: + ([@bs.as "animationcancel"] _, Dom.animationEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addAnimationCancelEventListenerWithOptions: + ( + [@bs.as "animationcancel"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addAnimationCancelEventListenerUseCapture: + ( + [@bs.as "animationcancel"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationCancelEventListener: + ([@bs.as "animationcancel"] _, Dom.animationEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationCancelEventListenerWithOptions: + ( + [@bs.as "animationcancel"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeAnimationCancelEventListenerUseCapture: + ( + [@bs.as "animationcancel"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addAnimationEndEventListener: + ([@bs.as "animationend"] _, Dom.animationEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addAnimationEndEventListenerWithOptions: + ( + [@bs.as "animationend"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addAnimationEndEventListenerUseCapture: + ( + [@bs.as "animationend"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationEndEventListener: + ([@bs.as "animationend"] _, Dom.animationEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationEndEventListenerWithOptions: + ( + [@bs.as "animationend"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeAnimationEndEventListenerUseCapture: + ( + [@bs.as "animationend"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addAnimationIterationEventListener: + ([@bs.as "animationiteration"] _, Dom.animationEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addAnimationIterationEventListenerWithOptions: + ( + [@bs.as "animationiteration"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addAnimationIterationEventListenerUseCapture: + ( + [@bs.as "animationiteration"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationIterationEventListener: + ([@bs.as "animationiteration"] _, Dom.animationEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationIterationEventListenerWithOptions: + ( + [@bs.as "animationiteration"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeAnimationIterationEventListenerUseCapture: + ( + [@bs.as "animationiteration"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; + + [@bs.send.pipe: T.t] + external addAnimationStartEventListener: + ([@bs.as "animationstart"] _, Dom.animationEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addAnimationStartEventListenerWithOptions: + ( + [@bs.as "animationstart"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addAnimationStartEventListenerUseCapture: + ( + [@bs.as "animationstart"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationStartEventListener: + ([@bs.as "animationstart"] _, Dom.animationEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeAnimationStartEventListenerWithOptions: + ( + [@bs.as "animationstart"] _, + Dom.animationEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeAnimationStartEventListenerUseCapture: + ( + [@bs.as "animationstart"] _, + Dom.animationEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; +}; + +include Impl({ + type nonrec t = Dom.eventTarget; +}); + +external unsafeAsDocument: Dom.eventTarget => Dom.document = "%identity"; +external unsafeAsElement: Dom.eventTarget => Dom.element = "%identity"; +external unsafeAsWindow: Dom.eventTarget => Dom.window = "%identity"; diff --git a/packages/webapi/Webapi__Dom__FocusEvent.re b/packages/webapi/Webapi__Dom__FocusEvent.re new file mode 100644 index 000000000..b1f929719 --- /dev/null +++ b/packages/webapi/Webapi__Dom__FocusEvent.re @@ -0,0 +1,14 @@ +type t = Dom.focusEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "FocusEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "FocusEvent"; + +[@bs.get] [@bs.return nullable] +external relatedTarget: t => option(Dom.eventTarget); diff --git a/packages/webapi/Webapi__Dom__GlobalEventHandlers.re b/packages/webapi/Webapi__Dom__GlobalEventHandlers.re new file mode 100644 index 000000000..90f274dc4 --- /dev/null +++ b/packages/webapi/Webapi__Dom__GlobalEventHandlers.re @@ -0,0 +1,56 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.send.pipe: T.t] + external addSelectionChangeEventListener: + ([@bs.as "selectionchange"] _, Dom.focusEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external addSelectionChangeEventListenerWithOptions: + ( + [@bs.as "selectionchange"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "once": bool, + "passive": bool, + } + ) => + unit = + "addEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external addSelectionChangeEventListenerUseCapture: + ( + [@bs.as "selectionchange"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "addEventListener"; + [@bs.send.pipe: T.t] + external removeSelectionChangeEventListener: + ([@bs.as "selectionchange"] _, Dom.focusEvent => unit) => unit = + "removeEventListener"; + [@bs.send.pipe: T.t] + external removeSelectionChangeEventListenerWithOptions: + ( + [@bs.as "selectionchange"] _, + Dom.focusEvent => unit, + { + . + "capture": bool, + "passive": bool, + } + ) => + unit = + "removeEventListener"; /* not widely supported */ + [@bs.send.pipe: T.t] + external removeSelectionChangeEventListenerUseCapture: + ( + [@bs.as "selectionchange"] _, + Dom.focusEvent => unit, + [@bs.as {json|true|json}] _ + ) => + unit = + "removeEventListener"; +}; diff --git a/packages/webapi/Webapi__Dom__History.re b/packages/webapi/Webapi__Dom__History.re new file mode 100644 index 000000000..e1150453b --- /dev/null +++ b/packages/webapi/Webapi__Dom__History.re @@ -0,0 +1,14 @@ +type t = Dom.history; +type state; /* TODO: should be "anything that can be serializable" apparently */ + +[@bs.get] external length: t => int; +[@bs.get] external scrollRestoration: t => bool; /* experimental */ +[@bs.set] +external setScrollRestoration: (t, bool) => unit = "scrollRestoration"; /* experimental */ +[@bs.get] external state: t => state; + +[@bs.send.pipe: t] external back: unit; +[@bs.send.pipe: t] external forward: unit; +[@bs.send.pipe: t] external go: int => unit; +[@bs.send.pipe: t] external pushState: (state, string, string) => unit; +[@bs.send.pipe: t] external replaceState: (state, string, string) => unit; diff --git a/packages/webapi/Webapi__Dom__HtmlCollection.re b/packages/webapi/Webapi__Dom__HtmlCollection.re new file mode 100644 index 000000000..7538992ab --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlCollection.re @@ -0,0 +1,10 @@ +type t = Dom.htmlCollection; + +[@bs.val] [@bs.scope ("Array", "prototype", "slice")] +external toArray: t => array(Dom.element) = "call"; + +[@bs.get] external length: t => int; +[@bs.send.pipe: t] [@bs.return nullable] +external item: int => option(Dom.element); +[@bs.send.pipe: t] [@bs.return nullable] +external namedItem: string => option(Dom.element); diff --git a/packages/webapi/Webapi__Dom__HtmlDocument.re b/packages/webapi/Webapi__Dom__HtmlDocument.re new file mode 100644 index 000000000..201263a1a --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlDocument.re @@ -0,0 +1,90 @@ +module Impl = (T: {type t;}) => { + type t_htmlDocument = T.t; + + [@bs.get] [@bs.return nullable] + external activeElement: t_htmlDocument => option(Dom.element); + [@bs.get] [@bs.return nullable] + external body: t_htmlDocument => option(Dom.element); /* returns option HTMLBodyElement */ + [@bs.set] external setBody: (t_htmlDocument, Dom.element) => unit = "body"; /* accepth HTMLBodyElement */ + [@bs.get] external cookie: t_htmlDocument => string; + [@bs.set] external setCookie: (t_htmlDocument, string) => unit = "cookie"; + [@bs.get] [@bs.return nullable] + external defaultView: t_htmlDocument => option(Dom.window); + [@bs.get] + external designMode: t_htmlDocument => string /* designMode enum */; + let designMode: t_htmlDocument => Webapi__Dom__Types.designMode = + self => Webapi__Dom__Types.decodeDesignMode(designMode(self)); + [@bs.set] + external setDesignMode: + (t_htmlDocument, string /* designMode enum */) => unit = + "designMode"; + let setDesignMode: (t_htmlDocument, Webapi__Dom__Types.designMode) => unit = + (self, value) => + setDesignMode(self, Webapi__Dom__Types.encodeDesignMode(value)); + [@bs.get] external dir: t_htmlDocument => string /* dir enum */; + let dir: t_htmlDocument => Webapi__Dom__Types.dir = + self => Webapi__Dom__Types.decodeDir(dir(self)); + [@bs.set] + external setDir: (t_htmlDocument, string /* dir enum */) => unit = "dir"; + let setDir: (t_htmlDocument, Webapi__Dom__Types.dir) => unit = + (self, value) => setDir(self, Webapi__Dom__Types.encodeDir(value)); + [@bs.get] [@bs.return nullable] + external domain: t_htmlDocument => option(string); + [@bs.set] external setDomain: (t_htmlDocument, string) => unit = "domain"; + [@bs.get] external embeds: t_htmlDocument => Dom.nodeList; + [@bs.get] external forms: t_htmlDocument => Dom.htmlCollection; + [@bs.get] external head: t_htmlDocument => Dom.element; /* returns HTMLHeadElement */ + [@bs.get] external images: t_htmlDocument => Dom.htmlCollection; + [@bs.get] external lastModified: t_htmlDocument => string; + [@bs.get] external links: t_htmlDocument => Dom.nodeList; + [@bs.get] external location: t_htmlDocument => Dom.location; + [@bs.set] + external setLocation: (t_htmlDocument, string) => unit = "location"; + [@bs.get] external plugins: t_htmlDocument => Dom.htmlCollection; + [@bs.get] external readyState: t_htmlDocument => string /* enum */; + let readyState: t_htmlDocument => Webapi__Dom__Types.readyState = + self => Webapi__Dom__Types.decodeReadyState(readyState(self)); + [@bs.get] external referrer: t_htmlDocument => string; + [@bs.get] external scripts: t_htmlDocument => Dom.htmlCollection; + [@bs.get] external title: t_htmlDocument => string; + [@bs.set] external setTitle: (t_htmlDocument, string) => unit = "title"; + [@bs.get] external url: t_htmlDocument => string = "URL"; + + [@bs.send.pipe: t_htmlDocument] external close: unit; + [@bs.send.pipe: t_htmlDocument] + external execCommand: (string, bool, Js.null(string)) => bool; + let execCommand: (string, bool, option(string), t_htmlDocument) => bool = + (command, show, value, self) => + execCommand(command, show, Js.Null.fromOption(value), self); + [@bs.send.pipe: t_htmlDocument] + external getElementsByName: string => Dom.nodeList; + [@bs.send.pipe: t_htmlDocument] external getSelection: Dom.selection; + [@bs.send.pipe: t_htmlDocument] external hasFocus: bool; + [@bs.send.pipe: t_htmlDocument] external open_: unit = "open"; + [@bs.send.pipe: t_htmlDocument] external queryCommandEnabled: string => bool; + [@bs.send.pipe: t_htmlDocument] + external queryCommandIndeterm: string => bool; + [@bs.send.pipe: t_htmlDocument] + external queryCommandSupported: string => bool; + [@bs.send.pipe: t_htmlDocument] external queryCommandValue: string => string; + [@bs.send.pipe: t_htmlDocument] external write: string => unit; + [@bs.send.pipe: t_htmlDocument] external writeln: string => unit; +}; + +type t = Dom.htmlDocument; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__GlobalEventHandlers.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Document.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__HtmlElement.re b/packages/webapi/Webapi__Dom__HtmlElement.re new file mode 100644 index 000000000..854183e8c --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlElement.re @@ -0,0 +1,118 @@ +module Impl = (T: {type t;}) => { + type t_htmlElement = T.t; + + let ofElement = Webapi__Dom__Element.asHtmlElement; + + [@bs.get] external accessKey: t_htmlElement => string; + [@bs.set] + external setAccessKey: (t_htmlElement, string) => unit = "accessKey"; + [@bs.get] external accessKeyLabel: t_htmlElement => string; + [@bs.get] external contentEditable: t_htmlElement => string /* enum */; + let contentEditable: t_htmlElement => Webapi__Dom__Types.contentEditable = + self => Webapi__Dom__Types.decodeContentEditable(contentEditable(self)); + [@bs.set] + external setContentEditable: (t_htmlElement, string /* enum */) => unit = + "contentEditable"; + let setContentEditable: + (t_htmlElement, Webapi__Dom__Types.contentEditable) => unit = + (self, value) => + setContentEditable( + self, + Webapi__Dom__Types.encodeContentEditable(value), + ); + [@bs.get] external isContentEditable: t_htmlElement => bool; + [@bs.get] external contextMenu: t_htmlElement => Dom.htmlElement; /* returns HTMLMenuElement */ + [@bs.set] + external setContextMenu: (t_htmlElement, Dom.htmlElement) => unit = + "contextMenu"; /* accepts and returns HTMLMenuElement */ + [@bs.get] external dataset: t_htmlElement => Dom.domStringMap; + [@bs.get] external dir: t_htmlElement => string /* enum */; + let dir: t_htmlElement => Webapi__Dom__Types.dir = + self => Webapi__Dom__Types.decodeDir(dir(self)); + [@bs.set] + external setDir: (t_htmlElement, string /* enum */) => unit = "dir"; + let setDir: (t_htmlElement, Webapi__Dom__Types.dir) => unit = + (self, value) => setDir(self, Webapi__Dom__Types.encodeDir(value)); + [@bs.get] external draggable: t_htmlElement => bool; + [@bs.set] external setDraggable: (t_htmlElement, bool) => unit = "draggable" /*let setDraggable : t_htmlElement => bool => unit = fun self value => setDraggable self (Js.Boolean.to_js_boolean value);*/; /* temproarily removed to reduce codegen size */ + [@bs.get] external dropzone: t_htmlElement => Dom.domSettableTokenList; + [@bs.get] external hidden: t_htmlElement => bool; + [@bs.set] external setHidden: (t_htmlElement, bool) => unit = "hidden" /*let setHidden : t_htmlElement => bool => unit = fun self value => setHidden self (Js.Boolean.to_js_boolean value);*/; /* temproarily removed to reduce codegen size */ + [@bs.get] external itemScope: t_htmlElement => bool; /* experimental */ + [@bs.set] external setItemScope: (t_htmlElement, bool) => unit = "itemScope" /*let setItemScope : t_htmlElement => bool => unit = fun self value => setItemScope self (Js.Boolean.to_js_boolean value);*/; /* experimental */ /* temproarily removed to reduce codegen size */ + [@bs.get] external itemType: t_htmlElement => Dom.domSettableTokenList; /* experimental */ + [@bs.get] external itemId: t_htmlElement => string; /* experimental */ + [@bs.set] external setItemId: (t_htmlElement, string) => unit = "itemId"; /* experimental */ + [@bs.get] external itemRef: t_htmlElement => Dom.domSettableTokenList; /* experimental */ + [@bs.get] external itemProp: t_htmlElement => Dom.domSettableTokenList; /* experimental */ + [@bs.get] external itemValue: t_htmlElement => Js.t({..}); /* experimental */ + [@bs.set] + external setItemValue: (t_htmlElement, Js.t({..})) => unit = "itemValue"; /* experimental */ + [@bs.get] external lang: t_htmlElement => string; + [@bs.set] external setLang: (t_htmlElement, string) => unit = "lang"; + [@bs.get] external offsetHeight: t_htmlElement => int; /* experimental */ + [@bs.get] external offsetLeft: t_htmlElement => int; /* experimental */ + [@bs.get] [@bs.return nullable] + external offsetParent: t_htmlElement => option(Dom.element); /* experimental */ + [@bs.get] external offsetTop: t_htmlElement => int; /* experimental, but widely supported */ + [@bs.get] external offsetWidth: t_htmlElement => int; /* experimental */ + /*external properties : r => HTMLPropertiesCollection.t = "properties" [@@bs.get]; /* experimental */*/ + [@bs.get] external spellcheck: t_htmlElement => bool; + [@bs.set] + external setSpellcheck: (t_htmlElement, bool) => unit = "spellcheck" /*let setSpellcheck : t_htmlElement => bool => unit = fun self value => setSpellcheck self (Js.Boolean.to_js_boolean value);*/; /* temproarily removed to reduce codegen size */ + [@bs.get] external style: t_htmlElement => Dom.cssStyleDeclaration; + [@bs.set] + external setStyle: (t_htmlElement, Dom.cssStyleDeclaration) => unit = + "style"; + [@bs.get] external tabIndex: t_htmlElement => int; + [@bs.set] external setTabIndex: (t_htmlElement, int) => unit = "tabIndex"; + [@bs.get] external title: t_htmlElement => string; + [@bs.set] external setTitle: (t_htmlElement, string) => unit = "title"; + [@bs.get] external translate: t_htmlElement => bool; /* experimental */ + [@bs.set] external setTranslate: (t_htmlElement, bool) => unit = "translate" /*let setTranslate : t_htmlElement => bool => unit = fun self value => setTranslate self (Js.Boolean.to_js_boolean value);*/; /* experimental */ /* temproarily removed to reduce codegen size */ + [@bs.send.pipe: t_htmlElement] external blur: unit; + [@bs.send.pipe: t_htmlElement] external click: unit; + [@bs.send.pipe: t_htmlElement] external focus: unit; + [@bs.send.pipe: t_htmlElement] + external focusPreventScroll: + ([@bs.as {json|{ "preventScroll": true }|json}] _) => unit = + "focus"; + [@bs.send.pipe: t_htmlElement] external forceSpellCheck: unit; /* experimental */ + + /* TODO: element-spcific, should be pulled out */ + [@bs.get] external value: t_htmlElement => string; /* HTMLInputElement */ + [@bs.get] external checked: t_htmlElement => bool; /* HTMLInputElement */ + [@bs.get] external type_: t_htmlElement => string = "type"; /* HTMLStyleElement */ + [@bs.set] external setType: (t_htmlElement, string) => unit = "type"; /* HTMLStyleElement */ + [@bs.get] external rel: t_htmlElement => string; /* HTMLLinkElement */ + [@bs.set] external setRel: (t_htmlElement, string) => unit = "rel"; /* HTMLLinkElement */ + [@bs.get] external href: t_htmlElement => string; /* HTMLLinkElement, HTMLAnchorElement */ + [@bs.set] external setHref: (t_htmlElement, string) => unit = "href"; /* HTMLLinkElement, HTMLAnchorElement */ +}; + +/* TODO + module Tree (T: { type t; }) => { + include ElementRe.Tree { type t = Type }; + include Impl { type t = Type }; + }; + + include Tree { type t = Dom.htmlElement }; + */ + +type t = Dom.htmlElement; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__GlobalEventHandlers.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Element.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__HtmlFormElement.re b/packages/webapi/Webapi__Dom__HtmlFormElement.re new file mode 100644 index 000000000..2f359de61 --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlFormElement.re @@ -0,0 +1,63 @@ +/* + * Spec: https://html.spec.whatwg.org/multipage/forms.html#the-form-element + * MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement + */ + +module Impl = (T: {type t;}) => { + type t_htmlFormElement = T.t; + + /* TODO: elements: HTMLFormControlsCollection */ + [@bs.get] external length: t_htmlFormElement => int; + [@bs.get] external name: t_htmlFormElement => string; + [@bs.set] external setName: (t_htmlFormElement, string) => unit = "name"; + [@bs.get] external method: t_htmlFormElement => string; + [@bs.set] external setMethod: (t_htmlFormElement, string) => unit = "method"; + [@bs.get] external target: t_htmlFormElement => string; + [@bs.set] external setTarget: (t_htmlFormElement, string) => unit = "target"; + [@bs.get] external action: t_htmlFormElement => string; + [@bs.set] external setAction: (t_htmlFormElement, string) => unit = "action"; + [@bs.get] external acceptCharset: t_htmlFormElement => string; + [@bs.set] + external setAcceptCharset: (t_htmlFormElement, string) => unit = + "acceptCharset"; + [@bs.get] external autocomplete: t_htmlFormElement => string; + [@bs.set] + external setAutocomplete: (t_htmlFormElement, string) => unit = + "autocomplete"; + [@bs.get] external noValidate: t_htmlFormElement => bool; + [@bs.set] + external setNoValidate: (t_htmlFormElement, bool) => unit = "noValidate"; + [@bs.get] external enctype: t_htmlFormElement => string; + [@bs.set] + external setEnctype: (t_htmlFormElement, string) => unit = "enctype"; + [@bs.get] external encoding: t_htmlFormElement => string; + [@bs.set] + external setEncoding: (t_htmlFormElement, string) => unit = "encoding"; + + [@bs.send.pipe: t_htmlFormElement] external submit: unit; + [@bs.send.pipe: t_htmlFormElement] external reset: unit; + [@bs.send.pipe: t_htmlFormElement] external checkValidity: bool; + [@bs.send.pipe: t_htmlFormElement] external reportValidity: bool; + + /** @since 0.18.0 */ + [@bs.new] + external data: T.t => Fetch.FormData.t = "FormData"; +}; + +type t = Dom.htmlFormElement; + +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Element.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__HtmlElement.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__HtmlImageElement.re b/packages/webapi/Webapi__Dom__HtmlImageElement.re new file mode 100644 index 000000000..2fd5cd698 --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlImageElement.re @@ -0,0 +1,49 @@ +type t; + +[@bs.new] external make: unit => t = "Image"; +[@bs.new] external makeWithSize: (int, int) => t = "Image"; + +[@bs.get] external alt: t => string = "alt"; +[@bs.set] external setAlt: (t, string) => unit = "alt"; +[@bs.get] external src: t => string = "src"; +[@bs.set] external setSrc: (t, string) => unit = "src"; +[@bs.get] external srcset: t => string = "srcset"; +[@bs.set] external setSrcset: (t, string) => unit = "srcset"; +[@bs.get] external sizes: t => string = "sizes"; +[@bs.set] external setSizes: (t, string) => unit = "sizes"; +[@bs.get] [@bs.return nullable] external crossOrigin: t => option(string); +[@bs.set] +external setCrossOrigin: (t, Js.null(string)) => unit = "crossOrigin"; +let setCrossOrigin = (self, value) => + setCrossOrigin(self, Js.Null.fromOption(value)); +[@bs.get] external useMap: t => string; +[@bs.set] external setUseMap: (t, string) => unit = "useMap"; +[@bs.get] external isMap: t => bool; +[@bs.set] external setIsMap: (t, bool) => unit = "isMap"; +[@bs.get] external height: t => int; +[@bs.set] external setHeight: (t, int) => unit = "height"; +[@bs.get] external width: t => int; +[@bs.set] external setWidth: (t, int) => unit = "width"; +[@bs.get] external naturalHeight: t => int; +[@bs.get] external naturalWidth: t => int; +[@bs.get] external complete: t => bool; +[@bs.get] external currentSrc: t => string; +[@bs.get] external referrerPolicy: t => string; +[@bs.set] external setReferrerPolicy: (t, string) => unit = "referrerPolicy"; +[@bs.get] external decoding: t => string; +[@bs.set] external setDecoding: (t, string) => unit = "decoding"; + +/* [@bs.send.pipe: t] external decode: Js.Promise.t(unit); */ + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Element.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__HtmlElement.Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__HtmlInputElement.re b/packages/webapi/Webapi__Dom__HtmlInputElement.re new file mode 100644 index 000000000..9b3e54846 --- /dev/null +++ b/packages/webapi/Webapi__Dom__HtmlInputElement.re @@ -0,0 +1,238 @@ +/* + * Spec: https://html.spec.whatwg.org/multipage/input.html#the-input-element + * MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement + */ + +module Impl = (T: {type t;}) => { + type t_htmlInputElement = T.t; + + [@bs.get] [@bs.return nullable] + external form: t_htmlInputElement => option(Dom.htmlFormElement); + [@bs.get] external formAction: t_htmlInputElement => string; + [@bs.set] + external setFormAction: (t_htmlInputElement, string) => unit = "formAction"; + [@bs.get] external formEncType: t_htmlInputElement => string; + [@bs.set] + external setFormEncType: (t_htmlInputElement, string) => unit = + "formEncType"; + [@bs.get] external formMethod: t_htmlInputElement => string; + [@bs.set] + external setFormMethod: (t_htmlInputElement, string) => unit = "formMethod"; + [@bs.get] external formNoValidate: t_htmlInputElement => bool; + [@bs.set] + external setFormNoValidate: (t_htmlInputElement, bool) => unit = + "formNoValidate"; + [@bs.get] external formTarget: t_htmlInputElement => string; + [@bs.set] + external setFormTarget: (t_htmlInputElement, string) => unit = "formTarget"; + + /* Properties that apply to any type of input element that is not hidden */ + [@bs.get] external name: t_htmlInputElement => string; + [@bs.set] external setName: (t_htmlInputElement, string) => unit = "name"; + [@bs.get] external type_: t_htmlInputElement => string = "type"; + [@bs.set] external setType: (t_htmlInputElement, string) => unit = "type"; + [@bs.get] external disabled: t_htmlInputElement => bool; + [@bs.set] + external setDisabled: (t_htmlInputElement, bool) => unit = "disabled"; + [@bs.get] external autofocus: t_htmlInputElement => bool; + [@bs.set] + external setAutofocus: (t_htmlInputElement, bool) => unit = "autofocus"; + [@bs.get] external required: t_htmlInputElement => bool; + [@bs.set] + external setRequired: (t_htmlInputElement, bool) => unit = "required"; + [@bs.get] external value: t_htmlInputElement => string; + [@bs.set] external setValue: (t_htmlInputElement, string) => unit = "value"; + [@bs.get] + external validity: t_htmlInputElement => Webapi__Dom__ValidityState.t; + [@bs.get] external validationMessage: t_htmlInputElement => string; + [@bs.get] external willValidate: t_htmlInputElement => bool; + + /* Properties that apply only to elements of type "checkbox" or "radio" */ + [@bs.get] external checked: t_htmlInputElement => bool; + [@bs.set] + external setChecked: (t_htmlInputElement, bool) => unit = "checked"; + [@bs.get] external defaultChecked: t_htmlInputElement => bool; + [@bs.set] + external setDefaultChecked: (t_htmlInputElement, bool) => unit = + "defaultChecked"; + [@bs.get] external indeterminate: t_htmlInputElement => bool; + [@bs.set] + external setIndeterminate: (t_htmlInputElement, bool) => unit = + "indeterminate"; + + /* Properties that apply only to elements of type "image" */ + [@bs.get] external alt: t_htmlInputElement => string; + [@bs.set] external setAlt: (t_htmlInputElement, string) => unit = "alt"; + [@bs.get] external height: t_htmlInputElement => string; + [@bs.set] + external setHeight: (t_htmlInputElement, string) => unit = "height"; + [@bs.get] external src: t_htmlInputElement => string; + [@bs.set] external setSrc: (t_htmlInputElement, string) => unit = "src"; + [@bs.get] external width: t_htmlInputElement => string; + [@bs.set] external setWidth: (t_htmlInputElement, string) => unit = "width"; + + /* Properties that apply only to elements of type "file" */ + [@bs.get] external accept: t_htmlInputElement => string; + [@bs.set] + external setAccept: (t_htmlInputElement, string) => unit = "accept"; + /* TODO: files: Returns/accepts a FileList object. */ + + /* Properties that apply only to text/number-containing or elements */ + [@bs.get] external autocomplete: t_htmlInputElement => string; + [@bs.set] + external setAutocomplete: (t_htmlInputElement, string) => unit = + "autocomplete"; + [@bs.get] external maxLength: t_htmlInputElement => int; + [@bs.set] + external setMaxLength: (t_htmlInputElement, int) => unit = "maxLength"; + [@bs.get] external minLength: t_htmlInputElement => int; + [@bs.set] + external setMinLength: (t_htmlInputElement, int) => unit = "minLength"; + [@bs.get] external size: t_htmlInputElement => int; + [@bs.set] external setSize: (t_htmlInputElement, int) => unit = "size"; + [@bs.get] external pattern: t_htmlInputElement => string; + [@bs.set] + external setPattern: (t_htmlInputElement, string) => unit = "pattern"; + [@bs.get] external placeholder: t_htmlInputElement => string; + [@bs.set] + external setPlaceholder: (t_htmlInputElement, string) => unit = + "placeholder"; + [@bs.get] external readOnly: t_htmlInputElement => bool; + [@bs.set] + external setReadOnly: (t_htmlInputElement, bool) => unit = "readOnly"; + [@bs.get] external min: t_htmlInputElement => string; + [@bs.set] external setMin: (t_htmlInputElement, string) => unit = "min"; + [@bs.get] external max: t_htmlInputElement => string; + [@bs.set] external setMax: (t_htmlInputElement, string) => unit = "max"; + [@bs.get] external selectionStart: t_htmlInputElement => int; + [@bs.set] + external setSelectionStart: (t_htmlInputElement, int) => unit = + "selectionStart"; + [@bs.get] external selectionEnd: t_htmlInputElement => int; + [@bs.set] + external setSelectionEnd: (t_htmlInputElement, int) => unit = "selectionEnd"; + [@bs.get] external selectionDirection: t_htmlInputElement => string; + [@bs.set] + external setSelectionDirection: (t_htmlInputElement, string) => unit = + "selectionDirection"; + + /* Properties not yet categorized */ + [@bs.get] external defaultValue: t_htmlInputElement => string; + [@bs.set] + external setDefaultValue: (t_htmlInputElement, string) => unit = + "defaultValue"; + [@bs.get] external dirName: t_htmlInputElement => string; + [@bs.set] + external setDirName: (t_htmlInputElement, string) => unit = "dirName"; + [@bs.get] external accessKey: t_htmlInputElement => string; + [@bs.set] + external setAccessKey: (t_htmlInputElement, string) => unit = "accessKey"; + [@bs.get] [@bs.return nullable] + external list: t_htmlInputElement => option(Dom.htmlElement); + [@bs.get] external multiple: t_htmlInputElement => bool; + [@bs.set] + external setMultiple: (t_htmlInputElement, bool) => unit = "multiple"; + /* TODO: files: FileList array. Returns the list of selected files. */ + [@bs.get] external labels: t_htmlInputElement => array(Dom.nodeList); + [@bs.get] external step: t_htmlInputElement => string; + [@bs.set] external setStep: (t_htmlInputElement, string) => unit = "step"; + /* [@bs.get] [@bs.return nullable] + external valueAsDate: t_htmlInputElement => option(Js.Date.t); */ + /* [@bs.set] + external setValueAsDate: (t_htmlInputElement, Js.Date.t) => unit = + "valueAsDate"; */ + [@bs.get] external valueAsNumber: t_htmlInputElement => float; + + [@bs.send.pipe: t_htmlInputElement] external select: unit; + + module SelectionDirection = { + type t = + | Forward + | Backward + | None; + + let toString = + fun + | Forward => "forward" + | Backward => "backward" + | None => "none"; + }; + + [@bs.send.pipe: t_htmlInputElement] + external setSelectionRange: (int, int) => unit; + [@bs.send.pipe: t_htmlInputElement] + external setSelectionRangeWithDirection_: (int, int, string) => unit = + "setSelectionRange"; + let setSelectionRangeWithDirection = + (selectionStart, selectionEnd, selectionDirection, element) => + element + |> setSelectionRangeWithDirection_( + selectionStart, + selectionEnd, + selectionDirection |> SelectionDirection.toString, + ); + + module SelectionMode = { + type t = + | Select + | Start + | End + | Preserve; + + let toString = + fun + | Select => "select" + | Start => "start" + | End => "end" + | Preserve => "preserve"; + }; + + [@bs.send.pipe: t_htmlInputElement] + external setRangeTextWithinSelection: string => unit = "setRangeText"; + [@bs.send.pipe: t_htmlInputElement] + external setRangeTextWithinInterval: (string, int, int) => unit = + "setRangeText"; + [@bs.send.pipe: t_htmlInputElement] + external setRangeTextWithinIntervalWithSelectionMode_: + (string, int, int, string) => unit = + "setRangeText"; + let setRangeTextWithinIntervalWithSelectionMode = + (text, selectionStart, selectionEnd, selectionMode, element) => + element + |> setRangeTextWithinIntervalWithSelectionMode_( + text, + selectionStart, + selectionEnd, + selectionMode |> SelectionMode.toString, + ); + + [@bs.send.pipe: t_htmlInputElement] + external setCustomValidity: string => unit; + [@bs.send.pipe: t_htmlInputElement] external checkValidity: bool; + [@bs.send.pipe: t_htmlInputElement] external reportValidity: bool; + [@bs.send.pipe: t_htmlInputElement] + external stepDownBy: int => unit = "stepDown"; + [@bs.send.pipe: t_htmlInputElement] + external stepDownByOne: unit = "stepDown"; + [@bs.send.pipe: t_htmlInputElement] + external stepUpBy: int => unit = "stepUp"; + [@bs.send.pipe: t_htmlInputElement] external stepUpByOne: unit = "stepUp"; +}; + +type t = Dom.htmlInputElement; + +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Element.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__HtmlElement.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__IdbVersionChangeEvent.re b/packages/webapi/Webapi__Dom__IdbVersionChangeEvent.re new file mode 100644 index 000000000..c7ba9f3bd --- /dev/null +++ b/packages/webapi/Webapi__Dom__IdbVersionChangeEvent.re @@ -0,0 +1,12 @@ +type t = Dom.idbVersionChangeEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "IDBVersionChangeEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "IDBVersionChangeEvent"; + +[@bs.get] external oldVersion: t => int; +[@bs.get] external newVersion: t => int; diff --git a/packages/webapi/Webapi__Dom__Image.re b/packages/webapi/Webapi__Dom__Image.re new file mode 100644 index 000000000..ba8467cfe --- /dev/null +++ b/packages/webapi/Webapi__Dom__Image.re @@ -0,0 +1,17 @@ +type t; + +/* [@bs.new] + external makeWithData: + ( + ~array: Js.Typed_array.Uint8ClampedArray.t, + ~width: float, + ~height: float + ) => + t = + "ImageData"; */ + +[@bs.new] external make: (~width: float, ~height: float) => t = "ImageData"; + +/* [@bs.get] external data: t => Js.Typed_array.Uint8ClampedArray.t; */ +[@bs.get] external height: t => float = "height"; +[@bs.get] external width: t => float = "width"; diff --git a/packages/webapi/Webapi__Dom__InputEvent.re b/packages/webapi/Webapi__Dom__InputEvent.re new file mode 100644 index 000000000..c48bda3ef --- /dev/null +++ b/packages/webapi/Webapi__Dom__InputEvent.re @@ -0,0 +1,14 @@ +type t = Dom.inputEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "InputEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "InputEvent"; + +[@bs.get] external data: t => string; +[@bs.get] external isComposing: t => bool; diff --git a/packages/webapi/Webapi__Dom__KeyboardEvent.re b/packages/webapi/Webapi__Dom__KeyboardEvent.re new file mode 100644 index 000000000..7417a78ab --- /dev/null +++ b/packages/webapi/Webapi__Dom__KeyboardEvent.re @@ -0,0 +1,29 @@ +type t = Dom.keyboardEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "KeyboardEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "KeyboardEvent"; + +[@bs.get] external altKey: t => bool; +[@bs.get] external code: t => string; +[@bs.get] external ctrlKey: t => bool; +[@bs.get] external isComposing: t => bool; +[@bs.get] external key: t => string; +[@bs.get] external locale: t => string; +[@bs.get] external location: t => int; +[@bs.get] external metaKey: t => bool; +[@bs.get] external repeat: t => bool; +[@bs.get] external shiftKey: t => bool; + +[@bs.send.pipe: t] +external getModifierState: string /* modifierKey enum */ => bool; +let getModifierState: (Webapi__Dom__Types.modifierKey, t) => bool = + (key, self) => + getModifierState(Webapi__Dom__Types.encodeModifierKey(key), self); diff --git a/packages/webapi/Webapi__Dom__Location.re b/packages/webapi/Webapi__Dom__Location.re new file mode 100644 index 000000000..f1650288a --- /dev/null +++ b/packages/webapi/Webapi__Dom__Location.re @@ -0,0 +1,31 @@ +type t = Dom.location; + +/* a more ergonomic API would perhaps accept a Window.t directly instead of Location.t */ +[@bs.get] external href: t => string; +[@bs.set] external setHref: (t, string) => unit = "href"; +[@bs.get] external protocol: t => string; +[@bs.set] external setProtocol: (t, string) => unit = "protocol"; +[@bs.get] external host: t => string; +[@bs.set] external setHost: (t, string) => unit = "host"; +[@bs.get] external hostname: t => string; +[@bs.set] external setHostname: (t, string) => unit = "hostname"; +[@bs.get] external port: t => string; +[@bs.set] external setPort: (t, string) => unit = "port"; +[@bs.get] external pathname: t => string; +[@bs.set] external setPathname: (t, string) => unit = "pathname"; +[@bs.get] external search: t => string; +[@bs.set] external setSearch: (t, string) => unit = "search"; +[@bs.get] external hash: t => string; +[@bs.set] external setHash: (t, string) => unit = "hash"; +[@bs.get] external username: t => string; +[@bs.set] external setUsername: (t, string) => unit = "username"; +[@bs.get] external password: t => string; +[@bs.set] external setPassword: (t, string) => unit = "password"; +[@bs.get] external origin: t => string; + +[@bs.send.pipe: t] external assign: string => unit; +[@bs.send.pipe: t] external reload: unit; +[@bs.send.pipe: t] +external reloadWithForce: ([@bs.as {json|true|json}] _) => unit = "reload"; +[@bs.send.pipe: t] external replace: string => unit; +[@bs.send.pipe: t] external toString: string; diff --git a/packages/webapi/Webapi__Dom__MouseEvent.re b/packages/webapi/Webapi__Dom__MouseEvent.re new file mode 100644 index 000000000..9018f05df --- /dev/null +++ b/packages/webapi/Webapi__Dom__MouseEvent.re @@ -0,0 +1,43 @@ +module Impl = (T: {type t;}) => { + [@bs.get] external altKey: T.t => bool; + [@bs.get] external button: T.t => int; + [@bs.get] external buttons: T.t => int /* bitmask */; + [@bs.get] external clientX: T.t => int; + [@bs.get] external clientY: T.t => int; + [@bs.get] external ctrlKey: T.t => bool; + [@bs.get] external metaKey: T.t => bool; + [@bs.get] external movementX: T.t => int; + [@bs.get] external movementY: T.t => int; + [@bs.get] external offsetX: T.t => int; /* experimental, but widely supported */ + [@bs.get] external offsetY: T.t => int; /* experimental, but widely supported */ + [@bs.get] external pageX: T.t => int; /* experimental, but widely supported */ + [@bs.get] external pageY: T.t => int; /* experimental, but widely supported */ + [@bs.get] [@bs.return nullable] external region: T.t => option(string); + [@bs.get] [@bs.return nullable] + external relatedTarget: T.t => option(Dom.eventTarget); + [@bs.get] external screenX: T.t => int; + [@bs.get] external screenY: T.t => int; + [@bs.get] external shiftKey: T.t => bool; + [@bs.get] external x: T.t => int; /* experimental */ + [@bs.get] external y: T.t => int; /* experimental */ + [@bs.send.pipe: T.t] + external getModifierState: string /* modifierKey enum */ => bool; + let getModifierState: (Webapi__Dom__Types.modifierKey, T.t) => bool = + (key, self) => + getModifierState(Webapi__Dom__Types.encodeModifierKey(key), self); +}; + +type t = Dom.mouseEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "MouseEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "MouseEvent"; diff --git a/packages/webapi/Webapi__Dom__MutationObserver.re b/packages/webapi/Webapi__Dom__MutationObserver.re new file mode 100644 index 000000000..70740bd14 --- /dev/null +++ b/packages/webapi/Webapi__Dom__MutationObserver.re @@ -0,0 +1,9 @@ +type t = Dom.mutationObserver; + +[@bs.new] +external make: ((array(Dom.mutationRecord), t) => unit) => t = + "MutationObserver"; + +[@bs.send.pipe: t] external observe: (Dom.node_like('a), Js.t({..})) => unit; +[@bs.send.pipe: t] external disconnect: unit; +[@bs.send.pipe: t] external takeRecords: array(Dom.mutationRecord); diff --git a/packages/webapi/Webapi__Dom__MutationRecord.re b/packages/webapi/Webapi__Dom__MutationRecord.re new file mode 100644 index 000000000..20b7bdc20 --- /dev/null +++ b/packages/webapi/Webapi__Dom__MutationRecord.re @@ -0,0 +1,12 @@ +type t = Dom.mutationRecord; + +[@bs.get] external type_: t => string = "type"; +[@bs.get] external target: t => Dom.node; +[@bs.get] external addedNodes: t => Dom.nodeList; +[@bs.get] external removedNodes: t => Dom.nodeList; +[@bs.get] [@bs.return nullable] +external previousSibling: t => option(Dom.node); +[@bs.get] [@bs.return nullable] external pnextSibling: t => option(Dom.node); +[@bs.get] external attributeName: t => string; +[@bs.get] external attributeNamespace: t => string; +[@bs.get] external oldValue: t => string; diff --git a/packages/webapi/Webapi__Dom__NamedNodeMap.re b/packages/webapi/Webapi__Dom__NamedNodeMap.re new file mode 100644 index 000000000..fa6e104a7 --- /dev/null +++ b/packages/webapi/Webapi__Dom__NamedNodeMap.re @@ -0,0 +1,17 @@ +type t = Dom.namedNodeMap; + +[@bs.get] external length: t => int; + +[@bs.send.pipe: t] [@bs.return nullable] +external item: int => option(Dom.attr); +[@bs.send.pipe: t] [@bs.return nullable] +external getNamedItem: string => option(Dom.attr); +[@bs.send.pipe: t] [@bs.return nullable] +external getNamedItemNS: (string, string) => option(Dom.attr); +[@bs.send.pipe: t] external setNamedItem: Dom.attr => unit; +[@bs.send.pipe: t] external setNamedItemNS: Dom.attr => unit; +[@bs.send.pipe: t] external removeNamedItem: string => Dom.attr; +[@bs.send.pipe: t] external removeNamedItemNS: (string, string) => Dom.attr; + +[@bs.val] [@bs.scope ("Array", "prototype", "slice")] +external toArray: t => array(Dom.attr) = "call"; diff --git a/packages/webapi/Webapi__Dom__Node.re b/packages/webapi/Webapi__Dom__Node.re new file mode 100644 index 000000000..6df4f443b --- /dev/null +++ b/packages/webapi/Webapi__Dom__Node.re @@ -0,0 +1,83 @@ +module Impl = (T: {type t;}) => { + external asNode: T.t => Dom.node = "%identity"; + + /* baseURI */ + [@bs.get] external childNodes: T.t => Dom.nodeList; + [@bs.get] [@bs.return nullable] + external firstChild: T.t => option(Dom.node); + [@bs.get] external innerText: T.t => string; + [@bs.set] external setInnerText: (T.t, string) => unit = "innerText"; + [@bs.get] [@bs.return nullable] external lastChild: T.t => option(Dom.node); + [@bs.get] [@bs.return nullable] + external nextSibling: T.t => option(Dom.node); + [@bs.get] external nodeName: T.t => string; /* nodePrincipal */ + [@bs.get] external nodeType: T.t => int /* nodeType enum */; + let nodeType: T.t => Webapi__Dom__Types.nodeType = + self => Webapi__Dom__Types.decodeNodeType(nodeType(self)); + [@bs.get] [@bs.return nullable] external nodeValue: T.t => option(string); + [@bs.set] + external setNodeValue: (T.t, Js.null(string)) => unit = "nodeValue" /* let setNodeValue : T.t => option string => unit = fun self value => setNodeValue self (Js.Null.fromOption value); */; /* temporarily removed to reduce codegen size */ + /* Not supported yet + external setNodeValue : T.t => string => unit = "nodeValue" [@@bs.set]; + external clearNodeValue : T.t => _ [@bs.as {json|null|json}] => unit = "nodeValue" [@@bs.set]; + */ + /* outerText */ + [@bs.get] external ownerDocument: T.t => Dom.document; + [@bs.get] [@bs.return nullable] + external parentElement: T.t => option(Dom.element); + [@bs.get] [@bs.return nullable] + external parentNode: T.t => option(Dom.node); + [@bs.get] [@bs.return nullable] + external previousSibling: T.t => option(Dom.node); + [@bs.get] external rootNode: T.t => Dom.node; + [@bs.get] external textContent: T.t => string; + [@bs.set] external setTextContent: (T.t, string) => unit = "textContent"; + + [@bs.send.pipe: T.t] external appendChild: Dom.node_like('a) => unit; + [@bs.send.pipe: T.t] external cloneNode: T.t; + [@bs.send.pipe: T.t] + external cloneNodeDeep: ([@bs.as {json|true|json}] _) => T.t = "cloneNode"; + [@bs.send.pipe: T.t] + external compareDocumentPosition: Dom.node_like('a) => int; /* returns a bitmask which could also be represeneted as an enum, see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition */ + [@bs.send.pipe: T.t] external contains: Dom.node_like('a) => bool; + [@bs.send.pipe: T.t] external getRootNode: Dom.node; + [@bs.send.pipe: T.t] + external getRootNodeComposed: + ([@bs.as {json|{ "composed": true }|json}] _) => Dom.node = + "getRootNode"; + [@bs.send.pipe: T.t] external hasChildNodes: bool; + [@bs.send.pipe: T.t] + external insertBefore: + (Dom.node_like('a), Dom.node_like('b)) => Dom.node_like('a); + /* (temporarily?) removed to reduce codegen size. This variant is just for convenience, `appendChild` can be used in place of passing `null` to `insertBefore` + external insertBefore : Dom.node_like 'a => Js.null (Dom.node_like 'b) => Dom.node_like 'a = "" [@@bs.send.pipe: T.t]; + let insertBefore : Dom.node_like 'a => option (Dom.node_like 'b) => T.t => Dom.node_like 'a = fun node reference self => insertBefore node (Js.Null.fromOption reference) self; + */ + [@bs.send.pipe: T.t] external isDefaultNamespace: string => bool; + [@bs.send.pipe: T.t] external isEqualNode: Dom.node_like('a) => bool; + [@bs.send.pipe: T.t] external isSameNode: Dom.node_like('a) => bool; + [@bs.send.pipe: T.t] [@bs.return nullable] + external lookupNamespaceURI: string => option(string); + [@bs.send.pipe: T.t] [@bs.return nullable] + external lookupDefaultNamespaceURI: + ([@bs.as {json|null|json}] _) => option(string) = + "lookupNamespaceURI"; + [@bs.send.pipe: T.t] external lookupPrefix: string = "lookupPrefix"; + [@bs.send.pipe: T.t] external normalize: unit; + [@bs.send.pipe: T.t] + external removeChild: Dom.node_like('a) => Dom.node_like('a); + + /** @since 0.19.0 */ + [@bs.send.pipe: T.t] + external replaceChild: + (Dom.node_like('a), Dom.node_like('b)) => Dom.node_like('b); +}; + +type t = Dom.node; + +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__NodeFilter.re b/packages/webapi/Webapi__Dom__NodeFilter.re new file mode 100644 index 000000000..d25bc0d2d --- /dev/null +++ b/packages/webapi/Webapi__Dom__NodeFilter.re @@ -0,0 +1,3 @@ +type t = Dom.nodeFilter; + +let make = f => {Dom.acceptNode: f}; diff --git a/packages/webapi/Webapi__Dom__NodeIterator.re b/packages/webapi/Webapi__Dom__NodeIterator.re new file mode 100644 index 000000000..b1dbc46ec --- /dev/null +++ b/packages/webapi/Webapi__Dom__NodeIterator.re @@ -0,0 +1,12 @@ +type t = Dom.nodeIterator; + +[@bs.get] external root: t => Dom.node; +[@bs.get] external referenceNode: t => Dom.node; +[@bs.get] external pointerBeforeReferenceNode: t => bool; +[@bs.get] external whatToShow: t => Webapi__Dom__Types.WhatToShow.t; +[@bs.get] [@bs.return nullable] external filter: t => option(Dom.nodeFilter); + +[@bs.send.pipe: t] [@bs.return nullable] external nextNode: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] +external previousNode: option(Dom.node); +[@bs.send.pipe: t] external detach: unit; diff --git a/packages/webapi/Webapi__Dom__NodeList.re b/packages/webapi/Webapi__Dom__NodeList.re new file mode 100644 index 000000000..0e116e456 --- /dev/null +++ b/packages/webapi/Webapi__Dom__NodeList.re @@ -0,0 +1,11 @@ +type t = Dom.nodeList; + +[@bs.val] +external toArray: t => array(Dom.node) = "Array.prototype.slice.call"; + +[@bs.send.pipe: t] external forEach: ((Dom.node, int) => unit) => unit; + +[@bs.get] external length: t => int; + +[@bs.send.pipe: t] [@bs.return nullable] +external item: int => option(Dom.node); diff --git a/packages/webapi/Webapi__Dom__NonDocumentTypeChildNode.re b/packages/webapi/Webapi__Dom__NonDocumentTypeChildNode.re new file mode 100644 index 000000000..4ebc74c77 --- /dev/null +++ b/packages/webapi/Webapi__Dom__NonDocumentTypeChildNode.re @@ -0,0 +1,7 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.get] [@bs.return nullable] + external previousElementSibling: T.t => option(Dom.element); + [@bs.get] [@bs.return nullable] + external nextElementSibling: T.t => option(Dom.element); +}; diff --git a/packages/webapi/Webapi__Dom__NonElementParentNode.re b/packages/webapi/Webapi__Dom__NonElementParentNode.re new file mode 100644 index 000000000..01065763e --- /dev/null +++ b/packages/webapi/Webapi__Dom__NonElementParentNode.re @@ -0,0 +1,5 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.send.pipe: T.t] [@bs.return nullable] + external getElementById: string => option(Dom.element); +}; diff --git a/packages/webapi/Webapi__Dom__PageTransitionEvent.re b/packages/webapi/Webapi__Dom__PageTransitionEvent.re new file mode 100644 index 000000000..1f8045ee9 --- /dev/null +++ b/packages/webapi/Webapi__Dom__PageTransitionEvent.re @@ -0,0 +1,11 @@ +type t = Dom.pageTransitionEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "PageTransitionEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "PageTransitionEvent"; + +[@bs.get] external persisted: t => bool; diff --git a/packages/webapi/Webapi__Dom__ParentNode.re b/packages/webapi/Webapi__Dom__ParentNode.re new file mode 100644 index 000000000..eadaec5c3 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ParentNode.re @@ -0,0 +1,12 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.get] external children: T.t => Dom.htmlCollection; + [@bs.get] [@bs.return nullable] + external firstElementChild: T.t => option(Dom.element); + [@bs.get] [@bs.return nullable] + external lastElementChild: T.t => option(Dom.element); + [@bs.get] external childElementCount: T.t => int; + [@bs.send.pipe: T.t] [@bs.return nullable] + external querySelector: string => option(Dom.element); + [@bs.send.pipe: T.t] external querySelectorAll: string => Dom.nodeList; +}; diff --git a/packages/webapi/Webapi__Dom__PointerEvent.re b/packages/webapi/Webapi__Dom__PointerEvent.re new file mode 100644 index 000000000..8948be182 --- /dev/null +++ b/packages/webapi/Webapi__Dom__PointerEvent.re @@ -0,0 +1,27 @@ +type t = Dom.pointerEvent; +type pointerId = Dom.eventPointerId; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__MouseEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "PointerEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "PointerEvent"; + +[@bs.get] external pointerId: t => pointerId; +[@bs.get] external width: t => int; +[@bs.get] external height: t => int; +[@bs.get] external pressure: t => float; +[@bs.get] external tiltX: t => int; +[@bs.get] external tiltY: t => int; +[@bs.get] external pointerType: t => string /* pointerType enum */; +let pointerType: t => Webapi__Dom__Types.pointerType = + self => Webapi__Dom__Types.decodePointerType(pointerType(self)); +[@bs.get] external isPrimary: t => bool; diff --git a/packages/webapi/Webapi__Dom__PopStateEvent.re b/packages/webapi/Webapi__Dom__PopStateEvent.re new file mode 100644 index 000000000..217671871 --- /dev/null +++ b/packages/webapi/Webapi__Dom__PopStateEvent.re @@ -0,0 +1,11 @@ +type t = Dom.popStateEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "PopStateEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "PopStateEvent"; + +[@bs.get] external state: t => Js.t({..}); diff --git a/packages/webapi/Webapi__Dom__ProcessingInstruction.re b/packages/webapi/Webapi__Dom__ProcessingInstruction.re new file mode 100644 index 000000000..43392a7c2 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ProcessingInstruction.re @@ -0,0 +1,16 @@ +type t = Dom.processingInstruction; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); + +[@bs.get] external target: t => string; diff --git a/packages/webapi/Webapi__Dom__ProgressEvent.re b/packages/webapi/Webapi__Dom__ProgressEvent.re new file mode 100644 index 000000000..817d30c71 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ProgressEvent.re @@ -0,0 +1,13 @@ +type t = Dom.progressEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "ProgressEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "ProgressEvent"; + +[@bs.get] external lengthComputable: t => bool; +[@bs.get] external loaded: t => int; +[@bs.get] external total: t => int; diff --git a/packages/webapi/Webapi__Dom__Range.re b/packages/webapi/Webapi__Dom__Range.re new file mode 100644 index 000000000..772ad532e --- /dev/null +++ b/packages/webapi/Webapi__Dom__Range.re @@ -0,0 +1,56 @@ +type t = Dom.range; + +[@bs.new] external make: unit => t = "Range"; /* experimental */ + +[@bs.get] external collapsed: t => bool; +[@bs.get] external commonAncestorContainer: t => Dom.node; +[@bs.get] external endContainer: t => Dom.node; +[@bs.get] external endOffset: t => int; +[@bs.get] external startContainer: t => Dom.node; +[@bs.get] external startOffset: t => int; + +[@bs.send.pipe: t] external setStart: (Dom.node_like('a), int) => unit; +[@bs.send.pipe: t] external setEnd: (Dom.node_like('a), int) => unit; +[@bs.send.pipe: t] external setStartBefore: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external setStartAfter: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external setEndBefore: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external setEndAfter: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external selectNode: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external selectNodeContents: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external collapse: unit; +[@bs.send.pipe: t] +external collapseToStart: ([@bs.as {json|true|json}] _) => unit = "collapse"; +[@bs.send.pipe: t] external cloneContents: Dom.documentFragment; +[@bs.send.pipe: t] external deleteContents: unit; +[@bs.send.pipe: t] external extractContents: Dom.documentFragment; +[@bs.send.pipe: t] external insertNode: Dom.node_like('a) => unit; +[@bs.send.pipe: t] external surroundContents: Dom.node_like('a) => unit; +[@bs.send.pipe: t] +external compareBoundaryPoints: + (int /* compareHow enum */, t) => int /* compareResult enum */; +let compareBoundaryPoint: + (Webapi__Dom__Types.compareHow, t, t) => Webapi__Dom__Types.compareResult = + (how, range, self) => + Webapi__Dom__Types.decodeCompareResult( + compareBoundaryPoints( + Webapi__Dom__Types.encodeCompareHow(how), + range, + self, + ), + ); +[@bs.send.pipe: t] external cloneRange: t; +[@bs.send.pipe: t] external detach: unit; +[@bs.send.pipe: t] external toString: string; +[@bs.send.pipe: t] +external comparePoint: + (Dom.node_like('a), int) => int /* compareRsult enum */; +let comparePoint: + (Dom.node_like('a), int, t) => Webapi__Dom__Types.compareResult = + (node, offset, self) => + Webapi__Dom__Types.decodeCompareResult(comparePoint(node, offset, self)); +[@bs.send.pipe: t] +external createContextualFragment: string => Dom.documentFragment; /* experimental, but widely supported */ +[@bs.send.pipe: t] external getBoundingClientRect: Dom.domRect; /* experimental, but widely supported */ +[@bs.send.pipe: t] external getClientRects: array(Dom.domRect); /* experimental, but widely supported */ +[@bs.send.pipe: t] external intersectsNode: Dom.node_like('a) => bool; +[@bs.send.pipe: t] external isPointInRange: (Dom.node_like('a), int) => bool; diff --git a/packages/webapi/Webapi__Dom__RelatedEvent.re b/packages/webapi/Webapi__Dom__RelatedEvent.re new file mode 100644 index 000000000..86c3ac8f1 --- /dev/null +++ b/packages/webapi/Webapi__Dom__RelatedEvent.re @@ -0,0 +1,12 @@ +type t = Dom.relatedEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "RelatedEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "RelatedEvent"; + +[@bs.get] [@bs.return nullable] +external relatedTarget: t => option(Dom.eventTarget); diff --git a/packages/webapi/Webapi__Dom__Selection.re b/packages/webapi/Webapi__Dom__Selection.re new file mode 100644 index 000000000..c9c735a8b --- /dev/null +++ b/packages/webapi/Webapi__Dom__Selection.re @@ -0,0 +1,30 @@ +type t = Dom.selection; + +[@bs.get] [@bs.return nullable] external anchorNode: t => option(Dom.node); +[@bs.get] external anchorOffset: t => int; +[@bs.get] [@bs.return nullable] external focusNode: t => option(Dom.node); +[@bs.get] external focusOffset: t => int; +[@bs.get] external isCollapsed: t => bool; +[@bs.get] external rangeCount: t => int; + +[@bs.send.pipe: t] external getRangeAt: int => Dom.range; +[@bs.send.pipe: t] external collapse: (Dom.node_like(_), int) => unit; +[@bs.send.pipe: t] external extend: (Dom.node_like(_), int) => unit; +[@bs.send.pipe: t] external collapseToStart: unit; +[@bs.send.pipe: t] external collapseToEnd: unit; +[@bs.send.pipe: t] external selectAllChildren: Dom.node_like(_) => unit; +[@bs.send.pipe: t] +external setBaseAndExtent: + (Dom.node_like(_), int, Dom.node_like(_), int) => unit; +[@bs.send.pipe: t] external addRange: Dom.range => unit; +[@bs.send.pipe: t] external removeRange: Dom.range => unit; +[@bs.send.pipe: t] external removeAllRanges: unit; +[@bs.send.pipe: t] external deleteFromDocument: unit; +[@bs.send.pipe: t] external toString: string; +[@bs.send.pipe: t] +external containsNode: + (Dom.node_like(_), [@bs.as {json|false|json}] _) => bool; +[@bs.send.pipe: t] +external containsNodePartly: + (Dom.node_like(_), [@bs.as {json|true|json}] _) => bool = + "containsNode"; diff --git a/packages/webapi/Webapi__Dom__ShadowRoot.re b/packages/webapi/Webapi__Dom__ShadowRoot.re new file mode 100644 index 000000000..1d8ace9a5 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ShadowRoot.re @@ -0,0 +1,22 @@ +type t = Dom.shadowRoot; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonElementParentNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__DocumentOrShadowRoot.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ParentNode.Impl({ + type nonrec t = t; +}); + +[@bs.get] external shadowRootMode: t => string; +let shadowRootMode: t => Webapi__Dom__Types.shadowRootMode = + self => Webapi__Dom__Types.decodeShadowRootMode(shadowRootMode(self)); +[@bs.get] external host: t => Dom.element; diff --git a/packages/webapi/Webapi__Dom__Slotable.re b/packages/webapi/Webapi__Dom__Slotable.re new file mode 100644 index 000000000..b2c5b78ce --- /dev/null +++ b/packages/webapi/Webapi__Dom__Slotable.re @@ -0,0 +1,5 @@ +/* Mixin */ +module Impl = (T: {type t;}) => { + [@bs.get] [@bs.return nullable] + external assignedSlot: T.t => option(Dom.htmlSlotElement); +}; diff --git a/packages/webapi/Webapi__Dom__StorageEvent.re b/packages/webapi/Webapi__Dom__StorageEvent.re new file mode 100644 index 000000000..884d360ed --- /dev/null +++ b/packages/webapi/Webapi__Dom__StorageEvent.re @@ -0,0 +1,15 @@ +type t = Dom.storageEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "StorageEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "StorageEvent"; + +[@bs.get] external key: t => string; +[@bs.get] external newValue: t => Js.Nullable.t(string); +[@bs.get] external oldValue: t => Js.Nullable.t(string); +[@bs.get] external storageArea: t => Dom.Storage.t; +[@bs.get] external url: t => string; diff --git a/packages/webapi/Webapi__Dom__SvgZoomEvent.re b/packages/webapi/Webapi__Dom__SvgZoomEvent.re new file mode 100644 index 000000000..a7be89f80 --- /dev/null +++ b/packages/webapi/Webapi__Dom__SvgZoomEvent.re @@ -0,0 +1,18 @@ +type t = Dom.svgZoomEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "SVGZoomEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "SVGZoomEvent"; + +[@bs.get] external zoomRectScreen: t => Dom.svgRect; +[@bs.get] external previousScale: t => float; +[@bs.get] external previousTranslate: t => Dom.svgPoint; +[@bs.get] external newScale: t => float; +[@bs.get] external newTranslate: t => Dom.svgPoint; diff --git a/packages/webapi/Webapi__Dom__Text.re b/packages/webapi/Webapi__Dom__Text.re new file mode 100644 index 000000000..b3cb79bfe --- /dev/null +++ b/packages/webapi/Webapi__Dom__Text.re @@ -0,0 +1,34 @@ +let ofNode = (node: Dom.node): option('a) => + Webapi__Dom__Node.nodeType(node) == Webapi__Dom__Types.Text + ? Some(Obj.magic(node)) : None; + +module Impl = (T: {type t;}) => { + let ofNode: Dom.node => option(T.t) = ofNode; + + [@bs.send.pipe: T.t] external splitText: (~offset: int, unit) => Dom.text; + [@bs.get] external wholeText: T.t => string; +}; + +type t = Dom.text; + +include Webapi__Dom__Node.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__CharacterData.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__NonDocumentTypeChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__ChildNode.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__Slotable.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__Dom__TimeEvent.re b/packages/webapi/Webapi__Dom__TimeEvent.re new file mode 100644 index 000000000..112450269 --- /dev/null +++ b/packages/webapi/Webapi__Dom__TimeEvent.re @@ -0,0 +1,11 @@ +type t = Dom.timeEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "TimeEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "TimeEvent"; + +[@bs.get] external detail: t => int; +[@bs.get] external view: t => Dom.window; /* technically returns a `WindowProxy` */ diff --git a/packages/webapi/Webapi__Dom__TouchEvent.re b/packages/webapi/Webapi__Dom__TouchEvent.re new file mode 100644 index 000000000..cd70f58e7 --- /dev/null +++ b/packages/webapi/Webapi__Dom__TouchEvent.re @@ -0,0 +1,26 @@ +type touchList; /* TODO, Touch Events */ + +module Impl = (T: {type t;}) => { + [@bs.get] external altKey: T.t => bool; + [@bs.get] external changedTouches: T.t => touchList; + [@bs.get] external ctrlKey: T.t => bool; + [@bs.get] external metaKey: T.t => bool; + [@bs.get] external shiftKey: T.t => bool; + [@bs.get] external targetTouches: T.t => touchList; + [@bs.get] external touches: T.t => touchList; +}; + +type t = Dom.touchEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "TouchEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "TouchEvent"; diff --git a/packages/webapi/Webapi__Dom__TrackEvent.re b/packages/webapi/Webapi__Dom__TrackEvent.re new file mode 100644 index 000000000..516d990b9 --- /dev/null +++ b/packages/webapi/Webapi__Dom__TrackEvent.re @@ -0,0 +1,11 @@ +type t = Dom.trackEvent; +type track; /* TODO: VideoTrack or AudioTrack or TextTrack */ + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "TrackEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "TrackEvent"; + +[@bs.get] external track: t => track; diff --git a/packages/webapi/Webapi__Dom__TransitionEvent.re b/packages/webapi/Webapi__Dom__TransitionEvent.re new file mode 100644 index 000000000..91fdd24a7 --- /dev/null +++ b/packages/webapi/Webapi__Dom__TransitionEvent.re @@ -0,0 +1,13 @@ +type t = Dom.transitionEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "TransitionEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "TransitionEvent"; + +[@bs.get] external propertyName: t => string; +[@bs.get] external elapsedTime: t => float; +[@bs.get] external pseudoElement: t => string /* enum-ish */; diff --git a/packages/webapi/Webapi__Dom__TreeWalker.re b/packages/webapi/Webapi__Dom__TreeWalker.re new file mode 100644 index 000000000..99beb98bb --- /dev/null +++ b/packages/webapi/Webapi__Dom__TreeWalker.re @@ -0,0 +1,20 @@ +type t = Dom.treeWalker; + +[@bs.get] external root: t => Dom.node; +[@bs.get] external whatToShow: t => Webapi__Dom__Types.WhatToShow.t; +[@bs.get] [@bs.return nullable] external filter: t => option(Dom.nodeFilter); +[@bs.get] external currentNode: t => Dom.node; +[@bs.set] external setCurrentNode: (t, Dom.node) => unit; + +[@bs.send.pipe: t] [@bs.return nullable] +external parentNode: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] +external firstChild: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] external lastChild: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] +external previousSibling: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] +external nextSibling: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] +external previousNode: option(Dom.node); +[@bs.send.pipe: t] [@bs.return nullable] external nextNode: option(Dom.node); diff --git a/packages/webapi/Webapi__Dom__Types.re b/packages/webapi/Webapi__Dom__Types.re new file mode 100644 index 000000000..0128b9509 --- /dev/null +++ b/packages/webapi/Webapi__Dom__Types.re @@ -0,0 +1,309 @@ +/*** enums, bitmaks and constants ***/ +type compareHow = + | StartToStart + | StartToEnd + | EndToEnd + | EndToStart; + +let encodeCompareHow = + fun /* internal */ + | StartToStart => 0 + | StartToEnd => 1 + | EndToEnd => 2 + | EndToStart => 3; + +type compareResult = + | Before + | Equal + | After + | Unknown; + +let decodeCompareResult = + fun /* internal */ + | (-1) => Before + | 0 => Equal + | 1 => After + | _ => Unknown; + +type compatMode = + | BackCompat + | CSS1Compat + | Unknown; + +let decodeCompatMode = + fun /* internal */ + | "BackCompat" => BackCompat + | "CSS1Compat" => CSS1Compat + | _ => Unknown; + +type contentEditable = + | True + | False + | Inherit + | Unknown; + +let encodeContentEditable = + fun /* internal */ + | True => "true" + | False => "false" + | Inherit => "inherit" + | Unknown => ""; + +let decodeContentEditable = + fun /* internal */ + | "true" => True + | "false" => False + | "inherit" => Inherit + | _ => Unknown; + +type deltaMode = + | Pixel + | Line + | Page; + +let decodeDeltaMode = + fun /* internal */ + | 0 => Pixel + | 1 => Line + | 2 => Page + | _ => raise(Invalid_argument("invalid deltaMode")); + +type designMode = + | On + | Off + | Unknown; + +let encodeDesignMode = + fun /* internal */ + | On => "on" + | Off => "off" + | Unknown => ""; + +let decodeDesignMode = + fun /* internal */ + | "on" => On + | "off" => Off + | _ => Unknown; + +type dir = + | Ltr + | Rtl + | Unknown; + +let encodeDir = + fun /* internal */ + | Ltr => "ltr" + | Rtl => "rtl" + | Unknown => ""; + +let decodeDir = + fun /* internal */ + | "ltr" => Ltr + | "rtl" => Rtl + | _ => Unknown; + +/** @since 0.17.1 */ +module EventPhase = { + type t = + | None + | CapturingPhase + | AtTarget + | BubblingPhase + | Unknown; + + let decode = + fun /* internal */ + | 1 => CapturingPhase + | 2 => AtTarget + | 3 => BubblingPhase + | 0 => None + | _ => Unknown; +}; + +[@deprecated "Use EventPhase.t"] +type eventPhase = + EventPhase.t = | None | CapturingPhase | AtTarget | BubblingPhase | Unknown; + +type filterAction = + | Accept + | Reject + | Skip; + +let encodeFilterAction = + fun + | Accept => 1 + | Reject => 2 + | Skip => 3; + +type insertPosition = + | BeforeBegin + | AfterBegin + | BeforeEnd + | AfterEnd; + +let encodeInsertPosition = + fun /* internal */ + | BeforeBegin => "beforebegin" + | AfterBegin => "afterbegin" + | BeforeEnd => "beforeend" + | AfterEnd => "afterend"; + +type modifierKey = + | Alt + | AltGraph + | CapsLock + | Control + | Fn + | FnLock + | Hyper + | Meta + | NumLock + | ScrollLock + | Shift + | Super + | Symbol + | SymbolLock; + +let encodeModifierKey = + fun /* internal */ + | Alt => "Alt" + | AltGraph => "AltGraph" + | CapsLock => "CapsLock" + | Control => "Control" + | Fn => "Fn" + | FnLock => "FnLock" + | Hyper => "Hyper" + | Meta => "Meta" + | NumLock => "NumLock" + | ScrollLock => "ScrollLock" + | Shift => "Shift" + | Super => "Super" + | Symbol => "Symbol" + | SymbolLock => "SymbolLock"; + +type nodeType = + | Element + | Attribute /* deprecated */ + | Text + | CDATASection /* deprecated */ + | EntityReference /* deprecated */ + | Entity /* deprecated */ + | ProcessingInstruction + | Comment + | Document + | DocumentType + | DocumentFragment + | Notation /* deprecated */ + | Unknown; + +let decodeNodeType = + fun /* internal */ + | 1 => Element + | 2 => Attribute + | 3 => Text + | 4 => CDATASection + | 5 => EntityReference + | 6 => Entity + | 7 => ProcessingInstruction + | 8 => Comment + | 9 => Document + | 10 => DocumentType + | 11 => DocumentFragment + | 12 => Notation + | _ => Unknown; + +type pointerType = + | Mouse + | Pen + | Touch + | Unknown; + +let decodePointerType = + fun /* itnernal */ + | "mouse" => Mouse + | "pen" => Pen + | "touch|" => Touch + | _ => Unknown; + +type readyState = + | Loading + | Interactive + | Complete + | Unknown; + +let decodeReadyState = + fun /* internal */ + | "loading" => Loading + | "interactive" => Interactive + | "complete" => Complete + | _ => Unknown; + +type shadowRootMode = + | Open + | Closed; + +let decodeShadowRootMode = + fun /* internal */ + | "open" => Open + | "closed" => Closed + | _ => raise(Invalid_argument("Unknown shadowRootMode")); + +type visibilityState = + | Visible + | Hidden + | Prerender + | Unloaded + | Unknown; + +let decodeVisibilityState = + fun /* internal */ + | "visible" => Visible + | "hidden" => Hidden + | "prerender" => Prerender + | "unloaded" => Unloaded + | _ => Unknown; + +type image; + +module type WhatToShowT = { + type t; + + let _All: t; + let _Element: t; + let _Attribute: t; + let _Text: t; + let _CDATASection: t; + let _EntityReference: t; + let _Entity: t; + let _ProcessingInstruction: t; + let _Comment: t; + let _Document: t; + let _DocumentType: t; + let _DocumentFragment: t; + let _Notation: t; + + let many: list(t) => t; +}; + +module WhatToShow: WhatToShowT = { + type t = int; + + let _All = (-1); + let _Element = 1; + let _Attribute = 2; + let _Text = 4; + let _CDATASection = 8; + let _EntityReference = 16; + let _Entity = 32; + let _ProcessingInstruction = 64; + let _Comment = 128; + let _Document = 256; + let _DocumentType = 512; + let _DocumentFragment = 1024; + let _Notation = 2048; + + let rec many = + fun + | [] => 0 + | [hd, ...rest] => hd lor many(rest); +}; diff --git a/packages/webapi/Webapi__Dom__UiEvent.re b/packages/webapi/Webapi__Dom__UiEvent.re new file mode 100644 index 000000000..67b28be7b --- /dev/null +++ b/packages/webapi/Webapi__Dom__UiEvent.re @@ -0,0 +1,16 @@ +module Impl = (T: {type t;}) => { + [@bs.get] external detail: T.t => int; + [@bs.get] external view: T.t => Dom.window; /* technically returns a `WindowProxy` */ +}; + +type t = Dom.uiEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "UIEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "UIEvent"; diff --git a/packages/webapi/Webapi__Dom__ValidityState.re b/packages/webapi/Webapi__Dom__ValidityState.re new file mode 100644 index 000000000..b34826a49 --- /dev/null +++ b/packages/webapi/Webapi__Dom__ValidityState.re @@ -0,0 +1,13 @@ +type t; + +[@bs.get] external valueMissing: t => bool; +[@bs.get] external typeMismatch: t => bool; +[@bs.get] external patternMismatch: t => bool; +[@bs.get] external tooLong: t => bool; +[@bs.get] external tooShort: t => bool; +[@bs.get] external rangeUnderflow: t => bool; +[@bs.get] external rangeOverflow: t => bool; +[@bs.get] external stepMismatch: t => bool; +[@bs.get] external badInput: t => bool; +[@bs.get] external customError: t => bool; +[@bs.get] external valid: t => bool; diff --git a/packages/webapi/Webapi__Dom__WebGlContextEvent.re b/packages/webapi/Webapi__Dom__WebGlContextEvent.re new file mode 100644 index 000000000..51ef10657 --- /dev/null +++ b/packages/webapi/Webapi__Dom__WebGlContextEvent.re @@ -0,0 +1,11 @@ +type t = Dom.webGlContextEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "WebGLContextEvent"; +[@bs.new] +external makeWithOptions: (string, Js.t({..})) => t = "WebGLContextEvent"; + +[@bs.get] external statusMessage: t => string; diff --git a/packages/webapi/Webapi__Dom__WheelEvent.re b/packages/webapi/Webapi__Dom__WheelEvent.re new file mode 100644 index 000000000..395f858a2 --- /dev/null +++ b/packages/webapi/Webapi__Dom__WheelEvent.re @@ -0,0 +1,21 @@ +type t = Dom.wheelEvent; + +include Webapi__Dom__Event.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__UiEvent.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__MouseEvent.Impl({ + type nonrec t = t; +}); + +[@bs.new] external make: string => t = "WheelEvent"; +[@bs.new] external makeWithOptions: (string, Js.t({..})) => t = "WheelEvent"; + +[@bs.get] external deltaX: t => float; +[@bs.get] external deltaY: t => float; +[@bs.get] external deltaZ: t => float; +[@bs.get] external deltaMode: t => int; +let deltaMode: t => Webapi__Dom__Types.deltaMode = + self => Webapi__Dom__Types.decodeDeltaMode(deltaMode(self)); diff --git a/packages/webapi/Webapi__Dom__Window.re b/packages/webapi/Webapi__Dom__Window.re new file mode 100644 index 000000000..607a172aa --- /dev/null +++ b/packages/webapi/Webapi__Dom__Window.re @@ -0,0 +1,135 @@ +type console; /* Console API, should maybe be defined in Js stdlib */ +type crypto; /* Web Cryptography API */ +type frameList; /* array-like, WindowProxy? */ +type idleDeadline; /* Cooperative Scheduling of Background Tasks */ +type locationbar; /* "bar object" */ +type menubar; /* "bar object" */ +type navigator; +type personalbar; /* "bar object" */ +type screen; +type scrollbars; /* "bar object" */ +type speechSynthesis; +type statusbar; /* "bar object" */ +type toolbar; /* "bar object" */ +type mediaQueryList; /* CSSOM View module */ +type transferable; + +type idleCallbackId; /* used by requestIdleCallback and cancelIdleCallback */ + +module Impl = (T: {type t;}) => { + type t_window = T.t; + + /* A lot of this isn't really "dom", but rather global exports */ + + [@bs.get] external console: t_window => console; + [@bs.get] external crypto: t_window => crypto; + [@bs.get] external document: t_window => Dom.document; + [@bs.get] [@bs.return nullable] + external frameElement: t_window => option(Dom.element); /* experimental? */ + [@bs.get] external frames: t_window => frameList; + [@bs.get] external fullScreen: t_window => bool; + [@bs.get] external history: t_window => Dom.history; + [@bs.get] external innerWidth: t_window => int; + [@bs.get] external innerHeight: t_window => int; + [@bs.get] external isSecureContext: t_window => bool; + [@bs.get] external length: t_window => int; + [@bs.get] external location: t_window => Dom.location; + [@bs.set] external setLocation: (t_window, string) => unit = "location"; + [@bs.get] external locationbar: t_window => locationbar; + /* localStorage: accessed directly via Dom.Storage.localStorage */ + [@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] [@bs.return nullable] + external opener: t_window => option(Dom.window); + [@bs.get] external outerWidth: t_window => int; + [@bs.get] external outerHeight: t_window => int; + [@bs.get] external pageXOffset: t_window => float; /* alias for scrollX */ + [@bs.get] external pageYOffset: t_window => float; /* alias for scrollY */ + [@bs.get] external parent: t_window => Dom.window; + [@bs.get] external performance: t_window => Webapi__Performance.t; + [@bs.get] external personalbar: t_window => personalbar; + [@bs.get] external screen: t_window => screen; + [@bs.get] external screenX: t_window => int; + [@bs.get] external screenY: t_window => int; + [@bs.get] external scrollbars: t_window => scrollbars; + [@bs.get] external scrollX: t_window => float; + [@bs.get] external scrollY: t_window => float; + [@bs.get] external self: t_window => Dom.window; /* alias for window, but apparently convenient because self (stand-alone) resolves to WorkerGlobalScope in a web worker. Probably poitnless here though */ + /* sessionStorage: accessed directly via Dom.Storage.sessionStorage */ + [@bs.get] external speechSynthesis: t_window => speechSynthesis; /* experimental */ + [@bs.get] external status: t_window => string; + [@bs.set] external setStatus: (t_window, string) => unit = "status"; + [@bs.get] external statusbar: t_window => statusbar; + [@bs.get] external toolbar: t_window => toolbar; + [@bs.get] external top: t_window => Dom.window; + [@bs.get] external window: t_window => t_window; /* This is pointless I think, it's just here because window is the implicit global scope, and it's needed to be able to get a reference to it */ + + [@bs.send.pipe: t_window] external alert: string => unit; + [@bs.send.pipe: t_window] external blur: unit; + [@bs.send.pipe: t_window] + external cancelIdleCallback: idleCallbackId => unit; /* experimental, Cooperative Scheduling of Background Tasks */ + [@bs.send.pipe: t_window] external close: unit; + [@bs.send.pipe: t_window] external confirm: string => bool; + [@bs.send.pipe: t_window] external focus: unit; + [@bs.send.pipe: t_window] + external getComputedStyle: Dom.element => Dom.cssStyleDeclaration; + [@bs.send.pipe: t_window] + external getComputedStyleWithPseudoElement: + (Dom.element, string) => Dom.cssStyleDeclaration = + "getComputedStyle"; + [@bs.send.pipe: t_window] external getSelection: Dom.selection; + [@bs.send.pipe: t_window] external matchMedia: string => mediaQueryList; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external moveBy: (int, int) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external moveTo: (int, int) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] [@bs.return nullable] + external open_: + (~url: string, ~name: string, ~features: string=?) => option(Dom.window) = + "open"; /* yes, features is a stringly typed list of key value pairs, sigh */ + [@bs.send.pipe: t_window] external postMessage: ('a, string) => unit; /* experimental-ish?, Web Messaging */ + [@bs.send.pipe: t_window] + external postMessageWithTransfers: ('a, string, array(transferable)) => unit = + "postMessage"; /* experimental-ish?, Web Messaging */ + [@bs.send.pipe: t_window] external print: unit; + [@bs.send.pipe: t_window] external prompt: string => string; + [@bs.send.pipe: t_window] + external promptWithDefault: (string, string) => string = "prompt"; + /* requestAnimationFrame: accessed directly via Webapi */ + [@bs.send.pipe: t_window] + external requestIdleCallback: (idleDeadline => unit) => idleCallbackId; /* experimental, Cooperative Scheduling of Background Tasks */ + [@bs.send.pipe: t_window] + external requestIdleCallbackWithOptions: + (idleDeadline => unit, {. "timeout": int}) => idleCallbackId = + "requestIdleCallback"; /* experimental, Cooperative Scheduling of Background Tasks */ + [@bs.send.pipe: t_window] external resizeBy: (int, int) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external resizeTo: (int, int) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external scroll: (float, float) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external scrollBy: (float, float) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external scrollTo: (float, float) => unit; /* experimental, CSSOM View module */ + [@bs.send.pipe: t_window] external stop: unit; + + [@bs.send.pipe: t_window] + external addPopStateEventListener: + ([@bs.as "popstate"] _, Dom.popStateEvent => unit) => unit = + "addEventListener"; + [@bs.send.pipe: t_window] + external removePopStateEventListener: + ([@bs.as "popstate"] _, Dom.popStateEvent => unit) => unit = + "removeEventListener"; + + [@bs.set] external setOnLoad: (t_window, unit => unit) => unit = "onload"; /* use addEventListener instead? */ +}; + +type t = Dom.window; + +/* include WindowOrWorkerGlobalScope? not really "dom" though */ +include Webapi__Dom__EventTarget.Impl({ + type nonrec t = t; +}); +include Webapi__Dom__GlobalEventHandlers.Impl({ + type nonrec t = t; +}); +include Impl({ + type nonrec t = t; +}); diff --git a/packages/webapi/Webapi__File.re b/packages/webapi/Webapi__File.re new file mode 100644 index 000000000..d90917f4a --- /dev/null +++ b/packages/webapi/Webapi__File.re @@ -0,0 +1,17 @@ +type t = Fetch.file; + +[@text "{1 Blob superclass}"]; + +include Webapi__Blob.Impl({ + type nonrec t = t; +}); + +[@text "{1 File class}"]; + +/** @since 0.18.0 */ [@bs.get] external lastModified: t => float; + +// [@bs.new] external make: ... = "File"; + +[@bs.get] external name: t => string; + +[@bs.get] external preview: t => string; diff --git a/packages/webapi/Webapi__Performance.re b/packages/webapi/Webapi__Performance.re new file mode 100644 index 000000000..b49aebc5e --- /dev/null +++ b/packages/webapi/Webapi__Performance.re @@ -0,0 +1,3 @@ +type t; + +[@bs.send] external now: t => float; diff --git a/packages/webapi/Webapi__ReadableStream.re b/packages/webapi/Webapi__ReadableStream.re new file mode 100644 index 000000000..926f41088 --- /dev/null +++ b/packages/webapi/Webapi__ReadableStream.re @@ -0,0 +1,34 @@ +module type Reader = { + type t; + type closed; + + /* [@bs.send] external closed: t => Js.Promise.t(closed); */ + /* [@bs.send] external cancel: t => Js.Promise.t(unit); */ + /* [@bs.send.pipe: t] + external cancelWith: string => Js.Promise.t(string) = "cancel"; */ + [@bs.send] external releaseLock: t => unit; +}; + +module rec DefaultReader: { + include Reader; + /* [@bs.send] + external read: t => Js.Promise.t(Fetch__Iterator.Next.t(string)); */ +} = DefaultReader; + +module rec BYOBReader: { + include Reader; + // [@bs.send.pipe: t] external read: view => Js.Promise.t(Fetch__Iterator.Next.t(string)) = "read"; +} = BYOBReader; + +type t = Fetch.readableStream; + +[@bs.get] external locked: t => bool; +/* [@bs.send] external cancel: t => Js.Promise.t(unit); */ +/* [@bs.send.pipe: t] + external cancelWith: string => Js.Promise.t(string) = "cancel"; */ +[@bs.send] external getReader: t => DefaultReader.t; +[@bs.send] +external getReaderBYOB: + (t, [@bs.as {json|{"mode": "byob"}|json}] _) => BYOBReader.t = + "getReader"; +[@bs.send] external tee: t => (t, t); diff --git a/packages/webapi/Webapi__ResizeObserver.re b/packages/webapi/Webapi__ResizeObserver.re new file mode 100644 index 000000000..71d920a55 --- /dev/null +++ b/packages/webapi/Webapi__ResizeObserver.re @@ -0,0 +1,13 @@ +module ResizeObserverEntry = Webapi__ResizeObserver__ResizeObserverEntry; + +type t; + +[@bs.new] +external make: (array(ResizeObserverEntry.t) => unit) => t = "ResizeObserver"; +[@bs.new] +external makeWithObserver: ((array(ResizeObserverEntry.t), t) => unit) => t = + "ResizeObserver"; + +[@bs.send] external disconnect: t => unit; +[@bs.send] external observe: (t, Dom.element) => unit; +[@bs.send] external unobserve: (t, Dom.element) => unit; diff --git a/packages/webapi/Webapi__ResizeObserver__ResizeObserverEntry.re b/packages/webapi/Webapi__ResizeObserver__ResizeObserverEntry.re new file mode 100644 index 000000000..d28f73e7c --- /dev/null +++ b/packages/webapi/Webapi__ResizeObserver__ResizeObserverEntry.re @@ -0,0 +1,4 @@ +type t; + +[@bs.get] external contentRect: t => Dom.domRect; +[@bs.get] external target: t => Dom.element; diff --git a/packages/webapi/Webapi__Url.re b/packages/webapi/Webapi__Url.re new file mode 100644 index 000000000..e7784704e --- /dev/null +++ b/packages/webapi/Webapi__Url.re @@ -0,0 +1,61 @@ +module URLSearchParams = { + type t; + + [@bs.new] external make: string => t = "URLSearchParams"; + [@bs.new] external makeWithDict: Js.Dict.t(string) => t = "URLSearchParams"; + [@bs.new] + external makeWithArray: array((string, string)) => t = "URLSearchParams"; + [@bs.send.pipe: t] external append: (string, string) => unit; + [@bs.send.pipe: t] external delete: string => unit; + [@bs.send.pipe: t] external entries: Js.Array.array_like((string, string)); + [@bs.send.pipe: t] + external forEach: ([@bs.uncurry] ((string, string) => unit)) => unit; + [@bs.return nullable] [@bs.send.pipe: t] + external get: string => option(string); + [@bs.send.pipe: t] external getAll: string => array(string); + [@bs.send.pipe: t] external has: string => bool; + [@bs.send.pipe: t] external keys: Js.Array.array_like(string); + [@bs.send.pipe: t] external set: (string, string) => unit; + [@bs.send.pipe: t] external sort: unit; + [@bs.send.pipe: t] external toString: string; + [@bs.send.pipe: t] external values: Js.Array.array_like(string); +}; + +type t; + +[@bs.new] external make: string => t = "URL"; + +/** Deprecated, use [makeWith] instead. */ +[@deprecated "Use [makeWith] instead."] [@bs.new] +external makeWithBase: (string, string) => t = "URL"; + +/** @since 0.19.0 */ +[@bs.new] +external makeWith: (string, ~base: string) => t = "URL"; + +[@bs.get] external hash: t => string; +[@bs.set] external setHash: (t, string) => unit = "hash"; +[@bs.get] external host: t => string; +[@bs.set] external setHost: (t, string) => unit = "host"; +[@bs.get] external hostname: t => string; +[@bs.set] external setHostname: (t, string) => unit = "hostname"; +[@bs.get] external href: t => string; +[@bs.set] external setHref: (t, string) => unit = "href"; +[@bs.get] external origin: t => string; +[@bs.get] external password: t => string; +[@bs.set] external setPassword: (t, string) => unit = "password"; +[@bs.get] external pathname: t => string; +[@bs.set] external setPathname: (t, string) => unit = "pathname"; +[@bs.get] external port: t => string; +[@bs.set] external setPort: (t, string) => unit = "port"; +[@bs.get] external protocol: t => string; +[@bs.set] external setProtocol: (t, string) => unit = "protocol"; +[@bs.get] external search: t => string; +[@bs.set] external setSearch: (t, string) => unit = "search"; +[@bs.get] external searchParams: t => URLSearchParams.t; +[@bs.get] external username: t => string; +[@bs.set] external setUsername: (t, string) => unit = "username"; +[@bs.get] external toJson: t => string; + +[@bs.val] [@bs.scope "URL"] external createObjectURL: Webapi__File.t => string; +[@bs.val] [@bs.scope "URL"] external revokeObjectURL: string => unit; diff --git a/packages/webapi/dom.ml b/packages/webapi/dom.ml new file mode 100644 index 000000000..a8ee4425e --- /dev/null +++ b/packages/webapi/dom.ml @@ -0,0 +1,339 @@ +(* copied from melange *) + +type _baseClass +type animation (* Web Animations API *) + +(* TODO: Should we bother with this indirection? + (* core *) + type domString = string + type domTimestamp = float +*) + +(* css *) +type cssStyleDeclaration +type cssStyleSheet + +(* events (early) *) +type 'a eventTarget_like +type eventTarget = _baseClass eventTarget_like + +(* nodes *) +type 'a _node +type 'a node_like = 'a _node eventTarget_like +type node = _baseClass node_like +type _attr +type attr = _attr node_like +type 'a _characterData +type 'a characterData_like = 'a _characterData node_like +type characterData = _baseClass characterData_like +type _cdataSection +type cdataSection = _cdataSection characterData_like +type _comment +type comment = _comment characterData_like +type 'a _document +type 'a document_like = 'a _document node_like +type document = _baseClass document_like +type _documentFragment +type documentFragment = _documentFragment node_like +type _documentType +type documentType = _documentType node_like +type domImplementation +type 'a _element +type 'a element_like = 'a _element node_like +type element = _baseClass element_like +type htmlCollection +type htmlFormControlsCollection +type htmlOptionsCollection +type intersectionObserver +type intersectionObserverEntry +type mutationObserver +type mutationRecord +type performanceObserver +type performanceObserverEntryList +type reportingObserver +type reportingObserverOptions +type resizeObserver +type resizeObserverEntry +type namedNodeMap +type nodeList +type radioNodeList +type processingInstruction +type _shadowRoot +type shadowRoot = _shadowRoot node_like +type _text +type text = _text characterData_like + +(* geometry *) +type domRect + +(* html *) +type dataTransfer (* Drag and Drop API *) +type domStringMap +type history +type _htmlDocument +type htmlDocument = _htmlDocument document_like +type 'a _htmlElement +type 'a htmlElement_like = 'a _htmlElement element_like +type htmlElement = _baseClass htmlElement_like +type _htmlAnchorElement +type htmlAnchorElement = _htmlAnchorElement htmlElement_like +type _htmlAreaElement +type htmlAreaElement = _htmlAreaElement htmlElement_like +type _htmlAudioElement +type htmlAudioElement = _htmlAudioElement htmlElement_like +type _htmlBaseElement +type htmlBaseElement = _htmlBaseElement htmlElement_like +type _htmlBodyElement +type htmlBodyElement = _htmlBodyElement htmlElement_like +type _htmlBrElement +type htmlBrElement = _htmlBrElement htmlElement_like +type _htmlButtonElement +type htmlButtonElement = _htmlButtonElement htmlElement_like +type _htmlCanvasElement +type htmlCanvasElement = _htmlCanvasElement htmlElement_like +type _htmlDataElement +type htmlDataElement = _htmlDataElement htmlElement_like +type _htmlDataListElement +type htmlDataListElement = _htmlDataListElement htmlElement_like +type _htmlDialogElement +type htmlDialogElement = _htmlDialogElement htmlElement_like +type _htmlDivElement +type htmlDivElement = _htmlDivElement htmlElement_like +type _htmlDlistElement +type htmlDlistElement = _htmlDlistElement htmlElement_like +type _htmlEmbedElement +type htmlEmbedElement = _htmlEmbedElement htmlElement_like +type _htmlFieldSetElement +type htmlFieldSetElement = _htmlFieldSetElement htmlElement_like +type _htmlFormElement +type htmlFormElement = _htmlFormElement htmlElement_like +type _htmlHeadElement +type htmlHeadElement = _htmlHeadElement htmlElement_like +type _htmlHeadingElement +type htmlHeadingElement = _htmlHeadingElement htmlElement_like +type _htmlHrElement +type htmlHrElement = _htmlHrElement htmlElement_like +type _htmlHtmlElement +type htmlHtmlElement = _htmlHtmlElement htmlElement_like +type _htmlIframeElement +type htmlIframeElement = _htmlIframeElement htmlElement_like +type _htmlImageElement +type htmlImageElement = _htmlImageElement htmlElement_like +type _htmlInputElement +type htmlInputElement = _htmlInputElement htmlElement_like +type _htmlLabelElement +type htmlLabelElement = _htmlLabelElement htmlElement_like +type _htmlLegendElement +type htmlLegendElement = _htmlLegendElement htmlElement_like +type _htmlLiElement +type htmlLiElement = _htmlLiElement htmlElement_like +type _htmlLinkElement +type htmlLinkElement = _htmlLinkElement htmlElement_like +type _htmlMapElement +type htmlMapElement = _htmlMapElement htmlElement_like +type _htmlMediaElement +type htmlMediaElement = _htmlMediaElement htmlElement_like +type _htmlMenuElement +type htmlMenuElement = _htmlMenuElement htmlElement_like +type _htmlMetaElement +type htmlMetaElement = _htmlMetaElement htmlElement_like +type _htmlMeterElement +type htmlMeterElement = _htmlMeterElement htmlElement_like +type _htmlModElement +type htmlModElement = _htmlModElement htmlElement_like +type _htmlOListElement +type htmlOListElement = _htmlOListElement htmlElement_like +type _htmlObjectElement +type htmlObjectElement = _htmlObjectElement htmlElement_like +type _htmlOptGroupElement +type htmlOptGroupElement = _htmlOptGroupElement htmlElement_like +type _htmlOptionElement +type htmlOptionElement = _htmlOptionElement htmlElement_like +type _htmlOutputElement +type htmlOutputElement = _htmlOutputElement htmlElement_like +type _htmlParagraphElement +type htmlParagraphElement = _htmlParagraphElement htmlElement_like +type _htmlParamElement +type htmlParamElement = _htmlParamElement htmlElement_like +type _htmlPreElement +type htmlPreElement = _htmlPreElement htmlElement_like +type _htmlProgressElement +type htmlProgressElement = _htmlProgressElement htmlElement_like +type _htmlQuoteElement +type htmlQuoteElement = _htmlQuoteElement htmlElement_like +type _htmlScriptElement +type htmlScriptElement = _htmlScriptElement htmlElement_like +type _htmlSelectElement +type htmlSelectElement = _htmlSelectElement htmlElement_like +type _htmlSlotElement +type htmlSlotElement = _htmlSlotElement htmlElement_like +type _htmlSourceElement +type htmlSourceElement = _htmlSourceElement htmlElement_like +type _htmlSpanElement +type htmlSpanElement = _htmlSpanElement htmlElement_like +type _htmlStyleElement +type htmlStyleElement = _htmlStyleElement htmlElement_like +type _htmlTableCaptionElement +type htmlTableCaptionElement = _htmlTableCaptionElement htmlElement_like +type _htmlTableCellElement +type htmlTableCellElement = _htmlTableCellElement htmlElement_like +type _htmlTableColElement +type htmlTableColElement = _htmlTableColElement htmlElement_like +type _htmlTableDataCellElement +type htmlTableDataCellElement = _htmlTableDataCellElement htmlElement_like +type _htmlTableElement +type htmlTableElement = _htmlTableElement htmlElement_like +type _htmlTableHeaderCellElement +type htmlTableHeaderCellElement = _htmlTableHeaderCellElement htmlElement_like +type _htmlTableRowElement +type htmlTableRowElement = _htmlTableRowElement htmlElement_like +type _htmlTableSectionElement +type htmlTableSectionElement = _htmlTableSectionElement htmlElement_like +type _htmlTextAreaElement +type htmlTextAreaElement = _htmlTextAreaElement htmlElement_like +type _htmlTimeElement +type htmlTimeElement = _htmlTimeElement htmlElement_like +type _htmlTitleElement +type htmlTitleElement = _htmlTitleElement htmlElement_like +type _htmlTrackElement +type htmlTrackElement = _htmlTrackElement htmlElement_like +type _htmlUlistElement +type htmlUlistElement = _htmlUlistElement htmlElement_like +type _htmlUnknownElement +type htmlUnknownElement = _htmlUnknownElement htmlElement_like +type _htmlVideoElement +type htmlVideoElement = _htmlVideoElement htmlElement_like +type location +type window +type _xmlDocument +type xmlDocument = _xmlDocument document_like + +(* events *) +type 'a event_like +type event = _baseClass event_like +type 'a _uiEvent +type 'a uiEvent_like = 'a _uiEvent event_like +type uiEvent = _baseClass uiEvent_like +type _animationEvent +type animationEvent = _animationEvent event_like +type _beforeUnloadEvent +type beforeUnloadEvent = _beforeUnloadEvent event_like +type _clipboardEvent +type clipboardEvent = _clipboardEvent event_like +type _closeEvent +type closeEvent = _closeEvent event_like +type _compositionEvent +type compositionEvent = _compositionEvent uiEvent_like +type _customEvent +type customEvent = _customEvent event_like +type _dragEvent +type dragEvent = _dragEvent event_like +type _errorEvent +type errorEvent = _errorEvent event_like +type _focusEvent +type focusEvent = _focusEvent uiEvent_like +type _idbVersionChangeEvent +type idbVersionChangeEvent = _idbVersionChangeEvent event_like +type _inputEvent +type inputEvent = _inputEvent uiEvent_like +type _keyboardEvent +type keyboardEvent = _keyboardEvent uiEvent_like +type 'a _mouseEvent +type 'a mouseEvent_like = 'a _mouseEvent uiEvent_like +type mouseEvent = _baseClass mouseEvent_like +type _pageTransitionEvent +type pageTransitionEvent = _pageTransitionEvent event_like +type _pointerEvent +type pointerEvent = _pointerEvent mouseEvent_like +type _popStateEvent +type popStateEvent = _popStateEvent event_like +type _progressEvent +type progressEvent = _progressEvent event_like +type _relatedEvent +type relatedEvent = _relatedEvent event_like +type _storageEvent +type storageEvent = _storageEvent event_like +type _svgZoomEvent +type svgZoomEvent = _svgZoomEvent event_like +type _timeEvent +type timeEvent = _timeEvent event_like +type _touchEvent +type touchEvent = _touchEvent uiEvent_like +type _trackEvent +type trackEvent = _trackEvent event_like +type _transitionEvent +type transitionEvent = _transitionEvent event_like +type _webGlContextEvent +type webGlContextEvent = _webGlContextEvent event_like +type _wheelEvent +type wheelEvent = _wheelEvent uiEvent_like + +(* ranges *) +type range + +(* selection (TODO: move out of dom?) *) +type selection + +(* sets *) +type domTokenList +type domSettableTokenList + +(* traversal *) +type nodeFilter = { + acceptNode : element -> int; + (* return type should be NodeFilter.action, but that would create a cycle *) +} + +type nodeIterator +type treeWalker + +(* SVG *) +type svgRect +type svgPoint + +(* special *) +type eventPointerId + +module Storage2 = struct + type t + + external getItem : t -> string -> string option = "getItem" + [@@bs.send] [@@bs.return null_to_opt] + + external setItem : t -> string -> string -> unit = "setItem" [@@bs.send] + external removeItem : t -> string -> unit = "removeItem" [@@bs.send] + external clear : t -> unit = "clear" [@@bs.send] + + external key : t -> int -> string option = "key" + [@@bs.send] [@@bs.return null_to_opt] + + external length : t -> int = "length" [@@bs.get] + (* external localStorage : t = "localStorage" [@@bs.val] *) + + let localStorage : t = assert false + + (* external sessionStorage : t = "sessionStorage" [@@bs.val] *) + let sessionStorage : t = assert false +end + +module Storage = struct + type t = Storage2.t + + external getItem : string -> string option = "getItem" + [@@bs.send.pipe: t] [@@bs.return null_to_opt] + + external setItem : string -> string -> unit = "setItem" [@@bs.send.pipe: t] + external removeItem : string -> unit = "removeItem" [@@bs.send.pipe: t] + external clear : unit = "clear" [@@bs.send.pipe: t] + + external key : int -> string option = "key" + [@@bs.send.pipe: t] [@@bs.return null_to_opt] + + external length : t -> int = "length" [@@bs.get] + + (* external localStorage : t = "localStorage" [@@bs.val] *) + let localStorage : t = assert false + + (* external sessionStorage : t = "sessionStorage" [@@bs.val] *) + let sessionStorage : t = assert false +end diff --git a/packages/webapi/dune b/packages/webapi/dune new file mode 100644 index 000000000..5d384b829 --- /dev/null +++ b/packages/webapi/dune @@ -0,0 +1,6 @@ +(library + (name webapi) + (public_name server-reason-react.webapi) + (libraries js) + (preprocess + (pps melange.ppx))) diff --git a/packages/webapi/src/dune b/packages/webapi/src/dune deleted file mode 100644 index 14073d393..000000000 --- a/packages/webapi/src/dune +++ /dev/null @@ -1,12 +0,0 @@ -(include_subdirs unqualified) - -(library - (name webapi) - (public_name server-reason-react.webapi) - (wrapped false) - (libraries - server-reason-react.melange-fetch - server-reason-react.js - server-reason-react.melange-runtime) - (preprocess - (pps melange.ppx)))