GeezerVison is showing github.com — Improve Bridge Flow types (#352) · react/react@4b34a77
File treeExpand file treeCollapse file tree Open diff view settings packages/react-devtools-core/src shells/dev/app/SuspenseTree
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintignore +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,6 +4,7 @@ shells/browser/chrome/build | 4 | 4 | shells/browser/firefox/build | 5 | 5 | shells/browser/shared/build | 6 | 6 | shells/dev/dist | | 7 | +packages/react-devtools-core/dist | 7 | 8 | vendor | 8 | 9 | *.js.snap | 9 | 10 |
| |
Collapse file Copy file name to clipboardExpand all lines: package.json +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 63 | 63 | "test:chrome": "node ./shells/browser/chrome/test", | 64 | 64 | "test:firefox": "node ./shells/browser/firefox/test", | 65 | 65 | "test:standalone": "cd packages/react-devtools && yarn start", | 66 | | - "typecheck": "flow check" | | 66 | + "typecheck": "flow check --show-all-errors" | 67 | 67 | }, | 68 | 68 | "devEngines": { | 69 | 69 | "node": "10.x || 11.x" | | 119 | 119 | "fbjs": "0.5.1", | 120 | 120 | "fbjs-scripts": "0.7.0", | 121 | 121 | "firefox-profile": "^1.0.2", | 122 | | - "flow-bin": "^0.97.0", | | 122 | + "flow-bin": "^0.103.0", | 123 | 123 | "fs-extra": "^3.0.1", | 124 | 124 | "gh-pages": "^1.0.0", | 125 | 125 | "html2canvas": "^1.0.0-alpha.12", | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/src/backend.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import { __DEBUG__ } from 'src/constants'; | 8 | 8 | import setupNativeStyleEditor from 'src/backend/NativeStyleEditor/setupNativeStyleEditor'; | 9 | 9 | import { getDefaultComponentFilters } from 'src/utils'; | 10 | 10 |
| | 11 | +import type { BackendBridge } from 'src/bridge'; | 11 | 12 | import type { ComponentFilter } from 'src/types'; | 12 | 13 | import type { DevToolsHook } from 'src/backend/types'; | 13 | 14 | import type { ResolveNativeStyle } from 'src/backend/NativeStyleEditor/setupNativeStyleEditor'; | @@ -64,7 +65,7 @@ export function connectToDevTools(options: ?ConnectOptions) { | 64 | 65 | return; | 65 | 66 | } | 66 | 67 |
| 67 | | - let bridge: Bridge | null = null; | | 68 | + let bridge: BackendBridge | null = null; | 68 | 69 |
| 69 | 70 | const messageListeners = []; | 70 | 71 | const uri = 'ws://' + host + ':' + port; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/src/standalone.js +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ import DevTools from 'src/devtools/views/DevTools'; | 17 | 17 | import launchEditor from './launchEditor'; | 18 | 18 | import { __DEBUG__ } from 'src/constants'; | 19 | 19 |
| | 20 | +import type { FrontendBridge } from 'src/bridge'; | 20 | 21 | import type { InspectedElement } from 'src/devtools/views/Components/types'; | 21 | 22 |
| 22 | 23 | installHook(window); | @@ -46,7 +47,7 @@ function setStatusListener(value: StatusListener) { | 46 | 47 | return DevtoolsUI; | 47 | 48 | } | 48 | 49 |
| 49 | | -let bridge: Bridge | null = null; | | 50 | +let bridge: FrontendBridge | null = null; | 50 | 51 | let store: Store | null = null; | 51 | 52 | let root = null; | 52 | 53 |
| @@ -83,7 +84,7 @@ function reload() { | 83 | 84 | root = createRoot(node); | 84 | 85 | root.render( | 85 | 86 | createElement(DevTools, { | 86 | | - bridge: ((bridge: any): Bridge), | | 87 | + bridge: ((bridge: any): FrontendBridge), | 87 | 88 | showTabBar: true, | 88 | 89 | store: ((store: any): Store), | 89 | 90 | warnIfLegacyBackendDetected: true, | @@ -166,7 +167,7 @@ function initialize(socket: WebSocket) { | 166 | 167 | } | 167 | 168 | }, | 168 | 169 | }); | 169 | | - ((bridge: any): Bridge).addListener('shutdown', () => { | | 170 | + ((bridge: any): FrontendBridge).addListener('shutdown', () => { | 170 | 171 | socket.close(); | 171 | 172 | }); | 172 | 173 |
| |
Collapse file Copy file name to clipboardExpand all lines: shells/dev/app/SuspenseTree/index.js +20-20Lines changed: 20 additions & 20 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | // @flow | 2 | 2 |
| 3 | | -import React, { Suspense, useState } from 'react'; | | 3 | +import React, { Fragment, Suspense, useState } from 'react'; | 4 | 4 |
| 5 | 5 | function SuspenseTree() { | 6 | 6 | return ( | 7 | | - <> | | 7 | + <Fragment> | 8 | 8 | <h1>Suspense</h1> | 9 | 9 | <h4>Primary to Fallback Cycle</h4> | 10 | 10 | <PrimaryFallbackTest initialSuspend={false} /> | 11 | 11 | <h4>Fallback to Primary Cycle</h4> | 12 | 12 | <PrimaryFallbackTest initialSuspend={true} /> | 13 | 13 | <NestedSuspenseTest /> | 14 | | - </> | | 14 | + </Fragment> | 15 | 15 | ); | 16 | 16 | } | 17 | 17 |
| @@ -20,7 +20,7 @@ function PrimaryFallbackTest({ initialSuspend }) { | 20 | 20 | const fallbackStep = useTestSequence('fallback', Fallback1, Fallback2); | 21 | 21 | const primaryStep = useTestSequence('primary', Primary1, Primary2); | 22 | 22 | return ( | 23 | | - <> | | 23 | + <Fragment> | 24 | 24 | <label> | 25 | 25 | <input | 26 | 26 | checked={suspend} | @@ -33,7 +33,7 @@ function PrimaryFallbackTest({ initialSuspend }) { | 33 | 33 | <Suspense fallback={fallbackStep}> | 34 | 34 | {suspend ? <Never /> : primaryStep} | 35 | 35 | </Suspense> | 36 | | - </> | | 36 | + </Fragment> | 37 | 37 | ); | 38 | 38 | } | 39 | 39 |
| @@ -45,32 +45,32 @@ function useTestSequence(label, T1, T2) { | 45 | 45 | </button> | 46 | 46 | ); | 47 | 47 | let allSteps = [ | 48 | | - <>{next}</>, | 49 | | - <> | | 48 | + <Fragment>{next}</Fragment>, | | 49 | + <Fragment> | 50 | 50 | {next} <T1 prop={step}>mount</T1> | 51 | | - </>, | 52 | | - <> | | 51 | + </Fragment>, | | 52 | + <Fragment> | 53 | 53 | {next} <T1 prop={step}>update</T1> | 54 | | - </>, | 55 | | - <> | | 54 | + </Fragment>, | | 55 | + <Fragment> | 56 | 56 | {next} <T2 prop={step}>several</T2> <T1 prop={step}>different</T1>{' '} | 57 | 57 | <T2 prop={step}>children</T2> | 58 | | - </>, | 59 | | - <> | | 58 | + </Fragment>, | | 59 | + <Fragment> | 60 | 60 | {next} <T2 prop={step}>goodbye</T2> | 61 | | - </>, | | 61 | + </Fragment>, | 62 | 62 | ]; | 63 | 63 | return allSteps[step]; | 64 | 64 | } | 65 | 65 |
| 66 | 66 | function NestedSuspenseTest() { | 67 | 67 | return ( | 68 | | - <> | | 68 | + <Fragment> | 69 | 69 | <h3>Nested Suspense</h3> | 70 | 70 | <Suspense fallback={<Fallback1>Loading outer</Fallback1>}> | 71 | 71 | <Parent /> | 72 | 72 | </Suspense> | 73 | | - </> | | 73 | + </Fragment> | 74 | 74 | ); | 75 | 75 | } | 76 | 76 |
| @@ -118,19 +118,19 @@ function Never() { | 118 | 118 | throw new Promise(resolve => {}); | 119 | 119 | } | 120 | 120 |
| 121 | | -function Fallback1({ prop, ...rest }) { | | 121 | +function Fallback1({ prop, ...rest }: any) { | 122 | 122 | return <span {...rest} />; | 123 | 123 | } | 124 | 124 |
| 125 | | -function Fallback2({ prop, ...rest }) { | | 125 | +function Fallback2({ prop, ...rest }: any) { | 126 | 126 | return <span {...rest} />; | 127 | 127 | } | 128 | 128 |
| 129 | | -function Primary1({ prop, ...rest }) { | | 129 | +function Primary1({ prop, ...rest }: any) { | 130 | 130 | return <span {...rest} />; | 131 | 131 | } | 132 | 132 |
| 133 | | -function Primary2({ prop, ...rest }) { | | 133 | +function Primary2({ prop, ...rest }: any) { | 134 | 134 | return <span {...rest} />; | 135 | 135 | } | 136 | 136 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/bridge-test.js +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,19 +15,19 @@ describe('Bridge', () => { | 15 | 15 | const bridge = new Bridge(wall); | 16 | 16 |
| 17 | 17 | // Check that we're wired up correctly. | 18 | | - bridge.send('init'); | | 18 | + bridge.send('reloadAppForProfiling'); | 19 | 19 | jest.runAllTimers(); | 20 | | - expect(wall.send).toHaveBeenCalledWith('init', undefined, undefined); | | 20 | + expect(wall.send).toHaveBeenCalledWith('reloadAppForProfiling'); | 21 | 21 |
| 22 | 22 | // Should flush pending messages and then shut down. | 23 | 23 | wall.send.mockClear(); | 24 | 24 | bridge.send('update', '1'); | 25 | 25 | bridge.send('update', '2'); | 26 | 26 | bridge.shutdown(); | 27 | 27 | jest.runAllTimers(); | 28 | | - expect(wall.send).toHaveBeenCalledWith('update', '1', undefined); | 29 | | - expect(wall.send).toHaveBeenCalledWith('update', '2', undefined); | 30 | | - expect(wall.send).toHaveBeenCalledWith('shutdown', undefined, undefined); | | 28 | + expect(wall.send).toHaveBeenCalledWith('update', '1'); | | 29 | + expect(wall.send).toHaveBeenCalledWith('update', '2'); | | 30 | + expect(wall.send).toHaveBeenCalledWith('shutdown'); | 31 | 31 |
| 32 | 32 | // Verify that the Bridge doesn't send messages after shutdown. | 33 | 33 | spyOn(console, 'warn'); | |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/inspectedElementContext-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | import typeof ReactTestRenderer from 'react-test-renderer'; | 4 | 4 | import type { GetInspectedElementPath } from 'src/devtools/views/Components/InspectedElementContext'; | 5 | | -import type Bridge from 'src/bridge'; | | 5 | +import type { FrontendBridge } from 'src/bridge'; | 6 | 6 | import type Store from 'src/devtools/store'; | 7 | 7 |
| 8 | 8 | describe('InspectedElementContext', () => { | 9 | 9 | let React; | 10 | 10 | let ReactDOM; | 11 | 11 | let TestRenderer: ReactTestRenderer; | 12 | | - let bridge: Bridge; | | 12 | + let bridge: FrontendBridge; | 13 | 13 | let store: Store; | 14 | 14 | let meta; | 15 | 15 | let utils; | |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/legacy/inspectElement-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | import type { InspectedElementPayload } from 'src/backend/types'; | 4 | 4 | import type { DehydratedData } from 'src/devtools/views/Components/types'; | 5 | | -import type Bridge from 'src/bridge'; | | 5 | +import type { FrontendBridge } from 'src/bridge'; | 6 | 6 | import type Store from 'src/devtools/store'; | 7 | 7 |
| 8 | 8 | describe('InspectedElementContext', () => { | 9 | 9 | let React; | 10 | 10 | let ReactDOM; | 11 | 11 | let hydrate; | 12 | 12 | let meta; | 13 | | - let bridge: Bridge; | | 13 | + let bridge: FrontendBridge; | 14 | 14 | let store: Store; | 15 | 15 |
| 16 | 16 | const act = (callback: Function) => { | |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/ownersListContext-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | import typeof ReactTestRenderer from 'react-test-renderer'; | 4 | 4 | import type { Element } from 'src/devtools/views/Components/types'; | 5 | | -import type Bridge from 'src/bridge'; | | 5 | +import type { FrontendBridge } from 'src/bridge'; | 6 | 6 | import type Store from 'src/devtools/store'; | 7 | 7 |
| 8 | 8 | describe('OwnersListContext', () => { | 9 | 9 | let React; | 10 | 10 | let ReactDOM; | 11 | 11 | let TestRenderer: ReactTestRenderer; | 12 | | - let bridge: Bridge; | | 12 | + let bridge: FrontendBridge; | 13 | 13 | let store: Store; | 14 | 14 | let utils; | 15 | 15 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/profilerContext-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | // @flow | 2 | 2 |
| 3 | 3 | import typeof ReactTestRenderer from 'react-test-renderer'; | 4 | | -import type Bridge from 'src/bridge'; | | 4 | +import type { FrontendBridge } from 'src/bridge'; | 5 | 5 | import type { Context } from 'src/devtools/views/Profiler/ProfilerContext'; | 6 | 6 | import type { DispatcherContext } from 'src/devtools/views/Components/TreeContext'; | 7 | 7 | import type Store from 'src/devtools/store'; | @@ -10,7 +10,7 @@ describe('ProfilerContext', () => { | 10 | 10 | let React; | 11 | 11 | let ReactDOM; | 12 | 12 | let TestRenderer: ReactTestRenderer; | 13 | | - let bridge: Bridge; | | 13 | + let bridge: FrontendBridge; | 14 | 14 | let store: Store; | 15 | 15 | let utils; | 16 | 16 |
| |
|