@serwist/sw 9.0.0-preview.11 → 9.0.0-preview.13

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.
@@ -16,9 +16,8 @@ export type HandlePrecachingOptions = {
16
16
  cleanupOutdatedCaches?: boolean;
17
17
  } & ({
18
18
  /**
19
- * An URL that should point to a HTML
20
- * file with which navigation requests for URLs that aren't precached will be fulfilled.
21
- * For more complex cases, consider `@serwist/sw.fallbacks`instead.
19
+ * An URL that should point to a HTML file with which navigation requests for URLs that aren't
20
+ * precached will be fulfilled.
22
21
  */
23
22
  navigateFallback: string;
24
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"handlePrecaching.d.ts","sourceRoot":"","sources":["../src/handlePrecaching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI/E,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7C;;OAEG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,CACA;IACE;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,GACD;IAAE,gBAAgB,CAAC,EAAE,KAAK,CAAA;CAAE,CAC/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,4EAAqF,uBAAuB,KAAG,IAoB3I,CAAC"}
1
+ {"version":3,"file":"handlePrecaching.d.ts","sourceRoot":"","sources":["../src/handlePrecaching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI/E,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7C;;OAEG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,CACA;IACE;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,GACD;IAAE,gBAAgB,CAAC,EAAE,KAAK,CAAA;CAAE,CAC/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,4EAAqF,uBAAuB,KAAG,IAoB3I,CAAC"}
package/dist/index.js CHANGED
@@ -27,13 +27,13 @@ const fallbacks = ({ runtimeCaching, entries, precacheOptions })=>{
27
27
  const handlePrecaching = ({ precacheEntries, precacheOptions, cleanupOutdatedCaches: cleanupOutdatedCaches$1 = false, ...options })=>{
28
28
  if (!!precacheEntries && precacheEntries.length > 0) {
29
29
  precacheAndRoute(precacheEntries, precacheOptions);
30
- }
31
- if (cleanupOutdatedCaches$1) cleanupOutdatedCaches();
32
- if (options.navigateFallback) {
33
- registerRoute(new NavigationRoute(createHandlerBoundToURL(options.navigateFallback), {
34
- allowlist: options.navigateFallbackAllowlist,
35
- denylist: options.navigateFallbackDenylist
36
- }));
30
+ if (cleanupOutdatedCaches$1) cleanupOutdatedCaches();
31
+ if (options.navigateFallback) {
32
+ registerRoute(new NavigationRoute(createHandlerBoundToURL(options.navigateFallback), {
33
+ allowlist: options.navigateFallbackAllowlist,
34
+ denylist: options.navigateFallbackDenylist
35
+ }));
36
+ }
37
37
  }
38
38
  };
39
39
 
@@ -78,6 +78,13 @@ const installSerwist = ({ precacheEntries, precacheOptions, cleanupOutdatedCache
78
78
  navigateFallbackDenylist: options.navigateFallbackDenylist
79
79
  }
80
80
  });
81
+ if (offlineAnalyticsConfig !== undefined) {
82
+ if (typeof offlineAnalyticsConfig === "boolean") {
83
+ offlineAnalyticsConfig && initialize();
84
+ } else {
85
+ initialize(offlineAnalyticsConfig);
86
+ }
87
+ }
81
88
  if (runtimeCaching !== undefined) {
82
89
  if (!("__WB_FORCE_RUNTIME_CACHING" in globalThis)) {
83
90
  self.__WB_FORCE_RUNTIME_CACHING = false;
@@ -94,13 +101,6 @@ const installSerwist = ({ precacheEntries, precacheOptions, cleanupOutdatedCache
94
101
  registerRuntimeCaching(...runtimeCaching);
95
102
  }
96
103
  }
97
- if (offlineAnalyticsConfig !== undefined) {
98
- if (typeof offlineAnalyticsConfig === "boolean") {
99
- offlineAnalyticsConfig && initialize();
100
- } else {
101
- initialize(offlineAnalyticsConfig);
102
- }
103
- }
104
104
  if (disableDevLogs$1) disableDevLogs();
105
105
  };
106
106
 
@@ -17,7 +17,7 @@ export type InstallSerwistOptions = HandlePrecachingOptions & {
17
17
  */
18
18
  importScripts?: string[];
19
19
  /**
20
- * Enables Navigation Preload if it is supported.
20
+ * Enables navigation preloading if it is supported.
21
21
  *
22
22
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload
23
23
  */
@@ -61,7 +61,7 @@ export type InstallSerwistOptions = HandlePrecachingOptions & {
61
61
  fallbacks?: Omit<FallbacksOptions, "runtimeCaching">;
62
62
  };
63
63
  /**
64
- * A function that abstracts away the core APIs of Serwist.
64
+ * Abstracts away the core APIs of Serwist.
65
65
  * @param options - `installSerwist` options.
66
66
  */
67
67
  export declare const installSerwist: ({ precacheEntries, precacheOptions, cleanupOutdatedCaches, skipWaiting, importScripts, navigationPreload, cacheId, clientsClaim, runtimeCaching, offlineAnalyticsConfig, disableDevLogs, fallbacks, ...options }: InstallSerwistOptions) => void;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@serwist/sw",
3
- "version": "9.0.0-preview.11",
3
+ "version": "9.0.0-preview.13",
4
4
  "type": "module",
5
- "description": "This module makes it easy to get started with the Serwist service worker libraries.",
5
+ "description": "A module that makes it easy to get started with the Serwist service worker libraries.",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -28,23 +28,23 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@serwist/background-sync": "9.0.0-preview.11",
32
- "@serwist/broadcast-update": "9.0.0-preview.11",
33
- "@serwist/cacheable-response": "9.0.0-preview.11",
34
- "@serwist/core": "9.0.0-preview.11",
35
- "@serwist/expiration": "9.0.0-preview.11",
36
- "@serwist/google-analytics": "9.0.0-preview.11",
37
- "@serwist/navigation-preload": "9.0.0-preview.11",
38
- "@serwist/precaching": "9.0.0-preview.11",
39
- "@serwist/range-requests": "9.0.0-preview.11",
40
- "@serwist/routing": "9.0.0-preview.11",
41
- "@serwist/strategies": "9.0.0-preview.11"
31
+ "@serwist/background-sync": "9.0.0-preview.13",
32
+ "@serwist/broadcast-update": "9.0.0-preview.13",
33
+ "@serwist/cacheable-response": "9.0.0-preview.13",
34
+ "@serwist/core": "9.0.0-preview.13",
35
+ "@serwist/expiration": "9.0.0-preview.13",
36
+ "@serwist/google-analytics": "9.0.0-preview.13",
37
+ "@serwist/navigation-preload": "9.0.0-preview.13",
38
+ "@serwist/precaching": "9.0.0-preview.13",
39
+ "@serwist/range-requests": "9.0.0-preview.13",
40
+ "@serwist/routing": "9.0.0-preview.13",
41
+ "@serwist/strategies": "9.0.0-preview.13"
42
42
  },
43
43
  "devDependencies": {
44
- "rollup": "4.9.6",
45
- "typescript": "5.4.0-dev.20240206",
46
- "@serwist/constants": "9.0.0-preview.11",
47
- "@serwist/utils": "9.0.0-preview.11"
44
+ "rollup": "4.12.0",
45
+ "typescript": "5.5.0-dev.20240304",
46
+ "@serwist/constants": "9.0.0-preview.13",
47
+ "@serwist/utils": "9.0.0-preview.13"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "typescript": ">=5.0.0"
@@ -20,9 +20,8 @@ export type HandlePrecachingOptions = {
20
20
  } & (
21
21
  | {
22
22
  /**
23
- * An URL that should point to a HTML
24
- * file with which navigation requests for URLs that aren't precached will be fulfilled.
25
- * For more complex cases, consider `@serwist/sw.fallbacks`instead.
23
+ * An URL that should point to a HTML file with which navigation requests for URLs that aren't
24
+ * precached will be fulfilled.
26
25
  */
27
26
  navigateFallback: string;
28
27
  /**
@@ -52,16 +51,16 @@ export const handlePrecaching = ({ precacheEntries, precacheOptions, cleanupOutd
52
51
  * See https://goo.gl/S9QRab
53
52
  */
54
53
  precacheAndRoute(precacheEntries, precacheOptions);
55
- }
56
54
 
57
- if (cleanupOutdatedCaches) cleanupOutdatedCachesImpl();
55
+ if (cleanupOutdatedCaches) cleanupOutdatedCachesImpl();
58
56
 
59
- if (options.navigateFallback) {
60
- registerRoute(
61
- new NavigationRoute(createHandlerBoundToURL(options.navigateFallback), {
62
- allowlist: options.navigateFallbackAllowlist,
63
- denylist: options.navigateFallbackDenylist,
64
- }),
65
- );
57
+ if (options.navigateFallback) {
58
+ registerRoute(
59
+ new NavigationRoute(createHandlerBoundToURL(options.navigateFallback), {
60
+ allowlist: options.navigateFallbackAllowlist,
61
+ denylist: options.navigateFallbackDenylist,
62
+ }),
63
+ );
64
+ }
66
65
  }
67
66
  };
@@ -27,7 +27,7 @@ export type InstallSerwistOptions = HandlePrecachingOptions & {
27
27
  */
28
28
  importScripts?: string[];
29
29
  /**
30
- * Enables Navigation Preload if it is supported.
30
+ * Enables navigation preloading if it is supported.
31
31
  *
32
32
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload
33
33
  */
@@ -72,7 +72,7 @@ export type InstallSerwistOptions = HandlePrecachingOptions & {
72
72
  };
73
73
 
74
74
  /**
75
- * A function that abstracts away the core APIs of Serwist.
75
+ * Abstracts away the core APIs of Serwist.
76
76
  * @param options - `installSerwist` options.
77
77
  */
78
78
  export const installSerwist = ({
@@ -124,6 +124,14 @@ export const installSerwist = ({
124
124
  }),
125
125
  });
126
126
 
127
+ if (offlineAnalyticsConfig !== undefined) {
128
+ if (typeof offlineAnalyticsConfig === "boolean") {
129
+ offlineAnalyticsConfig && initialize();
130
+ } else {
131
+ initialize(offlineAnalyticsConfig);
132
+ }
133
+ }
134
+
127
135
  if (runtimeCaching !== undefined) {
128
136
  if (!("__WB_FORCE_RUNTIME_CACHING" in globalThis)) {
129
137
  self.__WB_FORCE_RUNTIME_CACHING = false;
@@ -138,13 +146,5 @@ export const installSerwist = ({
138
146
  }
139
147
  }
140
148
 
141
- if (offlineAnalyticsConfig !== undefined) {
142
- if (typeof offlineAnalyticsConfig === "boolean") {
143
- offlineAnalyticsConfig && initialize();
144
- } else {
145
- initialize(offlineAnalyticsConfig);
146
- }
147
- }
148
-
149
149
  if (disableDevLogs) disableDevLogsImpl();
150
150
  };