Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/devtools/client/components/OpenGraphMissingTabs.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { MetaFlatInput } from '@unhead/schema'
import type { ReactiveHead } from '@unhead/vue'
import type { MetaFlatInput, ReactiveHead } from '@unhead/vue'
import type { NormalizedHeadTag } from '../../src/types'
import { defu } from 'defu'
import { computed, ref } from 'vue'
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/composables/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NuxtDevtoolsClient, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient } from '@nuxt/devtools-kit/types'
import type { Unhead } from '@unhead/schema'
import type { Unhead } from '@unhead/vue'
import type { ComputedRef } from 'vue'
import type { useRoute, useRouter } from '#imports'
import { useColorMode } from '@vueuse/core'
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/client/composables/state-commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { $Fetch } from 'ofetch'
import type { MaybeRefOrGetter } from 'vue'
import { randomStr } from '@antfu/utils'
import { computed, onUnmounted, reactive, toValue } from 'vue'
Expand Down Expand Up @@ -77,7 +78,7 @@ let _nuxtDocsCommands: CommandItem[] | undefined

export async function getNuxtDocsCommands() {
if (!_nuxtDocsCommands) {
const list = await $fetch<any[]>('https://nuxt.com/api/search.json', {
const list = await ($fetch as $Fetch)<any[]>('https://nuxt.com/api/search.json', {
query: {
select: '_path,title,description,navigation',
},
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/client/composables/state-modules.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { $Fetch } from 'ofetch'
import type { InstalledModuleInfo, ModuleStaticInfo } from '../../src/types'
import { computed } from 'vue'
import { $fetch, useState } from '#imports'
Expand All @@ -16,7 +17,7 @@ const ignoredModules = [

export function useModulesList() {
return useAsyncState('getModulesList', async () => {
const m = await $fetch<{ modules: ModuleStaticInfo[] }>('https://api.nuxt.com/modules?version=3')
const m = await ($fetch as $Fetch)<{ modules: ModuleStaticInfo[] }>('https://api.nuxt.com/modules?version=3')
return m.modules
.filter((item: ModuleStaticInfo) => !ignoredModules.includes(item.npm) && item.compatibility.nuxt.includes('>=3'))
})
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools/client/data/open-graph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { MetaFlatInput } from '@unhead/schema'
import type { ReactiveHead } from '@unhead/vue'
import type { MetaFlatInput, ReactiveHead } from '@unhead/vue'

export interface OpenGraphTagDefine {
name: string
Expand Down
13 changes: 12 additions & 1 deletion packages/devtools/client/pages/modules/open-graph.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
import type { HeadTag, Unhead } from '@unhead/vue'
import type { NormalizedHeadTag } from '~/../src/types/ui-state'
import { resolveTags } from '@unhead/vue/utils'
import { computedAsync, until } from '@vueuse/core'
import { computed, nextTick, ref } from 'vue'
import { definePageMeta } from '#imports'
Expand All @@ -22,10 +24,19 @@ definePageMeta({
const counter = ref(0)
const head = useClientHead()

// unhead v2 apps expose tag resolution as an async instance method; v3 removed it in
// favour of the standalone `resolveTags` util, and the inspected app may be on either.
async function resolveHeadTags(instance: Unhead): Promise<HeadTag[]> {
const legacy = instance as Partial<{ resolveTags: () => Promise<HeadTag[]> }>
if (typeof legacy.resolveTags === 'function')
return await legacy.resolveTags()
return resolveTags(instance)
}

const headTags = computedAsync(async () => {
// eslint-disable-next-line ts/no-unused-expressions
counter.value // for force refresh
const tags = await head.value?.resolveTags()
const tags = head.value ? await resolveHeadTags(head.value) : []
return tags.map((tag): NormalizedHeadTag => {
const props = tag.props || {}
if (tag.tag === 'htmlAttrs' && props.lang) {
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"@nuxt/test-utils": "catalog:cli",
"@parcel/watcher": "catalog:buildtools",
"@types/markdown-it-link-attributes": "catalog:types",
"@unhead/schema": "catalog:types",
"@unhead/vue": "catalog:frontend",
"@unocss/nuxt": "catalog:buildtools",
"@unocss/preset-icons": "catalog:buildtools",
"@unocss/preset-uno": "catalog:buildtools",
Expand Down
277 changes: 160 additions & 117 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ catalogs:
vue-tsc: ^3.3.9
frontend:
'@antfu/utils': ^9.3.0
'@unhead/vue': ^3.2.3
'@unocss/reset': ^66.7.5
'@unocss/runtime': ^66.7.5
'@vue/devtools-applet': ^8.2.1
Expand Down Expand Up @@ -169,6 +170,5 @@ catalogs:
'@types/node': ^25.9.5
'@types/which': ^3.0.4
'@types/ws': ^8.18.1
'@unhead/schema': ^2.1.16
'@vitejs/devtools-kit': ^0.4.10
unimport: ^6.4.0