-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DevTools] Add Flight Renderer (#30906)
This represents a virtual renderer that connects to the Flight Client. It's virtual in the sense that the actual rendering has already happened on the server. The Flight Client parses the result. Most of the result then end up in objects that render into another renderer and that's how we see most Server Components in DevTools. As part of the client's tree. However, some things are side-effects that don't really connect to any particular client renderer. For example preloads() and logs. For those we need to treat the Flight Client as if it was its own renderer just like a Fiber renderer or even legacy renderer. We really could support Fizz and Flight Server as DevTools targets too for example to connect it to the backend but there's just not much demand for that. This will initially only be used to track the owners of replayed console logs but could be expanded to more. For example to send controls to start profiling on the server. It could also be expanded to build an RSC payload inspector that is automatically connected.
- Loading branch information
1 parent
e07235b
commit 3cac8cd
Showing
4 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
packages/react-devtools-shared/src/backend/flight/renderer.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,101 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and 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 {DevToolsHook, ReactRenderer, RendererInterface} from '../types'; | ||
|
||
import { | ||
patchConsoleUsingWindowValues, | ||
registerRenderer as registerRendererWithConsole, | ||
} from '../console'; | ||
|
||
export function attach( | ||
hook: DevToolsHook, | ||
rendererID: number, | ||
renderer: ReactRenderer, | ||
global: Object, | ||
): RendererInterface { | ||
patchConsoleUsingWindowValues(); | ||
registerRendererWithConsole(renderer); | ||
|
||
return { | ||
cleanup() {}, | ||
clearErrorsAndWarnings() {}, | ||
clearErrorsForElementID() {}, | ||
clearWarningsForElementID() {}, | ||
getSerializedElementValueByPath() {}, | ||
deletePath() {}, | ||
findHostInstancesForElementID() { | ||
return null; | ||
}, | ||
flushInitialOperations() {}, | ||
getBestMatchForTrackedPath() { | ||
return null; | ||
}, | ||
getDisplayNameForElementID() { | ||
return null; | ||
}, | ||
getNearestMountedDOMNode() { | ||
return null; | ||
}, | ||
getElementIDForHostInstance() { | ||
return null; | ||
}, | ||
getInstanceAndStyle() { | ||
return { | ||
instance: null, | ||
style: null, | ||
}; | ||
}, | ||
getOwnersList() { | ||
return null; | ||
}, | ||
getPathForElement() { | ||
return null; | ||
}, | ||
getProfilingData() { | ||
throw new Error('getProfilingData not supported by this renderer'); | ||
}, | ||
handleCommitFiberRoot() {}, | ||
handleCommitFiberUnmount() {}, | ||
handlePostCommitFiberRoot() {}, | ||
hasElementWithId() { | ||
return false; | ||
}, | ||
inspectElement( | ||
requestID: number, | ||
id: number, | ||
path: Array<string | number> | null, | ||
) { | ||
return { | ||
id, | ||
responseID: requestID, | ||
type: 'not-found', | ||
}; | ||
}, | ||
logElementToConsole() {}, | ||
patchConsoleForStrictMode() {}, | ||
getElementAttributeByPath() {}, | ||
getElementSourceFunctionById() {}, | ||
overrideError() {}, | ||
overrideSuspense() {}, | ||
overrideValueAtPath() {}, | ||
renamePath() {}, | ||
renderer, | ||
setTraceUpdatesEnabled() {}, | ||
setTrackedPath() {}, | ||
startProfiling() {}, | ||
stopProfiling() {}, | ||
storeAsGlobal() {}, | ||
unpatchConsoleForStrictMode() {}, | ||
updateComponentFilters() {}, | ||
getEnvironmentNames() { | ||
return []; | ||
}, | ||
}; | ||
} |
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