@serwist/nuxt 9.1.1 → 10.0.0-preview.10
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.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
import path from 'node:path';
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, extendWebpackConfig } from '@nuxt/kit';
|
3
|
-
import {
|
3
|
+
import { resolveEntry } from '@serwist/utils/node';
|
4
|
+
import { createContext, main, dev, generateServiceWorker } from 'vite-plugin-serwist';
|
4
5
|
import { createHash } from 'node:crypto';
|
5
6
|
import { createReadStream } from 'node:fs';
|
6
7
|
import fsp from 'node:fs/promises';
|
7
8
|
|
8
|
-
const version = "
|
9
|
+
const version = "10.0.0-preview.10";
|
10
|
+
const packageJson = {
|
11
|
+
version: version};
|
9
12
|
|
10
13
|
function configurePwaOptions(options, nuxt, nitroConfig) {
|
11
14
|
let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
|
@@ -83,7 +86,7 @@ const module = defineNuxtModule({
|
|
83
86
|
compatibility: {
|
84
87
|
nuxt: "^3.8.0 || ^4.0.0"
|
85
88
|
},
|
86
|
-
version
|
89
|
+
version: packageJson.version
|
87
90
|
},
|
88
91
|
defaults(nuxt) {
|
89
92
|
const publicDir = path.resolve(nuxt.options.rootDir, ".output/public");
|
@@ -105,7 +108,6 @@ const module = defineNuxtModule({
|
|
105
108
|
async setup(options, nuxt) {
|
106
109
|
const resolver = createResolver(import.meta.url);
|
107
110
|
let ctx;
|
108
|
-
let api;
|
109
111
|
const { client: _client, ...userOptions } = options;
|
110
112
|
const client = { registerPlugin: true, ..._client };
|
111
113
|
const runtimeDir = resolver.resolve("./runtime");
|
@@ -123,19 +125,15 @@ const module = defineNuxtModule({
|
|
123
125
|
configurePwaOptions(options, nuxt, nitro.options);
|
124
126
|
});
|
125
127
|
nuxt.hook("vite:extend", ({ config }) => {
|
126
|
-
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "
|
128
|
+
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
127
129
|
if (plugin) {
|
128
|
-
throw new Error("Remove '
|
130
|
+
throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
129
131
|
}
|
130
132
|
});
|
131
133
|
nuxt.hook("vite:extendConfig", async (viteInlineConfig, { isClient }) => {
|
132
|
-
if (!viteInlineConfig.plugins)
|
133
|
-
|
134
|
-
|
135
|
-
const plugin = viteInlineConfig.plugins.find((p) => p && typeof p === "object" && "name" in p && p.name === "@serwist/vite");
|
136
|
-
if (plugin) {
|
137
|
-
throw new Error("Remove '@serwist/vite' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
138
|
-
}
|
134
|
+
if (!viteInlineConfig.plugins) viteInlineConfig.plugins = [];
|
135
|
+
const plugin = viteInlineConfig.plugins.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
136
|
+
if (plugin) throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
139
137
|
if (isClient) {
|
140
138
|
const configuration = "virtual:serwist-nuxt-configuration";
|
141
139
|
const resolvedConfiguration = `\0${configuration}`;
|
@@ -157,19 +155,14 @@ const module = defineNuxtModule({
|
|
157
155
|
});
|
158
156
|
}
|
159
157
|
ctx = createContext(userOptions, "nuxt");
|
160
|
-
|
161
|
-
const plugins = [main(ctx, api), dev(ctx, api)];
|
162
|
-
viteInlineConfig.plugins.push(plugins);
|
158
|
+
viteInlineConfig.plugins.push(main(ctx), dev(ctx));
|
163
159
|
});
|
164
160
|
extendWebpackConfig(() => {
|
165
161
|
throw new Error("Webpack is not supported: '@serwist/nuxt' can only be used with Vite!");
|
166
162
|
});
|
167
163
|
if (!nuxt.options.dev) {
|
168
164
|
nuxt.hook("nitro:build:public-assets", () => {
|
169
|
-
if (
|
170
|
-
return;
|
171
|
-
}
|
172
|
-
void api.generateSW();
|
165
|
+
if (ctx && !ctx.options.disable) void generateServiceWorker(ctx);
|
173
166
|
});
|
174
167
|
}
|
175
168
|
}
|
@@ -2,18 +2,18 @@ import type { Serwist } from "@serwist/window";
|
|
2
2
|
|
3
3
|
declare module "#app" {
|
4
4
|
interface NuxtApp {
|
5
|
-
$serwist: Serwist |
|
5
|
+
$serwist: Serwist | null;
|
6
6
|
}
|
7
7
|
}
|
8
8
|
|
9
9
|
declare module "vue" {
|
10
10
|
interface ComponentCustomProperties {
|
11
|
-
$serwist: Serwist |
|
11
|
+
$serwist: Serwist | null;
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
15
15
|
declare module "@vue/runtime-core" {
|
16
16
|
interface ComponentCustomProperties {
|
17
|
-
$serwist: Serwist |
|
17
|
+
$serwist: Serwist | null;
|
18
18
|
}
|
19
19
|
}
|
@@ -1,10 +1,12 @@
|
|
1
|
-
import {
|
1
|
+
import { useSerwist } from "virtual:serwist/vue";
|
2
2
|
import { defineNuxtPlugin } from "#imports";
|
3
|
-
const plugin = defineNuxtPlugin(
|
4
|
-
const serwist =
|
3
|
+
const plugin = defineNuxtPlugin(() => {
|
4
|
+
const serwist = useSerwist();
|
5
5
|
return {
|
6
6
|
provide: {
|
7
|
-
serwist
|
7
|
+
get serwist() {
|
8
|
+
return serwist.value;
|
9
|
+
}
|
8
10
|
}
|
9
11
|
};
|
10
12
|
});
|
package/package.json
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/nuxt",
|
3
|
-
"version": "
|
3
|
+
"version": "10.0.0-preview.10",
|
4
4
|
"type": "module",
|
5
|
+
"sideEffects": false,
|
5
6
|
"description": "A Nuxt module that integrates Serwist into your application.",
|
6
7
|
"files": [
|
7
8
|
"dist"
|
8
9
|
],
|
9
10
|
"keywords": [
|
10
11
|
"nuxt",
|
12
|
+
"nuxt-module",
|
11
13
|
"pwa",
|
12
14
|
"vite",
|
13
15
|
"vite-plugin",
|
@@ -17,11 +19,10 @@
|
|
17
19
|
"sw",
|
18
20
|
"service worker",
|
19
21
|
"web",
|
20
|
-
"service-worker"
|
21
|
-
"nuxt-module"
|
22
|
+
"service-worker"
|
22
23
|
],
|
23
24
|
"engines": {
|
24
|
-
"node": ">=
|
25
|
+
"node": ">=20.0.0"
|
25
26
|
},
|
26
27
|
"repository": "https://github.com/serwist/serwist",
|
27
28
|
"bugs": "https://github.com/serwist/serwist/issues",
|
@@ -44,16 +45,17 @@
|
|
44
45
|
"vite",
|
45
46
|
"@nuxt/kit",
|
46
47
|
"@serwist/build",
|
47
|
-
"
|
48
|
+
"vite-plugin-serwist",
|
48
49
|
"virtual:serwist-nuxt-configuration",
|
49
50
|
"virtual:serwist"
|
50
51
|
]
|
51
52
|
},
|
52
53
|
"dependencies": {
|
53
54
|
"@nuxt/kit": "4.0.0",
|
54
|
-
"@serwist/build": "
|
55
|
-
"@serwist/
|
56
|
-
"@serwist/window": "
|
55
|
+
"@serwist/build": "10.0.0-preview.10",
|
56
|
+
"@serwist/utils": "10.0.0-preview.10",
|
57
|
+
"@serwist/window": "10.0.0-preview.10",
|
58
|
+
"vite-plugin-serwist": "10.0.0-preview.10"
|
57
59
|
},
|
58
60
|
"devDependencies": {
|
59
61
|
"@nuxt/module-builder": "1.0.1",
|
@@ -61,16 +63,16 @@
|
|
61
63
|
"@types/node": "24.0.14",
|
62
64
|
"eslint": "9.31.0",
|
63
65
|
"nuxt": "4.0.0",
|
64
|
-
"rimraf": "
|
66
|
+
"rimraf": "6.0.1",
|
65
67
|
"serve": "14.2.4",
|
66
68
|
"typescript": "5.8.3",
|
67
|
-
"vite": "7.0.
|
69
|
+
"vite": "7.0.5",
|
68
70
|
"vue-tsc": "3.0.1",
|
69
|
-
"@serwist/configs": "
|
71
|
+
"@serwist/configs": "10.0.0-preview.10"
|
70
72
|
},
|
71
73
|
"peerDependencies": {
|
72
74
|
"typescript": ">=5.0.0",
|
73
|
-
"vite": "
|
75
|
+
"vite": ">=5.0.0"
|
74
76
|
},
|
75
77
|
"peerDependenciesMeta": {
|
76
78
|
"typescript": {
|