@serwist/navigation-preload 9.0.0-preview.0 → 9.0.0-preview.2
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.js +3 -23
- package/package.json +4 -4
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
|
-
*/ const 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
|
-
*/ const disable = ()=>{
|
|
7
|
+
const disable = ()=>{
|
|
20
8
|
if (isSupported()) {
|
|
21
9
|
self.addEventListener("activate", (event)=>{
|
|
22
10
|
event.waitUntil(self.registration.navigationPreload.disable().then(()=>{
|
|
@@ -32,18 +20,10 @@ import { logger } from '@serwist/core/internal';
|
|
|
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
|
-
*/ const 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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/navigation-preload",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.2",
|
|
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": [
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@serwist/core": "9.0.0-preview.
|
|
32
|
+
"@serwist/core": "9.0.0-preview.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"rollup": "4.9.6",
|
|
36
|
-
"typescript": "5.4.0-dev.
|
|
37
|
-
"@serwist/constants": "9.0.0-preview.
|
|
36
|
+
"typescript": "5.4.0-dev.20240206",
|
|
37
|
+
"@serwist/constants": "9.0.0-preview.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"typescript": ">=5.0.0"
|