Skip to content

Commit

Permalink
upgrade react
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Oct 11, 2023
1 parent ec0a8da commit 520f153
Show file tree
Hide file tree
Showing 80 changed files with 9,921 additions and 5,612 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:[email protected]",
"react-builtin": "npm:[email protected]d900fadbf-20230929",
"react-builtin": "npm:[email protected]be67db46b-20231010",
"react-dom": "18.2.0",
"react-dom-17": "npm:[email protected]",
"react-dom-builtin": "npm:[email protected]d900fadbf-20230929",
"react-dom-experimental-builtin": "npm:[email protected]d900fadbf-20230929",
"react-experimental-builtin": "npm:[email protected]d900fadbf-20230929",
"react-server-dom-turbopack": "18.3.0-canary-d900fadbf-20230929",
"react-server-dom-turbopack-experimental": "npm:[email protected]d900fadbf-20230929",
"react-server-dom-webpack": "18.3.0-canary-d900fadbf-20230929",
"react-server-dom-webpack-experimental": "npm:[email protected]d900fadbf-20230929",
"react-dom-builtin": "npm:[email protected]be67db46b-20231010",
"react-dom-experimental-builtin": "npm:[email protected]be67db46b-20231010",
"react-experimental-builtin": "npm:[email protected]be67db46b-20231010",
"react-server-dom-turbopack": "18.3.0-canary-be67db46b-20231010",
"react-server-dom-turbopack-experimental": "npm:[email protected]be67db46b-20231010",
"react-server-dom-webpack": "18.3.0-canary-be67db46b-20231010",
"react-server-dom-webpack-experimental": "npm:[email protected]be67db46b-20231010",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand All @@ -211,8 +211,8 @@
"resolve-from": "5.0.0",
"sass": "1.54.0",
"satori": "0.10.6",
"scheduler-builtin": "npm:[email protected]d900fadbf-20230929",
"scheduler-experimental-builtin": "npm:[email protected]d900fadbf-20230929",
"scheduler-builtin": "npm:[email protected]be67db46b-20231010",
"scheduler-experimental-builtin": "npm:[email protected]be67db46b-20231010",
"seedrandom": "3.0.5",
"selenium-webdriver": "4.0.0-beta.4",
"semver": "7.3.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
var React = require("next/dist/compiled/react-experimental");
var ReactDOM = require('react-dom');

var ReactVersion = '18.3.0-experimental-d900fadbf-20230929';
var ReactVersion = '18.3.0-experimental-be67db46b-20231010';

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -8196,9 +8196,12 @@ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
return getServerSnapshot();
}

function useDeferredValue(value) {
function useDeferredValue(value, initialValue) {
resolveCurrentlyRenderingComponent();
return value;

{
return initialValue !== undefined ? initialValue : value;
}
}

function unsupportedStartTransition() {
Expand Down Expand Up @@ -8983,11 +8986,7 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c

try {
// We use the safe form because we don't handle suspending here. Only error handling.
if (typeof childSlots === 'number') {
resumeNode(request, task, childSlots, content, -1);
} else {
renderNode(request, task, content, -1);
}
renderNode(request, task, content, -1);

if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) {
throw new Error("Couldn't find all resumable slots by key/index during replaying. " + "The tree doesn't match so React will fallback to client rendering.");
Expand Down Expand Up @@ -9038,33 +9037,23 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
task.keyPath = prevKeyPath;
}

var fallbackKeyPath = [keyPath[0], 'Suspense Fallback', keyPath[2]];
var suspendedFallbackTask; // We create suspended task for the fallback because we don't want to actually work
var fallbackKeyPath = [keyPath[0], 'Suspense Fallback', keyPath[2]]; // We create suspended task for the fallback because we don't want to actually work
// on it yet in case we finish the main content, so we queue for later.

if (typeof fallbackSlots === 'number') {
// Resuming directly in the fallback.
var resumedSegment = createPendingSegment(request, 0, null, task.formatContext, false, false);
resumedSegment.id = fallbackSlots;
resumedSegment.parentFlushed = true;
suspendedFallbackTask = createRenderTask(request, null, fallback, -1, parentBoundary, resumedSegment, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext);
} else {
var fallbackReplay = {
nodes: fallbackNodes,
slots: fallbackSlots,
pendingTasks: 0
};
suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext);
}
var fallbackReplay = {
nodes: fallbackNodes,
slots: fallbackSlots,
pendingTasks: 0
};
var suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext);

{
suspendedFallbackTask.componentStack = task.componentStack;
} // TODO: This should be queued at a separate lower priority queue so that we only work
// on preparing fallbacks if we don't have any more main content to task on.


request.pingedTasks.push(suspendedFallbackTask); // TODO: Should this be in the finally?

request.pingedTasks.push(suspendedFallbackTask);
popComponentStackInDEV(task);
}

Expand Down Expand Up @@ -9605,37 +9594,6 @@ function resumeNode(request, task, segmentId, node, childIndex) {
}
}

function resumeElement(request, task, keyPath, segmentId, prevThenableState, type, props, ref) {
var prevReplay = task.replay;
var blockedBoundary = task.blockedBoundary;
var resumedSegment = createPendingSegment(request, 0, null, task.formatContext, false, false);
resumedSegment.id = segmentId;
resumedSegment.parentFlushed = true;

try {
// Convert the current ReplayTask to a RenderTask.
var renderTask = task;
renderTask.replay = null;
renderTask.blockedSegment = resumedSegment;
renderElement(request, task, keyPath, prevThenableState, type, props, ref);
resumedSegment.status = COMPLETED;

if (blockedBoundary === null) {
request.completedRootSegment = resumedSegment;
} else {
queueCompletedSegment(blockedBoundary, resumedSegment);

if (blockedBoundary.parentFlushed) {
request.partialBoundaries.push(blockedBoundary);
}
}
} finally {
// Restore to a ReplayTask.
task.replay = prevReplay;
task.blockedSegment = null;
}
}

function replayElement(request, task, keyPath, prevThenableState, name, keyOrIndex, childIndex, type, props, ref, replay) {
// We're replaying. Find the path to follow.
var replayNodes = replay.nodes;
Expand All @@ -9646,15 +9604,15 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd

if (keyOrIndex !== node[1]) {
continue;
} // Let's double check that the component name matches as a precaution.


if (name !== null && name !== node[0]) {
throw new Error('Expected to see a component of type "' + name + '" in this slot. ' + "The tree doesn't match so React will fallback to client rendering.");
}

if (node.length === 4) {
// Matched a replayable path.
// Let's double check that the component name matches as a precaution.
if (name !== null && name !== node[0]) {
throw new Error('Expected the resume to render <' + node[0] + '> in this slot but instead it rendered <' + name + '>. ' + "The tree doesn't match so React will fallback to client rendering.");
}

var childNodes = node[2];
var childSlots = node[3];
task.replay = {
Expand All @@ -9664,12 +9622,7 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd
};

try {
if (typeof childSlots === 'number') {
// Matched a resumable element.
resumeElement(request, task, keyPath, childSlots, prevThenableState, type, props, ref);
} else {
renderElement(request, task, keyPath, prevThenableState, type, props, ref);
}
renderElement(request, task, keyPath, prevThenableState, type, props, ref);

if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0 // TODO check remaining slots
) {
Expand All @@ -9694,7 +9647,8 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd
} else {
// Let's double check that the component type matches.
if (type !== REACT_SUSPENSE_TYPE) {
throw new Error('Expected to see a Suspense boundary in this slot. ' + "The tree doesn't match so React will fallback to client rendering.");
var expectedType = 'Suspense';
throw new Error('Expected the resume to render <' + expectedType + '> in this slot but instead it rendered <' + (getComponentNameFromType(type) || 'Unknown') + '>. ' + "The tree doesn't match so React will fallback to client rendering.");
} // Matched a replayable path.


Expand Down Expand Up @@ -9758,8 +9712,15 @@ prevThenableState, node, childIndex) {


function renderNodeDestructiveImpl(request, task, prevThenableState, node, childIndex) {
// Stash the node we're working on. We'll pick up from this task in case
if (task.replay !== null && typeof task.replay.slots === 'number') {
// TODO: Figure out a cheaper place than this hot path to do this check.
var resumeSegmentID = task.replay.slots;
resumeNode(request, task, resumeSegmentID, node, childIndex);
return;
} // Stash the node we're working on. We'll pick up from this task in case
// something suspends.


task.node = node;
task.childIndex = childIndex; // Handle object types

Expand Down Expand Up @@ -9946,6 +9907,7 @@ function replayFragment(request, task, children, childIndex) {
// in the original prerender. What's unable to complete is the child
// replay nodes which might be Suspense boundaries which are able to
// absorb the error and we can still continue with siblings.
// This is an error, stash the component stack if it is null.


erroredReplay(request, task.blockedBoundary, x, childNodes, childSlots);
Expand Down Expand Up @@ -10314,6 +10276,7 @@ function renderNode(request, task, node, childIndex) {
task.componentStack = previousComponentStack;
}

lastBoundaryErrorComponentStackDev = null;
return;
}
}
Expand Down Expand Up @@ -10375,6 +10338,7 @@ function erroredTask(request, boundary, error) {
}

if (boundary === null) {
lastBoundaryErrorComponentStackDev = null;
fatalError(request, error);
} else {
boundary.pendingTasks--;
Expand All @@ -10396,6 +10360,8 @@ function erroredTask(request, boundary, error) {
// We reuse the same queue for errors.
request.clientRenderedBoundaries.push(boundary);
}
} else {
lastBoundaryErrorComponentStackDev = null;
}
}

Expand Down Expand Up @@ -10509,8 +10475,6 @@ function abortTask(task, request, error) {
}

if (boundary === null) {
request.allPendingTasks--;

if (request.status !== CLOSING && request.status !== CLOSED) {
var replay = task.replay;

Expand All @@ -10519,6 +10483,7 @@ function abortTask(task, request, error) {
// the request;
logRecoverableError(request, error);
fatalError(request, error);
return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
// we should be able to recover by client rendering all the root boundaries in
Expand All @@ -10529,6 +10494,14 @@ function abortTask(task, request, error) {
var errorDigest = logRecoverableError(request, error);
abortRemainingReplayNodes(request, null, replay.nodes, replay.slots, error, errorDigest);
}

request.pendingRootTasks--;

if (request.pendingRootTasks === 0) {
request.onShellError = noop;
var onShellReady = request.onShellReady;
onShellReady();
}
}
}
} else {
Expand Down Expand Up @@ -10570,12 +10543,13 @@ function abortTask(task, request, error) {
return abortTask(fallbackTask, request, error);
});
boundary.fallbackAbortableTasks.clear();
request.allPendingTasks--;
}

if (request.allPendingTasks === 0) {
var onAllReady = request.onAllReady;
onAllReady();
}
request.allPendingTasks--;

if (request.allPendingTasks === 0) {
var onAllReady = request.onAllReady;
onAllReady();
}
}

Expand Down Expand Up @@ -10759,6 +10733,7 @@ function retryRenderTask(request, task, segment) {
logPostpone(request, postponeInstance.message);
trackPostpone(request, trackedPostpones, task, segment);
finishedTask(request, task.blockedBoundary, segment);
lastBoundaryErrorComponentStackDev = null;
return;
}
}
Expand Down Expand Up @@ -10835,6 +10810,14 @@ function retryReplayTask(request, task) {
task.replay.pendingTasks--;
task.abortSet.delete(task);
erroredReplay(request, task.blockedBoundary, x, task.replay.nodes, task.replay.slots);
request.pendingRootTasks--;

if (request.pendingRootTasks === 0) {
request.onShellError = noop;
var onShellReady = request.onShellReady;
onShellReady();
}

request.allPendingTasks--;

if (request.allPendingTasks === 0) {
Expand Down
Loading

0 comments on commit 520f153

Please sign in to comment.