@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.
@@ -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
+ }