@tanstack/solid-devtools 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core.js +18 -9
- package/dist/esm/core.js.map +1 -1
- package/package.json +2 -2
- package/src/core.tsx +33 -12
package/dist/esm/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createComponent, template, use, Portal } from "solid-js/web";
|
|
2
2
|
import { TanStackDevtoolsCore } from "@tanstack/devtools";
|
|
3
|
-
import { createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
3
|
+
import { createMemo, createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
4
4
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
5
5
|
const convertRender = (el, Component, theme) => createComponent(Portal, {
|
|
6
6
|
mount: el,
|
|
@@ -13,17 +13,18 @@ function SolidDevtoolsCore({
|
|
|
13
13
|
plugins,
|
|
14
14
|
eventBusConfig
|
|
15
15
|
}) {
|
|
16
|
+
const pluginsMap = createMemo(() => plugins?.map((plugin) => ({
|
|
17
|
+
...plugin,
|
|
18
|
+
name: typeof plugin.name === "string" ? plugin.name : (
|
|
19
|
+
// The check above confirms that `plugin.name` is of Render type
|
|
20
|
+
((el, theme) => convertRender(el, plugin.name, theme))
|
|
21
|
+
),
|
|
22
|
+
render: (el, theme) => convertRender(el, plugin.render, theme)
|
|
23
|
+
})));
|
|
16
24
|
const [devtools] = createSignal(new TanStackDevtoolsCore({
|
|
17
25
|
config,
|
|
18
26
|
eventBusConfig,
|
|
19
|
-
plugins:
|
|
20
|
-
...plugin,
|
|
21
|
-
name: typeof plugin.name === "string" ? plugin.name : (
|
|
22
|
-
// The check above confirms that `plugin.name` is of Render type
|
|
23
|
-
((el, theme) => convertRender(el, plugin.name, theme))
|
|
24
|
-
),
|
|
25
|
-
render: (el, theme) => convertRender(el, plugin.render, theme)
|
|
26
|
-
}))
|
|
27
|
+
plugins: pluginsMap()
|
|
27
28
|
}));
|
|
28
29
|
let devToolRef;
|
|
29
30
|
createEffect(() => {
|
|
@@ -31,6 +32,14 @@ function SolidDevtoolsCore({
|
|
|
31
32
|
config
|
|
32
33
|
});
|
|
33
34
|
});
|
|
35
|
+
createEffect(() => {
|
|
36
|
+
const currentPlugins = pluginsMap();
|
|
37
|
+
if (currentPlugins) {
|
|
38
|
+
devtools().setConfig({
|
|
39
|
+
plugins: currentPlugins
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
34
43
|
onMount(() => {
|
|
35
44
|
if (devToolRef) {
|
|
36
45
|
devtools().mount(devToolRef);
|
package/dist/esm/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../src/core.tsx"],"sourcesContent":["import { TanStackDevtoolsCore } from '@tanstack/devtools'\nimport {
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/core.tsx"],"sourcesContent":["import { TanStackDevtoolsCore } from '@tanstack/devtools'\nimport {\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n onMount,\n} from 'solid-js'\nimport { Portal } from 'solid-js/web'\nimport type { JSX } from 'solid-js'\nimport type {\n ClientEventBusConfig,\n TanStackDevtoolsConfig,\n TanStackDevtoolsPlugin,\n} from '@tanstack/devtools'\n\ntype SolidPluginRender =\n | JSX.Element\n | ((\n el: HTMLDivElement | HTMLHeadingElement,\n theme: 'dark' | 'light',\n ) => JSX.Element)\nconst convertRender = (\n el: HTMLDivElement | HTMLHeadingElement,\n Component: SolidPluginRender,\n theme: 'dark' | 'light',\n) => (\n <Portal mount={el}>\n {typeof Component === 'function' ? Component(el, theme) : Component}\n </Portal>\n)\n\nexport type TanStackDevtoolsSolidPlugin = Omit<\n TanStackDevtoolsPlugin,\n 'render' | 'name'\n> & {\n /**\n * The render function can be a SolidJS element or a function that returns a SolidJS element.\n * If it's a function, it will be called to render the plugin, otherwise it will be rendered directly.\n *\n * Example:\n * ```ts\n * {\n * render: () => <CustomPluginComponent />,\n * }\n * ```\n * or\n * ```ts\n * {\n * render: <CustomPluginComponent />,\n * }\n * ```\n */\n render: SolidPluginRender\n /**\n * Name to be displayed in the devtools UI.\n * If a string, it will be used as the plugin name.\n * If a function, it will be called with the mount element.\n *\n * Example:\n * ```ts\n * {\n * name: \"Your Plugin\",\n * render: () => <CustomPluginComponent />,\n * }\n * ```\n * or\n * ```ts\n * {\n * name: <h1>Your Plugin title</h1>,\n * render: () => <CustomPluginComponent />,\n * }\n * ```\n */\n name: string | SolidPluginRender\n}\nexport interface TanStackDevtoolsInit {\n /**\n * Array of plugins to be used in the devtools.\n * Each plugin should have a `render` function that returns a React element or a function\n *\n * Example:\n * ```jsx\n * <TanStackDevtools\n * plugins={[\n * {\n * id: \"your-plugin-id\",\n * name: \"Your Plugin\",\n * render: <CustomPluginComponent />,\n * }\n * ]}\n * />\n * ```\n */\n plugins?: Array<TanStackDevtoolsSolidPlugin>\n /**\n * Configuration for the devtools shell. These configuration options are used to set the\n * initial state of the devtools when it is started for the first time. Afterwards,\n * the settings are persisted in local storage and changed through the settings panel.\n */\n config?: Partial<TanStackDevtoolsConfig>\n /**\n * Configuration for the TanStack Devtools client event bus.\n */\n eventBusConfig?: ClientEventBusConfig\n}\n\nexport default function SolidDevtoolsCore({\n config,\n plugins,\n eventBusConfig,\n}: TanStackDevtoolsInit) {\n // Convert plugins to the format expected by the core\n const pluginsMap = createMemo<Array<TanStackDevtoolsPlugin> | undefined>(() =>\n plugins?.map((plugin) => ({\n ...plugin,\n name:\n typeof plugin.name === 'string'\n ? plugin.name\n : // The check above confirms that `plugin.name` is of Render type\n (el, theme) =>\n convertRender(el, plugin.name as SolidPluginRender, theme),\n render: (el: HTMLDivElement, theme: 'dark' | 'light') =>\n convertRender(el, plugin.render, theme),\n })),\n )\n\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config,\n eventBusConfig,\n plugins: pluginsMap(),\n }),\n )\n let devToolRef: HTMLDivElement | undefined\n\n createEffect(() => {\n devtools().setConfig({ config })\n })\n\n // Update plugins when they change\n createEffect(() => {\n const currentPlugins = pluginsMap()\n if (currentPlugins) {\n devtools().setConfig({ plugins: currentPlugins })\n }\n })\n\n onMount(() => {\n if (devToolRef) {\n devtools().mount(devToolRef)\n\n onCleanup(() => {\n devtools().unmount()\n })\n }\n })\n return <div style={{ position: 'absolute' }} ref={devToolRef} />\n}\n"],"names":["convertRender","el","Component","theme","_$createComponent","Portal","mount","children","SolidDevtoolsCore","config","plugins","eventBusConfig","pluginsMap","createMemo","map","plugin","name","render","devtools","createSignal","TanStackDevtoolsCore","devToolRef","createEffect","setConfig","currentPlugins","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use","style","setProperty"],"mappings":";;;;AAsBA,MAAMA,gBAAgBA,CACpBC,IACAC,WACAC,UAAuBC,gBAEtBC,QAAM;AAAA,EAACC,OAAOL;AAAAA,EAAE,IAAAM,WAAA;AAAA,WACd,OAAOL,cAAc,aAAaA,UAAUD,IAAIE,KAAK,IAAID;AAAAA,EAAS;AAAA,CAAA;AA+EvE,SAAwBM,kBAAkB;AAAA,EACxCC;AAAAA,EACAC;AAAAA,EACAC;AACoB,GAAG;AAEvB,QAAMC,aAAaC,WAAsD,MACvEH,SAASI,IAAKC,CAAAA,YAAY;AAAA,IACxB,GAAGA;AAAAA,IACHC,MACE,OAAOD,OAAOC,SAAS,WACnBD,OAAOC;AAAAA;AAAAA,OAEP,CAACf,IAAIE,UACHH,cAAcC,IAAIc,OAAOC,MAA2Bb,KAAK;AAAA;AAAA,IACjEc,QAAQA,CAAChB,IAAoBE,UAC3BH,cAAcC,IAAIc,OAAOE,QAAQd,KAAK;AAAA,EAAA,EACxC,CACJ;AAEA,QAAM,CAACe,QAAQ,IAAIC,aACjB,IAAIC,qBAAqB;AAAA,IACvBX;AAAAA,IACAE;AAAAA,IACAD,SAASE,WAAAA;AAAAA,EAAW,CACrB,CACH;AACA,MAAIS;AAEJC,eAAa,MAAM;AACjBJ,aAAAA,EAAWK,UAAU;AAAA,MAAEd;AAAAA,IAAAA,CAAQ;AAAA,EACjC,CAAC;AAGDa,eAAa,MAAM;AACjB,UAAME,iBAAiBZ,WAAAA;AACvB,QAAIY,gBAAgB;AAClBN,eAAAA,EAAWK,UAAU;AAAA,QAAEb,SAASc;AAAAA,MAAAA,CAAgB;AAAA,IAClD;AAAA,EACF,CAAC;AAEDC,UAAQ,MAAM;AACZ,QAAIJ,YAAY;AACdH,eAAAA,EAAWZ,MAAMe,UAAU;AAE3BK,gBAAU,MAAM;AACdR,iBAAAA,EAAWS,QAAAA;AAAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,UAAA,MAAA;AAAA,QAAAC,OAAAC,OAAAA;AAAA,QAAAC,QAAkDT;AAAU,WAAAS,UAAA,aAAAC,IAAAD,OAAAF,IAAA,IAAVP,aAAUO;AAAAA,SAAAI,MAAAC,YAAA,YAAA,UAAA;AAAA,WAAAL;AAAAA,EAAA,GAAA;AAC9D;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-devtools",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "TanStack Devtools is a set of tools for building advanced devtools for your Solid application.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"src"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tanstack/devtools": "0.6.
|
|
42
|
+
"@tanstack/devtools": "0.6.22"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"solid-js": "^1.9.9",
|
package/src/core.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { TanStackDevtoolsCore } from '@tanstack/devtools'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createEffect,
|
|
4
|
+
createMemo,
|
|
5
|
+
createSignal,
|
|
6
|
+
onCleanup,
|
|
7
|
+
onMount,
|
|
8
|
+
} from 'solid-js'
|
|
3
9
|
import { Portal } from 'solid-js/web'
|
|
4
10
|
import type { JSX } from 'solid-js'
|
|
5
11
|
import type {
|
|
@@ -104,27 +110,42 @@ export default function SolidDevtoolsCore({
|
|
|
104
110
|
plugins,
|
|
105
111
|
eventBusConfig,
|
|
106
112
|
}: TanStackDevtoolsInit) {
|
|
113
|
+
// Convert plugins to the format expected by the core
|
|
114
|
+
const pluginsMap = createMemo<Array<TanStackDevtoolsPlugin> | undefined>(() =>
|
|
115
|
+
plugins?.map((plugin) => ({
|
|
116
|
+
...plugin,
|
|
117
|
+
name:
|
|
118
|
+
typeof plugin.name === 'string'
|
|
119
|
+
? plugin.name
|
|
120
|
+
: // The check above confirms that `plugin.name` is of Render type
|
|
121
|
+
(el, theme) =>
|
|
122
|
+
convertRender(el, plugin.name as SolidPluginRender, theme),
|
|
123
|
+
render: (el: HTMLDivElement, theme: 'dark' | 'light') =>
|
|
124
|
+
convertRender(el, plugin.render, theme),
|
|
125
|
+
})),
|
|
126
|
+
)
|
|
127
|
+
|
|
107
128
|
const [devtools] = createSignal(
|
|
108
129
|
new TanStackDevtoolsCore({
|
|
109
130
|
config,
|
|
110
131
|
eventBusConfig,
|
|
111
|
-
plugins:
|
|
112
|
-
...plugin,
|
|
113
|
-
name:
|
|
114
|
-
typeof plugin.name === 'string'
|
|
115
|
-
? plugin.name
|
|
116
|
-
: // The check above confirms that `plugin.name` is of Render type
|
|
117
|
-
(el, theme) =>
|
|
118
|
-
convertRender(el, plugin.name as SolidPluginRender, theme),
|
|
119
|
-
render: (el: HTMLDivElement, theme: 'dark' | 'light') =>
|
|
120
|
-
convertRender(el, plugin.render, theme),
|
|
121
|
-
})),
|
|
132
|
+
plugins: pluginsMap(),
|
|
122
133
|
}),
|
|
123
134
|
)
|
|
124
135
|
let devToolRef: HTMLDivElement | undefined
|
|
136
|
+
|
|
125
137
|
createEffect(() => {
|
|
126
138
|
devtools().setConfig({ config })
|
|
127
139
|
})
|
|
140
|
+
|
|
141
|
+
// Update plugins when they change
|
|
142
|
+
createEffect(() => {
|
|
143
|
+
const currentPlugins = pluginsMap()
|
|
144
|
+
if (currentPlugins) {
|
|
145
|
+
devtools().setConfig({ plugins: currentPlugins })
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
128
149
|
onMount(() => {
|
|
129
150
|
if (devToolRef) {
|
|
130
151
|
devtools().mount(devToolRef)
|