-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): module update track for graph page (#195)
Co-authored-by: arlo <[email protected]>
- Loading branch information
1 parent
93b33b8
commit 98fc8ed
Showing
12 changed files
with
337 additions
and
43 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import type { ViteInspectAPI } from 'vite-plugin-inspect' | ||
import type { ModuleInfo } from './types' | ||
import { debounce } from 'perfect-debounce' | ||
import type { BirpcGroupReturn } from 'birpc' | ||
import type { ModuleInfo, ViteRPCFunctions } from './types' | ||
|
||
export interface SetupGraphOptions { | ||
rpc: ViteInspectAPI['rpc'] | ||
server: any | ||
getRpcServer: () => BirpcGroupReturn<ViteRPCFunctions> | ||
} | ||
export function setupGraphRPC(options: SetupGraphOptions) { | ||
const { rpc } = options | ||
const { rpc, server, getRpcServer } = options | ||
|
||
const debouncedModuleUpdated = debounce(() => { | ||
getRpcServer().moduleUpdated() | ||
}, 100) | ||
|
||
server.middlewares.use((req, res, next) => { | ||
debouncedModuleUpdated() | ||
next() | ||
}) | ||
|
||
return { | ||
async getGraph(): Promise<ModuleInfo[]> { | ||
const list = await rpc.list() | ||
const modules = list?.modules || [] | ||
|
||
return modules | ||
}, | ||
moduleUpdated: () => {}, | ||
} | ||
} |
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
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
Oops, something went wrong.