Skip to content

Commit d579c1b

Browse files
committed
chore: cleanup package exports and add basic docs
1 parent 80745ca commit d579c1b

File tree

17 files changed

+232
-73
lines changed

17 files changed

+232
-73
lines changed

.changeset/ninety-badgers-feel.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@tanstack/react-devtools': minor
3+
'@tanstack/solid-devtools': minor
4+
'@tanstack/devtools': minor
5+
---
6+
7+
Initial alpha release of @tanstack/devtools

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,42 @@ Install one of the following packages based on your framework of choice:
6565
```bash
6666
# Npm
6767
npm install @tanstack/react-devtools
68+
npm install @tanstack/solid-devtools
6869
npm install @tanstack/devtools # no framework, just vanilla js
6970
```
7071

72+
## Usage
73+
74+
### React
75+
76+
77+
```tsx
78+
import { TanstackDevtools } from '@tanstack/react-devtools'
79+
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
80+
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
81+
82+
function App() {
83+
return (
84+
<div>
85+
<h1>My App</h1>
86+
<TanstackDevtools
87+
plugins={[
88+
{
89+
name: 'Tanstack Query',
90+
render: <ReactQueryDevtoolsPanel />,
91+
},
92+
{
93+
name: 'Tanstack Router',
94+
render: <TanStackRouterDevtoolsPanel router={router} />,
95+
},
96+
]}
97+
/>
98+
</div>
99+
)
100+
}
101+
102+
```
103+
71104
## Development
72105

73106
To contribute to the development of TanStack Devtools, you can clone the repository and run the following commands:

examples/react/basic/src/setup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
createRootRoute,
1010
} from '@tanstack/react-router'
1111
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
12-
import { Devtools } from '@tanstack/react-devtools'
12+
import { TanstackDevtools } from '@tanstack/react-devtools'
1313

1414
const rootRoute = createRootRoute({
1515
component: () => (
@@ -60,7 +60,7 @@ export default function DevtoolsExample() {
6060
return (
6161
<>
6262
<QueryClientProvider client={queryClient}>
63-
<Devtools
63+
<TanstackDevtools
6464
plugins={[
6565
{
6666
name: 'Tanstack Query',

examples/react/start/src/components/devtools.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
22
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
33
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
4-
import { Devtools } from '@tanstack/react-devtools'
4+
import { TanstackDevtools } from '@tanstack/react-devtools'
55
import { StudioPlugin } from './prisma-plugin'
66

77
const queryClient = new QueryClient()
@@ -10,7 +10,7 @@ export default function DevtoolsExample() {
1010
return (
1111
<>
1212
<QueryClientProvider client={queryClient}>
13-
<Devtools
13+
<TanstackDevtools
1414
plugins={[
1515
{
1616
name: 'Tanstack Query',

examples/solid/basic/src/setup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
createRootRoute,
99
} from '@tanstack/solid-router'
1010
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
11-
import { Devtools } from '@tanstack/solid-devtools'
11+
import { TanstackDevtools } from '@tanstack/solid-devtools'
1212
const rootRoute = createRootRoute({
1313
component: () => (
1414
<>
@@ -49,7 +49,7 @@ const queryClient = new QueryClient()
4949
export default function DevtoolsExample() {
5050
return (
5151
<>
52-
<Devtools
52+
<TanstackDevtools
5353
plugins={[
5454
{
5555
name: 'Tanstack Query',

packages/devtools/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @tanstack/devtools
2+
3+
This package is still under active development and might have breaking changes in the future. Please use it with caution.
4+
5+
## General Usage
6+
7+
```tsx
8+
import { TanStackDevtoolsCore } from '@tanstack/devtools'
9+
10+
11+
const devtools = new TanStackDevtoolsCore({
12+
options: {
13+
// your options here
14+
},
15+
plugins: [
16+
// your plugins here
17+
],
18+
})
19+
20+
devtools.mount(document.getElementById('your-devtools-container')!)
21+
22+
```
23+
24+
## Creating plugins
25+
26+
In order to create a plugin for TanStack Devtools, you can use the `plugins` arg of the `TanStackDevtoolsCore` class. Here's an example of how to create a simple plugin:
27+
28+
```ts
29+
import { TanStackDevtoolsCore } from '@tanstack/devtools'
30+
31+
const devtools = new TanStackDevtoolsCore({
32+
options: {
33+
// your options here
34+
},
35+
plugins: [
36+
{
37+
id: 'my-plugin',
38+
name: 'My Plugin',
39+
render: (el) => el.innerHTML = '<div>My Plugin Content</div>',
40+
}
41+
]
42+
})
43+
44+
```
45+

packages/devtools/src/context/devtools-context.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { DevtoolsStore } from './devtools-store'
1212
import type { Setter } from 'solid-js'
1313
import type { JSX } from 'solid-js/jsx-runtime'
1414

15-
export interface DevtoolsPlugin {
15+
export interface TanStackDevtoolsPlugin {
1616
name: string | ((el: HTMLHeadingElement) => void)
1717
id?: string
1818
render: (el: HTMLDivElement) => void
@@ -24,8 +24,8 @@ export const DevtoolsContext = createContext<{
2424

2525
interface ContextProps {
2626
children: JSX.Element
27-
plugins?: Array<DevtoolsPlugin>
28-
config?: DevtoolsSettings
27+
plugins?: Array<TanStackDevtoolsPlugin>
28+
config?: TanStackDevtoolsConfig
2929
}
3030

3131
const getSettings = () => {
@@ -36,7 +36,7 @@ const getSettings = () => {
3636
}
3737
}
3838

39-
const generatePluginId = (plugin: DevtoolsPlugin, index: number) => {
39+
const generatePluginId = (plugin: TanStackDevtoolsPlugin, index: number) => {
4040
// if set by user, return the plugin id
4141
if (plugin.id) {
4242
return plugin.id
@@ -50,8 +50,8 @@ const generatePluginId = (plugin: DevtoolsPlugin, index: number) => {
5050
}
5151

5252
const getExistingStateFromStorage = (
53-
config?: DevtoolsSettings,
54-
plugins?: Array<DevtoolsPlugin>,
53+
config?: TanStackDevtoolsConfig,
54+
plugins?: Array<TanStackDevtoolsPlugin>,
5555
) => {
5656
const existingState = getStorageItem(TANSTACK_DEVTOOLS_STATE)
5757
const settings = getSettings()
@@ -79,7 +79,7 @@ const getExistingStateFromStorage = (
7979
return state
8080
}
8181

82-
export type DevtoolsSettings = DevtoolsStore['settings']
82+
export type TanStackDevtoolsConfig = DevtoolsStore['settings']
8383

8484
export const DevtoolsProvider = (props: ContextProps) => {
8585
const [store, setStore] = createStore(

packages/devtools/src/context/devtools-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { TabName } from '../tabs'
2-
import type { DevtoolsPlugin } from './devtools-context'
2+
import type { TanStackDevtoolsPlugin } from './devtools-context'
33

44
type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift'
55
type KeyboardKey = ModifierKey | (string & {})
@@ -57,7 +57,7 @@ export type DevtoolsStore = {
5757
activePlugin?: string | undefined
5858
persistOpen: boolean
5959
}
60-
plugins?: Array<DevtoolsPlugin>
60+
plugins?: Array<TanStackDevtoolsPlugin>
6161
}
6262

6363
export const initialState: DevtoolsStore = {

packages/devtools/src/core.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ import { Portal, render } from 'solid-js/web'
33
import { DevtoolsProvider } from './context/devtools-context'
44
import { initialState } from './context/devtools-store'
55
import type {
6-
DevtoolsPlugin,
7-
DevtoolsSettings,
6+
TanStackDevtoolsConfig,
7+
TanStackDevtoolsPlugin,
88
} from './context/devtools-context'
99

10-
export interface DevtoolsOptions {
11-
options?: Partial<DevtoolsSettings>
12-
plugins?: Array<DevtoolsPlugin>
10+
export interface TanStackDevtoolsInit {
11+
config?: Partial<TanStackDevtoolsConfig>
12+
plugins?: Array<TanStackDevtoolsPlugin>
1313
}
1414

15-
class TanStackDevtoolsCore {
16-
#options: DevtoolsSettings = {
15+
export class TanStackDevtoolsCore {
16+
#config: TanStackDevtoolsConfig = {
1717
...initialState.settings,
1818
}
19-
#plugins: Array<DevtoolsPlugin> = []
19+
#plugins: Array<TanStackDevtoolsPlugin> = []
2020
#isMounted = false
2121
#dispose?: () => void
2222
#Component: any
2323

24-
constructor(config: DevtoolsOptions) {
25-
this.#plugins = config.plugins || []
26-
this.#options = {
27-
...this.#options,
28-
...config.options,
24+
constructor(init: TanStackDevtoolsInit) {
25+
this.#plugins = init.plugins || []
26+
this.#config = {
27+
...this.#config,
28+
...init.config,
2929
}
3030
}
3131

@@ -40,7 +40,7 @@ class TanStackDevtoolsCore {
4040
const Devtools = this.#Component
4141

4242
return (
43-
<DevtoolsProvider plugins={this.#plugins} config={this.#options}>
43+
<DevtoolsProvider plugins={this.#plugins} config={this.#config}>
4444
<Portal mount={mountTo}>
4545
<Devtools />
4646
</Portal>
@@ -60,12 +60,10 @@ class TanStackDevtoolsCore {
6060
this.#isMounted = false
6161
}
6262

63-
setOptions(options: Partial<DevtoolsOptions>) {
64-
this.#options = {
65-
...this.#options,
66-
...options,
63+
setConfig(config: Partial<TanStackDevtoolsInit>) {
64+
this.#config = {
65+
...this.#config,
66+
...config,
6767
}
6868
}
6969
}
70-
71-
export { TanStackDevtoolsCore as TanStackRouterDevtoolsCore }

packages/devtools/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export { TanStackRouterDevtoolsCore } from './core'
2-
export type { DevtoolsOptions } from './core'
3-
export type { DevtoolsPlugin } from './context/devtools-context'
41
export { PLUGIN_CONTAINER_ID, PLUGIN_TITLE_CONTAINER_ID } from './constants'
2+
export { TanStackDevtoolsCore } from './core'
3+
export type { TanStackDevtoolsInit } from './core'
4+
export type {
5+
TanStackDevtoolsPlugin,
6+
TanStackDevtoolsConfig,
7+
} from './context/devtools-context'

0 commit comments

Comments
 (0)