@vite-pwa/nuxt 1.1.1 → 2.0.1

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.
Files changed (50) hide show
  1. package/README.md +28 -59
  2. package/config/index.d.mts +1 -0
  3. package/config/index.mjs +3 -0
  4. package/configuration.d.ts +3 -0
  5. package/dist/chunks/create-nuxt-pwa-context.mjs +27 -0
  6. package/dist/chunks/prepare-module.mjs +871 -0
  7. package/dist/chunks/prepare-pwa-icons.mjs +161 -0
  8. package/dist/module.d.mts +42 -89
  9. package/dist/module.json +4 -4
  10. package/dist/module.mjs +40 -8
  11. package/dist/runtime/components/NuxtPwaAssets.d.ts +1 -1
  12. package/dist/runtime/components/NuxtPwaAssets.js +8 -4
  13. package/dist/runtime/components/{VitePwaManifest.d.ts → NuxtPwaManifest.d.ts} +1 -1
  14. package/dist/runtime/components/{VitePwaManifest.js → NuxtPwaManifest.js} +2 -2
  15. package/dist/runtime/{composables/index.d.ts → composables.d.ts} +12 -28
  16. package/dist/runtime/{composables/index.js → composables.js} +1 -11
  17. package/dist/runtime/plugins/pwa-install.client.d.ts +6 -0
  18. package/dist/runtime/plugins/pwa-install.client.js +70 -0
  19. package/dist/runtime/plugins/pwa.client.d.ts +1 -1
  20. package/dist/runtime/plugins/pwa.client.js +90 -77
  21. package/dist/runtime/plugins/types.d.ts +70 -129
  22. package/dist/runtime/plugins/types.js +0 -0
  23. package/dist/types.d.mts +5 -5
  24. package/package.json +40 -59
  25. package/dist/chunks/dev.mjs +0 -37
  26. package/dist/chunks/pwa-icons.mjs +0 -155
  27. package/dist/module.cjs +0 -5
  28. package/dist/module.d.ts +0 -110
  29. package/dist/runtime/components/PwaAppleImage.vue +0 -12
  30. package/dist/runtime/components/PwaAppleImage.vue.d.ts +0 -2
  31. package/dist/runtime/components/PwaAppleSplashScreenImage.vue +0 -12
  32. package/dist/runtime/components/PwaAppleSplashScreenImage.vue.d.ts +0 -2
  33. package/dist/runtime/components/PwaFaviconImage.vue +0 -12
  34. package/dist/runtime/components/PwaFaviconImage.vue.d.ts +0 -2
  35. package/dist/runtime/components/PwaMaskableImage.vue +0 -12
  36. package/dist/runtime/components/PwaMaskableImage.vue.d.ts +0 -2
  37. package/dist/runtime/components/PwaTransparentImage.vue +0 -12
  38. package/dist/runtime/components/PwaTransparentImage.vue.d.ts +0 -2
  39. package/dist/runtime/components/nuxt4/PwaAppleImage.d.ts +0 -4
  40. package/dist/runtime/components/nuxt4/PwaAppleImage.js +0 -15
  41. package/dist/runtime/components/nuxt4/PwaAppleSplashScreenImage.d.ts +0 -4
  42. package/dist/runtime/components/nuxt4/PwaAppleSplashScreenImage.js +0 -15
  43. package/dist/runtime/components/nuxt4/PwaFaviconImage.d.ts +0 -4
  44. package/dist/runtime/components/nuxt4/PwaFaviconImage.js +0 -15
  45. package/dist/runtime/components/nuxt4/PwaMaskableImage.d.ts +0 -4
  46. package/dist/runtime/components/nuxt4/PwaMaskableImage.js +0 -15
  47. package/dist/runtime/components/nuxt4/PwaTransparentImage.d.ts +0 -4
  48. package/dist/runtime/components/nuxt4/PwaTransparentImage.js +0 -15
  49. package/dist/shared/nuxt.9518178d.mjs +0 -734
  50. package/dist/types.d.ts +0 -15
@@ -1,63 +1,86 @@
1
- import { defineNuxtPlugin } from "#imports";
2
- import { display, installPrompt, periodicSyncForUpdates } from "virtual:nuxt-pwa-configuration";
1
+ import {
2
+ activateSWSwitcherDev,
3
+ callBeforeRegisterHook,
4
+ initializeDev,
5
+ periodicSyncForUpdates
6
+ } from "virtual:nuxt-pwa-configuration";
3
7
  import { useRegisterSW } from "virtual:pwa-register/vue";
4
- import { nextTick, reactive, ref } from "vue";
8
+ import { defineNuxtPlugin, reactive, ref } from "#imports";
5
9
  const plugin = defineNuxtPlugin({
6
10
  name: "vite-pwa:nuxt:client:plugin",
7
11
  enforce: "post",
8
12
  parallel: true,
9
- setup(nuxtApp) {
13
+ async setup(nuxtApp) {
14
+ if (import.meta.dev) {
15
+ initializeDev();
16
+ }
10
17
  const registrationError = ref(false);
11
18
  const swActivated = ref(false);
12
- const showInstallPrompt = ref(false);
13
- const hideInstall = ref(!installPrompt ? true : localStorage.getItem(installPrompt) === "true");
14
- const ua = navigator.userAgent;
15
- const ios = ua.match(/iPhone|iPad|iPod/);
16
- const useDisplay = display === "standalone" || display === "minimal-ui" ? `${display}` : "standalone";
17
- const standalone = window.matchMedia(`(display-mode: ${useDisplay})`).matches;
18
- const isInstalled = ref(!!(standalone || ios && !ua.match(/Safari/)));
19
- const isPWAInstalled = ref(isInstalled.value);
20
- window.matchMedia(`(display-mode: ${useDisplay})`).addEventListener("change", (e) => {
21
- if (!isPWAInstalled.value && e.matches)
22
- isPWAInstalled.value = true;
23
- });
24
- let swRegistration;
25
- const getSWRegistration = () => swRegistration;
26
- const registerPeriodicSync = (swUrl, r, timeout) => {
19
+ function registerPeriodicSync(swUrl, r, timeout) {
27
20
  setInterval(async () => {
28
- if (r && r.installing || "connection" in navigator && !navigator.onLine)
21
+ if (r && r.installing || "connection" in navigator && !navigator.onLine) {
29
22
  return;
30
- const resp = await fetch(swUrl, {
31
- cache: "no-store",
32
- headers: {
33
- "cache": "no-store",
34
- "cache-control": "no-cache"
23
+ }
24
+ try {
25
+ const resp = await fetch(
26
+ swUrl,
27
+ {
28
+ cache: "no-store",
29
+ headers: {
30
+ "cache": "no-store",
31
+ "cache-control": "no-cache"
32
+ }
33
+ }
34
+ );
35
+ if (resp?.status === 200) {
36
+ await r.update();
35
37
  }
36
- });
37
- if (resp?.status === 200)
38
- await r.update();
38
+ } catch (error) {
39
+ await nuxtApp.hooks.callHook(
40
+ "service-worker:periodic-sync-update-failed",
41
+ {
42
+ url: swUrl,
43
+ error,
44
+ registration: r
45
+ }
46
+ );
47
+ }
39
48
  }, timeout);
40
- };
41
- const {
42
- offlineReady,
43
- needRefresh,
44
- updateServiceWorker
45
- } = useRegisterSW({
49
+ }
50
+ const hooks = nuxtApp.hooks;
51
+ const options = {
46
52
  immediate: true,
47
53
  onRegisterError(error) {
48
- nuxtApp.hooks.callHook("service-worker:registration-failed", { error });
54
+ hooks.callHook(
55
+ "service-worker:registration-failed",
56
+ { error }
57
+ );
49
58
  registrationError.value = true;
50
59
  },
51
60
  onRegisteredSW(swUrl, r) {
52
- swRegistration = r;
61
+ if (import.meta.dev) {
62
+ activateSWSwitcherDev();
63
+ }
53
64
  const timeout = periodicSyncForUpdates;
54
- nuxtApp.hooks.callHook("service-worker:registered", { url: swUrl, registration: r });
65
+ nuxtApp.hooks.callHook(
66
+ "service-worker:registered",
67
+ {
68
+ url: swUrl,
69
+ registration: r
70
+ }
71
+ );
55
72
  if (r?.active?.state === "activated") {
56
73
  swActivated.value = true;
57
74
  if (timeout > 0) {
58
75
  registerPeriodicSync(swUrl, r, timeout * 1e3);
59
76
  }
60
- nuxtApp.hooks.callHook("service-worker:activated", { url: swUrl, registration: r });
77
+ nuxtApp.hooks.callHook(
78
+ "service-worker:activated",
79
+ {
80
+ url: swUrl,
81
+ registration: r
82
+ }
83
+ );
61
84
  } else if (r?.installing) {
62
85
  r.installing.addEventListener("statechange", (e) => {
63
86
  const sw = e.target;
@@ -66,53 +89,44 @@ const plugin = defineNuxtPlugin({
66
89
  if (timeout > 0) {
67
90
  registerPeriodicSync(swUrl, r, timeout * 1e3);
68
91
  }
69
- nuxtApp.hooks.callHook("service-worker:activated", { url: swUrl, registration: r });
92
+ nuxtApp.hooks.callHook(
93
+ "service-worker:activated",
94
+ {
95
+ url: swUrl,
96
+ registration: r
97
+ }
98
+ );
70
99
  }
71
100
  });
72
101
  }
73
102
  }
74
- });
75
- const cancelPrompt = async () => {
76
- offlineReady.value = false;
77
- needRefresh.value = false;
78
103
  };
79
- let install = () => Promise.resolve(void 0);
80
- let cancelInstall = () => {
81
- };
82
- if (!hideInstall.value) {
83
- let deferredPrompt;
84
- const beforeInstallPrompt = (e) => {
85
- e.preventDefault();
86
- deferredPrompt = e;
87
- showInstallPrompt.value = true;
88
- };
89
- window.addEventListener("beforeinstallprompt", beforeInstallPrompt);
90
- window.addEventListener("appinstalled", () => {
91
- deferredPrompt = void 0;
92
- showInstallPrompt.value = false;
93
- });
94
- cancelInstall = () => {
95
- deferredPrompt = void 0;
96
- showInstallPrompt.value = false;
97
- window.removeEventListener("beforeinstallprompt", beforeInstallPrompt);
98
- hideInstall.value = true;
99
- localStorage.setItem(installPrompt, "true");
100
- };
101
- install = async () => {
102
- if (!showInstallPrompt.value || !deferredPrompt) {
103
- showInstallPrompt.value = false;
104
- return void 0;
104
+ if (callBeforeRegisterHook) {
105
+ await hooks.callHook(
106
+ "service-worker:before-register",
107
+ (trustedScriptUrl) => {
108
+ options.trustedScriptUrl = trustedScriptUrl;
105
109
  }
106
- showInstallPrompt.value = false;
107
- await nextTick();
108
- deferredPrompt.prompt();
109
- return await deferredPrompt.userChoice;
110
- };
110
+ );
111
111
  }
112
+ const {
113
+ offlineReady,
114
+ needRefresh,
115
+ updateServiceWorker
116
+ } = useRegisterSW(options);
117
+ async function cancelPrompt() {
118
+ offlineReady.value = false;
119
+ needRefresh.value = false;
120
+ }
121
+ const {
122
+ isPWAInstalled,
123
+ showInstallPrompt,
124
+ cancelInstall,
125
+ install
126
+ } = nuxtApp.$pwaInstallPrompt;
112
127
  return {
113
128
  provide: {
114
129
  pwa: reactive({
115
- isInstalled,
116
130
  isPWAInstalled,
117
131
  showInstallPrompt,
118
132
  cancelInstall,
@@ -122,8 +136,7 @@ const plugin = defineNuxtPlugin({
122
136
  offlineReady,
123
137
  needRefresh,
124
138
  updateServiceWorker,
125
- cancelPrompt,
126
- getSWRegistration
139
+ cancelPrompt
127
140
  })
128
141
  }
129
142
  };
@@ -1,149 +1,90 @@
1
- import type { Ref } from 'vue'
2
- import type { UnwrapNestedRefs } from 'vue'
3
-
1
+ import type { Ref } from 'vue';
4
2
  /**
5
3
  * Result of the native PWA installation prompt.
6
4
  */
7
5
  export interface UserChoice {
8
- /**
9
- * The user's selection on the install prompt.
10
- */
11
- outcome: 'accepted' | 'dismissed'
12
- /**
13
- * Platform identifier provided by the browser for where the prompt was shown
14
- * (for example, 'web' or a store-specific value). The exact values are
15
- * browser-dependent and not standardized.
16
- */
17
- platform: string
6
+ /**
7
+ * The user's selection on the installation prompt.
8
+ */
9
+ outcome: 'accepted' | 'dismissed';
10
+ /**
11
+ * Platform identifier provided by the browser for where the prompt was shown
12
+ * (for example, 'web' or a store-specific value). The exact values are
13
+ * browser-dependent and not standardized.
14
+ */
15
+ platform: string;
18
16
  }
19
-
20
17
  /**
21
18
  * Browser event fired before showing the native PWA install prompt.
22
19
  *
23
20
  * This event allows delaying the native prompt and showing a custom UI first.
24
21
  */
25
22
  export type BeforeInstallPromptEvent = Event & {
26
- /**
27
- * Triggers the browser's native install prompt.
28
- */
29
- prompt: () => void
30
- /**
31
- * Resolves with the user's selection once they interact with the prompt.
32
- */
33
- userChoice: Promise<UserChoice>
23
+ /**
24
+ * Triggers the browser's native installation prompt.
25
+ */
26
+ prompt: () => void;
27
+ /**
28
+ * Resolves with the user's selection once they interact with the prompt.
29
+ */
30
+ userChoice: Promise<UserChoice>;
31
+ };
32
+ /**
33
+ * PWA Install Prompt state and helpers injected into Nuxt as `$pwaInstallPrompt`.
34
+ */
35
+ export interface PwaInstallPromptInjection {
36
+ /**
37
+ * Whether the app is currently installed as a PWA.
38
+ * This value updates as installation state changes (e.g. display-mode changes).
39
+ */
40
+ isPWAInstalled: Ref<boolean>;
41
+ /**
42
+ * When `true`, your UI should show a custom installation prompt. This flag is set
43
+ * after the `beforeinstallprompt` event is captured and cleared when the user
44
+ * proceeds or cancels.
45
+ */
46
+ showInstallPrompt: Ref<boolean>;
47
+ /**
48
+ * Cancels the custom install flow and hides future prompts by setting an
49
+ * opt-out flag (stored in `localStorage` when configured via `installPrompt`).
50
+ */
51
+ cancelInstall: () => void;
52
+ /**
53
+ * Shows the native installation prompt if available and returns the user's choice.
54
+ * Returns `undefined` when the prompt is not available or not currently shown.
55
+ */
56
+ install: () => Promise<UserChoice | undefined>;
34
57
  }
35
-
36
58
  /**
37
59
  * Reactive PWA state and helpers injected into Nuxt as `$pwa`.
38
60
  */
39
- export interface PwaInjection {
40
- /**
41
- * @deprecated Use `isPWAInstalled` instead. Legacy boolean computed from
42
- * browser heuristics to detect if the app is installed.
43
- */
44
- isInstalled: boolean
45
- /**
46
- * Whether the app is currently installed as a PWA.
47
- * This value updates as installation state changes (e.g. display-mode changes).
48
- */
49
- isPWAInstalled: Ref<boolean>
50
- /**
51
- * When `true`, your UI should show a custom install prompt. This flag is set
52
- * after the `beforeinstallprompt` event is captured and cleared when the user
53
- * proceeds or cancels.
54
- */
55
- showInstallPrompt: Ref<boolean>
56
- /**
57
- * Cancels the custom install flow and hides future prompts by setting an
58
- * opt-out flag (stored in `localStorage` when configured via `installPrompt`).
59
- */
60
- cancelInstall: () => void
61
- /**
62
- * Shows the native install prompt if available and returns the user's choice.
63
- * Returns `undefined` when the prompt is not available or not currently shown.
64
- */
65
- install: () => Promise<UserChoice | undefined>
66
- /**
67
- * Whether the service worker has reached the `activated` state.
68
- */
69
- swActivated: Ref<boolean>
70
- /**
71
- * Indicates that registering the service worker failed.
72
- */
73
- registrationError: Ref<boolean>
74
- /**
75
- * Becomes `true` when the app is ready to work offline (precache completed).
76
- * This flag is activated only once, when the service worker is registered and activated for first time.
77
- */
78
- offlineReady: Ref<boolean>
79
- /**
80
- * Becomes `true` when a new service worker is waiting to activate and a
81
- * refresh is recommended to apply updates.
82
- */
83
- needRefresh: Ref<boolean>
84
- /**
85
- * Applies the waiting service worker. When `reloadPage` is `true`, reloads
86
- * the page after activating the new service worker.
87
- */
88
- updateServiceWorker: (reloadPage?: boolean | undefined) => Promise<void>
89
- /**
90
- * Dismisses update/install notifications by resetting `offlineReady` and
91
- * `needRefresh` to `false`.
92
- */
93
- cancelPrompt: () => Promise<void>
94
- /**
95
- * From version 0.10.8 it is deprecated, use a plugin instead with the new Nuxt Runtime Client Hooks:
96
- * ```ts
97
- * // plugins/pwa.client.ts
98
- * export default defineNuxtPlugin((nuxtApp) => {
99
- * nuxtApp.hook('service-worker:registered', ({ url, registration }) => {
100
- * // eslint-disable-next-line no-console
101
- * console.log(`service worker registered at ${url}`, registration)
102
- * })
103
- * nuxtApp.hook('service-worker:registration-failed', ({ error }) => {
104
- * console.error(`service worker registration failed`, error)
105
- * })
106
- * nuxtApp.hook('service-worker:activated', ({ url, registration }) => {
107
- * // eslint-disable-next-line no-console
108
- * console.log(`service worker activated at ${url}`, registration)
109
- * })
110
- * })
111
- * ```
112
- *
113
- * @deprecated Directly access the registration in your own plugin via the
114
- * runtime client hooks instead.
115
- */
116
- getSWRegistration: () => ServiceWorkerRegistration | undefined
117
- }
118
-
119
- declare module '#app' {
120
- interface NuxtApp {
61
+ export interface PwaInjection extends PwaInstallPromptInjection {
121
62
  /**
122
- * Reactive PWA state and controls provided by @vite-pwa/nuxt.
123
- *
124
- * Example:
125
- * ```ts
126
- * const { $pwa } = useNuxtApp()
127
- * if ($pwa?.needRefresh) await $pwa.updateServiceWorker(true)
128
- * ```
63
+ * Whether the service worker has reached the `activated` state.
129
64
  */
130
- $pwa?: UnwrapNestedRefs<PwaInjection>
131
- }
132
- }
133
-
134
- declare module 'vue' {
135
- interface ComponentCustomProperties {
65
+ swActivated: Ref<boolean>;
66
+ /**
67
+ * Indicates that registering the service worker failed.
68
+ */
69
+ registrationError: Ref<boolean>;
70
+ /**
71
+ * Becomes `true` when the app is ready to work offline (precache completed).
72
+ * This flag is activated only once, when the service worker is registered and activated for first time.
73
+ */
74
+ offlineReady: Ref<boolean>;
75
+ /**
76
+ * Becomes `true` when a new service worker is waiting to activate and a
77
+ * refresh is recommended to apply updates.
78
+ */
79
+ needRefresh: Ref<boolean>;
80
+ /**
81
+ * Applies the waiting service worker. When `reloadPage` is `true`, reloads
82
+ * the page after activating the new service worker.
83
+ */
84
+ updateServiceWorker: (reloadPage?: boolean | undefined) => Promise<void>;
136
85
  /**
137
- * Reactive PWA state and controls provided by @vite-pwa/nuxt.
138
- *
139
- * Example:
140
- * ```ts
141
- * const { $pwa } = useNuxtApp()
142
- * if ($pwa?.needRefresh) await $pwa.updateServiceWorker(true)
143
- * ```
86
+ * Dismisses service worker update/installed notifications by resetting `offlineReady` and
87
+ * `needRefresh` to `false`.
144
88
  */
145
- $pwa?: UnwrapNestedRefs<PwaInjection>
146
- }
89
+ cancelPrompt: () => Promise<void>;
147
90
  }
148
-
149
- export {}
File without changes
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ModuleHooks, ModuleRuntimeHooks } from './module.js'
1
+ import type { ModuleHooks, ModuleRuntimeHooks } from './module.mjs'
2
2
 
3
3
  declare module '#app' {
4
4
  interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
@@ -8,8 +8,8 @@ declare module '@nuxt/schema' {
8
8
  interface NuxtHooks extends ModuleHooks {}
9
9
  }
10
10
 
11
- declare module 'nuxt/schema' {
12
- interface NuxtHooks extends ModuleHooks {}
13
- }
11
+ export { type definePwaConfig } from '@vite-pwa/nuxt-core/config'
12
+
13
+ export { default } from './module.mjs'
14
14
 
15
- export { type ClientOptions, type ModuleHooks, type ModuleOptions, type ModuleRuntimeHooks, type PwaModuleHooks, type PwaModuleOptions, default } from './module.js'
15
+ export { type BeforeBuildServiceWorkerHook, type ModuleHooks, type ModuleOptions, type ModuleRuntimeHooks, type PWAModuleRuntimeHooks, type PwaModuleHooks, type PwaModuleOptions, type ServiceWorkerPeriodicSyncUpdateError, type ServiceWorkerRegistrationErrorOptions, type ServiceWorkerRuntimeHooksOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "@vite-pwa/nuxt",
3
3
  "type": "module",
4
- "version": "1.1.1",
5
- "description": "Zero-config PWA for Nuxt 3",
4
+ "version": "2.0.1",
5
+ "description": "Zero-config PWA for Nuxt",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/antfu",
9
9
  "homepage": "https://github.com/vite-pwa/nuxt#readme",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+https://github.com/vite-pwa/nuxt.git"
12
+ "url": "git+https://github.com/vite-pwa/nuxt.git",
13
+ "directory": "packages/module"
13
14
  },
14
15
  "bugs": "https://github.com/vite-pwa/nuxt/issues",
15
16
  "keywords": [
16
17
  "nuxt",
17
18
  "pwa",
18
19
  "workbox",
19
- "vite-plugin-pwa",
20
+ "unplugin-pwa",
20
21
  "nuxt-module"
21
22
  ],
22
23
  "exports": {
@@ -24,53 +25,49 @@
24
25
  "types": "./dist/types.d.mts",
25
26
  "default": "./dist/module.mjs"
26
27
  },
28
+ "./config": "./config/index.mjs",
27
29
  "./configuration": {
28
30
  "types": "./configuration.d.ts"
29
31
  },
30
- "./package.json": "./package.json",
31
- "./*": "./*"
32
+ "./package.json": "./package.json"
32
33
  },
33
34
  "main": "./dist/module.mjs",
34
- "types": "./dist/types.d.ts",
35
+ "types": "./dist/types.d.mts",
35
36
  "files": [
36
37
  "*.d.ts",
38
+ "config",
37
39
  "dist"
38
40
  ],
39
41
  "peerDependencies": {
40
- "@vite-pwa/assets-generator": "^1.0.0"
42
+ "@vite-pwa/assets-generator": "^1.0.0 || ^2.0.0",
43
+ "magicast": "^0.5.0",
44
+ "rolldown": "^1.0.0-0"
41
45
  },
42
46
  "peerDependenciesMeta": {
43
47
  "@vite-pwa/assets-generator": {
44
48
  "optional": true
49
+ },
50
+ "magicast": {
51
+ "optional": true
52
+ },
53
+ "rolldown": {
54
+ "optional": true
45
55
  }
46
56
  },
47
57
  "dependencies": {
48
- "@nuxt/kit": "^3.9.0",
49
- "pathe": "^1.1.1",
50
- "ufo": "^1.3.2",
51
- "vite-plugin-pwa": "^1.2.0"
58
+ "@nuxt/kit": "^4.6.4",
59
+ "@unplugin-pwa/core": "^0.0.6",
60
+ "@vite-pwa/nuxt-core": "2.0.1",
61
+ "@vite-pwa/nuxt-vite": "2.0.1",
62
+ "@vite-pwa/workbox-build": "^8.0.15",
63
+ "defu": "^6.1.7",
64
+ "verkit": "^0.5.0"
52
65
  },
53
66
  "devDependencies": {
54
- "@antfu/eslint-config": "^4.11.0",
55
- "@antfu/ni": "^0.21.10",
56
- "@nuxt/module-builder": "^0.8.3",
57
- "@nuxt/schema": "^3.10.1",
58
- "@nuxt/test-utils": "^3.11.0",
59
- "@playwright/test": "^1.40.1",
60
- "@types/node": "^18",
61
- "bumpp": "^9.2.0",
62
- "eslint": "^9.23.0",
63
- "node-fetch-native": "^1.4.1",
64
- "nuxt": "^3.10.1",
65
- "publint": "^0.2.5",
66
- "rimraf": "^5.0.5",
67
- "serve": "^14.2.1",
68
- "typescript": "^5.4.5",
69
- "vitest": "^1.1.0",
70
- "vue-tsc": "^1.8.27"
71
- },
72
- "resolutions": {
73
- "@nuxt/kit": "^3.10.1"
67
+ "@nuxt/devtools": "^4.1.0",
68
+ "@nuxt/schema": "^4.6.4",
69
+ "@vite-pwa/assets-generator": "^2.0.0",
70
+ "nuxt": "^4.6.4"
74
71
  },
75
72
  "build": {
76
73
  "externals": [
@@ -81,38 +78,22 @@
81
78
  "h3",
82
79
  "pathe",
83
80
  "rollup",
81
+ "rolldown",
84
82
  "ufo",
85
83
  "vite",
86
- "vite-plugin-pwa"
84
+ "@unplugin-pwa/core",
85
+ "@unplugin-pwa/vite",
86
+ "@vite-pwa/workbox-build",
87
+ "@vite-pwa/workbox-swkit",
88
+ "@vite-pwa/workbox-window"
87
89
  ]
88
90
  },
89
- "stackblitz": {
90
- "startCommand": "nr prepack && nr dev:prepare && nr dev"
91
+ "publishConfig": {
92
+ "access": "public",
93
+ "provenance": true
91
94
  },
92
95
  "scripts": {
93
- "dev": "nuxi dev playground",
94
- "dev:generate": "nuxi generate playground",
95
- "dev:generate:netlify": "NITRO_PRESET=netlify nuxi generate playground",
96
- "dev:generate:vercel": "NITRO_PRESET=vercel nuxi generate playground",
97
- "dev:build": "nuxi build playground",
98
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
99
- "dev:preview:build": "nr dev:build && node playground/.output/server/index.mjs",
100
- "dev:preview:generate": "nr dev:generate && serve playground/dist",
101
- "dev:assets:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground-assets",
102
- "dev:assets": "nr dev:assets:prepare && nuxi dev playground-assets",
103
- "dev:assets:generate": "nr dev:assets:prepare && nuxi generate playground-assets",
104
- "dev:assets:build": "nr dev:assets:prepare && nuxi build playground-assets",
105
- "release": "bumpp",
106
- "lint": "eslint .",
107
- "lint:fix": "nr lint --fix",
108
- "test:build:serve": "PORT=4173 node playground/.output/server/index.mjs",
109
- "test:generate:serve": "PORT=4173 serve playground/dist",
110
- "test:build": "nr dev:build && NUXT_ECOSYSTEM_CI=true TEST_BUILD=true vitest run && TEST_BUILD=true playwright test",
111
- "test:generate": "nr dev:generate && NUXT_ECOSYSTEM_CI=true vitest run && playwright test",
112
- "test:build:local": "nr dev:build && TEST_BUILD=true vitest run && TEST_BUILD=true playwright test",
113
- "test:generate:local": "nr dev:generate && vitest run && playwright test",
114
- "test:local": "nr test:build:local && nr test:generate:local",
115
- "test": "nr test:build && nr test:generate",
116
- "test:with-build": "nr dev:prepare && nr prepack && nr test"
96
+ "build": "nuxt-module-build prepare && nuxt-module-build build",
97
+ "test:typecheck": "vue-tsc --noEmit"
117
98
  }
118
99
  }
@@ -1,37 +0,0 @@
1
- import fs from 'node:fs';
2
- import { join } from 'node:path';
3
- import { eventHandler } from 'h3';
4
-
5
- function dev(swMap, resolvedSwMapFile, worboxMap, buildDir, baseURL) {
6
- return eventHandler(async (event) => {
7
- const url = event.path;
8
- if (!url)
9
- return;
10
- const file = url === swMap ? resolvedSwMapFile : url.startsWith(worboxMap) && url.endsWith(".js.map") ? join(
11
- buildDir,
12
- "dev-sw-dist",
13
- url.slice(baseURL.length)
14
- ) : void 0;
15
- if (file) {
16
- try {
17
- await waitFor(() => fs.existsSync(file));
18
- const map = fs.readFileSync(file, "utf-8");
19
- event.headers.set("Content-Type", "application/json");
20
- event.headers.set("Cache-Control", "public, max-age=0, must-revalidate");
21
- event.headers.set("Content-Length", `${map.length}`);
22
- event.node.res.end(map);
23
- } catch {
24
- }
25
- }
26
- });
27
- }
28
- async function waitFor(method, retries = 5) {
29
- if (method())
30
- return;
31
- if (retries === 0)
32
- throw new Error("Timeout in waitFor");
33
- await new Promise((resolve) => setTimeout(resolve, 300));
34
- return waitFor(method, retries - 1);
35
- }
36
-
37
- export { dev };