diff --git a/packages/react-flight/README.md b/packages/react-client/README.md similarity index 93% rename from packages/react-flight/README.md rename to packages/react-client/README.md index 3f4c4b5a81860..12ff567d0cc97 100644 --- a/packages/react-flight/README.md +++ b/packages/react-client/README.md @@ -1,4 +1,4 @@ -# react-flight +# react-client This is an experimental package for consuming custom React streaming models. diff --git a/packages/react-flight/index.js b/packages/react-client/flight.js similarity index 100% rename from packages/react-flight/index.js rename to packages/react-client/flight.js diff --git a/packages/react-client/npm/flight.js b/packages/react-client/npm/flight.js new file mode 100644 index 0000000000000..8009499c2898e --- /dev/null +++ b/packages/react-client/npm/flight.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./cjs/react-client-flight.production.min.js'); +} else { + module.exports = require('./cjs/react-client-flight.development.js'); +} diff --git a/packages/react-flight/package.json b/packages/react-client/package.json similarity index 86% rename from packages/react-flight/package.json rename to packages/react-client/package.json index 88c50d4dc58de..a0edddb8c3197 100644 --- a/packages/react-flight/package.json +++ b/packages/react-client/package.json @@ -1,5 +1,5 @@ { - "name": "react-flight", + "name": "react-client", "description": "React package for consuming streaming models.", "version": "0.1.0", "private": true, @@ -12,14 +12,13 @@ "files": [ "LICENSE", "README.md", - "index.js", + "flight.js", "cjs/" ], - "main": "index.js", "repository": { "type" : "git", "url" : "https://github.com/facebook/react.git", - "directory": "packages/react-flight" + "directory": "packages/react-client" }, "engines": { "node": ">=0.10.0" diff --git a/packages/react-flight/src/ReactFlightClient.js b/packages/react-client/src/ReactFlightClient.js similarity index 100% rename from packages/react-flight/src/ReactFlightClient.js rename to packages/react-client/src/ReactFlightClient.js diff --git a/packages/react-flight/src/ReactFlightClientHostConfig.js b/packages/react-client/src/ReactFlightClientHostConfig.js similarity index 100% rename from packages/react-flight/src/ReactFlightClientHostConfig.js rename to packages/react-client/src/ReactFlightClientHostConfig.js diff --git a/packages/react-flight/src/ReactFlightHostConfigBrowser.js b/packages/react-client/src/ReactFlightClientHostConfigBrowser.js similarity index 100% rename from packages/react-flight/src/ReactFlightHostConfigBrowser.js rename to packages/react-client/src/ReactFlightClientHostConfigBrowser.js diff --git a/packages/react-flight/src/__tests__/ReactFlight-test.js b/packages/react-client/src/__tests__/ReactFlight-test.js similarity index 100% rename from packages/react-flight/src/__tests__/ReactFlight-test.js rename to packages/react-client/src/__tests__/ReactFlight-test.js diff --git a/packages/react-flight/src/forks/ReactFlightClientHostConfig.custom.js b/packages/react-client/src/forks/ReactFlightClientHostConfig.custom.js similarity index 100% rename from packages/react-flight/src/forks/ReactFlightClientHostConfig.custom.js rename to packages/react-client/src/forks/ReactFlightClientHostConfig.custom.js diff --git a/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-browser.js b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-browser.js new file mode 100644 index 0000000000000..eb1e6199b425d --- /dev/null +++ b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-browser.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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-client/src/ReactFlightClientHostConfigBrowser'; diff --git a/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-relay.js b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-relay.js new file mode 100644 index 0000000000000..7428b890f2e33 --- /dev/null +++ b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom-relay.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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-flight-dom-relay/src/ReactFlightDOMRelayClientHostConfig'; diff --git a/packages/react-client/src/forks/ReactFlightClientHostConfig.dom.js b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom.js new file mode 100644 index 0000000000000..eb1e6199b425d --- /dev/null +++ b/packages/react-client/src/forks/ReactFlightClientHostConfig.dom.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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-client/src/ReactFlightClientHostConfigBrowser'; diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js index 0a3b41db0cc69..769b052fdd993 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js @@ -13,7 +13,7 @@ import { createRequest, startWork, startFlowing, -} from 'react-server/src/ReactFizzStreamer'; +} from 'react-server/src/ReactFizzServer'; function renderToReadableStream(children: ReactNodeList): ReadableStream { let request; diff --git a/packages/react-dom/src/server/ReactDOMFizzServerNode.js b/packages/react-dom/src/server/ReactDOMFizzServerNode.js index 538becc925bb2..717be00af2194 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerNode.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerNode.js @@ -14,7 +14,7 @@ import { createRequest, startWork, startFlowing, -} from 'react-server/src/ReactFizzStreamer'; +} from 'react-server/src/ReactFizzServer'; function createDrainHandler(destination, request) { return () => startFlowing(request); diff --git a/packages/react-server/src/forks/ReactServerHostConfig.dom-browser.js b/packages/react-flight-dom-relay/index.js similarity index 80% rename from packages/react-server/src/forks/ReactServerHostConfig.dom-browser.js rename to packages/react-flight-dom-relay/index.js index 2937762e0c840..91f46a967fef4 100644 --- a/packages/react-server/src/forks/ReactServerHostConfig.dom-browser.js +++ b/packages/react-flight-dom-relay/index.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactServerHostConfigBrowser'; +export * from './src/ReactFlightDOMRelayClient'; diff --git a/packages/react-flight-dom-relay/package.json b/packages/react-flight-dom-relay/package.json new file mode 100644 index 0000000000000..1bf1189ce2611 --- /dev/null +++ b/packages/react-flight-dom-relay/package.json @@ -0,0 +1,18 @@ +{ + "name": "react-flight-dom-relay", + "version": "0.1.0", + "private": true, + "repository": { + "type" : "git", + "url" : "https://github.com/facebook/react.git", + "directory": "packages/react-flight-dom-relay" + }, + "dependencies": { + "object-assign": "^4.1.1", + "scheduler": "^0.11.0" + }, + "peerDependencies": { + "react": "^16.0.0", + "react-dom": "^16.0.0" + } +} diff --git a/packages/react-flight/src/forks/ReactFlightClientHostConfig.dom-browser.js b/packages/react-flight-dom-relay/server.js similarity index 76% rename from packages/react-flight/src/forks/ReactFlightClientHostConfig.dom-browser.js rename to packages/react-flight-dom-relay/server.js index aeb1f1f690af9..46b468786e756 100644 --- a/packages/react-flight/src/forks/ReactFlightClientHostConfig.dom-browser.js +++ b/packages/react-flight-dom-relay/server.js @@ -7,4 +7,4 @@ * @flow */ -export * from 'react-flight/src/ReactFlightHostConfigBrowser'; +export * from './src/ReactFlightDOMRelayServer'; diff --git a/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClient.js b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClient.js new file mode 100644 index 0000000000000..9507e654d607d --- /dev/null +++ b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClient.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 {ReactModelRoot} from 'react-client/src/ReactFlightClient'; + +import { + createResponse, + getModelRoot, + processStringChunk, + complete, +} from 'react-client/src/ReactFlightClient'; + +type EncodedData = Array; + +function read(data: EncodedData): ReactModelRoot { + let response = createResponse(data); + for (let i = 0; i < data.length; i++) { + processStringChunk(response, data[i], 0); + } + complete(response); + return getModelRoot(response); +} + +export {read}; diff --git a/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClientHostConfig.js b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClientHostConfig.js new file mode 100644 index 0000000000000..22aa7844c44ad --- /dev/null +++ b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayClientHostConfig.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 Source = Array; + +export type StringDecoder = void; + +export const supportsBinaryStreams = false; + +export function createStringDecoder(): void { + throw new Error('Should never be called'); +} + +export function readPartialStringChunk( + decoder: StringDecoder, + buffer: Uint8Array, +): string { + throw new Error('Should never be called'); +} + +export function readFinalStringChunk( + decoder: StringDecoder, + buffer: Uint8Array, +): string { + throw new Error('Should never be called'); +} diff --git a/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServer.js b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServer.js new file mode 100644 index 0000000000000..8945e0e1d9526 --- /dev/null +++ b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServer.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 {ReactModel} from 'react-server/src/ReactFlightServer'; + +import {createRequest, startWork} from 'react-server/src/ReactFlightServer'; + +type EncodedData = Array; + +function render(model: ReactModel): EncodedData { + let data: EncodedData = []; + let request = createRequest(model, data); + startWork(request); + return data; +} + +export {render}; diff --git a/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js new file mode 100644 index 0000000000000..5ede8b9503fed --- /dev/null +++ b/packages/react-flight-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js @@ -0,0 +1,34 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 Destination = Array; + +export function scheduleWork(callback: () => void) { + callback(); +} + +export function flushBuffered(destination: Destination) {} + +export function beginWriting(destination: Destination) {} + +export function writeChunk( + destination: Destination, + buffer: Uint8Array, +): boolean { + destination.push(Buffer.from((buffer: any)).toString('utf8')); + return true; +} + +export function completeWriting(destination: Destination) {} + +export function close(destination: Destination) {} + +export function convertStringToBuffer(content: string): Uint8Array { + return Buffer.from(content, 'utf8'); +} diff --git a/packages/react-flight-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js b/packages/react-flight-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js new file mode 100644 index 0000000000000..2c109eedaf87e --- /dev/null +++ b/packages/react-flight-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js @@ -0,0 +1,42 @@ +/** + * Copyright (c) Facebook, Inc. and its 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'; + +// Polyfills for test environment +global.TextDecoder = require('util').TextDecoder; + +let React; +let ReactDOMFlightRelayServer; +let ReactDOMFlightRelayClient; + +describe('ReactFlightDOMRelay', () => { + beforeEach(() => { + jest.resetModules(); + + React = require('react'); + ReactDOMFlightRelayServer = require('react-flight-dom-relay/server'); + ReactDOMFlightRelayClient = require('react-flight-dom-relay'); + }); + + it('can resolve a model', () => { + function Bar({text}) { + return text.toUpperCase(); + } + function Foo() { + return { + bar: [, ], + }; + } + let data = ReactDOMFlightRelayServer.render({ + foo: , + }); + let root = ReactDOMFlightRelayClient.read(data); + let model = root.model; + expect(model).toEqual({foo: {bar: ['A', 'B']}}); + }); +}); diff --git a/packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js b/packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js index d5712e281bb50..6a3e42e60ac09 100644 --- a/packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js +++ b/packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js @@ -7,7 +7,7 @@ * @flow */ -import type {ReactModelRoot} from 'react-flight/src/ReactFlightClient'; +import type {ReactModelRoot} from 'react-client/src/ReactFlightClient'; import { createResponse, @@ -16,7 +16,7 @@ import { processStringChunk, processBinaryChunk, complete, -} from 'react-flight/src/ReactFlightClient'; +} from 'react-client/src/ReactFlightClient'; function startReadingFromStream(response, stream: ReadableStream): void { let reader = stream.getReader(); diff --git a/packages/react-flight/npm/index.js b/packages/react-flight/npm/index.js deleted file mode 100644 index 1c9cdd060304a..0000000000000 --- a/packages/react-flight/npm/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/react-flight.production.min.js'); -} else { - module.exports = require('./cjs/react-flight.development.js'); -} diff --git a/packages/react-noop-renderer/package.json b/packages/react-noop-renderer/package.json index 32630b190d94b..6c3b60b26a8b6 100644 --- a/packages/react-noop-renderer/package.json +++ b/packages/react-noop-renderer/package.json @@ -14,7 +14,7 @@ "object-assign": "^4.1.1", "regenerator-runtime": "^0.11.0", "react-reconciler": "*", - "react-flight": "*", + "react-client": "*", "react-server": "*" }, "peerDependencies": { diff --git a/packages/react-noop-renderer/src/ReactNoopFlightClient.js b/packages/react-noop-renderer/src/ReactNoopFlightClient.js index 511c7004bf851..99a062017b812 100644 --- a/packages/react-noop-renderer/src/ReactNoopFlightClient.js +++ b/packages/react-noop-renderer/src/ReactNoopFlightClient.js @@ -14,9 +14,9 @@ * environment. */ -import type {ReactModelRoot} from 'react-flight'; +import type {ReactModelRoot} from 'react-client/flight'; -import ReactFlightClient from 'react-flight'; +import ReactFlightClient from 'react-client/flight'; type Source = Array; diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js index b9a668be4a03f..0242220d191e4 100644 --- a/packages/react-noop-renderer/src/ReactNoopServer.js +++ b/packages/react-noop-renderer/src/ReactNoopServer.js @@ -14,11 +14,11 @@ * environment. */ -import ReactFizzStreamer from 'react-server'; +import ReactFizzServer from 'react-server'; type Destination = Array; -const ReactNoopServer = ReactFizzStreamer({ +const ReactNoopServer = ReactFizzServer({ scheduleWork(callback: () => void) { callback(); }, diff --git a/packages/react-flight/src/forks/ReactFlightClientHostConfig.dom.js b/packages/react-reconciler/src/forks/ReactFiberHostConfig.dom-relay.js similarity index 76% rename from packages/react-flight/src/forks/ReactFlightClientHostConfig.dom.js rename to packages/react-reconciler/src/forks/ReactFiberHostConfig.dom-relay.js index aeb1f1f690af9..d830c8501be27 100644 --- a/packages/react-flight/src/forks/ReactFlightClientHostConfig.dom.js +++ b/packages/react-reconciler/src/forks/ReactFiberHostConfig.dom-relay.js @@ -7,4 +7,4 @@ * @flow */ -export * from 'react-flight/src/ReactFlightHostConfigBrowser'; +export * from 'react-dom/src/client/ReactDOMHostConfig'; diff --git a/packages/react-server/index.js b/packages/react-server/index.js index b13c062b44692..eec1bf58818aa 100644 --- a/packages/react-server/index.js +++ b/packages/react-server/index.js @@ -7,4 +7,4 @@ * @flow */ -export * from './src/ReactFizzStreamer'; +export * from './src/ReactFizzServer'; diff --git a/packages/react-server/src/ReactDOMServerFormatConfig.js b/packages/react-server/src/ReactDOMServerFormatConfig.js index fa94102a98c9a..0aeb94cde6ecc 100644 --- a/packages/react-server/src/ReactDOMServerFormatConfig.js +++ b/packages/react-server/src/ReactDOMServerFormatConfig.js @@ -7,7 +7,7 @@ * @flow */ -import {convertStringToBuffer} from 'react-server/src/ReactServerHostConfig'; +import {convertStringToBuffer} from 'react-server/src/ReactServerStreamConfig'; import {renderToStaticMarkup} from 'react-dom/server'; diff --git a/packages/react-server/src/ReactFizzStreamer.js b/packages/react-server/src/ReactFizzServer.js similarity index 95% rename from packages/react-server/src/ReactFizzStreamer.js rename to packages/react-server/src/ReactFizzServer.js index eeadab8c14d21..3bf9f9ef70233 100644 --- a/packages/react-server/src/ReactFizzStreamer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -7,7 +7,7 @@ * @flow */ -import type {Destination} from './ReactServerHostConfig'; +import type {Destination} from './ReactServerStreamConfig'; import type {ReactNodeList} from 'shared/ReactTypes'; import { @@ -17,7 +17,7 @@ import { completeWriting, flushBuffered, close, -} from './ReactServerHostConfig'; +} from './ReactServerStreamConfig'; import {formatChunk} from './ReactServerFormatConfig'; import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 9f896a1b0a2b0..3cc0733598605 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -7,7 +7,7 @@ * @flow */ -import type {Destination} from './ReactServerHostConfig'; +import type {Destination} from './ReactServerStreamConfig'; import { scheduleWork, @@ -17,7 +17,7 @@ import { flushBuffered, close, convertStringToBuffer, -} from './ReactServerHostConfig'; +} from './ReactServerStreamConfig'; import {renderHostChildrenToString} from './ReactServerFormatConfig'; import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; diff --git a/packages/react-server/src/ReactServerHostConfig.js b/packages/react-server/src/ReactServerStreamConfig.js similarity index 100% rename from packages/react-server/src/ReactServerHostConfig.js rename to packages/react-server/src/ReactServerStreamConfig.js diff --git a/packages/react-server/src/ReactServerHostConfigBrowser.js b/packages/react-server/src/ReactServerStreamConfigBrowser.js similarity index 100% rename from packages/react-server/src/ReactServerHostConfigBrowser.js rename to packages/react-server/src/ReactServerStreamConfigBrowser.js diff --git a/packages/react-server/src/ReactServerHostConfigNode.js b/packages/react-server/src/ReactServerStreamConfigNode.js similarity index 100% rename from packages/react-server/src/ReactServerHostConfigNode.js rename to packages/react-server/src/ReactServerStreamConfigNode.js diff --git a/packages/react-server/src/forks/ReactServerHostConfig.dom.js b/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js similarity index 81% rename from packages/react-server/src/forks/ReactServerHostConfig.dom.js rename to packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js index 6f560aa1b4962..e06662579e5a2 100644 --- a/packages/react-server/src/forks/ReactServerHostConfig.dom.js +++ b/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactServerHostConfigNode'; +export * from '../ReactDOMServerFormatConfig'; diff --git a/packages/react-server/src/forks/ReactServerHostConfig.custom.js b/packages/react-server/src/forks/ReactServerStreamConfig.custom.js similarity index 100% rename from packages/react-server/src/forks/ReactServerHostConfig.custom.js rename to packages/react-server/src/forks/ReactServerStreamConfig.custom.js diff --git a/packages/react-server/src/forks/ReactServerStreamConfig.dom-browser.js b/packages/react-server/src/forks/ReactServerStreamConfig.dom-browser.js new file mode 100644 index 0000000000000..24cee99c318ec --- /dev/null +++ b/packages/react-server/src/forks/ReactServerStreamConfig.dom-browser.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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 '../ReactServerStreamConfigBrowser'; diff --git a/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js b/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js new file mode 100644 index 0000000000000..e283cca637c43 --- /dev/null +++ b/packages/react-server/src/forks/ReactServerStreamConfig.dom-relay.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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-flight-dom-relay/src/ReactFlightDOMRelayServerHostConfig'; diff --git a/packages/react-server/src/forks/ReactServerStreamConfig.dom.js b/packages/react-server/src/forks/ReactServerStreamConfig.dom.js new file mode 100644 index 0000000000000..7b6480120ee82 --- /dev/null +++ b/packages/react-server/src/forks/ReactServerStreamConfig.dom.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its 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/createFlowConfigs.js b/scripts/flow/createFlowConfigs.js index 0c5e8f4dce984..434368af00424 100644 --- a/scripts/flow/createFlowConfigs.js +++ b/scripts/flow/createFlowConfigs.js @@ -49,7 +49,7 @@ function writeConfig(renderer, rendererInfo, isServerSupported) { '%REACT_RENDERER_FLOW_OPTIONS%', ` module.name_mapper='ReactFiberHostConfig$$' -> 'forks/ReactFiberHostConfig.${renderer}' -module.name_mapper='ReactServerHostConfig$$' -> 'forks/ReactServerHostConfig.${serverRenderer}' +module.name_mapper='ReactServerStreamConfig$$' -> 'forks/ReactServerStreamConfig.${serverRenderer}' module.name_mapper='ReactServerFormatConfig$$' -> 'forks/ReactServerFormatConfig.${serverRenderer}' module.name_mapper='ReactFlightClientHostConfig$$' -> 'forks/ReactFlightClientHostConfig.${serverRenderer}' `.trim(), diff --git a/scripts/jest/setupHostConfigs.js b/scripts/jest/setupHostConfigs.js index e34279b0786f8..d11330db5522b 100644 --- a/scripts/jest/setupHostConfigs.js +++ b/scripts/jest/setupHostConfigs.js @@ -11,35 +11,35 @@ jest.mock('react-reconciler', () => { return require.requireActual('react-reconciler'); }; }); -const shimServerHostConfigPath = 'react-server/src/ReactServerHostConfig'; +const shimServerStreamConfigPath = 'react-server/src/ReactServerStreamConfig'; const shimServerFormatConfigPath = 'react-server/src/ReactServerFormatConfig'; jest.mock('react-server', () => { return config => { - jest.mock(shimServerHostConfigPath, () => config); + jest.mock(shimServerStreamConfigPath, () => config); jest.mock(shimServerFormatConfigPath, () => config); return require.requireActual('react-server'); }; }); jest.mock('react-server/flight', () => { return config => { - jest.mock(shimServerHostConfigPath, () => config); + jest.mock(shimServerStreamConfigPath, () => config); jest.mock(shimServerFormatConfigPath, () => config); return require.requireActual('react-server/flight'); }; }); const shimFlightClientHostConfigPath = - 'react-flight/src/ReactFlightClientHostConfig'; -jest.mock('react-flight', () => { + 'react-client/src/ReactFlightClientHostConfig'; +jest.mock('react-client/flight', () => { return config => { jest.mock(shimFlightClientHostConfigPath, () => config); - return require.requireActual('react-flight'); + return require.requireActual('react-client/flight'); }; }); const configPaths = [ 'react-reconciler/src/ReactFiberHostConfig', - 'react-flight/src/ReactFlightClientHostConfig', - 'react-server/src/ReactServerHostConfig', + 'react-client/src/ReactFlightClientHostConfig', + 'react-server/src/ReactServerStreamConfig', 'react-server/src/ReactServerFormatConfig', ]; diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index e4d48638f798c..7a355bc46d33f 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -197,6 +197,24 @@ const bundles = [ externals: ['react'], }, + /******* React DOM Flight Server Relay *******/ + { + bundleTypes: [FB_WWW_DEV, FB_WWW_PROD], + moduleType: RENDERER, + entry: 'react-flight-dom-relay/server', + global: 'ReactFlightDOMRelayServer', + externals: ['react', 'react-dom/server'], + }, + + /******* React DOM Flight Client Relay *******/ + { + bundleTypes: [FB_WWW_DEV, FB_WWW_PROD], + moduleType: RENDERER, + entry: 'react-flight-dom-relay', + global: 'ReactFlightDOMRelayClient', + externals: ['react'], + }, + /******* React ART *******/ { bundleTypes: [ @@ -384,7 +402,7 @@ const bundles = [ { bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RECONCILER, - entry: 'react-flight', + entry: 'react-client/flight', global: 'ReactFlightClient', externals: ['react'], }, diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index a69629936bf5c..105eb2585333d 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -298,7 +298,7 @@ const forks = Object.freeze({ ); }, - 'react-server/src/ReactServerHostConfig': ( + 'react-server/src/ReactServerStreamConfig': ( bundleType, entry, dependencies, @@ -316,11 +316,11 @@ const forks = Object.freeze({ if (!rendererInfo.isServerSupported) { return null; } - return `react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`; + return `react-server/src/forks/ReactServerStreamConfig.${rendererInfo.shortName}.js`; } } throw new Error( - 'Expected ReactServerHostConfig to always be replaced with a shim, but ' + + 'Expected ReactServerStreamConfig to always be replaced with a shim, but ' + `found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` + 'Did you mean to add it there to associate it with a specific renderer?' ); @@ -354,13 +354,13 @@ const forks = Object.freeze({ ); }, - 'react-flight/src/ReactFlightClientHostConfig': ( + 'react-client/src/ReactFlightClientHostConfig': ( bundleType, entry, dependencies, moduleType ) => { - if (dependencies.indexOf('react-flight') !== -1) { + if (dependencies.indexOf('react-client') !== -1) { return null; } if (moduleType !== RENDERER && moduleType !== RECONCILER) { @@ -372,7 +372,7 @@ const forks = Object.freeze({ if (!rendererInfo.isServerSupported) { return null; } - return `react-flight/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`; + return `react-client/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`; } } throw new Error( diff --git a/scripts/shared/inlinedHostConfigs.js b/scripts/shared/inlinedHostConfigs.js index 0bef020e278c3..051ecf90b7b92 100644 --- a/scripts/shared/inlinedHostConfigs.js +++ b/scripts/shared/inlinedHostConfigs.js @@ -78,11 +78,18 @@ module.exports = [ isFlowTyped: true, isServerSupported: false, }, + { + shortName: 'dom-relay', + entryPoints: ['react-flight-dom-relay', 'react-flight-dom-relay/server'], + paths: ['react-dom', 'react-flight-dom-relay'], + isFlowTyped: true, + isServerSupported: true, + }, { shortName: 'custom', entryPoints: [ 'react-reconciler', - 'react-flight', + 'react-client/flight', 'react-server', 'react-server/flight', ],