Skip to content

Commit 0197581

Browse files
authored
Merge branch 'main' into bugfix/issue-35460
2 parents fb79b1e + c80a075 commit 0197581

67 files changed

Lines changed: 2157 additions & 509 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ module.exports = {
626626
FinalizationRegistry: 'readonly',
627627
Exclude: 'readonly',
628628
Omit: 'readonly',
629+
Pick: 'readonly',
629630
Keyframe: 'readonly',
630631
PropertyIndexedKeyframes: 'readonly',
631632
KeyframeAnimationOptions: 'readonly',

compiler/yarn.lock

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10525,7 +10525,16 @@ string-length@^4.0.1:
1052510525
char-regex "^1.0.2"
1052610526
strip-ansi "^6.0.0"
1052710527

10528-
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
10528+
"string-width-cjs@npm:string-width@^4.2.0":
10529+
version "4.2.3"
10530+
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
10531+
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
10532+
dependencies:
10533+
emoji-regex "^8.0.0"
10534+
is-fullwidth-code-point "^3.0.0"
10535+
strip-ansi "^6.0.1"
10536+
10537+
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1052910538
version "4.2.3"
1053010539
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
1053110540
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -10598,7 +10607,14 @@ string_decoder@~1.1.1:
1059810607
dependencies:
1059910608
safe-buffer "~5.1.0"
1060010609

10601-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
10610+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
10611+
version "6.0.1"
10612+
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
10613+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
10614+
dependencies:
10615+
ansi-regex "^5.0.1"
10616+
10617+
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1060210618
version "6.0.1"
1060310619
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
1060410620
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11064,9 +11080,9 @@ undici-types@~6.19.2:
1106411080
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
1106511081

1106611082
undici@^6.19.5:
11067-
version "6.21.2"
11068-
resolved "https://registry.npmjs.org/undici/-/undici-6.21.2.tgz"
11069-
integrity sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==
11083+
version "6.23.0"
11084+
resolved "https://registry.yarnpkg.com/undici/-/undici-6.23.0.tgz#7953087744d9095a96f115de3140ca3828aff3a4"
11085+
integrity sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==
1107011086

1107111087
unicode-canonical-property-names-ecmascript@^2.0.0:
1107211088
version "2.0.1"
@@ -11375,7 +11391,7 @@ workerpool@^6.5.1:
1137511391
resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz"
1137611392
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==
1137711393

11378-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
11394+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
1137911395
version "7.0.0"
1138011396
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
1138111397
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -11393,6 +11409,15 @@ wrap-ansi@^6.2.0:
1139311409
string-width "^4.1.0"
1139411410
strip-ansi "^6.0.0"
1139511411

11412+
wrap-ansi@^7.0.0:
11413+
version "7.0.0"
11414+
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
11415+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
11416+
dependencies:
11417+
ansi-styles "^4.0.0"
11418+
string-width "^4.1.0"
11419+
strip-ansi "^6.0.0"
11420+
1139611421
wrap-ansi@^8.1.0:
1139711422
version "8.1.0"
1139811423
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz"

fixtures/packaging/webpack-alias/dev/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ punycode@^1.2.4, punycode@^1.4.1:
936936
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
937937

938938
qs@~6.4.0:
939-
version "6.4.0"
940-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
939+
version "6.4.1"
940+
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.1.tgz#2bad97710a5b661c366b378b1e3a44a592ff45e6"
941941

942942
querystring-es3@^0.2.0:
943943
version "0.2.1"

fixtures/packaging/webpack/prod/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ punycode@^1.2.4, punycode@^1.4.1:
936936
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
937937

938938
qs@~6.4.0:
939-
version "6.4.0"
940-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
939+
version "6.4.1"
940+
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.1.tgz#2bad97710a5b661c366b378b1e3a44a592ff45e6"
941941

942942
querystring-es3@^0.2.0:
943943
version "0.2.1"

flow-typed/environments/dom.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,8 @@ declare class Document extends Node {
14151415
links: HTMLCollection<HTMLLinkElement>;
14161416
media: string;
14171417
open(url?: string, name?: string, features?: string, replace?: boolean): any;
1418+
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/prerendering} */
1419+
prerendering: boolean;
14181420
readyState: string;
14191421
referrer: string;
14201422
scripts: HTMLCollection<HTMLScriptElement>;

packages/react-client/flight.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
* @flow
88
*/
99

10+
import typeof * as FlightClientAPI from './src/ReactFlightClient';
11+
import typeof * as HostConfig from './src/ReactFlightClientConfig';
12+
1013
export * from './src/ReactFlightClient';
14+
15+
// At build time, this module is wrapped as a factory function ($$$reconciler).
16+
// Consumers pass a host config object and get back the Flight client API.
17+
declare export default (hostConfig: HostConfig) => FlightClientAPI;

packages/react-client/src/ReactFlightClient.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,8 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
10401040
// Initialize any debug info and block the initializing chunk on any
10411041
// unresolved entries.
10421042
initializeDebugChunk(response, chunk);
1043+
// TODO: The chunk might have transitioned to ERRORED now.
1044+
// Should we return early if that happens?
10431045
}
10441046

10451047
try {
@@ -1075,6 +1077,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
10751077
const initializedChunk: InitializedChunk<T> = (chunk: any);
10761078
initializedChunk.status = INITIALIZED;
10771079
initializedChunk.value = value;
1080+
initializedChunk.reason = null;
10781081

10791082
if (__DEV__) {
10801083
processChunkDebugInfo(response, initializedChunk, value);
@@ -1097,6 +1100,7 @@ function initializeModuleChunk<T>(chunk: ResolvedModuleChunk<T>): void {
10971100
const initializedChunk: InitializedChunk<T> = (chunk: any);
10981101
initializedChunk.status = INITIALIZED;
10991102
initializedChunk.value = value;
1103+
initializedChunk.reason = null;
11001104
} catch (error) {
11011105
const erroredChunk: ErroredChunk<T> = (chunk: any);
11021106
erroredChunk.status = ERRORED;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
// This is a host config that's used for the internal `react-noop-renderer` package.
11+
//
12+
// Its API lets you pass the host config as an argument.
13+
// However, inside the `react-server` we treat host config as a module.
14+
// This file is a shim between two worlds.
15+
//
16+
// It works because the `react-server` bundle is wrapped in something like:
17+
//
18+
// module.exports = function ($$$config) {
19+
// /* renderer code */
20+
// }
21+
//
22+
// So `$$$config` looks like a global variable, but it's
23+
// really an argument to a top-level wrapping function.
24+
25+
declare const $$$config: $FlowFixMe;
26+
27+
export opaque type ModuleLoading = mixed;
28+
export opaque type ServerConsumerModuleMap = mixed;
29+
export opaque type ServerManifest = mixed;
30+
export opaque type ServerReferenceId = string;
31+
export opaque type ClientReferenceMetadata = mixed;
32+
export opaque type ClientReference<T> = mixed; // eslint-disable-line no-unused-vars
33+
export const resolveClientReference = $$$config.resolveClientReference;
34+
export const resolveServerReference = $$$config.resolveServerReference;
35+
export const preloadModule = $$$config.preloadModule;
36+
export const requireModule = $$$config.requireModule;
37+
export const getModuleDebugInfo = $$$config.getModuleDebugInfo;
38+
export const dispatchHint = $$$config.dispatchHint;
39+
export const prepareDestinationForModule =
40+
$$$config.prepareDestinationForModule;
41+
export const usedWithSSR = true;
42+
43+
export opaque type Source = mixed;
44+
45+
export opaque type StringDecoder = mixed;
46+
47+
export const createStringDecoder = $$$config.createStringDecoder;
48+
export const readPartialStringChunk = $$$config.readPartialStringChunk;
49+
export const readFinalStringChunk = $$$config.readFinalStringChunk;
50+
51+
export const bindToConsole = $$$config.bindToConsole;
52+
53+
export const rendererVersion = $$$config.rendererVersion;
54+
export const rendererPackageName = $$$config.rendererPackageName;
55+
56+
export const checkEvalAvailabilityOnceDev =
57+
$$$config.checkEvalAvailabilityOnceDev;

packages/react-devtools-extensions/src/background/index.js

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
/* global chrome */
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
/* global chrome, ExtensionRuntimePort */
210

311
'use strict';
412

@@ -12,20 +20,19 @@ import {
1220
handleFetchResourceContentScriptMessage,
1321
} from './messageHandlers';
1422

15-
/*
16-
{
17-
[tabId]: {
18-
extension: ExtensionPort,
19-
proxy: ProxyPort,
20-
disconnectPipe: Function,
21-
},
22-
...
23-
}
24-
*/
25-
const ports = {};
26-
27-
function registerTab(tabId) {
23+
const ports: {
24+
// TODO: Check why we convert tab IDs to strings, and if we can avoid it
25+
[tabId: string]: {
26+
extension: ExtensionRuntimePort | null,
27+
proxy: ExtensionRuntimePort | null,
28+
disconnectPipe: Function | null,
29+
},
30+
} = {};
31+
32+
function registerTab(tabId: number) {
33+
// $FlowFixMe[incompatible-type]
2834
if (!ports[tabId]) {
35+
// $FlowFixMe[incompatible-type]
2936
ports[tabId] = {
3037
extension: null,
3138
proxy: null,
@@ -34,18 +41,21 @@ function registerTab(tabId) {
3441
}
3542
}
3643

37-
function registerExtensionPort(port, tabId) {
44+
function registerExtensionPort(port: ExtensionRuntimePort, tabId: number) {
45+
// $FlowFixMe[incompatible-type]
3846
ports[tabId].extension = port;
3947

4048
port.onDisconnect.addListener(() => {
4149
// This should delete disconnectPipe from ports dictionary
50+
// $FlowFixMe[incompatible-type]
4251
ports[tabId].disconnectPipe?.();
4352

44-
delete ports[tabId].extension;
53+
// $FlowFixMe[incompatible-type]
54+
ports[tabId].extension = null;
4555
});
4656
}
4757

48-
function registerProxyPort(port, tabId) {
58+
function registerProxyPort(port: ExtensionRuntimePort, tabId: string) {
4959
ports[tabId].proxy = port;
5060

5161
// In case proxy port was disconnected from the other end, from content script
@@ -54,7 +64,7 @@ function registerProxyPort(port, tabId) {
5464
port.onDisconnect.addListener(() => {
5565
ports[tabId].disconnectPipe?.();
5666

57-
delete ports[tabId].proxy;
67+
ports[tabId].proxy = null;
5868
});
5969
}
6070

@@ -73,14 +83,22 @@ chrome.runtime.onConnect.addListener(port => {
7383
// Proxy content script is executed in tab, so it should have it specified.
7484
const tabId = port.sender.tab.id;
7585

76-
if (ports[tabId]?.proxy) {
77-
ports[tabId].disconnectPipe?.();
78-
ports[tabId].proxy.disconnect();
86+
// $FlowFixMe[incompatible-type]
87+
const registeredPort = ports[tabId];
88+
const proxy = registeredPort?.proxy;
89+
if (proxy) {
90+
registeredPort.disconnectPipe?.();
91+
proxy.disconnect();
7992
}
8093

8194
registerTab(tabId);
82-
registerProxyPort(port, tabId);
95+
registerProxyPort(
96+
port,
97+
// $FlowFixMe[incompatible-call]
98+
tabId,
99+
);
83100

101+
// $FlowFixMe[incompatible-type]
84102
if (ports[tabId].extension) {
85103
connectExtensionAndProxyPorts(
86104
ports[tabId].extension,
@@ -97,8 +115,13 @@ chrome.runtime.onConnect.addListener(port => {
97115
const tabId = +port.name;
98116

99117
registerTab(tabId);
100-
registerExtensionPort(port, tabId);
118+
registerExtensionPort(
119+
port,
120+
// $FlowFixMe[incompatible-call]
121+
tabId,
122+
);
101123

124+
// $FlowFixMe[incompatible-type]
102125
if (ports[tabId].proxy) {
103126
connectExtensionAndProxyPorts(
104127
ports[tabId].extension,
@@ -114,26 +137,33 @@ chrome.runtime.onConnect.addListener(port => {
114137
console.warn(`Unknown port ${port.name} connected`);
115138
});
116139

117-
function connectExtensionAndProxyPorts(extensionPort, proxyPort, tabId) {
118-
if (!extensionPort) {
140+
function connectExtensionAndProxyPorts(
141+
maybeExtensionPort: ExtensionRuntimePort | null,
142+
maybeProxyPort: ExtensionRuntimePort | null,
143+
tabId: number,
144+
) {
145+
if (!maybeExtensionPort) {
119146
throw new Error(
120147
`Attempted to connect ports, when extension port is not present`,
121148
);
122149
}
150+
const extensionPort = maybeExtensionPort;
123151

124-
if (!proxyPort) {
152+
if (!maybeProxyPort) {
125153
throw new Error(
126154
`Attempted to connect ports, when proxy port is not present`,
127155
);
128156
}
157+
const proxyPort = maybeProxyPort;
129158

159+
// $FlowFixMe[incompatible-type]
130160
if (ports[tabId].disconnectPipe) {
131161
throw new Error(
132162
`Attempted to connect already connected ports for tab with id ${tabId}`,
133163
);
134164
}
135165

136-
function extensionPortMessageListener(message) {
166+
function extensionPortMessageListener(message: any) {
137167
try {
138168
proxyPort.postMessage(message);
139169
} catch (e) {
@@ -145,7 +175,7 @@ function connectExtensionAndProxyPorts(extensionPort, proxyPort, tabId) {
145175
}
146176
}
147177

148-
function proxyPortMessageListener(message) {
178+
function proxyPortMessageListener(message: any) {
149179
try {
150180
extensionPort.postMessage(message);
151181
} catch (e) {
@@ -164,6 +194,7 @@ function connectExtensionAndProxyPorts(extensionPort, proxyPort, tabId) {
164194
// We handle disconnect() calls manually, based on each specific case
165195
// No need to disconnect other port here
166196

197+
// $FlowFixMe[incompatible-type]
167198
delete ports[tabId].disconnectPipe;
168199
}
169200

0 commit comments

Comments
 (0)