@tanstack/solid-devtools 0.7.11 → 0.7.12
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.d.ts +9 -1
- package/dist/esm/core.js +18 -3
- package/dist/esm/core.js.map +1 -1
- package/package.json +2 -2
- package/src/core.tsx +30 -3
package/dist/esm/core.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export type TanStackDevtoolsSolidPlugin = Omit<TanStackDevtoolsPlugin, 'render'
|
|
|
42
42
|
*/
|
|
43
43
|
name: string | SolidPluginRender;
|
|
44
44
|
};
|
|
45
|
+
interface TriggerProps {
|
|
46
|
+
theme: 'light' | 'dark';
|
|
47
|
+
}
|
|
45
48
|
export interface TanStackDevtoolsInit {
|
|
46
49
|
/**
|
|
47
50
|
* Array of plugins to be used in the devtools.
|
|
@@ -66,7 +69,12 @@ export interface TanStackDevtoolsInit {
|
|
|
66
69
|
* initial state of the devtools when it is started for the first time. Afterwards,
|
|
67
70
|
* the settings are persisted in local storage and changed through the settings panel.
|
|
68
71
|
*/
|
|
69
|
-
config?: Partial<TanStackDevtoolsConfig
|
|
72
|
+
config?: Omit<Partial<TanStackDevtoolsConfig>, 'customTrigger'> & {
|
|
73
|
+
/**
|
|
74
|
+
* An optional custom function to render the dev tools trigger component.
|
|
75
|
+
*/
|
|
76
|
+
customTrigger?: ((el: HTMLElement, props: TriggerProps) => JSX.Element) | JSX.Element;
|
|
77
|
+
};
|
|
70
78
|
/**
|
|
71
79
|
* Configuration for the TanStack Devtools client event bus.
|
|
72
80
|
*/
|
package/dist/esm/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, template,
|
|
1
|
+
import { createComponent, template, Portal, use } from "solid-js/web";
|
|
2
2
|
import { TanStackDevtoolsCore } from "@tanstack/devtools";
|
|
3
3
|
import { createMemo, createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
4
4
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
@@ -21,15 +21,30 @@ function SolidDevtoolsCore({
|
|
|
21
21
|
),
|
|
22
22
|
render: (el, theme) => convertRender(el, plugin.render, theme)
|
|
23
23
|
})));
|
|
24
|
+
const convertTrigger = (el, props) => {
|
|
25
|
+
const Trigger = config?.customTrigger;
|
|
26
|
+
return createComponent(Portal, {
|
|
27
|
+
mount: el,
|
|
28
|
+
get children() {
|
|
29
|
+
return typeof Trigger === "function" ? Trigger(el, props) : Trigger;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
24
33
|
const [devtools] = createSignal(new TanStackDevtoolsCore({
|
|
25
|
-
config
|
|
34
|
+
config: {
|
|
35
|
+
...config,
|
|
36
|
+
customTrigger: (el, props) => convertTrigger(el, props)
|
|
37
|
+
},
|
|
26
38
|
eventBusConfig,
|
|
27
39
|
plugins: pluginsMap()
|
|
28
40
|
}));
|
|
29
41
|
let devToolRef;
|
|
30
42
|
createEffect(() => {
|
|
31
43
|
devtools().setConfig({
|
|
32
|
-
config
|
|
44
|
+
config: {
|
|
45
|
+
...config,
|
|
46
|
+
customTrigger: (el, props) => convertTrigger(el, props)
|
|
47
|
+
}
|
|
33
48
|
});
|
|
34
49
|
});
|
|
35
50
|
createEffect(() => {
|
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 {\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
|
|
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}\ninterface TriggerProps {\n theme: 'light' | 'dark'\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?: Omit<Partial<TanStackDevtoolsConfig>, 'customTrigger'> & {\n /**\n * An optional custom function to render the dev tools trigger component.\n */\n customTrigger?:\n | ((el: HTMLElement, props: TriggerProps) => JSX.Element)\n | JSX.Element\n }\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 convertTrigger = (el: HTMLElement, props: TriggerProps) => {\n const Trigger = config?.customTrigger\n\n return (\n <Portal mount={el}>\n {typeof Trigger === 'function' ? Trigger(el, props) : Trigger}\n </Portal>\n )\n }\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config: {\n ...config,\n customTrigger: (el, props) => convertTrigger(el, props),\n },\n eventBusConfig,\n plugins: pluginsMap(),\n }),\n )\n let devToolRef: HTMLDivElement | undefined\n\n createEffect(() => {\n devtools().setConfig({\n config: {\n ...config,\n customTrigger: (el, props) => convertTrigger(el, props),\n },\n })\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","convertTrigger","props","Trigger","customTrigger","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;AAyFvE,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,QAAMe,iBAAiBA,CAACjB,IAAiBkB,UAAwB;AAC/D,UAAMC,UAAUX,QAAQY;AAExB,WAAAjB,gBACGC,QAAM;AAAA,MAACC,OAAOL;AAAAA,MAAE,IAAAM,WAAA;AAAA,eACd,OAAOa,YAAY,aAAaA,QAAQnB,IAAIkB,KAAK,IAAIC;AAAAA,MAAO;AAAA,IAAA,CAAA;AAAA,EAGnE;AACA,QAAM,CAACE,QAAQ,IAAIC,aACjB,IAAIC,qBAAqB;AAAA,IACvBf,QAAQ;AAAA,MACN,GAAGA;AAAAA,MACHY,eAAeA,CAACpB,IAAIkB,UAAUD,eAAejB,IAAIkB,KAAK;AAAA,IAAA;AAAA,IAExDR;AAAAA,IACAD,SAASE,WAAAA;AAAAA,EAAW,CACrB,CACH;AACA,MAAIa;AAEJC,eAAa,MAAM;AACjBJ,aAAAA,EAAWK,UAAU;AAAA,MACnBlB,QAAQ;AAAA,QACN,GAAGA;AAAAA,QACHY,eAAeA,CAACpB,IAAIkB,UAAUD,eAAejB,IAAIkB,KAAK;AAAA,MAAA;AAAA,IACxD,CACD;AAAA,EACH,CAAC;AAGDO,eAAa,MAAM;AACjB,UAAME,iBAAiBhB,WAAAA;AACvB,QAAIgB,gBAAgB;AAClBN,eAAAA,EAAWK,UAAU;AAAA,QAAEjB,SAASkB;AAAAA,MAAAA,CAAgB;AAAA,IAClD;AAAA,EACF,CAAC;AAEDC,UAAQ,MAAM;AACZ,QAAIJ,YAAY;AACdH,eAAAA,EAAWhB,MAAMmB,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.12",
|
|
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.
|
|
42
|
+
"@tanstack/devtools": "0.8.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"solid-js": "^1.9.9",
|
package/src/core.tsx
CHANGED
|
@@ -74,6 +74,9 @@ export type TanStackDevtoolsSolidPlugin = Omit<
|
|
|
74
74
|
*/
|
|
75
75
|
name: string | SolidPluginRender
|
|
76
76
|
}
|
|
77
|
+
interface TriggerProps {
|
|
78
|
+
theme: 'light' | 'dark'
|
|
79
|
+
}
|
|
77
80
|
export interface TanStackDevtoolsInit {
|
|
78
81
|
/**
|
|
79
82
|
* Array of plugins to be used in the devtools.
|
|
@@ -98,7 +101,14 @@ export interface TanStackDevtoolsInit {
|
|
|
98
101
|
* initial state of the devtools when it is started for the first time. Afterwards,
|
|
99
102
|
* the settings are persisted in local storage and changed through the settings panel.
|
|
100
103
|
*/
|
|
101
|
-
config?: Partial<TanStackDevtoolsConfig>
|
|
104
|
+
config?: Omit<Partial<TanStackDevtoolsConfig>, 'customTrigger'> & {
|
|
105
|
+
/**
|
|
106
|
+
* An optional custom function to render the dev tools trigger component.
|
|
107
|
+
*/
|
|
108
|
+
customTrigger?:
|
|
109
|
+
| ((el: HTMLElement, props: TriggerProps) => JSX.Element)
|
|
110
|
+
| JSX.Element
|
|
111
|
+
}
|
|
102
112
|
/**
|
|
103
113
|
* Configuration for the TanStack Devtools client event bus.
|
|
104
114
|
*/
|
|
@@ -125,9 +135,21 @@ export default function SolidDevtoolsCore({
|
|
|
125
135
|
})),
|
|
126
136
|
)
|
|
127
137
|
|
|
138
|
+
const convertTrigger = (el: HTMLElement, props: TriggerProps) => {
|
|
139
|
+
const Trigger = config?.customTrigger
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Portal mount={el}>
|
|
143
|
+
{typeof Trigger === 'function' ? Trigger(el, props) : Trigger}
|
|
144
|
+
</Portal>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
128
147
|
const [devtools] = createSignal(
|
|
129
148
|
new TanStackDevtoolsCore({
|
|
130
|
-
config
|
|
149
|
+
config: {
|
|
150
|
+
...config,
|
|
151
|
+
customTrigger: (el, props) => convertTrigger(el, props),
|
|
152
|
+
},
|
|
131
153
|
eventBusConfig,
|
|
132
154
|
plugins: pluginsMap(),
|
|
133
155
|
}),
|
|
@@ -135,7 +157,12 @@ export default function SolidDevtoolsCore({
|
|
|
135
157
|
let devToolRef: HTMLDivElement | undefined
|
|
136
158
|
|
|
137
159
|
createEffect(() => {
|
|
138
|
-
devtools().setConfig({
|
|
160
|
+
devtools().setConfig({
|
|
161
|
+
config: {
|
|
162
|
+
...config,
|
|
163
|
+
customTrigger: (el, props) => convertTrigger(el, props),
|
|
164
|
+
},
|
|
165
|
+
})
|
|
139
166
|
})
|
|
140
167
|
|
|
141
168
|
// Update plugins when they change
|