Skip to content

Commit 54555fa

Browse files
authored
fix: client hints plugin (#9)
* fix: client hints plugin * chore: cleanup
1 parent 1eb195f commit 54555fa

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Diff for: playground/app.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
</template>
1010

1111
<script setup>
12-
12+
const critical = useNuxtApp().$httpClientHints?.critical
13+
console.log(critical?.devicePixelRatio)
1314
</script>

Diff for: src/runtime/plugins/types.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DeepReadonly, UnwrapNestedRefs } from '@vue/reactivity'
1+
import type { DeepReadonly } from '@vue/reactivity'
22
import type { Browser, asyncDetect, detect, detectOS, parseUserAgent } from 'detect-browser-es'
33
import type { HttpClientHintsState, UserAgentDataHints } from '../shared-types/types'
44

@@ -9,13 +9,13 @@ declare module '#app' {
99
$detectBrowserAsync?: (hints?: UserAgentDataHints[]) => ReturnType<typeof asyncDetect>
1010
$detectOS?: () => ReturnType<typeof detectOS>
1111
$parseUserAgent?: () => ReturnType<typeof parseUserAgent>
12-
$httpClientHints?: DeepReadonly<UnwrapNestedRefs<HttpClientHintsState>>
12+
$httpClientHints?: DeepReadonly<HttpClientHintsState>
1313
}
1414
}
1515

1616
declare module 'vue' {
1717
interface ComponentCustomProperties {
18-
$httpClientHints?: DeepReadonly<UnwrapNestedRefs<HttpClientHintsState>>
18+
$httpClientHints?: DeepReadonly<HttpClientHintsState>
1919
}
2020
}
2121

Diff for: src/utils/configuration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default defineNuxtPlugin({
172172
)
173173
return {
174174
provide: {
175-
httpClientHints: readonly(clientHints),
175+
httpClientHints: readonly(clientHints.value),
176176
}
177177
}
178178
}

0 commit comments

Comments
 (0)