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

Function createDebugger

packages/debugger/src/main/index.ts:26–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24import { isSolidComponent, isSolidRoot } from './utils.ts'
25
26function createDebugger() {
27 assert(globalThis.SolidDevtools$$, 'solid-devtools is not setup')
28
29 const _output_listeners: OutputListener[] = []
30
31 function listen(listener: OutputListener): (() => void) {
32 _output_listeners.push(listener)
33 return () => mutate_remove(_output_listeners, listener)
34 }
35
36 function emitOutput(e: OutputMessage) {
37
38 DEV: {log_message('Client', 'Debugger', e)}
39
40 for (let fn of _output_listeners) fn(e)
41 }
42
43 //
44 // Debugger Enabled
45 //
46 const [modules, toggleModules] = createStaticStore({
47 debugger: false,
48 locator: false,
49 dgraph: false,
50 locatorKeyPressSignal: (): boolean => false,
51 })
52
53 // The debugger can be enabled by devtools or by the locator
54 const debuggerEnabled = s.createMemo(
55 () => modules.debugger || modules.locatorKeyPressSignal()
56 )
57 const dgraphEnabled = s.createMemo(
58 () => modules.dgraph && debuggerEnabled()
59 )
60 // locator is enabled if debugger is enabled, and user pressed the key to activate it, or the plugin activated it
61 const locatorEnabled = s.createMemo(
62 () => (modules.locatorKeyPressSignal() || modules.locator) && debuggerEnabled(),
63 )
64
65 s.createEffect(defer(debuggerEnabled, enabled => {
66 emitOutput(msg('DebuggerEnabled', enabled))
67 }))
68
69 //
70 // Current Open VIEW (currently not used)
71 //
72 let currentView: DevtoolsMainView = DEFAULT_MAIN_VIEW
73
74 //
75 // Enabled Modules
76 //
77 function toggleModule(data: InputChannels['ToggleModule']): void {
78 switch (data.module) {
79 case DebuggerModule.Structure:
80 // * Structure is always enabled
81 break
82 case DebuggerModule.Dgraph:
83 toggleModules('dgraph', data.enabled)

Callers 1

useDebuggerFunction · 0.85

Calls 9

assertFunction · 0.90
msgFunction · 0.90
createStructureFunction · 0.90
createInspectorFunction · 0.90
createDependencyGraphFunction · 0.90
createLocatorFunction · 0.90
attachDebuggerFunction · 0.90
emitOutputFunction · 0.85
handleCreatedOwnerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…