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

Function Dgraph_View

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

Source from the content-addressed store, hash-verified

215}
216
217export function Dgraph_View(): s.JSX.Element {
218 const ctx = useAppCtx()
219 const {inspector, hovered} = ctx
220 const dgraph = createDependencyGraph()
221
222 const order = s.createMemo<NodeOrder | null>((p = null) => {
223 const graph = dgraph.graph()
224 if (!graph) return null
225
226 return s.untrack(() => {
227 const inspectedId = inspector.inspected.signalId ?? inspector.inspected.ownerId
228 if (!inspectedId) return p
229
230 const inspectedNode = graph[inspectedId]
231 if (!inspectedNode) return p
232
233 return calculateNodeOrder(graph, inspectedId, inspectedNode)
234 })
235 })
236
237 const thereIsAHoveredNode = s.createMemo(() => !!hovered.hoveredId())
238
239 const pattern_size = '1px'
240 const pattern = `${theme.vars.panel[2]} 0,
241 ${theme.vars.panel[2]} ${pattern_size},
242 transparent ${pattern_size},
243 transparent ${grid_size}`
244
245 return (
246 <ui.Scrollable contentProps={{class: 'flex bg-panel-1'}}>
247 <div
248 class="relative min-h-full min-w-full flex flex-col items-start"
249 style={{padding: `calc(${grid_size} - ${pattern_size})`}}
250 >
251 <div
252 class="absolute inset-0 opacity-70"
253 style={{
254 background: `repeating-linear-gradient(${pattern}), repeating-linear-gradient(90deg, ${pattern})`,
255 'background-position': `-${pattern_size} -${pattern_size}`,
256 }}
257 />
258 <s.Show when={dgraph.graph() && order()}>{s.untrack(() => {
259 const flowOrder = (): readonly debug.NodeID[] => order()!.flowOrder
260 const depthMap = (): Record<debug.NodeID, number> => order()!.depthMap
261 const length = (): number => flowOrder().length
262 return <>
263 <s.For each={flowOrder()}>{id => (
264 <GraphNode
265 id={id}
266 depth={depthMap()[id]!}
267 node={dgraph.graph()![id]!}
268 isInspected={inspector.isInspected(id)}
269 onInspect={() => dgraph.inspectNode(id)}
270 isHovered={hovered.isNodeHovered(id)}
271 onHoverChange={state => hovered.toggleHoveredNode(id, 'node', state)}
272 listenToUpdate={listener => ctx.listenToNodeUpdate(id, listener)}
273 />
274 )}</s.For>

Callers

nothing calls this directly

Calls 6

useAppCtxFunction · 0.90
calculateNodeOrderFunction · 0.85
flowOrderFunction · 0.85
depthMapFunction · 0.85
createDependencyGraphFunction · 0.70
lengthFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…