@tanstack/solid-devtools 0.1.0 → 0.2.0

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 CHANGED
@@ -24,3 +24,28 @@ function App() {
24
24
  )
25
25
  }
26
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
+ ```
@@ -12,10 +12,12 @@ const convertRender = (el, Component) => web.createComponent(web.Portal, {
12
12
  });
13
13
  const TanstackDevtools = ({
14
14
  config,
15
- plugins
15
+ plugins,
16
+ eventBusConfig
16
17
  }) => {
17
18
  const [devtools$1] = solidJs.createSignal(new devtools.TanStackDevtoolsCore({
18
19
  config,
20
+ eventBusConfig,
19
21
  plugins: plugins?.map((plugin) => ({
20
22
  ...plugin,
21
23
  name: typeof plugin.name === "string" ? plugin.name : (
@@ -1 +1 @@
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 render: SolidPluginRender\n name: string | SolidPluginRender\n}\ninterface TanstackDevtoolsInit {\n plugins?: Array<TanStackDevtoolsSolidPlugin>\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;AAgBzD,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;;"}
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 ClientEventBusConfig,\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?: Partial<TanStackDevtoolsConfig>\n /**\n * Configuration for the TanStack Devtools client event bus.\n */\n eventBusConfig?: ClientEventBusConfig\n}\n\nexport const TanstackDevtools = ({\n config,\n plugins,\n eventBusConfig,\n}: TanstackDevtoolsInit) => {\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config,\n eventBusConfig,\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","eventBusConfig","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use"],"mappings":";;;;;;AAWA,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;AA+EzD,MAAMK,mBAAmBA,CAAC;AAAA,EAC/BC;AAAAA,EACAC;AAAAA,EACAC;AACoB,MAAM;AAC1B,QAAM,CAACC,UAAQ,IAAIC,QAAAA,aACjB,IAAIC,SAAAA,qBAAqB;AAAA,IACvBL;AAAAA,IACAE;AAAAA,IACAD,SAASA,SAASK,IAAKC,CAAAA,YAAY;AAAA,MACjC,GAAGA;AAAAA,MACHC,MACE,OAAOD,OAAOC,SAAS,WACnBD,OAAOC;AAAAA;AAAAA,QAENf,CAAAA,OAAOD,cAAcC,IAAIc,OAAOC,IAAyB;AAAA;AAAA,MAChEC,QAAQA,CAAChB,OAAuBD,cAAcC,IAAIc,OAAOE,MAAM;AAAA,IAAA,EAC/D;AAAA,EAAA,CACH,CACH;AACA,MAAIC;AACJC,UAAAA,aAAa,MAAM;AACjBR,eAAAA,EAAWS,UAAU;AAAA,MAAEZ;AAAAA,IAAAA,CAAQ;AAAA,EACjC,CAAC;AACDa,UAAAA,QAAQ,MAAM;AACZ,QAAIH,YAAY;AACdP,iBAAAA,EAAWN,MAAMa,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;;"}
@@ -1,13 +1,76 @@
1
1
  import { JSX } from 'solid-js';
2
- import { TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
2
+ import { ClientEventBusConfig, TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
3
3
  type SolidPluginRender = JSX.Element | (() => JSX.Element);
4
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
+ */
5
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
+ */
6
43
  name: string | SolidPluginRender;
7
44
  };
8
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
+ */
9
63
  plugins?: Array<TanStackDevtoolsSolidPlugin>;
10
- config?: TanStackDevtoolsConfig;
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?: Partial<TanStackDevtoolsConfig>;
70
+ /**
71
+ * Configuration for the TanStack Devtools client event bus.
72
+ */
73
+ eventBusConfig?: ClientEventBusConfig;
11
74
  }
12
- export declare const TanstackDevtools: ({ config, plugins }: TanstackDevtoolsInit) => JSX.Element;
75
+ export declare const TanstackDevtools: ({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit) => JSX.Element;
13
76
  export {};
@@ -1,13 +1,76 @@
1
1
  import { JSX } from 'solid-js';
2
- import { TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
2
+ import { ClientEventBusConfig, TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
3
3
  type SolidPluginRender = JSX.Element | (() => JSX.Element);
4
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
+ */
5
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
+ */
6
43
  name: string | SolidPluginRender;
7
44
  };
8
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
+ */
9
63
  plugins?: Array<TanStackDevtoolsSolidPlugin>;
10
- config?: TanStackDevtoolsConfig;
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?: Partial<TanStackDevtoolsConfig>;
70
+ /**
71
+ * Configuration for the TanStack Devtools client event bus.
72
+ */
73
+ eventBusConfig?: ClientEventBusConfig;
11
74
  }
12
- export declare const TanstackDevtools: ({ config, plugins }: TanstackDevtoolsInit) => JSX.Element;
75
+ export declare const TanstackDevtools: ({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit) => JSX.Element;
13
76
  export {};
@@ -10,10 +10,12 @@ const convertRender = (el, Component) => createComponent(Portal, {
10
10
  });
11
11
  const TanstackDevtools = ({
12
12
  config,
13
- plugins
13
+ plugins,
14
+ eventBusConfig
14
15
  }) => {
15
16
  const [devtools] = createSignal(new TanStackDevtoolsCore({
16
17
  config,
18
+ eventBusConfig,
17
19
  plugins: plugins?.map((plugin) => ({
18
20
  ...plugin,
19
21
  name: typeof plugin.name === "string" ? plugin.name : (
@@ -1 +1 @@
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 render: SolidPluginRender\n name: string | SolidPluginRender\n}\ninterface TanstackDevtoolsInit {\n plugins?: Array<TanStackDevtoolsSolidPlugin>\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;AAgBzD,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;"}
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 ClientEventBusConfig,\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?: Partial<TanStackDevtoolsConfig>\n /**\n * Configuration for the TanStack Devtools client event bus.\n */\n eventBusConfig?: ClientEventBusConfig\n}\n\nexport const TanstackDevtools = ({\n config,\n plugins,\n eventBusConfig,\n}: TanstackDevtoolsInit) => {\n const [devtools] = createSignal(\n new TanStackDevtoolsCore({\n config,\n eventBusConfig,\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","eventBusConfig","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use"],"mappings":";;;;AAWA,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;AA+EzD,MAAMK,mBAAmBA,CAAC;AAAA,EAC/BC;AAAAA,EACAC;AAAAA,EACAC;AACoB,MAAM;AAC1B,QAAM,CAACC,QAAQ,IAAIC,aACjB,IAAIC,qBAAqB;AAAA,IACvBL;AAAAA,IACAE;AAAAA,IACAD,SAASA,SAASK,IAAKC,CAAAA,YAAY;AAAA,MACjC,GAAGA;AAAAA,MACHC,MACE,OAAOD,OAAOC,SAAS,WACnBD,OAAOC;AAAAA;AAAAA,QAENf,CAAAA,OAAOD,cAAcC,IAAIc,OAAOC,IAAyB;AAAA;AAAA,MAChEC,QAAQA,CAAChB,OAAuBD,cAAcC,IAAIc,OAAOE,MAAM;AAAA,IAAA,EAC/D;AAAA,EAAA,CACH,CACH;AACA,MAAIC;AACJC,eAAa,MAAM;AACjBR,aAAAA,EAAWS,UAAU;AAAA,MAAEZ;AAAAA,IAAAA,CAAQ;AAAA,EACjC,CAAC;AACDa,UAAQ,MAAM;AACZ,QAAIH,YAAY;AACdP,eAAAA,EAAWN,MAAMa,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-devtools",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
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",
@@ -44,7 +44,7 @@
44
44
  "src"
45
45
  ],
46
46
  "dependencies": {
47
- "@tanstack/devtools": "0.1.0"
47
+ "@tanstack/devtools": "0.2.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "solid-js": "^1.9.7",
package/src/devtools.tsx CHANGED
@@ -3,6 +3,7 @@ import { createEffect, createSignal, onCleanup, onMount } from 'solid-js'
3
3
  import { Portal } from 'solid-js/web'
4
4
  import type { JSX } from 'solid-js'
5
5
  import type {
6
+ ClientEventBusConfig,
6
7
  TanStackDevtoolsConfig,
7
8
  TanStackDevtoolsPlugin,
8
9
  } from '@tanstack/devtools'
@@ -21,18 +22,86 @@ export type TanStackDevtoolsSolidPlugin = Omit<
21
22
  TanStackDevtoolsPlugin,
22
23
  'render' | 'name'
23
24
  > & {
25
+ /**
26
+ * The render function can be a SolidJS element or a function that returns a SolidJS element.
27
+ * If it's a function, it will be called to render the plugin, otherwise it will be rendered directly.
28
+ *
29
+ * Example:
30
+ * ```ts
31
+ * {
32
+ * render: () => <CustomPluginComponent />,
33
+ * }
34
+ * ```
35
+ * or
36
+ * ```ts
37
+ * {
38
+ * render: <CustomPluginComponent />,
39
+ * }
40
+ * ```
41
+ */
24
42
  render: SolidPluginRender
43
+ /**
44
+ * Name to be displayed in the devtools UI.
45
+ * If a string, it will be used as the plugin name.
46
+ * If a function, it will be called with the mount element.
47
+ *
48
+ * Example:
49
+ * ```ts
50
+ * {
51
+ * name: "Your Plugin",
52
+ * render: () => <CustomPluginComponent />,
53
+ * }
54
+ * ```
55
+ * or
56
+ * ```ts
57
+ * {
58
+ * name: <h1>Your Plugin title</h1>,
59
+ * render: () => <CustomPluginComponent />,
60
+ * }
61
+ * ```
62
+ */
25
63
  name: string | SolidPluginRender
26
64
  }
27
65
  interface TanstackDevtoolsInit {
66
+ /**
67
+ * Array of plugins to be used in the devtools.
68
+ * Each plugin should have a `render` function that returns a React element or a function
69
+ *
70
+ * Example:
71
+ * ```jsx
72
+ * <TanstackDevtools
73
+ * plugins={[
74
+ * {
75
+ * id: "your-plugin-id",
76
+ * name: "Your Plugin",
77
+ * render: <CustomPluginComponent />,
78
+ * }
79
+ * ]}
80
+ * />
81
+ * ```
82
+ */
28
83
  plugins?: Array<TanStackDevtoolsSolidPlugin>
29
- config?: TanStackDevtoolsConfig
84
+ /**
85
+ * Configuration for the devtools shell. These configuration options are used to set the
86
+ * initial state of the devtools when it is started for the first time. Afterwards,
87
+ * the settings are persisted in local storage and changed through the settings panel.
88
+ */
89
+ config?: Partial<TanStackDevtoolsConfig>
90
+ /**
91
+ * Configuration for the TanStack Devtools client event bus.
92
+ */
93
+ eventBusConfig?: ClientEventBusConfig
30
94
  }
31
95
 
32
- export const TanstackDevtools = ({ config, plugins }: TanstackDevtoolsInit) => {
96
+ export const TanstackDevtools = ({
97
+ config,
98
+ plugins,
99
+ eventBusConfig,
100
+ }: TanstackDevtoolsInit) => {
33
101
  const [devtools] = createSignal(
34
102
  new TanStackDevtoolsCore({
35
103
  config,
104
+ eventBusConfig,
36
105
  plugins: plugins?.map((plugin) => ({
37
106
  ...plugin,
38
107
  name: