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

Function createAppCtx

packages/frontend/src/controller.tsx:107–294  ·  view source on GitHub ↗
(props: DevtoolsOptions)

Source from the content-addressed store, hash-verified

105}
106
107function createAppCtx(props: DevtoolsOptions) {
108
109 let output_listeners: OutputListener[] = []
110 const output: OutputEventBus = {
111 listen(listener) {
112 output_listeners.push(listener)
113 s.onCleanup(() => {
114 mutate_remove(output_listeners, listener)
115 })
116 },
117 emit(e) {
118 s.batch(() => {
119 for (let fn of output_listeners) {
120 fn(e)
121 }
122 })
123 },
124 }
125
126 let input_listeners: InputListener[] = []
127 const input: InputEventBus = {
128 listen(listener) {
129 input_listeners.push(listener)
130 s.onCleanup(() => {
131 mutate_remove(input_listeners, listener)
132 })
133 },
134 emit(e) {
135 s.batch(() => {
136 for (let fn of input_listeners) {
137 fn(e)
138 }
139 })
140 },
141 }
142
143 let options: DevtoolsOptionsWithDefaults = {
144 errorOverlayFooter: props.errorOverlayFooter ?? (() => null),
145 headerSubtitle: props.headerSubtitle ?? (() => null),
146 useShortcuts: props.useShortcuts ?? false,
147 catchWindowErrors: props.catchWindowErrors ?? false,
148 }
149
150 //
151 // LOCATOR
152 //
153 const [devtoolsLocatorEnabled, setDevtoolsLocatorState] = s.createSignal(false)
154 const [clientLocatorEnabled, setClientLocator] = s.createSignal(false)
155 const locatorEnabled = () => devtoolsLocatorEnabled() || clientLocatorEnabled()
156
157 // send devtools locator state
158 s.createEffect(defer(devtoolsLocatorEnabled, enabled => {
159 output.emit({
160 kind: 'ToggleModule',
161 data: {module: debug.DebuggerModule.Locator, enabled}
162 })
163 }))
164

Callers 1

createDevtoolsFunction · 0.85

Calls 4

msgFunction · 0.90
createViewCacheFunction · 0.85
setClientLocatorStateFunction · 0.85
createInspectorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…