@serwist/window 8.3.0 → 8.4.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.cjs +4 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -6
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -20,8 +20,7 @@ var internal = require('@serwist/core/internal');
|
|
|
20
20
|
* @param sw The service worker to send the message to.
|
|
21
21
|
* @param data An object to send to the service worker.
|
|
22
22
|
* @returns
|
|
23
|
-
*/ // Better not change type of data.
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
23
|
+
*/ // biome-ignore lint/complexity/noBannedTypes: Better not change type of data.
|
|
25
24
|
function messageSW(sw, data) {
|
|
26
25
|
return new Promise((resolve)=>{
|
|
27
26
|
const messageChannel = new MessageChannel();
|
|
@@ -177,7 +176,7 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
177
176
|
* [`TrustedScriptURL`](https://web.dev/trusted-types/) is supported.
|
|
178
177
|
* @param registerOptions The service worker options associated
|
|
179
178
|
* with this instance.
|
|
180
|
-
*/ //
|
|
179
|
+
*/ // biome-ignore lint/complexity/noBannedTypes: Unknown reason
|
|
181
180
|
constructor(scriptURL, registerOptions = {}){
|
|
182
181
|
super();
|
|
183
182
|
this._scriptURL = scriptURL;
|
|
@@ -351,7 +350,7 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
351
350
|
* If there is no current registration or no service worker is `waiting`,
|
|
352
351
|
* calling this will have no effect.
|
|
353
352
|
*/ messageSkipWaiting() {
|
|
354
|
-
if (this._registration
|
|
353
|
+
if (this._registration?.waiting) {
|
|
355
354
|
void messageSW(this._registration.waiting, SKIP_WAITING_MESSAGE);
|
|
356
355
|
}
|
|
357
356
|
}
|
|
@@ -365,9 +364,8 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
365
364
|
const controller = navigator.serviceWorker.controller;
|
|
366
365
|
if (controller && urlsMatch(controller.scriptURL, this._scriptURL.toString())) {
|
|
367
366
|
return controller;
|
|
368
|
-
} else {
|
|
369
|
-
return undefined;
|
|
370
367
|
}
|
|
368
|
+
return undefined;
|
|
371
369
|
}
|
|
372
370
|
/**
|
|
373
371
|
* Registers a service worker for this instances script URL and register
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,8 +18,7 @@ import { Deferred, logger, dontWaitFor } from '@serwist/core/internal';
|
|
|
18
18
|
* @param sw The service worker to send the message to.
|
|
19
19
|
* @param data An object to send to the service worker.
|
|
20
20
|
* @returns
|
|
21
|
-
*/ // Better not change type of data.
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
21
|
+
*/ // biome-ignore lint/complexity/noBannedTypes: Better not change type of data.
|
|
23
22
|
function messageSW(sw, data) {
|
|
24
23
|
return new Promise((resolve)=>{
|
|
25
24
|
const messageChannel = new MessageChannel();
|
|
@@ -175,7 +174,7 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
175
174
|
* [`TrustedScriptURL`](https://web.dev/trusted-types/) is supported.
|
|
176
175
|
* @param registerOptions The service worker options associated
|
|
177
176
|
* with this instance.
|
|
178
|
-
*/ //
|
|
177
|
+
*/ // biome-ignore lint/complexity/noBannedTypes: Unknown reason
|
|
179
178
|
constructor(scriptURL, registerOptions = {}){
|
|
180
179
|
super();
|
|
181
180
|
this._scriptURL = scriptURL;
|
|
@@ -349,7 +348,7 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
349
348
|
* If there is no current registration or no service worker is `waiting`,
|
|
350
349
|
* calling this will have no effect.
|
|
351
350
|
*/ messageSkipWaiting() {
|
|
352
|
-
if (this._registration
|
|
351
|
+
if (this._registration?.waiting) {
|
|
353
352
|
void messageSW(this._registration.waiting, SKIP_WAITING_MESSAGE);
|
|
354
353
|
}
|
|
355
354
|
}
|
|
@@ -363,9 +362,8 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
363
362
|
const controller = navigator.serviceWorker.controller;
|
|
364
363
|
if (controller && urlsMatch(controller.scriptURL, this._scriptURL.toString())) {
|
|
365
364
|
return controller;
|
|
366
|
-
} else {
|
|
367
|
-
return undefined;
|
|
368
365
|
}
|
|
366
|
+
return undefined;
|
|
369
367
|
}
|
|
370
368
|
/**
|
|
371
369
|
* Registers a service worker for this instances script URL and register
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/window",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simplifies communications with Serwist packages running in the service worker",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"repository": "serwist/serwist",
|
|
22
22
|
"bugs": "https://github.com/serwist/serwist/issues",
|
|
23
|
-
"homepage": "https://serwist.
|
|
23
|
+
"homepage": "https://serwist.pages.dev",
|
|
24
24
|
"module": "./dist/index.js",
|
|
25
25
|
"main": "./dist/index.cjs",
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@types/trusted-types": "2.0.7",
|
|
42
|
-
"@serwist/core": "8.
|
|
42
|
+
"@serwist/core": "8.4.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"rollup": "4.9.1",
|
|
46
|
-
"@serwist/constants": "8.
|
|
46
|
+
"@serwist/constants": "8.4.1"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
|
|
50
|
-
"
|
|
50
|
+
"dev": "rollup --config rollup.config.js --watch",
|
|
51
|
+
"lint": "biome lint ./src",
|
|
51
52
|
"typecheck": "tsc"
|
|
52
53
|
}
|
|
53
54
|
}
|