@serwist/nuxt 10.0.0-preview.1 → 10.0.0-preview.11
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 +2 -1
- package/dist/module.json +3 -4
- package/dist/module.mjs +16 -132
- package/dist/runtime/plugins/augmentation.d.ts +3 -3
- package/dist/runtime/plugins/client.d.ts +5 -1
- package/dist/runtime/plugins/client.js +6 -4
- package/dist/types.d.mts +3 -1
- package/package.json +21 -20
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -34
- package/dist/types.d.ts +0 -1
package/dist/module.d.mts
CHANGED
@@ -31,4 +31,5 @@ interface ModuleOptions extends Optional<PluginOptions, "swSrc" | "swDest" | "gl
|
|
31
31
|
|
32
32
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
33
33
|
|
34
|
-
export {
|
34
|
+
export { _default as default };
|
35
|
+
export type { ClientOptions, ModuleOptions };
|
package/dist/module.json
CHANGED
@@ -2,12 +2,11 @@
|
|
2
2
|
"name": "@serwist/nuxt",
|
3
3
|
"configKey": "serwist",
|
4
4
|
"compatibility": {
|
5
|
-
"nuxt": "^3.8.0"
|
6
|
-
"bridge": false
|
5
|
+
"nuxt": "^3.8.0 || ^4.0.0"
|
7
6
|
},
|
8
|
-
"version": "10.0.0-preview.
|
7
|
+
"version": "10.0.0-preview.11",
|
9
8
|
"builder": {
|
10
|
-
"@nuxt/module-builder": "0.
|
9
|
+
"@nuxt/module-builder": "1.0.1",
|
11
10
|
"unbuild": "unknown"
|
12
11
|
}
|
13
12
|
}
|
package/dist/module.mjs
CHANGED
@@ -1,133 +1,24 @@
|
|
1
1
|
import path from 'node:path';
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, extendWebpackConfig } from '@nuxt/kit';
|
3
|
-
import { resolveEntry
|
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
|
9
|
-
const version = "10.0.0-preview.1";
|
10
|
-
const type = "module";
|
11
|
-
const description = "A Nuxt module that integrates Serwist into your application.";
|
12
|
-
const files = [
|
13
|
-
"dist"
|
14
|
-
];
|
15
|
-
const keywords = [
|
16
|
-
"nuxt",
|
17
|
-
"pwa",
|
18
|
-
"vite",
|
19
|
-
"vite-plugin",
|
20
|
-
"serwist",
|
21
|
-
"serwistjs",
|
22
|
-
"pwa",
|
23
|
-
"sw",
|
24
|
-
"service worker",
|
25
|
-
"web",
|
26
|
-
"service-worker",
|
27
|
-
"nuxt-module"
|
28
|
-
];
|
29
|
-
const engines = {
|
30
|
-
node: ">=18.0.0"
|
31
|
-
};
|
32
|
-
const repository = "https://github.com/serwist/serwist";
|
33
|
-
const bugs = "https://github.com/serwist/serwist/issues";
|
34
|
-
const homepage = "https://serwist.pages.dev";
|
35
|
-
const main = "./dist/module.mjs";
|
36
|
-
const types = "./dist/types.d.ts";
|
37
|
-
const exports = {
|
38
|
-
".": {
|
39
|
-
types: "./dist/types.d.mts",
|
40
|
-
"default": "./dist/module.mjs"
|
41
|
-
}
|
42
|
-
};
|
43
|
-
const build = {
|
44
|
-
externals: [
|
45
|
-
"node:child_process",
|
46
|
-
"node:fs",
|
47
|
-
"node:path",
|
48
|
-
"consola",
|
49
|
-
"esbuild",
|
50
|
-
"rollup",
|
51
|
-
"vite",
|
52
|
-
"@nuxt/kit",
|
53
|
-
"@serwist/build",
|
54
|
-
"vite-plugin-serwist",
|
55
|
-
"virtual:serwist-nuxt-configuration",
|
56
|
-
"virtual:serwist"
|
57
|
-
]
|
58
|
-
};
|
59
|
-
const scripts = {
|
60
|
-
build: "nuxt-module-build prepare && nuxt-module-build build",
|
61
|
-
dev: "nuxi dev playground --port 5173",
|
62
|
-
"dev:generate": "nuxi generate playground",
|
63
|
-
"dev:generate:netlify": "NITRO_PRESET=netlify nuxi generate playground",
|
64
|
-
"dev:generate:vercel": "NITRO_PRESET=vercel nuxi generate playground",
|
65
|
-
"dev:build": "nuxi build playground",
|
66
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
67
|
-
"dev:preview:build": "nr dev:build && node playground/.output/server/index.mjs",
|
68
|
-
"dev:preview:generate": "nr dev:generate && serve playground/dist"
|
69
|
-
};
|
70
|
-
const dependencies = {
|
71
|
-
"@nuxt/kit": "3.15.4",
|
72
|
-
"@serwist/build": "workspace:*",
|
73
|
-
"vite-plugin-serwist": "workspace:*",
|
74
|
-
"@serwist/window": "workspace:*"
|
75
|
-
};
|
76
|
-
const devDependencies = {
|
77
|
-
"@nuxt/module-builder": "0.8.4",
|
78
|
-
"@nuxt/schema": "3.15.4",
|
79
|
-
"@serwist/configs": "workspace:*",
|
80
|
-
"@types/node": "22.13.5",
|
81
|
-
eslint: "9.21.0",
|
82
|
-
nuxt: "3.15.4",
|
83
|
-
rimraf: "5.0.9",
|
84
|
-
serve: "14.2.4",
|
85
|
-
typescript: "5.7.3",
|
86
|
-
vite: "6.1.1",
|
87
|
-
"vue-tsc": "2.2.4"
|
88
|
-
};
|
89
|
-
const peerDependencies = {
|
90
|
-
typescript: ">=5.0.0",
|
91
|
-
vite: "^5.0.0"
|
92
|
-
};
|
93
|
-
const peerDependenciesMeta = {
|
94
|
-
typescript: {
|
95
|
-
optional: true
|
96
|
-
}
|
97
|
-
};
|
9
|
+
const version = "10.0.0-preview.11";
|
98
10
|
const packageJson = {
|
99
|
-
|
100
|
-
version: version,
|
101
|
-
type: type,
|
102
|
-
description: description,
|
103
|
-
files: files,
|
104
|
-
keywords: keywords,
|
105
|
-
engines: engines,
|
106
|
-
repository: repository,
|
107
|
-
bugs: bugs,
|
108
|
-
homepage: homepage,
|
109
|
-
main: main,
|
110
|
-
types: types,
|
111
|
-
exports: exports,
|
112
|
-
build: build,
|
113
|
-
scripts: scripts,
|
114
|
-
dependencies: dependencies,
|
115
|
-
devDependencies: devDependencies,
|
116
|
-
peerDependencies: peerDependencies,
|
117
|
-
peerDependenciesMeta: peerDependenciesMeta
|
118
|
-
};
|
11
|
+
version: version};
|
119
12
|
|
120
13
|
function configurePwaOptions(options, nuxt, nitroConfig) {
|
121
14
|
let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
|
122
|
-
if (buildAssetsDir[0] === "/")
|
123
|
-
|
124
|
-
if (buildAssetsDir[buildAssetsDir.length - 1] !== "/")
|
125
|
-
buildAssetsDir += "/";
|
15
|
+
if (buildAssetsDir[0] === "/") buildAssetsDir = buildAssetsDir.slice(1);
|
16
|
+
if (buildAssetsDir[buildAssetsDir.length - 1] !== "/") buildAssetsDir += "/";
|
126
17
|
if (!("dontCacheBustURLsMatching" in options)) {
|
127
18
|
options.dontCacheBustURLsMatching = new RegExp(buildAssetsDir);
|
128
19
|
}
|
129
20
|
if (nuxt.options.experimental.payloadExtraction) {
|
130
|
-
const enableGlobPatterns = nuxt.options._generate || !!nitroConfig.prerender?.routes?.length || Object.values(nitroConfig.routeRules ?? {}).some((r) => r.prerender);
|
21
|
+
const enableGlobPatterns = nuxt.options.nitro.static || nuxt.options._generate || !!nitroConfig.prerender?.routes?.length || Object.values(nitroConfig.routeRules ?? {}).some((r) => r.prerender);
|
131
22
|
if (enableGlobPatterns) {
|
132
23
|
options.globPatterns = options.globPatterns ?? [];
|
133
24
|
options.globPatterns.push("**/_payload.json");
|
@@ -178,10 +69,8 @@ function createManifestTransform(base, publicDir, appManifestFolder) {
|
|
178
69
|
});
|
179
70
|
});
|
180
71
|
const latestEntry = entries.find((e) => e.url === latest);
|
181
|
-
if (latestEntry)
|
182
|
-
|
183
|
-
else
|
184
|
-
entries.push({ url: latest, revision, size: data.size });
|
72
|
+
if (latestEntry) latestEntry.revision = revision;
|
73
|
+
else entries.push({ url: latest, revision, size: data.size });
|
185
74
|
} else {
|
186
75
|
entries = entries.filter((e) => e.url !== latest);
|
187
76
|
}
|
@@ -195,13 +84,12 @@ const module = defineNuxtModule({
|
|
195
84
|
name: "@serwist/nuxt",
|
196
85
|
configKey: "serwist",
|
197
86
|
compatibility: {
|
198
|
-
nuxt: "^3.8.0"
|
199
|
-
bridge: false
|
87
|
+
nuxt: "^3.8.0 || ^4.0.0"
|
200
88
|
},
|
201
89
|
version: packageJson.version
|
202
90
|
},
|
203
91
|
defaults(nuxt) {
|
204
|
-
const publicDir =
|
92
|
+
const publicDir = path.resolve(nuxt.options.rootDir, ".output/public");
|
205
93
|
return {
|
206
94
|
base: nuxt.options.app.baseURL,
|
207
95
|
scope: nuxt.options.app.baseURL,
|
@@ -223,8 +111,7 @@ const module = defineNuxtModule({
|
|
223
111
|
const { client: _client, ...userOptions } = options;
|
224
112
|
const client = { registerPlugin: true, ..._client };
|
225
113
|
const runtimeDir = resolver.resolve("./runtime");
|
226
|
-
if (!nuxt.options.ssr)
|
227
|
-
nuxt.options.build.transpile.push(runtimeDir);
|
114
|
+
if (!nuxt.options.ssr) nuxt.options.build.transpile.push(runtimeDir);
|
228
115
|
if (client.registerPlugin) {
|
229
116
|
addPlugin({
|
230
117
|
src: resolver.resolve(runtimeDir, "plugins/client"),
|
@@ -244,11 +131,9 @@ const module = defineNuxtModule({
|
|
244
131
|
}
|
245
132
|
});
|
246
133
|
nuxt.hook("vite:extendConfig", async (viteInlineConfig, { isClient }) => {
|
247
|
-
if (!viteInlineConfig.plugins)
|
248
|
-
viteInlineConfig.plugins = [];
|
134
|
+
if (!viteInlineConfig.plugins) viteInlineConfig.plugins = [];
|
249
135
|
const plugin = viteInlineConfig.plugins.find((p) => p && typeof p === "object" && "name" in p && p.name === "vite-plugin-serwist");
|
250
|
-
if (plugin)
|
251
|
-
throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
136
|
+
if (plugin) throw new Error("Remove 'vite-plugin-serwist' from your Vite configuration! Do not use it alongside '@serwist/nuxt'.");
|
252
137
|
if (isClient) {
|
253
138
|
const configuration = "virtual:serwist-nuxt-configuration";
|
254
139
|
const resolvedConfiguration = `\0${configuration}`;
|
@@ -270,15 +155,14 @@ const module = defineNuxtModule({
|
|
270
155
|
});
|
271
156
|
}
|
272
157
|
ctx = createContext(userOptions, "nuxt");
|
273
|
-
viteInlineConfig.plugins.push(main
|
158
|
+
viteInlineConfig.plugins.push(main(ctx), dev(ctx));
|
274
159
|
});
|
275
160
|
extendWebpackConfig(() => {
|
276
161
|
throw new Error("Webpack is not supported: '@serwist/nuxt' can only be used with Vite!");
|
277
162
|
});
|
278
163
|
if (!nuxt.options.dev) {
|
279
164
|
nuxt.hook("nitro:build:public-assets", () => {
|
280
|
-
if (ctx && !ctx.options.disable)
|
281
|
-
void generateServiceWorker(ctx);
|
165
|
+
if (ctx && !ctx.options.disable) void generateServiceWorker(ctx);
|
282
166
|
});
|
283
167
|
}
|
284
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/dist/types.d.mts
CHANGED
package/package.json
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/nuxt",
|
3
|
-
"version": "10.0.0-preview.
|
3
|
+
"version": "10.0.0-preview.11",
|
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,17 +19,15 @@
|
|
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",
|
28
29
|
"homepage": "https://serwist.pages.dev",
|
29
30
|
"main": "./dist/module.mjs",
|
30
|
-
"types": "./dist/types.d.ts",
|
31
31
|
"exports": {
|
32
32
|
".": {
|
33
33
|
"types": "./dist/types.d.mts",
|
@@ -51,27 +51,28 @@
|
|
51
51
|
]
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@nuxt/kit": "
|
55
|
-
"@serwist/build": "10.0.0-preview.
|
56
|
-
"
|
57
|
-
"@serwist/window": "10.0.0-preview.
|
54
|
+
"@nuxt/kit": "4.0.0",
|
55
|
+
"@serwist/build": "10.0.0-preview.11",
|
56
|
+
"@serwist/utils": "10.0.0-preview.11",
|
57
|
+
"@serwist/window": "10.0.0-preview.11",
|
58
|
+
"vite-plugin-serwist": "10.0.0-preview.11"
|
58
59
|
},
|
59
60
|
"devDependencies": {
|
60
|
-
"@nuxt/module-builder": "0.
|
61
|
-
"@nuxt/schema": "
|
62
|
-
"@types/node": "
|
63
|
-
"eslint": "9.
|
64
|
-
"nuxt": "
|
65
|
-
"rimraf": "
|
61
|
+
"@nuxt/module-builder": "1.0.1",
|
62
|
+
"@nuxt/schema": "4.0.0",
|
63
|
+
"@types/node": "24.0.14",
|
64
|
+
"eslint": "9.31.0",
|
65
|
+
"nuxt": "4.0.0",
|
66
|
+
"rimraf": "6.0.1",
|
66
67
|
"serve": "14.2.4",
|
67
|
-
"typescript": "5.
|
68
|
-
"vite": "
|
69
|
-
"vue-tsc": "
|
70
|
-
"@serwist/configs": "10.0.0-preview.
|
68
|
+
"typescript": "5.8.3",
|
69
|
+
"vite": "7.0.5",
|
70
|
+
"vue-tsc": "3.0.1",
|
71
|
+
"@serwist/configs": "10.0.0-preview.11"
|
71
72
|
},
|
72
73
|
"peerDependencies": {
|
73
74
|
"typescript": ">=5.0.0",
|
74
|
-
"vite": "
|
75
|
+
"vite": ">=5.0.0"
|
75
76
|
},
|
76
77
|
"peerDependenciesMeta": {
|
77
78
|
"typescript": {
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
2
|
-
import { PluginOptions } from 'vite-plugin-serwist';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Make certain fields in a object type optional
|
6
|
-
*
|
7
|
-
* @example
|
8
|
-
* interface A {
|
9
|
-
* a: string;
|
10
|
-
* b: string;
|
11
|
-
* c: string;
|
12
|
-
* }
|
13
|
-
* type B = Optional<A, "b" | "c">;
|
14
|
-
* const b: B = { a: "hehe" }; //valid
|
15
|
-
* const b: B = {}; //invalid
|
16
|
-
*/
|
17
|
-
type Optional<T, U extends keyof T> = Omit<T, U> & Partial<Pick<T, U>>;
|
18
|
-
|
19
|
-
interface ClientOptions {
|
20
|
-
/**
|
21
|
-
* Whether this plugin should be registered.
|
22
|
-
*/
|
23
|
-
registerPlugin?: boolean;
|
24
|
-
}
|
25
|
-
interface ModuleOptions extends Optional<PluginOptions, "swSrc" | "swDest" | "globDirectory"> {
|
26
|
-
/**
|
27
|
-
* Options for plugin.
|
28
|
-
*/
|
29
|
-
client?: ClientOptions;
|
30
|
-
}
|
31
|
-
|
32
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
33
|
-
|
34
|
-
export { type ClientOptions, type ModuleOptions, _default as default };
|
package/dist/types.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { type ClientOptions, type ModuleOptions, default } from './module'
|