@serwist/navigation-preload
Advanced tools
Comparing version 9.0.0-preview.0 to 9.0.0-preview.1
import { logger } from '@serwist/core/internal'; | ||
/* | ||
Copyright 2018 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ // Give TypeScript the correct global. | ||
/** | ||
* @returns Whether or not the current browser supports enabling | ||
* navigation preload. | ||
*/ const isSupported = ()=>{ | ||
const isSupported = ()=>{ | ||
return Boolean(self.registration?.navigationPreload); | ||
}; | ||
/** | ||
* If the browser supports Navigation Preload, then this will disable it. | ||
*/ const disable = ()=>{ | ||
const disable = ()=>{ | ||
if (isSupported()) { | ||
@@ -35,14 +23,6 @@ self.addEventListener("activate", (event)=>{ | ||
/** | ||
* If the browser supports Navigation Preload, then this will enable it. | ||
* | ||
* @param headerValue Optionally, allows developers to | ||
* [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header) | ||
* the value of the `Service-Worker-Navigation-Preload` header which will be | ||
* sent to the server when making the navigation request. | ||
*/ const enable = (headerValue)=>{ | ||
const enable = (headerValue)=>{ | ||
if (isSupported()) { | ||
self.addEventListener("activate", (event)=>{ | ||
event.waitUntil(self.registration.navigationPreload.enable().then(()=>{ | ||
// Defaults to Service-Worker-Navigation-Preload: true if not set. | ||
if (headerValue) { | ||
@@ -49,0 +29,0 @@ void self.registration.navigationPreload.setHeaderValue(headerValue); |
{ | ||
"name": "@serwist/navigation-preload", | ||
"version": "9.0.0-preview.0", | ||
"version": "9.0.0-preview.1", | ||
"type": "module", | ||
@@ -32,3 +32,3 @@ "description": "This library allows developers to opt-in to using Navigation Preload in their service worker.", | ||
"dependencies": { | ||
"@serwist/core": "9.0.0-preview.0" | ||
"@serwist/core": "9.0.0-preview.1" | ||
}, | ||
@@ -38,3 +38,3 @@ "devDependencies": { | ||
"typescript": "5.4.0-dev.20240203", | ||
"@serwist/constants": "9.0.0-preview.0" | ||
"@serwist/constants": "9.0.0-preview.1" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
3
0
9023
154
+ Added@serwist/core@9.0.0-preview.1(transitive)
- Removed@serwist/core@9.0.0-preview.0(transitive)