Skip to content

Commit

Permalink
style(react-dom): formatted Experimental module
Browse files Browse the repository at this point in the history
  • Loading branch information
r17x committed Jul 21, 2024
1 parent 562c8c5 commit 2906274
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 106 deletions.
82 changes: 45 additions & 37 deletions src/ReactDOM.re
Original file line number Diff line number Diff line change
Expand Up @@ -479,47 +479,52 @@ external flushSync: (unit => unit) => unit = "flushSync";

module Experimental = {
type preloadOptions;

[@mel.obj]
external preloadOptions: (
~_as: [
| `audio
| `document
| `embed
| `fetch
| `font
| `image
| [@mel.as "object"] `object_
| `script
| `style
| `track
| `video
| `worker
],
~fetchPriority: [ `auto | `high | `low ]=?,
~referrerPolicy: [
| [@mel.as "no-referrer"] `noReferrer
| [@mel.as "no-referrer-when-downgrade"] `noReferrerWhenDowngrade
| [@mel.as "origin"] `origin
| [@mel.as "origin-when-cross-origin"] `originWhenCrossOrigin
| [@mel.as "unsafe-url"] `unsafeUrl
]=?,
external preloadOptions:
(
~_as: [
| `audio
| `document
| `embed
| `fetch
| `font
| `image
| [@mel.as "object"] `object_
| `script
| `style
| `track
| `video
| `worker
],
~fetchPriority: [ | `auto | `high | `low]=?,
~referrerPolicy: [
| [@mel.as "no-referrer"] `noReferrer
| [@mel.as "no-referrer-when-downgrade"]
`noReferrerWhenDowngrade
| [@mel.as "origin"] `origin
| [@mel.as "origin-when-cross-origin"]
`originWhenCrossOrigin
| [@mel.as "unsafe-url"] `unsafeUrl
]
=?,
~imageSrcSet: string=?,
~imageSizes: string=?,
~crossOrigin: string=?,
~integrity: string=?,
~nonce: string=?,
unit
) => preloadOptions;
unit
) =>
preloadOptions;

[@deriving jsProperties]
type preinitOptions = {
[@mel.as "as"]
_as: [ | `script | `style ],
_as: [ | `script | `style],
[@mel.optional]
fetchPriority: option([ `auto | `high | `low ]),
fetchPriority: option([ | `auto | `high | `low]),
[@mel.optional]
precedence: option([ `reset | `low | `medium | `high ]),
precedence: option([ | `reset | `low | `medium | `high]),
[@mel.optional]
crossOrigin: option(string),
[@mel.optional]
Expand All @@ -531,7 +536,7 @@ module Experimental = {
[@deriving jsProperties]
type preOptions = {
[@mel.as "as"]
_as: [ | `script ],
_as: [ | `script],
[@mel.optional]
crossOrigin: option(string),
[@mel.optional]
Expand All @@ -540,19 +545,22 @@ module Experimental = {
nonce: option(string),
};

[@mel.module "react-dom"]
external preconnect: string => unit = "preconnect";
[@mel.module "react-dom"] external preconnect: string => unit = "preconnect";
[@mel.module "react-dom"]
external prefetchDNS: string => unit = "prefetchDNS";
[@mel.module "react-dom"]
external preinit: (string, ~options: preinitOptions=?, unit) => unit = "preinit";
external preinit: (string, ~options: preinitOptions=?, unit) => unit =
"preinit";
[@mel.module "react-dom"]
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
external preinitModule: (string, ~options: preOptions=?, unit) => unit =
"preinitModule";
[@mel.module "react-dom"]
external preload: (string, ~options: preloadOptions=?, unit) => unit = "preload";
external preload: (string, ~options: preloadOptions=?, unit) => unit =
"preload";
[@mel.module "react-dom"]
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
}
external preloadModule: (string, ~options: preOptions=?, unit) => unit =
"preloadModule";
};

external domElementToObj: Dom.element => Js.t({..}) = "%identity";

Expand Down
146 changes: 77 additions & 69 deletions src/ReactDOM.rei
Original file line number Diff line number Diff line change
Expand Up @@ -487,65 +487,70 @@ module Experimental: {
type preloadOptions;

[@mel.obj]
external preloadOptions: (
external preloadOptions:
/* Its possible values are audio, document, embed, fetch, font, image, object, script, style, track, video, worker. */
~_as: [
| `audio
| `document
| `embed
| `fetch
| `font
| `image
| [@mel.as "object"] `object_
| `script
| `style
| `track
| `video
| `worker
],
/*
Suggests a relative priority for fetching the resource.
The possible values are auto (the default), high, and low.
*/
~fetchPriority: [ `auto | `high | `low ]=?,
/*
The Referrer header to send when fetching.
Its possible values are no-referrer-when-downgrade (the default), no-referrer, origin, origin-when-cross-origin, and unsafe-url.
*/
~referrerPolicy: [
| [@mel.as "no-referrer"] `noReferrer
| [@mel.as "no-referrer-when-downgrade"] `noReferrerWhenDowngrade
| [@mel.as "origin"] `origin
| [@mel.as "origin-when-cross-origin"] `originWhenCrossOrigin
| [@mel.as "unsafe-url"] `unsafeUrl
]=?,
/*
For use only with as: "image". Specifies the source set of the image.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
*/
~imageSrcSet: string=?,
/*
For use only with as: "image". Specifies the source sizes of the image.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
*/
~imageSizes: string=?,
/*
a required string. It must be "anonymous", "use-credentials", and "".
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
*/
~crossOrigin: string=?,
/*
A cryptographic hash of the module, to verify its authenticity.
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
*/
~integrity: string=?,
/*
A cryptographic nonce to allow the module when using a strict Content Security Policy.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
*/
~nonce: string=?,
unit
) => preloadOptions;
(
~_as: [
| `audio
| `document
| `embed
| `fetch
| `font
| `image
| [@mel.as "object"] `object_
| `script
| `style
| `track
| `video
| `worker
],
/*
Suggests a relative priority for fetching the resource.
The possible values are auto (the default), high, and low.
*/
~fetchPriority: [ | `auto | `high | `low]=?,
/*
The Referrer header to send when fetching.
Its possible values are no-referrer-when-downgrade (the default), no-referrer, origin, origin-when-cross-origin, and unsafe-url.
*/
~referrerPolicy: [
| [@mel.as "no-referrer"] `noReferrer
| [@mel.as "no-referrer-when-downgrade"]
`noReferrerWhenDowngrade
| [@mel.as "origin"] `origin
| [@mel.as "origin-when-cross-origin"]
`originWhenCrossOrigin
| [@mel.as "unsafe-url"] `unsafeUrl
]
=?,
/*
For use only with as: "image". Specifies the source set of the image.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
*/
~imageSrcSet: string=?,
/*
For use only with as: "image". Specifies the source sizes of the image.
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
*/
~imageSizes: string=?,
/*
a required string. It must be "anonymous", "use-credentials", and "".
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
*/
~crossOrigin: string=?,
/*
A cryptographic hash of the module, to verify its authenticity.
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
*/
~integrity: string=?,
/*
A cryptographic nonce to allow the module when using a strict Content Security Policy.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
*/
~nonce: string=?,
unit
) =>
preloadOptions;

/*
preinit options.
Expand All @@ -555,20 +560,20 @@ module Experimental: {
type preinitOptions = {
/* possible values: "script" or "style" */
[@mel.as "as"]
_as: [ | `script | `style ],
_as: [ | `script | `style],
/*
Suggests a relative priority for fetching the resource.
The possible values are auto (the default), high, and low.
*/
[@mel.optional]
fetchPriority: option([ `auto | `high | `low ]),
fetchPriority: option([ | `auto | `high | `low]),
/*
Required with Stylesheets (`style). Says where to insert the stylesheet relative to others.
Stylesheets with higher precedence can override those with lower precedence.
The possible values are reset, low, medium, high.
*/
[@mel.optional]
precedence: option([ `reset | `low | `medium | `high ]),
precedence: option([ | `reset | `low | `medium | `high]),
/*
a required string. It must be "anonymous", "use-credentials", and "".
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
Expand Down Expand Up @@ -598,7 +603,7 @@ module Experimental: {
type preOptions = {
/* It must be 'script'. */
[@mel.as "as"]
_as: [ | `script ],
_as: [ | `script],
/*
a required string. It must be "anonymous", "use-credentials", and "".
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
Expand All @@ -619,19 +624,22 @@ module Experimental: {
nonce: option(string),
};

[@mel.module "react-dom"]
external preconnect: string => unit = "preconnect";
[@mel.module "react-dom"] external preconnect: string => unit = "preconnect";
[@mel.module "react-dom"]
external prefetchDNS: string => unit = "prefetchDNS";
[@mel.module "react-dom"]
external preinit: (string, ~options: preinitOptions=?, unit) => unit = "preinit";
external preinit: (string, ~options: preinitOptions=?, unit) => unit =
"preinit";
[@mel.module "react-dom"]
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
external preinitModule: (string, ~options: preOptions=?, unit) => unit =
"preinitModule";
[@mel.module "react-dom"]
external preload: (string, ~options: preloadOptions=?, unit) => unit = "preload";
external preload: (string, ~options: preloadOptions=?, unit) => unit =
"preload";
[@mel.module "react-dom"]
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
}
external preloadModule: (string, ~options: preOptions=?, unit) => unit =
"preloadModule";
};

external domElementToObj: Dom.element => Js.t({..}) = "%identity";

Expand Down

0 comments on commit 2906274

Please sign in to comment.