{rule.id}
diff --git a/packages/devtools-a11y/src/core/components/Shell.tsx b/packages/devtools-a11y/src/core/components/Shell.tsx
index 6778a23c0..c11039506 100644
--- a/packages/devtools-a11y/src/core/components/Shell.tsx
+++ b/packages/devtools-a11y/src/core/components/Shell.tsx
@@ -1,4 +1,4 @@
-/** @jsxImportSource solid-js */
+/** @jsxImportSource @solidjs/web */
import { Match, Show, Switch, createMemo, createSignal } from 'solid-js'
import { Button, Header, MainPanel } from '@tanstack/devtools-ui'
@@ -81,7 +81,11 @@ export function Shell() {
diff --git a/packages/devtools-a11y/src/core/components/index.tsx b/packages/devtools-a11y/src/core/components/index.tsx
index f3fda3575..5bdc300b0 100644
--- a/packages/devtools-a11y/src/core/components/index.tsx
+++ b/packages/devtools-a11y/src/core/components/index.tsx
@@ -1,4 +1,4 @@
-/** @jsxImportSource solid-js */
+/** @jsxImportSource @solidjs/web */
import { ThemeContextProvider } from '@tanstack/devtools-ui'
import { AllyProvider } from '../contexts/allyContext'
import { Shell } from './Shell'
diff --git a/packages/devtools-a11y/src/core/contexts/allyContext.tsx b/packages/devtools-a11y/src/core/contexts/allyContext.tsx
index 378601542..9c0ed7007 100644
--- a/packages/devtools-a11y/src/core/contexts/allyContext.tsx
+++ b/packages/devtools-a11y/src/core/contexts/allyContext.tsx
@@ -1,13 +1,15 @@
-/** @jsxImportSource solid-js */
+/** @jsxImportSource @solidjs/web */
import {
createContext,
createEffect,
createMemo,
createSignal,
+ createStore,
+ deep,
useContext as getContext,
+ snapshot,
} from 'solid-js'
-import { createStore } from 'solid-js/store'
import { createTheme } from '@tanstack/devtools-ui'
import { filterIssuesAboveThreshold, runAudit } from '../utils/ally-audit.utils'
import { mergeConfig, saveConfig } from '../utils/config.utils'
@@ -40,8 +42,14 @@ function createAllyValue() {
)
const triggerAllyScan = async () => {
- setAllyResult('state', 'scanning')
- setAllyResult({ audit: await runAudit(config), state: 'done' })
+ setAllyResult((result) => {
+ result.state = 'scanning'
+ })
+ const audit = await runAudit(config)
+ setAllyResult((result) => {
+ result.audit = audit
+ result.state = 'done'
+ })
}
const filteredIssues = createMemo(() => {
@@ -63,19 +71,20 @@ function createAllyValue() {
return results.filter((val) => val.impact === impactKey())
})
- createEffect(() => {
- if (config.showOverlays === false) {
- clearHighlights()
- return
- }
-
- if (allyResult.state === 'done')
- highlightAllIssues(filteredIssues(), theme())
- })
+ createEffect(
+ () =>
+ config.showOverlays === false
+ ? null
+ : allyResult.state === 'done'
+ ? { issues: filteredIssues(), theme: theme() }
+ : undefined,
+ (overlay) => {
+ if (overlay === null) clearHighlights()
+ else if (overlay) highlightAllIssues(overlay.issues, overlay.theme)
+ },
+ )
- createEffect(() => {
- saveConfig(config)
- })
+ createEffect(() => snapshot(deep(config)), saveConfig)
return {
impactKey,
@@ -99,24 +108,16 @@ type ContextType = ReturnType
// context
//
-const AllyContext = createContext(null)
+const AllyContext = createContext()
type AllyProviderProps = {}
export const AllyProvider: ParentComponent = (props) => {
const value = createAllyValue()
- return (
- {props.children}
- )
+ return {props.children}
}
export function createAllyContext() {
- const context = getContext(AllyContext)
-
- if (context === null) {
- throw new Error('createAllyContext must be used within an AllyProvider')
- }
-
- return context
+ return getContext(AllyContext)
}
diff --git a/packages/devtools-a11y/src/core/core.tsx b/packages/devtools-a11y/src/core/core.tsx
index 6f80c033c..1cb941ff1 100644
--- a/packages/devtools-a11y/src/core/core.tsx
+++ b/packages/devtools-a11y/src/core/core.tsx
@@ -1,4 +1,4 @@
-/** @jsxImportSource solid-js */
+/** @jsxImportSource @solidjs/web */
import { constructCoreClass } from '@tanstack/devtools-utils/solid'
diff --git a/packages/devtools-a11y/tests/theme.test.ts b/packages/devtools-a11y/tests/theme.test.ts
index 0f4e870bb..e92c42e79 100644
--- a/packages/devtools-a11y/tests/theme.test.ts
+++ b/packages/devtools-a11y/tests/theme.test.ts
@@ -1,7 +1,7 @@
import { readdirSync, readFileSync } from 'node:fs'
import { extname, join, relative } from 'node:path'
import { createComponent } from 'solid-js'
-import { render } from 'solid-js/web'
+import { render } from '@solidjs/web'
import { afterEach, describe, expect, it } from 'vitest'
import { ThemeContextProvider } from '@tanstack/devtools-ui'
import { resolveSemanticTheme } from '@tanstack/devtools-ui/internal'
diff --git a/packages/devtools-a11y/tsconfig.json b/packages/devtools-a11y/tsconfig.json
index bf61a1a91..d905f5813 100644
--- a/packages/devtools-a11y/tsconfig.json
+++ b/packages/devtools-a11y/tsconfig.json
@@ -2,7 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "preserve",
- "jsxImportSource": "solid-js"
+ "jsxImportSource": "@solidjs/web"
},
"include": ["src", "tests", "eslint.config.js", "vite.config.ts"]
}
diff --git a/packages/devtools-a11y/vite.config.ts b/packages/devtools-a11y/vite.config.ts
index 20e13d17b..5cd6ab91e 100644
--- a/packages/devtools-a11y/vite.config.ts
+++ b/packages/devtools-a11y/vite.config.ts
@@ -1,7 +1,7 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { fileURLToPath } from 'node:url'
import { tanstackViteConfig } from '@tanstack/vite-config'
-import solid from 'vite-plugin-solid'
+import solid from '@solidjs/vite-plugin'
import packageJson from './package.json'
import type { Plugin } from 'vite'
@@ -9,9 +9,6 @@ const config = defineConfig({
plugins: [
solid({
ssr: process.env.VITEST !== 'true',
- // Vitest 4's module runner treats `/@solid-refresh` as `file:///@solid-refresh`
- // and throws. HMR is not used in tests.
- hot: process.env.VITEST !== 'true',
}) as any satisfies Plugin,
],
test: {
diff --git a/packages/devtools-ui/package.json b/packages/devtools-ui/package.json
index 66fb1f5bc..1d6c761da 100644
--- a/packages/devtools-ui/package.json
+++ b/packages/devtools-ui/package.json
@@ -66,15 +66,13 @@
"build": "vite build"
},
"dependencies": {
+ "@solidjs/web": "^2.0.0-rc.21",
"clsx": "^2.1.1",
"dayjs": "^1.11.19",
"goober": "^2.1.16",
- "solid-js": "^1.9.13"
- },
- "peerDependencies": {
- "solid-js": "^1.9.13"
+ "solid-js": "^2.0.0-rc.21"
},
"devDependencies": {
- "vite-plugin-solid": "^2.11.11"
+ "@solidjs/vite-plugin": "^3.0.0-next.57"
}
}
diff --git a/packages/devtools-ui/src/components/button.tsx b/packages/devtools-ui/src/components/button.tsx
index 5568d71d0..02205c86b 100644
--- a/packages/devtools-ui/src/components/button.tsx
+++ b/packages/devtools-ui/src/components/button.tsx
@@ -3,7 +3,7 @@ import clsx from 'clsx'
import { createStyles } from '../styles/use-styles'
// types
-import type { JSX } from 'solid-js'
+import type { JSX } from '@solidjs/web'
export type ButtonVariant =
| 'primary'
diff --git a/packages/devtools-ui/src/components/checkbox.tsx b/packages/devtools-ui/src/components/checkbox.tsx
index 011f62c63..a709aa8c7 100644
--- a/packages/devtools-ui/src/components/checkbox.tsx
+++ b/packages/devtools-ui/src/components/checkbox.tsx
@@ -10,7 +10,7 @@ interface CheckboxProps {
export function Checkbox(props: CheckboxProps) {
const styles = createStyles()
- const [isChecked, setIsChecked] = createSignal(props.checked || false)
+ const [isChecked, setIsChecked] = createSignal(() => props.checked || false)
const descriptionId = `${createUniqueId()}-description`
const handleChange = (e: Event) => {
diff --git a/packages/devtools-ui/src/components/header.tsx b/packages/devtools-ui/src/components/header.tsx
index bdda44bfb..5c5ea0b1f 100644
--- a/packages/devtools-ui/src/components/header.tsx
+++ b/packages/devtools-ui/src/components/header.tsx
@@ -1,30 +1,24 @@
import clsx from 'clsx'
+import { omit } from 'solid-js'
import { createStyles } from '../styles/use-styles'
-import type { JSX } from 'solid-js/jsx-runtime'
+import type { JSX } from '@solidjs/web'
-export function Header({
- children,
- class: className,
- ...rest
-}: JSX.IntrinsicElements['header']) {
+export function Header(props: JSX.IntrinsicElements['header']) {
const styles = createStyles()
+ const rest = omit(props, 'children', 'class')
return (
)
}
-export function HeaderLogo({
- children,
- flavor,
- onClick,
-}: {
+export function HeaderLogo(props: {
children: JSX.Element
flavor: {
light: string
@@ -38,13 +32,15 @@ export function HeaderLogo({
diff --git a/packages/devtools-ui/src/components/input.tsx b/packages/devtools-ui/src/components/input.tsx
index f0bd362bf..e178a6f8e 100644
--- a/packages/devtools-ui/src/components/input.tsx
+++ b/packages/devtools-ui/src/components/input.tsx
@@ -12,13 +12,13 @@ interface InputProps {
export function Input(props: InputProps) {
const styles = createStyles()
- const [val, setVal] = createSignal(props.value || '')
+ const [val, setVal] = createSignal(() => props.value || '')
const id = createUniqueId()
const descriptionId = `${id}-description`
const handleChange = (e: Event) => {
const value = (e.target as HTMLInputElement).value
- setVal((prev) => (prev !== value ? value : prev))
+ setVal(value)
props.onChange?.(value)
}
diff --git a/packages/devtools-ui/src/components/main-panel.tsx b/packages/devtools-ui/src/components/main-panel.tsx
index 097d7c881..bec8b7acd 100644
--- a/packages/devtools-ui/src/components/main-panel.tsx
+++ b/packages/devtools-ui/src/components/main-panel.tsx
@@ -1,6 +1,6 @@
import clsx from 'clsx'
import { createStyles } from '../styles/use-styles'
-import type { JSX } from 'solid-js/jsx-runtime'
+import type { JSX } from '@solidjs/web'
type PanelProps = JSX.IntrinsicElements['div'] & {
children?: any
@@ -8,24 +8,19 @@ type PanelProps = JSX.IntrinsicElements['div'] & {
withPadding?: boolean
}
-export const MainPanel = ({
- className,
- children,
- class: classStyles,
- withPadding,
-}: PanelProps) => {
+export const MainPanel = (props: PanelProps) => {
const styles = createStyles()
return (
- {children}
+ {props.children}
)
}
diff --git a/packages/devtools-ui/src/components/section.tsx b/packages/devtools-ui/src/components/section.tsx
index d1a574b30..4732b3b25 100644
--- a/packages/devtools-ui/src/components/section.tsx
+++ b/packages/devtools-ui/src/components/section.tsx
@@ -1,59 +1,52 @@
import clsx from 'clsx'
+import { omit } from 'solid-js'
import { createStyles } from '../styles/use-styles'
-import type { JSX } from 'solid-js/jsx-runtime'
+import type { JSX } from '@solidjs/web'
-export const Section = ({
- children,
- ...rest
-}: JSX.IntrinsicElements['section']) => {
+export const Section = (props: JSX.IntrinsicElements['section']) => {
const styles = createStyles()
+ const rest = omit(props, 'children', 'class')
return (
- {children}
+ {props.children}
)
}
-export const SectionTitle = ({
- children,
- ...rest
-}: JSX.IntrinsicElements['h3']) => {
+export const SectionTitle = (props: JSX.IntrinsicElements['h3']) => {
const styles = createStyles()
+ const rest = omit(props, 'children', 'class')
return (
- {children}
+ {props.children}
)
}
-export const SectionDescription = ({
- children,
- ...rest
-}: JSX.IntrinsicElements['p']) => {
+export const SectionDescription = (props: JSX.IntrinsicElements['p']) => {
const styles = createStyles()
+ const rest = omit(props, 'children', 'class')
return (
-
- {children}
+
+ {props.children}
)
}
-export const SectionIcon = ({
- children,
- ...rest
-}: JSX.IntrinsicElements['span']) => {
+export const SectionIcon = (props: JSX.IntrinsicElements['span']) => {
const styles = createStyles()
+ const rest = omit(props, 'children', 'class')
return (
-
- {children}
+
+ {props.children}
)
}
diff --git a/packages/devtools-ui/src/components/select.tsx b/packages/devtools-ui/src/components/select.tsx
index 0d631e2b5..8ca02da40 100644
--- a/packages/devtools-ui/src/components/select.tsx
+++ b/packages/devtools-ui/src/components/select.tsx
@@ -1,4 +1,4 @@
-import { createEffect, createSignal, createUniqueId } from 'solid-js'
+import { createSignal, createUniqueId } from 'solid-js'
import { createStyles } from '../styles/use-styles'
interface SelectOption {
@@ -16,18 +16,12 @@ interface SelectProps {
export function Select(props: SelectProps) {
const styles = createStyles()
- const [selected, setSelected] = createSignal(
- props.value ?? props.options[0]?.value,
+ const [selected, setSelected] = createSignal(
+ () => props.value ?? props.options[0]?.value,
)
const id = createUniqueId()
const descriptionId = `${id}-description`
- createEffect(() => {
- if (props.value !== undefined) {
- setSelected(() => props.value)
- }
- })
-
const handleChange = (e: Event) => {
const value = (e.target as HTMLSelectElement).value
const option = props.options.find(
diff --git a/packages/devtools-ui/src/components/theme.tsx b/packages/devtools-ui/src/components/theme.tsx
index 305d26e5e..751203350 100644
--- a/packages/devtools-ui/src/components/theme.tsx
+++ b/packages/devtools-ui/src/components/theme.tsx
@@ -1,11 +1,12 @@
import {
createContext,
- createEffect,
createSignal,
useContext as getContext,
+ onSettled,
} from 'solid-js'
import { ensureDevtoolsStyles } from '../styles/semantic-theme'
-import type { Accessor, JSX } from 'solid-js'
+import type { Accessor } from 'solid-js'
+import type { JSX } from '@solidjs/web'
export type TanStackDevtoolsTheme = 'light' | 'dark'
@@ -13,35 +14,29 @@ type ThemeContextValue = {
theme: Accessor
setTheme: (theme: TanStackDevtoolsTheme) => void
}
-const ThemeContext = createContext(undefined)
+const ThemeContext = createContext()
export const ThemeContextProvider = (props: {
children: JSX.Element
theme: TanStackDevtoolsTheme
}) => {
- const [theme, setTheme] = createSignal(props.theme)
- createEffect(() => {
- setTheme(props.theme)
- })
- const [container, setContainer] = createSignal()
- createEffect(() => {
- const element = container()
- if (element) ensureDevtoolsStyles(element.ownerDocument)
+ // Follows `props.theme`, and `setTheme` overrides it until the prop changes.
+ const [theme, setTheme] = createSignal(
+ () => props.theme,
+ )
+ let container: HTMLSpanElement | undefined
+ onSettled(() => {
+ if (container) ensureDevtoolsStyles(container.ownerDocument)
})
return (
-
-
+
+
{props.children}
-
+
)
}
export function createTheme() {
- const context = getContext(ThemeContext)
- if (!context) {
- throw new Error('createTheme must be used within a ThemeContextProvider')
- }
-
- return context
+ return getContext(ThemeContext)
}
diff --git a/packages/devtools-ui/src/components/tree.tsx b/packages/devtools-ui/src/components/tree.tsx
index 9c112b8a1..04d915320 100644
--- a/packages/devtools-ui/src/components/tree.tsx
+++ b/packages/devtools-ui/src/components/tree.tsx
@@ -1,4 +1,4 @@
-import { For, Match, Show, Switch, createSignal } from 'solid-js'
+import { For, Match, Show, Switch, createSignal, untrack } from 'solid-js'
import clsx from 'clsx'
import dayjs from 'dayjs'
@@ -173,11 +173,14 @@ const ArrayValue = (props: {
const styles = createStyles()
const [expanded, setExpanded] = createSignal(
- props.depth <= props.defaultExpansionDepth &&
- !props.collapsePaths?.includes(props.path),
+ untrack(
+ () =>
+ props.depth <= props.defaultExpansionDepth &&
+ !props.collapsePaths?.includes(props.path),
+ ),
)
- if (props.value.length === 0) {
+ if (untrack(() => props.value.length) === 0) {
return (
{props.keyName && (
@@ -204,7 +207,7 @@ const ArrayValue = (props: {
{props.keyName && (
{
+ onClick={(e) => {
e.stopPropagation()
e.stopImmediatePropagation()
setExpanded(!expanded())
@@ -228,12 +231,11 @@ const ArrayValue = (props: {
>
{(item, i) => {
- const isLastKey = i() === props.value.length - 1
return (
+ props.depth <= props.defaultExpansionDepth &&
+ !props.collapsePaths?.includes(props.path),
+ ),
)
- const keys = Object.keys(props.value)
+ const keys = untrack(() => Object.keys(props.value))
const lastKeyName = keys[keys.length - 1]
- if (props.value instanceof Date) {
+ if (untrack(() => props.value) instanceof Date) {
return (
{props.keyName && (
@@ -299,7 +304,7 @@ const ObjectValue = (props: {
)}
- {dayjs(props.value).format(
+ {dayjs(props.value as unknown as Date).format(
props.config?.dateFormat ? props.config.dateFormat : 'DDMMMYY',
)}
@@ -469,8 +474,8 @@ const Expander = (props: { expanded: boolean; onClick: () => void }) => {
{
diff --git a/packages/devtools-ui/src/styles/use-styles.ts b/packages/devtools-ui/src/styles/use-styles.ts
index 2aea1cb8a..908dc17a5 100644
--- a/packages/devtools-ui/src/styles/use-styles.ts
+++ b/packages/devtools-ui/src/styles/use-styles.ts
@@ -1,5 +1,5 @@
import * as goober from 'goober'
-import { createEffect, createSignal } from 'solid-js'
+import { createMemo } from 'solid-js'
import { createTheme } from '../components/theme'
import { resolveSemanticTheme } from './semantic-theme'
import type { tokens } from './tokens'
@@ -717,9 +717,5 @@ const stylesFactory = (theme: TanStackDevtoolsTheme) => {
export function createStyles() {
const { theme } = createTheme()
- const [styles, setStyles] = createSignal(stylesFactory(theme()))
- createEffect(() => {
- setStyles(stylesFactory(theme()))
- })
- return styles
+ return createMemo(() => stylesFactory(theme()))
}
diff --git a/packages/devtools-ui/tests/index.test.ts b/packages/devtools-ui/tests/index.test.ts
index b60c6a6c8..cd3da5c7a 100644
--- a/packages/devtools-ui/tests/index.test.ts
+++ b/packages/devtools-ui/tests/index.test.ts
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, expectTypeOf, it } from 'vitest'
import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import { createComponent } from 'solid-js'
-import { render } from 'solid-js/web'
+import { render } from '@solidjs/web'
import {
Button,
Checkbox,
diff --git a/packages/devtools-ui/tests/test-setup.ts b/packages/devtools-ui/tests/test-setup.ts
index a9d0dd31a..0797096af 100644
--- a/packages/devtools-ui/tests/test-setup.ts
+++ b/packages/devtools-ui/tests/test-setup.ts
@@ -1 +1,34 @@
import '@testing-library/jest-dom/vitest'
+import { flush } from 'solid-js'
+
+// Solid 2 applies writes on the next flush; Solid 1 applied them before an
+// event handler returned. These suites drive the UI with Testing Library
+// events and plain `dispatchEvent` calls and assert on the DOM right after, so
+// flush once the outermost dispatch returns.
+let dispatchDepth = 0
+const flushAfterDispatch = (
+ dispatch: (this: EventTarget, event: Event) => boolean,
+) =>
+ function (this: EventTarget, event: Event) {
+ dispatchDepth++
+ try {
+ return dispatch.call(this, event)
+ } finally {
+ if (--dispatchDepth === 0) flush()
+ }
+ }
+EventTarget.prototype.dispatchEvent = flushAfterDispatch(
+ EventTarget.prototype.dispatchEvent,
+)
+// Vitest's jsdom environment gives `window` its own `dispatchEvent`.
+window.dispatchEvent = flushAfterDispatch(window.dispatchEvent)
+// jsdom's `click()` dispatches internally, without `dispatchEvent`.
+const click = HTMLElement.prototype.click
+HTMLElement.prototype.click = function () {
+ dispatchDepth++
+ try {
+ click.call(this)
+ } finally {
+ if (--dispatchDepth === 0) flush()
+ }
+}
diff --git a/packages/devtools-ui/tests/tree.tsx b/packages/devtools-ui/tests/tree.tsx
index e90f0e973..73111d7f1 100644
--- a/packages/devtools-ui/tests/tree.tsx
+++ b/packages/devtools-ui/tests/tree.tsx
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { render } from 'solid-js/web'
+import { flush } from 'solid-js'
+import { render } from '@solidjs/web'
import { JsonTree } from '../src/components/tree'
import { ThemeContextProvider } from '../src/components/theme'
@@ -77,6 +78,8 @@ describe('JsonTree', () => {
)!
copy.click()
await Promise.resolve()
+ // The clipboard promise settles after the click's flush.
+ flush()
expect(copy.getAttribute('data-copy-state')).toBe('SuccessCopy')
expect(copy.querySelector('path')?.getAttribute('stroke')).toBe(
'currentColor',
@@ -88,6 +91,8 @@ describe('JsonTree', () => {
)[1]!
second.click()
await Promise.resolve()
+ // The clipboard promise settles after the click's flush.
+ flush()
expect(second.getAttribute('data-copy-state')).toBe('ErrorCopy')
expect(second.querySelector('path')?.getAttribute('stroke')).toBe(
'currentColor',
diff --git a/packages/devtools-ui/tsconfig.json b/packages/devtools-ui/tsconfig.json
index f58883b0e..9781176da 100644
--- a/packages/devtools-ui/tsconfig.json
+++ b/packages/devtools-ui/tsconfig.json
@@ -9,7 +9,7 @@
],
"compilerOptions": {
"types": ["vite/client"],
- "jsxImportSource": "solid-js",
+ "jsxImportSource": "@solidjs/web",
"jsx": "preserve"
}
}
diff --git a/packages/devtools-ui/vite.config.ts b/packages/devtools-ui/vite.config.ts
index 048092c8e..9082ac018 100644
--- a/packages/devtools-ui/vite.config.ts
+++ b/packages/devtools-ui/vite.config.ts
@@ -1,18 +1,12 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/vite-config'
-import solid from 'vite-plugin-solid'
+import solid from '@solidjs/vite-plugin'
import packageJson from './package.json'
import type { Plugin } from 'vite'
const config = defineConfig({
base: './',
- plugins: [
- solid({
- // Vitest 4's module runner treats `/@solid-refresh` as `file:///@solid-refresh`
- // and throws. HMR is not used in tests.
- hot: process.env.VITEST !== 'true',
- }) as any satisfies Plugin,
- ],
+ plugins: [solid() as any satisfies Plugin],
build: {
rollupOptions: {
output: {
diff --git a/packages/devtools-utils/package.json b/packages/devtools-utils/package.json
index 37ed811f5..647f91af9 100644
--- a/packages/devtools-utils/package.json
+++ b/packages/devtools-utils/package.json
@@ -86,20 +86,25 @@
"node": ">=18"
},
"devDependencies": {
+ "@babel/core": "^7.28.0",
+ "@solidjs/babel-plugin": "^2.0.0-rc.21",
+ "@solidjs/vite-plugin": "^3.0.0-next.57",
+ "@solidjs/web": "^2.0.0-rc.21",
"@sveltejs/vite-plugin-svelte": "^6.0.0",
"@tanstack/devtools": "workspace:^",
"preact": "^11.0.1",
+ "solid-js": "^2.0.0-rc.21",
"svelte": "^5.0.0",
"tsup": "^8.5.0",
- "tsup-preset-solid": "^2.2.0",
- "vite-plugin-solid": "^2.11.11"
+ "tsup-preset-solid": "^2.2.0"
},
"peerDependencies": {
"@angular/core": ">=19.0.0",
+ "@solidjs/web": ">=2.0.0-rc.21 <3.0.0",
"@types/react": ">=17.0.0",
"preact": ">=10.0.0",
"react": ">=17.0.0",
- "solid-js": "^1.9.13",
+ "solid-js": ">=2.0.0-rc.21 <3.0.0",
"svelte": ">=5.0.0",
"vue": ">=3.2.0"
},
@@ -107,6 +112,9 @@
"@angular/core": {
"optional": true
},
+ "@solidjs/web": {
+ "optional": true
+ },
"@types/react": {
"optional": true
},
diff --git a/packages/devtools-utils/skills/devtools-framework-adapters/references/solid.md b/packages/devtools-utils/skills/devtools-framework-adapters/references/solid.md
index 41c987ff3..a9c4488b8 100644
--- a/packages/devtools-utils/skills/devtools-framework-adapters/references/solid.md
+++ b/packages/devtools-utils/skills/devtools-framework-adapters/references/solid.md
@@ -56,8 +56,8 @@ A `readonly [Plugin, NoOpPlugin]` tuple:
```tsx
// packages/devtools-utils/src/solid/plugin.tsx
-/** @jsxImportSource solid-js */
-import type { JSX } from 'solid-js'
+/** @jsxImportSource @solidjs/web */
+import type { JSX } from '@solidjs/web'
import type { DevtoolsPanelProps } from './panel'
export function createSolidPlugin({
@@ -148,17 +148,17 @@ Where `ClassType` is `ReturnType[0]` -- a class with
- **`Panel`** -- A Solid component that:
- Creates a `` with a ref.
- - Instantiates `CoreClass` immediately via `createSignal`.
- - Calls `core.mount(el, props.theme ?? 'dark')` inside `onMount`.
- - Calls `core.unmount()` via `onCleanup` (nested inside `onMount`).
+ - Instantiates `CoreClass` once, when the component is created.
+ - Calls `core.mount(el, props)` inside `onSettled`.
+ - Calls `core.unmount()` from the cleanup that `onSettled` returns.
- **`NoOpPanel`** -- Renders `<>>`.
### Source
```tsx
// packages/devtools-utils/src/solid/panel.tsx
-/** @jsxImportSource solid-js */
-import { createSignal, onCleanup, onMount } from 'solid-js'
+/** @jsxImportSource @solidjs/web */
+import { onSettled } from 'solid-js'
import type { ClassType } from './class'
export function createSolidPanel<
@@ -166,14 +166,12 @@ export function createSolidPanel<
>(CoreClass: ClassType) {
function Panel(props: TComponentProps) {
let devToolRef: HTMLDivElement | undefined
- const [devtools] = createSignal(new CoreClass())
- onMount(() => {
+ const devtools = new CoreClass()
+ onSettled(() => {
if (devToolRef) {
- devtools().mount(devToolRef, props?.theme ?? 'dark')
+ devtools.mount(devToolRef, props)
}
- onCleanup(() => {
- devtools().unmount()
- })
+ return () => devtools.unmount()
})
return
}
@@ -267,8 +265,8 @@ const [DevtoolsCore, NoOpDevtoolsCore] = constructCoreClass(
3. **Default theme is `'dark'`.** If `props.theme` is undefined, the panel defaults to `'dark'`.
-4. **`onCleanup` is nested inside `onMount`.** In `createSolidPanel`, cleanup is registered inside `onMount`, which is the Solid idiom for pairing mount/unmount lifecycle.
+4. **Unmount is the cleanup `onSettled` returns.** Solid 2 replaces `onMount` with `onSettled`, and `onCleanup` cannot be registered inside it, so `createSolidPanel` returns the unmount from `onSettled`.
-5. **Core class instantiation is eager.** `createSignal(new CoreClass())` runs immediately when the Panel component is created, not lazily. The actual `mount` call happens in `onMount`.
+5. **Core class instantiation is eager.** `new CoreClass()` runs immediately when the Panel component is created, not lazily. The actual `mount` call happens in `onSettled`.
6. **`constructCoreClass` handles async import abort.** If `unmount()` is called while the dynamic import is still in flight, the mount is aborted cleanly. No need to handle this manually.
diff --git a/packages/devtools-utils/src/solid/class-mount-impl.tsx b/packages/devtools-utils/src/solid/class-mount-impl.tsx
index 62652af44..b6a8a3eb0 100644
--- a/packages/devtools-utils/src/solid/class-mount-impl.tsx
+++ b/packages/devtools-utils/src/solid/class-mount-impl.tsx
@@ -1,9 +1,10 @@
-/** @jsxImportSource solid-js - we use Solid.js as JSX here */
+/** @jsxImportSource @solidjs/web - we use Solid.js as JSX here */
-import { lazy } from 'solid-js'
-import { Portal, render } from 'solid-js/web'
+import { Show, createComponent, createSignal, untrack } from 'solid-js'
+import { Portal, render } from '@solidjs/web'
-import type { JSX } from 'solid-js'
+import type { Component } from 'solid-js'
+import type { JSX } from '@solidjs/web'
import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
export function __mountComponent(
@@ -13,13 +14,20 @@ export function __mountComponent(
default: (props: TanStackDevtoolsPluginProps) => JSX.Element
}>,
): () => void {
- const Component = lazy(importFn)
+ // Loaded by hand rather than with `lazy`, which would need a `Loading`
+ // boundary to keep the root from waiting on the chunk.
+ const [panel, setPanel] =
+ createSignal
>()
+ void importFn().then((mod) => setPanel(() => mod.default))
return render(
() => (
-
+ {/* Set once, when the chunk arrives. */}
+
+ {(Panel) => createComponent(untrack(Panel), props)}
+
),
diff --git a/packages/devtools-utils/src/solid/class.test.tsx b/packages/devtools-utils/src/solid/class.test.tsx
index ddaeb7ddd..d07cffe99 100644
--- a/packages/devtools-utils/src/solid/class.test.tsx
+++ b/packages/devtools-utils/src/solid/class.test.tsx
@@ -1,4 +1,4 @@
-/** @jsxImportSource solid-js - we use Solid.js as JSX here */
+/** @jsxImportSource @solidjs/web - we use Solid.js as JSX here */
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { constructCoreClass } from './class'
diff --git a/packages/devtools-utils/src/solid/class.ts b/packages/devtools-utils/src/solid/class.ts
index 22181e095..b5d18dcdc 100644
--- a/packages/devtools-utils/src/solid/class.ts
+++ b/packages/devtools-utils/src/solid/class.ts
@@ -1,5 +1,5 @@
import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
-import type { JSX } from 'solid-js'
+import type { JSX } from '@solidjs/web'
/**
* Constructs the core class for the Devtools.
diff --git a/packages/devtools-utils/src/solid/panel.tsx b/packages/devtools-utils/src/solid/panel.tsx
index cecafe38c..2b2a3c807 100644
--- a/packages/devtools-utils/src/solid/panel.tsx
+++ b/packages/devtools-utils/src/solid/panel.tsx
@@ -1,6 +1,6 @@
-/** @jsxImportSource solid-js - we use Solid.js as JSX here */
+/** @jsxImportSource @solidjs/web - we use Solid.js as JSX here */
-import { createSignal, onCleanup, onMount } from 'solid-js'
+import { onSettled } from 'solid-js'
import type { ClassType } from './class'
import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
@@ -11,14 +11,12 @@ export function createSolidPanel(
) {
function Panel(props: TComponentProps) {
let devToolRef: HTMLDivElement | undefined
- const [devtools] = createSignal(new CoreClass())
- onMount(() => {
+ const devtools = new CoreClass()
+ onSettled(() => {
if (devToolRef) {
- devtools().mount(devToolRef, props)
+ devtools.mount(devToolRef, props)
}
- onCleanup(() => {
- devtools().unmount()
- })
+ return () => devtools.unmount()
})
return
diff --git a/packages/devtools-utils/src/solid/plugin.tsx b/packages/devtools-utils/src/solid/plugin.tsx
index 81a7ef28a..33142f900 100644
--- a/packages/devtools-utils/src/solid/plugin.tsx
+++ b/packages/devtools-utils/src/solid/plugin.tsx
@@ -1,6 +1,6 @@
-/** @jsxImportSource solid-js - we use Solid.js as JSX here */
+/** @jsxImportSource @solidjs/web - we use Solid.js as JSX here */
-import type { JSX } from 'solid-js'
+import type { JSX } from '@solidjs/web'
import type { DevtoolsPanelProps } from './panel'
import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
diff --git a/packages/devtools-utils/tsconfig.solid.json b/packages/devtools-utils/tsconfig.solid.json
index dd4f3ba97..1922f4e32 100644
--- a/packages/devtools-utils/tsconfig.solid.json
+++ b/packages/devtools-utils/tsconfig.solid.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"jsx": "preserve",
- "jsxImportSource": "solid-js"
+ "jsxImportSource": "@solidjs/web"
},
"extends": "../../tsconfig.json",
"include": ["src/solid/**"]
diff --git a/packages/devtools-utils/tsup.config.ts b/packages/devtools-utils/tsup.config.ts
index bd57209b5..d5ba3de35 100644
--- a/packages/devtools-utils/tsup.config.ts
+++ b/packages/devtools-utils/tsup.config.ts
@@ -1,5 +1,6 @@
import { defineConfig } from 'tsup'
import { generateTsupOptions, parsePresetOptions } from 'tsup-preset-solid'
+import { withSolidV2 } from '../../scripts/tsup-solid-v2'
const preset_options = {
entries: {
@@ -13,7 +14,7 @@ const preset_options = {
export default defineConfig(() => {
const parsed_data = parsePresetOptions(preset_options)
- const tsup_options = generateTsupOptions(parsed_data)
+ const tsup_options = withSolidV2(generateTsupOptions(parsed_data))
return tsup_options.map((o) => ({
...o,
diff --git a/packages/devtools-utils/vite.config.solid-class.ts b/packages/devtools-utils/vite.config.solid-class.ts
index 2f1665668..dff72289c 100644
--- a/packages/devtools-utils/vite.config.solid-class.ts
+++ b/packages/devtools-utils/vite.config.solid-class.ts
@@ -1,16 +1,10 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/vite-config'
-import solid from 'vite-plugin-solid'
+import solid from '@solidjs/vite-plugin'
import packageJson from './package.json'
const config = defineConfig({
- plugins: [
- solid({
- // Vitest 4's module runner treats `/@solid-refresh` as `file:///@solid-refresh`
- // and throws. HMR is not used in tests.
- hot: process.env.VITEST !== 'true',
- }),
- ],
+ plugins: [solid()],
test: {
name: packageJson.name,
dir: './',
diff --git a/packages/devtools-utils/vite.config.solid.ts b/packages/devtools-utils/vite.config.solid.ts
index 991823394..f103b1b7e 100644
--- a/packages/devtools-utils/vite.config.solid.ts
+++ b/packages/devtools-utils/vite.config.solid.ts
@@ -1,6 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/vite-config'
-import solid from 'vite-plugin-solid'
+import solid from '@solidjs/vite-plugin'
import packageJson from './package.json'
import tsconfig from './tsconfig.solid.json'
@@ -8,9 +8,6 @@ const config = defineConfig({
plugins: [
solid({
ssr: true,
- // Vitest 4's module runner treats `/@solid-refresh` as `file:///@solid-refresh`
- // and throws. HMR is not used in tests.
- hot: process.env.VITEST !== 'true',
}) as any,
],
test: {
diff --git a/packages/devtools-vite/skills/devtools-vite-plugin/SKILL.md b/packages/devtools-vite/skills/devtools-vite-plugin/SKILL.md
index 960f9d91b..8b5e92772 100644
--- a/packages/devtools-vite/skills/devtools-vite-plugin/SKILL.md
+++ b/packages/devtools-vite/skills/devtools-vite-plugin/SKILL.md
@@ -122,7 +122,7 @@ Bidirectional console piping between client and server. Injects runtime code (II
1. Wraps `console[level]` to batch and POST entries to `/__tsd/console-pipe/server`
2. These are then broadcast to all SSE clients
-**Entry file detection:** looks for ` => {
code.includes('StartClient') ||
code.includes('hydrateRoot') ||
code.includes('createRoot') ||
- (code.includes('solid-js/web') && code.includes('render('))
+ // Solid 1 renders from `solid-js/web`, Solid 2 from `@solidjs/web`.
+ ((code.includes('solid-js/web') || code.includes('@solidjs/web')) &&
+ code.includes('render('))
if (isRootEntry) {
const viteServerUrl = `http://localhost:${port}`
diff --git a/packages/devtools/package.json b/packages/devtools/package.json
index b70cf87ce..2d5f4f70a 100644
--- a/packages/devtools/package.json
+++ b/packages/devtools/package.json
@@ -65,24 +65,23 @@
},
"dependencies": {
"@neodrag/core": "3.0.0-next.11",
- "@neodrag/solid": "3.0.0-next.11",
- "@solid-primitives/event-listener": "^2.4.3",
- "@solid-primitives/keyboard": "^1.3.3",
- "@solid-primitives/resize-observer": "^2.1.3",
+ "@solid-primitives/event-listener": "^3.0.0-next.10",
+ "@solid-primitives/keyboard": "^2.0.0-next.8",
+ "@solid-primitives/resize-observer": "^4.0.0-next.7",
+ "@solidjs/web": "^2.0.0-rc.21",
"@tanstack/devtools-client": "workspace:*",
"@tanstack/devtools-event-bus": "workspace:*",
"@tanstack/devtools-ui": "workspace:*",
"clsx": "^2.1.1",
"goober": "^2.1.16",
- "solid-js": "^1.9.13"
- },
- "peerDependencies": {
- "solid-js": "^1.9.13"
+ "solid-js": "^2.0.0-rc.21"
},
"devDependencies": {
- "@solidjs/testing-library": "^0.8.10",
+ "@babel/core": "^7.28.0",
+ "@solidjs/babel-plugin": "^2.0.0-rc.21",
+ "@solidjs/testing-library": "^1.0.0-rc.2",
+ "@solidjs/vite-plugin": "^3.0.0-next.57",
"tsup": "^8.5.0",
- "tsup-preset-solid": "^2.2.0",
- "vite-plugin-solid": "^2.11.11"
+ "tsup-preset-solid": "^2.2.0"
}
}
diff --git a/packages/devtools/skills/devtools-app-setup/SKILL.md b/packages/devtools/skills/devtools-app-setup/SKILL.md
index 80d9a8a5f..4fbb1a718 100644
--- a/packages/devtools/skills/devtools-app-setup/SKILL.md
+++ b/packages/devtools/skills/devtools-app-setup/SKILL.md
@@ -100,7 +100,7 @@ npm install -D @tanstack/solid-devtools @tanstack/devtools-vite
```
```tsx
-import { render } from 'solid-js/web'
+import { render } from '@solidjs/web'
import { TanStackDevtools } from '@tanstack/solid-devtools'
import { SolidQueryDevtoolsPanel } from '@tanstack/solid-query-devtools'
import App from './App'
diff --git a/packages/devtools/skills/devtools-plugin-panel/SKILL.md b/packages/devtools/skills/devtools-plugin-panel/SKILL.md
index a1a72fdd5..754985922 100644
--- a/packages/devtools/skills/devtools-plugin-panel/SKILL.md
+++ b/packages/devtools/skills/devtools-plugin-panel/SKILL.md
@@ -81,7 +81,7 @@ Event names are suffixes only. The `pluginId` is prepended automatically: `'stor
### Step 2: Build the Solid.js Panel Component
```tsx
-/** @jsxImportSource solid-js */
+/** @jsxImportSource @solidjs/web */
import { createSignal, onCleanup, For } from 'solid-js'
import {
MainPanel,
diff --git a/packages/devtools/src/components/content-panel.tsx b/packages/devtools/src/components/content-panel.tsx
index d289ad9ed..72373430f 100644
--- a/packages/devtools/src/components/content-panel.tsx
+++ b/packages/devtools/src/components/content-panel.tsx
@@ -8,7 +8,7 @@ import {
PANEL_CLOSE_THRESHOLD,
PANEL_MAX_VIEWPORT_RATIO,
} from '../utils/constants'
-import type { JSX } from 'solid-js/jsx-runtime'
+import type { JSX } from '@solidjs/web'
export const ContentPanel = (props: {
ref: (el: HTMLDivElement | undefined) => void
@@ -66,7 +66,7 @@ export const ContentPanel = (props: {
aria-valuemin={PANEL_CLOSE_THRESHOLD}
aria-valuemax={maxHeight()}
aria-valuenow={clampedHeight()}
- tabIndex={0}
+ tabindex={0}
onKeyDown={resizeWithKeyboard}
/>
) : null}
diff --git a/packages/devtools/src/components/main-panel.tsx b/packages/devtools/src/components/main-panel.tsx
index 163ebd5e6..4d3265a04 100644
--- a/packages/devtools/src/components/main-panel.tsx
+++ b/packages/devtools/src/components/main-panel.tsx
@@ -1,5 +1,5 @@
import clsx from 'clsx'
-import { createEffect, createSignal, onCleanup } from 'solid-js'
+import { createEffect, createSignal, untrack } from 'solid-js'
import {
createDevtoolsSettings,
createHeight,
@@ -8,7 +8,8 @@ import { createStyles } from '../styles/use-styles'
import { TANSTACK_DEVTOOLS } from '../utils/storage'
import { createPiPWindow } from '../context/pip-context'
import { CollapseToggle } from './workbench-secondary-tabs'
-import type { Accessor, JSX } from 'solid-js'
+import type { Accessor } from 'solid-js'
+import type { JSX } from '@solidjs/web'
export const MainPanel = (props: {
isOpen: Accessor
@@ -31,10 +32,9 @@ export const MainPanel = (props: {
targetWindow.innerWidth
)
}
- const [clientWidth, setClientWidth] = createSignal(readClientWidth())
+ const [clientWidth, setClientWidth] = createSignal(untrack(readClientWidth))
- createEffect(() => {
- const targetWindow = panelWindow()
+ createEffect(panelWindow, (targetWindow) => {
if (!targetWindow) return
const targetRoot = targetWindow.document.documentElement
const syncClientWidth = () => {
@@ -51,10 +51,10 @@ export const MainPanel = (props: {
? new ResizeObserverConstructor(syncClientWidth)
: null
resizeObserver?.observe(targetRoot)
- onCleanup(() => {
+ return () => {
targetWindow.removeEventListener('resize', syncClientWidth)
resizeObserver?.disconnect()
- })
+ }
})
const isAttached = () => pip().pipWindow === null
diff --git a/packages/devtools/src/components/plugin-workspace.tsx b/packages/devtools/src/components/plugin-workspace.tsx
index 6f563294d..489164558 100644
--- a/packages/devtools/src/components/plugin-workspace.tsx
+++ b/packages/devtools/src/components/plugin-workspace.tsx
@@ -1,15 +1,15 @@
import {
For,
- Index,
Show,
createEffect,
createMemo,
createSignal,
+ flush,
onCleanup,
} from 'solid-js'
-import { Portal } from 'solid-js/web'
+import { Portal } from '@solidjs/web'
import { PackageIcon, X } from '@tanstack/devtools-ui/icons'
-import { createSortable } from '@neodrag/solid/sortable'
+import { createSortable } from '../utils/create-sortable'
import {
createPlugins,
createStripDrag,
@@ -168,7 +168,7 @@ const GroupTabBar = (props: {
data-tsd-group-tab
data-testid={`plugin-tab-${tabId}`}
data-tsd-control
- aria-pressed={index() === props.activeIndex}
+ aria-pressed={index() === props.activeIndex ? 'true' : 'false'}
aria-describedby={props.moveHintId}
class={styles().pluginGroupTab}
onPointerDown={(event) => props.onPointerDown(tabId, event)}
@@ -210,8 +210,10 @@ export const PluginWorkspace = (props: {
const { theme } = createTheme()
const styles = createStyles()
+ // Written from a pane's cleanup, which runs inside Solid's disposal.
const [pluginRefs, setPluginRefs] = createSignal(
new Map(),
+ { ownedWrite: true },
)
const [box, setBox] = createSignal({ w: 0, h: 0 })
const [held, setHeld] = createSignal(null)
@@ -244,15 +246,18 @@ export const PluginWorkspace = (props: {
setBox({ w: rect.width, h: rect.height })
}
+ // Refs own nothing in Solid 2, so the observer is torn down from here.
+ let workspaceObserver: ResizeObserver | undefined
+ onCleanup(() => workspaceObserver?.disconnect())
const registerWorkspace = (el: HTMLDivElement) => {
workspaceEl = el
measure()
const Observer = (globalThis as { ResizeObserver?: typeof ResizeObserver })
.ResizeObserver
if (!Observer) return
- const observer = new Observer(measure)
- observer.observe(el)
- onCleanup(() => observer.disconnect())
+ workspaceObserver?.disconnect()
+ workspaceObserver = new Observer(measure)
+ workspaceObserver.observe(el)
}
/**
@@ -261,11 +266,10 @@ export const PluginWorkspace = (props: {
* for a panel that only slid out of sight, so mounting hidden would otherwise
* leave the box at its initial value for good.
*/
- createEffect(() => {
- props.visible
- props.isOpen
- measure()
- })
+ createEffect(
+ () => [props.visible, props.isOpen],
+ () => measure(),
+ )
const paddedBox = createMemo(() => ({
w: Math.max(box().w - PANE_CARD_INSET * 2, 0),
@@ -304,7 +308,7 @@ export const PluginWorkspace = (props: {
* changes when a plugin opens or closes, which inserts or removes a node
* anyway. Rearranging the layout leaves every existing node untouched.
*/
- const paneOrder = createMemo(() => [...activePlugins()].sort(), [], {
+ const paneOrder = createMemo(() => [...activePlugins()].sort(), {
equals: (a, b) => a.length === b.length && a.every((id, i) => id === b[i]),
})
@@ -346,15 +350,22 @@ export const PluginWorkspace = (props: {
// Hand each plugin its mount node. Re-runs when the theme or open state
// changes, which is the documented contract for `render`.
- createEffect(() => {
- for (const pluginId of activePlugins()) {
- const plugin = pluginById(pluginId)
- const ref = pluginRefs().get(pluginId)
- if (plugin && ref) {
- plugin.render(ref, { theme: theme(), devtoolsOpen: props.isOpen })
+ createEffect(
+ () => {
+ const renderProps = { theme: theme(), devtoolsOpen: props.isOpen }
+ const refs = pluginRefs()
+ return activePlugins().map((pluginId) => ({
+ render: pluginById(pluginId)?.render,
+ ref: refs.get(pluginId),
+ renderProps,
+ }))
+ },
+ (mounts) => {
+ for (const { render, ref, renderProps } of mounts) {
+ if (render && ref) render(ref, renderProps)
}
- }
- })
+ },
+ )
const clearDrag = () => {
setHeld(null)
@@ -369,17 +380,15 @@ export const PluginWorkspace = (props: {
* of the host page for the duration of the drag. The devtools must not restyle
* the page they are inspecting.
*/
- createEffect(() => {
- const host = workspaceEl?.closest(`#${TANSTACK_DEVTOOLS}`)
- if (!host) return
- const className = styles().pluginDraggingCursor
- if (previewAt() === null) {
- host.classList.remove(className)
- return
- }
- host.classList.add(className)
- onCleanup(() => host.classList.remove(className))
- })
+ createEffect(
+ () => (previewAt() === null ? null : styles().pluginDraggingCursor),
+ (className) => {
+ const host = workspaceEl?.closest(`#${TANSTACK_DEVTOOLS}`)
+ if (!host || className === null) return
+ host.classList.add(className)
+ return () => host.classList.remove(className)
+ },
+ )
/**
* `aria-grabbed` is deprecated, so the state of a move is narrated through a
@@ -522,6 +531,8 @@ export const PluginWorkspace = (props: {
}
measure()
+ // `aim` below reads the rects the new box feeds, before the next flush.
+ flush()
setHeld({ tabId: pluginId })
setPreviewAt(startPoint)
const aim = (point: { x: number; y: number }) =>
@@ -830,14 +841,14 @@ export const PluginWorkspace = (props: {
}}
- {/* `Index`, not `For`: `splitterHandles` returns fresh objects on every
+ {/* Unkeyed `For`: `splitterHandles` returns fresh objects on every
re-measure, so a keyed `For` destroyed and rebuilt every gutter
whenever the geometry changed. That threw away keyboard focus
mid-resize and left stale element references behind. Keying by
position keeps the elements alive and just updates their values. */}
-
+
{(handle) => {
- // Accessor, not a snapshot: Index keeps this node for a given
+ // Accessor, not a snapshot: an unkeyed For keeps this node for a given
// gutter index, so a const taken at mount would stay at the first
// geometry (two equal panes) after a third pane opens or the
// workspace is re-measured.
@@ -845,7 +856,7 @@ export const PluginWorkspace = (props: {
return (
)
}}
-
+
{/* Outside the "has panes" branch on purpose: dropping onto an empty
diff --git a/packages/devtools/src/components/plugins-strip.tsx b/packages/devtools/src/components/plugins-strip.tsx
index 55a6e2dc3..61767b34b 100644
--- a/packages/devtools/src/components/plugins-strip.tsx
+++ b/packages/devtools/src/components/plugins-strip.tsx
@@ -1,4 +1,4 @@
-import { For, createEffect, createMemo } from 'solid-js'
+import { For, createEffect, createMemo, untrack } from 'solid-js'
import {
createCollapsed,
createDevtoolsState,
@@ -91,12 +91,13 @@ export const PluginsStrip = (props: { isOpen: Accessor }) => {
* plugin closes and returns to it. Only those two transitions are automatic, so
* a deliberate fold or unfold in between is left alone.
*/
- createEffect((wasEmpty: boolean | undefined) => {
- const isEmpty = available().length === 0
- if (isEmpty && wasEmpty === false) setCollapsed(true)
- if (!isEmpty && wasEmpty === true) setCollapsed(false)
- return isEmpty
- })
+ createEffect(
+ () => available().length === 0,
+ (isEmpty, wasEmpty) => {
+ if (isEmpty && wasEmpty === false) setCollapsed(true)
+ if (!isEmpty && wasEmpty === true) setCollapsed(false)
+ },
+ )
return (
}) => {
{(plugin) => {
let heading: HTMLHeadingElement | undefined
- const renderName = () => {
+ const nameProps = () => ({
+ name: plugin.name,
+ theme: theme(),
+ devtoolsOpen: props.isOpen(),
+ })
+ const renderName = ({
+ name,
+ ...renderProps
+ }: ReturnType) => {
if (!heading) return
- if (typeof plugin.name === 'string') {
- heading.textContent = plugin.name
+ if (typeof name === 'string') {
+ heading.textContent = name
} else {
- plugin.name(heading, {
- theme: theme(),
- devtoolsOpen: props.isOpen(),
- })
+ name(heading, renderProps)
}
}
- let nameMounted = false
- createEffect(() => {
- theme()
- props.isOpen()
- if (!nameMounted) {
- nameMounted = true
- return
- }
- renderName()
- })
+ // The ref renders the name first; this re-renders it on change.
+ createEffect(nameProps, renderName, { defer: true })
return (
}) => {
id={`${PLUGIN_TITLE_CONTAINER_ID}-${plugin.id}`}
ref={(element) => {
heading = element
- renderName()
+ renderName(untrack(nameProps))
}}
style={
typeof plugin.name === 'function'
diff --git a/packages/devtools/src/components/source-inspector.tsx b/packages/devtools/src/components/source-inspector.tsx
index 44012dbc2..ab4453f25 100644
--- a/packages/devtools/src/components/source-inspector.tsx
+++ b/packages/devtools/src/components/source-inspector.tsx
@@ -1,5 +1,4 @@
-import { createEffect, createMemo, createSignal } from 'solid-js'
-import { createStore } from 'solid-js/store'
+import { createEffect, createMemo, createSignal, createStore } from 'solid-js'
import { createElementSize } from '@solid-primitives/resize-observer'
import { useKeyDownList as getKeyDownList } from '@solid-primitives/keyboard'
import { createEventListener } from '@solid-primitives/event-listener'
@@ -17,7 +16,7 @@ export const SourceInspector = () => {
const [highlightState, setHighlightState] = createStore(highlightStateInit())
const resetHighlight = () => {
- setHighlightState(highlightStateInit())
+ setHighlightState(() => highlightStateInit())
}
const [nameTagRef, setNameTagRef] = createSignal(null)
@@ -25,7 +24,10 @@ export const SourceInspector = () => {
const [mousePosition, setMousePosition] = createStore({ x: 0, y: 0 })
createEventListener(document, 'mousemove', (e) => {
- setMousePosition({ x: e.clientX, y: e.clientY })
+ setMousePosition((position) => {
+ position.x = e.clientX
+ position.y = e.clientY
+ })
})
const downList = getKeyDownList()
@@ -36,61 +38,58 @@ export const SourceInspector = () => {
return isHotkeyCombinationPressed(downList(), settings().inspectHotkey)
})
- createEffect(() => {
- if (!isHighlightingKeysHeld()) {
- setDisabledAfterClick(false)
- }
+ createEffect(isHighlightingKeysHeld, (held) => {
+ if (!held) setDisabledAfterClick(false)
})
const isActive = createMemo(
() => isHighlightingKeysHeld() && !disabledAfterClick(),
)
- createEffect(() => {
- if (isActive()) {
- document.body.style.cursor = 'pointer'
- } else {
- document.body.style.cursor = ''
- }
+ createEffect(isActive, (active) => {
+ document.body.style.cursor = active ? 'pointer' : ''
})
- createEffect(() => {
- if (!isActive()) {
- resetHighlight()
- return
- }
+ createEffect(
+ () => (isActive() ? { x: mousePosition.x, y: mousePosition.y } : null),
+ (point) => {
+ if (!point) {
+ resetHighlight()
+ return
+ }
- const target = document.elementFromPoint(mousePosition.x, mousePosition.y)
+ const target = document.elementFromPoint(point.x, point.y)
- if (!(target instanceof HTMLElement)) {
- resetHighlight()
- return
- }
+ if (!(target instanceof HTMLElement)) {
+ resetHighlight()
+ return
+ }
- if (target === highlightState.element) {
- return
- }
+ if (target === highlightState.element) {
+ return
+ }
- const dataSource = target.getAttribute('data-tsd-source')
- if (!dataSource) {
- resetHighlight()
- return
- }
+ const dataSource = target.getAttribute('data-tsd-source')
+ if (!dataSource) {
+ resetHighlight()
+ return
+ }
- const rect = target.getBoundingClientRect()
- const bounding = {
- width: rect.width,
- height: rect.height,
- left: rect.left,
- top: rect.top,
- }
+ const rect = target.getBoundingClientRect()
+ const bounding = {
+ width: rect.width,
+ height: rect.height,
+ left: rect.left,
+ top: rect.top,
+ }
- setHighlightState({
- element: target,
- bounding,
- dataSource,
- })
- })
+ setHighlightState(() => ({
+ element: target,
+ bounding,
+ dataSource,
+ }))
+ },
+ )
const openSourceUrl = (source: string) => {
// A host that injects `data-tsd-source` without `@tanstack/devtools-vite`
diff --git a/packages/devtools/src/components/tab-content.tsx b/packages/devtools/src/components/tab-content.tsx
index e63285618..b9d59ee12 100644
--- a/packages/devtools/src/components/tab-content.tsx
+++ b/packages/devtools/src/components/tab-content.tsx
@@ -4,7 +4,7 @@ import { tabs } from '../tabs'
import { createStyles } from '../styles/use-styles'
import { PluginMarketplace } from '../tabs/plugin-marketplace'
import { PluginWorkspace } from './plugin-workspace'
-import type { JSX } from 'solid-js'
+import type { JSX } from '@solidjs/web'
export const TabContent = (props: {
isOpen: boolean
diff --git a/packages/devtools/src/components/trigger.test.tsx b/packages/devtools/src/components/trigger.test.tsx
index d71f41f93..9fe6e4875 100644
--- a/packages/devtools/src/components/trigger.test.tsx
+++ b/packages/devtools/src/components/trigger.test.tsx
@@ -1,5 +1,5 @@
import { fireEvent, render } from '@solidjs/testing-library'
-import { createSignal } from 'solid-js'
+import { createSignal, flush } from 'solid-js'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { DevtoolsProvider } from '../context/devtools-context'
import { TANSTACK_DEVTOOLS_SETTINGS } from '../utils/storage'
@@ -17,6 +17,12 @@ import {
} from './trigger'
import type { TanStackDevtoolsConfig } from '../context/devtools-context'
+// Timer callbacks write signals; flush so the DOM reflects them.
+const advanceTimers = (ms: number) => {
+ vi.advanceTimersByTime(ms)
+ flush()
+}
+
const renderTrigger = (config?: Partial) => {
const [isOpen, setIsOpen] = createSignal(false)
return render(() => (
@@ -325,7 +331,7 @@ describe('the drag tooltip', () => {
drag(button, 'pointerdown', 400, 400)
expect(queryByText(/magnetic mode/)).not.toBeNull()
- vi.advanceTimersByTime(1500)
+ advanceTimers(1500)
expect(queryByText(/magnetic mode/)).toBeNull()
drag(button, 'pointermove', 500, 400)
@@ -467,9 +473,9 @@ describe('holding a drag on a hot corner', () => {
drag(button, 'pointermove', 1016, 760)
expect(mark()).not.toBeNull()
- vi.advanceTimersByTime(1999)
+ advanceTimers(1999)
expect(mark()).not.toBeNull()
- vi.advanceTimersByTime(1)
+ advanceTimers(1)
expect(mark()).toBeNull()
drag(button, 'pointermove', 500, 400)
@@ -486,7 +492,7 @@ describe('holding a drag on a hot corner', () => {
drag(button, 'pointerdown', 8, 8)
drag(button, 'pointermove', 1016, 760)
- vi.advanceTimersByTime(2000)
+ advanceTimers(2000)
expect(mark()).toBeNull()
drag(button, 'pointermove', 1010, 750)
@@ -509,11 +515,11 @@ describe('holding a drag on a hot corner', () => {
drag(button, 'pointerdown', 8, 8)
drag(button, 'pointermove', 1016, 760)
- vi.advanceTimersByTime(1500)
+ advanceTimers(1500)
drag(button, 'pointermove', 1020, 750)
- vi.advanceTimersByTime(1500)
+ advanceTimers(1500)
expect(mark()).not.toBeNull()
- vi.advanceTimersByTime(500)
+ advanceTimers(500)
expect(mark()).toBeNull()
drag(button, 'pointermove', 500, 400)
@@ -526,7 +532,7 @@ describe('holding a drag on a hot corner', () => {
drag(button, 'pointerdown', 8, 8)
drag(button, 'pointermove', 1016, 760)
- vi.advanceTimersByTime(1500)
+ advanceTimers(1500)
drag(button, 'pointerup', 1016, 760)
expect(storedSettings().triggerCorner).toBe('bottom-right')
})
@@ -539,7 +545,7 @@ describe('holding a drag on a hot corner', () => {
drag(button, 'pointerdown', 8, 8)
drag(button, 'pointermove', 2000, 2000)
- vi.advanceTimersByTime(2000)
+ advanceTimers(2000)
drag(button, 'pointerup', 2000, 2000)
expect(storedSettings().triggerCorner).toBeUndefined()
diff --git a/packages/devtools/src/components/trigger.tsx b/packages/devtools/src/components/trigger.tsx
index bf7d71a0e..f2341332a 100644
--- a/packages/devtools/src/components/trigger.tsx
+++ b/packages/devtools/src/components/trigger.tsx
@@ -3,6 +3,7 @@ import {
createEffect,
createMemo,
createSignal,
+ flush,
onCleanup,
untrack,
} from 'solid-js'
@@ -16,6 +17,7 @@ import {
TRIGGER_EDGE_TAB_PAD,
TRIGGER_TOOLTIP_MS,
} from '../utils/constants'
+import { nativeListener } from '../utils/native-listener'
import { TanStackTriggerMark } from './tanstack-trigger-mark'
import type {
TriggerCoords,
@@ -210,11 +212,11 @@ export const Trigger = (props: {
// percent of the free space, see `persist` and `placeFromSettings`.
const [coords, setCoords] = createSignal(null)
const [pinnedCorner, setPinnedCorner] = createSignal(
- settings().triggerCorner ?? null,
+ untrack(() => settings().triggerCorner ?? null),
)
const [hotCorner, setHotCorner] = createSignal(null)
const [dockedEdge, setDockedEdge] = createSignal(
- settings().triggerEdge ?? null,
+ untrack(() => settings().triggerEdge ?? null),
)
const [hoverEdge, setHoverEdge] = createSignal(null)
const [tooltipVisible, setTooltipVisible] = createSignal(false)
@@ -338,6 +340,9 @@ export const Trigger = (props: {
}
const persist = () => {
+ // Callers set the signals this reads in the same handler, and Solid 2
+ // applies writes on flush.
+ flush()
const el = buttonRef()
const current = coords()
const b = el && bounds(el)
@@ -477,6 +482,7 @@ export const Trigger = (props: {
} else {
raf = undefined
setShiftMagnetic(false)
+ flush()
const corner = hotCorner()
if (corner) pinTo(corner, el)
else persist()
@@ -540,12 +546,14 @@ export const Trigger = (props: {
// Mounts the floating button (the tab unmounts), then centers it under
// the pointer and hands the drag to it. Pointer capture moves with it.
setDockedEdge(null)
+ flush()
const el = buttonRef()
if (!el) return
setCoords({
x: e.clientX - el.offsetWidth / 2,
y: e.clientY - el.offsetHeight / 2,
})
+ flush()
beginDrag(e)
moved = true
}
@@ -693,15 +701,15 @@ export const Trigger = (props: {
// Runs on going floating and on coming back from an edge dock. Reads
// settings untracked so this only runs on mode/ref/dock changes.
- createEffect(() => {
- if (!isFloating() || dockedEdge()) return
- const el = buttonRef()
- if (!el) return
- untrack(() => placeFromSettings(el))
- })
+ createEffect(
+ () => (isFloating() && !dockedEdge() ? buttonRef() : undefined),
+ (el) => {
+ if (el) untrack(() => placeFromSettings(el))
+ },
+ )
- createEffect(() => {
- if (!isFloating()) return
+ createEffect(isFloating, (floating) => {
+ if (!floating) return
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape' && cancelGesture()) event.stopPropagation()
if (event.altKey && event.key.toLowerCase() === 'm') {
@@ -710,20 +718,22 @@ export const Trigger = (props: {
}
}
window.addEventListener('keydown', onKeyDown)
- onCleanup(() => window.removeEventListener('keydown', onKeyDown))
+ return () => window.removeEventListener('keydown', onKeyDown)
})
// Keep the trigger at the same relative spot when the window is resized.
- createEffect(() => {
- if (!isFloating()) return
+ createEffect(isFloating, (floating) => {
+ if (!floating) return
const onResize = () => {
if (dockedEdge()) return
const el = buttonRef()
// A drag or throw in flight owns the position; it persists when it ends.
- if (el && !dragging && raf === undefined) placeFromSettings(el)
+ if (el && !dragging && raf === undefined) {
+ untrack(() => placeFromSettings(el))
+ }
}
window.addEventListener('resize', onResize)
- onCleanup(() => window.removeEventListener('resize', onResize))
+ return () => window.removeEventListener('resize', onResize)
})
onCleanup(() => {
@@ -732,15 +742,16 @@ export const Trigger = (props: {
hideTooltip()
})
- createEffect(() => {
- const triggerComponent = settings().customTrigger
- const el = containerRef()
- if (triggerComponent && el) {
- triggerComponent(el, {
- theme: settings().theme,
- })
- }
- })
+ createEffect(
+ () => ({
+ triggerComponent: settings().customTrigger,
+ el: containerRef(),
+ theme: settings().theme,
+ }),
+ ({ triggerComponent, el, theme }) => {
+ if (triggerComponent && el) triggerComponent(el, { theme })
+ },
+ )
return (
@@ -754,8 +765,8 @@ export const Trigger = (props: {
type="button"
data-tsd-control
aria-label="Open TanStack Devtools (docked)"
- aria-hidden={dockedEdge() ? undefined : true}
- tabIndex={dockedEdge() ? undefined : -1}
+ aria-hidden={dockedEdge() ? undefined : 'true'}
+ tabindex={dockedEdge() ? undefined : -1}
class={clsx(
styles().triggerEdgeTab(
edge(),
@@ -769,10 +780,8 @@ export const Trigger = (props: {
dockedEdge() ? () => props.setIsOpen(!props.isOpen()) : undefined
}
onPointerDown={onTabPointerDown}
- // Native, not delegated: Solid's document-level pointermove handler
- // leaves event.currentTarget on for every later listener,
- // which breaks libraries such as react-resizable-panels.
- on:pointermove={onTabPointerMove}
+ // Native, not delegated, see `nativeListener`.
+ ref={nativeListener('pointermove', onTabPointerMove)}
onPointerUp={onTabPointerUp}
onPointerCancel={onTabPointerUp}
>
@@ -800,7 +809,7 @@ export const Trigger = (props: {
)}