@tanstack/devtools 0.6.24 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk/{XF4JFOLU.js → G64KXXVZ.js} +34 -11
- package/dist/dev.js +3 -3
- package/dist/devtools/{UUNAZSBD.js → MYTOQ6G4.js} +79 -51
- package/dist/devtools/{OBIHU6L6.js → RHZRAMXS.js} +72 -49
- package/dist/index.d.ts +15 -5
- package/dist/index.js +3 -3
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/src/components/trigger.tsx +22 -10
- package/src/context/devtools-context.test.ts +268 -1
- package/src/context/devtools-context.tsx +29 -9
- package/src/context/devtools-store.ts +12 -6
- package/src/context/use-devtools-context.ts +2 -1
- package/src/devtools.tsx +27 -8
- package/src/tabs/settings-tab.tsx +1 -7
- package/src/utils/constants.ts +4 -0
- package/src/utils/get-default-active-plugins.test.ts +194 -0
- package/src/utils/get-default-active-plugins.ts +36 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MAX_ACTIVE_PLUGINS } from './constants'
|
|
2
|
+
|
|
3
|
+
export interface PluginWithId {
|
|
4
|
+
id: string
|
|
5
|
+
defaultOpen?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Determines which plugins should be active by default when no plugins are currently active.
|
|
10
|
+
*
|
|
11
|
+
* Rules:
|
|
12
|
+
* 1. If there's only 1 plugin, activate it automatically
|
|
13
|
+
* 2. If there are multiple plugins, activate those with defaultOpen: true (up to MAX_ACTIVE_PLUGINS limit)
|
|
14
|
+
* 3. If no plugins have defaultOpen: true, return empty array
|
|
15
|
+
*
|
|
16
|
+
* @param plugins - Array of plugins with IDs
|
|
17
|
+
* @returns Array of plugin IDs that should be active by default
|
|
18
|
+
*/
|
|
19
|
+
export function getDefaultActivePlugins(
|
|
20
|
+
plugins: Array<PluginWithId>,
|
|
21
|
+
): Array<string> {
|
|
22
|
+
if (plugins.length === 0) {
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// If there's only 1 plugin, activate it automatically
|
|
27
|
+
if (plugins.length === 1) {
|
|
28
|
+
return [plugins[0]!.id]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Otherwise, activate plugins with defaultOpen: true (up to the limit)
|
|
32
|
+
return plugins
|
|
33
|
+
.filter((plugin) => plugin.defaultOpen === true)
|
|
34
|
+
.slice(0, MAX_ACTIVE_PLUGINS)
|
|
35
|
+
.map((plugin) => plugin.id)
|
|
36
|
+
}
|