@serwist/svelte 9.0.0-preview.15 → 9.0.0-preview.16
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.d.ts +7 -1
- package/dist/index.worker.d.ts.map +1 -1
- package/dist/index.worker.js +2 -1
- package/package.json +8 -8
- package/src/index.worker.ts +111 -102
package/dist/index.worker.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="@sveltejs/kit" />
|
2
2
|
import type { PrecacheEntry } from "@serwist/precaching";
|
3
3
|
import type { RuntimeCaching } from "@serwist/sw";
|
4
|
-
import { base as basePath, build as immutableAssets,
|
4
|
+
import { base as basePath, build as immutableAssets, files as staticAssets, prerendered as prerenderedRoutes, version as serviceWorkerVersion } from "$service-worker";
|
5
5
|
export { basePath, immutableAssets, staticAssets, prerenderedRoutes, serviceWorkerVersion };
|
6
6
|
export type StaticRevisions = string | {
|
7
7
|
[url: string]: string | null;
|
@@ -59,5 +59,11 @@ export interface GetPrecacheManifestOptions {
|
|
59
59
|
*/
|
60
60
|
export declare const getPrecacheManifest: ({ precacheImmutable, precacheStatic, precachePrerendered, staticRevisions, manifestTransforms, }?: GetPrecacheManifestOptions) => PrecacheEntry[] | undefined;
|
61
61
|
export declare const defaultIgnoreUrlParameters: RegExp[];
|
62
|
+
/**
|
63
|
+
* The default, recommended list of caching strategies for applications
|
64
|
+
* built with SvelteKit.
|
65
|
+
*
|
66
|
+
* @see https://serwist.pages.dev/docs/svelte/worker-exports#default-cache
|
67
|
+
*/
|
62
68
|
export declare const defaultCache: RuntimeCaching[];
|
63
69
|
//# sourceMappingURL=index.worker.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.worker.d.ts","sourceRoot":"","sources":["../src/index.worker.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE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eAAO,MAAM,YAAY,EAAE,cAAc,EA8GpC,CAAC"}
|
package/dist/index.worker.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { logger } from '@serwist/core/internal';
|
2
2
|
import { ExpirationPlugin } from '@serwist/expiration';
|
3
3
|
import { CacheFirst, StaleWhileRevalidate, NetworkFirst } from '@serwist/strategies';
|
4
|
+
import { dev } from '$app/environment';
|
4
5
|
import { build, files, prerendered, version } from '$service-worker';
|
5
6
|
export { base as basePath, build as immutableAssets, prerendered as prerenderedRoutes, version as serviceWorkerVersion, files as staticAssets } from '$service-worker';
|
6
7
|
|
@@ -47,7 +48,7 @@ const getPrecacheManifest = ({ precacheImmutable = true, precacheStatic = true,
|
|
47
48
|
const defaultIgnoreUrlParameters = [
|
48
49
|
/^x-sveltekit-invalidated$/
|
49
50
|
];
|
50
|
-
const defaultCache = [
|
51
|
+
const defaultCache = dev ? [] : [
|
51
52
|
{
|
52
53
|
matcher: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
|
53
54
|
handler: new CacheFirst({
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@serwist/svelte",
|
3
|
-
"version": "9.0.0-preview.
|
3
|
+
"version": "9.0.0-preview.16",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A module that complements SvelteKit's built-in service worker support.",
|
6
6
|
"files": [
|
@@ -40,21 +40,21 @@
|
|
40
40
|
"./package.json": "./package.json"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
|
-
"@serwist/core": "9.0.0-preview.
|
44
|
-
"@serwist/expiration": "9.0.0-preview.
|
45
|
-
"@serwist/strategies": "9.0.0-preview.
|
43
|
+
"@serwist/core": "9.0.0-preview.16",
|
44
|
+
"@serwist/expiration": "9.0.0-preview.16",
|
45
|
+
"@serwist/strategies": "9.0.0-preview.16"
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@sveltejs/kit": "2.5.4",
|
49
49
|
"rollup": "4.13.0",
|
50
|
-
"@serwist/constants": "9.0.0-preview.
|
51
|
-
"@serwist/precaching": "9.0.0-preview.
|
52
|
-
"@serwist/sw": "9.0.0-preview.
|
50
|
+
"@serwist/constants": "9.0.0-preview.16",
|
51
|
+
"@serwist/precaching": "9.0.0-preview.16",
|
52
|
+
"@serwist/sw": "9.0.0-preview.16"
|
53
53
|
},
|
54
54
|
"peerDependencies": {
|
55
55
|
"@sveltejs/kit": ">=2.0.0",
|
56
56
|
"typescript": ">=5.0.0",
|
57
|
-
"@serwist/sw": "9.0.0-preview.
|
57
|
+
"@serwist/sw": "9.0.0-preview.16"
|
58
58
|
},
|
59
59
|
"peerDependenciesMeta": {
|
60
60
|
"@serwist/sw": {
|
package/src/index.worker.ts
CHANGED
@@ -4,12 +4,13 @@ import type { PrecacheEntry } from "@serwist/precaching";
|
|
4
4
|
import { CacheFirst, NetworkFirst, StaleWhileRevalidate } from "@serwist/strategies";
|
5
5
|
import type { RuntimeCaching } from "@serwist/sw";
|
6
6
|
|
7
|
+
import { dev } from "$app/environment";
|
7
8
|
import {
|
8
9
|
base as basePath,
|
9
10
|
build as immutableAssets,
|
11
|
+
files as staticAssets,
|
10
12
|
prerendered as prerenderedRoutes,
|
11
13
|
version as serviceWorkerVersion,
|
12
|
-
files as staticAssets,
|
13
14
|
} from "$service-worker";
|
14
15
|
|
15
16
|
export { basePath, immutableAssets, staticAssets, prerenderedRoutes, serviceWorkerVersion };
|
@@ -122,112 +123,120 @@ export const getPrecacheManifest = ({
|
|
122
123
|
|
123
124
|
export const defaultIgnoreUrlParameters = [/^x-sveltekit-invalidated$/];
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
126
|
+
/**
|
127
|
+
* The default, recommended list of caching strategies for applications
|
128
|
+
* built with SvelteKit.
|
129
|
+
*
|
130
|
+
* @see https://serwist.pages.dev/docs/svelte/worker-exports#default-cache
|
131
|
+
*/
|
132
|
+
export const defaultCache: RuntimeCaching[] = dev
|
133
|
+
? []
|
134
|
+
: [
|
135
|
+
{
|
136
|
+
matcher: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
|
137
|
+
handler: new CacheFirst({
|
138
|
+
cacheName: "google-fonts",
|
139
|
+
plugins: [
|
140
|
+
new ExpirationPlugin({
|
141
|
+
maxEntries: 4,
|
142
|
+
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
|
143
|
+
maxAgeFrom: "last-used",
|
144
|
+
}),
|
145
|
+
],
|
135
146
|
}),
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
147
|
+
},
|
148
|
+
{
|
149
|
+
matcher: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,
|
150
|
+
handler: new StaleWhileRevalidate({
|
151
|
+
cacheName: "static-font-assets",
|
152
|
+
plugins: [
|
153
|
+
new ExpirationPlugin({
|
154
|
+
maxEntries: 4,
|
155
|
+
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
|
156
|
+
maxAgeFrom: "last-used",
|
157
|
+
}),
|
158
|
+
],
|
148
159
|
}),
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
},
|
161
|
+
{
|
162
|
+
matcher: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,
|
163
|
+
handler: new StaleWhileRevalidate({
|
164
|
+
cacheName: "static-image-assets",
|
165
|
+
plugins: [
|
166
|
+
new ExpirationPlugin({
|
167
|
+
maxEntries: 64,
|
168
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
169
|
+
maxAgeFrom: "last-used",
|
170
|
+
}),
|
171
|
+
],
|
161
172
|
}),
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
173
|
+
},
|
174
|
+
{
|
175
|
+
matcher: /\.(?:js)$/i,
|
176
|
+
handler: new StaleWhileRevalidate({
|
177
|
+
cacheName: "static-js-assets",
|
178
|
+
plugins: [
|
179
|
+
new ExpirationPlugin({
|
180
|
+
maxEntries: 32,
|
181
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
182
|
+
maxAgeFrom: "last-used",
|
183
|
+
}),
|
184
|
+
],
|
174
185
|
}),
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
186
|
+
},
|
187
|
+
{
|
188
|
+
matcher: /\.(?:css|less)$/i,
|
189
|
+
handler: new StaleWhileRevalidate({
|
190
|
+
cacheName: "static-style-assets",
|
191
|
+
plugins: [
|
192
|
+
new ExpirationPlugin({
|
193
|
+
maxEntries: 32,
|
194
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
195
|
+
maxAgeFrom: "last-used",
|
196
|
+
}),
|
197
|
+
],
|
187
198
|
}),
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
199
|
+
},
|
200
|
+
{
|
201
|
+
matcher: /\.(?:json|xml|csv)$/i,
|
202
|
+
handler: new NetworkFirst({
|
203
|
+
cacheName: "static-data-assets",
|
204
|
+
plugins: [
|
205
|
+
new ExpirationPlugin({
|
206
|
+
maxEntries: 32,
|
207
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
208
|
+
maxAgeFrom: "last-used",
|
209
|
+
}),
|
210
|
+
],
|
200
211
|
}),
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
212
|
+
},
|
213
|
+
{
|
214
|
+
matcher: /\/api\/.*$/i,
|
215
|
+
method: "GET",
|
216
|
+
handler: new NetworkFirst({
|
217
|
+
cacheName: "apis",
|
218
|
+
plugins: [
|
219
|
+
new ExpirationPlugin({
|
220
|
+
maxEntries: 16,
|
221
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
222
|
+
maxAgeFrom: "last-used",
|
223
|
+
}),
|
224
|
+
],
|
225
|
+
networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds
|
214
226
|
}),
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
227
|
+
},
|
228
|
+
{
|
229
|
+
matcher: /.*/i,
|
230
|
+
handler: new NetworkFirst({
|
231
|
+
cacheName: "others",
|
232
|
+
plugins: [
|
233
|
+
new ExpirationPlugin({
|
234
|
+
maxEntries: 32,
|
235
|
+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
236
|
+
maxAgeFrom: "last-used",
|
237
|
+
}),
|
238
|
+
],
|
239
|
+
networkTimeoutSeconds: 10,
|
228
240
|
}),
|
229
|
-
|
230
|
-
|
231
|
-
}),
|
232
|
-
},
|
233
|
-
];
|
241
|
+
},
|
242
|
+
];
|