Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed May 12, 2023
1 parent 393168f commit 082f23c
Show file tree
Hide file tree
Showing 39 changed files with 273 additions and 282 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,6 @@ module.exports = {
globals: {
__webpack_chunk_load__: 'readonly',
__webpack_require__: 'readonly',
__webpack_public_path__: 'readonly',
__webpack_nonce__: 'readonly',
__WEBPACK_FLIGHT_CROSS_ORIGIN_CREDENTIALS__: 'readonly',
__WEBPACK_FLIGHT_CROSS_ORIGIN_ANONYMOUS__: 'readonly',
},
},
{
Expand Down
1 change: 1 addition & 0 deletions fixtures/flight/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
2 changes: 1 addition & 1 deletion fixtures/flight/server/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (process.env.NODE_ENV === 'development') {
serverSideRender: true,
headers: () => {
return {
'Cache-Control': 'max-age=10, must-revalidate',
'Cache-Control': 'no-store, must-revalidate',
};
},
})
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "^3.0.1",
"filesize": "^6.0.1",
"flow-bin": "^0.202.0",
"flow-remove-types": "^2.202.0",
"flow-bin": "^0.205.1",
"flow-remove-types": "^2.205.1",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20230206.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ export function processReply(
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
const originalValue = parent[key];
// $FlowFixMe[method-unbinding]
if (originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export * from 'react-client/src/ReactFlightClientConfigStream';
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM';

export type Response = any;
export opaque type SSRManifest = mixed;
export opaque type BundleConfig = mixed;
export opaque type ServerManifest = mixed;
export opaque type ServerReferenceId = string;
export opaque type ClientReferenceMetadata = mixed;
Expand Down
1 change: 0 additions & 1 deletion packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function onDisconnected() {
disconnectedCallback();
}

// $FlowFixMe[missing-local-annot]
function onError({code, message}: $FlowFixMe) {
safeUnmount();

Expand Down
6 changes: 3 additions & 3 deletions packages/react-devtools-extensions/flow-typed/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* eslint-disable no-unused-vars */

type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
Expand Down Expand Up @@ -626,7 +626,7 @@ interface JestExpectType {
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
* class.
*/
toBeInstanceOf(cls: Class<*>): void;
toBeInstanceOf(cls: Class<any>): void;
/**
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
* nicer.
Expand Down Expand Up @@ -815,7 +815,7 @@ type JestObjectType = {
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
fn<TArguments: $ReadOnlyArray<any>, TReturn>(
implementation?: (...args: TArguments) => TReturn
): JestMockFn<TArguments, TReturn>,
/**
Expand Down
1 change: 0 additions & 1 deletion packages/react-devtools-extensions/src/backendManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {COMPACT_VERSION_NAME} from './utils';

let welcomeHasInitialized = false;

// $FlowFixMe[missing-local-annot]
function welcome(event: $FlowFixMe) {
if (
event.source !== window ||
Expand Down
4 changes: 0 additions & 4 deletions packages/react-devtools-shared/src/backend/legacy/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
Expand Down Expand Up @@ -281,7 +280,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
Expand Down Expand Up @@ -318,7 +316,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
Expand Down Expand Up @@ -350,7 +347,6 @@ export function attach(

return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
Expand Down
6 changes: 4 additions & 2 deletions packages/react-devtools-shared/src/backend/profilingHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ let supportsUserTiming =
let supportsUserTimingV3 = false;
if (supportsUserTiming) {
const CHECK_V3_MARK = '__v3';
const markOptions = ({}: {startTime?: number});
const markOptions: {
detail?: mixed,
startTime?: number,
} = {};
Object.defineProperty(markOptions, 'startTime', {
get: function () {
supportsUserTimingV3 = true;
Expand All @@ -64,7 +67,6 @@ if (supportsUserTiming) {
});

try {
// $FlowFixMe[extra-arg]: Flow expects the User Timing level 2 API.
performance.mark(CHECK_V3_MARK, markOptions);
} catch (error) {
// Ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const resource: Resource<
(element: Element) => {
const request = inProgressRequests.get(element);
if (request != null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
return request.promise;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ function addTrappedEventListener(
if (enableLegacyFBSupport && isDeferredListenerForLegacyFBSupport) {
const originalListener = listener;
// $FlowFixMe[missing-this-annot]
// $FlowFixMe[definition-cycle]
listener = function (...p) {
removeEventListener(
targetContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ if (document.body != null) {
}
});
// documentElement must already exist at this point
// $FlowFixMe[incompatible-call]
domBodyObserver.observe(document.documentElement, {childList: true});
}

Expand Down
3 changes: 2 additions & 1 deletion packages/react-native-renderer/src/ReactFiberConfigFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {dispatchEvent} from './ReactFabricEventEmitter';
import {
DefaultEventPriority,
DiscreteEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
import {HostText} from 'react-reconciler/src/ReactWorkTags';

Expand Down Expand Up @@ -317,7 +318,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
return false;
}

export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
const currentEventPriority = fabricGetCurrentEventPriority
? fabricGetCurrentEventPriority()
: null;
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native-renderer/src/ReactFiberConfigNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
} from './ReactNativeComponentTree';
import ReactNativeFiberHostComponent from './ReactNativeFiberHostComponent';

import {DefaultEventPriority} from 'react-reconciler/src/ReactEventPriorities';
import {
DefaultEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

Expand Down Expand Up @@ -217,9 +220,10 @@ export function getChildHostContext(
}
}

export function getPublicInstance(instance: Instance): * {
export function getPublicInstance(instance: Instance): PublicInstance {
// $FlowExpectedError[prop-missing] For compatibility with Fabric
if (instance.canonical != null && instance.canonical.publicInstance != null) {
// $FlowFixMe[incompatible-return]
return instance.canonical.publicInstance;
}

Expand Down Expand Up @@ -262,7 +266,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
return false;
}

export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
return DefaultEventPriority;
}

Expand Down
1 change: 0 additions & 1 deletion packages/react-refresh/src/ReactFreshRuntime.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ export function createSignatureFunctionForTransform(): <T>(
// in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))).
if (!savedType) {
// We're in the innermost call, so this is the actual type.
// $FlowFixMe[escaped-generic] discovered when updating Flow
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import isArray from 'shared/isArray';

export type {ClientReferenceMetadata} from 'ReactFlightDOMRelayClientIntegration';

export type SSRManifest = null;
export type BundleConfig = null;
export type ServerManifest = null;
export type ServerReferenceId = string;

Expand All @@ -40,7 +40,7 @@ export type UninitializedModel = JSONValue;
export type Response = ResponseBase;

export function resolveClientReference<T>(
bundlerConfig: SSRManifest,
bundlerConfig: BundleConfig,
metadata: ClientReferenceMetadata,
): ClientReference<T> {
return resolveClientReferenceImpl(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ export type ServerManifest = void;

export type ServerReferenceId = string;

export opaque type ClientReferenceMetadata = {
export opaque type ClientReferenceMetadata_ = {
id: string,
chunks: Array<string>,
name: string,
};

const ID = 0;
const CHUNKS = 1;
const NAME = 2;

export opaque type ClientReferenceMetadata = [
/* id */ string,
/* chunks id/name pairs */ Array<string>,
/* name */ string,
];

// eslint-disable-next-line no-unused-vars
export opaque type ClientReference<T> = {
specifier: string,
Expand All @@ -50,8 +60,8 @@ export function resolveClientReference<T>(
metadata: ClientReferenceMetadata,
): ClientReference<T> {
const ssrManifest = bundlerConfig.ssrManifest;
const moduleExports = ssrManifest[metadata.id];
let resolvedModuleData = moduleExports[metadata.name];
const moduleExports = ssrManifest[metadata[ID]];
let resolvedModuleData = moduleExports[metadata[NAME]];
let name;
if (resolvedModuleData) {
// The potentially aliased name.
Expand All @@ -62,19 +72,19 @@ export function resolveClientReference<T>(
if (!resolvedModuleData) {
throw new Error(
'Could not find the module "' +
metadata.id +
metadata[ID] +
'" in the React SSR Manifest. ' +
'This is probably a bug in the React Server Components bundler.',
);
}
name = metadata.name;
name = metadata[NAME];
}

const prefix = bundlerConfig.chunkLoading.prefix;
const crossOrigin = bundlerConfig.chunkLoading.crossOrigin;
const chunkFiles = metadata.chunks;
for (let i = 0; i < chunkFiles.length; i++) {
preinitModulesForSSR(prefix + chunkFiles[i], crossOrigin);
const chunks = metadata[CHUNKS];
for (let i = 1; i < chunks.length; i += 2) {
preinitModulesForSSR(prefix + chunks[i], crossOrigin);
}

return {
Expand Down
Loading

0 comments on commit 082f23c

Please sign in to comment.