Skip to content

Commit b9047a2

Browse files
AlemTuzlakautofix-ci[bot]KevinVandy
authored
feat: add initial setup for devtools (#53)
* feat: add initial setup for devtools * ci: apply automated fixes * chore: fix test issues * ci: apply automated fixes * chore:fix render issue * ci: apply automated fixes * feat: drastically improve the pacer devtools UI * ci: apply automated fixes * chore: remove built-in tree in favor of devtools/ui * ci: apply automated fixes * refactor to key * ci: apply automated fixes * rename devtool packages to be consistent with query devtool package names * fix sherif * separate left and right panels of devtools * denser ui * better right panel, emit entire instance * add some action buttons to devtools that kind of work * event bus goes both ways * all utils listen to devtools * remove console log * ci: apply automated fixes * break up devtools components * chore: improve the event listening/emitting * ci: apply automated fixes * fix action buttons and add reduction stat * ci: apply automated fixes * fix reactivity issues * add devtools docs and exclude from production builds * fix: utils shouldn't listen to other instances with different key * start to add a few solid devtools to examples * fix devtool versions * fix solid devtools * remove unnecessary public _emit * update guides --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Kevin Van Cott <[email protected]>
1 parent be21dea commit b9047a2

File tree

186 files changed

+5048
-1445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+5048
-1445
lines changed

docs/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
{
2121
"label": "Installation",
2222
"to": "installation"
23+
},
24+
{
25+
"label": "Devtools",
26+
"to": "devtools"
2327
}
2428
],
2529
"frameworks": [

docs/devtools.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Devtools
3+
id: devtools
4+
---
5+
6+
What? My debouncer can have dedicated devtools? Yep!
7+
8+
TanStack Pacer provides devtools for debugging and monitoring all your utilities in real-time. The devtools integrate seamlessly within the new [TanStack Devtools](https://tanstack.com/devtools) multi-panel UI.
9+
10+
> [!NOTE] By default, the TanStack Devtools and TanStack Pacer Devtools will only be included in development mode. This helps keep your production bundle size minimal. If you need to include devtools in production builds (e.g., for debugging production issues), you can use the alternative "production" imports.
11+
12+
## Installation
13+
14+
Install the devtools packages for your framework:
15+
16+
### React
17+
18+
```sh
19+
npm install @tanstack/react-devtools @tanstack/react-pacer-devtools
20+
```
21+
22+
### Solid
23+
24+
```sh
25+
npm install @tanstack/solid-devtools @tanstack/solid-pacer-devtools
26+
```
27+
28+
## Basic Setup
29+
30+
### React Setup
31+
32+
```tsx
33+
import { TanStackDevtools } from '@tanstack/react-devtools'
34+
import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools'
35+
36+
function App() {
37+
return (
38+
<div>
39+
{/* Your app content */}
40+
41+
<TanStackDevtools
42+
eventBusConfig={{
43+
debug: false,
44+
}}
45+
plugins={[{ name: 'TanStack Pacer', render: <PacerDevtoolsPanel /> }]}
46+
/>
47+
</div>
48+
)
49+
}
50+
```
51+
52+
### Solid Setup
53+
54+
```tsx
55+
import { TanStackDevtools } from '@tanstack/solid-devtools'
56+
import { PacerDevtoolsPanel } from '@tanstack/solid-pacer-devtools'
57+
58+
function App() {
59+
return (
60+
<div>
61+
{/* Your app content */}
62+
63+
<TanStackDevtools
64+
eventBusConfig={{
65+
debug: false,
66+
}}
67+
plugins={[{ name: 'TanStack Pacer', render: <PacerDevtoolsPanel /> }]}
68+
/>
69+
</div>
70+
)
71+
}
72+
```
73+
74+
## Production Builds
75+
76+
By default, devtools are excluded from production builds to minimize bundle size. The default imports will return no-op implementations in production:
77+
78+
```tsx
79+
// This will be a no-op in production builds
80+
import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools'
81+
```
82+
83+
If you need to include devtools in production builds (e.g., for debugging production issues), use the production-specific imports:
84+
85+
```tsx
86+
// This will include full devtools even in production builds
87+
import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools/production'
88+
```
89+
90+
## Registering Utilities
91+
92+
Each utility should automatically be detected and displayed in the devtools. However, if you don't provide a `key` option to the utility, it will show with a uuid for its name. Give it an identifiable name with the `key` option.
93+
94+
```tsx
95+
const debouncer = new Debouncer(myDebounceFn, {
96+
key: 'My Debouncer', // friendly name for the utility instead of auto-generated uuid
97+
wait: 1000,
98+
})
99+
```

docs/guides/async-debouncing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ The `AsyncDebouncerState` includes:
200200
- `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
201201
- `lastArgs`: The arguments from the most recent call to `maybeExecute`
202202
- `lastResult`: The result from the most recent successful function execution
203+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
203204
- `settleCount`: Number of function executions that have completed (either successfully or with errors)
204205
- `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
205206
- `successCount`: Number of function executions that have completed successfully

docs/guides/async-queuing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ const queue = new AsyncQueuer(
9696
{
9797
concurrency: 2, // Process 2 items at once
9898
wait: 1000, // Wait 1 second between starting new items
99-
started: true // Start processing immediately
99+
started: true, // Start processing immediately
100+
key: 'data-processor' // Identify this queuer in devtools
100101
}
101102
)
102103

@@ -325,6 +326,7 @@ unsubscribe()
325326
The `AsyncQueuerState` includes all properties from the core queuing guide plus:
326327

327328
- `activeItems`: Array of items currently being processed
329+
- `addItemCount`: Number of times addItem has been called (for reduction calculations)
328330
- `errorCount`: Number of function executions that have resulted in errors
329331
- `expirationCount`: Number of items that have been removed from the queue due to expiration
330332
- `isEmpty`: Whether the queuer has no items to process (items array is empty)

docs/guides/async-rate-limiting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ The `AsyncRateLimiterState` includes:
187187
- `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
188188
- `isExecuting`: Whether the rate-limited function is currently executing asynchronously
189189
- `lastResult`: The result from the most recent successful function execution
190+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
190191
- `rejectionCount`: Number of function executions that have been rejected due to rate limiting
191192
- `settledCount`: Number of function executions that have completed (either successfully or with errors)
192193
- `status`: Current execution status ('disabled' | 'exceeded' | 'idle')

docs/guides/async-throttling.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ The `AsyncThrottlerState` includes:
201201
- `lastArgs`: The arguments from the most recent call to `maybeExecute`
202202
- `lastExecutionTime`: Timestamp of the last function execution in milliseconds
203203
- `lastResult`: The result from the most recent successful function execution
204+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
204205
- `nextExecutionTime`: Timestamp when the next execution can occur in milliseconds
205206
- `settleCount`: Number of function executions that have completed (either successfully or with errors)
206207
- `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')

docs/guides/debouncing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ const initialState = savedState ? JSON.parse(savedState) : {}
243243

244244
const debouncer = new Debouncer(fn, {
245245
wait: 500,
246+
key: 'search-debouncer',
246247
initialState
247248
})
248249
```
@@ -273,6 +274,7 @@ The `DebouncerState` includes:
273274
- `executionCount`: Number of function executions that have been completed
274275
- `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
275276
- `lastArgs`: The arguments from the most recent call to `maybeExecute`
277+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
276278
- `status`: Current execution status ('disabled' | 'idle' | 'pending')
277279

278280
## Framework Adapters

docs/guides/queuing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ unsubscribe()
473473

474474
The `QueuerState` includes:
475475

476+
- `addItemCount`: Number of times addItem has been called (for reduction calculations)
476477
- `executionCount`: Number of items that have been processed by the queuer
477478
- `expirationCount`: Number of items that have been removed from the queue due to expiration
478479
- `isEmpty`: Whether the queuer has no items to process (items array is empty)

docs/guides/rate-limiting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ The `RateLimiterState` includes:
292292
- `executionCount`: Number of function executions that have been completed
293293
- `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
294294
- `isExceeded`: Whether the rate limiter has exceeded the limit
295+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
295296
- `rejectionCount`: Number of function executions that have been rejected due to rate limiting
296297
- `status`: Current execution status ('disabled' | 'exceeded' | 'idle')
297298

docs/guides/throttling.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ The `ThrottlerState` includes:
264264
- `isPending`: Whether the throttler is waiting for the timeout to trigger execution
265265
- `lastArgs`: The arguments from the most recent call to `maybeExecute`
266266
- `lastExecutionTime`: Timestamp of the last function execution in milliseconds
267+
- `maybeExecuteCount`: Number of times `maybeExecute` has been called
267268
- `nextExecutionTime`: Timestamp when the next execution can occur in milliseconds
268269
- `status`: Current execution status ('disabled' | 'idle' | 'pending')
269270

0 commit comments

Comments
 (0)