diff --git a/modules/pwa/types.ts b/modules/pwa/types.ts index 90446c52e6..2fc3f8b506 100644 --- a/modules/pwa/types.ts +++ b/modules/pwa/types.ts @@ -1,7 +1,33 @@ 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 +} + +// TODO: we'll need to review this to '#app/nuxt' +declare module '#app' { + 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 }