MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / createDependencyGraph

Function createDependencyGraph

packages/frontend/src/dgraph.tsx:10–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import * as ui from './ui/index.ts'
9
10export function createDependencyGraph() {
11 const ctx = useAppCtx()
12
13 const [graph, setGraph] = s.createSignal<debug.DGraphUpdate>(null)
14
15 ctx.input.listen(e => {
16 // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
17 switch (e.kind) {
18 case 'DgraphUpdate':
19 setGraph(e.data)
20 break
21 }
22 })
23
24 ctx.output.emit(msg('ToggleModule', {module: debug.DebuggerModule.Dgraph, enabled: true}))
25 s.onCleanup(() => {
26 ctx.output.emit(msg('ToggleModule', {module: debug.DebuggerModule.Dgraph, enabled: false}))
27 })
28
29 function inspectNode(id: debug.NodeID) {
30 const node = graph()?.[id]
31 // eslint-disable-next-line no-console
32 if (!node) return console.warn('inspectNode: node not found', id)
33
34 if (node.type === debug.NodeType.Signal) {
35 ctx.inspector.setInspectedNode(node.graph ?? null, id)
36 } else {
37 ctx.inspector.setInspectedOwner(id)
38 }
39 }
40
41 return {
42 graph,
43 inspectNode,
44 }
45}
46
47type NodeOrder = {
48 flowOrder: readonly debug.NodeID[]

Callers 1

Dgraph_ViewFunction · 0.70

Calls 2

useAppCtxFunction · 0.90
msgFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…