@@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
1717var React = require ( "next/dist/compiled/react-experimental" ) ;
1818var ReactDOM = require ( 'react-dom' ) ;
1919
20- var ReactVersion = '18.3.0-experimental-2983249dd-20231107 ' ;
20+ var ReactVersion = '18.3.0-experimental-7508dcd5c-20231108 ' ;
2121
2222var ReactSharedInternals = React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ;
2323
@@ -1736,11 +1736,14 @@ var DEFAULT_HEADERS_CAPACITY_IN_UTF16_CODE_UNITS = 2000; // Allows us to keep tr
17361736// if passed externalRuntimeConfig and the enableFizzExternalRuntime feature flag
17371737// is set, the server will send instructions via data attributes (instead of inline scripts)
17381738
1739- function createRenderState$1 ( resumableState , nonce , bootstrapScriptContent , bootstrapScripts , bootstrapModules , externalRuntimeConfig , importMap , onHeaders , maxHeadersLength ) {
1739+ function createRenderState$1 ( resumableState , nonce , externalRuntimeConfig , importMap , onHeaders , maxHeadersLength ) {
17401740 var inlineScriptWithNonce = nonce === undefined ? startInlineScript : stringToPrecomputedChunk ( '<script nonce="' + escapeTextForBrowser ( nonce ) + '">' ) ;
17411741 var idPrefix = resumableState . idPrefix ;
17421742 var bootstrapChunks = [ ] ;
17431743 var externalRuntimeScript = null ;
1744+ var bootstrapScriptContent = resumableState . bootstrapScriptContent ,
1745+ bootstrapScripts = resumableState . bootstrapScripts ,
1746+ bootstrapModules = resumableState . bootstrapModules ;
17441747
17451748 if ( bootstrapScriptContent !== undefined ) {
17461749 bootstrapChunks . push ( inlineScriptWithNonce , stringToChunk ( escapeBootstrapAndImportMapScriptContent ( bootstrapScriptContent ) ) , endInlineScript ) ;
@@ -1929,7 +1932,7 @@ function createRenderState$1(resumableState, nonce, bootstrapScriptContent, boot
19291932
19301933 return renderState ;
19311934}
1932- function createResumableState ( identifierPrefix , externalRuntimeConfig ) {
1935+ function createResumableState ( identifierPrefix , externalRuntimeConfig , bootstrapScriptContent , bootstrapScripts , bootstrapModules ) {
19331936 var idPrefix = identifierPrefix === undefined ? '' : identifierPrefix ;
19341937 var streamingFormat = ScriptStreamingFormat ;
19351938
@@ -1943,6 +1946,9 @@ function createResumableState(identifierPrefix, externalRuntimeConfig) {
19431946 idPrefix : idPrefix ,
19441947 nextFormID : 0 ,
19451948 streamingFormat : streamingFormat ,
1949+ bootstrapScriptContent : bootstrapScriptContent ,
1950+ bootstrapScripts : bootstrapScripts ,
1951+ bootstrapModules : bootstrapModules ,
19461952 instructions : NothingSent ,
19471953 hasBody : false ,
19481954 hasHtml : false ,
@@ -4409,7 +4415,10 @@ function pushEndInstance(target, type, props, resumableState, formatContext) {
44094415 target . push ( endChunkForTag ( type ) ) ;
44104416}
44114417
4412- function writeBootstrap ( destination , renderState ) {
4418+ function writeBootstrap ( destination , renderState , resumableState ) {
4419+ resumableState . bootstrapScriptContent = undefined ;
4420+ resumableState . bootstrapScripts = undefined ;
4421+ resumableState . bootstrapModules = undefined ;
44134422 var bootstrapChunks = renderState . bootstrapChunks ;
44144423 var i = 0 ;
44154424
@@ -4426,8 +4435,8 @@ function writeBootstrap(destination, renderState) {
44264435 return true ;
44274436}
44284437
4429- function writeCompletedRoot ( destination , renderState ) {
4430- return writeBootstrap ( destination , renderState ) ;
4438+ function writeCompletedRoot ( destination , renderState , resumableState ) {
4439+ return writeBootstrap ( destination , renderState , resumableState ) ;
44314440} // Structural Nodes
44324441// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
44334442// display. It's never visible to users. We use the template tag because it can be used in every
@@ -4784,7 +4793,7 @@ function writeCompletedBoundaryInstruction(destination, resumableState, renderSt
47844793 writeMore = writeChunkAndReturn ( destination , completeBoundaryDataEnd ) ;
47854794 }
47864795
4787- return writeBootstrap ( destination , renderState ) && writeMore ;
4796+ return writeBootstrap ( destination , renderState , resumableState ) && writeMore ;
47884797}
47894798var clientRenderScript1Full = stringToPrecomputedChunk ( clientRenderBoundary + ';$RX("' ) ;
47904799var clientRenderScript1Partial = stringToPrecomputedChunk ( '$RX("' ) ;
@@ -6520,7 +6529,7 @@ function emitEarlyPreloads(renderState, resumableState, shellComplete) {
65206529}
65216530
65226531function createRenderState ( resumableState , generateStaticMarkup ) {
6523- var renderState = createRenderState$1 ( resumableState , undefined , undefined , undefined , undefined , undefined , undefined , undefined ) ;
6532+ var renderState = createRenderState$1 ( resumableState , undefined , undefined , undefined , undefined , undefined ) ;
65246533 return {
65256534 // Keep this in sync with ReactFizzConfigDOM
65266535 placeholderPrefix : renderState . placeholderPrefix ,
@@ -6876,6 +6885,18 @@ var componentFrameCache;
68766885 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map ;
68776886 componentFrameCache = new PossiblyWeakMap ( ) ;
68786887}
6888+ /**
6889+ * Leverages native browser/VM stack frames to get proper details (e.g.
6890+ * filename, line + col number) for a single component in a component stack. We
6891+ * do this by:
6892+ * (1) throwing and catching an error in the function - this will be our
6893+ * control error.
6894+ * (2) calling the component which will eventually throw an error that we'll
6895+ * catch - this will be our sample error.
6896+ * (3) diffing the control and sample error stacks to find the stack frame
6897+ * which represents our component.
6898+ */
6899+
68796900
68806901function describeNativeComponentFrame ( fn , construct ) {
68816902 // If something asked for a stack inside a fake render, it should get ignored.
@@ -6891,7 +6912,6 @@ function describeNativeComponentFrame(fn, construct) {
68916912 }
68926913 }
68936914
6894- var control ;
68956915 reentry = true ;
68966916 var previousPrepareStackTrace = Error . prepareStackTrace ; // $FlowFixMe[incompatible-type] It does accept undefined.
68976917
@@ -6905,81 +6925,140 @@ function describeNativeComponentFrame(fn, construct) {
69056925 ReactCurrentDispatcher$1 . current = null ;
69066926 disableLogs ( ) ;
69076927 }
6928+ /**
6929+ * Finding a common stack frame between sample and control errors can be
6930+ * tricky given the different types and levels of stack trace truncation from
6931+ * different JS VMs. So instead we'll attempt to control what that common
6932+ * frame should be through this object method:
6933+ * Having both the sample and control errors be in the function under the
6934+ * `DescribeNativeComponentFrameRoot` property, + setting the `name` and
6935+ * `displayName` properties of the function ensures that a stack
6936+ * frame exists that has the method name `DescribeNativeComponentFrameRoot` in
6937+ * it for both control and sample stacks.
6938+ */
69086939
6909- try {
6910- // This should throw.
6911- if ( construct ) {
6912- // Something should be setting the props in the constructor.
6913- var Fake = function ( ) {
6914- throw Error ( ) ;
6915- } ; // $FlowFixMe[prop-missing]
69166940
6941+ var RunInRootFrame = {
6942+ DetermineComponentFrameRoot : function ( ) {
6943+ var control ;
69176944
6918- Object . defineProperty ( Fake . prototype , 'props' , {
6919- set : function ( ) {
6920- // We use a throwing setter instead of frozen or non-writable props
6921- // because that won't throw in a non-strict mode function.
6922- throw Error ( ) ;
6923- }
6924- } ) ;
6945+ try {
6946+ // This should throw.
6947+ if ( construct ) {
6948+ // Something should be setting the props in the constructor.
6949+ var Fake = function ( ) {
6950+ throw Error ( ) ;
6951+ } ; // $FlowFixMe[prop-missing]
6952+
6953+
6954+ Object . defineProperty ( Fake . prototype , 'props' , {
6955+ set : function ( ) {
6956+ // We use a throwing setter instead of frozen or non-writable props
6957+ // because that won't throw in a non-strict mode function.
6958+ throw Error ( ) ;
6959+ }
6960+ } ) ;
69256961
6926- if ( typeof Reflect === 'object' && Reflect . construct ) {
6927- // We construct a different control for this case to include any extra
6928- // frames added by the construct call.
6929- try {
6930- Reflect . construct ( Fake , [ ] ) ;
6931- } catch ( x ) {
6932- control = x ;
6933- }
6962+ if ( typeof Reflect === 'object' && Reflect . construct ) {
6963+ // We construct a different control for this case to include any extra
6964+ // frames added by the construct call.
6965+ try {
6966+ Reflect . construct ( Fake , [ ] ) ;
6967+ } catch ( x ) {
6968+ control = x ;
6969+ }
69346970
6935- Reflect . construct ( fn , [ ] , Fake ) ;
6936- } else {
6937- try {
6938- Fake . call ( ) ;
6939- } catch ( x ) {
6940- control = x ;
6941- } // $FlowFixMe[prop-missing] found when upgrading Flow
6971+ Reflect . construct ( fn , [ ] , Fake ) ;
6972+ } else {
6973+ try {
6974+ Fake . call ( ) ;
6975+ } catch ( x ) {
6976+ control = x ;
6977+ } // $FlowFixMe[prop-missing] found when upgrading Flow
69426978
69436979
6944- fn . call ( Fake . prototype ) ;
6945- }
6946- } else {
6947- try {
6948- throw Error ( ) ;
6949- } catch ( x ) {
6950- control = x ;
6951- } // TODO(luna): This will currently only throw if the function component
6952- // tries to access React/ReactDOM/props. We should probably make this throw
6953- // in simple components too
6980+ fn . call ( Fake . prototype ) ;
6981+ }
6982+ } else {
6983+ try {
6984+ throw Error ( ) ;
6985+ } catch ( x ) {
6986+ control = x ;
6987+ } // TODO(luna): This will currently only throw if the function component
6988+ // tries to access React/ReactDOM/props. We should probably make this throw
6989+ // in simple components too
69546990
69556991
6956- var maybePromise = fn ( ) ; // If the function component returns a promise, it's likely an async
6957- // component, which we don't yet support. Attach a noop catch handler to
6958- // silence the error.
6959- // TODO: Implement component stacks for async client components?
6992+ var maybePromise = fn ( ) ; // If the function component returns a promise, it's likely an async
6993+ // component, which we don't yet support. Attach a noop catch handler to
6994+ // silence the error.
6995+ // TODO: Implement component stacks for async client components?
69606996
6961- if ( maybePromise && typeof maybePromise . catch === 'function' ) {
6962- maybePromise . catch ( function ( ) { } ) ;
6997+ if ( maybePromise && typeof maybePromise . catch === 'function' ) {
6998+ maybePromise . catch ( function ( ) { } ) ;
6999+ }
7000+ }
7001+ } catch ( sample ) {
7002+ // This is inlined manually because closure doesn't do it for us.
7003+ if ( sample && control && typeof sample . stack === 'string' ) {
7004+ return [ sample . stack , control . stack ] ;
7005+ }
69637006 }
7007+
7008+ return [ null , null ] ;
69647009 }
6965- } catch ( sample ) {
6966- // This is inlined manually because closure doesn't do it for us.
6967- if ( sample && control && typeof sample . stack === 'string' ) {
7010+ } ; // $FlowFixMe[prop-missing]
7011+
7012+ RunInRootFrame . DetermineComponentFrameRoot . displayName = 'DetermineComponentFrameRoot' ;
7013+ var namePropDescriptor = Object . getOwnPropertyDescriptor ( RunInRootFrame . DetermineComponentFrameRoot , 'name' ) ; // Before ES6, the `name` property was not configurable.
7014+
7015+ if ( namePropDescriptor && namePropDescriptor . configurable ) {
7016+ // V8 utilizes a function's `name` property when generating a stack trace.
7017+ Object . defineProperty ( RunInRootFrame . DetermineComponentFrameRoot , // Configurable properties can be updated even if its writable descriptor
7018+ // is set to `false`.
7019+ // $FlowFixMe[cannot-write]
7020+ 'name' , {
7021+ value : 'DetermineComponentFrameRoot'
7022+ } ) ;
7023+ }
7024+
7025+ try {
7026+ var _RunInRootFrame$Deter = RunInRootFrame . DetermineComponentFrameRoot ( ) ,
7027+ sampleStack = _RunInRootFrame$Deter [ 0 ] ,
7028+ controlStack = _RunInRootFrame$Deter [ 1 ] ;
7029+
7030+ if ( sampleStack && controlStack ) {
69687031 // This extracts the first frame from the sample that isn't also in the control.
69697032 // Skipping one frame that we assume is the frame that calls the two.
6970- var sampleLines = sample . stack . split ( '\n' ) ;
6971- var controlLines = control . stack . split ( '\n' ) ;
6972- var s = sampleLines . length - 1 ;
6973- var c = controlLines . length - 1 ;
6974-
6975- while ( s >= 1 && c >= 0 && sampleLines [ s ] !== controlLines [ c ] ) {
6976- // We expect at least one stack frame to be shared.
6977- // Typically this will be the root most one. However, stack frames may be
6978- // cut off due to maximum stack limits. In this case, one maybe cut off
6979- // earlier than the other. We assume that the sample is longer or the same
6980- // and there for cut off earlier. So we should find the root most frame in
6981- // the sample somewhere in the control.
6982- c -- ;
7033+ var sampleLines = sampleStack . split ( '\n' ) ;
7034+ var controlLines = controlStack . split ( '\n' ) ;
7035+ var s = 0 ;
7036+ var c = 0 ;
7037+
7038+ while ( s < sampleLines . length && ! sampleLines [ s ] . includes ( 'DetermineComponentFrameRoot' ) ) {
7039+ s ++ ;
7040+ }
7041+
7042+ while ( c < controlLines . length && ! controlLines [ c ] . includes ( 'DetermineComponentFrameRoot' ) ) {
7043+ c ++ ;
7044+ } // We couldn't find our intentionally injected common root frame, attempt
7045+ // to find another common root frame by search from the bottom of the
7046+ // control stack...
7047+
7048+
7049+ if ( s === sampleLines . length || c === controlLines . length ) {
7050+ s = sampleLines . length - 1 ;
7051+ c = controlLines . length - 1 ;
7052+
7053+ while ( s >= 1 && c >= 0 && sampleLines [ s ] !== controlLines [ c ] ) {
7054+ // We expect at least one stack frame to be shared.
7055+ // Typically this will be the root most one. However, stack frames may be
7056+ // cut off due to maximum stack limits. In this case, one maybe cut off
7057+ // earlier than the other. We assume that the sample is longer or the same
7058+ // and there for cut off earlier. So we should find the root most frame in
7059+ // the sample somewhere in the control.
7060+ c -- ;
7061+ }
69837062 }
69847063
69857064 for ( ; s >= 1 && c >= 0 ; s -- , c -- ) {
@@ -7008,7 +7087,7 @@ function describeNativeComponentFrame(fn, construct) {
70087087 _frame = _frame . replace ( '<anonymous>' , fn . displayName ) ;
70097088 }
70107089
7011- {
7090+ if ( true ) {
70127091 if ( typeof fn === 'function' ) {
70137092 componentFrameCache . set ( fn , _frame ) ;
70147093 }
@@ -11612,7 +11691,7 @@ function flushCompletedQueues(request, destination) {
1161211691
1161311692 flushSegment ( request , destination , completedRootSegment ) ;
1161411693 request . completedRootSegment = null ;
11615- writeCompletedRoot ( destination , request . renderState ) ;
11694+ writeCompletedRoot ( destination , request . renderState , request . resumableState ) ;
1161611695 } else {
1161711696 // We haven't flushed the root yet so we don't need to check any other branches further down
1161811697 return ;
0 commit comments