@serwist/nuxt 9.2.0 → 9.2.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.
- package/dist/module.d.mts +23 -2
- package/dist/module.json +2 -2
- package/dist/module.mjs +20 -19
- package/dist/types.d.mts +1 -1
- package/package.json +16 -15
package/dist/module.d.mts
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
2
2
|
import { PluginOptions } from '@serwist/vite';
|
3
3
|
|
4
|
+
/**
|
5
|
+
* Make certain fields in a object type required
|
6
|
+
*
|
7
|
+
* @example
|
8
|
+
* interface A {
|
9
|
+
* a?: string;
|
10
|
+
* b?: string;
|
11
|
+
* c?: string;
|
12
|
+
* }
|
13
|
+
* type B = RequiredFields<A, "b" | "c">;
|
14
|
+
* const b: B = {
|
15
|
+
* b: "hehe",
|
16
|
+
* c: "hehe",
|
17
|
+
* }; //valid
|
18
|
+
* const b: B = { a: "hehe" }; //invalid
|
19
|
+
* const c: B = { a: "hehe", b: "hehe" }; //invalid
|
20
|
+
*/
|
21
|
+
type Require<T, U extends keyof T> = T & Required<Pick<T, U>>;
|
4
22
|
/**
|
5
23
|
* Make certain fields in a object type optional
|
6
24
|
*
|
@@ -28,8 +46,11 @@ interface ModuleOptions extends Optional<PluginOptions, "swSrc" | "swDest" | "gl
|
|
28
46
|
*/
|
29
47
|
client?: ClientOptions;
|
30
48
|
}
|
49
|
+
type DefaultModuleKeys = "base" | "scope" | "client" | "swSrc" | "swDest" | "swUrl" | "globDirectory" | "injectionPoint";
|
50
|
+
type DefaultModuleOptions = Required<Pick<ModuleOptions, DefaultModuleKeys>>;
|
51
|
+
type ResolvedModuleOptions = Require<ModuleOptions, DefaultModuleKeys>;
|
31
52
|
|
32
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions,
|
53
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, Required<Pick<ModuleOptions, DefaultModuleKeys>>, true>;
|
33
54
|
|
34
55
|
export { _default as default };
|
35
|
-
export type { ClientOptions, ModuleOptions };
|
56
|
+
export type { ClientOptions, DefaultModuleKeys, DefaultModuleOptions, ModuleOptions, ResolvedModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
@@ -4,35 +4,35 @@ import { createContext, createApi, main, dev, resolveEntry } from '@serwist/vite
|
|
4
4
|
import { createHash } from 'node:crypto';
|
5
5
|
import { createReadStream } from 'node:fs';
|
6
6
|
import fsp from 'node:fs/promises';
|
7
|
+
import { DEFAULT_GLOB_PATTERNS } from '@serwist/build';
|
7
8
|
|
8
|
-
const version = "9.2.
|
9
|
+
const version = "9.2.1";
|
9
10
|
|
10
|
-
|
11
|
+
const configureSerwistOptions = (options, nuxt, nitroConfig) => {
|
11
12
|
let buildAssetsDir = nuxt.options.app.buildAssetsDir ?? "_nuxt/";
|
12
13
|
if (buildAssetsDir[0] === "/") buildAssetsDir = buildAssetsDir.slice(1);
|
13
14
|
if (buildAssetsDir[buildAssetsDir.length - 1] !== "/") buildAssetsDir += "/";
|
14
15
|
if (!("dontCacheBustURLsMatching" in options)) {
|
15
16
|
options.dontCacheBustURLsMatching = new RegExp(buildAssetsDir);
|
16
17
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
options.globPatterns.push("**/_payload.json");
|
22
|
-
}
|
18
|
+
options.globPatterns = options.globPatterns ?? DEFAULT_GLOB_PATTERNS;
|
19
|
+
if (nuxt.options.experimental.payloadExtraction && // Has prerendered routes
|
20
|
+
(nuxt.options.nitro.static || nuxt.options._generate || !!nitroConfig.prerender?.routes?.length || Object.values(nitroConfig.routeRules ?? {}).some((r) => r.prerender))) {
|
21
|
+
options.globPatterns.push("**/_payload.json");
|
23
22
|
}
|
24
23
|
let appManifestFolder;
|
25
24
|
if (nuxt.options.experimental.appManifest) {
|
26
|
-
options.globPatterns = options.globPatterns ?? [];
|
27
25
|
appManifestFolder = `${buildAssetsDir}builds/`;
|
28
26
|
options.globPatterns.push(`${appManifestFolder}**/*.json`);
|
29
27
|
}
|
30
28
|
const _public = nitroConfig.output?.publicDir ?? nuxt.options.nitro?.output?.publicDir;
|
31
|
-
const publicDir = _public ? path.resolve(_public) : path.resolve(nuxt.options.
|
29
|
+
const publicDir = _public ? path.resolve(_public) : path.resolve(nuxt.options.rootDir, ".output/public");
|
30
|
+
options.swDest = options.swDest ? path.isAbsolute(options.swDest) ? options.swDest : path.resolve(publicDir, options.swDest) : path.resolve(publicDir, "sw.js");
|
31
|
+
options.globDirectory = options.globDirectory || publicDir;
|
32
32
|
if (!nuxt.options.dev && !options.manifestTransforms) {
|
33
33
|
options.manifestTransforms = [createManifestTransform(nuxt.options.app.baseURL ?? "/", publicDir, appManifestFolder)];
|
34
34
|
}
|
35
|
-
}
|
35
|
+
};
|
36
36
|
function createManifestTransform(base, publicDir, appManifestFolder) {
|
37
37
|
return async (entries) => {
|
38
38
|
entries.filter((e) => e.url.endsWith(".html")).forEach((e) => {
|
@@ -76,7 +76,7 @@ function createManifestTransform(base, publicDir, appManifestFolder) {
|
|
76
76
|
};
|
77
77
|
}
|
78
78
|
|
79
|
-
const module = defineNuxtModule({
|
79
|
+
const module = defineNuxtModule().with({
|
80
80
|
meta: {
|
81
81
|
name: "@serwist/nuxt",
|
82
82
|
configKey: "serwist",
|
@@ -86,7 +86,6 @@ const module = defineNuxtModule({
|
|
86
86
|
version
|
87
87
|
},
|
88
88
|
defaults(nuxt) {
|
89
|
-
const publicDir = path.resolve(nuxt.options.rootDir, ".output/public");
|
90
89
|
return {
|
91
90
|
base: nuxt.options.app.baseURL,
|
92
91
|
scope: nuxt.options.app.baseURL,
|
@@ -96,17 +95,19 @@ const module = defineNuxtModule({
|
|
96
95
|
// Try to find `service-worker.{ts,js}` or `service-worker/index.{ts,js}`. If not found,
|
97
96
|
// force the user to provide a `swSrc` themself.
|
98
97
|
swSrc: resolveEntry(path.resolve(nuxt.options.rootDir, "service-worker")) || void 0,
|
99
|
-
swDest
|
98
|
+
// If `swDest` is not set by `configureSerwistOptions`, something is wrong.
|
99
|
+
swDest: "",
|
100
100
|
swUrl: "/sw.js",
|
101
|
-
globDirectory
|
101
|
+
// If `globDirectory` is not set by `configureSerwistOptions`, something is wrong.
|
102
|
+
globDirectory: "",
|
102
103
|
injectionPoint: "self.__SW_MANIFEST"
|
103
104
|
};
|
104
105
|
},
|
105
|
-
async setup(
|
106
|
+
async setup(_options, nuxt) {
|
106
107
|
const resolver = createResolver(import.meta.url);
|
107
108
|
let ctx;
|
108
109
|
let api;
|
109
|
-
const { client: _client, ...
|
110
|
+
const { client: _client, ...options } = _options;
|
110
111
|
const client = { registerPlugin: true, ..._client };
|
111
112
|
const runtimeDir = resolver.resolve("./runtime");
|
112
113
|
if (!nuxt.options.ssr) nuxt.options.build.transpile.push(runtimeDir);
|
@@ -120,7 +121,7 @@ const module = defineNuxtModule({
|
|
120
121
|
references.push({ path: resolver.resolve(runtimeDir, "plugins/augmentation.d.ts") });
|
121
122
|
});
|
122
123
|
nuxt.hook("nitro:init", (nitro) => {
|
123
|
-
|
124
|
+
configureSerwistOptions(options, nuxt, nitro.options);
|
124
125
|
});
|
125
126
|
nuxt.hook("vite:extend", ({ config }) => {
|
126
127
|
const plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "@serwist/vite");
|
@@ -156,7 +157,7 @@ const module = defineNuxtModule({
|
|
156
157
|
}
|
157
158
|
});
|
158
159
|
}
|
159
|
-
ctx = createContext(
|
160
|
+
ctx = createContext(options, "nuxt");
|
160
161
|
api = createApi(ctx);
|
161
162
|
const plugins = [main(ctx, api), dev(ctx, api)];
|
162
163
|
viteInlineConfig.plugins.push(plugins);
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/nuxt",
|
3
|
-
"version": "9.2.
|
3
|
+
"version": "9.2.1",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A Nuxt module that integrates Serwist into your application.",
|
6
6
|
"files": [
|
@@ -50,27 +50,28 @@
|
|
50
50
|
]
|
51
51
|
},
|
52
52
|
"dependencies": {
|
53
|
-
"@nuxt/kit": "4.0.
|
54
|
-
"@serwist/build": "9.2.
|
55
|
-
"@serwist/vite": "9.2.
|
56
|
-
"@serwist/window": "9.2.
|
53
|
+
"@nuxt/kit": "4.0.3",
|
54
|
+
"@serwist/build": "9.2.1",
|
55
|
+
"@serwist/vite": "9.2.1",
|
56
|
+
"@serwist/window": "9.2.1"
|
57
57
|
},
|
58
58
|
"devDependencies": {
|
59
|
-
"@nuxt/module-builder": "1.0.
|
60
|
-
"@nuxt/schema": "4.0.
|
61
|
-
"@types/node": "24.0
|
62
|
-
"eslint": "9.
|
63
|
-
"nuxt": "4.0.
|
59
|
+
"@nuxt/module-builder": "1.0.2",
|
60
|
+
"@nuxt/schema": "4.0.3",
|
61
|
+
"@types/node": "24.3.0",
|
62
|
+
"eslint": "9.34.0",
|
63
|
+
"nuxt": "4.0.3",
|
64
64
|
"rimraf": "5.0.9",
|
65
65
|
"serve": "14.2.4",
|
66
|
-
"typescript": "5.
|
67
|
-
"vite": "7.
|
68
|
-
"vue-tsc": "3.0.
|
69
|
-
"@serwist/configs": "9.2.
|
66
|
+
"typescript": "5.9.2",
|
67
|
+
"vite": "7.1.3",
|
68
|
+
"vue-tsc": "3.0.6",
|
69
|
+
"@serwist/configs": "9.2.1",
|
70
|
+
"@serwist/utils": "9.2.1"
|
70
71
|
},
|
71
72
|
"peerDependencies": {
|
72
73
|
"typescript": ">=5.0.0",
|
73
|
-
"vite": "
|
74
|
+
"vite": ">=5.0.0"
|
74
75
|
},
|
75
76
|
"peerDependenciesMeta": {
|
76
77
|
"typescript": {
|