Skip to content

Commit f7ea109

Browse files
committed
Merge branch 'feat/add_shell' of https://github.com/TanStack/devtools into feat/add_shell
2 parents 143edb9 + 17bcb27 commit f7ea109

File tree

3 files changed

+65
-66
lines changed

3 files changed

+65
-66
lines changed

packages/devtools/src/components/trigger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import clsx from 'clsx'
33
import { useDevtoolsSettings } from '../context/use-devtools-context'
44
import { useStyles } from '../styles/use-styles'
55
import { TanStackLogo } from './logo'
6-
import type { Accessor} from 'solid-js';
6+
import type { Accessor } from 'solid-js'
77

88
export const Trigger = ({
99
isOpen,

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

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,92 @@ import { createContext } from 'solid-js'
22
import { createStore } from 'solid-js/store'
33
import { tryParseJson } from '../utils/sanitize'
44
import {
5-
TANSTACK_DEVTOOLS_SETTINGS,
6-
TANSTACK_DEVTOOLS_STATE,
7-
getStorageItem,
8-
setStorageItem,
5+
TANSTACK_DEVTOOLS_SETTINGS,
6+
TANSTACK_DEVTOOLS_STATE,
7+
getStorageItem,
8+
setStorageItem,
99
} from '../utils/storage'
1010
import { initialState } from './devtools-store'
11-
import type { DevtoolsStore } from './devtools-store';
11+
import type { DevtoolsStore } from './devtools-store'
1212
import type { Setter } from 'solid-js'
1313
import type { JSX } from 'solid-js/jsx-runtime'
1414

1515
export interface DevtoolsPlugin {
16-
name: string | ((el: HTMLDivElement) => void)
17-
id: string
18-
component: (el: HTMLDivElement) => void
16+
name: string | ((el: HTMLDivElement) => void)
17+
id: string
18+
component: (el: HTMLDivElement) => void
1919
}
2020

2121
export const DevtoolsContext = createContext<{
22-
store: DevtoolsStore
23-
setStore: Setter<DevtoolsStore>
22+
store: DevtoolsStore
23+
setStore: Setter<DevtoolsStore>
2424
}>()
2525

2626
interface ContextProps {
27-
children: JSX.Element
28-
plugins?: Array<DevtoolsPlugin>
29-
config?: DevtoolsSettings
27+
children: JSX.Element
28+
plugins?: Array<DevtoolsPlugin>
29+
config?: DevtoolsSettings
3030
}
3131

3232
const getSettings = () => {
33-
const settingsString = getStorageItem(TANSTACK_DEVTOOLS_SETTINGS)
34-
const settings = tryParseJson<DevtoolsStore['settings']>(settingsString)
35-
return {
36-
...settings,
37-
}
33+
const settingsString = getStorageItem(TANSTACK_DEVTOOLS_SETTINGS)
34+
const settings = tryParseJson<DevtoolsStore['settings']>(settingsString)
35+
return {
36+
...settings,
37+
}
3838
}
3939

4040
const getExistingStateFromStorage = (
41-
config?: DevtoolsSettings,
42-
plugins?: Array<DevtoolsPlugin>,
41+
config?: DevtoolsSettings,
42+
plugins?: Array<DevtoolsPlugin>,
4343
) => {
44-
const existingState = getStorageItem(TANSTACK_DEVTOOLS_STATE)
45-
const settings = getSettings()
44+
const existingState = getStorageItem(TANSTACK_DEVTOOLS_STATE)
45+
const settings = getSettings()
4646

47-
const state: DevtoolsStore = {
48-
...initialState,
49-
plugins: plugins || [],
50-
state: {
51-
...initialState.state,
52-
...(existingState ? JSON.parse(existingState) : {}),
53-
},
54-
settings: {
55-
...initialState.settings,
56-
...config,
57-
...settings,
58-
},
59-
}
60-
return state
47+
const state: DevtoolsStore = {
48+
...initialState,
49+
plugins: plugins || [],
50+
state: {
51+
...initialState.state,
52+
...(existingState ? JSON.parse(existingState) : {}),
53+
},
54+
settings: {
55+
...initialState.settings,
56+
...config,
57+
...settings,
58+
},
59+
}
60+
return state
6161
}
6262

6363
export type DevtoolsSettings = DevtoolsStore['settings']
6464

6565
export const DevtoolsProvider = (props: ContextProps) => {
66-
const [store, setStore] = createStore(
67-
getExistingStateFromStorage(props.config, props.plugins),
68-
)
66+
const [store, setStore] = createStore(
67+
getExistingStateFromStorage(props.config, props.plugins),
68+
)
6969

70-
const value = {
71-
store,
72-
setStore: (
73-
updater: (prev: DevtoolsStore) => DevtoolsStore | Partial<DevtoolsStore>,
74-
) => {
75-
const newState = updater(store)
76-
const { settings, state: internalState } = newState
77-
// Store user settings for dev tools into local storage
78-
setStorageItem(TANSTACK_DEVTOOLS_SETTINGS, JSON.stringify(settings))
79-
// Store general state into local storage
80-
setStorageItem(TANSTACK_DEVTOOLS_STATE, JSON.stringify(internalState))
81-
setStore((prev) => ({
82-
...prev,
83-
...newState,
84-
}))
85-
},
86-
}
70+
const value = {
71+
store,
72+
setStore: (
73+
updater: (prev: DevtoolsStore) => DevtoolsStore | Partial<DevtoolsStore>,
74+
) => {
75+
const newState = updater(store)
76+
const { settings, state: internalState } = newState
77+
// Store user settings for dev tools into local storage
78+
setStorageItem(TANSTACK_DEVTOOLS_SETTINGS, JSON.stringify(settings))
79+
// Store general state into local storage
80+
setStorageItem(TANSTACK_DEVTOOLS_STATE, JSON.stringify(internalState))
81+
setStore((prev) => ({
82+
...prev,
83+
...newState,
84+
}))
85+
},
86+
}
8787

88-
return (
89-
<DevtoolsContext.Provider value={value}>
90-
{props.children}
91-
</DevtoolsContext.Provider>
92-
)
88+
return (
89+
<DevtoolsContext.Provider value={value}>
90+
{props.children}
91+
</DevtoolsContext.Provider>
92+
)
9393
}

packages/devtools/src/core.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { lazy } from 'solid-js'
22
import { Portal, render } from 'solid-js/web'
3-
import {
4-
DevtoolsProvider,
5-
} from './context/devtools-context'
3+
import { DevtoolsProvider } from './context/devtools-context'
64
import { initialState } from './context/devtools-store'
75
import type {
86
DevtoolsPlugin,
9-
DevtoolsSettings} from './context/devtools-context';
7+
DevtoolsSettings,
8+
} from './context/devtools-context'
109

1110
export interface DevtoolsOptions {
1211
options?: Partial<DevtoolsSettings>

0 commit comments

Comments
 (0)