@serwist/navigation-preload 8.4.4 → 9.0.0-preview.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/disable.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * If the browser supports Navigation Preload, then this will disable it.
3
3
  */
4
- declare function disable(): void;
5
- export { disable };
4
+ export declare const disable: () => void;
5
+ //# sourceMappingURL=disable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disable.d.ts","sourceRoot":"","sources":["../src/disable.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,OAAO,QAAO,IAgB1B,CAAC"}
package/dist/enable.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  * the value of the `Service-Worker-Navigation-Preload` header which will be
7
7
  * sent to the server when making the navigation request.
8
8
  */
9
- declare function enable(headerValue?: string): void;
10
- export { enable };
9
+ export declare const enable: (headerValue?: string) => void;
10
+ //# sourceMappingURL=enable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable.d.ts","sourceRoot":"","sources":["../src/enable.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,iBAAkB,MAAM,KAAG,IAqB7C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ import { disable } from "./disable.js";
2
2
  import { enable } from "./enable.js";
3
3
  import { isSupported } from "./isSupported.js";
4
4
  export { disable, enable, isSupported };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,22 +1,10 @@
1
1
  import { logger } from '@serwist/core/internal';
2
2
 
3
- /*
4
- Copyright 2018 Google LLC
5
-
6
- Use of this source code is governed by an MIT-style
7
- license that can be found in the LICENSE file or at
8
- https://opensource.org/licenses/MIT.
9
- */ // Give TypeScript the correct global.
10
- /**
11
- * @returns Whether or not the current browser supports enabling
12
- * navigation preload.
13
- */ function isSupported() {
3
+ const isSupported = ()=>{
14
4
  return Boolean(self.registration?.navigationPreload);
15
- }
5
+ };
16
6
 
17
- /**
18
- * If the browser supports Navigation Preload, then this will disable it.
19
- */ function disable() {
7
+ const disable = ()=>{
20
8
  if (isSupported()) {
21
9
  self.addEventListener("activate", (event)=>{
22
10
  event.waitUntil(self.registration.navigationPreload.disable().then(()=>{
@@ -30,20 +18,12 @@ import { logger } from '@serwist/core/internal';
30
18
  logger.log("Navigation preload is not supported in this browser.");
31
19
  }
32
20
  }
33
- }
21
+ };
34
22
 
35
- /**
36
- * If the browser supports Navigation Preload, then this will enable it.
37
- *
38
- * @param headerValue Optionally, allows developers to
39
- * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
40
- * the value of the `Service-Worker-Navigation-Preload` header which will be
41
- * sent to the server when making the navigation request.
42
- */ function enable(headerValue) {
23
+ const enable = (headerValue)=>{
43
24
  if (isSupported()) {
44
25
  self.addEventListener("activate", (event)=>{
45
26
  event.waitUntil(self.registration.navigationPreload.enable().then(()=>{
46
- // Defaults to Service-Worker-Navigation-Preload: true if not set.
47
27
  if (headerValue) {
48
28
  void self.registration.navigationPreload.setHeaderValue(headerValue);
49
29
  }
@@ -57,6 +37,6 @@ import { logger } from '@serwist/core/internal';
57
37
  logger.log("Navigation preload is not supported in this browser.");
58
38
  }
59
39
  }
60
- }
40
+ };
61
41
 
62
42
  export { disable, enable, isSupported };
@@ -2,5 +2,5 @@
2
2
  * @returns Whether or not the current browser supports enabling
3
3
  * navigation preload.
4
4
  */
5
- declare function isSupported(): boolean;
6
- export { isSupported };
5
+ export declare const isSupported: () => boolean;
6
+ //# sourceMappingURL=isSupported.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSupported.d.ts","sourceRoot":"","sources":["../src/isSupported.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAO,OAE9B,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@serwist/navigation-preload",
3
- "version": "8.4.4",
3
+ "version": "9.0.0-preview.1",
4
4
  "type": "module",
5
5
  "description": "This library allows developers to opt-in to using Navigation Preload in their service worker.",
6
6
  "files": [
7
- "dist",
8
- "!dist/**/dts"
7
+ "src",
8
+ "dist"
9
9
  ],
10
10
  "keywords": [
11
11
  "serwist",
@@ -19,28 +19,30 @@
19
19
  "repository": "serwist/serwist",
20
20
  "bugs": "https://github.com/serwist/serwist/issues",
21
21
  "homepage": "https://serwist.pages.dev",
22
- "module": "./dist/index.js",
23
- "main": "./dist/index.cjs",
22
+ "main": "./dist/index.js",
24
23
  "types": "./dist/index.d.ts",
25
24
  "exports": {
26
25
  ".": {
27
- "import": {
28
- "types": "./dist/index.d.ts",
29
- "default": "./dist/index.js"
30
- },
31
- "require": {
32
- "types": "./dist/index.d.cts",
33
- "default": "./dist/index.cjs"
34
- }
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
35
28
  },
36
29
  "./package.json": "./package.json"
37
30
  },
38
31
  "dependencies": {
39
- "@serwist/core": "8.4.4"
32
+ "@serwist/core": "9.0.0-preview.1"
40
33
  },
41
34
  "devDependencies": {
42
- "rollup": "4.9.1",
43
- "@serwist/constants": "8.4.4"
35
+ "rollup": "4.9.6",
36
+ "typescript": "5.4.0-dev.20240203",
37
+ "@serwist/constants": "9.0.0-preview.1"
38
+ },
39
+ "peerDependencies": {
40
+ "typescript": ">=5.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "typescript": {
44
+ "optional": true
45
+ }
44
46
  },
45
47
  "scripts": {
46
48
  "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
package/src/disable.ts ADDED
@@ -0,0 +1,35 @@
1
+ /*
2
+ Copyright 2018 Google LLC
3
+
4
+ Use of this source code is governed by an MIT-style
5
+ license that can be found in the LICENSE file or at
6
+ https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ import { logger } from "@serwist/core/internal";
10
+
11
+ import { isSupported } from "./isSupported.js";
12
+
13
+ // Give TypeScript the correct global.
14
+ declare let self: ServiceWorkerGlobalScope;
15
+
16
+ /**
17
+ * If the browser supports Navigation Preload, then this will disable it.
18
+ */
19
+ export const disable = (): void => {
20
+ if (isSupported()) {
21
+ self.addEventListener("activate", (event: ExtendableEvent) => {
22
+ event.waitUntil(
23
+ self.registration.navigationPreload.disable().then(() => {
24
+ if (process.env.NODE_ENV !== "production") {
25
+ logger.log("Navigation preload is disabled.");
26
+ }
27
+ }),
28
+ );
29
+ });
30
+ } else {
31
+ if (process.env.NODE_ENV !== "production") {
32
+ logger.log("Navigation preload is not supported in this browser.");
33
+ }
34
+ }
35
+ };
package/src/enable.ts ADDED
@@ -0,0 +1,45 @@
1
+ /*
2
+ Copyright 2018 Google LLC
3
+
4
+ Use of this source code is governed by an MIT-style
5
+ license that can be found in the LICENSE file or at
6
+ https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ import { logger } from "@serwist/core/internal";
10
+
11
+ import { isSupported } from "./isSupported.js";
12
+
13
+ // Give TypeScript the correct global.
14
+ declare let self: ServiceWorkerGlobalScope;
15
+
16
+ /**
17
+ * If the browser supports Navigation Preload, then this will enable it.
18
+ *
19
+ * @param headerValue Optionally, allows developers to
20
+ * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
21
+ * the value of the `Service-Worker-Navigation-Preload` header which will be
22
+ * sent to the server when making the navigation request.
23
+ */
24
+ export const enable = (headerValue?: string): void => {
25
+ if (isSupported()) {
26
+ self.addEventListener("activate", (event: ExtendableEvent) => {
27
+ event.waitUntil(
28
+ self.registration.navigationPreload.enable().then(() => {
29
+ // Defaults to Service-Worker-Navigation-Preload: true if not set.
30
+ if (headerValue) {
31
+ void self.registration.navigationPreload.setHeaderValue(headerValue);
32
+ }
33
+
34
+ if (process.env.NODE_ENV !== "production") {
35
+ logger.log("Navigation preload is enabled.");
36
+ }
37
+ }),
38
+ );
39
+ });
40
+ } else {
41
+ if (process.env.NODE_ENV !== "production") {
42
+ logger.log("Navigation preload is not supported in this browser.");
43
+ }
44
+ }
45
+ };
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ /*
2
+ Copyright 2018 Google LLC
3
+
4
+ Use of this source code is governed by an MIT-style
5
+ license that can be found in the LICENSE file or at
6
+ https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ import { disable } from "./disable.js";
10
+ import { enable } from "./enable.js";
11
+ import { isSupported } from "./isSupported.js";
12
+
13
+ export { disable, enable, isSupported };
@@ -0,0 +1,18 @@
1
+ /*
2
+ Copyright 2018 Google LLC
3
+
4
+ Use of this source code is governed by an MIT-style
5
+ license that can be found in the LICENSE file or at
6
+ https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ // Give TypeScript the correct global.
10
+ declare let self: ServiceWorkerGlobalScope;
11
+
12
+ /**
13
+ * @returns Whether or not the current browser supports enabling
14
+ * navigation preload.
15
+ */
16
+ export const isSupported = (): boolean => {
17
+ return Boolean(self.registration?.navigationPreload);
18
+ };
package/dist/index.cjs DELETED
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- var internal = require('@serwist/core/internal');
4
-
5
- /*
6
- Copyright 2018 Google LLC
7
-
8
- Use of this source code is governed by an MIT-style
9
- license that can be found in the LICENSE file or at
10
- https://opensource.org/licenses/MIT.
11
- */ // Give TypeScript the correct global.
12
- /**
13
- * @returns Whether or not the current browser supports enabling
14
- * navigation preload.
15
- */ function isSupported() {
16
- return Boolean(self.registration?.navigationPreload);
17
- }
18
-
19
- /**
20
- * If the browser supports Navigation Preload, then this will disable it.
21
- */ function disable() {
22
- if (isSupported()) {
23
- self.addEventListener("activate", (event)=>{
24
- event.waitUntil(self.registration.navigationPreload.disable().then(()=>{
25
- if (process.env.NODE_ENV !== "production") {
26
- internal.logger.log("Navigation preload is disabled.");
27
- }
28
- }));
29
- });
30
- } else {
31
- if (process.env.NODE_ENV !== "production") {
32
- internal.logger.log("Navigation preload is not supported in this browser.");
33
- }
34
- }
35
- }
36
-
37
- /**
38
- * If the browser supports Navigation Preload, then this will enable it.
39
- *
40
- * @param headerValue Optionally, allows developers to
41
- * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
42
- * the value of the `Service-Worker-Navigation-Preload` header which will be
43
- * sent to the server when making the navigation request.
44
- */ function enable(headerValue) {
45
- if (isSupported()) {
46
- self.addEventListener("activate", (event)=>{
47
- event.waitUntil(self.registration.navigationPreload.enable().then(()=>{
48
- // Defaults to Service-Worker-Navigation-Preload: true if not set.
49
- if (headerValue) {
50
- void self.registration.navigationPreload.setHeaderValue(headerValue);
51
- }
52
- if (process.env.NODE_ENV !== "production") {
53
- internal.logger.log("Navigation preload is enabled.");
54
- }
55
- }));
56
- });
57
- } else {
58
- if (process.env.NODE_ENV !== "production") {
59
- internal.logger.log("Navigation preload is not supported in this browser.");
60
- }
61
- }
62
- }
63
-
64
- exports.disable = disable;
65
- exports.enable = enable;
66
- exports.isSupported = isSupported;
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- import { disable } from "./disable.js";
2
- import { enable } from "./enable.js";
3
- import { isSupported } from "./isSupported.js";
4
- export { disable, enable, isSupported };