React DOM fizz instruction set external runtime
执行了全局副作用。
// This is a string so Closure's advanced compilation mode doesn't mangle it.
// 这是一个字符串,因此 Closure 的高级编译模式不会破坏它。
// These will be renamed to local references by the external-runtime-plugin.
// 这些将由 external-runtime-plugin 重命名为本地引用。
window['$RM'] = new Map();
window['$RB'] = [];
window['$RX'] = clientRenderBoundary;
window['$RV'] = revealCompletedBoundariesWithViewTransitions.bind(
null,
revealCompletedBoundaries,
);
window['$RC'] = completeBoundary;
window['$RR'] = completeBoundaryWithStyles;
window['$RS'] = completeSegment;
listenToFormSubmissionsForReplaying();
// Track the paint time of the shell.
// 跟踪外壳的绘制时间。
const entries = performance.getEntriesByType
? performance.getEntriesByType('paint')
: [];
if (entries.length > 0) {
// We might have already painted before this external runtime loaded. In that case we
// try to get the first paint from the performance metrics to avoid delaying further
// than necessary.
// 在此外部运行时加载之前,我们可能已经进行了绘制。在这种情况下,我们尝试从性能指标中获取第一次绘制,
// 以避免不必要的进一步延迟。
window['$RT'] = entries[0].startTime;
} else {
// Otherwise we wait for the next rAF for it.
// 否则我们等待下一个 rAF(requestAnimationFrame) 执行它。
requestAnimationFrame(() => {
window['$RT'] = performance.now();
});
}