@tanstack/solid-devtools 0.3.0 → 0.3.2
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/cjs/client-only.cjs +26 -0
- package/dist/cjs/client-only.cjs.map +1 -0
- package/dist/cjs/client-only.d.cts +12 -0
- package/dist/cjs/core.cjs +52 -0
- package/dist/cjs/core.cjs.map +1 -0
- package/dist/cjs/core.d.cts +76 -0
- package/dist/cjs/devtools.cjs +3 -49
- package/dist/cjs/devtools.cjs.map +1 -1
- package/dist/cjs/devtools.d.cts +3 -76
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/client-only.d.ts +12 -0
- package/dist/esm/client-only.js +27 -0
- package/dist/esm/client-only.js.map +1 -0
- package/dist/esm/core.d.ts +76 -0
- package/dist/esm/core.js +53 -0
- package/dist/esm/core.js.map +1 -0
- package/dist/esm/devtools.d.ts +3 -76
- package/dist/esm/devtools.js +2 -49
- package/dist/esm/devtools.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/client-only.ts +54 -0
- package/src/core.tsx +130 -0
- package/src/devtools.tsx +3 -128
- package/src/index.ts +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const solidJs = require("solid-js");
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
function clientOnly(fn, options = {}) {
|
|
5
|
+
if (web.isServer)
|
|
6
|
+
return (props) => props.fallback;
|
|
7
|
+
const [comp, setComp] = solidJs.createSignal();
|
|
8
|
+
!options.lazy && load(fn, setComp);
|
|
9
|
+
return (props) => {
|
|
10
|
+
let Comp;
|
|
11
|
+
let m;
|
|
12
|
+
const [, rest] = solidJs.splitProps(props, ["fallback"]);
|
|
13
|
+
options.lazy && load(fn, setComp);
|
|
14
|
+
if ((Comp = comp()) && !solidJs.sharedConfig.context) return Comp(rest);
|
|
15
|
+
const [mounted, setMounted] = solidJs.createSignal(!solidJs.sharedConfig.context);
|
|
16
|
+
solidJs.onMount(() => setMounted(true));
|
|
17
|
+
return solidJs.createMemo(
|
|
18
|
+
() => (Comp = comp(), m = mounted(), solidJs.untrack(() => Comp && m ? Comp(rest) : props.fallback))
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function load(fn, setComp) {
|
|
23
|
+
fn().then((m) => setComp(() => m.default));
|
|
24
|
+
}
|
|
25
|
+
module.exports = clientOnly;
|
|
26
|
+
//# sourceMappingURL=client-only.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-only.cjs","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":["isServer","createSignal","splitProps","sharedConfig","onMount","createMemo","untrack"],"mappings":";;;AAgBA,SAAwB,WACtB,IAGA,UAA8B,IAC9B;AACA,MAAIA,IAAAA;AACF,WAAO,CAAC,UACN,MAAM;AAEV,QAAM,CAAC,MAAM,OAAO,IAAIC,qBAAA;AACxB,GAAC,QAAQ,QAAQ,KAAK,IAAI,OAAO;AACjC,SAAO,CAAC,UAA6B;AACnC,QAAI;AACJ,QAAI;AACJ,UAAM,CAAA,EAAG,IAAI,IAAIC,QAAAA,WAAW,OAAO,CAAC,UAAU,CAAC;AAC/C,YAAQ,QAAQ,KAAK,IAAI,OAAO;AAChC,SAAK,OAAO,WAAW,CAACC,QAAAA,aAAa,QAAS,QAAO,KAAK,IAAI;AAC9D,UAAM,CAAC,SAAS,UAAU,IAAIF,QAAAA,aAAa,CAACE,QAAAA,aAAa,OAAO;AAChEC,oBAAQ,MAAM,WAAW,IAAI,CAAC;AAC9B,WAAOC,QAAAA;AAAAA,MACL,OACG,OAAO,KAAA,GACP,IAAI,QAAA,GACLC,QAAAA,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;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component, ComponentProps, JSX } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
|
|
5
|
+
*/
|
|
6
|
+
export default function clientOnly<T extends Component<any>>(fn: () => Promise<{
|
|
7
|
+
default: T;
|
|
8
|
+
}>, options?: {
|
|
9
|
+
lazy?: boolean;
|
|
10
|
+
}): (props: ComponentProps<T> & {
|
|
11
|
+
fallback?: JSX.Element;
|
|
12
|
+
}) => any;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const web = require("solid-js/web");
|
|
3
|
+
const devtools = require("@tanstack/devtools");
|
|
4
|
+
const solidJs = require("solid-js");
|
|
5
|
+
var _tmpl$ = /* @__PURE__ */ web.template(`<div>`);
|
|
6
|
+
const convertRender = (el, Component) => web.createComponent(web.Portal, {
|
|
7
|
+
mount: el,
|
|
8
|
+
get children() {
|
|
9
|
+
return typeof Component === "function" ? web.createComponent(Component, {}) : Component;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function SolidDevtoolsCore({
|
|
13
|
+
config,
|
|
14
|
+
plugins,
|
|
15
|
+
eventBusConfig
|
|
16
|
+
}) {
|
|
17
|
+
const [devtools$1] = solidJs.createSignal(new devtools.TanStackDevtoolsCore({
|
|
18
|
+
config,
|
|
19
|
+
eventBusConfig,
|
|
20
|
+
plugins: plugins?.map((plugin) => ({
|
|
21
|
+
...plugin,
|
|
22
|
+
name: typeof plugin.name === "string" ? plugin.name : (
|
|
23
|
+
// The check above confirms that `plugin.name` is of Render type
|
|
24
|
+
(el) => convertRender(el, plugin.name)
|
|
25
|
+
),
|
|
26
|
+
render: (el) => convertRender(el, plugin.render)
|
|
27
|
+
}))
|
|
28
|
+
}));
|
|
29
|
+
let devToolRef;
|
|
30
|
+
solidJs.createEffect(() => {
|
|
31
|
+
devtools$1().setConfig({
|
|
32
|
+
config
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
solidJs.onMount(() => {
|
|
36
|
+
if (devToolRef) {
|
|
37
|
+
devtools$1().mount(devToolRef);
|
|
38
|
+
solidJs.onCleanup(() => {
|
|
39
|
+
devtools$1().unmount();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return (() => {
|
|
44
|
+
var _el$ = _tmpl$();
|
|
45
|
+
var _ref$ = devToolRef;
|
|
46
|
+
typeof _ref$ === "function" ? web.use(_ref$, _el$) : devToolRef = _el$;
|
|
47
|
+
_el$.style.setProperty("position", "absolute");
|
|
48
|
+
return _el$;
|
|
49
|
+
})();
|
|
50
|
+
}
|
|
51
|
+
module.exports = SolidDevtoolsCore;
|
|
52
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["../../src/core.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}\nexport interface TanstackDevtoolsInit {\n /**\n * Array of plugins to be used in the devtools.\n * Each plugin should have a `render` function that returns a React element or a function\n *\n * Example:\n * ```jsx\n * <TanstackDevtools\n * plugins={[\n * {\n * id: \"your-plugin-id\",\n * name: \"Your Plugin\",\n * render: <CustomPluginComponent />,\n * }\n * ]}\n * />\n * ```\n */\n plugins?: Array<TanStackDevtoolsSolidPlugin>\n /**\n * Configuration for the devtools shell. These configuration options are used to set the\n * initial state of the devtools when it is started for the first time. Afterwards,\n * the settings are persisted in local storage and changed through the settings panel.\n */\n config?: Partial<TanStackDevtoolsConfig>\n /**\n * Configuration for the TanStack Devtools client event bus.\n */\n eventBusConfig?: ClientEventBusConfig\n}\n\nexport default function SolidDevtoolsCore({\n config,\n plugins,\n eventBusConfig,\n}: TanstackDevtoolsInit) {\n 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 style={{ position: 'absolute' }} ref={devToolRef} />\n}\n"],"names":["convertRender","el","Component","_$createComponent","Portal","mount","children","SolidDevtoolsCore","config","plugins","eventBusConfig","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use","style","setProperty"],"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+EhE,SAAwBK,kBAAkB;AAAA,EACxCC;AAAAA,EACAC;AAAAA,EACAC;AACoB,GAAG;AACvB,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,QAAkDR;AAAU,WAAAQ,UAAA,aAAAC,IAAAA,IAAAD,OAAAF,IAAA,IAAVN,aAAUM;AAAAA,SAAAI,MAAAC,YAAA,YAAA,UAAA;AAAA,WAAAL;AAAAA,EAAA,GAAA;AAC9D;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { ClientEventBusConfig, 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
|
+
export 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?: Partial<TanStackDevtoolsConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for the TanStack Devtools client event bus.
|
|
72
|
+
*/
|
|
73
|
+
eventBusConfig?: ClientEventBusConfig;
|
|
74
|
+
}
|
|
75
|
+
export default function SolidDevtoolsCore({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit): JSX.Element;
|
|
76
|
+
export {};
|
package/dist/cjs/devtools.cjs
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ web.template(`<div>`);
|
|
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
|
-
eventBusConfig
|
|
17
|
-
}) => {
|
|
18
|
-
const [devtools$1] = solidJs.createSignal(new devtools.TanStackDevtoolsCore({
|
|
19
|
-
config,
|
|
20
|
-
eventBusConfig,
|
|
21
|
-
plugins: plugins?.map((plugin) => ({
|
|
22
|
-
...plugin,
|
|
23
|
-
name: typeof plugin.name === "string" ? plugin.name : (
|
|
24
|
-
// The check above confirms that `plugin.name` is of Render type
|
|
25
|
-
(el) => convertRender(el, plugin.name)
|
|
26
|
-
),
|
|
27
|
-
render: (el) => convertRender(el, plugin.render)
|
|
28
|
-
}))
|
|
29
|
-
}));
|
|
30
|
-
let devToolRef;
|
|
31
|
-
solidJs.createEffect(() => {
|
|
32
|
-
devtools$1().setConfig({
|
|
33
|
-
config
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
solidJs.onMount(() => {
|
|
37
|
-
if (devToolRef) {
|
|
38
|
-
devtools$1().mount(devToolRef);
|
|
39
|
-
solidJs.onCleanup(() => {
|
|
40
|
-
devtools$1().unmount();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return (() => {
|
|
45
|
-
var _el$ = _tmpl$();
|
|
46
|
-
var _ref$ = devToolRef;
|
|
47
|
-
typeof _ref$ === "function" ? web.use(_ref$, _el$) : devToolRef = _el$;
|
|
48
|
-
_el$.style.setProperty("height", "100%");
|
|
49
|
-
return _el$;
|
|
50
|
-
})();
|
|
51
|
-
};
|
|
3
|
+
const clientOnly = require("./client-only.cjs");
|
|
4
|
+
const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
|
|
5
|
+
const TanstackDevtools = clientOnly(() => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./core.cjs"))).then((m) => m));
|
|
52
6
|
exports.TanstackDevtools = TanstackDevtools;
|
|
53
7
|
//# 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 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,QAAA,QAAA,EAAA,KAAA,MAAA,6CAAA,QAAO,YAAQ,CAAA,CAAA,EAAEC,KAAMC,CAAAA,MAAMA,CAAC,CAChC;;"}
|
package/dist/cjs/devtools.d.cts
CHANGED
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
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?: Partial<TanStackDevtoolsConfig>;
|
|
70
|
-
/**
|
|
71
|
-
* Configuration for the TanStack Devtools client event bus.
|
|
72
|
-
*/
|
|
73
|
-
eventBusConfig?: ClientEventBusConfig;
|
|
74
|
-
}
|
|
75
|
-
export declare const TanstackDevtools: ({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit) => JSX.Element;
|
|
76
|
-
export {};
|
|
1
|
+
export declare const TanstackDevtools: (props: import('./core.cjs').TanstackDevtoolsInit & {
|
|
2
|
+
fallback?: import("solid-js").JSX.Element;
|
|
3
|
+
}) => any;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -3,4 +3,4 @@ export * from '@tanstack/devtools';
|
|
|
3
3
|
* Export every hook individually - DON'T export from barrel files
|
|
4
4
|
*/
|
|
5
5
|
export { TanstackDevtools } from './devtools.cjs';
|
|
6
|
-
export type { TanStackDevtoolsSolidPlugin } from './
|
|
6
|
+
export type { TanStackDevtoolsSolidPlugin } from './core.cjs';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component, ComponentProps, JSX } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
|
|
5
|
+
*/
|
|
6
|
+
export default function clientOnly<T extends Component<any>>(fn: () => Promise<{
|
|
7
|
+
default: T;
|
|
8
|
+
}>, options?: {
|
|
9
|
+
lazy?: boolean;
|
|
10
|
+
}): (props: ComponentProps<T> & {
|
|
11
|
+
fallback?: JSX.Element;
|
|
12
|
+
}) => any;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createSignal, splitProps, sharedConfig, onMount, createMemo, untrack } from "solid-js";
|
|
2
|
+
import { isServer } from "solid-js/web";
|
|
3
|
+
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
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function load(fn, setComp) {
|
|
22
|
+
fn().then((m) => setComp(() => m.default));
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
clientOnly as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=client-only.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { ClientEventBusConfig, 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
|
+
export 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?: Partial<TanStackDevtoolsConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for the TanStack Devtools client event bus.
|
|
72
|
+
*/
|
|
73
|
+
eventBusConfig?: ClientEventBusConfig;
|
|
74
|
+
}
|
|
75
|
+
export default function SolidDevtoolsCore({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit): JSX.Element;
|
|
76
|
+
export {};
|
package/dist/esm/core.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createComponent, template, use, Portal } from "solid-js/web";
|
|
2
|
+
import { TanStackDevtoolsCore } from "@tanstack/devtools";
|
|
3
|
+
import { createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
4
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
5
|
+
const convertRender = (el, Component) => createComponent(Portal, {
|
|
6
|
+
mount: el,
|
|
7
|
+
get children() {
|
|
8
|
+
return typeof Component === "function" ? createComponent(Component, {}) : Component;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function SolidDevtoolsCore({
|
|
12
|
+
config,
|
|
13
|
+
plugins,
|
|
14
|
+
eventBusConfig
|
|
15
|
+
}) {
|
|
16
|
+
const [devtools] = createSignal(new TanStackDevtoolsCore({
|
|
17
|
+
config,
|
|
18
|
+
eventBusConfig,
|
|
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
|
+
}));
|
|
28
|
+
let devToolRef;
|
|
29
|
+
createEffect(() => {
|
|
30
|
+
devtools().setConfig({
|
|
31
|
+
config
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
onMount(() => {
|
|
35
|
+
if (devToolRef) {
|
|
36
|
+
devtools().mount(devToolRef);
|
|
37
|
+
onCleanup(() => {
|
|
38
|
+
devtools().unmount();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return (() => {
|
|
43
|
+
var _el$ = _tmpl$();
|
|
44
|
+
var _ref$ = devToolRef;
|
|
45
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : devToolRef = _el$;
|
|
46
|
+
_el$.style.setProperty("position", "absolute");
|
|
47
|
+
return _el$;
|
|
48
|
+
})();
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
SolidDevtoolsCore as default
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/core.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}\nexport interface TanstackDevtoolsInit {\n /**\n * Array of plugins to be used in the devtools.\n * Each plugin should have a `render` function that returns a React element or a function\n *\n * Example:\n * ```jsx\n * <TanstackDevtools\n * plugins={[\n * {\n * id: \"your-plugin-id\",\n * name: \"Your Plugin\",\n * render: <CustomPluginComponent />,\n * }\n * ]}\n * />\n * ```\n */\n plugins?: Array<TanStackDevtoolsSolidPlugin>\n /**\n * Configuration for the devtools shell. These configuration options are used to set the\n * initial state of the devtools when it is started for the first time. Afterwards,\n * the settings are persisted in local storage and changed through the settings panel.\n */\n config?: Partial<TanStackDevtoolsConfig>\n /**\n * Configuration for the TanStack Devtools client event bus.\n */\n eventBusConfig?: ClientEventBusConfig\n}\n\nexport default function SolidDevtoolsCore({\n config,\n plugins,\n eventBusConfig,\n}: TanstackDevtoolsInit) {\n 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 style={{ position: 'absolute' }} ref={devToolRef} />\n}\n"],"names":["convertRender","el","Component","_$createComponent","Portal","mount","children","SolidDevtoolsCore","config","plugins","eventBusConfig","devtools","createSignal","TanStackDevtoolsCore","map","plugin","name","render","devToolRef","createEffect","setConfig","onMount","onCleanup","unmount","_el$","_tmpl$","_ref$","_$use","style","setProperty"],"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+EhE,SAAwBK,kBAAkB;AAAA,EACxCC;AAAAA,EACAC;AAAAA,EACAC;AACoB,GAAG;AACvB,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,QAAkDR;AAAU,WAAAQ,UAAA,aAAAC,IAAAD,OAAAF,IAAA,IAAVN,aAAUM;AAAAA,SAAAI,MAAAC,YAAA,YAAA,UAAA;AAAA,WAAAL;AAAAA,EAAA,GAAA;AAC9D;"}
|
package/dist/esm/devtools.d.ts
CHANGED
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
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?: Partial<TanStackDevtoolsConfig>;
|
|
70
|
-
/**
|
|
71
|
-
* Configuration for the TanStack Devtools client event bus.
|
|
72
|
-
*/
|
|
73
|
-
eventBusConfig?: ClientEventBusConfig;
|
|
74
|
-
}
|
|
75
|
-
export declare const TanstackDevtools: ({ config, plugins, eventBusConfig, }: TanstackDevtoolsInit) => JSX.Element;
|
|
76
|
-
export {};
|
|
1
|
+
export declare const TanstackDevtools: (props: import('./core.js').TanstackDevtoolsInit & {
|
|
2
|
+
fallback?: import("solid-js").JSX.Element;
|
|
3
|
+
}) => any;
|
package/dist/esm/devtools.js
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { createSignal, createEffect, onMount, onCleanup } from "solid-js";
|
|
4
|
-
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
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
|
-
eventBusConfig
|
|
15
|
-
}) => {
|
|
16
|
-
const [devtools] = createSignal(new TanStackDevtoolsCore({
|
|
17
|
-
config,
|
|
18
|
-
eventBusConfig,
|
|
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
|
-
}));
|
|
28
|
-
let devToolRef;
|
|
29
|
-
createEffect(() => {
|
|
30
|
-
devtools().setConfig({
|
|
31
|
-
config
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
onMount(() => {
|
|
35
|
-
if (devToolRef) {
|
|
36
|
-
devtools().mount(devToolRef);
|
|
37
|
-
onCleanup(() => {
|
|
38
|
-
devtools().unmount();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return (() => {
|
|
43
|
-
var _el$ = _tmpl$();
|
|
44
|
-
var _ref$ = devToolRef;
|
|
45
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) : devToolRef = _el$;
|
|
46
|
-
_el$.style.setProperty("height", "100%");
|
|
47
|
-
return _el$;
|
|
48
|
-
})();
|
|
49
|
-
};
|
|
1
|
+
import clientOnly from "./client-only.js";
|
|
2
|
+
const TanstackDevtools = clientOnly(() => import("./core.js").then((m) => m));
|
|
50
3
|
export {
|
|
51
4
|
TanstackDevtools
|
|
52
5
|
};
|
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 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;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export * from '@tanstack/devtools';
|
|
|
3
3
|
* Export every hook individually - DON'T export from barrel files
|
|
4
4
|
*/
|
|
5
5
|
export { TanstackDevtools } from './devtools.js';
|
|
6
|
-
export type { TanStackDevtoolsSolidPlugin } from './
|
|
6
|
+
export type { TanStackDevtoolsSolidPlugin } from './core.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-devtools",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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.3.
|
|
47
|
+
"@tanstack/devtools": "0.3.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"solid-js": "^1.9.7",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMemo,
|
|
3
|
+
createSignal,
|
|
4
|
+
onMount,
|
|
5
|
+
sharedConfig,
|
|
6
|
+
splitProps,
|
|
7
|
+
untrack,
|
|
8
|
+
} from 'solid-js'
|
|
9
|
+
import { isServer } from 'solid-js/web'
|
|
10
|
+
import type { Component, ComponentProps, JSX, Setter } from 'solid-js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
|
|
15
|
+
*/
|
|
16
|
+
// not using Suspense
|
|
17
|
+
export default function clientOnly<T extends Component<any>>(
|
|
18
|
+
fn: () => Promise<{
|
|
19
|
+
default: T
|
|
20
|
+
}>,
|
|
21
|
+
options: { lazy?: boolean } = {},
|
|
22
|
+
) {
|
|
23
|
+
if (isServer)
|
|
24
|
+
return (props: ComponentProps<T> & { fallback?: JSX.Element }) =>
|
|
25
|
+
props.fallback
|
|
26
|
+
|
|
27
|
+
const [comp, setComp] = createSignal<T>()
|
|
28
|
+
!options.lazy && load(fn, setComp)
|
|
29
|
+
return (props: ComponentProps<T>) => {
|
|
30
|
+
let Comp: T | undefined
|
|
31
|
+
let m: boolean
|
|
32
|
+
const [, rest] = splitProps(props, ['fallback'])
|
|
33
|
+
options.lazy && load(fn, setComp)
|
|
34
|
+
if ((Comp = comp()) && !sharedConfig.context) return Comp(rest)
|
|
35
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.context)
|
|
36
|
+
onMount(() => setMounted(true))
|
|
37
|
+
return createMemo(
|
|
38
|
+
() => (
|
|
39
|
+
(Comp = comp()),
|
|
40
|
+
(m = mounted()),
|
|
41
|
+
untrack(() => (Comp && m ? Comp(rest) : props.fallback))
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function load<T>(
|
|
48
|
+
fn: () => Promise<{
|
|
49
|
+
default: T
|
|
50
|
+
}>,
|
|
51
|
+
setComp: Setter<T>,
|
|
52
|
+
) {
|
|
53
|
+
fn().then((m) => setComp(() => m.default))
|
|
54
|
+
}
|
package/src/core.tsx
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { TanStackDevtoolsCore } from '@tanstack/devtools'
|
|
2
|
+
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js'
|
|
3
|
+
import { Portal } from 'solid-js/web'
|
|
4
|
+
import type { JSX } from 'solid-js'
|
|
5
|
+
import type {
|
|
6
|
+
ClientEventBusConfig,
|
|
7
|
+
TanStackDevtoolsConfig,
|
|
8
|
+
TanStackDevtoolsPlugin,
|
|
9
|
+
} from '@tanstack/devtools'
|
|
10
|
+
|
|
11
|
+
type SolidPluginRender = JSX.Element | (() => JSX.Element)
|
|
12
|
+
const convertRender = (
|
|
13
|
+
el: HTMLDivElement | HTMLHeadingElement,
|
|
14
|
+
Component: SolidPluginRender,
|
|
15
|
+
) => (
|
|
16
|
+
<Portal mount={el}>
|
|
17
|
+
{typeof Component === 'function' ? <Component /> : Component}
|
|
18
|
+
</Portal>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export type TanStackDevtoolsSolidPlugin = Omit<
|
|
22
|
+
TanStackDevtoolsPlugin,
|
|
23
|
+
'render' | 'name'
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
63
|
+
name: string | SolidPluginRender
|
|
64
|
+
}
|
|
65
|
+
export 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
|
+
*/
|
|
83
|
+
plugins?: Array<TanStackDevtoolsSolidPlugin>
|
|
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
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default function SolidDevtoolsCore({
|
|
97
|
+
config,
|
|
98
|
+
plugins,
|
|
99
|
+
eventBusConfig,
|
|
100
|
+
}: TanstackDevtoolsInit) {
|
|
101
|
+
const [devtools] = createSignal(
|
|
102
|
+
new TanStackDevtoolsCore({
|
|
103
|
+
config,
|
|
104
|
+
eventBusConfig,
|
|
105
|
+
plugins: plugins?.map((plugin) => ({
|
|
106
|
+
...plugin,
|
|
107
|
+
name:
|
|
108
|
+
typeof plugin.name === 'string'
|
|
109
|
+
? plugin.name
|
|
110
|
+
: // The check above confirms that `plugin.name` is of Render type
|
|
111
|
+
(el) => convertRender(el, plugin.name as SolidPluginRender),
|
|
112
|
+
render: (el: HTMLDivElement) => convertRender(el, plugin.render),
|
|
113
|
+
})),
|
|
114
|
+
}),
|
|
115
|
+
)
|
|
116
|
+
let devToolRef: HTMLDivElement | undefined
|
|
117
|
+
createEffect(() => {
|
|
118
|
+
devtools().setConfig({ config })
|
|
119
|
+
})
|
|
120
|
+
onMount(() => {
|
|
121
|
+
if (devToolRef) {
|
|
122
|
+
devtools().mount(devToolRef)
|
|
123
|
+
|
|
124
|
+
onCleanup(() => {
|
|
125
|
+
devtools().unmount()
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
return <div style={{ position: 'absolute' }} ref={devToolRef} />
|
|
130
|
+
}
|
package/src/devtools.tsx
CHANGED
|
@@ -1,130 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js'
|
|
3
|
-
import { Portal } from 'solid-js/web'
|
|
4
|
-
import type { JSX } from 'solid-js'
|
|
5
|
-
import type {
|
|
6
|
-
ClientEventBusConfig,
|
|
7
|
-
TanStackDevtoolsConfig,
|
|
8
|
-
TanStackDevtoolsPlugin,
|
|
9
|
-
} from '@tanstack/devtools'
|
|
1
|
+
import clientOnly from './client-only'
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
el: HTMLDivElement | HTMLHeadingElement,
|
|
14
|
-
Component: SolidPluginRender,
|
|
15
|
-
) => (
|
|
16
|
-
<Portal mount={el}>
|
|
17
|
-
{typeof Component === 'function' ? <Component /> : Component}
|
|
18
|
-
</Portal>
|
|
3
|
+
export const TanstackDevtools = clientOnly(() =>
|
|
4
|
+
import('./core').then((m) => m),
|
|
19
5
|
)
|
|
20
|
-
|
|
21
|
-
export type TanStackDevtoolsSolidPlugin = Omit<
|
|
22
|
-
TanStackDevtoolsPlugin,
|
|
23
|
-
'render' | 'name'
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
63
|
-
name: string | SolidPluginRender
|
|
64
|
-
}
|
|
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
|
-
*/
|
|
83
|
-
plugins?: Array<TanStackDevtoolsSolidPlugin>
|
|
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
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const TanstackDevtools = ({
|
|
97
|
-
config,
|
|
98
|
-
plugins,
|
|
99
|
-
eventBusConfig,
|
|
100
|
-
}: TanstackDevtoolsInit) => {
|
|
101
|
-
const [devtools] = createSignal(
|
|
102
|
-
new TanStackDevtoolsCore({
|
|
103
|
-
config,
|
|
104
|
-
eventBusConfig,
|
|
105
|
-
plugins: plugins?.map((plugin) => ({
|
|
106
|
-
...plugin,
|
|
107
|
-
name:
|
|
108
|
-
typeof plugin.name === 'string'
|
|
109
|
-
? plugin.name
|
|
110
|
-
: // The check above confirms that `plugin.name` is of Render type
|
|
111
|
-
(el) => convertRender(el, plugin.name as SolidPluginRender),
|
|
112
|
-
render: (el: HTMLDivElement) => convertRender(el, plugin.render),
|
|
113
|
-
})),
|
|
114
|
-
}),
|
|
115
|
-
)
|
|
116
|
-
let devToolRef: HTMLDivElement | undefined
|
|
117
|
-
createEffect(() => {
|
|
118
|
-
devtools().setConfig({ config })
|
|
119
|
-
})
|
|
120
|
-
onMount(() => {
|
|
121
|
-
if (devToolRef) {
|
|
122
|
-
devtools().mount(devToolRef)
|
|
123
|
-
|
|
124
|
-
onCleanup(() => {
|
|
125
|
-
devtools().unmount()
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
return <div style={{ height: '100%' }} ref={devToolRef} />
|
|
130
|
-
}
|
package/src/index.ts
CHANGED