From 5309f102854475030fb91ab732141411b49c1126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Wed, 17 May 2023 20:33:25 -0400 Subject: [PATCH] Remove Flight Relay DOM/Native (#26828) The bindings upstream in Relay has been removed so we don't need these builds anymore. The idea is to revisit an FB integration of Flight but it wouldn't use the Relay specific bindings. It's a bit unclear how it would look but likely more like the OSS version so not worth keeping these around. The `dom-relay` name also included the FB specific Fizz implementation of the streaming config so I renamed that to `dom-fb`. There's no Fizz implementation for Native yet so I just removed `native-relay`. We created a configurable fork for how to encode the output of Flight and the Relay implementation encoded it as JSON objects instead of strings/streams. The new implementation would likely be more stream-like and just encode it directly as string/binary chunks. So I removed those indirections so that this can just be declared inline in ReactFlightServer/Client. --- .eslintrc.js | 1 - packages/react-client/flight.js | 2 +- .../react-client/src/ReactFlightClient.js | 143 ++++++- .../src/ReactFlightClientConfigNoStream.js | 33 -- .../src/ReactFlightClientConfigStream.js | 23 -- .../src/ReactFlightClientStream.js | 146 ------- .../forks/ReactFlightClientConfig.custom.js | 4 - .../ReactFlightClientConfig.dom-browser.js | 1 - .../forks/ReactFlightClientConfig.dom-bun.js | 1 - ...eactFlightClientConfig.dom-edge-webpack.js | 1 - .../ReactFlightClientConfig.dom-legacy.js | 1 - ...eactFlightClientConfig.dom-node-webpack.js | 1 - .../forks/ReactFlightClientConfig.dom-node.js | 1 - .../ReactFlightClientConfig.dom-relay.js | 12 - .../ReactFlightClientConfig.native-relay.js | 11 - packages/react-native-renderer/package.json | 4 +- .../src/server/ReactFizzConfigNative.js | 359 ------------------ .../server/ReactFlightServerConfigNative.js | 19 - ...om-relay.js => ReactFiberConfig.dom-fb.js} | 0 .../forks/ReactFiberConfig.native-relay.js | 10 - .../package.json | 9 +- .../src/ReactDOMServerFB.js | 0 .../src/ReactServerStreamConfigFB.js | 0 .../ReactDOMServerFB-test.internal.js | 0 packages/react-server-dom-relay/index.js | 10 - packages/react-server-dom-relay/package.json | 17 - packages/react-server-dom-relay/server.js | 10 - .../src/ReactFlightClientConfigDOMRelay.js | 97 ----- .../src/ReactFlightDOMRelayClient.js | 61 --- .../src/ReactFlightDOMRelayProtocol.js | 36 -- .../src/ReactFlightDOMRelayServer.js | 44 --- .../src/ReactFlightServerConfigDOMRelay.js | 236 ------------ .../src/__mocks__/JSResourceReferenceImpl.js | 19 - .../ReactFlightDOMRelayClientIntegration.js | 22 -- .../ReactFlightDOMRelayServerIntegration.js | 20 - .../ReactFlightDOMRelay-test.internal.js | 240 ------------ .../src/ReactFlightDOMClientBrowser.js | 4 +- .../src/ReactFlightDOMClientEdge.js | 4 +- .../src/ReactFlightDOMClientNode.js | 6 +- packages/react-server-native-relay/server.js | 10 - .../src/ReactFlightClientConfigNativeRelay.js | 99 ----- .../src/ReactFlightNativeRelayClient.js | 56 --- .../src/ReactFlightNativeRelayProtocol.js | 34 -- .../src/ReactFlightNativeRelayServer.js | 32 -- .../src/ReactFlightServerConfigNativeRelay.js | 232 ----------- ...ReactFlightNativeRelayClientIntegration.js | 22 -- ...ReactFlightNativeRelayServerIntegration.js | 20 - .../ReactFlightNativeRelay-test.internal.js | 140 ------- ...actFlightNativeRelay-test.internal.js.snap | 25 -- .../react-server/src/ReactFlightServer.js | 127 ++++++- .../src/ReactFlightServerConfigStream.js | 174 --------- ...dom-relay.js => ReactFizzConfig.dom-fb.js} | 0 .../src/forks/ReactFizzConfig.native-relay.js | 14 - .../forks/ReactFlightServerConfig.custom.js | 8 +- .../ReactFlightServerConfig.dom-browser.js | 1 - .../forks/ReactFlightServerConfig.dom-bun.js | 1 - ...eactFlightServerConfig.dom-edge-webpack.js | 1 - .../ReactFlightServerConfig.dom-legacy.js | 1 - ...eactFlightServerConfig.dom-node-webpack.js | 1 - .../forks/ReactFlightServerConfig.dom-node.js | 1 - .../ReactFlightServerConfig.dom-relay.js | 11 - .../ReactFlightServerConfig.native-relay.js | 11 - .../forks/ReactServerStreamConfig.dom-fb.js} | 2 +- .../ReactServerStreamConfig.dom-relay.js | 10 - .../ReactServerStreamConfig.native-relay.js | 10 - scripts/flow/config/flowconfig | 1 - scripts/flow/createFlowConfigs.js | 22 +- scripts/flow/react-relay-hooks.js | 102 ----- scripts/rollup/bundles.js | 66 +--- scripts/rollup/packaging.js | 2 - scripts/shared/inlinedHostConfigs.js | 62 +-- yarn.lock | 8 - 72 files changed, 294 insertions(+), 2620 deletions(-) delete mode 100644 packages/react-client/src/ReactFlightClientConfigNoStream.js delete mode 100644 packages/react-client/src/ReactFlightClientConfigStream.js delete mode 100644 packages/react-client/src/ReactFlightClientStream.js delete mode 100644 packages/react-client/src/forks/ReactFlightClientConfig.dom-relay.js delete mode 100644 packages/react-client/src/forks/ReactFlightClientConfig.native-relay.js delete mode 100644 packages/react-native-renderer/src/server/ReactFizzConfigNative.js delete mode 100644 packages/react-native-renderer/src/server/ReactFlightServerConfigNative.js rename packages/react-reconciler/src/forks/{ReactFiberConfig.dom-relay.js => ReactFiberConfig.dom-fb.js} (100%) delete mode 100644 packages/react-reconciler/src/forks/ReactFiberConfig.native-relay.js rename packages/{react-server-native-relay => react-server-dom-fb}/package.json (54%) rename packages/{react-server-dom-relay => react-server-dom-fb}/src/ReactDOMServerFB.js (100%) rename packages/{react-server-dom-relay => react-server-dom-fb}/src/ReactServerStreamConfigFB.js (100%) rename packages/{react-server-dom-relay => react-server-dom-fb}/src/__tests__/ReactDOMServerFB-test.internal.js (100%) delete mode 100644 packages/react-server-dom-relay/index.js delete mode 100644 packages/react-server-dom-relay/package.json delete mode 100644 packages/react-server-dom-relay/server.js delete mode 100644 packages/react-server-dom-relay/src/ReactFlightClientConfigDOMRelay.js delete mode 100644 packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js delete mode 100644 packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js delete mode 100644 packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js delete mode 100644 packages/react-server-dom-relay/src/ReactFlightServerConfigDOMRelay.js delete mode 100644 packages/react-server-dom-relay/src/__mocks__/JSResourceReferenceImpl.js delete mode 100644 packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayClientIntegration.js delete mode 100644 packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayServerIntegration.js delete mode 100644 packages/react-server-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js delete mode 100644 packages/react-server-native-relay/server.js delete mode 100644 packages/react-server-native-relay/src/ReactFlightClientConfigNativeRelay.js delete mode 100644 packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js delete mode 100644 packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js delete mode 100644 packages/react-server-native-relay/src/ReactFlightNativeRelayServer.js delete mode 100644 packages/react-server-native-relay/src/ReactFlightServerConfigNativeRelay.js delete mode 100644 packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayClientIntegration.js delete mode 100644 packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayServerIntegration.js delete mode 100644 packages/react-server-native-relay/src/__tests__/ReactFlightNativeRelay-test.internal.js delete mode 100644 packages/react-server-native-relay/src/__tests__/__snapshots__/ReactFlightNativeRelay-test.internal.js.snap delete mode 100644 packages/react-server/src/ReactFlightServerConfigStream.js rename packages/react-server/src/forks/{ReactFizzConfig.dom-relay.js => ReactFizzConfig.dom-fb.js} (100%) delete mode 100644 packages/react-server/src/forks/ReactFizzConfig.native-relay.js delete mode 100644 packages/react-server/src/forks/ReactFlightServerConfig.dom-relay.js delete mode 100644 packages/react-server/src/forks/ReactFlightServerConfig.native-relay.js rename packages/{react-server-native-relay/index.js => react-server/src/forks/ReactServerStreamConfig.dom-fb.js} (72%) delete mode 100644 packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js delete mode 100644 packages/react-server/src/forks/ReactServerStreamConfig.native-relay.js delete mode 100644 scripts/flow/react-relay-hooks.js diff --git a/.eslintrc.js b/.eslintrc.js index 53e01fe8c16a7..12d6f14fa86e9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -416,7 +416,6 @@ module.exports = { { files: [ 'packages/react-native-renderer/**/*.js', - 'packages/react-server-native-relay/**/*.js', ], globals: { nativeFabricUIManager: 'readonly', diff --git a/packages/react-client/flight.js b/packages/react-client/flight.js index 1e6cdeb433fb5..9089ae80c70f3 100644 --- a/packages/react-client/flight.js +++ b/packages/react-client/flight.js @@ -7,4 +7,4 @@ * @flow */ -export * from './src/ReactFlightClientStream'; +export * from './src/ReactFlightClient'; diff --git a/packages/react-client/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js index 4fdbc0d5cea8a..3d06c5e0ded10 100644 --- a/packages/react-client/src/ReactFlightClient.js +++ b/packages/react-client/src/ReactFlightClient.js @@ -13,9 +13,8 @@ import type {LazyComponent} from 'react/src/ReactLazy'; import type { ClientReference, ClientReferenceMetadata, - UninitializedModel, - Response, SSRManifest, + StringDecoder, } from './ReactFlightClientConfig'; import type {HintModel} from 'react-server/src/ReactFlightServerConfig'; @@ -26,8 +25,11 @@ import { resolveClientReference, preloadModule, requireModule, - parseModel, dispatchHint, + readPartialStringChunk, + readFinalStringChunk, + supportsBinaryStreams, + createStringDecoder, } from './ReactFlightClientConfig'; import { @@ -41,6 +43,8 @@ import {getOrCreateServerContext} from 'shared/ReactServerContextRegistry'; export type {CallServerCallback}; +type UninitializedModel = string; + export type JSONValue = | number | null @@ -158,15 +162,15 @@ Chunk.prototype.then = function ( } }; -export type ResponseBase = { +export type Response = { _bundlerConfig: SSRManifest, _callServer: CallServerCallback, _chunks: Map>, - ... + _partialRow: string, + _fromJSON: (key: string, value: JSONValue) => any, + _stringDecoder: StringDecoder, }; -export type {Response}; - function readChunk(chunk: SomeChunk): T { // If we have resolved content, we try to initialize it first which // might put us back into one of the other states. @@ -512,7 +516,7 @@ function createServerReferenceProxy, T>( return proxy; } -export function parseModelString( +function parseModelString( response: Response, parentObject: Object, key: string, @@ -632,7 +636,7 @@ export function parseModelString( return value; } -export function parseModelTuple( +function parseModelTuple( response: Response, value: {+[key: string]: JSONValue} | $ReadOnlyArray, ): any { @@ -656,17 +660,25 @@ function missingCall() { export function createResponse( bundlerConfig: SSRManifest, callServer: void | CallServerCallback, -): ResponseBase { +): Response { const chunks: Map> = new Map(); - const response = { + const response: Response = { _bundlerConfig: bundlerConfig, _callServer: callServer !== undefined ? callServer : missingCall, _chunks: chunks, + _partialRow: '', + _stringDecoder: (null: any), + _fromJSON: (null: any), }; + if (supportsBinaryStreams) { + response._stringDecoder = createStringDecoder(); + } + // Don't inline this call because it causes closure to outline the call above. + response._fromJSON = createFromJSONCallback(response); return response; } -export function resolveModel( +function resolveModel( response: Response, id: number, model: UninitializedModel, @@ -680,7 +692,7 @@ export function resolveModel( } } -export function resolveModule( +function resolveModule( response: Response, id: number, model: UninitializedModel, @@ -729,7 +741,7 @@ export function resolveModule( } type ErrorWithDigest = Error & {digest?: string}; -export function resolveErrorProd( +function resolveErrorProd( response: Response, id: number, digest: string, @@ -758,7 +770,7 @@ export function resolveErrorProd( } } -export function resolveErrorDev( +function resolveErrorDev( response: Response, id: number, digest: string, @@ -789,7 +801,7 @@ export function resolveErrorDev( } } -export function resolveHint( +function resolveHint( response: Response, code: string, model: UninitializedModel, @@ -798,6 +810,105 @@ export function resolveHint( dispatchHint(code, hintModel); } +function processFullRow(response: Response, row: string): void { + if (row === '') { + return; + } + const colon = row.indexOf(':', 0); + const id = parseInt(row.slice(0, colon), 16); + const tag = row[colon + 1]; + // When tags that are not text are added, check them here before + // parsing the row as text. + // switch (tag) { + // } + switch (tag) { + case 'I': { + resolveModule(response, id, row.slice(colon + 2)); + return; + } + case 'H': { + const code = row[colon + 2]; + resolveHint(response, code, row.slice(colon + 3)); + return; + } + case 'E': { + const errorInfo = JSON.parse(row.slice(colon + 2)); + if (__DEV__) { + resolveErrorDev( + response, + id, + errorInfo.digest, + errorInfo.message, + errorInfo.stack, + ); + } else { + resolveErrorProd(response, id, errorInfo.digest); + } + return; + } + default: { + // We assume anything else is JSON. + resolveModel(response, id, row.slice(colon + 1)); + return; + } + } +} + +export function processStringChunk( + response: Response, + chunk: string, + offset: number, +): void { + let linebreak = chunk.indexOf('\n', offset); + while (linebreak > -1) { + const fullrow = response._partialRow + chunk.slice(offset, linebreak); + processFullRow(response, fullrow); + response._partialRow = ''; + offset = linebreak + 1; + linebreak = chunk.indexOf('\n', offset); + } + response._partialRow += chunk.slice(offset); +} + +export function processBinaryChunk( + response: Response, + chunk: Uint8Array, +): void { + if (!supportsBinaryStreams) { + throw new Error("This environment don't support binary chunks."); + } + const stringDecoder = response._stringDecoder; + let linebreak = chunk.indexOf(10); // newline + while (linebreak > -1) { + const fullrow = + response._partialRow + + readFinalStringChunk(stringDecoder, chunk.subarray(0, linebreak)); + processFullRow(response, fullrow); + response._partialRow = ''; + chunk = chunk.subarray(linebreak + 1); + linebreak = chunk.indexOf(10); // newline + } + response._partialRow += readPartialStringChunk(stringDecoder, chunk); +} + +function parseModel(response: Response, json: UninitializedModel): T { + return JSON.parse(json, response._fromJSON); +} + +function createFromJSONCallback(response: Response) { + // $FlowFixMe[missing-this-annot] + return function (key: string, value: JSONValue) { + if (typeof value === 'string') { + // We can't use .bind here because we need the "this" value. + return parseModelString(response, this, key, value); + } + if (typeof value === 'object' && value !== null) { + return parseModelTuple(response, value); + } + return value; + }; +} + export function close(response: Response): void { // In case there are any remaining unresolved chunks, they won't // be resolved now. So we need to issue an error to those. diff --git a/packages/react-client/src/ReactFlightClientConfigNoStream.js b/packages/react-client/src/ReactFlightClientConfigNoStream.js deleted file mode 100644 index 37b85f2ed1273..0000000000000 --- a/packages/react-client/src/ReactFlightClientConfigNoStream.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export type StringDecoder = void; - -export const supportsBinaryStreams = false; - -export function createStringDecoder(): void { - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error('Should never be called'); -} - -export function readPartialStringChunk( - decoder: StringDecoder, - buffer: Uint8Array, -): string { - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error('Should never be called'); -} - -export function readFinalStringChunk( - decoder: StringDecoder, - buffer: Uint8Array, -): string { - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error('Should never be called'); -} diff --git a/packages/react-client/src/ReactFlightClientConfigStream.js b/packages/react-client/src/ReactFlightClientConfigStream.js deleted file mode 100644 index 62a8b248d78c7..0000000000000 --- a/packages/react-client/src/ReactFlightClientConfigStream.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {ResponseBase} from './ReactFlightClient'; -import type {StringDecoder} from './ReactFlightClientConfig'; - -export type Response = ResponseBase & { - _partialRow: string, - _fromJSON: (key: string, value: JSONValue) => any, - _stringDecoder: StringDecoder, -}; - -export type UninitializedModel = string; - -export function parseModel(response: Response, json: UninitializedModel): T { - return JSON.parse(json, response._fromJSON); -} diff --git a/packages/react-client/src/ReactFlightClientStream.js b/packages/react-client/src/ReactFlightClientStream.js deleted file mode 100644 index 2c4c29919db6c..0000000000000 --- a/packages/react-client/src/ReactFlightClientStream.js +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {CallServerCallback} from './ReactFlightClient'; -import type {Response} from './ReactFlightClientConfigStream'; -import type {SSRManifest} from './ReactFlightClientConfig'; - -import { - resolveModule, - resolveModel, - resolveErrorProd, - resolveErrorDev, - resolveHint, - createResponse as createResponseBase, - parseModelString, - parseModelTuple, -} from './ReactFlightClient'; - -import { - readPartialStringChunk, - readFinalStringChunk, - supportsBinaryStreams, - createStringDecoder, -} from './ReactFlightClientConfig'; - -export type {Response}; - -function processFullRow(response: Response, row: string): void { - if (row === '') { - return; - } - const colon = row.indexOf(':', 0); - const id = parseInt(row.slice(0, colon), 16); - const tag = row[colon + 1]; - // When tags that are not text are added, check them here before - // parsing the row as text. - // switch (tag) { - // } - switch (tag) { - case 'I': { - resolveModule(response, id, row.slice(colon + 2)); - return; - } - case 'H': { - const code = row[colon + 2]; - resolveHint(response, code, row.slice(colon + 3)); - return; - } - case 'E': { - const errorInfo = JSON.parse(row.slice(colon + 2)); - if (__DEV__) { - resolveErrorDev( - response, - id, - errorInfo.digest, - errorInfo.message, - errorInfo.stack, - ); - } else { - resolveErrorProd(response, id, errorInfo.digest); - } - return; - } - default: { - // We assume anything else is JSON. - resolveModel(response, id, row.slice(colon + 1)); - return; - } - } -} - -export function processStringChunk( - response: Response, - chunk: string, - offset: number, -): void { - let linebreak = chunk.indexOf('\n', offset); - while (linebreak > -1) { - const fullrow = response._partialRow + chunk.slice(offset, linebreak); - processFullRow(response, fullrow); - response._partialRow = ''; - offset = linebreak + 1; - linebreak = chunk.indexOf('\n', offset); - } - response._partialRow += chunk.slice(offset); -} - -export function processBinaryChunk( - response: Response, - chunk: Uint8Array, -): void { - if (!supportsBinaryStreams) { - throw new Error("This environment don't support binary chunks."); - } - const stringDecoder = response._stringDecoder; - let linebreak = chunk.indexOf(10); // newline - while (linebreak > -1) { - const fullrow = - response._partialRow + - readFinalStringChunk(stringDecoder, chunk.subarray(0, linebreak)); - processFullRow(response, fullrow); - response._partialRow = ''; - chunk = chunk.subarray(linebreak + 1); - linebreak = chunk.indexOf(10); // newline - } - response._partialRow += readPartialStringChunk(stringDecoder, chunk); -} - -function createFromJSONCallback(response: Response) { - // $FlowFixMe[missing-this-annot] - return function (key: string, value: JSONValue) { - if (typeof value === 'string') { - // We can't use .bind here because we need the "this" value. - return parseModelString(response, this, key, value); - } - if (typeof value === 'object' && value !== null) { - return parseModelTuple(response, value); - } - return value; - }; -} - -export function createResponse( - bundlerConfig: SSRManifest, - callServer: void | CallServerCallback, -): Response { - // NOTE: CHECK THE COMPILER OUTPUT EACH TIME YOU CHANGE THIS. - // It should be inlined to one object literal but minor changes can break it. - const stringDecoder = supportsBinaryStreams ? createStringDecoder() : null; - const response: any = createResponseBase(bundlerConfig, callServer); - response._partialRow = ''; - if (supportsBinaryStreams) { - response._stringDecoder = stringDecoder; - } - // Don't inline this call because it causes closure to outline the call above. - response._fromJSON = createFromJSONCallback(response); - return response; -} - -export {reportGlobalError, getRoot, close} from './ReactFlightClient'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js index d8a49b459a0d8..477ecd6e15b0c 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.custom.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.custom.js @@ -25,7 +25,6 @@ declare var $$$config: any; -export type Response = any; export opaque type SSRManifest = mixed; export opaque type ServerManifest = mixed; export opaque type ServerReferenceId = string; @@ -39,9 +38,6 @@ export const dispatchHint = $$$config.dispatchHint; export opaque type Source = mixed; -export type UninitializedModel = string; -export const parseModel = $$$config.parseModel; - export opaque type StringDecoder = mixed; // eslint-disable-line no-undef export const supportsBinaryStreams = $$$config.supportsBinaryStreams; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js index 8de1c06df33fc..a51bc8f1c2f77 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-browser.js @@ -8,6 +8,5 @@ */ export * from 'react-client/src/ReactFlightClientConfigBrowser'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js index a1c0a72c129b1..64200788f1966 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js @@ -8,7 +8,6 @@ */ export * from 'react-client/src/ReactFlightClientConfigBrowser'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; export type Response = any; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js index 8de1c06df33fc..a51bc8f1c2f77 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-webpack.js @@ -8,6 +8,5 @@ */ export * from 'react-client/src/ReactFlightClientConfigBrowser'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js index 8de1c06df33fc..a51bc8f1c2f77 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-legacy.js @@ -8,6 +8,5 @@ */ export * from 'react-client/src/ReactFlightClientConfigBrowser'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-webpack.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-webpack.js index dba506435584e..4529bdb4e1fea 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-webpack.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node-webpack.js @@ -8,6 +8,5 @@ */ export * from 'react-client/src/ReactFlightClientConfigNode'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightClientConfigWebpackBundler'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js index a8aaffa969c4a..e4098fad781fc 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.dom-node.js @@ -8,6 +8,5 @@ */ export * from 'react-client/src/ReactFlightClientConfigNode'; -export * from 'react-client/src/ReactFlightClientConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightClientConfigNodeBundler'; export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.dom-relay.js b/packages/react-client/src/forks/ReactFlightClientConfig.dom-relay.js deleted file mode 100644 index 17540fb203718..0000000000000 --- a/packages/react-client/src/forks/ReactFlightClientConfig.dom-relay.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-server-dom-relay/src/ReactFlightClientConfigDOMRelay'; -export * from '../ReactFlightClientConfigNoStream'; -export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.native-relay.js b/packages/react-client/src/forks/ReactFlightClientConfig.native-relay.js deleted file mode 100644 index b0110b5ffe687..0000000000000 --- a/packages/react-client/src/forks/ReactFlightClientConfig.native-relay.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-server-native-relay/src/ReactFlightClientConfigNativeRelay'; -export * from '../ReactFlightClientConfigNoStream'; diff --git a/packages/react-native-renderer/package.json b/packages/react-native-renderer/package.json index 9df888773f2ca..b27292c1f7b9c 100644 --- a/packages/react-native-renderer/package.json +++ b/packages/react-native-renderer/package.json @@ -8,9 +8,9 @@ "directory": "packages/react-native-renderer" }, "dependencies": { - "scheduler": "^0.11.0" + "scheduler": "^0.23.0" }, "peerDependencies": { - "react": "^17.0.0" + "react": "^18.0.0" } } diff --git a/packages/react-native-renderer/src/server/ReactFizzConfigNative.js b/packages/react-native-renderer/src/server/ReactFizzConfigNative.js deleted file mode 100644 index 61f746b4b987d..0000000000000 --- a/packages/react-native-renderer/src/server/ReactFizzConfigNative.js +++ /dev/null @@ -1,359 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {ReactNodeList} from 'shared/ReactTypes'; - -import type { - Destination, - Chunk, - PrecomputedChunk, -} from 'react-server/src/ReactServerStreamConfig'; - -import { - writeChunk, - writeChunkAndReturn, - stringToChunk, - stringToPrecomputedChunk, -} from 'react-server/src/ReactServerStreamConfig'; - -export const isPrimaryRenderer = true; - -// Every list of children or string is null terminated. -const END_TAG = 0; -// Tree node tags. -const INSTANCE_TAG = 1; -const PLACEHOLDER_TAG = 2; -const SUSPENSE_PENDING_TAG = 3; -const SUSPENSE_COMPLETE_TAG = 4; -const SUSPENSE_CLIENT_RENDER_TAG = 5; -// Command tags. -const SEGMENT_TAG = 1; -const SUSPENSE_UPDATE_TO_COMPLETE_TAG = 2; -const SUSPENSE_UPDATE_TO_CLIENT_RENDER_TAG = 3; - -const END = new Uint8Array(1); -END[0] = END_TAG; -const PLACEHOLDER = new Uint8Array(1); -PLACEHOLDER[0] = PLACEHOLDER_TAG; -const INSTANCE = new Uint8Array(1); -INSTANCE[0] = INSTANCE_TAG; -const SUSPENSE_PENDING = new Uint8Array(1); -SUSPENSE_PENDING[0] = SUSPENSE_PENDING_TAG; -const SUSPENSE_COMPLETE = new Uint8Array(1); -SUSPENSE_COMPLETE[0] = SUSPENSE_COMPLETE_TAG; -const SUSPENSE_CLIENT_RENDER = new Uint8Array(1); -SUSPENSE_CLIENT_RENDER[0] = SUSPENSE_CLIENT_RENDER_TAG; - -const SEGMENT = new Uint8Array(1); -SEGMENT[0] = SEGMENT_TAG; -const SUSPENSE_UPDATE_TO_COMPLETE = new Uint8Array(1); -SUSPENSE_UPDATE_TO_COMPLETE[0] = SUSPENSE_UPDATE_TO_COMPLETE_TAG; -const SUSPENSE_UPDATE_TO_CLIENT_RENDER = new Uint8Array(1); -SUSPENSE_UPDATE_TO_CLIENT_RENDER[0] = SUSPENSE_UPDATE_TO_CLIENT_RENDER_TAG; - -export type Resources = void; -export type BoundaryResources = void; - -// Per response, -export type ResponseState = { - nextSuspenseID: number, -}; - -// Allows us to keep track of what we've already written so we can refer back to it. -export function createResponseState(): ResponseState { - return { - nextSuspenseID: 0, - }; -} - -// isInAParentText -export type FormatContext = boolean; - -export function createRootFormatContext(): FormatContext { - return false; -} - -export function getChildFormatContext( - parentContext: FormatContext, - type: string, - props: Object, -): FormatContext { - const prevIsInAParentText = parentContext; - const isInAParentText = - type === 'AndroidTextInput' || // Android - type === 'RCTMultilineTextInputView' || // iOS - type === 'RCTSinglelineTextInputView' || // iOS - type === 'RCTText' || - type === 'RCTVirtualText'; - - if (prevIsInAParentText !== isInAParentText) { - return isInAParentText; - } else { - return parentContext; - } -} - -// This object is used to lazily reuse the ID of the first generated node, or assign one. -// This is very specific to DOM where we can't assign an ID to. -export type SuspenseBoundaryID = number; - -export const UNINITIALIZED_SUSPENSE_BOUNDARY_ID = -1; - -export function assignSuspenseBoundaryID( - responseState: ResponseState, -): SuspenseBoundaryID { - return responseState.nextSuspenseID++; -} - -export function makeId( - responseState: ResponseState, - treeId: string, - localId: number, -): string { - throw new Error('Not implemented'); -} - -const RAW_TEXT = stringToPrecomputedChunk('RCTRawText'); - -export function pushTextInstance( - target: Array, - text: string, - responseState: ResponseState, - // This Renderer does not use this argument - textEmbedded: boolean, -): boolean { - target.push( - INSTANCE, - RAW_TEXT, // Type - END, // Null terminated type string - // TODO: props { text: text } - END, // End of children - ); - return false; -} - -export function pushStartInstance( - target: Array, - type: string, - props: Object, - resources: Resources, - responseState: ResponseState, - formatContext: FormatContext, - textEmbedded: boolean, -): ReactNodeList { - target.push( - INSTANCE, - stringToChunk(type), - END, // Null terminated type string - // TODO: props - ); - return props.children; -} - -export function pushEndInstance( - target: Array, - type: string, - props: Object, - responseState: ResponseState, - formatContext: FormatContext, -): void { - target.push(END); -} - -// In this Renderer this is a noop -export function pushSegmentFinale( - target: Array, - responseState: ResponseState, - lastPushedText: boolean, - textEmbedded: boolean, -): void {} - -export function writeCompletedRoot( - destination: Destination, - responseState: ResponseState, -): boolean { - return true; -} - -// IDs are formatted as little endian Uint16 -function formatID(id: number): Uint8Array { - if (id > 0xffff) { - throw new Error( - 'More boundaries or placeholders than we expected to ever emit.', - ); - } - const buffer = new Uint8Array(2); - buffer[0] = (id >>> 8) & 0xff; - buffer[1] = id & 0xff; - return buffer; -} - -// Structural Nodes - -// A placeholder is a node inside a hidden partial tree that can be filled in later, but before -// display. It's never visible to users. -export function writePlaceholder( - destination: Destination, - responseState: ResponseState, - id: number, -): boolean { - writeChunk(destination, PLACEHOLDER); - return writeChunkAndReturn(destination, formatID(id)); -} - -// Suspense boundaries are encoded as comments. -export function writeStartCompletedSuspenseBoundary( - destination: Destination, - responseState: ResponseState, -): boolean { - return writeChunkAndReturn(destination, SUSPENSE_COMPLETE); -} - -export function pushStartCompletedSuspenseBoundary( - target: Array, -): void { - target.push(SUSPENSE_COMPLETE); -} - -export function writeStartPendingSuspenseBoundary( - destination: Destination, - responseState: ResponseState, - id: SuspenseBoundaryID, -): boolean { - writeChunk(destination, SUSPENSE_PENDING); - return writeChunkAndReturn(destination, formatID(id)); -} -export function writeStartClientRenderedSuspenseBoundary( - destination: Destination, - responseState: ResponseState, - // TODO: encode error for native - errorDigest: ?string, - errorMessage: ?string, - errorComponentStack: ?string, -): boolean { - return writeChunkAndReturn(destination, SUSPENSE_CLIENT_RENDER); -} -export function writeEndCompletedSuspenseBoundary( - destination: Destination, - responseState: ResponseState, -): boolean { - return writeChunkAndReturn(destination, END); -} -export function pushEndCompletedSuspenseBoundary( - target: Array, -): void { - target.push(END); -} -export function writeEndPendingSuspenseBoundary( - destination: Destination, - responseState: ResponseState, -): boolean { - return writeChunkAndReturn(destination, END); -} -export function writeEndClientRenderedSuspenseBoundary( - destination: Destination, - responseState: ResponseState, -): boolean { - return writeChunkAndReturn(destination, END); -} - -export function writeStartSegment( - destination: Destination, - responseState: ResponseState, - formatContext: FormatContext, - id: number, -): boolean { - writeChunk(destination, SEGMENT); - return writeChunkAndReturn(destination, formatID(id)); -} -export function writeEndSegment( - destination: Destination, - formatContext: FormatContext, -): boolean { - return writeChunkAndReturn(destination, END); -} - -// Instruction Set - -export function writeCompletedSegmentInstruction( - destination: Destination, - responseState: ResponseState, - contentSegmentID: number, -): boolean { - // We don't need to emit this. Instead the client will keep track of pending placeholders. - // TODO: Returning true here is not correct. Avoid having to call this function at all. - return true; -} - -export function writeCompletedBoundaryInstruction( - destination: Destination, - responseState: ResponseState, - boundaryID: SuspenseBoundaryID, - contentSegmentID: number, - resources: BoundaryResources, -): boolean { - writeChunk(destination, SUSPENSE_UPDATE_TO_COMPLETE); - writeChunk(destination, formatID(boundaryID)); - return writeChunkAndReturn(destination, formatID(contentSegmentID)); -} - -export function writeClientRenderBoundaryInstruction( - destination: Destination, - responseState: ResponseState, - boundaryID: SuspenseBoundaryID, - // TODO: encode error for native - errorDigest: ?string, - errorMessage: ?string, - errorComponentStack: ?string, -): boolean { - writeChunk(destination, SUSPENSE_UPDATE_TO_CLIENT_RENDER); - return writeChunkAndReturn(destination, formatID(boundaryID)); -} - -export function writePreamble( - destination: Destination, - resources: Resources, - responseState: ResponseState, - willFlushAllSegments: boolean, -) {} - -export function writeHoistables( - destination: Destination, - resources: Resources, - responseState: ResponseState, -) {} - -export function writePostamble( - destination: Destination, - responseState: ResponseState, -) {} - -export function hoistResources( - resources: Resources, - boundaryResources: BoundaryResources, -) {} - -export function prepareHostDispatcher() {} -export function createResources() {} -export function createBoundaryResources() {} -export function setCurrentlyRenderingBoundaryResourcesTarget( - resources: Resources, - boundaryResources: ?BoundaryResources, -) {} - -export function writeResourcesForBoundary( - destination: Destination, - boundaryResources: BoundaryResources, - responseState: ResponseState, -): boolean { - return true; -} - -export type TransitionStatus = mixed; -export const NotPendingTransition: TransitionStatus = null; diff --git a/packages/react-native-renderer/src/server/ReactFlightServerConfigNative.js b/packages/react-native-renderer/src/server/ReactFlightServerConfigNative.js deleted file mode 100644 index e13d4c5ab7205..0000000000000 --- a/packages/react-native-renderer/src/server/ReactFlightServerConfigNative.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export const isPrimaryRenderer = true; - -export type Hints = null; -export type HintModel = ''; - -export function createHints(): null { - return null; -} - -export function prepareHostDispatcher() {} diff --git a/packages/react-reconciler/src/forks/ReactFiberConfig.dom-relay.js b/packages/react-reconciler/src/forks/ReactFiberConfig.dom-fb.js similarity index 100% rename from packages/react-reconciler/src/forks/ReactFiberConfig.dom-relay.js rename to packages/react-reconciler/src/forks/ReactFiberConfig.dom-fb.js diff --git a/packages/react-reconciler/src/forks/ReactFiberConfig.native-relay.js b/packages/react-reconciler/src/forks/ReactFiberConfig.native-relay.js deleted file mode 100644 index f1787a68e845b..0000000000000 --- a/packages/react-reconciler/src/forks/ReactFiberConfig.native-relay.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-native-renderer/src/ReactFiberConfigFabric'; diff --git a/packages/react-server-native-relay/package.json b/packages/react-server-dom-fb/package.json similarity index 54% rename from packages/react-server-native-relay/package.json rename to packages/react-server-dom-fb/package.json index e97b2f9b2be77..c6c70b12a7cc5 100644 --- a/packages/react-server-native-relay/package.json +++ b/packages/react-server-dom-fb/package.json @@ -1,16 +1,17 @@ { - "name": "react-server-native-relay", + "name": "react-server-dom-fb", "version": "0.1.0", "private": true, "repository": { "type" : "git", "url" : "https://github.com/facebook/react.git", - "directory": "packages/react-server-native-relay" + "directory": "packages/react-server-dom-fb" }, "dependencies": { - "scheduler": "^0.11.0" + "scheduler": "^0.23.0" }, "peerDependencies": { - "react": "^17.0.0" + "react": "^18.0.0", + "react-dom": "^18.0.0" } } diff --git a/packages/react-server-dom-relay/src/ReactDOMServerFB.js b/packages/react-server-dom-fb/src/ReactDOMServerFB.js similarity index 100% rename from packages/react-server-dom-relay/src/ReactDOMServerFB.js rename to packages/react-server-dom-fb/src/ReactDOMServerFB.js diff --git a/packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js b/packages/react-server-dom-fb/src/ReactServerStreamConfigFB.js similarity index 100% rename from packages/react-server-dom-relay/src/ReactServerStreamConfigFB.js rename to packages/react-server-dom-fb/src/ReactServerStreamConfigFB.js diff --git a/packages/react-server-dom-relay/src/__tests__/ReactDOMServerFB-test.internal.js b/packages/react-server-dom-fb/src/__tests__/ReactDOMServerFB-test.internal.js similarity index 100% rename from packages/react-server-dom-relay/src/__tests__/ReactDOMServerFB-test.internal.js rename to packages/react-server-dom-fb/src/__tests__/ReactDOMServerFB-test.internal.js diff --git a/packages/react-server-dom-relay/index.js b/packages/react-server-dom-relay/index.js deleted file mode 100644 index b7eb738af7ae6..0000000000000 --- a/packages/react-server-dom-relay/index.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from './src/ReactFlightDOMRelayClient'; diff --git a/packages/react-server-dom-relay/package.json b/packages/react-server-dom-relay/package.json deleted file mode 100644 index 5fef49b1d1b75..0000000000000 --- a/packages/react-server-dom-relay/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "react-server-dom-relay", - "version": "0.1.0", - "private": true, - "repository": { - "type" : "git", - "url" : "https://github.com/facebook/react.git", - "directory": "packages/react-server-dom-relay" - }, - "dependencies": { - "scheduler": "^0.11.0" - }, - "peerDependencies": { - "react": "^17.0.0", - "react-dom": "^17.0.0" - } -} diff --git a/packages/react-server-dom-relay/server.js b/packages/react-server-dom-relay/server.js deleted file mode 100644 index 6d41820307b77..0000000000000 --- a/packages/react-server-dom-relay/server.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from './src/ReactFlightDOMRelayServer'; diff --git a/packages/react-server-dom-relay/src/ReactFlightClientConfigDOMRelay.js b/packages/react-server-dom-relay/src/ReactFlightClientConfigDOMRelay.js deleted file mode 100644 index 8b831bbe88814..0000000000000 --- a/packages/react-server-dom-relay/src/ReactFlightClientConfigDOMRelay.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {JSONValue, ResponseBase} from 'react-client/src/ReactFlightClient'; - -import type {JSResourceReference} from 'JSResourceReference'; - -import type {ClientReferenceMetadata} from 'ReactFlightDOMRelayClientIntegration'; - -export type ClientReference = JSResourceReference; - -import { - parseModelString, - parseModelTuple, -} from 'react-client/src/ReactFlightClient'; - -export { - preloadModule, - requireModule, -} from 'ReactFlightDOMRelayClientIntegration'; - -import {resolveClientReference as resolveClientReferenceImpl} from 'ReactFlightDOMRelayClientIntegration'; - -import isArray from 'shared/isArray'; - -export type {ClientReferenceMetadata} from 'ReactFlightDOMRelayClientIntegration'; - -export type SSRManifest = null; -export type ServerManifest = null; -export type ServerReferenceId = string; - -export type UninitializedModel = JSONValue; - -export type Response = ResponseBase; - -export function resolveClientReference( - bundlerConfig: SSRManifest, - metadata: ClientReferenceMetadata, -): ClientReference { - return resolveClientReferenceImpl(metadata); -} - -export function resolveServerReference( - bundlerConfig: ServerManifest, - id: ServerReferenceId, -): ClientReference { - throw new Error('Not implemented.'); -} - -function parseModelRecursively( - response: Response, - parentObj: {+[key: string]: JSONValue} | $ReadOnlyArray, - key: string, - value: JSONValue, -): $FlowFixMe { - if (typeof value === 'string') { - return parseModelString(response, parentObj, key, value); - } - if (typeof value === 'object' && value !== null) { - if (isArray(value)) { - const parsedValue: Array<$FlowFixMe> = []; - for (let i = 0; i < value.length; i++) { - (parsedValue: any)[i] = parseModelRecursively( - response, - value, - '' + i, - value[i], - ); - } - return parseModelTuple(response, parsedValue); - } else { - const parsedValue = {}; - for (const innerKey in value) { - (parsedValue: any)[innerKey] = parseModelRecursively( - response, - value, - innerKey, - value[innerKey], - ); - } - return parsedValue; - } - } - return value; -} - -const dummy = {}; - -export function parseModel(response: Response, json: UninitializedModel): T { - return (parseModelRecursively(response, dummy, '', json): any); -} diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js deleted file mode 100644 index 4268993e76faf..0000000000000 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayClient.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {RowEncoding} from './ReactFlightDOMRelayProtocol'; - -import type {Response} from 'react-client/src/ReactFlightClient'; - -import { - createResponse, - resolveModel, - resolveModule, - resolveErrorDev, - resolveErrorProd, - resolveHint, - close, - getRoot, -} from 'react-client/src/ReactFlightClient'; - -export {createResponse, close, getRoot}; - -export function resolveRow(response: Response, chunk: RowEncoding): void { - if (chunk[0] === 'O') { - // $FlowFixMe[incompatible-call] unable to refine on array indices - resolveModel(response, chunk[1], chunk[2]); - } else if (chunk[0] === 'I') { - // $FlowFixMe[incompatible-call] unable to refine on array indices - resolveModule(response, chunk[1], chunk[2]); - } else if (chunk[0] === 'H') { - // $FlowFixMe[incompatible-call] unable to refine on array indices - resolveHint(response, chunk[1], chunk[2]); - } else { - if (__DEV__) { - resolveErrorDev( - response, - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - chunk[1], - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[prop-missing] - // $FlowFixMe[incompatible-use] - chunk[2].digest, - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - chunk[2].message || '', - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - chunk[2].stack || '', - ); - } else { - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[prop-missing] - // $FlowFixMe[incompatible-use] - resolveErrorProd(response, chunk[1], chunk[2].digest); - } - } -} diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js deleted file mode 100644 index 5e7ae5ae8784c..0000000000000 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayProtocol.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {HintModel} from 'react-server/src/ReactFlightServerConfig'; -import type {ClientReferenceMetadata} from 'ReactFlightDOMRelayServerIntegration'; - -export type JSONValue = - | string - | number - | boolean - | null - | {+[key: string]: JSONValue} - | $ReadOnlyArray; - -export type RowEncoding = - | ['O', number, JSONValue] - | ['I', number, ClientReferenceMetadata] - | ['H', string, HintModel] - | ['P', number, string] - | ['S', number, string] - | [ - 'E', - number, - { - digest: string, - message?: string, - stack?: string, - ... - }, - ]; diff --git a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js b/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js deleted file mode 100644 index e5255fbf894a9..0000000000000 --- a/packages/react-server-dom-relay/src/ReactFlightDOMRelayServer.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {ReactClientValue} from 'react-server/src/ReactFlightServer'; -import type { - ClientManifest, - Destination, -} from './ReactFlightServerConfigDOMRelay'; - -import { - createRequest, - startWork, - startFlowing, -} from 'react-server/src/ReactFlightServer'; - -type Options = { - onError?: (error: mixed) => void, - identifierPrefix?: string, -}; - -function render( - model: ReactClientValue, - destination: Destination, - config: ClientManifest, - options?: Options, -): void { - const request = createRequest( - model, - config, - options ? options.onError : undefined, - undefined, // not currently set up to supply context overrides - options ? options.identifierPrefix : undefined, - ); - startWork(request); - startFlowing(request, destination); -} - -export {render}; diff --git a/packages/react-server-dom-relay/src/ReactFlightServerConfigDOMRelay.js b/packages/react-server-dom-relay/src/ReactFlightServerConfigDOMRelay.js deleted file mode 100644 index e270e543ab95b..0000000000000 --- a/packages/react-server-dom-relay/src/ReactFlightServerConfigDOMRelay.js +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {HintModel} from 'react-server/src/ReactFlightServerConfig'; -import type {RowEncoding, JSONValue} from './ReactFlightDOMRelayProtocol'; - -import type { - Request, - ReactClientValue, -} from 'react-server/src/ReactFlightServer'; - -import type {JSResourceReference} from 'JSResourceReference'; -import JSResourceReferenceImpl from 'JSResourceReferenceImpl'; - -import hasOwnProperty from 'shared/hasOwnProperty'; -import isArray from 'shared/isArray'; - -export type ClientReference = JSResourceReference; -export type ServerReference = T; -export type ServerReferenceId = {}; - -import type { - Destination, - BundlerConfig as ClientManifest, - ClientReferenceMetadata, -} from 'ReactFlightDOMRelayServerIntegration'; - -import {resolveModelToJSON} from 'react-server/src/ReactFlightServer'; - -import { - emitRow, - resolveClientReferenceMetadata as resolveClientReferenceMetadataImpl, - close, -} from 'ReactFlightDOMRelayServerIntegration'; - -export type { - Destination, - BundlerConfig as ClientManifest, - ClientReferenceMetadata, -} from 'ReactFlightDOMRelayServerIntegration'; - -export function isClientReference(reference: Object): boolean { - return reference instanceof JSResourceReferenceImpl; -} - -export function isServerReference(reference: Object): boolean { - return false; -} - -export type ClientReferenceKey = ClientReference; - -export function getClientReferenceKey( - reference: ClientReference, -): ClientReferenceKey { - // We use the reference object itself as the key because we assume the - // object will be cached by the bundler runtime. - return reference; -} - -export function resolveClientReferenceMetadata( - config: ClientManifest, - resource: ClientReference, -): ClientReferenceMetadata { - return resolveClientReferenceMetadataImpl(config, resource); -} - -export function getServerReferenceId( - config: ClientManifest, - resource: ServerReference, -): ServerReferenceId { - throw new Error('Not implemented.'); -} - -export function getServerReferenceBoundArguments( - config: ClientManifest, - resource: ServerReference, -): Array { - throw new Error('Not implemented.'); -} - -export type Chunk = RowEncoding; - -export function processErrorChunkProd( - request: Request, - id: number, - digest: string, -): Chunk { - if (__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkProd should never be called while in development mode. Use processErrorChunkDev instead. This is a bug in React.', - ); - } - - return [ - 'E', - id, - { - digest, - }, - ]; -} - -export function processErrorChunkDev( - request: Request, - id: number, - digest: string, - message: string, - stack: string, -): Chunk { - if (!__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkDev should never be called while in production mode. Use processErrorChunkProd instead. This is a bug in React.', - ); - } - - return [ - 'E', - id, - { - digest, - message, - stack, - }, - ]; -} - -function convertModelToJSON( - request: Request, - parent: {+[key: string]: ReactClientValue} | $ReadOnlyArray, - key: string, - model: ReactClientValue, -): JSONValue { - const json = resolveModelToJSON(request, parent, key, model); - if (typeof json === 'object' && json !== null) { - if (isArray(json)) { - const jsonArray: Array = []; - for (let i = 0; i < json.length; i++) { - jsonArray[i] = convertModelToJSON(request, json, '' + i, json[i]); - } - return jsonArray; - } else { - const jsonObj: {[key: string]: JSONValue} = {}; - for (const nextKey in json) { - if (hasOwnProperty.call(json, nextKey)) { - jsonObj[nextKey] = convertModelToJSON( - request, - json, - nextKey, - json[nextKey], - ); - } - } - return jsonObj; - } - } - return json; -} - -export function processModelChunk( - request: Request, - id: number, - model: ReactClientValue, -): Chunk { - const json = convertModelToJSON(request, {}, '', model); - return ['O', id, json]; -} - -export function processReferenceChunk( - request: Request, - id: number, - reference: string, -): Chunk { - return ['O', id, reference]; -} - -export function processImportChunk( - request: Request, - id: number, - clientReferenceMetadata: ClientReferenceMetadata, -): Chunk { - // The clientReferenceMetadata is already a JSON serializable value. - return ['I', id, clientReferenceMetadata]; -} - -export function processHintChunk( - request: Request, - id: number, - code: string, - model: HintModel, -): Chunk { - // The hint is already a JSON serializable value. - return ['H', code, model]; -} - -export function scheduleWork(callback: () => void) { - callback(); -} - -export function flushBuffered(destination: Destination) {} - -export const supportsRequestStorage = false; -export const requestStorage: AsyncLocalStorage = (null: any); - -export function beginWriting(destination: Destination) {} - -export function writeChunk(destination: Destination, chunk: Chunk): void { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - emitRow(destination, chunk); -} - -export function writeChunkAndReturn( - destination: Destination, - chunk: Chunk, -): boolean { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - emitRow(destination, chunk); - return true; -} - -export function completeWriting(destination: Destination) {} - -export {close}; - -export function closeWithError(destination: Destination, error: mixed): void { - close(destination); -} diff --git a/packages/react-server-dom-relay/src/__mocks__/JSResourceReferenceImpl.js b/packages/react-server-dom-relay/src/__mocks__/JSResourceReferenceImpl.js deleted file mode 100644 index 70414ab21135d..0000000000000 --- a/packages/react-server-dom-relay/src/__mocks__/JSResourceReferenceImpl.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -class JSResourceReferenceImpl { - constructor(moduleId) { - this._moduleId = moduleId; - } - getModuleId() { - return this._moduleId; - } -} - -module.exports = JSResourceReferenceImpl; diff --git a/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayClientIntegration.js b/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayClientIntegration.js deleted file mode 100644 index 1132c75cf7146..0000000000000 --- a/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayClientIntegration.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -import JSResourceReferenceImpl from 'JSResourceReferenceImpl'; - -const ReactFlightDOMRelayClientIntegration = { - resolveClientReference(metadata) { - return new JSResourceReferenceImpl(metadata); - }, - preloadModule(clientReference) {}, - requireModule(clientReference) { - return clientReference._moduleId; - }, -}; - -module.exports = ReactFlightDOMRelayClientIntegration; diff --git a/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayServerIntegration.js b/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayServerIntegration.js deleted file mode 100644 index 769e61b1adc25..0000000000000 --- a/packages/react-server-dom-relay/src/__mocks__/ReactFlightDOMRelayServerIntegration.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -const ReactFlightDOMRelayServerIntegration = { - emitRow(destination, json) { - destination.push(json); - }, - close(destination) {}, - resolveClientReferenceMetadata(config, resource) { - return resource._moduleId; - }, -}; - -module.exports = ReactFlightDOMRelayServerIntegration; diff --git a/packages/react-server-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js b/packages/react-server-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js deleted file mode 100644 index a79346676d022..0000000000000 --- a/packages/react-server-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js +++ /dev/null @@ -1,240 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -let act; -let React; -let ReactDOMClient; -let JSResourceReferenceImpl; -let ReactDOMFlightRelayServer; -let ReactDOMFlightRelayClient; -let SuspenseList; - -describe('ReactFlightDOMRelay', () => { - beforeEach(() => { - jest.resetModules(); - - act = require('internal-test-utils').act; - React = require('react'); - ReactDOMClient = require('react-dom/client'); - ReactDOMFlightRelayServer = require('react-server-dom-relay/server'); - ReactDOMFlightRelayClient = require('react-server-dom-relay'); - JSResourceReferenceImpl = require('JSResourceReferenceImpl'); - if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; - } - }); - - function readThrough(data) { - const response = ReactDOMFlightRelayClient.createResponse(); - for (let i = 0; i < data.length; i++) { - const chunk = data[i]; - ReactDOMFlightRelayClient.resolveRow(response, chunk); - } - ReactDOMFlightRelayClient.close(response); - const promise = ReactDOMFlightRelayClient.getRoot(response); - let model; - let error; - promise.then( - m => (model = m), - e => (error = e), - ); - if (error) { - throw error; - } - return model; - } - - it('can render a Server Component', () => { - function Bar({text}) { - return text.toUpperCase(); - } - function Foo() { - return { - bar: ( -
- , -
- ), - }; - } - const transport = []; - ReactDOMFlightRelayServer.render( - { - foo: , - }, - transport, - ); - - const model = readThrough(transport); - expect(model).toEqual({ - foo: { - bar: ( -
- {'A'} - {', '} - {'B'} -
- ), - }, - }); - }); - - it('can render a Client Component using a module reference and render there', async () => { - function UserClient(props) { - return ( - - {props.greeting}, {props.name} - - ); - } - const User = new JSResourceReferenceImpl(UserClient); - - function Greeting({firstName, lastName}) { - return ; - } - - const model = { - greeting: , - }; - - const transport = []; - ReactDOMFlightRelayServer.render(model, transport); - - const modelClient = readThrough(transport); - - const container = document.createElement('div'); - const root = ReactDOMClient.createRoot(container); - await act(() => { - root.render(modelClient.greeting); - }); - - expect(container.innerHTML).toEqual('Hello, Seb Smith'); - }); - - // @gate enableSuspenseList - it('can reasonably handle different element types', () => { - const {forwardRef, memo, Fragment, StrictMode, Profiler, Suspense} = React; - - const Inner = memo( - forwardRef((props, ref) => { - return
{'Hello ' + props.name}
; - }), - ); - - function Foo() { - return { - bar: ( -
- Fragment child - Profiler child - StrictMode child - Suspense child - - {'SuspenseList row 1'} - {'SuspenseList row 2'} - - -
- ), - }; - } - const transport = []; - ReactDOMFlightRelayServer.render( - { - foo: , - }, - transport, - ); - - const model = readThrough(transport); - expect(model).toEqual({ - foo: { - bar: ( -
- Fragment child - Profiler child - StrictMode child - Suspense child - - {'SuspenseList row 1'} - {'SuspenseList row 2'} - -
Hello world
-
- ), - }, - }); - }); - - it('can handle a subset of Hooks', () => { - const {useMemo, useCallback} = React; - function Inner({x}) { - const foo = useMemo(() => x + x, [x]); - const bar = useCallback(() => 10 + foo, [foo]); - return bar(); - } - - function Foo() { - return { - bar: , - }; - } - const transport = []; - ReactDOMFlightRelayServer.render( - { - foo: , - }, - transport, - ); - - const model = readThrough(transport); - expect(model).toEqual({ - foo: { - bar: 14, - }, - }); - }); - - it('can handle a subset of Hooks, with element as root', () => { - const {useMemo, useCallback} = React; - function Inner({x}) { - const foo = useMemo(() => x + x, [x]); - const bar = useCallback(() => 10 + foo, [foo]); - return bar(); - } - - function Foo() { - return ; - } - const transport = []; - ReactDOMFlightRelayServer.render(, transport); - - const model = readThrough(transport); - expect(model).toEqual(14); - }); - - it('should warn in DEV if a class instance polyfill is passed to a host component', () => { - function Bar() {} - - function Foo() {} - Foo.prototype = Object.create(Bar.prototype); - // This is enumerable which some polyfills do. - Foo.prototype.constructor = Foo; - Foo.prototype.method = function () {}; - - expect(() => { - const transport = []; - ReactDOMFlightRelayServer.render(, transport); - readThrough(transport); - }).toErrorDev( - 'Only plain objects can be passed to Client Components from Server Components. ', - {withoutStack: true}, - ); - }); -}); diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMClientBrowser.js b/packages/react-server-dom-webpack/src/ReactFlightDOMClientBrowser.js index c835d0b81d7ff..0b72d58c606cc 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMClientBrowser.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMClientBrowser.js @@ -9,7 +9,7 @@ import type {Thenable} from 'shared/ReactTypes.js'; -import type {Response as FlightResponse} from 'react-client/src/ReactFlightClientStream'; +import type {Response as FlightResponse} from 'react-client/src/ReactFlightClient'; import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient'; @@ -20,7 +20,7 @@ import { processStringChunk, processBinaryChunk, close, -} from 'react-client/src/ReactFlightClientStream'; +} from 'react-client/src/ReactFlightClient'; import { processReply, diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMClientEdge.js b/packages/react-server-dom-webpack/src/ReactFlightDOMClientEdge.js index 28c9dfb3fb827..fc3b4cfa375e8 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMClientEdge.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMClientEdge.js @@ -9,7 +9,7 @@ import type {Thenable} from 'shared/ReactTypes.js'; -import type {Response as FlightResponse} from 'react-client/src/ReactFlightClientStream'; +import type {Response as FlightResponse} from 'react-client/src/ReactFlightClient'; import type {SSRManifest} from './ReactFlightClientConfigWebpackBundler'; @@ -19,7 +19,7 @@ import { reportGlobalError, processBinaryChunk, close, -} from 'react-client/src/ReactFlightClientStream'; +} from 'react-client/src/ReactFlightClient'; function noServerCall() { throw new Error( diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMClientNode.js b/packages/react-server-dom-webpack/src/ReactFlightDOMClientNode.js index d9db7682c7e46..75005208a1b15 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMClientNode.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMClientNode.js @@ -9,7 +9,7 @@ import type {Thenable} from 'shared/ReactTypes.js'; -import type {Response} from 'react-client/src/ReactFlightClientStream'; +import type {Response} from 'react-client/src/ReactFlightClient'; import type {SSRManifest} from 'react-client/src/ReactFlightClientConfig'; @@ -21,8 +21,8 @@ import { reportGlobalError, processBinaryChunk, close, -} from 'react-client/src/ReactFlightClientStream'; -import {processStringChunk} from '../../react-client/src/ReactFlightClientStream'; +} from 'react-client/src/ReactFlightClient'; +import {processStringChunk} from '../../react-client/src/ReactFlightClient'; function noServerCall() { throw new Error( diff --git a/packages/react-server-native-relay/server.js b/packages/react-server-native-relay/server.js deleted file mode 100644 index 7727d20b9c386..0000000000000 --- a/packages/react-server-native-relay/server.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from './src/ReactFlightNativeRelayServer'; diff --git a/packages/react-server-native-relay/src/ReactFlightClientConfigNativeRelay.js b/packages/react-server-native-relay/src/ReactFlightClientConfigNativeRelay.js deleted file mode 100644 index 7cdd99d1db2ce..0000000000000 --- a/packages/react-server-native-relay/src/ReactFlightClientConfigNativeRelay.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {JSONValue, ResponseBase} from 'react-client/src/ReactFlightClient'; - -import type {JSResourceReference} from 'JSResourceReference'; - -import type {ClientReferenceMetadata} from 'ReactFlightNativeRelayClientIntegration'; - -export type ClientReference = JSResourceReference; - -import { - parseModelString, - parseModelTuple, -} from 'react-client/src/ReactFlightClient'; - -export { - preloadModule, - requireModule, -} from 'ReactFlightNativeRelayClientIntegration'; - -import {resolveClientReference as resolveClientReferenceImpl} from 'ReactFlightNativeRelayClientIntegration'; - -import isArray from 'shared/isArray'; - -export type {ClientReferenceMetadata} from 'ReactFlightNativeRelayClientIntegration'; - -export type SSRManifest = null; -export type ServerManifest = null; -export type ServerReferenceId = string; - -export type UninitializedModel = JSONValue; - -export type Response = ResponseBase; - -export function resolveClientReference( - bundlerConfig: SSRManifest, - metadata: ClientReferenceMetadata, -): ClientReference { - return resolveClientReferenceImpl(metadata); -} - -export function resolveServerReference( - bundlerConfig: ServerManifest, - id: ServerReferenceId, -): ClientReference { - throw new Error('Not implemented.'); -} - -function parseModelRecursively( - response: Response, - parentObj: {+[key: string]: JSONValue} | $ReadOnlyArray, - key: string, - value: JSONValue, -): $FlowFixMe { - if (typeof value === 'string') { - return parseModelString(response, parentObj, key, value); - } - if (typeof value === 'object' && value !== null) { - if (isArray(value)) { - const parsedValue: Array<$FlowFixMe> = []; - for (let i = 0; i < value.length; i++) { - (parsedValue: any)[i] = parseModelRecursively( - response, - value, - '' + i, - value[i], - ); - } - return parseModelTuple(response, parsedValue); - } else { - const parsedValue = {}; - for (const innerKey in value) { - (parsedValue: any)[innerKey] = parseModelRecursively( - response, - value, - innerKey, - value[innerKey], - ); - } - return parsedValue; - } - } - return value; -} - -const dummy = {}; - -export function parseModel(response: Response, json: UninitializedModel): T { - return (parseModelRecursively(response, dummy, '', json): any); -} - -export function dispatchHint(code: string, model: mixed) {} diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js deleted file mode 100644 index 289a179388044..0000000000000 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayClient.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {RowEncoding} from './ReactFlightNativeRelayProtocol'; - -import type {Response} from 'react-client/src/ReactFlightClient'; - -import { - createResponse, - resolveModel, - resolveModule, - resolveErrorDev, - resolveErrorProd, - close, - getRoot, -} from 'react-client/src/ReactFlightClient'; - -export {createResponse, close, getRoot}; - -export function resolveRow(response: Response, chunk: RowEncoding): void { - if (chunk[0] === 'O') { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - resolveModel(response, chunk[1], chunk[2]); - } else if (chunk[0] === 'I') { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - resolveModule(response, chunk[1], chunk[2]); - } else { - if (__DEV__) { - resolveErrorDev( - response, - chunk[1], - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - // $FlowFixMe[prop-missing] - chunk[2].digest, - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - chunk[2].message || '', - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - chunk[2].stack || '', - ); - } else { - // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples. - // $FlowFixMe[incompatible-use] - // $FlowFixMe[prop-missing] - resolveErrorProd(response, chunk[1], chunk[2].digest); - } - } -} diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js deleted file mode 100644 index a242ba36cc923..0000000000000 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayProtocol.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {ClientReferenceMetadata} from 'ReactFlightNativeRelayServerIntegration'; - -export type JSONValue = - | string - | number - | boolean - | null - | {+[key: string]: JSONValue} - | Array; - -export type RowEncoding = - | ['O', number, JSONValue] - | ['I', number, ClientReferenceMetadata] - | ['P', number, string] - | ['S', number, string] - | [ - 'E', - number, - { - digest: string, - message?: string, - stack?: string, - ... - }, - ]; diff --git a/packages/react-server-native-relay/src/ReactFlightNativeRelayServer.js b/packages/react-server-native-relay/src/ReactFlightNativeRelayServer.js deleted file mode 100644 index c3cc85c1cce9f..0000000000000 --- a/packages/react-server-native-relay/src/ReactFlightNativeRelayServer.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {ReactClientValue} from 'react-server/src/ReactFlightServer'; -import type { - ClientManifest, - Destination, -} from './ReactFlightServerConfigNativeRelay'; - -import { - createRequest, - startWork, - startFlowing, -} from 'react-server/src/ReactFlightServer'; - -function render( - model: ReactClientValue, - destination: Destination, - config: ClientManifest, -): void { - const request = createRequest(model, config); - startWork(request); - startFlowing(request, destination); -} - -export {render}; diff --git a/packages/react-server-native-relay/src/ReactFlightServerConfigNativeRelay.js b/packages/react-server-native-relay/src/ReactFlightServerConfigNativeRelay.js deleted file mode 100644 index 7feb8628f2486..0000000000000 --- a/packages/react-server-native-relay/src/ReactFlightServerConfigNativeRelay.js +++ /dev/null @@ -1,232 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {RowEncoding, JSONValue} from './ReactFlightNativeRelayProtocol'; -import type { - Request, - ReactClientValue, -} from 'react-server/src/ReactFlightServer'; -import hasOwnProperty from 'shared/hasOwnProperty'; -import isArray from 'shared/isArray'; -import type {JSResourceReference} from 'JSResourceReference'; -import JSResourceReferenceImpl from 'JSResourceReferenceImpl'; - -export type ClientReference = JSResourceReference; -export type ServerReference = T; -export type ServerReferenceId = {}; - -import type { - Destination, - BundlerConfig as ClientManifest, - ClientReferenceMetadata, -} from 'ReactFlightNativeRelayServerIntegration'; - -import {resolveModelToJSON} from 'react-server/src/ReactFlightServer'; - -import { - emitRow, - close, - resolveClientReferenceMetadata as resolveClientReferenceMetadataImpl, -} from 'ReactFlightNativeRelayServerIntegration'; - -export type { - Destination, - BundlerConfig as ClientManifest, - ClientReferenceMetadata, -} from 'ReactFlightNativeRelayServerIntegration'; - -export function isClientReference(reference: Object): boolean { - return reference instanceof JSResourceReferenceImpl; -} - -export function isServerReference(reference: Object): boolean { - return false; -} - -export type ClientReferenceKey = ClientReference; - -export function getClientReferenceKey( - reference: ClientReference, -): ClientReferenceKey { - // We use the reference object itself as the key because we assume the - // object will be cached by the bundler runtime. - return reference; -} - -export function resolveClientReferenceMetadata( - config: ClientManifest, - resource: ClientReference, -): ClientReferenceMetadata { - return resolveClientReferenceMetadataImpl(config, resource); -} - -export function getServerReferenceId( - config: ClientManifest, - resource: ServerReference, -): ServerReferenceId { - throw new Error('Not implemented.'); -} - -export function getServerReferenceBoundArguments( - config: ClientManifest, - resource: ServerReference, -): Array { - throw new Error('Not implemented.'); -} - -export type Chunk = RowEncoding; - -export function processErrorChunkProd( - request: Request, - id: number, - digest: string, -): Chunk { - if (__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkProd should never be called while in development mode. Use processErrorChunkDev instead. This is a bug in React.', - ); - } - - return [ - 'E', - id, - { - digest, - }, - ]; -} -export function processErrorChunkDev( - request: Request, - id: number, - digest: string, - message: string, - stack: string, -): Chunk { - if (!__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkDev should never be called while in production mode. Use processErrorChunkProd instead. This is a bug in React.', - ); - } - - return [ - 'E', - id, - { - digest, - message, - stack, - }, - ]; -} - -function convertModelToJSON( - request: Request, - parent: {+[key: string]: ReactClientValue} | $ReadOnlyArray, - key: string, - model: ReactClientValue, -): JSONValue { - const json = resolveModelToJSON(request, parent, key, model); - if (typeof json === 'object' && json !== null) { - if (isArray(json)) { - const jsonArray: Array = []; - for (let i = 0; i < json.length; i++) { - jsonArray[i] = convertModelToJSON(request, json, '' + i, json[i]); - } - return jsonArray; - } else { - const jsonObj: {[key: string]: JSONValue} = {}; - for (const nextKey in json) { - if (hasOwnProperty.call(json, nextKey)) { - jsonObj[nextKey] = convertModelToJSON( - request, - json, - nextKey, - json[nextKey], - ); - } - } - return jsonObj; - } - } - return json; -} - -export function processModelChunk( - request: Request, - id: number, - model: ReactClientValue, -): Chunk { - const json = convertModelToJSON(request, {}, '', model); - return ['O', id, json]; -} - -export function processReferenceChunk( - request: Request, - id: number, - reference: string, -): Chunk { - return ['O', id, reference]; -} - -export function processImportChunk( - request: Request, - id: number, - clientReferenceMetadata: ClientReferenceMetadata, -): Chunk { - // The clientReferenceMetadata is already a JSON serializable value. - return ['I', id, clientReferenceMetadata]; -} - -export function processHintChunk( - request: Request, - id: number, - code: string, - model: JSONValue, -): Chunk { - throw new Error( - 'React Internal Error: processHintChunk is not implemented for Native-Relay. The fact that this method was called means there is a bug in React.', - ); -} - -export function scheduleWork(callback: () => void) { - callback(); -} - -export function flushBuffered(destination: Destination) {} - -export const supportsRequestStorage = false; -export const requestStorage: AsyncLocalStorage = (null: any); - -export function beginWriting(destination: Destination) {} - -export function writeChunk(destination: Destination, chunk: Chunk): void { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - emitRow(destination, chunk); -} - -export function writeChunkAndReturn( - destination: Destination, - chunk: Chunk, -): boolean { - // $FlowFixMe[incompatible-call] `Chunk` doesn't flow into `JSONValue` because of the `E` row type. - emitRow(destination, chunk); - return true; -} - -export function completeWriting(destination: Destination) {} - -export {close}; - -export function closeWithError(destination: Destination, error: mixed): void { - close(destination); -} diff --git a/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayClientIntegration.js b/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayClientIntegration.js deleted file mode 100644 index 40befb5c70eaf..0000000000000 --- a/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayClientIntegration.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -import JSResourceReferenceImpl from 'JSResourceReferenceImpl'; - -const ReactFlightNativeRelayClientIntegration = { - resolveClientReference(metadata) { - return new JSResourceReferenceImpl(metadata); - }, - preloadModule(clientReference) {}, - requireModule(clientReference) { - return clientReference._moduleId; - }, -}; - -module.exports = ReactFlightNativeRelayClientIntegration; diff --git a/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayServerIntegration.js b/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayServerIntegration.js deleted file mode 100644 index 52371c59eaba0..0000000000000 --- a/packages/react-server-native-relay/src/__mocks__/ReactFlightNativeRelayServerIntegration.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -const ReactFlightNativeRelayServerIntegration = { - emitRow(destination, json) { - destination.push(json); - }, - close(destination) {}, - resolveClientReferenceMetadata(config, resource) { - return resource._moduleId; - }, -}; - -module.exports = ReactFlightNativeRelayServerIntegration; diff --git a/packages/react-server-native-relay/src/__tests__/ReactFlightNativeRelay-test.internal.js b/packages/react-server-native-relay/src/__tests__/ReactFlightNativeRelay-test.internal.js deleted file mode 100644 index 1ed48fe30fc92..0000000000000 --- a/packages/react-server-native-relay/src/__tests__/ReactFlightNativeRelay-test.internal.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -let React; -let ReactFabric; -let createReactNativeComponentClass; -let View; -let Text; -let JSResourceReferenceImpl; -let ReactNativeFlightRelayServer; -let ReactNativeFlightRelayClient; - -describe('ReactFlightNativeRelay', () => { - beforeEach(() => { - jest.resetModules(); - - require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager'); - - React = require('react'); - // TODO: Switch this out to react-native - ReactFabric = require('react-native-renderer/fabric'); - createReactNativeComponentClass = - require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') - .ReactNativeViewConfigRegistry.register; - View = createReactNativeComponentClass('RCTView', () => ({ - validAttributes: {}, - uiViewClassName: 'RCTView', - })); - Text = createReactNativeComponentClass('RCTText', () => ({ - validAttributes: {}, - uiViewClassName: 'RCTText', - })); - - ReactNativeFlightRelayServer = require('react-server-native-relay/server'); - ReactNativeFlightRelayClient = require('react-server-native-relay'); - JSResourceReferenceImpl = require('JSResourceReferenceImpl'); - }); - - function readThrough(data) { - const response = ReactNativeFlightRelayClient.createResponse(); - for (let i = 0; i < data.length; i++) { - const chunk = data[i]; - ReactNativeFlightRelayClient.resolveRow(response, chunk); - } - ReactNativeFlightRelayClient.close(response); - const promise = ReactNativeFlightRelayClient.getRoot(response); - let model; - let error; - promise.then( - m => (model = m), - e => (error = e), - ); - if (error) { - throw error; - } - return model; - } - - it('can render a Server Component', () => { - function Bar({text}) { - return {text.toUpperCase()}; - } - function Foo() { - return { - bar: ( - - - - ), - }; - } - const transport = []; - ReactNativeFlightRelayServer.render( - { - foo: , - }, - transport, - ); - - const model = readThrough(transport); - expect(model).toMatchSnapshot(); - }); - - it('can render a Client Component using a module reference and render there', () => { - function UserClient(props) { - return ( - - {props.greeting}, {props.name} - - ); - } - const User = new JSResourceReferenceImpl(UserClient); - - function Greeting({firstName, lastName}) { - return ; - } - - const model = { - greeting: , - }; - - const transport = []; - ReactNativeFlightRelayServer.render(model, transport); - - const modelClient = readThrough(transport); - - ReactFabric.render(modelClient.greeting, 1); - expect( - nativeFabricUIManager.__dumpHierarchyForJestTestsOnly(), - ).toMatchSnapshot(); - }); - - it('should warn in DEV if a class instance polyfill is passed to a host component', () => { - function Bar() {} - - function Foo() {} - Foo.prototype = Object.create(Bar.prototype); - // This is enumerable which some polyfills do. - Foo.prototype.constructor = Foo; - Foo.prototype.method = function () {}; - - expect(() => { - const transport = []; - ReactNativeFlightRelayServer.render( - , - transport, - ); - readThrough(transport); - }).toErrorDev( - 'Only plain objects can be passed to Client Components from Server Components. ', - {withoutStack: true}, - ); - }); -}); diff --git a/packages/react-server-native-relay/src/__tests__/__snapshots__/ReactFlightNativeRelay-test.internal.js.snap b/packages/react-server-native-relay/src/__tests__/__snapshots__/ReactFlightNativeRelay-test.internal.js.snap deleted file mode 100644 index 324f64d706603..0000000000000 --- a/packages/react-server-native-relay/src/__tests__/__snapshots__/ReactFlightNativeRelay-test.internal.js.snap +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ReactFlightNativeRelay can render a Client Component using a module reference and render there 1`] = ` -"1 - RCTText null - RCTRawText {"text":"Hello"} - RCTRawText {"text":", "} - RCTRawText {"text":"Seb Smith"}" -`; - -exports[`ReactFlightNativeRelay can render a Server Component 1`] = ` -{ - "foo": { - "bar": - - A - - - - B - - , - }, -} -`; diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index e2931752de456..40cdeab9c2af9 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -7,9 +7,22 @@ * @flow */ +import type {Chunk, Destination} from './ReactServerStreamConfig'; + +import { + scheduleWork, + flushBuffered, + beginWriting, + writeChunkAndReturn, + stringToChunk, + completeWriting, + close, + closeWithError, +} from './ReactServerStreamConfig'; + +export type {Destination, Chunk} from './ReactServerStreamConfig'; + import type { - Destination, - Chunk, ClientManifest, ClientReferenceMetadata, ClientReference, @@ -34,19 +47,6 @@ import type { import type {LazyComponent} from 'react/src/ReactLazy'; import { - scheduleWork, - beginWriting, - writeChunkAndReturn, - completeWriting, - flushBuffered, - close, - closeWithError, - processModelChunk, - processImportChunk, - processErrorChunkProd, - processErrorChunkDev, - processReferenceChunk, - processHintChunk, resolveClientReferenceMetadata, getServerReferenceId, getServerReferenceBoundArguments, @@ -99,6 +99,16 @@ import ReactSharedInternals from 'shared/ReactSharedInternals'; import isArray from 'shared/isArray'; import {SuspenseException, getSuspendedThenable} from './ReactFlightThenable'; +type JSONValue = + | string + | boolean + | number + | null + | {+[key: string]: JSONValue} + | $ReadOnlyArray; + +const stringify = JSON.stringify; + type ReactJSONValue = | string | boolean @@ -723,7 +733,7 @@ function escapeStringValue(value: string): string { let insideContextProps = null; let isInsideContextValue = false; -export function resolveModelToJSON( +function resolveModelToJSON( request: Request, parent: | {+[key: string | number]: ReactClientValue} @@ -1450,3 +1460,88 @@ function importServerContexts( } return rootContextSnapshot; } + +function serializeRowHeader(tag: string, id: number) { + return id.toString(16) + ':' + tag; +} + +function processErrorChunkProd( + request: Request, + id: number, + digest: string, +): Chunk { + if (__DEV__) { + // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + throw new Error( + 'processErrorChunkProd should never be called while in development mode. Use processErrorChunkDev instead. This is a bug in React.', + ); + } + + const errorInfo: any = {digest}; + const row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; + return stringToChunk(row); +} + +function processErrorChunkDev( + request: Request, + id: number, + digest: string, + message: string, + stack: string, +): Chunk { + if (!__DEV__) { + // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + throw new Error( + 'processErrorChunkDev should never be called while in production mode. Use processErrorChunkProd instead. This is a bug in React.', + ); + } + + const errorInfo: any = {digest, message, stack}; + const row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; + return stringToChunk(row); +} + +function processModelChunk( + request: Request, + id: number, + model: ReactClientValue, +): Chunk { + // $FlowFixMe[incompatible-type] stringify can return null + const json: string = stringify(model, request.toJSON); + const row = id.toString(16) + ':' + json + '\n'; + return stringToChunk(row); +} + +function processReferenceChunk( + request: Request, + id: number, + reference: string, +): Chunk { + const json = stringify(reference); + const row = id.toString(16) + ':' + json + '\n'; + return stringToChunk(row); +} + +function processImportChunk( + request: Request, + id: number, + clientReferenceMetadata: ReactClientValue, +): Chunk { + // $FlowFixMe[incompatible-type] stringify can return null + const json: string = stringify(clientReferenceMetadata); + const row = serializeRowHeader('I', id) + json + '\n'; + return stringToChunk(row); +} + +function processHintChunk( + request: Request, + id: number, + code: string, + model: JSONValue, +): Chunk { + const json: string = stringify(model); + const row = serializeRowHeader('H' + code, id) + json + '\n'; + return stringToChunk(row); +} diff --git a/packages/react-server/src/ReactFlightServerConfigStream.js b/packages/react-server/src/ReactFlightServerConfigStream.js deleted file mode 100644 index 2180228f6bff2..0000000000000 --- a/packages/react-server/src/ReactFlightServerConfigStream.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -// This file is an intermediate layer to translate between Flight -// calls to stream output over a binary stream. - -/* -FLIGHT PROTOCOL GRAMMAR - -Response -- RowSequence - -RowSequence -- Row RowSequence -- Row - -Row -- "J" RowID JSONData -- "M" RowID JSONModuleData -- "H" RowID HTMLData -- "B" RowID BlobData -- "U" RowID URLData -- "E" RowID ErrorData - -RowID -- HexDigits ":" - -HexDigits -- HexDigit HexDigits -- HexDigit - -HexDigit -- 0-F - -URLData -- (UTF8 encoded URL) "\n" - -ErrorData -- (UTF8 encoded JSON: {message: "...", stack: "..."}) "\n" - -JSONData -- (UTF8 encoded JSON) "\n" - - String values that begin with $ are escaped with a "$" prefix. - - References to other rows are encoding as JSONReference strings. - -JSONReference -- "$" HexDigits - -HTMLData -- ByteSize (UTF8 encoded HTML) - -BlobData -- ByteSize (Binary Data) - -ByteSize -- (unsigned 32-bit integer) -*/ - -// TODO: Implement HTMLData, BlobData and URLData. - -import type { - Request, - ReactClientValue, -} from 'react-server/src/ReactFlightServer'; - -import {stringToChunk} from './ReactServerStreamConfig'; - -import type {Chunk} from './ReactServerStreamConfig'; - -export type {Destination, Chunk} from './ReactServerStreamConfig'; - -const stringify = JSON.stringify; - -function serializeRowHeader(tag: string, id: number) { - return id.toString(16) + ':' + tag; -} - -export function processErrorChunkProd( - request: Request, - id: number, - digest: string, -): Chunk { - if (__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkProd should never be called while in development mode. Use processErrorChunkDev instead. This is a bug in React.', - ); - } - - const errorInfo: any = {digest}; - const row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; - return stringToChunk(row); -} - -export function processErrorChunkDev( - request: Request, - id: number, - digest: string, - message: string, - stack: string, -): Chunk { - if (!__DEV__) { - // These errors should never make it into a build so we don't need to encode them in codes.json - // eslint-disable-next-line react-internal/prod-error-codes - throw new Error( - 'processErrorChunkDev should never be called while in production mode. Use processErrorChunkProd instead. This is a bug in React.', - ); - } - - const errorInfo: any = {digest, message, stack}; - const row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; - return stringToChunk(row); -} - -export function processModelChunk( - request: Request, - id: number, - model: ReactClientValue, -): Chunk { - // $FlowFixMe[incompatible-type] stringify can return null - const json: string = stringify(model, request.toJSON); - const row = id.toString(16) + ':' + json + '\n'; - return stringToChunk(row); -} - -export function processReferenceChunk( - request: Request, - id: number, - reference: string, -): Chunk { - const json = stringify(reference); - const row = id.toString(16) + ':' + json + '\n'; - return stringToChunk(row); -} - -export function processImportChunk( - request: Request, - id: number, - clientReferenceMetadata: ReactClientValue, -): Chunk { - // $FlowFixMe[incompatible-type] stringify can return null - const json: string = stringify(clientReferenceMetadata); - const row = serializeRowHeader('I', id) + json + '\n'; - return stringToChunk(row); -} - -export function processHintChunk( - request: Request, - id: number, - code: string, - model: JSONValue, -): Chunk { - const json: string = stringify(model); - const row = serializeRowHeader('H' + code, id) + json + '\n'; - return stringToChunk(row); -} - -export { - scheduleWork, - flushBuffered, - beginWriting, - writeChunk, - writeChunkAndReturn, - completeWriting, - close, - closeWithError, -} from './ReactServerStreamConfig'; diff --git a/packages/react-server/src/forks/ReactFizzConfig.dom-relay.js b/packages/react-server/src/forks/ReactFizzConfig.dom-fb.js similarity index 100% rename from packages/react-server/src/forks/ReactFizzConfig.dom-relay.js rename to packages/react-server/src/forks/ReactFizzConfig.dom-fb.js diff --git a/packages/react-server/src/forks/ReactFizzConfig.native-relay.js b/packages/react-server/src/forks/ReactFizzConfig.native-relay.js deleted file mode 100644 index df90c935a9c92..0000000000000 --- a/packages/react-server/src/forks/ReactFizzConfig.native-relay.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ -import type {Request} from 'react-server/src/ReactFizzServer'; - -export * from 'react-native-renderer/src/server/ReactFizzConfigNative'; - -export const supportsRequestStorage = false; -export const requestStorage: AsyncLocalStorage = (null: any); diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.custom.js b/packages/react-server/src/forks/ReactFlightServerConfig.custom.js index 4590689e5f440..1535d2ffde51e 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.custom.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.custom.js @@ -6,13 +6,13 @@ * * @flow */ + import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from '../ReactFlightServerConfigBundlerCustom'; -export type Hints = null; -export type HintModel = ''; +export type Hints = any; +export type HintModel = any; export const isPrimaryRenderer = false; @@ -21,6 +21,6 @@ export const prepareHostDispatcher = () => {}; export const supportsRequestStorage = false; export const requestStorage: AsyncLocalStorage = (null: any); -export function createHints(): null { +export function createHints(): any { return null; } diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js index a532e31b6c206..212bd8c89a66e 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js @@ -9,7 +9,6 @@ import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js index 31db7c12414eb..2e7273d82d696 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js @@ -9,7 +9,6 @@ import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from '../ReactFlightServerConfigBundlerCustom'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-webpack.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-webpack.js index 036c0b7dc3a38..79c5d9c946fa5 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-webpack.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-webpack.js @@ -8,7 +8,6 @@ */ import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js index a532e31b6c206..212bd8c89a66e 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js @@ -9,7 +9,6 @@ import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-webpack.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-webpack.js index 62a70db4abe6f..10d36f14a93eb 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-webpack.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node-webpack.js @@ -10,7 +10,6 @@ import {AsyncLocalStorage} from 'async_hooks'; import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js index ccbacc8c1c3a0..5d917f6f7868c 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js @@ -11,7 +11,6 @@ import {AsyncLocalStorage} from 'async_hooks'; import type {Request} from 'react-server/src/ReactFlightServer'; -export * from '../ReactFlightServerConfigStream'; export * from 'react-server-dom-webpack/src/ReactFlightServerConfigWebpackBundler'; export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.dom-relay.js b/packages/react-server/src/forks/ReactFlightServerConfig.dom-relay.js deleted file mode 100644 index 13963e1a286c2..0000000000000 --- a/packages/react-server/src/forks/ReactFlightServerConfig.dom-relay.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-server-dom-relay/src/ReactFlightServerConfigDOMRelay'; -export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM'; diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.native-relay.js b/packages/react-server/src/forks/ReactFlightServerConfig.native-relay.js deleted file mode 100644 index 1eacc4516fe1d..0000000000000 --- a/packages/react-server/src/forks/ReactFlightServerConfig.native-relay.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-server-native-relay/src/ReactFlightServerConfigNativeRelay'; -export * from 'react-native-renderer/src/server/ReactFlightServerConfigNative'; diff --git a/packages/react-server-native-relay/index.js b/packages/react-server/src/forks/ReactServerStreamConfig.dom-fb.js similarity index 72% rename from packages/react-server-native-relay/index.js rename to packages/react-server/src/forks/ReactServerStreamConfig.dom-fb.js index 7bb8ab4147746..6b6461f942210 100644 --- a/packages/react-server-native-relay/index.js +++ b/packages/react-server/src/forks/ReactServerStreamConfig.dom-fb.js @@ -7,4 +7,4 @@ * @flow */ -export * from './src/ReactFlightNativeRelayClient'; +export * from '../../../react-server-dom-fb/src/ReactServerStreamConfigFB'; diff --git a/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js b/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js deleted file mode 100644 index 072816e8d491d..0000000000000 --- a/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from 'react-server-dom-relay/src/ReactServerStreamConfigFB'; diff --git a/packages/react-server/src/forks/ReactServerStreamConfig.native-relay.js b/packages/react-server/src/forks/ReactServerStreamConfig.native-relay.js deleted file mode 100644 index 1a3871aef2e8b..0000000000000 --- a/packages/react-server/src/forks/ReactServerStreamConfig.native-relay.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export * from '../ReactServerStreamConfigNode'; diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index c3959a9ec412d..dbe183e01aeb1 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -23,7 +23,6 @@ ./scripts/flow/environment.js ./scripts/flow/react-devtools.js ./scripts/flow/react-native-host-hooks.js -./scripts/flow/react-relay-hooks.js ./scripts/flow/xplat.js [lints] diff --git a/scripts/flow/createFlowConfigs.js b/scripts/flow/createFlowConfigs.js index 5890b3e294f90..8a7c22b6d337c 100644 --- a/scripts/flow/createFlowConfigs.js +++ b/scripts/flow/createFlowConfigs.js @@ -16,11 +16,21 @@ const configTemplate = fs .readFileSync(__dirname + '/config/flowconfig') .toString(); -function writeConfig(renderer, rendererInfo, isServerSupported) { +function writeConfig( + renderer, + rendererInfo, + isServerSupported, + isFlightSupported, +) { const folder = __dirname + '/' + renderer; mkdirp.sync(folder); + isFlightSupported = + isFlightSupported === true || + (isServerSupported && isFlightSupported !== false); + const serverRenderer = isServerSupported ? renderer : 'custom'; + const flightRenderer = isFlightSupported ? renderer : 'custom'; const ignoredPaths = []; @@ -35,7 +45,10 @@ function writeConfig(renderer, rendererInfo, isServerSupported) { ignoredPaths.push(`.*/packages/${otherPath}`); }); - if (otherRenderer.shortName !== serverRenderer) { + if ( + otherRenderer.shortName !== serverRenderer && + otherRenderer.shortName !== flightRenderer + ) { ignoredPaths.push( `.*/packages/.*/forks/.*\\.${otherRenderer.shortName}.js`, ); @@ -54,8 +67,8 @@ function writeConfig(renderer, rendererInfo, isServerSupported) { module.name_mapper='ReactFiberConfig$$' -> 'forks/ReactFiberConfig.${renderer}' module.name_mapper='ReactServerStreamConfig$$' -> 'forks/ReactServerStreamConfig.${serverRenderer}' module.name_mapper='ReactFizzConfig$$' -> 'forks/ReactFizzConfig.${serverRenderer}' -module.name_mapper='ReactFlightServerConfig$$' -> 'forks/ReactFlightServerConfig.${serverRenderer}' -module.name_mapper='ReactFlightClientConfig$$' -> 'forks/ReactFlightClientConfig.${serverRenderer}' +module.name_mapper='ReactFlightServerConfig$$' -> 'forks/ReactFlightServerConfig.${flightRenderer}' +module.name_mapper='ReactFlightClientConfig$$' -> 'forks/ReactFlightClientConfig.${flightRenderer}' module.name_mapper='react-devtools-feature-flags' -> 'react-devtools-shared/src/config/DevToolsFeatureFlags.default' `.trim(), ) @@ -96,6 +109,7 @@ inlinedHostConfigs.forEach(rendererInfo => { rendererInfo.shortName, rendererInfo, rendererInfo.isServerSupported, + rendererInfo.isFlightSupported, ); } }); diff --git a/scripts/flow/react-relay-hooks.js b/scripts/flow/react-relay-hooks.js deleted file mode 100644 index 62d2d13909cd6..0000000000000 --- a/scripts/flow/react-relay-hooks.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -type JSONValue = - | string - | boolean - | number - | null - | {+[key: string]: JSONValue} - | $ReadOnlyArray; - -declare module 'JSResourceReference' { - declare export interface JSResourceReference { - getModuleId(): string; - getModuleIdAsRef(): $Flow$ModuleRef; - getModuleIfRequired(): ?T; - load(): Promise; - preload(): void; - } -} - -declare module 'JSResourceReferenceImpl' { - declare export default class JSResourceReferenceImpl { - getModuleId(): string; - getModuleIdAsRef(): $Flow$ModuleRef; - getModuleIfRequired(): ?T; - load(): Promise; - preload(): void; - } -} - -declare module 'ReactFlightDOMRelayServerIntegration' { - import type {JSResourceReference} from 'JSResourceReference'; - - declare export opaque type Destination; - declare export opaque type BundlerConfig; - declare export function emitRow( - destination: Destination, - json: JSONValue, - ): void; - declare export function close(destination: Destination): void; - - declare export type ClientReferenceMetadata = JSONValue; - declare export function resolveClientReferenceMetadata( - config: BundlerConfig, - resourceReference: JSResourceReference, - ): ClientReferenceMetadata; -} - -declare module 'ReactFlightDOMRelayClientIntegration' { - import type {JSResourceReference} from 'JSResourceReference'; - - declare export opaque type ClientReferenceMetadata; - declare export function resolveClientReference( - moduleData: ClientReferenceMetadata, - ): JSResourceReference; - declare export function preloadModule( - moduleReference: JSResourceReference, - ): null | Promise; - declare export function requireModule( - moduleReference: JSResourceReference, - ): T; -} - -declare module 'ReactFlightNativeRelayServerIntegration' { - import type {JSResourceReference} from 'JSResourceReference'; - - declare export opaque type Destination; - declare export opaque type BundlerConfig; - declare export function emitRow( - destination: Destination, - json: JSONValue, - ): void; - declare export function close(destination: Destination): void; - - declare export type ClientReferenceMetadata = JSONValue; - declare export function resolveClientReferenceMetadata( - config: BundlerConfig, - resourceReference: JSResourceReference, - ): ClientReferenceMetadata; -} - -declare module 'ReactFlightNativeRelayClientIntegration' { - import type {JSResourceReference} from 'JSResourceReference'; - - declare export opaque type ClientReferenceMetadata; - declare export function resolveClientReference( - moduleData: ClientReferenceMetadata, - ): JSResourceReference; - declare export function preloadModule( - moduleReference: JSResourceReference, - ): null | Promise; - declare export function requireModule( - moduleReference: JSResourceReference, - ): T; -} diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 579d9b6ca2672..9a54e73983418 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -253,7 +253,7 @@ const bundles = [ { bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [], moduleType: RENDERER, - entry: 'react-server-dom-relay/src/ReactDOMServerFB.js', + entry: 'react-server-dom-fb/src/ReactDOMServerFB.js', global: 'ReactDOMServerStreaming', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, @@ -450,70 +450,6 @@ const bundles = [ externals: ['url', 'module'], }, - /******* React Server DOM Relay Writer *******/ - { - bundleTypes: [FB_WWW_DEV, FB_WWW_PROD], - moduleType: RENDERER, - entry: 'react-server-dom-relay/server', - global: 'ReactFlightDOMRelayServer', - minifyWithProdErrorCodes: false, - wrapWithModuleBoundaries: false, - externals: [ - 'react', - 'ReactFlightDOMRelayServerIntegration', - 'JSResourceReferenceImpl', - ], - }, - - /******* React Server DOM Relay Reader *******/ - { - bundleTypes: [FB_WWW_DEV, FB_WWW_PROD], - moduleType: RENDERER, - entry: 'react-server-dom-relay', - global: 'ReactFlightDOMRelayClient', - minifyWithProdErrorCodes: true, - wrapWithModuleBoundaries: false, - externals: [ - 'react', - 'ReactFlightDOMRelayClientIntegration', - 'JSResourceReferenceImpl', - ], - }, - - /******* React Server Native Relay Writer *******/ - { - bundleTypes: [RN_FB_DEV, RN_FB_PROD], - moduleType: RENDERER, - entry: 'react-server-native-relay/server', - global: 'ReactFlightNativeRelayServer', - minifyWithProdErrorCodes: false, - wrapWithModuleBoundaries: false, - externals: [ - 'react', - 'ReactFlightNativeRelayServerIntegration', - 'JSResourceReferenceImpl', - 'ReactNativeInternalFeatureFlags', - 'util', - 'async_hooks', - ], - }, - - /******* React Server Native Relay Reader *******/ - { - bundleTypes: [RN_FB_DEV, RN_FB_PROD], - moduleType: RENDERER, - entry: 'react-server-native-relay', - global: 'ReactFlightNativeRelayClient', - minifyWithProdErrorCodes: true, - wrapWithModuleBoundaries: false, - externals: [ - 'react', - 'ReactFlightNativeRelayClientIntegration', - 'JSResourceReferenceImpl', - 'ReactNativeInternalFeatureFlags', - ], - }, - /******* React Suspense Test Utils *******/ { bundleTypes: [NODE_ES2015], diff --git a/scripts/rollup/packaging.js b/scripts/rollup/packaging.js index dba7e835cddab..64b1cf1735b7d 100644 --- a/scripts/rollup/packaging.js +++ b/scripts/rollup/packaging.js @@ -93,8 +93,6 @@ function getBundleOutputPath(bundle, bundleType, filename, packageName) { /\.js$/, '.fb.js' )}`; - case 'react-server-native-relay': - return `build/facebook-relay/flight/${filename}`; default: throw new Error('Unknown RN package.'); } diff --git a/scripts/shared/inlinedHostConfigs.js b/scripts/shared/inlinedHostConfigs.js index cf65774ca8048..70af232fc1c50 100644 --- a/scripts/shared/inlinedHostConfigs.js +++ b/scripts/shared/inlinedHostConfigs.js @@ -34,7 +34,6 @@ module.exports = [ 'react-server-dom-webpack/server', 'react-server-dom-webpack/server.node.unbundled', 'react-server-dom-webpack/src/ReactFlightDOMServerNode.js', // react-server-dom-webpack/server.node - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. 'react-devtools', 'react-devtools-core', 'react-devtools-shell', @@ -85,7 +84,6 @@ module.exports = [ 'react-server-dom-webpack/server.browser', 'react-server-dom-webpack/src/ReactFlightDOMClientBrowser.js', // react-server-dom-webpack/client.browser 'react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-server-dom-webpack/server.browser - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. 'react-devtools', 'react-devtools-core', 'react-devtools-shell', @@ -117,7 +115,6 @@ module.exports = [ 'react-server-dom-webpack/server.edge', 'react-server-dom-webpack/src/ReactFlightDOMClientEdge.js', // react-server-dom-webpack/client.edge 'react-server-dom-webpack/src/ReactFlightDOMServerEdge.js', // react-server-dom-webpack/server.edge - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. 'react-devtools', 'react-devtools-core', 'react-devtools-shell', @@ -148,7 +145,6 @@ module.exports = [ 'react-server-dom-webpack/server', 'react-server-dom-webpack/server.node', 'react-server-dom-webpack/src/ReactFlightDOMServerNode.js', // react-server-dom-webpack/server.node - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. 'react-devtools', 'react-devtools-core', 'react-devtools-shell', @@ -174,18 +170,23 @@ module.exports = [ 'react-dom/src/server/ReactDOMLegacyServerNode.js', // react-dom/server.node 'react-dom/src/server/ReactDOMLegacyServerNode.classic.fb.js', 'react-dom/src/server/ReactDOMLegacyServerNodeStream.js', // file indirection to support partial forking of some methods in *Node - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. 'shared/ReactDOMSharedInternals', ], isFlowTyped: true, isServerSupported: true, }, { - shortName: 'art', - entryPoints: ['react-art'], - paths: ['react-art'], - isFlowTyped: false, // TODO: type it. - isServerSupported: false, + shortName: 'dom-fb', + entryPoints: ['react-server-dom-fb/src/ReactDOMServerFB.js'], + paths: [ + 'react-dom', + 'react-dom-bindings', + 'react-server-dom-fb', + 'shared/ReactDOMSharedInternals', + ], + isFlowTyped: true, + isServerSupported: true, + isFlightSupported: false, }, { shortName: 'native', @@ -209,36 +210,11 @@ module.exports = [ isServerSupported: false, }, { - shortName: 'dom-relay', - entryPoints: [ - 'react-server-dom-relay', - 'react-server-dom-relay/server', - 'react-server-dom-relay/src/ReactDOMServerFB.js', - ], - paths: [ - 'react-dom', - 'react-dom-bindings', - 'react-server-dom-relay', - 'shared/ReactDOMSharedInternals', - ], - isFlowTyped: true, - isServerSupported: true, - }, - { - shortName: 'native-relay', - entryPoints: [ - 'react-server-native-relay', - 'react-server-native-relay/server', - ], - paths: [ - 'react-native-renderer', - 'react-server-native-relay', - // this is included here so that it's not included in the main native check - // remove this when it's added to the main native renderer. - 'react-native-renderer/src/server', - ], - isFlowTyped: true, - isServerSupported: true, + shortName: 'art', + entryPoints: ['react-art'], + paths: ['react-art'], + isFlowTyped: false, // TODO: type it. + isServerSupported: false, }, { shortName: 'custom', @@ -248,11 +224,7 @@ module.exports = [ 'react-server', 'react-server/flight', ], - paths: [ - 'react-client/flight', - 'react-server/flight', - 'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations. - ], + paths: ['react-client/flight', 'react-server/flight'], isFlowTyped: true, isServerSupported: true, }, diff --git a/yarn.lock b/yarn.lock index 5a8df0ab2cfaa..e3daa273b1f60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14143,14 +14143,6 @@ saxes@^6.0.0: loose-envify "^1.1.0" object-assign "^4.1.1" -scheduler@^0.11.0: - version "0.11.3" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.3.tgz#b5769b90cf8b1464f3f3cfcafe8e3cd7555a2d6b" - integrity sha512-i9X9VRRVZDd3xZw10NY5Z2cVMbdYg6gqFecfj79USv1CFN+YrJ3gIPRKf1qlY+Sxly4djoKdfx1T+m9dnRB8kQ== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler@^0.13.0: version "0.13.6" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"