@vite-pwa/nuxt 0.3.4 → 0.3.5

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.
@@ -1,5 +1,6 @@
1
1
  declare module 'virtual:nuxt-pwa-configuration' {
2
2
  export const enabled: boolean
3
+ export const display: 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser'
3
4
  export const installPrompt: string | undefined
4
5
  export const periodicSyncForUpdates: number
5
6
  }
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.6.5",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.3.4"
8
+ "version": "0.3.5"
9
9
  }
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { defineNuxtModule, createResolver, getNuxtVersion, addPlugin, addCompone
4
4
  import { VitePWA } from 'vite-plugin-pwa';
5
5
  import { resolve } from 'pathe';
6
6
 
7
- const version = "0.3.4";
7
+ const version = "0.3.5";
8
8
 
9
9
  function configurePWAOptions(nuxt3_8, options, nuxt, nitroConfig) {
10
10
  if (!options.outDir) {
@@ -192,8 +192,10 @@ const module = defineNuxtModule({
192
192
  },
193
193
  load(id) {
194
194
  if (id === resolvedConfiguration) {
195
+ const display = typeof options.manifest !== "boolean" ? options.manifest?.display ?? "standalone" : "standalone";
195
196
  const installPrompt = typeof client.installPrompt === "undefined" || client.installPrompt === false ? void 0 : client.installPrompt === true || client.installPrompt.trim() === "" ? "vite-pwa:hide-install" : client.installPrompt.trim();
196
197
  return `export const enabled = ${client.registerPlugin}
198
+ export const display = '${display}'
197
199
  export const installPrompt = ${JSON.stringify(installPrompt)}
198
200
  export const periodicSyncForUpdates = ${typeof client.periodicSyncForUpdates === "number" ? client.periodicSyncForUpdates : 0}
199
201
  `;
@@ -1,6 +1,6 @@
1
1
  import { nextTick, reactive, ref } from "vue";
2
2
  import { useRegisterSW } from "virtual:pwa-register/vue";
3
- import { installPrompt, periodicSyncForUpdates } from "virtual:nuxt-pwa-configuration";
3
+ import { display, installPrompt, periodicSyncForUpdates } from "virtual:nuxt-pwa-configuration";
4
4
  import { defineNuxtPlugin } from "#imports";
5
5
  const plugin = defineNuxtPlugin(() => {
6
6
  const registrationError = ref(false);
@@ -9,8 +9,14 @@ const plugin = defineNuxtPlugin(() => {
9
9
  const hideInstall = ref(!installPrompt ? true : localStorage.getItem(installPrompt) === "true");
10
10
  const ua = navigator.userAgent;
11
11
  const ios = ua.match(/iPhone|iPad|iPod/);
12
- const standalone = window.matchMedia("(display-mode: standalone)").matches;
13
- const isInstalled = !!(standalone || ios && !ua.match(/Safari/));
12
+ const useDisplay = display === "standalone" || display === "minimal-ui" ? `${display}` : "standalone";
13
+ const standalone = window.matchMedia(`(display-mode: ${useDisplay})`).matches;
14
+ const isInstalled = ref(!!(standalone || ios && !ua.match(/Safari/)));
15
+ const isPWAInstalled = ref(isInstalled.value);
16
+ window.matchMedia(`(display-mode: ${useDisplay})`).addEventListener("change", (e) => {
17
+ if (!isPWAInstalled.value && e.matches)
18
+ isPWAInstalled.value = true;
19
+ });
14
20
  let swRegistration;
15
21
  const getSWRegistration = () => swRegistration;
16
22
  const registerPeriodicSync = (swUrl, r, timeout) => {
@@ -96,6 +102,7 @@ const plugin = defineNuxtPlugin(() => {
96
102
  provide: {
97
103
  pwa: reactive({
98
104
  isInstalled,
105
+ isPWAInstalled,
99
106
  showInstallPrompt,
100
107
  cancelInstall,
101
108
  install,
@@ -2,7 +2,11 @@ import type { Ref } from 'vue'
2
2
  import type { UnwrapNestedRefs } from 'vue'
3
3
 
4
4
  export interface PwaInjection {
5
+ /**
6
+ * @deprecated use `isPWAInstalled` instead
7
+ */
5
8
  isInstalled: boolean
9
+ isPWAInstalled: Ref<boolean>
6
10
  showInstallPrompt: Ref<boolean>
7
11
  cancelInstall: () => void
8
12
  install: () => Promise<void>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vite-pwa/nuxt",
3
3
  "type": "module",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "packageManager": "pnpm@8.11.0",
6
6
  "description": "Zero-config PWA for Nuxt 3",
7
7
  "author": "antfu <anthonyfu117@hotmail.com>",
@@ -97,4 +97,4 @@
97
97
  "stackblitz": {
98
98
  "startCommand": "nr prepack && nr dev:prepare && nr dev"
99
99
  }
100
- }
100
+ }