From 4291721296196fecc6eb1ba3acdd37d25eacc58d Mon Sep 17 00:00:00 2001 From: userquin Date: Wed, 8 Nov 2023 21:40:41 +0100 Subject: [PATCH 1/2] chore(types): fix `$pwa` module augmentation types for Nuxt and Vue --- modules/pwa/types.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/pwa/types.ts b/modules/pwa/types.ts index 90446c52e6..104b60e20b 100644 --- a/modules/pwa/types.ts +++ b/modules/pwa/types.ts @@ -1,7 +1,32 @@ import type { VitePWAOptions } from 'vite-plugin-pwa' +import { type Ref, type UnwrapNestedRefs } from 'vue' export interface VitePWANuxtOptions extends Partial {} +export interface PwaInjection { + isInstalled: boolean + showInstallPrompt: Ref + cancelInstall: () => void + install: () => Promise + swActivated: Ref + registrationError: Ref + needRefresh: Ref + updateServiceWorker: (reloadPage?: boolean | undefined) => Promise + close: () => Promise +} + +declare module '#app/nuxt' { + interface NuxtApp { + $pwa: UnwrapNestedRefs + } +} + +declare module '@vue/runtime-core' { + export interface ComponentCustomProperties { + $pwa: UnwrapNestedRefs + } +} + declare module '@nuxt/schema' { interface NuxtConfig { pwa?: { [K in keyof VitePWANuxtOptions]?: Partial } From 755a5841349852d13291233aa047091332307879 Mon Sep 17 00:00:00 2001 From: userquin Date: Wed, 8 Nov 2023 22:18:41 +0100 Subject: [PATCH 2/2] chore: use `#app` instead `#app/nuxt` --- modules/pwa/types.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/pwa/types.ts b/modules/pwa/types.ts index 104b60e20b..2fc3f8b506 100644 --- a/modules/pwa/types.ts +++ b/modules/pwa/types.ts @@ -15,7 +15,8 @@ export interface PwaInjection { close: () => Promise } -declare module '#app/nuxt' { +// TODO: we'll need to review this to '#app/nuxt' +declare module '#app' { interface NuxtApp { $pwa: UnwrapNestedRefs }