@tanstack/solid-devtools 0.7.32 → 0.8.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.
@@ -1,27 +1,29 @@
1
- import { createSignal, splitProps, sharedConfig, onMount, createMemo, untrack } from "solid-js";
1
+ import { createMemo, createSignal, onMount, sharedConfig, splitProps, untrack } from "solid-js";
2
2
  import { isServer } from "solid-js/web";
3
+ //#region src/client-only.ts
4
+ /**
5
+ *
6
+ * Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
7
+ */
3
8
  function clientOnly(fn, options = {}) {
4
- if (isServer)
5
- return (props) => props.fallback;
6
- const [comp, setComp] = createSignal();
7
- !options.lazy && load(fn, setComp);
8
- return (props) => {
9
- let Comp;
10
- let m;
11
- const [, rest] = splitProps(props, ["fallback"]);
12
- options.lazy && load(fn, setComp);
13
- if ((Comp = comp()) && !sharedConfig.context) return Comp(rest);
14
- const [mounted, setMounted] = createSignal(!sharedConfig.context);
15
- onMount(() => setMounted(true));
16
- return createMemo(
17
- () => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback))
18
- );
19
- };
9
+ if (isServer) return (props) => props.fallback;
10
+ const [comp, setComp] = createSignal();
11
+ !options.lazy && load(fn, setComp);
12
+ return (props) => {
13
+ let Comp;
14
+ let m;
15
+ const [, rest] = splitProps(props, ["fallback"]);
16
+ options.lazy && load(fn, setComp);
17
+ if ((Comp = comp()) && !sharedConfig.context) return Comp(rest);
18
+ const [mounted, setMounted] = createSignal(!sharedConfig.context);
19
+ onMount(() => setMounted(true));
20
+ return createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
21
+ };
20
22
  }
21
23
  function load(fn, setComp) {
22
- fn().then((m) => setComp(() => m.default));
24
+ fn().then((m) => setComp(() => m.default));
23
25
  }
24
- export {
25
- clientOnly as default
26
- };
27
- //# sourceMappingURL=client-only.js.map
26
+ //#endregion
27
+ export { clientOnly as default };
28
+
29
+ //# sourceMappingURL=client-only.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-only.js","sources":["../../src/client-only.ts"],"sourcesContent":["import {\n createMemo,\n createSignal,\n onMount,\n sharedConfig,\n splitProps,\n untrack,\n} from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport type { Component, ComponentProps, JSX, Setter } from 'solid-js'\n\n/**\n *\n * Read more: https://docs.solidjs.com/solid-start/reference/client/client-only\n */\n// not using Suspense\nexport default function clientOnly<T extends Component<any>>(\n fn: () => Promise<{\n default: T\n }>,\n options: { lazy?: boolean } = {},\n) {\n if (isServer)\n return (props: ComponentProps<T> & { fallback?: JSX.Element }) =>\n props.fallback\n\n const [comp, setComp] = createSignal<T>()\n !options.lazy && load(fn, setComp)\n return (props: ComponentProps<T>) => {\n let Comp: T | undefined\n let m: boolean\n const [, rest] = splitProps(props, ['fallback'])\n options.lazy && load(fn, setComp)\n if ((Comp = comp()) && !sharedConfig.context) return Comp(rest)\n const [mounted, setMounted] = createSignal(!sharedConfig.context)\n onMount(() => setMounted(true))\n return createMemo(\n () => (\n (Comp = comp()),\n (m = mounted()),\n untrack(() => (Comp && m ? Comp(rest) : props.fallback))\n ),\n )\n }\n}\n\nfunction load<T>(\n fn: () => Promise<{\n default: T\n }>,\n setComp: Setter<T>,\n) {\n fn().then((m) => setComp(() => m.default))\n}\n"],"names":[],"mappings":";;AAgBA,SAAwB,WACtB,IAGA,UAA8B,IAC9B;AACA,MAAI;AACF,WAAO,CAAC,UACN,MAAM;AAEV,QAAM,CAAC,MAAM,OAAO,IAAI,aAAA;AACxB,GAAC,QAAQ,QAAQ,KAAK,IAAI,OAAO;AACjC,SAAO,CAAC,UAA6B;AACnC,QAAI;AACJ,QAAI;AACJ,UAAM,CAAA,EAAG,IAAI,IAAI,WAAW,OAAO,CAAC,UAAU,CAAC;AAC/C,YAAQ,QAAQ,KAAK,IAAI,OAAO;AAChC,SAAK,OAAO,WAAW,CAAC,aAAa,QAAS,QAAO,KAAK,IAAI;AAC9D,UAAM,CAAC,SAAS,UAAU,IAAI,aAAa,CAAC,aAAa,OAAO;AAChE,YAAQ,MAAM,WAAW,IAAI,CAAC;AAC9B,WAAO;AAAA,MACL,OACG,OAAO,KAAA,GACP,IAAI,QAAA,GACL,QAAQ,MAAO,QAAQ,IAAI,KAAK,IAAI,IAAI,MAAM,QAAS;AAAA,IAAA;AAAA,EAG7D;AACF;AAEA,SAAS,KACP,IAGA,SACA;AACA,KAAA,EAAK,KAAK,CAAC,MAAM,QAAQ,MAAM,EAAE,OAAO,CAAC;AAC3C;"}
1
+ {"version":3,"file":"client-only.js","names":[],"sources":["../../src/client-only.ts"],"sourcesContent":["import {\n createMemo,\n createSignal,\n onMount,\n sharedConfig,\n splitProps,\n untrack,\n} from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport type { Component, ComponentProps, JSX, Setter } from 'solid-js'\n\n/**\n *\n * Read more: https://docs.solidjs.com/solid-start/reference/client/client-only\n */\n// not using Suspense\nexport default function clientOnly<T extends Component<any>>(\n fn: () => Promise<{\n default: T\n }>,\n options: { lazy?: boolean } = {},\n) {\n if (isServer)\n return (props: ComponentProps<T> & { fallback?: JSX.Element }) =>\n props.fallback\n\n const [comp, setComp] = createSignal<T>()\n !options.lazy && load(fn, setComp)\n return (props: ComponentProps<T>) => {\n let Comp: T | undefined\n let m: boolean\n const [, rest] = splitProps(props, ['fallback'])\n options.lazy && load(fn, setComp)\n if ((Comp = comp()) && !sharedConfig.context) return Comp(rest)\n const [mounted, setMounted] = createSignal(!sharedConfig.context)\n onMount(() => setMounted(true))\n return createMemo(\n () => (\n (Comp = comp()),\n (m = mounted()),\n untrack(() => (Comp && m ? Comp(rest) : props.fallback))\n ),\n )\n }\n}\n\nfunction load<T>(\n fn: () => Promise<{\n default: T\n }>,\n setComp: Setter<T>,\n) {\n fn().then((m) => setComp(() => m.default))\n}\n"],"mappings":";;;;;;;AAgBA,SAAwB,WACtB,IAGA,UAA8B,EAAE,EAChC;AACA,KAAI,SACF,SAAQ,UACN,MAAM;CAEV,MAAM,CAAC,MAAM,WAAW,cAAiB;AACzC,EAAC,QAAQ,QAAQ,KAAK,IAAI,QAAQ;AAClC,SAAQ,UAA6B;EACnC,IAAI;EACJ,IAAI;EACJ,MAAM,GAAG,QAAQ,WAAW,OAAO,CAAC,WAAW,CAAC;AAChD,UAAQ,QAAQ,KAAK,IAAI,QAAQ;AACjC,OAAK,OAAO,MAAM,KAAK,CAAC,aAAa,QAAS,QAAO,KAAK,KAAK;EAC/D,MAAM,CAAC,SAAS,cAAc,aAAa,CAAC,aAAa,QAAQ;AACjE,gBAAc,WAAW,KAAK,CAAC;AAC/B,SAAO,kBAEF,OAAO,MAAM,EACb,IAAI,SAAS,EACd,cAAe,QAAQ,IAAI,KAAK,KAAK,GAAG,MAAM,SAAU,EAE3D;;;AAIL,SAAS,KACP,IAGA,SACA;AACA,KAAI,CAAC,MAAM,MAAM,cAAc,EAAE,QAAQ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { JSX } from 'solid-js';
2
- import { ClientEventBusConfig, TanStackDevtoolsConfig, TanStackDevtoolsPlugin } from '@tanstack/devtools';
3
- type SolidPluginRender = JSX.Element | ((el: HTMLDivElement | HTMLHeadingElement, theme: 'dark' | 'light') => JSX.Element);
2
+ import { ClientEventBusConfig, TanStackDevtoolsConfig, TanStackDevtoolsPlugin, TanStackDevtoolsPluginProps, TanStackDevtoolsTheme } from '@tanstack/devtools';
3
+ type SolidPluginRender = JSX.Element | ((el: HTMLDivElement | HTMLHeadingElement, props: TanStackDevtoolsPluginProps) => JSX.Element);
4
4
  export type TanStackDevtoolsSolidPlugin = Omit<TanStackDevtoolsPlugin, 'render' | 'name'> & {
5
5
  /**
6
6
  * The render function can be a SolidJS element or a function that returns a SolidJS element.
@@ -43,7 +43,7 @@ export type TanStackDevtoolsSolidPlugin = Omit<TanStackDevtoolsPlugin, 'render'
43
43
  name: string | SolidPluginRender;
44
44
  };
45
45
  interface TriggerProps {
46
- theme: 'light' | 'dark';
46
+ theme: TanStackDevtoolsTheme;
47
47
  }
48
48
  export interface TanStackDevtoolsInit {
49
49
  /**
package/dist/esm/core.js CHANGED
@@ -1,76 +1,64 @@
1
- import { createComponent, Portal, use, template } from "solid-js/web";
1
+ import { createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js";
2
+ import { Portal, createComponent, template, use } from "solid-js/web";
2
3
  import { TanStackDevtoolsCore } from "@tanstack/devtools";
3
- import { createMemo, createSignal, createEffect, onMount, onCleanup } from "solid-js";
4
+ //#region src/core.tsx
4
5
  var _tmpl$ = /* @__PURE__ */ template(`<div style=position:absolute>`);
5
- const convertRender = (el, Component, theme) => createComponent(Portal, {
6
- mount: el,
7
- get children() {
8
- return typeof Component === "function" ? Component(el, theme) : Component;
9
- }
6
+ var convertRender = (el, Component, props) => createComponent(Portal, {
7
+ mount: el,
8
+ get children() {
9
+ return typeof Component === "function" ? Component(el, props) : Component;
10
+ }
10
11
  });
11
- function SolidDevtoolsCore({
12
- config,
13
- plugins,
14
- eventBusConfig
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
- })));
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
- };
33
- const [devtools] = createSignal(new TanStackDevtoolsCore({
34
- config: {
35
- ...config,
36
- customTrigger: config?.customTrigger ? (el, props) => convertTrigger(el, props) : void 0
37
- },
38
- eventBusConfig,
39
- plugins: pluginsMap()
40
- }));
41
- let devToolRef;
42
- createEffect(() => {
43
- devtools().setConfig({
44
- config: {
45
- ...config,
46
- customTrigger: config?.customTrigger ? (el, props) => convertTrigger(el, props) : void 0
47
- }
48
- });
49
- });
50
- createEffect(() => {
51
- const currentPlugins = pluginsMap();
52
- if (currentPlugins) {
53
- devtools().setConfig({
54
- plugins: currentPlugins
55
- });
56
- }
57
- });
58
- onMount(() => {
59
- if (devToolRef) {
60
- devtools().mount(devToolRef);
61
- onCleanup(() => {
62
- devtools().unmount();
63
- });
64
- }
65
- });
66
- return (() => {
67
- var _el$ = _tmpl$();
68
- var _ref$ = devToolRef;
69
- typeof _ref$ === "function" ? use(_ref$, _el$) : devToolRef = _el$;
70
- return _el$;
71
- })();
12
+ function SolidDevtoolsCore({ config, plugins, eventBusConfig }) {
13
+ const pluginsMap = createMemo(() => plugins?.map((plugin) => ({
14
+ ...plugin,
15
+ name: typeof plugin.name === "string" ? plugin.name : (el, props) => convertRender(el, plugin.name, props),
16
+ render: (el, props) => convertRender(el, plugin.render, props)
17
+ })));
18
+ const convertTrigger = (el, props) => {
19
+ const Trigger = config?.customTrigger;
20
+ return createComponent(Portal, {
21
+ mount: el,
22
+ get children() {
23
+ return typeof Trigger === "function" ? Trigger(el, props) : Trigger;
24
+ }
25
+ });
26
+ };
27
+ const [devtools] = createSignal(new TanStackDevtoolsCore({
28
+ config: {
29
+ ...config,
30
+ customTrigger: config?.customTrigger ? (el, props) => convertTrigger(el, props) : void 0
31
+ },
32
+ eventBusConfig,
33
+ plugins: pluginsMap()
34
+ }));
35
+ let devToolRef;
36
+ createEffect(() => {
37
+ devtools().setConfig({ config: {
38
+ ...config,
39
+ customTrigger: config?.customTrigger ? (el, props) => convertTrigger(el, props) : void 0
40
+ } });
41
+ });
42
+ createEffect(() => {
43
+ const currentPlugins = pluginsMap();
44
+ if (currentPlugins) devtools().setConfig({ plugins: currentPlugins });
45
+ });
46
+ onMount(() => {
47
+ if (devToolRef) {
48
+ devtools().mount(devToolRef);
49
+ onCleanup(() => {
50
+ devtools().unmount();
51
+ });
52
+ }
53
+ });
54
+ return (() => {
55
+ var _el$ = _tmpl$();
56
+ var _ref$ = devToolRef;
57
+ typeof _ref$ === "function" ? use(_ref$, _el$) : devToolRef = _el$;
58
+ return _el$;
59
+ })();
72
60
  }
73
- export {
74
- SolidDevtoolsCore as default
75
- };
76
- //# sourceMappingURL=core.js.map
61
+ //#endregion
62
+ export { SolidDevtoolsCore as default };
63
+
64
+ //# sourceMappingURL=core.js.map
@@ -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}\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: config?.customTrigger\n ? (el, props) => convertTrigger(el, props)\n : undefined,\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: config?.customTrigger\n ? (el, props) => convertTrigger(el, props)\n : undefined,\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","undefined","devToolRef","createEffect","setConfig","currentPlugins","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use"],"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,eAAeZ,QAAQY,gBACnB,CAACpB,IAAIkB,UAAUD,eAAejB,IAAIkB,KAAK,IACvCM;AAAAA,IAAAA;AAAAA,IAENd;AAAAA,IACAD,SAASE,WAAAA;AAAAA,EAAW,CACrB,CACH;AACA,MAAIc;AAEJC,eAAa,MAAM;AACjBL,aAAAA,EAAWM,UAAU;AAAA,MACnBnB,QAAQ;AAAA,QACN,GAAGA;AAAAA,QACHY,eAAeZ,QAAQY,gBACnB,CAACpB,IAAIkB,UAAUD,eAAejB,IAAIkB,KAAK,IACvCM;AAAAA,MAAAA;AAAAA,IACN,CACD;AAAA,EACH,CAAC;AAGDE,eAAa,MAAM;AACjB,UAAME,iBAAiBjB,WAAAA;AACvB,QAAIiB,gBAAgB;AAClBP,eAAAA,EAAWM,UAAU;AAAA,QAAElB,SAASmB;AAAAA,MAAAA,CAAgB;AAAA,IAClD;AAAA,EACF,CAAC;AAEDC,UAAQ,MAAM;AACZ,QAAIJ,YAAY;AACdJ,eAAAA,EAAWhB,MAAMoB,UAAU;AAE3BK,gBAAU,MAAM;AACdT,iBAAAA,EAAWU,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;AAAA,WAAAA;AAAAA,EAAA,GAAA;AAC9D;"}
1
+ {"version":3,"file":"core.js","names":["TanStackDevtoolsCore","createEffect","createMemo","createSignal","onCleanup","onMount","Portal","JSX","ClientEventBusConfig","TanStackDevtoolsConfig","TanStackDevtoolsPlugin","TanStackDevtoolsPluginProps","TanStackDevtoolsTheme","SolidPluginRender","Element","el","HTMLDivElement","HTMLHeadingElement","props","convertRender","Component","_$createComponent","mount","children","TanStackDevtoolsSolidPlugin","Omit","render","name","TriggerProps","theme","TanStackDevtoolsInit","plugins","Array","config","Partial","customTrigger","HTMLElement","eventBusConfig","SolidDevtoolsCore","pluginsMap","map","plugin","convertTrigger","Trigger","devtools","undefined","devToolRef","setConfig","currentPlugins","unmount","_el$","_tmpl$","_ref$","_$use"],"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 TanStackDevtoolsPluginProps,\n TanStackDevtoolsTheme,\n} from '@tanstack/devtools'\n\ntype SolidPluginRender =\n | JSX.Element\n | ((\n el: HTMLDivElement | HTMLHeadingElement,\n props: TanStackDevtoolsPluginProps,\n ) => JSX.Element)\nconst convertRender = (\n el: HTMLDivElement | HTMLHeadingElement,\n Component: SolidPluginRender,\n props: TanStackDevtoolsPluginProps,\n) => (\n <Portal mount={el}>\n {typeof Component === 'function' ? Component(el, props) : 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: TanStackDevtoolsTheme\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, props) =>\n convertRender(el, plugin.name as SolidPluginRender, props),\n render: (el: HTMLDivElement, props: TanStackDevtoolsPluginProps) =>\n convertRender(el, plugin.render, props),\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: config?.customTrigger\n ? (el, props) => convertTrigger(el, props)\n : undefined,\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: config?.customTrigger\n ? (el, props) => convertTrigger(el, props)\n : undefined,\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"],"mappings":";;;;;AAwBA,IAAMmB,iBACJJ,IACAK,WACAF,UAAkCG,gBAEjCf,QAAM;CAACgB,OAAOP;CAAE,IAAAQ,WAAA;AAAA,SACd,OAAOH,cAAc,aAAaA,UAAUL,IAAIG,MAAM,GAAGE;;CAAS,CAEtE;AAuFD,SAAwBkB,kBAAkB,EACxCL,QACAF,SACAM,kBACuB;CAEvB,MAAME,aAAarC,iBACjB6B,SAASS,KAAKC,YAAY;EACxB,GAAGA;EACHd,MACE,OAAOc,OAAOd,SAAS,WACnBc,OAAOd,QAENZ,IAAIG,UACHC,cAAcJ,IAAI0B,OAAOd,MAA2BT,MAAM;EAClEQ,SAASX,IAAoBG,UAC3BC,cAAcJ,IAAI0B,OAAOf,QAAQR,MAAK;EACzC,EACH,CAAC;CAED,MAAMwB,kBAAkB3B,IAAiBG,UAAwB;EAC/D,MAAMyB,UAAUV,QAAQE;AAExB,SAAAd,gBACGf,QAAM;GAACgB,OAAOP;GAAE,IAAAQ,WAAA;AAAA,WACd,OAAOoB,YAAY,aAAaA,QAAQ5B,IAAIG,MAAM,GAAGyB;;GAAO,CAAA;;CAInE,MAAM,CAACC,YAAYzC,aACjB,IAAIH,qBAAqB;EACvBiC,QAAQ;GACN,GAAGA;GACHE,eAAeF,QAAQE,iBAClBpB,IAAIG,UAAUwB,eAAe3B,IAAIG,MAAM,GACxC2B,KAAAA;GACL;EACDR;EACAN,SAASQ,YAAW;EACrB,CACH,CAAC;CACD,IAAIO;AAEJ7C,oBAAmB;AACjB2C,YAAU,CAACG,UAAU,EACnBd,QAAQ;GACN,GAAGA;GACHE,eAAeF,QAAQE,iBAClBpB,IAAIG,UAAUwB,eAAe3B,IAAIG,MAAM,GACxC2B,KAAAA;GACN,EACD,CAAC;GACF;AAGF5C,oBAAmB;EACjB,MAAM+C,iBAAiBT,YAAY;AACnC,MAAIS,eACFJ,WAAU,CAACG,UAAU,EAAEhB,SAASiB,gBAAgB,CAAC;GAEnD;AAEF3C,eAAc;AACZ,MAAIyC,YAAY;AACdF,aAAU,CAACtB,MAAMwB,WAAW;AAE5B1C,mBAAgB;AACdwC,cAAU,CAACK,SAAS;KACpB;;GAEJ;AACF,eAAA;EAAA,IAAAC,OAAAC,QAAA;EAAA,IAAAC,QAAkDN;AAAU,SAAAM,UAAA,aAAAC,IAAAD,OAAAF,KAAA,GAAVJ,aAAUI;AAAA,SAAAA;KAAA"}
@@ -1,6 +1,7 @@
1
1
  import clientOnly from "./client-only.js";
2
- const TanStackDevtools = clientOnly(() => import("./core.js").then((m) => m));
3
- export {
4
- TanStackDevtools
5
- };
6
- //# sourceMappingURL=devtools.js.map
2
+ //#region src/devtools.tsx
3
+ var TanStackDevtools = clientOnly(() => import("./core.js").then((m) => m));
4
+ //#endregion
5
+ export { TanStackDevtools };
6
+
7
+ //# sourceMappingURL=devtools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.js","sources":["../../src/devtools.tsx"],"sourcesContent":["import clientOnly from './client-only'\n\nexport const TanStackDevtools = clientOnly(() =>\n import('./core').then((m) => m),\n)\n"],"names":["TanStackDevtools","clientOnly","then","m"],"mappings":";AAEO,MAAMA,mBAAmBC,WAAW,MACzC,OAAO,WAAQ,EAAEC,KAAMC,CAAAA,MAAMA,CAAC,CAChC;"}
1
+ {"version":3,"file":"devtools.js","names":["clientOnly","TanStackDevtools","then","m"],"sources":["../../src/devtools.tsx"],"sourcesContent":["import clientOnly from './client-only'\n\nexport const TanStackDevtools = clientOnly(() =>\n import('./core').then((m) => m),\n)\n"],"mappings":";;AAEA,IAAaC,mBAAmBD,iBAC9B,OAAO,aAAUE,MAAMC,MAAMA,EAC/B,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,5 +1,2 @@
1
1
  import { TanStackDevtools } from "./devtools.js";
2
- export {
3
- TanStackDevtools
4
- };
5
- //# sourceMappingURL=index.js.map
2
+ export { TanStackDevtools };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-devtools",
3
- "version": "0.7.32",
3
+ "version": "0.8.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",
@@ -39,11 +39,11 @@
39
39
  "src"
40
40
  ],
41
41
  "dependencies": {
42
- "@tanstack/devtools": "0.10.13"
42
+ "@tanstack/devtools": "0.11.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "solid-js": "^1.9.9",
46
- "vite-plugin-solid": "^2.11.8"
46
+ "vite-plugin-solid": "^2.11.11"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "solid-js": ">=1.9.7"
package/src/core.tsx CHANGED
@@ -12,21 +12,23 @@ import type {
12
12
  ClientEventBusConfig,
13
13
  TanStackDevtoolsConfig,
14
14
  TanStackDevtoolsPlugin,
15
+ TanStackDevtoolsPluginProps,
16
+ TanStackDevtoolsTheme,
15
17
  } from '@tanstack/devtools'
16
18
 
17
19
  type SolidPluginRender =
18
20
  | JSX.Element
19
21
  | ((
20
22
  el: HTMLDivElement | HTMLHeadingElement,
21
- theme: 'dark' | 'light',
23
+ props: TanStackDevtoolsPluginProps,
22
24
  ) => JSX.Element)
23
25
  const convertRender = (
24
26
  el: HTMLDivElement | HTMLHeadingElement,
25
27
  Component: SolidPluginRender,
26
- theme: 'dark' | 'light',
28
+ props: TanStackDevtoolsPluginProps,
27
29
  ) => (
28
30
  <Portal mount={el}>
29
- {typeof Component === 'function' ? Component(el, theme) : Component}
31
+ {typeof Component === 'function' ? Component(el, props) : Component}
30
32
  </Portal>
31
33
  )
32
34
 
@@ -75,7 +77,7 @@ export type TanStackDevtoolsSolidPlugin = Omit<
75
77
  name: string | SolidPluginRender
76
78
  }
77
79
  interface TriggerProps {
78
- theme: 'light' | 'dark'
80
+ theme: TanStackDevtoolsTheme
79
81
  }
80
82
  export interface TanStackDevtoolsInit {
81
83
  /**
@@ -128,10 +130,10 @@ export default function SolidDevtoolsCore({
128
130
  typeof plugin.name === 'string'
129
131
  ? plugin.name
130
132
  : // The check above confirms that `plugin.name` is of Render type
131
- (el, theme) =>
132
- convertRender(el, plugin.name as SolidPluginRender, theme),
133
- render: (el: HTMLDivElement, theme: 'dark' | 'light') =>
134
- convertRender(el, plugin.render, theme),
133
+ (el, props) =>
134
+ convertRender(el, plugin.name as SolidPluginRender, props),
135
+ render: (el: HTMLDivElement, props: TanStackDevtoolsPluginProps) =>
136
+ convertRender(el, plugin.render, props),
135
137
  })),
136
138
  )
137
139
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}