From 17b73906924d476e561b65863c7961d379f53e36 Mon Sep 17 00:00:00 2001 From: kassens Date: Thu, 18 Apr 2024 20:48:47 +0000 Subject: [PATCH] Remove ReactFlightFB bundles (#28864) Remove ReactFlightFB bundles DiffTrain build for [1cd77a4ff7a2189003965246a3cfc475d2d9857d](https://github.com/facebook/react/commit/1cd77a4ff7a2189003965246a3cfc475d2d9857d) --- compiled/facebook-www/REVISION | 2 +- .../ReactFlightDOMClient-dev.modern.js | 1532 -------- .../ReactFlightDOMClient-prod.modern.js | 610 --- .../ReactFlightDOMServer-dev.modern.js | 3266 ----------------- .../ReactFlightDOMServer-prod.modern.js | 1171 ------ .../facebook-www/ReactServer-dev.modern.js | 3160 ---------------- .../facebook-www/ReactServer-prod.modern.js | 595 --- 7 files changed, 1 insertion(+), 10335 deletions(-) delete mode 100644 compiled/facebook-www/ReactFlightDOMClient-dev.modern.js delete mode 100644 compiled/facebook-www/ReactFlightDOMClient-prod.modern.js delete mode 100644 compiled/facebook-www/ReactFlightDOMServer-dev.modern.js delete mode 100644 compiled/facebook-www/ReactFlightDOMServer-prod.modern.js delete mode 100644 compiled/facebook-www/ReactServer-dev.modern.js delete mode 100644 compiled/facebook-www/ReactServer-prod.modern.js diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index caf9c6785464e..b29a1494c8123 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -ea24427d16f3ac9b0f3bb45cdc7919ac208130c9 +1cd77a4ff7a2189003965246a3cfc475d2d9857d diff --git a/compiled/facebook-www/ReactFlightDOMClient-dev.modern.js b/compiled/facebook-www/ReactFlightDOMClient-dev.modern.js deleted file mode 100644 index 4f930c09a6440..0000000000000 --- a/compiled/facebook-www/ReactFlightDOMClient-dev.modern.js +++ /dev/null @@ -1,1532 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; - -if (__DEV__) { - (function () { - "use strict"; - - var ReactDOM = require("react-dom"); - - // Re-export dynamic flags from the www version. - var dynamicFeatureFlags = require("ReactFeatureFlags"); - - var enableRefAsProp = dynamicFeatureFlags.enableRefAsProp; - // On WWW, true is used for a new modern build. - var enableBinaryFlight = false; - - function createStringDecoder() { - return new TextDecoder(); - } - var decoderOptions = { - stream: true - }; - function readPartialStringChunk(decoder, buffer) { - return decoder.decode(buffer, decoderOptions); - } - function readFinalStringChunk(decoder, buffer) { - return decoder.decode(buffer); - } - - var badgeFormat = "[%s] "; - var pad = " "; - function printToConsole(methodName, args, badgeName) { - var offset = 0; - - switch (methodName) { - case "dir": - case "dirxml": - case "groupEnd": - case "table": { - // These methods cannot be colorized because they don't take a formatting string. - // eslint-disable-next-line react-internal/no-production-logging - console[methodName].apply(console, args); - return; - } - - case "assert": { - // assert takes formatting options as the second argument. - offset = 1; - } - } - - var newArgs = args.slice(0); - - if (typeof newArgs[offset] === "string") { - newArgs.splice( - offset, - 1, - badgeFormat + newArgs[offset], - pad + badgeName + pad - ); - } else { - newArgs.splice(offset, 0, badgeFormat, pad + badgeName + pad); - } // eslint-disable-next-line react-internal/no-production-logging - - console[methodName].apply(console, newArgs); - return; - } - - var ReactDOMSharedInternals = - ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; - - // This client file is in the shared folder because it applies to both SSR and browser contexts. - function dispatchHint(code, model) { - var dispatcher = ReactDOMSharedInternals.d; - /* ReactDOMCurrentDispatcher */ - - switch (code) { - case "D": { - var refined = refineModel(code, model); - var href = refined; - dispatcher.D( - /* prefetchDNS */ - href - ); - return; - } - - case "C": { - var _refined = refineModel(code, model); - - if (typeof _refined === "string") { - var _href = _refined; - dispatcher.C( - /* preconnect */ - _href - ); - } else { - var _href2 = _refined[0]; - var crossOrigin = _refined[1]; - dispatcher.C( - /* preconnect */ - _href2, - crossOrigin - ); - } - - return; - } - - case "L": { - var _refined2 = refineModel(code, model); - - var _href3 = _refined2[0]; - var as = _refined2[1]; - - if (_refined2.length === 3) { - var options = _refined2[2]; - dispatcher.L( - /* preload */ - _href3, - as, - options - ); - } else { - dispatcher.L( - /* preload */ - _href3, - as - ); - } - - return; - } - - case "m": { - var _refined3 = refineModel(code, model); - - if (typeof _refined3 === "string") { - var _href4 = _refined3; - dispatcher.m( - /* preloadModule */ - _href4 - ); - } else { - var _href5 = _refined3[0]; - var _options = _refined3[1]; - dispatcher.m( - /* preloadModule */ - _href5, - _options - ); - } - - return; - } - - case "X": { - var _refined4 = refineModel(code, model); - - if (typeof _refined4 === "string") { - var _href6 = _refined4; - dispatcher.X( - /* preinitScript */ - _href6 - ); - } else { - var _href7 = _refined4[0]; - var _options2 = _refined4[1]; - dispatcher.X( - /* preinitScript */ - _href7, - _options2 - ); - } - - return; - } - - case "S": { - var _refined5 = refineModel(code, model); - - if (typeof _refined5 === "string") { - var _href8 = _refined5; - dispatcher.S( - /* preinitStyle */ - _href8 - ); - } else { - var _href9 = _refined5[0]; - var precedence = _refined5[1] === 0 ? undefined : _refined5[1]; - - var _options3 = _refined5.length === 3 ? _refined5[2] : undefined; - - dispatcher.S( - /* preinitStyle */ - _href9, - precedence, - _options3 - ); - } - - return; - } - - case "M": { - var _refined6 = refineModel(code, model); - - if (typeof _refined6 === "string") { - var _href10 = _refined6; - dispatcher.M( - /* preinitModuleScript */ - _href10 - ); - } else { - var _href11 = _refined6[0]; - var _options4 = _refined6[1]; - dispatcher.M( - /* preinitModuleScript */ - _href11, - _options4 - ); - } - - return; - } - } - } // Flow is having trouble refining the HintModels so we help it a bit. - // This should be compiled out in the production build. - - function refineModel(code, model) { - return model; - } - - function resolveClientReference(moduleMap, metadata) { - if (typeof moduleMap.resolveClientReference === "function") { - return moduleMap.resolveClientReference(metadata); - } else { - throw new Error( - "Expected `resolveClientReference` to be defined on the moduleMap." - ); - } - } - var asyncModuleCache = new Map(); - function preloadModule(clientReference) { - var existingPromise = asyncModuleCache.get(clientReference.getModuleId()); - - if (existingPromise) { - if (existingPromise.status === "fulfilled") { - return null; - } - - return existingPromise; - } else { - var modulePromise = clientReference.load(); - modulePromise.then( - function (value) { - var fulfilledThenable = modulePromise; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = value; - }, - function (reason) { - var rejectedThenable = modulePromise; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = reason; - } - ); - asyncModuleCache.set(clientReference.getModuleId(), modulePromise); - return modulePromise; - } - } - function requireModule(clientReference) { - var module; // We assume that preloadModule has been called before, which - // should have added something to the module cache. - - var promise = asyncModuleCache.get(clientReference.getModuleId()); - - if (promise.status === "fulfilled") { - module = promise.value; - } else { - throw promise.reason; - } // We are currently only support default exports for client components - - return module; - } - - // This refers to a WWW module. - require("warning"); - - // ATTENTION - // When adding new symbols to this file, - // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' - // The Symbol used to tag the ReactElement-like types. - var REACT_ELEMENT_TYPE = Symbol.for("react.element"); - var REACT_LAZY_TYPE = Symbol.for("react.lazy"); - var ASYNC_ITERATOR = Symbol.asyncIterator; - - function readTemporaryReference(set, id) { - if (id < 0 || id >= set.length) { - throw new Error( - "The RSC response contained a reference that doesn't exist in the temporary reference set. " + - "Always pass the matching set that was used to create the reply when parsing its response." - ); - } - - return set[id]; - } - - var knownServerReferences = new WeakMap(); // Serializable values - - function registerServerReference(proxy, reference, encodeFormAction) { - knownServerReferences.set(proxy, reference); - } // $FlowFixMe[method-unbinding] - - var ROW_ID = 0; - var ROW_TAG = 1; - var ROW_LENGTH = 2; - var ROW_CHUNK_BY_NEWLINE = 3; - var ROW_CHUNK_BY_LENGTH = 4; - var PENDING = "pending"; - var BLOCKED = "blocked"; - var CYCLIC = "cyclic"; - var RESOLVED_MODEL = "resolved_model"; - var RESOLVED_MODULE = "resolved_module"; - var INITIALIZED = "fulfilled"; - var ERRORED = "rejected"; // $FlowFixMe[missing-this-annot] - - function Chunk(status, value, reason, response) { - this.status = status; - this.value = value; - this.reason = reason; - this._response = response; - - { - this._debugInfo = null; - } - } // We subclass Promise.prototype so that we get other methods like .catch - - Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then - - Chunk.prototype.then = function (resolve, reject) { - var chunk = this; // If we have resolved content, we try to initialize it first which - // might put us back into one of the other states. - - switch (chunk.status) { - case RESOLVED_MODEL: - initializeModelChunk(chunk); - break; - - case RESOLVED_MODULE: - initializeModuleChunk(chunk); - break; - } // The status might have changed after initialization. - - switch (chunk.status) { - case INITIALIZED: - resolve(chunk.value); - break; - - case PENDING: - case BLOCKED: - case CYCLIC: - if (resolve) { - if (chunk.value === null) { - chunk.value = []; - } - - chunk.value.push(resolve); - } - - if (reject) { - if (chunk.reason === null) { - chunk.reason = []; - } - - chunk.reason.push(reject); - } - - break; - - default: - if (reject) { - reject(chunk.reason); - } - - break; - } - }; - - function readChunk(chunk) { - // If we have resolved content, we try to initialize it first which - // might put us back into one of the other states. - switch (chunk.status) { - case RESOLVED_MODEL: - initializeModelChunk(chunk); - break; - - case RESOLVED_MODULE: - initializeModuleChunk(chunk); - break; - } // The status might have changed after initialization. - - switch (chunk.status) { - case INITIALIZED: - return chunk.value; - - case PENDING: - case BLOCKED: - case CYCLIC: - // eslint-disable-next-line no-throw-literal - throw chunk; - - default: - throw chunk.reason; - } - } - - function getRoot(response) { - var chunk = getChunk(response, 0); - return chunk; - } - - function createPendingChunk(response) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(PENDING, null, null, response); - } - - function createBlockedChunk(response) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(BLOCKED, null, null, response); - } - - function createErrorChunk(response, error) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(ERRORED, null, error, response); - } - - function wakeChunk(listeners, value) { - for (var i = 0; i < listeners.length; i++) { - var listener = listeners[i]; - listener(value); - } - } - - function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) { - switch (chunk.status) { - case INITIALIZED: - wakeChunk(resolveListeners, chunk.value); - break; - - case PENDING: - case BLOCKED: - case CYCLIC: - chunk.value = resolveListeners; - chunk.reason = rejectListeners; - break; - - case ERRORED: - if (rejectListeners) { - wakeChunk(rejectListeners, chunk.reason); - } - - break; - } - } - - function triggerErrorOnChunk(chunk, error) { - if (chunk.status !== PENDING && chunk.status !== BLOCKED) { - return; - } - - var listeners = chunk.reason; - var erroredChunk = chunk; - erroredChunk.status = ERRORED; - erroredChunk.reason = error; - - if (listeners !== null) { - wakeChunk(listeners, error); - } - } - - function createResolvedModelChunk(response, value) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(RESOLVED_MODEL, value, null, response); - } - - function createResolvedModuleChunk(response, value) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(RESOLVED_MODULE, value, null, response); - } - - function createInitializedTextChunk(response, value) { - // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors - return new Chunk(INITIALIZED, value, null, response); - } - - function resolveModelChunk(chunk, value) { - if (chunk.status !== PENDING) { - return; - } - - var resolveListeners = chunk.value; - var rejectListeners = chunk.reason; - var resolvedChunk = chunk; - resolvedChunk.status = RESOLVED_MODEL; - resolvedChunk.value = value; - - if (resolveListeners !== null) { - // This is unfortunate that we're reading this eagerly if - // we already have listeners attached since they might no - // longer be rendered or might not be the highest pri. - initializeModelChunk(resolvedChunk); // The status might have changed after initialization. - - wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners); - } - } - - function resolveModuleChunk(chunk, value) { - if (chunk.status !== PENDING && chunk.status !== BLOCKED) { - // We already resolved. We didn't expect to see this. - return; - } - - var resolveListeners = chunk.value; - var rejectListeners = chunk.reason; - var resolvedChunk = chunk; - resolvedChunk.status = RESOLVED_MODULE; - resolvedChunk.value = value; - - if (resolveListeners !== null) { - initializeModuleChunk(resolvedChunk); - wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners); - } - } - - var initializingChunk = null; - var initializingChunkBlockedModel = null; - - function initializeModelChunk(chunk) { - var prevChunk = initializingChunk; - var prevBlocked = initializingChunkBlockedModel; - initializingChunk = chunk; - initializingChunkBlockedModel = null; - var resolvedModel = chunk.value; // We go to the CYCLIC state until we've fully resolved this. - // We do this before parsing in case we try to initialize the same chunk - // while parsing the model. Such as in a cyclic reference. - - var cyclicChunk = chunk; - cyclicChunk.status = CYCLIC; - cyclicChunk.value = null; - cyclicChunk.reason = null; - - try { - var value = parseModel(chunk._response, resolvedModel); - - if ( - initializingChunkBlockedModel !== null && - initializingChunkBlockedModel.deps > 0 - ) { - initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved. - // We have to go the BLOCKED state until they're resolved. - - var blockedChunk = chunk; - blockedChunk.status = BLOCKED; - blockedChunk.value = null; - blockedChunk.reason = null; - } else { - var resolveListeners = cyclicChunk.value; - var initializedChunk = chunk; - initializedChunk.status = INITIALIZED; - initializedChunk.value = value; - - if (resolveListeners !== null) { - wakeChunk(resolveListeners, value); - } - } - } catch (error) { - var erroredChunk = chunk; - erroredChunk.status = ERRORED; - erroredChunk.reason = error; - } finally { - initializingChunk = prevChunk; - initializingChunkBlockedModel = prevBlocked; - } - } - - function initializeModuleChunk(chunk) { - try { - var value = requireModule(chunk.value); - var initializedChunk = chunk; - initializedChunk.status = INITIALIZED; - initializedChunk.value = value; - } catch (error) { - var erroredChunk = chunk; - erroredChunk.status = ERRORED; - erroredChunk.reason = error; - } - } // Report that any missing chunks in the model is now going to throw this - // error upon read. Also notify any pending promises. - - function reportGlobalError(response, error) { - response._chunks.forEach(function (chunk) { - // If this chunk was already resolved or errored, it won't - // trigger an error but if it wasn't then we need to - // because we won't be getting any new data to resolve it. - if (chunk.status === PENDING) { - triggerErrorOnChunk(chunk, error); - } - }); - } - - function nullRefGetter() { - { - return null; - } - } - - function createElement(type, key, props, owner) { - // DEV-only - var element; - - if (enableRefAsProp) { - // `ref` is non-enumerable in dev - element = { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - props: props, - _owner: owner - }; - Object.defineProperty(element, "ref", { - enumerable: false, - get: nullRefGetter - }); - } else { - element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - ref: null, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - } - - { - // We don't really need to add any of these but keeping them for good measure. - // Unfortunately, _store is enumerable in jest matchers so for equality to - // work, I need to keep it or make _store non-enumerable in the other file. - element._store = {}; - Object.defineProperty(element._store, "validated", { - configurable: false, - enumerable: false, - writable: true, - value: true // This element has already been validated on the server. - }); // debugInfo contains Server Component debug information. - - Object.defineProperty(element, "_debugInfo", { - configurable: false, - enumerable: false, - writable: true, - value: null - }); - } - - return element; - } - - function createLazyChunkWrapper(chunk) { - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _payload: chunk, - _init: readChunk - }; - - { - // Ensure we have a live array to track future debug info. - var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []); - lazyType._debugInfo = chunkDebugInfo; - } - - return lazyType; - } - - function getChunk(response, id) { - var chunks = response._chunks; - var chunk = chunks.get(id); - - if (!chunk) { - chunk = createPendingChunk(response); - chunks.set(id, chunk); - } - - return chunk; - } - - function createModelResolver( - chunk, - parentObject, - key, - cyclic, - response, - map - ) { - var blocked; - - if (initializingChunkBlockedModel) { - blocked = initializingChunkBlockedModel; - - if (!cyclic) { - blocked.deps++; - } - } else { - blocked = initializingChunkBlockedModel = { - deps: cyclic ? 0 : 1, - value: null - }; - } - - return function (value) { - parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value` - // is a stale `null`, the resolved value can be used directly. - - if (key === "" && blocked.value === null) { - blocked.value = parentObject[key]; - } - - blocked.deps--; - - if (blocked.deps === 0) { - if (chunk.status !== BLOCKED) { - return; - } - - var resolveListeners = chunk.value; - var initializedChunk = chunk; - initializedChunk.status = INITIALIZED; - initializedChunk.value = blocked.value; - - if (resolveListeners !== null) { - wakeChunk(resolveListeners, blocked.value); - } - } - }; - } - - function createModelReject(chunk) { - return function (error) { - return triggerErrorOnChunk(chunk, error); - }; - } - - function createServerReferenceProxy(response, metaData) { - var callServer = response._callServer; - - var proxy = function () { - // $FlowFixMe[method-unbinding] - var args = Array.prototype.slice.call(arguments); - var p = metaData.bound; - - if (!p) { - return callServer(metaData.id, args); - } - - if (p.status === INITIALIZED) { - var bound = p.value; - return callServer(metaData.id, bound.concat(args)); - } // Since this is a fake Promise whose .then doesn't chain, we have to wrap it. - // TODO: Remove the wrapper once that's fixed. - - return Promise.resolve(p).then(function (bound) { - return callServer(metaData.id, bound.concat(args)); - }); - }; - - registerServerReference(proxy, metaData); - return proxy; - } - - function getOutlinedModel(response, id, parentObject, key, map) { - var chunk = getChunk(response, id); - - switch (chunk.status) { - case RESOLVED_MODEL: - initializeModelChunk(chunk); - break; - - case RESOLVED_MODULE: - initializeModuleChunk(chunk); - break; - } // The status might have changed after initialization. - - switch (chunk.status) { - case INITIALIZED: - var chunkValue = map(response, chunk.value); - - if (chunk._debugInfo) { - // If we have a direct reference to an object that was rendered by a synchronous - // server component, it might have some debug info about how it was rendered. - // We forward this to the underlying object. This might be a React Element or - // an Array fragment. - // If this was a string / number return value we lose the debug info. We choose - // that tradeoff to allow sync server components to return plain values and not - // use them as React Nodes necessarily. We could otherwise wrap them in a Lazy. - if ( - typeof chunkValue === "object" && - chunkValue !== null && - (Array.isArray(chunkValue) || - typeof chunkValue[ASYNC_ITERATOR] === "function" || - chunkValue.$$typeof === REACT_ELEMENT_TYPE) && - !chunkValue._debugInfo - ) { - // We should maybe use a unique symbol for arrays but this is a React owned array. - // $FlowFixMe[prop-missing]: This should be added to elements. - Object.defineProperty(chunkValue, "_debugInfo", { - configurable: false, - enumerable: false, - writable: true, - value: chunk._debugInfo - }); - } - } - - return chunkValue; - - case PENDING: - case BLOCKED: - case CYCLIC: - var parentChunk = initializingChunk; - chunk.then( - createModelResolver( - parentChunk, - parentObject, - key, - chunk.status === CYCLIC, - response, - map - ), - createModelReject(parentChunk) - ); - return null; - - default: - throw chunk.reason; - } - } - - function createMap(response, model) { - return new Map(model); - } - - function createSet(response, model) { - return new Set(model); - } - - function createFormData(response, model) { - var formData = new FormData(); - - for (var i = 0; i < model.length; i++) { - formData.append(model[i][0], model[i][1]); - } - - return formData; - } - - function createModel(response, model) { - return model; - } - - function parseModelString(response, parentObject, key, value) { - if (value[0] === "$") { - if (value === "$") { - // A very common symbol. - return REACT_ELEMENT_TYPE; - } - - switch (value[1]) { - case "$": { - // This was an escaped string value. - return value.slice(1); - } - - case "L": { - // Lazy node - var id = parseInt(value.slice(2), 16); - var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values. - // When passed into React, we'll know how to suspend on this. - - return createLazyChunkWrapper(chunk); - } - - case "@": { - // Promise - if (value.length === 2) { - // Infinite promise that never resolves. - return new Promise(function () {}); - } - - var _id = parseInt(value.slice(2), 16); - - var _chunk = getChunk(response, _id); - - return _chunk; - } - - case "S": { - // Symbol - return Symbol.for(value.slice(2)); - } - - case "F": { - // Server Reference - var _id2 = parseInt(value.slice(2), 16); - - return getOutlinedModel( - response, - _id2, - parentObject, - key, - createServerReferenceProxy - ); - } - - case "T": { - // Temporary Reference - var _id3 = parseInt(value.slice(2), 16); - - var temporaryReferences = response._tempRefs; - - if (temporaryReferences == null) { - throw new Error( - "Missing a temporary reference set but the RSC response returned a temporary reference. " + - "Pass a temporaryReference option with the set that was used with the reply." - ); - } - - return readTemporaryReference(temporaryReferences, _id3); - } - - case "Q": { - // Map - var _id4 = parseInt(value.slice(2), 16); - - return getOutlinedModel( - response, - _id4, - parentObject, - key, - createMap - ); - } - - case "W": { - // Set - var _id5 = parseInt(value.slice(2), 16); - - return getOutlinedModel( - response, - _id5, - parentObject, - key, - createSet - ); - } - - case "B": { - return undefined; - } - - case "K": { - // FormData - var _id7 = parseInt(value.slice(2), 16); - - return getOutlinedModel( - response, - _id7, - parentObject, - key, - createFormData - ); - } - - case "I": { - // $Infinity - return Infinity; - } - - case "-": { - // $-0 or $-Infinity - if (value === "$-0") { - return -0; - } else { - return -Infinity; - } - } - - case "N": { - // $NaN - return NaN; - } - - case "u": { - // matches "$undefined" - // Special encoding for `undefined` which can't be serialized as JSON otherwise. - return undefined; - } - - case "D": { - // Date - return new Date(Date.parse(value.slice(2))); - } - - case "n": { - // BigInt - return BigInt(value.slice(2)); - } - - case "E": { - { - // In DEV mode we allow indirect eval to produce functions for logging. - // This should not compile to eval() because then it has local scope access. - try { - // eslint-disable-next-line no-eval - return (0, eval)(value.slice(2)); - } catch (x) { - // We currently use this to express functions so we fail parsing it, - // let's just return a blank function as a place holder. - return function () {}; - } - } // Fallthrough - } - - default: { - // We assume that anything else is a reference ID. - var _id8 = parseInt(value.slice(1), 16); - - return getOutlinedModel( - response, - _id8, - parentObject, - key, - createModel - ); - } - } - } - - return value; - } - - function parseModelTuple(response, value) { - var tuple = value; - - if (tuple[0] === REACT_ELEMENT_TYPE) { - // TODO: Consider having React just directly accept these arrays as elements. - // Or even change the ReactElement type to be an array. - return createElement(tuple[1], tuple[2], tuple[3], tuple[4]); - } - - return value; - } - - function missingCall() { - throw new Error( - 'Trying to call a function from "use server" but the callServer option ' + - "was not implemented in your router runtime." - ); - } - - function createResponse( - bundlerConfig, - moduleLoading, - callServer, - encodeFormAction, - nonce, - temporaryReferences - ) { - var chunks = new Map(); - var response = { - _bundlerConfig: bundlerConfig, - _moduleLoading: moduleLoading, - _callServer: callServer !== undefined ? callServer : missingCall, - _encodeFormAction: encodeFormAction, - _nonce: nonce, - _chunks: chunks, - _stringDecoder: createStringDecoder(), - _fromJSON: null, - _rowState: 0, - _rowID: 0, - _rowTag: 0, - _rowLength: 0, - _buffer: [], - _tempRefs: temporaryReferences - }; // Don't inline this call because it causes closure to outline the call above. - - response._fromJSON = createFromJSONCallback(response); - return response; - } - - function resolveModel(response, id, model) { - var chunks = response._chunks; - var chunk = chunks.get(id); - - if (!chunk) { - chunks.set(id, createResolvedModelChunk(response, model)); - } else { - resolveModelChunk(chunk, model); - } - } - - function resolveText(response, id, text) { - var chunks = response._chunks; - - chunks.set(id, createInitializedTextChunk(response, text)); - } - - function resolveModule(response, id, model) { - var chunks = response._chunks; - var chunk = chunks.get(id); - var clientReferenceMetadata = parseModel(response, model); - var clientReference = resolveClientReference( - response._bundlerConfig, - clientReferenceMetadata - ); - // For now we preload all modules as early as possible since it's likely - // that we'll need them. - - var promise = preloadModule(clientReference); - - if (promise) { - var blockedChunk; - - if (!chunk) { - // Technically, we should just treat promise as the chunk in this - // case. Because it'll just behave as any other promise. - blockedChunk = createBlockedChunk(response); - chunks.set(id, blockedChunk); - } else { - // This can't actually happen because we don't have any forward - // references to modules. - blockedChunk = chunk; - blockedChunk.status = BLOCKED; - } - - promise.then( - function () { - return resolveModuleChunk(blockedChunk, clientReference); - }, - function (error) { - return triggerErrorOnChunk(blockedChunk, error); - } - ); - } else { - if (!chunk) { - chunks.set(id, createResolvedModuleChunk(response, clientReference)); - } else { - // This can't actually happen because we don't have any forward - // references to modules. - resolveModuleChunk(chunk, clientReference); - } - } - } - - function resolveErrorDev(response, id, digest, message, stack) { - var error = new Error( - message || - "An error occurred in the Server Components render but no message was provided" - ); - error.stack = stack; - error.digest = digest; - var errorWithDigest = error; - var chunks = response._chunks; - var chunk = chunks.get(id); - - if (!chunk) { - chunks.set(id, createErrorChunk(response, errorWithDigest)); - } else { - triggerErrorOnChunk(chunk, errorWithDigest); - } - } - - function resolveHint(response, code, model) { - var hintModel = parseModel(response, model); - dispatchHint(code, hintModel); - } - - function resolveDebugInfo(response, id, debugInfo) { - var chunk = getChunk(response, id); - var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []); - chunkDebugInfo.push(debugInfo); - } - - function resolveConsoleEntry(response, value) { - var payload = parseModel(response, value); - var methodName = payload[0]; // TODO: Restore the fake stack before logging. - // const stackTrace = payload[1]; - // const owner = payload[2]; - - var env = payload[3]; - var args = payload.slice(4); - printToConsole(methodName, args, env); - } - - function processFullRow(response, id, tag, buffer, chunk) { - var stringDecoder = response._stringDecoder; - var row = ""; - - for (var i = 0; i < buffer.length; i++) { - row += readPartialStringChunk(stringDecoder, buffer[i]); - } - - row += readFinalStringChunk(stringDecoder, chunk); - - switch (tag) { - case 73: /* "I" */ - { - resolveModule(response, id, row); - return; - } - - case 72: /* "H" */ - { - var code = row[0]; - resolveHint(response, code, row.slice(1)); - return; - } - - case 69: /* "E" */ - { - var errorInfo = JSON.parse(row); - - { - resolveErrorDev( - response, - id, - errorInfo.digest, - errorInfo.message, - errorInfo.stack - ); - } - - return; - } - - case 84: /* "T" */ - { - resolveText(response, id, row); - return; - } - - case 68: /* "D" */ - { - { - var debugInfo = parseModel(response, row); - resolveDebugInfo(response, id, debugInfo); - return; - } // Fallthrough to share the error with Console entries. - } - - case 87: /* "W" */ - { - { - resolveConsoleEntry(response, row); - return; - } - } - - case 82: - /* "R" */ - // Fallthrough - - case 114: - /* "r" */ - // Fallthrough - - case 88: - /* "X" */ - // Fallthrough - - case 120: - /* "x" */ - // Fallthrough - - case 67: - /* "C" */ - // Fallthrough - - case 80: - /* "P" */ - // Fallthrough - - default: /* """ "{" "[" "t" "f" "n" "0" - "9" */ - { - // We assume anything else is JSON. - resolveModel(response, id, row); - return; - } - } - } - - function processBinaryChunk(response, chunk) { - var i = 0; - var rowState = response._rowState; - var rowID = response._rowID; - var rowTag = response._rowTag; - var rowLength = response._rowLength; - var buffer = response._buffer; - var chunkLength = chunk.length; - - while (i < chunkLength) { - var lastIdx = -1; - - switch (rowState) { - case ROW_ID: { - var byte = chunk[i++]; - - if ( - byte === 58 - /* ":" */ - ) { - // Finished the rowID, next we'll parse the tag. - rowState = ROW_TAG; - } else { - rowID = (rowID << 4) | (byte > 96 ? byte - 87 : byte - 48); - } - - continue; - } - - case ROW_TAG: { - var resolvedRowTag = chunk[i]; - - if ( - resolvedRowTag === 84 || - /* "T" */ - enableBinaryFlight - /* "V" */ - ) { - rowTag = resolvedRowTag; - rowState = ROW_LENGTH; - i++; - } else if ( - (resolvedRowTag > 64 && resolvedRowTag < 91) || - /* "A"-"Z" */ - resolvedRowTag === 114 || - /* "r" */ - resolvedRowTag === 120 - /* "x" */ - ) { - rowTag = resolvedRowTag; - rowState = ROW_CHUNK_BY_NEWLINE; - i++; - } else { - rowTag = 0; - rowState = ROW_CHUNK_BY_NEWLINE; // This was an unknown tag so it was probably part of the data. - } - - continue; - } - - case ROW_LENGTH: { - var _byte = chunk[i++]; - - if ( - _byte === 44 - /* "," */ - ) { - // Finished the rowLength, next we'll buffer up to that length. - rowState = ROW_CHUNK_BY_LENGTH; - } else { - rowLength = - (rowLength << 4) | (_byte > 96 ? _byte - 87 : _byte - 48); - } - - continue; - } - - case ROW_CHUNK_BY_NEWLINE: { - // We're looking for a newline - lastIdx = chunk.indexOf( - 10, - /* "\n" */ - i - ); - break; - } - - case ROW_CHUNK_BY_LENGTH: { - // We're looking for the remaining byte length - lastIdx = i + rowLength; - - if (lastIdx > chunk.length) { - lastIdx = -1; - } - - break; - } - } - - var offset = chunk.byteOffset + i; - - if (lastIdx > -1) { - // We found the last chunk of the row - var length = lastIdx - i; - var lastChunk = new Uint8Array(chunk.buffer, offset, length); - processFullRow(response, rowID, rowTag, buffer, lastChunk); // Reset state machine for a new row - - i = lastIdx; - - if (rowState === ROW_CHUNK_BY_NEWLINE) { - // If we're trailing by a newline we need to skip it. - i++; - } - - rowState = ROW_ID; - rowTag = 0; - rowID = 0; - rowLength = 0; - buffer.length = 0; - } else { - // The rest of this row is in a future chunk. We stash the rest of the - // current chunk until we can process the full row. - var _length = chunk.byteLength - i; - - var remainingSlice = new Uint8Array(chunk.buffer, offset, _length); - buffer.push(remainingSlice); // Update how many bytes we're still waiting for. If we're looking for - // a newline, this doesn't hurt since we'll just ignore it. - - rowLength -= remainingSlice.byteLength; - break; - } - } - - response._rowState = rowState; - response._rowID = rowID; - response._rowTag = rowTag; - response._rowLength = rowLength; - } - - function parseModel(response, json) { - return JSON.parse(json, response._fromJSON); - } - - function createFromJSONCallback(response) { - // $FlowFixMe[missing-this-annot] - return function (key, value) { - if (typeof value === "string") { - // We can't use .bind here because we need the "this" value. - return parseModelString(response, this, key, value); - } - - if (typeof value === "object" && value !== null) { - return parseModelTuple(response, value); - } - - return value; - }; - } - - function close(response) { - // In case there are any remaining unresolved chunks, they won't - // be resolved now. So we need to issue an error to those. - // Ideally we should be able to early bail out if we kept a - // ref count of pending chunks. - reportGlobalError(response, new Error("Connection closed.")); - } - - function createResponseFromOptions(options) { - var moduleMap = options && options.moduleMap; - - if (moduleMap == null) { - throw new Error("Expected `moduleMap` to be defined."); - } - - return createResponse(moduleMap, null, undefined, undefined); - } - - function processChunk(response, chunk) { - var buffer = typeof chunk !== "string" ? chunk : encodeString(chunk); - processBinaryChunk(response, buffer); - } - - function encodeString(string) { - var textEncoder = new TextEncoder(); - return textEncoder.encode(string); - } - - function startReadingFromStream(response, stream) { - var reader = stream.getReader(); - - function progress(_ref) { - var done = _ref.done, - value = _ref.value; - - if (done) { - close(response); - return; - } - - var buffer = value; - processChunk(response, buffer); - return reader.read().then(progress).catch(error); - } - - function error(e) { - reportGlobalError(response, e); - } - - reader.read().then(progress).catch(error); - } - - function createFromReadableStream(stream, options) { - var response = createResponseFromOptions(options); - startReadingFromStream(response, stream); - return getRoot(response); - } - - exports.createFromReadableStream = createFromReadableStream; - })(); -} diff --git a/compiled/facebook-www/ReactFlightDOMClient-prod.modern.js b/compiled/facebook-www/ReactFlightDOMClient-prod.modern.js deleted file mode 100644 index 7ea8b3ac454b9..0000000000000 --- a/compiled/facebook-www/ReactFlightDOMClient-prod.modern.js +++ /dev/null @@ -1,610 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; -var ReactDOM = require("react-dom"); -require("ReactFeatureFlags"); -var decoderOptions = { stream: !0 }, - ReactDOMSharedInternals = - ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; -function resolveClientReference(moduleMap, metadata) { - if ("function" === typeof moduleMap.resolveClientReference) - return moduleMap.resolveClientReference(metadata); - throw Error( - "Expected `resolveClientReference` to be defined on the moduleMap." - ); -} -var asyncModuleCache = new Map(); -function preloadModule(clientReference) { - var existingPromise = asyncModuleCache.get(clientReference.getModuleId()); - if (existingPromise) - return "fulfilled" === existingPromise.status ? null : existingPromise; - var modulePromise = clientReference.load(); - modulePromise.then( - function (value) { - modulePromise.status = "fulfilled"; - modulePromise.value = value; - }, - function (reason) { - modulePromise.status = "rejected"; - modulePromise.reason = reason; - } - ); - asyncModuleCache.set(clientReference.getModuleId(), modulePromise); - return modulePromise; -} -var REACT_ELEMENT_TYPE = Symbol.for("react.element"), - REACT_LAZY_TYPE = Symbol.for("react.lazy"), - knownServerReferences = new WeakMap(); -function Chunk(status, value, reason, response) { - this.status = status; - this.value = value; - this.reason = reason; - this._response = response; -} -Chunk.prototype = Object.create(Promise.prototype); -Chunk.prototype.then = function (resolve, reject) { - switch (this.status) { - case "resolved_model": - initializeModelChunk(this); - break; - case "resolved_module": - initializeModuleChunk(this); - } - switch (this.status) { - case "fulfilled": - resolve(this.value); - break; - case "pending": - case "blocked": - case "cyclic": - resolve && - (null === this.value && (this.value = []), this.value.push(resolve)); - reject && - (null === this.reason && (this.reason = []), this.reason.push(reject)); - break; - default: - reject && reject(this.reason); - } -}; -function readChunk(chunk) { - switch (chunk.status) { - case "resolved_model": - initializeModelChunk(chunk); - break; - case "resolved_module": - initializeModuleChunk(chunk); - } - switch (chunk.status) { - case "fulfilled": - return chunk.value; - case "pending": - case "blocked": - case "cyclic": - throw chunk; - default: - throw chunk.reason; - } -} -function wakeChunk(listeners, value) { - for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value); -} -function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) { - switch (chunk.status) { - case "fulfilled": - wakeChunk(resolveListeners, chunk.value); - break; - case "pending": - case "blocked": - case "cyclic": - chunk.value = resolveListeners; - chunk.reason = rejectListeners; - break; - case "rejected": - rejectListeners && wakeChunk(rejectListeners, chunk.reason); - } -} -function triggerErrorOnChunk(chunk, error) { - if ("pending" === chunk.status || "blocked" === chunk.status) { - var listeners = chunk.reason; - chunk.status = "rejected"; - chunk.reason = error; - null !== listeners && wakeChunk(listeners, error); - } -} -function resolveModuleChunk(chunk, value) { - if ("pending" === chunk.status || "blocked" === chunk.status) { - var resolveListeners = chunk.value, - rejectListeners = chunk.reason; - chunk.status = "resolved_module"; - chunk.value = value; - null !== resolveListeners && - (initializeModuleChunk(chunk), - wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners)); - } -} -var initializingChunk = null, - initializingChunkBlockedModel = null; -function initializeModelChunk(chunk) { - var prevChunk = initializingChunk, - prevBlocked = initializingChunkBlockedModel; - initializingChunk = chunk; - initializingChunkBlockedModel = null; - var resolvedModel = chunk.value; - chunk.status = "cyclic"; - chunk.value = null; - chunk.reason = null; - try { - var value = JSON.parse(resolvedModel, chunk._response._fromJSON); - if ( - null !== initializingChunkBlockedModel && - 0 < initializingChunkBlockedModel.deps - ) - (initializingChunkBlockedModel.value = value), - (chunk.status = "blocked"), - (chunk.value = null), - (chunk.reason = null); - else { - var resolveListeners = chunk.value; - chunk.status = "fulfilled"; - chunk.value = value; - null !== resolveListeners && wakeChunk(resolveListeners, value); - } - } catch (error) { - (chunk.status = "rejected"), (chunk.reason = error); - } finally { - (initializingChunk = prevChunk), - (initializingChunkBlockedModel = prevBlocked); - } -} -function initializeModuleChunk(chunk) { - try { - var promise = asyncModuleCache.get(chunk.value.getModuleId()); - if ("fulfilled" === promise.status) var module = promise.value; - else throw promise.reason; - chunk.status = "fulfilled"; - chunk.value = module; - } catch (error) { - (chunk.status = "rejected"), (chunk.reason = error); - } -} -function reportGlobalError(response, error) { - response._chunks.forEach(function (chunk) { - "pending" === chunk.status && triggerErrorOnChunk(chunk, error); - }); -} -function getChunk(response, id) { - var chunks = response._chunks, - chunk = chunks.get(id); - chunk || - ((chunk = new Chunk("pending", null, null, response)), - chunks.set(id, chunk)); - return chunk; -} -function createModelResolver(chunk, parentObject, key, cyclic, response, map) { - if (initializingChunkBlockedModel) { - var blocked = initializingChunkBlockedModel; - cyclic || blocked.deps++; - } else - blocked = initializingChunkBlockedModel = { - deps: cyclic ? 0 : 1, - value: null - }; - return function (value) { - parentObject[key] = map(response, value); - "" === key && null === blocked.value && (blocked.value = parentObject[key]); - blocked.deps--; - 0 === blocked.deps && - "blocked" === chunk.status && - ((value = chunk.value), - (chunk.status = "fulfilled"), - (chunk.value = blocked.value), - null !== value && wakeChunk(value, blocked.value)); - }; -} -function createModelReject(chunk) { - return function (error) { - return triggerErrorOnChunk(chunk, error); - }; -} -function createServerReferenceProxy(response, metaData) { - function proxy() { - var args = Array.prototype.slice.call(arguments), - p = metaData.bound; - return p - ? "fulfilled" === p.status - ? callServer(metaData.id, p.value.concat(args)) - : Promise.resolve(p).then(function (bound) { - return callServer(metaData.id, bound.concat(args)); - }) - : callServer(metaData.id, args); - } - var callServer = response._callServer; - knownServerReferences.set(proxy, metaData); - return proxy; -} -function getOutlinedModel(response, id, parentObject, key, map) { - id = getChunk(response, id); - switch (id.status) { - case "resolved_model": - initializeModelChunk(id); - break; - case "resolved_module": - initializeModuleChunk(id); - } - switch (id.status) { - case "fulfilled": - return map(response, id.value); - case "pending": - case "blocked": - case "cyclic": - var parentChunk = initializingChunk; - id.then( - createModelResolver( - parentChunk, - parentObject, - key, - "cyclic" === id.status, - response, - map - ), - createModelReject(parentChunk) - ); - return null; - default: - throw id.reason; - } -} -function createMap(response, model) { - return new Map(model); -} -function createSet(response, model) { - return new Set(model); -} -function createFormData(response, model) { - response = new FormData(); - for (var i = 0; i < model.length; i++) - response.append(model[i][0], model[i][1]); - return response; -} -function createModel(response, model) { - return model; -} -function parseModelString(response, parentObject, key, value) { - if ("$" === value[0]) { - if ("$" === value) return REACT_ELEMENT_TYPE; - switch (value[1]) { - case "$": - return value.slice(1); - case "L": - return ( - (parentObject = parseInt(value.slice(2), 16)), - (response = getChunk(response, parentObject)), - { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk } - ); - case "@": - if (2 === value.length) return new Promise(function () {}); - parentObject = parseInt(value.slice(2), 16); - return getChunk(response, parentObject); - case "S": - return Symbol.for(value.slice(2)); - case "F": - return ( - (value = parseInt(value.slice(2), 16)), - getOutlinedModel( - response, - value, - parentObject, - key, - createServerReferenceProxy - ) - ); - case "T": - parentObject = parseInt(value.slice(2), 16); - response = response._tempRefs; - if (null == response) - throw Error( - "Missing a temporary reference set but the RSC response returned a temporary reference. Pass a temporaryReference option with the set that was used with the reply." - ); - if (0 > parentObject || parentObject >= response.length) - throw Error( - "The RSC response contained a reference that doesn't exist in the temporary reference set. Always pass the matching set that was used to create the reply when parsing its response." - ); - return response[parentObject]; - case "Q": - return ( - (value = parseInt(value.slice(2), 16)), - getOutlinedModel(response, value, parentObject, key, createMap) - ); - case "W": - return ( - (value = parseInt(value.slice(2), 16)), - getOutlinedModel(response, value, parentObject, key, createSet) - ); - case "B": - return; - case "K": - return ( - (value = parseInt(value.slice(2), 16)), - getOutlinedModel(response, value, parentObject, key, createFormData) - ); - case "I": - return Infinity; - case "-": - return "$-0" === value ? -0 : -Infinity; - case "N": - return NaN; - case "u": - return; - case "D": - return new Date(Date.parse(value.slice(2))); - case "n": - return BigInt(value.slice(2)); - default: - return ( - (value = parseInt(value.slice(1), 16)), - getOutlinedModel(response, value, parentObject, key, createModel) - ); - } - } - return value; -} -function missingCall() { - throw Error( - 'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.' - ); -} -function resolveModule(response, id, model) { - var chunks = response._chunks, - chunk = chunks.get(id); - model = JSON.parse(model, response._fromJSON); - var clientReference = resolveClientReference(response._bundlerConfig, model); - if ((model = preloadModule(clientReference))) { - if (chunk) { - var blockedChunk = chunk; - blockedChunk.status = "blocked"; - } else - (blockedChunk = new Chunk("blocked", null, null, response)), - chunks.set(id, blockedChunk); - model.then( - function () { - return resolveModuleChunk(blockedChunk, clientReference); - }, - function (error) { - return triggerErrorOnChunk(blockedChunk, error); - } - ); - } else - chunk - ? resolveModuleChunk(chunk, clientReference) - : chunks.set( - id, - new Chunk("resolved_module", clientReference, null, response) - ); -} -function createFromJSONCallback(response) { - return function (key, value) { - return "string" === typeof value - ? parseModelString(response, this, key, value) - : "object" === typeof value && null !== value - ? ((key = - value[0] === REACT_ELEMENT_TYPE - ? { - $$typeof: REACT_ELEMENT_TYPE, - type: value[1], - key: value[2], - ref: null, - props: value[3], - _owner: null - } - : value), - key) - : value; - }; -} -function startReadingFromStream(response, stream) { - function progress(_ref) { - var value = _ref.value; - if (_ref.done) reportGlobalError(response, Error("Connection closed.")); - else { - value = - "string" !== typeof value ? value : new TextEncoder().encode(value); - var i = 0, - rowState = response._rowState, - rowID = response._rowID, - rowTag = response._rowTag, - rowLength = response._rowLength; - _ref = response._buffer; - for (var chunkLength = value.length; i < chunkLength; ) { - var lastIdx = -1; - switch (rowState) { - case 0: - lastIdx = value[i++]; - 58 === lastIdx - ? (rowState = 1) - : (rowID = - (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48)); - continue; - case 1: - rowState = value[i]; - 84 === rowState - ? ((rowTag = rowState), (rowState = 2), i++) - : (64 < rowState && 91 > rowState) || - 114 === rowState || - 120 === rowState - ? ((rowTag = rowState), (rowState = 3), i++) - : ((rowTag = 0), (rowState = 3)); - continue; - case 2: - lastIdx = value[i++]; - 44 === lastIdx - ? (rowState = 4) - : (rowLength = - (rowLength << 4) | - (96 < lastIdx ? lastIdx - 87 : lastIdx - 48)); - continue; - case 3: - lastIdx = value.indexOf(10, i); - break; - case 4: - (lastIdx = i + rowLength), lastIdx > value.length && (lastIdx = -1); - } - var offset = value.byteOffset + i; - if (-1 < lastIdx) { - i = new Uint8Array(value.buffer, offset, lastIdx - i); - rowLength = response; - offset = rowTag; - var stringDecoder = rowLength._stringDecoder; - rowTag = ""; - for (var i$jscomp$0 = 0; i$jscomp$0 < _ref.length; i$jscomp$0++) - rowTag += stringDecoder.decode(_ref[i$jscomp$0], decoderOptions); - rowTag += stringDecoder.decode(i); - switch (offset) { - case 73: - resolveModule(rowLength, rowID, rowTag); - break; - case 72: - rowID = rowTag[0]; - rowTag = rowTag.slice(1); - rowLength = JSON.parse(rowTag, rowLength._fromJSON); - rowTag = ReactDOMSharedInternals.d; - switch (rowID) { - case "D": - rowTag.D(rowLength); - break; - case "C": - "string" === typeof rowLength - ? rowTag.C(rowLength) - : rowTag.C(rowLength[0], rowLength[1]); - break; - case "L": - rowID = rowLength[0]; - i = rowLength[1]; - 3 === rowLength.length - ? rowTag.L(rowID, i, rowLength[2]) - : rowTag.L(rowID, i); - break; - case "m": - "string" === typeof rowLength - ? rowTag.m(rowLength) - : rowTag.m(rowLength[0], rowLength[1]); - break; - case "X": - "string" === typeof rowLength - ? rowTag.X(rowLength) - : rowTag.X(rowLength[0], rowLength[1]); - break; - case "S": - "string" === typeof rowLength - ? rowTag.S(rowLength) - : rowTag.S( - rowLength[0], - 0 === rowLength[1] ? void 0 : rowLength[1], - 3 === rowLength.length ? rowLength[2] : void 0 - ); - break; - case "M": - "string" === typeof rowLength - ? rowTag.M(rowLength) - : rowTag.M(rowLength[0], rowLength[1]); - } - break; - case 69: - rowTag = JSON.parse(rowTag); - i = rowTag.digest; - rowTag = Error( - "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error." - ); - rowTag.stack = "Error: " + rowTag.message; - rowTag.digest = i; - i = rowLength._chunks; - (offset = i.get(rowID)) - ? triggerErrorOnChunk(offset, rowTag) - : i.set(rowID, new Chunk("rejected", null, rowTag, rowLength)); - break; - case 84: - rowLength._chunks.set( - rowID, - new Chunk("fulfilled", rowTag, null, rowLength) - ); - break; - case 68: - case 87: - throw Error( - "Failed to read a RSC payload created by a development version of React on the server while using a production version on the client. Always use matching versions on the server and the client." - ); - default: - (i = rowLength._chunks), - (offset = i.get(rowID)) - ? ((rowLength = offset), - (rowID = rowTag), - "pending" === rowLength.status && - ((rowTag = rowLength.value), - (i = rowLength.reason), - (rowLength.status = "resolved_model"), - (rowLength.value = rowID), - null !== rowTag && - (initializeModelChunk(rowLength), - wakeChunkIfInitialized(rowLength, rowTag, i)))) - : i.set( - rowID, - new Chunk("resolved_model", rowTag, null, rowLength) - ); - } - i = lastIdx; - 3 === rowState && i++; - rowLength = rowID = rowTag = rowState = 0; - _ref.length = 0; - } else { - value = new Uint8Array(value.buffer, offset, value.byteLength - i); - _ref.push(value); - rowLength -= value.byteLength; - break; - } - } - response._rowState = rowState; - response._rowID = rowID; - response._rowTag = rowTag; - response._rowLength = rowLength; - return reader.read().then(progress).catch(error); - } - } - function error(e) { - reportGlobalError(response, e); - } - var reader = stream.getReader(); - reader.read().then(progress).catch(error); -} -exports.createFromReadableStream = function (stream, options) { - options = options && options.moduleMap; - if (null == options) throw Error("Expected `moduleMap` to be defined."); - var chunks = new Map(); - options = { - _bundlerConfig: options, - _moduleLoading: null, - _callServer: missingCall, - _encodeFormAction: void 0, - _nonce: void 0, - _chunks: chunks, - _stringDecoder: new TextDecoder(), - _fromJSON: null, - _rowState: 0, - _rowID: 0, - _rowTag: 0, - _rowLength: 0, - _buffer: [], - _tempRefs: void 0 - }; - options._fromJSON = createFromJSONCallback(options); - startReadingFromStream(options, stream); - return getChunk(options, 0); -}; diff --git a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js b/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js deleted file mode 100644 index ae2d235337cf1..0000000000000 --- a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js +++ /dev/null @@ -1,3266 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; - -if (__DEV__) { - (function () { - "use strict"; - - var ReactDOM = require("react-dom"); - var React = require("react"); - - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-unused-vars - var requestedClientReferencesKeys = new Set(); - var checkIsClientReference; - function setCheckIsClientReference(impl) { - checkIsClientReference = impl; - } - function registerClientReference(clientReference) {} - function isClientReference(reference) { - if (checkIsClientReference == null) { - throw new Error("Expected implementation for checkIsClientReference."); - } - - return checkIsClientReference(reference); - } - function getClientReferenceKey(clientReference) { - var moduleId = clientReference.getModuleId(); - requestedClientReferencesKeys.add(moduleId); - return clientReference.getModuleId(); - } - function resolveClientReferenceMetadata(config, clientReference) { - return { - moduleId: clientReference.getModuleId(), - exportName: "default" - }; - } - function registerServerReference(serverReference, id, exportName) { - throw new Error("registerServerReference: Not Implemented."); - } - function isServerReference(reference) { - throw new Error("isServerReference: Not Implemented."); - } - function getServerReferenceId(config, serverReference) { - throw new Error("getServerReferenceId: Not Implemented."); - } - function getRequestedClientReferencesKeys() { - return Array.from(requestedClientReferencesKeys); - } - function clearRequestedClientReferencesKeysSet() { - requestedClientReferencesKeys.clear(); - } - - // This refers to a WWW module. - var warningWWW = require("warning"); - function error(format) { - { - { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 1 ? _len2 - 1 : 0), - _key2 = 1; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 1] = arguments[_key2]; - } - - printWarning("error", format, args); - } - } - } - - function printWarning(level, format, args) { - { - var React = require("react"); - - var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. - - if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); - - if (stack !== "") { - format += "%s"; - args.push(stack); - } - } // TODO: don't ignore level and pass it down somewhere too. - - args.unshift(format); - args.unshift(false); - warningWWW.apply(null, args); - } - } - - // Re-export dynamic flags from the www version. - var dynamicFeatureFlags = require("ReactFeatureFlags"); - - var enableRefAsProp = dynamicFeatureFlags.enableRefAsProp; - // On WWW, true is used for a new modern build. - - function stringToChunk(content) { - return content; - } - - var byteLengthImpl = null; - function setByteLengthOfChunkImplementation(impl) { - byteLengthImpl = impl; - } - function byteLengthOfChunk(chunk) { - if (byteLengthImpl == null) { - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - "byteLengthOfChunk implementation is not configured. Please, provide the implementation via ReactFlightDOMServer.setConfig(...);" - ); - } - - return byteLengthImpl(chunk); - } - function scheduleWork(callback) { - callback(); - } - function beginWriting(destination) { - destination.beginWriting(); - } - function writeChunkAndReturn(destination, chunk) { - destination.write(chunk); - return true; - } - function completeWriting(destination) { - destination.completeWriting(); - } - function flushBuffered(destination) { - destination.flushBuffered(); - } - function close(destination) { - destination.close(); - } - function closeWithError(destination, error) { - destination.onError(error); - destination.close(); - } - - function getServerReferenceBoundArguments(config, serverReference) { - throw new Error("getServerReferenceBoundArguments: Not Implemented."); - } - - var ReactDOMSharedInternals = - ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; - - var previousDispatcher = ReactDOMSharedInternals.d; - /* ReactDOMCurrentDispatcher */ - - ReactDOMSharedInternals.d = - /* ReactDOMCurrentDispatcher */ - { - f: - /* flushSyncWork */ - previousDispatcher.f, - /* flushSyncWork */ - r: - /* requestFormReset */ - previousDispatcher.r, - /* requestFormReset */ - D: - /* prefetchDNS */ - prefetchDNS, - C: - /* preconnect */ - preconnect, - L: - /* preload */ - preload, - m: - /* preloadModule */ - preloadModule, - X: - /* preinitScript */ - preinitScript, - S: - /* preinitStyle */ - preinitStyle, - M: - /* preinitModuleScript */ - preinitModuleScript - }; - - function prefetchDNS(href) { - if (typeof href === "string" && href) { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "D|" + href; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - emitHint(request, "D", href); - } else { - previousDispatcher.D( - /* prefetchDNS */ - href - ); - } - } - } - - function preconnect(href, crossOrigin) { - if (typeof href === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = - "C|" + (crossOrigin == null ? "null" : crossOrigin) + "|" + href; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - - if (typeof crossOrigin === "string") { - emitHint(request, "C", [href, crossOrigin]); - } else { - emitHint(request, "C", href); - } - } else { - previousDispatcher.C( - /* preconnect */ - href, - crossOrigin - ); - } - } - } - - function preload(href, as, options) { - if (typeof href === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "L"; - - if (as === "image" && options) { - key += getImagePreloadKey( - href, - options.imageSrcSet, - options.imageSizes - ); - } else { - key += "[" + as + "]" + href; - } - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - var trimmed = trimOptions(options); - - if (trimmed) { - emitHint(request, "L", [href, as, trimmed]); - } else { - emitHint(request, "L", [href, as]); - } - } else { - previousDispatcher.L( - /* preload */ - href, - as, - options - ); - } - } - } - - function preloadModule(href, options) { - if (typeof href === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "m|" + href; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - var trimmed = trimOptions(options); - - if (trimmed) { - return emitHint(request, "m", [href, trimmed]); - } else { - return emitHint(request, "m", href); - } - } else { - previousDispatcher.m( - /* preloadModule */ - href, - options - ); - } - } - } - - function preinitStyle(href, precedence, options) { - if (typeof href === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "S|" + href; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - var trimmed = trimOptions(options); - - if (trimmed) { - return emitHint(request, "S", [ - href, - typeof precedence === "string" ? precedence : 0, - trimmed - ]); - } else if (typeof precedence === "string") { - return emitHint(request, "S", [href, precedence]); - } else { - return emitHint(request, "S", href); - } - } else { - previousDispatcher.S( - /* preinitStyle */ - href, - precedence, - options - ); - } - } - } - - function preinitScript(src, options) { - if (typeof src === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "X|" + src; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - var trimmed = trimOptions(options); - - if (trimmed) { - return emitHint(request, "X", [src, trimmed]); - } else { - return emitHint(request, "X", src); - } - } else { - previousDispatcher.X( - /* preinitScript */ - src, - options - ); - } - } - } - - function preinitModuleScript(src, options) { - if (typeof src === "string") { - var request = resolveRequest(); - - if (request) { - var hints = getHints(request); - var key = "M|" + src; - - if (hints.has(key)) { - // duplicate hint - return; - } - - hints.add(key); - var trimmed = trimOptions(options); - - if (trimmed) { - return emitHint(request, "M", [src, trimmed]); - } else { - return emitHint(request, "M", src); - } - } else { - previousDispatcher.M( - /* preinitModuleScript */ - src, - options - ); - } - } - } // Flight normally encodes undefined as a special character however for directive option - // arguments we don't want to send unnecessary keys and bloat the payload so we create a - // trimmed object which omits any keys with null or undefined values. - // This is only typesafe because these option objects have entirely optional fields where - // null and undefined represent the same thing as no property. - - function trimOptions(options) { - if (options == null) return null; - var hasProperties = false; - var trimmed = {}; - - for (var key in options) { - if (options[key] != null) { - hasProperties = true; - trimmed[key] = options[key]; - } - } - - return hasProperties ? trimmed : null; - } - - function getImagePreloadKey(href, imageSrcSet, imageSizes) { - var uniquePart = ""; - - if (typeof imageSrcSet === "string" && imageSrcSet !== "") { - uniquePart += "[" + imageSrcSet + "]"; - - if (typeof imageSizes === "string") { - uniquePart += "[" + imageSizes + "]"; - } - } else { - uniquePart += "[][]" + href; - } - - return "[image]" + uniquePart; - } - - // This module registers the host dispatcher so it needs to be imported - // small, smaller than how we encode undefined, and is unambiguous. We could use - // a different tuple structure to encode this instead but this makes the runtime - // cost cheaper by eliminating a type checks in more positions. - // prettier-ignore - - function createHints() { - return new Set(); -} - - var supportsRequestStorage = false; - var requestStorage = null; - - var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"); // eslint-disable-next-line no-unused-vars - - function isTemporaryReference(reference) { - return reference.$$typeof === TEMPORARY_REFERENCE_TAG; - } - function resolveTemporaryReferenceID(temporaryReference) { - return temporaryReference.$$id; - } - - // ATTENTION - // When adding new symbols to this file, - // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' - // The Symbol used to tag the ReactElement-like types. - var REACT_ELEMENT_TYPE = Symbol.for("react.element"); - var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"); - var REACT_CONTEXT_TYPE = Symbol.for("react.context"); - var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"); - var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"); - var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"); - var REACT_MEMO_TYPE = Symbol.for("react.memo"); - var REACT_LAZY_TYPE = Symbol.for("react.lazy"); - var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"); - var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = "@@iterator"; - function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable !== "object") { - return null; - } - - var maybeIterator = - (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || - maybeIterable[FAUX_ITERATOR_SYMBOL]; - - if (typeof maybeIterator === "function") { - return maybeIterator; - } - - return null; - } - - // Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally, - // changes to one module should be reflected in the others. - // TODO: Rename this module and the corresponding Fiber one to "Thenable" - // instead of "Wakeable". Or some other more appropriate name. - // An error that is thrown (e.g. by `use`) to trigger Suspense. If we - // detect this is caught by userspace, we'll log a warning in development. - var SuspenseException = new Error( - "Suspense Exception: This is not a real error! It's an implementation " + - "detail of `use` to interrupt the current render. You must either " + - "rethrow it immediately, or move the `use` call outside of the " + - "`try/catch` block. Capturing without rethrowing will lead to " + - "unexpected behavior.\n\n" + - "To handle async errors, wrap your component in an error boundary, or " + - "call the promise's `.catch` method and pass the result to `use`" - ); - function createThenableState() { - // The ThenableState is created the first time a component suspends. If it - // suspends again, we'll reuse the same state. - return []; - } - - function noop() {} - - function trackUsedThenable(thenableState, thenable, index) { - var previous = thenableState[index]; - - if (previous === undefined) { - thenableState.push(thenable); - } else { - if (previous !== thenable) { - // Reuse the previous thenable, and drop the new one. We can assume - // they represent the same value, because components are idempotent. - // Avoid an unhandled rejection errors for the Promises that we'll - // intentionally ignore. - thenable.then(noop, noop); - thenable = previous; - } - } // We use an expando to track the status and result of a thenable so that we - // can synchronously unwrap the value. Think of this as an extension of the - // Promise API, or a custom interface that is a superset of Thenable. - // - // If the thenable doesn't have a status, set it to "pending" and attach - // a listener that will update its status and result when it resolves. - - switch (thenable.status) { - case "fulfilled": { - var fulfilledValue = thenable.value; - return fulfilledValue; - } - - case "rejected": { - var rejectedError = thenable.reason; - throw rejectedError; - } - - default: { - if (typeof thenable.status === "string") { - // Only instrument the thenable if the status if not defined. If - // it's defined, but an unknown value, assume it's been instrumented by - // some custom userspace implementation. We treat it as "pending". - // Attach a dummy listener, to ensure that any lazy initialization can - // happen. Flight lazily parses JSON when the value is actually awaited. - thenable.then(noop, noop); - } else { - var pendingThenable = thenable; - pendingThenable.status = "pending"; - pendingThenable.then( - function (fulfilledValue) { - if (thenable.status === "pending") { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if (thenable.status === "pending") { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - ); - } // Check one more time in case the thenable resolved synchronously - - switch (thenable.status) { - case "fulfilled": { - var fulfilledThenable = thenable; - return fulfilledThenable.value; - } - - case "rejected": { - var rejectedThenable = thenable; - throw rejectedThenable.reason; - } - } // Suspend. - // - // Throwing here is an implementation detail that allows us to unwind the - // call stack. But we shouldn't allow it to leak into userspace. Throw an - // opaque placeholder value instead of the actual thenable. If it doesn't - // get captured by the work loop, log a warning, because that means - // something in userspace must have caught it. - - suspendedThenable = thenable; - throw SuspenseException; - } - } - } // This is used to track the actual thenable that suspended so it can be - // passed to the rest of the Suspense implementation — which, for historical - // reasons, expects to receive a thenable. - - var suspendedThenable = null; - function getSuspendedThenable() { - // This is called right after `use` suspends by throwing an exception. `use` - // throws an opaque value instead of the thenable itself so that it can't be - // caught in userspace. Then the work loop accesses the actual thenable using - // this function. - if (suspendedThenable === null) { - throw new Error( - "Expected a suspended thenable. This is a bug in React. Please file " + - "an issue." - ); - } - - var thenable = suspendedThenable; - suspendedThenable = null; - return thenable; - } - - var currentRequest$1 = null; - var thenableIndexCounter = 0; - var thenableState = null; - var currentComponentDebugInfo = null; - function prepareToUseHooksForRequest(request) { - currentRequest$1 = request; - } - function resetHooksForRequest() { - currentRequest$1 = null; - } - function prepareToUseHooksForComponent( - prevThenableState, - componentDebugInfo - ) { - thenableIndexCounter = 0; - thenableState = prevThenableState; - - { - currentComponentDebugInfo = componentDebugInfo; - } - } - function getThenableStateAfterSuspending() { - // If you use() to Suspend this should always exist but if you throw a Promise instead, - // which is not really supported anymore, it will be empty. We use the empty set as a - // marker to know if this was a replay of the same component or first attempt. - var state = thenableState || createThenableState(); - - { - // This is a hack but we stash the debug info here so that we don't need a completely - // different data structure just for this in DEV. Not too happy about it. - state._componentDebugInfo = currentComponentDebugInfo; - currentComponentDebugInfo = null; - } - - thenableState = null; - return state; - } - var HooksDispatcher = { - useMemo: function (nextCreate) { - return nextCreate(); - }, - useCallback: function (callback) { - return callback; - }, - useDebugValue: function () {}, - useDeferredValue: unsupportedHook, - useTransition: unsupportedHook, - readContext: unsupportedContext, - useContext: unsupportedContext, - useReducer: unsupportedHook, - useRef: unsupportedHook, - useState: unsupportedHook, - useInsertionEffect: unsupportedHook, - useLayoutEffect: unsupportedHook, - useImperativeHandle: unsupportedHook, - useEffect: unsupportedHook, - useId: useId, - useSyncExternalStore: unsupportedHook, - useCacheRefresh: function () { - return unsupportedRefresh; - }, - useMemoCache: function (size) { - var data = new Array(size); - - for (var i = 0; i < size; i++) { - data[i] = REACT_MEMO_CACHE_SENTINEL; - } - - return data; - }, - use: use - }; - - function unsupportedHook() { - throw new Error("This Hook is not supported in Server Components."); - } - - function unsupportedRefresh() { - throw new Error( - "Refreshing the cache is not supported in Server Components." - ); - } - - function unsupportedContext() { - throw new Error("Cannot read a Client Context from a Server Component."); - } - - function useId() { - if (currentRequest$1 === null) { - throw new Error("useId can only be used while React is rendering"); - } - - var id = currentRequest$1.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client - - return ( - ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":" - ); - } - - function use(usable) { - if ( - (usable !== null && typeof usable === "object") || - typeof usable === "function" - ) { - // $FlowFixMe[method-unbinding] - if (typeof usable.then === "function") { - // This is a thenable. - var thenable = usable; // Track the position of the thenable within this fiber. - - var index = thenableIndexCounter; - thenableIndexCounter += 1; - - if (thenableState === null) { - thenableState = createThenableState(); - } - - return trackUsedThenable(thenableState, thenable, index); - } else if (usable.$$typeof === REACT_CONTEXT_TYPE) { - unsupportedContext(); - } - } - - if (isClientReference(usable)) { - if ( - usable.value != null && - usable.value.$$typeof === REACT_CONTEXT_TYPE - ) { - // Show a more specific message since it's a common mistake. - throw new Error( - "Cannot read a Client Context from a Server Component." - ); - } else { - throw new Error("Cannot use() an already resolved Client Reference."); - } - } else { - throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion - "An unsupported type was passed to use(): " + String(usable) - ); - } - } - - function resolveCache() { - var request = resolveRequest(); - - if (request) { - return getCache(request); - } - - return new Map(); - } - - var DefaultCacheDispatcher = { - getCacheForType: function (resourceType) { - var cache = resolveCache(); - var entry = cache.get(resourceType); - - if (entry === undefined) { - entry = resourceType(); // TODO: Warn if undefined? - - cache.set(resourceType, entry); - } - - return entry; - } - }; - - var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare - - function isArray(a) { - return isArrayImpl(a); - } - - var getPrototypeOf = Object.getPrototypeOf; - - // in case they error. - - var jsxPropsParents = new WeakMap(); - var jsxChildrenParents = new WeakMap(); - - function isObjectPrototype(object) { - if (!object) { - return false; - } - - var ObjectPrototype = Object.prototype; - - if (object === ObjectPrototype) { - return true; - } // It might be an object from a different Realm which is - // still just a plain simple object. - - if (getPrototypeOf(object)) { - return false; - } - - var names = Object.getOwnPropertyNames(object); - - for (var i = 0; i < names.length; i++) { - if (!(names[i] in ObjectPrototype)) { - return false; - } - } - - return true; - } - - function isSimpleObject(object) { - if (!isObjectPrototype(getPrototypeOf(object))) { - return false; - } - - var names = Object.getOwnPropertyNames(object); - - for (var i = 0; i < names.length; i++) { - var descriptor = Object.getOwnPropertyDescriptor(object, names[i]); - - if (!descriptor) { - return false; - } - - if (!descriptor.enumerable) { - if ( - (names[i] === "key" || names[i] === "ref") && - typeof descriptor.get === "function" - ) { - // React adds key and ref getters to props objects to issue warnings. - // Those getters will not be transferred to the client, but that's ok, - // so we'll special case them. - continue; - } - - return false; - } - } - - return true; - } - function objectName(object) { - // $FlowFixMe[method-unbinding] - var name = Object.prototype.toString.call(object); - return name.replace(/^\[object (.*)\]$/, function (m, p0) { - return p0; - }); - } - - function describeKeyForErrorMessage(key) { - var encodedKey = JSON.stringify(key); - return '"' + key + '"' === encodedKey ? key : encodedKey; - } - - function describeValueForErrorMessage(value) { - switch (typeof value) { - case "string": { - return JSON.stringify( - value.length <= 10 ? value : value.slice(0, 10) + "..." - ); - } - - case "object": { - if (isArray(value)) { - return "[...]"; - } - - if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { - return describeClientReference(); - } - - var name = objectName(value); - - if (name === "Object") { - return "{...}"; - } - - return name; - } - - case "function": { - if (value.$$typeof === CLIENT_REFERENCE_TAG) { - return describeClientReference(); - } - - var _name = value.displayName || value.name; - - return _name ? "function " + _name : "function"; - } - - default: - // eslint-disable-next-line react-internal/safe-string-coercion - return String(value); - } - } - - function describeElementType(type) { - if (typeof type === "string") { - return type; - } - - switch (type) { - case REACT_SUSPENSE_TYPE: - return "Suspense"; - - case REACT_SUSPENSE_LIST_TYPE: - return "SuspenseList"; - } - - if (typeof type === "object") { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeElementType(type.render); - - case REACT_MEMO_TYPE: - return describeElementType(type.type); - - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - // Lazy may contain any component type so we recursively resolve it. - return describeElementType(init(payload)); - } catch (x) {} - } - } - } - - return ""; - } - - var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); - - function describeClientReference(ref) { - return "client"; - } - - function describeObjectForErrorMessage(objectOrArray, expandedName) { - var objKind = objectName(objectOrArray); - - if (objKind !== "Object" && objKind !== "Array") { - return objKind; - } - - var str = ""; - var start = -1; - var length = 0; - - if (isArray(objectOrArray)) { - if (jsxChildrenParents.has(objectOrArray)) { - // Print JSX Children - var type = jsxChildrenParents.get(objectOrArray); - str = "<" + describeElementType(type) + ">"; - var array = objectOrArray; - - for (var i = 0; i < array.length; i++) { - var value = array[i]; - var substr = void 0; - - if (typeof value === "string") { - substr = value; - } else if (typeof value === "object" && value !== null) { - substr = "{" + describeObjectForErrorMessage(value) + "}"; - } else { - substr = "{" + describeValueForErrorMessage(value) + "}"; - } - - if ("" + i === expandedName) { - start = str.length; - length = substr.length; - str += substr; - } else if (substr.length < 15 && str.length + substr.length < 40) { - str += substr; - } else { - str += "{...}"; - } - } - - str += ""; - } else { - // Print Array - str = "["; - var _array = objectOrArray; - - for (var _i = 0; _i < _array.length; _i++) { - if (_i > 0) { - str += ", "; - } - - var _value = _array[_i]; - - var _substr = void 0; - - if (typeof _value === "object" && _value !== null) { - _substr = describeObjectForErrorMessage(_value); - } else { - _substr = describeValueForErrorMessage(_value); - } - - if ("" + _i === expandedName) { - start = str.length; - length = _substr.length; - str += _substr; - } else if ( - _substr.length < 10 && - str.length + _substr.length < 40 - ) { - str += _substr; - } else { - str += "..."; - } - } - - str += "]"; - } - } else { - if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { - str = "<" + describeElementType(objectOrArray.type) + "/>"; - } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { - return describeClientReference(); - } else if (jsxPropsParents.has(objectOrArray)) { - // Print JSX - var _type = jsxPropsParents.get(objectOrArray); - - str = "<" + (describeElementType(_type) || "..."); - var object = objectOrArray; - var names = Object.keys(object); - - for (var _i2 = 0; _i2 < names.length; _i2++) { - str += " "; - var name = names[_i2]; - str += describeKeyForErrorMessage(name) + "="; - var _value2 = object[name]; - - var _substr2 = void 0; - - if ( - name === expandedName && - typeof _value2 === "object" && - _value2 !== null - ) { - _substr2 = describeObjectForErrorMessage(_value2); - } else { - _substr2 = describeValueForErrorMessage(_value2); - } - - if (typeof _value2 !== "string") { - _substr2 = "{" + _substr2 + "}"; - } - - if (name === expandedName) { - start = str.length; - length = _substr2.length; - str += _substr2; - } else if ( - _substr2.length < 10 && - str.length + _substr2.length < 40 - ) { - str += _substr2; - } else { - str += "..."; - } - } - - str += ">"; - } else { - // Print Object - str = "{"; - var _object = objectOrArray; - - var _names = Object.keys(_object); - - for (var _i3 = 0; _i3 < _names.length; _i3++) { - if (_i3 > 0) { - str += ", "; - } - - var _name2 = _names[_i3]; - str += describeKeyForErrorMessage(_name2) + ": "; - var _value3 = _object[_name2]; - - var _substr3 = void 0; - - if (typeof _value3 === "object" && _value3 !== null) { - _substr3 = describeObjectForErrorMessage(_value3); - } else { - _substr3 = describeValueForErrorMessage(_value3); - } - - if (_name2 === expandedName) { - start = str.length; - length = _substr3.length; - str += _substr3; - } else if ( - _substr3.length < 10 && - str.length + _substr3.length < 40 - ) { - str += _substr3; - } else { - str += "..."; - } - } - - str += "}"; - } - } - - if (expandedName === undefined) { - return str; - } - - if (start > -1 && length > 0) { - var highlight = " ".repeat(start) + "^".repeat(length); - return "\n " + str + "\n " + highlight; - } - - return "\n " + str; - } - - var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to. - React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; - - if (!ReactSharedInternalsServer) { - throw new Error( - 'The "react" package in this environment is not configured correctly. ' + - 'The "react-server" condition must be enabled in any environment that ' + - "runs React Server Components." - ); - } - - var ReactSharedInternals = ReactSharedInternalsServer; - - function patchConsole(consoleInst, methodName) { - var descriptor = Object.getOwnPropertyDescriptor(consoleInst, methodName); - - if ( - descriptor && - (descriptor.configurable || descriptor.writable) && - typeof descriptor.value === "function" - ) { - var originalMethod = descriptor.value; - var originalName = Object.getOwnPropertyDescriptor( - // $FlowFixMe[incompatible-call]: We should be able to get descriptors from any function. - originalMethod, - "name" - ); - - var wrapperMethod = function () { - var request = resolveRequest(); - - if (methodName === "assert" && arguments[0]); - else if (request !== null) { - // Extract the stack. Not all console logs print the full stack but they have at - // least the line it was called from. We could optimize transfer by keeping just - // one stack frame but keeping it simple for now and include all frames. - var stack = new Error().stack; - - if (stack.startsWith("Error: \n")) { - stack = stack.slice(8); - } - - var firstLine = stack.indexOf("\n"); - - if (firstLine === -1) { - stack = ""; - } else { - // Skip the console wrapper itself. - stack = stack.slice(firstLine + 1); - } - - request.pendingChunks++; // We don't currently use this id for anything but we emit it so that we can later - // refer to previous logs in debug info to associate them with a component. - - var id = request.nextChunkId++; - var owner = ReactSharedInternals.owner; - emitConsoleChunk(request, id, methodName, owner, stack, arguments); - } // $FlowFixMe[prop-missing] - - return originalMethod.apply(this, arguments); - }; - - if (originalName) { - Object.defineProperty( - wrapperMethod, // $FlowFixMe[cannot-write] yes it is - "name", - originalName - ); - } - - Object.defineProperty(consoleInst, methodName, { - value: wrapperMethod - }); - } - } - - if (typeof console === "object" && console !== null) { - // Instrument console to capture logs for replaying on the client. - patchConsole(console, "assert"); - patchConsole(console, "debug"); - patchConsole(console, "dir"); - patchConsole(console, "dirxml"); - patchConsole(console, "error"); - patchConsole(console, "group"); - patchConsole(console, "groupCollapsed"); - patchConsole(console, "groupEnd"); - patchConsole(console, "info"); - patchConsole(console, "log"); - patchConsole(console, "table"); - patchConsole(console, "trace"); - patchConsole(console, "warn"); - } - - var ObjectPrototype = Object.prototype; - var stringify = JSON.stringify; // Serializable values - // Thenable - // task status - - var PENDING = 0; - var COMPLETED = 1; - var ERRORED = 4; // object reference status - - var SEEN_BUT_NOT_YET_OUTLINED = -1; - var NEVER_OUTLINED = -2; - - function defaultErrorHandler(error) { - console["error"](error); // Don't transform to our wrapper - } - - function defaultPostponeHandler(reason) { - // Noop - } - - var OPEN = 0; - var CLOSING = 1; - var CLOSED = 2; - function createRequest( - model, - bundlerConfig, - onError, - identifierPrefix, - onPostpone, - environmentName - ) { - if ( - ReactSharedInternals.C !== null && - ReactSharedInternals.C !== DefaultCacheDispatcher - ) { - throw new Error( - "Currently React only supports one RSC renderer at a time." - ); - } - - ReactSharedInternals.C = DefaultCacheDispatcher; - var abortSet = new Set(); - var pingedTasks = []; - var cleanupQueue = []; - - var hints = createHints(); - var request = { - status: OPEN, - flushScheduled: false, - fatalError: null, - destination: null, - bundlerConfig: bundlerConfig, - cache: new Map(), - nextChunkId: 0, - pendingChunks: 0, - hints: hints, - abortListeners: new Set(), - abortableTasks: abortSet, - pingedTasks: pingedTasks, - completedImportChunks: [], - completedHintChunks: [], - completedRegularChunks: [], - completedErrorChunks: [], - writtenSymbols: new Map(), - writtenClientReferences: new Map(), - writtenServerReferences: new Map(), - writtenObjects: new WeakMap(), - identifierPrefix: identifierPrefix || "", - identifierCount: 1, - taintCleanupQueue: cleanupQueue, - onError: onError === undefined ? defaultErrorHandler : onError, - onPostpone: - onPostpone === undefined ? defaultPostponeHandler : onPostpone - }; - - { - request.environmentName = - environmentName === undefined ? "Server" : environmentName; - } - - var rootTask = createTask(request, model, null, false, abortSet); - pingedTasks.push(rootTask); - return request; - } - var currentRequest = null; - function resolveRequest() { - if (currentRequest) return currentRequest; - - return null; - } - - function serializeThenable(request, task, thenable) { - var newTask = createTask( - request, - null, - task.keyPath, // the server component sequence continues through Promise-as-a-child. - task.implicitSlot, - request.abortableTasks - ); - - { - // If this came from Flight, forward any debug info into this new row. - var debugInfo = thenable._debugInfo; - - if (debugInfo) { - forwardDebugInfo(request, newTask.id, debugInfo); - } - } - - switch (thenable.status) { - case "fulfilled": { - // We have the resolved value, we can go ahead and schedule it for serialization. - newTask.model = thenable.value; - pingTask(request, newTask); - return newTask.id; - } - - case "rejected": { - var x = thenable.reason; - - { - var digest = logRecoverableError(request, x); - emitErrorChunk(request, newTask.id, digest, x); - } - - return newTask.id; - } - - default: { - if (typeof thenable.status === "string") { - // Only instrument the thenable if the status if not defined. If - // it's defined, but an unknown value, assume it's been instrumented by - // some custom userspace implementation. We treat it as "pending". - break; - } - - var pendingThenable = thenable; - pendingThenable.status = "pending"; - pendingThenable.then( - function (fulfilledValue) { - if (thenable.status === "pending") { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if (thenable.status === "pending") { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - ); - break; - } - } - - thenable.then( - function (value) { - newTask.model = value; - pingTask(request, newTask); - }, - function (reason) { - { - newTask.status = ERRORED; - - var _digest = logRecoverableError(request, reason); - - emitErrorChunk(request, newTask.id, _digest, reason); - } - - request.abortableTasks.delete(newTask); - enqueueFlush(request); - } - ); - return newTask.id; - } - - function emitHint(request, code, model) { - emitHintChunk(request, code, model); - enqueueFlush(request); - } - function getHints(request) { - return request.hints; - } - function getCache(request) { - return request.cache; - } - - function readThenable(thenable) { - if (thenable.status === "fulfilled") { - return thenable.value; - } else if (thenable.status === "rejected") { - throw thenable.reason; - } - - throw thenable; - } - - function createLazyWrapperAroundWakeable(wakeable) { - // This is a temporary fork of the `use` implementation until we accept - // promises everywhere. - var thenable = wakeable; - - switch (thenable.status) { - case "fulfilled": - case "rejected": - break; - - default: { - if (typeof thenable.status === "string") { - // Only instrument the thenable if the status if not defined. If - // it's defined, but an unknown value, assume it's been instrumented by - // some custom userspace implementation. We treat it as "pending". - break; - } - - var pendingThenable = thenable; - pendingThenable.status = "pending"; - pendingThenable.then( - function (fulfilledValue) { - if (thenable.status === "pending") { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if (thenable.status === "pending") { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - ); - break; - } - } - - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _payload: thenable, - _init: readThenable - }; - - { - // If this came from React, transfer the debug info. - lazyType._debugInfo = thenable._debugInfo || []; - } - - return lazyType; - } - - function renderFunctionComponent( - request, - task, - key, - Component, - props, - owner - ) { - // Reset the task's thenable state before continuing, so that if a later - // component suspends we can reuse the same task object. If the same - // component suspends again, the thenable state will be restored. - var prevThenableState = task.thenableState; - task.thenableState = null; - var componentDebugInfo = null; - - { - if (debugID === null) { - // We don't have a chunk to assign debug info. We need to outline this - // component to assign it an ID. - return outlineTask(request, task); - } else if (prevThenableState !== null) { - // This is a replay and we've already emitted the debug info of this component - // in the first pass. We skip emitting a duplicate line. - // As a hack we stashed the previous component debug info on this object in DEV. - componentDebugInfo = prevThenableState._componentDebugInfo; - } else { - // This is a new component in the same task so we can emit more debug info. - var componentName = Component.displayName || Component.name || ""; - request.pendingChunks++; - var componentDebugID = debugID; - componentDebugInfo = { - name: componentName, - env: request.environmentName, - owner: owner - }; // We outline this model eagerly so that we can refer to by reference as an owner. - // If we had a smarter way to dedupe we might not have to do this if there ends up - // being no references to this as an owner. - - outlineModel(request, componentDebugInfo); - emitDebugChunk(request, componentDebugID, componentDebugInfo); - } - } - - prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early. - - var secondArg = undefined; - var result; - - { - ReactSharedInternals.owner = componentDebugInfo; - - try { - result = Component(props, secondArg); - } finally { - ReactSharedInternals.owner = null; - } - } - - if ( - typeof result === "object" && - result !== null && - typeof result.then === "function" - ) { - // When the return value is in children position we can resolve it immediately, - // to its value without a wrapper if it's synchronously available. - var thenable = result; - - if (thenable.status === "fulfilled") { - return thenable.value; - } // TODO: Once we accept Promises as children on the client, we can just return - // the thenable here. - - result = createLazyWrapperAroundWakeable(result); - } // Track this element's key on the Server Component on the keyPath context.. - - var prevKeyPath = task.keyPath; - var prevImplicitSlot = task.implicitSlot; - - if (key !== null) { - // Append the key to the path. Technically a null key should really add the child - // index. We don't do that to hold the payload small and implementation simple. - task.keyPath = prevKeyPath === null ? key : prevKeyPath + "," + key; - } else if (prevKeyPath === null) { - // This sequence of Server Components has no keys. This means that it was rendered - // in a slot that needs to assign an implicit key. Even if children below have - // explicit keys, they should not be used for the outer most key since it might - // collide with other slots in that set. - task.implicitSlot = true; - } - - var json = renderModelDestructive(request, task, emptyRoot, "", result); - task.keyPath = prevKeyPath; - task.implicitSlot = prevImplicitSlot; - return json; - } - - function renderFragment(request, task, children) { - if (task.keyPath !== null) { - // We have a Server Component that specifies a key but we're now splitting - // the tree using a fragment. - var fragment = [ - REACT_ELEMENT_TYPE, - REACT_FRAGMENT_TYPE, - task.keyPath, - { - children: children - } - ]; - - if (!task.implicitSlot) { - // If this was keyed inside a set. I.e. the outer Server Component was keyed - // then we need to handle reorders of the whole set. To do this we need to wrap - // this array in a keyed Fragment. - return fragment; - } // If the outer Server Component was implicit but then an inner one had a key - // we don't actually need to be able to move the whole set around. It'll always be - // in an implicit slot. The key only exists to be able to reset the state of the - // children. We could achieve the same effect by passing on the keyPath to the next - // set of components inside the fragment. This would also allow a keyless fragment - // reconcile against a single child. - // Unfortunately because of JSON.stringify, we can't call the recursive loop for - // each child within this context because we can't return a set with already resolved - // values. E.g. a string would get double encoded. Returning would pop the context. - // So instead, we wrap it with an unkeyed fragment and inner keyed fragment. - - return [fragment]; - } // Since we're yielding here, that implicitly resets the keyPath context on the - // way up. Which is what we want since we've consumed it. If this changes to - // be recursive serialization, we need to reset the keyPath and implicitSlot, - // before recursing here. - - { - var debugInfo = children._debugInfo; - - if (debugInfo) { - // If this came from Flight, forward any debug info into this new row. - if (debugID === null) { - // We don't have a chunk to assign debug info. We need to outline this - // component to assign it an ID. - return outlineTask(request, task); - } else { - // Forward any debug info we have the first time we see it. - // We do this after init so that we have received all the debug info - // from the server by the time we emit it. - forwardDebugInfo(request, debugID, debugInfo); - } // Since we're rendering this array again, create a copy that doesn't - // have the debug info so we avoid outlining or emitting debug info again. - - children = Array.from(children); - } - } - - return children; - } - - function renderClientElement(task, type, key, props, owner) { - // DEV-only - // the keys of any Server Components which are not serialized. - - var keyPath = task.keyPath; - - if (key === null) { - key = keyPath; - } else if (keyPath !== null) { - key = keyPath + "," + key; - } - - var element = [REACT_ELEMENT_TYPE, type, key, props, owner]; - - if (task.implicitSlot && key !== null) { - // The root Server Component had no key so it was in an implicit slot. - // If we had a key lower, it would end up in that slot with an explicit key. - // We wrap the element in a fragment to give it an implicit key slot with - // an inner explicit key. - return [element]; - } // Since we're yielding here, that implicitly resets the keyPath context on the - // way up. Which is what we want since we've consumed it. If this changes to - // be recursive serialization, we need to reset the keyPath and implicitSlot, - // before recursing here. We also need to reset it once we render into an array - // or anything else too which we also get implicitly. - - return element; - } // The chunk ID we're currently rendering that we can assign debug data to. - - var debugID = null; - - function outlineTask(request, task) { - var newTask = createTask( - request, - task.model, // the currently rendering element - task.keyPath, // unlike outlineModel this one carries along context - task.implicitSlot, - request.abortableTasks - ); - retryTask(request, newTask); - - if (newTask.status === COMPLETED) { - // We completed synchronously so we can refer to this by reference. This - // makes it behaves the same as prod during deserialization. - return serializeByValueID(newTask.id); - } // This didn't complete synchronously so it wouldn't have even if we didn't - // outline it, so this would reduce to a lazy reference even in prod. - - return serializeLazyID(newTask.id); - } - - function renderElement(request, task, type, key, ref, props, owner) { - // DEV only - if (ref !== null && ref !== undefined) { - // When the ref moves to the regular props object this will implicitly - // throw for functions. We could probably relax it to a DEV warning for other - // cases. - // TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we - // do what the above comment says? - throw new Error( - "Refs cannot be used in Server Components, nor passed to Client Components." - ); - } - - { - jsxPropsParents.set(props, type); - - if (typeof props.children === "object" && props.children !== null) { - jsxChildrenParents.set(props.children, type); - } - } - - if (typeof type === "function") { - if (isClientReference(type) || isTemporaryReference(type)) { - // This is a reference to a Client Component. - return renderClientElement(task, type, key, props, owner); - } // This is a Server Component. - - return renderFunctionComponent(request, task, key, type, props, owner); - } else if (typeof type === "string") { - // This is a host element. E.g. HTML. - return renderClientElement(task, type, key, props, owner); - } else if (typeof type === "symbol") { - if (type === REACT_FRAGMENT_TYPE && key === null) { - // For key-less fragments, we add a small optimization to avoid serializing - // it as a wrapper. - var prevImplicitSlot = task.implicitSlot; - - if (task.keyPath === null) { - task.implicitSlot = true; - } - - var json = renderModelDestructive( - request, - task, - emptyRoot, - "", - props.children - ); - task.implicitSlot = prevImplicitSlot; - return json; - } // This might be a built-in React component. We'll let the client decide. - // Any built-in works as long as its props are serializable. - - return renderClientElement(task, type, key, props, owner); - } else if (type != null && typeof type === "object") { - if (isClientReference(type)) { - // This is a reference to a Client Component. - return renderClientElement(task, type, key, props, owner); - } - - switch (type.$$typeof) { - case REACT_LAZY_TYPE: { - var payload = type._payload; - var init = type._init; - var wrappedType = init(payload); - return renderElement( - request, - task, - wrappedType, - key, - ref, - props, - owner - ); - } - - case REACT_FORWARD_REF_TYPE: { - return renderFunctionComponent( - request, - task, - key, - type.render, - props, - owner - ); - } - - case REACT_MEMO_TYPE: { - return renderElement( - request, - task, - type.type, - key, - ref, - props, - owner - ); - } - } - } - - throw new Error( - "Unsupported Server Component type: " + - describeValueForErrorMessage(type) - ); - } - - function pingTask(request, task) { - var pingedTasks = request.pingedTasks; - pingedTasks.push(task); - - if (pingedTasks.length === 1) { - request.flushScheduled = request.destination !== null; - scheduleWork(function () { - return performWork(request); - }); - } - } - - function createTask(request, model, keyPath, implicitSlot, abortSet) { - request.pendingChunks++; - var id = request.nextChunkId++; - - if (typeof model === "object" && model !== null) { - // If we're about to write this into a new task we can assign it an ID early so that - // any other references can refer to the value we're about to write. - if (keyPath !== null || implicitSlot); - else { - request.writtenObjects.set(model, id); - } - } - - var task = { - id: id, - status: PENDING, - model: model, - keyPath: keyPath, - implicitSlot: implicitSlot, - ping: function () { - return pingTask(request, task); - }, - toJSON: function (parentPropertyName, value) { - var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us - - { - // $FlowFixMe[incompatible-use] - var originalValue = parent[parentPropertyName]; - - if ( - typeof originalValue === "object" && - originalValue !== value && - !(originalValue instanceof Date) - ) { - if (objectName(originalValue) !== "Object") { - var jsxParentType = jsxChildrenParents.get(parent); - - if (typeof jsxParentType === "string") { - error( - "%s objects cannot be rendered as text children. Try formatting it using toString().%s", - objectName(originalValue), - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } else { - error( - "Only plain objects can be passed to Client Components from Server Components. " + - "%s objects are not supported.%s", - objectName(originalValue), - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - } else { - error( - "Only plain objects can be passed to Client Components from Server Components. " + - "Objects with toJSON methods are not supported. Convert it manually " + - "to a simple value before passing it to props.%s", - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - } - } - - return renderModel(request, task, parent, parentPropertyName, value); - }, - thenableState: null - }; - abortSet.add(task); - return task; - } - - function serializeByValueID(id) { - return "$" + id.toString(16); - } - - function serializeLazyID(id) { - return "$L" + id.toString(16); - } - - function serializeInfinitePromise() { - return "$@"; - } - - function serializePromiseID(id) { - return "$@" + id.toString(16); - } - - function serializeServerReferenceID(id) { - return "$F" + id.toString(16); - } - - function serializeTemporaryReferenceID(id) { - return "$T" + id; - } - - function serializeSymbolReference(name) { - return "$S" + name; - } - - function serializeNumber(number) { - if (Number.isFinite(number)) { - if (number === 0 && 1 / number === -Infinity) { - return "$-0"; - } else { - return number; - } - } else { - if (number === Infinity) { - return "$Infinity"; - } else if (number === -Infinity) { - return "$-Infinity"; - } else { - return "$NaN"; - } - } - } - - function serializeUndefined() { - return "$undefined"; - } - - function serializeDateFromDateJSON(dateJSON) { - // JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString. - // We need only tack on a $D prefix. - return "$D" + dateJSON; - } - - function serializeBigInt(n) { - return "$n" + n.toString(10); - } - - function serializeRowHeader(tag, id) { - return id.toString(16) + ":" + tag; - } - - function encodeReferenceChunk(request, id, reference) { - var json = stringify(reference); - var row = id.toString(16) + ":" + json + "\n"; - return stringToChunk(row); - } - - function serializeClientReference( - request, - parent, - parentPropertyName, - clientReference - ) { - var clientReferenceKey = getClientReferenceKey(clientReference); - var writtenClientReferences = request.writtenClientReferences; - var existingId = writtenClientReferences.get(clientReferenceKey); - - if (existingId !== undefined) { - if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === "1") { - // If we're encoding the "type" of an element, we can refer - // to that by a lazy reference instead of directly since React - // knows how to deal with lazy values. This lets us suspend - // on this component rather than its parent until the code has - // loaded. - return serializeLazyID(existingId); - } - - return serializeByValueID(existingId); - } - - try { - var clientReferenceMetadata = resolveClientReferenceMetadata( - request.bundlerConfig, - clientReference - ); - request.pendingChunks++; - var importId = request.nextChunkId++; - emitImportChunk(request, importId, clientReferenceMetadata); - writtenClientReferences.set(clientReferenceKey, importId); - - if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === "1") { - // If we're encoding the "type" of an element, we can refer - // to that by a lazy reference instead of directly since React - // knows how to deal with lazy values. This lets us suspend - // on this component rather than its parent until the code has - // loaded. - return serializeLazyID(importId); - } - - return serializeByValueID(importId); - } catch (x) { - request.pendingChunks++; - var errorId = request.nextChunkId++; - var digest = logRecoverableError(request, x); - emitErrorChunk(request, errorId, digest, x); - return serializeByValueID(errorId); - } - } - - function outlineModel(request, value) { - var newTask = createTask( - request, - value, - null, // The way we use outlining is for reusing an object. - false, // It makes no sense for that use case to be contextual. - request.abortableTasks - ); - retryTask(request, newTask); - return newTask.id; - } - - function serializeServerReference(request, serverReference) { - var writtenServerReferences = request.writtenServerReferences; - var existingId = writtenServerReferences.get(serverReference); - - if (existingId !== undefined) { - return serializeServerReferenceID(existingId); - } - - var bound = getServerReferenceBoundArguments(); - var serverReferenceMetadata = { - id: getServerReferenceId(), - bound: bound ? Promise.resolve(bound) : null - }; - var metadataId = outlineModel(request, serverReferenceMetadata); - writtenServerReferences.set(serverReference, metadataId); - return serializeServerReferenceID(metadataId); - } - - function serializeTemporaryReference(request, temporaryReference) { - var id = resolveTemporaryReferenceID(temporaryReference); - return serializeTemporaryReferenceID(id); - } - - function serializeLargeTextString(request, text) { - request.pendingChunks++; - var textId = request.nextChunkId++; - emitTextChunk(request, textId, text); - return serializeByValueID(textId); - } - - function serializeMap(request, map) { - var entries = Array.from(map); - - for (var i = 0; i < entries.length; i++) { - var key = entries[i][0]; - - if (typeof key === "object" && key !== null) { - var writtenObjects = request.writtenObjects; - var existingId = writtenObjects.get(key); - - if (existingId === undefined) { - writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED); - } - } - } - - var id = outlineModel(request, entries); - return "$Q" + id.toString(16); - } - - function serializeFormData(request, formData) { - var entries = Array.from(formData.entries()); - var id = outlineModel(request, entries); - return "$K" + id.toString(16); - } - - function serializeSet(request, set) { - var entries = Array.from(set); - - for (var i = 0; i < entries.length; i++) { - var key = entries[i]; - - if (typeof key === "object" && key !== null) { - var writtenObjects = request.writtenObjects; - var existingId = writtenObjects.get(key); - - if (existingId === undefined) { - writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED); - } - } - } - - var id = outlineModel(request, entries); - return "$W" + id.toString(16); - } - - function escapeStringValue(value) { - if (value[0] === "$") { - // We need to escape $ prefixed strings since we use those to encode - // references to IDs and as special symbol values. - return "$" + value; - } else { - return value; - } - } - - var modelRoot = false; - - function renderModel(request, task, parent, key, value) { - var prevKeyPath = task.keyPath; - var prevImplicitSlot = task.implicitSlot; - - try { - return renderModelDestructive(request, task, parent, key, value); - } catch (thrownValue) { - var x = - thrownValue === SuspenseException // This is a special type of exception used for Suspense. For historical - ? // reasons, the rest of the Suspense implementation expects the thrown - // value to be a thenable, because before `use` existed that was the - // (unstable) API for suspending. This implementation detail can change - // later, once we deprecate the old API in favor of `use`. - getSuspendedThenable() - : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced - // to a lazy reference, so that it doesn't error the parent. - - var model = task.model; - var wasReactNode = - typeof model === "object" && - model !== null && - (model.$$typeof === REACT_ELEMENT_TYPE || - model.$$typeof === REACT_LAZY_TYPE); - - if (typeof x === "object" && x !== null) { - // $FlowFixMe[method-unbinding] - if (typeof x.then === "function") { - // Something suspended, we'll need to create a new task and resolve it later. - var newTask = createTask( - request, - task.model, - task.keyPath, - task.implicitSlot, - request.abortableTasks - ); - var ping = newTask.ping; - x.then(ping, ping); - newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner - // functions in case nothing throws so we don't use "finally" here. - - task.keyPath = prevKeyPath; - task.implicitSlot = prevImplicitSlot; - - if (wasReactNode) { - return serializeLazyID(newTask.id); - } - - return serializeByValueID(newTask.id); - } - } // Restore the context. We assume that this will be restored by the inner - // functions in case nothing throws so we don't use "finally" here. - - task.keyPath = prevKeyPath; - task.implicitSlot = prevImplicitSlot; - - if (wasReactNode) { - // Something errored. We'll still send everything we have up until this point. - // We'll replace this element with a lazy reference that throws on the client - // once it gets rendered. - request.pendingChunks++; - var errorId = request.nextChunkId++; - var digest = logRecoverableError(request, x); - emitErrorChunk(request, errorId, digest, x); - return serializeLazyID(errorId); - } // Something errored but it was not in a React Node. There's no need to serialize - // it by value because it'll just error the whole parent row anyway so we can - // just stop any siblings and error the whole parent row. - - throw x; - } - } - - function renderModelDestructive( - request, - task, - parent, - parentPropertyName, - value - ) { - // Set the currently rendering model - task.model = value; // Special Symbol, that's very common. - - if (value === REACT_ELEMENT_TYPE) { - return "$"; - } - - if (value === null) { - return null; - } - - if (typeof value === "object") { - switch (value.$$typeof) { - case REACT_ELEMENT_TYPE: { - var _writtenObjects = request.writtenObjects; - - var _existingId = _writtenObjects.get(value); - - if (_existingId !== undefined) { - if (task.keyPath !== null || task.implicitSlot); - else if (modelRoot === value) { - // This is the ID we're currently emitting so we need to write it - // once but if we discover it again, we refer to it by id. - modelRoot = null; - } else if (_existingId === SEEN_BUT_NOT_YET_OUTLINED) { - // TODO: If we throw here we can treat this as suspending which causes an outline - // but that is able to reuse the same task if we're already in one but then that - // will be a lazy future value rather than guaranteed to exist but maybe that's good. - var newId = outlineModel(request, value); - return serializeByValueID(newId); - } else { - // We've already emitted this as an outlined object, so we can refer to that by its - // existing ID. TODO: We should use a lazy reference since, unlike plain objects, - // elements might suspend so it might not have emitted yet even if we have the ID for - // it. However, this creates an extra wrapper when it's not needed. We should really - // detect whether this already was emitted and synchronously available. In that - // case we can refer to it synchronously and only make it lazy otherwise. - // We currently don't have a data structure that lets us see that though. - return serializeByValueID(_existingId); - } - } else { - // This is the first time we've seen this object. We may never see it again - // so we'll inline it. Mark it as seen. If we see it again, we'll outline. - _writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED); // The element's props are marked as "never outlined" so that they are inlined into - // the same row as the element itself. - - _writtenObjects.set(value.props, NEVER_OUTLINED); - } - - var element = value; - - { - var debugInfo = value._debugInfo; - - if (debugInfo) { - // If this came from Flight, forward any debug info into this new row. - if (debugID === null) { - // We don't have a chunk to assign debug info. We need to outline this - // component to assign it an ID. - return outlineTask(request, task); - } else { - // Forward any debug info we have the first time we see it. - forwardDebugInfo(request, debugID, debugInfo); - } - } - } - - var props = element.props; - var ref; - - if (enableRefAsProp) { - // TODO: This is a temporary, intermediate step. Once the feature - // flag is removed, we should get the ref off the props object right - // before using it. - var refProp = props.ref; - ref = refProp !== undefined ? refProp : null; - } else { - ref = element.ref; - } // Attempt to render the Server Component. - - return renderElement( - request, - task, - element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string - element.key, - ref, - props, - element._owner - ); - } - - case REACT_LAZY_TYPE: { - // Reset the task's thenable state before continuing. If there was one, it was - // from suspending the lazy before. - task.thenableState = null; - var lazy = value; - var payload = lazy._payload; - var init = lazy._init; - var resolvedModel = init(payload); - - { - var _debugInfo = lazy._debugInfo; - - if (_debugInfo) { - // If this came from Flight, forward any debug info into this new row. - if (debugID === null) { - // We don't have a chunk to assign debug info. We need to outline this - // component to assign it an ID. - return outlineTask(request, task); - } else { - // Forward any debug info we have the first time we see it. - // We do this after init so that we have received all the debug info - // from the server by the time we emit it. - forwardDebugInfo(request, debugID, _debugInfo); - } - } - } - - return renderModelDestructive( - request, - task, - emptyRoot, - "", - resolvedModel - ); - } - } - - if (isClientReference(value)) { - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - } - - var writtenObjects = request.writtenObjects; - var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding] - - if (typeof value.then === "function") { - if (existingId !== undefined) { - if (task.keyPath !== null || task.implicitSlot) { - // If we're in some kind of context we can't reuse the result of this render or - // previous renders of this element. We only reuse Promises if they're not wrapped - // by another Server Component. - var _promiseId = serializeThenable(request, task, value); - - return serializePromiseID(_promiseId); - } else if (modelRoot === value) { - // This is the ID we're currently emitting so we need to write it - // once but if we discover it again, we refer to it by id. - modelRoot = null; - } else { - // We've seen this promise before, so we can just refer to the same result. - return serializePromiseID(existingId); - } - } // We assume that any object with a .then property is a "Thenable" type, - // or a Promise type. Either of which can be represented by a Promise. - - var promiseId = serializeThenable(request, task, value); - writtenObjects.set(value, promiseId); - return serializePromiseID(promiseId); - } - - if (existingId !== undefined) { - if (modelRoot === value) { - // This is the ID we're currently emitting so we need to write it - // once but if we discover it again, we refer to it by id. - modelRoot = null; - } else if (existingId === SEEN_BUT_NOT_YET_OUTLINED) { - var _newId = outlineModel(request, value); - - return serializeByValueID(_newId); - } else if (existingId !== NEVER_OUTLINED) { - // We've already emitted this as an outlined object, so we can - // just refer to that by its existing ID. - return serializeByValueID(existingId); - } - } else { - // This is the first time we've seen this object. We may never see it again - // so we'll inline it. Mark it as seen. If we see it again, we'll outline. - writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED); - } - - if (isArray(value)) { - return renderFragment(request, task, value); - } - - if (value instanceof Map) { - return serializeMap(request, value); - } - - if (value instanceof Set) { - return serializeSet(request, value); - } // TODO: FormData is not available in old Node. Remove the typeof later. - - if (typeof FormData === "function" && value instanceof FormData) { - return serializeFormData(request, value); - } - - var iteratorFn = getIteratorFn(value); - - if (iteratorFn) { - return renderFragment(request, task, Array.from(value)); - } - - var proto = getPrototypeOf(value); - - if ( - proto !== ObjectPrototype && - (proto === null || getPrototypeOf(proto) !== null) - ) { - throw new Error( - "Only plain objects, and a few built-ins, can be passed to Client Components " + - "from Server Components. Classes or null prototypes are not supported." - ); - } - - { - if (objectName(value) !== "Object") { - error( - "Only plain objects can be passed to Client Components from Server Components. " + - "%s objects are not supported.%s", - objectName(value), - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } else if (!isSimpleObject(value)) { - error( - "Only plain objects can be passed to Client Components from Server Components. " + - "Classes or other objects with methods are not supported.%s", - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } else if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(value); - - if (symbols.length > 0) { - error( - "Only plain objects can be passed to Client Components from Server Components. " + - "Objects with symbol properties like %s are not supported.%s", - symbols[0].description, - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - } - } // $FlowFixMe[incompatible-return] - - return value; - } - - if (typeof value === "string") { - if (value[value.length - 1] === "Z") { - // Possibly a Date, whose toJSON automatically calls toISOString - // $FlowFixMe[incompatible-use] - var originalValue = parent[parentPropertyName]; - - if (originalValue instanceof Date) { - return serializeDateFromDateJSON(value); - } - } - - if (value.length >= 1024) { - // For large strings, we encode them outside the JSON payload so that we - // don't have to double encode and double parse the strings. This can also - // be more compact in case the string has a lot of escaped characters. - return serializeLargeTextString(request, value); - } - - return escapeStringValue(value); - } - - if (typeof value === "boolean") { - return value; - } - - if (typeof value === "number") { - return serializeNumber(value); - } - - if (typeof value === "undefined") { - return serializeUndefined(); - } - - if (typeof value === "function") { - if (isClientReference(value)) { - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - } - - if (isServerReference()) { - return serializeServerReference(request, value); - } - - if (isTemporaryReference(value)) { - return serializeTemporaryReference(request, value); - } - - if (/^on[A-Z]/.test(parentPropertyName)) { - throw new Error( - "Event handlers cannot be passed to Client Component props." + - describeObjectForErrorMessage(parent, parentPropertyName) + - "\nIf you need interactivity, consider converting part of this to a Client Component." - ); - } else if ( - jsxChildrenParents.has(parent) || - (jsxPropsParents.has(parent) && parentPropertyName === "children") - ) { - var componentName = value.displayName || value.name || "Component"; - throw new Error( - "Functions are not valid as a child of Client Components. This may happen if " + - "you return " + - componentName + - " instead of <" + - componentName + - " /> from render. " + - "Or maybe you meant to call this function rather than return it." + - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } else { - throw new Error( - "Functions cannot be passed directly to Client Components " + - 'unless you explicitly expose it by marking it with "use server". ' + - "Or maybe you meant to call this function rather than return it." + - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - } - - if (typeof value === "symbol") { - var writtenSymbols = request.writtenSymbols; - - var _existingId2 = writtenSymbols.get(value); - - if (_existingId2 !== undefined) { - return serializeByValueID(_existingId2); - } // $FlowFixMe[incompatible-type] `description` might be undefined - - var name = value.description; - - if (Symbol.for(name) !== value) { - throw new Error( - "Only global symbols received from Symbol.for(...) can be passed to Client Components. " + - ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined - value.description + - ") cannot be found among global symbols.") + - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - - request.pendingChunks++; - var symbolId = request.nextChunkId++; - emitSymbolChunk(request, symbolId, name); - writtenSymbols.set(value, symbolId); - return serializeByValueID(symbolId); - } - - if (typeof value === "bigint") { - return serializeBigInt(value); - } - - throw new Error( - "Type " + - typeof value + - " is not supported in Client Component props." + - describeObjectForErrorMessage(parent, parentPropertyName) - ); - } - - function logRecoverableError(request, error) { - var prevRequest = currentRequest; - currentRequest = null; - var errorDigest; - - try { - var onError = request.onError; - - if (supportsRequestStorage); - else { - errorDigest = onError(error); - } - } finally { - currentRequest = prevRequest; - } - - if (errorDigest != null && typeof errorDigest !== "string") { - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' + - typeof errorDigest + - '" instead' - ); - } - - return errorDigest || ""; - } - - function fatalError(request, error) { - if (request.destination !== null) { - request.status = CLOSED; - closeWithError(request.destination, error); - } else { - request.status = CLOSING; - request.fatalError = error; - } - } - - function emitErrorChunk(request, id, digest, error) { - var errorInfo; - - { - var message; - var stack = ""; - - try { - if (error instanceof Error) { - // eslint-disable-next-line react-internal/safe-string-coercion - message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion - - stack = String(error.stack); - } else if (typeof error === "object" && error !== null) { - message = describeObjectForErrorMessage(error); - } else { - // eslint-disable-next-line react-internal/safe-string-coercion - message = String(error); - } - } catch (x) { - message = - "An error occurred but serializing the error message failed."; - } - - errorInfo = { - digest: digest, - message: message, - stack: stack - }; - } - - var row = serializeRowHeader("E", id) + stringify(errorInfo) + "\n"; - var processedChunk = stringToChunk(row); - request.completedErrorChunks.push(processedChunk); - } - - function emitImportChunk(request, id, clientReferenceMetadata) { - // $FlowFixMe[incompatible-type] stringify can return null - var json = stringify(clientReferenceMetadata); - var row = serializeRowHeader("I", id) + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedImportChunks.push(processedChunk); - } - - function emitHintChunk(request, code, model) { - var json = stringify(model); - var id = request.nextChunkId++; - var row = serializeRowHeader("H" + code, id) + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedHintChunks.push(processedChunk); - } - - function emitSymbolChunk(request, id, name) { - var symbolReference = serializeSymbolReference(name); - var processedChunk = encodeReferenceChunk(request, id, symbolReference); - request.completedImportChunks.push(processedChunk); - } - - function emitModelChunk(request, id, json) { - var row = id.toString(16) + ":" + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedRegularChunks.push(processedChunk); - } - - function emitDebugChunk(request, id, debugInfo) { - // use the full serialization that requires a task. - - var counter = { - objectCount: 0 - }; - - function replacer(parentPropertyName, value) { - return renderConsoleValue( - request, - counter, - this, - parentPropertyName, - value - ); - } // $FlowFixMe[incompatible-type] stringify can return null - - var json = stringify(debugInfo, replacer); - var row = serializeRowHeader("D", id) + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedRegularChunks.push(processedChunk); - } - - function emitTextChunk(request, id, text) { - request.pendingChunks++; // Extra chunk for the header. - - var textChunk = stringToChunk(text); - var binaryLength = byteLengthOfChunk(textChunk); - var row = id.toString(16) + ":T" + binaryLength.toString(16) + ","; - var headerChunk = stringToChunk(row); - request.completedRegularChunks.push(headerChunk, textChunk); - } - - function serializeEval(source) { - return "$E" + source; - } // This is a forked version of renderModel which should never error, never suspend and is limited - // in the depth it can encode. - - function renderConsoleValue( - request, - counter, - parent, - parentPropertyName, - value - ) { - // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us - // $FlowFixMe[incompatible-use] - var originalValue = parent[parentPropertyName]; - - if (value === null) { - return null; - } - - if (typeof value === "object") { - if (isClientReference(value)) { - // We actually have this value on the client so we could import it. - // This might be confusing though because on the Server it won't actually - // be this value, so if you're debugging client references maybe you'd be - // better with a place holder. - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - } - - if (counter.objectCount > 20) { - // We've reached our max number of objects to serialize across the wire so we serialize this - // object but no properties inside of it, as a place holder. - return Array.isArray(value) ? [] : {}; - } - - counter.objectCount++; - var writtenObjects = request.writtenObjects; - var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding] - - if (typeof value.then === "function") { - if (existingId !== undefined) { - // We've seen this promise before, so we can just refer to the same result. - return serializePromiseID(existingId); - } - - var thenable = value; - - switch (thenable.status) { - case "fulfilled": { - return serializePromiseID( - outlineConsoleValue(request, counter, thenable.value) - ); - } - - case "rejected": { - var x = thenable.reason; - request.pendingChunks++; - var errorId = request.nextChunkId++; - - { - // We don't log these errors since they didn't actually throw into Flight. - var digest = ""; - emitErrorChunk(request, errorId, digest, x); - } - - return serializePromiseID(errorId); - } - } // If it hasn't already resolved (and been instrumented) we just encode an infinite - // promise that will never resolve. - - return serializeInfinitePromise(); - } - - if (existingId !== undefined && existingId >= 0) { - // We've already emitted this as a real object, so we can - // just refer to that by its existing ID. - return serializeByValueID(existingId); - } - - if (isArray(value)) { - return value; - } - - if (value instanceof Map) { - return serializeMap(request, value); - } - - if (value instanceof Set) { - return serializeSet(request, value); - } // TODO: FormData is not available in old Node. Remove the typeof later. - - if (typeof FormData === "function" && value instanceof FormData) { - return serializeFormData(request, value); - } - - var iteratorFn = getIteratorFn(value); - - if (iteratorFn) { - return Array.from(value); - } // $FlowFixMe[incompatible-return] - - return value; - } - - if (typeof value === "string") { - if (value[value.length - 1] === "Z") { - // Possibly a Date, whose toJSON automatically calls toISOString - if (originalValue instanceof Date) { - return serializeDateFromDateJSON(value); - } - } - - if (value.length >= 1024) { - // For large strings, we encode them outside the JSON payload so that we - // don't have to double encode and double parse the strings. This can also - // be more compact in case the string has a lot of escaped characters. - return serializeLargeTextString(request, value); - } - - return escapeStringValue(value); - } - - if (typeof value === "boolean") { - return value; - } - - if (typeof value === "number") { - return serializeNumber(value); - } - - if (typeof value === "undefined") { - return serializeUndefined(); - } - - if (typeof value === "function") { - if (isClientReference(value)) { - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - } - - if (isTemporaryReference(value)) { - return serializeTemporaryReference(request, value); - } // Serialize the body of the function as an eval so it can be printed. - // $FlowFixMe[method-unbinding] - - return serializeEval( - "(" + Function.prototype.toString.call(value) + ")" - ); - } - - if (typeof value === "symbol") { - var writtenSymbols = request.writtenSymbols; - - var _existingId3 = writtenSymbols.get(value); - - if (_existingId3 !== undefined) { - return serializeByValueID(_existingId3); - } // $FlowFixMe[incompatible-type] `description` might be undefined - - var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough. - - request.pendingChunks++; - var symbolId = request.nextChunkId++; - emitSymbolChunk(request, symbolId, name); - return serializeByValueID(symbolId); - } - - if (typeof value === "bigint") { - return serializeBigInt(value); - } - - return "unknown type " + typeof value; - } - - function outlineConsoleValue(request, counter, model) { - function replacer(parentPropertyName, value) { - try { - return renderConsoleValue( - request, - counter, - this, - parentPropertyName, - value - ); - } catch (x) { - return "unknown value"; - } - } // $FlowFixMe[incompatible-type] stringify can return null - - var json = stringify(model, replacer); - request.pendingChunks++; - var id = request.nextChunkId++; - var row = id.toString(16) + ":" + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedRegularChunks.push(processedChunk); - return id; - } - - function emitConsoleChunk( - request, - id, - methodName, - owner, - stackTrace, - args - ) { - var counter = { - objectCount: 0 - }; - - function replacer(parentPropertyName, value) { - try { - return renderConsoleValue( - request, - counter, - this, - parentPropertyName, - value - ); - } catch (x) { - return "unknown value"; - } - } // TODO: Don't double badge if this log came from another Flight Client. - - var env = request.environmentName; - var payload = [methodName, stackTrace, owner, env]; // $FlowFixMe[method-unbinding] - - payload.push.apply(payload, args); // $FlowFixMe[incompatible-type] stringify can return null - - var json = stringify(payload, replacer); - var row = serializeRowHeader("W", id) + json + "\n"; - var processedChunk = stringToChunk(row); - request.completedRegularChunks.push(processedChunk); - } - - function forwardDebugInfo(request, id, debugInfo) { - for (var i = 0; i < debugInfo.length; i++) { - request.pendingChunks++; - emitDebugChunk(request, id, debugInfo[i]); - } - } - - function emitChunk(request, task, value) { - var id = task.id; // For certain types we have special types, we typically outlined them but - // we can emit them directly for this row instead of through an indirection. - - if (typeof value === "string") { - emitTextChunk(request, id, value); - return; - } - // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do - - var json = stringify(value, task.toJSON); - emitModelChunk(request, task.id, json); - } - - var emptyRoot = {}; - - function retryTask(request, task) { - if (task.status !== PENDING) { - // We completed this by other means before we had a chance to retry it. - return; - } - - var prevDebugID = debugID; - - try { - // Track the root so we know that we have to emit this object even though it - // already has an ID. This is needed because we might see this object twice - // in the same toJSON if it is cyclic. - modelRoot = task.model; - - if (true) { - // Track the ID of the current task so we can assign debug info to this id. - debugID = task.id; - } // We call the destructive form that mutates this task. That way if something - // suspends again, we can reuse the same task instead of spawning a new one. - - var resolvedModel = renderModelDestructive( - request, - task, - emptyRoot, - "", - task.model - ); - - if (true) { - // We're now past rendering this task and future renders will spawn new tasks for their - // debug info. - debugID = null; - } // Track the root again for the resolved object. - - modelRoot = resolvedModel; // The keyPath resets at any terminal child node. - - task.keyPath = null; - task.implicitSlot = false; - - if (typeof resolvedModel === "object" && resolvedModel !== null) { - // Object might contain unresolved values like additional elements. - // This is simulating what the JSON loop would do if this was part of it. - emitChunk(request, task, resolvedModel); - } else { - // If the value is a string, it means it's a terminal value and we already escaped it - // We don't need to escape it again so it's not passed the toJSON replacer. - // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do - var json = stringify(resolvedModel); - emitModelChunk(request, task.id, json); - } - - request.abortableTasks.delete(task); - task.status = COMPLETED; - } catch (thrownValue) { - var x = - thrownValue === SuspenseException // This is a special type of exception used for Suspense. For historical - ? // reasons, the rest of the Suspense implementation expects the thrown - // value to be a thenable, because before `use` existed that was the - // (unstable) API for suspending. This implementation detail can change - // later, once we deprecate the old API in favor of `use`. - getSuspendedThenable() - : thrownValue; - - if (typeof x === "object" && x !== null) { - // $FlowFixMe[method-unbinding] - if (typeof x.then === "function") { - // Something suspended again, let's pick it back up later. - var ping = task.ping; - x.then(ping, ping); - task.thenableState = getThenableStateAfterSuspending(); - return; - } - } - - request.abortableTasks.delete(task); - task.status = ERRORED; - var digest = logRecoverableError(request, x); - emitErrorChunk(request, task.id, digest, x); - } finally { - { - debugID = prevDebugID; - } - } - } - - function performWork(request) { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = HooksDispatcher; - var prevRequest = currentRequest; - currentRequest = request; - prepareToUseHooksForRequest(request); - - try { - var pingedTasks = request.pingedTasks; - request.pingedTasks = []; - - for (var i = 0; i < pingedTasks.length; i++) { - var task = pingedTasks[i]; - retryTask(request, task); - } - - if (request.destination !== null) { - flushCompletedChunks(request, request.destination); - } - } catch (error) { - logRecoverableError(request, error); - fatalError(request, error); - } finally { - ReactSharedInternals.H = prevDispatcher; - resetHooksForRequest(); - currentRequest = prevRequest; - } - } - - function flushCompletedChunks(request, destination) { - beginWriting(destination); - - try { - // We emit module chunks first in the stream so that - // they can be preloaded as early as possible. - var importsChunks = request.completedImportChunks; - var i = 0; - - for (; i < importsChunks.length; i++) { - request.pendingChunks--; - var chunk = importsChunks[i]; - var keepWriting = writeChunkAndReturn(destination, chunk); - - if (!keepWriting) { - request.destination = null; - i++; - break; - } - } - - importsChunks.splice(0, i); // Next comes hints. - - var hintChunks = request.completedHintChunks; - i = 0; - - for (; i < hintChunks.length; i++) { - var _chunk = hintChunks[i]; - - var _keepWriting = writeChunkAndReturn(destination, _chunk); - - if (!_keepWriting) { - request.destination = null; - i++; - break; - } - } - - hintChunks.splice(0, i); // Next comes model data. - - var regularChunks = request.completedRegularChunks; - i = 0; - - for (; i < regularChunks.length; i++) { - request.pendingChunks--; - var _chunk2 = regularChunks[i]; - - var _keepWriting2 = writeChunkAndReturn(destination, _chunk2); - - if (!_keepWriting2) { - request.destination = null; - i++; - break; - } - } - - regularChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay - // any error messages and prioritize display of other parts of - // the page. - - var errorChunks = request.completedErrorChunks; - i = 0; - - for (; i < errorChunks.length; i++) { - request.pendingChunks--; - var _chunk3 = errorChunks[i]; - - var _keepWriting3 = writeChunkAndReturn(destination, _chunk3); - - if (!_keepWriting3) { - request.destination = null; - i++; - break; - } - } - - errorChunks.splice(0, i); - } finally { - request.flushScheduled = false; - completeWriting(destination); - } - - flushBuffered(destination); - - if (request.pendingChunks === 0) { - close(destination); - request.destination = null; - } - } - - function startWork(request) { - request.flushScheduled = request.destination !== null; - - { - scheduleWork(function () { - return performWork(request); - }); - } - } - - function enqueueFlush(request) { - if ( - request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes - request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will - // happen when we start flowing again - request.destination !== null - ) { - var destination = request.destination; - request.flushScheduled = true; - scheduleWork(function () { - return flushCompletedChunks(request, destination); - }); - } - } - - function startFlowing(request, destination) { - if (request.status === CLOSING) { - request.status = CLOSED; - closeWithError(destination, request.fatalError); - return; - } - - if (request.status === CLOSED) { - return; - } - - if (request.destination !== null) { - // We're already flowing. - return; - } - - request.destination = destination; - - try { - flushCompletedChunks(request, destination); - } catch (error) { - logRecoverableError(request, error); - fatalError(request, error); - } - } - - function renderToDestination(destination, model, options) { - if (!configured) { - throw new Error( - "Please make sure to call `setConfig(...)` before calling `renderToDestination`." - ); - } - - var request = createRequest( - model, - null, - options ? options.onError : undefined, - undefined, - undefined - ); - startWork(request); - startFlowing(request, destination); - } - - var configured = false; - - function setConfig(config) { - setByteLengthOfChunkImplementation(config.byteLength); - setCheckIsClientReference(config.isClientReference); - configured = true; - } - - exports.clearRequestedClientReferencesKeysSet = - clearRequestedClientReferencesKeysSet; - exports.getRequestedClientReferencesKeys = getRequestedClientReferencesKeys; - exports.registerClientReference = registerClientReference; - exports.registerServerReference = registerServerReference; - exports.renderToDestination = renderToDestination; - exports.setCheckIsClientReference = setCheckIsClientReference; - exports.setConfig = setConfig; - })(); -} diff --git a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js b/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js deleted file mode 100644 index 4d767bd6b9a31..0000000000000 --- a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js +++ /dev/null @@ -1,1171 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; -var ReactDOM = require("react-dom"), - React = require("react"), - requestedClientReferencesKeys = new Set(), - checkIsClientReference; -function isClientReference(reference) { - if (null == checkIsClientReference) - throw Error("Expected implementation for checkIsClientReference."); - return checkIsClientReference(reference); -} -var enableRefAsProp = require("ReactFeatureFlags").enableRefAsProp, - byteLengthImpl = null; -function writeChunkAndReturn(destination, chunk) { - destination.write(chunk); - return !0; -} -var ReactDOMSharedInternals = - ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, - previousDispatcher = ReactDOMSharedInternals.d; -ReactDOMSharedInternals.d = { - f: previousDispatcher.f, - r: previousDispatcher.r, - D: prefetchDNS, - C: preconnect, - L: preload, - m: preloadModule, - X: preinitScript, - S: preinitStyle, - M: preinitModuleScript -}; -function prefetchDNS(href) { - if ("string" === typeof href && href) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "D|" + href; - hints.has(key) || (hints.add(key), emitHint(request, "D", href)); - } else previousDispatcher.D(href); - } -} -function preconnect(href, crossOrigin) { - if ("string" === typeof href) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "C|" + (null == crossOrigin ? "null" : crossOrigin) + "|" + href; - hints.has(key) || - (hints.add(key), - "string" === typeof crossOrigin - ? emitHint(request, "C", [href, crossOrigin]) - : emitHint(request, "C", href)); - } else previousDispatcher.C(href, crossOrigin); - } -} -function preload(href, as, options) { - if ("string" === typeof href) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "L"; - if ("image" === as && options) { - var imageSrcSet = options.imageSrcSet, - imageSizes = options.imageSizes, - uniquePart = ""; - "string" === typeof imageSrcSet && "" !== imageSrcSet - ? ((uniquePart += "[" + imageSrcSet + "]"), - "string" === typeof imageSizes && - (uniquePart += "[" + imageSizes + "]")) - : (uniquePart += "[][]" + href); - key += "[image]" + uniquePart; - } else key += "[" + as + "]" + href; - hints.has(key) || - (hints.add(key), - (options = trimOptions(options)) - ? emitHint(request, "L", [href, as, options]) - : emitHint(request, "L", [href, as])); - } else previousDispatcher.L(href, as, options); - } -} -function preloadModule(href, options) { - if ("string" === typeof href) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "m|" + href; - if (hints.has(key)) return; - hints.add(key); - return (options = trimOptions(options)) - ? emitHint(request, "m", [href, options]) - : emitHint(request, "m", href); - } - previousDispatcher.m(href, options); - } -} -function preinitStyle(href, precedence, options) { - if ("string" === typeof href) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "S|" + href; - if (hints.has(key)) return; - hints.add(key); - return (options = trimOptions(options)) - ? emitHint(request, "S", [ - href, - "string" === typeof precedence ? precedence : 0, - options - ]) - : "string" === typeof precedence - ? emitHint(request, "S", [href, precedence]) - : emitHint(request, "S", href); - } - previousDispatcher.S(href, precedence, options); - } -} -function preinitScript(src, options) { - if ("string" === typeof src) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "X|" + src; - if (hints.has(key)) return; - hints.add(key); - return (options = trimOptions(options)) - ? emitHint(request, "X", [src, options]) - : emitHint(request, "X", src); - } - previousDispatcher.X(src, options); - } -} -function preinitModuleScript(src, options) { - if ("string" === typeof src) { - var request = currentRequest ? currentRequest : null; - if (request) { - var hints = request.hints, - key = "M|" + src; - if (hints.has(key)) return; - hints.add(key); - return (options = trimOptions(options)) - ? emitHint(request, "M", [src, options]) - : emitHint(request, "M", src); - } - previousDispatcher.M(src, options); - } -} -function trimOptions(options) { - if (null == options) return null; - var hasProperties = !1, - trimmed = {}, - key; - for (key in options) - null != options[key] && - ((hasProperties = !0), (trimmed[key] = options[key])); - return hasProperties ? trimmed : null; -} -var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"), - REACT_ELEMENT_TYPE = Symbol.for("react.element"), - REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), - REACT_CONTEXT_TYPE = Symbol.for("react.context"), - REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), - REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), - REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), - REACT_MEMO_TYPE = Symbol.for("react.memo"), - REACT_LAZY_TYPE = Symbol.for("react.lazy"), - REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"), - MAYBE_ITERATOR_SYMBOL = Symbol.iterator, - SuspenseException = Error( - "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`" - ); -function noop() {} -function trackUsedThenable(thenableState, thenable, index) { - index = thenableState[index]; - void 0 === index - ? thenableState.push(thenable) - : index !== thenable && (thenable.then(noop, noop), (thenable = index)); - switch (thenable.status) { - case "fulfilled": - return thenable.value; - case "rejected": - throw thenable.reason; - default: - "string" === typeof thenable.status - ? thenable.then(noop, noop) - : ((thenableState = thenable), - (thenableState.status = "pending"), - thenableState.then( - function (fulfilledValue) { - if ("pending" === thenable.status) { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if ("pending" === thenable.status) { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - )); - switch (thenable.status) { - case "fulfilled": - return thenable.value; - case "rejected": - throw thenable.reason; - } - suspendedThenable = thenable; - throw SuspenseException; - } -} -var suspendedThenable = null; -function getSuspendedThenable() { - if (null === suspendedThenable) - throw Error( - "Expected a suspended thenable. This is a bug in React. Please file an issue." - ); - var thenable = suspendedThenable; - suspendedThenable = null; - return thenable; -} -var currentRequest$1 = null, - thenableIndexCounter = 0, - thenableState = null; -function getThenableStateAfterSuspending() { - var state = thenableState || []; - thenableState = null; - return state; -} -var HooksDispatcher = { - useMemo: function (nextCreate) { - return nextCreate(); - }, - useCallback: function (callback) { - return callback; - }, - useDebugValue: function () {}, - useDeferredValue: unsupportedHook, - useTransition: unsupportedHook, - readContext: unsupportedContext, - useContext: unsupportedContext, - useReducer: unsupportedHook, - useRef: unsupportedHook, - useState: unsupportedHook, - useInsertionEffect: unsupportedHook, - useLayoutEffect: unsupportedHook, - useImperativeHandle: unsupportedHook, - useEffect: unsupportedHook, - useId: useId, - useSyncExternalStore: unsupportedHook, - useCacheRefresh: function () { - return unsupportedRefresh; - }, - useMemoCache: function (size) { - for (var data = Array(size), i = 0; i < size; i++) - data[i] = REACT_MEMO_CACHE_SENTINEL; - return data; - }, - use: use -}; -function unsupportedHook() { - throw Error("This Hook is not supported in Server Components."); -} -function unsupportedRefresh() { - throw Error("Refreshing the cache is not supported in Server Components."); -} -function unsupportedContext() { - throw Error("Cannot read a Client Context from a Server Component."); -} -function useId() { - if (null === currentRequest$1) - throw Error("useId can only be used while React is rendering"); - var id = currentRequest$1.identifierCount++; - return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":"; -} -function use(usable) { - if ( - (null !== usable && "object" === typeof usable) || - "function" === typeof usable - ) { - if ("function" === typeof usable.then) { - var index = thenableIndexCounter; - thenableIndexCounter += 1; - null === thenableState && (thenableState = []); - return trackUsedThenable(thenableState, usable, index); - } - usable.$$typeof === REACT_CONTEXT_TYPE && unsupportedContext(); - } - if (isClientReference(usable)) { - if (null != usable.value && usable.value.$$typeof === REACT_CONTEXT_TYPE) - throw Error("Cannot read a Client Context from a Server Component."); - throw Error("Cannot use() an already resolved Client Reference."); - } - throw Error("An unsupported type was passed to use(): " + String(usable)); -} -var DefaultCacheDispatcher = { - getCacheForType: function (resourceType) { - var JSCompiler_inline_result = (JSCompiler_inline_result = currentRequest - ? currentRequest - : null) - ? JSCompiler_inline_result.cache - : new Map(); - var entry = JSCompiler_inline_result.get(resourceType); - void 0 === entry && - ((entry = resourceType()), - JSCompiler_inline_result.set(resourceType, entry)); - return entry; - } - }, - isArrayImpl = Array.isArray, - getPrototypeOf = Object.getPrototypeOf; -function objectName(object) { - return Object.prototype.toString - .call(object) - .replace(/^\[object (.*)\]$/, function (m, p0) { - return p0; - }); -} -function describeValueForErrorMessage(value) { - switch (typeof value) { - case "string": - return JSON.stringify( - 10 >= value.length ? value : value.slice(0, 10) + "..." - ); - case "object": - if (isArrayImpl(value)) return "[...]"; - if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG) - return "client"; - value = objectName(value); - return "Object" === value ? "{...}" : value; - case "function": - return value.$$typeof === CLIENT_REFERENCE_TAG - ? "client" - : (value = value.displayName || value.name) - ? "function " + value - : "function"; - default: - return String(value); - } -} -function describeElementType(type) { - if ("string" === typeof type) return type; - switch (type) { - case REACT_SUSPENSE_TYPE: - return "Suspense"; - case REACT_SUSPENSE_LIST_TYPE: - return "SuspenseList"; - } - if ("object" === typeof type) - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeElementType(type.render); - case REACT_MEMO_TYPE: - return describeElementType(type.type); - case REACT_LAZY_TYPE: - var payload = type._payload; - type = type._init; - try { - return describeElementType(type(payload)); - } catch (x) {} - } - return ""; -} -var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); -function describeObjectForErrorMessage(objectOrArray, expandedName) { - var objKind = objectName(objectOrArray); - if ("Object" !== objKind && "Array" !== objKind) return objKind; - objKind = -1; - var length = 0; - if (isArrayImpl(objectOrArray)) { - var str = "["; - for (var i = 0; i < objectOrArray.length; i++) { - 0 < i && (str += ", "); - var value = objectOrArray[i]; - value = - "object" === typeof value && null !== value - ? describeObjectForErrorMessage(value) - : describeValueForErrorMessage(value); - "" + i === expandedName - ? ((objKind = str.length), (length = value.length), (str += value)) - : (str = - 10 > value.length && 40 > str.length + value.length - ? str + value - : str + "..."); - } - str += "]"; - } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) - str = "<" + describeElementType(objectOrArray.type) + "/>"; - else { - if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client"; - str = "{"; - i = Object.keys(objectOrArray); - for (value = 0; value < i.length; value++) { - 0 < value && (str += ", "); - var name = i[value], - encodedKey = JSON.stringify(name); - str += ('"' + name + '"' === encodedKey ? name : encodedKey) + ": "; - encodedKey = objectOrArray[name]; - encodedKey = - "object" === typeof encodedKey && null !== encodedKey - ? describeObjectForErrorMessage(encodedKey) - : describeValueForErrorMessage(encodedKey); - name === expandedName - ? ((objKind = str.length), - (length = encodedKey.length), - (str += encodedKey)) - : (str = - 10 > encodedKey.length && 40 > str.length + encodedKey.length - ? str + encodedKey - : str + "..."); - } - str += "}"; - } - return void 0 === expandedName - ? str - : -1 < objKind && 0 < length - ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)), - "\n " + str + "\n " + objectOrArray) - : "\n " + str; -} -var ReactSharedInternalsServer = - React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; -if (!ReactSharedInternalsServer) - throw Error( - 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.' - ); -var ObjectPrototype = Object.prototype, - stringify = JSON.stringify; -function defaultErrorHandler(error) { - console.error(error); -} -function defaultPostponeHandler() {} -var currentRequest = null; -function serializeThenable(request, task, thenable) { - var newTask = createTask( - request, - null, - task.keyPath, - task.implicitSlot, - request.abortableTasks - ); - switch (thenable.status) { - case "fulfilled": - return ( - (newTask.model = thenable.value), pingTask(request, newTask), newTask.id - ); - case "rejected": - return ( - (task = logRecoverableError(request, thenable.reason)), - emitErrorChunk(request, newTask.id, task), - newTask.id - ); - default: - "string" !== typeof thenable.status && - ((thenable.status = "pending"), - thenable.then( - function (fulfilledValue) { - "pending" === thenable.status && - ((thenable.status = "fulfilled"), - (thenable.value = fulfilledValue)); - }, - function (error) { - "pending" === thenable.status && - ((thenable.status = "rejected"), (thenable.reason = error)); - } - )); - } - thenable.then( - function (value) { - newTask.model = value; - pingTask(request, newTask); - }, - function (reason) { - newTask.status = 4; - reason = logRecoverableError(request, reason); - emitErrorChunk(request, newTask.id, reason); - request.abortableTasks.delete(newTask); - enqueueFlush(request); - } - ); - return newTask.id; -} -function emitHint(request, code, model) { - model = stringify(model); - var id = request.nextChunkId++; - code = "H" + code; - code = id.toString(16) + ":" + code; - request.completedHintChunks.push(code + model + "\n"); - enqueueFlush(request); -} -function readThenable(thenable) { - if ("fulfilled" === thenable.status) return thenable.value; - if ("rejected" === thenable.status) throw thenable.reason; - throw thenable; -} -function createLazyWrapperAroundWakeable(wakeable) { - switch (wakeable.status) { - case "fulfilled": - case "rejected": - break; - default: - "string" !== typeof wakeable.status && - ((wakeable.status = "pending"), - wakeable.then( - function (fulfilledValue) { - "pending" === wakeable.status && - ((wakeable.status = "fulfilled"), - (wakeable.value = fulfilledValue)); - }, - function (error) { - "pending" === wakeable.status && - ((wakeable.status = "rejected"), (wakeable.reason = error)); - } - )); - } - return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable }; -} -function renderFunctionComponent(request, task, key, Component, props) { - var prevThenableState = task.thenableState; - task.thenableState = null; - thenableIndexCounter = 0; - thenableState = prevThenableState; - Component = Component(props, void 0); - if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then - ) { - props = Component; - if ("fulfilled" === props.status) return props.value; - Component = createLazyWrapperAroundWakeable(Component); - } - props = task.keyPath; - prevThenableState = task.implicitSlot; - null !== key - ? (task.keyPath = null === props ? key : props + "," + key) - : null === props && (task.implicitSlot = !0); - request = renderModelDestructive(request, task, emptyRoot, "", Component); - task.keyPath = props; - task.implicitSlot = prevThenableState; - return request; -} -function renderFragment(request, task, children) { - return null !== task.keyPath - ? ((request = [ - REACT_ELEMENT_TYPE, - REACT_FRAGMENT_TYPE, - task.keyPath, - { children: children } - ]), - task.implicitSlot ? [request] : request) - : children; -} -function renderClientElement(task, type, key, props) { - var keyPath = task.keyPath; - null === key - ? (key = keyPath) - : null !== keyPath && (key = keyPath + "," + key); - type = [REACT_ELEMENT_TYPE, type, key, props]; - return task.implicitSlot && null !== key ? [type] : type; -} -function renderElement(request, task, type, key, ref, props) { - if (null !== ref && void 0 !== ref) - throw Error( - "Refs cannot be used in Server Components, nor passed to Client Components." - ); - if ("function" === typeof type) - return isClientReference(type) || type.$$typeof === TEMPORARY_REFERENCE_TAG - ? renderClientElement(task, type, key, props) - : renderFunctionComponent(request, task, key, type, props); - if ("string" === typeof type) - return renderClientElement(task, type, key, props); - if ("symbol" === typeof type) - return type === REACT_FRAGMENT_TYPE && null === key - ? ((key = task.implicitSlot), - null === task.keyPath && (task.implicitSlot = !0), - (request = renderModelDestructive( - request, - task, - emptyRoot, - "", - props.children - )), - (task.implicitSlot = key), - request) - : renderClientElement(task, type, key, props); - if (null != type && "object" === typeof type) { - if (isClientReference(type)) - return renderClientElement(task, type, key, props); - switch (type.$$typeof) { - case REACT_LAZY_TYPE: - var init = type._init; - type = init(type._payload); - return renderElement(request, task, type, key, ref, props); - case REACT_FORWARD_REF_TYPE: - return renderFunctionComponent(request, task, key, type.render, props); - case REACT_MEMO_TYPE: - return renderElement(request, task, type.type, key, ref, props); - } - } - throw Error( - "Unsupported Server Component type: " + describeValueForErrorMessage(type) - ); -} -function pingTask(request, task) { - var pingedTasks = request.pingedTasks; - pingedTasks.push(task); - 1 === pingedTasks.length && - ((request.flushScheduled = null !== request.destination), - performWork(request)); -} -function createTask(request, model, keyPath, implicitSlot, abortSet) { - request.pendingChunks++; - var id = request.nextChunkId++; - "object" !== typeof model || - null === model || - null !== keyPath || - implicitSlot || - request.writtenObjects.set(model, id); - var task = { - id: id, - status: 0, - model: model, - keyPath: keyPath, - implicitSlot: implicitSlot, - ping: function () { - return pingTask(request, task); - }, - toJSON: function (parentPropertyName, value) { - var prevKeyPath = task.keyPath, - prevImplicitSlot = task.implicitSlot; - try { - var JSCompiler_inline_result = renderModelDestructive( - request, - task, - this, - parentPropertyName, - value - ); - } catch (thrownValue) { - if ( - ((parentPropertyName = - thrownValue === SuspenseException - ? getSuspendedThenable() - : thrownValue), - (value = task.model), - (value = - "object" === typeof value && - null !== value && - (value.$$typeof === REACT_ELEMENT_TYPE || - value.$$typeof === REACT_LAZY_TYPE)), - "object" === typeof parentPropertyName && - null !== parentPropertyName && - "function" === typeof parentPropertyName.then) - ) { - JSCompiler_inline_result = createTask( - request, - task.model, - task.keyPath, - task.implicitSlot, - request.abortableTasks - ); - var ping = JSCompiler_inline_result.ping; - parentPropertyName.then(ping, ping); - JSCompiler_inline_result.thenableState = - getThenableStateAfterSuspending(); - task.keyPath = prevKeyPath; - task.implicitSlot = prevImplicitSlot; - JSCompiler_inline_result = value - ? "$L" + JSCompiler_inline_result.id.toString(16) - : serializeByValueID(JSCompiler_inline_result.id); - } else if ( - ((task.keyPath = prevKeyPath), - (task.implicitSlot = prevImplicitSlot), - value) - ) - request.pendingChunks++, - (prevKeyPath = request.nextChunkId++), - (prevImplicitSlot = logRecoverableError( - request, - parentPropertyName - )), - emitErrorChunk(request, prevKeyPath, prevImplicitSlot), - (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16)); - else throw parentPropertyName; - } - return JSCompiler_inline_result; - }, - thenableState: null - }; - abortSet.add(task); - return task; -} -function serializeByValueID(id) { - return "$" + id.toString(16); -} -function serializeClientReference( - request, - parent, - parentPropertyName, - clientReference -) { - var JSCompiler_inline_result = clientReference.getModuleId(); - requestedClientReferencesKeys.add(JSCompiler_inline_result); - JSCompiler_inline_result = clientReference.getModuleId(); - var writtenClientReferences = request.writtenClientReferences, - existingId = writtenClientReferences.get(JSCompiler_inline_result); - if (void 0 !== existingId) - return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName - ? "$L" + existingId.toString(16) - : serializeByValueID(existingId); - try { - var clientReferenceMetadata = { - moduleId: clientReference.getModuleId(), - exportName: "default" - }; - request.pendingChunks++; - var importId = request.nextChunkId++, - json = stringify(clientReferenceMetadata), - processedChunk = importId.toString(16) + ":I" + json + "\n"; - request.completedImportChunks.push(processedChunk); - writtenClientReferences.set(JSCompiler_inline_result, importId); - return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName - ? "$L" + importId.toString(16) - : serializeByValueID(importId); - } catch (x) { - return ( - request.pendingChunks++, - (parent = request.nextChunkId++), - (parentPropertyName = logRecoverableError(request, x)), - emitErrorChunk(request, parent, parentPropertyName), - serializeByValueID(parent) - ); - } -} -function outlineModel(request, value) { - value = createTask(request, value, null, !1, request.abortableTasks); - retryTask(request, value); - return value.id; -} -var modelRoot = !1; -function renderModelDestructive( - request, - task, - parent, - parentPropertyName, - value -) { - task.model = value; - if (value === REACT_ELEMENT_TYPE) return "$"; - if (null === value) return null; - if ("object" === typeof value) { - switch (value.$$typeof) { - case REACT_ELEMENT_TYPE: - parent = request.writtenObjects; - parentPropertyName = parent.get(value); - if (void 0 !== parentPropertyName) { - if (null === task.keyPath && !task.implicitSlot) - if (modelRoot === value) modelRoot = null; - else - return -1 === parentPropertyName - ? ((request = outlineModel(request, value)), - serializeByValueID(request)) - : serializeByValueID(parentPropertyName); - } else parent.set(value, -1), parent.set(value.props, -2); - parent = value.props; - enableRefAsProp - ? ((parentPropertyName = parent.ref), - (parentPropertyName = - void 0 !== parentPropertyName ? parentPropertyName : null)) - : (parentPropertyName = value.ref); - return renderElement( - request, - task, - value.type, - value.key, - parentPropertyName, - parent - ); - case REACT_LAZY_TYPE: - return ( - (task.thenableState = null), - (parent = value._init), - (value = parent(value._payload)), - renderModelDestructive(request, task, emptyRoot, "", value) - ); - } - if (isClientReference(value)) - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - parent = request.writtenObjects; - parentPropertyName = parent.get(value); - if ("function" === typeof value.then) { - if (void 0 !== parentPropertyName) { - if (null !== task.keyPath || task.implicitSlot) - return "$@" + serializeThenable(request, task, value).toString(16); - if (modelRoot === value) modelRoot = null; - else return "$@" + parentPropertyName.toString(16); - } - request = serializeThenable(request, task, value); - parent.set(value, request); - return "$@" + request.toString(16); - } - if (void 0 !== parentPropertyName) - if (modelRoot === value) modelRoot = null; - else { - if (-1 === parentPropertyName) - return ( - (request = outlineModel(request, value)), - serializeByValueID(request) - ); - if (-2 !== parentPropertyName) - return serializeByValueID(parentPropertyName); - } - else parent.set(value, -1); - if (isArrayImpl(value)) return renderFragment(request, task, value); - if (value instanceof Map) { - value = Array.from(value); - for (task = 0; task < value.length; task++) - (parent = value[task][0]), - "object" === typeof parent && - null !== parent && - ((parentPropertyName = request.writtenObjects), - void 0 === parentPropertyName.get(parent) && - parentPropertyName.set(parent, -1)); - return "$Q" + outlineModel(request, value).toString(16); - } - if (value instanceof Set) { - value = Array.from(value); - for (task = 0; task < value.length; task++) - (parent = value[task]), - "object" === typeof parent && - null !== parent && - ((parentPropertyName = request.writtenObjects), - void 0 === parentPropertyName.get(parent) && - parentPropertyName.set(parent, -1)); - return "$W" + outlineModel(request, value).toString(16); - } - if ("function" === typeof FormData && value instanceof FormData) - return ( - (value = Array.from(value.entries())), - "$K" + outlineModel(request, value).toString(16) - ); - null === value || "object" !== typeof value - ? (parent = null) - : ((parent = - (MAYBE_ITERATOR_SYMBOL && value[MAYBE_ITERATOR_SYMBOL]) || - value["@@iterator"]), - (parent = "function" === typeof parent ? parent : null)); - if (parent) return renderFragment(request, task, Array.from(value)); - request = getPrototypeOf(value); - if ( - request !== ObjectPrototype && - (null === request || null !== getPrototypeOf(request)) - ) - throw Error( - "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." - ); - return value; - } - if ("string" === typeof value) { - if ( - "Z" === value[value.length - 1] && - parent[parentPropertyName] instanceof Date - ) - return "$D" + value; - if (1024 <= value.length) - return ( - request.pendingChunks++, - (task = request.nextChunkId++), - emitTextChunk(request, task, value), - serializeByValueID(task) - ); - request = "$" === value[0] ? "$" + value : value; - return request; - } - if ("boolean" === typeof value) return value; - if ("number" === typeof value) - return Number.isFinite(value) - ? 0 === value && -Infinity === 1 / value - ? "$-0" - : value - : Infinity === value - ? "$Infinity" - : -Infinity === value - ? "$-Infinity" - : "$NaN"; - if ("undefined" === typeof value) return "$undefined"; - if ("function" === typeof value) { - if (isClientReference(value)) - return serializeClientReference( - request, - parent, - parentPropertyName, - value - ); - throw Error("isServerReference: Not Implemented."); - } - if ("symbol" === typeof value) { - task = request.writtenSymbols; - var existingId$9 = task.get(value); - if (void 0 !== existingId$9) return serializeByValueID(existingId$9); - existingId$9 = value.description; - if (Symbol.for(existingId$9) !== value) - throw Error( - "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" + - (value.description + ") cannot be found among global symbols.") + - describeObjectForErrorMessage(parent, parentPropertyName) - ); - request.pendingChunks++; - parent = request.nextChunkId++; - parentPropertyName = stringify("$S" + existingId$9); - parentPropertyName = parent.toString(16) + ":" + parentPropertyName + "\n"; - request.completedImportChunks.push(parentPropertyName); - task.set(value, parent); - return serializeByValueID(parent); - } - if ("bigint" === typeof value) return "$n" + value.toString(10); - throw Error( - "Type " + - typeof value + - " is not supported in Client Component props." + - describeObjectForErrorMessage(parent, parentPropertyName) - ); -} -function logRecoverableError(request, error) { - var prevRequest = currentRequest; - currentRequest = null; - try { - var onError = request.onError; - var errorDigest = onError(error); - } finally { - currentRequest = prevRequest; - } - if (null != errorDigest && "string" !== typeof errorDigest) - throw Error( - 'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' + - typeof errorDigest + - '" instead' - ); - return errorDigest || ""; -} -function fatalError(request, error) { - null !== request.destination - ? ((request.status = 2), - (request = request.destination), - request.onError(error), - request.close()) - : ((request.status = 1), (request.fatalError = error)); -} -function emitErrorChunk(request, id, digest) { - digest = { digest: digest }; - id = id.toString(16) + ":E" + stringify(digest) + "\n"; - request.completedErrorChunks.push(id); -} -function emitTextChunk(request, id, text) { - request.pendingChunks++; - if (null == byteLengthImpl) - throw Error( - "byteLengthOfChunk implementation is not configured. Please, provide the implementation via ReactFlightDOMServer.setConfig(...);" - ); - var JSCompiler_inline_result = byteLengthImpl(text); - id = id.toString(16) + ":T" + JSCompiler_inline_result.toString(16) + ","; - request.completedRegularChunks.push(id, text); -} -var emptyRoot = {}; -function retryTask(request, task) { - if (0 === task.status) - try { - modelRoot = task.model; - var resolvedModel = renderModelDestructive( - request, - task, - emptyRoot, - "", - task.model - ); - modelRoot = resolvedModel; - task.keyPath = null; - task.implicitSlot = !1; - if ("object" === typeof resolvedModel && null !== resolvedModel) { - var id = task.id; - if ("string" === typeof resolvedModel) - emitTextChunk(request, id, resolvedModel); - else { - var json = stringify(resolvedModel, task.toJSON), - processedChunk = task.id.toString(16) + ":" + json + "\n"; - request.completedRegularChunks.push(processedChunk); - } - } else { - var json$jscomp$0 = stringify(resolvedModel), - processedChunk$jscomp$0 = - task.id.toString(16) + ":" + json$jscomp$0 + "\n"; - request.completedRegularChunks.push(processedChunk$jscomp$0); - } - request.abortableTasks.delete(task); - task.status = 1; - } catch (thrownValue) { - var x = - thrownValue === SuspenseException - ? getSuspendedThenable() - : thrownValue; - if ("object" === typeof x && null !== x && "function" === typeof x.then) { - var ping = task.ping; - x.then(ping, ping); - task.thenableState = getThenableStateAfterSuspending(); - } else { - request.abortableTasks.delete(task); - task.status = 4; - var digest = logRecoverableError(request, x); - emitErrorChunk(request, task.id, digest); - } - } finally { - } -} -function performWork(request) { - var prevDispatcher = ReactSharedInternalsServer.H; - ReactSharedInternalsServer.H = HooksDispatcher; - var prevRequest = currentRequest; - currentRequest$1 = currentRequest = request; - try { - var pingedTasks = request.pingedTasks; - request.pingedTasks = []; - for (var i = 0; i < pingedTasks.length; i++) - retryTask(request, pingedTasks[i]); - null !== request.destination && - flushCompletedChunks(request, request.destination); - } catch (error) { - logRecoverableError(request, error), fatalError(request, error); - } finally { - (ReactSharedInternalsServer.H = prevDispatcher), - (currentRequest$1 = null), - (currentRequest = prevRequest); - } -} -function flushCompletedChunks(request, destination) { - destination.beginWriting(); - try { - for ( - var importsChunks = request.completedImportChunks, i = 0; - i < importsChunks.length; - i++ - ) - request.pendingChunks--, - writeChunkAndReturn(destination, importsChunks[i]); - importsChunks.splice(0, i); - var hintChunks = request.completedHintChunks; - for (i = 0; i < hintChunks.length; i++) - writeChunkAndReturn(destination, hintChunks[i]); - hintChunks.splice(0, i); - var regularChunks = request.completedRegularChunks; - for (i = 0; i < regularChunks.length; i++) - request.pendingChunks--, - writeChunkAndReturn(destination, regularChunks[i]); - regularChunks.splice(0, i); - var errorChunks = request.completedErrorChunks; - for (i = 0; i < errorChunks.length; i++) - request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]); - errorChunks.splice(0, i); - } finally { - (request.flushScheduled = !1), destination.completeWriting(); - } - destination.flushBuffered(); - 0 === request.pendingChunks && - (destination.close(), (request.destination = null)); -} -function enqueueFlush(request) { - if ( - !1 === request.flushScheduled && - 0 === request.pingedTasks.length && - null !== request.destination - ) { - var destination = request.destination; - request.flushScheduled = !0; - flushCompletedChunks(request, destination); - } -} -var configured = !1; -exports.clearRequestedClientReferencesKeysSet = function () { - requestedClientReferencesKeys.clear(); -}; -exports.getRequestedClientReferencesKeys = function () { - return Array.from(requestedClientReferencesKeys); -}; -exports.registerClientReference = function () {}; -exports.registerServerReference = function () { - throw Error("registerServerReference: Not Implemented."); -}; -exports.renderToDestination = function (destination, model, options) { - if (!configured) - throw Error( - "Please make sure to call `setConfig(...)` before calling `renderToDestination`." - ); - var onError = options ? options.onError : void 0; - if ( - null !== ReactSharedInternalsServer.C && - ReactSharedInternalsServer.C !== DefaultCacheDispatcher - ) - throw Error("Currently React only supports one RSC renderer at a time."); - ReactSharedInternalsServer.C = DefaultCacheDispatcher; - var abortSet = new Set(); - options = []; - var hints = new Set(); - onError = { - status: 0, - flushScheduled: !1, - fatalError: null, - destination: null, - bundlerConfig: null, - cache: new Map(), - nextChunkId: 0, - pendingChunks: 0, - hints: hints, - abortListeners: new Set(), - abortableTasks: abortSet, - pingedTasks: options, - completedImportChunks: [], - completedHintChunks: [], - completedRegularChunks: [], - completedErrorChunks: [], - writtenSymbols: new Map(), - writtenClientReferences: new Map(), - writtenServerReferences: new Map(), - writtenObjects: new WeakMap(), - identifierPrefix: "", - identifierCount: 1, - taintCleanupQueue: [], - onError: void 0 === onError ? defaultErrorHandler : onError, - onPostpone: defaultPostponeHandler - }; - model = createTask(onError, model, null, !1, abortSet); - options.push(model); - onError.flushScheduled = null !== onError.destination; - performWork(onError); - if (1 === onError.status) - (onError.status = 2), - destination.onError(onError.fatalError), - destination.close(); - else if (2 !== onError.status && null === onError.destination) { - onError.destination = destination; - try { - flushCompletedChunks(onError, destination); - } catch (error) { - logRecoverableError(onError, error), fatalError(onError, error); - } - } -}; -exports.setCheckIsClientReference = function (impl) { - checkIsClientReference = impl; -}; -exports.setConfig = function (config) { - byteLengthImpl = config.byteLength; - checkIsClientReference = config.isClientReference; - configured = !0; -}; diff --git a/compiled/facebook-www/ReactServer-dev.modern.js b/compiled/facebook-www/ReactServer-dev.modern.js deleted file mode 100644 index 024e2f308ce18..0000000000000 --- a/compiled/facebook-www/ReactServer-dev.modern.js +++ /dev/null @@ -1,3160 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; - -if (__DEV__) { - (function () { - "use strict"; - - // This refers to a WWW module. - var warningWWW = require("warning"); - function warn(format) { - { - { - for ( - var _len = arguments.length, - args = new Array(_len > 1 ? _len - 1 : 0), - _key = 1; - _key < _len; - _key++ - ) { - args[_key - 1] = arguments[_key]; - } - - printWarning("warn", format, args); - } - } - } - function error(format) { - { - { - for ( - var _len2 = arguments.length, - args = new Array(_len2 > 1 ? _len2 - 1 : 0), - _key2 = 1; - _key2 < _len2; - _key2++ - ) { - args[_key2 - 1] = arguments[_key2]; - } - - printWarning("error", format, args); - } - } - } - - function printWarning(level, format, args) { - { - var React = require("react"); - - var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. - - if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); - - if (stack !== "") { - format += "%s"; - args.push(stack); - } - } // TODO: don't ignore level and pass it down somewhere too. - - args.unshift(format); - args.unshift(false); - warningWWW.apply(null, args); - } - } - - var assign = Object.assign; - - // Re-export dynamic flags from the www version. - var dynamicFeatureFlags = require("ReactFeatureFlags"); - - var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing, - enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, - enableRenderableContext = dynamicFeatureFlags.enableRenderableContext, - enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, - disableDefaultPropsExceptForClasses = - dynamicFeatureFlags.disableDefaultPropsExceptForClasses; // On WWW, true is used for a new modern build. - // because JSX is an extremely hot path. - - var disableStringRefs = false; - - var ReactSharedInternals = { - H: null, - C: null - }; - - { - ReactSharedInternals.owner = null; - } - - { - var currentExtraStackFrame = null; - - ReactSharedInternals.setExtraStackFrame = function (stack) { - currentExtraStackFrame = stack; - }; // Stack implementation injected by the current renderer. - - ReactSharedInternals.getCurrentStack = null; - - ReactSharedInternals.getStackAddendum = function () { - var stack = ""; // Add an extra top frame while an element is being validated - - if (currentExtraStackFrame) { - stack += currentExtraStackFrame; - } // Delegate to the injected renderer-specific implementation - - var impl = ReactSharedInternals.getCurrentStack; - - if (impl) { - stack += impl() || ""; - } - - return stack; - }; - } - - var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare - - function isArray(a) { - return isArrayImpl(a); - } - - // ATTENTION - // When adding new symbols to this file, - // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' - // The Symbol used to tag the ReactElement-like types. - var REACT_ELEMENT_TYPE = Symbol.for("react.element"); - var REACT_PORTAL_TYPE = Symbol.for("react.portal"); - var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"); - var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"); - var REACT_PROFILER_TYPE = Symbol.for("react.profiler"); - var REACT_PROVIDER_TYPE = Symbol.for("react.provider"); // TODO: Delete with enableRenderableContext - - var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"); - var REACT_CONTEXT_TYPE = Symbol.for("react.context"); - var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"); - var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"); - var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"); - var REACT_MEMO_TYPE = Symbol.for("react.memo"); - var REACT_LAZY_TYPE = Symbol.for("react.lazy"); - var REACT_SCOPE_TYPE = Symbol.for("react.scope"); - var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode"); - var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"); - var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"); - var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"); - var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = "@@iterator"; - function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable !== "object") { - return null; - } - - var maybeIterator = - (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || - maybeIterable[FAUX_ITERATOR_SYMBOL]; - - if (typeof maybeIterator === "function") { - return maybeIterator; - } - - return null; - } - - /* - * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol - * and Temporal.* types. See https://github.com/facebook/react/pull/22064. - * - * The functions in this module will throw an easier-to-understand, - * easier-to-debug exception with a clear errors message message explaining the - * problem. (Instead of a confusing exception thrown inside the implementation - * of the `value` object). - */ - // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. - function typeName(value) { - { - // toStringTag is needed for namespaced types like Temporal.Instant - var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag; - var type = - (hasToStringTag && value[Symbol.toStringTag]) || - value.constructor.name || - "Object"; // $FlowFixMe[incompatible-return] - - return type; - } - } // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. - - function willCoercionThrow(value) { - { - try { - testStringCoercion(value); - return false; - } catch (e) { - return true; - } - } - } - - function testStringCoercion(value) { - // If you ended up here by following an exception call stack, here's what's - // happened: you supplied an object or symbol value to React (as a prop, key, - // DOM attribute, CSS property, string ref, etc.) and when React tried to - // coerce it to a string using `'' + value`, an exception was thrown. - // - // The most common types that will cause this exception are `Symbol` instances - // and Temporal objects like `Temporal.Instant`. But any object that has a - // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this - // exception. (Library authors do this to prevent users from using built-in - // numeric operators like `+` or comparison operators like `>=` because custom - // methods are needed to perform accurate arithmetic or comparison.) - // - // To fix the problem, coerce this object or symbol value to a string before - // passing it to React. The most reliable way is usually `String(value)`. - // - // To find which value is throwing, check the browser or debugger console. - // Before this exception was thrown, there should be `console.error` output - // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the - // problem and how that type was used: key, atrribute, input value prop, etc. - // In most cases, this console output also shows the component and its - // ancestor components where the exception happened. - // - // eslint-disable-next-line react-internal/safe-string-coercion - return "" + value; - } - function checkKeyStringCoercion(value) { - { - if (willCoercionThrow(value)) { - error( - "The provided key is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } - function checkPropStringCoercion(value, propName) { - { - if (willCoercionThrow(value)) { - error( - "The provided `%s` prop is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - propName, - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } - - function getWrappedName$1(outerType, innerType, wrapperName) { - var displayName = outerType.displayName; - - if (displayName) { - return displayName; - } - - var functionName = innerType.displayName || innerType.name || ""; - return functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName; - } // Keep in sync with react-reconciler/getComponentNameFromFiber - - function getContextName$1(type) { - return type.displayName || "Context"; - } - - var REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. - - function getComponentNameFromType(type) { - if (type == null) { - // Host root, text node or just invalid type. - return null; - } - - if (typeof type === "function") { - if (type.$$typeof === REACT_CLIENT_REFERENCE$2) { - // TODO: Create a convention for naming client references with debug info. - return null; - } - - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - switch (type) { - case REACT_FRAGMENT_TYPE: - return "Fragment"; - - case REACT_PORTAL_TYPE: - return "Portal"; - - case REACT_PROFILER_TYPE: - return "Profiler"; - - case REACT_STRICT_MODE_TYPE: - return "StrictMode"; - - case REACT_SUSPENSE_TYPE: - return "Suspense"; - - case REACT_SUSPENSE_LIST_TYPE: - return "SuspenseList"; - // Fall through - - case REACT_TRACING_MARKER_TYPE: - if (enableTransitionTracing) { - return "TracingMarker"; - } - } - - if (typeof type === "object") { - { - if (typeof type.tag === "number") { - error( - "Received an unexpected object in getComponentNameFromType(). " + - "This is likely a bug in React. Please file an issue." - ); - } - } - - switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: - if (enableRenderableContext) { - return null; - } else { - var provider = type; - return getContextName$1(provider._context) + ".Provider"; - } - - case REACT_CONTEXT_TYPE: - var context = type; - - if (enableRenderableContext) { - return getContextName$1(context) + ".Provider"; - } else { - return getContextName$1(context) + ".Consumer"; - } - - case REACT_CONSUMER_TYPE: - if (enableRenderableContext) { - var consumer = type; - return getContextName$1(consumer._context) + ".Consumer"; - } else { - return null; - } - - case REACT_FORWARD_REF_TYPE: - return getWrappedName$1(type, type.render, "ForwardRef"); - - case REACT_MEMO_TYPE: - var outerName = type.displayName || null; - - if (outerName !== null) { - return outerName; - } - - return getComponentNameFromType(type.type) || "Memo"; - - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - return getComponentNameFromType(init(payload)); - } catch (x) { - return null; - } - } - } - } - - return null; - } - - // $FlowFixMe[method-unbinding] - var hasOwnProperty = Object.prototype.hasOwnProperty; - - var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); - function isValidElementType(type) { - if (typeof type === "string" || typeof type === "function") { - return true; - } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). - - if ( - type === REACT_FRAGMENT_TYPE || - type === REACT_PROFILER_TYPE || - (enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) || - type === REACT_STRICT_MODE_TYPE || - type === REACT_SUSPENSE_TYPE || - type === REACT_SUSPENSE_LIST_TYPE || - type === REACT_LEGACY_HIDDEN_TYPE || - type === REACT_OFFSCREEN_TYPE || - type === REACT_SCOPE_TYPE || - (enableTransitionTracing && type === REACT_TRACING_MARKER_TYPE) - ) { - return true; - } - - if (typeof type === "object" && type !== null) { - if ( - type.$$typeof === REACT_LAZY_TYPE || - type.$$typeof === REACT_MEMO_TYPE || - type.$$typeof === REACT_CONTEXT_TYPE || - (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || - (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || - type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object - // types supported by any Flight configuration anywhere since - // we don't know which Flight build this will end up being used - // with. - type.$$typeof === REACT_CLIENT_REFERENCE$1 || - type.getModuleId !== undefined - ) { - return true; - } - } - - return false; - } - - // Helpers to patch console.logs to avoid logging during side-effect free - // replaying on render function. This currently only patches the object - // lazily which won't cover if the log function was extracted eagerly. - // We could also eagerly patch the method. - var disabledDepth = 0; - var prevLog; - var prevInfo; - var prevWarn; - var prevError; - var prevGroup; - var prevGroupCollapsed; - var prevGroupEnd; - - function disabledLog() {} - - disabledLog.__reactDisabledLog = true; - function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 - - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } - - disabledDepth++; - } - } - function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - - Object.defineProperties(console, { - log: assign({}, props, { - value: prevLog - }), - info: assign({}, props, { - value: prevInfo - }), - warn: assign({}, props, { - value: prevWarn - }), - error: assign({}, props, { - value: prevError - }), - group: assign({}, props, { - value: prevGroup - }), - groupCollapsed: assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } - - if (disabledDepth < 0) { - error( - "disabledDepth fell below zero. " + - "This is a bug in React. Please file an issue." - ); - } - } - } - - var prefix; - function describeBuiltInComponentFrame(name) { - { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - } // We use the prefix to ensure our stacks line up with native stack frames. - - return "\n" + prefix + name; - } - } - var reentry = false; - var componentFrameCache; - - { - var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap(); - } - /** - * Leverages native browser/VM stack frames to get proper details (e.g. - * filename, line + col number) for a single component in a component stack. We - * do this by: - * (1) throwing and catching an error in the function - this will be our - * control error. - * (2) calling the component which will eventually throw an error that we'll - * catch - this will be our sample error. - * (3) diffing the control and sample error stacks to find the stack frame - * which represents our component. - */ - - function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ""; - } - - { - var frame = componentFrameCache.get(fn); - - if (frame !== undefined) { - return frame; - } - } - - reentry = true; - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - - Error.prepareStackTrace = undefined; - var previousDispatcher = null; - - { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function - // for warnings. - - ReactSharedInternals.H = null; - disableLogs(); - } - /** - * Finding a common stack frame between sample and control errors can be - * tricky given the different types and levels of stack trace truncation from - * different JS VMs. So instead we'll attempt to control what that common - * frame should be through this object method: - * Having both the sample and control errors be in the function under the - * `DescribeNativeComponentFrameRoot` property, + setting the `name` and - * `displayName` properties of the function ensures that a stack - * frame exists that has the method name `DescribeNativeComponentFrameRoot` in - * it for both control and sample stacks. - */ - - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - var control; - - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - var Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] - - Object.defineProperty(Fake.prototype, "props", { - set: function () { - // We use a throwing setter instead of frozen or non-writable props - // because that won't throw in a non-strict mode function. - throw Error(); - } - }); - - if (typeof Reflect === "object" && Reflect.construct) { - // We construct a different control for this case to include any extra - // frames added by the construct call. - try { - Reflect.construct(Fake, []); - } catch (x) { - control = x; - } - - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow - - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x) { - control = x; - } // TODO(luna): This will currently only throw if the function component - // tries to access React/ReactDOM/props. We should probably make this throw - // in simple components too - - var maybePromise = fn(); // If the function component returns a promise, it's likely an async - // component, which we don't yet support. Attach a noop catch handler to - // silence the error. - // TODO: Implement component stacks for async client components? - - if (maybePromise && typeof maybePromise.catch === "function") { - maybePromise.catch(function () {}); - } - } - } catch (sample) { - // This is inlined manually because closure doesn't do it for us. - if (sample && control && typeof sample.stack === "string") { - return [sample.stack, control.stack]; - } - } - - return [null, null]; - } - }; // $FlowFixMe[prop-missing] - - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); // Before ES6, the `name` property was not configurable. - - if (namePropDescriptor && namePropDescriptor.configurable) { - // V8 utilizes a function's `name` property when generating a stack trace. - Object.defineProperty( - RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor - // is set to `false`. - // $FlowFixMe[cannot-write] - "name", - { - value: "DetermineComponentFrameRoot" - } - ); - } - - try { - var _RunInRootFrame$Deter = - RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - - if (sampleStack && controlStack) { - // This extracts the first frame from the sample that isn't also in the control. - // Skipping one frame that we assume is the frame that calls the two. - var sampleLines = sampleStack.split("\n"); - var controlLines = controlStack.split("\n"); - var s = 0; - var c = 0; - - while ( - s < sampleLines.length && - !sampleLines[s].includes("DetermineComponentFrameRoot") - ) { - s++; - } - - while ( - c < controlLines.length && - !controlLines[c].includes("DetermineComponentFrameRoot") - ) { - c++; - } // We couldn't find our intentionally injected common root frame, attempt - // to find another common root frame by search from the bottom of the - // control stack... - - if (s === sampleLines.length || c === controlLines.length) { - s = sampleLines.length - 1; - c = controlLines.length - 1; - - while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { - // We expect at least one stack frame to be shared. - // Typically this will be the root most one. However, stack frames may be - // cut off due to maximum stack limits. In this case, one maybe cut off - // earlier than the other. We assume that the sample is longer or the same - // and there for cut off earlier. So we should find the root most frame in - // the sample somewhere in the control. - c--; - } - } - - for (; s >= 1 && c >= 0; s--, c--) { - // Next we find the first one that isn't the same which should be the - // frame that called our sample function and the control. - if (sampleLines[s] !== controlLines[c]) { - // In V8, the first line is describing the message but other VMs don't. - // If we're about to return the first line, and the control is also on the same - // line, that's a pretty good indicator that our sample threw at same line as - // the control. I.e. before we entered the sample frame. So we ignore this result. - // This can happen if you passed a class to function component, or non-function. - if (s !== 1 || c !== 1) { - do { - s--; - c--; // We may still have similar intermediate frames from the construct call. - // The next one that isn't the same should be our match though. - - if (c < 0 || sampleLines[s] !== controlLines[c]) { - // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. - var _frame = - "\n" + sampleLines[s].replace(" at new ", " at "); // If our component frame is labeled "" - // but we have a user-provided "displayName" - // splice it in to make the stack more readable. - - if (fn.displayName && _frame.includes("")) { - _frame = _frame.replace("", fn.displayName); - } - - if (true) { - if (typeof fn === "function") { - componentFrameCache.set(fn, _frame); - } - } // Return the line we found. - - return _frame; - } - } while (s >= 1 && c >= 0); - } - - break; - } - } - } - } finally { - reentry = false; - - { - ReactSharedInternals.H = previousDispatcher; - reenableLogs(); - } - - Error.prepareStackTrace = previousPrepareStackTrace; - } // Fallback to just using the name if we couldn't make it throw. - - var name = fn ? fn.displayName || fn.name : ""; - var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ""; - - { - if (typeof fn === "function") { - componentFrameCache.set(fn, syntheticFrame); - } - } - - return syntheticFrame; - } - function describeFunctionComponentFrame(fn) { - { - return describeNativeComponentFrame(fn, false); - } - } - - function shouldConstruct(Component) { - var prototype = Component.prototype; - return !!(prototype && prototype.isReactComponent); - } - - function describeUnknownElementTypeFrameInDEV(type) { - if (type == null) { - return ""; - } - - if (typeof type === "function") { - { - return describeNativeComponentFrame(type, shouldConstruct(type)); - } - } - - if (typeof type === "string") { - return describeBuiltInComponentFrame(type); - } - - switch (type) { - case REACT_SUSPENSE_TYPE: - return describeBuiltInComponentFrame("Suspense"); - - case REACT_SUSPENSE_LIST_TYPE: - return describeBuiltInComponentFrame("SuspenseList"); - } - - if (typeof type === "object") { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeFunctionComponentFrame(type.render); - - case REACT_MEMO_TYPE: - // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type); - - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload)); - } catch (x) {} - } - } - } - - return ""; - } - - var FunctionComponent = 0; - var ClassComponent = 1; - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var ScopeComponent = 21; - var OffscreenComponent = 22; - var LegacyHiddenComponent = 23; - var CacheComponent = 24; - var TracingMarkerComponent = 25; - var HostHoistable = 26; - var HostSingleton = 27; - var IncompleteFunctionComponent = 28; - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - (functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName) - ); - } // Keep in sync with shared/getComponentNameFromType - - function getContextName(type) { - return type.displayName || "Context"; - } - function getComponentNameFromFiber(fiber) { - var tag = fiber.tag, - type = fiber.type; - - switch (tag) { - case CacheComponent: - return "Cache"; - - case ContextConsumer: - if (enableRenderableContext) { - var consumer = type; - return getContextName(consumer._context) + ".Consumer"; - } else { - var context = type; - return getContextName(context) + ".Consumer"; - } - - case ContextProvider: - if (enableRenderableContext) { - var _context = type; - return getContextName(_context) + ".Provider"; - } else { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } - - case DehydratedFragment: - return "DehydratedFragment"; - - case ForwardRef: - return getWrappedName(type, type.render, "ForwardRef"); - - case Fragment: - return "Fragment"; - - case HostHoistable: - case HostSingleton: - case HostComponent: - // Host component type is the display name (e.g. "div", "View") - return type; - - case HostPortal: - return "Portal"; - - case HostRoot: - return "Root"; - - case HostText: - return "Text"; - - case LazyComponent: - // Name comes from the type in this case; we don't have a tag. - return getComponentNameFromType(type); - - case Mode: - if (type === REACT_STRICT_MODE_TYPE) { - // Don't be less specific than shared/getComponentNameFromType - return "StrictMode"; - } - - return "Mode"; - - case OffscreenComponent: - return "Offscreen"; - - case Profiler: - return "Profiler"; - - case ScopeComponent: - return "Scope"; - - case SuspenseComponent: - return "Suspense"; - - case SuspenseListComponent: - return "SuspenseList"; - - case TracingMarkerComponent: - return "TracingMarker"; - // The display name for these tags come from the user-provided type: - - case IncompleteClassComponent: - case IncompleteFunctionComponent: { - break; - } - - // Fallthrough - - case ClassComponent: - case FunctionComponent: - case MemoComponent: - case SimpleMemoComponent: - if (typeof type === "function") { - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - break; - - case LegacyHiddenComponent: { - return "LegacyHidden"; - } - } - - return null; - } - - var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); - var specialPropKeyWarningShown; - var specialPropRefWarningShown; - var didWarnAboutStringRefs; - var didWarnAboutElementRef; - var didWarnAboutOldJSXRuntime; - - { - didWarnAboutStringRefs = {}; - didWarnAboutElementRef = {}; - } - - function hasValidRef(config) { - { - if (hasOwnProperty.call(config, "ref")) { - var getter = Object.getOwnPropertyDescriptor(config, "ref").get; - - if (getter && getter.isReactWarning) { - return false; - } - } - } - - return config.ref !== undefined; - } - - function hasValidKey(config) { - { - if (hasOwnProperty.call(config, "key")) { - var getter = Object.getOwnPropertyDescriptor(config, "key").get; - - if (getter && getter.isReactWarning) { - return false; - } - } - } - - return config.key !== undefined; - } - - function warnIfStringRefCannotBeAutoConverted(config, self) { - { - if ( - typeof config.ref === "string" && - ReactSharedInternals.owner && - self && - ReactSharedInternals.owner.stateNode !== self - ) { - var componentName = getComponentNameFromType( - ReactSharedInternals.owner.type - ); - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". ' + - "Support for string refs will be removed in a future major release. " + - "This case cannot be automatically converted to an arrow function. " + - "We ask you to manually fix this case by using useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - getComponentNameFromType(ReactSharedInternals.owner.type), - config.ref - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - } - - function defineKeyPropWarningGetter(props, displayName) { - { - var warnAboutAccessingKey = function () { - if (!specialPropKeyWarningShown) { - specialPropKeyWarningShown = true; - - error( - "%s: `key` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://react.dev/link/special-props)", - displayName - ); - } - }; - - warnAboutAccessingKey.isReactWarning = true; - Object.defineProperty(props, "key", { - get: warnAboutAccessingKey, - configurable: true - }); - } - } - - function defineRefPropWarningGetter(props, displayName) { - if (!enableRefAsProp) { - { - var warnAboutAccessingRef = function () { - if (!specialPropRefWarningShown) { - specialPropRefWarningShown = true; - - error( - "%s: `ref` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://react.dev/link/special-props)", - displayName - ); - } - }; - - warnAboutAccessingRef.isReactWarning = true; - Object.defineProperty(props, "ref", { - get: warnAboutAccessingRef, - configurable: true - }); - } - } - } - - function elementRefGetterWithDeprecationWarning() { - { - var componentName = getComponentNameFromType(this.type); - - if (!didWarnAboutElementRef[componentName]) { - didWarnAboutElementRef[componentName] = true; - - error( - "Accessing element.ref was removed in React 19. ref is now a " + - "regular prop. It will be removed from the JSX Element " + - "type in a future release." - ); - } // An undefined `element.ref` is coerced to `null` for - // backwards compatibility. - - var refProp = this.props.ref; - return refProp !== undefined ? refProp : null; - } - } - /** - * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, instanceof check - * will not work. Instead test $$typeof field against Symbol.for('react.element') to check - * if something is a React Element. - * - * @param {*} type - * @param {*} props - * @param {*} key - * @param {string|object} ref - * @param {*} owner - * @param {*} self A *temporary* helper to detect places where `this` is - * different from the `owner` when React.createElement is called, so that we - * can warn. We want to get rid of owner and replace string `ref`s with arrow - * functions, and as long as `this` and owner are the same, there will be no - * change in behavior. - * @param {*} source An annotation object (added by a transpiler or otherwise) - * indicating filename, line number, and/or other information. - * @internal - */ - - function ReactElement(type, key, _ref, self, source, owner, props) { - var ref; - - if (enableRefAsProp) { - // When enableRefAsProp is on, ignore whatever was passed as the ref - // argument and treat `props.ref` as the source of truth. The only thing we - // use this for is `element.ref`, which will log a deprecation warning on - // access. In the next release, we can remove `element.ref` as well as the - // `ref` argument. - var refProp = props.ref; // An undefined `element.ref` is coerced to `null` for - // backwards compatibility. - - ref = refProp !== undefined ? refProp : null; - } else { - ref = _ref; - } - - var element; - - if (enableRefAsProp) { - // In dev, make `ref` a non-enumerable property with a warning. It's non- - // enumerable so that test matchers and serializers don't access it and - // trigger the warning. - // - // `ref` will be removed from the element completely in a future release. - element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element - type: type, - key: key, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - - if (ref !== null) { - Object.defineProperty(element, "ref", { - enumerable: false, - get: elementRefGetterWithDeprecationWarning - }); - } else { - // Don't warn on access if a ref is not given. This reduces false - // positives in cases where a test serializer uses - // getOwnPropertyDescriptors to compare objects, like Jest does, which is - // a problem because it bypasses non-enumerability. - // - // So unfortunately this will trigger a false positive warning in Jest - // when the diff is printed: - // - // expect(
).toEqual(); - // - // A bit sketchy, but this is what we've done for the `props.key` and - // `props.ref` accessors for years, which implies it will be good enough - // for `element.ref`, too. Let's see if anyone complains. - Object.defineProperty(element, "ref", { - enumerable: false, - value: null - }); - } - } else { - // In prod, `ref` is a regular property. It will be removed in a - // future release. - element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element - type: type, - key: key, - ref: ref, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - } - - { - // The validation flag is currently mutative. We put it on - // an external backing store so that we can freeze the whole object. - // This can be replaced with a WeakMap once they are implemented in - // commonly used development environments. - element._store = {}; // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - - Object.defineProperty(element._store, "validated", { - configurable: false, - enumerable: false, - writable: true, - value: false - }); // debugInfo contains Server Component debug information. - - Object.defineProperty(element, "_debugInfo", { - configurable: false, - enumerable: false, - writable: true, - value: null - }); - - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); - } - } - - return element; - } - // support `jsx` and `jsxs` when running in development. This supports the case - // where a third-party dependency ships code that was compiled for production; - // we want to still provide warnings in development. - // - // So these functions are the _dev_ implementations of the _production_ - // API signatures. - // - // Since these functions are dev-only, it's ok to add an indirection here. They - // only exist to provide different versions of `isStaticChildren`. (We shouldn't - // use this pattern for the prod versions, though, because it will add an call - // frame.) - - function jsxProdSignatureRunningInDevWithDynamicChildren( - type, - config, - maybeKey, - source, - self - ) { - { - var isStaticChildren = false; - return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); - } - } - function jsxProdSignatureRunningInDevWithStaticChildren( - type, - config, - maybeKey, - source, - self - ) { - { - var isStaticChildren = true; - return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); - } - } - var didWarnAboutKeySpread = {}; - /** - * https://github.com/reactjs/rfcs/pull/107 - * @param {*} type - * @param {object} props - * @param {string} key - */ - - function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { - { - if (!isValidElementType(type)) { - // This is an invalid element type. - // - // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. - var info = ""; - - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and named imports."; - } - - var typeString; - - if (type === null) { - typeString = "null"; - } else if (isArray(type)) { - typeString = "array"; - } else if ( - type !== undefined && - type.$$typeof === REACT_ELEMENT_TYPE - ) { - typeString = - "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; - info = - " Did you accidentally export a JSX literal instead of a component?"; - } else { - typeString = typeof type; - } - - error( - "React.jsx: type is invalid -- expected a string (for " + - "built-in components) or a class/function (for composite " + - "components) but got: %s.%s", - typeString, - info - ); - } else { - // This is a valid element type. - // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing - // errors. We don't want exception behavior to differ between dev and - // prod. (Rendering will throw with a helpful message and as soon as the - // type is fixed, the key warnings will appear.) - var children = config.children; - - if (children !== undefined) { - if (isStaticChildren) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - validateChildKeys(children[i], type); - } - - if (Object.freeze) { - Object.freeze(children); - } - } else { - error( - "React.jsx: Static children should always be an array. " + - "You are likely explicitly calling React.jsxs or React.jsxDEV. " + - "Use the Babel transform instead." - ); - } - } else { - validateChildKeys(children, type); - } - } - } // Warn about key spread regardless of whether the type is valid. - - if (hasOwnProperty.call(config, "key")) { - var componentName = getComponentNameFromType(type); - var keys = Object.keys(config).filter(function (k) { - return k !== "key"; - }); - var beforeExample = - keys.length > 0 - ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" - : "{key: someKey}"; - - if (!didWarnAboutKeySpread[componentName + beforeExample]) { - var afterExample = - keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}"; - - error( - 'A props object containing a "key" prop is being spread into JSX:\n' + - " let props = %s;\n" + - " <%s {...props} />\n" + - "React keys must be passed directly to JSX without using spread:\n" + - " let props = %s;\n" + - " <%s key={someKey} {...props} />", - beforeExample, - componentName, - afterExample, - componentName - ); - - didWarnAboutKeySpread[componentName + beforeExample] = true; - } - } - - var key = null; - var ref = null; // Currently, key can be spread in as a prop. This causes a potential - // issue if key is also explicitly declared (ie.
- // or
). We want to deprecate key spread, - // but as an intermediary step, we will use jsxDEV for everything except - //
, because we aren't currently able to tell if - // key is explicitly declared to be undefined or not. - - if (maybeKey !== undefined) { - { - checkKeyStringCoercion(maybeKey); - } - - key = "" + maybeKey; - } - - if (hasValidKey(config)) { - { - checkKeyStringCoercion(config.key); - } - - key = "" + config.key; - } - - if (hasValidRef(config)) { - if (!enableRefAsProp) { - ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } - } - - { - warnIfStringRefCannotBeAutoConverted(config, self); - } - } - - var props; - - if (enableRefAsProp && disableStringRefs && !("key" in config)) { - // If key was not spread in, we can reuse the original props object. This - // only works for `jsx`, not `createElement`, because `jsx` is a compiler - // target and the compiler always passes a new object. For `createElement`, - // we can't assume a new object is passed every time because it can be - // called manually. - // - // Spreading key is a warning in dev. In a future release, we will not - // remove a spread key from the props object. (But we'll still warn.) We'll - // always pass the object straight through. - props = config; - } else { - // We need to remove reserved props (key, prop, ref). Create a fresh props - // object and copy over all the non-reserved props. We don't use `delete` - // because in V8 it will deopt the object to dictionary mode. - props = {}; - - for (var propName in config) { - // Skip over reserved prop names - if (propName !== "key" && (enableRefAsProp || propName !== "ref")) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } - } - } - - if (!disableDefaultPropsExceptForClasses) { - // Resolve default props - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; - - for (var _propName2 in defaultProps) { - if (props[_propName2] === undefined) { - props[_propName2] = defaultProps[_propName2]; - } - } - } - } - - if (key || (!enableRefAsProp && ref)) { - var displayName = - typeof type === "function" - ? type.displayName || type.name || "Unknown" - : type; - - if (key) { - defineKeyPropWarningGetter(props, displayName); - } - - if (!enableRefAsProp && ref) { - defineRefPropWarningGetter(props, displayName); - } - } - - var element = ReactElement( - type, - key, - ref, - self, - source, - ReactSharedInternals.owner, - props - ); - - if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps(element); - } - - return element; - } - } - /** - * Create and return a new ReactElement of the given type. - * See https://reactjs.org/docs/react-api.html#createelement - */ - - function createElement(type, config, children) { - { - if (!isValidElementType(type)) { - // This is an invalid element type. - // - // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. - var info = ""; - - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and named imports."; - } - - var typeString; - - if (type === null) { - typeString = "null"; - } else if (isArray(type)) { - typeString = "array"; - } else if ( - type !== undefined && - type.$$typeof === REACT_ELEMENT_TYPE - ) { - typeString = - "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; - info = - " Did you accidentally export a JSX literal instead of a component?"; - } else { - typeString = typeof type; - } - - error( - "React.createElement: type is invalid -- expected a string (for " + - "built-in components) or a class/function (for composite " + - "components) but got: %s.%s", - typeString, - info - ); - } else { - // This is a valid element type. - // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing - // errors. We don't want exception behavior to differ between dev and - // prod. (Rendering will throw with a helpful message and as soon as the - // type is fixed, the key warnings will appear.) - for (var i = 2; i < arguments.length; i++) { - validateChildKeys(arguments[i], type); - } - } // Unlike the jsx() runtime, createElement() doesn't warn about key spread. - } - - var propName; // Reserved names are extracted - - var props = {}; - var key = null; - var ref = null; - - if (config != null) { - { - if ( - !didWarnAboutOldJSXRuntime && - "__self" in config && // Do not assume this is the result of an oudated JSX transform if key - // is present, because the modern JSX transform sometimes outputs - // createElement to preserve precedence between a static key and a - // spread key. To avoid false positive warnings, we never warn if - // there's a key. - !("key" in config) - ) { - didWarnAboutOldJSXRuntime = true; - - warn( - "Your app (or one of its dependencies) is using an outdated JSX " + - "transform. Update to the modern JSX transform for " + - "faster performance: " + // TODO: Create a short link for this - "https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html" - ); - } - } - - if (hasValidRef(config)) { - if (!enableRefAsProp) { - ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } - } - - { - warnIfStringRefCannotBeAutoConverted(config, config.__self); - } - } - - if (hasValidKey(config)) { - { - checkKeyStringCoercion(config.key); - } - - key = "" + config.key; - } // Remaining properties are added to a new props object - - for (propName in config) { - if ( - hasOwnProperty.call(config, propName) && // Skip over reserved prop names - propName !== "key" && - (enableRefAsProp || propName !== "ref") && // Even though we don't use these anymore in the runtime, we don't want - // them to appear as props, so in createElement we filter them out. - // We don't have to do this in the jsx() runtime because the jsx() - // transform never passed these as props; it used separate arguments. - propName !== "__self" && - propName !== "__source" - ) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } - } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - - var childrenLength = arguments.length - 2; - - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - - for (var _i = 0; _i < childrenLength; _i++) { - childArray[_i] = arguments[_i + 2]; - } - - { - if (Object.freeze) { - Object.freeze(childArray); - } - } - - props.children = childArray; - } // Resolve default props - - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; - - for (propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } - } - } - - { - if (key || (!enableRefAsProp && ref)) { - var displayName = - typeof type === "function" - ? type.displayName || type.name || "Unknown" - : type; - - if (key) { - defineKeyPropWarningGetter(props, displayName); - } - - if (!enableRefAsProp && ref) { - defineRefPropWarningGetter(props, displayName); - } - } - } - - var element = ReactElement( - type, - key, - ref, - undefined, - undefined, - ReactSharedInternals.owner, - props - ); - - if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps(element); - } - - return element; - } - function cloneAndReplaceKey(oldElement, newKey) { - return ReactElement( - oldElement.type, - newKey, // When enableRefAsProp is on, this argument is ignored. This check only - // exists to avoid the `ref` access warning. - enableRefAsProp ? null : oldElement.ref, - undefined, - undefined, - oldElement._owner, - oldElement.props - ); - } - /** - * Clone and return a new ReactElement using element as the starting point. - * See https://reactjs.org/docs/react-api.html#cloneelement - */ - - function cloneElement(element, config, children) { - if (element === null || element === undefined) { - throw new Error( - "The argument must be a React element, but you passed " + - element + - "." - ); - } - - var propName; // Original props are copied - - var props = assign({}, element.props); // Reserved names are extracted - - var key = element.key; - var ref = enableRefAsProp ? null : element.ref; // Owner will be preserved, unless ref is overridden - - var owner = element._owner; - - if (config != null) { - if (hasValidRef(config)) { - owner = ReactSharedInternals.owner; - - if (!enableRefAsProp) { - // Silently steal the ref from the parent. - ref = config.ref; - - { - ref = coerceStringRef(ref, owner, element.type); - } - } - } - - if (hasValidKey(config)) { - { - checkKeyStringCoercion(config.key); - } - - key = "" + config.key; - } // Remaining properties override existing props - - var defaultProps; - - if ( - !disableDefaultPropsExceptForClasses && - element.type && - element.type.defaultProps - ) { - defaultProps = element.type.defaultProps; - } - - for (propName in config) { - if ( - hasOwnProperty.call(config, propName) && // Skip over reserved prop names - propName !== "key" && - (enableRefAsProp || propName !== "ref") && // ...and maybe these, too, though we currently rely on them for - // warnings and debug information in dev. Need to decide if we're OK - // with dropping them. In the jsx() runtime it's not an issue because - // the data gets passed as separate arguments instead of props, but - // it would be nice to stop relying on them entirely so we can drop - // them from the internal Fiber field. - propName !== "__self" && - propName !== "__source" && // Undefined `ref` is ignored by cloneElement. We treat it the same as - // if the property were missing. This is mostly for - // backwards compatibility. - !(enableRefAsProp && propName === "ref" && config.ref === undefined) - ) { - if ( - !disableDefaultPropsExceptForClasses && - config[propName] === undefined && - defaultProps !== undefined - ) { - // Resolve default props - props[propName] = defaultProps[propName]; - } else { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - owner, - element.type - ); - } else { - props[propName] = config[propName]; - } - } - } - } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - - var childrenLength = arguments.length - 2; - - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; - } - - props.children = childArray; - } - - var clonedElement = ReactElement( - element.type, - key, - ref, - undefined, - undefined, - owner, - props - ); - - for (var _i2 = 2; _i2 < arguments.length; _i2++) { - validateChildKeys(arguments[_i2], clonedElement.type); - } - - return clonedElement; - } - - function getDeclarationErrorAddendum() { - { - if (ReactSharedInternals.owner) { - var name = getComponentNameFromType(ReactSharedInternals.owner.type); - - if (name) { - return "\n\nCheck the render method of `" + name + "`."; - } - } - - return ""; - } - } - /** - * Ensure that every element either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {ReactNode} node Statically passed child of any type. - * @param {*} parentType node's parent's type. - */ - - function validateChildKeys(node, parentType) { - { - if (typeof node !== "object" || !node) { - return; - } - - if (node.$$typeof === REACT_CLIENT_REFERENCE); - else if (isArray(node)) { - for (var i = 0; i < node.length; i++) { - var child = node[i]; - - if (isValidElement(child)) { - validateExplicitKey(child, parentType); - } - } - } else if (isValidElement(node)) { - // This element was passed in a valid location. - if (node._store) { - node._store.validated = true; - } - } else { - var iteratorFn = getIteratorFn(node); - - if (typeof iteratorFn === "function") { - // Entry iterators used to provide implicit keys, - // but now we print a separate warning for them later. - if (iteratorFn !== node.entries) { - var iterator = iteratorFn.call(node); - var step; - - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); - } - } - } - } - } - } - } - /** - * Verifies the object is a ReactElement. - * See https://reactjs.org/docs/react-api.html#isvalidelement - * @param {?object} object - * @return {boolean} True if `object` is a ReactElement. - * @final - */ - - function isValidElement(object) { - return ( - typeof object === "object" && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE - ); - } - var ownerHasKeyUseWarning = {}; - /** - * Warn if the element doesn't have an explicit key assigned to it. - * This element is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. Error statuses are cached so a warning - * will only be shown once. - * - * @internal - * @param {ReactElement} element Element that requires a key. - * @param {*} parentType element's parent's type. - */ - - function validateExplicitKey(element, parentType) { - { - if ( - !element._store || - element._store.validated || - element.key != null - ) { - return; - } - - element._store.validated = true; - var currentComponentErrorInfo = - getCurrentComponentErrorInfo(parentType); - - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { - return; - } - - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a - // property, it may be the creator of the child that's responsible for - // assigning it a key. - - var childOwner = ""; - - if ( - element && - element._owner != null && - element._owner !== ReactSharedInternals.owner - ) { - var ownerName = null; - - if (typeof element._owner.tag === "number") { - ownerName = getComponentNameFromType(element._owner.type); - } else if (typeof element._owner.name === "string") { - ownerName = element._owner.name; - } // Give the component that originally created this child. - - childOwner = " It was passed a child from " + ownerName + "."; - } - - setCurrentlyValidatingElement(element); - - error( - 'Each child in a list should have a unique "key" prop.' + - "%s%s See https://react.dev/link/warning-keys for more information.", - currentComponentErrorInfo, - childOwner - ); - - setCurrentlyValidatingElement(null); - } - } - - function setCurrentlyValidatingElement(element) { - { - if (element) { - var stack = describeUnknownElementTypeFrameInDEV(element.type); - ReactSharedInternals.setExtraStackFrame(stack); - } else { - ReactSharedInternals.setExtraStackFrame(null); - } - } - } - - function getCurrentComponentErrorInfo(parentType) { - { - var info = getDeclarationErrorAddendum(); - - if (!info) { - var parentName = getComponentNameFromType(parentType); - - if (parentName) { - info = - "\n\nCheck the top-level render call using <" + parentName + ">."; - } - } - - return info; - } - } - /** - * Given a fragment, validate that it can only be provided with fragment props - * @param {ReactElement} fragment - */ - - function validateFragmentProps(fragment) { - // TODO: Move this to render phase instead of at element creation. - { - var keys = Object.keys(fragment.props); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - - if (key !== "children" && key !== "key") { - setCurrentlyValidatingElement(fragment); - - error( - "Invalid prop `%s` supplied to `React.Fragment`. " + - "React.Fragment can only have `key` and `children` props.", - key - ); - - setCurrentlyValidatingElement(null); - break; - } - } - - if (!enableRefAsProp && fragment.ref !== null) { - setCurrentlyValidatingElement(fragment); - - error("Invalid attribute `ref` supplied to `React.Fragment`."); - - setCurrentlyValidatingElement(null); - } - } - } - - function coerceStringRef(mixedRef, owner, type) { - var stringRef; - - if (typeof mixedRef === "string") { - stringRef = mixedRef; - } else { - if (typeof mixedRef === "number" || typeof mixedRef === "boolean") { - { - checkPropStringCoercion(mixedRef, "ref"); - } - - stringRef = "" + mixedRef; - } else { - return mixedRef; - } - } - - var callback = stringRefAsCallbackRef.bind(null, stringRef, type, owner); // This is used to check whether two callback refs conceptually represent - // the same string ref, and can therefore be reused by the reconciler. Needed - // for backwards compatibility with old Meta code that relies on string refs - // not being reattached on every render. - - callback.__stringRef = stringRef; - callback.__type = type; - callback.__owner = owner; - return callback; - } - - function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) { - throw new Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://react.dev/link/refs-must-have-owner for more information." - ); - } - - if (owner.tag !== ClassComponent) { - throw new Error( - "Function components cannot have string refs. " + - "We recommend using useRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref" - ); - } - - { - if ( - // Will already warn with "Function components cannot be given refs" - !(typeof type === "function" && !isReactClass(type)) - ) { - var componentName = getComponentNameFromFiber(owner) || "Component"; - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". Support for string refs ' + - "will be removed in a future major release. We recommend using " + - "useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - componentName, - stringRef - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - - var inst = owner.stateNode; - - if (!inst) { - throw new Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a " + - "bug in React. Please file an issue." - ); - } - - var refs = inst.refs; - - if (value === null) { - delete refs[stringRef]; - } else { - refs[stringRef] = value; - } - } - - function isReactClass(type) { - return type.prototype && type.prototype.isReactComponent; - } - - var SEPARATOR = "."; - var SUBSEPARATOR = ":"; - /** - * Escape and wrap key so it is safe to use as a reactid - * - * @param {string} key to be escaped. - * @return {string} the escaped key. - */ - - function escape(key) { - var escapeRegex = /[=:]/g; - var escaperLookup = { - "=": "=0", - ":": "=2" - }; - var escapedString = key.replace(escapeRegex, function (match) { - return escaperLookup[match]; - }); - return "$" + escapedString; - } - /** - * TODO: Test that a single child and an array with one item have the same key - * pattern. - */ - - var didWarnAboutMaps = false; - var userProvidedKeyEscapeRegex = /\/+/g; - - function escapeUserProvidedKey(text) { - return text.replace(userProvidedKeyEscapeRegex, "$&/"); - } - /** - * Generate a key string that identifies a element within a set. - * - * @param {*} element A element that could contain a manual key. - * @param {number} index Index that is used if a manual key is not provided. - * @return {string} - */ - - function getElementKey(element, index) { - // Do some typechecking here since we call this blindly. We want to ensure - // that we don't block potential future ES APIs. - if ( - typeof element === "object" && - element !== null && - element.key != null - ) { - // Explicit key - { - checkKeyStringCoercion(element.key); - } - - return escape("" + element.key); - } // Implicit key determined by the index in the set - - return index.toString(36); - } - - function noop$1() {} - - function resolveThenable(thenable) { - switch (thenable.status) { - case "fulfilled": { - var fulfilledValue = thenable.value; - return fulfilledValue; - } - - case "rejected": { - var rejectedError = thenable.reason; - throw rejectedError; - } - - default: { - if (typeof thenable.status === "string") { - // Only instrument the thenable if the status if not defined. If - // it's defined, but an unknown value, assume it's been instrumented by - // some custom userspace implementation. We treat it as "pending". - // Attach a dummy listener, to ensure that any lazy initialization can - // happen. Flight lazily parses JSON when the value is actually awaited. - thenable.then(noop$1, noop$1); - } else { - // This is an uncached thenable that we haven't seen before. - // TODO: Detect infinite ping loops caused by uncached promises. - var pendingThenable = thenable; - pendingThenable.status = "pending"; - pendingThenable.then( - function (fulfilledValue) { - if (thenable.status === "pending") { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if (thenable.status === "pending") { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - ); - } // Check one more time in case the thenable resolved synchronously. - - switch (thenable.status) { - case "fulfilled": { - var fulfilledThenable = thenable; - return fulfilledThenable.value; - } - - case "rejected": { - var rejectedThenable = thenable; - var _rejectedError = rejectedThenable.reason; - throw _rejectedError; - } - } - } - } - - throw thenable; - } - - function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { - var type = typeof children; - - if (type === "undefined" || type === "boolean") { - // All of the above are perceived as null. - children = null; - } - - var invokeCallback = false; - - if (children === null) { - invokeCallback = true; - } else { - switch (type) { - case "bigint": - case "string": - case "number": - invokeCallback = true; - break; - - case "object": - switch (children.$$typeof) { - case REACT_ELEMENT_TYPE: - case REACT_PORTAL_TYPE: - invokeCallback = true; - break; - - case REACT_LAZY_TYPE: - var payload = children._payload; - var init = children._init; - return mapIntoArray( - init(payload), - array, - escapedPrefix, - nameSoFar, - callback - ); - } - } - } - - if (invokeCallback) { - var _child = children; - var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array - // so that it's consistent if the number of children grows: - - var childKey = - nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; - - if (isArray(mappedChild)) { - var escapedChildKey = ""; - - if (childKey != null) { - escapedChildKey = escapeUserProvidedKey(childKey) + "/"; - } - - mapIntoArray(mappedChild, array, escapedChildKey, "", function (c) { - return c; - }); - } else if (mappedChild != null) { - if (isValidElement(mappedChild)) { - { - // The `if` statement here prevents auto-disabling of the safe - // coercion ESLint rule, so we must manually disable it below. - // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key - if ( - mappedChild.key && - (!_child || _child.key !== mappedChild.key) - ) { - checkKeyStringCoercion(mappedChild.key); - } - } - - mappedChild = cloneAndReplaceKey( - mappedChild, // Keep both the (mapped) and old keys if they differ, just as - // traverseAllChildren used to do for objects as children - escapedPrefix + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key - (mappedChild.key && (!_child || _child.key !== mappedChild.key) - ? escapeUserProvidedKey( - // $FlowFixMe[unsafe-addition] - "" + mappedChild.key // eslint-disable-line react-internal/safe-string-coercion - ) + "/" - : "") + - childKey - ); - } - - array.push(mappedChild); - } - - return 1; - } - - var child; - var nextName; - var subtreeCount = 0; // Count of children found in the current subtree. - - var nextNamePrefix = - nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR; - - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - child = children[i]; - nextName = nextNamePrefix + getElementKey(child, i); - subtreeCount += mapIntoArray( - child, - array, - escapedPrefix, - nextName, - callback - ); - } - } else { - var iteratorFn = getIteratorFn(children); - - if (typeof iteratorFn === "function") { - var iterableChildren = children; - - { - // Warn about using Maps as children - if (iteratorFn === iterableChildren.entries) { - if (!didWarnAboutMaps) { - warn( - "Using Maps as children is not supported. " + - "Use an array of keyed ReactElements instead." - ); - } - - didWarnAboutMaps = true; - } - } - - var iterator = iteratorFn.call(iterableChildren); - var step; - var ii = 0; // $FlowFixMe[incompatible-use] `iteratorFn` might return null according to typing. - - while (!(step = iterator.next()).done) { - child = step.value; - nextName = nextNamePrefix + getElementKey(child, ii++); - subtreeCount += mapIntoArray( - child, - array, - escapedPrefix, - nextName, - callback - ); - } - } else if (type === "object") { - if (typeof children.then === "function") { - return mapIntoArray( - resolveThenable(children), - array, - escapedPrefix, - nameSoFar, - callback - ); - } // eslint-disable-next-line react-internal/safe-string-coercion - - var childrenString = String(children); - throw new Error( - "Objects are not valid as a React child (found: " + - (childrenString === "[object Object]" - ? "object with keys {" + Object.keys(children).join(", ") + "}" - : childrenString) + - "). " + - "If you meant to render a collection of children, use an array " + - "instead." - ); - } - } - - return subtreeCount; - } - /** - * Maps children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenmap - * - * The provided mapFunction(child, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} func The map function. - * @param {*} context Context for mapFunction. - * @return {object} Object containing the ordered map of results. - */ - - function mapChildren(children, func, context) { - if (children == null) { - // $FlowFixMe limitation refining abstract types in Flow - return children; - } - - var result = []; - var count = 0; - mapIntoArray(children, result, "", "", function (child) { - return func.call(context, child, count++); - }); - return result; - } - /** - * Count the number of children that are typically specified as - * `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrencount - * - * @param {?*} children Children tree container. - * @return {number} The number of children. - */ - - function countChildren(children) { - var n = 0; - mapChildren(children, function () { - n++; // Don't return anything - }); - return n; - } - /** - * Iterates through children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenforeach - * - * The provided forEachFunc(child, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} forEachFunc - * @param {*} forEachContext Context for forEachContext. - */ - - function forEachChildren(children, forEachFunc, forEachContext) { - mapChildren( - children, // $FlowFixMe[missing-this-annot] - function () { - forEachFunc.apply(this, arguments); // Don't return anything. - }, - forEachContext - ); - } - /** - * Flatten a children object (typically specified as `props.children`) and - * return an array with appropriately re-keyed children. - * - * See https://reactjs.org/docs/react-api.html#reactchildrentoarray - */ - - function toArray(children) { - return ( - mapChildren(children, function (child) { - return child; - }) || [] - ); - } - /** - * Returns the first child in a collection of children and verifies that there - * is only one child in the collection. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenonly - * - * The current implementation of this function assumes that a single child gets - * passed without a wrapper, but the purpose of this helper function is to - * abstract away the particular structure of children. - * - * @param {?object} children Child collection structure. - * @return {ReactElement} The first and only `ReactElement` contained in the - * structure. - */ - - function onlyChild(children) { - if (!isValidElement(children)) { - throw new Error( - "React.Children.only expected to receive a single React element child." - ); - } - - return children; - } - - // an immutable object with a single mutable value - function createRef() { - var refObject = { - current: null - }; - - { - Object.seal(refObject); - } - - return refObject; - } - - function resolveDispatcher() { - var dispatcher = ReactSharedInternals.H; - - { - if (dispatcher === null) { - error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" + - " one of the following reasons:\n" + - "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" + - "2. You might be breaking the Rules of Hooks\n" + - "3. You might have more than one copy of React in the same app\n" + - "See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem." - ); - } - } // Will result in a null access error if accessed outside render phase. We - // intentionally don't throw our own error because this is in a hot path. - // Also helps ensure this is inlined. - - return dispatcher; - } - function useCallback(callback, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useCallback(callback, deps); - } - function useMemo(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useMemo(create, deps); - } - function useDebugValue(value, formatterFn) { - { - var dispatcher = resolveDispatcher(); - return dispatcher.useDebugValue(value, formatterFn); - } - } - function useId() { - var dispatcher = resolveDispatcher(); - return dispatcher.useId(); - } - function use(usable) { - var dispatcher = resolveDispatcher(); - return dispatcher.use(usable); - } - function useActionState(action, initialState, permalink) { - { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useActionState(action, initialState, permalink); - } - } - - function forwardRef(render) { - { - if (render != null && render.$$typeof === REACT_MEMO_TYPE) { - error( - "forwardRef requires a render function but received a `memo` " + - "component. Instead of forwardRef(memo(...)), use " + - "memo(forwardRef(...))." - ); - } else if (typeof render !== "function") { - error( - "forwardRef requires a render function but was given %s.", - render === null ? "null" : typeof render - ); - } else { - if (render.length !== 0 && render.length !== 2) { - error( - "forwardRef render functions accept exactly two parameters: props and ref. %s", - render.length === 1 - ? "Did you forget to use the ref parameter?" - : "Any additional parameter will be undefined." - ); - } - } - - if (render != null) { - if (render.defaultProps != null) { - error( - "forwardRef render functions do not support defaultProps. " + - "Did you accidentally pass a React component?" - ); - } - } - } - - var elementType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: render - }; - - { - var ownName; - Object.defineProperty(elementType, "displayName", { - enumerable: false, - configurable: true, - get: function () { - return ownName; - }, - set: function (name) { - ownName = name; // The inner component shouldn't inherit this display name in most cases, - // because the component may be used elsewhere. - // But it's nice for anonymous functions to inherit the name, - // so that our component-stack generation logic will display their frames. - // An anonymous function generally suggests a pattern like: - // React.forwardRef((props, ref) => {...}); - // This kind of inner function is not used elsewhere so the side effect is okay. - - if (!render.name && !render.displayName) { - render.displayName = name; - } - } - }); - } - - return elementType; - } - - var Uninitialized = -1; - var Pending = 0; - var Resolved = 1; - var Rejected = 2; - - function lazyInitializer(payload) { - if (payload._status === Uninitialized) { - var ctor = payload._result; - var thenable = ctor(); // Transition to the next state. - // This might throw either because it's missing or throws. If so, we treat it - // as still uninitialized and try again next time. Which is the same as what - // happens if the ctor or any wrappers processing the ctor throws. This might - // end up fixing it if the resolution was a concurrency bug. - - thenable.then( - function (moduleObject) { - if ( - payload._status === Pending || - payload._status === Uninitialized - ) { - // Transition to the next state. - var resolved = payload; - resolved._status = Resolved; - resolved._result = moduleObject; - } - }, - function (error) { - if ( - payload._status === Pending || - payload._status === Uninitialized - ) { - // Transition to the next state. - var rejected = payload; - rejected._status = Rejected; - rejected._result = error; - } - } - ); - - if (payload._status === Uninitialized) { - // In case, we're still uninitialized, then we're waiting for the thenable - // to resolve. Set it as pending in the meantime. - var pending = payload; - pending._status = Pending; - pending._result = thenable; - } - } - - if (payload._status === Resolved) { - var moduleObject = payload._result; - - { - if (moduleObject === undefined) { - error( - "lazy: Expected the result of a dynamic imp" + - "ort() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))\n\n" + - "Did you accidentally put curly braces around the import?", - moduleObject - ); - } - } - - { - if (!("default" in moduleObject)) { - error( - "lazy: Expected the result of a dynamic imp" + - "ort() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))", - moduleObject - ); - } - } - - return moduleObject.default; - } else { - throw payload._result; - } - } - - function lazy(ctor) { - var payload = { - // We use these fields to store the result. - _status: Uninitialized, - _result: ctor - }; - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _payload: payload, - _init: lazyInitializer - }; - - if (!disableDefaultPropsExceptForClasses) { - { - // In production, this would just set it on the object. - var defaultProps; // $FlowFixMe[prop-missing] - - Object.defineProperties(lazyType, { - defaultProps: { - configurable: true, - get: function () { - return defaultProps; - }, - // $FlowFixMe[missing-local-annot] - set: function (newDefaultProps) { - error( - "It is not supported to assign `defaultProps` to " + - "a lazy component import. Either specify them where the component " + - "is defined, or create a wrapping component around it." - ); - - defaultProps = newDefaultProps; // Match production behavior more closely: - // $FlowFixMe[prop-missing] - - Object.defineProperty(lazyType, "defaultProps", { - enumerable: true - }); - } - } - }); - } - } - - return lazyType; - } - - function memo(type, compare) { - { - if (!isValidElementType(type)) { - error( - "memo: The first argument must be a component. Instead " + - "received: %s", - type === null ? "null" : typeof type - ); - } - } - - var elementType = { - $$typeof: REACT_MEMO_TYPE, - type: type, - compare: compare === undefined ? null : compare - }; - - { - var ownName; - Object.defineProperty(elementType, "displayName", { - enumerable: false, - configurable: true, - get: function () { - return ownName; - }, - set: function (name) { - ownName = name; // The inner component shouldn't inherit this display name in most cases, - // because the component may be used elsewhere. - // But it's nice for anonymous functions to inherit the name, - // so that our component-stack generation logic will display their frames. - // An anonymous function generally suggests a pattern like: - // React.memo((props) => {...}); - // This kind of inner function is not used elsewhere so the side effect is okay. - - if (!type.name && !type.displayName) { - type.displayName = name; - } - } - }); - } - - return elementType; - } - - var UNTERMINATED = 0; - var TERMINATED = 1; - var ERRORED = 2; - - function createCacheRoot() { - return new WeakMap(); - } - - function createCacheNode() { - return { - s: UNTERMINATED, - // status, represents whether the cached computation returned a value or threw an error - v: undefined, - // value, either the cached result or an error, depending on s - o: null, - // object cache, a WeakMap where non-primitive arguments are stored - p: null // primitive cache, a regular Map where primitive arguments are stored. - }; - } - - function cache(fn) { - return function () { - var dispatcher = ReactSharedInternals.C; - - if (!dispatcher) { - // If there is no dispatcher, then we treat this as not being cached. - // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. - return fn.apply(null, arguments); - } - - var fnMap = dispatcher.getCacheForType(createCacheRoot); - var fnNode = fnMap.get(fn); - var cacheNode; - - if (fnNode === undefined) { - cacheNode = createCacheNode(); - fnMap.set(fn, cacheNode); - } else { - cacheNode = fnNode; - } - - for (var i = 0, l = arguments.length; i < l; i++) { - var arg = arguments[i]; - - if ( - typeof arg === "function" || - (typeof arg === "object" && arg !== null) - ) { - // Objects go into a WeakMap - var objectCache = cacheNode.o; - - if (objectCache === null) { - cacheNode.o = objectCache = new WeakMap(); - } - - var objectNode = objectCache.get(arg); - - if (objectNode === undefined) { - cacheNode = createCacheNode(); - objectCache.set(arg, cacheNode); - } else { - cacheNode = objectNode; - } - } else { - // Primitives go into a regular Map - var primitiveCache = cacheNode.p; - - if (primitiveCache === null) { - cacheNode.p = primitiveCache = new Map(); - } - - var primitiveNode = primitiveCache.get(arg); - - if (primitiveNode === undefined) { - cacheNode = createCacheNode(); - primitiveCache.set(arg, cacheNode); - } else { - cacheNode = primitiveNode; - } - } - } - - if (cacheNode.s === TERMINATED) { - return cacheNode.v; - } - - if (cacheNode.s === ERRORED) { - throw cacheNode.v; - } - - try { - // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. - var result = fn.apply(null, arguments); - var terminatedNode = cacheNode; - terminatedNode.s = TERMINATED; - terminatedNode.v = result; - return result; - } catch (error) { - // We store the first error that's thrown and rethrow it. - var erroredNode = cacheNode; - erroredNode.s = ERRORED; - erroredNode.v = error; - throw error; - } - }; - } - - var reportGlobalError = - typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, - ? // emulating an uncaught JavaScript error. - reportError - : function (error) { - if ( - typeof window === "object" && - typeof window.ErrorEvent === "function" - ) { - // Browser Polyfill - var message = - typeof error === "object" && - error !== null && - typeof error.message === "string" // eslint-disable-next-line react-internal/safe-string-coercion - ? String(error.message) // eslint-disable-next-line react-internal/safe-string-coercion - : String(error); - var event = new window.ErrorEvent("error", { - bubbles: true, - cancelable: true, - message: message, - error: error - }); - var shouldLog = window.dispatchEvent(event); - - if (!shouldLog) { - return; - } - } else if ( - typeof process === "object" && // $FlowFixMe[method-unbinding] - typeof process.emit === "function" - ) { - // Node Polyfill - process.emit("uncaughtException", error); - return; - } // eslint-disable-next-line react-internal/no-production-logging - - console["error"](error); - }; - - function startTransition(scope, options) { - var prevTransition = ReactSharedInternals.T; // Each renderer registers a callback to receive the return value of - // the scope function. This is used to implement async actions. - - var callbacks = new Set(); - var transition = { - _callbacks: callbacks - }; - ReactSharedInternals.T = transition; - var currentTransition = ReactSharedInternals.T; - - { - ReactSharedInternals.T._updatedFibers = new Set(); - } - - if (enableTransitionTracing) { - if (options !== undefined && options.name !== undefined) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.name = options.name; // $FlowFixMe[incompatible-use] found when upgrading Flow - - ReactSharedInternals.T.startTime = -1; - } - } - - { - try { - var returnValue = scope(); - - if ( - typeof returnValue === "object" && - returnValue !== null && - typeof returnValue.then === "function" - ) { - callbacks.forEach(function (callback) { - return callback(currentTransition, returnValue); - }); - returnValue.then(noop, reportGlobalError); - } - } catch (error) { - reportGlobalError(error); - } finally { - warnAboutTransitionSubscriptions(prevTransition, currentTransition); - ReactSharedInternals.T = prevTransition; - } - } - } - - function warnAboutTransitionSubscriptions( - prevTransition, - currentTransition - ) { - { - if (prevTransition === null && currentTransition._updatedFibers) { - var updatedFibersCount = currentTransition._updatedFibers.size; - - currentTransition._updatedFibers.clear(); - - if (updatedFibersCount > 10) { - warn( - "Detected a large number of updates inside startTransition. " + - "If this is due to a subscription please re-write it to use React provided hooks. " + - "Otherwise concurrent mode guarantees are off the table." - ); - } - } - } - } - - function noop() {} - - var ReactVersion = "19.0.0-www-modern-d87a79cd"; - - // Patch fetch - var Children = { - map: mapChildren, - forEach: forEachChildren, - count: countChildren, - toArray: toArray, - only: onlyChild - }; - - var jsx = jsxProdSignatureRunningInDevWithDynamicChildren; // we may want to special case jsxs internally to take advantage of static children. - // for now we can ship identical prod functions - - var jsxs = jsxProdSignatureRunningInDevWithStaticChildren; - var jsxDEV = jsxDEV$1; - - exports.Children = Children; - exports.Fragment = REACT_FRAGMENT_TYPE; - exports.Profiler = REACT_PROFILER_TYPE; - exports.StrictMode = REACT_STRICT_MODE_TYPE; - exports.Suspense = REACT_SUSPENSE_TYPE; - exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = - ReactSharedInternals; - exports.cache = cache; - exports.cloneElement = cloneElement; - exports.createElement = createElement; - exports.createRef = createRef; - exports.forwardRef = forwardRef; - exports.isValidElement = isValidElement; - exports.jsx = jsx; - exports.jsxDEV = jsxDEV; - exports.jsxs = jsxs; - exports.lazy = lazy; - exports.memo = memo; - exports.startTransition = startTransition; - exports.use = use; - exports.useActionState = useActionState; - exports.useCallback = useCallback; - exports.useDebugValue = useDebugValue; - exports.useId = useId; - exports.useMemo = useMemo; - exports.version = ReactVersion; - })(); -} diff --git a/compiled/facebook-www/ReactServer-prod.modern.js b/compiled/facebook-www/ReactServer-prod.modern.js deleted file mode 100644 index 5bdb44fa825af..0000000000000 --- a/compiled/facebook-www/ReactServer-prod.modern.js +++ /dev/null @@ -1,595 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @noflow - * @nolint - * @preventMunge - * @preserve-invariant-messages - */ - -"use strict"; -var assign = Object.assign, - dynamicFeatureFlags = require("ReactFeatureFlags"), - enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, - enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, - disableDefaultPropsExceptForClasses = - dynamicFeatureFlags.disableDefaultPropsExceptForClasses, - ReactSharedInternals = { H: null, C: null, owner: null }; -function formatProdErrorMessage(code) { - var url = "https://react.dev/errors/" + code; - if (1 < arguments.length) { - url += "?args[]=" + encodeURIComponent(arguments[1]); - for (var i = 2; i < arguments.length; i++) - url += "&args[]=" + encodeURIComponent(arguments[i]); - } - return ( - "Minified React error #" + - code + - "; visit " + - url + - " for the full message or use the non-minified dev environment for full errors and additional helpful warnings." - ); -} -var isArrayImpl = Array.isArray, - REACT_ELEMENT_TYPE = Symbol.for("react.element"), - REACT_PORTAL_TYPE = Symbol.for("react.portal"), - REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), - REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), - REACT_PROFILER_TYPE = Symbol.for("react.profiler"), - REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), - REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), - REACT_MEMO_TYPE = Symbol.for("react.memo"), - REACT_LAZY_TYPE = Symbol.for("react.lazy"), - MAYBE_ITERATOR_SYMBOL = Symbol.iterator; -function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "object" !== typeof maybeIterable) return null; - maybeIterable = - (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || - maybeIterable["@@iterator"]; - return "function" === typeof maybeIterable ? maybeIterable : null; -} -var hasOwnProperty = Object.prototype.hasOwnProperty; -function ReactElement(type, key, _ref, self, source, owner, props) { - enableRefAsProp && - ((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null)); - return { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - ref: _ref, - props: props, - _owner: owner - }; -} -function jsxProd(type, config, maybeKey) { - var key = null, - ref = null; - void 0 !== maybeKey && (key = "" + maybeKey); - void 0 !== config.key && (key = "" + config.key); - void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))); - maybeKey = {}; - for (var propName in config) - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - (enableRefAsProp && "ref" === propName - ? (maybeKey.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (maybeKey[propName] = config[propName])); - if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) { - config = type.defaultProps; - for (var propName$0 in config) - void 0 === maybeKey[propName$0] && - (maybeKey[propName$0] = config[propName$0]); - } - return ReactElement( - type, - key, - ref, - void 0, - void 0, - ReactSharedInternals.owner, - maybeKey - ); -} -function cloneAndReplaceKey(oldElement, newKey) { - return ReactElement( - oldElement.type, - newKey, - enableRefAsProp ? null : oldElement.ref, - void 0, - void 0, - oldElement._owner, - oldElement.props - ); -} -function isValidElement(object) { - return ( - "object" === typeof object && - null !== object && - object.$$typeof === REACT_ELEMENT_TYPE - ); -} -function coerceStringRef(mixedRef, owner, type) { - if ("string" !== typeof mixedRef) - if ("number" === typeof mixedRef || "boolean" === typeof mixedRef) - mixedRef = "" + mixedRef; - else return mixedRef; - var callback = stringRefAsCallbackRef.bind(null, mixedRef, type, owner); - callback.__stringRef = mixedRef; - callback.__type = type; - callback.__owner = owner; - return callback; -} -function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) throw Error(formatProdErrorMessage(290, stringRef)); - if (1 !== owner.tag) throw Error(formatProdErrorMessage(309)); - type = owner.stateNode; - if (!type) throw Error(formatProdErrorMessage(147, stringRef)); - type = type.refs; - null === value ? delete type[stringRef] : (type[stringRef] = value); -} -function escape(key) { - var escaperLookup = { "=": "=0", ":": "=2" }; - return ( - "$" + - key.replace(/[=:]/g, function (match) { - return escaperLookup[match]; - }) - ); -} -var userProvidedKeyEscapeRegex = /\/+/g; -function getElementKey(element, index) { - return "object" === typeof element && null !== element && null != element.key - ? escape("" + element.key) - : index.toString(36); -} -function noop$1() {} -function resolveThenable(thenable) { - switch (thenable.status) { - case "fulfilled": - return thenable.value; - case "rejected": - throw thenable.reason; - default: - switch ( - ("string" === typeof thenable.status - ? thenable.then(noop$1, noop$1) - : ((thenable.status = "pending"), - thenable.then( - function (fulfilledValue) { - "pending" === thenable.status && - ((thenable.status = "fulfilled"), - (thenable.value = fulfilledValue)); - }, - function (error) { - "pending" === thenable.status && - ((thenable.status = "rejected"), (thenable.reason = error)); - } - )), - thenable.status) - ) { - case "fulfilled": - return thenable.value; - case "rejected": - throw thenable.reason; - } - } - throw thenable; -} -function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { - var type = typeof children; - if ("undefined" === type || "boolean" === type) children = null; - var invokeCallback = !1; - if (null === children) invokeCallback = !0; - else - switch (type) { - case "bigint": - case "string": - case "number": - invokeCallback = !0; - break; - case "object": - switch (children.$$typeof) { - case REACT_ELEMENT_TYPE: - case REACT_PORTAL_TYPE: - invokeCallback = !0; - break; - case REACT_LAZY_TYPE: - return ( - (invokeCallback = children._init), - mapIntoArray( - invokeCallback(children._payload), - array, - escapedPrefix, - nameSoFar, - callback - ) - ); - } - } - if (invokeCallback) - return ( - (callback = callback(children)), - (invokeCallback = - "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar), - isArrayImpl(callback) - ? ((escapedPrefix = ""), - null != invokeCallback && - (escapedPrefix = - invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), - mapIntoArray(callback, array, escapedPrefix, "", function (c) { - return c; - })) - : null != callback && - (isValidElement(callback) && - (callback = cloneAndReplaceKey( - callback, - escapedPrefix + - (!callback.key || (children && children.key === callback.key) - ? "" - : ("" + callback.key).replace( - userProvidedKeyEscapeRegex, - "$&/" - ) + "/") + - invokeCallback - )), - array.push(callback)), - 1 - ); - invokeCallback = 0; - var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":"; - if (isArrayImpl(children)) - for (var i = 0; i < children.length; i++) - (nameSoFar = children[i]), - (type = nextNamePrefix + getElementKey(nameSoFar, i)), - (invokeCallback += mapIntoArray( - nameSoFar, - array, - escapedPrefix, - type, - callback - )); - else if (((i = getIteratorFn(children)), "function" === typeof i)) - for ( - children = i.call(children), i = 0; - !(nameSoFar = children.next()).done; - - ) - (nameSoFar = nameSoFar.value), - (type = nextNamePrefix + getElementKey(nameSoFar, i++)), - (invokeCallback += mapIntoArray( - nameSoFar, - array, - escapedPrefix, - type, - callback - )); - else if ("object" === type) { - if ("function" === typeof children.then) - return mapIntoArray( - resolveThenable(children), - array, - escapedPrefix, - nameSoFar, - callback - ); - array = String(children); - throw Error( - formatProdErrorMessage( - 31, - "[object Object]" === array - ? "object with keys {" + Object.keys(children).join(", ") + "}" - : array - ) - ); - } - return invokeCallback; -} -function mapChildren(children, func, context) { - if (null == children) return children; - var result = [], - count = 0; - mapIntoArray(children, result, "", "", function (child) { - return func.call(context, child, count++); - }); - return result; -} -function lazyInitializer(payload) { - if (-1 === payload._status) { - var ctor = payload._result; - ctor = ctor(); - ctor.then( - function (moduleObject) { - if (0 === payload._status || -1 === payload._status) - (payload._status = 1), (payload._result = moduleObject); - }, - function (error) { - if (0 === payload._status || -1 === payload._status) - (payload._status = 2), (payload._result = error); - } - ); - -1 === payload._status && ((payload._status = 0), (payload._result = ctor)); - } - if (1 === payload._status) return payload._result.default; - throw payload._result; -} -function createCacheRoot() { - return new WeakMap(); -} -function createCacheNode() { - return { s: 0, v: void 0, o: null, p: null }; -} -var reportGlobalError = - "function" === typeof reportError - ? reportError - : function (error) { - if ( - "object" === typeof window && - "function" === typeof window.ErrorEvent - ) { - var event = new window.ErrorEvent("error", { - bubbles: !0, - cancelable: !0, - message: - "object" === typeof error && - null !== error && - "string" === typeof error.message - ? String(error.message) - : String(error), - error: error - }); - if (!window.dispatchEvent(event)) return; - } else if ( - "object" === typeof process && - "function" === typeof process.emit - ) { - process.emit("uncaughtException", error); - return; - } - console.error(error); - }; -function noop() {} -exports.Children = { - map: mapChildren, - forEach: function (children, forEachFunc, forEachContext) { - mapChildren( - children, - function () { - forEachFunc.apply(this, arguments); - }, - forEachContext - ); - }, - count: function (children) { - var n = 0; - mapChildren(children, function () { - n++; - }); - return n; - }, - toArray: function (children) { - return ( - mapChildren(children, function (child) { - return child; - }) || [] - ); - }, - only: function (children) { - if (!isValidElement(children)) throw Error(formatProdErrorMessage(143)); - return children; - } -}; -exports.Fragment = REACT_FRAGMENT_TYPE; -exports.Profiler = REACT_PROFILER_TYPE; -exports.StrictMode = REACT_STRICT_MODE_TYPE; -exports.Suspense = REACT_SUSPENSE_TYPE; -exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = - ReactSharedInternals; -exports.cache = function (fn) { - return function () { - var dispatcher = ReactSharedInternals.C; - if (!dispatcher) return fn.apply(null, arguments); - var fnMap = dispatcher.getCacheForType(createCacheRoot); - dispatcher = fnMap.get(fn); - void 0 === dispatcher && - ((dispatcher = createCacheNode()), fnMap.set(fn, dispatcher)); - fnMap = 0; - for (var l = arguments.length; fnMap < l; fnMap++) { - var arg = arguments[fnMap]; - if ( - "function" === typeof arg || - ("object" === typeof arg && null !== arg) - ) { - var objectCache = dispatcher.o; - null === objectCache && (dispatcher.o = objectCache = new WeakMap()); - dispatcher = objectCache.get(arg); - void 0 === dispatcher && - ((dispatcher = createCacheNode()), objectCache.set(arg, dispatcher)); - } else - (objectCache = dispatcher.p), - null === objectCache && (dispatcher.p = objectCache = new Map()), - (dispatcher = objectCache.get(arg)), - void 0 === dispatcher && - ((dispatcher = createCacheNode()), - objectCache.set(arg, dispatcher)); - } - if (1 === dispatcher.s) return dispatcher.v; - if (2 === dispatcher.s) throw dispatcher.v; - try { - var result = fn.apply(null, arguments); - fnMap = dispatcher; - fnMap.s = 1; - return (fnMap.v = result); - } catch (error) { - throw ((result = dispatcher), (result.s = 2), (result.v = error), error); - } - }; -}; -exports.cloneElement = function (element, config, children) { - if (null === element || void 0 === element) - throw Error(formatProdErrorMessage(267, element)); - var props = assign({}, element.props), - key = element.key, - ref = enableRefAsProp ? null : element.ref, - owner = element._owner; - if (null != config) { - void 0 !== config.ref && - ((owner = ReactSharedInternals.owner), - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, owner, element.type)))); - void 0 !== config.key && (key = "" + config.key); - if ( - !disableDefaultPropsExceptForClasses && - element.type && - element.type.defaultProps - ) - var defaultProps = element.type.defaultProps; - for (propName in config) - !hasOwnProperty.call(config, propName) || - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - "__self" === propName || - "__source" === propName || - (enableRefAsProp && "ref" === propName && void 0 === config.ref) || - (disableDefaultPropsExceptForClasses || - void 0 !== config[propName] || - void 0 === defaultProps - ? enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - owner, - element.type - )) - : (props[propName] = config[propName]) - : (props[propName] = defaultProps[propName])); - } - var propName = arguments.length - 2; - if (1 === propName) props.children = children; - else if (1 < propName) { - defaultProps = Array(propName); - for (var i = 0; i < propName; i++) defaultProps[i] = arguments[i + 2]; - props.children = defaultProps; - } - return ReactElement(element.type, key, ref, void 0, void 0, owner, props); -}; -exports.createElement = function (type, config, children) { - var propName, - props = {}, - key = null, - ref = null; - if (null != config) - for (propName in (void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))), - void 0 !== config.key && (key = "" + config.key), - config)) - hasOwnProperty.call(config, propName) && - "key" !== propName && - (enableRefAsProp || "ref" !== propName) && - "__self" !== propName && - "__source" !== propName && - (enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (props[propName] = config[propName])); - var childrenLength = arguments.length - 2; - if (1 === childrenLength) props.children = children; - else if (1 < childrenLength) { - for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) - childArray[i] = arguments[i + 2]; - props.children = childArray; - } - if (type && type.defaultProps) - for (propName in ((childrenLength = type.defaultProps), childrenLength)) - void 0 === props[propName] && - (props[propName] = childrenLength[propName]); - return ReactElement( - type, - key, - ref, - void 0, - void 0, - ReactSharedInternals.owner, - props - ); -}; -exports.createRef = function () { - return { current: null }; -}; -exports.forwardRef = function (render) { - return { $$typeof: REACT_FORWARD_REF_TYPE, render: render }; -}; -exports.isValidElement = isValidElement; -exports.jsx = jsxProd; -exports.jsxDEV = void 0; -exports.jsxs = jsxProd; -exports.lazy = function (ctor) { - return { - $$typeof: REACT_LAZY_TYPE, - _payload: { _status: -1, _result: ctor }, - _init: lazyInitializer - }; -}; -exports.memo = function (type, compare) { - return { - $$typeof: REACT_MEMO_TYPE, - type: type, - compare: void 0 === compare ? null : compare - }; -}; -exports.startTransition = function (scope, options) { - var prevTransition = ReactSharedInternals.T, - callbacks = new Set(); - ReactSharedInternals.T = { _callbacks: callbacks }; - var currentTransition = ReactSharedInternals.T; - enableTransitionTracing && - void 0 !== options && - void 0 !== options.name && - ((ReactSharedInternals.T.name = options.name), - (ReactSharedInternals.T.startTime = -1)); - try { - var returnValue = scope(); - "object" === typeof returnValue && - null !== returnValue && - "function" === typeof returnValue.then && - (callbacks.forEach(function (callback) { - return callback(currentTransition, returnValue); - }), - returnValue.then(noop, reportGlobalError)); - } catch (error) { - reportGlobalError(error); - } finally { - ReactSharedInternals.T = prevTransition; - } -}; -exports.use = function (usable) { - return ReactSharedInternals.H.use(usable); -}; -exports.useActionState = function (action, initialState, permalink) { - return ReactSharedInternals.H.useActionState(action, initialState, permalink); -}; -exports.useCallback = function (callback, deps) { - return ReactSharedInternals.H.useCallback(callback, deps); -}; -exports.useDebugValue = function () {}; -exports.useId = function () { - return ReactSharedInternals.H.useId(); -}; -exports.useMemo = function (create, deps) { - return ReactSharedInternals.H.useMemo(create, deps); -}; -exports.version = "19.0.0-www-modern-31a64bca";