@serwist/window 8.2.0 → 8.3.0
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/Serwist.d.ts +15 -0
- package/dist/index.cjs +23 -4
- package/dist/index.js +23 -4
- package/package.json +3 -3
package/dist/Serwist.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export declare class Serwist extends SerwistEventTarget {
|
|
|
134
134
|
private _registerScript;
|
|
135
135
|
/**
|
|
136
136
|
* @private
|
|
137
|
+
* @param originalEvent
|
|
137
138
|
*/
|
|
138
139
|
private readonly _onUpdateFound;
|
|
139
140
|
/**
|
|
@@ -268,3 +269,17 @@ export declare class Serwist extends SerwistEventTarget {
|
|
|
268
269
|
* @property {string} type `redundant`.
|
|
269
270
|
* @property {Workbox} target The `Workbox` instance.
|
|
270
271
|
*/
|
|
272
|
+
/**
|
|
273
|
+
* The `installing` event is dispatched if the service worker
|
|
274
|
+
* finds the new version and starts installing.
|
|
275
|
+
*
|
|
276
|
+
* @event workbox-window.Workbox#installing
|
|
277
|
+
* @type {SerwistEvent}
|
|
278
|
+
* @property {ServiceWorker} sw The installing service worker instance.
|
|
279
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
280
|
+
* event.
|
|
281
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
282
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
283
|
+
* @property {string} type `installing`.
|
|
284
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
285
|
+
*/
|
package/dist/index.cjs
CHANGED
|
@@ -395,7 +395,8 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
395
395
|
}
|
|
396
396
|
/**
|
|
397
397
|
* @private
|
|
398
|
-
|
|
398
|
+
* @param originalEvent
|
|
399
|
+
*/ _onUpdateFound = (originalEvent)=>{
|
|
399
400
|
// `this._registration` will never be `undefined` after an update is found.
|
|
400
401
|
const registration = this._registration;
|
|
401
402
|
const installingSW = registration.installing;
|
|
@@ -432,16 +433,21 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
432
433
|
this._sw = installingSW;
|
|
433
434
|
this._ownSWs.add(installingSW);
|
|
434
435
|
this._swDeferred.resolve(installingSW);
|
|
435
|
-
// The `installing` state isn't something we have a dedicated
|
|
436
|
-
// callback for, but we do log messages for it in development.
|
|
437
436
|
if (process.env.NODE_ENV !== "production") {
|
|
438
|
-
if (
|
|
437
|
+
if (this._isUpdate) {
|
|
439
438
|
internal.logger.log("Updated service worker found. Installing now...");
|
|
440
439
|
} else {
|
|
441
440
|
internal.logger.log("Service worker is installing...");
|
|
442
441
|
}
|
|
443
442
|
}
|
|
444
443
|
}
|
|
444
|
+
// Dispatch the `installing` event when the SW is installing.
|
|
445
|
+
this.dispatchEvent(new SerwistEvent("installing", {
|
|
446
|
+
sw: installingSW,
|
|
447
|
+
originalEvent,
|
|
448
|
+
isExternal: updateLikelyTriggeredExternally,
|
|
449
|
+
isUpdate: this._isUpdate
|
|
450
|
+
}));
|
|
445
451
|
// Increment the `updatefound` count, so future invocations of this
|
|
446
452
|
// method can be sure they were triggered externally.
|
|
447
453
|
++this._updateFoundCount;
|
|
@@ -686,6 +692,19 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
686
692
|
* controlling when this `Workbox` instance called `register()`.
|
|
687
693
|
* @property {string} type `redundant`.
|
|
688
694
|
* @property {Workbox} target The `Workbox` instance.
|
|
695
|
+
*/ /**
|
|
696
|
+
* The `installing` event is dispatched if the service worker
|
|
697
|
+
* finds the new version and starts installing.
|
|
698
|
+
*
|
|
699
|
+
* @event workbox-window.Workbox#installing
|
|
700
|
+
* @type {SerwistEvent}
|
|
701
|
+
* @property {ServiceWorker} sw The installing service worker instance.
|
|
702
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
703
|
+
* event.
|
|
704
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
705
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
706
|
+
* @property {string} type `installing`.
|
|
707
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
689
708
|
*/
|
|
690
709
|
|
|
691
710
|
exports.Serwist = Serwist;
|
package/dist/index.js
CHANGED
|
@@ -393,7 +393,8 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
393
393
|
}
|
|
394
394
|
/**
|
|
395
395
|
* @private
|
|
396
|
-
|
|
396
|
+
* @param originalEvent
|
|
397
|
+
*/ _onUpdateFound = (originalEvent)=>{
|
|
397
398
|
// `this._registration` will never be `undefined` after an update is found.
|
|
398
399
|
const registration = this._registration;
|
|
399
400
|
const installingSW = registration.installing;
|
|
@@ -430,16 +431,21 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
430
431
|
this._sw = installingSW;
|
|
431
432
|
this._ownSWs.add(installingSW);
|
|
432
433
|
this._swDeferred.resolve(installingSW);
|
|
433
|
-
// The `installing` state isn't something we have a dedicated
|
|
434
|
-
// callback for, but we do log messages for it in development.
|
|
435
434
|
if (process.env.NODE_ENV !== "production") {
|
|
436
|
-
if (
|
|
435
|
+
if (this._isUpdate) {
|
|
437
436
|
logger.log("Updated service worker found. Installing now...");
|
|
438
437
|
} else {
|
|
439
438
|
logger.log("Service worker is installing...");
|
|
440
439
|
}
|
|
441
440
|
}
|
|
442
441
|
}
|
|
442
|
+
// Dispatch the `installing` event when the SW is installing.
|
|
443
|
+
this.dispatchEvent(new SerwistEvent("installing", {
|
|
444
|
+
sw: installingSW,
|
|
445
|
+
originalEvent,
|
|
446
|
+
isExternal: updateLikelyTriggeredExternally,
|
|
447
|
+
isUpdate: this._isUpdate
|
|
448
|
+
}));
|
|
443
449
|
// Increment the `updatefound` count, so future invocations of this
|
|
444
450
|
// method can be sure they were triggered externally.
|
|
445
451
|
++this._updateFoundCount;
|
|
@@ -684,6 +690,19 @@ const SKIP_WAITING_MESSAGE = {
|
|
|
684
690
|
* controlling when this `Workbox` instance called `register()`.
|
|
685
691
|
* @property {string} type `redundant`.
|
|
686
692
|
* @property {Workbox} target The `Workbox` instance.
|
|
693
|
+
*/ /**
|
|
694
|
+
* The `installing` event is dispatched if the service worker
|
|
695
|
+
* finds the new version and starts installing.
|
|
696
|
+
*
|
|
697
|
+
* @event workbox-window.Workbox#installing
|
|
698
|
+
* @type {SerwistEvent}
|
|
699
|
+
* @property {ServiceWorker} sw The installing service worker instance.
|
|
700
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
701
|
+
* event.
|
|
702
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
703
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
704
|
+
* @property {string} type `installing`.
|
|
705
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
687
706
|
*/
|
|
688
707
|
|
|
689
708
|
export { Serwist, SerwistEvent, messageSW };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/window",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simplifies communications with Serwist packages running in the service worker",
|
|
6
6
|
"files": [
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@types/trusted-types": "2.0.7",
|
|
42
|
-
"@serwist/core": "8.
|
|
42
|
+
"@serwist/core": "8.3.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"rollup": "4.9.1",
|
|
46
|
-
"@serwist/constants": "8.
|
|
46
|
+
"@serwist/constants": "8.3.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
|