@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.
@@ -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, prerendered as prerenderedRoutes, version as serviceWorkerVersion, files as staticAssets } from "$service-worker";
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,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,KAAK,IAAI,eAAe,EACxB,WAAW,IAAI,iBAAiB,EAChC,OAAO,IAAI,oBAAoB,EAC/B,KAAK,IAAI,YAAY,EACtB,MAAM,iBAAiB,CAAC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,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;AAE5F,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK;IAC7D,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,sGAM7B,0BAA0B,KAAQ,aAAa,EAAE,GAAG,SA2CtD,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAAgC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,EA8GpC,CAAC"}
@@ -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.15",
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.15",
44
- "@serwist/expiration": "9.0.0-preview.15",
45
- "@serwist/strategies": "9.0.0-preview.15"
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.15",
51
- "@serwist/precaching": "9.0.0-preview.15",
52
- "@serwist/sw": "9.0.0-preview.15"
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.15"
57
+ "@serwist/sw": "9.0.0-preview.16"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "@serwist/sw": {
@@ -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
- export const defaultCache: RuntimeCaching[] = [
126
- {
127
- matcher: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
128
- handler: new CacheFirst({
129
- cacheName: "google-fonts",
130
- plugins: [
131
- new ExpirationPlugin({
132
- maxEntries: 4,
133
- maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
134
- maxAgeFrom: "last-used",
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
- matcher: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,
141
- handler: new StaleWhileRevalidate({
142
- cacheName: "static-font-assets",
143
- plugins: [
144
- new ExpirationPlugin({
145
- maxEntries: 4,
146
- maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
147
- maxAgeFrom: "last-used",
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
- matcher: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,
154
- handler: new StaleWhileRevalidate({
155
- cacheName: "static-image-assets",
156
- plugins: [
157
- new ExpirationPlugin({
158
- maxEntries: 64,
159
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
160
- maxAgeFrom: "last-used",
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
- matcher: /\.(?:js)$/i,
167
- handler: new StaleWhileRevalidate({
168
- cacheName: "static-js-assets",
169
- plugins: [
170
- new ExpirationPlugin({
171
- maxEntries: 32,
172
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
173
- maxAgeFrom: "last-used",
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
- matcher: /\.(?:css|less)$/i,
180
- handler: new StaleWhileRevalidate({
181
- cacheName: "static-style-assets",
182
- plugins: [
183
- new ExpirationPlugin({
184
- maxEntries: 32,
185
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
186
- maxAgeFrom: "last-used",
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
- matcher: /\.(?:json|xml|csv)$/i,
193
- handler: new NetworkFirst({
194
- cacheName: "static-data-assets",
195
- plugins: [
196
- new ExpirationPlugin({
197
- maxEntries: 32,
198
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
199
- maxAgeFrom: "last-used",
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
- matcher: /\/api\/.*$/i,
206
- method: "GET",
207
- handler: new NetworkFirst({
208
- cacheName: "apis",
209
- plugins: [
210
- new ExpirationPlugin({
211
- maxEntries: 16,
212
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
213
- maxAgeFrom: "last-used",
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
- networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds
217
- }),
218
- },
219
- {
220
- matcher: /.*/i,
221
- handler: new NetworkFirst({
222
- cacheName: "others",
223
- plugins: [
224
- new ExpirationPlugin({
225
- maxEntries: 32,
226
- maxAgeSeconds: 24 * 60 * 60, // 24 hours
227
- maxAgeFrom: "last-used",
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
- networkTimeoutSeconds: 10,
231
- }),
232
- },
233
- ];
241
+ },
242
+ ];