@serwist/navigation-preload 9.0.0-preview.18 → 9.0.0-preview.19

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/sw";
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,aAAa,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 preloading is disabled.");
13
- }
14
- }));
15
- });
16
- } else {
17
- if (process.env.NODE_ENV !== "production") {
18
- logger.log("Navigation preloading 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 preloading is enabled.");
32
- }
33
- }));
34
- });
35
- } else {
36
- if (process.env.NODE_ENV !== "production") {
37
- logger.log("Navigation preloading 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/sw';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/navigation-preload",
3
- "version": "9.0.0-preview.18",
3
+ "version": "9.0.0-preview.19",
4
4
  "type": "module",
5
5
  "description": "A module that allows developers to enable navigation preloading in their service worker.",
6
6
  "files": [
@@ -16,8 +16,8 @@
16
16
  ],
17
17
  "author": "Google's Web DevRel Team, Serwist's Team",
18
18
  "license": "MIT",
19
- "repository": "serwist/serwist",
20
- "bugs": "https://github.com/serwist/serwist/issues",
19
+ "repository": "https://gitlab.com/serwist/serwist",
20
+ "bugs": "https://gitlab.com/serwist/serwist/issues",
21
21
  "homepage": "https://serwist.pages.dev",
22
22
  "main": "./dist/index.js",
23
23
  "types": "./dist/index.d.ts",
@@ -29,12 +29,12 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "dependencies": {
32
- "@serwist/core": "9.0.0-preview.18"
32
+ "@serwist/sw": "9.0.0-preview.19"
33
33
  },
34
34
  "devDependencies": {
35
35
  "rollup": "4.13.0",
36
36
  "typescript": "5.5.0-dev.20240323",
37
- "@serwist/constants": "9.0.0-preview.18"
37
+ "@serwist/constants": "9.0.0-preview.19"
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/sw";
package/dist/disable.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * If the browser supports navigation preloading, 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,9 +0,0 @@
1
- /**
2
- * If the browser supports navigation preloading, then this will enable it.
3
- *
4
- * @param headerValue Optional. Allows developers to override the value of
5
- * the `Service-Worker-Navigation-Preload` header which will be sent to the
6
- * server when making the navigation request.
7
- */
8
- export declare const enable: (headerValue?: string) => void;
9
- //# sourceMappingURL=enable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enable.d.ts","sourceRoot":"","sources":["../src/enable.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,iBAAkB,MAAM,KAAG,IAqB7C,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Checks whether the current browser supports
3
- * navigation preloading.
4
- *
5
- * @returns
6
- */
7
- export declare const isSupported: () => boolean;
8
- //# sourceMappingURL=isSupported.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSupported.d.ts","sourceRoot":"","sources":["../src/isSupported.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;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 preloading, 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 preloading is disabled.");
26
- }
27
- }),
28
- );
29
- });
30
- } else {
31
- if (process.env.NODE_ENV !== "production") {
32
- logger.log("Navigation preloading is not supported in this browser.");
33
- }
34
- }
35
- };
package/src/enable.ts DELETED
@@ -1,44 +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 preloading, then this will enable it.
18
- *
19
- * @param headerValue Optional. Allows developers to override the value of
20
- * the `Service-Worker-Navigation-Preload` header which will be sent to the
21
- * server when making the navigation request.
22
- */
23
- export const enable = (headerValue?: string): void => {
24
- if (isSupported()) {
25
- self.addEventListener("activate", (event) => {
26
- event.waitUntil(
27
- self.registration.navigationPreload.enable().then(() => {
28
- // Defaults to Service-Worker-Navigation-Preload: true if not set.
29
- if (headerValue) {
30
- void self.registration.navigationPreload.setHeaderValue(headerValue);
31
- }
32
-
33
- if (process.env.NODE_ENV !== "production") {
34
- logger.log("Navigation preloading is enabled.");
35
- }
36
- }),
37
- );
38
- });
39
- } else {
40
- if (process.env.NODE_ENV !== "production") {
41
- logger.log("Navigation preloading is not supported in this browser.");
42
- }
43
- }
44
- };
@@ -1,20 +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
- * Checks whether the current browser supports
14
- * navigation preloading.
15
- *
16
- * @returns
17
- */
18
- export const isSupported = (): boolean => {
19
- return Boolean(self.registration?.navigationPreload);
20
- };