@altafusion/fugue-devtools 0.5.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @altafusion/fugue-devtools
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ae2d33b: Make `DevToolsPanel` self-contained: mount `<DevToolsPanel />` once and it owns its open state, shows a draggable dock, and opens the drawer on `?qetools` (the new default `openParams`; `?qetools=off` turns it off). Sections now register through `useDevTools().registerSection()` or `nuxtApp.$fugueDevtools`, each `public` or `privileged`, with a reactive `setAccessResolver`. `@altafusion/fugue-content` registers its Studio drafts as a privileged section when fugue-devtools is installed.
8
+
9
+ ### Patch Changes
10
+
11
+ - 0a61dc0: Order the dev tools drawer header controls, left to right, as turn off (a circle-off icon), the four dock positions, then close.
12
+ - 0a61dc0: Show real tooltips (Nuxt UI `UTooltip`, above the drawer) on the dev tools header buttons and the toggle button, instead of the browser's slow native `title`.
13
+ - 39ccb17: Show the dev tools drawer's turn-off control as a circled X, after the close button (it was a power icon before it).
14
+ - Updated dependencies [e07bde1]
15
+ - @altafusion/fugue-ui@0.6.0
16
+
3
17
  ## 0.5.0
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -16,20 +16,57 @@ Optionally extend **`@altafusion/fugue-theme`** alongside Fugue layers. **`@nuxt
16
16
  ```ts
17
17
  export default defineNuxtConfig({
18
18
  extends: ['@altafusion/fugue-theme', '@altafusion/fugue-devtools'],
19
- runtimeConfig: {
20
- public: {
21
- fugueDevtools: {
22
- openParams: ['devtools'],
23
- innerToggleParams: ['devtoolstoggle'],
24
- },
25
- },
26
- },
27
19
  })
28
20
  ```
29
21
 
30
- Components auto-import from **`components/DevTools/`**: **`DevToolsPanel`**, **`DevToolsNav`**, **`DevToolsSection`**, **`DevToolsToggleButton`**.
22
+ Mount the panel once and it works alone. No props, no open state, no toggle button:
31
23
 
32
- Composables: **`useDevTools()`** (chrome: open, dock position) — register via the layer plugin or a project adapter that merges domain state.
24
+ ```vue
25
+ <template>
26
+ <UApp>
27
+ <NuxtPage />
28
+ <DevToolsPanel />
29
+ </UApp>
30
+ </template>
31
+ ```
32
+
33
+ Add **`?qetools`** to any URL. That turns the dev tools on and opens the drawer, and it stays on (localStorage) across navigation and reloads. **`?qetools=off`** turns them off. The drawer header has close (keeps the dock) and turn off (removes the dock, resets the saved state; only the param brings it back). The dock is draggable and the drawer can sit on any side. The default is the bottom, dock bottom-right.
34
+
35
+ Config (`runtimeConfig.public.fugueDevtools`): `openParams` (default `['qetools']`), `innerToggleParams`, `persistNamespace`, `persistKey`, `defaultPosition` (`'bottom'`).
36
+
37
+ ### Sections: registry first
38
+
39
+ ```ts
40
+ // a plugin in your site or layer (no import of this package needed)
41
+ export default defineNuxtPlugin((nuxtApp) => {
42
+ nuxtApp.hook('app:created', () => {
43
+ nuxtApp.$fugueDevtools?.registerSection({
44
+ id: 'my-section',
45
+ label: 'My section',
46
+ component: MySection,
47
+ access: 'public', // or 'privileged' (the default)
48
+ })
49
+ })
50
+ })
51
+ ```
52
+
53
+ Register in `app:created` so the order of layers does not matter. `registerSection` returns an unregister function; registering the same `id` again replaces it. `@altafusion/fugue-content` registers its Studio drafts this way, as a privileged section.
54
+
55
+ ### Access
56
+
57
+ - `public` sections show to anyone who opened the drawer. Keep them to troubleshooting (the built-in **Diagnostics** is one).
58
+ - `privileged` sections (the default) need `useDevTools().setAccessResolver(() => boolean)`. It is reactive (read your session inside it), and until it returns `true` the section is hidden, not greyed out. Without a resolver, privileged sections show in development only.
59
+ - The gate is a convenience for the UI, **not a security boundary**. A privileged section must only do what the user could already do (local browser data, or API calls the server authorizes).
60
+
61
+ ### Slots
62
+
63
+ `DevToolsPanel` slots are the second path: `dock` (replace the toggle; receives `open` and `toggle`), `header`, `section-<id>` (override how one section renders), the default slot (extra inline content, use `DevToolsSection`) and `footer`.
64
+
65
+ Not a Nuxt DevTools tab (out of scope for now). The registry does not depend on the UI, so a module could list the same sections later.
66
+
67
+ Composables: **`useDevTools()`** (chrome: enabled, open, dock position; the section registry).
68
+
69
+ Try it in the theme playground: `pnpm play:theme`, then open `http://localhost:7010/?qetools`.
33
70
 
34
71
  ## Component naming
35
72
 
@@ -0,0 +1,66 @@
1
+ <script setup lang="ts">
2
+ /** Built-in public section: safe for any visitor to see, and handy to paste into a bug report. */
3
+ const route = useRoute()
4
+ const colorMode = useColorMode()
5
+ const api = useDevTools()
6
+ const width = ref(window.innerWidth)
7
+ const height = ref(window.innerHeight)
8
+
9
+ function measure() {
10
+ width.value = window.innerWidth
11
+ height.value = window.innerHeight
12
+ }
13
+
14
+ onMounted(() => window.addEventListener('resize', measure))
15
+ onBeforeUnmount(() => window.removeEventListener('resize', measure))
16
+
17
+ const rows = computed(() => ({
18
+ url: route.fullPath,
19
+ viewport: `${width.value}x${height.value}`,
20
+ theme: colorMode.value,
21
+ language: navigator.language,
22
+ userAgent: navigator.userAgent,
23
+ }))
24
+
25
+ const copied = ref(false)
26
+
27
+ async function copy() {
28
+ await navigator.clipboard.writeText(JSON.stringify(rows.value, null, 2))
29
+ copied.value = true
30
+ setTimeout(() => (copied.value = false), 1500)
31
+ }
32
+ </script>
33
+
34
+ <template>
35
+ <div class="space-y-2 text-sm">
36
+ <dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1">
37
+ <template
38
+ v-for="(value, key) in rows"
39
+ :key="key"
40
+ >
41
+ <dt class="text-muted">
42
+ {{ key }}
43
+ </dt>
44
+ <dd class="break-all font-mono text-xs">
45
+ {{ value }}
46
+ </dd>
47
+ </template>
48
+ </dl>
49
+ <div class="flex gap-2">
50
+ <UButton
51
+ :label="copied ? 'Copied' : 'Copy diagnostics'"
52
+ size="xs"
53
+ color="neutral"
54
+ variant="soft"
55
+ @click="copy"
56
+ />
57
+ <UButton
58
+ label="Turn off dev tools"
59
+ size="xs"
60
+ color="neutral"
61
+ variant="ghost"
62
+ @click="api.disable()"
63
+ />
64
+ </div>
65
+ </div>
66
+ </template>
@@ -15,6 +15,7 @@ const emit = defineEmits<{
15
15
  positionChange: [pos: DevToolsPanelPosition]
16
16
  settingsToggle: []
17
17
  close: []
18
+ turnOff: []
18
19
  }>()
19
20
 
20
21
  const dockOptions: { pos: DevToolsPanelPosition, icon: string, label: string }[] = [
@@ -23,6 +24,9 @@ const dockOptions: { pos: DevToolsPanelPosition, icon: string, label: string }[]
23
24
  { pos: 'bottom', icon: 'i-lucide-panel-bottom', label: 'Dock bottom' },
24
25
  { pos: 'left', icon: 'i-lucide-panel-left', label: 'Dock left' },
25
26
  ]
27
+
28
+ // The drawer is z-50 and the tooltip theme sets no z-index, so without this the tooltip would open underneath it.
29
+ const tooltipUi = { content: 'z-[60]' }
26
30
  </script>
27
31
 
28
32
  <template>
@@ -33,39 +37,66 @@ const dockOptions: { pos: DevToolsPanelPosition, icon: string, label: string }[]
33
37
  {{ brand }}
34
38
  </slot>
35
39
  </span>
36
- <UButton
40
+ <UTooltip
37
41
  v-if="showSettingsToggle"
38
- icon="i-lucide-settings"
39
- color="primary"
40
- variant="ghost"
41
- size="xs"
42
- aria-label="Toggle dev tools settings"
43
- @click="emit('settingsToggle')"
44
- />
42
+ text="Toggle dev tools settings"
43
+ :ui="tooltipUi"
44
+ >
45
+ <UButton
46
+ icon="i-lucide-settings"
47
+ color="primary"
48
+ variant="ghost"
49
+ size="xs"
50
+ aria-label="Toggle dev tools settings"
51
+ @click="emit('settingsToggle')"
52
+ />
53
+ </UTooltip>
45
54
  </div>
46
55
 
47
56
  <div class="flex shrink-0 items-center gap-x-0.5">
48
- <UButton
57
+ <UTooltip
58
+ text="Turn off Devtools"
59
+ :ui="tooltipUi"
60
+ >
61
+ <UButton
62
+ icon="i-lucide-circle-off"
63
+ color="neutral"
64
+ variant="ghost"
65
+ size="xs"
66
+ data-testid="devtools-panel-turn-off"
67
+ aria-label="Turn off dev tools"
68
+ @click="emit('turnOff')"
69
+ />
70
+ </UTooltip>
71
+ <UTooltip
49
72
  v-for="{ pos, icon, label } in dockOptions"
50
73
  :key="pos"
51
- :icon="icon"
52
- :color="panelPosition === pos ? 'primary' : 'neutral'"
53
- variant="ghost"
54
- size="xs"
55
- :aria-label="`Position panel ${pos}`"
56
- :title="label"
57
- @click="emit('positionChange', pos)"
58
- />
59
- <UButton
60
- icon="i-lucide-x"
61
- color="neutral"
62
- variant="ghost"
63
- size="xs"
64
- data-testid="devtools-panel-close"
65
- aria-label="Close dev tools"
66
- title="Close"
67
- @click="emit('close')"
68
- />
74
+ :text="label"
75
+ :ui="tooltipUi"
76
+ >
77
+ <UButton
78
+ :icon="icon"
79
+ :color="panelPosition === pos ? 'primary' : 'neutral'"
80
+ variant="ghost"
81
+ size="xs"
82
+ :aria-label="`Position panel ${pos}`"
83
+ @click="emit('positionChange', pos)"
84
+ />
85
+ </UTooltip>
86
+ <UTooltip
87
+ text="Close"
88
+ :ui="tooltipUi"
89
+ >
90
+ <UButton
91
+ icon="i-lucide-x"
92
+ color="neutral"
93
+ variant="ghost"
94
+ size="xs"
95
+ data-testid="devtools-panel-close"
96
+ aria-label="Close dev tools"
97
+ @click="emit('close')"
98
+ />
99
+ </UTooltip>
69
100
  </div>
70
101
  </div>
71
102
  </template>
@@ -0,0 +1,171 @@
1
+ <script setup lang="ts">
2
+ import type { DevToolsPanelPosition } from '#devtools/composables/devtoolsTypes'
3
+ import { isHorizontalDevToolsDock } from '#devtools/persist'
4
+
5
+ /**
6
+ * The whole dev tools UI. The `.client.vue` suffix keeps it off the server: the API it reads is provided by a client-only plugin. Mount `<DevToolsPanel />` once (app.vue) and it works alone: it reads `useDevTools()`, shows a
7
+ * draggable dock while the tools are enabled, and opens a non-modal drawer with the registered sections.
8
+ *
9
+ * Sections come from `registerSection()` (the way a layer or plugin adds one). Slots are the second path:
10
+ * - `dock`: replace the toggle (receives `open` and `toggle`)
11
+ * - `header`: extra controls in the drawer header
12
+ * - `section-<id>`: override how one registered section renders
13
+ * - default: extra inline content below the active section (use `DevToolsSection`)
14
+ * - `footer`
15
+ */
16
+ const {
17
+ bodyGridClass = '',
18
+ sectionClass = '',
19
+ brand = 'Dev Tools',
20
+ } = defineProps<{
21
+ /** Extra grid classes on the section container (e.g. 3-column bottom dock). */
22
+ bodyGridClass?: string
23
+ /** Extra class on sections passed through `sectionClass` slot prop. */
24
+ sectionClass?: string
25
+ brand?: string
26
+ }>()
27
+
28
+ const api = useDevTools()
29
+ const { chrome, showPanel, visibleSections, activeSection } = api
30
+
31
+ const open = computed({
32
+ get: () => chrome.value.open,
33
+ set: value => api.updateChrome('open', value),
34
+ })
35
+
36
+ const panelPosition = computed<DevToolsPanelPosition>({
37
+ get: () => chrome.value.panelPosition,
38
+ set: value => api.updateChrome('panelPosition', value),
39
+ })
40
+
41
+ const isHorizontalDock = computed(() => isHorizontalDevToolsDock(panelPosition.value))
42
+
43
+ function toggle() {
44
+ open.value = !open.value
45
+ }
46
+
47
+ const drawerSurfaceClass
48
+ = 'devtools-panel__surface--drawer !bg-muted ring-default shadow-lg drop-shadow-xl'
49
+
50
+ // `bottom-12` leaves room for the dock bar under a bottom-docked drawer, so the two never overlap. The drawer is inset 1rem from the sides, and the dock's margin (16) lines the bar's right end up with it.
51
+ const drawerUi = computed(() => {
52
+ const surface = drawerSurfaceClass
53
+ const body = 'devtools-panel overflow-y-auto px-3 py-2'
54
+ const container = 'gap-0'
55
+
56
+ switch (panelPosition.value) {
57
+ case 'left':
58
+ return { content: `top-22 left-4 bottom-4 max-w-96 z-50 ${surface}`, body, container }
59
+ case 'top':
60
+ return { content: `inset-x-4 top-22 max-h-[min(24rem,70vh)] sm:max-h-[min(28rem,75vh)] z-50 ${surface}`, body, container }
61
+ case 'bottom':
62
+ return { content: `inset-x-4 bottom-12 max-h-[min(24rem,70vh)] sm:max-h-[min(28rem,75vh)] z-50 ${surface}`, body, container }
63
+ default:
64
+ return { content: `top-22 right-4 bottom-4 max-w-96 z-50 ${surface}`, body, container }
65
+ }
66
+ })
67
+ </script>
68
+
69
+ <template>
70
+ <template v-if="showPanel">
71
+ <slot
72
+ name="dock"
73
+ :open="open"
74
+ :toggle="toggle"
75
+ >
76
+ <FloatingDock
77
+ v-model:open="open"
78
+ storage-key="fugue-devtools:dock"
79
+ label="Dev tools"
80
+ bottom-class="bottom-2"
81
+ :default-percent="100"
82
+ align="end"
83
+ :margin="16"
84
+ />
85
+ </slot>
86
+
87
+ <UDrawer
88
+ :key="panelPosition"
89
+ v-model:open="open"
90
+ :direction="panelPosition"
91
+ :modal="false"
92
+ :overlay="false"
93
+ :dismissible="false"
94
+ :handle="false"
95
+ inset
96
+ :ui="drawerUi"
97
+ >
98
+ <template #body>
99
+ <DevToolsNav
100
+ :brand="brand"
101
+ :panel-position="panelPosition"
102
+ :show-settings-toggle="false"
103
+ @position-change="panelPosition = $event"
104
+ @close="open = false"
105
+ @turn-off="api.disable()"
106
+ >
107
+ <template #brand>
108
+ <slot name="header">
109
+ {{ brand }}
110
+ </slot>
111
+ </template>
112
+ </DevToolsNav>
113
+
114
+ <div
115
+ v-if="visibleSections.length > 1"
116
+ class="mt-2 flex flex-wrap gap-1"
117
+ role="tablist"
118
+ >
119
+ <UButton
120
+ v-for="section in visibleSections"
121
+ :key="section.id"
122
+ :label="section.label"
123
+ :color="activeSection?.id === section.id ? 'primary' : 'neutral'"
124
+ :variant="activeSection?.id === section.id ? 'soft' : 'ghost'"
125
+ size="xs"
126
+ role="tab"
127
+ :aria-selected="activeSection?.id === section.id"
128
+ :data-testid="`devtools-tab-${section.id}`"
129
+ @click="api.activeId.value = section.id"
130
+ />
131
+ </div>
132
+
133
+ <div
134
+ class="mt-3 grid grid-cols-1 gap-4"
135
+ :class="bodyGridClass"
136
+ >
137
+ <template v-if="activeSection">
138
+ <slot
139
+ :name="`section-${activeSection.id}`"
140
+ :section-class="sectionClass"
141
+ :panel-position="panelPosition"
142
+ :is-horizontal-dock="isHorizontalDock"
143
+ >
144
+ <DevToolsSection
145
+ :title="activeSection.label"
146
+ :class="sectionClass"
147
+ >
148
+ <component :is="activeSection.component" />
149
+ </DevToolsSection>
150
+ </slot>
151
+ </template>
152
+ <p
153
+ v-else
154
+ class="text-sm text-muted"
155
+ >
156
+ Nothing to show here for you.
157
+ </p>
158
+
159
+ <slot
160
+ :section-class="sectionClass"
161
+ :is-bottom-dock="panelPosition === 'bottom'"
162
+ :is-horizontal-dock="isHorizontalDock"
163
+ :panel-position="panelPosition"
164
+ />
165
+ </div>
166
+
167
+ <slot name="footer" />
168
+ </template>
169
+ </UDrawer>
170
+ </template>
171
+ </template>
@@ -13,14 +13,18 @@ const emit = defineEmits<{
13
13
  </script>
14
14
 
15
15
  <template>
16
- <UButton
17
- icon="i-lucide-settings"
18
- :color="open ? 'primary' : 'neutral'"
19
- variant="ghost"
20
- size="sm"
21
- :aria-label="ariaLabel"
22
- title="Toggle Dev Tools"
23
- :aria-pressed="open"
24
- @click="emit('toggle')"
25
- />
16
+ <UTooltip
17
+ text="Toggle Dev Tools"
18
+ :ui="{ content: 'z-[60]' }"
19
+ >
20
+ <UButton
21
+ icon="i-lucide-settings"
22
+ :color="open ? 'primary' : 'neutral'"
23
+ variant="ghost"
24
+ size="sm"
25
+ :aria-label="ariaLabel"
26
+ :aria-pressed="open"
27
+ @click="emit('toggle')"
28
+ />
29
+ </UTooltip>
26
30
  </template>
@@ -0,0 +1,73 @@
1
+ import type { Component, ComputedRef, Ref } from 'vue'
2
+ import { computed, ref, shallowRef } from 'vue'
3
+
4
+ export type DevToolsSectionAccess = 'public' | 'privileged'
5
+
6
+ export interface DevToolsSectionDefinition {
7
+ id: string
8
+ label: string
9
+ component: Component
10
+ /** `public` sections show to anyone who opened the drawer; `privileged` (default) need the access resolver to allow it. */
11
+ access?: DevToolsSectionAccess
12
+ order?: number
13
+ }
14
+
15
+ export interface RegisteredDevToolsSection extends DevToolsSectionDefinition {
16
+ access: DevToolsSectionAccess
17
+ }
18
+
19
+ export interface DevToolsRegistry {
20
+ sections: ComputedRef<RegisteredDevToolsSection[]>
21
+ visibleSections: ComputedRef<RegisteredDevToolsSection[]>
22
+ activeId: Ref<string | undefined>
23
+ activeSection: ComputedRef<RegisteredDevToolsSection | undefined>
24
+ registerSection: (section: DevToolsSectionDefinition) => () => void
25
+ /** Reactive: read the site's session inside `resolver`. Privileged sections stay hidden until it returns true. */
26
+ setAccessResolver: (resolver: () => boolean) => void
27
+ }
28
+
29
+ export function createDevToolsRegistry(options: { isDev: boolean }): DevToolsRegistry {
30
+ const map = shallowRef(new Map<string, RegisteredDevToolsSection>())
31
+ const resolver = shallowRef<() => boolean>(() => options.isDev)
32
+ const activeId = ref<string | undefined>()
33
+
34
+ const sections = computed(() =>
35
+ [
36
+ ...map.value.values(),
37
+ ].sort((a, b) => (a.order ?? 0) - (b.order ?? 0)),
38
+ )
39
+
40
+ const canAccessPrivileged = computed(() => resolver.value() === true)
41
+
42
+ const visibleSections = computed(() =>
43
+ sections.value.filter(s => s.access === 'public' || canAccessPrivileged.value),
44
+ )
45
+
46
+ const activeSection = computed(() =>
47
+ visibleSections.value.find(s => s.id === activeId.value) ?? visibleSections.value[0],
48
+ )
49
+
50
+ function registerSection(section: DevToolsSectionDefinition) {
51
+ const next = new Map(map.value)
52
+ next.set(section.id, { ...section, access: section.access ?? 'privileged' })
53
+ map.value = next
54
+ return () => {
55
+ const after = new Map(map.value)
56
+ after.delete(section.id)
57
+ map.value = after
58
+ }
59
+ }
60
+
61
+ function setAccessResolver(next: () => boolean) {
62
+ resolver.value = next
63
+ }
64
+
65
+ return {
66
+ sections,
67
+ visibleSections,
68
+ activeId,
69
+ activeSection,
70
+ registerSection,
71
+ setAccessResolver,
72
+ }
73
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ComputedRef, InjectionKey, Ref } from 'vue'
2
2
  import type { DevToolsChromeState, DevToolsPanelPosition } from '#devtools/persist'
3
+ import type { DevToolsRegistry } from './devtoolsRegistry'
3
4
 
4
5
  export type { DevToolsChromeState, DevToolsPanelPosition }
5
6
  export {
@@ -10,6 +11,8 @@ export {
10
11
 
11
12
  export interface DevToolsUrlActivation {
12
13
  enabledFromUrl: boolean
14
+ /** An open param carries the value `off`: turn the devtools off. */
15
+ disabledFromUrl: boolean
13
16
  hasInnerToggleParam: boolean
14
17
  }
15
18
 
@@ -23,7 +26,7 @@ export interface DevToolsPersistConfig {
23
26
  key: string
24
27
  }
25
28
 
26
- export interface DevToolsApi {
29
+ export interface DevToolsApi extends DevToolsRegistry {
27
30
  chrome: Ref<DevToolsChromeState>
28
31
  showPanel: ComputedRef<boolean>
29
32
  updateChrome: <K extends keyof DevToolsChromeState>(_key: K, _value: DevToolsChromeState[K]) => void
@@ -1,6 +1,7 @@
1
1
  import type { Router } from 'vue-router'
2
2
  import type { DevToolsApi, DevToolsChromeState, DevToolsPersistConfig, DevToolsPublicConfig } from '#devtools/composables/devtoolsTypes'
3
3
  import { computed, inject, ref, watch } from 'vue'
4
+ import { createDevToolsRegistry } from '#devtools/composables/devtoolsRegistry'
4
5
  import { createDefaultDevToolsChrome, DEVTOOLS_INJECTION_KEY } from '#devtools/composables/devtoolsTypes'
5
6
  import {
6
7
  getDevToolsStorage,
@@ -13,6 +14,7 @@ export function createDevToolsApi(options: {
13
14
  router: Router
14
15
  isDev: boolean
15
16
  urlConfig: DevToolsPublicConfig
17
+ /** Site defaults; a value the user saved takes precedence. */
16
18
  initialChrome?: Partial<DevToolsChromeState>
17
19
  persist?: DevToolsPersistConfig
18
20
  }): DevToolsApi {
@@ -30,10 +32,11 @@ export function createDevToolsApi(options: {
30
32
 
31
33
  const chrome = ref<DevToolsChromeState>({
32
34
  ...createDefaultDevToolsChrome(isDev),
35
+ // Site defaults sit under what the user saved, so a remembered dock position wins.
36
+ ...options.initialChrome,
33
37
  ...(persist && storage
34
38
  ? readDevToolsPersisted(storage, persist.key)?.chrome
35
39
  : undefined),
36
- ...options.initialChrome,
37
40
  })
38
41
 
39
42
  const showPanel = computed(
@@ -41,12 +44,17 @@ export function createDevToolsApi(options: {
41
44
  )
42
45
 
43
46
  function applyUrlActivation() {
44
- const { enabledFromUrl, hasInnerToggleParam } = urlActivation.value
47
+ const { enabledFromUrl, disabledFromUrl, hasInnerToggleParam } = urlActivation.value
48
+ if (disabledFromUrl) {
49
+ turnOff()
50
+ return
51
+ }
45
52
  if (!enabledFromUrl)
46
53
  return
47
54
  chrome.value = {
48
55
  ...chrome.value,
49
56
  enabled: true,
57
+ open: true,
50
58
  innerToggle: hasInnerToggleParam || isDev
51
59
  ? true
52
60
  : chrome.value.innerToggle,
@@ -75,9 +83,14 @@ export function createDevToolsApi(options: {
75
83
  chrome.value = { ...chrome.value, [key]: value }
76
84
  }
77
85
 
78
- function disable() {
79
- chrome.value = { ...chrome.value, enabled: false }
80
- if (!urlActivation.value.enabledFromUrl)
86
+ /** Back to the defaults (off, closed, default dock), which is also what gets persisted. */
87
+ function turnOff() {
88
+ chrome.value = {
89
+ ...createDefaultDevToolsChrome(isDev),
90
+ ...options.initialChrome,
91
+ }
92
+ const { enabledFromUrl, disabledFromUrl } = urlActivation.value
93
+ if (!enabledFromUrl && !disabledFromUrl)
81
94
  return
82
95
 
83
96
  const query = stripDevToolsOpenParams({ ...route.query }, urlConfig) as typeof route.query
@@ -88,12 +101,15 @@ export function createDevToolsApi(options: {
88
101
  chrome.value = { ...chrome.value, enabled: true }
89
102
  }
90
103
 
104
+ const registry = createDevToolsRegistry({ isDev })
105
+
91
106
  return {
92
107
  chrome,
93
108
  showPanel,
94
109
  updateChrome,
95
- disable,
110
+ disable: turnOff,
96
111
  enable,
112
+ ...registry,
97
113
  }
98
114
  }
99
115
 
package/nuxt.config.ts CHANGED
@@ -27,10 +27,12 @@ export default defineNuxtConfig({
27
27
  fugueDevtools: {
28
28
  /** Set `false` when a product adapter registers its own devtools API at the app layer. */
29
29
  registerPlugin: true,
30
- openParams: ['devtools'],
30
+ openParams: ['qetools'],
31
31
  innerToggleParams: ['devtoolstoggle'],
32
32
  persistNamespace: 'app',
33
33
  persistKey: 'devtools',
34
+ /** Where the drawer docks the first time (the user can move it). */
35
+ defaultPosition: 'bottom',
34
36
  },
35
37
  },
36
38
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@altafusion/fugue-devtools",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
5
5
  "description": "Generic non-modal dev tools drawer for Nuxt apps — Fugue family",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/altafusion/fugue/tree/main/packages-fugue/fugue-devtools#readme",
@@ -36,17 +36,17 @@
36
36
  "vue-router": "^5.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@altafusion/fugue-ui": "0.5.0"
39
+ "@altafusion/fugue-ui": "0.6.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@altafusion/eslint-config": "0.5.0",
43
- "@altafusion/nuxt-base": "0.5.0",
44
- "@types/node": "^26.6.10",
42
+ "@altafusion/eslint-config": "0.6.0",
43
+ "@altafusion/nuxt-base": "0.6.0",
44
+ "@types/node": "^26.6.11",
45
45
  "eslint": "^10.15.0",
46
46
  "nuxt": "^4.7.0",
47
47
  "typescript": "^6.0.3",
48
48
  "vue": "^3.5.46",
49
- "vue-router": "^5.5.1"
49
+ "vue-router": "^5.5.3"
50
50
  },
51
51
  "scripts": {
52
52
  "clean": "rm -rf .output .nuxt node_modules/.cache dist",
package/persist/types.ts CHANGED
@@ -18,6 +18,8 @@ export function isDevToolsPanelPosition(value: unknown): value is DevToolsPanelP
18
18
  /** Drawer chrome — shared across Fugue devtools adapters. */
19
19
  export interface DevToolsChromeState {
20
20
  enabled: boolean
21
+ /** Whether the drawer is showing. Closing keeps `enabled`, so the dock stays. */
22
+ open: boolean
21
23
  panelPosition: DevToolsPanelPosition
22
24
  innerToggle: boolean
23
25
  }
@@ -31,6 +33,7 @@ export interface DevToolsPersistedV1<TDomain = Record<string, unknown>> {
31
33
  export function createDefaultDevToolsChrome(isDev = false): DevToolsChromeState {
32
34
  return {
33
35
  enabled: false,
36
+ open: false,
34
37
  panelPosition: 'bottom',
35
38
  innerToggle: isDev,
36
39
  }
@@ -1,3 +1,4 @@
1
+ import Diagnostics from '#devtools/components/DevTools/Diagnostics.vue'
1
2
  import { DEVTOOLS_INJECTION_KEY } from '#devtools/composables/devtoolsTypes'
2
3
  import { createDevToolsApi } from '#devtools/composables/useDevTools'
3
4
 
@@ -12,9 +13,12 @@ export default defineNuxtPlugin((nuxtApp) => {
12
13
 
13
14
  const api = createDevToolsApi({
14
15
  router,
16
+ initialChrome: devtoolsConfig.defaultPosition
17
+ ? { panelPosition: devtoolsConfig.defaultPosition }
18
+ : undefined,
15
19
  isDev: import.meta.dev,
16
20
  urlConfig: {
17
- openParams: devtoolsConfig.openParams ?? ['devtools'],
21
+ openParams: devtoolsConfig.openParams ?? ['qetools'],
18
22
  innerToggleParams: devtoolsConfig.innerToggleParams ?? ['devtoolstoggle'],
19
23
  },
20
24
  persist: devtoolsConfig.persistNamespace && devtoolsConfig.persistKey
@@ -25,5 +29,18 @@ export default defineNuxtPlugin((nuxtApp) => {
25
29
  : undefined,
26
30
  })
27
31
 
32
+ api.registerSection({
33
+ id: 'diagnostics',
34
+ label: 'Diagnostics',
35
+ component: Diagnostics,
36
+ access: 'public',
37
+ order: -1,
38
+ })
39
+
28
40
  nuxtApp.vueApp.provide(DEVTOOLS_INJECTION_KEY, api)
41
+
42
+ // Other layers (fugue-content, a site) register sections through this, without importing this package.
43
+ return {
44
+ provide: { fugueDevtools: api },
45
+ }
29
46
  })
@@ -8,8 +8,15 @@ declare module 'nuxt/schema' {
8
8
  innerToggleParams: string[]
9
9
  persistNamespace?: string
10
10
  persistKey?: string
11
+ defaultPosition?: 'top' | 'right' | 'bottom' | 'left'
11
12
  }
12
13
  }
13
14
  }
14
15
 
16
+ declare module '#app' {
17
+ interface NuxtApp {
18
+ $fugueDevtools?: import('#devtools/composables/devtoolsTypes').DevToolsApi
19
+ }
20
+ }
21
+
15
22
  export {}
@@ -9,9 +9,13 @@ export function parseDevToolsUrlActivation(
9
9
  )
10
10
  const openParams = config.openParams.map(p => p.toLowerCase())
11
11
  const innerParams = config.innerToggleParams.map(p => p.toLowerCase())
12
+ const disabledFromUrl = Array.from(searchParams.entries()).some(
13
+ ([key, value]) => openParams.includes(key.toLowerCase()) && value.toLowerCase() === 'off',
14
+ )
12
15
  return {
13
- enabledFromUrl: openParams.some(p => queryKeys.has(p))
14
- || innerParams.some(p => queryKeys.has(p)),
16
+ enabledFromUrl: !disabledFromUrl && (openParams.some(p => queryKeys.has(p))
17
+ || innerParams.some(p => queryKeys.has(p))),
18
+ disabledFromUrl,
15
19
  hasInnerToggleParam: innerParams.some(p => queryKeys.has(p)),
16
20
  }
17
21
  }
@@ -37,12 +41,12 @@ export function readDevToolsUrlActivation(
37
41
  config: Pick<DevToolsPublicConfig, 'openParams' | 'innerToggleParams'>,
38
42
  ): DevToolsUrlActivation {
39
43
  const fromRoute = parseDevToolsUrlActivation(queryRecordToSearchParams(query), config)
40
- if (fromRoute.enabledFromUrl)
44
+ if (fromRoute.enabledFromUrl || fromRoute.disabledFromUrl)
41
45
  return fromRoute
42
46
 
43
47
  if (typeof window !== 'undefined') {
44
48
  const fromWindow = parseDevToolsUrlActivation(new URLSearchParams(window.location.search), config)
45
- if (fromWindow.enabledFromUrl)
49
+ if (fromWindow.enabledFromUrl || fromWindow.disabledFromUrl)
46
50
  return fromWindow
47
51
  }
48
52
 
@@ -1,87 +0,0 @@
1
- <script setup lang="ts">
2
- import type { DevToolsPanelPosition } from '#devtools/composables/devtoolsTypes'
3
- import { isHorizontalDevToolsDock } from '#devtools/persist'
4
-
5
- const {
6
- bodyGridClass = '',
7
- sectionClass = '',
8
- } = defineProps<{
9
- /** Extra grid classes on the section container (e.g. 3-column bottom dock). */
10
- bodyGridClass?: string
11
- /** Extra class on sections passed through `sectionClass` slot prop. */
12
- sectionClass?: string
13
- }>()
14
-
15
- const open = defineModel<boolean>('open', { required: true })
16
-
17
- const panelPosition = defineModel<DevToolsPanelPosition>('panelPosition', {
18
- required: true,
19
- })
20
-
21
- const direction = computed(() => panelPosition.value)
22
-
23
- const isHorizontalDock = computed(() => isHorizontalDevToolsDock(panelPosition.value))
24
-
25
- const drawerSurfaceClass
26
- = 'devtools-panel__surface--drawer !bg-muted ring-default shadow-lg drop-shadow-xl'
27
-
28
- const drawerUi = computed(() => {
29
- const surface = drawerSurfaceClass
30
- const body = 'devtools-panel overflow-y-auto px-3 py-2'
31
- const container = 'gap-0'
32
-
33
- switch (panelPosition.value) {
34
- case 'left':
35
- return {
36
- content: `top-22 left-4 bottom-4 max-w-96 z-50 ${surface}`,
37
- body,
38
- container,
39
- }
40
- case 'top':
41
- return {
42
- content: `inset-x-4 top-22 max-h-[min(24rem,70vh)] sm:max-h-[min(28rem,75vh)] z-50 ${surface}`,
43
- body,
44
- container,
45
- }
46
- case 'bottom':
47
- return {
48
- content: `inset-x-4 bottom-12 max-h-[min(24rem,70vh)] sm:max-h-[min(28rem,75vh)] z-50 ${surface}`,
49
- body,
50
- container,
51
- }
52
- default:
53
- return {
54
- content: `top-22 right-4 bottom-4 max-w-96 z-50 ${surface}`,
55
- body,
56
- container,
57
- }
58
- }
59
- })
60
- </script>
61
-
62
- <template>
63
- <UDrawer
64
- :key="direction"
65
- v-model:open="open"
66
- :direction="direction"
67
- :modal="false"
68
- :overlay="false"
69
- :dismissible="false"
70
- :handle="false"
71
- inset
72
- :ui="drawerUi"
73
- >
74
- <template #body>
75
- <slot name="nav" />
76
-
77
- <div class="mt-3 grid grid-cols-1 gap-4" :class="bodyGridClass">
78
- <slot
79
- :section-class="sectionClass"
80
- :is-bottom-dock="panelPosition === 'bottom'"
81
- :is-horizontal-dock="isHorizontalDock"
82
- :panel-position="panelPosition"
83
- />
84
- </div>
85
- </template>
86
- </UDrawer>
87
- </template>