@serwist/next 9.0.0-preview.3 → 9.0.0-preview.5
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/index.worker.js +19 -19
- package/dist/worker/defaultCache.d.ts +3 -3
- package/package.json +12 -12
- package/src/worker/defaultCache.ts +19 -19
package/dist/index.worker.js
CHANGED
|
@@ -10,7 +10,7 @@ const PAGES_CACHE_NAME = {
|
|
|
10
10
|
|
|
11
11
|
const defaultCache = [
|
|
12
12
|
{
|
|
13
|
-
|
|
13
|
+
matcher: /^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,
|
|
14
14
|
handler: new CacheFirst({
|
|
15
15
|
cacheName: "google-fonts-webfonts",
|
|
16
16
|
plugins: [
|
|
@@ -22,7 +22,7 @@ const defaultCache = [
|
|
|
22
22
|
})
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
matcher: /^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,
|
|
26
26
|
handler: new StaleWhileRevalidate({
|
|
27
27
|
cacheName: "google-fonts-stylesheets",
|
|
28
28
|
plugins: [
|
|
@@ -34,7 +34,7 @@ const defaultCache = [
|
|
|
34
34
|
})
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
|
|
37
|
+
matcher: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,
|
|
38
38
|
handler: new StaleWhileRevalidate({
|
|
39
39
|
cacheName: "static-font-assets",
|
|
40
40
|
plugins: [
|
|
@@ -46,7 +46,7 @@ const defaultCache = [
|
|
|
46
46
|
})
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
|
|
49
|
+
matcher: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,
|
|
50
50
|
handler: new StaleWhileRevalidate({
|
|
51
51
|
cacheName: "static-image-assets",
|
|
52
52
|
plugins: [
|
|
@@ -58,7 +58,7 @@ const defaultCache = [
|
|
|
58
58
|
})
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
matcher: /\/_next\/static.+\.js$/i,
|
|
62
62
|
handler: new CacheFirst({
|
|
63
63
|
cacheName: "next-static-js-assets",
|
|
64
64
|
plugins: [
|
|
@@ -70,7 +70,7 @@ const defaultCache = [
|
|
|
70
70
|
})
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
|
-
|
|
73
|
+
matcher: /\/_next\/image\?url=.+$/i,
|
|
74
74
|
handler: new StaleWhileRevalidate({
|
|
75
75
|
cacheName: "next-image",
|
|
76
76
|
plugins: [
|
|
@@ -82,7 +82,7 @@ const defaultCache = [
|
|
|
82
82
|
})
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
|
|
85
|
+
matcher: /\.(?:mp3|wav|ogg)$/i,
|
|
86
86
|
handler: new CacheFirst({
|
|
87
87
|
cacheName: "static-audio-assets",
|
|
88
88
|
plugins: [
|
|
@@ -95,7 +95,7 @@ const defaultCache = [
|
|
|
95
95
|
})
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
|
-
|
|
98
|
+
matcher: /\.(?:mp4|webm)$/i,
|
|
99
99
|
handler: new CacheFirst({
|
|
100
100
|
cacheName: "static-video-assets",
|
|
101
101
|
plugins: [
|
|
@@ -108,7 +108,7 @@ const defaultCache = [
|
|
|
108
108
|
})
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
|
-
|
|
111
|
+
matcher: /\.(?:js)$/i,
|
|
112
112
|
handler: new StaleWhileRevalidate({
|
|
113
113
|
cacheName: "static-js-assets",
|
|
114
114
|
plugins: [
|
|
@@ -120,7 +120,7 @@ const defaultCache = [
|
|
|
120
120
|
})
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
|
-
|
|
123
|
+
matcher: /\.(?:css|less)$/i,
|
|
124
124
|
handler: new StaleWhileRevalidate({
|
|
125
125
|
cacheName: "static-style-assets",
|
|
126
126
|
plugins: [
|
|
@@ -132,8 +132,8 @@ const defaultCache = [
|
|
|
132
132
|
})
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
|
-
|
|
136
|
-
handler: new
|
|
135
|
+
matcher: /\/_next\/data\/.+\/.+\.json$/i,
|
|
136
|
+
handler: new NetworkFirst({
|
|
137
137
|
cacheName: "next-data",
|
|
138
138
|
plugins: [
|
|
139
139
|
new ExpirationPlugin({
|
|
@@ -144,7 +144,7 @@ const defaultCache = [
|
|
|
144
144
|
})
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
|
-
|
|
147
|
+
matcher: /\.(?:json|xml|csv)$/i,
|
|
148
148
|
handler: new NetworkFirst({
|
|
149
149
|
cacheName: "static-data-assets",
|
|
150
150
|
plugins: [
|
|
@@ -156,7 +156,7 @@ const defaultCache = [
|
|
|
156
156
|
})
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
|
-
|
|
159
|
+
matcher: ({ sameOrigin, url: { pathname } })=>{
|
|
160
160
|
if (!sameOrigin || pathname.startsWith("/api/auth/callback")) {
|
|
161
161
|
return false;
|
|
162
162
|
}
|
|
@@ -178,7 +178,7 @@ const defaultCache = [
|
|
|
178
178
|
})
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
|
-
|
|
181
|
+
matcher: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("RSC") === "1" && request.headers.get("Next-Router-Prefetch") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
182
182
|
handler: new NetworkFirst({
|
|
183
183
|
cacheName: PAGES_CACHE_NAME.rscPrefetch,
|
|
184
184
|
plugins: [
|
|
@@ -190,7 +190,7 @@ const defaultCache = [
|
|
|
190
190
|
})
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
|
|
193
|
+
matcher: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("RSC") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
194
194
|
handler: new NetworkFirst({
|
|
195
195
|
cacheName: PAGES_CACHE_NAME.rsc,
|
|
196
196
|
plugins: [
|
|
@@ -202,7 +202,7 @@ const defaultCache = [
|
|
|
202
202
|
})
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
|
-
|
|
205
|
+
matcher: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("Content-Type")?.includes("text/html") && sameOrigin && !pathname.startsWith("/api/"),
|
|
206
206
|
handler: new NetworkFirst({
|
|
207
207
|
cacheName: PAGES_CACHE_NAME.html,
|
|
208
208
|
plugins: [
|
|
@@ -214,7 +214,7 @@ const defaultCache = [
|
|
|
214
214
|
})
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
|
-
|
|
217
|
+
matcher: ({ url: { pathname }, sameOrigin })=>sameOrigin && !pathname.startsWith("/api/"),
|
|
218
218
|
handler: new NetworkFirst({
|
|
219
219
|
cacheName: "others",
|
|
220
220
|
plugins: [
|
|
@@ -226,7 +226,7 @@ const defaultCache = [
|
|
|
226
226
|
})
|
|
227
227
|
},
|
|
228
228
|
{
|
|
229
|
-
|
|
229
|
+
matcher: ({ sameOrigin })=>!sameOrigin,
|
|
230
230
|
handler: new NetworkFirst({
|
|
231
231
|
cacheName: "cross-origin",
|
|
232
232
|
plugins: [
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { CacheFirst, NetworkFirst } from "@serwist/strategies";
|
|
2
2
|
export declare const defaultCache: ({
|
|
3
|
-
|
|
3
|
+
matcher: RegExp;
|
|
4
4
|
handler: CacheFirst;
|
|
5
5
|
method?: undefined;
|
|
6
6
|
} | {
|
|
7
|
-
|
|
7
|
+
matcher: ({ sameOrigin, url: { pathname } }: import("@serwist/core").RouteMatchCallbackOptions) => boolean;
|
|
8
8
|
method: "GET";
|
|
9
9
|
handler: NetworkFirst;
|
|
10
10
|
} | {
|
|
11
|
-
|
|
11
|
+
matcher: ({ request, url: { pathname }, sameOrigin }: import("@serwist/core").RouteMatchCallbackOptions) => boolean | undefined;
|
|
12
12
|
handler: NetworkFirst;
|
|
13
13
|
method?: undefined;
|
|
14
14
|
})[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
6
|
"files": [
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"chalk": "5.3.0",
|
|
54
54
|
"clean-webpack-plugin": "4.0.0",
|
|
55
55
|
"fast-glob": "3.3.2",
|
|
56
|
-
"@serwist/build": "9.0.0-preview.
|
|
57
|
-
"@serwist/core": "9.0.0-preview.
|
|
58
|
-
"@serwist/expiration": "9.0.0-preview.
|
|
59
|
-
"@serwist/range-requests": "9.0.0-preview.
|
|
60
|
-
"@serwist/strategies": "9.0.0-preview.
|
|
61
|
-
"@serwist/webpack-plugin": "9.0.0-preview.
|
|
62
|
-
"@serwist/window": "9.0.0-preview.
|
|
56
|
+
"@serwist/build": "9.0.0-preview.5",
|
|
57
|
+
"@serwist/core": "9.0.0-preview.5",
|
|
58
|
+
"@serwist/expiration": "9.0.0-preview.5",
|
|
59
|
+
"@serwist/range-requests": "9.0.0-preview.5",
|
|
60
|
+
"@serwist/strategies": "9.0.0-preview.5",
|
|
61
|
+
"@serwist/webpack-plugin": "9.0.0-preview.5",
|
|
62
|
+
"@serwist/window": "9.0.0-preview.5"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/node": "20.11.16",
|
|
@@ -70,15 +70,15 @@
|
|
|
70
70
|
"type-fest": "4.10.2",
|
|
71
71
|
"typescript": "5.4.0-dev.20240206",
|
|
72
72
|
"webpack": "5.90.1",
|
|
73
|
-
"@serwist/constants": "9.0.0-preview.
|
|
74
|
-
"@serwist/sw": "9.0.0-preview.
|
|
75
|
-
"@serwist/utils": "9.0.0-preview.
|
|
73
|
+
"@serwist/constants": "9.0.0-preview.5",
|
|
74
|
+
"@serwist/sw": "9.0.0-preview.5",
|
|
75
|
+
"@serwist/utils": "9.0.0-preview.5"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"next": ">=14.0.0",
|
|
79
79
|
"typescript": ">=5.0.0",
|
|
80
80
|
"webpack": ">=5.9.0",
|
|
81
|
-
"@serwist/sw": "9.0.0-preview.
|
|
81
|
+
"@serwist/sw": "9.0.0-preview.5"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
84
84
|
"@serwist/sw": {
|
|
@@ -8,7 +8,7 @@ import { PAGES_CACHE_NAME } from "./constants.js";
|
|
|
8
8
|
// Serwist RuntimeCaching config: https://serwist.pages.dev/docs/sw/register-runtime-caching
|
|
9
9
|
export const defaultCache = [
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
matcher: /^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,
|
|
12
12
|
handler: new CacheFirst({
|
|
13
13
|
cacheName: "google-fonts-webfonts",
|
|
14
14
|
plugins: [
|
|
@@ -20,7 +20,7 @@ export const defaultCache = [
|
|
|
20
20
|
}),
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
|
|
23
|
+
matcher: /^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,
|
|
24
24
|
handler: new StaleWhileRevalidate({
|
|
25
25
|
cacheName: "google-fonts-stylesheets",
|
|
26
26
|
plugins: [
|
|
@@ -32,7 +32,7 @@ export const defaultCache = [
|
|
|
32
32
|
}),
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
|
|
35
|
+
matcher: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,
|
|
36
36
|
handler: new StaleWhileRevalidate({
|
|
37
37
|
cacheName: "static-font-assets",
|
|
38
38
|
plugins: [
|
|
@@ -44,7 +44,7 @@ export const defaultCache = [
|
|
|
44
44
|
}),
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
matcher: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,
|
|
48
48
|
handler: new StaleWhileRevalidate({
|
|
49
49
|
cacheName: "static-image-assets",
|
|
50
50
|
plugins: [
|
|
@@ -56,7 +56,7 @@ export const defaultCache = [
|
|
|
56
56
|
}),
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
|
|
59
|
+
matcher: /\/_next\/static.+\.js$/i,
|
|
60
60
|
handler: new CacheFirst({
|
|
61
61
|
cacheName: "next-static-js-assets",
|
|
62
62
|
plugins: [
|
|
@@ -68,7 +68,7 @@ export const defaultCache = [
|
|
|
68
68
|
}),
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
|
|
71
|
+
matcher: /\/_next\/image\?url=.+$/i,
|
|
72
72
|
handler: new StaleWhileRevalidate({
|
|
73
73
|
cacheName: "next-image",
|
|
74
74
|
plugins: [
|
|
@@ -80,7 +80,7 @@ export const defaultCache = [
|
|
|
80
80
|
}),
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
matcher: /\.(?:mp3|wav|ogg)$/i,
|
|
84
84
|
handler: new CacheFirst({
|
|
85
85
|
cacheName: "static-audio-assets",
|
|
86
86
|
plugins: [
|
|
@@ -93,7 +93,7 @@ export const defaultCache = [
|
|
|
93
93
|
}),
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
|
|
96
|
+
matcher: /\.(?:mp4|webm)$/i,
|
|
97
97
|
handler: new CacheFirst({
|
|
98
98
|
cacheName: "static-video-assets",
|
|
99
99
|
plugins: [
|
|
@@ -106,7 +106,7 @@ export const defaultCache = [
|
|
|
106
106
|
}),
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
|
-
|
|
109
|
+
matcher: /\.(?:js)$/i,
|
|
110
110
|
handler: new StaleWhileRevalidate({
|
|
111
111
|
cacheName: "static-js-assets",
|
|
112
112
|
plugins: [
|
|
@@ -118,7 +118,7 @@ export const defaultCache = [
|
|
|
118
118
|
}),
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
|
-
|
|
121
|
+
matcher: /\.(?:css|less)$/i,
|
|
122
122
|
handler: new StaleWhileRevalidate({
|
|
123
123
|
cacheName: "static-style-assets",
|
|
124
124
|
plugins: [
|
|
@@ -130,8 +130,8 @@ export const defaultCache = [
|
|
|
130
130
|
}),
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
|
|
134
|
-
handler: new
|
|
133
|
+
matcher: /\/_next\/data\/.+\/.+\.json$/i,
|
|
134
|
+
handler: new NetworkFirst({
|
|
135
135
|
cacheName: "next-data",
|
|
136
136
|
plugins: [
|
|
137
137
|
new ExpirationPlugin({
|
|
@@ -142,7 +142,7 @@ export const defaultCache = [
|
|
|
142
142
|
}),
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
|
-
|
|
145
|
+
matcher: /\.(?:json|xml|csv)$/i,
|
|
146
146
|
handler: new NetworkFirst({
|
|
147
147
|
cacheName: "static-data-assets",
|
|
148
148
|
plugins: [
|
|
@@ -154,7 +154,7 @@ export const defaultCache = [
|
|
|
154
154
|
}),
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
|
-
|
|
157
|
+
matcher: ({ sameOrigin, url: { pathname } }) => {
|
|
158
158
|
// Exclude /api/auth/callback/* to fix OAuth workflow in Safari without having an impact on other environments
|
|
159
159
|
// The above route is the default for next-auth, you may need to change it if your OAuth workflow has a different callback route
|
|
160
160
|
// Issue: https://github.com/shadowwalker/next-pwa/issues/131#issuecomment-821894809
|
|
@@ -181,7 +181,7 @@ export const defaultCache = [
|
|
|
181
181
|
}),
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
|
|
184
|
+
matcher: ({ request, url: { pathname }, sameOrigin }) =>
|
|
185
185
|
request.headers.get("RSC") === "1" && request.headers.get("Next-Router-Prefetch") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
186
186
|
handler: new NetworkFirst({
|
|
187
187
|
cacheName: PAGES_CACHE_NAME.rscPrefetch,
|
|
@@ -194,7 +194,7 @@ export const defaultCache = [
|
|
|
194
194
|
}),
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
|
-
|
|
197
|
+
matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get("RSC") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
198
198
|
handler: new NetworkFirst({
|
|
199
199
|
cacheName: PAGES_CACHE_NAME.rsc,
|
|
200
200
|
plugins: [
|
|
@@ -206,7 +206,7 @@ export const defaultCache = [
|
|
|
206
206
|
}),
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
|
-
|
|
209
|
+
matcher: ({ request, url: { pathname }, sameOrigin }) =>
|
|
210
210
|
request.headers.get("Content-Type")?.includes("text/html") && sameOrigin && !pathname.startsWith("/api/"),
|
|
211
211
|
handler: new NetworkFirst({
|
|
212
212
|
cacheName: PAGES_CACHE_NAME.html,
|
|
@@ -219,7 +219,7 @@ export const defaultCache = [
|
|
|
219
219
|
}),
|
|
220
220
|
},
|
|
221
221
|
{
|
|
222
|
-
|
|
222
|
+
matcher: ({ url: { pathname }, sameOrigin }) => sameOrigin && !pathname.startsWith("/api/"),
|
|
223
223
|
handler: new NetworkFirst({
|
|
224
224
|
cacheName: "others",
|
|
225
225
|
plugins: [
|
|
@@ -231,7 +231,7 @@ export const defaultCache = [
|
|
|
231
231
|
}),
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
|
-
|
|
234
|
+
matcher: ({ sameOrigin }) => !sameOrigin,
|
|
235
235
|
handler: new NetworkFirst({
|
|
236
236
|
cacheName: "cross-origin",
|
|
237
237
|
plugins: [
|