UNPKG

next

Version:

The React Framework

1,381 lines (1,380 loc) • 195 kB
/** * @license React * react-server-dom-turbopack-server.edge.development.js * * 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. */ "use strict"; "production" !== process.env.NODE_ENV && (function () { function voidHandler() {} 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; } function _defineProperty(obj, key, value) { a: if ("object" == typeof key && key) { var e = key[Symbol.toPrimitive]; if (void 0 !== e) { key = e.call(key, "string"); if ("object" != typeof key) break a; throw new TypeError("@@toPrimitive must return a primitive value."); } key = String(key); } key = "symbol" == typeof key ? key : key + ""; key in obj ? Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }) : (obj[key] = value); return obj; } function handleErrorInNextTick(error) { setTimeout(function () { throw error; }); } function writeChunkAndReturn(destination, chunk) { if (0 !== chunk.byteLength) if (2048 < chunk.byteLength) 0 < writtenBytes && (destination.enqueue( new Uint8Array(currentView.buffer, 0, writtenBytes) ), (currentView = new Uint8Array(2048)), (writtenBytes = 0)), destination.enqueue(chunk); else { var allowableBytes = currentView.length - writtenBytes; allowableBytes < chunk.byteLength && (0 === allowableBytes ? destination.enqueue(currentView) : (currentView.set( chunk.subarray(0, allowableBytes), writtenBytes ), destination.enqueue(currentView), (chunk = chunk.subarray(allowableBytes))), (currentView = new Uint8Array(2048)), (writtenBytes = 0)); currentView.set(chunk, writtenBytes); writtenBytes += chunk.byteLength; } return !0; } function completeWriting(destination) { currentView && 0 < writtenBytes && (destination.enqueue( new Uint8Array(currentView.buffer, 0, writtenBytes) ), (currentView = null), (writtenBytes = 0)); } function stringToChunk(content) { return textEncoder.encode(content); } function byteLengthOfChunk(chunk) { return chunk.byteLength; } function closeWithError(destination, error) { "function" === typeof destination.error ? destination.error(error) : destination.close(); } function isClientReference(reference) { return reference.$$typeof === CLIENT_REFERENCE_TAG$1; } function registerClientReferenceImpl(proxyImplementation, id, async) { return Object.defineProperties(proxyImplementation, { $$typeof: { value: CLIENT_REFERENCE_TAG$1 }, $$id: { value: id }, $$async: { value: async } }); } function bind() { var newFn = FunctionBind.apply(this, arguments); if (this.$$typeof === SERVER_REFERENCE_TAG) { null != arguments[0] && console.error( 'Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().' ); var args = ArraySlice.call(arguments, 1), $$typeof = { value: SERVER_REFERENCE_TAG }, $$id = { value: this.$$id }; args = { value: this.$$bound ? this.$$bound.concat(args) : args }; return Object.defineProperties(newFn, { $$typeof: $$typeof, $$id: $$id, $$bound: args, $$location: { value: this.$$location, configurable: !0 }, bind: { value: bind, configurable: !0 } }); } return newFn; } function getReference(target, name) { switch (name) { case "$$typeof": return target.$$typeof; case "$$id": return target.$$id; case "$$async": return target.$$async; case "name": return target.name; case "defaultProps": return; case "_debugInfo": return; case "toJSON": return; case Symbol.toPrimitive: return Object.prototype[Symbol.toPrimitive]; case Symbol.toStringTag: return Object.prototype[Symbol.toStringTag]; case "__esModule": var moduleId = target.$$id; target.default = registerClientReferenceImpl( function () { throw Error( "Attempted to call the default export of " + moduleId + " from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, target.$$id + "#", target.$$async ); return !0; case "then": if (target.then) return target.then; if (target.$$async) return; var clientReference = registerClientReferenceImpl( {}, target.$$id, !0 ), proxy = new Proxy(clientReference, proxyHandlers$1); target.status = "fulfilled"; target.value = proxy; return (target.then = registerClientReferenceImpl( function (resolve) { return Promise.resolve(resolve(proxy)); }, target.$$id + "#then", !1 )); } if ("symbol" === typeof name) throw Error( "Cannot read Symbol exports. Only named exports are supported on a client module imported on the server." ); clientReference = target[name]; clientReference || ((clientReference = registerClientReferenceImpl( function () { throw Error( "Attempted to call " + String(name) + "() from the server but " + String(name) + " is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, target.$$id + "#" + name, target.$$async )), Object.defineProperty(clientReference, "name", { value: name }), (clientReference = target[name] = new Proxy(clientReference, deepProxyHandlers))); return clientReference; } function resolveClientReferenceMetadata(config, clientReference) { var modulePath = clientReference.$$id, name = "", resolvedModuleData = config[modulePath]; if (resolvedModuleData) name = resolvedModuleData.name; else { var idx = modulePath.lastIndexOf("#"); -1 !== idx && ((name = modulePath.slice(idx + 1)), (resolvedModuleData = config[modulePath.slice(0, idx)])); if (!resolvedModuleData) throw Error( 'Could not find the module "' + modulePath + '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.' ); } if (!0 === resolvedModuleData.async && !0 === clientReference.$$async) throw Error( 'The module "' + modulePath + '" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.' ); return !0 === resolvedModuleData.async || !0 === clientReference.$$async ? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1] : [resolvedModuleData.id, resolvedModuleData.chunks, name]; } 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; } function collectStackTracePrivate(error, structuredStackTrace) { error = []; for (var i = framesToSkip; i < structuredStackTrace.length; i++) { var callSite = structuredStackTrace[i], name = callSite.getFunctionName() || "<anonymous>"; if (name.includes("react_stack_bottom_frame")) break; else if (callSite.isNative()) (callSite = callSite.isAsync()), error.push([name, "", 0, 0, 0, 0, callSite]); else { if (callSite.isConstructor()) name = "new " + name; else if (!callSite.isToplevel()) { var callSite$jscomp$0 = callSite; name = callSite$jscomp$0.getTypeName(); var methodName = callSite$jscomp$0.getMethodName(); callSite$jscomp$0 = callSite$jscomp$0.getFunctionName(); var result = ""; callSite$jscomp$0 ? (name && identifierRegExp.test(callSite$jscomp$0) && callSite$jscomp$0 !== name && (result += name + "."), (result += callSite$jscomp$0), !methodName || callSite$jscomp$0 === methodName || callSite$jscomp$0.endsWith("." + methodName) || callSite$jscomp$0.endsWith(" " + methodName) || (result += " [as " + methodName + "]")) : (name && (result += name + "."), (result = methodName ? result + methodName : result + "<anonymous>")); name = result; } "<anonymous>" === name && (name = ""); methodName = callSite.getScriptNameOrSourceURL() || "<anonymous>"; "<anonymous>" === methodName && ((methodName = ""), callSite.isEval() && (callSite$jscomp$0 = callSite.getEvalOrigin()) && (methodName = callSite$jscomp$0.toString() + ", <anonymous>")); callSite$jscomp$0 = callSite.getLineNumber() || 0; result = callSite.getColumnNumber() || 0; var enclosingLine = "function" === typeof callSite.getEnclosingLineNumber ? callSite.getEnclosingLineNumber() || 0 : 0, enclosingCol = "function" === typeof callSite.getEnclosingColumnNumber ? callSite.getEnclosingColumnNumber() || 0 : 0; callSite = callSite.isAsync(); error.push([ name, methodName, callSite$jscomp$0, result, enclosingLine, enclosingCol, callSite ]); } } collectedStackTrace = error; return ""; } function collectStackTrace(error, structuredStackTrace) { collectStackTracePrivate(error, structuredStackTrace); error = (error.name || "Error") + ": " + (error.message || ""); for (var i = 0; i < structuredStackTrace.length; i++) error += "\n at " + structuredStackTrace[i].toString(); return error; } function parseStackTrace(error, skipFrames) { var existing = stackTraceCache.get(error); if (void 0 !== existing) return existing; collectedStackTrace = null; framesToSkip = skipFrames; existing = Error.prepareStackTrace; Error.prepareStackTrace = collectStackTrace; try { var stack = String(error.stack); } finally { Error.prepareStackTrace = existing; } if (null !== collectedStackTrace) return ( (stack = collectedStackTrace), (collectedStackTrace = null), stackTraceCache.set(error, stack), stack ); stack.startsWith("Error: react-stack-top-frame\n") && (stack = stack.slice(29)); existing = stack.indexOf("react_stack_bottom_frame"); -1 !== existing && (existing = stack.lastIndexOf("\n", existing)); -1 !== existing && (stack = stack.slice(0, existing)); stack = stack.split("\n"); for (existing = []; skipFrames < stack.length; skipFrames++) { var parsed = frameRegExp.exec(stack[skipFrames]); if (parsed) { var name = parsed[1] || "", isAsync = "async " === parsed[8]; "<anonymous>" === name ? (name = "") : name.startsWith("async ") && ((name = name.slice(5)), (isAsync = !0)); var filename = parsed[2] || parsed[5] || ""; "<anonymous>" === filename && (filename = ""); existing.push([ name, filename, +(parsed[3] || parsed[6]), +(parsed[4] || parsed[7]), 0, 0, isAsync ]); } } stackTraceCache.set(error, existing); return existing; } function createTemporaryReference(temporaryReferences, id) { var reference = Object.defineProperties( function () { throw Error( "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, { $$typeof: { value: TEMPORARY_REFERENCE_TAG } } ); reference = new Proxy(reference, proxyHandlers); temporaryReferences.set(reference, id); return reference; } function noop() {} function trackUsedThenable(thenableState, thenable, index) { index = thenableState[index]; void 0 === index ? (thenableState.push(thenable), (thenableState._stacks || (thenableState._stacks = [])).push(Error())) : 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; } } 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; } function getThenableStateAfterSuspending() { var state = thenableState || []; state._componentDebugInfo = currentComponentDebugInfo; thenableState = currentComponentDebugInfo = null; return state; } 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 resolveOwner() { if (currentOwner) return currentOwner; if (supportsComponentStorage) { var owner = componentStorage.getStore(); if (owner) return owner; } return null; } function prepareStackTrace(error, structuredStackTrace) { error = (error.name || "Error") + ": " + (error.message || ""); for (var i = 0; i < structuredStackTrace.length; i++) error += "\n at " + structuredStackTrace[i].toString(); return error; } function resetOwnerStackLimit() { var now = getCurrentTime(); 1e3 < now - lastResetTime && ((ReactSharedInternalsServer.recentlyCreatedOwnerStacks = 0), (lastResetTime = now)); } function isObjectPrototype(object) { if (!object) return !1; var ObjectPrototype = Object.prototype; if (object === ObjectPrototype) return !0; if (getPrototypeOf(object)) return !1; object = Object.getOwnPropertyNames(object); for (var i = 0; i < object.length; i++) if (!(object[i] in ObjectPrototype)) return !1; return !0; } function isGetter(object, name) { if (object === Object.prototype || null === object) return !1; var descriptor = Object.getOwnPropertyDescriptor(object, name); return void 0 === descriptor ? isGetter(getPrototypeOf(object), name) : "function" === typeof descriptor.get; } function isSimpleObject(object) { if (!isObjectPrototype(getPrototypeOf(object))) return !1; for ( var names = Object.getOwnPropertyNames(object), i = 0; i < names.length; i++ ) { var descriptor = Object.getOwnPropertyDescriptor(object, names[i]); if ( !descriptor || (!descriptor.enumerable && (("key" !== names[i] && "ref" !== names[i]) || "function" !== typeof descriptor.get)) ) return !1; } return !0; } function objectName(object) { object = Object.prototype.toString.call(object); return object.slice(8, object.length - 1); } function describeKeyForErrorMessage(key) { var encodedKey = JSON.stringify(key); return '"' + key + '"' === encodedKey ? key : encodedKey; } 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"; case REACT_VIEW_TRANSITION_TYPE: return "ViewTransition"; } 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 ""; } function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); if ("Object" !== objKind && "Array" !== objKind) return objKind; var start = -1, length = 0; if (isArrayImpl(objectOrArray)) if (jsxChildrenParents.has(objectOrArray)) { var type = jsxChildrenParents.get(objectOrArray); objKind = "<" + describeElementType(type) + ">"; for (var i = 0; i < objectOrArray.length; i++) { var value = objectOrArray[i]; value = "string" === typeof value ? value : "object" === typeof value && null !== value ? "{" + describeObjectForErrorMessage(value) + "}" : "{" + describeValueForErrorMessage(value) + "}"; "" + i === expandedName ? ((start = objKind.length), (length = value.length), (objKind += value)) : (objKind = 15 > value.length && 40 > objKind.length + value.length ? objKind + value : objKind + "{...}"); } objKind += "</" + describeElementType(type) + ">"; } else { objKind = "["; for (type = 0; type < objectOrArray.length; type++) 0 < type && (objKind += ", "), (i = objectOrArray[type]), (i = "object" === typeof i && null !== i ? describeObjectForErrorMessage(i) : describeValueForErrorMessage(i)), "" + type === expandedName ? ((start = objKind.length), (length = i.length), (objKind += i)) : (objKind = 10 > i.length && 40 > objKind.length + i.length ? objKind + i : objKind + "..."); objKind += "]"; } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) objKind = "<" + describeElementType(objectOrArray.type) + "/>"; else { if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client"; if (jsxPropsParents.has(objectOrArray)) { objKind = jsxPropsParents.get(objectOrArray); objKind = "<" + (describeElementType(objKind) || "..."); type = Object.keys(objectOrArray); for (i = 0; i < type.length; i++) { objKind += " "; value = type[i]; objKind += describeKeyForErrorMessage(value) + "="; var _value2 = objectOrArray[value]; var _substr2 = value === expandedName && "object" === typeof _value2 && null !== _value2 ? describeObjectForErrorMessage(_value2) : describeValueForErrorMessage(_value2); "string" !== typeof _value2 && (_substr2 = "{" + _substr2 + "}"); value === expandedName ? ((start = objKind.length), (length = _substr2.length), (objKind += _substr2)) : (objKind = 10 > _substr2.length && 40 > objKind.length + _substr2.length ? objKind + _substr2 : objKind + "..."); } objKind += ">"; } else { objKind = "{"; type = Object.keys(objectOrArray); for (i = 0; i < type.length; i++) 0 < i && (objKind += ", "), (value = type[i]), (objKind += describeKeyForErrorMessage(value) + ": "), (_value2 = objectOrArray[value]), (_value2 = "object" === typeof _value2 && null !== _value2 ? describeObjectForErrorMessage(_value2) : describeValueForErrorMessage(_value2)), value === expandedName ? ((start = objKind.length), (length = _value2.length), (objKind += _value2)) : (objKind = 10 > _value2.length && 40 > objKind.length + _value2.length ? objKind + _value2 : objKind + "..."); objKind += "}"; } } return void 0 === expandedName ? objKind : -1 < start && 0 < length ? ((objectOrArray = " ".repeat(start) + "^".repeat(length)), "\n " + objKind + "\n " + objectOrArray) : "\n " + objKind; } function defaultFilterStackFrame(filename) { return ( "" !== filename && !filename.startsWith("node:") && !filename.includes("node_modules") ); } function filterStackTrace(request, stack) { request = request.filterStackFrame; for (var filteredStack = [], i = 0; i < stack.length; i++) { var callsite = stack[i], functionName = callsite[0]; var url = callsite[1]; if (url.startsWith("about://React/")) { var envIdx = url.indexOf("/", 14), suffixIdx = url.lastIndexOf("?"); -1 < envIdx && -1 < suffixIdx && (url = decodeURI(url.slice(envIdx + 1, suffixIdx))); } request(url, functionName, callsite[2], callsite[3]) && ((callsite = callsite.slice(0)), (callsite[1] = url), filteredStack.push(callsite)); } return filteredStack; } function patchConsole(consoleInst, methodName) { var descriptor = Object.getOwnPropertyDescriptor(consoleInst, methodName); if ( descriptor && (descriptor.configurable || descriptor.writable) && "function" === typeof descriptor.value ) { var originalMethod = descriptor.value; descriptor = Object.getOwnPropertyDescriptor(originalMethod, "name"); var wrapperMethod = function () { var request = resolveRequest(); if (("assert" !== methodName || !arguments[0]) && null !== request) { a: { var error = Error("react-stack-top-frame"); collectedStackTrace = null; framesToSkip = 1; var previousPrepare = Error.prepareStackTrace; Error.prepareStackTrace = collectStackTracePrivate; try { if ("" !== error.stack) { var JSCompiler_inline_result = null; break a; } } finally { Error.prepareStackTrace = previousPrepare; } JSCompiler_inline_result = collectedStackTrace; } JSCompiler_inline_result = filterStackTrace( request, JSCompiler_inline_result || [] ); request.pendingDebugChunks++; error = resolveOwner(); previousPrepare = Array.from(arguments); a: { var env = 0; switch (methodName) { case "dir": case "dirxml": case "groupEnd": case "table": env = null; break a; case "assert": env = 1; } var format = previousPrepare[env], style = previousPrepare[env + 1], badge = previousPrepare[env + 2]; "string" === typeof format && format.startsWith("\u001b[0m\u001b[7m%c%s\u001b[0m%c") && "background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px" === style && "string" === typeof badge ? ((format = format.slice(18)), " " === format[0] && (format = format.slice(1)), previousPrepare.splice(env, 4, format), (env = badge.slice(1, badge.length - 1))) : (env = null); } null === env && (env = (0, request.environmentName)()); null != error && outlineComponentInfo(request, error); badge = [methodName, JSCompiler_inline_result, error, env]; badge.push.apply(badge, previousPrepare); previousPrepare = serializeDebugModel( request, (null === request.deferredDebugObjects ? 500 : 10) + JSCompiler_inline_result.length, badge ); "[" !== previousPrepare[0] && (previousPrepare = serializeDebugModel( request, 10 + JSCompiler_inline_result.length, [ methodName, JSCompiler_inline_result, error, env, "Unknown Value: React could not send it from the server." ] )); JSCompiler_inline_result = stringToChunk( ":W" + previousPrepare + "\n" ); request.completedDebugChunks.push(JSCompiler_inline_result); } return originalMethod.apply(this, arguments); }; descriptor && Object.defineProperty(wrapperMethod, "name", descriptor); Object.defineProperty(consoleInst, methodName, { value: wrapperMethod }); } } function getCurrentStackInDEV() { var owner = resolveOwner(); if (null === owner) return ""; try { var info = ""; if (owner.owner || "string" !== typeof owner.name) { for (; owner; ) { var ownerStack = owner.debugStack; if (null != ownerStack) { if ((owner = owner.owner)) { var JSCompiler_temp_const = info; var error = ownerStack, prevPrepareStackTrace = Error.prepareStackTrace; Error.prepareStackTrace = prepareStackTrace; var stack = error.stack; Error.prepareStackTrace = prevPrepareStackTrace; stack.startsWith("Error: react-stack-top-frame\n") && (stack = stack.slice(29)); var idx = stack.indexOf("\n"); -1 !== idx && (stack = stack.slice(idx + 1)); idx = stack.indexOf("react_stack_bottom_frame"); -1 !== idx && (idx = stack.lastIndexOf("\n", idx)); var JSCompiler_inline_result = -1 !== idx ? (stack = stack.slice(0, idx)) : ""; info = JSCompiler_temp_const + ("\n" + JSCompiler_inline_result); } } else break; } var JSCompiler_inline_result$jscomp$0 = info; } else { JSCompiler_temp_const = owner.name; if (void 0 === prefix) try { throw Error(); } catch (x) { (prefix = ((error = x.stack.trim().match(/\n( *(at )?)/)) && error[1]) || ""), (suffix = -1 < x.stack.indexOf("\n at") ? " (<anonymous>)" : -1 < x.stack.indexOf("@") ? "@unknown:0:0" : ""); } JSCompiler_inline_result$jscomp$0 = "\n" + prefix + JSCompiler_temp_const + suffix; } } catch (x) { JSCompiler_inline_result$jscomp$0 = "\nError generating stack: " + x.message + "\n" + x.stack; } return JSCompiler_inline_result$jscomp$0; } function throwTaintViolation(message) { throw Error(message); } function cleanupTaintQueue(request) { request = request.taintCleanupQueue; TaintRegistryPendingRequests.delete(request); for (var i = 0; i < request.length; i++) { var entryValue = request[i], entry = TaintRegistryValues.get(entryValue); void 0 !== entry && (1 === entry.count ? TaintRegistryValues.delete(entryValue) : entry.count--); } request.length = 0; } function defaultErrorHandler(error) { console.error(error); } function RequestInstance( type, model, bundlerConfig, onError, onPostpone, onAllReady, onFatalError, identifierPrefix, temporaryReferences, environmentName, filterStackFrame, keepDebugAlive ) { if ( null !== ReactSharedInternalsServer.A && ReactSharedInternalsServer.A !== DefaultAsyncDispatcher ) throw Error( "Currently React only supports one RSC renderer at a time." ); ReactSharedInternalsServer.A = DefaultAsyncDispatcher; ReactSharedInternalsServer.getCurrentStack = getCurrentStackInDEV; var abortSet = new Set(), pingedTasks = [], cleanupQueue = []; TaintRegistryPendingRequests.add(cleanupQueue); var hints = new Set(); this.type = type; this.status = 10; this.flushScheduled = !1; this.destination = this.fatalError = null; this.bundlerConfig = bundlerConfig; this.cache = new Map(); this.cacheController = new AbortController(); this.pendingChunks = this.nextChunkId = 0; this.hints = hints; this.abortableTasks = abortSet; this.pingedTasks = pingedTasks; this.completedImportChunks = []; this.completedHintChunks = []; this.completedRegularChunks = []; this.completedErrorChunks = []; this.writtenSymbols = new Map(); this.writtenClientReferences = new Map(); this.writtenServerReferences = new Map(); this.writtenObjects = new WeakMap(); this.temporaryReferences = temporaryReferences; this.identifierPrefix = identifierPrefix || ""; this.identifierCount = 1; this.taintCleanupQueue = cleanupQueue; this.onError = void 0 === onError ? defaultErrorHandler : onError; this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone; this.onAllReady = onAllReady; this.onFatalError = onFatalError; this.pendingDebugChunks = 0; this.completedDebugChunks = []; this.debugDestination = null; this.environmentName = void 0 === environmentName ? function () { return "Server"; } : "function" !== typeof environmentName ? function () { return environmentName; } : environmentName; this.filterStackFrame = void 0 === filterStackFrame ? defaultFilterStackFrame : filterStackFrame; this.didWarnForKey = null; this.writtenDebugObjects = new WeakMap(); this.deferredDebugObjects = keepDebugAlive ? { retained: new Map(), existing: new Map() } : null; type = this.timeOrigin = performance.now(); emitTimeOriginChunk(this, type + performance.timeOrigin); this.abortTime = -0; model = createTask( this, model, null, !1, abortSet, type, null, null, null ); pingedTasks.push(model); } function createRequest( model, bundlerConfig, onError, identifierPrefix, onPostpone, temporaryReferences, environmentName, filterStackFrame, keepDebugAlive ) { resetOwnerStackLimit(); return new RequestInstance( 20, model, bundlerConfig, onError, onPostpone, noop, noop, identifierPrefix, temporaryReferences, environmentName, filterStackFrame, keepDebugAlive ); } function createPrerenderRequest( model, bundlerConfig, onAllReady, onFatalError, onError, identifierPrefix, onPostpone, temporaryReferences, environmentName, filterStackFrame, keepDebugAlive ) { resetOwnerStackLimit(); return new RequestInstance( 21, model, bundlerConfig, onError, onPostpone, onAllReady, onFatalError, identifierPrefix, temporaryReferences, environmentName, filterStackFrame, keepDebugAlive ); } function resolveRequest() { if (currentRequest) return currentRequest; if (supportsRequestStorage) { var store = requestStorage.getStore(); if (store) return store; } return null; } function serializeDebugThenable(request, counter, thenable) { request.pendingDebugChunks++; var id = request.nextChunkId++, ref = "$@" + id.toString(16); request.writtenDebugObjects.set(thenable, ref); switch (thenable.status) { case "fulfilled": return ( emitOutlinedDebugModelChunk(request, id, counter, thenable.value), ref ); case "rejected": return emitErrorChunk(request, id, "", thenable.reason, !0), ref; } if (request.status === ABORTING) return emitDebugHaltChunk(request, id), ref; var deferredDebugObjects = request.deferredDebugObjects; if (null !== deferredDebugObjects) return ( deferredDebugObjects.retained.set(id, thenable), (ref = "$Y@" + id.toString(16)), request.writtenDebugObjects.set(thenable, ref), ref ); var cancelled = !1; thenable.then( function (value) { cancelled || ((cancelled = !0), request.status === ABORTING ? emitDebugHaltChunk(request, id) : emitOutlinedDebugModelChunk(request, id, counter, value), enqueueFlush(request)); }, function (reason) { cancelled || ((cancelled = !0), request.status === ABORTING ? emitDebugHaltChunk(request, id) : emitErrorChunk(request, id, "", reason, !0), enqueueFlush(request)); } ); Promise.resolve().then(function () { cancelled || ((cancelled = !0), emitDebugHaltChunk(request, id), enqueueFlush(request), (counter = request = null)); }); return ref; } function emitRequestedDebugThenable(request, id, counter, thenable) { thenable.then( function (value) { request.status === ABORTING ? emitDebugHaltChunk(request, id) : emitOutlinedDebugModelChunk(request, id, counter, value); enqueueFlush(request); }, function (reason) { request.status === ABORTING ? emitDebugHaltChunk(request, id) : emitErrorChunk(request, id, "", reason, !0); enqueueFlush(request); } ); } function serializeThenable(request, task, thenable) { var newTask = createTask( request, thenable, task.keyPath, task.implicitSlot, request.abortableTasks, task.time, task.debugOwner, task.debugStack, task.debugTask ); switch (thenable.status) { case "fulfilled": return ( forwardDebugInfoFromThenable( request, newTask, thenable, null, null ), (newTask.model = thenable.value), pingTask(request, newTask), newTask.id ); case "rejected": return ( forwardDebugInfoFromThenable( request, newTask, thenable, null, null ), erroredTask(request, newTask, thenable.reason), newTask.id ); default: if (request.status === ABORTING) return ( request.abortableTasks.delete(newTask), 21 === request.type ? (haltTask(newTask), finishHaltedTask(newTask, request)) : ((task = request.fatalError), abortTask(newTask), finishAbortedTask(newTask, request, task)), newTask.id ); "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) { forwardDebugInfoFromCurrentContext(request, newTask, thenable); newTask.model = value; pingTask(request, newTask); }, function (reason) { 0 === newTask.status && ((newTask.timed = !0), erroredTask(request, newTask, reason), enqueueFlush(request)); } ); return newTask.id; } function serializeReadableStream(request, task, stream) { function progress(entry) { if (0 === streamTask.status) if (entry.done) (streamTask.status = 1), (entry = streamTask.id.toString(16) + ":C\n"), request.completedRegularChunks.push(stringToChunk(entry)), request.abortableTasks.delete(streamTask), request.cacheController.signal.removeEventListener( "abort", abortStream ), enqueueFlush(request), callOnAllReadyIfReady(request); else try { (streamTask.model = entry.value), request.pendingChunks++, tryStreamTask(request, streamTask), enqueueFlush(request), reader.read().then(progress, error); } catch (x$0) { error(x$0); } } function error(reason) { 0 === streamTask.status && (request.cacheController.signal.removeEventListener( "abort", abortStream ), erroredTask(request, streamTask, reason), enqueueFlush(request), reader.cancel(reason).then(error, error)); } function abortStream() { if (0 === streamTask.status) { var signal = request.cacheController.signal; signal.removeEventListener("abort", abortStream); signal = signal.reason; 21 === request.type ? (request.abortableTasks.delete(streamTask), haltTask(streamTask), finishHaltedTask(streamTask, request)) : (erroredTask(request, streamTask, signal), enqueueFlush(request)); reader.cancel(signal).then(error, error); } } var supportsBYOB = stream.supportsBYOB; if (void 0 === supportsBYOB) try { stream.getReader({ mode: "byob" }).releaseLock(), (supportsBYOB = !0); } catch (x) { supportsBYOB = !1; } var reader = stream.getReader(), streamTask = createTask( request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks, task.time, task.debugOwner, task.debugStack, task.debugTask ); request.pendingChunks++; task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n"; request.completedRegularChunks.push(stringToChunk(task)); request.cacheController.signal.addEventListener("abort", abortStream); reader.read().then(progress, error); return serializeByValueID(streamTask.id); } function serializeAsyncIterable(request, task, iterable, iterator) { function progress(entry) { if (0 === streamTask.status) if (entry.done) { streamTask.status = 1; if (void 0 === entry.value) var endStreamRow = streamTask.id.toString(16) + ":C\n"; else try { var chunkId = outlineModel(request, entry.value); endStreamRow = streamTask.id.toString(16) + ":C" + stringify(serializeByValueID(chunkId)) + "\n"; } catch (x) { error(x); return; } request.completedRegularChunks.push(stringToChunk(endStreamRow)); request.abortableTasks.delete(streamTask); request.cacheController.signal.removeEventListener( "abort", abortIterable ); enqueueFlush(request); callOnAllReadyIfReady(request); } else try { (streamTask.model = entry.value), request.pendingChunks++, tryStreamTask(request, streamTask), enqueueFlush(request), callIteratorInDEV(iterator, progress, error); } catch (x$1) { error(x$1); } } function error(reason) { 0 === streamTask.status && (request.cacheController.signal.removeEventListener( "abort", abortIterable ), erroredTask(request, streamTask, reason), enqueueFlush(request), "function" === typeof iterator.throw && iterator.throw(reason).then(error, error)); } function abortIterable() { if (0 === streamTask.status) { var signal = request.cacheController.signal; signal.removeEventListener("abort", abortIterable); var reason = signal.reason; 21 === request.type ? (request.abortableTasks.delete(streamTask), haltTask(streamTask), finishHaltedTask(streamTask, request)) : (erroredTask(request, streamTask, signal.reason), enqueueFlush(request)); "function" === typeof iterator.throw && iterator.throw(reason).then(error, error); } } var isIterator = iterable === iterator, streamTask = createTask( request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks, task.time, task.debugOwner, task.debugStack, task.debugTask ); (task = iterable._debugInfo) && forwardDebugInfo(request, streamTask, task); request.pendingChunks++; isIterator = streamTask.id.toString(16) + ":" + (isIterator ? "x" : "X") + "\n"; request.completedRegularChunks.push(stringToChunk(isIterator)); request.cacheController.signal.addEventListener("abort", abortIterable); callIteratorInDEV(iterator, progress, error); return serializeByValueID(streamTask.id); } function emitHint(request, code, model) { model = stringify(model); code = stringToChunk(":H" + code + model + "\n"); request.completedHintChunks.push(code); enqueueFlush(request); } function readThenable(thenable) { if ("fulfilled" === thenable.status) return thenable.value; if ("rejected" === thenable.status) throw thenable.reason; throw thenable; } function createLazyWrapperAroundWakeable(request, task, wakeable) { switch (wakeable.status) { case "fulfilled": return ( forwardDebugInfoFromThenable(request, task, wakeable, null, null), wakeable.value ); case "rejected": forwardDebugInfoFromThenable(request, task, wakeable, null, null); break; default: "string" !== typeof wakeable.status && ((wakeable.status = "pending"), wakeable.then( function (fulfilledValue) { forwardDebugInfoFromCurrentContext(request, task, wakeable); "pending" === wakeable.status && ((wakeable.status = "fulfilled"), (wakeable.value = fulfilledValue)); }, function (error) { forwardDebugInfoFromCurrentContext(request, task, wakeable); "pending" === wakeable.status && ((wakeable.status = "rejected"), (wakeable.reason = error)); } )); } return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable }; } function callWithDebugContextInDEV(request, task, callback, arg) { var componentDebugInfo = { name: "", env: task.environmentName, key: null, owner: task.debugOwner }; componentDebugInfo.stack = null === task.debugStack ? null : filterStackTrace(request, parseStackTrace(task.debugStack, 1)); componentDebugInfo.debugStack = task.debugStack; request = componentDebugInfo.