@@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
17
17
var React = require ( "next/dist/compiled/react-experimental" ) ;
18
18
var ReactDOM = require ( 'react-dom' ) ;
19
19
20
- var ReactVersion = '18.3.0-experimental-2983249dd-20231107 ' ;
20
+ var ReactVersion = '18.3.0-experimental-7508dcd5c-20231108 ' ;
21
21
22
22
var ReactSharedInternals = React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ;
23
23
@@ -1736,11 +1736,14 @@ var DEFAULT_HEADERS_CAPACITY_IN_UTF16_CODE_UNITS = 2000; // Allows us to keep tr
1736
1736
// if passed externalRuntimeConfig and the enableFizzExternalRuntime feature flag
1737
1737
// is set, the server will send instructions via data attributes (instead of inline scripts)
1738
1738
1739
- function createRenderState$1 ( resumableState , nonce , bootstrapScriptContent , bootstrapScripts , bootstrapModules , externalRuntimeConfig , importMap , onHeaders , maxHeadersLength ) {
1739
+ function createRenderState$1 ( resumableState , nonce , externalRuntimeConfig , importMap , onHeaders , maxHeadersLength ) {
1740
1740
var inlineScriptWithNonce = nonce === undefined ? startInlineScript : stringToPrecomputedChunk ( '<script nonce="' + escapeTextForBrowser ( nonce ) + '">' ) ;
1741
1741
var idPrefix = resumableState . idPrefix ;
1742
1742
var bootstrapChunks = [ ] ;
1743
1743
var externalRuntimeScript = null ;
1744
+ var bootstrapScriptContent = resumableState . bootstrapScriptContent ,
1745
+ bootstrapScripts = resumableState . bootstrapScripts ,
1746
+ bootstrapModules = resumableState . bootstrapModules ;
1744
1747
1745
1748
if ( bootstrapScriptContent !== undefined ) {
1746
1749
bootstrapChunks . push ( inlineScriptWithNonce , stringToChunk ( escapeBootstrapAndImportMapScriptContent ( bootstrapScriptContent ) ) , endInlineScript ) ;
@@ -1929,7 +1932,7 @@ function createRenderState$1(resumableState, nonce, bootstrapScriptContent, boot
1929
1932
1930
1933
return renderState ;
1931
1934
}
1932
- function createResumableState ( identifierPrefix , externalRuntimeConfig ) {
1935
+ function createResumableState ( identifierPrefix , externalRuntimeConfig , bootstrapScriptContent , bootstrapScripts , bootstrapModules ) {
1933
1936
var idPrefix = identifierPrefix === undefined ? '' : identifierPrefix ;
1934
1937
var streamingFormat = ScriptStreamingFormat ;
1935
1938
@@ -1943,6 +1946,9 @@ function createResumableState(identifierPrefix, externalRuntimeConfig) {
1943
1946
idPrefix : idPrefix ,
1944
1947
nextFormID : 0 ,
1945
1948
streamingFormat : streamingFormat ,
1949
+ bootstrapScriptContent : bootstrapScriptContent ,
1950
+ bootstrapScripts : bootstrapScripts ,
1951
+ bootstrapModules : bootstrapModules ,
1946
1952
instructions : NothingSent ,
1947
1953
hasBody : false ,
1948
1954
hasHtml : false ,
@@ -4409,7 +4415,10 @@ function pushEndInstance(target, type, props, resumableState, formatContext) {
4409
4415
target . push ( endChunkForTag ( type ) ) ;
4410
4416
}
4411
4417
4412
- function writeBootstrap ( destination , renderState ) {
4418
+ function writeBootstrap ( destination , renderState , resumableState ) {
4419
+ resumableState . bootstrapScriptContent = undefined ;
4420
+ resumableState . bootstrapScripts = undefined ;
4421
+ resumableState . bootstrapModules = undefined ;
4413
4422
var bootstrapChunks = renderState . bootstrapChunks ;
4414
4423
var i = 0 ;
4415
4424
@@ -4426,8 +4435,8 @@ function writeBootstrap(destination, renderState) {
4426
4435
return true ;
4427
4436
}
4428
4437
4429
- function writeCompletedRoot ( destination , renderState ) {
4430
- return writeBootstrap ( destination , renderState ) ;
4438
+ function writeCompletedRoot ( destination , renderState , resumableState ) {
4439
+ return writeBootstrap ( destination , renderState , resumableState ) ;
4431
4440
} // Structural Nodes
4432
4441
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
4433
4442
// 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
4784
4793
writeMore = writeChunkAndReturn ( destination , completeBoundaryDataEnd ) ;
4785
4794
}
4786
4795
4787
- return writeBootstrap ( destination , renderState ) && writeMore ;
4796
+ return writeBootstrap ( destination , renderState , resumableState ) && writeMore ;
4788
4797
}
4789
4798
var clientRenderScript1Full = stringToPrecomputedChunk ( clientRenderBoundary + ';$RX("' ) ;
4790
4799
var clientRenderScript1Partial = stringToPrecomputedChunk ( '$RX("' ) ;
@@ -6520,7 +6529,7 @@ function emitEarlyPreloads(renderState, resumableState, shellComplete) {
6520
6529
}
6521
6530
6522
6531
function 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 ) ;
6524
6533
return {
6525
6534
// Keep this in sync with ReactFizzConfigDOM
6526
6535
placeholderPrefix : renderState . placeholderPrefix ,
@@ -6876,6 +6885,18 @@ var componentFrameCache;
6876
6885
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map ;
6877
6886
componentFrameCache = new PossiblyWeakMap ( ) ;
6878
6887
}
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
+
6879
6900
6880
6901
function describeNativeComponentFrame ( fn , construct ) {
6881
6902
// If something asked for a stack inside a fake render, it should get ignored.
@@ -6891,7 +6912,6 @@ function describeNativeComponentFrame(fn, construct) {
6891
6912
}
6892
6913
}
6893
6914
6894
- var control ;
6895
6915
reentry = true ;
6896
6916
var previousPrepareStackTrace = Error . prepareStackTrace ; // $FlowFixMe[incompatible-type] It does accept undefined.
6897
6917
@@ -6905,81 +6925,140 @@ function describeNativeComponentFrame(fn, construct) {
6905
6925
ReactCurrentDispatcher$1 . current = null ;
6906
6926
disableLogs ( ) ;
6907
6927
}
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
+ */
6908
6939
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]
6916
6940
6941
+ var RunInRootFrame = {
6942
+ DetermineComponentFrameRoot : function ( ) {
6943
+ var control ;
6917
6944
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
+ } ) ;
6925
6961
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
+ }
6934
6970
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
6942
6978
6943
6979
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
6954
6990
6955
6991
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?
6960
6996
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
+ }
6963
7006
}
7007
+
7008
+ return [ null , null ] ;
6964
7009
}
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 ) {
6968
7031
// This extracts the first frame from the sample that isn't also in the control.
6969
7032
// 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
+ }
6983
7062
}
6984
7063
6985
7064
for ( ; s >= 1 && c >= 0 ; s -- , c -- ) {
@@ -7008,7 +7087,7 @@ function describeNativeComponentFrame(fn, construct) {
7008
7087
_frame = _frame . replace ( '<anonymous>' , fn . displayName ) ;
7009
7088
}
7010
7089
7011
- {
7090
+ if ( true ) {
7012
7091
if ( typeof fn === 'function' ) {
7013
7092
componentFrameCache . set ( fn , _frame ) ;
7014
7093
}
@@ -11612,7 +11691,7 @@ function flushCompletedQueues(request, destination) {
11612
11691
11613
11692
flushSegment ( request , destination , completedRootSegment ) ;
11614
11693
request . completedRootSegment = null ;
11615
- writeCompletedRoot ( destination , request . renderState ) ;
11694
+ writeCompletedRoot ( destination , request . renderState , request . resumableState ) ;
11616
11695
} else {
11617
11696
// We haven't flushed the root yet so we don't need to check any other branches further down
11618
11697
return ;
0 commit comments