Skip to content

Commit 2b38118

Browse files
authored
Update React ot latest canary (#53881)
Updated React from cb3404a0c to f359f9b41. ### React upstream changes - facebook/react#27191 - facebook/react#27209 - facebook/react#27199 - facebook/react#27218 - facebook/react#27217 - facebook/react#27212
1 parent 4056994 commit 2b38118

File tree

52 files changed

+3148
-2265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3148
-2265
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@
189189
"random-seed": "0.3.0",
190190
"react": "18.2.0",
191191
"react-17": "npm:[email protected]",
192-
"react-builtin": "npm:[email protected]cb3404a0c-20230807",
192+
"react-builtin": "npm:[email protected]1a001dac6-20230812",
193193
"react-dom": "18.2.0",
194194
"react-dom-17": "npm:[email protected]",
195-
"react-dom-builtin": "npm:[email protected]cb3404a0c-20230807",
196-
"react-dom-experimental-builtin": "npm:[email protected]cb3404a0c-20230807",
197-
"react-experimental-builtin": "npm:[email protected]cb3404a0c-20230807",
198-
"react-server-dom-webpack": "18.3.0-canary-cb3404a0c-20230807",
199-
"react-server-dom-webpack-experimental": "npm:[email protected]cb3404a0c-20230807",
195+
"react-dom-builtin": "npm:[email protected]1a001dac6-20230812",
196+
"react-dom-experimental-builtin": "npm:[email protected]1a001dac6-20230812",
197+
"react-experimental-builtin": "npm:[email protected]1a001dac6-20230812",
198+
"react-server-dom-webpack": "18.3.0-canary-1a001dac6-20230812",
199+
"react-server-dom-webpack-experimental": "npm:[email protected]1a001dac6-20230812",
200200
"react-ssr-prepass": "1.0.8",
201201
"react-virtualized": "9.22.3",
202202
"relay-compiler": "13.0.2",
@@ -206,8 +206,8 @@
206206
"resolve-from": "5.0.0",
207207
"sass": "1.54.0",
208208
"satori": "0.10.1",
209-
"scheduler-builtin": "npm:[email protected]cb3404a0c-20230807",
210-
"scheduler-experimental-builtin": "npm:[email protected]cb3404a0c-20230807",
209+
"scheduler-builtin": "npm:[email protected]1a001dac6-20230812",
210+
"scheduler-experimental-builtin": "npm:[email protected]1a001dac6-20230812",
211211
"seedrandom": "3.0.5",
212212
"selenium-webdriver": "4.0.0-beta.4",
213213
"semver": "7.3.7",

packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
1717
var React = require("next/dist/compiled/react-experimental");
1818
var ReactDOM = require('react-dom');
1919

20-
var ReactVersion = '18.3.0-experimental-cb3404a0c-20230807';
20+
var ReactVersion = '18.3.0-experimental-1a001dac6-20230812';
2121

2222
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2323

@@ -3693,6 +3693,75 @@ function pushStyleContents(target, props) {
36933693
return;
36943694
}
36953695

3696+
function getImagePreloadKey(href, imageSrcSet, imageSizes) {
3697+
var uniquePart = '';
3698+
3699+
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
3700+
uniquePart += '[' + imageSrcSet + ']';
3701+
3702+
if (typeof imageSizes === 'string') {
3703+
uniquePart += '[' + imageSizes + ']';
3704+
}
3705+
} else {
3706+
uniquePart += '[][]' + href;
3707+
}
3708+
3709+
return getResourceKey('image', uniquePart);
3710+
}
3711+
3712+
function pushImg(target, props, resources) {
3713+
var src = props.src,
3714+
srcSet = props.srcSet;
3715+
3716+
if (props.loading !== 'lazy' && (typeof src === 'string' || typeof srcSet === 'string') && props.fetchPriority !== 'low' && // We exclude data URIs in src and srcSet since these should not be preloaded
3717+
!(typeof src === 'string' && src[4] === ':' && (src[0] === 'd' || src[0] === 'D') && (src[1] === 'a' || src[1] === 'A') && (src[2] === 't' || src[2] === 'T') && (src[3] === 'a' || src[3] === 'A')) && !(typeof srcSet === 'string' && srcSet[4] === ':' && (srcSet[0] === 'd' || srcSet[0] === 'D') && (srcSet[1] === 'a' || srcSet[1] === 'A') && (srcSet[2] === 't' || srcSet[2] === 'T') && (srcSet[3] === 'a' || srcSet[3] === 'A'))) {
3718+
// We have a suspensey image and ought to preload it to optimize the loading of display blocking
3719+
// resources.
3720+
var sizes = props.sizes;
3721+
var key = getImagePreloadKey(src, srcSet, sizes);
3722+
var resource = resources.preloadsMap.get(key);
3723+
3724+
if (!resource) {
3725+
resource = {
3726+
type: 'preload',
3727+
chunks: [],
3728+
state: NoState,
3729+
props: {
3730+
rel: 'preload',
3731+
as: 'image',
3732+
// There is a bug in Safari where imageSrcSet is not respected on preload links
3733+
// so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
3734+
// This harms older browers that do not support imageSrcSet by making their preloads not work
3735+
// but this population is shrinking fast and is already small so we accept this tradeoff.
3736+
href: srcSet ? undefined : src,
3737+
imageSrcSet: srcSet,
3738+
imageSizes: sizes,
3739+
crossOrigin: props.crossOrigin,
3740+
integrity: props.integrity,
3741+
type: props.type,
3742+
fetchPriority: props.fetchPriority,
3743+
referrerPolicy: props.referrerPolicy
3744+
}
3745+
};
3746+
resources.preloadsMap.set(key, resource);
3747+
3748+
{
3749+
markAsRenderedResourceDEV(resource, props);
3750+
}
3751+
3752+
pushLinkImpl(resource.chunks, resource.props);
3753+
}
3754+
3755+
if (props.fetchPriority === 'high' || resources.highImagePreloads.size < 10) {
3756+
resources.highImagePreloads.add(resource);
3757+
} else {
3758+
resources.bulkPreloads.add(resource);
3759+
}
3760+
}
3761+
3762+
return pushSelfClosing(target, props, 'img');
3763+
}
3764+
36963765
function pushSelfClosing(target, props, tag) {
36973766
target.push(startChunkForTag(tag));
36983767

@@ -4263,6 +4332,11 @@ function pushStartInstance(target, type, props, resources, responseState, format
42634332
{
42644333
return pushStartPreformattedElement(target, props, type);
42654334
}
4335+
4336+
case 'img':
4337+
{
4338+
return pushImg(target, props, resources) ;
4339+
}
42664340
// Omitted close tags
42674341

42684342
case 'base':
@@ -4271,7 +4345,6 @@ function pushStartInstance(target, type, props, resources, responseState, format
42714345
case 'col':
42724346
case 'embed':
42734347
case 'hr':
4274-
case 'img':
42754348
case 'keygen':
42764349
case 'param':
42774350
case 'source':
@@ -5160,14 +5233,16 @@ function writePreamble(destination, resources, responseState, willFlushAllSegmen
51605233

51615234
preconnectChunks.length = 0;
51625235
resources.fontPreloads.forEach(flushResourceInPreamble, destination);
5163-
resources.fontPreloads.clear(); // Flush unblocked stylesheets by precedence
5236+
resources.fontPreloads.clear();
5237+
resources.highImagePreloads.forEach(flushResourceInPreamble, destination);
5238+
resources.highImagePreloads.clear(); // Flush unblocked stylesheets by precedence
51645239

51655240
resources.precedences.forEach(flushAllStylesInPreamble, destination);
51665241
resources.bootstrapScripts.forEach(flushResourceInPreamble, destination);
51675242
resources.scripts.forEach(flushResourceInPreamble, destination);
51685243
resources.scripts.clear();
5169-
resources.explicitPreloads.forEach(flushResourceInPreamble, destination);
5170-
resources.explicitPreloads.clear(); // Write embedding preloadChunks
5244+
resources.bulkPreloads.forEach(flushResourceInPreamble, destination);
5245+
resources.bulkPreloads.clear(); // Write embedding preloadChunks
51715246

51725247
var preloadChunks = responseState.preloadChunks;
51735248

@@ -5215,16 +5290,18 @@ function writeHoistables(destination, resources, responseState) {
52155290

52165291
preconnectChunks.length = 0;
52175292
resources.fontPreloads.forEach(flushResourceLate, destination);
5218-
resources.fontPreloads.clear(); // Preload any stylesheets. these will emit in a render instruction that follows this
5293+
resources.fontPreloads.clear();
5294+
resources.highImagePreloads.forEach(flushResourceInPreamble, destination);
5295+
resources.highImagePreloads.clear(); // Preload any stylesheets. these will emit in a render instruction that follows this
52195296
// but we want to kick off preloading as soon as possible
52205297

52215298
resources.precedences.forEach(preloadLateStyles, destination); // bootstrap scripts should flush above script priority but these can only flush in the preamble
52225299
// so we elide the code here for performance
52235300

52245301
resources.scripts.forEach(flushResourceLate, destination);
52255302
resources.scripts.clear();
5226-
resources.explicitPreloads.forEach(flushResourceLate, destination);
5227-
resources.explicitPreloads.clear(); // Write embedding preloadChunks
5303+
resources.bulkPreloads.forEach(flushResourceLate, destination);
5304+
resources.bulkPreloads.clear(); // Write embedding preloadChunks
52285305

52295306
var preloadChunks = responseState.preloadChunks;
52305307

@@ -5641,12 +5718,13 @@ function createResources() {
56415718
// cleared on flush
56425719
preconnects: new Set(),
56435720
fontPreloads: new Set(),
5721+
highImagePreloads: new Set(),
56445722
// usedImagePreloads: new Set(),
56455723
precedences: new Map(),
56465724
stylePrecedences: new Map(),
56475725
bootstrapScripts: new Set(),
56485726
scripts: new Set(),
5649-
explicitPreloads: new Set(),
5727+
bulkPreloads: new Set(),
56505728
// like a module global for currently rendering boundary
56515729
boundaryResources: null
56525730
};
@@ -5803,19 +5881,7 @@ function preload(href, options) {
58035881
// by varying the href. this is an edge case but it is the most correct behavior.
58045882
var imageSrcSet = options.imageSrcSet,
58055883
imageSizes = options.imageSizes;
5806-
var uniquePart = '';
5807-
5808-
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
5809-
uniquePart += '[' + imageSrcSet + ']';
5810-
5811-
if (typeof imageSizes === 'string') {
5812-
uniquePart += '[' + imageSizes + ']';
5813-
}
5814-
} else {
5815-
uniquePart += '[][]' + href;
5816-
}
5817-
5818-
key = getResourceKey(as, uniquePart);
5884+
key = getImagePreloadKey(href, imageSrcSet, imageSizes);
58195885
} else {
58205886
key = getResourceKey(as, href);
58215887
}
@@ -5874,8 +5940,10 @@ function preload(href, options) {
58745940

58755941
if (as === 'font') {
58765942
resources.fontPreloads.add(resource);
5943+
} else if (as === 'image' && options.fetchPriority === 'high') {
5944+
resources.highImagePreloads.add(resource);
58775945
} else {
5878-
resources.explicitPreloads.add(resource);
5946+
resources.bulkPreloads.add(resource);
58795947
}
58805948

58815949
flushResources(request);

0 commit comments

Comments
 (0)