MCPcopy Create free account
hub / github.com/TanStack/devtools / SolidDevtoolsCore

Function SolidDevtoolsCore

packages/solid-devtools/src/core.tsx:120–192  ·  view source on GitHub ↗
({
  config,
  plugins,
  eventBusConfig,
}: TanStackDevtoolsInit)

Source from the content-addressed store, hash-verified

118}
119interface TanStackDevtoolsInit {
120 /**
121 * Array of plugins to be used in the devtools.
122 * Each plugin should have a `render` function that returns a Solid element or a function
123 *
124 * Example:
125 * ```jsx
126 * <TanStackDevtools
127 * plugins={[
128 * {
129 * id: "your-plugin-id",
130 * name: "Your Plugin",
131 * render: <CustomPluginComponent />,
132 * }
133 * ]}
134 * />
135 * ```
136 */
137 plugins?: Array<TanStackDevtoolsSolidPlugin>
138 /**
139 * Configuration for the devtools shell. These configuration options are used to set the
140 * initial state of the devtools when it is started for the first time. Afterwards,
141 * the settings are persisted in local storage and changed through the settings panel.
142 */
143 config?: Omit<Partial<TanStackDevtoolsConfig>, 'customTrigger'> & {
144 /**
145 * An optional custom function to render the dev tools trigger component.
146 */
147 customTrigger?:
148 | ((el: HTMLElement, props: TriggerProps) => SolidElement)
149 | SolidElement
150 }
151 /**
152 * Configuration for the TanStack Devtools client event bus.
153 */
154 eventBusConfig?: ClientEventBusConfig
155}
156
157/**
158 * Renders nothing. After the first render it mounts the devtools shell into an
159 * element at the end of `<body>`, so server and client output always match.
160 */
161export default function SolidDevtoolsCore(props: TanStackDevtoolsInit) {
162 // The shell calls `render`, `name` and `customTrigger` from its own
163 // effects, on its own copy of Solid. Each mount node gets a root owned by
164 // this component, so plugins see the app's context and are disposed with
165 // it. A new call replaces the node's previous root.
166 const owner = getOwner()
167 const mounts = new Map<Element, () => void>()
168 const mountInto = (el: Element, content: () => unknown) => {
169 mounts.get(el)?.()
170 runWithOwner(owner, () =>
171 createRoot((dispose) => {
172 mounts.set(el, () => {
173 dispose()
174 el.replaceChildren()
175 mounts.delete(el)
176 })
177 const resolved = children(content as () => any)

Callers

nothing calls this directly

Calls 6

devtoolsFunction · 0.85
setConfigMethod · 0.80
convertRenderFunction · 0.70
convertTriggerFunction · 0.70
mountMethod · 0.45
unmountMethod · 0.45

Tested by

no test coverage detected