@tanstack/devtools-utils 0.0.2 → 0.0.3
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/react/esm/panel.js +3 -1
- package/dist/react/esm/panel.js.map +1 -1
- package/dist/solid/esm/dev.js +7 -9
- package/dist/solid/esm/index.js +7 -9
- package/dist/solid/esm/server.js +6 -5
- package/package.json +1 -1
- package/src/react/panel.tsx +3 -1
- package/src/solid/class.tsx +1 -2
- package/src/solid/panel.tsx +6 -9
package/dist/react/esm/panel.js
CHANGED
|
@@ -11,7 +11,9 @@ function createReactPanel(CoreClass) {
|
|
|
11
11
|
devtools.current.mount(devToolRef.current, props?.theme ?? "dark");
|
|
12
12
|
}
|
|
13
13
|
return () => {
|
|
14
|
-
|
|
14
|
+
if (devToolRef.current) {
|
|
15
|
+
devtools.current?.unmount();
|
|
16
|
+
}
|
|
15
17
|
};
|
|
16
18
|
}, [props?.theme]);
|
|
17
19
|
return /* @__PURE__ */ jsx("div", { style: { height: "100%" }, ref: devToolRef });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.js","sources":["../../../src/react/panel.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport interface DevtoolsPanelProps {\n theme?: 'light' | 'dark'\n}\n\n/**\n * Creates a React component that dynamically imports and mounts a devtools panel. SSR friendly.\n * @param devtoolsPackageName The name of the devtools package to be imported, e.g., '@tanstack/devtools-react'\n * @param importName The name of the export to be imported from the devtools package (e.g., 'default' or 'DevtoolsCore')\n * @returns A React component that mounts the devtools\n * @example\n * ```tsx\n * // if the export is default\n * const [ReactDevtoolsPanel, NoOpReactDevtoolsPanel] = createReactPanel('@tanstack/devtools-react')\n * ```\n *\n * @example\n * ```tsx\n * // if the export is named differently\n * const [ReactDevtoolsPanel, NoOpReactDevtoolsPanel] = createReactPanel('@tanstack/devtools-react', 'DevtoolsCore')\n * ```\n */\nexport function createReactPanel<\n TComponentProps extends DevtoolsPanelProps | undefined,\n TCoreDevtoolsClass extends {\n mount: (el: HTMLElement, theme: 'light' | 'dark') => void\n unmount: () => void\n },\n>(CoreClass: new () => TCoreDevtoolsClass) {\n function Panel(props: TComponentProps) {\n const devToolRef = useRef<HTMLDivElement>(null)\n const devtools = useRef<TCoreDevtoolsClass | null>(null)\n useEffect(() => {\n if (devtools.current) return\n\n devtools.current = new CoreClass()\n\n if (devToolRef.current) {\n devtools.current.mount(devToolRef.current, props?.theme ?? 'dark')\n }\n\n return () => {\n devtools.current?.unmount()\n }\n }, [props?.theme])\n\n return <div style={{ height: '100%' }} ref={devToolRef} />\n }\n\n function NoOpPanel(_props: TComponentProps) {\n return <></>\n }\n return [Panel, NoOpPanel] as const\n}\n"],"names":[],"mappings":";;AAuBO,SAAS,iBAMd,WAAyC;AACzC,WAAS,MAAM,OAAwB;AACrC,UAAM,aAAa,OAAuB,IAAI;AAC9C,UAAM,WAAW,OAAkC,IAAI;AACvD,cAAU,MAAM;AACd,UAAI,SAAS,QAAS;AAEtB,eAAS,UAAU,IAAI,UAAA;AAEvB,UAAI,WAAW,SAAS;AACtB,iBAAS,QAAQ,MAAM,WAAW,SAAS,OAAO,SAAS,MAAM;AAAA,MACnE;AAEA,aAAO,MAAM;AACX,
|
|
1
|
+
{"version":3,"file":"panel.js","sources":["../../../src/react/panel.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport interface DevtoolsPanelProps {\n theme?: 'light' | 'dark'\n}\n\n/**\n * Creates a React component that dynamically imports and mounts a devtools panel. SSR friendly.\n * @param devtoolsPackageName The name of the devtools package to be imported, e.g., '@tanstack/devtools-react'\n * @param importName The name of the export to be imported from the devtools package (e.g., 'default' or 'DevtoolsCore')\n * @returns A React component that mounts the devtools\n * @example\n * ```tsx\n * // if the export is default\n * const [ReactDevtoolsPanel, NoOpReactDevtoolsPanel] = createReactPanel('@tanstack/devtools-react')\n * ```\n *\n * @example\n * ```tsx\n * // if the export is named differently\n * const [ReactDevtoolsPanel, NoOpReactDevtoolsPanel] = createReactPanel('@tanstack/devtools-react', 'DevtoolsCore')\n * ```\n */\nexport function createReactPanel<\n TComponentProps extends DevtoolsPanelProps | undefined,\n TCoreDevtoolsClass extends {\n mount: (el: HTMLElement, theme: 'light' | 'dark') => void\n unmount: () => void\n },\n>(CoreClass: new () => TCoreDevtoolsClass) {\n function Panel(props: TComponentProps) {\n const devToolRef = useRef<HTMLDivElement>(null)\n const devtools = useRef<TCoreDevtoolsClass | null>(null)\n useEffect(() => {\n if (devtools.current) return\n\n devtools.current = new CoreClass()\n\n if (devToolRef.current) {\n devtools.current.mount(devToolRef.current, props?.theme ?? 'dark')\n }\n\n return () => {\n if (devToolRef.current) {\n devtools.current?.unmount()\n }\n }\n }, [props?.theme])\n\n return <div style={{ height: '100%' }} ref={devToolRef} />\n }\n\n function NoOpPanel(_props: TComponentProps) {\n return <></>\n }\n return [Panel, NoOpPanel] as const\n}\n"],"names":[],"mappings":";;AAuBO,SAAS,iBAMd,WAAyC;AACzC,WAAS,MAAM,OAAwB;AACrC,UAAM,aAAa,OAAuB,IAAI;AAC9C,UAAM,WAAW,OAAkC,IAAI;AACvD,cAAU,MAAM;AACd,UAAI,SAAS,QAAS;AAEtB,eAAS,UAAU,IAAI,UAAA;AAEvB,UAAI,WAAW,SAAS;AACtB,iBAAS,QAAQ,MAAM,WAAW,SAAS,OAAO,SAAS,MAAM;AAAA,MACnE;AAEA,aAAO,MAAM;AACX,YAAI,WAAW,SAAS;AACtB,mBAAS,SAAS,QAAA;AAAA,QACpB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,OAAO,KAAK,CAAC;AAEjB,WAAO,oBAAC,SAAI,OAAO,EAAE,QAAQ,OAAA,GAAU,KAAK,YAAY;AAAA,EAC1D;AAEA,WAAS,UAAU,QAAyB;AAC1C,WAAO,oBAAA,UAAA,EAAE;AAAA,EACX;AACA,SAAO,CAAC,OAAO,SAAS;AAC1B;"}
|
package/dist/solid/esm/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, template, insert, use } from 'solid-js/web';
|
|
2
|
-
import { onMount, onCleanup } from 'solid-js';
|
|
2
|
+
import { createSignal, onMount, onCleanup } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
// src/solid/class.tsx
|
|
5
5
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
@@ -24,9 +24,7 @@ function constructCoreClass(Component) {
|
|
|
24
24
|
}
|
|
25
25
|
const mountTo = el;
|
|
26
26
|
const dispose = render(() => {
|
|
27
|
-
this.#Component =
|
|
28
|
-
default: Component
|
|
29
|
-
}));
|
|
27
|
+
this.#Component = Component;
|
|
30
28
|
this.#ThemeProvider = lazy(() => import('@tanstack/devtools-ui').then((mod) => ({
|
|
31
29
|
default: mod.ThemeContextProvider
|
|
32
30
|
})));
|
|
@@ -73,14 +71,14 @@ var _tmpl$2 = /* @__PURE__ */ template(`<div>`);
|
|
|
73
71
|
function createSolidPanel(CoreClass) {
|
|
74
72
|
function Panel(props) {
|
|
75
73
|
let devToolRef;
|
|
74
|
+
const [devtools] = createSignal(new CoreClass());
|
|
76
75
|
onMount(() => {
|
|
77
|
-
const devtools = new CoreClass();
|
|
78
76
|
if (devToolRef) {
|
|
79
|
-
devtools.mount(devToolRef, props?.theme ?? "dark");
|
|
80
|
-
onCleanup(() => {
|
|
81
|
-
devtools.unmount();
|
|
82
|
-
});
|
|
77
|
+
devtools().mount(devToolRef, props?.theme ?? "dark");
|
|
83
78
|
}
|
|
79
|
+
onCleanup(() => {
|
|
80
|
+
devtools().unmount();
|
|
81
|
+
});
|
|
84
82
|
});
|
|
85
83
|
return (() => {
|
|
86
84
|
var _el$ = _tmpl$2();
|
package/dist/solid/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, template, insert, use } from 'solid-js/web';
|
|
2
|
-
import { onMount, onCleanup } from 'solid-js';
|
|
2
|
+
import { createSignal, onMount, onCleanup } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
// src/solid/class.tsx
|
|
5
5
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
@@ -24,9 +24,7 @@ function constructCoreClass(Component) {
|
|
|
24
24
|
}
|
|
25
25
|
const mountTo = el;
|
|
26
26
|
const dispose = render(() => {
|
|
27
|
-
this.#Component =
|
|
28
|
-
default: Component
|
|
29
|
-
}));
|
|
27
|
+
this.#Component = Component;
|
|
30
28
|
this.#ThemeProvider = lazy(() => import('@tanstack/devtools-ui').then((mod) => ({
|
|
31
29
|
default: mod.ThemeContextProvider
|
|
32
30
|
})));
|
|
@@ -73,14 +71,14 @@ var _tmpl$2 = /* @__PURE__ */ template(`<div>`);
|
|
|
73
71
|
function createSolidPanel(CoreClass) {
|
|
74
72
|
function Panel(props) {
|
|
75
73
|
let devToolRef;
|
|
74
|
+
const [devtools] = createSignal(new CoreClass());
|
|
76
75
|
onMount(() => {
|
|
77
|
-
const devtools = new CoreClass();
|
|
78
76
|
if (devToolRef) {
|
|
79
|
-
devtools.mount(devToolRef, props?.theme ?? "dark");
|
|
80
|
-
onCleanup(() => {
|
|
81
|
-
devtools.unmount();
|
|
82
|
-
});
|
|
77
|
+
devtools().mount(devToolRef, props?.theme ?? "dark");
|
|
83
78
|
}
|
|
79
|
+
onCleanup(() => {
|
|
80
|
+
devtools().unmount();
|
|
81
|
+
});
|
|
84
82
|
});
|
|
85
83
|
return (() => {
|
|
86
84
|
var _el$ = _tmpl$2();
|
package/dist/solid/esm/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, ssr, escape } from 'solid-js/web';
|
|
2
|
-
import { onMount } from 'solid-js';
|
|
2
|
+
import { createSignal, onMount, onCleanup } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
// src/solid/class.tsx
|
|
5
5
|
var _tmpl$ = ['<div style="', '">', "</div>"];
|
|
@@ -24,9 +24,7 @@ function constructCoreClass(Component) {
|
|
|
24
24
|
}
|
|
25
25
|
const mountTo = el;
|
|
26
26
|
const dispose = render(() => {
|
|
27
|
-
this.#Component =
|
|
28
|
-
default: Component
|
|
29
|
-
}));
|
|
27
|
+
this.#Component = Component;
|
|
30
28
|
this.#ThemeProvider = lazy(() => import('@tanstack/devtools-ui').then((mod) => ({
|
|
31
29
|
default: mod.ThemeContextProvider
|
|
32
30
|
})));
|
|
@@ -69,8 +67,11 @@ function constructCoreClass(Component) {
|
|
|
69
67
|
var _tmpl$2 = ['<div style="', '"></div>'];
|
|
70
68
|
function createSolidPanel(CoreClass) {
|
|
71
69
|
function Panel(props) {
|
|
70
|
+
const [devtools] = createSignal(new CoreClass());
|
|
72
71
|
onMount(() => {
|
|
73
|
-
|
|
72
|
+
onCleanup(() => {
|
|
73
|
+
devtools().unmount();
|
|
74
|
+
});
|
|
74
75
|
});
|
|
75
76
|
return ssr(_tmpl$2, "height:100%");
|
|
76
77
|
}
|
package/package.json
CHANGED
package/src/react/panel.tsx
CHANGED
package/src/solid/class.tsx
CHANGED
|
@@ -28,8 +28,7 @@ export function constructCoreClass(Component: () => JSX.Element) {
|
|
|
28
28
|
}
|
|
29
29
|
const mountTo = el
|
|
30
30
|
const dispose = render(() => {
|
|
31
|
-
|
|
32
|
-
this.#Component = lazy(async () => ({ default: Component }))
|
|
31
|
+
this.#Component = Component
|
|
33
32
|
|
|
34
33
|
this.#ThemeProvider = lazy(() =>
|
|
35
34
|
import('@tanstack/devtools-ui').then((mod) => ({
|
package/src/solid/panel.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource solid-js - we use Solid.js as JSX here */
|
|
2
2
|
|
|
3
|
-
import { onCleanup, onMount } from 'solid-js'
|
|
3
|
+
import { createSignal, onCleanup, onMount } from 'solid-js'
|
|
4
4
|
import type { ClassType } from './class'
|
|
5
5
|
|
|
6
6
|
export interface DevtoolsPanelProps {
|
|
@@ -12,17 +12,14 @@ export function createSolidPanel<
|
|
|
12
12
|
>(CoreClass: ClassType) {
|
|
13
13
|
function Panel(props: TComponentProps) {
|
|
14
14
|
let devToolRef: HTMLDivElement | undefined
|
|
15
|
-
|
|
15
|
+
const [devtools] = createSignal(new CoreClass())
|
|
16
16
|
onMount(() => {
|
|
17
|
-
const devtools = new CoreClass()
|
|
18
|
-
|
|
19
17
|
if (devToolRef) {
|
|
20
|
-
devtools.mount(devToolRef, props?.theme ?? 'dark')
|
|
21
|
-
|
|
22
|
-
onCleanup(() => {
|
|
23
|
-
devtools.unmount()
|
|
24
|
-
})
|
|
18
|
+
devtools().mount(devToolRef, props?.theme ?? 'dark')
|
|
25
19
|
}
|
|
20
|
+
onCleanup(() => {
|
|
21
|
+
devtools().unmount()
|
|
22
|
+
})
|
|
26
23
|
})
|
|
27
24
|
|
|
28
25
|
return <div style={{ height: '100%' }} ref={devToolRef} />
|