@serwist/next 9.1.0-preview.0 → 9.1.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/chunks/schema.js +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.worker.d.ts.map +1 -1
- package/dist/index.worker.js +13 -10
- package/dist/lib/find-first-truthy.d.ts.map +1 -1
- package/dist/lib/get-content-hash.d.ts.map +1 -1
- package/dist/lib/get-file-hash.d.ts.map +1 -1
- package/dist/lib/get-package-version.d.ts.map +1 -1
- package/dist/lib/load-tsconfig.d.ts.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +64 -225
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/validator.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +16 -4
- package/src/index.worker.ts +14 -18
- package/src/lib/schema.ts +16 -16
- package/src/lib/validator.ts +3 -2
package/dist/chunks/schema.js
CHANGED
|
@@ -2,7 +2,7 @@ import { requiredSwDestPartial } from '@serwist/build/schema';
|
|
|
2
2
|
import { injectManifestOptions as injectManifestOptions$1 } from '@serwist/webpack-plugin/schema';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
const injectPartial = z.
|
|
5
|
+
const injectPartial = z.strictObject({
|
|
6
6
|
cacheOnNavigation: z.boolean().default(false),
|
|
7
7
|
disable: z.boolean().default(false),
|
|
8
8
|
register: z.boolean().default(true),
|
|
@@ -12,9 +12,13 @@ const injectPartial = z.object({
|
|
|
12
12
|
globPublicPatterns: z.array(z.string()).default([
|
|
13
13
|
"**/*"
|
|
14
14
|
])
|
|
15
|
-
})
|
|
16
|
-
const injectManifestOptions =
|
|
15
|
+
});
|
|
16
|
+
const injectManifestOptions = z.strictObject({
|
|
17
|
+
...injectManifestOptions$1.shape,
|
|
18
|
+
...requiredSwDestPartial.shape,
|
|
19
|
+
...injectPartial.shape
|
|
20
|
+
}).omit({
|
|
17
21
|
disablePrecacheManifest: true
|
|
18
|
-
})
|
|
22
|
+
});
|
|
19
23
|
|
|
20
24
|
export { injectManifestOptions as a, injectPartial as i };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAMnE;;;;GAIG;AACH,QAAA,MAAM,eAAe,GAAI,aAAa,qBAAqB,KAAG,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,KAAK,UAAU,CA8NrG,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,CAAC;AACzC,YAAY,EAAE,qBAAqB,IAAI,aAAa,EAAE,6BAA6B,IAAI,qBAAqB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,9 @@ import crypto from 'node:crypto';
|
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
11
|
+
import { z } from 'zod';
|
|
11
12
|
import { a as injectManifestOptions } from './chunks/schema.js';
|
|
12
13
|
import '@serwist/webpack-plugin/schema';
|
|
13
|
-
import 'zod';
|
|
14
14
|
|
|
15
15
|
const findFirstTruthy = (arr, fn)=>{
|
|
16
16
|
for (const i of arr){
|
|
@@ -86,19 +86,24 @@ const event = (...message)=>{
|
|
|
86
86
|
|
|
87
87
|
const validateInjectManifestOptions = (input)=>{
|
|
88
88
|
const result = injectManifestOptions.safeParse(input, {
|
|
89
|
-
|
|
89
|
+
error: validationErrorMap
|
|
90
90
|
});
|
|
91
91
|
if (!result.success) {
|
|
92
92
|
throw new SerwistConfigError({
|
|
93
93
|
moduleName: "@serwist/next",
|
|
94
|
-
message:
|
|
94
|
+
message: z.prettifyError(result.error)
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
return result.data;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
101
|
+
let warnedTurbopack = false;
|
|
101
102
|
const withSerwistInit = (userOptions)=>{
|
|
103
|
+
if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
|
|
104
|
+
warnedTurbopack = true;
|
|
105
|
+
console.warn(`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`);
|
|
106
|
+
}
|
|
102
107
|
return (nextConfig = {})=>({
|
|
103
108
|
...nextConfig,
|
|
104
109
|
webpack (config, options) {
|
|
@@ -188,8 +193,8 @@ const withSerwistInit = (userOptions)=>{
|
|
|
188
193
|
});
|
|
189
194
|
}
|
|
190
195
|
const shouldBuildSWEntryWorker = cacheOnNavigation;
|
|
191
|
-
let swEntryPublicPath
|
|
192
|
-
let swEntryWorkerDest
|
|
196
|
+
let swEntryPublicPath;
|
|
197
|
+
let swEntryWorkerDest;
|
|
193
198
|
if (shouldBuildSWEntryWorker) {
|
|
194
199
|
const swEntryWorkerSrc = path.join(dirname, "sw-entry-worker.js");
|
|
195
200
|
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
@@ -231,7 +236,7 @@ const withSerwistInit = (userOptions)=>{
|
|
|
231
236
|
({ asset, compilation })=>{
|
|
232
237
|
const swDestRelativeOutput = relativeToOutputPath(compilation, swDest);
|
|
233
238
|
const swAsset = compilation.getAsset(swDestRelativeOutput);
|
|
234
|
-
return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^
|
|
239
|
+
return asset.name === swAsset?.name || asset.name.startsWith("server/") || /^[^/]*\.json$/.test(asset.name) || dev && !asset.name.startsWith("static/runtime/");
|
|
235
240
|
}
|
|
236
241
|
],
|
|
237
242
|
manifestTransforms: [
|
|
@@ -244,7 +249,7 @@ const withSerwistInit = (userOptions)=>{
|
|
|
244
249
|
if (m.url.startsWith(publicFilesPrefix)) {
|
|
245
250
|
m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
|
|
246
251
|
}
|
|
247
|
-
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
252
|
+
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
|
|
248
253
|
return m;
|
|
249
254
|
});
|
|
250
255
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.worker.d.ts","sourceRoot":"","sources":["../src/index.worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.worker.d.ts","sourceRoot":"","sources":["../src/index.worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,EAkQlC,CAAC"}
|
package/dist/index.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NetworkOnly, CacheFirst,
|
|
1
|
+
import { NetworkOnly, CacheFirst, StaleWhileRevalidate, NetworkFirst, ExpirationPlugin, RangeRequestsPlugin } from 'serwist';
|
|
2
2
|
|
|
3
3
|
const PAGES_CACHE_NAME = {
|
|
4
4
|
rscPrefetch: "pages-rsc-prefetch",
|
|
@@ -170,15 +170,13 @@ const defaultCache = process.env.NODE_ENV !== "production" ? [
|
|
|
170
170
|
})
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
|
-
matcher:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return false;
|
|
181
|
-
},
|
|
173
|
+
matcher: /\/api\/auth\/.*/,
|
|
174
|
+
handler: new NetworkOnly({
|
|
175
|
+
networkTimeoutSeconds: 10
|
|
176
|
+
})
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
matcher: ({ sameOrigin, url: { pathname } })=>sameOrigin && pathname.startsWith("/api/"),
|
|
182
180
|
method: "GET",
|
|
183
181
|
handler: new NetworkFirst({
|
|
184
182
|
cacheName: "apis",
|
|
@@ -252,6 +250,11 @@ const defaultCache = process.env.NODE_ENV !== "production" ? [
|
|
|
252
250
|
],
|
|
253
251
|
networkTimeoutSeconds: 10
|
|
254
252
|
})
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
matcher: /.*/i,
|
|
256
|
+
method: "GET",
|
|
257
|
+
handler: new NetworkOnly()
|
|
255
258
|
}
|
|
256
259
|
];
|
|
257
260
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-first-truthy.d.ts","sourceRoot":"","sources":["../../src/lib/find-first-truthy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"find-first-truthy.d.ts","sourceRoot":"","sources":["../../src/lib/find-first-truthy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,+BAQhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-content-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"get-content-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,cAAc,GAAI,MAAM,EAAE,CAAC,oBAAoB,EAAE,OAAO,OAAO,WAK3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"get-file-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,GAAI,MAAM,EAAE,CAAC,oBAAoB,WAAyE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-package-version.d.ts","sourceRoot":"","sources":["../../src/lib/get-package-version.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"get-package-version.d.ts","sourceRoot":"","sources":["../../src/lib/get-package-version.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,MAAM,GAAG,SAMhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-tsconfig.d.ts","sourceRoot":"","sources":["../../src/lib/load-tsconfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9D,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"load-tsconfig.d.ts","sourceRoot":"","sources":["../../src/lib/load-tsconfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9D,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,sBAAsB,MAAM,GAAG,SAAS,KAAG,YAAY,GAAG,SAevG,CAAC"}
|
package/dist/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,SAAS,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,SAAS,GAAG,EAAE,SAEtC,CAAC"}
|
package/dist/lib/schema.d.ts
CHANGED
|
@@ -6,246 +6,85 @@ export declare const injectPartial: z.ZodObject<{
|
|
|
6
6
|
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
scope: z.ZodOptional<z.ZodString>;
|
|
8
8
|
swUrl: z.ZodDefault<z.ZodString>;
|
|
9
|
-
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
9
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
12
|
+
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
disable: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
register: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
17
|
+
swUrl: z.ZodDefault<z.ZodString>;
|
|
18
|
+
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
swDest: z.ZodString;
|
|
20
|
+
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
22
|
+
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
23
|
+
swSrc: z.ZodString;
|
|
24
|
+
chunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
26
|
+
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
include: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>, z.ZodTransform<(args_0: any) => boolean, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>>>]>>>;
|
|
28
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
29
29
|
integrity: z.ZodOptional<z.ZodString>;
|
|
30
30
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
31
|
url: z.ZodString;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, {
|
|
37
|
-
url: string;
|
|
38
|
-
integrity?: string | undefined;
|
|
39
|
-
revision?: string | null | undefined;
|
|
40
|
-
}>]>, "many">>;
|
|
41
|
-
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
-
dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
43
|
-
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
32
|
+
}, z.core.$strict>]>>>;
|
|
33
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
|
|
34
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
35
|
+
size: z.ZodNumber;
|
|
44
36
|
integrity: z.ZodOptional<z.ZodString>;
|
|
45
37
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
38
|
url: z.ZodString;
|
|
47
|
-
}, {
|
|
39
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
40
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
41
|
+
size: z.ZodNumber;
|
|
42
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
43
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
48
48
|
size: z.ZodNumber;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
url: string;
|
|
56
|
-
size: number;
|
|
57
|
-
integrity?: string | undefined;
|
|
58
|
-
revision?: string | null | undefined;
|
|
59
|
-
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
60
|
-
manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
49
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
50
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
url: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
53
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
54
|
+
size: z.ZodNumber;
|
|
61
55
|
integrity: z.ZodOptional<z.ZodString>;
|
|
62
56
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
57
|
url: z.ZodString;
|
|
64
|
-
},
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
}, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
61
|
+
size: z.ZodNumber;
|
|
62
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
63
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
url: z.ZodString;
|
|
65
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
66
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
65
67
|
size: z.ZodNumber;
|
|
66
|
-
}>, "strip", z.ZodTypeAny, {
|
|
67
|
-
url: string;
|
|
68
|
-
size: number;
|
|
69
|
-
integrity?: string | undefined;
|
|
70
|
-
revision?: string | null | undefined;
|
|
71
|
-
}, {
|
|
72
|
-
url: string;
|
|
73
|
-
size: number;
|
|
74
|
-
integrity?: string | undefined;
|
|
75
|
-
revision?: string | null | undefined;
|
|
76
|
-
}>, "many">;
|
|
77
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
78
|
-
}, "strict", z.ZodTypeAny, {
|
|
79
|
-
manifest: {
|
|
80
|
-
url: string;
|
|
81
|
-
size: number;
|
|
82
|
-
integrity?: string | undefined;
|
|
83
|
-
revision?: string | null | undefined;
|
|
84
|
-
}[];
|
|
85
|
-
warnings?: string[] | undefined;
|
|
86
|
-
}, {
|
|
87
|
-
manifest: {
|
|
88
|
-
url: string;
|
|
89
|
-
size: number;
|
|
90
|
-
integrity?: string | undefined;
|
|
91
|
-
revision?: string | null | undefined;
|
|
92
|
-
}[];
|
|
93
|
-
warnings?: string[] | undefined;
|
|
94
|
-
}>>, z.ZodObject<{
|
|
95
|
-
manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
|
|
96
68
|
integrity: z.ZodOptional<z.ZodString>;
|
|
97
69
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
70
|
url: z.ZodString;
|
|
99
|
-
},
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
74
|
+
size: z.ZodNumber;
|
|
75
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
76
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
|
+
url: z.ZodString;
|
|
78
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
79
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
100
80
|
size: z.ZodNumber;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
url: string;
|
|
108
|
-
size: number;
|
|
109
|
-
integrity?: string | undefined;
|
|
110
|
-
revision?: string | null | undefined;
|
|
111
|
-
}>, "many">;
|
|
112
|
-
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
113
|
-
}, "strict", z.ZodTypeAny, {
|
|
114
|
-
manifest: {
|
|
115
|
-
url: string;
|
|
116
|
-
size: number;
|
|
117
|
-
integrity?: string | undefined;
|
|
118
|
-
revision?: string | null | undefined;
|
|
119
|
-
}[];
|
|
120
|
-
warnings?: string[] | undefined;
|
|
121
|
-
}, {
|
|
122
|
-
manifest: {
|
|
123
|
-
url: string;
|
|
124
|
-
size: number;
|
|
125
|
-
integrity?: string | undefined;
|
|
126
|
-
revision?: string | null | undefined;
|
|
127
|
-
}[];
|
|
128
|
-
warnings?: string[] | undefined;
|
|
129
|
-
}>]>>, "many">>;
|
|
81
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
82
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
|
+
url: z.ZodString;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
}, z.core.$strict>>>>>>;
|
|
130
87
|
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
131
88
|
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
132
|
-
},
|
|
133
|
-
chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
134
|
-
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
135
|
-
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
136
|
-
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
137
|
-
}>, {
|
|
138
|
-
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
139
|
-
swSrc: z.ZodString;
|
|
140
|
-
}>, {
|
|
141
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
142
|
-
}>, {
|
|
143
|
-
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
145
|
-
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
146
|
-
}>, {
|
|
147
|
-
swDest: z.ZodString;
|
|
148
|
-
}>, {
|
|
149
|
-
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
-
disable: z.ZodDefault<z.ZodBoolean>;
|
|
151
|
-
register: z.ZodDefault<z.ZodBoolean>;
|
|
152
|
-
reloadOnOnline: z.ZodDefault<z.ZodBoolean>;
|
|
153
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
154
|
-
swUrl: z.ZodDefault<z.ZodString>;
|
|
155
|
-
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
156
|
-
}>, "disablePrecacheManifest">, "strict", z.ZodTypeAny, {
|
|
157
|
-
cacheOnNavigation: boolean;
|
|
158
|
-
disable: boolean;
|
|
159
|
-
register: boolean;
|
|
160
|
-
reloadOnOnline: boolean;
|
|
161
|
-
swUrl: string;
|
|
162
|
-
globPublicPatterns: string[];
|
|
163
|
-
maximumFileSizeToCacheInBytes: number;
|
|
164
|
-
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
165
|
-
injectionPoint: string;
|
|
166
|
-
swSrc: string;
|
|
167
|
-
swDest: string;
|
|
168
|
-
compileSrc: boolean;
|
|
169
|
-
scope?: string | undefined;
|
|
170
|
-
additionalPrecacheEntries?: (string | {
|
|
171
|
-
url: string;
|
|
172
|
-
integrity?: string | undefined;
|
|
173
|
-
revision?: string | null | undefined;
|
|
174
|
-
})[] | undefined;
|
|
175
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
176
|
-
manifestTransforms?: ((args_0: {
|
|
177
|
-
url: string;
|
|
178
|
-
size: number;
|
|
179
|
-
integrity?: string | undefined;
|
|
180
|
-
revision?: string | null | undefined;
|
|
181
|
-
}[], args_1: unknown) => {
|
|
182
|
-
manifest: {
|
|
183
|
-
url: string;
|
|
184
|
-
size: number;
|
|
185
|
-
integrity?: string | undefined;
|
|
186
|
-
revision?: string | null | undefined;
|
|
187
|
-
}[];
|
|
188
|
-
warnings?: string[] | undefined;
|
|
189
|
-
} | Promise<{
|
|
190
|
-
manifest: {
|
|
191
|
-
url: string;
|
|
192
|
-
size: number;
|
|
193
|
-
integrity?: string | undefined;
|
|
194
|
-
revision?: string | null | undefined;
|
|
195
|
-
}[];
|
|
196
|
-
warnings?: string[] | undefined;
|
|
197
|
-
}>)[] | undefined;
|
|
198
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
199
|
-
chunks?: string[] | undefined;
|
|
200
|
-
excludeChunks?: string[] | undefined;
|
|
201
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
202
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
203
|
-
}, {
|
|
204
|
-
swSrc: string;
|
|
205
|
-
swDest: string;
|
|
206
|
-
cacheOnNavigation?: boolean | undefined;
|
|
207
|
-
disable?: boolean | undefined;
|
|
208
|
-
register?: boolean | undefined;
|
|
209
|
-
reloadOnOnline?: boolean | undefined;
|
|
210
|
-
scope?: string | undefined;
|
|
211
|
-
swUrl?: string | undefined;
|
|
212
|
-
globPublicPatterns?: string[] | undefined;
|
|
213
|
-
additionalPrecacheEntries?: (string | {
|
|
214
|
-
url: string;
|
|
215
|
-
integrity?: string | undefined;
|
|
216
|
-
revision?: string | null | undefined;
|
|
217
|
-
})[] | undefined;
|
|
218
|
-
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
219
|
-
manifestTransforms?: ((args_0: {
|
|
220
|
-
url: string;
|
|
221
|
-
size: number;
|
|
222
|
-
integrity?: string | undefined;
|
|
223
|
-
revision?: string | null | undefined;
|
|
224
|
-
}[], args_1: unknown) => {
|
|
225
|
-
manifest: {
|
|
226
|
-
url: string;
|
|
227
|
-
size: number;
|
|
228
|
-
integrity?: string | undefined;
|
|
229
|
-
revision?: string | null | undefined;
|
|
230
|
-
}[];
|
|
231
|
-
warnings?: string[] | undefined;
|
|
232
|
-
} | Promise<{
|
|
233
|
-
manifest: {
|
|
234
|
-
url: string;
|
|
235
|
-
size: number;
|
|
236
|
-
integrity?: string | undefined;
|
|
237
|
-
revision?: string | null | undefined;
|
|
238
|
-
}[];
|
|
239
|
-
warnings?: string[] | undefined;
|
|
240
|
-
}>)[] | undefined;
|
|
241
|
-
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
242
|
-
modifyURLPrefix?: Record<string, string> | undefined;
|
|
243
|
-
chunks?: string[] | undefined;
|
|
244
|
-
exclude?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
245
|
-
excludeChunks?: string[] | undefined;
|
|
246
|
-
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
247
|
-
injectionPoint?: string | undefined;
|
|
248
|
-
compileSrc?: boolean | undefined;
|
|
249
|
-
webpackCompilationPlugins?: any[] | undefined;
|
|
250
|
-
}>;
|
|
89
|
+
}, z.core.$strict>;
|
|
251
90
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/lib/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;;;;kBAQxB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,6BAQ9D,CAAC"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,GAAI,MAAM,EAAE,CAAC,oBAAoB,WAAyE,CAAC;AAEnI,eAAO,MAAM,cAAc,GAAI,MAAM,EAAE,CAAC,oBAAoB,EAAE,OAAO,OAAO,WAK3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
6
|
"files": [
|
|
@@ -62,25 +62,25 @@
|
|
|
62
62
|
"./package.json": "./package.json"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"chalk": "5.
|
|
65
|
+
"chalk": "5.4.1",
|
|
66
66
|
"glob": "10.4.5",
|
|
67
|
-
"zod": "
|
|
68
|
-
"@serwist/build": "9.1.
|
|
69
|
-
"@serwist/webpack-plugin": "9.1.
|
|
70
|
-
"@serwist/window": "9.1.
|
|
71
|
-
"serwist": "9.1.
|
|
67
|
+
"zod": "4.0.5",
|
|
68
|
+
"@serwist/build": "9.1.1",
|
|
69
|
+
"@serwist/webpack-plugin": "9.1.1",
|
|
70
|
+
"@serwist/window": "9.1.1",
|
|
71
|
+
"serwist": "9.1.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@types/node": "
|
|
75
|
-
"next": "15.
|
|
76
|
-
"react": "
|
|
77
|
-
"react-dom": "
|
|
78
|
-
"rollup": "4.
|
|
79
|
-
"type-fest": "4.
|
|
80
|
-
"typescript": "5.
|
|
81
|
-
"webpack": "5.
|
|
82
|
-
"@serwist/configs": "9.1.
|
|
83
|
-
"@serwist/utils": "9.1.
|
|
74
|
+
"@types/node": "24.0.14",
|
|
75
|
+
"next": "15.4.1",
|
|
76
|
+
"react": "19.1.0",
|
|
77
|
+
"react-dom": "19.1.0",
|
|
78
|
+
"rollup": "4.45.1",
|
|
79
|
+
"type-fest": "4.41.0",
|
|
80
|
+
"typescript": "5.8.3",
|
|
81
|
+
"webpack": "5.100.2",
|
|
82
|
+
"@serwist/configs": "9.1.1",
|
|
83
|
+
"@serwist/utils": "9.1.1"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"next": ">=14.0.0",
|
package/src/index.ts
CHANGED
|
@@ -13,12 +13,20 @@ import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
|
13
13
|
|
|
14
14
|
const dirname = "__dirname" in globalThis ? __dirname : fileURLToPath(new URL(".", import.meta.url));
|
|
15
15
|
|
|
16
|
+
let warnedTurbopack = false;
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Integrates Serwist into your Next.js app.
|
|
18
20
|
* @param userOptions
|
|
19
21
|
* @returns
|
|
20
22
|
*/
|
|
21
23
|
const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: NextConfig) => NextConfig) => {
|
|
24
|
+
if (!warnedTurbopack && process.env.TURBOPACK && !userOptions.disable && !process.env.SERWIST_SUPPRESS_TURBOPACK_WARNING) {
|
|
25
|
+
warnedTurbopack = true;
|
|
26
|
+
console.warn(
|
|
27
|
+
`[@serwist/next] WARNING: You are using '@serwist/next' with \`next dev --turbopack\`, but Serwist doesn't support Turbopack at the moment. It is recommended that you set \`disable\` to \`process.env.NODE_ENV !== \"production\"\`. Follow https://github.com/serwist/serwist/issues/54 for progress on Serwist + Turbopack. You can also suppress this warning by setting SERWIST_SUPPRESS_TURBOPACK_WARNING=1.`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
22
30
|
return (nextConfig = {}) => ({
|
|
23
31
|
...nextConfig,
|
|
24
32
|
webpack(config: Configuration, options) {
|
|
@@ -138,8 +146,8 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
const shouldBuildSWEntryWorker = cacheOnNavigation;
|
|
141
|
-
let swEntryPublicPath: string | undefined
|
|
142
|
-
let swEntryWorkerDest: string | undefined
|
|
149
|
+
let swEntryPublicPath: string | undefined;
|
|
150
|
+
let swEntryWorkerDest: string | undefined;
|
|
143
151
|
|
|
144
152
|
if (shouldBuildSWEntryWorker) {
|
|
145
153
|
const swEntryWorkerSrc = path.join(dirname, "sw-entry-worker.js");
|
|
@@ -195,12 +203,16 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
195
203
|
// We don't need the service worker to be cached.
|
|
196
204
|
asset.name === swAsset?.name ||
|
|
197
205
|
asset.name.startsWith("server/") ||
|
|
198
|
-
|
|
206
|
+
// This excludes all JSON files in the compilation directory by filtering
|
|
207
|
+
// out paths that have slashes or don't end with `.json`. Only said files
|
|
208
|
+
// match this criterion.
|
|
209
|
+
/^[^/]*\.json$/.test(asset.name) ||
|
|
199
210
|
(dev && !asset.name.startsWith("static/runtime/"))
|
|
200
211
|
);
|
|
201
212
|
},
|
|
202
213
|
],
|
|
203
214
|
manifestTransforms: [
|
|
215
|
+
// TODO(ducanhgh): move this spread to below our transform function?
|
|
204
216
|
...manifestTransforms,
|
|
205
217
|
async (manifestEntries, compilation) => {
|
|
206
218
|
// This path always uses forward slashes, so it is safe to use it in the following string replace.
|
|
@@ -216,7 +228,7 @@ const withSerwistInit = (userOptions: InjectManifestOptions): ((nextConfig?: Nex
|
|
|
216
228
|
if (m.url.startsWith(publicFilesPrefix)) {
|
|
217
229
|
m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
|
|
218
230
|
}
|
|
219
|
-
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
231
|
+
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D").replace(/@/g, "%40");
|
|
220
232
|
return m;
|
|
221
233
|
});
|
|
222
234
|
return { manifest, warnings: [] };
|
package/src/index.worker.ts
CHANGED
|
@@ -181,24 +181,15 @@ export const defaultCache: RuntimeCaching[] =
|
|
|
181
181
|
}),
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (pathname.startsWith("/api/")) {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return false;
|
|
201
|
-
},
|
|
184
|
+
// Exclude /api/auth/* to fix auth callback
|
|
185
|
+
// https://github.com/serwist/serwist/discussions/28
|
|
186
|
+
matcher: /\/api\/auth\/.*/,
|
|
187
|
+
handler: new NetworkOnly({
|
|
188
|
+
networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
matcher: ({ sameOrigin, url: { pathname } }) => sameOrigin && pathname.startsWith("/api/"),
|
|
202
193
|
method: "GET",
|
|
203
194
|
handler: new NetworkFirst({
|
|
204
195
|
cacheName: "apis",
|
|
@@ -275,4 +266,9 @@ export const defaultCache: RuntimeCaching[] =
|
|
|
275
266
|
networkTimeoutSeconds: 10,
|
|
276
267
|
}),
|
|
277
268
|
},
|
|
269
|
+
{
|
|
270
|
+
matcher: /.*/i,
|
|
271
|
+
method: "GET",
|
|
272
|
+
handler: new NetworkOnly(),
|
|
273
|
+
},
|
|
278
274
|
];
|
package/src/lib/schema.ts
CHANGED
|
@@ -2,20 +2,20 @@ import { requiredSwDestPartial } from "@serwist/build/schema";
|
|
|
2
2
|
import { injectManifestOptions as webpackInjectManifestOptions } from "@serwist/webpack-plugin/schema";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
|
-
export const injectPartial = z
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
.strict("Do not pass invalid properties to NextInjectManifestPartial!");
|
|
5
|
+
export const injectPartial = z.strictObject({
|
|
6
|
+
cacheOnNavigation: z.boolean().default(false),
|
|
7
|
+
disable: z.boolean().default(false),
|
|
8
|
+
register: z.boolean().default(true),
|
|
9
|
+
reloadOnOnline: z.boolean().default(true),
|
|
10
|
+
scope: z.string().optional(),
|
|
11
|
+
swUrl: z.string().default("/sw.js"),
|
|
12
|
+
globPublicPatterns: z.array(z.string()).default(["**/*"]),
|
|
13
|
+
});
|
|
16
14
|
|
|
17
|
-
export const injectManifestOptions =
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export const injectManifestOptions = z
|
|
16
|
+
.strictObject({
|
|
17
|
+
...webpackInjectManifestOptions.shape,
|
|
18
|
+
...requiredSwDestPartial.shape,
|
|
19
|
+
...injectPartial.shape,
|
|
20
|
+
})
|
|
21
|
+
.omit({ disablePrecacheManifest: true });
|
package/src/lib/validator.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { injectManifestOptions } from "./schema.js";
|
|
3
4
|
import type { InjectManifestOptionsComplete } from "./types.js";
|
|
4
5
|
|
|
5
6
|
export const validateInjectManifestOptions = (input: unknown): InjectManifestOptionsComplete => {
|
|
6
7
|
const result = injectManifestOptions.safeParse(input, {
|
|
7
|
-
|
|
8
|
+
error: validationErrorMap,
|
|
8
9
|
});
|
|
9
10
|
if (!result.success) {
|
|
10
|
-
throw new SerwistConfigError({ moduleName: "@serwist/next", message:
|
|
11
|
+
throw new SerwistConfigError({ moduleName: "@serwist/next", message: z.prettifyError(result.error) });
|
|
11
12
|
}
|
|
12
13
|
return result.data;
|
|
13
14
|
};
|