@@ -24,7 +24,7 @@ if (__DEV__) {
24
24
) {
25
25
__REACT_DEVTOOLS_GLOBAL_HOOK__ . registerInternalModuleStart ( new Error ( ) ) ;
26
26
}
27
- var ReactVersion = "18.3.0-www-classic-28af9135 " ;
27
+ var ReactVersion = "18.3.0-www-classic-dd3d212c " ;
28
28
29
29
// ATTENTION
30
30
// When adding new symbols to this file,
@@ -2777,110 +2777,22 @@ if (__DEV__) {
2777
2777
return elementType ;
2778
2778
}
2779
2779
2780
- var UNTERMINATED = 0 ;
2781
- var TERMINATED = 1 ;
2782
- var ERRORED = 2 ;
2783
-
2784
- function createCacheRoot ( ) {
2785
- return new WeakMap ( ) ;
2786
- }
2787
-
2788
- function createCacheNode ( ) {
2789
- return {
2790
- s : UNTERMINATED ,
2791
- // status, represents whether the cached computation returned a value or threw an error
2792
- v : undefined ,
2793
- // value, either the cached result or an error, depending on s
2794
- o : null ,
2795
- // object cache, a WeakMap where non-primitive arguments are stored
2796
- p : null // primitive cache, a regular Map where primitive arguments are stored.
2797
- } ;
2798
- }
2799
-
2800
2780
function cache ( fn ) {
2781
+ // On the client (i.e. not a Server Components environment) `cache` has
2782
+ // no caching behavior. We just return the function as-is.
2783
+ //
2784
+ // We intend to implement client caching in a future major release. In the
2785
+ // meantime, it's only exposed as an API so that Shared Components can use
2786
+ // per-request caching on the server without breaking on the client. But it
2787
+ // does mean they need to be aware of the behavioral difference.
2788
+ //
2789
+ // The rest of the behavior is the same as the server implementation — it
2790
+ // returns a new reference, extra properties like `displayName` are not
2791
+ // preserved, the length of the new function is 0, etc. That way apps can't
2792
+ // accidentally depend on those details.
2801
2793
return function ( ) {
2802
- var dispatcher = ReactCurrentCache . current ;
2803
-
2804
- if ( ! dispatcher ) {
2805
- // If there is no dispatcher, then we treat this as not being cached.
2806
- // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2807
- return fn . apply ( null , arguments ) ;
2808
- }
2809
-
2810
- var fnMap = dispatcher . getCacheForType ( createCacheRoot ) ;
2811
- var fnNode = fnMap . get ( fn ) ;
2812
- var cacheNode ;
2813
-
2814
- if ( fnNode === undefined ) {
2815
- cacheNode = createCacheNode ( ) ;
2816
- fnMap . set ( fn , cacheNode ) ;
2817
- } else {
2818
- cacheNode = fnNode ;
2819
- }
2820
-
2821
- for ( var i = 0 , l = arguments . length ; i < l ; i ++ ) {
2822
- var arg = arguments [ i ] ;
2823
-
2824
- if (
2825
- typeof arg === "function" ||
2826
- ( typeof arg === "object" && arg !== null )
2827
- ) {
2828
- // Objects go into a WeakMap
2829
- var objectCache = cacheNode . o ;
2830
-
2831
- if ( objectCache === null ) {
2832
- cacheNode . o = objectCache = new WeakMap ( ) ;
2833
- }
2834
-
2835
- var objectNode = objectCache . get ( arg ) ;
2836
-
2837
- if ( objectNode === undefined ) {
2838
- cacheNode = createCacheNode ( ) ;
2839
- objectCache . set ( arg , cacheNode ) ;
2840
- } else {
2841
- cacheNode = objectNode ;
2842
- }
2843
- } else {
2844
- // Primitives go into a regular Map
2845
- var primitiveCache = cacheNode . p ;
2846
-
2847
- if ( primitiveCache === null ) {
2848
- cacheNode . p = primitiveCache = new Map ( ) ;
2849
- }
2850
-
2851
- var primitiveNode = primitiveCache . get ( arg ) ;
2852
-
2853
- if ( primitiveNode === undefined ) {
2854
- cacheNode = createCacheNode ( ) ;
2855
- primitiveCache . set ( arg , cacheNode ) ;
2856
- } else {
2857
- cacheNode = primitiveNode ;
2858
- }
2859
- }
2860
- }
2861
-
2862
- if ( cacheNode . s === TERMINATED ) {
2863
- return cacheNode . v ;
2864
- }
2865
-
2866
- if ( cacheNode . s === ERRORED ) {
2867
- throw cacheNode . v ;
2868
- }
2869
-
2870
- try {
2871
- // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2872
- var result = fn . apply ( null , arguments ) ;
2873
- var terminatedNode = cacheNode ;
2874
- terminatedNode . s = TERMINATED ;
2875
- terminatedNode . v = result ;
2876
- return result ;
2877
- } catch ( error ) {
2878
- // We store the first error that's thrown and rethrow it.
2879
- var erroredNode = cacheNode ;
2880
- erroredNode . s = ERRORED ;
2881
- erroredNode . v = error ;
2882
- throw error ;
2883
- }
2794
+ // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
2795
+ return fn . apply ( null , arguments ) ;
2884
2796
} ;
2885
2797
}
2886
2798
0 commit comments