@gridkit/devtools
v0.1.0
Published
Browser DevTools extension for debugging GridKit Enhanced tables
Maintainers
Readme
@gridkit/devtools
Browser DevTools extension for debugging GridKit Enhanced tables.
Features
- Table Inspector: View table state, columns, and rows
- Event Timeline: Interactive event log with filtering
- Performance Monitor: Real-time performance metrics
- Time Travel: UI controls for time-travel debugging
- State Diff Viewer: Visual state comparison
- Memory Profiler: Memory usage and leak detection
- Plugin Inspector: View loaded plugins and their state
Installation
Browser Extension
- Clone the GridKit repository
- Build the extension:
pnpm build:extension - Load the extension in your browser:
- Chrome: Go to
chrome://extensions/, enable Developer mode, and load theextension-distdirectory - Firefox: Go to
about:debugging, click "This Firefox", and load the temporary extension - Edge: Go to
edge://extensions/, enable Developer mode, and load theextension-distdirectory
Note: The built extension is located in
packages/devtools/extension-dist/after runningpnpm build:extension - Chrome: Go to
Package Installation
npm install @gridkit/devtoolsUsage
Automatic Integration
The DevTools extension automatically detects GridKit tables on the page.
Manual Integration
import { useGridEnhancedTable } from '@gridkit/core'
import { useDevToolsTable } from '@gridkit/devtools'
const table = useGridEnhancedTable({
data,
columns,
debug: {
devtools: true // Enable DevTools connection
}
})
// Automatically register with DevTools
useDevToolsTable(table)Manual Table Registration
import { devToolsBackend } from '@gridkit/devtools'
const table = createTable({ data, columns })
// Register table with DevTools
devToolsBackend.registerTable(table)
// Unregister when done
devToolsBackend.unregisterTable(table)Browser Compatibility
| Browser | Version | Status | |---------|---------|--------| | Chrome | 90+ | ✅ Primary | | Firefox | 88+ | ✅ Supported | | Edge | 90+ | ✅ Supported | | Safari | 14+ | ⚠️ Limited (WebExtension API) |
Development
Build the Extension
cd packages/devtools
pnpm build:extensionBuild the Package
cd packages/devtools
pnpm buildRun in Development Mode
cd packages/devtools
pnpm devAPI
devToolsBackend
Global instance of DevToolsBackend for table registration.
Methods
registerTable(table): Register a table with DevToolsunregisterTable(table): Unregister a tablegetTables(): Get all registered tablesgetTable(tableId): Get a specific table by ID
devToolsBridge
Communication bridge between backend and DevTools panel.
Methods
send(message): Send a message to DevToolssendCommand(command): Send a command and wait for responseonCommand(type, handler): Register a command handleronResponse(handler): Register a response handlerdisconnect(): Disconnect from DevTools
Hooks
useDevToolsTable(table, enabled)
React hook to automatically register a table with DevTools.
table: The GridKit table instanceenabled: Whether DevTools integration is enabled (default: true)
useAutoDetectDevTools(enabled)
React hook to automatically detect and register GridKit tables.
enabled: Whether auto-detection is enabled (default: true)
Extension Structure
packages/devtools/
├── extension/
│ ├── manifest.json # Browser extension manifest
│ ├── background.js # Background script
│ ├── content.js # Content script (injected)
│ ├── devtools.html # DevTools panel HTML
│ ├── devtools.js # DevTools panel script
│ ├── panel/ # DevTools panel UI
│ │ ├── index.html
│ │ ├── index.tsx
│ │ ├── components/
│ │ │ ├── TableInspector.tsx
│ │ │ ├── EventTimeline.tsx
│ │ │ ├── PerformanceMonitor.tsx
│ │ │ ├── TimeTravelControls.tsx
│ │ │ ├── StateDiffViewer.tsx
│ │ │ ├── MemoryProfiler.tsx
│ │ │ └── PluginInspector.tsx
│ │ └── styles/
│ ├── icons/ # Extension icons
│ └── assets/
├── bridge/ # Communication bridge
│ ├── DevToolsBridge.ts # Core bridge
│ ├── messages.ts # Message types
│ └── protocol.ts # Communication protocol
├── backend/ # Table integration
│ ├── DevToolsBackend.ts # Backend API
│ ├── detector.ts # Table detection
│ └── hooks.ts # Integration hooks
├── src/
│ └── index.ts # Package entry point
├── package.json
├── tsconfig.json
└── webpack.config.jsCommunication Protocol
The extension uses a message-based communication protocol between the content script, background script, and DevTools panel.
Message Types
BACKEND_READY: Backend is ready to accept connectionsCONTENT_READY: Content script is readyCOMMAND: Command from DevTools panelRESPONSE: Response to a commandTABLE_REGISTERED: New table registeredTABLE_UNREGISTERED: Table unregisteredSTATE_UPDATE: State changeEVENT_LOGGED: Event loggedPERFORMANCE_UPDATE: Performance metrics updateMEMORY_UPDATE: Memory usage update
Security
- All messages are validated before processing
- No external network requests
- No data collection or telemetry
- Respects Content Security Policy
License
MIT
