From 998c193fc9aee01ef8dc2a1e77a24b9bdedc982b Mon Sep 17 00:00:00 2001 From: gnoff Date: Tue, 12 Sep 2023 15:15:02 +0000 Subject: [PATCH] [Float] Refactor public interface and internal HostDispatcher implementation (#27361) When Float was first developed the internal implementation and external interface were the same. This is problematic for a few reasons. One, the public interface is typed but it is also untrusted and we should not assume that it is actually respected. Two, the internal implementations can get called from places other than the the public interface and having to construct an options argument that ends up being destructured to process the request is computationally wasteful and may limit JIT optimizations to some degree. Lastly, the wire format was not as compressed as it could be and it was untyped. This refactor aims to address that by separating the public interface from the internal implementations so we can solve these challenges and also make it easier to change Float in the future * The internal dispatcher method preinit is now preinitStyle and preinitScript. * The internal dispatcher method preinitModule is now preinitModuleScript in anticipation of different implementations for other module types in the future. * The wire format is explicitly typed and only includes options if they are actually used omitting undefined and nulls. * Some function arguments are not options even if they are optional. For instance precedence can be null/undefined because we deafult it to 'default' however we don't cosnider this an option because it is not something we transparently apply as props to the underlying instance. * Fixes a problem with keying images in flight where srcset and sizes were not being taken into account. * Moves argument validation into the ReactDOMFloat file where it is shared with all runtimes that expose these methods * Fixes crossOrigin serialization to use empty string except when 'use-credentials' DiffTrain build for [bbc8530ed7a67859583a7c990ac51cd39c7746e5](https://github.com/facebook/react/commit/bbc8530ed7a67859583a7c990ac51cd39c7746e5) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.modern.js | 2 +- compiled/facebook-www/ReactDOM-dev.classic.js | 1069 ++++++++-------- compiled/facebook-www/ReactDOM-dev.modern.js | 1073 ++++++++--------- .../facebook-www/ReactDOM-prod.classic.js | 593 ++++----- compiled/facebook-www/ReactDOM-prod.modern.js | 567 +++++---- .../ReactDOM-profiling.classic.js | 579 +++++---- .../facebook-www/ReactDOM-profiling.modern.js | 553 +++++---- .../ReactDOMServer-dev.classic.js | 514 +++----- .../facebook-www/ReactDOMServer-dev.modern.js | 514 +++----- .../ReactDOMServer-prod.classic.js | 248 ++-- .../ReactDOMServer-prod.modern.js | 248 ++-- .../ReactDOMServerStreaming-dev.modern.js | 512 +++----- .../ReactDOMServerStreaming-prod.modern.js | 246 ++-- .../ReactDOMTesting-dev.classic.js | 1069 ++++++++-------- .../ReactDOMTesting-dev.modern.js | 1073 ++++++++--------- .../ReactDOMTesting-prod.classic.js | 593 ++++----- .../ReactDOMTesting-prod.modern.js | 567 +++++---- .../ReactTestRenderer-dev.classic.js | 2 +- .../ReactTestRenderer-dev.modern.js | 2 +- compiled/facebook-www/WARNINGS | 4 - 21 files changed, 4743 insertions(+), 5287 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index b8fa2f9610b52..7b042b3400ed6 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -bb1d8d166799eb97892be6c7826179270ba283d0 +bbc8530ed7a67859583a7c990ac51cd39c7746e5 diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index d8a45aab2ce8c..c28bba0ff80ae 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-modern-1275e069"; +var ReactVersion = "18.3.0-www-modern-5ff32fc3"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index cd142883df5a6..07722c52dac8d 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -34009,7 +34009,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-5b9b66e9"; +var ReactVersion = "18.3.0-www-classic-6066e798"; function createPortal$1( children, @@ -41899,70 +41899,6 @@ function propNamesListJoin(list, combinator) { } } -function validatePreinitArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); - - error( - "ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg - ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg, - href - ); - } else { - var as = options.as; - - switch (as) { - case "style": - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + - ' and "script". The href for the preinit call where this warning originated is "%s".', - typeOfAs, - href - ); - } - } - } - } -} -function getValueDescriptorExpectingObjectForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : 'something with type "' + typeof thing + '"'; -} -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} - var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning"; var SUSPENSE_START_DATA = "$"; var SUSPENSE_END_DATA = "/$"; @@ -43432,8 +43368,9 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; // We expect this to get inlined. It is a function mostly to communicate the special nature of // how we resolve the HoistableRoot for ReactDOM.pre*() methods. Because we support calling // these methods outside of render there is no way to know which Document or ShadowRoot is 'scoped' @@ -43445,7 +43382,7 @@ function getDocumentForImperativeFloatMethods() { return document; } -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = getDocumentForImperativeFloatMethods(); if (typeof href === "string" && href) { @@ -43475,127 +43412,34 @@ function preconnectAs(rel, crossOrigin, href) { } } -function prefetchDNS$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - hasOwnProperty.call(options, "crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - - preconnectAs("dns-prefetch", null, href); +function prefetchDNS$1(href) { + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; - preconnectAs("preconnect", crossOrigin, href); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { - { - // TODO move this to ReactDOMFloat and expose a stricter function interface or possibly - // typed functions (preloadImage, preloadStyle, ...) - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - "The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - "The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - "The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag. %s', - encountered - ); - } - } - +function preload$1(href, as, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as && - ownerDocument - ) { - var as = options.as; + if (href && as && ownerDocument) { var preloadSelector = 'link[rel="preload"][as="' + escapeSelectorAttributeValueInsideDoubleQuotes(as) + '"]'; if (as === "image") { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - - if (typeof imageSrcSet === "string" && imageSrcSet !== "") { + if (options && options.imageSrcSet) { preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSrcSet) + '"]'; - if (typeof imageSizes === "string") { + if (typeof options.imageSizes === "string") { preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSizes) + '"]'; } } else { @@ -43624,7 +43468,20 @@ function preload$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadPropsFromPreloadOptions(href, as, options); + var preloadProps = assign( + { + rel: "preload", + // There is a bug in Safari where imageSrcSet is not respected on preload links + // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. + // This harms older browers that do not support imageSrcSet by making their preloads not work + // but this population is shrinking fast and is already small so we accept this tradeoff. + href: + as === "image" && options && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + preloadPropsMap.set(key, preloadProps); if (null === ownerDocument.querySelector(preloadSelector)) { @@ -43652,39 +43509,9 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var preloadSelector = 'link[rel="modulepreload"][as="' + @@ -43710,12 +43537,15 @@ function preloadModule$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadModulePropsFromPreloadModuleOptions( - href, - as, + var props = assign( + { + rel: "modulepreload", + href: href + }, options ); - preloadPropsMap.set(key, preloadProps); + + preloadPropsMap.set(key, props); if (null === ownerDocument.querySelector(preloadSelector)) { switch (as) { @@ -43732,7 +43562,7 @@ function preloadModule$1(href, options) { } var instance = ownerDocument.createElement("link"); - setInitialProperties(instance, "link", preloadProps); + setInitialProperties(instance, "link", props); markNodeAsHoistable(instance); ownerDocument.head.appendChild(instance); } @@ -43740,299 +43570,177 @@ function preloadModule$1(href, options) { } } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - -function preinit$1(href, options) { - { - validatePreinitArguments(href, options); - } - +function preinitStyle(href, precedence, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; - var key = getStyleKey(href); - var precedence = options.precedence || "default"; // Check if this resource already exists + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; + var key = getStyleKey(href); + precedence = precedence || "default"; // Check if this resource already exists - var resource = styles.get(key); + var resource = styles.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } - var state = { - loading: NotLoaded, - preload: null - }; // Attempt to hydrate instance from DOM + var state = { + loading: NotLoaded, + preload: null + }; // Attempt to hydrate instance from DOM - var instance = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - ); + var instance = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + ); - if (instance) { - state.loading = Loaded; - } else { - // Construct a new instance and insert it - var stylesheetProps = stylesheetPropsFromPreinitOptions( - href, - precedence, - options - ); - var preloadProps = preloadPropsMap.get(key); + if (instance) { + state.loading = Loaded; + } else { + // Construct a new instance and insert it + var stylesheetProps = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - if (preloadProps) { - adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - var link = (instance = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", stylesheetProps); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= Loaded; - }); - link.addEventListener("error", function () { - state.loading |= Errored; - }); - state.loading |= Inserted; - insertStylesheet(instance, precedence, ownerDocument); - } // Construct a Resource and cache it - - resource = { - type: "stylesheet", - instance: instance, - count: 1, - state: state - }; - styles.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); } - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var link = (instance = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", stylesheetProps); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= Loaded; + }); + link.addEventListener("error", function () { + state.loading |= Errored; + }); + state.loading |= Inserted; + insertStylesheet(instance, precedence, ownerDocument); + } // Construct a Resource and cache it + + resource = { + type: "stylesheet", + instance: instance, + count: 1, + state: state + }; + styles.set(key, resource); + return; + } +} - var _key = getScriptKey(src); // Check if this resource already exists +function preinitScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - var _resource = scripts.get(_key); + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (_resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var _instance = ownerDocument.querySelector( - getScriptSelectorFromKey(_key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!_instance) { - // Construct a new instance and insert it - var scriptProps = scriptPropsFromPreinitOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var _preloadProps = preloadPropsMap.get(_key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true + }, + options + ); // Adopt certain preload props - if (_preloadProps) { - adoptPreloadPropsForScript(scriptProps, _preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - _instance = ownerDocument.createElement("script"); - markNodeAsHoistable(_instance); - setInitialProperties(_instance, "link", scriptProps); - ownerDocument.head.appendChild(_instance); - } // Construct a Resource and cache it - - _resource = { - type: "script", - instance: _instance, - count: 1, - state: null - }; - scripts.set(_key, _resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} -function preinitModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } - - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered - ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; } +} +function preinitModuleScript(src, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; - - switch (_as) { - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; - var key = getScriptKey(src); // Check if this resource already exists + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - var resource = scripts.get(key); - - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var instance = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!instance) { - // Construct a new instance and insert it - var scriptProps = modulePropsFromPreinitModuleOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var preloadProps = preloadPropsMap.get(key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true, + type: "module" + }, + options + ); // Adopt certain preload props - if (preloadProps) { - adoptPreloadPropsForScript(scriptProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - instance = ownerDocument.createElement("script"); - markNodeAsHoistable(instance); - setInitialProperties(instance, "link", scriptProps); - ownerDocument.head.appendChild(instance); - } // Construct a Resource and cache it - - resource = { - type: "script", - instance: instance, - count: 1, - state: null - }; - scripts.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} - -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - async: true, - type: "module", - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; + } } // This function is called in begin work and we should always have a currentDocument set function getResource(type, currentProps, pendingProps) { @@ -44088,16 +43796,16 @@ function getResource(type, currentProps, pendingProps) { ) { var qualifiedProps = pendingProps; - var _key2 = getStyleKey(qualifiedProps.href); + var _key = getStyleKey(qualifiedProps.href); var _styles = getResourcesFromRoot(resourceRoot).hoistableStyles; - var _resource2 = _styles.get(_key2); + var _resource = _styles.get(_key); - if (!_resource2) { + if (!_resource) { // We asserted this above but Flow can't figure out that the type satisfies var ownerDocument = getDocumentFromRoot(resourceRoot); - _resource2 = { + _resource = { type: "stylesheet", instance: null, count: 0, @@ -44107,19 +43815,19 @@ function getResource(type, currentProps, pendingProps) { } }; - _styles.set(_key2, _resource2); + _styles.set(_key, _resource); - if (!preloadPropsMap.has(_key2)) { + if (!preloadPropsMap.has(_key)) { preloadStylesheet( ownerDocument, - _key2, + _key, preloadPropsFromStylesheet(qualifiedProps), - _resource2.state + _resource.state ); } } - return _resource2; + return _resource; } return null; @@ -44129,23 +43837,23 @@ function getResource(type, currentProps, pendingProps) { if (typeof pendingProps.src === "string" && pendingProps.async === true) { var scriptProps = pendingProps; - var _key3 = getScriptKey(scriptProps.src); + var _key2 = getScriptKey(scriptProps.src); var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; - var _resource3 = scripts.get(_key3); + var _resource2 = scripts.get(_key2); - if (!_resource3) { - _resource3 = { + if (!_resource2) { + _resource2 = { type: "script", instance: null, count: 0, state: null }; - scripts.set(_key3, _resource3); + scripts.set(_key2, _resource2); } - return _resource3; + return _resource2; } return { @@ -44292,14 +44000,14 @@ function acquireResource(hoistableRoot, resource, props) { var _qualifiedProps = props; var key = getStyleKey(_qualifiedProps.href); // Attempt to hydrate instance from DOM - var _instance2 = hoistableRoot.querySelector( + var _instance = hoistableRoot.querySelector( getStylesheetSelectorFromKey(key) ); - if (_instance2) { - resource.instance = _instance2; - markNodeAsHoistable(_instance2); - return _instance2; + if (_instance) { + resource.instance = _instance; + markNodeAsHoistable(_instance); + return _instance; } var stylesheetProps = stylesheetPropsFromRawProps(props); @@ -44311,18 +44019,18 @@ function acquireResource(hoistableRoot, resource, props) { var _ownerDocument = getDocumentFromRoot(hoistableRoot); - _instance2 = _ownerDocument.createElement("link"); - markNodeAsHoistable(_instance2); - var linkInstance = _instance2; + _instance = _ownerDocument.createElement("link"); + markNodeAsHoistable(_instance); + var linkInstance = _instance; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(_instance2, "link", stylesheetProps); + setInitialProperties(_instance, "link", stylesheetProps); resource.state.loading |= Inserted; - insertStylesheet(_instance2, _qualifiedProps.precedence, hoistableRoot); - resource.instance = _instance2; - return _instance2; + insertStylesheet(_instance, _qualifiedProps.precedence, hoistableRoot); + resource.instance = _instance; + return _instance; } case "script": { @@ -44331,37 +44039,37 @@ function acquireResource(hoistableRoot, resource, props) { // this cast still makes sense; var borrowedScriptProps = props; - var _key4 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM + var _key3 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM - var _instance3 = hoistableRoot.querySelector( - getScriptSelectorFromKey(_key4) + var _instance2 = hoistableRoot.querySelector( + getScriptSelectorFromKey(_key3) ); - if (_instance3) { - resource.instance = _instance3; - markNodeAsHoistable(_instance3); - return _instance3; + if (_instance2) { + resource.instance = _instance2; + markNodeAsHoistable(_instance2); + return _instance2; } var scriptProps = borrowedScriptProps; - var _preloadProps2 = preloadPropsMap.get(_key4); + var _preloadProps = preloadPropsMap.get(_key3); - if (_preloadProps2) { + if (_preloadProps) { scriptProps = assign({}, borrowedScriptProps); - adoptPreloadPropsForScript(scriptProps, _preloadProps2); + adoptPreloadPropsForScript(scriptProps, _preloadProps); } // Construct and insert a new instance var _ownerDocument2 = getDocumentFromRoot(hoistableRoot); - _instance3 = _ownerDocument2.createElement("script"); - markNodeAsHoistable(_instance3); - setInitialProperties(_instance3, "link", scriptProps); + _instance2 = _ownerDocument2.createElement("script"); + markNodeAsHoistable(_instance2); + setInitialProperties(_instance2, "link", scriptProps); - _ownerDocument2.head.appendChild(_instance3); + _ownerDocument2.head.appendChild(_instance2); - resource.instance = _instance3; - return _instance3; + resource.instance = _instance2; + return _instance2; } case "void": { @@ -44394,9 +44102,9 @@ function acquireResource(hoistableRoot, resource, props) { (resource.state.loading & Inserted) === NotLoaded ) { var _qualifiedProps2 = props; - var _instance4 = resource.instance; + var _instance3 = resource.instance; resource.state.loading |= Inserted; - insertStylesheet(_instance4, _qualifiedProps2.precedence, hoistableRoot); + insertStylesheet(_instance3, _qualifiedProps2.precedence, hoistableRoot); } } @@ -44524,9 +44232,9 @@ function hydrateHoistable(hoistableRoot, type, props, internalInstanceHandle) { ownerDocument ); - var _key5 = type + (props.content || ""); + var _key4 = type + (props.content || ""); - var _maybeNodes = _cache.get(_key5); + var _maybeNodes = _cache.get(_key4); if (_maybeNodes) { var _nodes = _maybeNodes; @@ -46896,78 +46604,361 @@ function createEventHandle(type, options) { var Dispatcher = Internals.Dispatcher; function prefetchDNS(href) { - var passedOptionArg; - { - if (arguments[1] !== undefined) { - passedOptionArg = arguments[1]; + if (typeof href !== "string" || !href) { + error( + "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (arguments.length > 1) { + var options = arguments[1]; + + if ( + typeof options === "object" && + options.hasOwnProperty("crossOrigin") + ) { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } } } var dispatcher = Dispatcher.current; - if (dispatcher) { - { - if (passedOptionArg !== undefined) { - // prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to - // elicit the warning. In prod we do not forward since it is not a part of the interface. - // @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and - // let the rest of the codebase trust the types - dispatcher.prefetchDNS(href, passedOptionArg); - } else { - dispatcher.prefetchDNS(href); - } - } + if (dispatcher && typeof href === "string") { + dispatcher.prefetchDNS(href); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preconnect(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options != null && typeof options !== "object") { + error( + "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options != null && typeof options.crossOrigin !== "string") { + error( + "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", + getValueDescriptorExpectingObjectForWarning(options.crossOrigin) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preconnect(href, options); + if (dispatcher && typeof href === "string") { + var crossOrigin = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null; + dispatcher.preconnect(href, crossOrigin); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preload(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options == null || typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (typeof options.as !== "string" || !options.as) { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preload(href, options); + if ( + dispatcher && + typeof href === "string" && // We check existence because we cannot enforce this function is actually called with the stated type + typeof options === "object" && + options !== null && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined, + nonce: typeof options.nonce === "string" ? options.nonce : undefined, + type: typeof options.type === "string" ? options.type : undefined, + fetchPriority: + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined, + referrerPolicy: + typeof options.referrerPolicy === "string" + ? options.referrerPolicy + : undefined, + imageSrcSet: + typeof options.imageSrcSet === "string" + ? options.imageSrcSet + : undefined, + imageSizes: + typeof options.imageSizes === "string" ? options.imageSizes : undefined + }); } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preloadModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && typeof options.as !== "string") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preloadModule(href, options); + if (dispatcher && typeof href === "string") { + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + typeof options.as === "string" && options.as !== "script" + ? options.as + : undefined, + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined + }); + } else { + dispatcher.preloadModule(href); + } } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinit(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options == null || typeof options !== "object") { + error( + "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options.as !== "style" && options.as !== "script") { + error( + 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', + getValueDescriptorExpectingEnumForWarning(options.as) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinit(href, options); + if ( + dispatcher && + typeof href === "string" && + options && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + var integrity = + typeof options.integrity === "string" ? options.integrity : undefined; + var fetchPriority = + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined; + + if (as === "style") { + dispatcher.preinitStyle( + href, + typeof options.precedence === "string" ? options.precedence : undefined, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ); + } else if (as === "script") { + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: typeof options.nonce === "string" ? options.nonce : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinitModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && options.as !== "script") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingEnumForWarning(options.as) + + "."; + } + + if (encountered) { + error( + "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", + encountered + ); + } else { + var as = + options && typeof options.as === "string" ? options.as : "script"; + + switch (as) { + case "script": { + break; + } + // We have an invalid as type and need to warn + + default: { + var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + + error( + 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + + ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + + " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + + " (https://github.com/tc39/proposal-import-attributes)", + typeOfAs, + href + ); + } + } + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinitModule(href, options); + if (dispatcher && typeof href === "string") { + if ( + options == null || + (typeof options === "object" && + (options.as == null || options.as === "script")) + ) { + var crossOrigin = options + ? getCrossOrigin(undefined, options.crossOrigin) + : undefined; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && typeof options.integrity === "string" + ? options.integrity + : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } +function getCrossOrigin(as, crossOrigin) { + return as === "font" + ? "" + : typeof crossOrigin === "string" + ? crossOrigin === "use-credentials" + ? "use-credentials" + : "" + : undefined; +} + +function getValueDescriptorExpectingObjectForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : 'something with type "' + typeof thing + '"'; +} + +function getValueDescriptorExpectingEnumForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : typeof thing === "string" + ? JSON.stringify(thing) + : typeof thing === "number" + ? "`" + thing + "`" + : 'something with type "' + typeof thing + '"'; +} + { if ( typeof Map !== "function" || // $FlowFixMe[prop-missing] Flow incorrectly thinks Map has no prototype diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index 31fac7c316a60..3af20d6363546 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -33854,7 +33854,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-dd5c91c5"; +var ReactVersion = "18.3.0-www-modern-aab107b3"; function createPortal$1( children, @@ -42409,70 +42409,6 @@ function propNamesListJoin(list, combinator) { } } -function validatePreinitArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); - - error( - "ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg - ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg, - href - ); - } else { - var as = options.as; - - switch (as) { - case "style": - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + - ' and "script". The href for the preinit call where this warning originated is "%s".', - typeOfAs, - href - ); - } - } - } - } -} -function getValueDescriptorExpectingObjectForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : 'something with type "' + typeof thing + '"'; -} -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} - var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning"; var SUSPENSE_START_DATA = "$"; var SUSPENSE_END_DATA = "/$"; @@ -43942,8 +43878,9 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; // We expect this to get inlined. It is a function mostly to communicate the special nature of // how we resolve the HoistableRoot for ReactDOM.pre*() methods. Because we support calling // these methods outside of render there is no way to know which Document or ShadowRoot is 'scoped' @@ -43955,7 +43892,7 @@ function getDocumentForImperativeFloatMethods() { return document; } -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = getDocumentForImperativeFloatMethods(); if (typeof href === "string" && href) { @@ -43985,127 +43922,34 @@ function preconnectAs(rel, crossOrigin, href) { } } -function prefetchDNS$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - hasOwnProperty.call(options, "crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - - preconnectAs("dns-prefetch", null, href); +function prefetchDNS$1(href) { + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; - preconnectAs("preconnect", crossOrigin, href); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { - { - // TODO move this to ReactDOMFloat and expose a stricter function interface or possibly - // typed functions (preloadImage, preloadStyle, ...) - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - "The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - "The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - "The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag. %s', - encountered - ); - } - } - +function preload$1(href, as, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as && - ownerDocument - ) { - var as = options.as; + if (href && as && ownerDocument) { var preloadSelector = 'link[rel="preload"][as="' + escapeSelectorAttributeValueInsideDoubleQuotes(as) + '"]'; if (as === "image") { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - - if (typeof imageSrcSet === "string" && imageSrcSet !== "") { + if (options && options.imageSrcSet) { preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSrcSet) + '"]'; - if (typeof imageSizes === "string") { + if (typeof options.imageSizes === "string") { preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSizes) + '"]'; } } else { @@ -44134,7 +43978,20 @@ function preload$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadPropsFromPreloadOptions(href, as, options); + var preloadProps = assign( + { + rel: "preload", + // There is a bug in Safari where imageSrcSet is not respected on preload links + // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. + // This harms older browers that do not support imageSrcSet by making their preloads not work + // but this population is shrinking fast and is already small so we accept this tradeoff. + href: + as === "image" && options && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + preloadPropsMap.set(key, preloadProps); if (null === ownerDocument.querySelector(preloadSelector)) { @@ -44162,39 +44019,9 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var preloadSelector = 'link[rel="modulepreload"][as="' + @@ -44220,12 +44047,15 @@ function preloadModule$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadModulePropsFromPreloadModuleOptions( - href, - as, + var props = assign( + { + rel: "modulepreload", + href: href + }, options ); - preloadPropsMap.set(key, preloadProps); + + preloadPropsMap.set(key, props); if (null === ownerDocument.querySelector(preloadSelector)) { switch (as) { @@ -44242,7 +44072,7 @@ function preloadModule$1(href, options) { } var instance = ownerDocument.createElement("link"); - setInitialProperties(instance, "link", preloadProps); + setInitialProperties(instance, "link", props); markNodeAsHoistable(instance); ownerDocument.head.appendChild(instance); } @@ -44250,299 +44080,177 @@ function preloadModule$1(href, options) { } } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - -function preinit$1(href, options) { - { - validatePreinitArguments(href, options); - } - +function preinitStyle(href, precedence, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; - var key = getStyleKey(href); - var precedence = options.precedence || "default"; // Check if this resource already exists + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; + var key = getStyleKey(href); + precedence = precedence || "default"; // Check if this resource already exists - var resource = styles.get(key); + var resource = styles.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } - var state = { - loading: NotLoaded, - preload: null - }; // Attempt to hydrate instance from DOM + var state = { + loading: NotLoaded, + preload: null + }; // Attempt to hydrate instance from DOM - var instance = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - ); + var instance = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + ); - if (instance) { - state.loading = Loaded; - } else { - // Construct a new instance and insert it - var stylesheetProps = stylesheetPropsFromPreinitOptions( - href, - precedence, - options - ); - var preloadProps = preloadPropsMap.get(key); + if (instance) { + state.loading = Loaded; + } else { + // Construct a new instance and insert it + var stylesheetProps = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - if (preloadProps) { - adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - var link = (instance = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", stylesheetProps); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= Loaded; - }); - link.addEventListener("error", function () { - state.loading |= Errored; - }); - state.loading |= Inserted; - insertStylesheet(instance, precedence, ownerDocument); - } // Construct a Resource and cache it - - resource = { - type: "stylesheet", - instance: instance, - count: 1, - state: state - }; - styles.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); } - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var link = (instance = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", stylesheetProps); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= Loaded; + }); + link.addEventListener("error", function () { + state.loading |= Errored; + }); + state.loading |= Inserted; + insertStylesheet(instance, precedence, ownerDocument); + } // Construct a Resource and cache it + + resource = { + type: "stylesheet", + instance: instance, + count: 1, + state: state + }; + styles.set(key, resource); + return; + } +} - var _key = getScriptKey(src); // Check if this resource already exists +function preinitScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - var _resource = scripts.get(_key); + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (_resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var _instance = ownerDocument.querySelector( - getScriptSelectorFromKey(_key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!_instance) { - // Construct a new instance and insert it - var scriptProps = scriptPropsFromPreinitOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var _preloadProps = preloadPropsMap.get(_key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true + }, + options + ); // Adopt certain preload props - if (_preloadProps) { - adoptPreloadPropsForScript(scriptProps, _preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - _instance = ownerDocument.createElement("script"); - markNodeAsHoistable(_instance); - setInitialProperties(_instance, "link", scriptProps); - ownerDocument.head.appendChild(_instance); - } // Construct a Resource and cache it - - _resource = { - type: "script", - instance: _instance, - count: 1, - state: null - }; - scripts.set(_key, _resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } + + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it + + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; } } -function preinitModule$1(href, options) { - { - var encountered = ""; +function preinitModuleScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } - - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered - ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } - } - - var ownerDocument = getDocumentForImperativeFloatMethods(); - - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; - - switch (_as) { - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; - var key = getScriptKey(src); // Check if this resource already exists - - var resource = scripts.get(key); + var resource = scripts.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM - - var instance = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!instance) { - // Construct a new instance and insert it - var scriptProps = modulePropsFromPreinitModuleOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var preloadProps = preloadPropsMap.get(key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true, + type: "module" + }, + options + ); // Adopt certain preload props - if (preloadProps) { - adoptPreloadPropsForScript(scriptProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - instance = ownerDocument.createElement("script"); - markNodeAsHoistable(instance); - setInitialProperties(instance, "link", scriptProps); - ownerDocument.head.appendChild(instance); - } // Construct a Resource and cache it - - resource = { - type: "script", - instance: instance, - count: 1, - state: null - }; - scripts.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} - -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - async: true, - type: "module", - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; + } } // This function is called in begin work and we should always have a currentDocument set function getResource(type, currentProps, pendingProps) { @@ -44598,16 +44306,16 @@ function getResource(type, currentProps, pendingProps) { ) { var qualifiedProps = pendingProps; - var _key2 = getStyleKey(qualifiedProps.href); + var _key = getStyleKey(qualifiedProps.href); var _styles = getResourcesFromRoot(resourceRoot).hoistableStyles; - var _resource2 = _styles.get(_key2); + var _resource = _styles.get(_key); - if (!_resource2) { + if (!_resource) { // We asserted this above but Flow can't figure out that the type satisfies var ownerDocument = getDocumentFromRoot(resourceRoot); - _resource2 = { + _resource = { type: "stylesheet", instance: null, count: 0, @@ -44617,19 +44325,19 @@ function getResource(type, currentProps, pendingProps) { } }; - _styles.set(_key2, _resource2); + _styles.set(_key, _resource); - if (!preloadPropsMap.has(_key2)) { + if (!preloadPropsMap.has(_key)) { preloadStylesheet( ownerDocument, - _key2, + _key, preloadPropsFromStylesheet(qualifiedProps), - _resource2.state + _resource.state ); } } - return _resource2; + return _resource; } return null; @@ -44639,23 +44347,23 @@ function getResource(type, currentProps, pendingProps) { if (typeof pendingProps.src === "string" && pendingProps.async === true) { var scriptProps = pendingProps; - var _key3 = getScriptKey(scriptProps.src); + var _key2 = getScriptKey(scriptProps.src); var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; - var _resource3 = scripts.get(_key3); + var _resource2 = scripts.get(_key2); - if (!_resource3) { - _resource3 = { + if (!_resource2) { + _resource2 = { type: "script", instance: null, count: 0, state: null }; - scripts.set(_key3, _resource3); + scripts.set(_key2, _resource2); } - return _resource3; + return _resource2; } return { @@ -44802,14 +44510,14 @@ function acquireResource(hoistableRoot, resource, props) { var _qualifiedProps = props; var key = getStyleKey(_qualifiedProps.href); // Attempt to hydrate instance from DOM - var _instance2 = hoistableRoot.querySelector( + var _instance = hoistableRoot.querySelector( getStylesheetSelectorFromKey(key) ); - if (_instance2) { - resource.instance = _instance2; - markNodeAsHoistable(_instance2); - return _instance2; + if (_instance) { + resource.instance = _instance; + markNodeAsHoistable(_instance); + return _instance; } var stylesheetProps = stylesheetPropsFromRawProps(props); @@ -44821,18 +44529,18 @@ function acquireResource(hoistableRoot, resource, props) { var _ownerDocument = getDocumentFromRoot(hoistableRoot); - _instance2 = _ownerDocument.createElement("link"); - markNodeAsHoistable(_instance2); - var linkInstance = _instance2; + _instance = _ownerDocument.createElement("link"); + markNodeAsHoistable(_instance); + var linkInstance = _instance; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(_instance2, "link", stylesheetProps); + setInitialProperties(_instance, "link", stylesheetProps); resource.state.loading |= Inserted; - insertStylesheet(_instance2, _qualifiedProps.precedence, hoistableRoot); - resource.instance = _instance2; - return _instance2; + insertStylesheet(_instance, _qualifiedProps.precedence, hoistableRoot); + resource.instance = _instance; + return _instance; } case "script": { @@ -44841,37 +44549,37 @@ function acquireResource(hoistableRoot, resource, props) { // this cast still makes sense; var borrowedScriptProps = props; - var _key4 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM + var _key3 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM - var _instance3 = hoistableRoot.querySelector( - getScriptSelectorFromKey(_key4) + var _instance2 = hoistableRoot.querySelector( + getScriptSelectorFromKey(_key3) ); - if (_instance3) { - resource.instance = _instance3; - markNodeAsHoistable(_instance3); - return _instance3; + if (_instance2) { + resource.instance = _instance2; + markNodeAsHoistable(_instance2); + return _instance2; } var scriptProps = borrowedScriptProps; - var _preloadProps2 = preloadPropsMap.get(_key4); + var _preloadProps = preloadPropsMap.get(_key3); - if (_preloadProps2) { + if (_preloadProps) { scriptProps = assign({}, borrowedScriptProps); - adoptPreloadPropsForScript(scriptProps, _preloadProps2); + adoptPreloadPropsForScript(scriptProps, _preloadProps); } // Construct and insert a new instance var _ownerDocument2 = getDocumentFromRoot(hoistableRoot); - _instance3 = _ownerDocument2.createElement("script"); - markNodeAsHoistable(_instance3); - setInitialProperties(_instance3, "link", scriptProps); + _instance2 = _ownerDocument2.createElement("script"); + markNodeAsHoistable(_instance2); + setInitialProperties(_instance2, "link", scriptProps); - _ownerDocument2.head.appendChild(_instance3); + _ownerDocument2.head.appendChild(_instance2); - resource.instance = _instance3; - return _instance3; + resource.instance = _instance2; + return _instance2; } case "void": { @@ -44904,9 +44612,9 @@ function acquireResource(hoistableRoot, resource, props) { (resource.state.loading & Inserted) === NotLoaded ) { var _qualifiedProps2 = props; - var _instance4 = resource.instance; + var _instance3 = resource.instance; resource.state.loading |= Inserted; - insertStylesheet(_instance4, _qualifiedProps2.precedence, hoistableRoot); + insertStylesheet(_instance3, _qualifiedProps2.precedence, hoistableRoot); } } @@ -45034,9 +44742,9 @@ function hydrateHoistable(hoistableRoot, type, props, internalInstanceHandle) { ownerDocument ); - var _key5 = type + (props.content || ""); + var _key4 = type + (props.content || ""); - var _maybeNodes = _cache.get(_key5); + var _maybeNodes = _cache.get(_key4); if (_maybeNodes) { var _nodes = _maybeNodes; @@ -45985,78 +45693,361 @@ function createEventHandle(type, options) { var Dispatcher = Internals.Dispatcher; function prefetchDNS(href) { - var passedOptionArg; - { - if (arguments[1] !== undefined) { - passedOptionArg = arguments[1]; + if (typeof href !== "string" || !href) { + error( + "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (arguments.length > 1) { + var options = arguments[1]; + + if ( + typeof options === "object" && + options.hasOwnProperty("crossOrigin") + ) { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } } } var dispatcher = Dispatcher.current; - if (dispatcher) { - { - if (passedOptionArg !== undefined) { - // prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to - // elicit the warning. In prod we do not forward since it is not a part of the interface. - // @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and - // let the rest of the codebase trust the types - dispatcher.prefetchDNS(href, passedOptionArg); - } else { - dispatcher.prefetchDNS(href); - } - } + if (dispatcher && typeof href === "string") { + dispatcher.prefetchDNS(href); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preconnect(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options != null && typeof options !== "object") { + error( + "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options != null && typeof options.crossOrigin !== "string") { + error( + "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", + getValueDescriptorExpectingObjectForWarning(options.crossOrigin) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preconnect(href, options); + if (dispatcher && typeof href === "string") { + var crossOrigin = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null; + dispatcher.preconnect(href, crossOrigin); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preload(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options == null || typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (typeof options.as !== "string" || !options.as) { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preload(href, options); + if ( + dispatcher && + typeof href === "string" && // We check existence because we cannot enforce this function is actually called with the stated type + typeof options === "object" && + options !== null && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined, + nonce: typeof options.nonce === "string" ? options.nonce : undefined, + type: typeof options.type === "string" ? options.type : undefined, + fetchPriority: + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined, + referrerPolicy: + typeof options.referrerPolicy === "string" + ? options.referrerPolicy + : undefined, + imageSrcSet: + typeof options.imageSrcSet === "string" + ? options.imageSrcSet + : undefined, + imageSizes: + typeof options.imageSizes === "string" ? options.imageSizes : undefined + }); } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preloadModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && typeof options.as !== "string") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preloadModule(href, options); + if (dispatcher && typeof href === "string") { + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + typeof options.as === "string" && options.as !== "script" + ? options.as + : undefined, + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined + }); + } else { + dispatcher.preloadModule(href); + } } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinit(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options == null || typeof options !== "object") { + error( + "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options.as !== "style" && options.as !== "script") { + error( + 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', + getValueDescriptorExpectingEnumForWarning(options.as) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinit(href, options); + if ( + dispatcher && + typeof href === "string" && + options && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + var integrity = + typeof options.integrity === "string" ? options.integrity : undefined; + var fetchPriority = + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined; + + if (as === "style") { + dispatcher.preinitStyle( + href, + typeof options.precedence === "string" ? options.precedence : undefined, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ); + } else if (as === "script") { + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: typeof options.nonce === "string" ? options.nonce : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinitModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && options.as !== "script") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingEnumForWarning(options.as) + + "."; + } + + if (encountered) { + error( + "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", + encountered + ); + } else { + var as = + options && typeof options.as === "string" ? options.as : "script"; + + switch (as) { + case "script": { + break; + } + // We have an invalid as type and need to warn + + default: { + var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + + error( + 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + + ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + + " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + + " (https://github.com/tc39/proposal-import-attributes)", + typeOfAs, + href + ); + } + } + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinitModule(href, options); + if (dispatcher && typeof href === "string") { + if ( + options == null || + (typeof options === "object" && + (options.as == null || options.as === "script")) + ) { + var crossOrigin = options + ? getCrossOrigin(undefined, options.crossOrigin) + : undefined; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && typeof options.integrity === "string" + ? options.integrity + : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } +function getCrossOrigin(as, crossOrigin) { + return as === "font" + ? "" + : typeof crossOrigin === "string" + ? crossOrigin === "use-credentials" + ? "use-credentials" + : "" + : undefined; +} + +function getValueDescriptorExpectingObjectForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : 'something with type "' + typeof thing + '"'; +} + +function getValueDescriptorExpectingEnumForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : typeof thing === "string" + ? JSON.stringify(thing) + : typeof thing === "number" + ? "`" + thing + "`" + : 'something with type "' + typeof thing + '"'; +} + { if ( typeof Map !== "function" || // $FlowFixMe[prop-missing] Flow incorrectly thinks Map has no prototype diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index 3ccf0414ef4ee..07a90af1c1f1a 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -12660,19 +12660,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$367; + var JSCompiler_inline_result$jscomp$363; if (canUseDOM) { - var isSupported$jscomp$inline_1534 = "oninput" in document; - if (!isSupported$jscomp$inline_1534) { - var element$jscomp$inline_1535 = document.createElement("div"); - element$jscomp$inline_1535.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1534 = - "function" === typeof element$jscomp$inline_1535.oninput; + var isSupported$jscomp$inline_1530 = "oninput" in document; + if (!isSupported$jscomp$inline_1530) { + var element$jscomp$inline_1531 = document.createElement("div"); + element$jscomp$inline_1531.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1530 = + "function" === typeof element$jscomp$inline_1531.oninput; } - JSCompiler_inline_result$jscomp$367 = isSupported$jscomp$inline_1534; - } else JSCompiler_inline_result$jscomp$367 = !1; + JSCompiler_inline_result$jscomp$363 = isSupported$jscomp$inline_1530; + } else JSCompiler_inline_result$jscomp$363 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$367 && + JSCompiler_inline_result$jscomp$363 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -12981,20 +12981,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1575 = 0; - i$jscomp$inline_1575 < simpleEventPluginEvents.length; - i$jscomp$inline_1575++ + var i$jscomp$inline_1571 = 0; + i$jscomp$inline_1571 < simpleEventPluginEvents.length; + i$jscomp$inline_1571++ ) { - var eventName$jscomp$inline_1576 = - simpleEventPluginEvents[i$jscomp$inline_1575], - domEventName$jscomp$inline_1577 = - eventName$jscomp$inline_1576.toLowerCase(), - capitalizedEvent$jscomp$inline_1578 = - eventName$jscomp$inline_1576[0].toUpperCase() + - eventName$jscomp$inline_1576.slice(1); + var eventName$jscomp$inline_1572 = + simpleEventPluginEvents[i$jscomp$inline_1571], + domEventName$jscomp$inline_1573 = + eventName$jscomp$inline_1572.toLowerCase(), + capitalizedEvent$jscomp$inline_1574 = + eventName$jscomp$inline_1572[0].toUpperCase() + + eventName$jscomp$inline_1572.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1577, - "on" + capitalizedEvent$jscomp$inline_1578 + domEventName$jscomp$inline_1573, + "on" + capitalizedEvent$jscomp$inline_1574 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15170,10 +15170,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -15186,92 +15187,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -15280,7 +15261,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -15300,13 +15281,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -15327,129 +15302,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -15478,17 +15427,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$276 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$277 = styles$276.get(type); - resource$277 || + var styles$272 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$273 = styles$272.get(type); + resource$273 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$277 = { + (resource$273 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$276.set(type, resource$277), + styles$272.set(type, resource$273), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -15503,9 +15452,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$277.state + resource$273.state )); - return resource$277; + return resource$273; } return null; case "script": @@ -15588,36 +15537,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$281 = hoistableRoot.querySelector( + var instance$277 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$281) + if (instance$277) return ( - (resource.instance = instance$281), - markNodeAsHoistable(instance$281), - instance$281 + (resource.instance = instance$277), + markNodeAsHoistable(instance$277), + instance$277 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$281 = ( + instance$277 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$281); - var linkInstance = instance$281; + markNodeAsHoistable(instance$277); + var linkInstance = instance$277; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$281, "link", instance); + setInitialProperties(instance$277, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$281, props.precedence, hoistableRoot); - return (resource.instance = instance$281); + insertStylesheet(instance$277, props.precedence, hoistableRoot); + return (resource.instance = instance$277); case "script": - instance$281 = getScriptKey(props.src); + instance$277 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$281) + getScriptSelectorFromKey(instance$277) )) ) return ( @@ -15626,7 +15575,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$281))) + if ((styleProps = preloadPropsMap.get(instance$277))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -16578,11 +16527,11 @@ function legacyCreateRootFromDOMContainer( if ("function" === typeof callback) { var originalCallback = callback; callback = function () { - var instance = getPublicRootInstance(root$301); + var instance = getPublicRootInstance(root$297); originalCallback.call(instance); }; } - var root$301 = createHydrationContainer( + var root$297 = createHydrationContainer( initialChildren, callback, container, @@ -16594,23 +16543,23 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$301; - container[internalContainerInstanceKey] = root$301.current; + container._reactRootContainer = root$297; + container[internalContainerInstanceKey] = root$297.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(); - return root$301; + return root$297; } clearContainer(container); if ("function" === typeof callback) { - var originalCallback$302 = callback; + var originalCallback$298 = callback; callback = function () { - var instance = getPublicRootInstance(root$303); - originalCallback$302.call(instance); + var instance = getPublicRootInstance(root$299); + originalCallback$298.call(instance); }; } - var root$303 = createFiberRoot( + var root$299 = createFiberRoot( container, 0, !1, @@ -16622,15 +16571,15 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$303; - container[internalContainerInstanceKey] = root$303.current; + container._reactRootContainer = root$299; + container[internalContainerInstanceKey] = root$299.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(function () { - updateContainer(initialChildren, root$303, parentComponent, callback); + updateContainer(initialChildren, root$299, parentComponent, callback); }); - return root$303; + return root$299; } function legacyRenderSubtreeIntoContainer( parentComponent, @@ -16682,6 +16631,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode, getNodeFromInstance, @@ -16690,17 +16648,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1782 = { +var devToolsConfig$jscomp$inline_1778 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-99a4df19", + version: "18.3.0-www-classic-bdb60afd", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2139 = { - bundleType: devToolsConfig$jscomp$inline_1782.bundleType, - version: devToolsConfig$jscomp$inline_1782.version, - rendererPackageName: devToolsConfig$jscomp$inline_1782.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1782.rendererConfig, +var internals$jscomp$inline_2135 = { + bundleType: devToolsConfig$jscomp$inline_1778.bundleType, + version: devToolsConfig$jscomp$inline_1778.version, + rendererPackageName: devToolsConfig$jscomp$inline_1778.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1778.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16716,26 +16674,26 @@ var internals$jscomp$inline_2139 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1782.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1778.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-99a4df19" + reconcilerVersion: "18.3.0-www-classic-bdb60afd" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2140 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2136 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2140.isDisabled && - hook$jscomp$inline_2140.supportsFiber + !hook$jscomp$inline_2136.isDisabled && + hook$jscomp$inline_2136.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2140.inject( - internals$jscomp$inline_2139 + (rendererID = hook$jscomp$inline_2136.inject( + internals$jscomp$inline_2135 )), - (injectedHook = hook$jscomp$inline_2140); + (injectedHook = hook$jscomp$inline_2136); } catch (err) {} } assign(Internals, { @@ -16861,27 +16819,120 @@ exports.hydrateRoot = function (container, initialChildren, options) { }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.render = function (element, container, callback) { if (!isValidContainerLegacy(container)) @@ -16962,4 +17013,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-99a4df19"; +exports.version = "18.3.0-www-classic-bdb60afd"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index 59353b15c231f..120792920614a 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -12902,19 +12902,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$365; + var JSCompiler_inline_result$jscomp$361; if (canUseDOM) { - var isSupported$jscomp$inline_1533 = "oninput" in document; - if (!isSupported$jscomp$inline_1533) { - var element$jscomp$inline_1534 = document.createElement("div"); - element$jscomp$inline_1534.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1533 = - "function" === typeof element$jscomp$inline_1534.oninput; + var isSupported$jscomp$inline_1529 = "oninput" in document; + if (!isSupported$jscomp$inline_1529) { + var element$jscomp$inline_1530 = document.createElement("div"); + element$jscomp$inline_1530.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1529 = + "function" === typeof element$jscomp$inline_1530.oninput; } - JSCompiler_inline_result$jscomp$365 = isSupported$jscomp$inline_1533; - } else JSCompiler_inline_result$jscomp$365 = !1; + JSCompiler_inline_result$jscomp$361 = isSupported$jscomp$inline_1529; + } else JSCompiler_inline_result$jscomp$361 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$365 && + JSCompiler_inline_result$jscomp$361 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13223,20 +13223,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1574 = 0; - i$jscomp$inline_1574 < simpleEventPluginEvents.length; - i$jscomp$inline_1574++ + var i$jscomp$inline_1570 = 0; + i$jscomp$inline_1570 < simpleEventPluginEvents.length; + i$jscomp$inline_1570++ ) { - var eventName$jscomp$inline_1575 = - simpleEventPluginEvents[i$jscomp$inline_1574], - domEventName$jscomp$inline_1576 = - eventName$jscomp$inline_1575.toLowerCase(), - capitalizedEvent$jscomp$inline_1577 = - eventName$jscomp$inline_1575[0].toUpperCase() + - eventName$jscomp$inline_1575.slice(1); + var eventName$jscomp$inline_1571 = + simpleEventPluginEvents[i$jscomp$inline_1570], + domEventName$jscomp$inline_1572 = + eventName$jscomp$inline_1571.toLowerCase(), + capitalizedEvent$jscomp$inline_1573 = + eventName$jscomp$inline_1571[0].toUpperCase() + + eventName$jscomp$inline_1571.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1576, - "on" + capitalizedEvent$jscomp$inline_1577 + domEventName$jscomp$inline_1572, + "on" + capitalizedEvent$jscomp$inline_1573 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15397,10 +15397,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -15413,92 +15414,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -15507,7 +15488,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -15527,13 +15508,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -15554,129 +15529,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -15705,17 +15654,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$280 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$281 = styles$280.get(type); - resource$281 || + var styles$276 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$277 = styles$276.get(type); + resource$277 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$281 = { + (resource$277 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$280.set(type, resource$281), + styles$276.set(type, resource$277), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -15730,9 +15679,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$281.state + resource$277.state )); - return resource$281; + return resource$277; } return null; case "script": @@ -15815,36 +15764,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$285 = hoistableRoot.querySelector( + var instance$281 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$285) + if (instance$281) return ( - (resource.instance = instance$285), - markNodeAsHoistable(instance$285), - instance$285 + (resource.instance = instance$281), + markNodeAsHoistable(instance$281), + instance$281 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$285 = ( + instance$281 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$285); - var linkInstance = instance$285; + markNodeAsHoistable(instance$281); + var linkInstance = instance$281; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$285, "link", instance); + setInitialProperties(instance$281, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$285, props.precedence, hoistableRoot); - return (resource.instance = instance$285); + insertStylesheet(instance$281, props.precedence, hoistableRoot); + return (resource.instance = instance$281); case "script": - instance$285 = getScriptKey(props.src); + instance$281 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$285) + getScriptSelectorFromKey(instance$281) )) ) return ( @@ -15853,7 +15802,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$285))) + if ((styleProps = preloadPropsMap.get(instance$281))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -16208,6 +16157,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode$1, getNodeFromInstance, @@ -16216,17 +16174,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1741 = { +var devToolsConfig$jscomp$inline_1737 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-3501ad4f", + version: "18.3.0-www-modern-cb1eb6e1", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2103 = { - bundleType: devToolsConfig$jscomp$inline_1741.bundleType, - version: devToolsConfig$jscomp$inline_1741.version, - rendererPackageName: devToolsConfig$jscomp$inline_1741.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1741.rendererConfig, +var internals$jscomp$inline_2099 = { + bundleType: devToolsConfig$jscomp$inline_1737.bundleType, + version: devToolsConfig$jscomp$inline_1737.version, + rendererPackageName: devToolsConfig$jscomp$inline_1737.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1737.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16243,26 +16201,26 @@ var internals$jscomp$inline_2103 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1741.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1737.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-3501ad4f" + reconcilerVersion: "18.3.0-www-modern-cb1eb6e1" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2104 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2100 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2104.isDisabled && - hook$jscomp$inline_2104.supportsFiber + !hook$jscomp$inline_2100.isDisabled && + hook$jscomp$inline_2100.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2104.inject( - internals$jscomp$inline_2103 + (rendererID = hook$jscomp$inline_2100.inject( + internals$jscomp$inline_2099 )), - (injectedHook = hook$jscomp$inline_2104); + (injectedHook = hook$jscomp$inline_2100); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; @@ -16364,27 +16322,120 @@ exports.hydrateRoot = function (container, initialChildren, options) { }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.unstable_batchedUpdates = batchedUpdates$1; exports.unstable_createEventHandle = function (type, options) { @@ -16417,4 +16468,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-3501ad4f"; +exports.version = "18.3.0-www-modern-cb1eb6e1"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index c46ee05b36721..4f49fe7c57556 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -13435,19 +13435,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$388; + var JSCompiler_inline_result$jscomp$384; if (canUseDOM) { - var isSupported$jscomp$inline_1619 = "oninput" in document; - if (!isSupported$jscomp$inline_1619) { - var element$jscomp$inline_1620 = document.createElement("div"); - element$jscomp$inline_1620.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1619 = - "function" === typeof element$jscomp$inline_1620.oninput; + var isSupported$jscomp$inline_1615 = "oninput" in document; + if (!isSupported$jscomp$inline_1615) { + var element$jscomp$inline_1616 = document.createElement("div"); + element$jscomp$inline_1616.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1615 = + "function" === typeof element$jscomp$inline_1616.oninput; } - JSCompiler_inline_result$jscomp$388 = isSupported$jscomp$inline_1619; - } else JSCompiler_inline_result$jscomp$388 = !1; + JSCompiler_inline_result$jscomp$384 = isSupported$jscomp$inline_1615; + } else JSCompiler_inline_result$jscomp$384 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$388 && + JSCompiler_inline_result$jscomp$384 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13756,20 +13756,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1660 = 0; - i$jscomp$inline_1660 < simpleEventPluginEvents.length; - i$jscomp$inline_1660++ + var i$jscomp$inline_1656 = 0; + i$jscomp$inline_1656 < simpleEventPluginEvents.length; + i$jscomp$inline_1656++ ) { - var eventName$jscomp$inline_1661 = - simpleEventPluginEvents[i$jscomp$inline_1660], - domEventName$jscomp$inline_1662 = - eventName$jscomp$inline_1661.toLowerCase(), - capitalizedEvent$jscomp$inline_1663 = - eventName$jscomp$inline_1661[0].toUpperCase() + - eventName$jscomp$inline_1661.slice(1); + var eventName$jscomp$inline_1657 = + simpleEventPluginEvents[i$jscomp$inline_1656], + domEventName$jscomp$inline_1658 = + eventName$jscomp$inline_1657.toLowerCase(), + capitalizedEvent$jscomp$inline_1659 = + eventName$jscomp$inline_1657[0].toUpperCase() + + eventName$jscomp$inline_1657.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1662, - "on" + capitalizedEvent$jscomp$inline_1663 + domEventName$jscomp$inline_1658, + "on" + capitalizedEvent$jscomp$inline_1659 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15945,10 +15945,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -15961,92 +15962,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -16055,7 +16036,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -16075,13 +16056,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -16102,129 +16077,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -16253,17 +16202,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$297 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$298 = styles$297.get(type); - resource$298 || + var styles$293 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$294 = styles$293.get(type); + resource$294 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$298 = { + (resource$294 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$297.set(type, resource$298), + styles$293.set(type, resource$294), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -16278,9 +16227,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$298.state + resource$294.state )); - return resource$298; + return resource$294; } return null; case "script": @@ -16363,36 +16312,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$302 = hoistableRoot.querySelector( + var instance$298 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$302) + if (instance$298) return ( - (resource.instance = instance$302), - markNodeAsHoistable(instance$302), - instance$302 + (resource.instance = instance$298), + markNodeAsHoistable(instance$298), + instance$298 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$302 = ( + instance$298 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$302); - var linkInstance = instance$302; + markNodeAsHoistable(instance$298); + var linkInstance = instance$298; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$302, "link", instance); + setInitialProperties(instance$298, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$302, props.precedence, hoistableRoot); - return (resource.instance = instance$302); + insertStylesheet(instance$298, props.precedence, hoistableRoot); + return (resource.instance = instance$298); case "script": - instance$302 = getScriptKey(props.src); + instance$298 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$302) + getScriptSelectorFromKey(instance$298) )) ) return ( @@ -16401,7 +16350,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$302))) + if ((styleProps = preloadPropsMap.get(instance$298))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -17353,11 +17302,11 @@ function legacyCreateRootFromDOMContainer( if ("function" === typeof callback) { var originalCallback = callback; callback = function () { - var instance = getPublicRootInstance(root$322); + var instance = getPublicRootInstance(root$318); originalCallback.call(instance); }; } - var root$322 = createHydrationContainer( + var root$318 = createHydrationContainer( initialChildren, callback, container, @@ -17369,23 +17318,23 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$322; - container[internalContainerInstanceKey] = root$322.current; + container._reactRootContainer = root$318; + container[internalContainerInstanceKey] = root$318.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(); - return root$322; + return root$318; } clearContainer(container); if ("function" === typeof callback) { - var originalCallback$323 = callback; + var originalCallback$319 = callback; callback = function () { - var instance = getPublicRootInstance(root$324); - originalCallback$323.call(instance); + var instance = getPublicRootInstance(root$320); + originalCallback$319.call(instance); }; } - var root$324 = createFiberRoot( + var root$320 = createFiberRoot( container, 0, !1, @@ -17397,15 +17346,15 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$324; - container[internalContainerInstanceKey] = root$324.current; + container._reactRootContainer = root$320; + container[internalContainerInstanceKey] = root$320.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(function () { - updateContainer(initialChildren, root$324, parentComponent, callback); + updateContainer(initialChildren, root$320, parentComponent, callback); }); - return root$324; + return root$320; } function legacyRenderSubtreeIntoContainer( parentComponent, @@ -17457,6 +17406,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode, getNodeFromInstance, @@ -17465,10 +17423,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1867 = { +var devToolsConfig$jscomp$inline_1863 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-8c23f84e", + version: "18.3.0-www-classic-e8e035f8", rendererPackageName: "react-dom" }; (function (internals) { @@ -17486,10 +17444,10 @@ var devToolsConfig$jscomp$inline_1867 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1867.bundleType, - version: devToolsConfig$jscomp$inline_1867.version, - rendererPackageName: devToolsConfig$jscomp$inline_1867.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1867.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1863.bundleType, + version: devToolsConfig$jscomp$inline_1863.version, + rendererPackageName: devToolsConfig$jscomp$inline_1863.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1863.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17505,14 +17463,14 @@ var devToolsConfig$jscomp$inline_1867 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1867.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1863.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-8c23f84e" + reconcilerVersion: "18.3.0-www-classic-e8e035f8" }); assign(Internals, { ReactBrowserEventEmitter: { @@ -17637,27 +17595,120 @@ exports.hydrateRoot = function (container, initialChildren, options) { }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.render = function (element, container, callback) { if (!isValidContainerLegacy(container)) @@ -17738,7 +17789,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-8c23f84e"; +exports.version = "18.3.0-www-classic-e8e035f8"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index 517080681143a..9773dfae7233f 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -13671,19 +13671,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$386; + var JSCompiler_inline_result$jscomp$382; if (canUseDOM) { - var isSupported$jscomp$inline_1618 = "oninput" in document; - if (!isSupported$jscomp$inline_1618) { - var element$jscomp$inline_1619 = document.createElement("div"); - element$jscomp$inline_1619.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1618 = - "function" === typeof element$jscomp$inline_1619.oninput; + var isSupported$jscomp$inline_1614 = "oninput" in document; + if (!isSupported$jscomp$inline_1614) { + var element$jscomp$inline_1615 = document.createElement("div"); + element$jscomp$inline_1615.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1614 = + "function" === typeof element$jscomp$inline_1615.oninput; } - JSCompiler_inline_result$jscomp$386 = isSupported$jscomp$inline_1618; - } else JSCompiler_inline_result$jscomp$386 = !1; + JSCompiler_inline_result$jscomp$382 = isSupported$jscomp$inline_1614; + } else JSCompiler_inline_result$jscomp$382 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$386 && + JSCompiler_inline_result$jscomp$382 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13992,20 +13992,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1659 = 0; - i$jscomp$inline_1659 < simpleEventPluginEvents.length; - i$jscomp$inline_1659++ + var i$jscomp$inline_1655 = 0; + i$jscomp$inline_1655 < simpleEventPluginEvents.length; + i$jscomp$inline_1655++ ) { - var eventName$jscomp$inline_1660 = - simpleEventPluginEvents[i$jscomp$inline_1659], - domEventName$jscomp$inline_1661 = - eventName$jscomp$inline_1660.toLowerCase(), - capitalizedEvent$jscomp$inline_1662 = - eventName$jscomp$inline_1660[0].toUpperCase() + - eventName$jscomp$inline_1660.slice(1); + var eventName$jscomp$inline_1656 = + simpleEventPluginEvents[i$jscomp$inline_1655], + domEventName$jscomp$inline_1657 = + eventName$jscomp$inline_1656.toLowerCase(), + capitalizedEvent$jscomp$inline_1658 = + eventName$jscomp$inline_1656[0].toUpperCase() + + eventName$jscomp$inline_1656.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1661, - "on" + capitalizedEvent$jscomp$inline_1662 + domEventName$jscomp$inline_1657, + "on" + capitalizedEvent$jscomp$inline_1658 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16166,10 +16166,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -16182,92 +16183,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -16276,7 +16257,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -16296,13 +16277,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -16323,129 +16298,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -16474,17 +16423,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$301 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$302 = styles$301.get(type); - resource$302 || + var styles$297 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$298 = styles$297.get(type); + resource$298 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$302 = { + (resource$298 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$301.set(type, resource$302), + styles$297.set(type, resource$298), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -16499,9 +16448,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$302.state + resource$298.state )); - return resource$302; + return resource$298; } return null; case "script": @@ -16584,36 +16533,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$306 = hoistableRoot.querySelector( + var instance$302 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$306) + if (instance$302) return ( - (resource.instance = instance$306), - markNodeAsHoistable(instance$306), - instance$306 + (resource.instance = instance$302), + markNodeAsHoistable(instance$302), + instance$302 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$306 = ( + instance$302 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$306); - var linkInstance = instance$306; + markNodeAsHoistable(instance$302); + var linkInstance = instance$302; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$306, "link", instance); + setInitialProperties(instance$302, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$306, props.precedence, hoistableRoot); - return (resource.instance = instance$306); + insertStylesheet(instance$302, props.precedence, hoistableRoot); + return (resource.instance = instance$302); case "script": - instance$306 = getScriptKey(props.src); + instance$302 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$306) + getScriptSelectorFromKey(instance$302) )) ) return ( @@ -16622,7 +16571,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$306))) + if ((styleProps = preloadPropsMap.get(instance$302))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -16977,6 +16926,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode$1, getNodeFromInstance, @@ -16985,10 +16943,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1826 = { +var devToolsConfig$jscomp$inline_1822 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-b6acedfc", + version: "18.3.0-www-modern-4b32ae1f", rendererPackageName: "react-dom" }; (function (internals) { @@ -17006,10 +16964,10 @@ var devToolsConfig$jscomp$inline_1826 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1826.bundleType, - version: devToolsConfig$jscomp$inline_1826.version, - rendererPackageName: devToolsConfig$jscomp$inline_1826.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1826.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1822.bundleType, + version: devToolsConfig$jscomp$inline_1822.version, + rendererPackageName: devToolsConfig$jscomp$inline_1822.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1822.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17026,14 +16984,14 @@ var devToolsConfig$jscomp$inline_1826 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1826.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1822.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-b6acedfc" + reconcilerVersion: "18.3.0-www-modern-4b32ae1f" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function (children, container) { @@ -17134,27 +17092,120 @@ exports.hydrateRoot = function (container, initialChildren, options) { }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.unstable_batchedUpdates = batchedUpdates$1; exports.unstable_createEventHandle = function (type, options) { @@ -17187,7 +17238,7 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-b6acedfc"; +exports.version = "18.3.0-www-modern-4b32ae1f"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMServer-dev.classic.js b/compiled/facebook-www/ReactDOMServer-dev.classic.js index a15d65cbea87c..52c41ce6deeb1 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.classic.js +++ b/compiled/facebook-www/ReactDOMServer-dev.classic.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-classic-ae77ec0b"; +var ReactVersion = "18.3.0-www-classic-51adb8d6"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -1848,17 +1848,6 @@ function getValueDescriptorExpectingObjectForWarning(thing) { ? "an empty string" : 'something with type "' + typeof thing + '"'; } -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; @@ -1872,8 +1861,9 @@ var ReactDOMServerDispatcher = { preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; function prepareHostDispatcher() { ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher; @@ -6442,7 +6432,7 @@ function getResourceKey(as, href) { return "[" + as + "]" + href; } -function prefetchDNS(href, options) { +function prefetchDNS(href) { var request = resolveRequest(); if (!request) { @@ -6456,30 +6446,6 @@ function prefetchDNS(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - options.hasOwnProperty("crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - if (typeof href === "string" && href) { var key = getResourceKey("prefetchDNS", href); var resource = resumableState.preconnectsMap.get(key); @@ -6503,7 +6469,7 @@ function prefetchDNS(href, options) { } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = resolveRequest(); if (!request) { @@ -6517,35 +6483,10 @@ function preconnect(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - if (typeof href === "string" && href) { - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; var key = "[preconnect][" + - (crossOrigin === null ? "null" : crossOrigin) + + (typeof crossOrigin === "string" ? crossOrigin : "null") + "]" + href; var resource = resumableState.preconnectsMap.get(key); @@ -6570,7 +6511,7 @@ function preconnect(href, options) { } } -function preload(href, options) { +function preload(href, as, options) { var request = resolveRequest(); if (!request) { @@ -6584,54 +6525,15 @@ function preload(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key; if (as === "image") { // For image preloads the key contains either the imageSrcSet + imageSizes or the href but not // both. This is to prevent identical calls with the same srcSet and sizes to be duplicated // by varying the href. this is an edge case but it is the most correct behavior. - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - key = getImagePreloadKey(href, imageSrcSet, imageSizes); + key = getImagePreloadKey(href, options.imageSrcSet, options.imageSizes); } else { key = getResourceKey(as, href); } @@ -6639,11 +6541,20 @@ function preload(href, options) { var resource = resumableState.preloadsMap.get(key); if (!resource) { + var props = assign( + { + rel: "preload", + href: as === "image" && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + resource = { type: "preload", chunks: [], state: NoState, - props: preloadPropsFromPreloadOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6651,7 +6562,7 @@ function preload(href, options) { if (as === "font") { resumableState.fontPreloads.add(resource); - } else if (as === "image" && options.fetchPriority === "high") { + } else if (as === "image" && resource.props.fetchPriority === "high") { resumableState.highImagePreloads.add(resource); } else { resumableState.bulkPreloads.add(resource); @@ -6675,47 +6586,25 @@ function preloadModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var key = getResourceKey(as, href); var resource = resumableState.preloadsMap.get(key); + var props = assign( + { + rel: "modulepreload", + href: href + }, + options + ); + if (!resource) { resource = { type: "preload", chunks: [], state: NoState, - props: preloadModulePropsFromPreloadModuleOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6726,7 +6615,7 @@ function preloadModule(href, options) { } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = resolveRequest(); if (!request) { @@ -6740,117 +6629,73 @@ function preinit(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options == null || typeof options !== "object") { - error( - "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options.as !== "style" && options.as !== "script") { - error( - 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', - getValueDescriptorExpectingEnumForWarning(options.as) - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var key = getResourceKey(as, href); - var resource = resumableState.stylesMap.get(key); - var precedence = options.precedence || "default"; - - if (!resource) { - var state = NoState; - var preloadResource = resumableState.preloadsMap.get(key); + if (href) { + var as = "style"; + var key = getResourceKey(as, href); + var resource = resumableState.stylesMap.get(key); - if (preloadResource && preloadResource.state & Flushed) { - state = PreloadFlushed; - } + if (!resource) { + precedence = precedence || "default"; + var state = NoState; + var preloadResource = resumableState.preloadsMap.get(key); - resource = { - type: "stylesheet", - chunks: [], - state: state, - props: stylesheetPropsFromPreinitOptions(href, precedence, options) - }; - resumableState.stylesMap.set(key, resource); - var precedenceSet = resumableState.precedences.get(precedence); + if (preloadResource && preloadResource.state & Flushed) { + state = PreloadFlushed; + } - if (!precedenceSet) { - precedenceSet = new Set(); - resumableState.precedences.set(precedence, precedenceSet); - var emptyStyleResource = { - type: "style", - chunks: [], - state: NoState, - props: { - precedence: precedence, - hrefs: [] - } - }; - precedenceSet.add(emptyStyleResource); + var props = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - { - if (resumableState.stylePrecedences.has(precedence)) { - error( - 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', - precedence - ); - } - } + resource = { + type: "stylesheet", + chunks: [], + state: state, + props: props + }; + resumableState.stylesMap.set(key, resource); + var precedenceSet = resumableState.precedences.get(precedence); - resumableState.stylePrecedences.set(precedence, emptyStyleResource); + if (!precedenceSet) { + precedenceSet = new Set(); + resumableState.precedences.set(precedence, precedenceSet); + var emptyStyleResource = { + type: "style", + chunks: [], + state: NoState, + props: { + precedence: precedence, + hrefs: [] } + }; + precedenceSet.add(emptyStyleResource); - precedenceSet.add(resource); - flushResources(request); + { + if (resumableState.stylePrecedences.has(precedence)) { + error( + 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', + precedence + ); + } } - return; + resumableState.stylePrecedences.set(precedence, emptyStyleResource); } - case "script": { - var src = href; - - var _key = getResourceKey(as, src); - - var _resource = resumableState.scriptsMap.get(_key); - - if (!_resource) { - _resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(_key, _resource); - var resourceProps = scriptPropsFromPreinitOptions(src, options); - resumableState.scripts.add(_resource); - pushScriptImpl(_resource.chunks, resourceProps); - flushResources(request); - } - - return; - } + precedenceSet.add(resource); + flushResources(request); } + + return; } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = resolveRequest(); if (!request) { @@ -6864,85 +6709,78 @@ function preinitModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered + var props = assign( + { + src: src, + async: true + }, + options ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); + } - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + return; + } +} - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } +function preinitModuleScript(src, options) { + var request = resolveRequest(); + + if (!request) { + // In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also + // possibly get them from the stack if we are not in an async context. Since we were not able to resolve + // the resources for this call in either case we opt to do nothing. We can consider making this a warning + // but there may be times where calling a function outside of render is intentional (i.e. to warm up data + // fetching) and we don't want to warn in those cases. + return; } - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; + var resumableState = getResumableState(request); - switch (_as) { - case "script": { - var src = href; - var key = getResourceKey(_as, src); - var resource = resumableState.scriptsMap.get(key); + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (!resource) { - resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(key, resource); - var resourceProps = modulePropsFromPreinitModuleOptions(src, options); - resumableState.scripts.add(resource); - pushScriptImpl(resource.chunks, resourceProps); - flushResources(request); - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - return; - } + var props = assign( + { + src: src, + type: "module", + async: true + }, + options + ); + + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); } + + return; } } // This function is only safe to call at Request start time since it assumes // that each script has not already been preloaded. If we find a need to preload @@ -7052,36 +6890,6 @@ function internalPreinitScript(resumableState, src, chunks) { return; } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function preloadAsStylePropsFromProps(href, props) { return { rel: "preload", @@ -7096,17 +6904,6 @@ function preloadAsStylePropsFromProps(href, props) { }; } -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} - function stylesheetPropsFromRawProps(rawProps) { return assign({}, rawProps, { "data-precedence": rawProps.precedence, @@ -7121,27 +6918,6 @@ function adoptPreloadPropsForStylesheetProps(resourceProps, preloadProps) { resourceProps.integrity = preloadProps.integrity; } -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} - -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - type: "module", - async: true, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function adoptPreloadPropsForScriptProps(resourceProps, preloadProps) { if (resourceProps.crossOrigin == null) resourceProps.crossOrigin = preloadProps.crossOrigin; diff --git a/compiled/facebook-www/ReactDOMServer-dev.modern.js b/compiled/facebook-www/ReactDOMServer-dev.modern.js index ccb6c1180d5a9..681983cdbe44b 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServer-dev.modern.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-modern-868baebb"; +var ReactVersion = "18.3.0-www-modern-78c6f394"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -1848,17 +1848,6 @@ function getValueDescriptorExpectingObjectForWarning(thing) { ? "an empty string" : 'something with type "' + typeof thing + '"'; } -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; @@ -1872,8 +1861,9 @@ var ReactDOMServerDispatcher = { preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; function prepareHostDispatcher() { ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher; @@ -6442,7 +6432,7 @@ function getResourceKey(as, href) { return "[" + as + "]" + href; } -function prefetchDNS(href, options) { +function prefetchDNS(href) { var request = resolveRequest(); if (!request) { @@ -6456,30 +6446,6 @@ function prefetchDNS(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - options.hasOwnProperty("crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - if (typeof href === "string" && href) { var key = getResourceKey("prefetchDNS", href); var resource = resumableState.preconnectsMap.get(key); @@ -6503,7 +6469,7 @@ function prefetchDNS(href, options) { } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = resolveRequest(); if (!request) { @@ -6517,35 +6483,10 @@ function preconnect(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - if (typeof href === "string" && href) { - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; var key = "[preconnect][" + - (crossOrigin === null ? "null" : crossOrigin) + + (typeof crossOrigin === "string" ? crossOrigin : "null") + "]" + href; var resource = resumableState.preconnectsMap.get(key); @@ -6570,7 +6511,7 @@ function preconnect(href, options) { } } -function preload(href, options) { +function preload(href, as, options) { var request = resolveRequest(); if (!request) { @@ -6584,54 +6525,15 @@ function preload(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key; if (as === "image") { // For image preloads the key contains either the imageSrcSet + imageSizes or the href but not // both. This is to prevent identical calls with the same srcSet and sizes to be duplicated // by varying the href. this is an edge case but it is the most correct behavior. - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - key = getImagePreloadKey(href, imageSrcSet, imageSizes); + key = getImagePreloadKey(href, options.imageSrcSet, options.imageSizes); } else { key = getResourceKey(as, href); } @@ -6639,11 +6541,20 @@ function preload(href, options) { var resource = resumableState.preloadsMap.get(key); if (!resource) { + var props = assign( + { + rel: "preload", + href: as === "image" && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + resource = { type: "preload", chunks: [], state: NoState, - props: preloadPropsFromPreloadOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6651,7 +6562,7 @@ function preload(href, options) { if (as === "font") { resumableState.fontPreloads.add(resource); - } else if (as === "image" && options.fetchPriority === "high") { + } else if (as === "image" && resource.props.fetchPriority === "high") { resumableState.highImagePreloads.add(resource); } else { resumableState.bulkPreloads.add(resource); @@ -6675,47 +6586,25 @@ function preloadModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var key = getResourceKey(as, href); var resource = resumableState.preloadsMap.get(key); + var props = assign( + { + rel: "modulepreload", + href: href + }, + options + ); + if (!resource) { resource = { type: "preload", chunks: [], state: NoState, - props: preloadModulePropsFromPreloadModuleOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6726,7 +6615,7 @@ function preloadModule(href, options) { } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = resolveRequest(); if (!request) { @@ -6740,117 +6629,73 @@ function preinit(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options == null || typeof options !== "object") { - error( - "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options.as !== "style" && options.as !== "script") { - error( - 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', - getValueDescriptorExpectingEnumForWarning(options.as) - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var key = getResourceKey(as, href); - var resource = resumableState.stylesMap.get(key); - var precedence = options.precedence || "default"; - - if (!resource) { - var state = NoState; - var preloadResource = resumableState.preloadsMap.get(key); + if (href) { + var as = "style"; + var key = getResourceKey(as, href); + var resource = resumableState.stylesMap.get(key); - if (preloadResource && preloadResource.state & Flushed) { - state = PreloadFlushed; - } + if (!resource) { + precedence = precedence || "default"; + var state = NoState; + var preloadResource = resumableState.preloadsMap.get(key); - resource = { - type: "stylesheet", - chunks: [], - state: state, - props: stylesheetPropsFromPreinitOptions(href, precedence, options) - }; - resumableState.stylesMap.set(key, resource); - var precedenceSet = resumableState.precedences.get(precedence); + if (preloadResource && preloadResource.state & Flushed) { + state = PreloadFlushed; + } - if (!precedenceSet) { - precedenceSet = new Set(); - resumableState.precedences.set(precedence, precedenceSet); - var emptyStyleResource = { - type: "style", - chunks: [], - state: NoState, - props: { - precedence: precedence, - hrefs: [] - } - }; - precedenceSet.add(emptyStyleResource); + var props = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - { - if (resumableState.stylePrecedences.has(precedence)) { - error( - 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', - precedence - ); - } - } + resource = { + type: "stylesheet", + chunks: [], + state: state, + props: props + }; + resumableState.stylesMap.set(key, resource); + var precedenceSet = resumableState.precedences.get(precedence); - resumableState.stylePrecedences.set(precedence, emptyStyleResource); + if (!precedenceSet) { + precedenceSet = new Set(); + resumableState.precedences.set(precedence, precedenceSet); + var emptyStyleResource = { + type: "style", + chunks: [], + state: NoState, + props: { + precedence: precedence, + hrefs: [] } + }; + precedenceSet.add(emptyStyleResource); - precedenceSet.add(resource); - flushResources(request); + { + if (resumableState.stylePrecedences.has(precedence)) { + error( + 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', + precedence + ); + } } - return; + resumableState.stylePrecedences.set(precedence, emptyStyleResource); } - case "script": { - var src = href; - - var _key = getResourceKey(as, src); - - var _resource = resumableState.scriptsMap.get(_key); - - if (!_resource) { - _resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(_key, _resource); - var resourceProps = scriptPropsFromPreinitOptions(src, options); - resumableState.scripts.add(_resource); - pushScriptImpl(_resource.chunks, resourceProps); - flushResources(request); - } - - return; - } + precedenceSet.add(resource); + flushResources(request); } + + return; } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = resolveRequest(); if (!request) { @@ -6864,85 +6709,78 @@ function preinitModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered + var props = assign( + { + src: src, + async: true + }, + options ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); + } - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + return; + } +} - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } +function preinitModuleScript(src, options) { + var request = resolveRequest(); + + if (!request) { + // In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also + // possibly get them from the stack if we are not in an async context. Since we were not able to resolve + // the resources for this call in either case we opt to do nothing. We can consider making this a warning + // but there may be times where calling a function outside of render is intentional (i.e. to warm up data + // fetching) and we don't want to warn in those cases. + return; } - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; + var resumableState = getResumableState(request); - switch (_as) { - case "script": { - var src = href; - var key = getResourceKey(_as, src); - var resource = resumableState.scriptsMap.get(key); + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (!resource) { - resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(key, resource); - var resourceProps = modulePropsFromPreinitModuleOptions(src, options); - resumableState.scripts.add(resource); - pushScriptImpl(resource.chunks, resourceProps); - flushResources(request); - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - return; - } + var props = assign( + { + src: src, + type: "module", + async: true + }, + options + ); + + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); } + + return; } } // This function is only safe to call at Request start time since it assumes // that each script has not already been preloaded. If we find a need to preload @@ -7052,36 +6890,6 @@ function internalPreinitScript(resumableState, src, chunks) { return; } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function preloadAsStylePropsFromProps(href, props) { return { rel: "preload", @@ -7096,17 +6904,6 @@ function preloadAsStylePropsFromProps(href, props) { }; } -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} - function stylesheetPropsFromRawProps(rawProps) { return assign({}, rawProps, { "data-precedence": rawProps.precedence, @@ -7121,27 +6918,6 @@ function adoptPreloadPropsForStylesheetProps(resourceProps, preloadProps) { resourceProps.integrity = preloadProps.integrity; } -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} - -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - type: "module", - async: true, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function adoptPreloadPropsForScriptProps(resourceProps, preloadProps) { if (resourceProps.crossOrigin == null) resourceProps.crossOrigin = preloadProps.crossOrigin; diff --git a/compiled/facebook-www/ReactDOMServer-prod.classic.js b/compiled/facebook-www/ReactDOMServer-prod.classic.js index 21fa79ea7cc80..57b065263e831 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.classic.js +++ b/compiled/facebook-www/ReactDOMServer-prod.classic.js @@ -191,8 +191,9 @@ var isArrayImpl = Array.isArray, preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }, scriptRegex = /(<\/|<)(s)(cript)/gi; function scriptReplacer(match, prefix, s, suffix) { @@ -2139,19 +2140,16 @@ function prefetchDNS(href) { } } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; if ("string" === typeof href && href) { - options = - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : ""; var key = - "[preconnect][" + (null === options ? "null" : options) + "]" + href, + "[preconnect][" + + ("string" === typeof crossOrigin ? crossOrigin : "null") + + "]" + + href, resource = resumableState.preconnectsMap.get(key); resource || ((resource = { type: "preconnect", chunks: [], state: 0, props: null }), @@ -2159,26 +2157,19 @@ function preconnect(href, options) { pushLinkImpl(resource.chunks, { rel: "preconnect", href: href, - crossOrigin: options + crossOrigin: crossOrigin })); resumableState.preconnects.add(resource); enqueueFlush(request); } } } -function preload(href, options) { +function preload(href, as, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key = "image" === as ? getImagePreloadKey(href, options.imageSrcSet, options.imageSizes) @@ -2189,25 +2180,20 @@ function preload(href, options) { type: "preload", chunks: [], state: 0, - props: { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - } + props: assign( + { + rel: "preload", + href: "image" === as && options.imageSrcSet ? void 0 : href, + as: as + }, + options + ) }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); "font" === as ? resumableState.fontPreloads.add(resource) - : "image" === as && "high" === options.fetchPriority + : "image" === as && "high" === resource.props.fetchPriority ? resumableState.highImagePreloads.add(resource) : resumableState.bulkPreloads.add(resource); enqueueFlush(request); @@ -2218,24 +2204,16 @@ function preloadModule(href, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script", - key = "[" + as + "]" + href, + if (href) { + var key = + "[" + + (options && "string" === typeof options.as ? options.as : "script") + + "]" + + href, resource = resumableState.preloadsMap.get(key); + href = assign({ rel: "modulepreload", href: href }, options); resource || - ((resource = { - type: "preload", - chunks: [], - state: 0, - props: { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - } - }), + ((resource = { type: "preload", chunks: [], state: 0, props: href }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); resumableState.bulkPreloads.add(resource); @@ -2243,102 +2221,78 @@ function preloadModule(href, options) { } } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) { - var as = options.as; - switch (as) { - case "style": - var key = "[" + as + "]" + href, - resource = resumableState.stylesMap.get(key); - as = options.precedence || "default"; - if (!resource) { - resource = 0; - var preloadResource = resumableState.preloadsMap.get(key); - preloadResource && preloadResource.state & 3 && (resource = 8); - resource = { - type: "stylesheet", - chunks: [], - state: resource, - props: { - rel: "stylesheet", - href: href, - "data-precedence": as, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - } - }; - resumableState.stylesMap.set(key, resource); - href = resumableState.precedences.get(as); - href || - ((href = new Set()), - resumableState.precedences.set(as, href), - (options = { - type: "style", - chunks: [], - state: 0, - props: { precedence: as, hrefs: [] } - }), - href.add(options), - resumableState.stylePrecedences.set(as, options)); - href.add(resource); - enqueueFlush(request); - } - break; - case "script": - (key = "[" + as + "]" + href), - (as = resumableState.scriptsMap.get(key)), - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); + if (href) { + var key = "[style]" + href, + resource = resumableState.stylesMap.get(key); + if (!resource) { + precedence = precedence || "default"; + resource = 0; + var preloadResource = resumableState.preloadsMap.get(key); + preloadResource && preloadResource.state & 3 && (resource = 8); + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + resource = { + type: "stylesheet", + chunks: [], + state: resource, + props: href + }; + resumableState.stylesMap.set(key, resource); + key = resumableState.precedences.get(precedence); + key || + ((key = new Set()), + resumableState.precedences.set(precedence, key), + (href = { + type: "style", + chunks: [], + state: 0, + props: { precedence: precedence, hrefs: [] } + }), + key.add(href), + resumableState.stylePrecedences.set(precedence, href)); + key.add(resource); + enqueueFlush(request); } } } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script"; - switch (as) { - case "script": - var key = "[" + as + "]" + href; - as = resumableState.scriptsMap.get(key); - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - type: "module", - async: !0, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); - } + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); + } + } +} +function preinitModuleScript(src, options) { + var request = currentRequest ? currentRequest : null; + if (request) { + var resumableState = request.resumableState; + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, type: "module", async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); } } } @@ -3577,13 +3531,13 @@ function renderChildrenArray(request, task, children, childIndex) { if ((prevKeyPath = prevKeyPath.call(node))) { node = prevKeyPath.next(); if (!node.done) { - var prevKeyPath$13 = task.keyPath; + var prevKeyPath$11 = task.keyPath; task.keyPath = [task.keyPath, "", childIndex]; var nestedChildren = []; do nestedChildren.push(node.value), (node = prevKeyPath.next()); while (!node.done); renderChildrenArray(request, task, nestedChildren, i); - task.keyPath = prevKeyPath$13; + task.keyPath = prevKeyPath$11; } continue; } @@ -4318,13 +4272,13 @@ function flushCompletedQueues(request, destination) { completedBoundaries.splice(0, i); var partialBoundaries = request.partialBoundaries; for (i = 0; i < partialBoundaries.length; i++) { - var boundary$16 = partialBoundaries[i]; + var boundary$14 = partialBoundaries[i]; a: { clientRenderedBoundaries = request; boundary = destination; clientRenderedBoundaries.renderState.boundaryResources = - boundary$16.resources; - var completedSegments = boundary$16.completedSegments; + boundary$14.resources; + var completedSegments = boundary$14.completedSegments; for ( resumableState$jscomp$1 = 0; resumableState$jscomp$1 < completedSegments.length; @@ -4334,7 +4288,7 @@ function flushCompletedQueues(request, destination) { !flushPartiallyCompletedSegment( clientRenderedBoundaries, boundary, - boundary$16, + boundary$14, completedSegments[resumableState$jscomp$1] ) ) { @@ -4346,7 +4300,7 @@ function flushCompletedQueues(request, destination) { completedSegments.splice(0, resumableState$jscomp$1); JSCompiler_inline_result = writeResourcesForBoundary( boundary, - boundary$16.resources, + boundary$14.resources, clientRenderedBoundaries.renderState ); } @@ -4409,8 +4363,8 @@ function abort(request, reason) { } null !== request.destination && flushCompletedQueues(request, request.destination); - } catch (error$18) { - logRecoverableError(request, error$18), fatalError(request, error$18); + } catch (error$16) { + logRecoverableError(request, error$16), fatalError(request, error$16); } } function onError() {} @@ -4497,4 +4451,4 @@ exports.renderToString = function (children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-classic-c0d5e385"; +exports.version = "18.3.0-www-classic-8c553ebd"; diff --git a/compiled/facebook-www/ReactDOMServer-prod.modern.js b/compiled/facebook-www/ReactDOMServer-prod.modern.js index 14957e4049100..83f404b829d16 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServer-prod.modern.js @@ -191,8 +191,9 @@ var isArrayImpl = Array.isArray, preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }, scriptRegex = /(<\/|<)(s)(cript)/gi; function scriptReplacer(match, prefix, s, suffix) { @@ -2139,19 +2140,16 @@ function prefetchDNS(href) { } } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; if ("string" === typeof href && href) { - options = - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : ""; var key = - "[preconnect][" + (null === options ? "null" : options) + "]" + href, + "[preconnect][" + + ("string" === typeof crossOrigin ? crossOrigin : "null") + + "]" + + href, resource = resumableState.preconnectsMap.get(key); resource || ((resource = { type: "preconnect", chunks: [], state: 0, props: null }), @@ -2159,26 +2157,19 @@ function preconnect(href, options) { pushLinkImpl(resource.chunks, { rel: "preconnect", href: href, - crossOrigin: options + crossOrigin: crossOrigin })); resumableState.preconnects.add(resource); enqueueFlush(request); } } } -function preload(href, options) { +function preload(href, as, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key = "image" === as ? getImagePreloadKey(href, options.imageSrcSet, options.imageSizes) @@ -2189,25 +2180,20 @@ function preload(href, options) { type: "preload", chunks: [], state: 0, - props: { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - } + props: assign( + { + rel: "preload", + href: "image" === as && options.imageSrcSet ? void 0 : href, + as: as + }, + options + ) }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); "font" === as ? resumableState.fontPreloads.add(resource) - : "image" === as && "high" === options.fetchPriority + : "image" === as && "high" === resource.props.fetchPriority ? resumableState.highImagePreloads.add(resource) : resumableState.bulkPreloads.add(resource); enqueueFlush(request); @@ -2218,24 +2204,16 @@ function preloadModule(href, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script", - key = "[" + as + "]" + href, + if (href) { + var key = + "[" + + (options && "string" === typeof options.as ? options.as : "script") + + "]" + + href, resource = resumableState.preloadsMap.get(key); + href = assign({ rel: "modulepreload", href: href }, options); resource || - ((resource = { - type: "preload", - chunks: [], - state: 0, - props: { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - } - }), + ((resource = { type: "preload", chunks: [], state: 0, props: href }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); resumableState.bulkPreloads.add(resource); @@ -2243,102 +2221,78 @@ function preloadModule(href, options) { } } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) { - var as = options.as; - switch (as) { - case "style": - var key = "[" + as + "]" + href, - resource = resumableState.stylesMap.get(key); - as = options.precedence || "default"; - if (!resource) { - resource = 0; - var preloadResource = resumableState.preloadsMap.get(key); - preloadResource && preloadResource.state & 3 && (resource = 8); - resource = { - type: "stylesheet", - chunks: [], - state: resource, - props: { - rel: "stylesheet", - href: href, - "data-precedence": as, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - } - }; - resumableState.stylesMap.set(key, resource); - href = resumableState.precedences.get(as); - href || - ((href = new Set()), - resumableState.precedences.set(as, href), - (options = { - type: "style", - chunks: [], - state: 0, - props: { precedence: as, hrefs: [] } - }), - href.add(options), - resumableState.stylePrecedences.set(as, options)); - href.add(resource); - enqueueFlush(request); - } - break; - case "script": - (key = "[" + as + "]" + href), - (as = resumableState.scriptsMap.get(key)), - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); + if (href) { + var key = "[style]" + href, + resource = resumableState.stylesMap.get(key); + if (!resource) { + precedence = precedence || "default"; + resource = 0; + var preloadResource = resumableState.preloadsMap.get(key); + preloadResource && preloadResource.state & 3 && (resource = 8); + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + resource = { + type: "stylesheet", + chunks: [], + state: resource, + props: href + }; + resumableState.stylesMap.set(key, resource); + key = resumableState.precedences.get(precedence); + key || + ((key = new Set()), + resumableState.precedences.set(precedence, key), + (href = { + type: "style", + chunks: [], + state: 0, + props: { precedence: precedence, hrefs: [] } + }), + key.add(href), + resumableState.stylePrecedences.set(precedence, href)); + key.add(resource); + enqueueFlush(request); } } } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script"; - switch (as) { - case "script": - var key = "[" + as + "]" + href; - as = resumableState.scriptsMap.get(key); - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - type: "module", - async: !0, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); - } + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); + } + } +} +function preinitModuleScript(src, options) { + var request = currentRequest ? currentRequest : null; + if (request) { + var resumableState = request.resumableState; + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, type: "module", async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); } } } @@ -3551,13 +3505,13 @@ function renderChildrenArray(request, task, children, childIndex) { if ((prevKeyPath = prevKeyPath.call(node))) { node = prevKeyPath.next(); if (!node.done) { - var prevKeyPath$13 = task.keyPath; + var prevKeyPath$11 = task.keyPath; task.keyPath = [task.keyPath, "", childIndex]; var nestedChildren = []; do nestedChildren.push(node.value), (node = prevKeyPath.next()); while (!node.done); renderChildrenArray(request, task, nestedChildren, i); - task.keyPath = prevKeyPath$13; + task.keyPath = prevKeyPath$11; } continue; } @@ -4292,13 +4246,13 @@ function flushCompletedQueues(request, destination) { completedBoundaries.splice(0, i); var partialBoundaries = request.partialBoundaries; for (i = 0; i < partialBoundaries.length; i++) { - var boundary$16 = partialBoundaries[i]; + var boundary$14 = partialBoundaries[i]; a: { clientRenderedBoundaries = request; boundary = destination; clientRenderedBoundaries.renderState.boundaryResources = - boundary$16.resources; - var completedSegments = boundary$16.completedSegments; + boundary$14.resources; + var completedSegments = boundary$14.completedSegments; for ( resumableState$jscomp$1 = 0; resumableState$jscomp$1 < completedSegments.length; @@ -4308,7 +4262,7 @@ function flushCompletedQueues(request, destination) { !flushPartiallyCompletedSegment( clientRenderedBoundaries, boundary, - boundary$16, + boundary$14, completedSegments[resumableState$jscomp$1] ) ) { @@ -4320,7 +4274,7 @@ function flushCompletedQueues(request, destination) { completedSegments.splice(0, resumableState$jscomp$1); JSCompiler_inline_result = writeResourcesForBoundary( boundary, - boundary$16.resources, + boundary$14.resources, clientRenderedBoundaries.renderState ); } @@ -4383,8 +4337,8 @@ function abort(request, reason) { } null !== request.destination && flushCompletedQueues(request, request.destination); - } catch (error$18) { - logRecoverableError(request, error$18), fatalError(request, error$18); + } catch (error$16) { + logRecoverableError(request, error$16), fatalError(request, error$16); } } function onError() {} @@ -4471,4 +4425,4 @@ exports.renderToString = function (children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-modern-2eb07bc4"; +exports.version = "18.3.0-www-modern-aeba0586"; diff --git a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js index 720db324d4cdd..20e3aa67fb4b7 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js @@ -1845,17 +1845,6 @@ function getValueDescriptorExpectingObjectForWarning(thing) { ? "an empty string" : 'something with type "' + typeof thing + '"'; } -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; @@ -1869,8 +1858,9 @@ var ReactDOMServerDispatcher = { preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; function prepareHostDispatcher() { ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher; @@ -6436,7 +6426,7 @@ function getResourceKey(as, href) { return "[" + as + "]" + href; } -function prefetchDNS(href, options) { +function prefetchDNS(href) { var request = resolveRequest(); if (!request) { @@ -6450,30 +6440,6 @@ function prefetchDNS(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - options.hasOwnProperty("crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - if (typeof href === "string" && href) { var key = getResourceKey("prefetchDNS", href); var resource = resumableState.preconnectsMap.get(key); @@ -6497,7 +6463,7 @@ function prefetchDNS(href, options) { } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = resolveRequest(); if (!request) { @@ -6511,35 +6477,10 @@ function preconnect(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - if (typeof href === "string" && href) { - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; var key = "[preconnect][" + - (crossOrigin === null ? "null" : crossOrigin) + + (typeof crossOrigin === "string" ? crossOrigin : "null") + "]" + href; var resource = resumableState.preconnectsMap.get(key); @@ -6564,7 +6505,7 @@ function preconnect(href, options) { } } -function preload(href, options) { +function preload(href, as, options) { var request = resolveRequest(); if (!request) { @@ -6578,54 +6519,15 @@ function preload(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key; if (as === "image") { // For image preloads the key contains either the imageSrcSet + imageSizes or the href but not // both. This is to prevent identical calls with the same srcSet and sizes to be duplicated // by varying the href. this is an edge case but it is the most correct behavior. - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - key = getImagePreloadKey(href, imageSrcSet, imageSizes); + key = getImagePreloadKey(href, options.imageSrcSet, options.imageSizes); } else { key = getResourceKey(as, href); } @@ -6633,11 +6535,20 @@ function preload(href, options) { var resource = resumableState.preloadsMap.get(key); if (!resource) { + var props = assign( + { + rel: "preload", + href: as === "image" && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + resource = { type: "preload", chunks: [], state: NoState, - props: preloadPropsFromPreloadOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6645,7 +6556,7 @@ function preload(href, options) { if (as === "font") { resumableState.fontPreloads.add(resource); - } else if (as === "image" && options.fetchPriority === "high") { + } else if (as === "image" && resource.props.fetchPriority === "high") { resumableState.highImagePreloads.add(resource); } else { resumableState.bulkPreloads.add(resource); @@ -6669,47 +6580,25 @@ function preloadModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var key = getResourceKey(as, href); var resource = resumableState.preloadsMap.get(key); + var props = assign( + { + rel: "modulepreload", + href: href + }, + options + ); + if (!resource) { resource = { type: "preload", chunks: [], state: NoState, - props: preloadModulePropsFromPreloadModuleOptions(href, as, options) + props: props }; resumableState.preloadsMap.set(key, resource); pushLinkImpl(resource.chunks, resource.props); @@ -6720,7 +6609,7 @@ function preloadModule(href, options) { } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = resolveRequest(); if (!request) { @@ -6734,117 +6623,73 @@ function preinit(href, options) { var resumableState = getResumableState(request); - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options == null || typeof options !== "object") { - error( - "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options.as !== "style" && options.as !== "script") { - error( - 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', - getValueDescriptorExpectingEnumForWarning(options.as) - ); - } - } - - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var key = getResourceKey(as, href); - var resource = resumableState.stylesMap.get(key); - var precedence = options.precedence || "default"; - - if (!resource) { - var state = NoState; - var preloadResource = resumableState.preloadsMap.get(key); + if (href) { + var as = "style"; + var key = getResourceKey(as, href); + var resource = resumableState.stylesMap.get(key); - if (preloadResource && preloadResource.state & Flushed) { - state = PreloadFlushed; - } + if (!resource) { + precedence = precedence || "default"; + var state = NoState; + var preloadResource = resumableState.preloadsMap.get(key); - resource = { - type: "stylesheet", - chunks: [], - state: state, - props: stylesheetPropsFromPreinitOptions(href, precedence, options) - }; - resumableState.stylesMap.set(key, resource); - var precedenceSet = resumableState.precedences.get(precedence); + if (preloadResource && preloadResource.state & Flushed) { + state = PreloadFlushed; + } - if (!precedenceSet) { - precedenceSet = new Set(); - resumableState.precedences.set(precedence, precedenceSet); - var emptyStyleResource = { - type: "style", - chunks: [], - state: NoState, - props: { - precedence: precedence, - hrefs: [] - } - }; - precedenceSet.add(emptyStyleResource); + var props = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - { - if (resumableState.stylePrecedences.has(precedence)) { - error( - 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', - precedence - ); - } - } + resource = { + type: "stylesheet", + chunks: [], + state: state, + props: props + }; + resumableState.stylesMap.set(key, resource); + var precedenceSet = resumableState.precedences.get(precedence); - resumableState.stylePrecedences.set(precedence, emptyStyleResource); + if (!precedenceSet) { + precedenceSet = new Set(); + resumableState.precedences.set(precedence, precedenceSet); + var emptyStyleResource = { + type: "style", + chunks: [], + state: NoState, + props: { + precedence: precedence, + hrefs: [] } + }; + precedenceSet.add(emptyStyleResource); - precedenceSet.add(resource); - flushResources(request); + { + if (resumableState.stylePrecedences.has(precedence)) { + error( + 'React constructed an empty style resource when a style resource already exists for this precedence: "%s". This is a bug in React.', + precedence + ); + } } - return; + resumableState.stylePrecedences.set(precedence, emptyStyleResource); } - case "script": { - var src = href; - - var _key = getResourceKey(as, src); - - var _resource = resumableState.scriptsMap.get(_key); - - if (!_resource) { - _resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(_key, _resource); - var resourceProps = scriptPropsFromPreinitOptions(src, options); - resumableState.scripts.add(_resource); - pushScriptImpl(_resource.chunks, resourceProps); - flushResources(request); - } - - return; - } + precedenceSet.add(resource); + flushResources(request); } + + return; } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = resolveRequest(); if (!request) { @@ -6858,85 +6703,78 @@ function preinitModule(href, options) { var resumableState = getResumableState(request); - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered + var props = assign( + { + src: src, + async: true + }, + options ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); + } - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + return; + } +} - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } +function preinitModuleScript(src, options) { + var request = resolveRequest(); + + if (!request) { + // In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also + // possibly get them from the stack if we are not in an async context. Since we were not able to resolve + // the resources for this call in either case we opt to do nothing. We can consider making this a warning + // but there may be times where calling a function outside of render is intentional (i.e. to warm up data + // fetching) and we don't want to warn in those cases. + return; } - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; + var resumableState = getResumableState(request); - switch (_as) { - case "script": { - var src = href; - var key = getResourceKey(_as, src); - var resource = resumableState.scriptsMap.get(key); + if (src) { + var key = getResourceKey("script", src); + var resource = resumableState.scriptsMap.get(key); - if (!resource) { - resource = { - type: "script", - chunks: [], - state: NoState, - props: null - }; - resumableState.scriptsMap.set(key, resource); - var resourceProps = modulePropsFromPreinitModuleOptions(src, options); - resumableState.scripts.add(resource); - pushScriptImpl(resource.chunks, resourceProps); - flushResources(request); - } + if (!resource) { + resource = { + type: "script", + chunks: [], + state: NoState, + props: null + }; + resumableState.scriptsMap.set(key, resource); - return; - } + var props = assign( + { + src: src, + type: "module", + async: true + }, + options + ); + + resumableState.scripts.add(resource); + pushScriptImpl(resource.chunks, props); + flushResources(request); } + + return; } } // This function is only safe to call at Request start time since it assumes // that each script has not already been preloaded. If we find a need to preload @@ -7046,36 +6884,6 @@ function internalPreinitScript(resumableState, src, chunks) { return; } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function preloadAsStylePropsFromProps(href, props) { return { rel: "preload", @@ -7090,17 +6898,6 @@ function preloadAsStylePropsFromProps(href, props) { }; } -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} - function stylesheetPropsFromRawProps(rawProps) { return assign({}, rawProps, { "data-precedence": rawProps.precedence, @@ -7115,27 +6912,6 @@ function adoptPreloadPropsForStylesheetProps(resourceProps, preloadProps) { resourceProps.integrity = preloadProps.integrity; } -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} - -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - type: "module", - async: true, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - function adoptPreloadPropsForScriptProps(resourceProps, preloadProps) { if (resourceProps.crossOrigin == null) resourceProps.crossOrigin = preloadProps.crossOrigin; diff --git a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js index 9c15647472089..f4c323a977df6 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js @@ -182,8 +182,9 @@ var isArrayImpl = Array.isArray, preconnect: preconnect, preload: preload, preloadModule: preloadModule, - preinit: preinit, - preinitModule: preinitModule + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }, scriptRegex = /(<\/|<)(s)(cript)/gi; function scriptReplacer(match, prefix, s, suffix) { @@ -2003,19 +2004,16 @@ function prefetchDNS(href) { } } } -function preconnect(href, options) { +function preconnect(href, crossOrigin) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; if ("string" === typeof href && href) { - options = - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : ""; var key = - "[preconnect][" + (null === options ? "null" : options) + "]" + href, + "[preconnect][" + + ("string" === typeof crossOrigin ? crossOrigin : "null") + + "]" + + href, resource = resumableState.preconnectsMap.get(key); resource || ((resource = { type: "preconnect", chunks: [], state: 0, props: null }), @@ -2023,26 +2021,19 @@ function preconnect(href, options) { pushLinkImpl(resource.chunks, { rel: "preconnect", href: href, - crossOrigin: options + crossOrigin: crossOrigin })); resumableState.preconnects.add(resource); enqueueFlush(request); } } } -function preload(href, options) { +function preload(href, as, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as - ) { - var as = options.as; + if (as && href) { + options = options || {}; var key = "image" === as ? getImagePreloadKey(href, options.imageSrcSet, options.imageSizes) @@ -2053,25 +2044,20 @@ function preload(href, options) { type: "preload", chunks: [], state: 0, - props: { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - } + props: assign( + { + rel: "preload", + href: "image" === as && options.imageSrcSet ? void 0 : href, + as: as + }, + options + ) }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); "font" === as ? resumableState.fontPreloads.add(resource) - : "image" === as && "high" === options.fetchPriority + : "image" === as && "high" === resource.props.fetchPriority ? resumableState.highImagePreloads.add(resource) : resumableState.bulkPreloads.add(resource); enqueueFlush(request); @@ -2082,24 +2068,16 @@ function preloadModule(href, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script", - key = "[" + as + "]" + href, + if (href) { + var key = + "[" + + (options && "string" === typeof options.as ? options.as : "script") + + "]" + + href, resource = resumableState.preloadsMap.get(key); + href = assign({ rel: "modulepreload", href: href }, options); resource || - ((resource = { - type: "preload", - chunks: [], - state: 0, - props: { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - } - }), + ((resource = { type: "preload", chunks: [], state: 0, props: href }), resumableState.preloadsMap.set(key, resource), pushLinkImpl(resource.chunks, resource.props)); resumableState.bulkPreloads.add(resource); @@ -2107,102 +2085,78 @@ function preloadModule(href, options) { } } } -function preinit(href, options) { +function preinitStyle(href, precedence, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) { - var as = options.as; - switch (as) { - case "style": - var key = "[" + as + "]" + href, - resource = resumableState.stylesMap.get(key); - as = options.precedence || "default"; - if (!resource) { - resource = 0; - var preloadResource = resumableState.preloadsMap.get(key); - preloadResource && preloadResource.state & 3 && (resource = 8); - resource = { - type: "stylesheet", - chunks: [], - state: resource, - props: { - rel: "stylesheet", - href: href, - "data-precedence": as, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - } - }; - resumableState.stylesMap.set(key, resource); - href = resumableState.precedences.get(as); - href || - ((href = new Set()), - resumableState.precedences.set(as, href), - (options = { - type: "style", - chunks: [], - state: 0, - props: { precedence: as, hrefs: [] } - }), - href.add(options), - resumableState.stylePrecedences.set(as, options)); - href.add(resource); - enqueueFlush(request); - } - break; - case "script": - (key = "[" + as + "]" + href), - (as = resumableState.scriptsMap.get(key)), - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); + if (href) { + var key = "[style]" + href, + resource = resumableState.stylesMap.get(key); + if (!resource) { + precedence = precedence || "default"; + resource = 0; + var preloadResource = resumableState.preloadsMap.get(key); + preloadResource && preloadResource.state & 3 && (resource = 8); + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + resource = { + type: "stylesheet", + chunks: [], + state: resource, + props: href + }; + resumableState.stylesMap.set(key, resource); + key = resumableState.precedences.get(precedence); + key || + ((key = new Set()), + resumableState.precedences.set(precedence, key), + (href = { + type: "style", + chunks: [], + state: 0, + props: { precedence: precedence, hrefs: [] } + }), + key.add(href), + resumableState.stylePrecedences.set(precedence, href)); + key.add(resource); + enqueueFlush(request); } } } } -function preinitModule(href, options) { +function preinitScript(src, options) { var request = currentRequest ? currentRequest : null; if (request) { var resumableState = request.resumableState; - if ("string" === typeof href && href) { - var as = - options && "string" === typeof options.as ? options.as : "script"; - switch (as) { - case "script": - var key = "[" + as + "]" + href; - as = resumableState.scriptsMap.get(key); - as || - ((as = { type: "script", chunks: [], state: 0, props: null }), - resumableState.scriptsMap.set(key, as), - (href = { - src: href, - type: "module", - async: !0, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - resumableState.scripts.add(as), - pushScriptImpl(as.chunks, href), - enqueueFlush(request)); - } + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); + } + } +} +function preinitModuleScript(src, options) { + var request = currentRequest ? currentRequest : null; + if (request) { + var resumableState = request.resumableState; + if (src) { + var key = "[script]" + src, + resource = resumableState.scriptsMap.get(key); + resource || + ((resource = { type: "script", chunks: [], state: 0, props: null }), + resumableState.scriptsMap.set(key, resource), + (src = assign({ src: src, type: "module", async: !0 }, options)), + resumableState.scripts.add(resource), + pushScriptImpl(resource.chunks, src), + enqueueFlush(request)); } } } @@ -3352,13 +3306,13 @@ function renderChildrenArray(request, task, children, childIndex) { if ((prevKeyPath = prevKeyPath.call(node))) { node = prevKeyPath.next(); if (!node.done) { - var prevKeyPath$13 = task.keyPath; + var prevKeyPath$11 = task.keyPath; task.keyPath = [task.keyPath, "", childIndex]; var nestedChildren = []; do nestedChildren.push(node.value), (node = prevKeyPath.next()); while (!node.done); renderChildrenArray(request, task, nestedChildren, i); - task.keyPath = prevKeyPath$13; + task.keyPath = prevKeyPath$11; } continue; } @@ -3992,13 +3946,13 @@ function flushCompletedQueues(request, destination) { completedBoundaries.splice(0, i); var partialBoundaries = request.partialBoundaries; for (i = 0; i < partialBoundaries.length; i++) { - var boundary$16 = partialBoundaries[i]; + var boundary$14 = partialBoundaries[i]; a: { clientRenderedBoundaries = request; boundary = destination; clientRenderedBoundaries.renderState.boundaryResources = - boundary$16.resources; - var completedSegments = boundary$16.completedSegments; + boundary$14.resources; + var completedSegments = boundary$14.completedSegments; for ( resumableState$jscomp$1 = 0; resumableState$jscomp$1 < completedSegments.length; @@ -4008,7 +3962,7 @@ function flushCompletedQueues(request, destination) { !flushPartiallyCompletedSegment( clientRenderedBoundaries, boundary, - boundary$16, + boundary$14, completedSegments[resumableState$jscomp$1] ) ) { @@ -4020,7 +3974,7 @@ function flushCompletedQueues(request, destination) { completedSegments.splice(0, resumableState$jscomp$1); JSCompiler_inline_result = writeResourcesForBoundary( boundary, - boundary$16.resources, + boundary$14.resources, clientRenderedBoundaries.renderState ); } @@ -4080,8 +4034,8 @@ function abort(request, reason) { } null !== request.destination && flushCompletedQueues(request, request.destination); - } catch (error$18) { - logRecoverableError(request, error$18), fatalError(request, error$18); + } catch (error$16) { + logRecoverableError(request, error$16), fatalError(request, error$16); } } exports.abortStream = function (stream) { diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index d6ae5210071cb..8d7539955f2e0 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -34626,7 +34626,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-d80c0530"; +var ReactVersion = "18.3.0-www-classic-f857f390"; function createPortal$1( children, @@ -42516,70 +42516,6 @@ function propNamesListJoin(list, combinator) { } } -function validatePreinitArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); - - error( - "ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg - ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg, - href - ); - } else { - var as = options.as; - - switch (as) { - case "style": - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + - ' and "script". The href for the preinit call where this warning originated is "%s".', - typeOfAs, - href - ); - } - } - } - } -} -function getValueDescriptorExpectingObjectForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : 'something with type "' + typeof thing + '"'; -} -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} - var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning"; var SUSPENSE_START_DATA = "$"; var SUSPENSE_END_DATA = "/$"; @@ -44181,8 +44117,9 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; // We expect this to get inlined. It is a function mostly to communicate the special nature of // how we resolve the HoistableRoot for ReactDOM.pre*() methods. Because we support calling // these methods outside of render there is no way to know which Document or ShadowRoot is 'scoped' @@ -44194,7 +44131,7 @@ function getDocumentForImperativeFloatMethods() { return document; } -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = getDocumentForImperativeFloatMethods(); if (typeof href === "string" && href) { @@ -44224,127 +44161,34 @@ function preconnectAs(rel, crossOrigin, href) { } } -function prefetchDNS$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - hasOwnProperty.call(options, "crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - - preconnectAs("dns-prefetch", null, href); +function prefetchDNS$1(href) { + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; - preconnectAs("preconnect", crossOrigin, href); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { - { - // TODO move this to ReactDOMFloat and expose a stricter function interface or possibly - // typed functions (preloadImage, preloadStyle, ...) - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - "The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - "The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - "The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag. %s', - encountered - ); - } - } - +function preload$1(href, as, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as && - ownerDocument - ) { - var as = options.as; + if (href && as && ownerDocument) { var preloadSelector = 'link[rel="preload"][as="' + escapeSelectorAttributeValueInsideDoubleQuotes(as) + '"]'; if (as === "image") { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - - if (typeof imageSrcSet === "string" && imageSrcSet !== "") { + if (options && options.imageSrcSet) { preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSrcSet) + '"]'; - if (typeof imageSizes === "string") { + if (typeof options.imageSizes === "string") { preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSizes) + '"]'; } } else { @@ -44373,7 +44217,20 @@ function preload$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadPropsFromPreloadOptions(href, as, options); + var preloadProps = assign( + { + rel: "preload", + // There is a bug in Safari where imageSrcSet is not respected on preload links + // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. + // This harms older browers that do not support imageSrcSet by making their preloads not work + // but this population is shrinking fast and is already small so we accept this tradeoff. + href: + as === "image" && options && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + preloadPropsMap.set(key, preloadProps); if (null === ownerDocument.querySelector(preloadSelector)) { @@ -44401,39 +44258,9 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var preloadSelector = 'link[rel="modulepreload"][as="' + @@ -44459,12 +44286,15 @@ function preloadModule$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadModulePropsFromPreloadModuleOptions( - href, - as, + var props = assign( + { + rel: "modulepreload", + href: href + }, options ); - preloadPropsMap.set(key, preloadProps); + + preloadPropsMap.set(key, props); if (null === ownerDocument.querySelector(preloadSelector)) { switch (as) { @@ -44481,7 +44311,7 @@ function preloadModule$1(href, options) { } var instance = ownerDocument.createElement("link"); - setInitialProperties(instance, "link", preloadProps); + setInitialProperties(instance, "link", props); markNodeAsHoistable(instance); ownerDocument.head.appendChild(instance); } @@ -44489,299 +44319,177 @@ function preloadModule$1(href, options) { } } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - -function preinit$1(href, options) { - { - validatePreinitArguments(href, options); - } - +function preinitStyle(href, precedence, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; - var key = getStyleKey(href); - var precedence = options.precedence || "default"; // Check if this resource already exists + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; + var key = getStyleKey(href); + precedence = precedence || "default"; // Check if this resource already exists - var resource = styles.get(key); + var resource = styles.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } - var state = { - loading: NotLoaded, - preload: null - }; // Attempt to hydrate instance from DOM + var state = { + loading: NotLoaded, + preload: null + }; // Attempt to hydrate instance from DOM - var instance = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - ); + var instance = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + ); - if (instance) { - state.loading = Loaded; - } else { - // Construct a new instance and insert it - var stylesheetProps = stylesheetPropsFromPreinitOptions( - href, - precedence, - options - ); - var preloadProps = preloadPropsMap.get(key); + if (instance) { + state.loading = Loaded; + } else { + // Construct a new instance and insert it + var stylesheetProps = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - if (preloadProps) { - adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - var link = (instance = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", stylesheetProps); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= Loaded; - }); - link.addEventListener("error", function () { - state.loading |= Errored; - }); - state.loading |= Inserted; - insertStylesheet(instance, precedence, ownerDocument); - } // Construct a Resource and cache it - - resource = { - type: "stylesheet", - instance: instance, - count: 1, - state: state - }; - styles.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); } - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var link = (instance = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", stylesheetProps); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= Loaded; + }); + link.addEventListener("error", function () { + state.loading |= Errored; + }); + state.loading |= Inserted; + insertStylesheet(instance, precedence, ownerDocument); + } // Construct a Resource and cache it + + resource = { + type: "stylesheet", + instance: instance, + count: 1, + state: state + }; + styles.set(key, resource); + return; + } +} - var _key = getScriptKey(src); // Check if this resource already exists +function preinitScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - var _resource = scripts.get(_key); + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (_resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var _instance = ownerDocument.querySelector( - getScriptSelectorFromKey(_key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!_instance) { - // Construct a new instance and insert it - var scriptProps = scriptPropsFromPreinitOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var _preloadProps = preloadPropsMap.get(_key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true + }, + options + ); // Adopt certain preload props - if (_preloadProps) { - adoptPreloadPropsForScript(scriptProps, _preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - _instance = ownerDocument.createElement("script"); - markNodeAsHoistable(_instance); - setInitialProperties(_instance, "link", scriptProps); - ownerDocument.head.appendChild(_instance); - } // Construct a Resource and cache it - - _resource = { - type: "script", - instance: _instance, - count: 1, - state: null - }; - scripts.set(_key, _resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} -function preinitModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } - - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered - ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; } +} +function preinitModuleScript(src, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; - - switch (_as) { - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; - var key = getScriptKey(src); // Check if this resource already exists + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - var resource = scripts.get(key); - - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var instance = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!instance) { - // Construct a new instance and insert it - var scriptProps = modulePropsFromPreinitModuleOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var preloadProps = preloadPropsMap.get(key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true, + type: "module" + }, + options + ); // Adopt certain preload props - if (preloadProps) { - adoptPreloadPropsForScript(scriptProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - instance = ownerDocument.createElement("script"); - markNodeAsHoistable(instance); - setInitialProperties(instance, "link", scriptProps); - ownerDocument.head.appendChild(instance); - } // Construct a Resource and cache it - - resource = { - type: "script", - instance: instance, - count: 1, - state: null - }; - scripts.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} - -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - async: true, - type: "module", - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; + } } // This function is called in begin work and we should always have a currentDocument set function getResource(type, currentProps, pendingProps) { @@ -44837,16 +44545,16 @@ function getResource(type, currentProps, pendingProps) { ) { var qualifiedProps = pendingProps; - var _key2 = getStyleKey(qualifiedProps.href); + var _key = getStyleKey(qualifiedProps.href); var _styles = getResourcesFromRoot(resourceRoot).hoistableStyles; - var _resource2 = _styles.get(_key2); + var _resource = _styles.get(_key); - if (!_resource2) { + if (!_resource) { // We asserted this above but Flow can't figure out that the type satisfies var ownerDocument = getDocumentFromRoot(resourceRoot); - _resource2 = { + _resource = { type: "stylesheet", instance: null, count: 0, @@ -44856,19 +44564,19 @@ function getResource(type, currentProps, pendingProps) { } }; - _styles.set(_key2, _resource2); + _styles.set(_key, _resource); - if (!preloadPropsMap.has(_key2)) { + if (!preloadPropsMap.has(_key)) { preloadStylesheet( ownerDocument, - _key2, + _key, preloadPropsFromStylesheet(qualifiedProps), - _resource2.state + _resource.state ); } } - return _resource2; + return _resource; } return null; @@ -44878,23 +44586,23 @@ function getResource(type, currentProps, pendingProps) { if (typeof pendingProps.src === "string" && pendingProps.async === true) { var scriptProps = pendingProps; - var _key3 = getScriptKey(scriptProps.src); + var _key2 = getScriptKey(scriptProps.src); var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; - var _resource3 = scripts.get(_key3); + var _resource2 = scripts.get(_key2); - if (!_resource3) { - _resource3 = { + if (!_resource2) { + _resource2 = { type: "script", instance: null, count: 0, state: null }; - scripts.set(_key3, _resource3); + scripts.set(_key2, _resource2); } - return _resource3; + return _resource2; } return { @@ -45041,14 +44749,14 @@ function acquireResource(hoistableRoot, resource, props) { var _qualifiedProps = props; var key = getStyleKey(_qualifiedProps.href); // Attempt to hydrate instance from DOM - var _instance2 = hoistableRoot.querySelector( + var _instance = hoistableRoot.querySelector( getStylesheetSelectorFromKey(key) ); - if (_instance2) { - resource.instance = _instance2; - markNodeAsHoistable(_instance2); - return _instance2; + if (_instance) { + resource.instance = _instance; + markNodeAsHoistable(_instance); + return _instance; } var stylesheetProps = stylesheetPropsFromRawProps(props); @@ -45060,18 +44768,18 @@ function acquireResource(hoistableRoot, resource, props) { var _ownerDocument = getDocumentFromRoot(hoistableRoot); - _instance2 = _ownerDocument.createElement("link"); - markNodeAsHoistable(_instance2); - var linkInstance = _instance2; + _instance = _ownerDocument.createElement("link"); + markNodeAsHoistable(_instance); + var linkInstance = _instance; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(_instance2, "link", stylesheetProps); + setInitialProperties(_instance, "link", stylesheetProps); resource.state.loading |= Inserted; - insertStylesheet(_instance2, _qualifiedProps.precedence, hoistableRoot); - resource.instance = _instance2; - return _instance2; + insertStylesheet(_instance, _qualifiedProps.precedence, hoistableRoot); + resource.instance = _instance; + return _instance; } case "script": { @@ -45080,37 +44788,37 @@ function acquireResource(hoistableRoot, resource, props) { // this cast still makes sense; var borrowedScriptProps = props; - var _key4 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM + var _key3 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM - var _instance3 = hoistableRoot.querySelector( - getScriptSelectorFromKey(_key4) + var _instance2 = hoistableRoot.querySelector( + getScriptSelectorFromKey(_key3) ); - if (_instance3) { - resource.instance = _instance3; - markNodeAsHoistable(_instance3); - return _instance3; + if (_instance2) { + resource.instance = _instance2; + markNodeAsHoistable(_instance2); + return _instance2; } var scriptProps = borrowedScriptProps; - var _preloadProps2 = preloadPropsMap.get(_key4); + var _preloadProps = preloadPropsMap.get(_key3); - if (_preloadProps2) { + if (_preloadProps) { scriptProps = assign({}, borrowedScriptProps); - adoptPreloadPropsForScript(scriptProps, _preloadProps2); + adoptPreloadPropsForScript(scriptProps, _preloadProps); } // Construct and insert a new instance var _ownerDocument2 = getDocumentFromRoot(hoistableRoot); - _instance3 = _ownerDocument2.createElement("script"); - markNodeAsHoistable(_instance3); - setInitialProperties(_instance3, "link", scriptProps); + _instance2 = _ownerDocument2.createElement("script"); + markNodeAsHoistable(_instance2); + setInitialProperties(_instance2, "link", scriptProps); - _ownerDocument2.head.appendChild(_instance3); + _ownerDocument2.head.appendChild(_instance2); - resource.instance = _instance3; - return _instance3; + resource.instance = _instance2; + return _instance2; } case "void": { @@ -45143,9 +44851,9 @@ function acquireResource(hoistableRoot, resource, props) { (resource.state.loading & Inserted) === NotLoaded ) { var _qualifiedProps2 = props; - var _instance4 = resource.instance; + var _instance3 = resource.instance; resource.state.loading |= Inserted; - insertStylesheet(_instance4, _qualifiedProps2.precedence, hoistableRoot); + insertStylesheet(_instance3, _qualifiedProps2.precedence, hoistableRoot); } } @@ -45273,9 +44981,9 @@ function hydrateHoistable(hoistableRoot, type, props, internalInstanceHandle) { ownerDocument ); - var _key5 = type + (props.content || ""); + var _key4 = type + (props.content || ""); - var _maybeNodes = _cache.get(_key5); + var _maybeNodes = _cache.get(_key4); if (_maybeNodes) { var _nodes = _maybeNodes; @@ -47647,78 +47355,361 @@ var ReactDOMSharedInternals = Internals; var Dispatcher = ReactDOMSharedInternals.Dispatcher; function prefetchDNS(href) { - var passedOptionArg; - { - if (arguments[1] !== undefined) { - passedOptionArg = arguments[1]; + if (typeof href !== "string" || !href) { + error( + "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (arguments.length > 1) { + var options = arguments[1]; + + if ( + typeof options === "object" && + options.hasOwnProperty("crossOrigin") + ) { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } } } var dispatcher = Dispatcher.current; - if (dispatcher) { - { - if (passedOptionArg !== undefined) { - // prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to - // elicit the warning. In prod we do not forward since it is not a part of the interface. - // @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and - // let the rest of the codebase trust the types - dispatcher.prefetchDNS(href, passedOptionArg); - } else { - dispatcher.prefetchDNS(href); - } - } + if (dispatcher && typeof href === "string") { + dispatcher.prefetchDNS(href); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preconnect(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options != null && typeof options !== "object") { + error( + "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options != null && typeof options.crossOrigin !== "string") { + error( + "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", + getValueDescriptorExpectingObjectForWarning(options.crossOrigin) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preconnect(href, options); + if (dispatcher && typeof href === "string") { + var crossOrigin = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null; + dispatcher.preconnect(href, crossOrigin); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preload(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options == null || typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (typeof options.as !== "string" || !options.as) { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preload(href, options); + if ( + dispatcher && + typeof href === "string" && // We check existence because we cannot enforce this function is actually called with the stated type + typeof options === "object" && + options !== null && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined, + nonce: typeof options.nonce === "string" ? options.nonce : undefined, + type: typeof options.type === "string" ? options.type : undefined, + fetchPriority: + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined, + referrerPolicy: + typeof options.referrerPolicy === "string" + ? options.referrerPolicy + : undefined, + imageSrcSet: + typeof options.imageSrcSet === "string" + ? options.imageSrcSet + : undefined, + imageSizes: + typeof options.imageSizes === "string" ? options.imageSizes : undefined + }); } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preloadModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && typeof options.as !== "string") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preloadModule(href, options); + if (dispatcher && typeof href === "string") { + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + typeof options.as === "string" && options.as !== "script" + ? options.as + : undefined, + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined + }); + } else { + dispatcher.preloadModule(href); + } } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinit(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options == null || typeof options !== "object") { + error( + "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options.as !== "style" && options.as !== "script") { + error( + 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', + getValueDescriptorExpectingEnumForWarning(options.as) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinit(href, options); + if ( + dispatcher && + typeof href === "string" && + options && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + var integrity = + typeof options.integrity === "string" ? options.integrity : undefined; + var fetchPriority = + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined; + + if (as === "style") { + dispatcher.preinitStyle( + href, + typeof options.precedence === "string" ? options.precedence : undefined, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ); + } else if (as === "script") { + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: typeof options.nonce === "string" ? options.nonce : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinitModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && options.as !== "script") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingEnumForWarning(options.as) + + "."; + } + + if (encountered) { + error( + "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", + encountered + ); + } else { + var as = + options && typeof options.as === "string" ? options.as : "script"; + + switch (as) { + case "script": { + break; + } + // We have an invalid as type and need to warn + + default: { + var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + + error( + 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + + ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + + " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + + " (https://github.com/tc39/proposal-import-attributes)", + typeOfAs, + href + ); + } + } + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinitModule(href, options); + if (dispatcher && typeof href === "string") { + if ( + options == null || + (typeof options === "object" && + (options.as == null || options.as === "script")) + ) { + var crossOrigin = options + ? getCrossOrigin(undefined, options.crossOrigin) + : undefined; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && typeof options.integrity === "string" + ? options.integrity + : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } +function getCrossOrigin(as, crossOrigin) { + return as === "font" + ? "" + : typeof crossOrigin === "string" + ? crossOrigin === "use-credentials" + ? "use-credentials" + : "" + : undefined; +} + +function getValueDescriptorExpectingObjectForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : 'something with type "' + typeof thing + '"'; +} + +function getValueDescriptorExpectingEnumForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : typeof thing === "string" + ? JSON.stringify(thing) + : typeof thing === "number" + ? "`" + thing + "`" + : 'something with type "' + typeof thing + '"'; +} + { if ( typeof Map !== "function" || // $FlowFixMe[prop-missing] Flow incorrectly thinks Map has no prototype diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index 7c3a004190727..a529f914d3a8f 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -34471,7 +34471,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-5c6a0c8b"; +var ReactVersion = "18.3.0-www-modern-6b264517"; function createPortal$1( children, @@ -43026,70 +43026,6 @@ function propNamesListJoin(list, combinator) { } } -function validatePreinitArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); - - error( - "ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg - ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg, - href - ); - } else { - var as = options.as; - - switch (as) { - case "style": - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + - ' and "script". The href for the preinit call where this warning originated is "%s".', - typeOfAs, - href - ); - } - } - } - } -} -function getValueDescriptorExpectingObjectForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : 'something with type "' + typeof thing + '"'; -} -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "`null`" - : thing === undefined - ? "`undefined`" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} - var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning"; var SUSPENSE_START_DATA = "$"; var SUSPENSE_END_DATA = "/$"; @@ -44691,8 +44627,9 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; // We expect this to get inlined. It is a function mostly to communicate the special nature of // how we resolve the HoistableRoot for ReactDOM.pre*() methods. Because we support calling // these methods outside of render there is no way to know which Document or ShadowRoot is 'scoped' @@ -44704,7 +44641,7 @@ function getDocumentForImperativeFloatMethods() { return document; } -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = getDocumentForImperativeFloatMethods(); if (typeof href === "string" && href) { @@ -44734,127 +44671,34 @@ function preconnectAs(rel, crossOrigin, href) { } } -function prefetchDNS$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null) { - if ( - typeof options === "object" && - hasOwnProperty.call(options, "crossOrigin") - ) { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else { - error( - "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } - } - } - - preconnectAs("dns-prefetch", null, href); +function prefetchDNS$1(href) { + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - { - if (typeof href !== "string" || !href) { - error( - "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", - getValueDescriptorExpectingObjectForWarning(href) - ); - } else if (options != null && typeof options !== "object") { - error( - "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", - getValueDescriptorExpectingEnumForWarning(options) - ); - } else if (options != null && typeof options.crossOrigin !== "string") { - error( - "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", - getValueDescriptorExpectingObjectForWarning(options.crossOrigin) - ); - } - } - - var crossOrigin = - options == null || typeof options.crossOrigin !== "string" - ? null - : options.crossOrigin === "use-credentials" - ? "use-credentials" - : ""; - preconnectAs("preconnect", crossOrigin, href); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { - { - // TODO move this to ReactDOMFloat and expose a stricter function interface or possibly - // typed functions (preloadImage, preloadStyle, ...) - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - "The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options == null || typeof options !== "object") { - encountered += - "The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (typeof options.as !== "string" || !options.as) { - encountered += - "The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag. %s', - encountered - ); - } - } - +function preload$1(href, as, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - typeof options.as === "string" && - options.as && - ownerDocument - ) { - var as = options.as; + if (href && as && ownerDocument) { var preloadSelector = 'link[rel="preload"][as="' + escapeSelectorAttributeValueInsideDoubleQuotes(as) + '"]'; if (as === "image") { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - - if (typeof imageSrcSet === "string" && imageSrcSet !== "") { + if (options && options.imageSrcSet) { preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSrcSet) + '"]'; - if (typeof imageSizes === "string") { + if (typeof options.imageSizes === "string") { preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes(options.imageSizes) + '"]'; } } else { @@ -44883,7 +44727,20 @@ function preload$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadPropsFromPreloadOptions(href, as, options); + var preloadProps = assign( + { + rel: "preload", + // There is a bug in Safari where imageSrcSet is not respected on preload links + // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. + // This harms older browers that do not support imageSrcSet by making their preloads not work + // but this population is shrinking fast and is already small so we accept this tradeoff. + href: + as === "image" && options && options.imageSrcSet ? undefined : href, + as: as + }, + options + ); + preloadPropsMap.set(key, preloadProps); if (null === ownerDocument.querySelector(preloadSelector)) { @@ -44911,39 +44768,9 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { - { - var encountered = ""; - - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } - - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && typeof options.as !== "string") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingObjectForWarning(options.as) + - "."; - } - - if (encountered) { - error( - 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', - encountered - ); - } - } - var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href === "string" && href) { + if (href) { var as = options && typeof options.as === "string" ? options.as : "script"; var preloadSelector = 'link[rel="modulepreload"][as="' + @@ -44969,12 +44796,15 @@ function preloadModule$1(href, options) { } if (!preloadPropsMap.has(key)) { - var preloadProps = preloadModulePropsFromPreloadModuleOptions( - href, - as, + var props = assign( + { + rel: "modulepreload", + href: href + }, options ); - preloadPropsMap.set(key, preloadProps); + + preloadPropsMap.set(key, props); if (null === ownerDocument.querySelector(preloadSelector)) { switch (as) { @@ -44991,7 +44821,7 @@ function preloadModule$1(href, options) { } var instance = ownerDocument.createElement("link"); - setInitialProperties(instance, "link", preloadProps); + setInitialProperties(instance, "link", props); markNodeAsHoistable(instance); ownerDocument.head.appendChild(instance); } @@ -44999,299 +44829,177 @@ function preloadModule$1(href, options) { } } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - rel: "preload", - as: as, - // There is a bug in Safari where imageSrcSet is not respected on preload links - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image. - // This harms older browers that do not support imageSrcSet by making their preloads not work - // but this population is shrinking fast and is already small so we accept this tradeoff. - href: as === "image" && options.imageSrcSet ? undefined : href, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }; -} - -function preloadModulePropsFromPreloadModuleOptions(href, as, options) { - return { - rel: "modulepreload", - as: as !== "script" ? as : undefined, - href: href, - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; -} - -function preinit$1(href, options) { - { - validatePreinitArguments(href, options); - } - +function preinitStyle(href, precedence, options) { var ownerDocument = getDocumentForImperativeFloatMethods(); - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var as = options.as; - - switch (as) { - case "style": { - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; - var key = getStyleKey(href); - var precedence = options.precedence || "default"; // Check if this resource already exists + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles; + var key = getStyleKey(href); + precedence = precedence || "default"; // Check if this resource already exists - var resource = styles.get(key); + var resource = styles.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } - var state = { - loading: NotLoaded, - preload: null - }; // Attempt to hydrate instance from DOM + var state = { + loading: NotLoaded, + preload: null + }; // Attempt to hydrate instance from DOM - var instance = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - ); + var instance = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + ); - if (instance) { - state.loading = Loaded; - } else { - // Construct a new instance and insert it - var stylesheetProps = stylesheetPropsFromPreinitOptions( - href, - precedence, - options - ); - var preloadProps = preloadPropsMap.get(key); + if (instance) { + state.loading = Loaded; + } else { + // Construct a new instance and insert it + var stylesheetProps = assign( + { + rel: "stylesheet", + href: href, + "data-precedence": precedence + }, + options + ); - if (preloadProps) { - adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - var link = (instance = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", stylesheetProps); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= Loaded; - }); - link.addEventListener("error", function () { - state.loading |= Errored; - }); - state.loading |= Inserted; - insertStylesheet(instance, precedence, ownerDocument); - } // Construct a Resource and cache it - - resource = { - type: "stylesheet", - instance: instance, - count: 1, - state: state - }; - styles.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForStylesheet(stylesheetProps, preloadProps); } - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var link = (instance = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", stylesheetProps); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= Loaded; + }); + link.addEventListener("error", function () { + state.loading |= Errored; + }); + state.loading |= Inserted; + insertStylesheet(instance, precedence, ownerDocument); + } // Construct a Resource and cache it + + resource = { + type: "stylesheet", + instance: instance, + count: 1, + state: state + }; + styles.set(key, resource); + return; + } +} - var _key = getScriptKey(src); // Check if this resource already exists +function preinitScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - var _resource = scripts.get(_key); + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (_resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM + var resource = scripts.get(key); - var _instance = ownerDocument.querySelector( - getScriptSelectorFromKey(_key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!_instance) { - // Construct a new instance and insert it - var scriptProps = scriptPropsFromPreinitOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var _preloadProps = preloadPropsMap.get(_key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true + }, + options + ); // Adopt certain preload props - if (_preloadProps) { - adoptPreloadPropsForScript(scriptProps, _preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - _instance = ownerDocument.createElement("script"); - markNodeAsHoistable(_instance); - setInitialProperties(_instance, "link", scriptProps); - ownerDocument.head.appendChild(_instance); - } // Construct a Resource and cache it - - _resource = { - type: "script", - instance: _instance, - count: 1, - state: null - }; - scripts.set(_key, _resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } + + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it + + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; } } -function preinitModule$1(href, options) { - { - var encountered = ""; +function preinitModuleScript(src, options) { + var ownerDocument = getDocumentForImperativeFloatMethods(); - if (typeof href !== "string" || !href) { - encountered += - " The `href` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(href) + - "."; - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; + var key = getScriptKey(src); // Check if this resource already exists - if (options !== undefined && typeof options !== "object") { - encountered += - " The `options` argument encountered was " + - getValueDescriptorExpectingObjectForWarning(options) + - "."; - } else if (options && "as" in options && options.as !== "script") { - encountered += - " The `as` option encountered was " + - getValueDescriptorExpectingEnumForWarning(options.as) + - "."; - } - - if (encountered) { - error( - "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", - encountered - ); - } else { - var as = - options && typeof options.as === "string" ? options.as : "script"; - - switch (as) { - case "script": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + - ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + - " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + - " (https://github.com/tc39/proposal-import-attributes)", - typeOfAs, - href - ); - } - } - } - } - - var ownerDocument = getDocumentForImperativeFloatMethods(); - - if (typeof href === "string" && href) { - var _as = options && typeof options.as === "string" ? options.as : "script"; - - switch (_as) { - case "script": { - var src = href; - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts; - var key = getScriptKey(src); // Check if this resource already exists - - var resource = scripts.get(key); + var resource = scripts.get(key); - if (resource) { - // We can early return. The resource exists and there is nothing - // more to do - return; - } // Attempt to hydrate instance from DOM - - var instance = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - ); + if (resource) { + // We can early return. The resource exists and there is nothing + // more to do + return; + } // Attempt to hydrate instance from DOM - if (!instance) { - // Construct a new instance and insert it - var scriptProps = modulePropsFromPreinitModuleOptions(src, options); // Adopt certain preload props + var instance = ownerDocument.querySelector(getScriptSelectorFromKey(key)); - var preloadProps = preloadPropsMap.get(key); + if (!instance) { + // Construct a new instance and insert it + var scriptProps = assign( + { + src: src, + async: true, + type: "module" + }, + options + ); // Adopt certain preload props - if (preloadProps) { - adoptPreloadPropsForScript(scriptProps, preloadProps); - } + var preloadProps = preloadPropsMap.get(key); - instance = ownerDocument.createElement("script"); - markNodeAsHoistable(instance); - setInitialProperties(instance, "link", scriptProps); - ownerDocument.head.appendChild(instance); - } // Construct a Resource and cache it - - resource = { - type: "script", - instance: instance, - count: 1, - state: null - }; - scripts.set(key, resource); - return; + if (preloadProps) { + adoptPreloadPropsForScript(scriptProps, preloadProps); } - } - } -} - -function stylesheetPropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; -} -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }; -} + instance = ownerDocument.createElement("script"); + markNodeAsHoistable(instance); + setInitialProperties(instance, "link", scriptProps); + ownerDocument.head.appendChild(instance); + } // Construct a Resource and cache it -function modulePropsFromPreinitModuleOptions(src, options) { - return { - src: src, - async: true, - type: "module", - crossOrigin: options ? options.crossOrigin : undefined, - integrity: options ? options.integrity : undefined - }; + resource = { + type: "script", + instance: instance, + count: 1, + state: null + }; + scripts.set(key, resource); + return; + } } // This function is called in begin work and we should always have a currentDocument set function getResource(type, currentProps, pendingProps) { @@ -45347,16 +45055,16 @@ function getResource(type, currentProps, pendingProps) { ) { var qualifiedProps = pendingProps; - var _key2 = getStyleKey(qualifiedProps.href); + var _key = getStyleKey(qualifiedProps.href); var _styles = getResourcesFromRoot(resourceRoot).hoistableStyles; - var _resource2 = _styles.get(_key2); + var _resource = _styles.get(_key); - if (!_resource2) { + if (!_resource) { // We asserted this above but Flow can't figure out that the type satisfies var ownerDocument = getDocumentFromRoot(resourceRoot); - _resource2 = { + _resource = { type: "stylesheet", instance: null, count: 0, @@ -45366,19 +45074,19 @@ function getResource(type, currentProps, pendingProps) { } }; - _styles.set(_key2, _resource2); + _styles.set(_key, _resource); - if (!preloadPropsMap.has(_key2)) { + if (!preloadPropsMap.has(_key)) { preloadStylesheet( ownerDocument, - _key2, + _key, preloadPropsFromStylesheet(qualifiedProps), - _resource2.state + _resource.state ); } } - return _resource2; + return _resource; } return null; @@ -45388,23 +45096,23 @@ function getResource(type, currentProps, pendingProps) { if (typeof pendingProps.src === "string" && pendingProps.async === true) { var scriptProps = pendingProps; - var _key3 = getScriptKey(scriptProps.src); + var _key2 = getScriptKey(scriptProps.src); var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; - var _resource3 = scripts.get(_key3); + var _resource2 = scripts.get(_key2); - if (!_resource3) { - _resource3 = { + if (!_resource2) { + _resource2 = { type: "script", instance: null, count: 0, state: null }; - scripts.set(_key3, _resource3); + scripts.set(_key2, _resource2); } - return _resource3; + return _resource2; } return { @@ -45551,14 +45259,14 @@ function acquireResource(hoistableRoot, resource, props) { var _qualifiedProps = props; var key = getStyleKey(_qualifiedProps.href); // Attempt to hydrate instance from DOM - var _instance2 = hoistableRoot.querySelector( + var _instance = hoistableRoot.querySelector( getStylesheetSelectorFromKey(key) ); - if (_instance2) { - resource.instance = _instance2; - markNodeAsHoistable(_instance2); - return _instance2; + if (_instance) { + resource.instance = _instance; + markNodeAsHoistable(_instance); + return _instance; } var stylesheetProps = stylesheetPropsFromRawProps(props); @@ -45570,18 +45278,18 @@ function acquireResource(hoistableRoot, resource, props) { var _ownerDocument = getDocumentFromRoot(hoistableRoot); - _instance2 = _ownerDocument.createElement("link"); - markNodeAsHoistable(_instance2); - var linkInstance = _instance2; + _instance = _ownerDocument.createElement("link"); + markNodeAsHoistable(_instance); + var linkInstance = _instance; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(_instance2, "link", stylesheetProps); + setInitialProperties(_instance, "link", stylesheetProps); resource.state.loading |= Inserted; - insertStylesheet(_instance2, _qualifiedProps.precedence, hoistableRoot); - resource.instance = _instance2; - return _instance2; + insertStylesheet(_instance, _qualifiedProps.precedence, hoistableRoot); + resource.instance = _instance; + return _instance; } case "script": { @@ -45590,37 +45298,37 @@ function acquireResource(hoistableRoot, resource, props) { // this cast still makes sense; var borrowedScriptProps = props; - var _key4 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM + var _key3 = getScriptKey(borrowedScriptProps.src); // Attempt to hydrate instance from DOM - var _instance3 = hoistableRoot.querySelector( - getScriptSelectorFromKey(_key4) + var _instance2 = hoistableRoot.querySelector( + getScriptSelectorFromKey(_key3) ); - if (_instance3) { - resource.instance = _instance3; - markNodeAsHoistable(_instance3); - return _instance3; + if (_instance2) { + resource.instance = _instance2; + markNodeAsHoistable(_instance2); + return _instance2; } var scriptProps = borrowedScriptProps; - var _preloadProps2 = preloadPropsMap.get(_key4); + var _preloadProps = preloadPropsMap.get(_key3); - if (_preloadProps2) { + if (_preloadProps) { scriptProps = assign({}, borrowedScriptProps); - adoptPreloadPropsForScript(scriptProps, _preloadProps2); + adoptPreloadPropsForScript(scriptProps, _preloadProps); } // Construct and insert a new instance var _ownerDocument2 = getDocumentFromRoot(hoistableRoot); - _instance3 = _ownerDocument2.createElement("script"); - markNodeAsHoistable(_instance3); - setInitialProperties(_instance3, "link", scriptProps); + _instance2 = _ownerDocument2.createElement("script"); + markNodeAsHoistable(_instance2); + setInitialProperties(_instance2, "link", scriptProps); - _ownerDocument2.head.appendChild(_instance3); + _ownerDocument2.head.appendChild(_instance2); - resource.instance = _instance3; - return _instance3; + resource.instance = _instance2; + return _instance2; } case "void": { @@ -45653,9 +45361,9 @@ function acquireResource(hoistableRoot, resource, props) { (resource.state.loading & Inserted) === NotLoaded ) { var _qualifiedProps2 = props; - var _instance4 = resource.instance; + var _instance3 = resource.instance; resource.state.loading |= Inserted; - insertStylesheet(_instance4, _qualifiedProps2.precedence, hoistableRoot); + insertStylesheet(_instance3, _qualifiedProps2.precedence, hoistableRoot); } } @@ -45783,9 +45491,9 @@ function hydrateHoistable(hoistableRoot, type, props, internalInstanceHandle) { ownerDocument ); - var _key5 = type + (props.content || ""); + var _key4 = type + (props.content || ""); - var _maybeNodes = _cache.get(_key5); + var _maybeNodes = _cache.get(_key4); if (_maybeNodes) { var _nodes = _maybeNodes; @@ -46736,78 +46444,361 @@ var ReactDOMSharedInternals = Internals; var Dispatcher = ReactDOMSharedInternals.Dispatcher; function prefetchDNS(href) { - var passedOptionArg; - { - if (arguments[1] !== undefined) { - passedOptionArg = arguments[1]; + if (typeof href !== "string" || !href) { + error( + "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (arguments.length > 1) { + var options = arguments[1]; + + if ( + typeof options === "object" && + options.hasOwnProperty("crossOrigin") + ) { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else { + error( + "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } } } var dispatcher = Dispatcher.current; - if (dispatcher) { - { - if (passedOptionArg !== undefined) { - // prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to - // elicit the warning. In prod we do not forward since it is not a part of the interface. - // @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and - // let the rest of the codebase trust the types - dispatcher.prefetchDNS(href, passedOptionArg); - } else { - dispatcher.prefetchDNS(href); - } - } + if (dispatcher && typeof href === "string") { + dispatcher.prefetchDNS(href); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preconnect(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options != null && typeof options !== "object") { + error( + "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options != null && typeof options.crossOrigin !== "string") { + error( + "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.", + getValueDescriptorExpectingObjectForWarning(options.crossOrigin) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preconnect(href, options); + if (dispatcher && typeof href === "string") { + var crossOrigin = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null; + dispatcher.preconnect(href, crossOrigin); } // We don't error because preconnect needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preload(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options == null || typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (typeof options.as !== "string" || !options.as) { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preload(href, options); + if ( + dispatcher && + typeof href === "string" && // We check existence because we cannot enforce this function is actually called with the stated type + typeof options === "object" && + options !== null && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined, + nonce: typeof options.nonce === "string" ? options.nonce : undefined, + type: typeof options.type === "string" ? options.type : undefined, + fetchPriority: + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined, + referrerPolicy: + typeof options.referrerPolicy === "string" + ? options.referrerPolicy + : undefined, + imageSrcSet: + typeof options.imageSrcSet === "string" + ? options.imageSrcSet + : undefined, + imageSizes: + typeof options.imageSizes === "string" ? options.imageSizes : undefined + }); } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preloadModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && typeof options.as !== "string") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingObjectForWarning(options.as) + + "."; + } + + if (encountered) { + error( + 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s', + encountered + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preloadModule(href, options); + if (dispatcher && typeof href === "string") { + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + typeof options.as === "string" && options.as !== "script" + ? options.as + : undefined, + crossOrigin: crossOrigin, + integrity: + typeof options.integrity === "string" ? options.integrity : undefined + }); + } else { + dispatcher.preloadModule(href); + } } // We don't error because preload needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinit(href, options) { + { + if (typeof href !== "string" || !href) { + error( + "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.", + getValueDescriptorExpectingObjectForWarning(href) + ); + } else if (options == null || typeof options !== "object") { + error( + "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.", + getValueDescriptorExpectingEnumForWarning(options) + ); + } else if (options.as !== "style" && options.as !== "script") { + error( + 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', + getValueDescriptorExpectingEnumForWarning(options.as) + ); + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinit(href, options); + if ( + dispatcher && + typeof href === "string" && + options && + typeof options.as === "string" + ) { + var as = options.as; + var crossOrigin = getCrossOrigin(as, options.crossOrigin); + var integrity = + typeof options.integrity === "string" ? options.integrity : undefined; + var fetchPriority = + typeof options.fetchPriority === "string" + ? options.fetchPriority + : undefined; + + if (as === "style") { + dispatcher.preinitStyle( + href, + typeof options.precedence === "string" ? options.precedence : undefined, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ); + } else if (as === "script") { + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: typeof options.nonce === "string" ? options.nonce : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } function preinitModule(href, options) { + { + var encountered = ""; + + if (typeof href !== "string" || !href) { + encountered += + " The `href` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(href) + + "."; + } + + if (options !== undefined && typeof options !== "object") { + encountered += + " The `options` argument encountered was " + + getValueDescriptorExpectingObjectForWarning(options) + + "."; + } else if (options && "as" in options && options.as !== "script") { + encountered += + " The `as` option encountered was " + + getValueDescriptorExpectingEnumForWarning(options.as) + + "."; + } + + if (encountered) { + error( + "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s", + encountered + ); + } else { + var as = + options && typeof options.as === "string" ? options.as : "script"; + + switch (as) { + case "script": { + break; + } + // We have an invalid as type and need to warn + + default: { + var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + + error( + 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + + ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + + " module types will be supported, aligning with the import-attributes proposal. Learn more here:" + + " (https://github.com/tc39/proposal-import-attributes)", + typeOfAs, + href + ); + } + } + } + } + var dispatcher = Dispatcher.current; - if (dispatcher) { - dispatcher.preinitModule(href, options); + if (dispatcher && typeof href === "string") { + if ( + options == null || + (typeof options === "object" && + (options.as == null || options.as === "script")) + ) { + var crossOrigin = options + ? getCrossOrigin(undefined, options.crossOrigin) + : undefined; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && typeof options.integrity === "string" + ? options.integrity + : undefined + }); + } } // We don't error because preinit needs to be resilient to being called in a variety of scopes // and the runtime may not be capable of responding. The function is optimistic and not critical // so we favor silent bailout over warning or erroring. } +function getCrossOrigin(as, crossOrigin) { + return as === "font" + ? "" + : typeof crossOrigin === "string" + ? crossOrigin === "use-credentials" + ? "use-credentials" + : "" + : undefined; +} + +function getValueDescriptorExpectingObjectForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : 'something with type "' + typeof thing + '"'; +} + +function getValueDescriptorExpectingEnumForWarning(thing) { + return thing === null + ? "`null`" + : thing === undefined + ? "`undefined`" + : thing === "" + ? "an empty string" + : typeof thing === "string" + ? JSON.stringify(thing) + : typeof thing === "number" + ? "`" + thing + "`" + : 'something with type "' + typeof thing + '"'; +} + { if ( typeof Map !== "function" || // $FlowFixMe[prop-missing] Flow incorrectly thinks Map has no prototype diff --git a/compiled/facebook-www/ReactDOMTesting-prod.classic.js b/compiled/facebook-www/ReactDOMTesting-prod.classic.js index 44be70866d31d..bd6296492a58d 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.classic.js @@ -12932,19 +12932,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$369; + var JSCompiler_inline_result$jscomp$365; if (canUseDOM) { - var isSupported$jscomp$inline_1563 = "oninput" in document; - if (!isSupported$jscomp$inline_1563) { - var element$jscomp$inline_1564 = document.createElement("div"); - element$jscomp$inline_1564.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1563 = - "function" === typeof element$jscomp$inline_1564.oninput; + var isSupported$jscomp$inline_1559 = "oninput" in document; + if (!isSupported$jscomp$inline_1559) { + var element$jscomp$inline_1560 = document.createElement("div"); + element$jscomp$inline_1560.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1559 = + "function" === typeof element$jscomp$inline_1560.oninput; } - JSCompiler_inline_result$jscomp$369 = isSupported$jscomp$inline_1563; - } else JSCompiler_inline_result$jscomp$369 = !1; + JSCompiler_inline_result$jscomp$365 = isSupported$jscomp$inline_1559; + } else JSCompiler_inline_result$jscomp$365 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$369 && + JSCompiler_inline_result$jscomp$365 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13253,20 +13253,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1604 = 0; - i$jscomp$inline_1604 < simpleEventPluginEvents.length; - i$jscomp$inline_1604++ + var i$jscomp$inline_1600 = 0; + i$jscomp$inline_1600 < simpleEventPluginEvents.length; + i$jscomp$inline_1600++ ) { - var eventName$jscomp$inline_1605 = - simpleEventPluginEvents[i$jscomp$inline_1604], - domEventName$jscomp$inline_1606 = - eventName$jscomp$inline_1605.toLowerCase(), - capitalizedEvent$jscomp$inline_1607 = - eventName$jscomp$inline_1605[0].toUpperCase() + - eventName$jscomp$inline_1605.slice(1); + var eventName$jscomp$inline_1601 = + simpleEventPluginEvents[i$jscomp$inline_1600], + domEventName$jscomp$inline_1602 = + eventName$jscomp$inline_1601.toLowerCase(), + capitalizedEvent$jscomp$inline_1603 = + eventName$jscomp$inline_1601[0].toUpperCase() + + eventName$jscomp$inline_1601.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1606, - "on" + capitalizedEvent$jscomp$inline_1607 + domEventName$jscomp$inline_1602, + "on" + capitalizedEvent$jscomp$inline_1603 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15499,10 +15499,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -15515,92 +15516,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -15609,7 +15590,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -15629,13 +15610,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -15656,129 +15631,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -15807,17 +15756,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$277 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$278 = styles$277.get(type); - resource$278 || + var styles$273 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$274 = styles$273.get(type); + resource$274 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$278 = { + (resource$274 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$277.set(type, resource$278), + styles$273.set(type, resource$274), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -15832,9 +15781,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$278.state + resource$274.state )); - return resource$278; + return resource$274; } return null; case "script": @@ -15917,36 +15866,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$282 = hoistableRoot.querySelector( + var instance$278 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$282) + if (instance$278) return ( - (resource.instance = instance$282), - markNodeAsHoistable(instance$282), - instance$282 + (resource.instance = instance$278), + markNodeAsHoistable(instance$278), + instance$278 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$282 = ( + instance$278 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$282); - var linkInstance = instance$282; + markNodeAsHoistable(instance$278); + var linkInstance = instance$278; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$282, "link", instance); + setInitialProperties(instance$278, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$282, props.precedence, hoistableRoot); - return (resource.instance = instance$282); + insertStylesheet(instance$278, props.precedence, hoistableRoot); + return (resource.instance = instance$278); case "script": - instance$282 = getScriptKey(props.src); + instance$278 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$282) + getScriptSelectorFromKey(instance$278) )) ) return ( @@ -15955,7 +15904,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$282))) + if ((styleProps = preloadPropsMap.get(instance$278))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -16907,11 +16856,11 @@ function legacyCreateRootFromDOMContainer( if ("function" === typeof callback) { var originalCallback = callback; callback = function () { - var instance = getPublicRootInstance(root$302); + var instance = getPublicRootInstance(root$298); originalCallback.call(instance); }; } - var root$302 = createHydrationContainer( + var root$298 = createHydrationContainer( initialChildren, callback, container, @@ -16923,23 +16872,23 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$302; - container[internalContainerInstanceKey] = root$302.current; + container._reactRootContainer = root$298; + container[internalContainerInstanceKey] = root$298.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(); - return root$302; + return root$298; } clearContainer(container); if ("function" === typeof callback) { - var originalCallback$303 = callback; + var originalCallback$299 = callback; callback = function () { - var instance = getPublicRootInstance(root$304); - originalCallback$303.call(instance); + var instance = getPublicRootInstance(root$300); + originalCallback$299.call(instance); }; } - var root$304 = createFiberRoot( + var root$300 = createFiberRoot( container, 0, !1, @@ -16951,15 +16900,15 @@ function legacyCreateRootFromDOMContainer( noopOnRecoverableError, null ); - container._reactRootContainer = root$304; - container[internalContainerInstanceKey] = root$304.current; + container._reactRootContainer = root$300; + container[internalContainerInstanceKey] = root$300.current; listenToAllSupportedEvents( 8 === container.nodeType ? container.parentNode : container ); flushSync$1(function () { - updateContainer(initialChildren, root$304, parentComponent, callback); + updateContainer(initialChildren, root$300, parentComponent, callback); }); - return root$304; + return root$300; } function legacyRenderSubtreeIntoContainer( parentComponent, @@ -17011,6 +16960,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode, getNodeFromInstance, @@ -17019,17 +16977,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1811 = { +var devToolsConfig$jscomp$inline_1807 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-dfb43f64", + version: "18.3.0-www-classic-eeba9077", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2173 = { - bundleType: devToolsConfig$jscomp$inline_1811.bundleType, - version: devToolsConfig$jscomp$inline_1811.version, - rendererPackageName: devToolsConfig$jscomp$inline_1811.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1811.rendererConfig, +var internals$jscomp$inline_2169 = { + bundleType: devToolsConfig$jscomp$inline_1807.bundleType, + version: devToolsConfig$jscomp$inline_1807.version, + rendererPackageName: devToolsConfig$jscomp$inline_1807.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1807.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17045,26 +17003,26 @@ var internals$jscomp$inline_2173 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1811.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1807.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-dfb43f64" + reconcilerVersion: "18.3.0-www-classic-eeba9077" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2174 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2170 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2174.isDisabled && - hook$jscomp$inline_2174.supportsFiber + !hook$jscomp$inline_2170.isDisabled && + hook$jscomp$inline_2170.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2174.inject( - internals$jscomp$inline_2173 + (rendererID = hook$jscomp$inline_2170.inject( + internals$jscomp$inline_2169 )), - (injectedHook = hook$jscomp$inline_2174); + (injectedHook = hook$jscomp$inline_2170); } catch (err) {} } assign(Internals, { @@ -17341,27 +17299,120 @@ exports.observeVisibleRects = function ( }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.render = function (element, container, callback) { if (!isValidContainerLegacy(container)) @@ -17442,4 +17493,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-dfb43f64"; +exports.version = "18.3.0-www-classic-eeba9077"; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index f40ae3f157444..5323ca9f6d368 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -13229,19 +13229,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$367; + var JSCompiler_inline_result$jscomp$363; if (canUseDOM) { - var isSupported$jscomp$inline_1562 = "oninput" in document; - if (!isSupported$jscomp$inline_1562) { - var element$jscomp$inline_1563 = document.createElement("div"); - element$jscomp$inline_1563.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1562 = - "function" === typeof element$jscomp$inline_1563.oninput; + var isSupported$jscomp$inline_1558 = "oninput" in document; + if (!isSupported$jscomp$inline_1558) { + var element$jscomp$inline_1559 = document.createElement("div"); + element$jscomp$inline_1559.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1558 = + "function" === typeof element$jscomp$inline_1559.oninput; } - JSCompiler_inline_result$jscomp$367 = isSupported$jscomp$inline_1562; - } else JSCompiler_inline_result$jscomp$367 = !1; + JSCompiler_inline_result$jscomp$363 = isSupported$jscomp$inline_1558; + } else JSCompiler_inline_result$jscomp$363 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$367 && + JSCompiler_inline_result$jscomp$363 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13550,20 +13550,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1603 = 0; - i$jscomp$inline_1603 < simpleEventPluginEvents.length; - i$jscomp$inline_1603++ + var i$jscomp$inline_1599 = 0; + i$jscomp$inline_1599 < simpleEventPluginEvents.length; + i$jscomp$inline_1599++ ) { - var eventName$jscomp$inline_1604 = - simpleEventPluginEvents[i$jscomp$inline_1603], - domEventName$jscomp$inline_1605 = - eventName$jscomp$inline_1604.toLowerCase(), - capitalizedEvent$jscomp$inline_1606 = - eventName$jscomp$inline_1604[0].toUpperCase() + - eventName$jscomp$inline_1604.slice(1); + var eventName$jscomp$inline_1600 = + simpleEventPluginEvents[i$jscomp$inline_1599], + domEventName$jscomp$inline_1601 = + eventName$jscomp$inline_1600.toLowerCase(), + capitalizedEvent$jscomp$inline_1602 = + eventName$jscomp$inline_1600[0].toUpperCase() + + eventName$jscomp$inline_1600.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1605, - "on" + capitalizedEvent$jscomp$inline_1606 + domEventName$jscomp$inline_1601, + "on" + capitalizedEvent$jscomp$inline_1602 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15781,10 +15781,11 @@ var ReactDOMClientDispatcher = { preconnect: preconnect$1, preload: preload$1, preloadModule: preloadModule$1, - preinit: preinit$1, - preinitModule: preinitModule$1 + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript }; -function preconnectAs(rel, crossOrigin, href) { +function preconnectAs(rel, href, crossOrigin) { var ownerDocument = document; if ("string" === typeof href && href) { var limitedEscapedHref = @@ -15797,92 +15798,72 @@ function preconnectAs(rel, crossOrigin, href) { (preconnectsSet.add(limitedEscapedHref), (rel = { rel: rel, crossOrigin: crossOrigin, href: href }), null === ownerDocument.querySelector(limitedEscapedHref) && - ((crossOrigin = ownerDocument.createElement("link")), - setInitialProperties(crossOrigin, "link", rel), - markNodeAsHoistable(crossOrigin), - ownerDocument.head.appendChild(crossOrigin))); + ((href = ownerDocument.createElement("link")), + setInitialProperties(href, "link", rel), + markNodeAsHoistable(href), + ownerDocument.head.appendChild(href))); } } function prefetchDNS$1(href) { - preconnectAs("dns-prefetch", null, href); + preconnectAs("dns-prefetch", href, null); } -function preconnect$1(href, options) { - preconnectAs( - "preconnect", - null == options || "string" !== typeof options.crossOrigin - ? null - : "use-credentials" === options.crossOrigin - ? "use-credentials" - : "", - href - ); +function preconnect$1(href, crossOrigin) { + preconnectAs("preconnect", href, crossOrigin); } -function preload$1(href, options) { +function preload$1(href, as, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options && - "string" === typeof options.as && - options.as && - ownerDocument - ) { - var as = options.as, - preloadSelector = - 'link[rel="preload"][as="' + - escapeSelectorAttributeValueInsideDoubleQuotes(as) + - '"]'; - if ("image" === as) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes; - "string" === typeof imageSrcSet && "" !== imageSrcSet + if (href && as && ownerDocument) { + var preloadSelector = + 'link[rel="preload"][as="' + + escapeSelectorAttributeValueInsideDoubleQuotes(as) + + '"]'; + "image" === as + ? options && options.imageSrcSet ? ((preloadSelector += '[imagesrcset="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSrcSet) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSrcSet + ) + '"]'), - "string" === typeof imageSizes && + "string" === typeof options.imageSizes && (preloadSelector += '[imagesizes="' + - escapeSelectorAttributeValueInsideDoubleQuotes(imageSizes) + + escapeSelectorAttributeValueInsideDoubleQuotes( + options.imageSizes + ) + '"]')) : (preloadSelector += '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]'); - } else - preloadSelector += - '[href="' + escapeSelectorAttributeValueInsideDoubleQuotes(href) + '"]'; - imageSrcSet = preloadSelector; + '"]') + : (preloadSelector += + '[href="' + + escapeSelectorAttributeValueInsideDoubleQuotes(href) + + '"]'); + var key = preloadSelector; switch (as) { case "style": - imageSrcSet = getStyleKey(href); + key = getStyleKey(href); break; case "script": - imageSrcSet = getScriptKey(href); + key = getScriptKey(href); } - preloadPropsMap.has(imageSrcSet) || - ((href = { - rel: "preload", - as: as, - href: "image" === as && options.imageSrcSet ? void 0 : href, - crossOrigin: "font" === as ? "" : options.crossOrigin, - integrity: options.integrity, - type: options.type, - nonce: options.nonce, - fetchPriority: options.fetchPriority, - imageSrcSet: options.imageSrcSet, - imageSizes: options.imageSizes, - referrerPolicy: options.referrerPolicy - }), - preloadPropsMap.set(imageSrcSet, href), + preloadPropsMap.has(key) || + ((href = assign( + { + rel: "preload", + href: + "image" === as && options && options.imageSrcSet ? void 0 : href, + as: as + }, + options + )), + preloadPropsMap.set(key, href), null !== ownerDocument.querySelector(preloadSelector) || ("style" === as && - ownerDocument.querySelector( - getStylesheetSelectorFromKey(imageSrcSet) - )) || + ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) || ("script" === as && - ownerDocument.querySelector(getScriptSelectorFromKey(imageSrcSet))) || + ownerDocument.querySelector(getScriptSelectorFromKey(key))) || ((as = ownerDocument.createElement("link")), setInitialProperties(as, "link", href), markNodeAsHoistable(as), @@ -15891,7 +15872,7 @@ function preload$1(href, options) { } function preloadModule$1(href, options) { var ownerDocument = document; - if ("string" === typeof href && href) { + if (href) { var as = options && "string" === typeof options.as ? options.as : "script", preloadSelector = 'link[rel="modulepreload"][as="' + @@ -15911,13 +15892,7 @@ function preloadModule$1(href, options) { } if ( !preloadPropsMap.has(key) && - ((href = { - rel: "modulepreload", - as: "script" !== as ? as : void 0, - href: href, - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), + ((href = assign({ rel: "modulepreload", href: href }, options)), preloadPropsMap.set(key, href), null === ownerDocument.querySelector(preloadSelector)) ) { @@ -15938,129 +15913,103 @@ function preloadModule$1(href, options) { } } } -function preinit$1(href, options) { +function preinitStyle(href, precedence, options) { var ownerDocument = document; - if ( - "string" === typeof href && - href && - "object" === typeof options && - null !== options - ) - switch (options.as) { - case "style": - var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, - key = getStyleKey(href), - precedence = options.precedence || "default", - resource = styles.get(key); - if (resource) break; - var state = { loading: 0, preload: null }; - if ( - (resource = ownerDocument.querySelector( - getStylesheetSelectorFromKey(key) - )) - ) - state.loading = 1; - else { - href = { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - fetchPriority: options.fetchPriority - }; - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForStylesheet(href, options); - var link = (resource = ownerDocument.createElement("link")); - markNodeAsHoistable(link); - setInitialProperties(link, "link", href); - link._p = new Promise(function (resolve, reject) { - link.onload = resolve; - link.onerror = reject; - }); - link.addEventListener("load", function () { - state.loading |= 1; - }); - link.addEventListener("error", function () { - state.loading |= 2; - }); - state.loading |= 4; - insertStylesheet(resource, precedence, ownerDocument); - } - resource = { - type: "stylesheet", - instance: resource, - count: 1, - state: state - }; - styles.set(key, resource); - break; - case "script": - (styles = getResourcesFromRoot(ownerDocument).hoistableScripts), - (key = getScriptKey(href)), - (precedence = styles.get(key)), - precedence || - ((precedence = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - precedence || - ((href = { - src: href, - async: !0, - crossOrigin: options.crossOrigin, - integrity: options.integrity, - nonce: options.nonce, - fetchPriority: options.fetchPriority - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (precedence = ownerDocument.createElement("script")), - markNodeAsHoistable(precedence), - setInitialProperties(precedence, "link", href), - ownerDocument.head.appendChild(precedence)), - (precedence = { - type: "script", - instance: precedence, - count: 1, - state: null - }), - styles.set(key, precedence)); + if (href) { + var styles = getResourcesFromRoot(ownerDocument).hoistableStyles, + key = getStyleKey(href); + precedence = precedence || "default"; + var resource = styles.get(key); + if (!resource) { + var state = { loading: 0, preload: null }; + if ( + (resource = ownerDocument.querySelector( + getStylesheetSelectorFromKey(key) + )) + ) + state.loading = 1; + else { + href = assign( + { rel: "stylesheet", href: href, "data-precedence": precedence }, + options + ); + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForStylesheet(href, options); + var link = (resource = ownerDocument.createElement("link")); + markNodeAsHoistable(link); + setInitialProperties(link, "link", href); + link._p = new Promise(function (resolve, reject) { + link.onload = resolve; + link.onerror = reject; + }); + link.addEventListener("load", function () { + state.loading |= 1; + }); + link.addEventListener("error", function () { + state.loading |= 2; + }); + state.loading |= 4; + insertStylesheet(resource, precedence, ownerDocument); + } + resource = { + type: "stylesheet", + instance: resource, + count: 1, + state: state + }; + styles.set(key, resource); } + } } -function preinitModule$1(href, options) { +function preinitScript(src, options) { var ownerDocument = document; - if ("string" === typeof href && href) - switch (options && "string" === typeof options.as ? options.as : "script") { - case "script": - var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, - key = getScriptKey(href), - resource = scripts.get(key); - resource || - ((resource = ownerDocument.querySelector( - getScriptSelectorFromKey(key) - )), - resource || - ((href = { - src: href, - async: !0, - type: "module", - crossOrigin: options ? options.crossOrigin : void 0, - integrity: options ? options.integrity : void 0 - }), - (options = preloadPropsMap.get(key)) && - adoptPreloadPropsForScript(href, options), - (resource = ownerDocument.createElement("script")), - markNodeAsHoistable(resource), - setInitialProperties(resource, "link", href), - ownerDocument.head.appendChild(resource)), - (resource = { - type: "script", - instance: resource, - count: 1, - state: null - }), - scripts.set(key, resource)); - } + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0 }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } +} +function preinitModuleScript(src, options) { + var ownerDocument = document; + if (src) { + var scripts = getResourcesFromRoot(ownerDocument).hoistableScripts, + key = getScriptKey(src), + resource = scripts.get(key); + resource || + ((resource = ownerDocument.querySelector(getScriptSelectorFromKey(key))), + resource || + ((src = assign({ src: src, async: !0, type: "module" }, options)), + (options = preloadPropsMap.get(key)) && + adoptPreloadPropsForScript(src, options), + (resource = ownerDocument.createElement("script")), + markNodeAsHoistable(resource), + setInitialProperties(resource, "link", src), + ownerDocument.head.appendChild(resource)), + (resource = { + type: "script", + instance: resource, + count: 1, + state: null + }), + scripts.set(key, resource)); + } } function getResource(type, currentProps, pendingProps) { currentProps = (currentProps = rootInstanceStackCursor.current) @@ -16089,17 +16038,17 @@ function getResource(type, currentProps, pendingProps) { "string" === typeof pendingProps.precedence ) { type = getStyleKey(pendingProps.href); - var styles$281 = getResourcesFromRoot(currentProps).hoistableStyles, - resource$282 = styles$281.get(type); - resource$282 || + var styles$277 = getResourcesFromRoot(currentProps).hoistableStyles, + resource$278 = styles$277.get(type); + resource$278 || ((currentProps = currentProps.ownerDocument || currentProps), - (resource$282 = { + (resource$278 = { type: "stylesheet", instance: null, count: 0, state: { loading: 0, preload: null } }), - styles$281.set(type, resource$282), + styles$277.set(type, resource$278), preloadPropsMap.has(type) || preloadStylesheet( currentProps, @@ -16114,9 +16063,9 @@ function getResource(type, currentProps, pendingProps) { hrefLang: pendingProps.hrefLang, referrerPolicy: pendingProps.referrerPolicy }, - resource$282.state + resource$278.state )); - return resource$282; + return resource$278; } return null; case "script": @@ -16199,36 +16148,36 @@ function acquireResource(hoistableRoot, resource, props) { return (resource.instance = instance); case "stylesheet": styleProps = getStyleKey(props.href); - var instance$286 = hoistableRoot.querySelector( + var instance$282 = hoistableRoot.querySelector( getStylesheetSelectorFromKey(styleProps) ); - if (instance$286) + if (instance$282) return ( - (resource.instance = instance$286), - markNodeAsHoistable(instance$286), - instance$286 + (resource.instance = instance$282), + markNodeAsHoistable(instance$282), + instance$282 ); instance = stylesheetPropsFromRawProps(props); (styleProps = preloadPropsMap.get(styleProps)) && adoptPreloadPropsForStylesheet(instance, styleProps); - instance$286 = ( + instance$282 = ( hoistableRoot.ownerDocument || hoistableRoot ).createElement("link"); - markNodeAsHoistable(instance$286); - var linkInstance = instance$286; + markNodeAsHoistable(instance$282); + var linkInstance = instance$282; linkInstance._p = new Promise(function (resolve, reject) { linkInstance.onload = resolve; linkInstance.onerror = reject; }); - setInitialProperties(instance$286, "link", instance); + setInitialProperties(instance$282, "link", instance); resource.state.loading |= 4; - insertStylesheet(instance$286, props.precedence, hoistableRoot); - return (resource.instance = instance$286); + insertStylesheet(instance$282, props.precedence, hoistableRoot); + return (resource.instance = instance$282); case "script": - instance$286 = getScriptKey(props.src); + instance$282 = getScriptKey(props.src); if ( (styleProps = hoistableRoot.querySelector( - getScriptSelectorFromKey(instance$286) + getScriptSelectorFromKey(instance$282) )) ) return ( @@ -16237,7 +16186,7 @@ function acquireResource(hoistableRoot, resource, props) { styleProps ); instance = props; - if ((styleProps = preloadPropsMap.get(instance$286))) + if ((styleProps = preloadPropsMap.get(instance$282))) (instance = assign({}, props)), adoptPreloadPropsForScript(instance, styleProps); hoistableRoot = hoistableRoot.ownerDocument || hoistableRoot; @@ -16592,6 +16541,15 @@ function registerReactDOMEvent(target, domEventName, isCapturePhaseListener) { } else throw Error(formatProdErrorMessage(369)); } var Dispatcher = Internals.Dispatcher; +function getCrossOrigin(as, crossOrigin) { + return "font" === as + ? "" + : "string" === typeof crossOrigin + ? "use-credentials" === crossOrigin + ? "use-credentials" + : "" + : void 0; +} Internals.Events = [ getInstanceFromNode$1, getNodeFromInstance, @@ -16600,17 +16558,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1770 = { +var devToolsConfig$jscomp$inline_1766 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-1275e069", + version: "18.3.0-www-modern-5ff32fc3", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2137 = { - bundleType: devToolsConfig$jscomp$inline_1770.bundleType, - version: devToolsConfig$jscomp$inline_1770.version, - rendererPackageName: devToolsConfig$jscomp$inline_1770.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1770.rendererConfig, +var internals$jscomp$inline_2133 = { + bundleType: devToolsConfig$jscomp$inline_1766.bundleType, + version: devToolsConfig$jscomp$inline_1766.version, + rendererPackageName: devToolsConfig$jscomp$inline_1766.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1766.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16627,26 +16585,26 @@ var internals$jscomp$inline_2137 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1770.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1766.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-1275e069" + reconcilerVersion: "18.3.0-www-modern-5ff32fc3" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2138 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2134 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2138.isDisabled && - hook$jscomp$inline_2138.supportsFiber + !hook$jscomp$inline_2134.isDisabled && + hook$jscomp$inline_2134.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2138.inject( - internals$jscomp$inline_2137 + (rendererID = hook$jscomp$inline_2134.inject( + internals$jscomp$inline_2133 )), - (injectedHook = hook$jscomp$inline_2138); + (injectedHook = hook$jscomp$inline_2134); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; @@ -16899,27 +16857,120 @@ exports.observeVisibleRects = function ( }; exports.preconnect = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preconnect(href, options); + dispatcher && + "string" === typeof href && + ((options = options + ? getCrossOrigin("preconnect", options.crossOrigin) + : null), + dispatcher.preconnect(href, options)); }; exports.prefetchDNS = function (href) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.prefetchDNS(href); + dispatcher && "string" === typeof href && dispatcher.prefetchDNS(href); }; exports.preinit = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinit(href, options); + if ( + dispatcher && + "string" === typeof href && + options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin), + integrity = + "string" === typeof options.integrity ? options.integrity : void 0, + fetchPriority = + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0; + "style" === as + ? dispatcher.preinitStyle( + href, + "string" === typeof options.precedence ? options.precedence : void 0, + { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority + } + ) + : "script" === as && + dispatcher.preinitScript(href, { + crossOrigin: crossOrigin, + integrity: integrity, + fetchPriority: fetchPriority, + nonce: "string" === typeof options.nonce ? options.nonce : void 0 + }); + } }; exports.preinitModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preinitModule(href, options); + if ( + dispatcher && + "string" === typeof href && + (null == options || + ("object" === typeof options && + (null == options.as || "script" === options.as))) + ) { + var crossOrigin = options + ? getCrossOrigin(void 0, options.crossOrigin) + : void 0; + dispatcher.preinitModuleScript(href, { + crossOrigin: crossOrigin, + integrity: + options && "string" === typeof options.integrity + ? options.integrity + : void 0 + }); + } }; exports.preload = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preload(href, options); + if ( + dispatcher && + "string" === typeof href && + "object" === typeof options && + null !== options && + "string" === typeof options.as + ) { + var as = options.as, + crossOrigin = getCrossOrigin(as, options.crossOrigin); + dispatcher.preload(href, as, { + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0, + nonce: "string" === typeof options.nonce ? options.nonce : void 0, + type: "string" === typeof options.type ? options.type : void 0, + fetchPriority: + "string" === typeof options.fetchPriority + ? options.fetchPriority + : void 0, + referrerPolicy: + "string" === typeof options.referrerPolicy + ? options.referrerPolicy + : void 0, + imageSrcSet: + "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0, + imageSizes: + "string" === typeof options.imageSizes ? options.imageSizes : void 0 + }); + } }; exports.preloadModule = function (href, options) { var dispatcher = Dispatcher.current; - dispatcher && dispatcher.preloadModule(href, options); + if (dispatcher && "string" === typeof href) + if (options) { + var crossOrigin = getCrossOrigin(options.as, options.crossOrigin); + dispatcher.preloadModule(href, { + as: + "string" === typeof options.as && "script" !== options.as + ? options.as + : void 0, + crossOrigin: crossOrigin, + integrity: + "string" === typeof options.integrity ? options.integrity : void 0 + }); + } else dispatcher.preloadModule(href); }; exports.unstable_batchedUpdates = batchedUpdates$1; exports.unstable_createEventHandle = function (type, options) { @@ -16952,4 +17003,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-1275e069"; +exports.version = "18.3.0-www-modern-5ff32fc3"; diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index 56439b2ab2286..64a5224f3724a 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -24356,7 +24356,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-d80c0530"; +var ReactVersion = "18.3.0-www-classic-f857f390"; // Might add PROFILE later. diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index 2ef1f709f2559..8d6d030d8e951 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -24356,7 +24356,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-10bb4e89"; +var ReactVersion = "18.3.0-www-modern-8702abe1"; // Might add PROFILE later. diff --git a/compiled/facebook-www/WARNINGS b/compiled/facebook-www/WARNINGS index 77a7f99258d47..7863406095220 100644 --- a/compiled/facebook-www/WARNINGS +++ b/compiled/facebook-www/WARNINGS @@ -238,15 +238,11 @@ "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`." "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`." "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead." -"ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead." -"ReactDOM.preinit() expected the second argument to be an options argument containing at least an \"as\" property specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are \"style\" and \"script\". The href for the preinit call where this warning originated is \"%s\"." -"ReactDOM.preinit() expected the second argument to be an options argument containing at least an \"as\" property specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is \"%s\"." "ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are \"style\" and \"script\"." "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead." "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead." "ReactDOM.preinitModule(): Currently the only supported \"as\" type for this function is \"script\" but received \"%s\" instead. This warning was generated for `href` \"%s\". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)" "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s" -"ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag. %s" "ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `` tag.%s" "ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `` tag.%s" "ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"