-
Notifications
You must be signed in to change notification settings - Fork 479
[LWDM] feat(devtools): wire LLD and LWM into devtools WebSocket transport #20267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| --- | ||
| "ledger-live-desktop": minor | ||
| "live-mobile": minor | ||
| --- | ||
|
|
||
| Add debug WebSocket transport to DevTools relay |
This file contains hidden or 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 hidden or 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
11 changes: 9 additions & 2 deletions
11
apps/ledger-live-desktop/src/mvvm/features/DevTools/screens/DevToolsScreen/index.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -1,16 +1,23 @@ | ||
| import React from "react"; | ||
| import { DevTools } from "@devtools/shell"; | ||
| import { TransportPanel } from "@devtools/transport-panel"; | ||
| import { useDevToolsScreenViewModel } from "./useDevToolsScreenViewModel"; | ||
|
|
||
| export default function DevToolsScreen() { | ||
| const { config, onClose } = useDevToolsScreenViewModel(); | ||
| const { config, onClose, transport, hubUrl, setHubUrl, role } = useDevToolsScreenViewModel(); | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ display: "flex", flexDirection: "column", flex: 1, minHeight: 0 }} | ||
| className="rounded-md overflow-hidden" | ||
| > | ||
| <DevTools config={config} onClose={onClose} /> | ||
| <DevTools | ||
| config={config} | ||
| onClose={onClose} | ||
| footer={ | ||
| <TransportPanel transport={transport} hubUrl={hubUrl} setHubUrl={setHubUrl} role={role} /> | ||
| } | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
...ledger-live-desktop/src/mvvm/features/DevTools/screens/DevToolsScreen/useDevToolsRelay.ts
This file contains hidden or 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,23 @@ | ||
| import { useSyncExternalStore } from "react"; | ||
| import { buildTransport, buildCopyStoreProtocol, combineProtocols } from "@devtools/wire"; | ||
| import { sleepingListener } from "~/state-manager/sleepingListener"; | ||
| import { useStore } from "LLD/hooks/redux"; | ||
|
|
||
| const HUB_URL = "ws://127.0.0.1:9090"; | ||
| const ROLE = "host" as const; | ||
|
|
||
| function buildRelay(store: ReturnType<typeof useStore>) { | ||
| return buildTransport( | ||
| { hubUrl: HUB_URL, role: ROLE, id: "lld" }, | ||
| combineProtocols(buildCopyStoreProtocol(store, sleepingListener, ROLE)), | ||
| ); | ||
| } | ||
|
|
||
| let relay: ReturnType<typeof buildRelay> | undefined; | ||
|
|
||
| export function useDevToolsRelay() { | ||
| const store = useStore(); | ||
| if (!relay) relay = buildRelay(store); | ||
| const wireState = useSyncExternalStore(relay.subscribe, relay.getState, relay.getState); | ||
| return { wire: relay, wireState }; | ||
| } | ||
|
Sebastien-Dav1d marked this conversation as resolved.
|
||
This file contains hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
apps/ledger-live-desktop/src/state-manager/sleepingListener.ts
This file contains hidden or 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,3 @@ | ||
| import { createListenerMiddleware } from "@reduxjs/toolkit"; | ||
|
|
||
| export const sleepingListener = createListenerMiddleware(); | ||
|
Sebastien-Dav1d marked this conversation as resolved.
|
||
This file contains hidden or 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 hidden or 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
14 changes: 12 additions & 2 deletions
14
apps/ledger-live-mobile/src/mvvm/features/DevTools/screens/DevToolsScreen/index.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| import React from "react"; | ||
| import { DevTools } from "@devtools/shell"; | ||
| import { TransportPanel } from "@devtools/transport-panel"; | ||
| import { useDevToolsScreenViewModel } from "./useDevToolsScreenViewModel"; | ||
|
|
||
| export default function DevToolsScreen() { | ||
| const { config, screenOptions } = useDevToolsScreenViewModel(); | ||
| const { config, screenOptions, transport, hubUrl, setHubUrl, role } = | ||
| useDevToolsScreenViewModel(); | ||
|
|
||
|
Sebastien-Dav1d marked this conversation as resolved.
|
||
| return <DevTools config={config} screenOptions={screenOptions} />; | ||
| return ( | ||
| <DevTools | ||
| config={config} | ||
| screenOptions={screenOptions} | ||
| footer={ | ||
| <TransportPanel transport={transport} hubUrl={hubUrl} setHubUrl={setHubUrl} role={role} /> | ||
| } | ||
| /> | ||
| ); | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
.../ledger-live-mobile/src/mvvm/features/DevTools/screens/DevToolsScreen/useDevToolsRelay.ts
This file contains hidden or 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,22 @@ | ||
| import { useSyncExternalStore } from "react"; | ||
| import { buildTransport, buildCopyStoreProtocol, combineProtocols } from "@devtools/wire"; | ||
| import { store } from "~/state-manager/configureStore"; | ||
| import { sleepingListener } from "~/state-manager/sleepingListener"; | ||
|
|
||
| const HUB_URL = "ws://127.0.0.1:9090"; | ||
| const ROLE = "host" as const; | ||
|
|
||
| function buildRelay() { | ||
| return buildTransport( | ||
| { hubUrl: HUB_URL, role: ROLE, id: "lwm" }, | ||
| combineProtocols(buildCopyStoreProtocol(store, sleepingListener, ROLE)), | ||
| ); | ||
| } | ||
|
|
||
| let relay: ReturnType<typeof buildRelay> | undefined; | ||
|
|
||
| export function useDevToolsRelay() { | ||
| if (!relay) relay = buildRelay(); | ||
| const wireState = useSyncExternalStore(relay.subscribe, relay.getState, relay.getState); | ||
| return { wire: relay, wireState }; | ||
|
Sebastien-Dav1d marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
apps/ledger-live-mobile/src/state-manager/sleepingListener.ts
This file contains hidden or 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,3 @@ | ||
| import { createListenerMiddleware } from "@reduxjs/toolkit"; | ||
|
|
||
| export const sleepingListener = createListenerMiddleware(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.