Skip to content

Commit

Permalink
Rename BundlerConfig -> SSRManifest/ClientManifest
Browse files Browse the repository at this point in the history
These could be more generic but for now that's what they mean.
  • Loading branch information
sebmarkbage committed Mar 9, 2023
1 parent 40b171b commit 9ac4542
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 57 deletions.
6 changes: 3 additions & 3 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
ClientReferenceMetadata,
UninitializedModel,
Response,
BundlerConfig,
SSRManifest,
} from './ReactFlightClientHostConfig';

import {
Expand Down Expand Up @@ -149,7 +149,7 @@ Chunk.prototype.then = function <T>(
};

export type ResponseBase = {
_bundlerConfig: BundlerConfig,
_bundlerConfig: SSRManifest,
_callServer: CallServerCallback,
_chunks: Map<number, SomeChunk<any>>,
...
Expand Down Expand Up @@ -611,7 +611,7 @@ function missingCall() {
}

export function createResponse(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
callServer: void | CallServerCallback,
): ResponseBase {
const chunks: Map<number, SomeChunk<any>> = new Map();
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/ReactFlightClientStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {CallServerCallback} from './ReactFlightClient';
import type {Response} from './ReactFlightClientHostConfigStream';
import type {BundlerConfig} from './ReactFlightClientHostConfig';
import type {SSRManifest} from './ReactFlightClientHostConfig';

import {
resolveModule,
Expand Down Expand Up @@ -121,7 +121,7 @@ function createFromJSONCallback(response: Response) {
}

export function createResponse(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
callServer: void | CallServerCallback,
): Response {
// NOTE: CHECK THE COMPILER OUTPUT EACH TIME YOU CHANGE THIS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
declare var $$$hostConfig: any;

export type Response = any;
export opaque type BundlerConfig = mixed;
export opaque type SSRManifest = mixed;
export opaque type ClientReferenceMetadata = mixed;
export opaque type ClientReference<T> = mixed; // eslint-disable-line no-unused-vars
export const resolveClientReference = $$$hostConfig.resolveClientReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';

export type Response = any;
export opaque type BundlerConfig = mixed;
export opaque type ClientManifest = mixed;
export opaque type ClientReferenceMetadata = mixed;
export opaque type ClientReference<T> = mixed; // eslint-disable-line no-unused-vars
export const resolveClientReference: any = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import isArray from 'shared/isArray';

export type {ClientReferenceMetadata} from 'ReactFlightDOMRelayClientIntegration';

export type BundlerConfig = null;
export type SSRManifest = null;

export type UninitializedModel = JSONValue;

export type Response = ResponseBase;

export function resolveClientReference<T>(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
metadata: ClientReferenceMetadata,
): ClientReference<T> {
return resolveClientReferenceImpl(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {
BundlerConfig,
ClientManifest,
Destination,
} from './ReactFlightDOMRelayServerHostConfig';

Expand All @@ -27,7 +27,7 @@ type Options = {
function render(
model: ReactClientValue,
destination: Destination,
config: BundlerConfig,
config: ClientManifest,
options?: Options,
): void {
const request = createRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type ServerReferenceId = {};

import type {
Destination,
BundlerConfig,
ClientManifest,
ClientReferenceMetadata,
} from 'ReactFlightDOMRelayServerIntegration';

Expand All @@ -40,7 +40,7 @@ import {

export type {
Destination,
BundlerConfig,
ClientManifest,
ClientReferenceMetadata,
} from 'ReactFlightDOMRelayServerIntegration';

Expand All @@ -63,21 +63,21 @@ export function getClientReferenceKey(
}

export function resolveClientReferenceMetadata<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ClientReference<T>,
): ClientReferenceMetadata {
return resolveClientReferenceMetadataImpl(config, resource);
}

export function getServerReferenceId<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ServerReference<T>,
): ServerReferenceId {
throw new Error('Not implemented.');
}

export function getServerReferenceBoundArguments<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ServerReference<T>,
): Array<ReactClientValue> {
throw new Error('Not implemented.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import type {
RejectedThenable,
} from 'shared/ReactTypes';

export type WebpackSSRMap = {
export type SSRManifest = {
[clientId: string]: {
[clientExportName: string]: ClientReference<any>,
},
};

export type BundlerConfig = WebpackSSRMap;

export opaque type ClientReferenceMetadata = {
id: string,
chunks: Array<string>,
Expand All @@ -34,7 +32,7 @@ export opaque type ClientReference<T> = {
};

export function resolveClientReference<T>(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
metadata: ClientReferenceMetadata,
): ClientReference<T> {
const resolvedModuleData = bundlerConfig[metadata.id][metadata.name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import type {
RejectedThenable,
} from 'shared/ReactTypes';

export type WebpackSSRMap = {
export type SSRManifest = null | {
[clientId: string]: {
[clientExportName: string]: ClientReferenceMetadata,
},
};

export type BundlerConfig = null | WebpackSSRMap;

export opaque type ClientReferenceMetadata = {
id: string,
chunks: Array<string>,
Expand All @@ -32,7 +30,7 @@ export opaque type ClientReferenceMetadata = {
export opaque type ClientReference<T> = ClientReferenceMetadata;

export function resolveClientReference<T>(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
metadata: ClientReferenceMetadata,
): ClientReference<T> {
if (bundlerConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {Thenable} from 'shared/ReactTypes.js';

import type {Response as FlightResponse} from 'react-client/src/ReactFlightClientStream';

import type {BundlerConfig} from './ReactFlightClientWebpackBundlerConfig';
import type {SSRManifest} from './ReactFlightClientWebpackBundlerConfig';

import {
createResponse,
Expand All @@ -30,7 +30,7 @@ function noServerCall() {
}

export type Options = {
moduleMap?: BundlerConfig,
moduleMap?: SSRManifest,
};

function createResponseFromOptions(options: void | Options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {Thenable} from 'shared/ReactTypes.js';

import type {Response} from 'react-client/src/ReactFlightClientStream';

import type {BundlerConfig} from 'react-client/src/ReactFlightClientHostConfig';
import type {SSRManifest} from 'react-client/src/ReactFlightClientHostConfig';

import type {Readable} from 'stream';

Expand All @@ -34,7 +34,7 @@ function noServerCall() {

function createFromNodeStream<T>(
stream: Readable,
moduleMap: $NonMaybeType<BundlerConfig>,
moduleMap: $NonMaybeType<SSRManifest>,
): Thenable<T> {
const response: Response = createResponse(moduleMap, noServerCall);
stream.on('data', chunk => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {ServerContextJSONValue} from 'shared/ReactTypes';
import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
import type {ClientManifest} from './ReactFlightServerWebpackBundlerConfig';

import {
createRequest,
Expand All @@ -27,7 +27,7 @@ type Options = {

function renderToReadableStream(
model: ReactClientValue,
webpackMap: BundlerConfig,
webpackMap: ClientManifest,
options?: Options,
): ReadableStream {
const request = createRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {ServerContextJSONValue} from 'shared/ReactTypes';
import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
import type {ClientManifest} from './ReactFlightServerWebpackBundlerConfig';

import {
createRequest,
Expand All @@ -27,7 +27,7 @@ type Options = {

function renderToReadableStream(
model: ReactClientValue,
webpackMap: BundlerConfig,
webpackMap: ClientManifest,
options?: Options,
): ReadableStream {
const request = createRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ReactClientValue,
} from 'react-server/src/ReactFlightServer';
import type {Destination} from 'react-server/src/ReactServerStreamConfigNode';
import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
import type {ClientManifest} from './ReactFlightServerWebpackBundlerConfig';
import type {Writable} from 'stream';
import type {ServerContextJSONValue} from 'shared/ReactTypes';

Expand Down Expand Up @@ -40,7 +40,7 @@ type PipeableStream = {

function renderToPipeableStream(
model: ReactClientValue,
webpackMap: BundlerConfig,
webpackMap: ClientManifest,
options?: Options,
): PipeableStream {
const request = createRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';

type WebpackMap = {
export type ClientManifest = {
[id: string]: ClientReferenceMetadata,
};

export type BundlerConfig = WebpackMap;

export type ServerReference<T: Function> = T & {
$$typeof: symbol,
$$id: string,
Expand Down Expand Up @@ -57,7 +55,7 @@ export function isServerReference(reference: Object): boolean {
}

export function resolveClientReferenceMetadata<T>(
config: BundlerConfig,
config: ClientManifest,
clientReference: ClientReference<T>,
): ClientReferenceMetadata {
const resolvedModuleData = config[clientReference.$$id];
Expand All @@ -74,14 +72,14 @@ export function resolveClientReferenceMetadata<T>(
}

export function getServerReferenceId<T>(
config: BundlerConfig,
config: ClientManifest,
serverReference: ServerReference<T>,
): ServerReferenceId {
return serverReference.$$id;
}

export function getServerReferenceBoundArguments<T>(
config: BundlerConfig,
config: ClientManifest,
serverReference: ServerReference<T>,
): null | Array<ReactClientValue> {
return serverReference.$$bound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import isArray from 'shared/isArray';

export type {ClientReferenceMetadata} from 'ReactFlightNativeRelayClientIntegration';

export type BundlerConfig = null;
export type SSRManifest = null;

export type UninitializedModel = JSONValue;

export type Response = ResponseBase;

export function resolveClientReference<T>(
bundlerConfig: BundlerConfig,
bundlerConfig: SSRManifest,
metadata: ClientReferenceMetadata,
): ClientReference<T> {
return resolveClientReferenceImpl(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {ReactClientValue} from 'react-server/src/ReactFlightServer';
import type {
BundlerConfig,
ClientManifest,
Destination,
} from './ReactFlightNativeRelayServerHostConfig';

Expand All @@ -22,7 +22,7 @@ import {
function render(
model: ReactClientValue,
destination: Destination,
config: BundlerConfig,
config: ClientManifest,
): void {
const request = createRequest(model, config);
startWork(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type ServerReferenceId = {};

import type {
Destination,
BundlerConfig,
ClientManifest,
ClientReferenceMetadata,
} from 'ReactFlightNativeRelayServerIntegration';

Expand All @@ -37,7 +37,7 @@ import {

export type {
Destination,
BundlerConfig,
ClientManifest,
ClientReferenceMetadata,
} from 'ReactFlightNativeRelayServerIntegration';

Expand All @@ -60,21 +60,21 @@ export function getClientReferenceKey(
}

export function resolveClientReferenceMetadata<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ClientReference<T>,
): ClientReferenceMetadata {
return resolveClientReferenceMetadataImpl(config, resource);
}

export function getServerReferenceId<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ServerReference<T>,
): ServerReferenceId {
throw new Error('Not implemented.');
}

export function getServerReferenceBoundArguments<T>(
config: BundlerConfig,
config: ClientManifest,
resource: ServerReference<T>,
): Array<ReactClientValue> {
throw new Error('Not implemented.');
Expand Down
Loading

0 comments on commit 9ac4542

Please sign in to comment.