-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename to clarify that it's client-only * Rename FizzStreamer to FizzServer for consistency * Rename react-flight to react-client/flight For consistency with react-server. Currently this just includes flight but it could be expanded to include the whole reconciler. * Add Relay Flight Build * Rename ReactServerHostConfig to ReactServerStreamConfig This will be the config specifically for streaming purposes. There will be other configs for other purposes.
- Loading branch information
1 parent
7a1691c
commit bdc5cc4
Showing
45 changed files
with
311 additions
and
48 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/react-flight/README.md → packages/react-client/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# react-flight | ||
# react-client | ||
|
||
This is an experimental package for consuming custom React streaming models. | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
packages/react-client/src/forks/ReactFlightClientHostConfig.dom-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
10 changes: 10 additions & 0 deletions
10
packages/react-client/src/forks/ReactFlightClientHostConfig.dom-relay.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
10 changes: 10 additions & 0 deletions
10
packages/react-client/src/forks/ReactFlightClientHostConfig.dom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
* @flow | ||
*/ | ||
|
||
export * from '../ReactServerHostConfigBrowser'; | ||
export * from './src/ReactFlightDOMRelayClient'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/react-flight-dom-relay/src/ReactFlightDOMRelayClient.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>; | ||
|
||
function read<T>(data: EncodedData): ReactModelRoot<T> { | ||
let response = createResponse(data); | ||
for (let i = 0; i < data.length; i++) { | ||
processStringChunk(response, data[i], 0); | ||
} | ||
complete(response); | ||
return getModelRoot(response); | ||
} | ||
|
||
export {read}; |
32 changes: 32 additions & 0 deletions
32
packages/react-flight-dom-relay/src/ReactFlightDOMRelayClientHostConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>; | ||
|
||
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'); | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/react-flight-dom-relay/src/ReactFlightDOMRelayServer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>; | ||
|
||
function render(model: ReactModel): EncodedData { | ||
let data: EncodedData = []; | ||
let request = createRequest(model, data); | ||
startWork(request); | ||
return data; | ||
} | ||
|
||
export {render}; |
34 changes: 34 additions & 0 deletions
34
packages/react-flight-dom-relay/src/ReactFlightDOMRelayServerHostConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>; | ||
|
||
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'); | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/react-flight-dom-relay/src/__tests__/ReactFlightDOMRelay-test.internal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [<Bar text="a" />, <Bar text="b" />], | ||
}; | ||
} | ||
let data = ReactDOMFlightRelayServer.render({ | ||
foo: <Foo />, | ||
}); | ||
let root = ReactDOMFlightRelayClient.read(data); | ||
let model = root.model; | ||
expect(model).toEqual({foo: {bar: ['A', 'B']}}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
* @flow | ||
*/ | ||
|
||
export * from './src/ReactFizzStreamer'; | ||
export * from './src/ReactFizzServer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.