-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[WIP] feat: add start devtools #5247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlemTuzlak
wants to merge
20
commits into
TanStack:main
Choose a base branch
from
AlemTuzlak:feat/devtools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b961381
feat: add start devtools
AlemTuzlak 2599dc3
Update packages/solid-start-devtools/package.json
AlemTuzlak 7c3ad0c
Update packages/start-devtools/package.json
AlemTuzlak 31f11bb
Update packages/react-start-devtools/package.json
AlemTuzlak 50bbb01
fix small issues
AlemTuzlak ebb82f0
Merge branch 'feat/devtools' of https://github.com/AlemTuzlak/router …
AlemTuzlak dac6459
add initial request interceptor util for devtools
AlemTuzlak c14f481
Merge branch 'main' into feat/devtools
AlemTuzlak dbbc347
feat(start-devtools): rewrite StartEventMap with 12 event types for f…
AlemTuzlak 41a3c0a
feat(start-devtools): add requestId, requestStartTime, eventClient to…
AlemTuzlak 00b3249
feat(start-devtools): add instrumentMiddlewareArray helper with tests
AlemTuzlak 49a4701
feat(start-devtools): instrument createStartHandler with full request…
AlemTuzlak 9c67928
feat(start-devtools): add server function lifecycle, serialization, a…
AlemTuzlak 70b3813
feat(start-devtools): add cross-package middleware-executed event for…
AlemTuzlak e271c73
feat(start-devtools): add reactive request store with event processin…
AlemTuzlak 3d39223
feat(start-devtools): add UI components - WaterfallBar, FilterBar, Re…
AlemTuzlak ed3c052
feat(start-devtools): rewrite panel with waterfall timeline, filters,…
AlemTuzlak 866759a
chore: format
AlemTuzlak 1f09649
fix(start-devtools): address code review findings
AlemTuzlak 8462118
feat(start-devtools): Chrome DevTools-style network panel redesign
AlemTuzlak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { createStart, createMiddleware } from '@tanstack/react-start' | ||
|
|
||
| export const requestLoggingMiddleware = createMiddleware().server( | ||
| async ({ next, pathname }) => { | ||
| const start = performance.now() | ||
| console.log(`[request] → ${pathname}`) | ||
|
|
||
| const result = await next({ | ||
| context: { | ||
| requestStartTime: start, | ||
| requestPathname: pathname, | ||
| }, | ||
| }) | ||
|
|
||
| const duration = performance.now() - start | ||
| console.log(`[request] ← ${pathname} (${duration.toFixed(1)}ms)`) | ||
|
|
||
| return result | ||
| }, | ||
| ) | ||
|
|
||
| export const rateLimitMiddleware = createMiddleware().server( | ||
| async ({ next }) => { | ||
| return next({ | ||
| context: { | ||
| rateLimited: false, | ||
| }, | ||
| }) | ||
| }, | ||
| ) | ||
|
|
||
| export const globalFunctionMiddleware = createMiddleware({ | ||
| type: 'function', | ||
| }).server(async ({ next }) => { | ||
| const start = performance.now() | ||
|
|
||
| const result = await next({ | ||
| context: { | ||
| globalFnMiddlewareApplied: true, | ||
| }, | ||
| }) | ||
|
|
||
| const duration = performance.now() - start | ||
| console.log(`[global-fn-middleware] executed in ${duration.toFixed(1)}ms`) | ||
|
|
||
| return result | ||
| }) | ||
|
|
||
| export const startInstance = createStart(() => ({ | ||
| requestMiddleware: [requestLoggingMiddleware, rateLimitMiddleware], | ||
| functionMiddleware: [globalFunctionMiddleware], | ||
| })) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // @ts-check | ||
|
|
||
| import pluginReact from '@eslint-react/eslint-plugin' | ||
| import pluginReactCompiler from 'eslint-plugin-react-compiler' | ||
| import pluginReactHooks from 'eslint-plugin-react-hooks' | ||
| import rootConfig from '../../eslint.config.js' | ||
|
|
||
| export default [ | ||
| ...rootConfig, | ||
| { | ||
| files: ['**/*.{ts,tsx}'], | ||
| ...pluginReact.configs.recommended, | ||
| }, | ||
| { | ||
| plugins: { | ||
| 'react-hooks': pluginReactHooks, | ||
| 'react-compiler': pluginReactCompiler, | ||
| }, | ||
| rules: { | ||
| '@eslint-react/dom/no-missing-button-type': 'off', | ||
| 'react-compiler/react-compiler': 'error', | ||
| 'react-hooks/exhaustive-deps': 'error', | ||
| 'react-hooks/rules-of-hooks': 'error', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/__tests__/**'], | ||
| rules: { | ||
| // 'react-compiler/react-compiler': 'off', | ||
| }, | ||
| }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "name": "@tanstack/react-start-devtools", | ||
| "version": "0.0.1", | ||
| "description": "React adapter for devtools for Start.", | ||
| "author": "Tanner Linsley", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/TanStack/router.git", | ||
| "directory": "packages/react-start-devtools" | ||
| }, | ||
|
AlemTuzlak marked this conversation as resolved.
|
||
| "homepage": "https://tanstack.com/start", | ||
| "funding": { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/tannerlinsley" | ||
| }, | ||
| "keywords": [], | ||
| "type": "module", | ||
| "types": "dist/esm/index.d.ts", | ||
| "module": "dist/esm/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "default": "./dist/esm/index.js" | ||
| } | ||
| }, | ||
| "./production": { | ||
| "import": { | ||
| "types": "./dist/esm/production.d.ts", | ||
| "default": "./dist/esm/production.js" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "sideEffects": false, | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "files": [ | ||
| "dist/", | ||
| "src" | ||
| ], | ||
| "scripts": { | ||
| "clean": "rimraf ./build ./dist", | ||
| "lint:fix": "eslint ./src --fix", | ||
| "test:eslint": "eslint ./src", | ||
| "test:lib": "vitest", | ||
| "test:lib:dev": "pnpm test:lib --watch", | ||
| "test:types": "tsc", | ||
| "test:build": "publint --strict", | ||
| "build": "vite build" | ||
| }, | ||
| "peerDependencies": { | ||
| "@types/react": ">=16.8", | ||
| "@types/react-dom": ">=16.8", | ||
| "react": ">=16.8", | ||
| "react-dom": ">=16.8" | ||
| }, | ||
| "dependencies": { | ||
| "@tanstack/devtools-utils": "^0.0.3", | ||
| "@tanstack/start-devtools": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint-react/eslint-plugin": "^1.53.1", | ||
| "@vitejs/plugin-react": "^5.0.2", | ||
| "eslint-plugin-react-compiler": "19.1.0-rc.2", | ||
| "eslint-plugin-react-hooks": "^5.2.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| import { createReactPanel } from '@tanstack/devtools-utils/react' | ||
| import { StartDevtoolsCore } from "@tanstack/start-devtools" | ||
| import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/react'; | ||
|
|
||
| export interface StartDevtoolsReactInit extends DevtoolsPanelProps { } | ||
|
|
||
| const [StartDevtoolsPanel, StartDevtoolsPanelNoOp] = createReactPanel(StartDevtoolsCore) | ||
|
|
||
| export { StartDevtoolsPanel, StartDevtoolsPanelNoOp } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 'use client' | ||
|
|
||
| import * as Devtools from './ReactStartDevtools' | ||
| import * as plugin from './plugin' | ||
|
|
||
| export const StartDevtoolsPanel = | ||
| process.env.NODE_ENV !== 'development' | ||
| ? Devtools.StartDevtoolsPanelNoOp | ||
| : Devtools.StartDevtoolsPanel | ||
|
|
||
| export const startDevtoolsPlugin = | ||
| process.env.NODE_ENV !== 'development' | ||
| ? plugin.startDevtoolsNoOpPlugin | ||
| : plugin.startDevtoolsPlugin | ||
|
|
||
| export type { StartDevtoolsReactInit } from './ReactStartDevtools' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { createReactPlugin } from '@tanstack/devtools-utils/react' | ||
| import { StartDevtoolsPanel } from './ReactStartDevtools' | ||
|
|
||
| const [startDevtoolsPlugin, startDevtoolsNoOpPlugin] = createReactPlugin("TanStack Start", StartDevtoolsPanel) | ||
|
|
||
| export { startDevtoolsPlugin, startDevtoolsNoOpPlugin } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 'use client' | ||
|
|
||
| export { StartDevtoolsPanel } from './ReactStartDevtools' | ||
|
|
||
| export type { StartDevtoolsReactInit } from './ReactStartDevtools' | ||
|
|
||
| export { startDevtoolsPlugin } from './plugin' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| describe('test suite', () => { | ||
| it('should work', () => { | ||
| expect(true).toBe(true) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import '@testing-library/jest-dom/vitest' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "include": ["tests", "src"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "include": ["src", "eslint.config.js", "vite.config.ts", "tests"], | ||
| "compilerOptions": { | ||
| "jsx": "react" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { defineConfig, mergeConfig } from 'vitest/config' | ||
| import { tanstackViteConfig } from '@tanstack/config/vite' | ||
| import react from '@vitejs/plugin-react' | ||
| import packageJson from './package.json' | ||
|
|
||
| const config = defineConfig({ | ||
| plugins: [react()], | ||
| test: { | ||
| name: packageJson.name, | ||
| dir: './', | ||
| watch: false, | ||
| environment: 'jsdom', | ||
| setupFiles: ['./tests/test-setup.ts'], | ||
| globals: true, | ||
| }, | ||
| }) | ||
|
|
||
| export default mergeConfig( | ||
| config, | ||
| tanstackViteConfig({ | ||
| entry: ['./src/index.ts', './src/production.ts'], | ||
| srcDir: './src', | ||
| cjs: false, | ||
| }), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // @ts-check | ||
|
|
||
| import rootConfig from '../../eslint.config.js' | ||
|
|
||
| export default [ | ||
| ...rootConfig, | ||
| { | ||
| rules: {}, | ||
| }, | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.