@tanstack/solid-devtools 0.0.0 → 0.1.1
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/README.md +51 -0
- package/dist/cjs/devtools.cjs +25 -4
- package/dist/cjs/devtools.cjs.map +1 -1
- package/dist/cjs/devtools.d.cts +72 -2
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/esm/devtools.d.ts +72 -2
- package/dist/esm/devtools.js +27 -6
- package/dist/esm/devtools.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -2
- package/package.json +6 -11
- package/src/devtools.tsx +104 -5
- package/src/index.ts +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @tanstack/solid-devtools
|
|
2
|
+
|
|
3
|
+
This package is still under active development and might have breaking changes in the future. Please use it with caution.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { TanstackDevtools } from '@tanstack/solid-devtools'
|
|
9
|
+
import { TanStackRouterDevtoolsPanel } from '@tanstack/solid-router-devtools'
|
|
10
|
+
|
|
11
|
+
function App() {
|
|
12
|
+
return (
|
|
13
|
+
<div>
|
|
14
|
+
<h1>My App</h1>
|
|
15
|
+
<TanstackDevtools
|
|
16
|
+
plugins={[
|
|
17
|
+
{
|
|
18
|
+
name: 'Tanstack Router',
|
|
19
|
+
render: <TanStackRouterDevtoolsPanel router={router} />,
|
|
20
|
+
},
|
|
21
|
+
]}
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Creating plugins
|
|
29
|
+
|
|
30
|
+
In order to create a plugin for TanStack Devtools, you can use the `plugins` prop of the `TanstackDevtools` component. Here's an example of how to create a simple plugin:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { TanstackDevtools } from '@tanstack/solid-devtools'
|
|
34
|
+
|
|
35
|
+
function App() {
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<h1>My App</h1>
|
|
39
|
+
<TanstackDevtools
|
|
40
|
+
plugins={[
|
|
41
|
+
{
|
|
42
|
+
id: 'your-plugin-id',
|
|
43
|
+
name: 'Your Plugin',
|
|
44
|
+
render: <CustomPluginComponent />,
|
|
45
|
+
},
|
|
46
|
+
]}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
```
|
package/dist/cjs/devtools.cjs
CHANGED
|
@@ -4,11 +4,32 @@ const web = require("solid-js/web");
|
|
|
4
4
|
const devtools = require("@tanstack/devtools");
|
|
5
5
|
const solidJs = require("solid-js");
|
|
6
6
|
var _tmpl$ = /* @__PURE__ */ web.template(`<div>`);
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const convertRender = (el, Component) => web.createComponent(web.Portal, {
|
|
8
|
+
mount: el,
|
|
9
|
+
get children() {
|
|
10
|
+
return typeof Component === "function" ? web.createComponent(Component, {}) : Component;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const TanstackDevtools = ({
|
|
14
|
+
config,
|
|
15
|
+
plugins
|
|
16
|
+
}) => {
|
|
17
|
+
const [devtools$1] = solidJs.createSignal(new devtools.TanStackDevtoolsCore({
|
|
18
|
+
config,
|
|
19
|
+
plugins: plugins?.map((plugin) => ({
|
|
20
|
+
...plugin,
|
|
21
|
+
name: typeof plugin.name === "string" ? plugin.name : (
|
|
22
|
+
// The check above confirms that `plugin.name` is of Render type
|
|
23
|
+
(el) => convertRender(el, plugin.name)
|
|
24
|
+
),
|
|
25
|
+
render: (el) => convertRender(el, plugin.render)
|
|
26
|
+
}))
|
|
27
|
+
}));
|
|
9
28
|
let devToolRef;
|
|
10
29
|
solidJs.createEffect(() => {
|
|
11
|
-
devtools$1().
|
|
30
|
+
devtools$1().setConfig({
|
|
31
|
+
config
|
|
32
|
+
});
|
|
12
33
|
});
|
|
13
34
|
solidJs.onMount(() => {
|
|
14
35
|
if (devToolRef) {
|
|
@@ -25,5 +46,5 @@ const Devtools = (opts) => {
|
|
|
25
46
|
return _el$;
|
|
26
47
|
})();
|
|
27
48
|
};
|
|
28
|
-
exports.
|
|
49
|
+
exports.TanstackDevtools = TanstackDevtools;
|
|
29
50
|
//# sourceMappingURL=devtools.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.cjs","sources":["../../src/devtools.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"devtools.cjs","sources":["../../src/devtools.tsx"],"sourcesContent":["import { TanStackDevtoolsCore } from '@tanstack/devtools'\nimport { createEffect, createSignal, onCleanup, onMount } from 'solid-js'\nimport { Portal } from 'solid-js/web'\nimport type { JSX } from 'solid-js'\nimport type {\n TanStackDevtoolsConfig,\n TanStackDevtoolsPlugin,\n} from '@tanstack/devtools'\n\ntype SolidPluginRender = JSX.Element | (() => JSX.Element)\nconst convertRender = (\n el: HTMLDivElement | HTMLHeadingElement,\n Component: SolidPluginRender,\n) => (\n <Portal mount={el}>\n {typeof Component === 'function' ? <Component /> : 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 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?: TanStackDevtoolsConfig\n}\n\nexport const TanstackDevtools = ({ config, plugins }: TanstackDevtoolsInit) => {\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config,\n plugins: 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) => convertRender(el, plugin.name as SolidPluginRender),\n render: (el: HTMLDivElement) => convertRender(el, plugin.render),\n })),\n }),\n )\n let devToolRef: HTMLDivElement | undefined\n createEffect(() => {\n devtools().setConfig({ config })\n })\n onMount(() => {\n if (devToolRef) {\n devtools().mount(devToolRef)\n\n onCleanup(() => {\n devtools().unmount()\n })\n }\n })\n return <div ref={devToolRef} />\n}\n"],"names":["convertRender","el","Component","_$createComponent","Portal","mount","children","TanstackDevtools","config","plugins","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use"],"mappings":";;;;;;AAUA,MAAMA,gBAAgBA,CACpBC,IACAC,cAA4BC,IAAAA,gBAE3BC,IAAAA,QAAM;AAAA,EAACC,OAAOJ;AAAAA,EAAE,IAAAK,WAAA;AAAA,WACd,OAAOJ,cAAc,aAAUC,IAAAA,gBAAID,WAAS,CAAA,CAAA,IAAMA;AAAAA,EAAS;AAAA,CAAA;AA2EzD,MAAMK,mBAAmBA,CAAC;AAAA,EAAEC;AAAAA,EAAQC;AAA8B,MAAM;AAC7E,QAAM,CAACC,UAAQ,IAAIC,QAAAA,aACjB,IAAIC,SAAAA,qBAAqB;AAAA,IACvBJ;AAAAA,IACAC,SAASA,SAASI,IAAKC,CAAAA,YAAY;AAAA,MACjC,GAAGA;AAAAA,MACHC,MACE,OAAOD,OAAOC,SAAS,WACnBD,OAAOC;AAAAA;AAAAA,QAENd,CAAAA,OAAOD,cAAcC,IAAIa,OAAOC,IAAyB;AAAA;AAAA,MAChEC,QAAQA,CAACf,OAAuBD,cAAcC,IAAIa,OAAOE,MAAM;AAAA,IAAA,EAC/D;AAAA,EAAA,CACH,CACH;AACA,MAAIC;AACJC,UAAAA,aAAa,MAAM;AACjBR,eAAAA,EAAWS,UAAU;AAAA,MAAEX;AAAAA,IAAAA,CAAQ;AAAA,EACjC,CAAC;AACDY,UAAAA,QAAQ,MAAM;AACZ,QAAIH,YAAY;AACdP,iBAAAA,EAAWL,MAAMY,UAAU;AAE3BI,cAAAA,UAAU,MAAM;AACdX,mBAAAA,EAAWY,QAAAA;AAAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,UAAA,MAAA;AAAA,QAAAC,OAAAC,OAAAA;AAAA,QAAAC,QAAiBR;AAAU,WAAAQ,UAAA,aAAAC,IAAAA,IAAAD,OAAAF,IAAA,IAAVN,aAAUM;AAAA,WAAAA;AAAAA,EAAA,GAAA;AAC7B;;"}
|
package/dist/cjs/devtools.d.cts
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
|
|
3
|
+
type SolidPluginRender = JSX.Element | (() => JSX.Element);
|
|
4
|
+
export type TanStackDevtoolsSolidPlugin = Omit<TanStackDevtoolsPlugin, 'render' | 'name'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The render function can be a SolidJS element or a function that returns a SolidJS element.
|
|
7
|
+
* If it's a function, it will be called to render the plugin, otherwise it will be rendered directly.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* ```ts
|
|
11
|
+
* {
|
|
12
|
+
* render: () => <CustomPluginComponent />,
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
* or
|
|
16
|
+
* ```ts
|
|
17
|
+
* {
|
|
18
|
+
* render: <CustomPluginComponent />,
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
render: SolidPluginRender;
|
|
23
|
+
/**
|
|
24
|
+
* Name to be displayed in the devtools UI.
|
|
25
|
+
* If a string, it will be used as the plugin name.
|
|
26
|
+
* If a function, it will be called with the mount element.
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* ```ts
|
|
30
|
+
* {
|
|
31
|
+
* name: "Your Plugin",
|
|
32
|
+
* render: () => <CustomPluginComponent />,
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* or
|
|
36
|
+
* ```ts
|
|
37
|
+
* {
|
|
38
|
+
* name: <h1>Your Plugin title</h1>,
|
|
39
|
+
* render: () => <CustomPluginComponent />,
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
name: string | SolidPluginRender;
|
|
44
|
+
};
|
|
45
|
+
interface TanstackDevtoolsInit {
|
|
46
|
+
/**
|
|
47
|
+
* Array of plugins to be used in the devtools.
|
|
48
|
+
* Each plugin should have a `render` function that returns a React element or a function
|
|
49
|
+
*
|
|
50
|
+
* Example:
|
|
51
|
+
* ```jsx
|
|
52
|
+
* <TanstackDevtools
|
|
53
|
+
* plugins={[
|
|
54
|
+
* {
|
|
55
|
+
* id: "your-plugin-id",
|
|
56
|
+
* name: "Your Plugin",
|
|
57
|
+
* render: <CustomPluginComponent />,
|
|
58
|
+
* }
|
|
59
|
+
* ]}
|
|
60
|
+
* />
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
plugins?: Array<TanStackDevtoolsSolidPlugin>;
|
|
64
|
+
/**
|
|
65
|
+
* Configuration for the devtools shell. These configuration options are used to set the
|
|
66
|
+
* initial state of the devtools when it is started for the first time. Afterwards,
|
|
67
|
+
* the settings are persisted in local storage and changed through the settings panel.
|
|
68
|
+
*/
|
|
69
|
+
config?: TanStackDevtoolsConfig;
|
|
70
|
+
}
|
|
71
|
+
export declare const TanstackDevtools: ({ config, plugins }: TanstackDevtoolsInit) => JSX.Element;
|
|
72
|
+
export {};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const devtools$1 = require("@tanstack/devtools");
|
|
4
4
|
const devtools = require("./devtools.cjs");
|
|
5
|
-
exports.
|
|
5
|
+
exports.TanstackDevtools = devtools.TanstackDevtools;
|
|
6
6
|
Object.keys(devtools$1).forEach((k) => {
|
|
7
7
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
8
8
|
enumerable: true,
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2,4 +2,5 @@ export * from '@tanstack/devtools';
|
|
|
2
2
|
/**
|
|
3
3
|
* Export every hook individually - DON'T export from barrel files
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { TanstackDevtools } from './devtools.cjs';
|
|
6
|
+
export type { TanStackDevtoolsSolidPlugin } from './devtools.cjs';
|
package/dist/esm/devtools.d.ts
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
|
|
3
|
+
type SolidPluginRender = JSX.Element | (() => JSX.Element);
|
|
4
|
+
export type TanStackDevtoolsSolidPlugin = Omit<TanStackDevtoolsPlugin, 'render' | 'name'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The render function can be a SolidJS element or a function that returns a SolidJS element.
|
|
7
|
+
* If it's a function, it will be called to render the plugin, otherwise it will be rendered directly.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* ```ts
|
|
11
|
+
* {
|
|
12
|
+
* render: () => <CustomPluginComponent />,
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
* or
|
|
16
|
+
* ```ts
|
|
17
|
+
* {
|
|
18
|
+
* render: <CustomPluginComponent />,
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
render: SolidPluginRender;
|
|
23
|
+
/**
|
|
24
|
+
* Name to be displayed in the devtools UI.
|
|
25
|
+
* If a string, it will be used as the plugin name.
|
|
26
|
+
* If a function, it will be called with the mount element.
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* ```ts
|
|
30
|
+
* {
|
|
31
|
+
* name: "Your Plugin",
|
|
32
|
+
* render: () => <CustomPluginComponent />,
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* or
|
|
36
|
+
* ```ts
|
|
37
|
+
* {
|
|
38
|
+
* name: <h1>Your Plugin title</h1>,
|
|
39
|
+
* render: () => <CustomPluginComponent />,
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
name: string | SolidPluginRender;
|
|
44
|
+
};
|
|
45
|
+
interface TanstackDevtoolsInit {
|
|
46
|
+
/**
|
|
47
|
+
* Array of plugins to be used in the devtools.
|
|
48
|
+
* Each plugin should have a `render` function that returns a React element or a function
|
|
49
|
+
*
|
|
50
|
+
* Example:
|
|
51
|
+
* ```jsx
|
|
52
|
+
* <TanstackDevtools
|
|
53
|
+
* plugins={[
|
|
54
|
+
* {
|
|
55
|
+
* id: "your-plugin-id",
|
|
56
|
+
* name: "Your Plugin",
|
|
57
|
+
* render: <CustomPluginComponent />,
|
|
58
|
+
* }
|
|
59
|
+
* ]}
|
|
60
|
+
* />
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
plugins?: Array<TanStackDevtoolsSolidPlugin>;
|
|
64
|
+
/**
|
|
65
|
+
* Configuration for the devtools shell. These configuration options are used to set the
|
|
66
|
+
* initial state of the devtools when it is started for the first time. Afterwards,
|
|
67
|
+
* the settings are persisted in local storage and changed through the settings panel.
|
|
68
|
+
*/
|
|
69
|
+
config?: TanStackDevtoolsConfig;
|
|
70
|
+
}
|
|
71
|
+
export declare const TanstackDevtools: ({ config, plugins }: TanstackDevtoolsInit) => JSX.Element;
|
|
72
|
+
export {};
|
package/dist/esm/devtools.js
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
import { template, use } from "solid-js/web";
|
|
2
|
-
import {
|
|
1
|
+
import { createComponent, template, use, Portal } from "solid-js/web";
|
|
2
|
+
import { TanStackDevtoolsCore } from "@tanstack/devtools";
|
|
3
3
|
import { createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
4
4
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const convertRender = (el, Component) => createComponent(Portal, {
|
|
6
|
+
mount: el,
|
|
7
|
+
get children() {
|
|
8
|
+
return typeof Component === "function" ? createComponent(Component, {}) : Component;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const TanstackDevtools = ({
|
|
12
|
+
config,
|
|
13
|
+
plugins
|
|
14
|
+
}) => {
|
|
15
|
+
const [devtools] = createSignal(new TanStackDevtoolsCore({
|
|
16
|
+
config,
|
|
17
|
+
plugins: plugins?.map((plugin) => ({
|
|
18
|
+
...plugin,
|
|
19
|
+
name: typeof plugin.name === "string" ? plugin.name : (
|
|
20
|
+
// The check above confirms that `plugin.name` is of Render type
|
|
21
|
+
(el) => convertRender(el, plugin.name)
|
|
22
|
+
),
|
|
23
|
+
render: (el) => convertRender(el, plugin.render)
|
|
24
|
+
}))
|
|
25
|
+
}));
|
|
7
26
|
let devToolRef;
|
|
8
27
|
createEffect(() => {
|
|
9
|
-
devtools().
|
|
28
|
+
devtools().setConfig({
|
|
29
|
+
config
|
|
30
|
+
});
|
|
10
31
|
});
|
|
11
32
|
onMount(() => {
|
|
12
33
|
if (devToolRef) {
|
|
@@ -24,6 +45,6 @@ const Devtools = (opts) => {
|
|
|
24
45
|
})();
|
|
25
46
|
};
|
|
26
47
|
export {
|
|
27
|
-
|
|
48
|
+
TanstackDevtools
|
|
28
49
|
};
|
|
29
50
|
//# sourceMappingURL=devtools.js.map
|
package/dist/esm/devtools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.js","sources":["../../src/devtools.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"devtools.js","sources":["../../src/devtools.tsx"],"sourcesContent":["import { TanStackDevtoolsCore } from '@tanstack/devtools'\nimport { createEffect, createSignal, onCleanup, onMount } from 'solid-js'\nimport { Portal } from 'solid-js/web'\nimport type { JSX } from 'solid-js'\nimport type {\n TanStackDevtoolsConfig,\n TanStackDevtoolsPlugin,\n} from '@tanstack/devtools'\n\ntype SolidPluginRender = JSX.Element | (() => JSX.Element)\nconst convertRender = (\n el: HTMLDivElement | HTMLHeadingElement,\n Component: SolidPluginRender,\n) => (\n <Portal mount={el}>\n {typeof Component === 'function' ? <Component /> : 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 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?: TanStackDevtoolsConfig\n}\n\nexport const TanstackDevtools = ({ config, plugins }: TanstackDevtoolsInit) => {\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config,\n plugins: 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) => convertRender(el, plugin.name as SolidPluginRender),\n render: (el: HTMLDivElement) => convertRender(el, plugin.render),\n })),\n }),\n )\n let devToolRef: HTMLDivElement | undefined\n createEffect(() => {\n devtools().setConfig({ config })\n })\n onMount(() => {\n if (devToolRef) {\n devtools().mount(devToolRef)\n\n onCleanup(() => {\n devtools().unmount()\n })\n }\n })\n return <div ref={devToolRef} />\n}\n"],"names":["convertRender","el","Component","_$createComponent","Portal","mount","children","TanstackDevtools","config","plugins","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use"],"mappings":";;;;AAUA,MAAMA,gBAAgBA,CACpBC,IACAC,cAA4BC,gBAE3BC,QAAM;AAAA,EAACC,OAAOJ;AAAAA,EAAE,IAAAK,WAAA;AAAA,WACd,OAAOJ,cAAc,aAAUC,gBAAID,WAAS,CAAA,CAAA,IAAMA;AAAAA,EAAS;AAAA,CAAA;AA2EzD,MAAMK,mBAAmBA,CAAC;AAAA,EAAEC;AAAAA,EAAQC;AAA8B,MAAM;AAC7E,QAAM,CAACC,QAAQ,IAAIC,aACjB,IAAIC,qBAAqB;AAAA,IACvBJ;AAAAA,IACAC,SAASA,SAASI,IAAKC,CAAAA,YAAY;AAAA,MACjC,GAAGA;AAAAA,MACHC,MACE,OAAOD,OAAOC,SAAS,WACnBD,OAAOC;AAAAA;AAAAA,QAENd,CAAAA,OAAOD,cAAcC,IAAIa,OAAOC,IAAyB;AAAA;AAAA,MAChEC,QAAQA,CAACf,OAAuBD,cAAcC,IAAIa,OAAOE,MAAM;AAAA,IAAA,EAC/D;AAAA,EAAA,CACH,CACH;AACA,MAAIC;AACJC,eAAa,MAAM;AACjBR,aAAAA,EAAWS,UAAU;AAAA,MAAEX;AAAAA,IAAAA,CAAQ;AAAA,EACjC,CAAC;AACDY,UAAQ,MAAM;AACZ,QAAIH,YAAY;AACdP,eAAAA,EAAWL,MAAMY,UAAU;AAE3BI,gBAAU,MAAM;AACdX,iBAAAA,EAAWY,QAAAA;AAAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,UAAA,MAAA;AAAA,QAAAC,OAAAC,OAAAA;AAAA,QAAAC,QAAiBR;AAAU,WAAAQ,UAAA,aAAAC,IAAAD,OAAAF,IAAA,IAAVN,aAAUM;AAAA,WAAAA;AAAAA,EAAA,GAAA;AAC7B;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export * from '@tanstack/devtools';
|
|
|
2
2
|
/**
|
|
3
3
|
* Export every hook individually - DON'T export from barrel files
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { TanstackDevtools } from './devtools.js';
|
|
6
|
+
export type { TanStackDevtoolsSolidPlugin } from './devtools.js';
|
package/dist/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-devtools",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
7
7
|
"repository": {
|
|
@@ -16,12 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"solid",
|
|
19
|
-
"devtools"
|
|
20
|
-
"autocomplete",
|
|
21
|
-
"dropdown",
|
|
22
|
-
"menu",
|
|
23
|
-
"headless-ui",
|
|
24
|
-
"nested"
|
|
19
|
+
"devtools"
|
|
25
20
|
],
|
|
26
21
|
"type": "module",
|
|
27
22
|
"types": "dist/esm/index.d.ts",
|
|
@@ -49,14 +44,14 @@
|
|
|
49
44
|
"src"
|
|
50
45
|
],
|
|
51
46
|
"dependencies": {
|
|
52
|
-
"@tanstack/devtools": "0.
|
|
47
|
+
"@tanstack/devtools": "0.1.1"
|
|
53
48
|
},
|
|
54
49
|
"devDependencies": {
|
|
55
|
-
"solid-js": "^1.9.
|
|
50
|
+
"solid-js": "^1.9.7",
|
|
56
51
|
"vite-plugin-solid": "^2.11.6"
|
|
57
52
|
},
|
|
58
53
|
"peerDependencies": {
|
|
59
|
-
"solid-js": ">=1.9.
|
|
54
|
+
"solid-js": ">=1.9.7"
|
|
60
55
|
},
|
|
61
56
|
"scripts": {
|
|
62
57
|
"clean": "premove ./build ./dist",
|
package/src/devtools.tsx
CHANGED
|
@@ -1,12 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TanStackDevtoolsCore } from '@tanstack/devtools'
|
|
2
2
|
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js'
|
|
3
|
-
import
|
|
3
|
+
import { Portal } from 'solid-js/web'
|
|
4
|
+
import type { JSX } from 'solid-js'
|
|
5
|
+
import type {
|
|
6
|
+
TanStackDevtoolsConfig,
|
|
7
|
+
TanStackDevtoolsPlugin,
|
|
8
|
+
} from '@tanstack/devtools'
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
type SolidPluginRender = JSX.Element | (() => JSX.Element)
|
|
11
|
+
const convertRender = (
|
|
12
|
+
el: HTMLDivElement | HTMLHeadingElement,
|
|
13
|
+
Component: SolidPluginRender,
|
|
14
|
+
) => (
|
|
15
|
+
<Portal mount={el}>
|
|
16
|
+
{typeof Component === 'function' ? <Component /> : Component}
|
|
17
|
+
</Portal>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
export type TanStackDevtoolsSolidPlugin = Omit<
|
|
21
|
+
TanStackDevtoolsPlugin,
|
|
22
|
+
'render' | 'name'
|
|
23
|
+
> & {
|
|
24
|
+
/**
|
|
25
|
+
* The render function can be a SolidJS element or a function that returns a SolidJS element.
|
|
26
|
+
* If it's a function, it will be called to render the plugin, otherwise it will be rendered directly.
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* ```ts
|
|
30
|
+
* {
|
|
31
|
+
* render: () => <CustomPluginComponent />,
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
* or
|
|
35
|
+
* ```ts
|
|
36
|
+
* {
|
|
37
|
+
* render: <CustomPluginComponent />,
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
render: SolidPluginRender
|
|
42
|
+
/**
|
|
43
|
+
* Name to be displayed in the devtools UI.
|
|
44
|
+
* If a string, it will be used as the plugin name.
|
|
45
|
+
* If a function, it will be called with the mount element.
|
|
46
|
+
*
|
|
47
|
+
* Example:
|
|
48
|
+
* ```ts
|
|
49
|
+
* {
|
|
50
|
+
* name: "Your Plugin",
|
|
51
|
+
* render: () => <CustomPluginComponent />,
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
* or
|
|
55
|
+
* ```ts
|
|
56
|
+
* {
|
|
57
|
+
* name: <h1>Your Plugin title</h1>,
|
|
58
|
+
* render: () => <CustomPluginComponent />,
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
name: string | SolidPluginRender
|
|
63
|
+
}
|
|
64
|
+
interface TanstackDevtoolsInit {
|
|
65
|
+
/**
|
|
66
|
+
* Array of plugins to be used in the devtools.
|
|
67
|
+
* Each plugin should have a `render` function that returns a React element or a function
|
|
68
|
+
*
|
|
69
|
+
* Example:
|
|
70
|
+
* ```jsx
|
|
71
|
+
* <TanstackDevtools
|
|
72
|
+
* plugins={[
|
|
73
|
+
* {
|
|
74
|
+
* id: "your-plugin-id",
|
|
75
|
+
* name: "Your Plugin",
|
|
76
|
+
* render: <CustomPluginComponent />,
|
|
77
|
+
* }
|
|
78
|
+
* ]}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
plugins?: Array<TanStackDevtoolsSolidPlugin>
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for the devtools shell. These configuration options are used to set the
|
|
85
|
+
* initial state of the devtools when it is started for the first time. Afterwards,
|
|
86
|
+
* the settings are persisted in local storage and changed through the settings panel.
|
|
87
|
+
*/
|
|
88
|
+
config?: TanStackDevtoolsConfig
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const TanstackDevtools = ({ config, plugins }: TanstackDevtoolsInit) => {
|
|
92
|
+
const [devtools] = createSignal(
|
|
93
|
+
new TanStackDevtoolsCore({
|
|
94
|
+
config,
|
|
95
|
+
plugins: plugins?.map((plugin) => ({
|
|
96
|
+
...plugin,
|
|
97
|
+
name:
|
|
98
|
+
typeof plugin.name === 'string'
|
|
99
|
+
? plugin.name
|
|
100
|
+
: // The check above confirms that `plugin.name` is of Render type
|
|
101
|
+
(el) => convertRender(el, plugin.name as SolidPluginRender),
|
|
102
|
+
render: (el: HTMLDivElement) => convertRender(el, plugin.render),
|
|
103
|
+
})),
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
7
106
|
let devToolRef: HTMLDivElement | undefined
|
|
8
107
|
createEffect(() => {
|
|
9
|
-
devtools().
|
|
108
|
+
devtools().setConfig({ config })
|
|
10
109
|
})
|
|
11
110
|
onMount(() => {
|
|
12
111
|
if (devToolRef) {
|
package/src/index.ts
CHANGED