Skip to content

Commit bb2fafe

Browse files
committed
feat(react-dom): add experimental module
list of experimental bind: * preconnect * prefetchDNS * preinit * preinitModule * preload * preloadModule
1 parent 15affd0 commit bb2fafe

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/ReactDOM.re

+27
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,33 @@ external unmountComponentAtNode: Dom.element => unit =
477477
[@mel.module "react-dom"]
478478
external flushSync: (unit => unit) => unit = "flushSync";
479479

480+
module Experimental = {
481+
[@deriving jsProperties]
482+
type preOptions = {
483+
[@mel.as "as"] [@mel.optional]
484+
_as: option([ | `script]),
485+
[@mel.optional]
486+
crossOrigin: option(string),
487+
[@mel.optional]
488+
integrity: option(string),
489+
[@mel.optional]
490+
nonce: option(string),
491+
};
492+
493+
[@mel.module "react-dom"]
494+
external preconnect: string => unit = "preconnect";
495+
[@mel.module "react-dom"]
496+
external prefetchDNS: string => unit = "prefetchDNS";
497+
[@mel.module "react-dom"]
498+
external preinit: string => unit = "preinit";
499+
[@mel.module "react-dom"]
500+
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
501+
[@mel.module "react-dom"]
502+
external preload: string => unit = "preload";
503+
[@mel.module "react-dom"]
504+
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
505+
}
506+
480507
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
481508

482509
type style = Style.t;

src/ReactDOM.rei

+46
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,52 @@ external unmountComponentAtNode: Dom.element => unit =
478478
[@mel.module "react-dom"]
479479
external flushSync: (unit => unit) => unit = "flushSync";
480480

481+
module Experimental: {
482+
/* This module is used to bind to APIs for future versions of ReactDOM. There is no guarantee of backwards compatibility or stability. */
483+
484+
/*
485+
preinitModule and preloadModule options.
486+
https://react.dev/reference/react-dom/preinitModule#parameters
487+
*/
488+
[@deriving jsProperties]
489+
type preOptions = {
490+
/* a required string. It must be 'script'. */
491+
[@mel.as "as"] [@mel.optional]
492+
_as: option([ | `script]),
493+
/*
494+
a required string. It must be "anonymous", "use-credentials", and "".
495+
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
496+
*/
497+
[@mel.optional]
498+
crossOrigin: option(string),
499+
/*
500+
A cryptographic hash of the module, to verify its authenticity.
501+
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
502+
*/
503+
[@mel.optional]
504+
integrity: option(string),
505+
/*
506+
A cryptographic nonce to allow the module when using a strict Content Security Policy.
507+
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
508+
*/
509+
[@mel.optional]
510+
nonce: option(string),
511+
};
512+
513+
[@mel.module "react-dom"]
514+
external preconnect: string => unit = "preconnect";
515+
[@mel.module "react-dom"]
516+
external prefetchDNS: string => unit = "prefetchDNS";
517+
[@mel.module "react-dom"]
518+
external preinit: string => unit = "preinit";
519+
[@mel.module "react-dom"]
520+
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
521+
[@mel.module "react-dom"]
522+
external preload: string => unit = "preload";
523+
[@mel.module "react-dom"]
524+
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
525+
}
526+
481527
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
482528

483529
type style = Style.t;

0 commit comments

Comments
 (0)