@serwist/navigation-preload 9.0.0-preview.9 → 9.0.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/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- import { disable } from "./disable.js";
2
- import { enable } from "./enable.js";
3
- import { isSupported } from "./isSupported.js";
4
- export { disable, enable, isSupported };
1
+ export { disableNavigationPreload as disable, enableNavigationPreload as enable, isNavigationPreloadSupported as isSupported } from "serwist";
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,IAAI,OAAO,EAAE,uBAAuB,IAAI,MAAM,EAAE,4BAA4B,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,42 +1 @@
1
- import { logger } from '@serwist/core/internal';
2
-
3
- const isSupported = ()=>{
4
- return Boolean(self.registration?.navigationPreload);
5
- };
6
-
7
- const disable = ()=>{
8
- if (isSupported()) {
9
- self.addEventListener("activate", (event)=>{
10
- event.waitUntil(self.registration.navigationPreload.disable().then(()=>{
11
- if (process.env.NODE_ENV !== "production") {
12
- logger.log("Navigation preload is disabled.");
13
- }
14
- }));
15
- });
16
- } else {
17
- if (process.env.NODE_ENV !== "production") {
18
- logger.log("Navigation preload is not supported in this browser.");
19
- }
20
- }
21
- };
22
-
23
- const enable = (headerValue)=>{
24
- if (isSupported()) {
25
- self.addEventListener("activate", (event)=>{
26
- event.waitUntil(self.registration.navigationPreload.enable().then(()=>{
27
- if (headerValue) {
28
- void self.registration.navigationPreload.setHeaderValue(headerValue);
29
- }
30
- if (process.env.NODE_ENV !== "production") {
31
- logger.log("Navigation preload is enabled.");
32
- }
33
- }));
34
- });
35
- } else {
36
- if (process.env.NODE_ENV !== "production") {
37
- logger.log("Navigation preload is not supported in this browser.");
38
- }
39
- }
40
- };
41
-
42
- export { disable, enable, isSupported };
1
+ export { disableNavigationPreload as disable, enableNavigationPreload as enable, isNavigationPreloadSupported as isSupported } from 'serwist';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@serwist/navigation-preload",
3
- "version": "9.0.0-preview.9",
3
+ "version": "9.0.1",
4
4
  "type": "module",
5
- "description": "This library allows developers to opt-in to using Navigation Preload in their service worker.",
5
+ "description": "A module that allows developers to enable navigation preloading in their service worker.",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "author": "Google's Web DevRel Team, Serwist's Team",
18
18
  "license": "MIT",
19
- "repository": "serwist/serwist",
19
+ "repository": "https://github.com/serwist/serwist",
20
20
  "bugs": "https://github.com/serwist/serwist/issues",
21
21
  "homepage": "https://serwist.pages.dev",
22
22
  "main": "./dist/index.js",
@@ -29,12 +29,12 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "dependencies": {
32
- "@serwist/core": "9.0.0-preview.9"
32
+ "serwist": "9.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "rollup": "4.9.6",
36
- "typescript": "5.4.0-dev.20240206",
37
- "@serwist/constants": "9.0.0-preview.9"
35
+ "rollup": "4.14.3",
36
+ "typescript": "5.5.0-dev.20240415",
37
+ "@serwist/configs": "9.0.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "typescript": ">=5.0.0"
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "scripts": {
48
48
  "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
49
- "dev": "rollup --config rollup.config.js --watch",
50
49
  "lint": "biome lint ./src",
51
50
  "typecheck": "tsc"
52
51
  }
package/src/index.ts CHANGED
@@ -1,13 +1 @@
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 };
1
+ export { disableNavigationPreload as disable, enableNavigationPreload as enable, isNavigationPreloadSupported as isSupported } from "serwist";
package/dist/disable.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * If the browser supports Navigation Preload, then this will disable it.
3
- */
4
- export declare const disable: () => void;
5
- //# sourceMappingURL=disable.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * If the browser supports Navigation Preload, then this will enable it.
3
- *
4
- * @param headerValue Optionally, allows developers to
5
- * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
6
- * the value of the `Service-Worker-Navigation-Preload` header which will be
7
- * sent to the server when making the navigation request.
8
- */
9
- export declare const enable: (headerValue?: string) => void;
10
- //# sourceMappingURL=enable.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- /**
2
- * @returns Whether or not the current browser supports enabling
3
- * navigation preload.
4
- */
5
- export declare const isSupported: () => boolean;
6
- //# sourceMappingURL=isSupported.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSupported.d.ts","sourceRoot":"","sources":["../src/isSupported.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAO,OAE9B,CAAC"}
package/src/disable.ts DELETED
@@ -1,35 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- };