Skip to content

Commit 3f8db9b

Browse files
committed
Merge branch 'main' into jestbump
2 parents 9a949a8 + 28fcae0 commit 3f8db9b

File tree

76 files changed

+3212
-1621
lines changed

Some content is hidden

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

76 files changed

+3212
-1621
lines changed

fixtures/attribute-behavior/AttributeTableSnapshot.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## `about` (on `<div>` inside `<div>`)
1+
## `about` (on `<div>` inside `<div>`)
22
| Test Case | Flags | Result |
33
| --- | --- | --- |
44
| `about=(string)`| (changed)| `"a string"` |
@@ -11373,6 +11373,56 @@
1137311373
| `transform=(null)`| (initial)| `[]` |
1137411374
| `transform=(undefined)`| (initial)| `[]` |
1137511375

11376+
## `transform-origin` (on `<svg>` inside `<div>`)
11377+
| Test Case | Flags | Result |
11378+
| --- | --- | --- |
11379+
| `transform-origin=(string)`| (changed, warning)| `"a string"` |
11380+
| `transform-origin=(empty string)`| (changed, warning)| `<empty string>` |
11381+
| `transform-origin=(array with string)`| (changed, warning)| `"string"` |
11382+
| `transform-origin=(empty array)`| (changed, warning)| `<empty string>` |
11383+
| `transform-origin=(object)`| (changed, warning)| `"result of toString()"` |
11384+
| `transform-origin=(numeric string)`| (changed, warning)| `"42"` |
11385+
| `transform-origin=(-1)`| (changed, warning)| `"-1"` |
11386+
| `transform-origin=(0)`| (changed, warning)| `"0"` |
11387+
| `transform-origin=(integer)`| (changed, warning)| `"1"` |
11388+
| `transform-origin=(NaN)`| (changed, warning)| `"NaN"` |
11389+
| `transform-origin=(float)`| (changed, warning)| `"99.99"` |
11390+
| `transform-origin=(true)`| (initial, warning)| `<null>` |
11391+
| `transform-origin=(false)`| (initial, warning)| `<null>` |
11392+
| `transform-origin=(string 'true')`| (changed, warning)| `"true"` |
11393+
| `transform-origin=(string 'false')`| (changed, warning)| `"false"` |
11394+
| `transform-origin=(string 'on')`| (changed, warning)| `"on"` |
11395+
| `transform-origin=(string 'off')`| (changed, warning)| `"off"` |
11396+
| `transform-origin=(symbol)`| (initial, warning)| `<null>` |
11397+
| `transform-origin=(function)`| (initial, warning)| `<null>` |
11398+
| `transform-origin=(null)`| (initial, warning)| `<null>` |
11399+
| `transform-origin=(undefined)`| (initial, warning)| `<null>` |
11400+
11401+
## `transformOrigin` (on `<svg>` inside `<div>`)
11402+
| Test Case | Flags | Result |
11403+
| --- | --- | --- |
11404+
| `transformOrigin=(string)`| (changed)| `"a string"` |
11405+
| `transformOrigin=(empty string)`| (changed)| `<empty string>` |
11406+
| `transformOrigin=(array with string)`| (changed)| `"string"` |
11407+
| `transformOrigin=(empty array)`| (changed)| `<empty string>` |
11408+
| `transformOrigin=(object)`| (changed)| `"result of toString()"` |
11409+
| `transformOrigin=(numeric string)`| (changed)| `"42"` |
11410+
| `transformOrigin=(-1)`| (changed)| `"-1"` |
11411+
| `transformOrigin=(0)`| (changed)| `"0"` |
11412+
| `transformOrigin=(integer)`| (changed)| `"1"` |
11413+
| `transformOrigin=(NaN)`| (changed, warning)| `"NaN"` |
11414+
| `transformOrigin=(float)`| (changed)| `"99.99"` |
11415+
| `transformOrigin=(true)`| (initial, warning)| `<null>` |
11416+
| `transformOrigin=(false)`| (initial, warning)| `<null>` |
11417+
| `transformOrigin=(string 'true')`| (changed)| `"true"` |
11418+
| `transformOrigin=(string 'false')`| (changed)| `"false"` |
11419+
| `transformOrigin=(string 'on')`| (changed)| `"on"` |
11420+
| `transformOrigin=(string 'off')`| (changed)| `"off"` |
11421+
| `transformOrigin=(symbol)`| (initial, warning)| `<null>` |
11422+
| `transformOrigin=(function)`| (initial, warning)| `<null>` |
11423+
| `transformOrigin=(null)`| (initial)| `<null>` |
11424+
| `transformOrigin=(undefined)`| (initial)| `<null>` |
11425+
1137611426
## `type` (on `<button>` inside `<div>`)
1137711427
| Test Case | Flags | Result |
1137811428
| --- | --- | --- |

fixtures/attribute-behavior/src/attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,16 @@ const attributes = [
19811981
overrideStringValue:
19821982
'translate(-10,-20) scale(2) rotate(45) translate(5,10)',
19831983
},
1984+
{
1985+
name: 'transform-origin',
1986+
tagName: 'svg',
1987+
read: getSVGAttribute('transform-origin'),
1988+
},
1989+
{
1990+
name: 'transformOrigin',
1991+
tagName: 'svg',
1992+
read: getSVGAttribute('transform-origin'),
1993+
},
19841994
{name: 'type', tagName: 'button', overrideStringValue: 'reset'},
19851995
{
19861996
name: 'type',

fixtures/flight-browser/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1>Flight Example</h1>
2020
<script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
2121
<script src="../../build/node_modules/react-dom/umd/react-dom-server.browser.development.js"></script>
2222
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js"></script>
23-
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack.development.js"></script>
23+
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack-client.development.js"></script>
2424
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
2525
<script type="text/babel">
2626
let Suspense = React.Suspense;
@@ -60,7 +60,7 @@ <h1>Flight Example</h1>
6060
content: <HTML />,
6161
};
6262

63-
let stream = ReactServerDOMWriter.renderToReadableStream(model);
63+
let stream = ReactServerDOMServer.renderToReadableStream(model);
6464
let response = new Response(stream, {
6565
headers: {'Content-Type': 'text/html'},
6666
});
@@ -70,13 +70,13 @@ <h1>Flight Example</h1>
7070
let blob = await responseToDisplay.blob();
7171
let url = URL.createObjectURL(blob);
7272

73-
let data = ReactServerDOMReader.createFromFetch(
73+
let data = ReactServerDOMClient.createFromFetch(
7474
fetch(url)
7575
);
7676
// The client also supports XHR streaming.
7777
// var xhr = new XMLHttpRequest();
7878
// xhr.open('GET', url);
79-
// let data = ReactServerDOMReader.createFromXHR(xhr);
79+
// let data = ReactServerDOMClient.createFromXHR(xhr);
8080
// xhr.send();
8181

8282
renderResult(data);

fixtures/flight/config/webpack.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,14 @@ module.exports = function (webpackEnv) {
752752
// },
753753
// }),
754754
// Fork Start
755-
new ReactFlightWebpackPlugin({isServer: false}),
755+
new ReactFlightWebpackPlugin({
756+
isServer: false,
757+
clientReferences: {
758+
directory: './src',
759+
recursive: true,
760+
include: /\.(js|ts|jsx|tsx)$/,
761+
},
762+
}),
756763
// Fork End
757764
].filter(Boolean),
758765
// Turn off performance processing because we utilize

fixtures/flight/loader/index.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
22
resolve,
3-
getSource,
3+
load as reactLoad,
4+
getSource as getSourceImpl,
45
transformSource as reactTransformSource,
56
} from 'react-server-dom-webpack/node-loader';
67

7-
export {resolve, getSource};
8+
export {resolve};
89

910
import babel from '@babel/core';
1011

@@ -17,6 +18,23 @@ const babelOptions = {
1718
],
1819
};
1920

21+
async function babelLoad(url, context, defaultLoad) {
22+
const {format} = context;
23+
const result = await defaultLoad(url, context, defaultLoad);
24+
if (result.format === 'module') {
25+
const opt = Object.assign({filename: url}, babelOptions);
26+
const {code} = await babel.transformAsync(result.source, opt);
27+
return {source: code, format: 'module'};
28+
}
29+
return defaultLoad(url, context, defaultLoad);
30+
}
31+
32+
export async function load(url, context, defaultLoad) {
33+
return await reactLoad(url, context, (u, c) => {
34+
return babelLoad(u, c, defaultLoad);
35+
});
36+
}
37+
2038
async function babelTransformSource(source, context, defaultTransformSource) {
2139
const {format} = context;
2240
if (format === 'module') {
@@ -27,8 +45,12 @@ async function babelTransformSource(source, context, defaultTransformSource) {
2745
return defaultTransformSource(source, context, defaultTransformSource);
2846
}
2947

30-
export async function transformSource(source, context, defaultTransformSource) {
31-
return reactTransformSource(source, context, (s, c) => {
48+
async function transformSourceImpl(source, context, defaultTransformSource) {
49+
return await reactTransformSource(source, context, (s, c) => {
3250
return babelTransformSource(s, c, defaultTransformSource);
3351
});
3452
}
53+
54+
export const transformSource =
55+
process.version < 'v16' ? transformSourceImpl : undefined;
56+
export const getSource = process.version < 'v16' ? getSourceImpl : undefined;

fixtures/flight/server/cli.server.js renamed to fixtures/flight/server/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const app = express();
2929

3030
// Application
3131
app.get('/', function (req, res) {
32-
require('./handler.server.js')(req, res);
32+
require('./handler.js')(req, res);
3333
});
3434

3535
app.get('/todos', function (req, res) {

fixtures/flight/server/handler.server.js renamed to fixtures/flight/server/handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const {resolve} = require('path');
66
const React = require('react');
77

88
module.exports = function (req, res) {
9-
// const m = require('../src/App.server.js');
10-
import('../src/App.server.js').then(m => {
9+
// const m = require('../src/App.js');
10+
import('../src/App.js').then(m => {
1111
const dist = process.env.NODE_ENV === 'development' ? 'dist' : 'build';
1212
readFile(
1313
resolve(__dirname, `../${dist}/react-client-manifest.json`),

fixtures/flight/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type": "commonjs",
3-
"main": "./cli.server.js"
3+
"main": "./cli.js"
44
}

fixtures/flight/src/App.server.js renamed to fixtures/flight/src/App.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as React from 'react';
2-
import {fetch} from 'react-fetch';
32

43
import Container from './Container.js';
54

6-
import {Counter} from './Counter.client.js';
7-
import {Counter as Counter2} from './Counter2.client.js';
5+
import {Counter} from './Counter.js';
6+
import {Counter as Counter2} from './Counter2.js';
87

9-
import ShowMore from './ShowMore.client.js';
8+
import ShowMore from './ShowMore.js';
109

11-
export default function App() {
12-
const todos = fetch('http://localhost:3001/todos').json();
10+
export default async function App() {
11+
const res = await fetch('http://localhost:3001/todos');
12+
const todos = await res.json();
1313
return (
1414
<Container>
1515
<h1>Hello, world</h1>

fixtures/flight/src/Counter.client.js renamed to fixtures/flight/src/Counter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import * as React from 'react';
24

35
import Container from './Container.js';

fixtures/flight/src/Counter2.client.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

fixtures/flight/src/Counter2.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use client';
2+
3+
export * from './Counter.js';

fixtures/flight/src/ShowMore.client.js renamed to fixtures/flight/src/ShowMore.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import * as React from 'react';
24

35
import Container from './Container.js';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
11+
export * from 'react-client/src/ReactFlightClientHostConfigStream';
12+
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';

packages/react-devtools-core/src/standalone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ function initialize(socket: WebSocket) {
262262
store = new Store(bridge, {
263263
checkBridgeProtocolCompatibility: true,
264264
supportsNativeInspection: true,
265+
supportsTraceUpdates: true,
265266
});
266267

267268
log('Connected');

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

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,31 @@ if (!IS_FIREFOX) {
1212
// It's critical since it allows us to directly run scripts on the "main" world on the page
1313
// "document_start" allows it to run before the page's scripts
1414
// so the hook can be detected by react reconciler
15-
chrome.scripting.registerContentScripts([
16-
{
17-
id: 'hook',
18-
matches: ['<all_urls>'],
19-
js: ['build/installHook.js'],
20-
runAt: 'document_start',
21-
world: chrome.scripting.ExecutionWorld.MAIN,
22-
},
23-
{
24-
id: 'renderer',
25-
matches: ['<all_urls>'],
26-
js: ['build/renderer.js'],
27-
runAt: 'document_start',
28-
world: chrome.scripting.ExecutionWorld.MAIN,
15+
chrome.scripting.registerContentScripts(
16+
[
17+
{
18+
id: 'hook',
19+
matches: ['<all_urls>'],
20+
js: ['build/installHook.js'],
21+
runAt: 'document_start',
22+
world: chrome.scripting.ExecutionWorld.MAIN,
23+
},
24+
{
25+
id: 'renderer',
26+
matches: ['<all_urls>'],
27+
js: ['build/renderer.js'],
28+
runAt: 'document_start',
29+
world: chrome.scripting.ExecutionWorld.MAIN,
30+
},
31+
],
32+
function () {
33+
// When the content scripts are already registered, an error will be thrown.
34+
// It happens when the service worker process is incorrectly duplicated.
35+
if (chrome.runtime.lastError) {
36+
console.error(chrome.runtime.lastError);
37+
}
2938
},
30-
]);
39+
);
3140
}
3241

3342
chrome.runtime.onConnect.addListener(function (port) {
@@ -51,7 +60,7 @@ chrome.runtime.onConnect.addListener(function (port) {
5160
ports[tab][name] = port;
5261

5362
if (ports[tab].devtools && ports[tab]['content-script']) {
54-
doublePipe(ports[tab].devtools, ports[tab]['content-script']);
63+
doublePipe(ports[tab].devtools, ports[tab]['content-script'], tab);
5564
}
5665
});
5766

@@ -70,20 +79,36 @@ function installProxy(tabId: number) {
7079
}
7180
}
7281

73-
function doublePipe(one, two) {
82+
function doublePipe(one, two, tabId) {
7483
one.onMessage.addListener(lOne);
7584
function lOne(message) {
76-
two.postMessage(message);
85+
try {
86+
two.postMessage(message);
87+
} catch (e) {
88+
if (__DEV__) {
89+
console.log(`Broken pipe ${tabId}: `, e);
90+
}
91+
shutdown();
92+
}
7793
}
7894
two.onMessage.addListener(lTwo);
7995
function lTwo(message) {
80-
one.postMessage(message);
96+
try {
97+
one.postMessage(message);
98+
} catch (e) {
99+
if (__DEV__) {
100+
console.log(`Broken pipe ${tabId}: `, e);
101+
}
102+
shutdown();
103+
}
81104
}
82105
function shutdown() {
83106
one.onMessage.removeListener(lOne);
84107
two.onMessage.removeListener(lTwo);
85108
one.disconnect();
86109
two.disconnect();
110+
// clean up so that we can rebuild the double pipe if the page is reloaded
111+
ports[tabId] = null;
87112
}
88113
one.onDisconnect.addListener(shutdown);
89114
two.onDisconnect.addListener(shutdown);

packages/react-devtools-shared/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"@reach/menu-button": "^0.16.1",
1919
"@reach/tooltip": "^0.16.0",
2020
"clipboard-js": "^0.3.6",
21+
"compare-versions": "^5.0.3",
2122
"json5": "^2.1.3",
2223
"local-storage-fallback": "^4.1.1",
2324
"lodash.throttle": "^4.1.1",
2425
"memoize-one": "^3.1.1",
25-
"react-virtualized-auto-sizer": "^1.0.6",
26-
"semver": "^6.3.0"
26+
"react-virtualized-auto-sizer": "^1.0.6"
2727
}
2828
}

0 commit comments

Comments
 (0)