@tanstack/devtools-utils 0.3.4 → 0.4.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.
Files changed (52) hide show
  1. package/dist/preact/esm/index.js +1 -5
  2. package/dist/preact/esm/panel.d.ts +4 -5
  3. package/dist/preact/esm/panel.js +48 -28
  4. package/dist/preact/esm/panel.js.map +1 -1
  5. package/dist/preact/esm/plugin.d.ts +3 -2
  6. package/dist/preact/esm/plugin.js +20 -22
  7. package/dist/preact/esm/plugin.js.map +1 -1
  8. package/dist/react/esm/index.js +1 -5
  9. package/dist/react/esm/panel.d.ts +4 -4
  10. package/dist/react/esm/panel.js +47 -28
  11. package/dist/react/esm/panel.js.map +1 -1
  12. package/dist/react/esm/plugin.d.ts +3 -2
  13. package/dist/react/esm/plugin.js +20 -22
  14. package/dist/react/esm/plugin.js.map +1 -1
  15. package/dist/solid/esm/chunk/{ZXPCWXRH.js → 7TSS377A.js} +2 -10
  16. package/dist/solid/esm/chunk/{UX5ZZ4MG.js → WUD4VD3N.js} +2 -10
  17. package/dist/solid/esm/class-mount-impl/5TF6RAHJ.js +1 -0
  18. package/dist/solid/esm/class-mount-impl/VN5QTPB3.js +1 -0
  19. package/dist/solid/esm/dev.js +9 -11
  20. package/dist/solid/esm/index.d.ts +10 -10
  21. package/dist/solid/esm/index.js +9 -11
  22. package/dist/solid/esm/server.js +8 -10
  23. package/dist/solid-class/esm/class-mount-impl.d.ts +3 -2
  24. package/dist/solid-class/esm/class-mount-impl.js +17 -23
  25. package/dist/solid-class/esm/class-mount-impl.js.map +1 -1
  26. package/dist/solid-class/esm/class.d.ts +4 -3
  27. package/dist/solid-class/esm/class.js +57 -54
  28. package/dist/solid-class/esm/class.js.map +1 -1
  29. package/dist/solid-class/esm/panel.d.ts +3 -3
  30. package/dist/solid-class/esm/plugin.d.ts +3 -2
  31. package/dist/vue/esm/index.js +1 -5
  32. package/dist/vue/esm/panel.d.ts +3 -3
  33. package/dist/vue/esm/panel.js +36 -45
  34. package/dist/vue/esm/panel.js.map +1 -1
  35. package/dist/vue/esm/plugin.js +20 -19
  36. package/dist/vue/esm/plugin.js.map +1 -1
  37. package/package.json +6 -8
  38. package/src/preact/panel.tsx +6 -7
  39. package/src/preact/plugin.tsx +4 -3
  40. package/src/react/panel.tsx +6 -7
  41. package/src/react/plugin.tsx +4 -3
  42. package/src/solid/class-mount-impl.tsx +7 -10
  43. package/src/solid/class.test.tsx +43 -12
  44. package/src/solid/class.ts +15 -4
  45. package/src/solid/panel.tsx +6 -7
  46. package/src/solid/plugin.tsx +4 -3
  47. package/src/vue/panel.ts +6 -7
  48. package/dist/preact/esm/index.js.map +0 -1
  49. package/dist/react/esm/index.js.map +0 -1
  50. package/dist/solid/esm/class-mount-impl/LK7V47IP.js +0 -1
  51. package/dist/solid/esm/class-mount-impl/ZAIAXV4M.js +0 -1
  52. package/dist/vue/esm/index.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { __mountComponent } from './chunk/ZXPCWXRH.js';
1
+ export { __mountComponent } from './chunk/7TSS377A.js';
2
2
  import { use, createComponent, template } from 'solid-js/web';
3
3
  import { createSignal, onMount, onCleanup } from 'solid-js';
4
4
 
@@ -11,19 +11,19 @@ function constructCoreClass(importFn) {
11
11
  #dispose;
12
12
  constructor() {
13
13
  }
14
- async mount(el, theme) {
14
+ async mount(el, props) {
15
15
  if (this.#isMounted || this.#isMounting) {
16
16
  throw new Error("Devtools is already mounted");
17
17
  }
18
18
  this.#isMounting = true;
19
19
  this.#abortMount = false;
20
20
  try {
21
- const { __mountComponent: __mountComponent2 } = await import('./class-mount-impl/ZAIAXV4M.js');
21
+ const { __mountComponent: __mountComponent2 } = await import('./class-mount-impl/VN5QTPB3.js');
22
22
  if (this.#abortMount) {
23
23
  this.#isMounting = false;
24
24
  return;
25
25
  }
26
- this.#dispose = __mountComponent2(el, theme, importFn);
26
+ this.#dispose = __mountComponent2(el, props, importFn);
27
27
  this.#isMounted = true;
28
28
  this.#isMounting = false;
29
29
  } catch (err) {
@@ -48,7 +48,7 @@ function constructCoreClass(importFn) {
48
48
  constructor() {
49
49
  super();
50
50
  }
51
- async mount(_el, _theme) {
51
+ async mount(_el, _props) {
52
52
  }
53
53
  unmount() {
54
54
  }
@@ -62,7 +62,7 @@ function createSolidPanel(CoreClass) {
62
62
  const [devtools] = createSignal(new CoreClass());
63
63
  onMount(() => {
64
64
  if (devToolRef) {
65
- devtools().mount(devToolRef, props?.theme ?? "dark");
65
+ devtools().mount(devToolRef, props);
66
66
  }
67
67
  onCleanup(() => {
68
68
  devtools().unmount();
@@ -87,17 +87,15 @@ function createSolidPlugin({
87
87
  function Plugin() {
88
88
  return {
89
89
  ...config,
90
- render: (_el, theme) => {
91
- return createComponent(Component, {
92
- theme
93
- });
90
+ render: (_el, props) => {
91
+ return createComponent(Component, props);
94
92
  }
95
93
  };
96
94
  }
97
95
  function NoOpPlugin() {
98
96
  return {
99
97
  ...config,
100
- render: (_el, _theme) => []
98
+ render: (_el, _props) => []
101
99
  };
102
100
  }
103
101
  return [Plugin, NoOpPlugin];
@@ -1,4 +1,4 @@
1
- export { __mountComponent } from './chunk/UX5ZZ4MG.js';
1
+ export { __mountComponent } from './chunk/WUD4VD3N.js';
2
2
  import { ssr, ssrStyleProperty, createComponent } from 'solid-js/web';
3
3
  import { createSignal, onMount, onCleanup } from 'solid-js';
4
4
 
@@ -11,19 +11,19 @@ function constructCoreClass(importFn) {
11
11
  #dispose;
12
12
  constructor() {
13
13
  }
14
- async mount(el, theme) {
14
+ async mount(el, props) {
15
15
  if (this.#isMounted || this.#isMounting) {
16
16
  throw new Error("Devtools is already mounted");
17
17
  }
18
18
  this.#isMounting = true;
19
19
  this.#abortMount = false;
20
20
  try {
21
- const { __mountComponent: __mountComponent2 } = await import('./class-mount-impl/LK7V47IP.js');
21
+ const { __mountComponent: __mountComponent2 } = await import('./class-mount-impl/5TF6RAHJ.js');
22
22
  if (this.#abortMount) {
23
23
  this.#isMounting = false;
24
24
  return;
25
25
  }
26
- this.#dispose = __mountComponent2(el, theme, importFn);
26
+ this.#dispose = __mountComponent2(el, props, importFn);
27
27
  this.#isMounted = true;
28
28
  this.#isMounting = false;
29
29
  } catch (err) {
@@ -48,7 +48,7 @@ function constructCoreClass(importFn) {
48
48
  constructor() {
49
49
  super();
50
50
  }
51
- async mount(_el, _theme) {
51
+ async mount(_el, _props) {
52
52
  }
53
53
  unmount() {
54
54
  }
@@ -78,17 +78,15 @@ function createSolidPlugin({
78
78
  function Plugin() {
79
79
  return {
80
80
  ...config,
81
- render: (_el, theme) => {
82
- return createComponent(Component, {
83
- theme
84
- });
81
+ render: (_el, props) => {
82
+ return createComponent(Component, props);
85
83
  }
86
84
  };
87
85
  }
88
86
  function NoOpPlugin() {
89
87
  return {
90
88
  ...config,
91
- render: (_el, _theme) => []
89
+ render: (_el, _props) => []
92
90
  };
93
91
  }
94
92
  return [Plugin, NoOpPlugin];
@@ -1,4 +1,5 @@
1
1
  import { JSX } from 'solid-js';
2
- export declare function __mountComponent(el: HTMLElement, theme: 'light' | 'dark', importFn: () => Promise<{
3
- default: () => JSX.Element;
2
+ import { TanStackDevtoolsPluginProps } from '@tanstack/devtools';
3
+ export declare function __mountComponent(el: HTMLElement, props: TanStackDevtoolsPluginProps, importFn: () => Promise<{
4
+ default: (props: TanStackDevtoolsPluginProps) => JSX.Element;
4
5
  }>): () => void;
@@ -1,26 +1,20 @@
1
- import { render, createComponent, Portal, insert, template } from "solid-js/web";
1
+ import { Portal, createComponent, insert, render, template } from "solid-js/web";
2
2
  import { lazy } from "solid-js";
3
+ //#region src/solid/class-mount-impl.tsx
4
+ /** @jsxImportSource solid-js - we use Solid.js as JSX here */
3
5
  var _tmpl$ = /* @__PURE__ */ template(`<div style=height:100%>`);
4
- function __mountComponent(el, theme, importFn) {
5
- const Component = lazy(importFn);
6
- const ThemeProvider = lazy(() => import("@tanstack/devtools-ui").then((m) => ({
7
- default: m.ThemeContextProvider
8
- })));
9
- return render(() => createComponent(Portal, {
10
- mount: el,
11
- get children() {
12
- var _el$ = _tmpl$();
13
- insert(_el$, createComponent(ThemeProvider, {
14
- theme,
15
- get children() {
16
- return createComponent(Component, {});
17
- }
18
- }));
19
- return _el$;
20
- }
21
- }), el);
6
+ function __mountComponent(el, props, importFn) {
7
+ const Component = lazy(importFn);
8
+ return render(() => createComponent(Portal, {
9
+ mount: el,
10
+ get children() {
11
+ var _el$ = _tmpl$();
12
+ insert(_el$, createComponent(Component, props));
13
+ return _el$;
14
+ }
15
+ }), el);
22
16
  }
23
- export {
24
- __mountComponent
25
- };
26
- //# sourceMappingURL=class-mount-impl.js.map
17
+ //#endregion
18
+ export { __mountComponent };
19
+
20
+ //# sourceMappingURL=class-mount-impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-mount-impl.js","sources":["../../../src/solid/class-mount-impl.tsx"],"sourcesContent":["/** @jsxImportSource solid-js - we use Solid.js as JSX here */\n\nimport { lazy } from 'solid-js'\nimport { Portal, render } from 'solid-js/web'\nimport type { JSX } from 'solid-js'\n\nexport function __mountComponent(\n el: HTMLElement,\n theme: 'light' | 'dark',\n importFn: () => Promise<{ default: () => JSX.Element }>,\n): () => void {\n const Component = lazy(importFn)\n const ThemeProvider = lazy(() =>\n import('@tanstack/devtools-ui').then((m) => ({\n default: m.ThemeContextProvider,\n })),\n )\n\n return render(\n () => (\n <Portal mount={el}>\n <div style={{ height: '100%' }}>\n <ThemeProvider theme={theme}>\n <Component />\n </ThemeProvider>\n </div>\n </Portal>\n ),\n el,\n )\n}\n"],"names":["__mountComponent","el","theme","importFn","Component","lazy","ThemeProvider","then","m","default","ThemeContextProvider","render","_$createComponent","Portal","mount","children","_el$","_tmpl$","_$insert"],"mappings":";;;AAMO,SAASA,iBACdC,IACAC,OACAC,UACY;AACZ,QAAMC,YAAYC,KAAKF,QAAQ;AAC/B,QAAMG,gBAAgBD,KAAK,MACzB,OAAO,uBAAuB,EAAEE,KAAMC,CAAAA,OAAO;AAAA,IAC3CC,SAASD,EAAEE;AAAAA,EAAAA,EACX,CACJ;AAEA,SAAOC,OACL,MAAAC,gBACGC,QAAM;AAAA,IAACC,OAAOb;AAAAA,IAAE,IAAAc,WAAA;AAAA,UAAAC,OAAAC,OAAAA;AAAAC,aAAAF,MAAAJ,gBAEZN,eAAa;AAAA,QAACJ;AAAAA,QAAY,IAAAa,WAAA;AAAA,iBAAAH,gBACxBR,WAAS,EAAA;AAAA,QAAA;AAAA,MAAA,CAAA,CAAA;AAAA,aAAAY;AAAAA,IAAA;AAAA,EAAA,CAAA,GAKlBf,EACF;AACF;"}
1
+ {"version":3,"file":"class-mount-impl.js","names":["lazy","Portal","render","JSX","TanStackDevtoolsPluginProps","__mountComponent","el","HTMLElement","props","importFn","Promise","default","Element","Component","_$createComponent","mount","children","_el$","_tmpl$","_$insert"],"sources":["../../../src/solid/class-mount-impl.tsx"],"sourcesContent":["/** @jsxImportSource solid-js - we use Solid.js as JSX here */\n\nimport { lazy } from 'solid-js'\nimport { Portal, render } from 'solid-js/web'\n\nimport type { JSX } from 'solid-js'\nimport type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'\n\nexport function __mountComponent(\n el: HTMLElement,\n props: TanStackDevtoolsPluginProps,\n importFn: () => Promise<{\n default: (props: TanStackDevtoolsPluginProps) => JSX.Element\n }>,\n): () => void {\n const Component = lazy(importFn)\n\n return render(\n () => (\n <Portal mount={el}>\n <div style={{ height: '100%' }}>\n <Component {...props} />\n </div>\n </Portal>\n ),\n el,\n )\n}\n"],"mappings":";;;;;AAQA,SAAgBK,iBACdC,IACAE,OACAC,UAGY;CACZ,MAAMI,YAAYb,KAAKS,SAAS;AAEhC,QAAOP,aACLY,gBACGb,QAAM;EAACc,OAAOT;EAAE,IAAAU,WAAA;GAAA,IAAAC,OAAAC,QAAA;AAAAC,UAAAF,MAAAH,gBAEZD,WAAcL,MAAK,CAAA;AAAA,UAAAS;;EAAA,CAGzB,EACDX,GACD"}
@@ -1,3 +1,4 @@
1
+ import { TanStackDevtoolsPluginProps } from '@tanstack/devtools';
1
2
  import { JSX } from 'solid-js';
2
3
  /**
3
4
  * Constructs the core class for the Devtools.
@@ -9,19 +10,19 @@ import { JSX } from 'solid-js';
9
10
  * @returns Tuple containing the DevtoolsCore class and a NoOpDevtoolsCore class
10
11
  */
11
12
  export declare function constructCoreClass(importFn: () => Promise<{
12
- default: () => JSX.Element;
13
+ default: (props: TanStackDevtoolsPluginProps) => JSX.Element;
13
14
  }>): readonly [{
14
15
  new (): {
15
16
  "__#private@#isMounted": boolean;
16
17
  "__#private@#isMounting": boolean;
17
18
  "__#private@#abortMount": boolean;
18
19
  "__#private@#dispose"?: () => void;
19
- mount<T extends HTMLElement>(el: T, theme: "light" | "dark"): Promise<void>;
20
+ mount<T extends HTMLElement>(el: T, props: TanStackDevtoolsPluginProps): Promise<void>;
20
21
  unmount(): void;
21
22
  };
22
23
  }, {
23
24
  new (): {
24
- mount<T extends HTMLElement>(_el: T, _theme: "light" | "dark"): Promise<void>;
25
+ mount<T extends HTMLElement>(_el: T, _props: TanStackDevtoolsPluginProps): Promise<void>;
25
26
  unmount(): void;
26
27
  "__#private@#isMounted": boolean;
27
28
  "__#private@#isMounting": boolean;
@@ -1,56 +1,59 @@
1
+ //#region src/solid/class.ts
2
+ /**
3
+ * Constructs the core class for the Devtools.
4
+ * This utility is used to construct a lazy loaded Solid component for the Devtools.
5
+ * It returns a tuple containing the main DevtoolsCore class and a NoOpDevtoolsCore class.
6
+ * The NoOpDevtoolsCore class is a no-op implementation that can be used for production if you want to explicitly exclude
7
+ * the Devtools from your application.
8
+ * @param importFn A function that returns a dynamic import of the Solid component
9
+ * @returns Tuple containing the DevtoolsCore class and a NoOpDevtoolsCore class
10
+ */
1
11
  function constructCoreClass(importFn) {
2
- class DevtoolsCore {
3
- #isMounted = false;
4
- #isMounting = false;
5
- #abortMount = false;
6
- #dispose;
7
- constructor() {
8
- }
9
- async mount(el, theme) {
10
- if (this.#isMounted || this.#isMounting) {
11
- throw new Error("Devtools is already mounted");
12
- }
13
- this.#isMounting = true;
14
- this.#abortMount = false;
15
- try {
16
- const { __mountComponent } = await import("./class-mount-impl.js");
17
- if (this.#abortMount) {
18
- this.#isMounting = false;
19
- return;
20
- }
21
- this.#dispose = __mountComponent(el, theme, importFn);
22
- this.#isMounted = true;
23
- this.#isMounting = false;
24
- } catch (err) {
25
- this.#isMounting = false;
26
- console.error("[TanStack Devtools] Failed to load:", err);
27
- }
28
- }
29
- unmount() {
30
- if (!this.#isMounted && !this.#isMounting) {
31
- throw new Error("Devtools is not mounted");
32
- }
33
- if (this.#isMounting) {
34
- this.#abortMount = true;
35
- this.#isMounting = false;
36
- return;
37
- }
38
- this.#dispose?.();
39
- this.#isMounted = false;
40
- }
41
- }
42
- class NoOpDevtoolsCore extends DevtoolsCore {
43
- constructor() {
44
- super();
45
- }
46
- async mount(_el, _theme) {
47
- }
48
- unmount() {
49
- }
50
- }
51
- return [DevtoolsCore, NoOpDevtoolsCore];
12
+ class DevtoolsCore {
13
+ #isMounted = false;
14
+ #isMounting = false;
15
+ #abortMount = false;
16
+ #dispose;
17
+ constructor() {}
18
+ async mount(el, props) {
19
+ if (this.#isMounted || this.#isMounting) throw new Error("Devtools is already mounted");
20
+ this.#isMounting = true;
21
+ this.#abortMount = false;
22
+ try {
23
+ const { __mountComponent } = await import("./class-mount-impl.js");
24
+ if (this.#abortMount) {
25
+ this.#isMounting = false;
26
+ return;
27
+ }
28
+ this.#dispose = __mountComponent(el, props, importFn);
29
+ this.#isMounted = true;
30
+ this.#isMounting = false;
31
+ } catch (err) {
32
+ this.#isMounting = false;
33
+ console.error("[TanStack Devtools] Failed to load:", err);
34
+ }
35
+ }
36
+ unmount() {
37
+ if (!this.#isMounted && !this.#isMounting) throw new Error("Devtools is not mounted");
38
+ if (this.#isMounting) {
39
+ this.#abortMount = true;
40
+ this.#isMounting = false;
41
+ return;
42
+ }
43
+ this.#dispose?.();
44
+ this.#isMounted = false;
45
+ }
46
+ }
47
+ class NoOpDevtoolsCore extends DevtoolsCore {
48
+ constructor() {
49
+ super();
50
+ }
51
+ async mount(_el, _props) {}
52
+ unmount() {}
53
+ }
54
+ return [DevtoolsCore, NoOpDevtoolsCore];
52
55
  }
53
- export {
54
- constructCoreClass
55
- };
56
- //# sourceMappingURL=class.js.map
56
+ //#endregion
57
+ export { constructCoreClass };
58
+
59
+ //# sourceMappingURL=class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"class.js","sources":["../../../src/solid/class.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\n\n/**\n * Constructs the core class for the Devtools.\n * This utility is used to construct a lazy loaded Solid component for the Devtools.\n * It returns a tuple containing the main DevtoolsCore class and a NoOpDevtoolsCore class.\n * The NoOpDevtoolsCore class is a no-op implementation that can be used for production if you want to explicitly exclude\n * the Devtools from your application.\n * @param importFn A function that returns a dynamic import of the Solid component\n * @returns Tuple containing the DevtoolsCore class and a NoOpDevtoolsCore class\n */\nexport function constructCoreClass(\n importFn: () => Promise<{ default: () => JSX.Element }>,\n) {\n class DevtoolsCore {\n #isMounted = false\n #isMounting = false\n #abortMount = false\n #dispose?: () => void\n\n constructor() {}\n\n async mount<T extends HTMLElement>(el: T, theme: 'light' | 'dark') {\n if (this.#isMounted || this.#isMounting) {\n throw new Error('Devtools is already mounted')\n }\n this.#isMounting = true\n this.#abortMount = false\n\n try {\n const { __mountComponent } = await import('./class-mount-impl')\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- can be set by unmount() during await\n if (this.#abortMount) {\n this.#isMounting = false\n return\n }\n\n this.#dispose = __mountComponent(el, theme, importFn)\n this.#isMounted = true\n this.#isMounting = false\n } catch (err) {\n this.#isMounting = false\n console.error('[TanStack Devtools] Failed to load:', err)\n }\n }\n\n unmount() {\n if (!this.#isMounted && !this.#isMounting) {\n throw new Error('Devtools is not mounted')\n }\n if (this.#isMounting) {\n this.#abortMount = true\n this.#isMounting = false\n return\n }\n this.#dispose?.()\n this.#isMounted = false\n }\n }\n\n class NoOpDevtoolsCore extends DevtoolsCore {\n constructor() {\n super()\n }\n async mount<T extends HTMLElement>(_el: T, _theme: 'light' | 'dark') {}\n unmount() {}\n }\n\n return [DevtoolsCore, NoOpDevtoolsCore] as const\n}\n\nexport type ClassType = ReturnType<typeof constructCoreClass>[0]\n"],"names":[],"mappings":"AAWO,SAAS,mBACd,UACA;AAAA,EACA,MAAM,aAAa;AAAA,IACjB,aAAa;AAAA,IACb,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IAEA,cAAc;AAAA,IAAC;AAAA,IAEf,MAAM,MAA6B,IAAO,OAAyB;AACjE,UAAI,KAAK,cAAc,KAAK,aAAa;AACvC,cAAM,IAAI,MAAM,6BAA6B;AAAA,MAC/C;AACA,WAAK,cAAc;AACnB,WAAK,cAAc;AAEnB,UAAI;AACF,cAAM,EAAE,iBAAA,IAAqB,MAAM,OAAO,uBAAoB;AAE9D,YAAI,KAAK,aAAa;AACpB,eAAK,cAAc;AACnB;AAAA,QACF;AAEA,aAAK,WAAW,iBAAiB,IAAI,OAAO,QAAQ;AACpD,aAAK,aAAa;AAClB,aAAK,cAAc;AAAA,MACrB,SAAS,KAAK;AACZ,aAAK,cAAc;AACnB,gBAAQ,MAAM,uCAAuC,GAAG;AAAA,MAC1D;AAAA,IACF;AAAA,IAEA,UAAU;AACR,UAAI,CAAC,KAAK,cAAc,CAAC,KAAK,aAAa;AACzC,cAAM,IAAI,MAAM,yBAAyB;AAAA,MAC3C;AACA,UAAI,KAAK,aAAa;AACpB,aAAK,cAAc;AACnB,aAAK,cAAc;AACnB;AAAA,MACF;AACA,WAAK,WAAA;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EAAA;AAAA,EAGF,MAAM,yBAAyB,aAAa;AAAA,IAC1C,cAAc;AACZ,YAAA;AAAA,IACF;AAAA,IACA,MAAM,MAA6B,KAAQ,QAA0B;AAAA,IAAC;AAAA,IACtE,UAAU;AAAA,IAAC;AAAA,EAAA;AAGb,SAAO,CAAC,cAAc,gBAAgB;AACxC;"}
1
+ {"version":3,"file":"class.js","names":["#isMounted","#isMounting","#abortMount","#dispose"],"sources":["../../../src/solid/class.ts"],"sourcesContent":["import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'\nimport type { JSX } from 'solid-js'\n\n/**\n * Constructs the core class for the Devtools.\n * This utility is used to construct a lazy loaded Solid component for the Devtools.\n * It returns a tuple containing the main DevtoolsCore class and a NoOpDevtoolsCore class.\n * The NoOpDevtoolsCore class is a no-op implementation that can be used for production if you want to explicitly exclude\n * the Devtools from your application.\n * @param importFn A function that returns a dynamic import of the Solid component\n * @returns Tuple containing the DevtoolsCore class and a NoOpDevtoolsCore class\n */\nexport function constructCoreClass(\n importFn: () => Promise<{\n default: (props: TanStackDevtoolsPluginProps) => JSX.Element\n }>,\n) {\n class DevtoolsCore {\n #isMounted = false\n #isMounting = false\n #abortMount = false\n #dispose?: () => void\n\n constructor() {}\n\n async mount<T extends HTMLElement>(\n el: T,\n props: TanStackDevtoolsPluginProps,\n ) {\n if (this.#isMounted || this.#isMounting) {\n throw new Error('Devtools is already mounted')\n }\n this.#isMounting = true\n this.#abortMount = false\n\n try {\n const { __mountComponent } = await import('./class-mount-impl')\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- can be set by unmount() during await\n if (this.#abortMount) {\n this.#isMounting = false\n return\n }\n\n this.#dispose = __mountComponent(el, props, importFn)\n this.#isMounted = true\n this.#isMounting = false\n } catch (err) {\n this.#isMounting = false\n console.error('[TanStack Devtools] Failed to load:', err)\n }\n }\n\n unmount() {\n if (!this.#isMounted && !this.#isMounting) {\n throw new Error('Devtools is not mounted')\n }\n\n if (this.#isMounting) {\n this.#abortMount = true\n this.#isMounting = false\n return\n }\n\n this.#dispose?.()\n this.#isMounted = false\n }\n }\n\n class NoOpDevtoolsCore extends DevtoolsCore {\n constructor() {\n super()\n }\n async mount<T extends HTMLElement>(\n _el: T,\n _props: TanStackDevtoolsPluginProps,\n ) {}\n unmount() {}\n }\n\n return [DevtoolsCore, NoOpDevtoolsCore] as const\n}\n\nexport type ClassType = ReturnType<typeof constructCoreClass>[0]\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,mBACd,UAGA;CACA,MAAM,aAAa;EACjB,aAAa;EACb,cAAc;EACd,cAAc;EACd;EAEA,cAAc;EAEd,MAAM,MACJ,IACA,OACA;AACA,OAAI,MAAA,aAAmB,MAAA,WACrB,OAAM,IAAI,MAAM,8BAA8B;AAEhD,SAAA,aAAmB;AACnB,SAAA,aAAmB;AAEnB,OAAI;IACF,MAAM,EAAE,qBAAqB,MAAM,OAAO;AAE1C,QAAI,MAAA,YAAkB;AACpB,WAAA,aAAmB;AACnB;;AAGF,UAAA,UAAgB,iBAAiB,IAAI,OAAO,SAAS;AACrD,UAAA,YAAkB;AAClB,UAAA,aAAmB;YACZ,KAAK;AACZ,UAAA,aAAmB;AACnB,YAAQ,MAAM,uCAAuC,IAAI;;;EAI7D,UAAU;AACR,OAAI,CAAC,MAAA,aAAmB,CAAC,MAAA,WACvB,OAAM,IAAI,MAAM,0BAA0B;AAG5C,OAAI,MAAA,YAAkB;AACpB,UAAA,aAAmB;AACnB,UAAA,aAAmB;AACnB;;AAGF,SAAA,WAAiB;AACjB,SAAA,YAAkB;;;CAItB,MAAM,yBAAyB,aAAa;EAC1C,cAAc;AACZ,UAAO;;EAET,MAAM,MACJ,KACA,QACA;EACF,UAAU;;AAGZ,QAAO,CAAC,cAAc,iBAAiB"}
@@ -1,5 +1,5 @@
1
1
  import { ClassType } from './class.js';
2
- export interface DevtoolsPanelProps {
3
- theme?: 'light' | 'dark';
2
+ import { TanStackDevtoolsPluginProps } from '@tanstack/devtools';
3
+ export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {
4
4
  }
5
- export declare function createSolidPanel<TComponentProps extends DevtoolsPanelProps | undefined>(CoreClass: ClassType): readonly [(props: TComponentProps) => import("solid-js").JSX.Element, (_props: TComponentProps) => import("solid-js").JSX.Element];
5
+ export declare function createSolidPanel<TComponentProps extends DevtoolsPanelProps>(CoreClass: ClassType): readonly [(props: TComponentProps) => import("solid-js").JSX.Element, (_props: TComponentProps) => import("solid-js").JSX.Element];
@@ -1,17 +1,18 @@
1
1
  import { JSX } from 'solid-js';
2
2
  import { DevtoolsPanelProps } from './panel.js';
3
+ import { TanStackDevtoolsPluginProps } from '@tanstack/devtools';
3
4
  export declare function createSolidPlugin({ Component, ...config }: {
4
5
  name: string;
5
6
  id?: string;
6
7
  defaultOpen?: boolean;
7
8
  Component: (props: DevtoolsPanelProps) => JSX.Element;
8
9
  }): readonly [() => {
9
- render: (_el: HTMLElement, theme: "light" | "dark") => JSX.Element;
10
+ render: (_el: HTMLElement, props: TanStackDevtoolsPluginProps) => JSX.Element;
10
11
  name: string;
11
12
  id?: string;
12
13
  defaultOpen?: boolean;
13
14
  }, () => {
14
- render: (_el: HTMLElement, _theme: "light" | "dark") => JSX.Element;
15
+ render: (_el: HTMLElement, _props: TanStackDevtoolsPluginProps) => JSX.Element;
15
16
  name: string;
16
17
  id?: string;
17
18
  defaultOpen?: boolean;
@@ -1,7 +1,3 @@
1
1
  import { createVuePanel } from "./panel.js";
2
2
  import { createVuePlugin } from "./plugin.js";
3
- export {
4
- createVuePanel,
5
- createVuePlugin
6
- };
7
- //# sourceMappingURL=index.js.map
3
+ export { createVuePanel, createVuePlugin };
@@ -1,9 +1,9 @@
1
+ import { TanStackDevtoolsPluginProps } from '@tanstack/devtools';
1
2
  import { DefineComponent } from 'vue';
2
- export interface DevtoolsPanelProps {
3
- theme?: 'dark' | 'light' | 'system';
3
+ export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {
4
4
  }
5
5
  export declare function createVuePanel<TComponentProps extends DevtoolsPanelProps, TCoreDevtoolsClass extends {
6
- mount: (el: HTMLElement, theme?: DevtoolsPanelProps['theme']) => void;
6
+ mount: (el: HTMLElement, props?: TanStackDevtoolsPluginProps) => void;
7
7
  unmount: () => void;
8
8
  }>(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass): [DefineComponent<{
9
9
  theme?: DevtoolsPanelProps["theme"];
@@ -1,47 +1,38 @@
1
- import { defineComponent, ref, onMounted, onUnmounted, h } from "vue";
1
+ import { defineComponent, h, onMounted, onUnmounted, ref } from "vue";
2
+ //#region src/vue/panel.ts
2
3
  function createVuePanel(CoreClass) {
3
- const props = {
4
- theme: {
5
- type: String
6
- },
7
- devtoolsProps: {
8
- type: Object
9
- }
10
- };
11
- const Panel = defineComponent({
12
- props,
13
- setup(config) {
14
- const devToolRef = ref(null);
15
- const devtools = ref(null);
16
- onMounted(() => {
17
- const instance = new CoreClass(config.devtoolsProps);
18
- devtools.value = instance;
19
- if (devToolRef.value) {
20
- instance.mount(devToolRef.value, config.theme);
21
- }
22
- });
23
- onUnmounted(() => {
24
- if (devToolRef.value && devtools.value) {
25
- devtools.value.unmount();
26
- }
27
- });
28
- return () => {
29
- return h("div", {
30
- style: { height: "100%" },
31
- ref: devToolRef
32
- });
33
- };
34
- }
35
- });
36
- const NoOpPanel = defineComponent({
37
- props,
38
- setup() {
39
- return () => null;
40
- }
41
- });
42
- return [Panel, NoOpPanel];
4
+ const props = {
5
+ props: { type: Object },
6
+ devtoolsProps: { type: Object }
7
+ };
8
+ return [defineComponent({
9
+ props,
10
+ setup(config) {
11
+ const devToolRef = ref(null);
12
+ const devtools = ref(null);
13
+ onMounted(() => {
14
+ const instance = new CoreClass(config.devtoolsProps);
15
+ devtools.value = instance;
16
+ if (devToolRef.value) instance.mount(devToolRef.value, config.props);
17
+ });
18
+ onUnmounted(() => {
19
+ if (devToolRef.value && devtools.value) devtools.value.unmount();
20
+ });
21
+ return () => {
22
+ return h("div", {
23
+ style: { height: "100%" },
24
+ ref: devToolRef
25
+ });
26
+ };
27
+ }
28
+ }), defineComponent({
29
+ props,
30
+ setup() {
31
+ return () => null;
32
+ }
33
+ })];
43
34
  }
44
- export {
45
- createVuePanel
46
- };
47
- //# sourceMappingURL=panel.js.map
35
+ //#endregion
36
+ export { createVuePanel };
37
+
38
+ //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"panel.js","sources":["../../../src/vue/panel.ts"],"sourcesContent":["import { defineComponent, h, onMounted, onUnmounted, ref } from 'vue'\nimport type { DefineComponent } from 'vue'\n\nexport interface DevtoolsPanelProps {\n theme?: 'dark' | 'light' | 'system'\n}\n\nexport function createVuePanel<\n TComponentProps extends DevtoolsPanelProps,\n TCoreDevtoolsClass extends {\n mount: (el: HTMLElement, theme?: DevtoolsPanelProps['theme']) => void\n unmount: () => void\n },\n>(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass) {\n const props = {\n theme: {\n type: String as () => DevtoolsPanelProps['theme'],\n },\n devtoolsProps: {\n type: Object as () => TComponentProps,\n },\n }\n\n const Panel = defineComponent({\n props,\n setup(config) {\n const devToolRef = ref<HTMLElement | null>(null)\n const devtools = ref<TCoreDevtoolsClass | null>(null)\n\n onMounted(() => {\n const instance = new CoreClass(config.devtoolsProps as TComponentProps)\n devtools.value = instance\n\n if (devToolRef.value) {\n instance.mount(devToolRef.value, config.theme)\n }\n })\n\n onUnmounted(() => {\n if (devToolRef.value && devtools.value) {\n devtools.value.unmount()\n }\n })\n\n return () => {\n return h('div', {\n style: { height: '100%' },\n ref: devToolRef,\n })\n }\n },\n })\n\n const NoOpPanel = defineComponent({\n props,\n setup() {\n return () => null\n },\n })\n\n return [Panel, NoOpPanel] as unknown as [\n DefineComponent<{\n theme?: DevtoolsPanelProps['theme']\n devtoolsProps: TComponentProps\n }>,\n DefineComponent<{\n theme?: DevtoolsPanelProps['theme']\n devtoolsProps: TComponentProps\n }>,\n ]\n}\n"],"names":[],"mappings":";AAOO,SAAS,eAMd,WAA+D;AAC/D,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,MAAM;AAAA,IAAA;AAAA,IAER,eAAe;AAAA,MACb,MAAM;AAAA,IAAA;AAAA,EACR;AAGF,QAAM,QAAQ,gBAAgB;AAAA,IAC5B;AAAA,IACA,MAAM,QAAQ;AACZ,YAAM,aAAa,IAAwB,IAAI;AAC/C,YAAM,WAAW,IAA+B,IAAI;AAEpD,gBAAU,MAAM;AACd,cAAM,WAAW,IAAI,UAAU,OAAO,aAAgC;AACtE,iBAAS,QAAQ;AAEjB,YAAI,WAAW,OAAO;AACpB,mBAAS,MAAM,WAAW,OAAO,OAAO,KAAK;AAAA,QAC/C;AAAA,MACF,CAAC;AAED,kBAAY,MAAM;AAChB,YAAI,WAAW,SAAS,SAAS,OAAO;AACtC,mBAAS,MAAM,QAAA;AAAA,QACjB;AAAA,MACF,CAAC;AAED,aAAO,MAAM;AACX,eAAO,EAAE,OAAO;AAAA,UACd,OAAO,EAAE,QAAQ,OAAA;AAAA,UACjB,KAAK;AAAA,QAAA,CACN;AAAA,MACH;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,YAAY,gBAAgB;AAAA,IAChC;AAAA,IACA,QAAQ;AACN,aAAO,MAAM;AAAA,IACf;AAAA,EAAA,CACD;AAED,SAAO,CAAC,OAAO,SAAS;AAU1B;"}
1
+ {"version":3,"file":"panel.js","names":[],"sources":["../../../src/vue/panel.ts"],"sourcesContent":["import { defineComponent, h, onMounted, onUnmounted, ref } from 'vue'\nimport type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'\nimport type { DefineComponent } from 'vue'\n\nexport interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {}\n\nexport function createVuePanel<\n TComponentProps extends DevtoolsPanelProps,\n TCoreDevtoolsClass extends {\n mount: (el: HTMLElement, props?: TanStackDevtoolsPluginProps) => void\n unmount: () => void\n },\n>(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass) {\n const props = {\n props: {\n type: Object as () => DevtoolsPanelProps,\n },\n devtoolsProps: {\n type: Object as () => TComponentProps,\n },\n }\n\n const Panel = defineComponent({\n props,\n setup(config) {\n const devToolRef = ref<HTMLElement | null>(null)\n const devtools = ref<TCoreDevtoolsClass | null>(null)\n\n onMounted(() => {\n const instance = new CoreClass(config.devtoolsProps as TComponentProps)\n devtools.value = instance\n\n if (devToolRef.value) {\n instance.mount(devToolRef.value, config.props)\n }\n })\n\n onUnmounted(() => {\n if (devToolRef.value && devtools.value) {\n devtools.value.unmount()\n }\n })\n\n return () => {\n return h('div', {\n style: { height: '100%' },\n ref: devToolRef,\n })\n }\n },\n })\n\n const NoOpPanel = defineComponent({\n props,\n setup() {\n return () => null\n },\n })\n\n return [Panel, NoOpPanel] as unknown as [\n DefineComponent<{\n theme?: DevtoolsPanelProps['theme']\n devtoolsProps: TComponentProps\n }>,\n DefineComponent<{\n theme?: DevtoolsPanelProps['theme']\n devtoolsProps: TComponentProps\n }>,\n ]\n}\n"],"mappings":";;AAMA,SAAgB,eAMd,WAA+D;CAC/D,MAAM,QAAQ;EACZ,OAAO,EACL,MAAM,QACP;EACD,eAAe,EACb,MAAM,QACP;EACF;AAuCD,QAAO,CArCO,gBAAgB;EAC5B;EACA,MAAM,QAAQ;GACZ,MAAM,aAAa,IAAwB,KAAK;GAChD,MAAM,WAAW,IAA+B,KAAK;AAErD,mBAAgB;IACd,MAAM,WAAW,IAAI,UAAU,OAAO,cAAiC;AACvE,aAAS,QAAQ;AAEjB,QAAI,WAAW,MACb,UAAS,MAAM,WAAW,OAAO,OAAO,MAAM;KAEhD;AAEF,qBAAkB;AAChB,QAAI,WAAW,SAAS,SAAS,MAC/B,UAAS,MAAM,SAAS;KAE1B;AAEF,gBAAa;AACX,WAAO,EAAE,OAAO;KACd,OAAO,EAAE,QAAQ,QAAQ;KACzB,KAAK;KACN,CAAC;;;EAGP,CAAC,EAEgB,gBAAgB;EAChC;EACA,QAAQ;AACN,gBAAa;;EAEhB,CAAC,CAEuB"}
@@ -1,22 +1,23 @@
1
1
  import { Fragment } from "vue";
2
+ //#region src/vue/plugin.ts
2
3
  function createVuePlugin(name, component) {
3
- function Plugin(props) {
4
- return {
5
- name,
6
- component,
7
- props
8
- };
9
- }
10
- function NoOpPlugin(props) {
11
- return {
12
- name,
13
- component: Fragment,
14
- props
15
- };
16
- }
17
- return [Plugin, NoOpPlugin];
4
+ function Plugin(props) {
5
+ return {
6
+ name,
7
+ component,
8
+ props
9
+ };
10
+ }
11
+ function NoOpPlugin(props) {
12
+ return {
13
+ name,
14
+ component: Fragment,
15
+ props
16
+ };
17
+ }
18
+ return [Plugin, NoOpPlugin];
18
19
  }
19
- export {
20
- createVuePlugin
21
- };
22
- //# sourceMappingURL=plugin.js.map
20
+ //#endregion
21
+ export { createVuePlugin };
22
+
23
+ //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../../../src/vue/plugin.ts"],"sourcesContent":["import { Fragment } from 'vue'\nimport type { DefineComponent } from 'vue'\n\nexport function createVuePlugin<TComponentProps extends Record<string, any>>(\n name: string,\n component: DefineComponent<TComponentProps, {}, unknown>,\n) {\n function Plugin(props: TComponentProps) {\n return {\n name,\n component,\n props,\n }\n }\n function NoOpPlugin(props: TComponentProps) {\n return {\n name,\n component: Fragment,\n props,\n }\n }\n return [Plugin, NoOpPlugin] as const\n}\n"],"names":[],"mappings":";AAGO,SAAS,gBACd,MACA,WACA;AACA,WAAS,OAAO,OAAwB;AACtC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,WAAS,WAAW,OAAwB;AAC1C,WAAO;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MACX;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO,CAAC,QAAQ,UAAU;AAC5B;"}
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../../../src/vue/plugin.ts"],"sourcesContent":["import { Fragment } from 'vue'\nimport type { DefineComponent } from 'vue'\n\nexport function createVuePlugin<TComponentProps extends Record<string, any>>(\n name: string,\n component: DefineComponent<TComponentProps, {}, unknown>,\n) {\n function Plugin(props: TComponentProps) {\n return {\n name,\n component,\n props,\n }\n }\n function NoOpPlugin(props: TComponentProps) {\n return {\n name,\n component: Fragment,\n props,\n }\n }\n return [Plugin, NoOpPlugin] as const\n}\n"],"mappings":";;AAGA,SAAgB,gBACd,MACA,WACA;CACA,SAAS,OAAO,OAAwB;AACtC,SAAO;GACL;GACA;GACA;GACD;;CAEH,SAAS,WAAW,OAAwB;AAC1C,SAAO;GACL;GACA,WAAW;GACX;GACD;;AAEH,QAAO,CAAC,QAAQ,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/devtools-utils",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "TanStack Devtools utilities for creating your own devtools.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -72,8 +72,11 @@
72
72
  "engines": {
73
73
  "node": ">=18"
74
74
  },
75
- "dependencies": {
76
- "@tanstack/devtools-ui": "^0.5.0"
75
+ "devDependencies": {
76
+ "tsup": "^8.5.0",
77
+ "tsup-preset-solid": "^2.2.0",
78
+ "vite-plugin-solid": "^2.11.11",
79
+ "@tanstack/devtools": "^0.11.0"
77
80
  },
78
81
  "peerDependencies": {
79
82
  "@types/react": ">=17.0.0",
@@ -105,11 +108,6 @@
105
108
  "skills",
106
109
  "bin"
107
110
  ],
108
- "devDependencies": {
109
- "tsup": "^8.5.0",
110
- "tsup-preset-solid": "^2.2.0",
111
- "vite-plugin-solid": "^2.11.8"
112
- },
113
111
  "scripts": {
114
112
  "clean": "premove ./build ./dist",
115
113
  "lint:fix": "eslint ./src --fix",
@@ -1,10 +1,9 @@
1
1
  /** @jsxImportSource preact */
2
2
 
3
3
  import { useEffect, useRef } from 'preact/hooks'
4
+ import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
4
5
 
5
- export interface DevtoolsPanelProps {
6
- theme?: 'light' | 'dark'
7
- }
6
+ export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {}
8
7
 
9
8
  /**
10
9
  * Creates a Preact component that dynamically imports and mounts a devtools panel. SSR friendly.
@@ -24,9 +23,9 @@ export interface DevtoolsPanelProps {
24
23
  * ```
25
24
  */
26
25
  export function createPreactPanel<
27
- TComponentProps extends DevtoolsPanelProps | undefined,
26
+ TComponentProps extends DevtoolsPanelProps,
28
27
  TCoreDevtoolsClass extends {
29
- mount: (el: HTMLElement, theme: 'light' | 'dark') => void
28
+ mount: (el: HTMLElement, props: TanStackDevtoolsPluginProps) => void
30
29
  unmount: () => void
31
30
  },
32
31
  >(CoreClass: new () => TCoreDevtoolsClass) {
@@ -38,7 +37,7 @@ export function createPreactPanel<
38
37
  devtools.current = new CoreClass()
39
38
 
40
39
  if (devToolRef.current) {
41
- devtools.current.mount(devToolRef.current, props?.theme ?? 'dark')
40
+ devtools.current.mount(devToolRef.current, props)
42
41
  }
43
42
 
44
43
  return () => {
@@ -47,7 +46,7 @@ export function createPreactPanel<
47
46
  devtools.current = null
48
47
  }
49
48
  }
50
- }, [props?.theme])
49
+ }, [props])
51
50
 
52
51
  return <div style={{ height: '100%' }} ref={devToolRef} />
53
52
  }