Unverified Commit 7a5ef27b authored by Josh Story's avatar Josh Story Committed by GitHub

Preload css (#48840)

This PR implements preloading of CSS from RSC.

1. The underlying Flight protocol was extended in
https://github.com/facebook/react/pull/26502 to allow sending hints from
RSC to SSR and Client runtimes. React was updated to include these
changes.
2. We now call `ReactDOM.preload()` for each stylesheet used in a
layout/page layer

There are a few implementation details to take note of
1. we were previously using the `.browser` variant of a few React
packages. This was a holdover from when there was just browser and node
and we wanted to use the browser variant b/c we wanted the same code to
work in edge/node runtimes. React now publishes a `.edge` variant which
is like `.browser` but expects to be server only. This is necessary to
get the opt-in for `AsyncLocalStorage`.
2. Even with the above change, AsyncLocalStorage was not patched on the
global scope until after React was loaded. I moved this into a module
which is loaded first
3. The component passed to RSC's `renderToReadableStream` is not
actually part of the RSC module graph. If I tried to call
`ReactDOM.preload()` inside that function or any other function defined
inside `app-render.tsx` file it would actually see the wrong instance of
`react-dom`. I added a new export on the RSC top level export which
exposes a `preloadStyle(...)` function which just delegates to
`ReactDOM.preload(...)`. This makes the preload run in the right module
graph


~There are a couple of bugs in React that this work uncovered that I
will upstream. We may want to delay merging until they are addressed.
I'll update this comment when that is complete.~
1. ~React, during SSR, can emit a preload for a style twice in some
circumstances because late discovered stylesheets don't consider whether
a preload has already been flushed when preparing to reveal a boundary
they are within~
2. ~React, during RSC updates on the client, can preload a style that is
already in the document because it currently only looks for existing
preload links and does not consider if there is a stylesheet link with
the same href.~

~both of these issues will not break functionality, they just make the
network tab look at bit more noisy. We would expect network deduping to
prevent multiple actual loads~

The above React bugs were fixed and included now in the React update in
this PR

---------
Co-authored-by: 's avatarShu Ding <g@shud.in>
parent ffefb31e
...@@ -196,13 +196,13 @@ ...@@ -196,13 +196,13 @@
"random-seed": "0.3.0", "random-seed": "0.3.0",
"react": "18.2.0", "react": "18.2.0",
"react-17": "npm:react@17.0.2", "react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-next-c8369527e-20230420", "react-builtin": "npm:react@18.3.0-next-6eadbe0c4-20230425",
"react-experimental-builtin": "npm:react@0.0.0-experimental-c8369527e-20230420", "react-experimental-builtin": "npm:react@0.0.0-experimental-6eadbe0c4-20230425",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2", "react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-next-c8369527e-20230420", "react-dom-builtin": "npm:react-dom@18.3.0-next-6eadbe0c4-20230425",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-c8369527e-20230420", "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-6eadbe0c4-20230425",
"react-server-dom-webpack": "18.3.0-next-1f248bdd7-20230419", "react-server-dom-webpack": "18.3.0-next-6eadbe0c4-20230425",
"react-ssr-prepass": "1.0.8", "react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3", "react-virtualized": "9.22.3",
"relay-compiler": "13.0.2", "relay-compiler": "13.0.2",
...@@ -213,8 +213,8 @@ ...@@ -213,8 +213,8 @@
"rimraf": "3.0.2", "rimraf": "3.0.2",
"sass": "1.54.0", "sass": "1.54.0",
"satori": "0.4.4", "satori": "0.4.4",
"scheduler-builtin": "npm:scheduler@0.24.0-next-c8369527e-20230420", "scheduler-builtin": "npm:scheduler@0.24.0-next-6eadbe0c4-20230425",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-c8369527e-20230420", "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-6eadbe0c4-20230425",
"seedrandom": "3.0.5", "seedrandom": "3.0.5",
"selenium-webdriver": "4.0.0-beta.4", "selenium-webdriver": "4.0.0-beta.4",
"semver": "7.3.7", "semver": "7.3.7",
......
...@@ -7,3 +7,4 @@ export { requestAsyncStorage } from 'next/dist/client/components/request-async-s ...@@ -7,3 +7,4 @@ export { requestAsyncStorage } from 'next/dist/client/components/request-async-s
import * as serverHooks from 'next/dist/client/components/hooks-server-context.js' import * as serverHooks from 'next/dist/client/components/hooks-server-context.js'
export { serverHooks } export { serverHooks }
export { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/server.edge' export { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/server.edge'
export { preloadStyle } from 'next/dist/server/app-render/rsc/preloads'
...@@ -591,6 +591,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() { ...@@ -591,6 +591,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
export { renderToReadableStream, decodeReply } from 'next/dist/compiled/react-server-dom-webpack/server.edge' export { renderToReadableStream, decodeReply } from 'next/dist/compiled/react-server-dom-webpack/server.edge'
export const __next_app_webpack_require__ = __webpack_require__ export const __next_app_webpack_require__ = __webpack_require__
export { preloadStyle } from 'next/dist/server/app-render/rsc/preloads'
` `
return result return result
......
...@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") { ...@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
(function() { (function() {
'use strict'; 'use strict';
var ReactVersion = '18.3.0-experimental-c8369527e-20230420'; var ReactVersion = '18.3.0-experimental-6eadbe0c4-20230425';
var Internals = { var Internals = {
usingClientEntryPoint: false, usingClientEntryPoint: false,
...@@ -24,41 +24,60 @@ var Internals = { ...@@ -24,41 +24,60 @@ var Internals = {
} }
}; };
function prefetchDNS() { var Dispatcher = Internals.Dispatcher;
var dispatcher = Internals.Dispatcher.current; function prefetchDNS(href) {
var passedOptionArg;
{
if (arguments[1] !== undefined) {
passedOptionArg = arguments[1];
}
}
var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.prefetchDNS.apply(this, arguments); {
if (passedOptionArg !== undefined) {
// prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to
// elicit the warning. In prod we do not forward since it is not a part of the interface.
// @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and
// let the rest of the codebase trust the types
dispatcher.prefetchDNS(href, passedOptionArg);
} else {
dispatcher.prefetchDNS(href);
}
}
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preconnect() { function preconnect(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preconnect.apply(this, arguments); dispatcher.preconnect(href, options);
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preload() { function preload(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preload.apply(this, arguments); dispatcher.preload(href, options);
} // We don't error because preload needs to be resilient to being called in a variety of scopes } // We don't error because preload needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preinit() { function preinit(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preinit.apply(this, arguments); dispatcher.preinit(href, options);
} // We don't error because preinit needs to be resilient to being called in a variety of scopes } // We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
......
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
'use strict';var b={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function d(a){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)e+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=b; 'use strict';var d={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function e(c){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+c,a=1;a<arguments.length;a++)b+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+c+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var f=d.Dispatcher;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d;
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preconnect=function(){var a=b.Dispatcher.current;a&&a.preconnect.apply(this,arguments)};exports.prefetchDNS=function(){var a=b.Dispatcher.current;a&&a.prefetchDNS.apply(this,arguments)};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-experimental-c8369527e-20230420"; exports.createPortal=function(){throw Error(e(448));};exports.flushSync=function(){throw Error(e(449));};exports.preconnect=function(c,b){var a=f.current;a&&a.preconnect(c,b)};exports.prefetchDNS=function(c){var b=f.current;b&&b.prefetchDNS(c)};exports.preinit=function(c,b){var a=f.current;a&&a.preinit(c,b)};exports.preload=function(c,b){var a=f.current;a&&a.preload(c,b)};exports.version="18.3.0-experimental-6eadbe0c4-20230425";
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
}, },
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"scheduler": "0.0.0-experimental-c8369527e-20230420" "scheduler": "0.0.0-experimental-6eadbe0c4-20230425"
}, },
"peerDependencies": { "peerDependencies": {
"react": "0.0.0-experimental-c8369527e-20230420" "react": "0.0.0-experimental-6eadbe0c4-20230425"
}, },
"browser": { "browser": {
"./server.js": "./server.browser.js", "./server.js": "./server.browser.js",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") { ...@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
(function() { (function() {
'use strict'; 'use strict';
var ReactVersion = '18.3.0-next-c8369527e-20230420'; var ReactVersion = '18.3.0-next-6eadbe0c4-20230425';
var Internals = { var Internals = {
usingClientEntryPoint: false, usingClientEntryPoint: false,
...@@ -24,41 +24,60 @@ var Internals = { ...@@ -24,41 +24,60 @@ var Internals = {
} }
}; };
function prefetchDNS() { var Dispatcher = Internals.Dispatcher;
var dispatcher = Internals.Dispatcher.current; function prefetchDNS(href) {
var passedOptionArg;
{
if (arguments[1] !== undefined) {
passedOptionArg = arguments[1];
}
}
var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.prefetchDNS.apply(this, arguments); {
if (passedOptionArg !== undefined) {
// prefetchDNS will warn if you pass reserved options arg. We pass it along in Dev only to
// elicit the warning. In prod we do not forward since it is not a part of the interface.
// @TODO move all arg validation into this file. It needs to be universal anyway so may as well lock down the interace here and
// let the rest of the codebase trust the types
dispatcher.prefetchDNS(href, passedOptionArg);
} else {
dispatcher.prefetchDNS(href);
}
}
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preconnect() { function preconnect(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preconnect.apply(this, arguments); dispatcher.preconnect(href, options);
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preload() { function preload(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preload.apply(this, arguments); dispatcher.preload(href, options);
} // We don't error because preload needs to be resilient to being called in a variety of scopes } // We don't error because preload needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
} }
function preinit() { function preinit(href, options) {
var dispatcher = Internals.Dispatcher.current; var dispatcher = Dispatcher.current;
if (dispatcher) { if (dispatcher) {
dispatcher.preinit.apply(this, arguments); dispatcher.preinit(href, options);
} // We don't error because preinit needs to be resilient to being called in a variety of scopes } // We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical // and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring. // so we favor silent bailout over warning or erroring.
......
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
'use strict';var b={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function d(a){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)e+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=b; 'use strict';var d={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function e(c){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+c,a=1;a<arguments.length;a++)b+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+c+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var f=d.Dispatcher;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d;
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preconnect=function(){var a=b.Dispatcher.current;a&&a.preconnect.apply(this,arguments)};exports.prefetchDNS=function(){var a=b.Dispatcher.current;a&&a.prefetchDNS.apply(this,arguments)};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-next-c8369527e-20230420"; exports.createPortal=function(){throw Error(e(448));};exports.flushSync=function(){throw Error(e(449));};exports.preconnect=function(c,b){var a=f.current;a&&a.preconnect(c,b)};exports.prefetchDNS=function(c){var b=f.current;b&&b.prefetchDNS(c)};exports.preinit=function(c,b){var a=f.current;a&&a.preinit(c,b)};exports.preload=function(c,b){var a=f.current;a&&a.preload(c,b)};exports.version="18.3.0-next-6eadbe0c4-20230425";
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
}, },
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"scheduler": "0.24.0-next-c8369527e-20230420" "scheduler": "0.24.0-next-6eadbe0c4-20230425"
}, },
"peerDependencies": { "peerDependencies": {
"react": "18.3.0-next-c8369527e-20230420" "react": "18.3.0-next-6eadbe0c4-20230425"
}, },
"browser": { "browser": {
"./server.js": "./server.browser.js" "./server.js": "./server.browser.js"
......
...@@ -23,7 +23,7 @@ if ( ...@@ -23,7 +23,7 @@ if (
) { ) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
} }
var ReactVersion = '18.3.0-experimental-c8369527e-20230420'; var ReactVersion = '18.3.0-experimental-6eadbe0c4-20230425';
// ATTENTION // ATTENTION
// When adding new symbols to this file, // When adding new symbols to this file,
......
...@@ -28,4 +28,4 @@ exports.forwardRef=function(a){return{$$typeof:w,render:a}};exports.isValidEleme ...@@ -28,4 +28,4 @@ exports.forwardRef=function(a){return{$$typeof:w,render:a}};exports.isValidEleme
exports.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};exports.unstable_getCacheForType=function(a){var b=U.current;return b?b.getCacheForType(a):a()};exports.unstable_getCacheSignal=function(){var a=U.current;return a?a.getCacheSignal():(a=new AbortController,a.abort(Error("This CacheSignal was requested outside React which means that it is immediately aborted.")),a.signal)};exports.unstable_useCacheRefresh=function(){return W.current.useCacheRefresh()}; exports.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};exports.unstable_getCacheForType=function(a){var b=U.current;return b?b.getCacheForType(a):a()};exports.unstable_getCacheSignal=function(){var a=U.current;return a?a.getCacheSignal():(a=new AbortController,a.abort(Error("This CacheSignal was requested outside React which means that it is immediately aborted.")),a.signal)};exports.unstable_useCacheRefresh=function(){return W.current.useCacheRefresh()};
exports.unstable_useMemoCache=function(a){return W.current.useMemoCache(a)};exports.use=function(a){return W.current.use(a)};exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return W.current.useDeferredValue(a)};exports.useEffect=function(a,b){return W.current.useEffect(a,b)};exports.useId=function(){return W.current.useId()}; exports.unstable_useMemoCache=function(a){return W.current.useMemoCache(a)};exports.use=function(a){return W.current.use(a)};exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return W.current.useDeferredValue(a)};exports.useEffect=function(a,b){return W.current.useEffect(a,b)};exports.useId=function(){return W.current.useId()};
exports.useImperativeHandle=function(a,b,c){return W.current.useImperativeHandle(a,b,c)};exports.useInsertionEffect=function(a,b){return W.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return W.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return W.current.useMemo(a,b)};exports.useReducer=function(a,b,c){return W.current.useReducer(a,b,c)};exports.useRef=function(a){return W.current.useRef(a)};exports.useState=function(a){return W.current.useState(a)}; exports.useImperativeHandle=function(a,b,c){return W.current.useImperativeHandle(a,b,c)};exports.useInsertionEffect=function(a,b){return W.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return W.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return W.current.useMemo(a,b)};exports.useReducer=function(a,b,c){return W.current.useReducer(a,b,c)};exports.useRef=function(a){return W.current.useRef(a)};exports.useState=function(a){return W.current.useState(a)};
exports.useSyncExternalStore=function(a,b,c){return W.current.useSyncExternalStore(a,b,c)};exports.useTransition=function(){return W.current.useTransition()};exports.version="18.3.0-experimental-c8369527e-20230420"; exports.useSyncExternalStore=function(a,b,c){return W.current.useSyncExternalStore(a,b,c)};exports.useTransition=function(){return W.current.useTransition()};exports.version="18.3.0-experimental-6eadbe0c4-20230425";
...@@ -301,7 +301,7 @@ function generateCacheKey(request) { ...@@ -301,7 +301,7 @@ function generateCacheKey(request) {
} }
} }
var ReactVersion = '18.3.0-experimental-c8369527e-20230420'; var ReactVersion = '18.3.0-experimental-6eadbe0c4-20230425';
// ATTENTION // ATTENTION
// When adding new symbols to this file, // When adding new symbols to this file,
......
...@@ -27,4 +27,4 @@ key:e,ref:f,props:c,_owner:h}};exports.createElement=function(a,b,d){var c,e={}, ...@@ -27,4 +27,4 @@ key:e,ref:f,props:c,_owner:h}};exports.createElement=function(a,b,d){var c,e={},
exports.createServerContext=function(a,b){var d=!0;if(!Z[a]){d=!1;var c={$$typeof:z,_currentValue:b,_currentValue2:b,_defaultValue:b,_threadCount:0,Provider:null,Consumer:null,_globalName:a};c.Provider={$$typeof:y,_context:c};Z[a]=c}c=Z[a];if(c._defaultValue===D)c._defaultValue=b,c._currentValue===D&&(c._currentValue=b),c._currentValue2===D&&(c._currentValue2=b);else if(d)throw Error(F(429,a));return c};exports.forwardRef=function(a){return{$$typeof:A,render:a}};exports.isValidElement=Q; exports.createServerContext=function(a,b){var d=!0;if(!Z[a]){d=!1;var c={$$typeof:z,_currentValue:b,_currentValue2:b,_defaultValue:b,_threadCount:0,Provider:null,Consumer:null,_globalName:a};c.Provider={$$typeof:y,_context:c};Z[a]=c}c=Z[a];if(c._defaultValue===D)c._defaultValue=b,c._currentValue===D&&(c._currentValue=b),c._currentValue2===D&&(c._currentValue2=b);else if(d)throw Error(F(429,a));return c};exports.forwardRef=function(a){return{$$typeof:A,render:a}};exports.isValidElement=Q;
exports.lazy=function(a){return{$$typeof:ba,_payload:{_status:-1,_result:a},_init:fa}};exports.memo=function(a,b){return{$$typeof:aa,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_DebugTracingMode=ca;exports.unstable_getCacheForType=function(a){var b=n.current;return b?b.getCacheForType(a):a()}; exports.lazy=function(a){return{$$typeof:ba,_payload:{_status:-1,_result:a},_init:fa}};exports.memo=function(a,b){return{$$typeof:aa,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_DebugTracingMode=ca;exports.unstable_getCacheForType=function(a){var b=n.current;return b?b.getCacheForType(a):a()};
exports.unstable_getCacheSignal=function(){var a=n.current;if(!a){a=new AbortController;var b=Error(F(455));a.abort(b);return a.signal}return a.getCacheSignal()};exports.use=function(a){return W.current.use(a)};exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useId=function(){return W.current.useId()};exports.useMemo=function(a,b){return W.current.useMemo(a,b)}; exports.unstable_getCacheSignal=function(){var a=n.current;if(!a){a=new AbortController;var b=Error(F(455));a.abort(b);return a.signal}return a.getCacheSignal()};exports.use=function(a){return W.current.use(a)};exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useId=function(){return W.current.useId()};exports.useMemo=function(a,b){return W.current.useMemo(a,b)};
exports.version="18.3.0-experimental-c8369527e-20230420"; exports.version="18.3.0-experimental-6eadbe0c4-20230425";
...@@ -14,6 +14,7 @@ if (process.env.NODE_ENV !== "production") { ...@@ -14,6 +14,7 @@ if (process.env.NODE_ENV !== "production") {
(function() { (function() {
'use strict'; 'use strict';
var ReactDOM = require('react-dom');
var React = require('react'); var React = require('react');
function createStringDecoder() { function createStringDecoder() {
...@@ -162,6 +163,57 @@ function requireModule(metadata) { ...@@ -162,6 +163,57 @@ function requireModule(metadata) {
return moduleExports[metadata.name]; return moduleExports[metadata.name];
} }
var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// This client file is in the shared folder because it applies to both SSR and browser contexts.
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
function dispatchHint(code, model) {
var dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
var href, options;
if (typeof model === 'string') {
href = model;
} else {
href = model[0];
options = model[1];
}
switch (code) {
case 'D':
{
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.prefetchDNS(href, options);
return;
}
case 'C':
{
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.preconnect(href, options);
return;
}
case 'L':
{
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preload(href, options);
return;
}
case 'I':
{
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preinit(href, options);
return;
}
}
}
}
var knownServerReferences = new WeakMap(); var knownServerReferences = new WeakMap();
function createServerReference(id, callServer) { function createServerReference(id, callServer) {
var proxy = function () { var proxy = function () {
...@@ -625,13 +677,13 @@ function parseModelString(response, parentObject, key, value) { ...@@ -625,13 +677,13 @@ function parseModelString(response, parentObject, key, value) {
case '$': case '$':
{ {
// This was an escaped string value. // This was an escaped string value.
return value.substring(1); return value.slice(1);
} }
case 'L': case 'L':
{ {
// Lazy node // Lazy node
var id = parseInt(value.substring(2), 16); var id = parseInt(value.slice(2), 16);
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values. 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. // When passed into React, we'll know how to suspend on this.
...@@ -641,7 +693,7 @@ function parseModelString(response, parentObject, key, value) { ...@@ -641,7 +693,7 @@ function parseModelString(response, parentObject, key, value) {
case '@': case '@':
{ {
// Promise // Promise
var _id = parseInt(value.substring(2), 16); var _id = parseInt(value.slice(2), 16);
var _chunk = getChunk(response, _id); var _chunk = getChunk(response, _id);
...@@ -651,19 +703,19 @@ function parseModelString(response, parentObject, key, value) { ...@@ -651,19 +703,19 @@ function parseModelString(response, parentObject, key, value) {
case 'S': case 'S':
{ {
// Symbol // Symbol
return Symbol.for(value.substring(2)); return Symbol.for(value.slice(2));
} }
case 'P': case 'P':
{ {
// Server Context Provider // Server Context Provider
return getOrCreateServerContext(value.substring(2)).Provider; return getOrCreateServerContext(value.slice(2)).Provider;
} }
case 'F': case 'F':
{ {
// Server Reference // Server Reference
var _id2 = parseInt(value.substring(2), 16); var _id2 = parseInt(value.slice(2), 16);
var _chunk2 = getChunk(response, _id2); var _chunk2 = getChunk(response, _id2);
...@@ -719,19 +771,19 @@ function parseModelString(response, parentObject, key, value) { ...@@ -719,19 +771,19 @@ function parseModelString(response, parentObject, key, value) {
case 'D': case 'D':
{ {
// Date // Date
return new Date(Date.parse(value.substring(2))); return new Date(Date.parse(value.slice(2)));
} }
case 'n': case 'n':
{ {
// BigInt // BigInt
return BigInt(value.substring(2)); return BigInt(value.slice(2));
} }
default: default:
{ {
// We assume that anything else is a reference ID. // We assume that anything else is a reference ID.
var _id3 = parseInt(value.substring(1), 16); var _id3 = parseInt(value.slice(1), 16);
var _chunk3 = getChunk(response, _id3); var _chunk3 = getChunk(response, _id3);
...@@ -858,6 +910,10 @@ function resolveErrorDev(response, id, digest, message, stack) { ...@@ -858,6 +910,10 @@ function resolveErrorDev(response, id, digest, message, stack) {
triggerErrorOnChunk(chunk, errorWithDigest); triggerErrorOnChunk(chunk, errorWithDigest);
} }
} }
function resolveHint(response, code, model) {
var hintModel = parseModel(response, model);
dispatchHint(code, hintModel);
}
function close(response) { function close(response) {
// In case there are any remaining unresolved chunks, they won't // In case there are any remaining unresolved chunks, they won't
// be resolved now. So we need to issue an error to those. // be resolved now. So we need to issue an error to those.
...@@ -872,7 +928,7 @@ function processFullRow(response, row) { ...@@ -872,7 +928,7 @@ function processFullRow(response, row) {
} }
var colon = row.indexOf(':', 0); var colon = row.indexOf(':', 0);
var id = parseInt(row.substring(0, colon), 16); var id = parseInt(row.slice(0, colon), 16);
var tag = row[colon + 1]; // When tags that are not text are added, check them here before var tag = row[colon + 1]; // When tags that are not text are added, check them here before
// parsing the row as text. // parsing the row as text.
// switch (tag) { // switch (tag) {
...@@ -881,13 +937,20 @@ function processFullRow(response, row) { ...@@ -881,13 +937,20 @@ function processFullRow(response, row) {
switch (tag) { switch (tag) {
case 'I': case 'I':
{ {
resolveModule(response, id, row.substring(colon + 2)); resolveModule(response, id, row.slice(colon + 2));
return;
}
case 'H':
{
var code = row[colon + 2];
resolveHint(response, code, row.slice(colon + 3));
return; return;
} }
case 'E': case 'E':
{ {
var errorInfo = JSON.parse(row.substring(colon + 2)); var errorInfo = JSON.parse(row.slice(colon + 2));
{ {
resolveErrorDev(response, id, errorInfo.digest, errorInfo.message, errorInfo.stack); resolveErrorDev(response, id, errorInfo.digest, errorInfo.message, errorInfo.stack);
...@@ -899,7 +962,7 @@ function processFullRow(response, row) { ...@@ -899,7 +962,7 @@ function processFullRow(response, row) {
default: default:
{ {
// We assume anything else is JSON. // We assume anything else is JSON.
resolveModel(response, id, row.substring(colon + 1)); resolveModel(response, id, row.slice(colon + 1));
return; return;
} }
} }
...@@ -909,14 +972,14 @@ function processStringChunk(response, chunk, offset) { ...@@ -909,14 +972,14 @@ function processStringChunk(response, chunk, offset) {
var linebreak = chunk.indexOf('\n', offset); var linebreak = chunk.indexOf('\n', offset);
while (linebreak > -1) { while (linebreak > -1) {
var fullrow = response._partialRow + chunk.substring(offset, linebreak); var fullrow = response._partialRow + chunk.slice(offset, linebreak);
processFullRow(response, fullrow); processFullRow(response, fullrow);
response._partialRow = ''; response._partialRow = '';
offset = linebreak + 1; offset = linebreak + 1;
linebreak = chunk.indexOf('\n', offset); linebreak = chunk.indexOf('\n', offset);
} }
response._partialRow += chunk.substring(offset); response._partialRow += chunk.slice(offset);
} }
function processBinaryChunk(response, chunk) { function processBinaryChunk(response, chunk) {
...@@ -1087,7 +1150,7 @@ function describeValueForErrorMessage(value) { ...@@ -1087,7 +1150,7 @@ function describeValueForErrorMessage(value) {
switch (typeof value) { switch (typeof value) {
case 'string': case 'string':
{ {
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...'); return JSON.stringify(value.length <= 10 ? value : value.slice(0, 10) + '...');
} }
case 'object': case 'object':
......
...@@ -23,7 +23,7 @@ if ( ...@@ -23,7 +23,7 @@ if (
) { ) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
} }
var ReactVersion = '18.3.0-next-c8369527e-20230420'; var ReactVersion = '18.3.0-next-6eadbe0c4-20230425';
// ATTENTION // ATTENTION
// When adding new symbols to this file, // When adding new symbols to this file,
......
...@@ -27,4 +27,4 @@ exports.createServerContext=function(a,b){var c=!0;if(!Z[a]){c=!1;var d={$$typeo ...@@ -27,4 +27,4 @@ exports.createServerContext=function(a,b){var c=!0;if(!Z[a]){c=!1;var d={$$typeo
exports.isValidElement=P;exports.lazy=function(a){return{$$typeof:z,_payload:{_status:-1,_result:a},_init:ba}};exports.memo=function(a,b){return{$$typeof:y,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};exports.unstable_useCacheRefresh=function(){return W.current.useCacheRefresh()};exports.use=function(a){return W.current.use(a)}; exports.isValidElement=P;exports.lazy=function(a){return{$$typeof:z,_payload:{_status:-1,_result:a},_init:ba}};exports.memo=function(a,b){return{$$typeof:y,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};exports.unstable_useCacheRefresh=function(){return W.current.useCacheRefresh()};exports.use=function(a){return W.current.use(a)};
exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return W.current.useDeferredValue(a)};exports.useEffect=function(a,b){return W.current.useEffect(a,b)};exports.useId=function(){return W.current.useId()};exports.useImperativeHandle=function(a,b,c){return W.current.useImperativeHandle(a,b,c)}; exports.useCallback=function(a,b){return W.current.useCallback(a,b)};exports.useContext=function(a){return W.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return W.current.useDeferredValue(a)};exports.useEffect=function(a,b){return W.current.useEffect(a,b)};exports.useId=function(){return W.current.useId()};exports.useImperativeHandle=function(a,b,c){return W.current.useImperativeHandle(a,b,c)};
exports.useInsertionEffect=function(a,b){return W.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return W.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return W.current.useMemo(a,b)};exports.useReducer=function(a,b,c){return W.current.useReducer(a,b,c)};exports.useRef=function(a){return W.current.useRef(a)};exports.useState=function(a){return W.current.useState(a)};exports.useSyncExternalStore=function(a,b,c){return W.current.useSyncExternalStore(a,b,c)}; exports.useInsertionEffect=function(a,b){return W.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return W.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return W.current.useMemo(a,b)};exports.useReducer=function(a,b,c){return W.current.useReducer(a,b,c)};exports.useRef=function(a){return W.current.useRef(a)};exports.useState=function(a){return W.current.useState(a)};exports.useSyncExternalStore=function(a,b,c){return W.current.useSyncExternalStore(a,b,c)};
exports.useTransition=function(){return W.current.useTransition()};exports.version="18.3.0-next-c8369527e-20230420"; exports.useTransition=function(){return W.current.useTransition()};exports.version="18.3.0-next-6eadbe0c4-20230425";
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export default function Loading({ children }) {
return <div>ly layout loading</div>
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment