nuxtseo-layer-devtools 0.4.5 → 0.5.1

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,332 @@
1
+ <script setup lang="ts">
2
+ import { useClipboard } from '@vueuse/core'
3
+ import { computed } from 'vue'
4
+ import { installedModules, moduleCatalog } from '../composables/modules'
5
+ import { detectPackageManager, pmCommands } from '../composables/package-manager'
6
+ import { useModuleUpdate } from '../composables/update-check'
7
+
8
+ const { moduleName, version } = defineProps<{
9
+ moduleName: string
10
+ version?: string
11
+ }>()
12
+
13
+ detectPackageManager()
14
+
15
+ const nuxtApp = useNuxtApp()
16
+ const nuxtVersion = nuxtApp.versions?.nuxt ?? 'unknown'
17
+ const vueVersion = nuxtApp.versions?.vue ?? 'unknown'
18
+
19
+ const moduleInfo = computed(() => moduleCatalog.value.find(m => m.name === moduleName))
20
+ const npmPackage = computed(() => moduleInfo.value?.npm)
21
+ const { latestVersion, hasUpdate } = useModuleUpdate(npmPackage.value, version)
22
+
23
+ const githubNewIssueUrl = computed(() => {
24
+ if (!moduleInfo.value?.repo)
25
+ return ''
26
+ return `https://github.com/${moduleInfo.value.repo}/issues/new`
27
+ })
28
+
29
+ // Build environment info for copy
30
+ const envInfo = computed(() => {
31
+ const lines: string[] = []
32
+ lines.push('### Environment')
33
+ lines.push('')
34
+
35
+ // Current module
36
+ if (version)
37
+ lines.push(`- **${npmPackage.value}**: v${version}${hasUpdate.value ? ` (latest: v${latestVersion.value})` : ''}`)
38
+
39
+ // Other installed Nuxt SEO modules
40
+ for (const mod of installedModules.value) {
41
+ if (mod.name === moduleName)
42
+ continue
43
+ const catalogEntry = moduleCatalog.value.find(m => m.name === mod.name)
44
+ if (catalogEntry?.npm)
45
+ lines.push(`- **${catalogEntry.npm}**: installed`)
46
+ }
47
+
48
+ lines.push('')
49
+ lines.push(`- **Nuxt**: v${nuxtVersion}`)
50
+ lines.push(`- **Vue**: v${vueVersion}`)
51
+
52
+ return lines.join('\n')
53
+ })
54
+
55
+ const { copy: copyEnv, copied: envCopied } = useClipboard({ source: envInfo })
56
+
57
+ const steps = computed(() => {
58
+ const pm = pmCommands()
59
+ const updateCmd = [pm.update, pm.dedupe].filter(Boolean).join(' && ')
60
+ return [
61
+ {
62
+ icon: 'carbon:reset',
63
+ title: 'Clear generated files and update dependencies',
64
+ description: 'Delete your .nuxt directory, update packages, then restart.',
65
+ codes: [
66
+ `rm -rf .nuxt && ${pm.exec} nuxi dev`,
67
+ updateCmd,
68
+ ],
69
+ },
70
+ {
71
+ icon: 'carbon:debug',
72
+ title: 'Enable debug mode',
73
+ description: 'Add debug: true to your module config for verbose logging.',
74
+ codes: [],
75
+ },
76
+ {
77
+ icon: 'carbon:code',
78
+ title: 'Create a minimal reproduction',
79
+ description: 'Use a StackBlitz playground to isolate the issue. This helps maintainers debug quickly.',
80
+ codes: [],
81
+ },
82
+ {
83
+ icon: 'carbon:flag',
84
+ title: 'Report the issue',
85
+ description: 'Open a GitHub issue with your reproduction link and environment info.',
86
+ codes: [],
87
+ },
88
+ ]
89
+ })
90
+ </script>
91
+
92
+ <template>
93
+ <DevtoolsSection icon="carbon:help" text="Troubleshooting" description="Steps to diagnose and report issues">
94
+ <div class="troubleshoot-steps">
95
+ <div v-for="(step, i) of steps" :key="i" class="troubleshoot-step">
96
+ <div class="troubleshoot-step-num">
97
+ {{ i + 1 }}
98
+ </div>
99
+ <div class="troubleshoot-step-content">
100
+ <div class="troubleshoot-step-title">
101
+ <UIcon :name="step.icon" class="w-3.5 h-3.5 text-[var(--color-text-muted)]" />
102
+ {{ step.title }}
103
+ </div>
104
+ <div class="troubleshoot-step-desc">
105
+ {{ step.description }}
106
+ </div>
107
+ <code v-for="code of step.codes" :key="code" class="troubleshoot-code">{{ code }}</code>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ <!-- Playgrounds for repro -->
113
+ <div class="troubleshoot-section">
114
+ <div class="troubleshoot-section-label">
115
+ <UIcon name="carbon:game-console" class="w-3.5 h-3.5" />
116
+ Playgrounds for reproduction
117
+ </div>
118
+ <DevtoolsPlaygrounds :module-name="moduleName" />
119
+ </div>
120
+
121
+ <!-- Environment info -->
122
+ <div class="troubleshoot-section">
123
+ <div class="troubleshoot-section-header">
124
+ <div class="troubleshoot-section-label">
125
+ <UIcon name="carbon:information" class="w-3.5 h-3.5" />
126
+ Environment info
127
+ </div>
128
+ <button type="button" class="troubleshoot-copy-btn" @click="copyEnv()">
129
+ <UIcon :name="envCopied ? 'carbon:checkmark' : 'carbon:copy'" class="w-3 h-3" />
130
+ {{ envCopied ? 'Copied' : 'Copy for issue' }}
131
+ </button>
132
+ </div>
133
+ <div class="troubleshoot-env">
134
+ <div class="troubleshoot-env-row">
135
+ <span class="troubleshoot-env-label">{{ npmPackage }}</span>
136
+ <span class="troubleshoot-env-value">
137
+ v{{ version || 'unknown' }}
138
+ <UBadge v-if="hasUpdate" size="xs" color="warning" variant="subtle">
139
+ v{{ latestVersion }} available
140
+ </UBadge>
141
+ </span>
142
+ </div>
143
+ <template v-for="mod of installedModules" :key="mod.name">
144
+ <div v-if="mod.name !== moduleName" class="troubleshoot-env-row">
145
+ <span class="troubleshoot-env-label">{{ moduleCatalog.find(m => m.name === mod.name)?.npm || mod.name }}</span>
146
+ <span class="troubleshoot-env-value">installed</span>
147
+ </div>
148
+ </template>
149
+ <div class="troubleshoot-env-row">
150
+ <span class="troubleshoot-env-label">nuxt</span>
151
+ <span class="troubleshoot-env-value">v{{ nuxtVersion }}</span>
152
+ </div>
153
+ <div class="troubleshoot-env-row">
154
+ <span class="troubleshoot-env-label">vue</span>
155
+ <span class="troubleshoot-env-value">v{{ vueVersion }}</span>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <!-- Report button -->
161
+ <a
162
+ v-if="githubNewIssueUrl"
163
+ :href="githubNewIssueUrl"
164
+ target="_blank"
165
+ rel="noopener"
166
+ class="troubleshoot-report-btn"
167
+ >
168
+ <UIcon name="simple-icons:github" class="w-3.5 h-3.5" />
169
+ Open an issue on GitHub
170
+ <UIcon name="carbon:arrow-up-right" class="w-3 h-3 opacity-40 ml-auto" />
171
+ </a>
172
+ </DevtoolsSection>
173
+ </template>
174
+
175
+ <style scoped>
176
+ .troubleshoot-steps {
177
+ display: flex;
178
+ flex-direction: column;
179
+ gap: 0.125rem;
180
+ }
181
+
182
+ .troubleshoot-step {
183
+ display: flex;
184
+ align-items: flex-start;
185
+ gap: 0.75rem;
186
+ padding: 0.5rem 0;
187
+ }
188
+
189
+ .troubleshoot-step-num {
190
+ display: flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ width: 1.375rem;
194
+ height: 1.375rem;
195
+ flex-shrink: 0;
196
+ border-radius: 50%;
197
+ background: var(--color-surface-elevated);
198
+ border: 1px solid var(--color-border);
199
+ font-size: 0.625rem;
200
+ font-weight: 700;
201
+ color: var(--color-text-muted);
202
+ }
203
+
204
+ .troubleshoot-step-content {
205
+ flex: 1;
206
+ min-width: 0;
207
+ }
208
+
209
+ .troubleshoot-step-title {
210
+ display: flex;
211
+ align-items: center;
212
+ gap: 0.375rem;
213
+ font-size: 0.8125rem;
214
+ font-weight: 600;
215
+ color: var(--color-text);
216
+ }
217
+
218
+ .troubleshoot-step-desc {
219
+ font-size: 0.75rem;
220
+ color: var(--color-text-muted);
221
+ margin-top: 0.125rem;
222
+ }
223
+
224
+ .troubleshoot-code {
225
+ display: inline-block;
226
+ margin-top: 0.375rem;
227
+ margin-right: 0.375rem;
228
+ padding: 0.25rem 0.5rem;
229
+ border-radius: var(--radius-sm);
230
+ background: var(--color-surface-elevated);
231
+ border: 1px solid var(--color-border);
232
+ font-family: var(--font-mono, monospace);
233
+ font-size: 0.6875rem;
234
+ color: var(--color-text);
235
+ }
236
+
237
+ .troubleshoot-section {
238
+ margin-top: 0.5rem;
239
+ padding-top: 0.75rem;
240
+ border-top: 1px solid var(--color-border);
241
+ }
242
+
243
+ .troubleshoot-section-header {
244
+ display: flex;
245
+ align-items: center;
246
+ justify-content: space-between;
247
+ }
248
+
249
+ .troubleshoot-section-label {
250
+ display: flex;
251
+ align-items: center;
252
+ gap: 0.375rem;
253
+ font-size: 0.75rem;
254
+ font-weight: 600;
255
+ color: var(--color-text-muted);
256
+ margin-bottom: 0.5rem;
257
+ }
258
+
259
+ .troubleshoot-copy-btn {
260
+ display: flex;
261
+ align-items: center;
262
+ gap: 0.25rem;
263
+ padding: 0.2rem 0.5rem;
264
+ border-radius: var(--radius-sm);
265
+ font-size: 0.625rem;
266
+ font-weight: 600;
267
+ color: var(--seo-green);
268
+ background: oklch(from var(--seo-green) l c h / 0.1);
269
+ cursor: pointer;
270
+ transition: background 100ms;
271
+ }
272
+
273
+ .troubleshoot-copy-btn:hover {
274
+ background: oklch(from var(--seo-green) l c h / 0.18);
275
+ }
276
+
277
+ .troubleshoot-env {
278
+ display: flex;
279
+ flex-direction: column;
280
+ gap: 1px;
281
+ border-radius: var(--radius-sm);
282
+ overflow: hidden;
283
+ }
284
+
285
+ .troubleshoot-env-row {
286
+ display: flex;
287
+ align-items: center;
288
+ justify-content: space-between;
289
+ padding: 0.3rem 0.5rem;
290
+ background: var(--color-surface-elevated);
291
+ }
292
+
293
+ .troubleshoot-env-label {
294
+ font-size: 0.6875rem;
295
+ font-family: var(--font-mono, monospace);
296
+ color: var(--color-text-muted);
297
+ }
298
+
299
+ .troubleshoot-env-value {
300
+ display: flex;
301
+ align-items: center;
302
+ gap: 0.375rem;
303
+ font-size: 0.6875rem;
304
+ font-family: var(--font-mono, monospace);
305
+ color: var(--color-text);
306
+ }
307
+
308
+ .troubleshoot-report-btn {
309
+ display: flex;
310
+ align-items: center;
311
+ gap: 0.5rem;
312
+ margin-top: 0.75rem;
313
+ padding: 0.5rem 0.625rem;
314
+ border-radius: var(--radius-sm);
315
+ font-size: 0.8125rem;
316
+ font-weight: 500;
317
+ color: var(--color-text-muted);
318
+ text-decoration: none;
319
+ border: 1px solid var(--color-border);
320
+ transition: background 100ms, color 100ms, border-color 100ms;
321
+ }
322
+
323
+ .troubleshoot-report-btn:hover {
324
+ background: var(--color-surface-elevated);
325
+ color: var(--color-text);
326
+ border-color: var(--color-neutral-400);
327
+ }
328
+
329
+ .dark .troubleshoot-report-btn:hover {
330
+ border-color: var(--color-neutral-600);
331
+ }
332
+ </style>