@vite-pwa/nuxt 0.0.1 → 0.0.2
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.
- package/dist/module.d.ts +3 -13
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -1
- package/dist/types.d.ts +6 -2
- package/package.json +3 -2
- package/templates/pwa.client.ts +7 -1
package/dist/module.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface ClientOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
installPrompt?: boolean | string;
|
|
23
23
|
}
|
|
24
|
-
interface
|
|
24
|
+
interface ModuleOptions extends Partial<VitePWAOptions> {
|
|
25
25
|
registerWebManifestInRouteRules?: boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Writes the plugin to disk: defaults to false (debug).
|
|
@@ -31,18 +31,8 @@ interface VitePWANuxtOptions extends Partial<VitePWAOptions> {
|
|
|
31
31
|
* Options for plugin.
|
|
32
32
|
*/
|
|
33
33
|
client?: ClientOptions;
|
|
34
|
-
}
|
|
35
|
-
declare module '@nuxt/schema' {
|
|
36
|
-
interface NuxtConfig {
|
|
37
|
-
pwa?: {
|
|
38
|
-
[K in keyof VitePWANuxtOptions]?: Partial<VitePWANuxtOptions[K]>;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
interface NuxtOptions {
|
|
42
|
-
pwa: VitePWANuxtOptions;
|
|
43
|
-
}
|
|
44
34
|
}
|
|
45
35
|
|
|
46
|
-
declare const _default: _nuxt_schema.NuxtModule<
|
|
36
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
47
37
|
|
|
48
|
-
export { ClientOptions,
|
|
38
|
+
export { ClientOptions, ModuleOptions, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -54,6 +54,7 @@ const module = defineNuxtModule({
|
|
|
54
54
|
injectRegister: false,
|
|
55
55
|
includeManifestIcons: false,
|
|
56
56
|
registerPlugin: true,
|
|
57
|
+
writePlugin: false,
|
|
57
58
|
client: {
|
|
58
59
|
registerPlugin: true,
|
|
59
60
|
installPrompt: false,
|
|
@@ -70,7 +71,7 @@ const module = defineNuxtModule({
|
|
|
70
71
|
if (client.registerPlugin) {
|
|
71
72
|
addPluginTemplate({
|
|
72
73
|
src: resolver.resolve("../templates/pwa.client.ts"),
|
|
73
|
-
write:
|
|
74
|
+
write: options.writePlugin,
|
|
74
75
|
options: {
|
|
75
76
|
periodicSyncForUpdates: typeof client.periodicSyncForUpdates === "number" ? client.periodicSyncForUpdates : 0,
|
|
76
77
|
installPrompt: typeof client.installPrompt === "undefined" || client.installPrompt === false ? void 0 : client.installPrompt === true || client.installPrompt.trim() === "" ? "vite-pwa:hide-install" : client.installPrompt.trim()
|
|
@@ -81,6 +82,9 @@ const module = defineNuxtModule({
|
|
|
81
82
|
name: "VitePwaManifest",
|
|
82
83
|
filePath: resolver.resolve("./runtime/VitePwaManifest")
|
|
83
84
|
});
|
|
85
|
+
nuxt.hook("prepare:types", ({ references }) => {
|
|
86
|
+
references.push({ types: "vite-plugin-pwa/client" });
|
|
87
|
+
});
|
|
84
88
|
nuxt.hook("nitro:init", (nitro) => {
|
|
85
89
|
options.outDir = nitro.options.output.publicDir;
|
|
86
90
|
options.injectManifest = options.injectManifest || {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { ModuleOptions } from './module'
|
|
3
3
|
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['pwa']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['pwa']?: ModuleOptions }
|
|
7
|
+
}
|
|
4
8
|
|
|
5
9
|
|
|
6
|
-
export { ClientOptions,
|
|
10
|
+
export { ClientOptions, ModuleOptions, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-pwa/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"packageManager": "pnpm@7.26.1",
|
|
6
6
|
"description": "Zero-config PWA for Nuxt 3",
|
|
7
7
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"types": "./dist/types.d.ts",
|
|
25
26
|
"require": "./dist/module.cjs",
|
|
26
27
|
"import": "./dist/module.mjs"
|
|
27
28
|
}
|
|
@@ -70,4 +71,4 @@
|
|
|
70
71
|
"vite-plugin-pwa"
|
|
71
72
|
]
|
|
72
73
|
}
|
|
73
|
-
}
|
|
74
|
+
}
|
package/templates/pwa.client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, reactive, nextTick } from 'vue'
|
|
2
2
|
import { useRegisterSW } from 'virtual:pwa-register/vue'
|
|
3
|
-
import { defineNuxtPlugin } from '#
|
|
3
|
+
import { defineNuxtPlugin } from '#imports'
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
const options: { periodicSyncForUpdates: number; installPrompt?: string } = <%= JSON.stringify(options) %>
|
|
@@ -17,6 +17,10 @@ export default defineNuxtPlugin(() => {
|
|
|
17
17
|
const standalone = window.matchMedia('(display-mode: standalone)').matches
|
|
18
18
|
const isInstalled = !!(standalone || (ios && !ua.match(/Safari/)))
|
|
19
19
|
|
|
20
|
+
let swRegistration: ServiceWorkerRegistration | undefined
|
|
21
|
+
|
|
22
|
+
const getSWRegistration = () => swRegistration
|
|
23
|
+
|
|
20
24
|
const registerPeriodicSync = (swUrl: string, r: ServiceWorkerRegistration, timeout: number) => {
|
|
21
25
|
setInterval(async () => {
|
|
22
26
|
if (('connection' in navigator) && !navigator.onLine)
|
|
@@ -43,6 +47,7 @@ export default defineNuxtPlugin(() => {
|
|
|
43
47
|
registrationError.value = true
|
|
44
48
|
},
|
|
45
49
|
onRegisteredSW(swUrl, r) {
|
|
50
|
+
swRegistration = r
|
|
46
51
|
const timeout = options.periodicSyncForUpdates
|
|
47
52
|
if (timeout > 0) {
|
|
48
53
|
// should add support in pwa plugin
|
|
@@ -124,6 +129,7 @@ export default defineNuxtPlugin(() => {
|
|
|
124
129
|
needRefresh,
|
|
125
130
|
updateServiceWorker,
|
|
126
131
|
cancelPrompt,
|
|
132
|
+
getSWRegistration,
|
|
127
133
|
}),
|
|
128
134
|
},
|
|
129
135
|
}
|